@baseplate-dev/project-builder-lib 0.4.0 → 0.4.2
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/dist/definition/model/model-field-utils.d.ts.map +1 -1
- package/dist/definition/model/model-field-utils.js +3 -7
- package/dist/definition/model/model-field-utils.js.map +1 -1
- package/dist/definition/plugins/plugin-utils.d.ts +3 -2
- package/dist/definition/plugins/plugin-utils.d.ts.map +1 -1
- package/dist/definition/plugins/plugin-utils.js +15 -6
- package/dist/definition/plugins/plugin-utils.js.map +1 -1
- package/dist/definition/project-definition-container.test-utils.d.ts.map +1 -1
- package/dist/definition/project-definition-container.test-utils.js +2 -2
- package/dist/definition/project-definition-container.test-utils.js.map +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/migration-021-migrate-bullmq-to-plugin.d.ts +42 -0
- package/dist/migrations/migration-021-migrate-bullmq-to-plugin.d.ts.map +1 -0
- package/dist/migrations/migration-021-migrate-bullmq-to-plugin.js +76 -0
- package/dist/migrations/migration-021-migrate-bullmq-to-plugin.js.map +1 -0
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js +1 -0
- package/dist/parser/parser.js.map +1 -1
- package/dist/plugins/metadata/types.d.ts +7 -126
- package/dist/plugins/metadata/types.d.ts.map +1 -1
- package/dist/plugins/plugins.test-utils.d.ts +0 -8
- package/dist/plugins/plugins.test-utils.d.ts.map +1 -1
- package/dist/plugins/plugins.test-utils.js +0 -19
- package/dist/plugins/plugins.test-utils.js.map +1 -1
- package/dist/references/collect-refs.d.ts +20 -0
- package/dist/references/collect-refs.d.ts.map +1 -0
- package/dist/references/collect-refs.js +67 -0
- package/dist/references/collect-refs.js.map +1 -0
- package/dist/references/definition-ref-builder.d.ts +24 -154
- package/dist/references/definition-ref-builder.d.ts.map +1 -1
- package/dist/references/definition-ref-builder.js +0 -207
- package/dist/references/definition-ref-builder.js.map +1 -1
- package/dist/references/deserialize-schema.d.ts +2 -2
- package/dist/references/deserialize-schema.d.ts.map +1 -1
- package/dist/references/deserialize-schema.js +3 -0
- package/dist/references/deserialize-schema.js.map +1 -1
- package/dist/references/extend-parser-context-with-refs.d.ts +12 -7
- package/dist/references/extend-parser-context-with-refs.d.ts.map +1 -1
- package/dist/references/extend-parser-context-with-refs.js +111 -58
- package/dist/references/extend-parser-context-with-refs.js.map +1 -1
- package/dist/references/extract-definition-refs.d.ts +20 -13
- package/dist/references/extract-definition-refs.d.ts.map +1 -1
- package/dist/references/extract-definition-refs.js +50 -58
- package/dist/references/extract-definition-refs.js.map +1 -1
- package/dist/references/fix-ref-deletions.js.map +1 -1
- package/dist/references/index.d.ts +1 -0
- package/dist/references/index.d.ts.map +1 -1
- package/dist/references/index.js +1 -0
- package/dist/references/index.js.map +1 -1
- package/dist/references/markers.d.ts +28 -14
- package/dist/references/markers.d.ts.map +1 -1
- package/dist/references/markers.js.map +1 -1
- package/dist/references/parse-schema-with-references.d.ts.map +1 -1
- package/dist/references/parse-schema-with-references.js +0 -2
- package/dist/references/parse-schema-with-references.js.map +1 -1
- package/dist/references/ref-context-slot.d.ts +84 -0
- package/dist/references/ref-context-slot.d.ts.map +1 -0
- package/dist/references/ref-context-slot.js +38 -0
- package/dist/references/ref-context-slot.js.map +1 -0
- package/dist/references/resolve-slots.d.ts +38 -0
- package/dist/references/resolve-slots.d.ts.map +1 -0
- package/dist/references/resolve-slots.js +86 -0
- package/dist/references/resolve-slots.js.map +1 -0
- package/dist/references/resolve-zod-ref-payload-names.d.ts +2 -2
- package/dist/references/resolve-zod-ref-payload-names.d.ts.map +1 -1
- package/dist/references/resolve-zod-ref-payload-names.js +18 -7
- package/dist/references/resolve-zod-ref-payload-names.js.map +1 -1
- package/dist/references/serialize-schema.d.ts +1 -1
- package/dist/references/serialize-schema.d.ts.map +1 -1
- package/dist/references/serialize-schema.js +3 -1
- package/dist/references/serialize-schema.js.map +1 -1
- package/dist/references/types.d.ts +5 -6
- package/dist/references/types.d.ts.map +1 -1
- package/dist/schema/apps/backend/index.d.ts +4 -22
- package/dist/schema/apps/backend/index.d.ts.map +1 -1
- package/dist/schema/apps/backend/index.js +3 -4
- package/dist/schema/apps/backend/index.js.map +1 -1
- package/dist/schema/apps/base.d.ts +4 -12
- package/dist/schema/apps/base.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/admin.d.ts +270 -1699
- package/dist/schema/apps/web/admin/admin.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/admin.js +9 -10
- package/dist/schema/apps/web/admin/admin.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/base.d.ts +2 -14
- package/dist/schema/apps/web/admin/sections/base.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.d.ts +2 -2
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.d.ts +13 -24
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.js +10 -19
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/built-in-actions.d.ts +10 -22
- package/dist/schema/apps/web/admin/sections/crud-actions/built-in-actions.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/types.d.ts +8 -12
- package/dist/schema/apps/web/admin/sections/crud-actions/types.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/types.js +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/types.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.d.ts +2 -3
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.d.ts +11 -23
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.js +12 -20
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/built-in-columns.d.ts +8 -30
- package/dist/schema/apps/web/admin/sections/crud-columns/built-in-columns.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/built-in-columns.js +6 -6
- package/dist/schema/apps/web/admin/sections/crud-columns/built-in-columns.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/types.d.ts +15 -12
- package/dist/schema/apps/web/admin/sections/crud-columns/types.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/types.js +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/types.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.d.ts +12 -23
- package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.js +13 -20
- package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.d.ts +2 -3
- package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/built-in-input.d.ts +40 -123
- package/dist/schema/apps/web/admin/sections/crud-form/built-in-input.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/built-in-input.js +15 -14
- package/dist/schema/apps/web/admin/sections/crud-form/built-in-input.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/types.d.ts +17 -12
- package/dist/schema/apps/web/admin/sections/crud-form/types.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/types.js +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/types.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud.d.ts +202 -930
- package/dist/schema/apps/web/admin/sections/crud.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud.js +32 -26
- package/dist/schema/apps/web/admin/sections/crud.js.map +1 -1
- package/dist/schema/apps/web/web-app.d.ts +196 -1257
- package/dist/schema/apps/web/web-app.d.ts.map +1 -1
- package/dist/schema/apps/web/web-app.js +4 -4
- package/dist/schema/apps/web/web-app.js.map +1 -1
- package/dist/schema/creator/extend-parser-context-with-defaults.d.ts +2 -2
- package/dist/schema/creator/extend-parser-context-with-defaults.d.ts.map +1 -1
- package/dist/schema/creator/extend-parser-context-with-defaults.js +8 -15
- package/dist/schema/creator/extend-parser-context-with-defaults.js.map +1 -1
- package/dist/schema/creator/infer-types.d.ts +21 -4
- package/dist/schema/creator/infer-types.d.ts.map +1 -1
- package/dist/schema/creator/schema-creator.d.ts +46 -2
- package/dist/schema/creator/schema-creator.d.ts.map +1 -1
- package/dist/schema/creator/schema-creator.js +53 -0
- package/dist/schema/creator/schema-creator.js.map +1 -1
- package/dist/schema/creator/types.d.ts +11 -6
- package/dist/schema/creator/types.d.ts.map +1 -1
- package/dist/schema/features/feature.d.ts +14 -22
- package/dist/schema/features/feature.d.ts.map +1 -1
- package/dist/schema/models/enums.d.ts +34 -84
- package/dist/schema/models/enums.d.ts.map +1 -1
- package/dist/schema/models/enums.js +8 -8
- package/dist/schema/models/enums.js.map +1 -1
- package/dist/schema/models/graphql.d.ts +16 -163
- package/dist/schema/models/graphql.d.ts.map +1 -1
- package/dist/schema/models/graphql.js +8 -6
- package/dist/schema/models/graphql.js.map +1 -1
- package/dist/schema/models/index.d.ts +293 -1827
- package/dist/schema/models/index.d.ts.map +1 -1
- package/dist/schema/models/index.js +53 -54
- package/dist/schema/models/index.js.map +1 -1
- package/dist/schema/models/transformers/built-in-transformers.d.ts +20 -58
- package/dist/schema/models/transformers/built-in-transformers.d.ts.map +1 -1
- package/dist/schema/models/transformers/built-in-transformers.js +8 -9
- package/dist/schema/models/transformers/built-in-transformers.js.map +1 -1
- package/dist/schema/models/transformers/model-transformer-spec.d.ts +3 -4
- package/dist/schema/models/transformers/model-transformer-spec.d.ts.map +1 -1
- package/dist/schema/models/transformers/model-transformer-spec.js +3 -4
- package/dist/schema/models/transformers/model-transformer-spec.js.map +1 -1
- package/dist/schema/models/transformers/transformers.d.ts +7 -16
- package/dist/schema/models/transformers/transformers.d.ts.map +1 -1
- package/dist/schema/models/transformers/transformers.js +8 -13
- package/dist/schema/models/transformers/transformers.js.map +1 -1
- package/dist/schema/models/transformers/types.d.ts +14 -10
- package/dist/schema/models/transformers/types.d.ts.map +1 -1
- package/dist/schema/models/transformers/types.js +1 -1
- package/dist/schema/models/transformers/types.js.map +1 -1
- package/dist/schema/plugins/definition.d.ts +67 -95
- package/dist/schema/plugins/definition.d.ts.map +1 -1
- package/dist/schema/plugins/definition.js +8 -11
- package/dist/schema/plugins/definition.js.map +1 -1
- package/dist/schema/project-definition.d.ts +869 -4669
- package/dist/schema/project-definition.d.ts.map +1 -1
- package/dist/schema/project-definition.js +7 -9
- package/dist/schema/project-definition.js.map +1 -1
- package/dist/schema/settings/general.d.ts +3 -33
- package/dist/schema/settings/general.d.ts.map +1 -1
- package/dist/schema/settings/infrastructure.d.ts +2 -24
- package/dist/schema/settings/infrastructure.d.ts.map +1 -1
- package/dist/schema/settings/monorepo.d.ts +1 -15
- package/dist/schema/settings/monorepo.d.ts.map +1 -1
- package/dist/schema/settings/settings.d.ts +105 -242
- package/dist/schema/settings/settings.d.ts.map +1 -1
- package/dist/schema/settings/template-extractor.d.ts +1 -36
- package/dist/schema/settings/template-extractor.d.ts.map +1 -1
- package/dist/schema/settings/theme.d.ts +175 -259
- package/dist/schema/settings/theme.d.ts.map +1 -1
- package/dist/schema/settings/theme.js +1 -1
- package/dist/schema/settings/theme.js.map +1 -1
- package/dist/tools/model-merger/model-merger.d.ts +28 -28
- package/dist/tools/model-merger/model-merger.d.ts.map +1 -1
- package/dist/tools/model-merger/model-merger.js +5 -2
- package/dist/tools/model-merger/model-merger.js.map +1 -1
- package/dist/utils/theme.d.ts.map +1 -1
- package/dist/utils/theme.js +3 -4
- package/dist/utils/theme.js.map +1 -1
- package/dist/web/hooks/use-definition-schema.d.ts +9 -2
- package/dist/web/hooks/use-definition-schema.d.ts.map +1 -1
- package/dist/web/hooks/use-definition-schema.js +7 -1
- package/dist/web/hooks/use-definition-schema.js.map +1 -1
- package/package.json +7 -7
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect-refs.d.ts","sourceRoot":"","sources":["../../src/references/collect-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAE1B,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAQtB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC;;OAEG;IACH,UAAU,EAAE,6BAA6B,EAAE,CAAC;IAC5C;;OAEG;IACH,KAAK,EAAE,wBAAwB,EAAE,CAAC;CACnC;AA4ED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAQzD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DefinitionReferenceMarker, REF_ANNOTATIONS_MARKER_SYMBOL, } from './markers.js';
|
|
2
|
+
function collectRefAnnotationsRecursive(pathPrefix, value) {
|
|
3
|
+
if (value === undefined || value === null)
|
|
4
|
+
return undefined;
|
|
5
|
+
if (value instanceof DefinitionReferenceMarker) {
|
|
6
|
+
return {
|
|
7
|
+
entities: [],
|
|
8
|
+
references: [
|
|
9
|
+
{ ...value.reference, path: [...pathPrefix, ...value.reference.path] },
|
|
10
|
+
],
|
|
11
|
+
slots: [],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const collected = {
|
|
15
|
+
entities: [],
|
|
16
|
+
references: [],
|
|
17
|
+
slots: [],
|
|
18
|
+
};
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
for (const [i, element] of value.entries()) {
|
|
21
|
+
const childCollected = collectRefAnnotationsRecursive([...pathPrefix, i], element);
|
|
22
|
+
if (childCollected) {
|
|
23
|
+
collected.entities.push(...childCollected.entities);
|
|
24
|
+
collected.references.push(...childCollected.references);
|
|
25
|
+
collected.slots.push(...childCollected.slots);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return collected;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'object') {
|
|
31
|
+
if (REF_ANNOTATIONS_MARKER_SYMBOL in value) {
|
|
32
|
+
const annotations = value[REF_ANNOTATIONS_MARKER_SYMBOL];
|
|
33
|
+
collected.entities.push(...annotations.entities.map((entity) => ({
|
|
34
|
+
...entity,
|
|
35
|
+
path: [...pathPrefix, ...entity.path],
|
|
36
|
+
})));
|
|
37
|
+
collected.references.push(...annotations.references.map((reference) => ({
|
|
38
|
+
...reference,
|
|
39
|
+
path: [...pathPrefix, ...reference.path],
|
|
40
|
+
})));
|
|
41
|
+
collected.slots.push(...annotations.slots.map((slot) => ({
|
|
42
|
+
...slot,
|
|
43
|
+
path: [...pathPrefix, ...slot.path],
|
|
44
|
+
})));
|
|
45
|
+
}
|
|
46
|
+
for (const [key, childValue] of Object.entries(value)) {
|
|
47
|
+
if (typeof key !== 'string')
|
|
48
|
+
continue;
|
|
49
|
+
const childCollected = collectRefAnnotationsRecursive([...pathPrefix, key], childValue);
|
|
50
|
+
if (childCollected) {
|
|
51
|
+
collected.entities.push(...childCollected.entities);
|
|
52
|
+
collected.references.push(...childCollected.references);
|
|
53
|
+
collected.slots.push(...childCollected.slots);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return collected;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
export function collectRefs(value) {
|
|
61
|
+
return (collectRefAnnotationsRecursive([], value) ?? {
|
|
62
|
+
entities: [],
|
|
63
|
+
references: [],
|
|
64
|
+
slots: [],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=collect-refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect-refs.js","sourceRoot":"","sources":["../../src/references/collect-refs.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,cAAc,CAAC;AAoBtB,SAAS,8BAA8B,CACrC,UAAyB,EACzB,KAAc;IAEd,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5D,IAAI,KAAK,YAAY,yBAAyB,EAAE,CAAC;QAC/C,OAAO;YACL,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE;gBACV,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;aACvE;YACD,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,KAAK,EAAE,EAAE;KACO,CAAC;IACnB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3C,MAAM,cAAc,GAAG,8BAA8B,CACnD,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC,EAClB,OAAO,CACR,CAAC;YACF,IAAI,cAAc,EAAE,CAAC;gBACnB,SAAS,CAAC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AAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,IAAI,OAAO,GAAG,KAAK,QAAQ;gBAAE,SAAS;YACtC,MAAM,cAAc,GAAG,8BAA8B,CACnD,CAAC,GAAG,UAAU,EAAE,GAAG,CAAC,EACpB,UAAU,CACX,CAAC;YACF,IAAI,cAAc,EAAE,CAAC;gBACnB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;gBACpD,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;gBACxD,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,8BAA8B,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI;QAC3C,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,KAAK,EAAE,EAAE;KACV,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
interface ContextValue {
|
|
5
|
-
context: string;
|
|
6
|
-
}
|
|
7
|
-
type PathInputOrContext<Type> = PathInput<Type> | ContextValue;
|
|
1
|
+
import type { TuplePaths } from '@baseplate-dev/utils';
|
|
2
|
+
import type { RefContextSlot } from './ref-context-slot.js';
|
|
3
|
+
import type { DefinitionEntity, DefinitionEntityType, DefinitionReference } from './types.js';
|
|
8
4
|
/**
|
|
9
5
|
* Allows the caller to resolve the name of an entity, optionally providing a
|
|
10
6
|
* map of entity ids that need to be resolved prior to resolving the entity's
|
|
@@ -37,186 +33,60 @@ export declare function createDefinitionEntityNameResolver<TEntityIds extends Re
|
|
|
37
33
|
* @template TPath - The type representing a path in TInput (e.g. a dot-separated string); defaults to undefined.
|
|
38
34
|
* @template TIdKey - The key type for the entity's id; defaults to "id".
|
|
39
35
|
*/
|
|
40
|
-
interface DefinitionEntityInputBase<TInput, TEntityType extends DefinitionEntityType,
|
|
36
|
+
interface DefinitionEntityInputBase<TInput, TEntityType extends DefinitionEntityType, TIdPath extends TuplePaths<TInput> | undefined = undefined> {
|
|
41
37
|
/** The entity type definition. */
|
|
42
38
|
type: TEntityType;
|
|
43
|
-
/** Optional dot-separated string representing the location of the entity within the input. */
|
|
44
|
-
path?: TPath;
|
|
45
39
|
/** Optional path key used to store the entity's id; if not provided, the id is assumed to be under the entity's path with key "id". */
|
|
46
|
-
idPath?:
|
|
40
|
+
idPath?: TIdPath;
|
|
47
41
|
/** Optional function used to get the name resolver from the input data. Otherwise, the entity's name is assumed to be under the entity's path with key "name". */
|
|
48
42
|
getNameResolver?: (value: TInput) => DefinitionEntityNameResolver<any> | string;
|
|
49
|
-
/** Optional context
|
|
50
|
-
|
|
43
|
+
/** Optional ref context slot that this entity provides. Registers this entity's path in a shared context. */
|
|
44
|
+
provides?: RefContextSlot<TEntityType>;
|
|
51
45
|
}
|
|
52
46
|
/**
|
|
53
47
|
* Entity input when a parent reference is required.
|
|
54
48
|
*/
|
|
55
|
-
interface DefinitionEntityInputWithParent<TInput, TEntityType extends DefinitionEntityType,
|
|
56
|
-
|
|
49
|
+
interface DefinitionEntityInputWithParent<TInput, TEntityType extends DefinitionEntityType, TIdPath extends TuplePaths<TInput> | undefined = undefined> extends DefinitionEntityInputBase<TInput, TEntityType, TIdPath> {
|
|
50
|
+
/** The slot from which to resolve the parent entity path. */
|
|
51
|
+
parentSlot: RefContextSlot<NonNullable<TEntityType['parentType']>>;
|
|
57
52
|
}
|
|
58
53
|
/**
|
|
59
54
|
* Entity input when no parent reference is expected.
|
|
60
55
|
*/
|
|
61
|
-
interface DefinitionEntityInputWithoutParent<TInput, TEntityType extends DefinitionEntityType,
|
|
62
|
-
|
|
56
|
+
interface DefinitionEntityInputWithoutParent<TInput, TEntityType extends DefinitionEntityType, TIdPath extends TuplePaths<TInput> | undefined = undefined> extends DefinitionEntityInputBase<TInput, TEntityType, TIdPath> {
|
|
57
|
+
parentSlot?: never;
|
|
63
58
|
}
|
|
64
59
|
/**
|
|
65
60
|
* Depending on the entity type’s requirements, this type resolves to either the
|
|
66
61
|
* with- or without-parent version.
|
|
67
62
|
*/
|
|
68
|
-
export type DefinitionEntityInput<TInput, TEntityType extends DefinitionEntityType,
|
|
63
|
+
export type DefinitionEntityInput<TInput, TEntityType extends DefinitionEntityType, TIdPath extends TuplePaths<TInput> | undefined = undefined> = TEntityType['parentType'] extends undefined ? DefinitionEntityInputWithoutParent<TInput, TEntityType, TIdPath> : DefinitionEntityInputWithParent<TInput, TEntityType, TIdPath>;
|
|
69
64
|
/**
|
|
70
65
|
* Base interface for defining a reference input.
|
|
71
66
|
* @template TInput - The overall input type.
|
|
72
67
|
* @template TEntityType - The entity type.
|
|
73
68
|
*/
|
|
74
|
-
interface DefinitionReferenceInputBase<
|
|
69
|
+
interface DefinitionReferenceInputBase<TEntityType extends DefinitionEntityType> extends Pick<DefinitionReference, 'onDelete'> {
|
|
75
70
|
type: TEntityType;
|
|
76
|
-
path
|
|
77
|
-
|
|
71
|
+
/** Optional ref context slot that this reference provides. Registers this reference's path in a shared context. */
|
|
72
|
+
provides?: RefContextSlot<TEntityType>;
|
|
78
73
|
}
|
|
79
|
-
interface DefinitionReferenceInputWithParent<
|
|
80
|
-
|
|
74
|
+
interface DefinitionReferenceInputWithParent<TEntityType extends DefinitionEntityType> extends DefinitionReferenceInputBase<TEntityType> {
|
|
75
|
+
/** The slot from which to resolve the parent entity path. */
|
|
76
|
+
parentSlot: RefContextSlot<NonNullable<TEntityType['parentType']>>;
|
|
81
77
|
}
|
|
82
|
-
interface DefinitionReferenceInputWithoutParent<
|
|
83
|
-
|
|
78
|
+
interface DefinitionReferenceInputWithoutParent<TEntityType extends DefinitionEntityType> extends DefinitionReferenceInputBase<TEntityType> {
|
|
79
|
+
parentSlot?: never;
|
|
84
80
|
}
|
|
85
81
|
/**
|
|
86
82
|
* Depending on the entity type’s requirements, defines the input required to create a definition reference.
|
|
87
83
|
*/
|
|
88
|
-
export type DefinitionReferenceInput<
|
|
84
|
+
export type DefinitionReferenceInput<TEntityType extends DefinitionEntityType> = TEntityType['parentType'] extends undefined ? DefinitionReferenceInputWithoutParent<TEntityType> : DefinitionReferenceInputWithParent<TEntityType>;
|
|
89
85
|
/**
|
|
90
86
|
* Entity with a name resolver.
|
|
91
87
|
*/
|
|
92
|
-
interface DefinitionEntityWithNameResolver extends Omit<DefinitionEntity, 'name'> {
|
|
93
|
-
nameResolver: DefinitionEntityNameResolver;
|
|
94
|
-
}
|
|
95
|
-
export interface RefBuilderContext {
|
|
96
|
-
pathMap: Map<string, {
|
|
97
|
-
path: ReferencePath;
|
|
98
|
-
type: DefinitionEntityType;
|
|
99
|
-
}>;
|
|
100
|
-
}
|
|
101
|
-
export interface ZodRefBuilderInterface<TInput> {
|
|
102
|
-
addReference<TEntityType extends DefinitionEntityType>(reference: DefinitionReferenceInput<TInput, TEntityType>): void;
|
|
103
|
-
addEntity<TEntityType extends DefinitionEntityType, TPath extends PathInput<TInput> | undefined = undefined, TIDKey extends string | PathInput<TInput> = 'id'>(entity: DefinitionEntityInput<TInput, TEntityType, TPath, TIDKey>): void;
|
|
104
|
-
addPathToContext(path: PathInput<TInput>, type: DefinitionEntityType, context: string): void;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* DefinitionRefBuilder is responsible for constructing reference paths, and registering
|
|
108
|
-
* references and entities as defined in a Zod schema.
|
|
109
|
-
*
|
|
110
|
-
* The builder uses a prefix (usually the current parsing path) and context (a
|
|
111
|
-
* shared map for resolving relative references) to build complete reference paths.
|
|
112
|
-
*
|
|
113
|
-
* @template TInput - The type of the input data being parsed.
|
|
114
|
-
*/
|
|
115
|
-
export declare class DefinitionRefBuilder<TInput> implements ZodRefBuilderInterface<TInput> {
|
|
116
|
-
readonly references: DefinitionReference[];
|
|
117
|
-
readonly entitiesWithNameResolver: DefinitionEntityWithNameResolver[];
|
|
118
|
-
readonly pathPrefix: ReferencePath;
|
|
119
|
-
readonly context: RefBuilderContext;
|
|
120
|
-
readonly pathMap: Map<string, {
|
|
121
|
-
path: ReferencePath;
|
|
122
|
-
type: DefinitionEntityType;
|
|
123
|
-
}>;
|
|
124
|
-
readonly data: TInput;
|
|
125
|
-
/**
|
|
126
|
-
* Creates a new builder instance.
|
|
127
|
-
* @param pathPrefix - The starting path for all references.
|
|
128
|
-
* @param context - Shared context including a path map and deserialize flag.
|
|
129
|
-
* @param data - The data being parsed.
|
|
130
|
-
*/
|
|
131
|
-
constructor(pathPrefix: ReferencePath, context: RefBuilderContext, data: TInput);
|
|
132
|
-
/**
|
|
133
|
-
* Converts a dot-separated string path into an array of keys.
|
|
134
|
-
* @param path - A string (e.g. "a.b.0.c") representing the path.
|
|
135
|
-
* @returns An array of keys (numbers for numeric strings, otherwise strings).
|
|
136
|
-
*/
|
|
137
|
-
protected _constructPathWithoutPrefix(path: PathInput<TInput> | undefined): ReferencePath;
|
|
138
|
-
/**
|
|
139
|
-
* Prepends the builder's path prefix to the provided path.
|
|
140
|
-
* @param path - The dot-separated path string.
|
|
141
|
-
* @returns The complete reference path as an array.
|
|
142
|
-
*/
|
|
143
|
-
protected _constructPath(path: PathInput<TInput> | undefined): ReferencePath;
|
|
144
|
-
/**
|
|
145
|
-
* Constructs a reference path that may be defined directly as a string or indirectly
|
|
146
|
-
* via a context object. If a context object is provided, the function looks up the
|
|
147
|
-
* actual path from the builder's context.
|
|
148
|
-
*
|
|
149
|
-
* @param path - Either a dot-separated string path or an object with a context key.
|
|
150
|
-
* @param expectedEntityType - The entity type expected for this context.
|
|
151
|
-
* @returns The resolved reference path.
|
|
152
|
-
* @throws If the context cannot be found or its type does not match.
|
|
153
|
-
*/
|
|
154
|
-
protected _constructPathWithContext(path: PathInputOrContext<TInput>, expectedEntityType: DefinitionEntityType): ReferencePath;
|
|
155
|
-
/**
|
|
156
|
-
* Registers a reference based on the provided input definition.
|
|
157
|
-
*
|
|
158
|
-
* Flow:
|
|
159
|
-
* 1. Validate that the parent path is provided if required (and vice versa).
|
|
160
|
-
* 2. Compute the reference path; if the path is empty, use the entire data.
|
|
161
|
-
* 3. If the referenced value is null or undefined, skip adding the reference.
|
|
162
|
-
* 4. Otherwise, add the reference and, if requested, register its context.
|
|
163
|
-
*
|
|
164
|
-
* @param reference - The reference definition.
|
|
165
|
-
* @throws If parent path usage is incorrect.
|
|
166
|
-
*/
|
|
167
|
-
addReference<TEntityType extends DefinitionEntityType>(reference: DefinitionReferenceInput<TInput, TEntityType>): void;
|
|
168
|
-
/**
|
|
169
|
-
* Registers an entity based on the provided definition.
|
|
170
|
-
*
|
|
171
|
-
* Flow:
|
|
172
|
-
* 1. Validate that not both a name and a name reference path are provided.
|
|
173
|
-
* 2. Compute the full entity path.
|
|
174
|
-
* 3. Resolve the entity ID:
|
|
175
|
-
* - Use the provided idPath if available; otherwise, default to appending 'id'
|
|
176
|
-
* to the entity path.
|
|
177
|
-
* - If no id is found, generate a new one.
|
|
178
|
-
* 4. Resolve the entity name:
|
|
179
|
-
* - Use the provided resolveName if available; otherwise, default to using the
|
|
180
|
-
* name path.
|
|
181
|
-
* 5. Register the entity in either the direct entities list or the name-ref list.
|
|
182
|
-
* 6. Optionally, add the entity’s id path to the shared context.
|
|
183
|
-
*
|
|
184
|
-
* @param entity - The entity definition.
|
|
185
|
-
* @throws If both name and nameRefPath are provided or if no name is resolved.
|
|
186
|
-
*/
|
|
187
|
-
addEntity<TEntityType extends DefinitionEntityType, TPath extends PathInput<TInput> | undefined = undefined, TIDKey extends string | PathInput<TInput> = 'id'>(entity: DefinitionEntityInput<TInput, TEntityType, TPath, TIDKey>): void;
|
|
188
|
-
/**
|
|
189
|
-
* Registers a given path into the builder's context map.
|
|
190
|
-
* @param path - The full reference path.
|
|
191
|
-
* @param type - The entity type associated with the path.
|
|
192
|
-
* @param context - A unique key to identify this context.
|
|
193
|
-
* @throws If the context key is already registered.
|
|
194
|
-
*/
|
|
195
|
-
_addPathToContext(path: ReferencePath, type: DefinitionEntityType, context: string): void;
|
|
196
|
-
/**
|
|
197
|
-
* Convenience method that builds a full path from a dot-separated string and
|
|
198
|
-
* adds it to the context.
|
|
199
|
-
* @param path - The dot-separated string path.
|
|
200
|
-
* @param type - The entity type.
|
|
201
|
-
* @param context - The context key.
|
|
202
|
-
*/
|
|
203
|
-
addPathToContext(path: PathInput<TInput>, type: DefinitionEntityType, context: string): void;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Function type for builder functions that register references and entities.
|
|
207
|
-
*
|
|
208
|
-
* @template Input - The input data type.
|
|
209
|
-
*/
|
|
210
|
-
export type ZodBuilderFunction<Input> = (builder: ZodRefBuilderInterface<Input>, data: Input) => void;
|
|
211
|
-
/**
|
|
212
|
-
* Payload returned after parsing, containing the data, references, and entities.
|
|
213
|
-
*
|
|
214
|
-
* @template TData - The type of the parsed data.
|
|
215
|
-
*/
|
|
216
|
-
export interface ZodRefPayload<TData> {
|
|
217
|
-
data: TData;
|
|
218
|
-
references: DefinitionReference[];
|
|
219
|
-
entitiesWithNameResolver: DefinitionEntityWithNameResolver[];
|
|
88
|
+
export interface DefinitionEntityWithNameResolver extends Omit<DefinitionEntity, 'name'> {
|
|
89
|
+
nameResolver: DefinitionEntityNameResolver | string;
|
|
220
90
|
}
|
|
221
91
|
export {};
|
|
222
92
|
//# sourceMappingURL=definition-ref-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition-ref-builder.d.ts","sourceRoot":"","sources":["../../src/references/definition-ref-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"definition-ref-builder.d.ts","sourceRoot":"","sources":["../../src/references/definition-ref-builder.ts"],"names":[],"m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,4BAA4B,CAAC,WAAW,CAAC;IACjD,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,CAAC,WAAW,SAAS,oBAAoB,IAC3E,WAAW,CAAC,YAAY,CAAC,SAAS,SAAS,GACvC,qCAAqC,CAAC,WAAW,CAAC,GAClD,kCAAkC,CAAC,WAAW,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,gCACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IACtC,YAAY,EAAE,4BAA4B,GAAG,MAAM,CAAC;CACrD"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { get } from 'es-toolkit/compat';
|
|
2
|
-
import { stripRefMarkers } from './strip-ref-markers.js';
|
|
3
1
|
/**
|
|
4
2
|
* Creates a definition entity name resolver.
|
|
5
3
|
* @param entityNameResolver - The entity name resolver.
|
|
@@ -8,209 +6,4 @@ import { stripRefMarkers } from './strip-ref-markers.js';
|
|
|
8
6
|
export function createDefinitionEntityNameResolver(entityNameResolver) {
|
|
9
7
|
return entityNameResolver;
|
|
10
8
|
}
|
|
11
|
-
/**
|
|
12
|
-
* DefinitionRefBuilder is responsible for constructing reference paths, and registering
|
|
13
|
-
* references and entities as defined in a Zod schema.
|
|
14
|
-
*
|
|
15
|
-
* The builder uses a prefix (usually the current parsing path) and context (a
|
|
16
|
-
* shared map for resolving relative references) to build complete reference paths.
|
|
17
|
-
*
|
|
18
|
-
* @template TInput - The type of the input data being parsed.
|
|
19
|
-
*/
|
|
20
|
-
export class DefinitionRefBuilder {
|
|
21
|
-
references;
|
|
22
|
-
entitiesWithNameResolver;
|
|
23
|
-
pathPrefix;
|
|
24
|
-
context;
|
|
25
|
-
pathMap;
|
|
26
|
-
data;
|
|
27
|
-
/**
|
|
28
|
-
* Creates a new builder instance.
|
|
29
|
-
* @param pathPrefix - The starting path for all references.
|
|
30
|
-
* @param context - Shared context including a path map and deserialize flag.
|
|
31
|
-
* @param data - The data being parsed.
|
|
32
|
-
*/
|
|
33
|
-
constructor(pathPrefix, context, data) {
|
|
34
|
-
this.references = [];
|
|
35
|
-
this.entitiesWithNameResolver = [];
|
|
36
|
-
this.pathPrefix = pathPrefix;
|
|
37
|
-
this.context = context;
|
|
38
|
-
this.pathMap = new Map();
|
|
39
|
-
this.data = data;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Converts a dot-separated string path into an array of keys.
|
|
43
|
-
* @param path - A string (e.g. "a.b.0.c") representing the path.
|
|
44
|
-
* @returns An array of keys (numbers for numeric strings, otherwise strings).
|
|
45
|
-
*/
|
|
46
|
-
_constructPathWithoutPrefix(path) {
|
|
47
|
-
if (!path)
|
|
48
|
-
return [];
|
|
49
|
-
const pathComponents = path
|
|
50
|
-
.split('.')
|
|
51
|
-
.map((key) => (/^[0-9]+$/.test(key) ? Number.parseInt(key, 10) : key));
|
|
52
|
-
return pathComponents;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Prepends the builder's path prefix to the provided path.
|
|
56
|
-
* @param path - The dot-separated path string.
|
|
57
|
-
* @returns The complete reference path as an array.
|
|
58
|
-
*/
|
|
59
|
-
_constructPath(path) {
|
|
60
|
-
if (!path)
|
|
61
|
-
return this.pathPrefix;
|
|
62
|
-
return [...this.pathPrefix, ...this._constructPathWithoutPrefix(path)];
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Constructs a reference path that may be defined directly as a string or indirectly
|
|
66
|
-
* via a context object. If a context object is provided, the function looks up the
|
|
67
|
-
* actual path from the builder's context.
|
|
68
|
-
*
|
|
69
|
-
* @param path - Either a dot-separated string path or an object with a context key.
|
|
70
|
-
* @param expectedEntityType - The entity type expected for this context.
|
|
71
|
-
* @returns The resolved reference path.
|
|
72
|
-
* @throws If the context cannot be found or its type does not match.
|
|
73
|
-
*/
|
|
74
|
-
_constructPathWithContext(path, expectedEntityType) {
|
|
75
|
-
if (typeof path === 'string') {
|
|
76
|
-
return this._constructPath(path);
|
|
77
|
-
}
|
|
78
|
-
// Lookup the context for the given key.
|
|
79
|
-
const pathContext = this.context.pathMap.get(path.context);
|
|
80
|
-
if (!pathContext) {
|
|
81
|
-
throw new Error(`Could not find context for ${path.context} from ${this.pathPrefix.join('.')}`);
|
|
82
|
-
}
|
|
83
|
-
if (pathContext.type !== expectedEntityType) {
|
|
84
|
-
throw new Error(`Attempted to retrieve context for ${path.context} from ${this.pathPrefix.join('.')} expecting ${expectedEntityType.name}, but found ${pathContext.type.name}`);
|
|
85
|
-
}
|
|
86
|
-
return pathContext.path;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Registers a reference based on the provided input definition.
|
|
90
|
-
*
|
|
91
|
-
* Flow:
|
|
92
|
-
* 1. Validate that the parent path is provided if required (and vice versa).
|
|
93
|
-
* 2. Compute the reference path; if the path is empty, use the entire data.
|
|
94
|
-
* 3. If the referenced value is null or undefined, skip adding the reference.
|
|
95
|
-
* 4. Otherwise, add the reference and, if requested, register its context.
|
|
96
|
-
*
|
|
97
|
-
* @param reference - The reference definition.
|
|
98
|
-
* @throws If parent path usage is incorrect.
|
|
99
|
-
*/
|
|
100
|
-
addReference(reference) {
|
|
101
|
-
if (!reference.type.parentType && reference.parentPath) {
|
|
102
|
-
throw new Error(`Parent path does nothing since reference does not have parent`);
|
|
103
|
-
}
|
|
104
|
-
if (reference.type.parentType && !reference.parentPath) {
|
|
105
|
-
throw new Error(`Parent path required if reference type has parent type`);
|
|
106
|
-
}
|
|
107
|
-
// Compute the path without prefix once.
|
|
108
|
-
const refPathWithoutPrefix = this._constructPathWithoutPrefix(reference.path);
|
|
109
|
-
// If the path is empty, use the entire data; otherwise, retrieve the value.
|
|
110
|
-
const refValue = refPathWithoutPrefix.length === 0
|
|
111
|
-
? this.data
|
|
112
|
-
: get(this.data, refPathWithoutPrefix);
|
|
113
|
-
if (refValue === undefined || refValue === null)
|
|
114
|
-
return;
|
|
115
|
-
const fullPath = this._constructPath(reference.path);
|
|
116
|
-
this.references.push({
|
|
117
|
-
type: reference.type,
|
|
118
|
-
path: fullPath,
|
|
119
|
-
parentPath: reference.parentPath &&
|
|
120
|
-
reference.type.parentType &&
|
|
121
|
-
this._constructPathWithContext(reference.parentPath, reference.type.parentType),
|
|
122
|
-
onDelete: reference.onDelete,
|
|
123
|
-
});
|
|
124
|
-
// Optionally, add this path to the shared context.
|
|
125
|
-
if (reference.addContext) {
|
|
126
|
-
this._addPathToContext(fullPath, reference.type, reference.addContext);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Registers an entity based on the provided definition.
|
|
131
|
-
*
|
|
132
|
-
* Flow:
|
|
133
|
-
* 1. Validate that not both a name and a name reference path are provided.
|
|
134
|
-
* 2. Compute the full entity path.
|
|
135
|
-
* 3. Resolve the entity ID:
|
|
136
|
-
* - Use the provided idPath if available; otherwise, default to appending 'id'
|
|
137
|
-
* to the entity path.
|
|
138
|
-
* - If no id is found, generate a new one.
|
|
139
|
-
* 4. Resolve the entity name:
|
|
140
|
-
* - Use the provided resolveName if available; otherwise, default to using the
|
|
141
|
-
* name path.
|
|
142
|
-
* 5. Register the entity in either the direct entities list or the name-ref list.
|
|
143
|
-
* 6. Optionally, add the entity’s id path to the shared context.
|
|
144
|
-
*
|
|
145
|
-
* @param entity - The entity definition.
|
|
146
|
-
* @throws If both name and nameRefPath are provided or if no name is resolved.
|
|
147
|
-
*/
|
|
148
|
-
addEntity(entity) {
|
|
149
|
-
// Build the full path for the entity.
|
|
150
|
-
const path = this._constructPath(entity.path);
|
|
151
|
-
// Resolve the id path: if provided use it; otherwise, assume the id is at "entity.path.id"
|
|
152
|
-
const idPath = entity.idPath
|
|
153
|
-
? this._constructPathWithoutPrefix(entity.idPath)
|
|
154
|
-
: [...this._constructPathWithoutPrefix(entity.path), 'id'];
|
|
155
|
-
const id = get(this.data, idPath);
|
|
156
|
-
if (!id) {
|
|
157
|
-
throw new Error(`No id found for entity ${entity.type.name}`);
|
|
158
|
-
}
|
|
159
|
-
if (!entity.type.isId(id)) {
|
|
160
|
-
throw new Error(`Invalid id: ${id} for entity ${entity.type.name}`);
|
|
161
|
-
}
|
|
162
|
-
// Resolve the name: if getNameResolver is provided, use it to build the name resolver; otherwise,
|
|
163
|
-
// use the default name resolver.
|
|
164
|
-
const getNameResolver = entity.getNameResolver ??
|
|
165
|
-
((value) => get(value, 'name'));
|
|
166
|
-
const nameResolver = getNameResolver(stripRefMarkers(this.data));
|
|
167
|
-
if (!nameResolver) {
|
|
168
|
-
throw new Error(`No name resolver found for entity ${entity.type.name} at ${path.join('.')}`);
|
|
169
|
-
}
|
|
170
|
-
// Base entity definition shared between regular entities and those with a name reference.
|
|
171
|
-
const entityBase = {
|
|
172
|
-
id,
|
|
173
|
-
type: entity.type,
|
|
174
|
-
path,
|
|
175
|
-
idPath: [...this.pathPrefix, ...idPath],
|
|
176
|
-
parentPath: entity.parentPath &&
|
|
177
|
-
entity.type.parentType &&
|
|
178
|
-
this._constructPathWithContext(entity.parentPath, entity.type.parentType),
|
|
179
|
-
};
|
|
180
|
-
this.entitiesWithNameResolver.push({
|
|
181
|
-
...entityBase,
|
|
182
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- needed to allow more specific generic typed to be put in here
|
|
183
|
-
nameResolver: typeof nameResolver === 'string'
|
|
184
|
-
? { resolveName: () => nameResolver }
|
|
185
|
-
: nameResolver,
|
|
186
|
-
});
|
|
187
|
-
// Optionally add the id path to the context.
|
|
188
|
-
if (entity.addContext) {
|
|
189
|
-
this._addPathToContext([...this.pathPrefix, ...idPath], entity.type, entity.addContext);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Registers a given path into the builder's context map.
|
|
194
|
-
* @param path - The full reference path.
|
|
195
|
-
* @param type - The entity type associated with the path.
|
|
196
|
-
* @param context - A unique key to identify this context.
|
|
197
|
-
* @throws If the context key is already registered.
|
|
198
|
-
*/
|
|
199
|
-
_addPathToContext(path, type, context) {
|
|
200
|
-
// For now, allow overriding contexts to maintain compatibility
|
|
201
|
-
this.pathMap.set(context, { path, type });
|
|
202
|
-
// Also register in the shared context for other builders to access
|
|
203
|
-
this.context.pathMap.set(context, { path, type });
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Convenience method that builds a full path from a dot-separated string and
|
|
207
|
-
* adds it to the context.
|
|
208
|
-
* @param path - The dot-separated string path.
|
|
209
|
-
* @param type - The entity type.
|
|
210
|
-
* @param context - The context key.
|
|
211
|
-
*/
|
|
212
|
-
addPathToContext(path, type, context) {
|
|
213
|
-
this._addPathToContext(this._constructPath(path), type, context);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
9
|
//# sourceMappingURL=definition-ref-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition-ref-builder.js","sourceRoot":"","sources":["../../src/references/definition-ref-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition-ref-builder.js","sourceRoot":"","sources":["../../src/references/definition-ref-builder.ts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAGhD,kBAA4D;IAE5D,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TypeOf, z } from 'zod';
|
|
2
1
|
import type { DefinitionSchemaCreator, DefinitionSchemaCreatorOptions } from '#src/schema/creator/types.js';
|
|
2
|
+
import type { def } from '#src/schema/index.js';
|
|
3
3
|
import type { ResolvedZodRefPayload } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Deserialize a schema with references using the new transform-based approach.
|
|
@@ -11,5 +11,5 @@ import type { ResolvedZodRefPayload } from './types.js';
|
|
|
11
11
|
* @param options - Options for the schema creator (excluding transformReferences)
|
|
12
12
|
* @returns The resolved payload with IDs instead of names
|
|
13
13
|
*/
|
|
14
|
-
export declare function deserializeSchemaWithTransformedReferences<T extends DefinitionSchemaCreator>(schemaCreator: T, input: unknown, options: Omit<DefinitionSchemaCreatorOptions, 'transformReferences'>): ResolvedZodRefPayload<
|
|
14
|
+
export declare function deserializeSchemaWithTransformedReferences<T extends DefinitionSchemaCreator>(schemaCreator: T, input: unknown, options: Omit<DefinitionSchemaCreatorOptions, 'transformReferences'>): ResolvedZodRefPayload<def.InferOutput<T>>;
|
|
15
15
|
//# sourceMappingURL=deserialize-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize-schema.d.ts","sourceRoot":"","sources":["../../src/references/deserialize-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deserialize-schema.d.ts","sourceRoot":"","sources":["../../src/references/deserialize-schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,KAAK,EAAoB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAQ1E;;;;;;;;;GASG;AACH,wBAAgB,0CAA0C,CACxD,CAAC,SAAS,uBAAuB,EAEjC,aAAa,EAAE,CAAC,EAChB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,IAAI,CAAC,8BAA8B,EAAE,qBAAqB,CAAC,GACnE,qBAAqB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAY3C"}
|
|
@@ -31,6 +31,9 @@ export function deserializeSchemaWithTransformedReferences(schemaCreator, input,
|
|
|
31
31
|
*/
|
|
32
32
|
function resolveReferencesToIds(payload) {
|
|
33
33
|
const { references, entities, data } = payload;
|
|
34
|
+
if (typeof data !== 'object' || data === null) {
|
|
35
|
+
throw new TypeError('Data is not an object');
|
|
36
|
+
}
|
|
34
37
|
// check we don't have more entities than IDs
|
|
35
38
|
const entitiesById = groupBy(entities, (entity) => entity.id);
|
|
36
39
|
const duplicateEntityIds = Object.values(entitiesById).filter((e) => e.length > 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize-schema.js","sourceRoot":"","sources":["../../src/references/deserialize-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deserialize-schema.js","sourceRoot":"","sources":["../../src/references/deserialize-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAU7C,OAAO,EAAE,oCAAoC,EAAE,MAAM,mCAAmC,CAAC;AAEzF,SAAS,uBAAuB,CAAC,IAAY,EAAE,QAAiB;IAC9D,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,0CAA0C,CAGxD,aAAgB,EAChB,KAAc,EACd,OAAoE;IAEpE,MAAM,OAAO,GAAG,oCAAoC,CAClD,aAAa,EACb,KAAK,EACL,OAAO,EACP;QACE,2BAA2B,EAAE,IAAI;KAClC,CACF,CAAC;IAEF,yDAAyD;IACzD,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAC7B,OAAiC;IAEjC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAE/C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAC/C,CAAC;IAED,6CAA6C;IAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE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;QACnD,CAAC,CAAC,CAAC;QAEL,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAW,CAAC;YAC3C,mFAAmF;YACnF,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,IAAK,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU,CAAY,CAAC;YACzE,MAAM,YAAY,GAAG,uBAAuB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAE7D,MAAM,cAAc,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;YAC5D,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CACb,gCAAgC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAChD,GAAG,CAAC,IAAI,CAAC,IACX,IAAI,YAAY,GAAG,CACpB,CAAC;YACJ,CAAC;YACD,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TuplePaths } from '@baseplate-dev/utils';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { DefinitionEntityType } from '#src/index.js';
|
|
4
4
|
import type { DefinitionSchemaCreatorOptions } from '#src/schema/index.js';
|
|
5
|
-
import type { DefinitionEntityInput, DefinitionReferenceInput
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
5
|
+
import type { DefinitionEntityInput, DefinitionReferenceInput } from './definition-ref-builder.js';
|
|
6
|
+
import type { RefContextSlotDefinition, RefContextSlotMap } from './ref-context-slot.js';
|
|
7
|
+
type ZodTypeWithOptional<T extends z.ZodType> = T extends z.ZodOptional ? z.ZodOptional<z.ZodType<z.output<T>, z.input<T>>> : T extends z.ZodDefault ? z.ZodDefault<z.ZodType<z.output<T>, z.input<T>>> : T extends z.ZodPrefault ? z.ZodPrefault<z.ZodType<z.output<T>, z.input<T>>> : z.ZodType<z.output<T>, z.input<T>>;
|
|
8
|
+
export type WithRefType = <TEntityType extends DefinitionEntityType>(reference: DefinitionReferenceInput<TEntityType>) => z.ZodType<string, string>;
|
|
9
|
+
export type WithEntType = <TType extends z.ZodType, TEntityType extends DefinitionEntityType, TIdPath extends TuplePaths<z.output<TType>> | undefined = undefined>(schema: TType, entity: DefinitionEntityInput<z.output<TType>, TEntityType, TIdPath>) => ZodTypeWithOptional<TType>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates ref context slots for use within a schema definition.
|
|
12
|
+
* Slots provide type-safe context for parent-child entity relationships.
|
|
13
|
+
*/
|
|
14
|
+
export type RefContextType = <TSlotDef extends RefContextSlotDefinition, TSchema extends z.ZodType>(slotDefinition: TSlotDef, schemaBuilder: (slots: RefContextSlotMap<TSlotDef>) => TSchema) => ZodTypeWithOptional<TSchema>;
|
|
10
15
|
export declare function extendParserContextWithRefs({ transformReferences, }: DefinitionSchemaCreatorOptions): {
|
|
11
16
|
withRef: WithRefType;
|
|
12
17
|
withEnt: WithEntType;
|
|
13
|
-
|
|
18
|
+
refContext: RefContextType;
|
|
14
19
|
};
|
|
15
20
|
export {};
|
|
16
21
|
//# sourceMappingURL=extend-parser-context-with-refs.d.ts.map
|