@se-studio/project-build 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @se-studio/project-build
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 79757c2: Add the `add-cms-type` bin: append component, collection or external component type names to the `componentType` / `collectionType` / `externalComponentType` enum in Contentful. Append-only, idempotent, with `--dry-run`. Documented in the `contentful-cms-content-model` skill.
8
+
9
+ ## 1.3.4
10
+
11
+ ### Patch Changes
12
+
13
+ - 5a3f66f: Reject impossible CMS slugs (`%`, `:`, `,`, `.`, `f_auto`, `wp-`) with `notFound` before any Contentful fetch in the shared page and article handlers. Generated page and article routes call the same guard. The site proxy template returns a CDN-cacheable 404 for those paths, including encoded asset URLs that end in a static extension. Ordinary images still skip the proxy.
14
+
3
15
  ## 1.3.3
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -141,6 +141,17 @@ Sets up color field validation in Contentful.
141
141
  setup-colours
142
142
  ```
143
143
 
144
+ #### `add-cms-type`
145
+ Adds a component, collection or external component type to Contentful. These are enum values (`componentType`, `collectionType`, `externalComponentType`), not content types, so this appends to the enum and publishes the content type. Append-only and idempotent.
146
+
147
+ **Usage:**
148
+ ```bash
149
+ add-cms-type component "Logo Wall" "Pricing Table"
150
+ add-cms-type collection "Logo Grid" --dry-run
151
+ add-cms-type externalComponent "Calendly"
152
+ ```
153
+ Needs `CONTENTFUL_SPACE_ID`, `CONTENTFUL_ENVIRONMENT_NAME` and `CONTENTFUL_MANAGEMENT_TOKEN` (read from `.env.local`). Afterwards register the type in `src/lib/registrations.ts` and run `pnpm codegen`.
154
+
144
155
  #### `seskills sync [target-dir]`
145
156
  Deprecated. Depend on `@se-studio/skills` and link it with `skills-npm` (see above). See `packages/skills/` for the canonical skill sources.
146
157
 
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=addCmsType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addCmsType.d.ts","sourceRoot":"","sources":["../../src/management/addCmsType.ts"],"names":[],"mappings":""}
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ /** biome-ignore-all lint/suspicious/noConsole: Console is ok */
3
+ import * as path from 'node:path';
4
+ import { parseArgs } from 'node:util';
5
+ import dotenv from 'dotenv';
6
+ import { addCmsTypes, CMS_TYPE_TARGETS } from './cmsTypes.js';
7
+ import { getManagementClient } from './shared.js';
8
+ dotenv.config({ path: path.join(process.cwd(), '.env.local') });
9
+ const USAGE = `Usage: add-cms-type <component|collection|externalComponent> <name> [name...] [--dry-run]
10
+
11
+ Appends type names to the componentType, collectionType or externalComponentType
12
+ enum in Contentful. Append-only and idempotent: existing names are kept and
13
+ re-running is a no-op. Needs CONTENTFUL_SPACE_ID, CONTENTFUL_ENVIRONMENT_NAME
14
+ and CONTENTFUL_MANAGEMENT_TOKEN.
15
+
16
+ Afterwards: register the type in src/lib/registrations.ts, run pnpm codegen, and
17
+ re-export the golden schema if you changed a core space.`;
18
+ function isKind(value) {
19
+ return value !== undefined && Object.hasOwn(CMS_TYPE_TARGETS, value);
20
+ }
21
+ async function run() {
22
+ const { values, positionals } = parseArgs({
23
+ allowPositionals: true,
24
+ options: { 'dry-run': { type: 'boolean' }, help: { type: 'boolean', short: 'h' } },
25
+ });
26
+ const [kind, ...names] = positionals;
27
+ if (values.help || !isKind(kind) || names.length === 0) {
28
+ console.log(USAGE);
29
+ process.exitCode = values.help ? 0 : 1;
30
+ return;
31
+ }
32
+ console.log(`Target: space ${process.env.CONTENTFUL_SPACE_ID} / environment ${process.env.CONTENTFUL_ENVIRONMENT_NAME}`);
33
+ const result = await addCmsTypes(getManagementClient(), kind, names, {
34
+ dryRun: values['dry-run'],
35
+ });
36
+ const target = `${result.contentTypeId}.${result.fieldId}`;
37
+ if (result.alreadyPresent.length > 0) {
38
+ console.log(`Already in ${target}: ${result.alreadyPresent.join(', ')}`);
39
+ }
40
+ if (result.added.length === 0) {
41
+ console.log('Nothing to add.');
42
+ }
43
+ else if (result.written) {
44
+ console.log(`Added to ${target}: ${result.added.join(', ')}`);
45
+ }
46
+ else {
47
+ console.log(`Dry run. Would add to ${target}: ${result.added.join(', ')}`);
48
+ }
49
+ }
50
+ run().catch((error) => {
51
+ console.error(error instanceof Error ? error.message : error);
52
+ process.exitCode = 1;
53
+ });
54
+ //# sourceMappingURL=addCmsType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addCmsType.js","sourceRoot":"","sources":["../../src/management/addCmsType.ts"],"names":[],"mappings":";AACA,gEAAgE;AAChE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;AAEhE,MAAM,KAAK,GAAG;;;;;;;;yDAQ2C,CAAC;AAE1D,SAAS,MAAM,CAAC,KAAyB;IACvC,OAAO,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;QACxC,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,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AC;IAChE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,yBAAyB,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { PlainClientAPI } from 'contentful-management';
2
+ /** The three kinds of CMS-driven type. Each is an enum on one content type, not a content type of its own. */
3
+ export type CmsTypeKind = 'component' | 'collection' | 'externalComponent';
4
+ export declare const CMS_TYPE_TARGETS: Record<CmsTypeKind, {
5
+ contentTypeId: string;
6
+ fieldId: string;
7
+ }>;
8
+ export interface AddTypesPlan {
9
+ /** The full list to write. Existing values are never removed. */
10
+ next: string[];
11
+ added: string[];
12
+ alreadyPresent: string[];
13
+ }
14
+ /**
15
+ * Append-only and idempotent. A name that matches an existing value ignoring
16
+ * case counts as already present (the enum can never shrink, so a case typo
17
+ * would be permanent). Existing values keep their order: new names are placed
18
+ * alphabetically when the list is already alphabetical, otherwise appended.
19
+ */
20
+ export declare function planAddTypes(current: readonly string[], requested: readonly string[]): AddTypesPlan;
21
+ export interface AddTypesResult extends AddTypesPlan {
22
+ kind: CmsTypeKind;
23
+ contentTypeId: string;
24
+ fieldId: string;
25
+ written: boolean;
26
+ }
27
+ /**
28
+ * Adds type names to the enum for `kind` on the target content type, then publishes it.
29
+ * With `dryRun` nothing is written. Does nothing when every name is already present.
30
+ * Refuses when the content type has unpublished changes, because publishing would ship them too.
31
+ */
32
+ export declare function addCmsTypes(client: PlainClientAPI, kind: CmsTypeKind, names: readonly string[], options?: {
33
+ dryRun?: boolean;
34
+ }): Promise<AddTypesResult>;
35
+ //# sourceMappingURL=cmsTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cmsTypes.d.ts","sourceRoot":"","sources":["../../src/management/cmsTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,8GAA8G;AAC9G,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,mBAAmB,CAAC;AAE3E,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,WAAW,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAI5F,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAcD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,YAAY,CAuBd;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AA0BD;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,OAAO,CAAC,cAAc,CAAC,CAuBzB"}
@@ -0,0 +1,93 @@
1
+ export const CMS_TYPE_TARGETS = {
2
+ component: { contentTypeId: 'component', fieldId: 'componentType' },
3
+ collection: { contentTypeId: 'collection', fieldId: 'collectionType' },
4
+ externalComponent: { contentTypeId: 'externalComponent', fieldId: 'externalComponentType' },
5
+ };
6
+ function compareNames(a, b) {
7
+ return a.localeCompare(b, 'en', { sensitivity: 'base' });
8
+ }
9
+ function isSorted(values) {
10
+ return values.every((value, index) => index === 0 || compareNames(values[index - 1] ?? '', value) <= 0);
11
+ }
12
+ const UNSAFE_NAME = /[\r\n\t]/;
13
+ /**
14
+ * Append-only and idempotent. A name that matches an existing value ignoring
15
+ * case counts as already present (the enum can never shrink, so a case typo
16
+ * would be permanent). Existing values keep their order: new names are placed
17
+ * alphabetically when the list is already alphabetical, otherwise appended.
18
+ */
19
+ export function planAddTypes(current, requested) {
20
+ const names = requested.map((name) => name.trim()).filter((name) => name.length > 0);
21
+ if (names.length === 0)
22
+ throw new Error('Name at least one type to add.');
23
+ for (const name of names) {
24
+ if (UNSAFE_NAME.test(name)) {
25
+ throw new Error(`"${name}" contains a newline or tab. Use a plain single-line name.`);
26
+ }
27
+ }
28
+ const existingByKey = new Map(current.map((value) => [value.toLowerCase(), value]));
29
+ const added = [];
30
+ const alreadyPresent = [];
31
+ for (const name of names) {
32
+ const match = existingByKey.get(name.toLowerCase());
33
+ if (match !== undefined) {
34
+ if (!alreadyPresent.includes(match))
35
+ alreadyPresent.push(match);
36
+ }
37
+ else if (!added.some((value) => value.toLowerCase() === name.toLowerCase())) {
38
+ added.push(name);
39
+ }
40
+ }
41
+ const next = isSorted(current)
42
+ ? [...current, ...added].sort(compareNames)
43
+ : [...current, ...[...added].sort(compareNames)];
44
+ return { next, added, alreadyPresent };
45
+ }
46
+ /** The validations array holding the enum: on the field, or on its items for an Array field. */
47
+ function enumHolder(field) {
48
+ const direct = field.validations ?? [];
49
+ const directIndex = direct.findIndex((validation) => Array.isArray(validation.in));
50
+ if (directIndex >= 0)
51
+ return { validations: direct, index: directIndex, viaItems: false };
52
+ const viaItems = field.items?.validations ?? [];
53
+ const itemsIndex = viaItems.findIndex((validation) => Array.isArray(validation.in));
54
+ if (itemsIndex >= 0)
55
+ return { validations: viaItems, index: itemsIndex, viaItems: true };
56
+ return null;
57
+ }
58
+ /**
59
+ * Publishing a content type publishes its whole draft. Contentful keeps a
60
+ * published, unchanged content type at version = publishedVersion + 1.
61
+ */
62
+ function hasUnpublishedChanges(sys) {
63
+ return sys.publishedVersion == null || sys.version > sys.publishedVersion + 1;
64
+ }
65
+ /**
66
+ * Adds type names to the enum for `kind` on the target content type, then publishes it.
67
+ * With `dryRun` nothing is written. Does nothing when every name is already present.
68
+ * Refuses when the content type has unpublished changes, because publishing would ship them too.
69
+ */
70
+ export async function addCmsTypes(client, kind, names, options = {}) {
71
+ const { contentTypeId, fieldId } = CMS_TYPE_TARGETS[kind];
72
+ const contentType = await client.contentType.get({ contentTypeId });
73
+ const field = contentType.fields.find((candidate) => candidate.id === fieldId);
74
+ if (!field)
75
+ throw new Error(`Content type ${contentTypeId} has no field ${fieldId}.`);
76
+ const holder = enumHolder(field);
77
+ if (!holder) {
78
+ throw new Error(`${contentTypeId}.${fieldId} has no "in" validation to extend.`);
79
+ }
80
+ const current = (holder.validations[holder.index]?.in ?? []);
81
+ const plan = planAddTypes(current, names);
82
+ const base = { ...plan, kind, contentTypeId, fieldId };
83
+ if (plan.added.length === 0 || options.dryRun)
84
+ return { ...base, written: false };
85
+ if (hasUnpublishedChanges(contentType.sys)) {
86
+ throw new Error(`${contentTypeId} has unpublished changes. Publishing would ship them with the new type. Publish or discard them in Contentful first.`);
87
+ }
88
+ holder.validations[holder.index] = { ...holder.validations[holder.index], in: plan.next };
89
+ const updated = await client.contentType.update({ contentTypeId }, contentType);
90
+ await client.contentType.publish({ contentTypeId }, updated);
91
+ return { ...base, written: true };
92
+ }
93
+ //# sourceMappingURL=cmsTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cmsTypes.js","sourceRoot":"","sources":["../../src/management/cmsTypes.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,gBAAgB,GAAoE;I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AC"}
@@ -1,2 +1,3 @@
1
+ export * from './cmsTypes.js';
1
2
  export * from './shared.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/management/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/management/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
@@ -1,3 +1,4 @@
1
1
  // Management scripts exports
2
+ export * from './cmsTypes.js';
2
3
  export * from './shared.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/management/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/management/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
@@ -1299,7 +1299,8 @@ function concreteArticlePage(rest, typeSlug) {
1299
1299
  'parent: ResolvingMetadata',
1300
1300
  ]);
1301
1301
  const page = openFn('export default async function ', [`props: ${props}`]);
1302
- return `${header()}import type { ResolvingMetadata } from 'next';
1302
+ return `${header()}import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
1303
+ import type { ResolvingMetadata } from 'next';
1303
1304
  import { generateArticleMetadata, generateArticlePage } from '@/lib/route-handlers';
1304
1305
  import { ARTICLE_DETAIL_ROUTE_CONFIG } from '@/lib/routeConfig';
1305
1306
 
@@ -1312,6 +1313,7 @@ export function generateStaticParams() {
1312
1313
  ${extract}
1313
1314
  const params = await props.params;
1314
1315
  const { article } = params;
1316
+ notFoundIfImpossibleCmsSlug(article);
1315
1317
  return { articleSlug: article, path: \`/${rest}/\${article}/\` };
1316
1318
  }
1317
1319
 
@@ -1721,6 +1723,7 @@ function levelPage() {
1721
1723
  ]);
1722
1724
  const page = openFn('export default async function ', [`props: ${props}`]);
1723
1725
  return `${header()}import { joinCmsPathSegments } from '@se-studio/core-ui';
1726
+ import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
1724
1727
  import type { ResolvingMetadata } from 'next';
1725
1728
  import { notFound } from 'next/navigation';
1726
1729
  import { generatePage, generatePageMetadata } from '@/lib/route-handlers';
@@ -1736,6 +1739,7 @@ ${extract}
1736
1739
  if (!slug) {
1737
1740
  notFound();
1738
1741
  }
1742
+ notFoundIfImpossibleCmsSlug(slug);
1739
1743
  return { slug, path: \`/\${slug}/\` };
1740
1744
  }
1741
1745
 
@@ -1760,6 +1764,7 @@ function levelSlugsPage() {
1760
1764
  ]);
1761
1765
  const page = openFn('export default async function ', [`props: ${props}`]);
1762
1766
  return `${header()}import { joinCmsPathSegments } from '@se-studio/core-ui';
1767
+ import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
1763
1768
  import type { ResolvingMetadata } from 'next';
1764
1769
  import { notFound } from 'next/navigation';
1765
1770
  import { generatePage, generatePageMetadata } from '@/lib/route-handlers';
@@ -1775,6 +1780,7 @@ ${extract}
1775
1780
  if (!slug) {
1776
1781
  notFound();
1777
1782
  }
1783
+ notFoundIfImpossibleCmsSlug(slug);
1778
1784
  return { slug, path: \`/\${slug}/\` };
1779
1785
  }
1780
1786
 
@@ -2156,6 +2162,7 @@ function fixedArticleDetail(segment) {
2156
2162
  ]);
2157
2163
  const page = openFn('export default async function ', [`props: ${props}`]);
2158
2164
  return `${header()}import { joinCmsPathSegments } from '@se-studio/core-ui';
2165
+ import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
2159
2166
  import type { ResolvingMetadata } from 'next';
2160
2167
  import { notFound } from 'next/navigation';
2161
2168
  import { generateArticleMetadata, generateArticlePage } from '@/lib/route-handlers';
@@ -2173,6 +2180,7 @@ ${extract}
2173
2180
  if (!articleSlug) {
2174
2181
  notFound();
2175
2182
  }
2183
+ notFoundIfImpossibleCmsSlug(articleSlug);
2176
2184
  return {
2177
2185
  articleSlug,
2178
2186
  path: \`/${segment}/\${articleSlug}/\`,
@@ -2261,7 +2269,8 @@ function dynamicArticleType(segment) {
2261
2269
  'parent: ResolvingMetadata',
2262
2270
  ]);
2263
2271
  const page = openFn('export default async function ', [`props: ${props}`]);
2264
- return `${header()}import type { ResolvingMetadata } from 'next';
2272
+ return `${header()}import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
2273
+ import type { ResolvingMetadata } from 'next';
2265
2274
  ${converterImport}import { generateArticleTypeMetadata, generateArticleTypePage } from '@/lib/route-handlers';
2266
2275
  import { DEFAULT_ROUTE_CONFIG } from '@/lib/routeConfig';
2267
2276
 
@@ -2272,6 +2281,7 @@ export function generateStaticParams() {
2272
2281
  ${extract}
2273
2282
  const params = await props.params;
2274
2283
  const { articleType } = params;
2284
+ notFoundIfImpossibleCmsSlug(articleType);
2275
2285
  return { slug: articleType, path: ${pathExpr} };
2276
2286
  }
2277
2287
 
@@ -2306,6 +2316,7 @@ function dynamicArticleDetail(segment) {
2306
2316
  ]);
2307
2317
  const page = openFn('export default async function ', [`props: ${props}`]);
2308
2318
  return `${header()}import { joinCmsPathSegments } from '@se-studio/core-ui';
2319
+ import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
2309
2320
  import type { ResolvingMetadata } from 'next';
2310
2321
  import { notFound } from 'next/navigation';
2311
2322
  ${converterImport}import { generateArticleMetadata, generateArticlePage } from '@/lib/route-handlers';
@@ -2322,6 +2333,7 @@ ${extract}
2322
2333
  if (!(articleType && articleSlug)) {
2323
2334
  notFound();
2324
2335
  }
2336
+ notFoundIfImpossibleCmsSlug(articleType, articleSlug);
2325
2337
  return {
2326
2338
  articleType,
2327
2339
  articleSlug,
@@ -2358,7 +2370,8 @@ function fixedArticleTag(segment) {
2358
2370
  'parent: ResolvingMetadata',
2359
2371
  ]);
2360
2372
  const page = openFn('export default async function ', [`props: ${props}`]);
2361
- return `${header()}import type { ResolvingMetadata } from 'next';
2373
+ return `${header()}import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
2374
+ import type { ResolvingMetadata } from 'next';
2362
2375
  import {
2363
2376
  generateArticleTypeTagMetadata,
2364
2377
  generateArticleTypeTagPage,
@@ -2374,6 +2387,7 @@ export function generateStaticParams() {
2374
2387
  ${extract}
2375
2388
  const params = await props.params;
2376
2389
  const { tag } = params;
2390
+ notFoundIfImpossibleCmsSlug(tag);
2377
2391
  return { tag, path: \`/${segment}/\${tag}/\` };
2378
2392
  }
2379
2393
 
@@ -2401,6 +2415,7 @@ function fixedArticleTagDetail(segment) {
2401
2415
  ]);
2402
2416
  const page = openFn('export default async function ', [`props: ${props}`]);
2403
2417
  return `${header()}import { joinCmsPathSegments } from '@se-studio/core-ui';
2418
+ import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
2404
2419
  import type { ResolvingMetadata } from 'next';
2405
2420
  import { notFound } from 'next/navigation';
2406
2421
  import { generateArticleMetadata, generateArticlePage } from '@/lib/route-handlers';
@@ -2419,6 +2434,7 @@ ${extract}
2419
2434
  if (!(tag && articleSlug)) {
2420
2435
  notFound();
2421
2436
  }
2437
+ notFoundIfImpossibleCmsSlug(tag, articleSlug);
2422
2438
  return {
2423
2439
  tag,
2424
2440
  articleSlug,
@@ -2462,7 +2478,8 @@ function dynamicArticleTag(segment) {
2462
2478
  'parent: ResolvingMetadata',
2463
2479
  ]);
2464
2480
  const page = openFn('export default async function ', [`props: ${props}`]);
2465
- return `${header()}import type { ResolvingMetadata } from 'next';
2481
+ return `${header()}import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
2482
+ import type { ResolvingMetadata } from 'next';
2466
2483
  ${converterImport}import {
2467
2484
  generateArticleTypeTagMetadata,
2468
2485
  generateArticleTypeTagPage,
@@ -2476,6 +2493,7 @@ export function generateStaticParams() {
2476
2493
  ${extract}
2477
2494
  const params = await props.params;
2478
2495
  const { articleType, tag } = params;
2496
+ notFoundIfImpossibleCmsSlug(articleType, tag);
2479
2497
  return { articleType, tag, path: ${pathExpr} };
2480
2498
  }
2481
2499
 
@@ -2516,6 +2534,7 @@ function dynamicArticleTagDetail(segment) {
2516
2534
  ]);
2517
2535
  const page = openFn('export default async function ', [`props: ${props}`]);
2518
2536
  return `${header()}import { joinCmsPathSegments } from '@se-studio/core-ui';
2537
+ import { notFoundIfImpossibleCmsSlug } from '@se-studio/core-ui/server';
2519
2538
  import type { ResolvingMetadata } from 'next';
2520
2539
  import { notFound } from 'next/navigation';
2521
2540
  ${converterImport}import { generateArticleMetadata, generateArticlePage } from '@/lib/route-handlers';
@@ -2533,6 +2552,7 @@ ${extract}
2533
2552
  if (!(articleType && tag && articleSlug)) {
2534
2553
  notFound();
2535
2554
  }
2555
+ notFoundIfImpossibleCmsSlug(articleType, tag, articleSlug);
2536
2556
  return {
2537
2557
  articleType,
2538
2558
  tag,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/project-build",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
4
4
  "description": "Build tools and management scripts for SE Studio projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,6 +34,7 @@
34
34
  "bin": {
35
35
  "setailwind": "./dist/setailwind.js",
36
36
  "setup-colours": "./dist/management/setupColours.js",
37
+ "add-cms-type": "./dist/management/addCmsType.js",
37
38
  "generate-showcase-data": "./dist/generate-showcase-data.js",
38
39
  "generate-showcase-mocks": "./dist/generate-showcase-mocks.js",
39
40
  "cms-generate-field-list": "./dist/cms-generate-field-list.js",