Skip to content

Commit

Permalink
Merge pull request #1547 from prismicio/dani/table-code
Browse files Browse the repository at this point in the history
Generate table code
  • Loading branch information
dani-mp authored Jan 31, 2025
2 parents a2d67b0 + ad6867d commit aecdee9
Show file tree
Hide file tree
Showing 15 changed files with 178 additions and 76 deletions.
4 changes: 2 additions & 2 deletions packages/adapter-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"pascal-case": "^3.1.2"
},
"devDependencies": {
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mock": "0.7.0-alpha.6",
"@size-limit/preset-small-lib": "8.2.4",
"@types/common-tags": "1.8.1",
"@types/react": "18.0.28",
Expand All @@ -95,7 +95,7 @@
"next": "14.1.3",
"prettier": "3.0.3",
"prettier-plugin-jsdoc": "1.1.1",
"prismic-ts-codegen": "0.1.23",
"prismic-ts-codegen": "0.1.25-alpha.0",
"react": "18.2.0",
"rollup-plugin-preserve-directives": "0.2.0",
"size-limit": "8.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`PageSnippet > App Router > return a snippet with JavaScript 1`] = `
{
"content": "## Create your Foo Bar's page component
"content": "## Create your Foobar's page component
Add a new route by creating an \`app/[uid]/page.js\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`app/marketing/[uid]/page.js\`.)
Expand Down Expand Up @@ -63,7 +63,7 @@ Make sure all of your import paths are correct. See the [install guide](https://
exports[`PageSnippet > App Router > return a snippet with TypeScript for TypeScript projects 1`] = `
{
"content": "## Create your Foo Bar's page component
"content": "## Create your Foobar's page component
Add a new route by creating an \`app/[uid]/page.tsx\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`app/marketing/[uid]/page.tsx\`.)
Expand Down Expand Up @@ -131,7 +131,7 @@ Make sure all of your import paths are correct. See the [install guide](https://
exports[`PageSnippet > Pages Router > return a snippet with JavaScript 1`] = `
{
"content": "## Create your Foo Bar's page component
"content": "## Create your Foobar's page component
Add a new route by creating a \`pages/[uid].js\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`pages/marketing/[uid].js\`.)
Expand Down Expand Up @@ -203,7 +203,7 @@ Make sure all of your import paths are correct. See the [install guide](https://
exports[`PageSnippet > Pages Router > return a snippet with TypeScript for TypeScript projects 1`] = `
{
"content": "## Create your Foo Bar's page component
"content": "## Create your Foobar's page component
Add a new route by creating a \`pages/[uid].tsx\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`pages/marketing/[uid].tsx\`.)
Expand Down
9 changes: 6 additions & 3 deletions packages/adapter-next/test/plugin-snippet-read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const model = mock.model.customType({
geoPoint: mock.model.geoPoint(),
group: mock.model.group(),
image: mock.model.image(),
integrationFields: mock.model.integrationFields(),
integrationFields: mock.model.integration(),
keyText: mock.model.keyText(),
link: mock.model.link(),
linkToMedia: mock.model.linkToMedia(),
link: mock.model.link({ repeat: false, allowText: false }),
linkToMedia: mock.model.linkToMedia({ allowText: false }),
number: mock.model.number(),
richText: mock.model.richText(),
select: mock.model.select(),
sliceZone: mock.model.sliceZone(),
table: mock.model.table(),
timestamp: mock.model.timestamp(),
title: mock.model.title(),
uid: mock.model.uid(),
Expand Down Expand Up @@ -160,6 +161,8 @@ testSnippet(
`<SliceZone slices={${model.id}.data.sliceZone} components={components} />`,
);

testSnippet("table", `<PrismicTable field={${model.id}.data.table} />`);

testSnippet("timestamp", `{${model.id}.data.timestamp}`, { format: false });

testSnippet("title", [
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"pascal-case": "^3.1.2"
},
"devDependencies": {
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mock": "0.7.0-alpha.6",
"@size-limit/preset-small-lib": "8.2.4",
"@types/common-tags": "1.8.1",
"@typescript-eslint/eslint-plugin": "5.55.0",
Expand All @@ -86,7 +86,7 @@
"nuxt": "3.3.3",
"prettier": "3.0.3",
"prettier-plugin-jsdoc": "1.1.1",
"prismic-ts-codegen": "0.1.23",
"prismic-ts-codegen": "0.1.25-alpha.0",
"size-limit": "8.2.4",
"ts-morph": "17.0.1",
"typescript": "4.9.5",
Expand Down
9 changes: 6 additions & 3 deletions packages/adapter-nuxt/test/plugin-snippet-read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const model = mock.model.customType({
geoPoint: mock.model.geoPoint(),
group: mock.model.group(),
image: mock.model.image(),
integrationFields: mock.model.integrationFields(),
integrationFields: mock.model.integration(),
keyText: mock.model.keyText(),
link: mock.model.link(),
linkToMedia: mock.model.linkToMedia(),
link: mock.model.link({ repeat: false, allowText: false }),
linkToMedia: mock.model.linkToMedia({ allowText: false }),
number: mock.model.number(),
richText: mock.model.richText(),
select: mock.model.select(),
sliceZone: mock.model.sliceZone(),
table: mock.model.table(),
timestamp: mock.model.timestamp(),
title: mock.model.title(),
uid: mock.model.uid(),
Expand Down Expand Up @@ -138,6 +139,8 @@ testSnippet(
`<SliceZone :slices="${model.id}.data.sliceZone" :components="components" />`,
);

testSnippet("table", `<PrismicTable :field="${model.id}.data.table" />`);

testSnippet("timestamp", `{{${model.id}.data.timestamp}}`);

testSnippet("title", [
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-nuxt2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"pascal-case": "^3.1.2"
},
"devDependencies": {
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mock": "0.7.0-alpha.6",
"@size-limit/preset-small-lib": "8.2.4",
"@typescript-eslint/eslint-plugin": "5.55.0",
"@typescript-eslint/parser": "5.55.0",
Expand All @@ -85,7 +85,7 @@
"nuxt": "2.16.3",
"prettier": "3.0.3",
"prettier-plugin-jsdoc": "1.1.1",
"prismic-ts-codegen": "0.1.23",
"prismic-ts-codegen": "0.1.25-alpha.0",
"size-limit": "8.2.4",
"ts-morph": "17.0.1",
"typescript": "4.9.5",
Expand Down
9 changes: 6 additions & 3 deletions packages/adapter-nuxt2/test/plugin-snippet-read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const model = mock.model.customType({
geoPoint: mock.model.geoPoint(),
group: mock.model.group(),
image: mock.model.image(),
integrationFields: mock.model.integrationFields(),
integrationFields: mock.model.integration(),
keyText: mock.model.keyText(),
link: mock.model.link(),
linkToMedia: mock.model.linkToMedia(),
link: mock.model.link({ repeat: false, allowText: false }),
linkToMedia: mock.model.linkToMedia({ allowText: false }),
number: mock.model.number(),
richText: mock.model.richText(),
select: mock.model.select(),
sliceZone: mock.model.sliceZone(),
table: mock.model.table(),
timestamp: mock.model.timestamp(),
title: mock.model.title(),
uid: mock.model.uid(),
Expand Down Expand Up @@ -138,6 +139,8 @@ testSnippet(
`<SliceZone :slices="${model.id}.data.sliceZone" :components="components" />`,
);

testSnippet("table", `<PrismicTable :field="${model.id}.data.table" />`);

testSnippet("timestamp", `{{${model.id}.data.timestamp}}`);

testSnippet("title", [
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"prettier-plugin-svelte": "^3.0.3"
},
"devDependencies": {
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mock": "0.7.0-alpha.6",
"@size-limit/preset-small-lib": "8.2.4",
"@sveltejs/kit": "2.0.0",
"@sveltejs/package": "2.2.1",
Expand All @@ -93,7 +93,7 @@
"eslint-plugin-tsdoc": "0.2.17",
"prettier": "3.0.3",
"prettier-plugin-jsdoc": "1.1.1",
"prismic-ts-codegen": "0.1.23",
"prismic-ts-codegen": "0.1.25-alpha.0",
"size-limit": "8.2.4",
"svelte": "4.2.0",
"typescript": "4.9.5",
Expand Down
9 changes: 6 additions & 3 deletions packages/adapter-sveltekit/test/plugin-snippet-read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const model = mock.model.customType({
geoPoint: mock.model.geoPoint(),
group: mock.model.group(),
image: mock.model.image(),
integrationFields: mock.model.integrationFields(),
integrationFields: mock.model.integration(),
keyText: mock.model.keyText(),
link: mock.model.link(),
linkToMedia: mock.model.linkToMedia(),
link: mock.model.link({ repeat: false, allowText: false }),
linkToMedia: mock.model.linkToMedia({ allowText: false }),
number: mock.model.number(),
richText: mock.model.richText(),
select: mock.model.select(),
sliceZone: mock.model.sliceZone(),
table: mock.model.table(),
timestamp: mock.model.timestamp(),
title: mock.model.title(),
uid: mock.model.uid(),
Expand Down Expand Up @@ -146,6 +147,8 @@ testSnippet(
`<SliceZone slices={${model.id}.data.sliceZone} {components} />`,
);

testSnippet("table", `<PrismicTable field={${model.id}.data.table} />`);

testSnippet("timestamp", `{${model.id}.data.timestamp}`);

testSnippet("title", [
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
},
"devDependencies": {
"@amplitude/experiment-node-server": "1.8.1",
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mock": "0.7.0-alpha.6",
"@size-limit/preset-small-lib": "8.2.4",
"@types/express": "4.17.17",
"@types/semver": "7.3.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ it("sends the provided user agent", async (ctx) => {

await manager.user.login(createPrismicAuthLoginResponse());
await manager.customTypes.pushCustomType({ id: model.id, userAgent: "foo" });
// TODO: update prismicio/mock library
expect(sentModel).toStrictEqual({ ...model, format: "custom" });

expect(sentModel).toStrictEqual(model);
});

it("throws if plugins have not been initialized", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ it("ignores plugins that implement `custom-type-library:read`", async (ctx) => {
const res = await manager.customTypes.readCustomType({ id: model.id });

expect(res).toStrictEqual({
model: { ...model, format: "custom" },
model,
errors: [],
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
"io-ts-reporters": "^2.0.1",
"p-limit": "^4.0.0",
"prettier": "^3.0.3",
"prismic-ts-codegen": "^0.1.23"
"prismic-ts-codegen": "0.1.25-alpha.0"
},
"devDependencies": {
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mock": "0.7.0-alpha.6",
"@prismicio/types-internal": "3.4.0-alpha.11",
"@size-limit/preset-small-lib": "8.2.4",
"@types/common-tags": "1.8.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/slice-machine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@prismicio/editor-fields": "0.4.61",
"@prismicio/editor-support": "0.4.61",
"@prismicio/editor-ui": "0.4.61",
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mock": "0.7.0-alpha.6",
"@prismicio/mocks": "2.8.0",
"@prismicio/simulator": "0.1.4",
"@prismicio/types-internal": "3.4.0-alpha.11",
Expand Down
Loading

0 comments on commit aecdee9

Please sign in to comment.