@lacecms/content 0.1.0-rc5 → 1.1.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.
Files changed (65) hide show
  1. package/dist/blocks/built-ins.d.ts.map +1 -1
  2. package/dist/blocks/built-ins.js +0 -2
  3. package/dist/blocks/built-ins.js.map +1 -1
  4. package/dist/entries/aggregate.d.ts.map +1 -1
  5. package/dist/entries/aggregate.js +18 -11
  6. package/dist/entries/aggregate.js.map +1 -1
  7. package/dist/fields/builders.d.ts +1 -0
  8. package/dist/fields/builders.d.ts.map +1 -1
  9. package/dist/fields/capabilities.d.ts +9 -1
  10. package/dist/fields/capabilities.d.ts.map +1 -1
  11. package/dist/fields/capabilities.js +8 -0
  12. package/dist/fields/capabilities.js.map +1 -1
  13. package/dist/fields/definitions.d.ts +9 -1
  14. package/dist/fields/definitions.d.ts.map +1 -1
  15. package/dist/fields/definitions.js +2 -0
  16. package/dist/fields/definitions.js.map +1 -1
  17. package/dist/fields/internal-link-tokens.d.ts +1 -1
  18. package/dist/fields/internal-link-tokens.d.ts.map +1 -1
  19. package/dist/fields/internal-link-tokens.js +1 -1
  20. package/dist/fields/internal-link-tokens.js.map +1 -1
  21. package/dist/fields/normalization.d.ts.map +1 -1
  22. package/dist/fields/normalization.js +2 -0
  23. package/dist/fields/normalization.js.map +1 -1
  24. package/dist/fields/scalar-builders.d.ts +3 -1
  25. package/dist/fields/scalar-builders.d.ts.map +1 -1
  26. package/dist/fields/scalar-builders.js +17 -0
  27. package/dist/fields/scalar-builders.js.map +1 -1
  28. package/dist/fields/validation.d.ts.map +1 -1
  29. package/dist/fields/validation.js +2 -0
  30. package/dist/fields/validation.js.map +1 -1
  31. package/dist/index.d.ts +7 -4
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +4 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/references/entry-references.d.ts +47 -0
  36. package/dist/references/entry-references.d.ts.map +1 -0
  37. package/dist/references/entry-references.js +71 -0
  38. package/dist/references/entry-references.js.map +1 -0
  39. package/dist/references/field-paths.d.ts +2 -0
  40. package/dist/references/field-paths.d.ts.map +1 -1
  41. package/dist/references/field-paths.js +7 -1
  42. package/dist/references/field-paths.js.map +1 -1
  43. package/dist/shared/errors.d.ts +10 -0
  44. package/dist/shared/errors.d.ts.map +1 -1
  45. package/dist/shared/errors.js +1 -0
  46. package/dist/shared/errors.js.map +1 -1
  47. package/dist/shared/identifiers.d.ts +1 -1
  48. package/dist/shared/identifiers.d.ts.map +1 -1
  49. package/dist/shared/model-icons.d.ts +6 -0
  50. package/dist/shared/model-icons.d.ts.map +1 -0
  51. package/dist/shared/model-icons.js +28 -0
  52. package/dist/shared/model-icons.js.map +1 -0
  53. package/dist/shared/model-kinds.d.ts +96 -0
  54. package/dist/shared/model-kinds.d.ts.map +1 -0
  55. package/dist/shared/model-kinds.js +42 -0
  56. package/dist/shared/model-kinds.js.map +1 -0
  57. package/package.json +3 -2
  58. package/dist/blocks/gallery-migration.d.ts +0 -8
  59. package/dist/blocks/gallery-migration.d.ts.map +0 -1
  60. package/dist/blocks/gallery-migration.js +0 -28
  61. package/dist/blocks/gallery-migration.js.map +0 -1
  62. package/dist/references/internal-links.d.ts +0 -30
  63. package/dist/references/internal-links.d.ts.map +0 -1
  64. package/dist/references/internal-links.js +0 -54
  65. package/dist/references/internal-links.js.map +0 -1
@@ -0,0 +1,96 @@
1
+ import type { ContentModelKind } from "./identifiers.js";
2
+ type ModelDelivery = {
3
+ readonly routing: "fixed";
4
+ readonly publicFamily: "pages";
5
+ readonly exportSection: "entries";
6
+ } | {
7
+ readonly routing: "slug";
8
+ readonly publicFamily: "collections";
9
+ readonly exportSection: "entries";
10
+ } | {
11
+ readonly routing: "none";
12
+ readonly publicFamily: "records";
13
+ readonly exportSection: "records";
14
+ } | {
15
+ readonly routing: "none";
16
+ readonly publicFamily: "globals";
17
+ readonly exportSection: "globals";
18
+ };
19
+ type ModelKindBehavior = {
20
+ readonly cardinality: "one" | "many";
21
+ readonly referenceTarget: boolean;
22
+ readonly admin: {
23
+ readonly navigation: "editor" | "list";
24
+ readonly title: "editable" | "system";
25
+ };
26
+ };
27
+ export type ModelKindDescriptor = ModelKindBehavior & ({
28
+ readonly delivery: Exclude<ModelDelivery, {
29
+ publicFamily: "collections" | "records";
30
+ }>;
31
+ readonly routeLessDelivery?: never;
32
+ } | {
33
+ readonly delivery: Extract<ModelDelivery, {
34
+ publicFamily: "collections";
35
+ }>;
36
+ readonly routeLessDelivery: Extract<ModelDelivery, {
37
+ publicFamily: "records";
38
+ }>;
39
+ });
40
+ export declare const modelKindDescriptors: {
41
+ readonly page: {
42
+ readonly cardinality: "one";
43
+ readonly referenceTarget: true;
44
+ readonly admin: {
45
+ readonly navigation: "editor";
46
+ readonly title: "editable";
47
+ };
48
+ readonly delivery: {
49
+ readonly routing: "fixed";
50
+ readonly publicFamily: "pages";
51
+ readonly exportSection: "entries";
52
+ };
53
+ };
54
+ readonly collection: {
55
+ readonly cardinality: "many";
56
+ readonly referenceTarget: true;
57
+ readonly admin: {
58
+ readonly navigation: "list";
59
+ readonly title: "editable";
60
+ };
61
+ readonly delivery: {
62
+ readonly routing: "slug";
63
+ readonly publicFamily: "collections";
64
+ readonly exportSection: "entries";
65
+ };
66
+ readonly routeLessDelivery: {
67
+ readonly routing: "none";
68
+ readonly publicFamily: "records";
69
+ readonly exportSection: "records";
70
+ };
71
+ };
72
+ readonly global: {
73
+ readonly cardinality: "one";
74
+ readonly referenceTarget: false;
75
+ readonly admin: {
76
+ readonly navigation: "editor";
77
+ readonly title: "system";
78
+ };
79
+ readonly delivery: {
80
+ readonly routing: "none";
81
+ readonly publicFamily: "globals";
82
+ readonly exportSection: "globals";
83
+ };
84
+ };
85
+ };
86
+ export declare const CONTENT_MODEL_KINDS: readonly ContentModelKind[];
87
+ export declare function isContentModelKind(value: unknown): value is ContentModelKind;
88
+ export declare function modelKindDescriptor<Kind extends ContentModelKind>(kind: Kind): (typeof modelKindDescriptors)[Kind];
89
+ export type ResolvedModelKind = ModelKindBehavior & ModelDelivery;
90
+ /** Resolves delivery and editing policy for a configured model. */
91
+ export declare function resolveModelKind(model: {
92
+ readonly kind: ContentModelKind;
93
+ readonly route?: string | undefined;
94
+ }): ResolvedModelKind;
95
+ export {};
96
+ //# sourceMappingURL=model-kinds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-kinds.d.ts","sourceRoot":"","sources":["../../src/shared/model-kinds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,KAAK,aAAa,GACd;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAA;CAAE,GAChG;IACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;CACnC,GACD;IACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;CACnC,GACD;IACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;CACnC,CAAC;AAEN,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,WAAW,EAAE,KAAK,GAAG,MAAM,CAAC;IACrC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,UAAU,EAAE,QAAQ,GAAG,MAAM,CAAC;QACvC,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC;KACvC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B,EAAE,SAAS,gBAAgB,EAE1D,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,SAAS,gBAAgB,EAC/D,IAAI,EAAE,IAAI,GACT,CAAC,OAAO,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAErC;AAED,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAElE,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,GAAG,iBAAiB,CAWpB"}
@@ -0,0 +1,42 @@
1
+ import { deepFreeze } from "./objects.js";
2
+ export const modelKindDescriptors = deepFreeze({
3
+ page: {
4
+ cardinality: "one",
5
+ referenceTarget: true,
6
+ admin: { navigation: "editor", title: "editable" },
7
+ delivery: { routing: "fixed", publicFamily: "pages", exportSection: "entries" },
8
+ },
9
+ collection: {
10
+ cardinality: "many",
11
+ referenceTarget: true,
12
+ admin: { navigation: "list", title: "editable" },
13
+ delivery: { routing: "slug", publicFamily: "collections", exportSection: "entries" },
14
+ routeLessDelivery: { routing: "none", publicFamily: "records", exportSection: "records" },
15
+ },
16
+ global: {
17
+ cardinality: "one",
18
+ referenceTarget: false,
19
+ admin: { navigation: "editor", title: "system" },
20
+ delivery: { routing: "none", publicFamily: "globals", exportSection: "globals" },
21
+ },
22
+ });
23
+ export const CONTENT_MODEL_KINDS = Object.freeze(Object.keys(modelKindDescriptors));
24
+ export function isContentModelKind(value) {
25
+ return typeof value === "string" && Object.hasOwn(modelKindDescriptors, value);
26
+ }
27
+ export function modelKindDescriptor(kind) {
28
+ return modelKindDescriptors[kind];
29
+ }
30
+ /** Resolves delivery and editing policy for a configured model. */
31
+ export function resolveModelKind(model) {
32
+ const { cardinality, admin, referenceTarget, delivery, routeLessDelivery } = modelKindDescriptor(model.kind);
33
+ return {
34
+ cardinality,
35
+ admin,
36
+ referenceTarget,
37
+ ...(model.route === undefined && routeLessDelivery !== undefined
38
+ ? routeLessDelivery
39
+ : delivery),
40
+ };
41
+ }
42
+ //# sourceMappingURL=model-kinds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-kinds.js","sourceRoot":"","sources":["../../src/shared/model-kinds.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAyC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC7C,IAAI,EAAE;QACJ,WAAW,EAAE,KAAK;QAClB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;QAClD,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE;KAChF;IACD,UAAU,EAAE;QACV,WAAW,EAAE,MAAM;QACnB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE;QAChD,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE;QACpF,iBAAiB,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE;KAC1F;IACD,MAAM,EAAE;QACN,WAAW,EAAE,KAAK;QAClB,eAAe,EAAE,KAAK;QACtB,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QAChD,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE;KACjF;CAC+D,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,mBAAmB,GAAgC,MAAM,CAAC,MAAM,CAC3E,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAuB,CACxD,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAU;IAEV,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAID,mEAAmE;AACnE,MAAM,UAAU,gBAAgB,CAAC,KAGhC;IACC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GACxE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO;QACL,WAAW;QACX,KAAK;QACL,eAAe;QACf,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,iBAAiB,KAAK,SAAS;YAC9D,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,QAAQ,CAAC;KACd,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lacecms/content",
3
- "version": "0.1.0-rc5",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,9 +20,10 @@
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public",
23
- "tag": "next"
23
+ "tag": "latest"
24
24
  },
25
25
  "dependencies": {
26
+ "emoji-regex": "11.0.0",
26
27
  "valibot": "1.5.0"
27
28
  },
28
29
  "engines": {
@@ -1,8 +0,0 @@
1
- import type { BlockMigrationInput, BlockMigrationOutput } from "./types.js";
2
- /**
3
- * Gallery version 6 (from the rc2 shape, version 5): the removed
4
- * `featured-first` preset becomes `columns-2` with a `full` first item, and
5
- * video items that relied on the old `player` default keep it explicitly.
6
- */
7
- export declare function migrateGalleryToV6({ data, settings }: BlockMigrationInput): BlockMigrationOutput;
8
- //# sourceMappingURL=gallery-migration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gallery-migration.d.ts","sourceRoot":"","sources":["../../src/blocks/gallery-migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,mBAAmB,GAAG,oBAAoB,CAkBhG"}
@@ -1,28 +0,0 @@
1
- import { isRecord } from "../shared/objects.js";
2
- /**
3
- * Gallery version 6 (from the rc2 shape, version 5): the removed
4
- * `featured-first` preset becomes `columns-2` with a `full` first item, and
5
- * video items that relied on the old `player` default keep it explicitly.
6
- */
7
- export function migrateGalleryToV6({ data, settings }) {
8
- const featured = settings.layoutPreset === "featured-first";
9
- const images = data.images;
10
- const migrated = Array.isArray(images)
11
- ? images.map((item, index) => {
12
- if (!isRecord(item))
13
- return item;
14
- let next = item;
15
- if (featured && index === 0)
16
- next = { ...next, placement: "full" };
17
- if (next.kind === "video" && next.playback === undefined) {
18
- next = { ...next, playback: "player" };
19
- }
20
- return next;
21
- })
22
- : images;
23
- return {
24
- data: migrated === undefined ? data : { ...data, images: migrated },
25
- settings: featured ? { ...settings, layoutPreset: "columns-2" } : settings,
26
- };
27
- }
28
- //# sourceMappingURL=gallery-migration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gallery-migration.js","sourceRoot":"","sources":["../../src/blocks/gallery-migration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAuB;IACxE,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,KAAK,gBAAgB,CAAC;IAC5D,MAAM,MAAM,GAA0B,IAAI,CAAC,MAAM,CAAC;IAClD,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACpC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAa,EAAE;YACpC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YACjC,IAAI,IAAI,GAAe,IAAkB,CAAC;YAC1C,IAAI,QAAQ,IAAI,KAAK,KAAK,CAAC;gBAAE,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACzD,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;YACzC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QACJ,CAAC,CAAC,MAAM,CAAC;IACX,OAAO;QACL,IAAI,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE;QACnE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ;KAC3E,CAAC;AACJ,CAAC"}
@@ -1,30 +0,0 @@
1
- import type { ValidationPathSegment } from "../shared/errors.js";
2
- import type { ModelFieldDefinitions, FieldVisibility } from "../fields/definitions.js";
3
- import type { JsonObject } from "../shared/json.js";
4
- /** A declared ordinary URL leaf, relative to its field map. */
5
- export interface FieldInternalLinkReference {
6
- readonly targetId: string;
7
- readonly path: readonly ValidationPathSegment[];
8
- }
9
- /** Discover references only in normalized ordinary URL descriptors. */
10
- export declare function collectFieldInternalLinks(definitions: ModelFieldDefinitions, values: JsonObject): readonly FieldInternalLinkReference[];
11
- /** A source-scoped reference tuple, ready for persistence and public manifests. */
12
- export interface InternalLinkReference {
13
- readonly sourceKey: string;
14
- readonly area: "fields" | "data";
15
- readonly pointer: string;
16
- readonly targetId: string;
17
- readonly delivered: boolean;
18
- }
19
- /** The local manifest location delivered to site consumers. */
20
- export type PublicInternalLinkReference = Omit<InternalLinkReference, "delivered">;
21
- /** Collect and bound every declared internal URL in one normalized snapshot. */
22
- export declare function collectSnapshotInternalLinks(fields: ModelFieldDefinitions, values: JsonObject, blocks: readonly {
23
- readonly key: string;
24
- readonly fields: ModelFieldDefinitions;
25
- readonly data: JsonObject;
26
- readonly hidden?: boolean;
27
- /** The block's data rules; links inside hidden targets are not delivered. */
28
- readonly visibility?: FieldVisibility;
29
- }[], visibility?: FieldVisibility): readonly InternalLinkReference[];
30
- //# sourceMappingURL=internal-links.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-links.d.ts","sourceRoot":"","sources":["../../src/references/internal-links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EACV,qBAAqB,EAErB,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,mBAAmB,CAAC;AAK/D,+DAA+D;AAC/D,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACjD;AAED,uEAAuE;AACvE,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,qBAAqB,EAClC,MAAM,EAAE,UAAU,GACjB,SAAS,0BAA0B,EAAE,CA0BvC;AAED,mFAAmF;AACnF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,+DAA+D;AAC/D,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;AAEnF,gFAAgF;AAChF,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,SAAS;IACf,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;CACvC,EAAE,EACH,UAAU,CAAC,EAAE,eAAe,GAC3B,SAAS,qBAAqB,EAAE,CAoDlC"}
@@ -1,54 +0,0 @@
1
- import { invalid } from "../shared/errors.js";
2
- import { decodeEntryLink, MAX_INTERNAL_LINK_REFERENCES } from "../fields/internal-link-tokens.js";
3
- import { isRecord, deepFreeze } from "../shared/objects.js";
4
- import { declaresFieldVisibility, publishedFieldValues } from "../fields/validation.js";
5
- /** Discover references only in normalized ordinary URL descriptors. */
6
- export function collectFieldInternalLinks(definitions, values) {
7
- const references = [];
8
- function visit(definition, value, path) {
9
- if (definition.type === "url" && definition.embedProviders === undefined) {
10
- const targetId = decodeEntryLink(value);
11
- if (targetId !== undefined)
12
- references.push({ targetId, path });
13
- }
14
- else if (definition.type === "group" && isRecord(value)) {
15
- walk(definition.fields, value, path);
16
- }
17
- else if (definition.type === "list" && Array.isArray(value)) {
18
- value.forEach((item, index) => visit(definition.item, item, [...path, index]));
19
- }
20
- }
21
- function walk(fields, data, path) {
22
- for (const [key, definition] of Object.entries(fields))
23
- visit(definition, data[key], [...path, key]);
24
- }
25
- walk(definitions, values, []);
26
- return deepFreeze(references);
27
- }
28
- /** Collect and bound every declared internal URL in one normalized snapshot. */
29
- export function collectSnapshotInternalLinks(fields, values, blocks, visibility) {
30
- const references = [];
31
- const pointerOf = (path) => `/${path.map((part) => String(part).replaceAll("~", "~0").replaceAll("/", "~1")).join("/")}`;
32
- function add(definitions, data, sourceKey, area, delivered, rootPath, rules) {
33
- // The projection keeps paths, so a link is visible exactly when it survives it.
34
- const visible = declaresFieldVisibility(definitions, rules)
35
- ? new Set(collectFieldInternalLinks(definitions, publishedFieldValues(definitions, data, rules)).map((reference) => pointerOf(reference.path)))
36
- : undefined;
37
- for (const reference of collectFieldInternalLinks(definitions, data)) {
38
- if (references.length === MAX_INTERNAL_LINK_REFERENCES)
39
- invalid([...rootPath, ...reference.path], "too_many_internal_links", `must not contain more than ${MAX_INTERNAL_LINK_REFERENCES} internal links.`);
40
- const pointer = pointerOf(reference.path);
41
- references.push({
42
- sourceKey,
43
- area,
44
- delivered: delivered && (visible === undefined || visible.has(pointer)),
45
- targetId: reference.targetId,
46
- pointer,
47
- });
48
- }
49
- }
50
- add(fields, values, "$fields", "fields", true, ["fields"], visibility);
51
- blocks.forEach((block, index) => add(block.fields, block.data, block.key, "data", block.hidden !== true, ["blocks", index, "data"], block.visibility));
52
- return deepFreeze(references);
53
- }
54
- //# sourceMappingURL=internal-links.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-links.js","sourceRoot":"","sources":["../../src/references/internal-links.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAO9C,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC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