Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ontent-cloud-sdk into PCC-1729-update-the-article-page-to-match-the-new-designs-including-author-and-tags
  • Loading branch information
kevinstubbs committed Jan 3, 2025
2 parents dff8ed9 + bbea2e1 commit 1f95525
Show file tree
Hide file tree
Showing 31 changed files with 431 additions and 18 deletions.
10 changes: 10 additions & 0 deletions .changeset/good-weeks-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@pantheon-systems/next-approuter-pcc-starter-ts": patch
"@pantheon-systems/pcc-react-sample-library": patch
"@pantheon-systems/pcc-react-sdk": patch
"@pantheon-systems/pcc-browser-sdk": patch
"@pantheon-systems/pcc-sdk-core": patch
"@pantheon-systems/pcc-cli": patch
---

Use 'label' for metadata group record identifiers instead of 'name'
29 changes: 29 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"mode": "pre",
"tag": "beta",
"initialVersions": {
"eslint-config-pcc-custom": "1.0.0",
"testpages": "0.1.0",
"@pantheon-systems/pcc-browser-sdk": "3.9.0",
"@pantheon-systems/pcc-cli": "3.9.0",
"@pantheon-systems/pcc-sdk-core": "3.9.0",
"@pantheon-systems/pcc-react-sample-library": "3.9.0",
"@pantheon-systems/pcc-react-sdk": "3.9.0",
"@pantheon-systems/pcc-vue-sdk": "3.9.0",
"gatsby-pcc-starter": "1.0.0",
"gatsby-pcc-starter-ts": "1.0.0",
"@pantheon-systems/next-pcc-starter": "1.0.0",
"@pantheon-systems/next-approuter-pcc-starter-ts": "1.1.8",
"@pantheon-systems/next-pcc-starter-ts": "1.0.0",
"@pantheon-systems/vue-pcc-starter": "1.1.3",
"@pantheon-systems/vue-pcc-starter-ts": "1.1.3"
},
"changesets": [
"good-weeks-agree",
"plenty-rice-cheer",
"proud-socks-cry",
"seven-owls-poke",
"sixty-moose-act",
"ten-cats-swim"
]
}
5 changes: 5 additions & 0 deletions .changeset/seven-owls-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pantheon-systems/pcc-sdk-core": patch
---

Allow caller to retrieve all metadata groups, optionally hydrated.
5 changes: 5 additions & 0 deletions .changeset/sixty-moose-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pantheon-systems/pcc-sdk-core": minor
---

Add support for metadata groups (like authors).
22 changes: 22 additions & 0 deletions packages/browser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# @pantheon-systems/pcc-browser-sdk

## 3.10.0-beta.2

### Patch Changes

- 67bc79b: Use 'label' for metadata group record identifiers instead of 'name'
- Updated dependencies [67bc79b]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.2

## 3.10.0-beta.1

### Patch Changes

- Updated dependencies [400fc48]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.1

## 3.10.0-beta.0

### Patch Changes

- Updated dependencies [572fb97]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.0

## 3.9.0

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@pantheon-systems/pcc-browser-sdk",
"author": "@pantheon-systems",
"description": "Pantheon Content Cloud Browser SDK",
"version": "3.9.0",
"version": "3.10.0-beta.2",
"main": "dist/index.js",
"files": [
"dist",
Expand Down
29 changes: 29 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# @pantheon-systems/pcc-cli

## 3.10.0-beta.2

### Minor Changes

- 0b3ee7b: No longer download turbo.json when initializing a new project from
the starter kit.

### Patch Changes

- 67bc79b: Use 'label' for metadata group record identifiers instead of 'name'
- 39b7604: Added a warning message when CLI build is pointing to non-production
environment.
- Updated dependencies [67bc79b]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.2

## 3.10.0-beta.1

### Patch Changes

- Updated dependencies [400fc48]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.1

## 3.10.0-beta.0

### Patch Changes

- Updated dependencies [572fb97]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.0

## 3.9.0

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@pantheon-systems/pcc-cli",
"author": "@pantheon-systems",
"description": "Pantheon Content Cloud CLI",
"version": "3.9.0",
"version": "3.10.0-beta.2",
"type": "module",
"license": "MIT",
"keywords": [
Expand Down
18 changes: 18 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @pantheon-systems/pcc-sdk-core

## 3.10.0-beta.2

### Patch Changes

- 67bc79b: Use 'label' for metadata group record identifiers instead of 'name'

## 3.10.0-beta.1

### Patch Changes

- 400fc48: Allow caller to retrieve all metadata groups, optionally hydrated.

## 3.10.0-beta.0

### Minor Changes

- 572fb97: Add support for metadata groups (like authors).

## 3.9.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@pantheon-systems/pcc-sdk-core",
"author": "@pantheon-systems",
"description": "Pantheon Content Cloud SDK Core",
"version": "3.9.0",
"version": "3.10.0-beta.2",
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
54 changes: 53 additions & 1 deletion packages/core/src/core/pantheon-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import queryString from "query-string";
import { getArticleBySlugOrId, PCCConvenienceFunctions } from "../helpers";
import { parseJwt } from "../lib/jwt";
import { Article, SmartComponentMap } from "../types";
import { Article, MetadataGroup, SmartComponentMap } from "../types";
import { PantheonClient, PantheonClientConfig } from "./pantheon-client";

export interface ApiRequest {
Expand Down Expand Up @@ -85,6 +85,11 @@ export interface PantheonAPIOptions {
* Map of smart component names to their schemas.
*/
smartComponentMap?: SmartComponentMap;

/**
* Metadata groups, schemas, and how to retrieve their data.
*/
metadataGroups?: MetadataGroup[];
}

const defaultOptions = {
Expand Down Expand Up @@ -238,6 +243,53 @@ export const PantheonAPI = (givenOptions?: PantheonAPIOptions) => {
return await res.redirect(302, options.notFoundPath);
}

case "metadata_group": {
const groupIdentifier = command[1];
const objectId = command[2];

if (options.metadataGroups == null) {
return res.json({
error: "This collection has no metadata groups defined.",
});
}

if (groupIdentifier == null) {
return res.json({
rows: await Promise.all(
options.metadataGroups.map(
async ({ label, groupIdentifier, schema, list }) => ({
label,
groupIdentifier,
schema,
values:
restOfQuery.hydrate === "true" ? await list() : undefined,
}),
),
),
});
}

const group = await options.metadataGroups.find(
(x) => x.groupIdentifier === groupIdentifier,
);

if (!group) {
return res.json({
error: "Could not find matching group by given identifier.",
});
}

if (!objectId) {
return res.json({
rows: await group.list(),
});
}

return res.json({
row: await group.get(objectId),
});
}

default: {
return await res.redirect(302, options.notFoundPath);
}
Expand Down
26 changes: 26 additions & 0 deletions packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,37 @@ export interface PantheonTreeNode<T extends "component" | string = string> {
id?: string;
type?: string;
}

export interface PantheonTree {
version: string;
children: PantheonTreeNode[];
}

interface MetadataGroupRowEssentials {
label: string;
}

export interface MetadataGroup {
label: string;
groupIdentifier: string;
schema?: Record<
string,
"string" | "textarea" | "number" | "boolean" | "date" | "file"
>;
get: (
id: string,
) =>
| Promise<(unknown & MetadataGroupRowEssentials) | null | undefined>
| (unknown & MetadataGroupRowEssentials)
| null
| undefined;
list: () =>
| Promise<(unknown & MetadataGroupRowEssentials)[] | null | undefined>
| (unknown & MetadataGroupRowEssentials)[]
| null
| undefined;
}

const fieldTypes = z.enum([
"string",
"textarea",
Expand Down
26 changes: 26 additions & 0 deletions packages/react-sample-library/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# @pantheon-systems/pcc-vue-sdk

## 3.10.0-beta.2

### Patch Changes

- 67bc79b: Use 'label' for metadata group record identifiers instead of 'name'
- Updated dependencies [67bc79b]
- Updated dependencies [b89c5ee]
- @pantheon-systems/pcc-react-sdk@3.10.0-beta.2
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.2

## 3.10.0-beta.1

### Patch Changes

- Updated dependencies [400fc48]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.1
- @pantheon-systems/pcc-react-sdk@3.10.0-beta.1

## 3.10.0-beta.0

### Patch Changes

- Updated dependencies [572fb97]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.0
- @pantheon-systems/pcc-react-sdk@3.10.0-beta.0

## 3.9.0

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sample-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@pantheon-systems/pcc-react-sample-library",
"author": "@pantheon-systems",
"description": "Pantheon Content Cloud Sample Component Library for React",
"version": "3.9.0",
"version": "3.10.0-beta.2",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
27 changes: 27 additions & 0 deletions packages/react-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# @pantheon-systems/pcc-react-sdk

## 3.10.0-beta.2

### Minor Changes

- b89c5ee: The injected preview bar is deprecated in favor of the integrated
preview bar in the dashboard preview interface

### Patch Changes

- 67bc79b: Use 'label' for metadata group record identifiers instead of 'name'
- Updated dependencies [67bc79b]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.2

## 3.10.0-beta.1

### Patch Changes

- Updated dependencies [400fc48]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.1

## 3.10.0-beta.0

### Patch Changes

- Updated dependencies [572fb97]
- @pantheon-systems/pcc-sdk-core@3.10.0-beta.0

## 3.9.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@pantheon-systems/pcc-react-sdk",
"author": "@pantheon-systems",
"description": "Pantheon Content Cloud React SDK",
"version": "3.9.0",
"version": "3.10.0-beta.2",
"license": "MIT",
"keywords": [
"pcc",
Expand Down
2 changes: 1 addition & 1 deletion starters/gatsby-starter-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@mdx-js/react": "2.3.0",
"@pantheon-systems/pcc-react-sdk": "~3.9.0",
"@pantheon-systems/pcc-react-sdk": "~3.10.0-beta.2",
"@pantheon-systems/pds-toolkit-react": "1.0.0-dev.55",
"autoprefixer": "^10.4.17",
"gatsby": "5.13.5",
Expand Down
2 changes: 1 addition & 1 deletion starters/gatsby-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@mdx-js/react": "2.3.0",
"@pantheon-systems/pcc-react-sdk": "3.9.0",
"@pantheon-systems/pcc-react-sdk": "3.10.0-beta.2",
"@pantheon-systems/pds-toolkit-react": "1.0.0-dev.55",
"autoprefixer": "^10.4.17",
"gatsby": "5.13.5",
Expand Down
Loading

0 comments on commit 1f95525

Please sign in to comment.