@baseplate-dev/plugin-auth 3.0.1 → 3.0.3
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/auth/core/components/auth-definition-editor.js +1 -1
- package/dist/auth/core/components/auth-definition-editor.js.map +1 -1
- package/dist/auth/core/node.d.ts.map +1 -1
- package/dist/auth/core/node.js +2 -1
- package/dist/auth/core/node.js.map +1 -1
- package/dist/auth/core/schema/plugin-definition.d.ts +6 -39
- package/dist/auth/core/schema/plugin-definition.d.ts.map +1 -1
- package/dist/auth/core/schema/roles/schema.d.ts +7 -27
- package/dist/auth/core/schema/roles/schema.d.ts.map +1 -1
- package/dist/auth/core/schema/roles/schema.js +1 -1
- package/dist/auth/core/schema/roles/schema.js.map +1 -1
- package/dist/auth0/core/components/auth0-definition-editor.js +1 -1
- package/dist/auth0/core/components/auth0-definition-editor.js.map +1 -1
- package/dist/auth0/core/schema/plugin-definition.d.ts +1 -1
- package/dist/auth0/core/schema/plugin-definition.d.ts.map +1 -1
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts +1 -1
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js +1 -1
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js.map +1 -1
- package/dist/auth0/generators/react/auth0-apollo/templates/auth-link.ts +1 -1
- package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts +1 -1
- package/dist/auth0/generators/react/auth0-hooks/templates/src/hooks/use-current-user.ts +3 -2
- package/dist/auth0/generators/react/auth0-pages/auth0-pages.generator.d.ts +1 -1
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts +1 -1
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.js +1 -1
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.js.map +1 -1
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js +1 -1
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js.map +1 -1
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.tsx +1 -1
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.js +1 -1
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.js.map +1 -1
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js +1 -1
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js.map +1 -1
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.tsx +1 -1
- package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +1 -1
- package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.js +1 -1
- package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.js.map +1 -1
- package/dist/local-auth/admin/schema/manage-role-action.d.ts +5 -11
- package/dist/local-auth/admin/schema/manage-role-action.d.ts.map +1 -1
- package/dist/local-auth/admin/schema/reset-password-action.d.ts +5 -11
- package/dist/local-auth/admin/schema/reset-password-action.d.ts.map +1 -1
- package/dist/local-auth/admin/schema/roles-column.d.ts +1 -10
- package/dist/local-auth/admin/schema/roles-column.d.ts.map +1 -1
- package/dist/local-auth/core/components/local-auth-definition-editor.js +1 -1
- package/dist/local-auth/core/components/local-auth-definition-editor.js.map +1 -1
- package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.d.ts +2 -2
- package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.js +2 -1
- package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.js.map +1 -1
- package/dist/local-auth/core/generators/auth-apollo/templates/session-error-link.js +12 -7
- package/dist/local-auth/core/generators/auth-apollo/templates/session-error-link.js.map +1 -1
- package/dist/local-auth/core/generators/auth-apollo/templates/session-error-link.ts +11 -9
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js +0 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.ts +0 -1
- package/dist/local-auth/core/generators/auth-hooks/auth-hooks.generator.d.ts +2 -2
- package/dist/local-auth/core/generators/auth-hooks/generated/index.d.ts +2 -2
- package/dist/local-auth/core/generators/auth-hooks/generated/template-renderers.d.ts +1 -1
- package/dist/local-auth/core/generators/auth-hooks/generated/typed-templates.d.ts +2 -2
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-current-user.js +1 -1
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-current-user.js.map +1 -1
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-current-user.ts +1 -1
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.js +1 -1
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.js.map +1 -1
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.ts +1 -1
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +4 -0
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js.map +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js.map +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.ts +1 -1
- package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +2 -2
- package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +3 -3
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +1 -1
- package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +4 -4
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.d.ts +3 -11
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +2 -5
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js.map +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +2 -5
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.d.ts +3 -11
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js +2 -5
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js.map +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.tsx +2 -5
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/route.d.ts +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/route.d.ts.map +1 -1
- package/dist/local-auth/core/generators/react-auth/react-auth.generator.d.ts +1 -1
- package/dist/local-auth/core/generators/react-session/generated/index.d.ts +1 -1
- package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.d.ts +3 -3
- package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.js +2 -2
- package/dist/local-auth/core/generators/react-session/generated/typed-templates.js +1 -1
- package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +2 -2
- package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.d.ts.map +1 -1
- package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js +17 -1
- package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js.map +1 -1
- package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.tsx +18 -1
- package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.d.ts.map +1 -1
- package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js +8 -2
- package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js.map +1 -1
- package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.ts +8 -2
- package/dist/local-auth/core/schema/plugin-definition.d.ts +3 -9
- package/dist/local-auth/core/schema/plugin-definition.d.ts.map +1 -1
- package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js +1 -1
- package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js.map +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/placeholder-auth-hooks.generator.d.ts +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.d.ts.map +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.js +2 -2
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.js.map +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.ts +3 -2
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/auth-module.generator.d.ts +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-react-auth/react-auth.generator.d.ts +1 -1
- package/dist/placeholder-auth/core/schema/plugin-definition.d.ts +1 -1
- package/dist/placeholder-auth/core/schema/plugin-definition.d.ts.map +1 -1
- package/dist/web/assets/{__federation_expose_auth0CoreCommon-xk1Gj1WU.js → __federation_expose_auth0CoreCommon-DxPG_Wc0.js} +3 -3
- package/dist/web/assets/{__federation_expose_auth0CoreCommon-xk1Gj1WU.js.map → __federation_expose_auth0CoreCommon-DxPG_Wc0.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_auth0CoreWeb-CAiUkJwE.js → __federation_expose_auth0CoreWeb-B9jV1EyN.js} +7 -7
- package/dist/web/assets/__federation_expose_auth0CoreWeb-B9jV1EyN.js.map +1 -0
- package/dist/web/assets/{__federation_expose_authCoreCommon-K21saJbW.js → __federation_expose_authCoreCommon-Cxa_7fkO.js} +3 -3
- package/dist/web/assets/{__federation_expose_authCoreCommon-K21saJbW.js.map → __federation_expose_authCoreCommon-Cxa_7fkO.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_authCoreWeb-L7mv-Kl9.js → __federation_expose_authCoreWeb-CTQI1rXb.js} +9 -9
- package/dist/web/assets/__federation_expose_authCoreWeb-CTQI1rXb.js.map +1 -0
- package/dist/web/assets/{__federation_expose_local-authAdminCommon-BcMGRCCu.js → __federation_expose_local-authAdminCommon-C0_ovnDb.js} +2 -2
- package/dist/web/assets/{__federation_expose_local-authAdminCommon-BcMGRCCu.js.map → __federation_expose_local-authAdminCommon-C0_ovnDb.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_local-authAdminWeb-DUY1rKEt.js → __federation_expose_local-authAdminWeb-GqHU6av7.js} +2 -2
- package/dist/web/assets/{__federation_expose_local-authAdminWeb-DUY1rKEt.js.map → __federation_expose_local-authAdminWeb-GqHU6av7.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_local-authCoreCommon-B1wtgXDT.js → __federation_expose_local-authCoreCommon-PHXPCKoj.js} +3 -3
- package/dist/web/assets/{__federation_expose_local-authCoreCommon-B1wtgXDT.js.map → __federation_expose_local-authCoreCommon-PHXPCKoj.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_local-authCoreWeb-CSWj3XON.js → __federation_expose_local-authCoreWeb-Dz4oU0uP.js} +7 -7
- package/dist/web/assets/__federation_expose_local-authCoreWeb-Dz4oU0uP.js.map +1 -0
- package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-BTZdABuy.js → __federation_expose_placeholder-authCoreCommon-CrB_sJO_.js} +3 -3
- package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-BTZdABuy.js.map → __federation_expose_placeholder-authCoreCommon-CrB_sJO_.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_placeholder-authCoreWeb-DXc_X2aO.js → __federation_expose_placeholder-authCoreWeb-KJ8YuuIQ.js} +7 -7
- package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-KJ8YuuIQ.js.map +1 -0
- package/dist/web/assets/{__federation_fn_import-BVpKhyMw.js → __federation_fn_import-CVjKjdRb.js} +2 -2
- package/dist/web/assets/{__federation_fn_import-BVpKhyMw.js.map → __federation_fn_import-CVjKjdRb.js.map} +1 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/{web-gdwlRH2l.js → web-BTmJxb08.js} +11 -6
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-BTmJxb08.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/{project-builder-lib-BvJ1_iif.js → project-builder-lib-FK4Jv94w.js} +620 -644
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-FK4Jv94w.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-E30UR3cY.js → ui-components-jZLf5m_y.js} +5 -5
- package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-E30UR3cY.js.map → ui-components-jZLf5m_y.js.map} +1 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/{utils-Ciu7eAT9.js → utils-CAgM5SRt.js} +47 -48
- package/dist/web/assets/__federation_shared_@baseplate-dev/utils-CAgM5SRt.js.map +1 -0
- package/dist/web/assets/__federation_shared_@tanstack/{react-router-AU7vpPwr.js → react-router-DynsSbJG.js} +2541 -2240
- package/dist/web/assets/__federation_shared_@tanstack/react-router-DynsSbJG.js.map +1 -0
- package/dist/web/assets/__federation_shared_zod-B6wbpZ4f.js +12007 -0
- package/dist/web/assets/__federation_shared_zod-B6wbpZ4f.js.map +1 -0
- package/dist/web/assets/{get-auth-plugin-definition-CHOjVGaq.js → get-auth-plugin-definition-DqZ2Eg7c.js} +2 -2
- package/dist/web/assets/{get-auth-plugin-definition-CHOjVGaq.js.map → get-auth-plugin-definition-DqZ2Eg7c.js.map} +1 -1
- package/dist/web/assets/{index-DqPqnxYC.js → index-Dccn3WBN.js} +2 -2
- package/dist/web/assets/{index-DqPqnxYC.js.map → index-Dccn3WBN.js.map} +1 -1
- package/dist/web/assets/{index.esm-DUunUtBj.js → index.esm-DeCjXqFv.js} +2 -2
- package/dist/web/assets/{index.esm-DUunUtBj.js.map → index.esm-DeCjXqFv.js.map} +1 -1
- package/dist/web/assets/{model-merger-CI1pu411.js → model-merger-kOQ_dmiE.js} +326 -170
- package/dist/web/assets/model-merger-kOQ_dmiE.js.map +1 -0
- package/dist/web/assets/{plugin-definition-CIiMl7Zf.js → plugin-definition-CxKhFkmJ.js} +3 -3
- package/dist/web/assets/plugin-definition-CxKhFkmJ.js.map +1 -0
- package/dist/web/assets/{plugin-definition--cfUfY5Z.js → plugin-definition-DKygiFuR.js} +2 -2
- package/dist/web/assets/{plugin-definition--cfUfY5Z.js.map → plugin-definition-DKygiFuR.js.map} +1 -1
- package/dist/web/assets/{plugin-definition-BzhiPIBh.js → plugin-definition-JFxKP18O.js} +2 -2
- package/dist/web/assets/{plugin-definition-BzhiPIBh.js.map → plugin-definition-JFxKP18O.js.map} +1 -1
- package/dist/web/assets/{plugin-definition-BYzEIUL9.js → plugin-definition-qkkt1X28.js} +2 -2
- package/dist/web/assets/{plugin-definition-BYzEIUL9.js.map → plugin-definition-qkkt1X28.js.map} +1 -1
- package/dist/web/assets/{react-DW8S9iUr.js → react-DA5A88WZ.js} +2 -2
- package/dist/web/assets/{react-DW8S9iUr.js.map → react-DA5A88WZ.js.map} +1 -1
- package/dist/web/assets/registries-19UehlAo.js +1081 -0
- package/dist/web/assets/registries-19UehlAo.js.map +1 -0
- package/dist/web/assets/remoteEntry.js +10 -10
- package/dist/web/assets/styles-CfTjrsB-.js +59 -0
- package/dist/web/assets/styles-CfTjrsB-.js.map +1 -0
- package/package.json +15 -15
- package/dist/index.js.map +0 -1
- package/dist/web/assets/__federation_expose_auth0CoreWeb-CAiUkJwE.js.map +0 -1
- package/dist/web/assets/__federation_expose_authCoreWeb-L7mv-Kl9.js.map +0 -1
- package/dist/web/assets/__federation_expose_local-authCoreWeb-CSWj3XON.js.map +0 -1
- package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-DXc_X2aO.js.map +0 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-gdwlRH2l.js.map +0 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-BvJ1_iif.js.map +0 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/utils-Ciu7eAT9.js.map +0 -1
- package/dist/web/assets/__federation_shared_@tanstack/react-router-AU7vpPwr.js.map +0 -1
- package/dist/web/assets/__federation_shared_zod-BGUJlEOa.js +0 -4291
- package/dist/web/assets/__federation_shared_zod-BGUJlEOa.js.map +0 -1
- package/dist/web/assets/model-merger-CI1pu411.js.map +0 -1
- package/dist/web/assets/plugin-definition-CIiMl7Zf.js.map +0 -1
- package/dist/web/assets/styles-N05E1ZaS.js +0 -58
- package/dist/web/assets/styles-N05E1ZaS.js.map +0 -1
- package/dist/web-export.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as createPluginSpec, m as mapValues, a as createEntityType, d as
|
|
2
|
-
export {
|
|
3
|
-
import { importShared } from '../__federation_fn_import-
|
|
1
|
+
import { c as createPluginSpec, m as mapValues, a as createEntityType, d as definitionSchemaWithSlots, D as DefinitionReferenceMarker, R as REF_ANNOTATIONS_MARKER_SYMBOL, s as stripRefMarkers, b as createDefinitionSchemaParserContext, g as get, e as set$1, f as definitionSchema, h as modelForeignRelationEntityType, i as modelLocalRelationEntityType, j as modelScalarFieldEntityType, k as modelEntityType, l as modelTransformerEntityType, n as modelEnumValueEntityType, o as modelEnumEntityType, p as featureEntityType, q as modelUniqueConstraintEntityType, r as createFeaturesSchema, M as ModelUtils, t as omit, u as cloneDeep } from '../model-merger-kOQ_dmiE.js';
|
|
2
|
+
export { O as DefinitionDiffArrayIncludesField, L as DefinitionDiffKeyedArrayField, N as DefinitionDiffReplacementField, y as DefinitionEntityType, F as FeatureUtils, S as applyDefinitionDiff, I as applyModelMergerDiff, J as applyModelMergerResultInPlace, K as createAndApplyModelMergerResults, Q as createDefinitionDiff, P as createDefinitionDiffConfig, B as createFeatureSchema, v as createInitializedPluginSpec, E as createModelMergerResult, H as createModelMergerResults, w as createRefContextSlot, x as createRefContextSlotMap, G as doesModelMergerResultsHaveChanges, A as featureNameSchema, C as modelMergerDefinitionDiffConfig, z as withPlaceholderSlots } from '../model-merger-kOQ_dmiE.js';
|
|
3
|
+
import { importShared } from '../__federation_fn_import-CVjKjdRb.js';
|
|
4
4
|
import { i as isEqual } from '../isEqual-DAXqKRba.js';
|
|
5
5
|
import { s as sortBy } from '../sortBy-BPH_zRB8.js';
|
|
6
6
|
|
|
@@ -312,45 +312,45 @@ function getManagedPluginsForPlugin(pluginStore, pluginKey) {
|
|
|
312
312
|
.map((p) => p.metadata);
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
const {z: z$
|
|
315
|
+
const {z: z$s} = await importShared('zod');
|
|
316
316
|
|
|
317
317
|
// matches semver
|
|
318
|
-
const versionSchema = z$
|
|
319
|
-
const pluginSpecSupportSchema = z$
|
|
320
|
-
spec: z$
|
|
321
|
-
version: z$
|
|
318
|
+
const versionSchema = z$s.string().regex(/^(\d+\.\d+\.\d+)$/);
|
|
319
|
+
const pluginSpecSupportSchema = z$s.object({
|
|
320
|
+
spec: z$s.string().min(1),
|
|
321
|
+
version: z$s.string().min(1),
|
|
322
322
|
});
|
|
323
|
-
const pluginSpecDependencySchema = z$
|
|
324
|
-
spec: z$
|
|
325
|
-
version: z$
|
|
323
|
+
const pluginSpecDependencySchema = z$s.object({
|
|
324
|
+
spec: z$s.string(),
|
|
325
|
+
version: z$s.string(),
|
|
326
326
|
});
|
|
327
327
|
/**
|
|
328
328
|
* Schema for the plugin's metadata (plugin.json)
|
|
329
329
|
*/
|
|
330
|
-
const pluginMetadataSchema = z$
|
|
330
|
+
const pluginMetadataSchema = z$s.object({
|
|
331
331
|
/**
|
|
332
332
|
* The name of the plugin - must be lowercase and contain only letters, numbers, and hyphens
|
|
333
333
|
*/
|
|
334
|
-
name: z$
|
|
334
|
+
name: z$s
|
|
335
335
|
.string()
|
|
336
336
|
.min(1)
|
|
337
337
|
.regex(/^[a-z0-9-]+$/),
|
|
338
338
|
/**
|
|
339
339
|
* A list of directories with entrypoints in them. Defaults to ['.']
|
|
340
340
|
*/
|
|
341
|
-
moduleDirectories: z$
|
|
341
|
+
moduleDirectories: z$s.array(z$s.string()).optional(),
|
|
342
342
|
/**
|
|
343
343
|
* The display name of the plugin
|
|
344
344
|
*/
|
|
345
|
-
displayName: z$
|
|
345
|
+
displayName: z$s.string().min(1),
|
|
346
346
|
/**
|
|
347
347
|
* The icon to display for the plugin as a pointer to the icon in the plugin's static folder
|
|
348
348
|
*/
|
|
349
|
-
icon: z$
|
|
349
|
+
icon: z$s.string().optional(),
|
|
350
350
|
/**
|
|
351
351
|
* A description of the plugin
|
|
352
352
|
*/
|
|
353
|
-
description: z$
|
|
353
|
+
description: z$s.string(),
|
|
354
354
|
/**
|
|
355
355
|
* The fully qualified name of the plugin that manages this plugin,
|
|
356
356
|
* e.g. "@baseplate-dev/plugin-auth:auth0" would be managed by the "@baseplate-dev/plugin-auth:auth" plugin.
|
|
@@ -358,7 +358,7 @@ const pluginMetadataSchema = z$r.object({
|
|
|
358
358
|
* Managed plugins do not appear in the plugin list but are managed by the base plugin. If the base
|
|
359
359
|
* plugin is disabled, the managed plugins will also be disabled.
|
|
360
360
|
*/
|
|
361
|
-
managedBy: z$
|
|
361
|
+
managedBy: z$s.string().optional(),
|
|
362
362
|
/**
|
|
363
363
|
* The version of the plugin using semver
|
|
364
364
|
*/
|
|
@@ -366,16 +366,16 @@ const pluginMetadataSchema = z$r.object({
|
|
|
366
366
|
/**
|
|
367
367
|
* Configuration for the specs that the plugin exports/depends on
|
|
368
368
|
*/
|
|
369
|
-
specs: z$
|
|
369
|
+
specs: z$s
|
|
370
370
|
.object({
|
|
371
371
|
/**
|
|
372
372
|
* The specs that the plugin exports
|
|
373
373
|
*/
|
|
374
|
-
exports: z$
|
|
374
|
+
exports: z$s.array(pluginSpecSupportSchema).optional(),
|
|
375
375
|
/**
|
|
376
376
|
* The specs that the plugin depends on
|
|
377
377
|
*/
|
|
378
|
-
dependencies: z$
|
|
378
|
+
dependencies: z$s.array(pluginSpecDependencySchema).optional(),
|
|
379
379
|
})
|
|
380
380
|
.optional(),
|
|
381
381
|
/**
|
|
@@ -383,7 +383,7 @@ const pluginMetadataSchema = z$r.object({
|
|
|
383
383
|
*
|
|
384
384
|
* (It can be used once in the definition but cannot be added)
|
|
385
385
|
*/
|
|
386
|
-
hidden: z$
|
|
386
|
+
hidden: z$s.boolean().optional(),
|
|
387
387
|
});
|
|
388
388
|
|
|
389
389
|
var NOTHING = Symbol.for("immer-nothing");
|
|
@@ -1829,320 +1829,237 @@ function createAppEntryType(name) {
|
|
|
1829
1829
|
|
|
1830
1830
|
const {CASE_VALIDATORS: CASE_VALIDATORS$2} = await importShared('@baseplate-dev/utils');
|
|
1831
1831
|
|
|
1832
|
-
const {z: z$
|
|
1832
|
+
const {z: z$r} = await importShared('zod');
|
|
1833
1833
|
const baseAppValidators = {
|
|
1834
|
-
id: z$
|
|
1834
|
+
id: z$r.string().default(appEntityType.generateNewId()),
|
|
1835
1835
|
name: CASE_VALIDATORS$2.KEBAB_CASE,
|
|
1836
|
-
type: z$
|
|
1836
|
+
type: z$r.string(),
|
|
1837
1837
|
};
|
|
1838
|
-
const baseAppSchema = z$
|
|
1838
|
+
const baseAppSchema = z$r.object(baseAppValidators);
|
|
1839
1839
|
|
|
1840
|
-
const {z: z$
|
|
1841
|
-
const createBackendAppSchema =
|
|
1840
|
+
const {z: z$q} = await importShared('zod');
|
|
1841
|
+
const createBackendAppSchema = definitionSchemaWithSlots({ appSlot: appEntityType }, () => z$q.object({
|
|
1842
1842
|
...baseAppValidators,
|
|
1843
|
-
type: z$
|
|
1844
|
-
enableStripe: z$
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
enableAxios: z$p.boolean().optional(),
|
|
1843
|
+
type: z$q.literal('backend'),
|
|
1844
|
+
enableStripe: z$q.boolean().optional(),
|
|
1845
|
+
enablePostmark: z$q.boolean().optional(),
|
|
1846
|
+
enableSubscriptions: z$q.boolean().optional(),
|
|
1847
|
+
enableAxios: z$q.boolean().optional(),
|
|
1849
1848
|
}));
|
|
1850
1849
|
const backendAppEntryType = createAppEntryType('backend');
|
|
1851
1850
|
|
|
1852
1851
|
const authRoleEntityType = createEntityType('role');
|
|
1853
1852
|
|
|
1854
1853
|
/**
|
|
1855
|
-
*
|
|
1856
|
-
* @param
|
|
1857
|
-
* @returns The
|
|
1854
|
+
* Creates a definition entity name resolver.
|
|
1855
|
+
* @param entityNameResolver - The entity name resolver.
|
|
1856
|
+
* @returns The definition entity name resolver.
|
|
1858
1857
|
*/
|
|
1859
|
-
function
|
|
1858
|
+
function createDefinitionEntityNameResolver(entityNameResolver) {
|
|
1859
|
+
return entityNameResolver;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
function collectRefAnnotationsRecursive(pathPrefix, value) {
|
|
1863
|
+
if (value === undefined || value === null)
|
|
1864
|
+
return undefined;
|
|
1860
1865
|
if (value instanceof DefinitionReferenceMarker) {
|
|
1861
|
-
return
|
|
1866
|
+
return {
|
|
1867
|
+
entities: [],
|
|
1868
|
+
references: [
|
|
1869
|
+
{ ...value.reference, path: [...pathPrefix, ...value.reference.path] },
|
|
1870
|
+
],
|
|
1871
|
+
slots: [],
|
|
1872
|
+
};
|
|
1862
1873
|
}
|
|
1874
|
+
const collected = {
|
|
1875
|
+
entities: [],
|
|
1876
|
+
references: [],
|
|
1877
|
+
slots: [],
|
|
1878
|
+
};
|
|
1863
1879
|
if (Array.isArray(value)) {
|
|
1864
|
-
|
|
1880
|
+
for (const [i, element] of value.entries()) {
|
|
1881
|
+
const childCollected = collectRefAnnotationsRecursive([...pathPrefix, i], element);
|
|
1882
|
+
if (childCollected) {
|
|
1883
|
+
collected.entities.push(...childCollected.entities);
|
|
1884
|
+
collected.references.push(...childCollected.references);
|
|
1885
|
+
collected.slots.push(...childCollected.slots);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
return collected;
|
|
1865
1889
|
}
|
|
1866
|
-
if (typeof value === 'object'
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1890
|
+
if (typeof value === 'object') {
|
|
1891
|
+
if (REF_ANNOTATIONS_MARKER_SYMBOL in value) {
|
|
1892
|
+
const annotations = value[REF_ANNOTATIONS_MARKER_SYMBOL];
|
|
1893
|
+
collected.entities.push(...annotations.entities.map((entity) => ({
|
|
1894
|
+
...entity,
|
|
1895
|
+
path: [...pathPrefix, ...entity.path],
|
|
1896
|
+
})));
|
|
1897
|
+
collected.references.push(...annotations.references.map((reference) => ({
|
|
1898
|
+
...reference,
|
|
1899
|
+
path: [...pathPrefix, ...reference.path],
|
|
1900
|
+
})));
|
|
1901
|
+
collected.slots.push(...annotations.slots.map((slot) => ({
|
|
1902
|
+
...slot,
|
|
1903
|
+
path: [...pathPrefix, ...slot.path],
|
|
1904
|
+
})));
|
|
1905
|
+
}
|
|
1906
|
+
for (const [key, childValue] of Object.entries(value)) {
|
|
1907
|
+
if (typeof key !== 'string')
|
|
1908
|
+
continue;
|
|
1909
|
+
const childCollected = collectRefAnnotationsRecursive([...pathPrefix, key], childValue);
|
|
1910
|
+
if (childCollected) {
|
|
1911
|
+
collected.entities.push(...childCollected.entities);
|
|
1912
|
+
collected.references.push(...childCollected.references);
|
|
1913
|
+
collected.slots.push(...childCollected.slots);
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
return collected;
|
|
1871
1917
|
}
|
|
1872
|
-
return
|
|
1918
|
+
return undefined;
|
|
1919
|
+
}
|
|
1920
|
+
function collectRefs(value) {
|
|
1921
|
+
return (collectRefAnnotationsRecursive([], value) ?? {
|
|
1922
|
+
entities: [],
|
|
1923
|
+
references: [],
|
|
1924
|
+
slots: [],
|
|
1925
|
+
});
|
|
1873
1926
|
}
|
|
1874
1927
|
|
|
1928
|
+
const {mapGroupBy} = await importShared('@baseplate-dev/utils');
|
|
1929
|
+
|
|
1875
1930
|
/**
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1878
|
-
* @
|
|
1931
|
+
* Calculates the length of the common prefix of two paths.
|
|
1932
|
+
*
|
|
1933
|
+
* @param a - The first path
|
|
1934
|
+
* @param b - The second path
|
|
1935
|
+
* @returns The length of the common prefix of the two paths
|
|
1879
1936
|
*/
|
|
1880
|
-
function
|
|
1881
|
-
|
|
1937
|
+
function commonPrefixLength(a, b) {
|
|
1938
|
+
let length = 0;
|
|
1939
|
+
const maxLength = Math.min(a.length, b.length);
|
|
1940
|
+
for (let i = 0; i < maxLength; i++) {
|
|
1941
|
+
if (a[i] !== b[i])
|
|
1942
|
+
break;
|
|
1943
|
+
length++;
|
|
1944
|
+
}
|
|
1945
|
+
return length;
|
|
1882
1946
|
}
|
|
1883
1947
|
/**
|
|
1884
|
-
*
|
|
1885
|
-
* references and entities as defined in a Zod schema.
|
|
1948
|
+
* Finds the nearest ancestor slot for a given target path.
|
|
1886
1949
|
*
|
|
1887
|
-
*
|
|
1888
|
-
*
|
|
1889
|
-
*
|
|
1890
|
-
* @template TInput - The type of the input data being parsed.
|
|
1950
|
+
* @param candidateSlots - The candidate slots to search through.
|
|
1951
|
+
* @param targetPath - The target path to find the nearest ancestor slot for.
|
|
1952
|
+
* @returns The nearest ancestor slot, or undefined if no slot is found.
|
|
1891
1953
|
*/
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
* @param context - Shared context including a path map and deserialize flag.
|
|
1903
|
-
* @param data - The data being parsed.
|
|
1904
|
-
*/
|
|
1905
|
-
constructor(pathPrefix, context, data) {
|
|
1906
|
-
this.references = [];
|
|
1907
|
-
this.entitiesWithNameResolver = [];
|
|
1908
|
-
this.pathPrefix = pathPrefix;
|
|
1909
|
-
this.context = context;
|
|
1910
|
-
this.pathMap = new Map();
|
|
1911
|
-
this.data = data;
|
|
1912
|
-
}
|
|
1913
|
-
/**
|
|
1914
|
-
* Converts a dot-separated string path into an array of keys.
|
|
1915
|
-
* @param path - A string (e.g. "a.b.0.c") representing the path.
|
|
1916
|
-
* @returns An array of keys (numbers for numeric strings, otherwise strings).
|
|
1917
|
-
*/
|
|
1918
|
-
_constructPathWithoutPrefix(path) {
|
|
1919
|
-
if (!path)
|
|
1920
|
-
return [];
|
|
1921
|
-
const pathComponents = path
|
|
1922
|
-
.split('.')
|
|
1923
|
-
.map((key) => (/^[0-9]+$/.test(key) ? Number.parseInt(key, 10) : key));
|
|
1924
|
-
return pathComponents;
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* Prepends the builder's path prefix to the provided path.
|
|
1928
|
-
* @param path - The dot-separated path string.
|
|
1929
|
-
* @returns The complete reference path as an array.
|
|
1930
|
-
*/
|
|
1931
|
-
_constructPath(path) {
|
|
1932
|
-
if (!path)
|
|
1933
|
-
return this.pathPrefix;
|
|
1934
|
-
return [...this.pathPrefix, ...this._constructPathWithoutPrefix(path)];
|
|
1935
|
-
}
|
|
1936
|
-
/**
|
|
1937
|
-
* Constructs a reference path that may be defined directly as a string or indirectly
|
|
1938
|
-
* via a context object. If a context object is provided, the function looks up the
|
|
1939
|
-
* actual path from the builder's context.
|
|
1940
|
-
*
|
|
1941
|
-
* @param path - Either a dot-separated string path or an object with a context key.
|
|
1942
|
-
* @param expectedEntityType - The entity type expected for this context.
|
|
1943
|
-
* @returns The resolved reference path.
|
|
1944
|
-
* @throws If the context cannot be found or its type does not match.
|
|
1945
|
-
*/
|
|
1946
|
-
_constructPathWithContext(path, expectedEntityType) {
|
|
1947
|
-
if (typeof path === 'string') {
|
|
1948
|
-
return this._constructPath(path);
|
|
1949
|
-
}
|
|
1950
|
-
// Lookup the context for the given key.
|
|
1951
|
-
const pathContext = this.context.pathMap.get(path.context);
|
|
1952
|
-
if (!pathContext) {
|
|
1953
|
-
throw new Error(`Could not find context for ${path.context} from ${this.pathPrefix.join('.')}`);
|
|
1954
|
-
}
|
|
1955
|
-
if (pathContext.type !== expectedEntityType) {
|
|
1956
|
-
throw new Error(`Attempted to retrieve context for ${path.context} from ${this.pathPrefix.join('.')} expecting ${expectedEntityType.name}, but found ${pathContext.type.name}`);
|
|
1954
|
+
function findNearestAncestorSlot(candidateSlots = [], targetPath) {
|
|
1955
|
+
let bestMatch;
|
|
1956
|
+
for (const candidateSlot of candidateSlots) {
|
|
1957
|
+
const prefixLength = commonPrefixLength(candidateSlot.path, targetPath);
|
|
1958
|
+
// A slot at path [] (root) is a valid ancestor of any path
|
|
1959
|
+
// For non-root slots, require at least 1 common prefix element
|
|
1960
|
+
const isValidAncestor = candidateSlot.path.length === 0 || prefixLength > 0;
|
|
1961
|
+
if (isValidAncestor &&
|
|
1962
|
+
(!bestMatch || prefixLength > bestMatch.prefixLength)) {
|
|
1963
|
+
bestMatch = { prefixLength, slot: candidateSlot };
|
|
1957
1964
|
}
|
|
1958
|
-
return pathContext.path;
|
|
1959
1965
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
const fullPath = this._constructPath(reference.path);
|
|
1988
|
-
this.references.push({
|
|
1989
|
-
type: reference.type,
|
|
1990
|
-
path: fullPath,
|
|
1991
|
-
parentPath: reference.parentPath &&
|
|
1992
|
-
reference.type.parentType &&
|
|
1993
|
-
this._constructPathWithContext(reference.parentPath, reference.type.parentType),
|
|
1994
|
-
onDelete: reference.onDelete,
|
|
1995
|
-
});
|
|
1996
|
-
// Optionally, add this path to the shared context.
|
|
1997
|
-
if (reference.addContext) {
|
|
1998
|
-
this._addPathToContext(fullPath, reference.type, reference.addContext);
|
|
1966
|
+
return bestMatch?.slot;
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Resolves all slot references to actual paths.
|
|
1970
|
+
*
|
|
1971
|
+
* This function takes the collected refs (which have `parentSlot` references)
|
|
1972
|
+
* and resolves them to `parentPath` values using the slotPaths map.
|
|
1973
|
+
*
|
|
1974
|
+
* For scoped slots (where the same slot can be registered multiple times),
|
|
1975
|
+
* we find the registration whose path is the nearest ancestor of the entity/reference.
|
|
1976
|
+
*
|
|
1977
|
+
* @param collected - The collected refs with unresolved slots.
|
|
1978
|
+
* @returns The resolved refs with parentPath instead of parentSlot.
|
|
1979
|
+
* @throws If a required slot is not found in the slotPaths map.
|
|
1980
|
+
*/
|
|
1981
|
+
function resolveSlots(collected) {
|
|
1982
|
+
const { entities, references, slots } = collected;
|
|
1983
|
+
// Collect all slots by path
|
|
1984
|
+
const slotsByType = mapGroupBy(slots, (slot) => slot.slot.id);
|
|
1985
|
+
const resolvedSlotsByType = new Map();
|
|
1986
|
+
function registerSlot(slot, resolvedPath) {
|
|
1987
|
+
const slotId = slot.id;
|
|
1988
|
+
const candidateSlots = slotsByType.get(slotId) ?? [];
|
|
1989
|
+
const nearestAncestorSlot = findNearestAncestorSlot(candidateSlots, resolvedPath);
|
|
1990
|
+
if (!nearestAncestorSlot) {
|
|
1991
|
+
throw new Error(`Could not find slot "${slotId.description ?? 'unknown'}" ` +
|
|
1992
|
+
`within path ${resolvedPath.join('.')}. Make sure the slot is registered for this path.`);
|
|
1999
1993
|
}
|
|
1994
|
+
const existingSlots = resolvedSlotsByType.get(slotId) ?? [];
|
|
1995
|
+
resolvedSlotsByType.set(slotId, [
|
|
1996
|
+
...existingSlots,
|
|
1997
|
+
{ resolvedPath, path: nearestAncestorSlot.path },
|
|
1998
|
+
]);
|
|
2000
1999
|
}
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
* 1. Validate that not both a name and a name reference path are provided.
|
|
2006
|
-
* 2. Compute the full entity path.
|
|
2007
|
-
* 3. Resolve the entity ID:
|
|
2008
|
-
* - Use the provided idPath if available; otherwise, default to appending 'id'
|
|
2009
|
-
* to the entity path.
|
|
2010
|
-
* - If no id is found, generate a new one.
|
|
2011
|
-
* 4. Resolve the entity name:
|
|
2012
|
-
* - Use the provided resolveName if available; otherwise, default to using the
|
|
2013
|
-
* name path.
|
|
2014
|
-
* 5. Register the entity in either the direct entities list or the name-ref list.
|
|
2015
|
-
* 6. Optionally, add the entity’s id path to the shared context.
|
|
2016
|
-
*
|
|
2017
|
-
* @param entity - The entity definition.
|
|
2018
|
-
* @throws If both name and nameRefPath are provided or if no name is resolved.
|
|
2019
|
-
*/
|
|
2020
|
-
addEntity(entity) {
|
|
2021
|
-
// Build the full path for the entity.
|
|
2022
|
-
const path = this._constructPath(entity.path);
|
|
2023
|
-
// Resolve the id path: if provided use it; otherwise, assume the id is at "entity.path.id"
|
|
2024
|
-
const idPath = entity.idPath
|
|
2025
|
-
? this._constructPathWithoutPrefix(entity.idPath)
|
|
2026
|
-
: [...this._constructPathWithoutPrefix(entity.path), 'id'];
|
|
2027
|
-
const id = get(this.data, idPath);
|
|
2028
|
-
if (!id) {
|
|
2029
|
-
throw new Error(`No id found for entity ${entity.type.name}`);
|
|
2030
|
-
}
|
|
2031
|
-
if (!entity.type.isId(id)) {
|
|
2032
|
-
throw new Error(`Invalid id: ${id} for entity ${entity.type.name}`);
|
|
2033
|
-
}
|
|
2034
|
-
// Resolve the name: if getNameResolver is provided, use it to build the name resolver; otherwise,
|
|
2035
|
-
// use the default name resolver.
|
|
2036
|
-
const getNameResolver = entity.getNameResolver ??
|
|
2037
|
-
((value) => get(value, 'name'));
|
|
2038
|
-
const nameResolver = getNameResolver(stripRefMarkers(this.data));
|
|
2039
|
-
if (!nameResolver) {
|
|
2040
|
-
throw new Error(`No name resolver found for entity ${entity.type.name} at ${path.join('.')}`);
|
|
2000
|
+
// Collect entity provides
|
|
2001
|
+
for (const entity of entities) {
|
|
2002
|
+
if (entity.provides) {
|
|
2003
|
+
registerSlot(entity.provides, [...entity.path, ...entity.idPath]);
|
|
2041
2004
|
}
|
|
2042
|
-
// Base entity definition shared between regular entities and those with a name reference.
|
|
2043
|
-
const entityBase = {
|
|
2044
|
-
id,
|
|
2045
|
-
type: entity.type,
|
|
2046
|
-
path,
|
|
2047
|
-
idPath: [...this.pathPrefix, ...idPath],
|
|
2048
|
-
parentPath: entity.parentPath &&
|
|
2049
|
-
entity.type.parentType &&
|
|
2050
|
-
this._constructPathWithContext(entity.parentPath, entity.type.parentType),
|
|
2051
|
-
};
|
|
2052
|
-
this.entitiesWithNameResolver.push({
|
|
2053
|
-
...entityBase,
|
|
2054
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- needed to allow more specific generic typed to be put in here
|
|
2055
|
-
nameResolver: typeof nameResolver === 'string'
|
|
2056
|
-
? { resolveName: () => nameResolver }
|
|
2057
|
-
: nameResolver,
|
|
2058
|
-
});
|
|
2059
|
-
// Optionally add the id path to the context.
|
|
2060
|
-
if (entity.addContext) {
|
|
2061
|
-
this._addPathToContext([...this.pathPrefix, ...idPath], entity.type, entity.addContext);
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
/**
|
|
2065
|
-
* Registers a given path into the builder's context map.
|
|
2066
|
-
* @param path - The full reference path.
|
|
2067
|
-
* @param type - The entity type associated with the path.
|
|
2068
|
-
* @param context - A unique key to identify this context.
|
|
2069
|
-
* @throws If the context key is already registered.
|
|
2070
|
-
*/
|
|
2071
|
-
_addPathToContext(path, type, context) {
|
|
2072
|
-
// For now, allow overriding contexts to maintain compatibility
|
|
2073
|
-
this.pathMap.set(context, { path, type });
|
|
2074
|
-
// Also register in the shared context for other builders to access
|
|
2075
|
-
this.context.pathMap.set(context, { path, type });
|
|
2076
2005
|
}
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
* @param context - The context key.
|
|
2083
|
-
*/
|
|
2084
|
-
addPathToContext(path, type, context) {
|
|
2085
|
-
this._addPathToContext(this._constructPath(path), type, context);
|
|
2006
|
+
// Collect reference provides
|
|
2007
|
+
for (const reference of references) {
|
|
2008
|
+
if (reference.provides) {
|
|
2009
|
+
registerSlot(reference.provides, reference.path);
|
|
2010
|
+
}
|
|
2086
2011
|
}
|
|
2012
|
+
return resolvedSlotsByType;
|
|
2087
2013
|
}
|
|
2088
2014
|
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2015
|
+
/**
|
|
2016
|
+
* Extracts definition refs from a parsed value using functional approach.
|
|
2017
|
+
*
|
|
2018
|
+
* Flow:
|
|
2019
|
+
* 1. Collect all refs (entities, references, slots) recursively
|
|
2020
|
+
* 2. Resolve all slot references to actual paths
|
|
2021
|
+
* 3. Strip ref markers from the data
|
|
2022
|
+
* 4. Validate no duplicate IDs
|
|
2023
|
+
*
|
|
2024
|
+
* @param value - The parsed value from Zod schema
|
|
2025
|
+
* @returns The extracted refs with clean data
|
|
2026
|
+
*/
|
|
2027
|
+
function extractDefinitionRefs(value) {
|
|
2028
|
+
// Step 1: Collect all refs without resolving slots
|
|
2029
|
+
const collected = collectRefs(value);
|
|
2030
|
+
// Step 2: Resolve all slots to paths
|
|
2031
|
+
const resolvedSlots = resolveSlots(collected);
|
|
2032
|
+
// Step 3: Strip markers from data
|
|
2033
|
+
const cleanData = stripRefMarkers(value);
|
|
2034
|
+
// Step 4: Resolve entity and reference parent paths
|
|
2035
|
+
function resolveParentPath(parentSlot, path) {
|
|
2036
|
+
const resolvedSlot = findNearestAncestorSlot(resolvedSlots.get(parentSlot.id), path);
|
|
2037
|
+
if (!resolvedSlot) {
|
|
2038
|
+
throw new Error(`Could not resolve parent path from ${path.join('.')} for slot ${parentSlot.id.description}`);
|
|
2109
2039
|
}
|
|
2110
|
-
|
|
2111
|
-
context.entitiesWithNameResolver.push(...builder.entitiesWithNameResolver);
|
|
2112
|
-
// Remove the marker symbol and process the clean object
|
|
2113
|
-
const { [REF_ANNOTATIONS_MARKER_SYMBOL]: _, ...cleanValue } = value;
|
|
2114
|
-
// Process the clean object recursively
|
|
2115
|
-
return Object.fromEntries(Object.entries(cleanValue).map(([key, childValue]) => [
|
|
2116
|
-
key,
|
|
2117
|
-
extractDefinitionRefsRecursive(childValue, context, [...path, key]),
|
|
2118
|
-
]));
|
|
2119
|
-
}
|
|
2120
|
-
// Run recursively for arrays first (arrays are also objects)
|
|
2121
|
-
if (Array.isArray(value)) {
|
|
2122
|
-
return value.map((element, i) => extractDefinitionRefsRecursive(element, context, [...path, i]));
|
|
2123
|
-
}
|
|
2124
|
-
// Run recursively for regular objects
|
|
2125
|
-
if (typeof value === 'object' && value !== null) {
|
|
2126
|
-
return Object.fromEntries(Object.entries(value).map(([key, childValue]) => [
|
|
2127
|
-
key,
|
|
2128
|
-
extractDefinitionRefsRecursive(childValue, context, [...path, key]),
|
|
2129
|
-
]));
|
|
2040
|
+
return resolvedSlot.resolvedPath;
|
|
2130
2041
|
}
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2042
|
+
const entitiesWithNameResolver = collected.entities.map((entity) => ({
|
|
2043
|
+
id: entity.id,
|
|
2044
|
+
idPath: entity.idPath,
|
|
2045
|
+
nameResolver: entity.nameResolver,
|
|
2046
|
+
type: entity.type,
|
|
2047
|
+
path: entity.path,
|
|
2048
|
+
parentPath: entity.parentSlot
|
|
2049
|
+
? resolveParentPath(entity.parentSlot, entity.path)
|
|
2050
|
+
: undefined,
|
|
2051
|
+
}));
|
|
2052
|
+
const references = collected.references.map((reference) => ({
|
|
2053
|
+
type: reference.type,
|
|
2054
|
+
path: reference.path,
|
|
2055
|
+
onDelete: reference.onDelete,
|
|
2056
|
+
parentPath: reference.parentSlot
|
|
2057
|
+
? resolveParentPath(reference.parentSlot, reference.path)
|
|
2058
|
+
: undefined,
|
|
2059
|
+
}));
|
|
2060
|
+
// Step 4: Validate no duplicate IDs
|
|
2144
2061
|
const idSet = new Set();
|
|
2145
|
-
for (const entity of
|
|
2062
|
+
for (const entity of collected.entities) {
|
|
2146
2063
|
if (idSet.has(entity.id)) {
|
|
2147
2064
|
throw new Error(`Duplicate ID found: ${entity.id}`);
|
|
2148
2065
|
}
|
|
@@ -2150,8 +2067,8 @@ function extractDefinitionRefs(value) {
|
|
|
2150
2067
|
}
|
|
2151
2068
|
return {
|
|
2152
2069
|
data: cleanData,
|
|
2153
|
-
references
|
|
2154
|
-
entitiesWithNameResolver
|
|
2070
|
+
references,
|
|
2071
|
+
entitiesWithNameResolver,
|
|
2155
2072
|
};
|
|
2156
2073
|
}
|
|
2157
2074
|
|
|
@@ -2170,6 +2087,9 @@ function resolveZodRefPayloadNames(payload, { skipReferenceNameResolution = fals
|
|
|
2170
2087
|
const resolvedEntitiesById = new Map();
|
|
2171
2088
|
// sort entities by dependency order
|
|
2172
2089
|
const orderedEntities = toposort$1(entitiesWithNameResolver.map((entity) => entity.id), entitiesWithNameResolver.flatMap((entity) => {
|
|
2090
|
+
if (typeof entity.nameResolver !== 'object') {
|
|
2091
|
+
return [];
|
|
2092
|
+
}
|
|
2173
2093
|
const entityIds = entity.nameResolver.idsToResolve ?? {};
|
|
2174
2094
|
return Object.values(entityIds)
|
|
2175
2095
|
.flat()
|
|
@@ -2191,13 +2111,21 @@ function resolveZodRefPayloadNames(payload, { skipReferenceNameResolution = fals
|
|
|
2191
2111
|
}
|
|
2192
2112
|
for (const id of orderedEntities) {
|
|
2193
2113
|
const { nameResolver, ...rest } = entitiesById[id];
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2114
|
+
if (typeof nameResolver === 'string') {
|
|
2115
|
+
resolvedEntitiesById.set(rest.id, {
|
|
2116
|
+
...rest,
|
|
2117
|
+
name: nameResolver,
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
else {
|
|
2121
|
+
const resolvedIds = mapValues(nameResolver.idsToResolve ?? {}, (idOrIds) => Array.isArray(idOrIds)
|
|
2122
|
+
? idOrIds.map((id) => resolveIdToName(id))
|
|
2123
|
+
: resolveIdToName(idOrIds));
|
|
2124
|
+
resolvedEntitiesById.set(rest.id, {
|
|
2125
|
+
...rest,
|
|
2126
|
+
name: nameResolver.resolveName(resolvedIds),
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2201
2129
|
}
|
|
2202
2130
|
return {
|
|
2203
2131
|
entities: [...resolvedEntitiesById.values()],
|
|
@@ -2221,10 +2149,8 @@ function parseSchemaWithTransformedReferences(schemaCreator, input, schemaCreato
|
|
|
2221
2149
|
transformReferences: true,
|
|
2222
2150
|
});
|
|
2223
2151
|
const schema = schemaCreator(schemaContext);
|
|
2224
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- using the type T which can be any zod schema
|
|
2225
2152
|
const value = schema.parse(input);
|
|
2226
2153
|
const refPayload = extractDefinitionRefs(value);
|
|
2227
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- using the type T which can be any zod schema
|
|
2228
2154
|
return resolveZodRefPayloadNames(refPayload, options);
|
|
2229
2155
|
}
|
|
2230
2156
|
|
|
@@ -2258,6 +2184,9 @@ function deserializeSchemaWithTransformedReferences(schemaCreator, input, option
|
|
|
2258
2184
|
*/
|
|
2259
2185
|
function resolveReferencesToIds(payload) {
|
|
2260
2186
|
const { references, entities, data } = payload;
|
|
2187
|
+
if (typeof data !== 'object' || data === null) {
|
|
2188
|
+
throw new TypeError('Data is not an object');
|
|
2189
|
+
}
|
|
2261
2190
|
// check we don't have more entities than IDs
|
|
2262
2191
|
const entitiesById = groupBy(entities, (entity) => entity.id);
|
|
2263
2192
|
const duplicateEntityIds = Object.values(entitiesById).filter((e) => e.length > 1);
|
|
@@ -2419,6 +2348,9 @@ function fixRefDeletions(schemaCreator, value, schemaCreatorOptions) {
|
|
|
2419
2348
|
|
|
2420
2349
|
function serializeSchemaFromRefPayload(payload) {
|
|
2421
2350
|
const { references, entities, data } = payload;
|
|
2351
|
+
if (typeof data !== 'object' || data === null) {
|
|
2352
|
+
throw new TypeError('Data is not an object');
|
|
2353
|
+
}
|
|
2422
2354
|
const entitiesById = new Map(entities.map((e) => [e.id, e]));
|
|
2423
2355
|
return produce((draftData) => {
|
|
2424
2356
|
for (const reference of references) {
|
|
@@ -2433,7 +2365,6 @@ function serializeSchemaFromRefPayload(payload) {
|
|
|
2433
2365
|
}
|
|
2434
2366
|
function serializeSchema(schemaCreator, value, schemaCreatorOptions) {
|
|
2435
2367
|
const payload = parseSchemaWithTransformedReferences(schemaCreator, value, schemaCreatorOptions);
|
|
2436
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- typed as def.InferOutput<T>
|
|
2437
2368
|
return serializeSchemaFromRefPayload(payload);
|
|
2438
2369
|
}
|
|
2439
2370
|
|
|
@@ -2450,121 +2381,122 @@ const SCALAR_FIELD_TYPES = [
|
|
|
2450
2381
|
'enum',
|
|
2451
2382
|
];
|
|
2452
2383
|
|
|
2453
|
-
const {z: z$
|
|
2384
|
+
const {z: z$p} = await importShared('zod');
|
|
2454
2385
|
|
|
2455
2386
|
const VALIDATORS = {
|
|
2456
|
-
PASCAL_CASE_STRING: z$
|
|
2387
|
+
PASCAL_CASE_STRING: z$p
|
|
2457
2388
|
.string()
|
|
2458
2389
|
.regex(/^[A-Z][a-zA-Z0-9]*$/, "Should be PascalCase, e.g. 'MyModel'"),
|
|
2459
|
-
CAMEL_CASE_STRING: z$
|
|
2390
|
+
CAMEL_CASE_STRING: z$p
|
|
2460
2391
|
.string()
|
|
2461
2392
|
.regex(/^[a-z][a-zA-Z0-9]*$/, "Should be camelCase, e.g. 'myField'"),
|
|
2462
|
-
CONSTANT_CASE_STRING: z$
|
|
2393
|
+
CONSTANT_CASE_STRING: z$p
|
|
2463
2394
|
.string()
|
|
2464
2395
|
.regex(/^[A-Z][A-Z0-9_]*$/, "Should be CONSTANT_CASE, e.g. 'MY_CONSTANT'"),
|
|
2465
|
-
OPTIONAL_CONSTANT_CASE_STRING: z$
|
|
2396
|
+
OPTIONAL_CONSTANT_CASE_STRING: z$p
|
|
2466
2397
|
.string()
|
|
2467
2398
|
.regex(/^[A-Z][A-Z0-9_]*$/, "Should be CONSTANT_CASE, e.g. 'MY_CONSTANT'")
|
|
2468
|
-
.or(z$
|
|
2399
|
+
.or(z$p.literal(''))
|
|
2469
2400
|
.optional(),
|
|
2470
2401
|
};
|
|
2471
2402
|
|
|
2472
|
-
const {z: z$
|
|
2473
|
-
const createRoleArray = definitionSchema((ctx) => ctx.withDefault(z$
|
|
2403
|
+
const {z: z$o} = await importShared('zod');
|
|
2404
|
+
const createRoleArray = definitionSchema((ctx) => ctx.withDefault(z$o.array(ctx.withRef({
|
|
2474
2405
|
type: authRoleEntityType,
|
|
2475
2406
|
onDelete: 'DELETE',
|
|
2476
2407
|
})), []));
|
|
2477
|
-
const createModelGraphqlSchema =
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2408
|
+
const createModelGraphqlSchema = definitionSchemaWithSlots({
|
|
2409
|
+
modelSlot: modelEntityType,
|
|
2410
|
+
}, (ctx, { modelSlot }) => z$o.object({
|
|
2411
|
+
objectType: ctx.withDefault(z$o.object({
|
|
2412
|
+
enabled: ctx.withDefault(z$o.boolean(), false),
|
|
2413
|
+
fields: ctx.withDefault(z$o.array(ctx.withRef({
|
|
2481
2414
|
type: modelScalarFieldEntityType,
|
|
2482
2415
|
onDelete: 'DELETE',
|
|
2483
|
-
|
|
2416
|
+
parentSlot: modelSlot,
|
|
2484
2417
|
})), []),
|
|
2485
|
-
localRelations: ctx.withDefault(z$
|
|
2418
|
+
localRelations: ctx.withDefault(z$o.array(ctx.withRef({
|
|
2486
2419
|
type: modelLocalRelationEntityType,
|
|
2487
2420
|
onDelete: 'DELETE',
|
|
2488
|
-
|
|
2421
|
+
parentSlot: modelSlot,
|
|
2489
2422
|
})), []),
|
|
2490
|
-
foreignRelations: ctx.withDefault(z$
|
|
2423
|
+
foreignRelations: ctx.withDefault(z$o.array(ctx.withRef({
|
|
2491
2424
|
type: modelForeignRelationEntityType,
|
|
2492
2425
|
onDelete: 'DELETE',
|
|
2493
|
-
|
|
2426
|
+
parentSlot: modelSlot,
|
|
2494
2427
|
})), []),
|
|
2495
2428
|
}), {}),
|
|
2496
|
-
queries: ctx.withDefault(z$
|
|
2497
|
-
get: ctx.withDefault(z$
|
|
2498
|
-
enabled: ctx.withDefault(z$
|
|
2429
|
+
queries: ctx.withDefault(z$o.object({
|
|
2430
|
+
get: ctx.withDefault(z$o.object({
|
|
2431
|
+
enabled: ctx.withDefault(z$o.boolean(), false),
|
|
2499
2432
|
roles: createRoleArray(ctx),
|
|
2500
2433
|
}), {}),
|
|
2501
|
-
list: ctx.withDefault(z$
|
|
2502
|
-
enabled: ctx.withDefault(z$
|
|
2434
|
+
list: ctx.withDefault(z$o.object({
|
|
2435
|
+
enabled: ctx.withDefault(z$o.boolean(), false),
|
|
2503
2436
|
roles: createRoleArray(ctx),
|
|
2504
2437
|
}), {}),
|
|
2505
2438
|
}), {}),
|
|
2506
|
-
mutations: ctx.withDefault(z$
|
|
2507
|
-
create: ctx.withDefault(z$
|
|
2508
|
-
enabled: ctx.withDefault(z$
|
|
2439
|
+
mutations: ctx.withDefault(z$o.object({
|
|
2440
|
+
create: ctx.withDefault(z$o.object({
|
|
2441
|
+
enabled: ctx.withDefault(z$o.boolean(), false),
|
|
2509
2442
|
roles: createRoleArray(ctx),
|
|
2510
2443
|
}), {}),
|
|
2511
|
-
update: ctx.withDefault(z$
|
|
2512
|
-
enabled: ctx.withDefault(z$
|
|
2444
|
+
update: ctx.withDefault(z$o.object({
|
|
2445
|
+
enabled: ctx.withDefault(z$o.boolean(), false),
|
|
2513
2446
|
roles: createRoleArray(ctx),
|
|
2514
2447
|
}), {}),
|
|
2515
|
-
delete: ctx.withDefault(z$
|
|
2516
|
-
enabled: ctx.withDefault(z$
|
|
2448
|
+
delete: ctx.withDefault(z$o.object({
|
|
2449
|
+
enabled: ctx.withDefault(z$o.boolean(), false),
|
|
2517
2450
|
roles: createRoleArray(ctx),
|
|
2518
2451
|
}), {}),
|
|
2519
2452
|
}), {}),
|
|
2520
2453
|
}));
|
|
2521
2454
|
|
|
2522
|
-
const {z: z$
|
|
2455
|
+
const {z: z$n} = await importShared('zod');
|
|
2523
2456
|
|
|
2524
2457
|
const baseTransformerFields = {
|
|
2525
|
-
id: z$
|
|
2526
|
-
type: z$
|
|
2458
|
+
id: z$n.string(),
|
|
2459
|
+
type: z$n.string().min(1),
|
|
2527
2460
|
};
|
|
2528
|
-
const baseTransformerSchema = z$
|
|
2461
|
+
const baseTransformerSchema = z$n.looseObject(baseTransformerFields);
|
|
2529
2462
|
function createModelTransformerType(payload) {
|
|
2530
2463
|
return payload;
|
|
2531
2464
|
}
|
|
2532
2465
|
|
|
2533
|
-
const {z: z$
|
|
2534
|
-
const createEmbeddedRelationTransformerSchema =
|
|
2466
|
+
const {z: z$m} = await importShared('zod');
|
|
2467
|
+
const createEmbeddedRelationTransformerSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, { modelSlot }) => ctx.refContext({ embeddedModelSlot: modelEntityType }, ({ embeddedModelSlot }) => ctx.withEnt(z$m.object({
|
|
2535
2468
|
...baseTransformerFields,
|
|
2536
2469
|
foreignRelationRef: ctx.withRef({
|
|
2537
2470
|
type: modelForeignRelationEntityType,
|
|
2538
2471
|
onDelete: 'DELETE_PARENT',
|
|
2539
|
-
|
|
2472
|
+
parentSlot: modelSlot,
|
|
2540
2473
|
}),
|
|
2541
|
-
type: z$
|
|
2542
|
-
embeddedFieldNames: z$
|
|
2474
|
+
type: z$m.literal('embeddedRelation'),
|
|
2475
|
+
embeddedFieldNames: z$m.array(ctx.withRef({
|
|
2543
2476
|
type: modelScalarFieldEntityType,
|
|
2544
2477
|
onDelete: 'RESTRICT',
|
|
2545
|
-
|
|
2478
|
+
parentSlot: embeddedModelSlot,
|
|
2546
2479
|
})),
|
|
2547
|
-
embeddedTransformerNames: z$
|
|
2480
|
+
embeddedTransformerNames: z$m
|
|
2548
2481
|
.array(ctx.withRef({
|
|
2549
2482
|
type: modelTransformerEntityType,
|
|
2550
2483
|
onDelete: 'RESTRICT',
|
|
2551
|
-
|
|
2484
|
+
parentSlot: embeddedModelSlot,
|
|
2552
2485
|
}))
|
|
2553
2486
|
.optional(),
|
|
2554
2487
|
modelRef: ctx.withRef({
|
|
2555
2488
|
type: modelEntityType,
|
|
2556
2489
|
onDelete: 'RESTRICT',
|
|
2490
|
+
provides: embeddedModelSlot,
|
|
2557
2491
|
}),
|
|
2558
2492
|
}), {
|
|
2559
2493
|
type: modelTransformerEntityType,
|
|
2560
|
-
|
|
2494
|
+
parentSlot: modelSlot,
|
|
2561
2495
|
getNameResolver: (entity) => createDefinitionEntityNameResolver({
|
|
2562
2496
|
idsToResolve: { foreignRelation: entity.foreignRelationRef },
|
|
2563
2497
|
resolveName: (entityNames) => entityNames.foreignRelation,
|
|
2564
2498
|
}),
|
|
2565
|
-
})
|
|
2566
|
-
builder.addPathToContext('modelRef', modelEntityType, 'embeddedModel');
|
|
2567
|
-
}));
|
|
2499
|
+
})));
|
|
2568
2500
|
const BUILT_IN_TRANSFORMERS = [
|
|
2569
2501
|
createModelTransformerType({
|
|
2570
2502
|
name: 'embeddedRelation',
|
|
@@ -2581,7 +2513,7 @@ function createModelTransformerImplementation() {
|
|
|
2581
2513
|
}
|
|
2582
2514
|
return {
|
|
2583
2515
|
registerModelTransformer(transformer) {
|
|
2584
|
-
if (
|
|
2516
|
+
if (transformer.name in transformers) {
|
|
2585
2517
|
throw new Error(`Model transformer with name ${transformer.name} is already registered`);
|
|
2586
2518
|
}
|
|
2587
2519
|
transformers[transformer.name] =
|
|
@@ -2591,11 +2523,10 @@ function createModelTransformerImplementation() {
|
|
|
2591
2523
|
return transformers;
|
|
2592
2524
|
},
|
|
2593
2525
|
getModelTransformer(name) {
|
|
2594
|
-
|
|
2595
|
-
if (!transformer) {
|
|
2526
|
+
if (!(name in transformers)) {
|
|
2596
2527
|
throw new Error(`Unable to find transformer with name ${name}`);
|
|
2597
2528
|
}
|
|
2598
|
-
return
|
|
2529
|
+
return transformers[name];
|
|
2599
2530
|
},
|
|
2600
2531
|
};
|
|
2601
2532
|
}
|
|
@@ -2606,51 +2537,46 @@ const modelTransformerSpec = createPluginSpec('core/model-transformer', {
|
|
|
2606
2537
|
defaultInitializer: createModelTransformerImplementation,
|
|
2607
2538
|
});
|
|
2608
2539
|
|
|
2609
|
-
const
|
|
2610
|
-
|
|
2611
|
-
const
|
|
2540
|
+
const z$l = await importShared('zod');
|
|
2541
|
+
const createTransformerSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, slots) => {
|
|
2542
|
+
const transformers = ctx.plugins
|
|
2612
2543
|
.getPluginSpec(modelTransformerSpec)
|
|
2613
|
-
.
|
|
2614
|
-
return transformer
|
|
2615
|
-
|
|
2616
|
-
.and(baseTransformerSchema)
|
|
2617
|
-
.parse(data, {
|
|
2618
|
-
path: parseCtx.path,
|
|
2619
|
-
});
|
|
2620
|
-
}));
|
|
2544
|
+
.getModelTransformers();
|
|
2545
|
+
return z$l.discriminatedUnion('type', Object.values(transformers).map((transformer) => transformer.createSchema(ctx, slots)));
|
|
2546
|
+
});
|
|
2621
2547
|
|
|
2622
2548
|
const {z: z$k} = await importShared('zod');
|
|
2623
|
-
const createEnumValueSchema =
|
|
2549
|
+
const createEnumValueSchema = definitionSchemaWithSlots({ enumSlot: modelEnumEntityType }, (ctx, { enumSlot }) => ctx.withEnt(z$k.object({
|
|
2624
2550
|
id: z$k.string(),
|
|
2625
2551
|
name: z$k.string().min(1),
|
|
2626
2552
|
friendlyName: z$k.string().min(1),
|
|
2627
2553
|
}), {
|
|
2628
2554
|
type: modelEnumValueEntityType,
|
|
2629
|
-
|
|
2555
|
+
parentSlot: enumSlot,
|
|
2630
2556
|
}));
|
|
2631
|
-
const createEnumBaseSchema =
|
|
2557
|
+
const createEnumBaseSchema = definitionSchemaWithSlots({ enumSlot: modelEnumEntityType }, (ctx, { enumSlot }) => z$k.object({
|
|
2632
2558
|
id: z$k.string(),
|
|
2633
2559
|
name: z$k.string().min(1),
|
|
2634
2560
|
featureRef: ctx.withRef({
|
|
2635
2561
|
type: featureEntityType,
|
|
2636
2562
|
onDelete: 'RESTRICT',
|
|
2637
2563
|
}),
|
|
2638
|
-
values: z$k.array(createEnumValueSchema(ctx)),
|
|
2564
|
+
values: z$k.array(createEnumValueSchema(ctx, { enumSlot })),
|
|
2639
2565
|
isExposed: z$k.boolean(),
|
|
2640
2566
|
}));
|
|
2641
|
-
const createEnumSchema = definitionSchema((ctx) => ctx.withEnt(createEnumBaseSchema(ctx), {
|
|
2567
|
+
const createEnumSchema = definitionSchema((ctx) => ctx.refContext({ enumSlot: modelEnumEntityType }, ({ enumSlot }) => ctx.withEnt(createEnumBaseSchema(ctx, { enumSlot }), {
|
|
2642
2568
|
type: modelEnumEntityType,
|
|
2643
|
-
|
|
2644
|
-
}));
|
|
2569
|
+
provides: enumSlot,
|
|
2570
|
+
})));
|
|
2645
2571
|
|
|
2646
2572
|
const {z: z$j} = await importShared('zod');
|
|
2647
|
-
const createModelScalarFieldSchema =
|
|
2573
|
+
const createModelScalarFieldSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, { modelSlot }) => ctx
|
|
2648
2574
|
.withEnt(z$j.object({
|
|
2649
2575
|
id: z$j.string(),
|
|
2650
2576
|
name: VALIDATORS.CAMEL_CASE_STRING,
|
|
2651
2577
|
type: z$j.enum(SCALAR_FIELD_TYPES),
|
|
2652
2578
|
isOptional: z$j.boolean().default(false),
|
|
2653
|
-
options: ctx.
|
|
2579
|
+
options: ctx.refContext({ enumSlot: modelEnumEntityType }, ({ enumSlot }) => z$j
|
|
2654
2580
|
.object({
|
|
2655
2581
|
// string options
|
|
2656
2582
|
default: z$j.string().default(''),
|
|
@@ -2664,25 +2590,25 @@ const createModelScalarFieldSchema = definitionSchema((ctx) => ctx
|
|
|
2664
2590
|
.withRef({
|
|
2665
2591
|
type: modelEnumEntityType,
|
|
2666
2592
|
onDelete: 'RESTRICT',
|
|
2593
|
+
provides: enumSlot,
|
|
2594
|
+
})
|
|
2595
|
+
.optional(),
|
|
2596
|
+
defaultEnumValueRef: ctx
|
|
2597
|
+
.withRef({
|
|
2598
|
+
type: modelEnumValueEntityType,
|
|
2599
|
+
onDelete: 'RESTRICT',
|
|
2600
|
+
parentSlot: enumSlot,
|
|
2667
2601
|
})
|
|
2668
2602
|
.optional(),
|
|
2669
|
-
defaultEnumValueRef: z$j.string().optional(),
|
|
2670
2603
|
})
|
|
2671
2604
|
.transform((val) => ({
|
|
2672
2605
|
...val,
|
|
2673
2606
|
...(val.enumRef ? {} : { defaultEnumValueRef: undefined }),
|
|
2674
2607
|
}))
|
|
2675
|
-
.
|
|
2676
|
-
builder.addReference({
|
|
2677
|
-
type: modelEnumValueEntityType,
|
|
2678
|
-
onDelete: 'RESTRICT',
|
|
2679
|
-
path: 'defaultEnumValueRef',
|
|
2680
|
-
parentPath: 'enumRef',
|
|
2681
|
-
});
|
|
2682
|
-
}),
|
|
2608
|
+
.prefault({})),
|
|
2683
2609
|
}), {
|
|
2684
2610
|
type: modelScalarFieldEntityType,
|
|
2685
|
-
|
|
2611
|
+
parentSlot: modelSlot,
|
|
2686
2612
|
})
|
|
2687
2613
|
.superRefine((arg, ctx) => {
|
|
2688
2614
|
// check default values
|
|
@@ -2718,7 +2644,7 @@ const REFERENTIAL_ACTIONS = [
|
|
|
2718
2644
|
'SetNull',
|
|
2719
2645
|
'SetDefault',
|
|
2720
2646
|
];
|
|
2721
|
-
const createModelRelationFieldSchema =
|
|
2647
|
+
const createModelRelationFieldSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, { modelSlot }) => ctx.refContext({ foreignModelSlot: modelEntityType }, ({ foreignModelSlot }) => ctx.withEnt(ctx.withEnt(z$j.object({
|
|
2722
2648
|
id: z$j.string(),
|
|
2723
2649
|
foreignId: z$j
|
|
2724
2650
|
.string()
|
|
@@ -2728,48 +2654,43 @@ const createModelRelationFieldSchema = definitionSchema((ctx) => ctx.withRefBuil
|
|
|
2728
2654
|
localRef: ctx.withRef({
|
|
2729
2655
|
type: modelScalarFieldEntityType,
|
|
2730
2656
|
onDelete: 'RESTRICT',
|
|
2731
|
-
|
|
2657
|
+
parentSlot: modelSlot,
|
|
2732
2658
|
}),
|
|
2733
2659
|
foreignRef: ctx.withRef({
|
|
2734
2660
|
type: modelScalarFieldEntityType,
|
|
2735
2661
|
onDelete: 'RESTRICT',
|
|
2736
|
-
|
|
2662
|
+
parentSlot: foreignModelSlot,
|
|
2737
2663
|
}),
|
|
2738
2664
|
})),
|
|
2739
|
-
modelRef:
|
|
2665
|
+
modelRef: ctx.withRef({
|
|
2666
|
+
type: modelEntityType,
|
|
2667
|
+
onDelete: 'RESTRICT',
|
|
2668
|
+
provides: foreignModelSlot,
|
|
2669
|
+
}),
|
|
2740
2670
|
foreignRelationName: VALIDATORS.CAMEL_CASE_STRING,
|
|
2741
2671
|
onDelete: z$j.enum(REFERENTIAL_ACTIONS).default('Cascade'),
|
|
2742
2672
|
onUpdate: z$j.enum(REFERENTIAL_ACTIONS).default('Restrict'),
|
|
2743
|
-
}),
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
});
|
|
2754
|
-
builder.addEntity({
|
|
2755
|
-
type: modelForeignRelationEntityType,
|
|
2756
|
-
idPath: 'foreignId',
|
|
2757
|
-
getNameResolver: (entity) => entity.foreignRelationName,
|
|
2758
|
-
parentPath: 'modelRef',
|
|
2759
|
-
});
|
|
2760
|
-
}));
|
|
2761
|
-
const createModelUniqueConstraintSchema = definitionSchema((ctx) => ctx.withEnt(z$j.object({
|
|
2673
|
+
}), {
|
|
2674
|
+
type: modelLocalRelationEntityType,
|
|
2675
|
+
parentSlot: modelSlot,
|
|
2676
|
+
}), {
|
|
2677
|
+
type: modelForeignRelationEntityType,
|
|
2678
|
+
idPath: ['foreignId'],
|
|
2679
|
+
getNameResolver: (entity) => entity.foreignRelationName,
|
|
2680
|
+
parentSlot: foreignModelSlot,
|
|
2681
|
+
})));
|
|
2682
|
+
const createModelUniqueConstraintSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, { modelSlot }) => ctx.withEnt(z$j.object({
|
|
2762
2683
|
id: z$j.string(),
|
|
2763
2684
|
fields: z$j.array(z$j.object({
|
|
2764
2685
|
fieldRef: ctx.withRef({
|
|
2765
2686
|
type: modelScalarFieldEntityType,
|
|
2766
2687
|
onDelete: 'RESTRICT',
|
|
2767
|
-
|
|
2688
|
+
parentSlot: modelSlot,
|
|
2768
2689
|
}),
|
|
2769
2690
|
})),
|
|
2770
2691
|
}), {
|
|
2771
2692
|
type: modelUniqueConstraintEntityType,
|
|
2772
|
-
|
|
2693
|
+
parentSlot: modelSlot,
|
|
2773
2694
|
getNameResolver(value) {
|
|
2774
2695
|
return createDefinitionEntityNameResolver({
|
|
2775
2696
|
idsToResolve: { fields: value.fields.map((f) => f.fieldRef) },
|
|
@@ -2777,7 +2698,7 @@ const createModelUniqueConstraintSchema = definitionSchema((ctx) => ctx.withEnt(
|
|
|
2777
2698
|
});
|
|
2778
2699
|
},
|
|
2779
2700
|
}));
|
|
2780
|
-
const createModelServiceSchema =
|
|
2701
|
+
const createModelServiceSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, { modelSlot }) => z$j.object({
|
|
2781
2702
|
create: z$j
|
|
2782
2703
|
.object({
|
|
2783
2704
|
enabled: z$j.boolean().default(false),
|
|
@@ -2785,14 +2706,14 @@ const createModelServiceSchema = definitionSchema((ctx) => z$j.object({
|
|
|
2785
2706
|
.array(ctx.withRef({
|
|
2786
2707
|
type: modelScalarFieldEntityType,
|
|
2787
2708
|
onDelete: 'DELETE',
|
|
2788
|
-
|
|
2709
|
+
parentSlot: modelSlot,
|
|
2789
2710
|
}))
|
|
2790
2711
|
.optional(),
|
|
2791
2712
|
transformerNames: z$j
|
|
2792
2713
|
.array(ctx.withRef({
|
|
2793
2714
|
type: modelTransformerEntityType,
|
|
2794
2715
|
onDelete: 'DELETE',
|
|
2795
|
-
|
|
2716
|
+
parentSlot: modelSlot,
|
|
2796
2717
|
}))
|
|
2797
2718
|
.optional(),
|
|
2798
2719
|
})
|
|
@@ -2804,14 +2725,14 @@ const createModelServiceSchema = definitionSchema((ctx) => z$j.object({
|
|
|
2804
2725
|
.array(ctx.withRef({
|
|
2805
2726
|
type: modelScalarFieldEntityType,
|
|
2806
2727
|
onDelete: 'DELETE',
|
|
2807
|
-
|
|
2728
|
+
parentSlot: modelSlot,
|
|
2808
2729
|
}))
|
|
2809
2730
|
.optional(),
|
|
2810
2731
|
transformerNames: z$j
|
|
2811
2732
|
.array(ctx.withRef({
|
|
2812
2733
|
type: modelTransformerEntityType,
|
|
2813
2734
|
onDelete: 'DELETE',
|
|
2814
|
-
|
|
2735
|
+
parentSlot: modelSlot,
|
|
2815
2736
|
}))
|
|
2816
2737
|
.optional(),
|
|
2817
2738
|
})
|
|
@@ -2823,9 +2744,11 @@ const createModelServiceSchema = definitionSchema((ctx) => z$j.object({
|
|
|
2823
2744
|
.default({
|
|
2824
2745
|
enabled: false,
|
|
2825
2746
|
}),
|
|
2826
|
-
transformers: z$j
|
|
2747
|
+
transformers: z$j
|
|
2748
|
+
.array(createTransformerSchema(ctx, { modelSlot }))
|
|
2749
|
+
.default([]),
|
|
2827
2750
|
}));
|
|
2828
|
-
const createModelBaseSchema =
|
|
2751
|
+
const createModelBaseSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, slots) => z$j.object({
|
|
2829
2752
|
id: z$j.string(),
|
|
2830
2753
|
name: VALIDATORS.PASCAL_CASE_STRING,
|
|
2831
2754
|
featureRef: ctx.withRef({
|
|
@@ -2833,31 +2756,33 @@ const createModelBaseSchema = definitionSchema((ctx) => z$j.object({
|
|
|
2833
2756
|
onDelete: 'RESTRICT',
|
|
2834
2757
|
}),
|
|
2835
2758
|
model: z$j.object({
|
|
2836
|
-
fields: z$j.array(createModelScalarFieldSchema(ctx)),
|
|
2837
|
-
relations: z$j
|
|
2759
|
+
fields: z$j.array(createModelScalarFieldSchema(ctx, slots)),
|
|
2760
|
+
relations: z$j
|
|
2761
|
+
.array(createModelRelationFieldSchema(ctx, slots))
|
|
2762
|
+
.optional(),
|
|
2838
2763
|
primaryKeyFieldRefs: z$j
|
|
2839
2764
|
.array(ctx.withRef({
|
|
2840
2765
|
type: modelScalarFieldEntityType,
|
|
2841
2766
|
onDelete: 'RESTRICT',
|
|
2842
|
-
|
|
2767
|
+
parentSlot: slots.modelSlot,
|
|
2843
2768
|
}))
|
|
2844
2769
|
.min(1),
|
|
2845
2770
|
uniqueConstraints: z$j
|
|
2846
|
-
.array(createModelUniqueConstraintSchema(ctx))
|
|
2771
|
+
.array(createModelUniqueConstraintSchema(ctx, slots))
|
|
2847
2772
|
.optional(),
|
|
2848
2773
|
}),
|
|
2849
|
-
service: createModelServiceSchema(ctx).default({
|
|
2774
|
+
service: createModelServiceSchema(ctx, slots).default({
|
|
2850
2775
|
create: { enabled: false },
|
|
2851
2776
|
update: { enabled: false },
|
|
2852
2777
|
delete: { enabled: false },
|
|
2853
2778
|
transformers: [],
|
|
2854
2779
|
}),
|
|
2855
|
-
graphql: ctx.withDefault(createModelGraphqlSchema(ctx).optional(), {}),
|
|
2780
|
+
graphql: ctx.withDefault(createModelGraphqlSchema(ctx, slots).optional(), {}),
|
|
2856
2781
|
}));
|
|
2857
|
-
const createModelSchema = definitionSchema((ctx) => ctx.withEnt(createModelBaseSchema(ctx), {
|
|
2782
|
+
const createModelSchema = definitionSchema((ctx) => ctx.refContext({ modelSlot: modelEntityType }, ({ modelSlot }) => ctx.withEnt(createModelBaseSchema(ctx, { modelSlot }), {
|
|
2858
2783
|
type: modelEntityType,
|
|
2859
|
-
|
|
2860
|
-
}));
|
|
2784
|
+
provides: modelSlot,
|
|
2785
|
+
})));
|
|
2861
2786
|
|
|
2862
2787
|
const adminSectionEntityType = createEntityType('admin-section', {
|
|
2863
2788
|
parentType: appEntityType,
|
|
@@ -2879,7 +2804,7 @@ const createBaseAdminSectionValidators = definitionSchema((ctx) => z$i.object({
|
|
|
2879
2804
|
}));
|
|
2880
2805
|
|
|
2881
2806
|
const {z: z$h} = await importShared('zod');
|
|
2882
|
-
const baseAdminCrudActionSchema = z$h.
|
|
2807
|
+
const baseAdminCrudActionSchema = z$h.looseObject({
|
|
2883
2808
|
id: z$h
|
|
2884
2809
|
.string()
|
|
2885
2810
|
.min(1)
|
|
@@ -2942,29 +2867,20 @@ const adminCrudActionSpec = createPluginSpec('core/admin-crud-action', {
|
|
|
2942
2867
|
defaultInitializer: createAdminCrudActionImplementation,
|
|
2943
2868
|
});
|
|
2944
2869
|
|
|
2945
|
-
const createAdminCrudActionSchema = definitionSchema((ctx) =>
|
|
2946
|
-
.
|
|
2947
|
-
type: adminCrudActionEntityType,
|
|
2948
|
-
parentPath: {
|
|
2949
|
-
context: 'admin-section',
|
|
2950
|
-
},
|
|
2951
|
-
getNameResolver: (value) => value.type,
|
|
2952
|
-
})
|
|
2953
|
-
.transform((data, parseCtx) => {
|
|
2954
|
-
const { type } = data;
|
|
2955
|
-
const crudAction = ctx.plugins
|
|
2870
|
+
const createAdminCrudActionSchema = definitionSchema((ctx) => {
|
|
2871
|
+
const adminCrudActions = ctx.plugins
|
|
2956
2872
|
.getPluginSpec(adminCrudActionSpec)
|
|
2957
|
-
.
|
|
2958
|
-
return
|
|
2959
|
-
.
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2873
|
+
.getAdminCrudActions();
|
|
2874
|
+
return baseAdminCrudActionSchema.transform((data) => {
|
|
2875
|
+
const actionDef = adminCrudActions.get(data.type);
|
|
2876
|
+
if (!actionDef)
|
|
2877
|
+
return data;
|
|
2878
|
+
return actionDef.createSchema(ctx).parse(data);
|
|
2963
2879
|
});
|
|
2964
|
-
})
|
|
2880
|
+
});
|
|
2965
2881
|
|
|
2966
2882
|
const {z: z$f} = await importShared('zod');
|
|
2967
|
-
const baseAdminCrudColumnSchema = z$f.
|
|
2883
|
+
const baseAdminCrudColumnSchema = z$f.looseObject({
|
|
2968
2884
|
id: z$f
|
|
2969
2885
|
.string()
|
|
2970
2886
|
.min(1)
|
|
@@ -2981,12 +2897,12 @@ const adminCrudColumnEntityType = createEntityType('admin-crud-column', {
|
|
|
2981
2897
|
|
|
2982
2898
|
const {z: z$e} = await importShared('zod');
|
|
2983
2899
|
// Text Column
|
|
2984
|
-
const createAdminCrudTextColumnSchema =
|
|
2900
|
+
const createAdminCrudTextColumnSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, { modelSlot }) => baseAdminCrudColumnSchema.extend({
|
|
2985
2901
|
type: z$e.literal('text'),
|
|
2986
2902
|
modelFieldRef: ctx.withRef({
|
|
2987
2903
|
type: modelScalarFieldEntityType,
|
|
2988
2904
|
onDelete: 'RESTRICT',
|
|
2989
|
-
|
|
2905
|
+
parentSlot: modelSlot,
|
|
2990
2906
|
}),
|
|
2991
2907
|
}));
|
|
2992
2908
|
const adminCrudTextColumnType = createAdminCrudColumnType({
|
|
@@ -2994,12 +2910,12 @@ const adminCrudTextColumnType = createAdminCrudColumnType({
|
|
|
2994
2910
|
createSchema: createAdminCrudTextColumnSchema,
|
|
2995
2911
|
});
|
|
2996
2912
|
// Foreign Column
|
|
2997
|
-
const createAdminCrudForeignColumnSchema =
|
|
2913
|
+
const createAdminCrudForeignColumnSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, { modelSlot }) => baseAdminCrudColumnSchema.extend({
|
|
2998
2914
|
type: z$e.literal('foreign'),
|
|
2999
2915
|
localRelationRef: ctx.withRef({
|
|
3000
2916
|
type: modelLocalRelationEntityType,
|
|
3001
2917
|
onDelete: 'RESTRICT',
|
|
3002
|
-
|
|
2918
|
+
parentSlot: modelSlot,
|
|
3003
2919
|
}),
|
|
3004
2920
|
labelExpression: z$e.string().min(1),
|
|
3005
2921
|
valueExpression: z$e.string().min(1),
|
|
@@ -3041,29 +2957,20 @@ const adminCrudColumnSpec = createPluginSpec('core/admin-crud-column', {
|
|
|
3041
2957
|
defaultInitializer: createAdminCrudColumnImplementation,
|
|
3042
2958
|
});
|
|
3043
2959
|
|
|
3044
|
-
const createAdminCrudColumnSchema =
|
|
3045
|
-
.
|
|
3046
|
-
type: adminCrudColumnEntityType,
|
|
3047
|
-
parentPath: {
|
|
3048
|
-
context: 'admin-section',
|
|
3049
|
-
},
|
|
3050
|
-
getNameResolver: (value) => value.type,
|
|
3051
|
-
})
|
|
3052
|
-
.transform((data, parseCtx) => {
|
|
3053
|
-
const { type } = data;
|
|
3054
|
-
const crudColumn = ctx.plugins
|
|
2960
|
+
const createAdminCrudColumnSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType }, (ctx, slots) => {
|
|
2961
|
+
const adminCrudColumns = ctx.plugins
|
|
3055
2962
|
.getPluginSpec(adminCrudColumnSpec)
|
|
3056
|
-
.
|
|
3057
|
-
return
|
|
3058
|
-
.
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
2963
|
+
.getAdminCrudColumns();
|
|
2964
|
+
return baseAdminCrudColumnSchema.transform((data) => {
|
|
2965
|
+
const columnDef = adminCrudColumns.get(data.type);
|
|
2966
|
+
if (!columnDef)
|
|
2967
|
+
return data;
|
|
2968
|
+
return columnDef.createSchema(ctx, slots).parse(data);
|
|
3062
2969
|
});
|
|
3063
|
-
})
|
|
2970
|
+
});
|
|
3064
2971
|
|
|
3065
2972
|
const {z: z$d} = await importShared('zod');
|
|
3066
|
-
const baseAdminCrudInputSchema = z$d.
|
|
2973
|
+
const baseAdminCrudInputSchema = z$d.looseObject({
|
|
3067
2974
|
id: z$d
|
|
3068
2975
|
.string()
|
|
3069
2976
|
.min(1)
|
|
@@ -3082,13 +2989,13 @@ const adminCrudInputEntityType = createEntityType('admin-crud-input', {
|
|
|
3082
2989
|
});
|
|
3083
2990
|
|
|
3084
2991
|
const {z: z$c} = await importShared('zod');
|
|
3085
|
-
const createAdminCrudTextInputSchema =
|
|
2992
|
+
const createAdminCrudTextInputSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, { modelSlot }) => baseAdminCrudInputSchema.extend({
|
|
3086
2993
|
type: z$c.literal('text'),
|
|
3087
2994
|
label: z$c.string().min(1),
|
|
3088
2995
|
modelFieldRef: ctx.withRef({
|
|
3089
2996
|
type: modelScalarFieldEntityType,
|
|
3090
2997
|
onDelete: 'RESTRICT',
|
|
3091
|
-
|
|
2998
|
+
parentSlot: modelSlot,
|
|
3092
2999
|
}),
|
|
3093
3000
|
validation: z$c.string().optional(),
|
|
3094
3001
|
}));
|
|
@@ -3096,13 +3003,13 @@ const adminCrudTextInputType = createAdminCrudInputType({
|
|
|
3096
3003
|
name: 'text',
|
|
3097
3004
|
createSchema: createAdminCrudTextInputSchema,
|
|
3098
3005
|
});
|
|
3099
|
-
const createAdminCrudForeignInputSchema =
|
|
3006
|
+
const createAdminCrudForeignInputSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, { modelSlot }) => baseAdminCrudInputSchema.extend({
|
|
3100
3007
|
type: z$c.literal('foreign'),
|
|
3101
3008
|
label: z$c.string().min(1),
|
|
3102
3009
|
localRelationRef: ctx.withRef({
|
|
3103
3010
|
type: modelLocalRelationEntityType,
|
|
3104
3011
|
onDelete: 'RESTRICT',
|
|
3105
|
-
|
|
3012
|
+
parentSlot: modelSlot,
|
|
3106
3013
|
}),
|
|
3107
3014
|
labelExpression: z$c.string().min(1),
|
|
3108
3015
|
valueExpression: z$c.string().min(1),
|
|
@@ -3113,30 +3020,30 @@ const adminCrudForeignInputType = createAdminCrudInputType({
|
|
|
3113
3020
|
name: 'foreign',
|
|
3114
3021
|
createSchema: createAdminCrudForeignInputSchema,
|
|
3115
3022
|
});
|
|
3116
|
-
const createAdminCrudEnumInputSchema =
|
|
3023
|
+
const createAdminCrudEnumInputSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, { modelSlot }) => baseAdminCrudInputSchema.extend({
|
|
3117
3024
|
type: z$c.literal('enum'),
|
|
3118
3025
|
label: z$c.string().min(1),
|
|
3119
3026
|
modelFieldRef: ctx.withRef({
|
|
3120
3027
|
type: modelScalarFieldEntityType,
|
|
3121
3028
|
onDelete: 'RESTRICT',
|
|
3122
|
-
|
|
3029
|
+
parentSlot: modelSlot,
|
|
3123
3030
|
}),
|
|
3124
3031
|
}));
|
|
3125
3032
|
const adminCrudEnumInputType = createAdminCrudInputType({
|
|
3126
3033
|
name: 'enum',
|
|
3127
3034
|
createSchema: createAdminCrudEnumInputSchema,
|
|
3128
3035
|
});
|
|
3129
|
-
const createAdminCrudEmbeddedInputSchema =
|
|
3036
|
+
const createAdminCrudEmbeddedInputSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, { modelSlot, adminSectionSlot }) => baseAdminCrudInputSchema.extend({
|
|
3130
3037
|
type: z$c.literal('embedded'),
|
|
3131
3038
|
label: z$c.string().min(1),
|
|
3132
3039
|
modelRelationRef: ctx.withRef({
|
|
3133
3040
|
type: modelForeignRelationEntityType,
|
|
3134
3041
|
onDelete: 'RESTRICT',
|
|
3135
|
-
|
|
3042
|
+
parentSlot: modelSlot,
|
|
3136
3043
|
}),
|
|
3137
3044
|
embeddedFormRef: ctx.withRef({
|
|
3138
3045
|
type: adminCrudEmbeddedFormEntityType,
|
|
3139
|
-
|
|
3046
|
+
parentSlot: adminSectionSlot,
|
|
3140
3047
|
onDelete: 'RESTRICT',
|
|
3141
3048
|
}),
|
|
3142
3049
|
}));
|
|
@@ -3144,17 +3051,17 @@ const adminCrudEmbeddedInputType = createAdminCrudInputType({
|
|
|
3144
3051
|
name: 'embedded',
|
|
3145
3052
|
createSchema: createAdminCrudEmbeddedInputSchema,
|
|
3146
3053
|
});
|
|
3147
|
-
const createAdminCrudEmbeddedLocalInputSchema =
|
|
3054
|
+
const createAdminCrudEmbeddedLocalInputSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, { modelSlot, adminSectionSlot }) => baseAdminCrudInputSchema.extend({
|
|
3148
3055
|
type: z$c.literal('embeddedLocal'),
|
|
3149
3056
|
label: z$c.string().min(1),
|
|
3150
3057
|
localRelationRef: ctx.withRef({
|
|
3151
3058
|
type: modelLocalRelationEntityType,
|
|
3152
3059
|
onDelete: 'RESTRICT',
|
|
3153
|
-
|
|
3060
|
+
parentSlot: modelSlot,
|
|
3154
3061
|
}),
|
|
3155
3062
|
embeddedFormRef: ctx.withRef({
|
|
3156
3063
|
type: adminCrudEmbeddedFormEntityType,
|
|
3157
|
-
|
|
3064
|
+
parentSlot: adminSectionSlot,
|
|
3158
3065
|
onDelete: 'RESTRICT',
|
|
3159
3066
|
}),
|
|
3160
3067
|
}));
|
|
@@ -3207,121 +3114,115 @@ const adminCrudInputSpec = createPluginSpec('core/admin-crud-input', {
|
|
|
3207
3114
|
defaultInitializer: createAdminCrudInputImplementation,
|
|
3208
3115
|
});
|
|
3209
3116
|
|
|
3210
|
-
const createAdminCrudInputSchema =
|
|
3211
|
-
.
|
|
3212
|
-
type: adminCrudInputEntityType,
|
|
3213
|
-
parentPath: {
|
|
3214
|
-
context: 'admin-section',
|
|
3215
|
-
},
|
|
3216
|
-
getNameResolver: (value) => value.id ?? '',
|
|
3217
|
-
})
|
|
3218
|
-
.transform((data, parseCtx) => {
|
|
3219
|
-
const { type } = data;
|
|
3220
|
-
const crudInput = ctx.plugins
|
|
3117
|
+
const createAdminCrudInputSchema = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, slots) => {
|
|
3118
|
+
const adminCrudInputs = ctx.plugins
|
|
3221
3119
|
.getPluginSpec(adminCrudInputSpec)
|
|
3222
|
-
.
|
|
3223
|
-
return
|
|
3224
|
-
.
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3120
|
+
.getAdminCrudInputs();
|
|
3121
|
+
return baseAdminCrudInputSchema.transform((data) => {
|
|
3122
|
+
const inputDef = adminCrudInputs.get(data.type);
|
|
3123
|
+
if (!inputDef)
|
|
3124
|
+
return data;
|
|
3125
|
+
return inputDef.createSchema(ctx, slots).parse(data);
|
|
3228
3126
|
});
|
|
3229
|
-
})
|
|
3127
|
+
});
|
|
3230
3128
|
|
|
3231
3129
|
const {z: z$b} = await importShared('zod');
|
|
3232
3130
|
// Embedded Crud
|
|
3233
|
-
const
|
|
3131
|
+
const createAdminCrudEmbeddedObjectSchemaInternal = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, { modelSlot, adminSectionSlot }) => z$b.object({
|
|
3234
3132
|
id: z$b.string().min(1),
|
|
3235
3133
|
name: z$b.string().min(1),
|
|
3236
3134
|
modelRef: ctx.withRef({
|
|
3237
3135
|
type: modelEntityType,
|
|
3238
3136
|
onDelete: 'RESTRICT',
|
|
3137
|
+
provides: modelSlot,
|
|
3239
3138
|
}),
|
|
3240
3139
|
includeIdField: z$b.boolean().optional(),
|
|
3241
3140
|
type: z$b.literal('object'),
|
|
3242
3141
|
form: z$b.object({
|
|
3243
|
-
fields: z$b.array(createAdminCrudInputSchema(ctx)),
|
|
3142
|
+
fields: z$b.array(createAdminCrudInputSchema(ctx, { modelSlot, adminSectionSlot })),
|
|
3244
3143
|
}),
|
|
3245
3144
|
}));
|
|
3246
|
-
const
|
|
3145
|
+
const createAdminCrudEmbeddedListSchemaInternal = definitionSchemaWithSlots({ modelSlot: modelEntityType, adminSectionSlot: adminSectionEntityType }, (ctx, { modelSlot, adminSectionSlot }) => z$b.object({
|
|
3247
3146
|
id: z$b.string().min(1),
|
|
3248
3147
|
name: z$b.string().min(1),
|
|
3249
3148
|
modelRef: ctx.withRef({
|
|
3250
3149
|
type: modelEntityType,
|
|
3251
3150
|
onDelete: 'RESTRICT',
|
|
3151
|
+
provides: modelSlot,
|
|
3252
3152
|
}),
|
|
3253
3153
|
includeIdField: z$b.boolean().optional(),
|
|
3254
3154
|
type: z$b.literal('list'),
|
|
3255
3155
|
table: z$b.object({
|
|
3256
|
-
columns: z$b.array(createAdminCrudColumnSchema(ctx)),
|
|
3156
|
+
columns: z$b.array(createAdminCrudColumnSchema(ctx, { modelSlot })),
|
|
3257
3157
|
}),
|
|
3258
3158
|
form: z$b.object({
|
|
3259
|
-
fields: z$b.array(createAdminCrudInputSchema(ctx)),
|
|
3159
|
+
fields: z$b.array(createAdminCrudInputSchema(ctx, { modelSlot, adminSectionSlot })),
|
|
3260
3160
|
}),
|
|
3261
3161
|
}));
|
|
3262
|
-
const createAdminCrudEmbeddedFormSchema =
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3162
|
+
const createAdminCrudEmbeddedFormSchema = definitionSchemaWithSlots({ adminSectionSlot: adminSectionEntityType }, (ctx, { adminSectionSlot }) => ctx.refContext({ modelSlot: modelEntityType }, ({ modelSlot }) => ctx.withEnt(z$b.discriminatedUnion('type', [
|
|
3163
|
+
createAdminCrudEmbeddedObjectSchemaInternal(ctx, {
|
|
3164
|
+
modelSlot,
|
|
3165
|
+
adminSectionSlot,
|
|
3166
|
+
}),
|
|
3167
|
+
createAdminCrudEmbeddedListSchemaInternal(ctx, {
|
|
3168
|
+
modelSlot,
|
|
3169
|
+
adminSectionSlot,
|
|
3170
|
+
}),
|
|
3171
|
+
]), {
|
|
3172
|
+
type: adminCrudEmbeddedFormEntityType,
|
|
3173
|
+
parentSlot: adminSectionSlot,
|
|
3174
|
+
})));
|
|
3272
3175
|
// Admin Section
|
|
3273
|
-
const createAdminCrudSectionSchema =
|
|
3176
|
+
const createAdminCrudSectionSchema = definitionSchemaWithSlots({ adminSectionSlot: adminSectionEntityType }, (ctx, { adminSectionSlot }) => ctx.refContext({ modelSlot: modelEntityType }, ({ modelSlot }) => createBaseAdminSectionValidators(ctx).and(z$b.object({
|
|
3274
3177
|
type: z$b.literal('crud'),
|
|
3275
3178
|
modelRef: ctx.withRef({
|
|
3276
3179
|
type: modelEntityType,
|
|
3277
3180
|
onDelete: 'RESTRICT',
|
|
3181
|
+
provides: modelSlot,
|
|
3278
3182
|
}),
|
|
3279
3183
|
/* The field that will be used to display the name of the entity in the form */
|
|
3280
3184
|
nameFieldRef: ctx.withRef({
|
|
3281
3185
|
type: modelScalarFieldEntityType,
|
|
3282
3186
|
onDelete: 'RESTRICT',
|
|
3283
|
-
|
|
3284
|
-
context: 'model',
|
|
3285
|
-
},
|
|
3187
|
+
parentSlot: modelSlot,
|
|
3286
3188
|
}),
|
|
3287
3189
|
disableCreate: ctx.withDefault(z$b.boolean(), false),
|
|
3288
3190
|
table: z$b.object({
|
|
3289
|
-
columns: z$b.array(createAdminCrudColumnSchema(ctx)),
|
|
3191
|
+
columns: z$b.array(createAdminCrudColumnSchema(ctx, { modelSlot })),
|
|
3290
3192
|
actions: ctx.withDefault(z$b.array(createAdminCrudActionSchema(ctx)), [
|
|
3291
3193
|
{ type: 'edit', position: 'inline' },
|
|
3292
3194
|
{ type: 'delete', position: 'dropdown' },
|
|
3293
3195
|
]),
|
|
3294
3196
|
}),
|
|
3295
3197
|
form: z$b.object({
|
|
3296
|
-
fields: z$b.array(createAdminCrudInputSchema(ctx
|
|
3198
|
+
fields: z$b.array(createAdminCrudInputSchema(ctx, {
|
|
3199
|
+
modelSlot,
|
|
3200
|
+
adminSectionSlot,
|
|
3201
|
+
})),
|
|
3297
3202
|
}),
|
|
3298
3203
|
embeddedForms: z$b
|
|
3299
|
-
.array(createAdminCrudEmbeddedFormSchema(ctx))
|
|
3204
|
+
.array(createAdminCrudEmbeddedFormSchema(ctx, { adminSectionSlot }))
|
|
3300
3205
|
.optional(),
|
|
3301
|
-
}))
|
|
3302
|
-
builder.addPathToContext('modelRef', modelEntityType, 'model');
|
|
3303
|
-
}));
|
|
3206
|
+
}))));
|
|
3304
3207
|
|
|
3305
3208
|
const {z: z$a} = await importShared('zod');
|
|
3306
|
-
const createWebAdminSectionSchema =
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
}));
|
|
3313
|
-
const createAdminAppSchema = definitionSchema((ctx) => ctx.withDefault(z$a.object({
|
|
3209
|
+
const createWebAdminSectionSchema = definitionSchemaWithSlots({ appSlot: appEntityType }, (ctx, { appSlot }) => ctx.refContext({ adminSectionSlot: adminSectionEntityType }, ({ adminSectionSlot }) => ctx.withEnt(createAdminCrudSectionSchema(ctx, { adminSectionSlot }), {
|
|
3210
|
+
type: adminSectionEntityType,
|
|
3211
|
+
parentSlot: appSlot,
|
|
3212
|
+
provides: adminSectionSlot,
|
|
3213
|
+
})));
|
|
3214
|
+
const createAdminAppSchema = definitionSchemaWithSlots({ appSlot: appEntityType }, (ctx, { appSlot }) => ctx.withDefault(z$a.object({
|
|
3314
3215
|
enabled: z$a.boolean(),
|
|
3315
3216
|
pathPrefix: z$a.string().default('/admin'),
|
|
3316
3217
|
allowedRoles: ctx.withDefault(z$a.array(ctx.withRef({
|
|
3317
3218
|
type: authRoleEntityType,
|
|
3318
3219
|
onDelete: 'DELETE',
|
|
3319
3220
|
})), []),
|
|
3320
|
-
sections: ctx.withDefault(z$a.array(createWebAdminSectionSchema(ctx)), []),
|
|
3221
|
+
sections: ctx.withDefault(z$a.array(createWebAdminSectionSchema(ctx, { appSlot })), []),
|
|
3321
3222
|
}), { enabled: false, pathPrefix: '/admin' }));
|
|
3322
3223
|
|
|
3323
3224
|
const {z: z$9} = await importShared('zod');
|
|
3324
|
-
const createWebAppSchema =
|
|
3225
|
+
const createWebAppSchema = definitionSchemaWithSlots({ appSlot: appEntityType }, (ctx, { appSlot }) => z$9.object({
|
|
3325
3226
|
...baseAppValidators,
|
|
3326
3227
|
type: z$9.literal('web'),
|
|
3327
3228
|
includeAuth: ctx.withDefault(z$9.boolean(), false),
|
|
@@ -3329,7 +3230,7 @@ const createWebAppSchema = definitionSchema((ctx) => z$9.object({
|
|
|
3329
3230
|
description: z$9.string().default(''),
|
|
3330
3231
|
includeUploadComponents: ctx.withDefault(z$9.boolean(), false),
|
|
3331
3232
|
enableSubscriptions: ctx.withDefault(z$9.boolean(), false),
|
|
3332
|
-
adminApp: createAdminAppSchema(ctx),
|
|
3233
|
+
adminApp: createAdminAppSchema(ctx, { appSlot }),
|
|
3333
3234
|
}));
|
|
3334
3235
|
const webAppEntryType = createAppEntryType('web');
|
|
3335
3236
|
|
|
@@ -3343,23 +3244,20 @@ const basePluginDefinitionSchema = z$8.object({
|
|
|
3343
3244
|
configSchemaVersion: z$8.number().optional(),
|
|
3344
3245
|
});
|
|
3345
3246
|
const createPluginWithConfigSchema = definitionSchema((ctx) => ctx
|
|
3346
|
-
.withEnt(basePluginDefinitionSchema
|
|
3247
|
+
.withEnt(basePluginDefinitionSchema, {
|
|
3347
3248
|
type: pluginEntityType,
|
|
3348
3249
|
})
|
|
3349
|
-
.transform((data
|
|
3250
|
+
.transform((data) => {
|
|
3350
3251
|
const pluginKey = pluginEntityType.keyFromId(data.id);
|
|
3351
3252
|
const createConfigSchema = ctx.plugins
|
|
3352
3253
|
.getPluginSpec(pluginConfigSpec)
|
|
3353
3254
|
.getSchemaCreator(pluginKey);
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
}
|
|
3360
|
-
return pluginDefinitionSchema.parse(data, {
|
|
3361
|
-
path: parseCtx.path,
|
|
3362
|
-
});
|
|
3255
|
+
if (!createConfigSchema)
|
|
3256
|
+
return data;
|
|
3257
|
+
return {
|
|
3258
|
+
...data,
|
|
3259
|
+
config: createConfigSchema(ctx).parse(data.config),
|
|
3260
|
+
};
|
|
3363
3261
|
}));
|
|
3364
3262
|
const createPluginsSchema = definitionSchema((ctx) => z$8.array(createPluginWithConfigSchema(ctx)));
|
|
3365
3263
|
|
|
@@ -3530,7 +3428,7 @@ const oklchColor = z$3
|
|
|
3530
3428
|
*
|
|
3531
3429
|
* Maps semantic color keys (e.g. "background", "foreground", "primary") to OKLCH color values.
|
|
3532
3430
|
*/
|
|
3533
|
-
const themeColorSchema = z$3.record(z$3.enum(THEME_COLOR_KEYS), oklchColor);
|
|
3431
|
+
const themeColorSchema = z$3.record(z$3.enum(THEME_COLOR_KEYS), oklchColor.optional());
|
|
3534
3432
|
/**
|
|
3535
3433
|
* Palette configuration schema
|
|
3536
3434
|
*
|
|
@@ -3648,15 +3546,13 @@ const createSettingsSchema = definitionSchema((ctx) => z$2.object({
|
|
|
3648
3546
|
}));
|
|
3649
3547
|
|
|
3650
3548
|
const {z: z$1} = await importShared('zod');
|
|
3651
|
-
const createAppSchema = definitionSchema((ctx) => ctx.
|
|
3652
|
-
createBackendAppSchema(ctx),
|
|
3653
|
-
createWebAppSchema(ctx),
|
|
3654
|
-
]),
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
});
|
|
3659
|
-
}));
|
|
3549
|
+
const createAppSchema = definitionSchema((ctx) => ctx.refContext({ appSlot: appEntityType }, ({ appSlot }) => ctx.withEnt(z$1.discriminatedUnion('type', [
|
|
3550
|
+
createBackendAppSchema(ctx, { appSlot }),
|
|
3551
|
+
createWebAppSchema(ctx, { appSlot }),
|
|
3552
|
+
]), {
|
|
3553
|
+
type: appEntityType,
|
|
3554
|
+
provides: appSlot,
|
|
3555
|
+
})));
|
|
3660
3556
|
const createProjectDefinitionSchema = definitionSchema((ctx) => z$1.object({
|
|
3661
3557
|
cliVersion: z$1.string().nullish(),
|
|
3662
3558
|
apps: z$1.array(createAppSchema(ctx)).default([]),
|
|
@@ -3724,7 +3620,9 @@ function getModelValidator(modelField) {
|
|
|
3724
3620
|
case 'date': {
|
|
3725
3621
|
return 'string()';
|
|
3726
3622
|
}
|
|
3727
|
-
case 'int':
|
|
3623
|
+
case 'int': {
|
|
3624
|
+
return 'int()';
|
|
3625
|
+
}
|
|
3728
3626
|
case 'float': {
|
|
3729
3627
|
return 'number()';
|
|
3730
3628
|
}
|
|
@@ -3746,12 +3644,6 @@ function getModelFieldValidation(projectDefinition, modelId, fieldId, preProcess
|
|
|
3746
3644
|
throw new Error(`Field ${fieldId} not found in model ${model.name}`);
|
|
3747
3645
|
}
|
|
3748
3646
|
const nullishSuffix = field.isOptional ? '.nullish()' : '';
|
|
3749
|
-
if (field.type === 'int') {
|
|
3750
|
-
return `z.number().or(z.string()).pipe(z.coerce.number().finite().int())${nullishSuffix}`;
|
|
3751
|
-
}
|
|
3752
|
-
if (field.type === 'float') {
|
|
3753
|
-
return `z.number().or(z.string()).pipe(z.coerce.number().finite())${nullishSuffix}`;
|
|
3754
|
-
}
|
|
3755
3647
|
const validator = `z.${getModelValidator(field)}${nullishSuffix}`;
|
|
3756
3648
|
if (!preProcess) {
|
|
3757
3649
|
return validator;
|
|
@@ -3779,75 +3671,6 @@ function getTransformName(definitionContainer, transformer, pluginStore) {
|
|
|
3779
3671
|
}
|
|
3780
3672
|
const ModelTransformerUtils = { getTransformer, getTransformName };
|
|
3781
3673
|
|
|
3782
|
-
function byKey(projectDefinition, key) {
|
|
3783
|
-
const pluginEntityId = pluginEntityType.idFromKey(key);
|
|
3784
|
-
const plugin = projectDefinition.plugins?.find((m) => m.id === pluginEntityId);
|
|
3785
|
-
return plugin;
|
|
3786
|
-
}
|
|
3787
|
-
function byKeyOrThrow(projectDefinition, id) {
|
|
3788
|
-
const plugin = byKey(projectDefinition, id);
|
|
3789
|
-
if (!plugin) {
|
|
3790
|
-
throw new Error(`Could not find plugin with ID ${id}`);
|
|
3791
|
-
}
|
|
3792
|
-
return plugin;
|
|
3793
|
-
}
|
|
3794
|
-
function configByKey(projectDefinition, key) {
|
|
3795
|
-
const def = byKey(projectDefinition, key);
|
|
3796
|
-
return def?.config;
|
|
3797
|
-
}
|
|
3798
|
-
function configByKeyOrThrow(projectDefinition, key) {
|
|
3799
|
-
const def = byKeyOrThrow(projectDefinition, key);
|
|
3800
|
-
return def.config;
|
|
3801
|
-
}
|
|
3802
|
-
function setPluginConfig(projectDefinition, plugin, pluginConfig, pluginImplementationStore) {
|
|
3803
|
-
const plugins = projectDefinition.plugins ?? [];
|
|
3804
|
-
const pluginEntityId = pluginEntityType.idFromKey(plugin.key);
|
|
3805
|
-
const pluginConfigService = pluginImplementationStore.getPluginSpec(pluginConfigSpec);
|
|
3806
|
-
const lastMigrationVersion = pluginConfigService.getLastMigrationVersion(plugin.key);
|
|
3807
|
-
projectDefinition.plugins = plugins.some((p) => p.id === pluginEntityId)
|
|
3808
|
-
? plugins.map((p) => pluginEntityId === p.id ? { ...p, config: pluginConfig } : p)
|
|
3809
|
-
: [
|
|
3810
|
-
...plugins,
|
|
3811
|
-
{
|
|
3812
|
-
id: pluginEntityId,
|
|
3813
|
-
name: plugin.name,
|
|
3814
|
-
version: plugin.version,
|
|
3815
|
-
packageName: plugin.packageName,
|
|
3816
|
-
config: pluginConfig,
|
|
3817
|
-
configSchemaVersion: lastMigrationVersion,
|
|
3818
|
-
},
|
|
3819
|
-
];
|
|
3820
|
-
}
|
|
3821
|
-
/**
|
|
3822
|
-
* Disables a plugin and all plugins that it manages recursively.
|
|
3823
|
-
*
|
|
3824
|
-
* @param projectDefinition The project definition to disable the plugin in
|
|
3825
|
-
* @param pluginKey The ID of the plugin to disable
|
|
3826
|
-
* @param context The schema parser context to use
|
|
3827
|
-
*/
|
|
3828
|
-
function disablePlugin(projectDefinition, pluginKey, context) {
|
|
3829
|
-
// Get plugin metadata to be disabled
|
|
3830
|
-
const pluginMetadata = getPluginMetadataByKeyOrThrow(context.pluginStore, pluginKey);
|
|
3831
|
-
// Make sure we disable any plugins that are managed by this plugin
|
|
3832
|
-
const managedPlugins = projectDefinition.plugins?.filter((p) => {
|
|
3833
|
-
const managedPlugin = getPluginMetadataByKeyOrThrow(context.pluginStore, pluginEntityType.keyFromId(p.id));
|
|
3834
|
-
return managedPlugin.managedBy === pluginMetadata.fullyQualifiedName;
|
|
3835
|
-
});
|
|
3836
|
-
if (managedPlugins) {
|
|
3837
|
-
for (const p of managedPlugins)
|
|
3838
|
-
disablePlugin(projectDefinition, p.id, context);
|
|
3839
|
-
}
|
|
3840
|
-
projectDefinition.plugins = projectDefinition.plugins?.filter((p) => p.id !== pluginEntityType.idFromKey(pluginKey));
|
|
3841
|
-
}
|
|
3842
|
-
const PluginUtils = {
|
|
3843
|
-
byKey,
|
|
3844
|
-
byKeyOrThrow,
|
|
3845
|
-
configByKey,
|
|
3846
|
-
setPluginConfig,
|
|
3847
|
-
configByKeyOrThrow,
|
|
3848
|
-
disablePlugin,
|
|
3849
|
-
};
|
|
3850
|
-
|
|
3851
3674
|
const {z} = await importShared('zod');
|
|
3852
3675
|
const COMMON_SPEC_IMPLEMENTATIONS = [
|
|
3853
3676
|
pluginConfigSpec,
|
|
@@ -3923,6 +3746,7 @@ function createPluginImplementationStoreWithNewPlugins(pluginStore, plugins, pro
|
|
|
3923
3746
|
version: p.version,
|
|
3924
3747
|
name: p.name,
|
|
3925
3748
|
packageName: p.packageName,
|
|
3749
|
+
config: undefined,
|
|
3926
3750
|
})),
|
|
3927
3751
|
],
|
|
3928
3752
|
};
|
|
@@ -3961,6 +3785,83 @@ function parseProjectDefinitionWithReferences(projectDefinition, context) {
|
|
|
3961
3785
|
return { definition, pluginStore: pluginImplementationStore };
|
|
3962
3786
|
}
|
|
3963
3787
|
|
|
3788
|
+
function byKey(projectDefinition, key) {
|
|
3789
|
+
const pluginEntityId = pluginEntityType.idFromKey(key);
|
|
3790
|
+
const plugin = projectDefinition.plugins?.find((m) => m.id === pluginEntityId);
|
|
3791
|
+
return plugin;
|
|
3792
|
+
}
|
|
3793
|
+
function byKeyOrThrow(projectDefinition, id) {
|
|
3794
|
+
const plugin = byKey(projectDefinition, id);
|
|
3795
|
+
if (!plugin) {
|
|
3796
|
+
throw new Error(`Could not find plugin with ID ${id}`);
|
|
3797
|
+
}
|
|
3798
|
+
return plugin;
|
|
3799
|
+
}
|
|
3800
|
+
function configByKey(projectDefinition, key) {
|
|
3801
|
+
const def = byKey(projectDefinition, key);
|
|
3802
|
+
return def?.config;
|
|
3803
|
+
}
|
|
3804
|
+
function configByKeyOrThrow(projectDefinition, key) {
|
|
3805
|
+
const def = byKeyOrThrow(projectDefinition, key);
|
|
3806
|
+
return def.config;
|
|
3807
|
+
}
|
|
3808
|
+
function setPluginConfig(projectDefinition, plugin, pluginConfig, definitionContainer) {
|
|
3809
|
+
const plugins = projectDefinition.plugins ?? [];
|
|
3810
|
+
const pluginEntityId = pluginEntityType.idFromKey(plugin.key);
|
|
3811
|
+
const isNewPlugin = !plugins.some((p) => p.id === pluginEntityId);
|
|
3812
|
+
if (isNewPlugin) {
|
|
3813
|
+
// When adding a new plugin, we need to create an implementation store
|
|
3814
|
+
// that includes this plugin so its migrations are properly registered
|
|
3815
|
+
const pluginImplementationStore = createPluginImplementationStoreWithNewPlugins(definitionContainer.parserContext.pluginStore, [plugin], definitionContainer.definition);
|
|
3816
|
+
const pluginConfigService = pluginImplementationStore.getPluginSpec(pluginConfigSpec);
|
|
3817
|
+
const lastMigrationVersion = pluginConfigService.getLastMigrationVersion(plugin.key);
|
|
3818
|
+
projectDefinition.plugins = [
|
|
3819
|
+
...plugins,
|
|
3820
|
+
{
|
|
3821
|
+
id: pluginEntityId,
|
|
3822
|
+
name: plugin.name,
|
|
3823
|
+
version: plugin.version,
|
|
3824
|
+
packageName: plugin.packageName,
|
|
3825
|
+
config: pluginConfig,
|
|
3826
|
+
configSchemaVersion: lastMigrationVersion,
|
|
3827
|
+
},
|
|
3828
|
+
];
|
|
3829
|
+
}
|
|
3830
|
+
else {
|
|
3831
|
+
// When updating an existing plugin, just update the config
|
|
3832
|
+
projectDefinition.plugins = plugins.map((p) => pluginEntityId === p.id ? { ...p, config: pluginConfig } : p);
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
/**
|
|
3836
|
+
* Disables a plugin and all plugins that it manages recursively.
|
|
3837
|
+
*
|
|
3838
|
+
* @param projectDefinition The project definition to disable the plugin in
|
|
3839
|
+
* @param pluginKey The ID of the plugin to disable
|
|
3840
|
+
* @param context The schema parser context to use
|
|
3841
|
+
*/
|
|
3842
|
+
function disablePlugin(projectDefinition, pluginKey, context) {
|
|
3843
|
+
// Get plugin metadata to be disabled
|
|
3844
|
+
const pluginMetadata = getPluginMetadataByKeyOrThrow(context.pluginStore, pluginKey);
|
|
3845
|
+
// Make sure we disable any plugins that are managed by this plugin
|
|
3846
|
+
const managedPlugins = projectDefinition.plugins?.filter((p) => {
|
|
3847
|
+
const managedPlugin = getPluginMetadataByKeyOrThrow(context.pluginStore, pluginEntityType.keyFromId(p.id));
|
|
3848
|
+
return managedPlugin.managedBy === pluginMetadata.fullyQualifiedName;
|
|
3849
|
+
});
|
|
3850
|
+
if (managedPlugins) {
|
|
3851
|
+
for (const p of managedPlugins)
|
|
3852
|
+
disablePlugin(projectDefinition, p.id, context);
|
|
3853
|
+
}
|
|
3854
|
+
projectDefinition.plugins = projectDefinition.plugins?.filter((p) => p.id !== pluginEntityType.idFromKey(pluginKey));
|
|
3855
|
+
}
|
|
3856
|
+
const PluginUtils = {
|
|
3857
|
+
byKey,
|
|
3858
|
+
byKeyOrThrow,
|
|
3859
|
+
configByKey,
|
|
3860
|
+
setPluginConfig,
|
|
3861
|
+
configByKeyOrThrow,
|
|
3862
|
+
disablePlugin,
|
|
3863
|
+
};
|
|
3864
|
+
|
|
3964
3865
|
const {stringifyPrettyStable} = await importShared('@baseplate-dev/utils');
|
|
3965
3866
|
/**
|
|
3966
3867
|
* Container for a project definition that includes references and entities.
|
|
@@ -9296,6 +9197,81 @@ const migration020MoveRedisToInfrastructure = createSchemaMigration({
|
|
|
9296
9197
|
},
|
|
9297
9198
|
});
|
|
9298
9199
|
|
|
9200
|
+
/**
|
|
9201
|
+
* Migration to move enableBullQueue from backend apps to queue/bullmq plugins
|
|
9202
|
+
*
|
|
9203
|
+
* This migration:
|
|
9204
|
+
* 1. Finds backend apps with enableBullQueue: true
|
|
9205
|
+
* 2. If found, adds the queue parent plugin with implementationPluginKey pointing to bullmq
|
|
9206
|
+
* 3. Adds the bullmq child plugin with default config
|
|
9207
|
+
* 4. Removes enableBullQueue from all backend apps
|
|
9208
|
+
*/
|
|
9209
|
+
const migration021MigrateBullmqToPlugin = createSchemaMigration({
|
|
9210
|
+
version: 21,
|
|
9211
|
+
name: 'migrateBullmqToPlugin',
|
|
9212
|
+
description: 'Migrate enableBullQueue from backend apps to queue/bullmq plugins',
|
|
9213
|
+
migrate: (config) => {
|
|
9214
|
+
// Find if any backend app has enableBullQueue: true
|
|
9215
|
+
const hasBullQueue = config.apps?.some((app) => app.type === 'backend' && app.enableBullQueue === true);
|
|
9216
|
+
// Remove enableBullQueue from all apps
|
|
9217
|
+
const apps = config.apps?.map((app) => {
|
|
9218
|
+
if (app.type === 'backend' && 'enableBullQueue' in app) {
|
|
9219
|
+
const { enableBullQueue: _, ...rest } = app;
|
|
9220
|
+
return rest;
|
|
9221
|
+
}
|
|
9222
|
+
return app;
|
|
9223
|
+
});
|
|
9224
|
+
// If enableBullQueue was set, add the plugins
|
|
9225
|
+
const plugins = config.plugins ? [...config.plugins] : [];
|
|
9226
|
+
if (hasBullQueue) {
|
|
9227
|
+
const queuePluginId = 'plugin:baseplate-dev_plugin-queue_queue';
|
|
9228
|
+
const bullmqPluginId = 'plugin:baseplate-dev_plugin-queue_bullmq';
|
|
9229
|
+
// Add/update queue parent plugin
|
|
9230
|
+
const queuePluginIndex = plugins.findIndex((p) => p.id === queuePluginId);
|
|
9231
|
+
if (queuePluginIndex === -1) {
|
|
9232
|
+
plugins.push({
|
|
9233
|
+
id: queuePluginId,
|
|
9234
|
+
name: 'queue',
|
|
9235
|
+
packageName: '@baseplate-dev/plugin-queue',
|
|
9236
|
+
version: '1.0.0',
|
|
9237
|
+
config: {
|
|
9238
|
+
implementationPluginKey: 'baseplate-dev_plugin-queue_bullmq',
|
|
9239
|
+
},
|
|
9240
|
+
});
|
|
9241
|
+
}
|
|
9242
|
+
else {
|
|
9243
|
+
plugins[queuePluginIndex] = {
|
|
9244
|
+
...plugins[queuePluginIndex],
|
|
9245
|
+
config: {
|
|
9246
|
+
...plugins[queuePluginIndex].config,
|
|
9247
|
+
implementationPluginKey: 'baseplate-dev_plugin-queue_bullmq',
|
|
9248
|
+
},
|
|
9249
|
+
};
|
|
9250
|
+
}
|
|
9251
|
+
// Add bullmq child plugin if not exists
|
|
9252
|
+
const bullmqPluginIndex = plugins.findIndex((p) => p.id === bullmqPluginId);
|
|
9253
|
+
if (bullmqPluginIndex === -1) {
|
|
9254
|
+
plugins.push({
|
|
9255
|
+
id: bullmqPluginId,
|
|
9256
|
+
name: 'bullmq',
|
|
9257
|
+
packageName: '@baseplate-dev/plugin-queue',
|
|
9258
|
+
version: '1.0.0',
|
|
9259
|
+
config: {
|
|
9260
|
+
bullmqOptions: {
|
|
9261
|
+
deleteAfterDays: 7,
|
|
9262
|
+
},
|
|
9263
|
+
},
|
|
9264
|
+
});
|
|
9265
|
+
}
|
|
9266
|
+
}
|
|
9267
|
+
return {
|
|
9268
|
+
...config,
|
|
9269
|
+
apps,
|
|
9270
|
+
plugins,
|
|
9271
|
+
};
|
|
9272
|
+
},
|
|
9273
|
+
});
|
|
9274
|
+
|
|
9299
9275
|
const SCHEMA_MIGRATIONS = [
|
|
9300
9276
|
migration005PrimaryUniqueRefs,
|
|
9301
9277
|
migration006IndividualServiceControllers,
|
|
@@ -9313,6 +9289,7 @@ const SCHEMA_MIGRATIONS = [
|
|
|
9313
9289
|
migration018CrudNameFieldRef,
|
|
9314
9290
|
migration019ColumnTypeBased,
|
|
9315
9291
|
migration020MoveRedisToInfrastructure,
|
|
9292
|
+
migration021MigrateBullmqToPlugin,
|
|
9316
9293
|
];
|
|
9317
9294
|
function isMigrateableProjectDefinition(projectDefinition) {
|
|
9318
9295
|
return (typeof projectDefinition === 'object' &&
|
|
@@ -9378,7 +9355,7 @@ function createTestProjectDefinitionContainer(input = {}) {
|
|
|
9378
9355
|
const pluginStore = {
|
|
9379
9356
|
availablePlugins: [],
|
|
9380
9357
|
};
|
|
9381
|
-
const pluginImplementationStore =
|
|
9358
|
+
const pluginImplementationStore = createPluginImplementationStore(pluginStore, { plugins: [] });
|
|
9382
9359
|
const resolvedRefPayload = deserializeSchemaWithTransformedReferences(createProjectDefinitionSchema, createTestProjectDefinitionInput(input), { plugins: pluginImplementationStore });
|
|
9383
9360
|
return new ProjectDefinitionContainer(resolvedRefPayload, {
|
|
9384
9361
|
pluginStore,
|
|
@@ -10427,10 +10404,9 @@ function generateThemeColorsFromShade(palettes, mode, previousValues) {
|
|
|
10427
10404
|
return result;
|
|
10428
10405
|
}
|
|
10429
10406
|
function generateCssFromThemeConfig(config) {
|
|
10430
|
-
return Object.fromEntries(Object.entries(config)
|
|
10431
|
-
|
|
10432
|
-
value
|
|
10433
|
-
]));
|
|
10407
|
+
return Object.fromEntries(Object.entries(config)
|
|
10408
|
+
.filter((input) => input[1] !== undefined)
|
|
10409
|
+
.map(([key, value]) => [`--${inflectionExports.dasherize(inflectionExports.underscore(key))}`, value]));
|
|
10434
10410
|
}
|
|
10435
10411
|
function generateDefaultTheme() {
|
|
10436
10412
|
const slatePalette = {
|
|
@@ -10450,5 +10426,5 @@ function generateDefaultTheme() {
|
|
|
10450
10426
|
};
|
|
10451
10427
|
}
|
|
10452
10428
|
|
|
10453
|
-
export { AVAILABLE_FLAGS, AppUtils, BUILT_IN_ADMIN_CRUD_ACTIONS, BUILT_IN_ADMIN_CRUD_COLUMNS, BUILT_IN_ADMIN_CRUD_INPUTS, BUILT_IN_TRANSFORMERS, COLOR_PALETTES,
|
|
10454
|
-
//# sourceMappingURL=project-builder-lib-
|
|
10429
|
+
export { AVAILABLE_FLAGS, AppUtils, BUILT_IN_ADMIN_CRUD_ACTIONS, BUILT_IN_ADMIN_CRUD_COLUMNS, BUILT_IN_ADMIN_CRUD_INPUTS, BUILT_IN_TRANSFORMERS, COLOR_PALETTES, EnumUtils, FIXED_COLOR_MAPPINGS, ModelFieldUtils, ModelTransformerUtils, ModelUtils, PALETTE_SHADES, PluginImplementationStore, PluginUtils, ProjectDefinitionContainer, REFERENTIAL_ACTIONS, SCALAR_FIELD_TYPES, SCHEMA_MIGRATIONS, SchemaMigrationError, THEME_COLORS, THEME_COLOR_KEYS, VALIDATORS, adminCrudActionCompilerSpec, adminCrudActionEntityType, adminCrudActionSpec, adminCrudColumnCompilerSpec, adminCrudColumnEntityType, adminCrudColumnSpec, adminCrudEmbeddedFormEntityType, adminCrudEmbeddedInputType, adminCrudEmbeddedLocalInputType, adminCrudInputCompilerSpec, adminCrudInputEntityType, adminCrudInputSpec, adminCrudSectionColumnEntityType, adminSectionEntityType, appCompilerSpec, appEntityType, authConfigSpec, authModelConfigSpec, authRoleEntityType, backendAppEntryType, baseAdminCrudActionSchema, baseAdminCrudColumnSchema, baseAdminCrudInputSchema, baseAppSchema, baseAppValidators, basePluginDefinitionSchema, baseTransformerFields, baseTransformerSchema, convertColorNameToOklch, convertHexToOklch, convertOklchToColorName, convertOklchToHex, createAdminAppSchema, createAdminCrudActionCompilerImplementation, createAdminCrudActionImplementation, createAdminCrudActionSchema, createAdminCrudActionType, createAdminCrudColumnCompiler, createAdminCrudColumnCompilerImplementation, createAdminCrudColumnImplementation, createAdminCrudColumnSchema, createAdminCrudColumnType, createAdminCrudDeleteActionSchema, createAdminCrudEditActionSchema, createAdminCrudEmbeddedFormSchema, createAdminCrudEmbeddedInputSchema, createAdminCrudEmbeddedLocalInputSchema, createAdminCrudEnumInputSchema, createAdminCrudForeignColumnSchema, createAdminCrudForeignInputSchema, createAdminCrudInputCompilerImplementation, createAdminCrudInputImplementation, createAdminCrudInputSchema, createAdminCrudInputType, createAdminCrudPasswordInputSchema, createAdminCrudSectionSchema, createAdminCrudTextColumnSchema, createAdminCrudTextInputSchema, createAppCompiler, createAppCompilerPlugin, createAppEntryType, createAppSchema, createBackendAppSchema, createBaseAdminSectionValidators, createDefinitionEntityNameResolver, createDefinitionSchemaParserContext, createEmbeddedRelationTransformerSchema, createEntityType, createEnumBaseSchema, createEnumSchema, createEnumValueSchema, createFeaturesSchema, createModelBaseSchema, createModelGraphqlSchema, createModelRelationFieldSchema, createModelScalarFieldSchema, createModelSchema, createModelServiceSchema, createModelTransformerCompilerImplementation, createModelTransformerImplementation, createModelTransformerType, createModelUniqueConstraintSchema, createPlatformPluginExport, createPluginConfigImplementation, createPluginImplementationStore, createPluginImplementationStoreWithNewPlugins, createPluginSpec, createPluginWithConfigSchema, createPluginsSchema, createProjectDefinitionSchema, createProjectDefinitionSchemaWithContext, createSettingsSchema, createTemplateExtractorSchema, createTestProjectDefinition, createTestProjectDefinitionContainer, createTestProjectDefinitionInput, createThemeSchema, createTransformerSchema, createWebAdminSectionSchema, createWebAppSchema, createWebConfigImplementation, definitionSchema, definitionSchemaWithSlots, deserializeSchemaWithTransformedReferences, extractDefinitionRefs, featureEntityType, fixRefDeletions, generalSettingsSchema, generateCssFromThemeConfig, generateDefaultTheme, generateThemeColorsFromShade, getBackendRelativePath, getDefaultThemeColorFromShade, getLatestMigrationVersion, getManagedPluginsForPlugin, getPluginMetadataByKey, getPluginMetadataByKeyOrThrow, infrastructureSettingsSchema, initializePlugins, isMigrateableProjectDefinition, modelEntityType, modelEnumEntityType, modelEnumValueEntityType, modelForeignRelationEntityType, modelLocalRelationEntityType, modelScalarFieldEntityType, modelTransformerCompilerSpec, modelTransformerEntityType, modelTransformerSpec, modelUniqueConstraintEntityType, monorepoSettingsSchema, oklchColor, paletteSchema, palettesSchema, parseOklch, parseProjectDefinitionWithContext, parseProjectDefinitionWithReferences, pluginConfigSpec, pluginEntityType, pluginMetadataSchema, pluginSpecDependencySchema, pluginSpecSupportSchema, runPluginMigrations, runSchemaMigrations, serializeSchema, serializeSchemaFromRefPayload, stripEmptyGeneratorChildren, stripUndefinedValues, themeColorSchema, undefinedIfEmpty, undefinedIfFalsy, webAppEntryType, webConfigSpec };
|
|
10430
|
+
//# sourceMappingURL=project-builder-lib-FK4Jv94w.js.map
|