@baseplate-dev/plugin-auth 4.0.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +3 -3
- 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 +2 -12
- package/dist/auth/core/schema/plugin-definition.d.ts.map +1 -1
- package/dist/auth/core/schema/roles/schema.d.ts +2 -12
- package/dist/auth/core/schema/roles/schema.d.ts.map +1 -1
- package/dist/auth/core/schema/roles/schema.js +10 -17
- package/dist/auth/core/schema/roles/schema.js.map +1 -1
- package/dist/auth/plugin.json +1 -1
- package/dist/better-auth/constants/model-names.d.ts +8 -0
- package/dist/better-auth/constants/model-names.d.ts.map +1 -0
- package/dist/better-auth/constants/model-names.js +8 -0
- package/dist/better-auth/constants/model-names.js.map +1 -0
- package/dist/better-auth/constants/packages.d.ts +4 -0
- package/dist/better-auth/constants/packages.d.ts.map +1 -0
- package/dist/better-auth/constants/packages.js +4 -0
- package/dist/better-auth/constants/packages.js.map +1 -0
- package/dist/better-auth/core/common.d.ts.map +1 -0
- package/dist/better-auth/core/common.js +17 -0
- package/dist/better-auth/core/common.js.map +1 -0
- package/dist/better-auth/core/components/better-auth-definition-editor.d.ts +5 -0
- package/dist/better-auth/core/components/better-auth-definition-editor.d.ts.map +1 -0
- package/dist/{auth0/core/components/auth0-definition-editor.js → better-auth/core/components/better-auth-definition-editor.js} +17 -17
- package/dist/better-auth/core/components/better-auth-definition-editor.js.map +1 -0
- package/dist/better-auth/core/index.d.ts +2 -0
- package/dist/better-auth/core/index.d.ts.map +1 -0
- package/dist/better-auth/core/index.js +2 -0
- package/dist/better-auth/core/index.js.map +1 -0
- package/dist/better-auth/core/node.d.ts.map +1 -0
- package/dist/{auth0 → better-auth}/core/node.js +16 -14
- package/dist/better-auth/core/node.js.map +1 -0
- package/dist/better-auth/core/schema/models.d.ts +3 -0
- package/dist/better-auth/core/schema/models.d.ts.map +1 -0
- package/dist/better-auth/core/schema/models.js +278 -0
- package/dist/better-auth/core/schema/models.js.map +1 -0
- package/dist/better-auth/core/schema/plugin-definition.d.ts +5 -0
- package/dist/better-auth/core/schema/plugin-definition.d.ts.map +1 -0
- package/dist/better-auth/core/schema/plugin-definition.js +4 -0
- package/dist/better-auth/core/schema/plugin-definition.js.map +1 -0
- package/dist/better-auth/core/web.d.ts.map +1 -0
- package/dist/{auth0 → better-auth}/core/web.js +2 -2
- package/dist/better-auth/core/web.js.map +1 -0
- package/dist/{auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts → better-auth/generators/fastify/better-auth-module/better-auth-module.generator.d.ts} +20 -26
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.d.ts.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.js +75 -0
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.js.map +1 -0
- package/dist/{auth0/generators/fastify/auth0-module → better-auth/generators/fastify/better-auth-module}/generated/index.d.ts +41 -26
- package/dist/better-auth/generators/fastify/better-auth-module/generated/index.d.ts.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/index.js +11 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/index.js.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-paths.d.ts +16 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-paths.d.ts.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-paths.js +28 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-paths.js.map +1 -0
- package/dist/{auth0/generators/fastify/auth0-module → better-auth/generators/fastify/better-auth-module}/generated/template-renderers.d.ts +16 -10
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.d.ts.map +1 -0
- package/dist/{auth0/generators/fastify/auth0-module → better-auth/generators/fastify/better-auth-module}/generated/template-renderers.js +35 -16
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.js.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.d.ts +30 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.d.ts.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.js +37 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.js.map +1 -0
- package/dist/{auth0/generators/fastify/auth0-module → better-auth/generators/fastify/better-auth-module}/generated/typed-templates.d.ts +29 -20
- package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.d.ts.map +1 -0
- package/dist/{auth0/generators/fastify/auth0-module → better-auth/generators/fastify/better-auth-module}/generated/typed-templates.js +37 -9
- package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.js.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/index.d.ts +4 -0
- package/dist/better-auth/generators/fastify/better-auth-module/index.d.ts.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/index.js +3 -0
- package/dist/better-auth/generators/fastify/better-auth-module/index.js.map +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/plugins/better-auth.plugin.ts +31 -0
- package/dist/{auth0/generators/fastify/auth0-module → better-auth/generators/fastify/better-auth-module}/templates/module/schema/user-session.queries.ts +1 -1
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/services/auth.ts +62 -0
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/services/user-session.service.ts +72 -0
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/utils/headers.utils.ts +21 -0
- package/dist/better-auth/generators/fastify/index.d.ts +2 -0
- package/dist/better-auth/generators/fastify/index.d.ts.map +1 -0
- package/dist/better-auth/generators/fastify/index.js +2 -0
- package/dist/better-auth/generators/fastify/index.js.map +1 -0
- package/dist/better-auth/generators/index.d.ts.map +1 -0
- package/dist/better-auth/generators/index.js.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts → better-auth/generators/react/better-auth-hooks/better-auth-hooks.generator.d.ts} +11 -7
- package/dist/better-auth/generators/react/better-auth-hooks/better-auth-hooks.generator.d.ts.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks/auth0-hooks.generator.js → better-auth/generators/react/better-auth-hooks/better-auth-hooks.generator.js} +8 -8
- package/dist/better-auth/generators/react/better-auth-hooks/better-auth-hooks.generator.js.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks → better-auth/generators/react/better-auth-hooks}/generated/index.d.ts +21 -8
- package/dist/better-auth/generators/react/better-auth-hooks/generated/index.d.ts.map +1 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/index.js +11 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/index.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-paths.d.ts +14 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-paths.d.ts.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks → better-auth/generators/react/better-auth-hooks}/generated/template-paths.js +9 -7
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-paths.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-renderers.d.ts +27 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-renderers.d.ts.map +1 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-renderers.js +43 -0
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-renderers.js.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks → better-auth/generators/react/better-auth-hooks}/generated/ts-import-providers.d.ts +2 -2
- package/dist/better-auth/generators/react/better-auth-hooks/generated/ts-import-providers.d.ts.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks → better-auth/generators/react/better-auth-hooks}/generated/ts-import-providers.js +5 -5
- package/dist/better-auth/generators/react/better-auth-hooks/generated/ts-import-providers.js.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks → better-auth/generators/react/better-auth-hooks}/generated/typed-templates.d.ts +21 -3
- package/dist/better-auth/generators/react/better-auth-hooks/generated/typed-templates.d.ts.map +1 -0
- package/dist/{auth0/generators/react/auth0-hooks → better-auth/generators/react/better-auth-hooks}/generated/typed-templates.js +7 -3
- package/dist/better-auth/generators/react/better-auth-hooks/generated/typed-templates.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-hooks/index.d.ts +2 -0
- package/dist/better-auth/generators/react/better-auth-hooks/index.d.ts.map +1 -0
- package/dist/better-auth/generators/react/better-auth-hooks/index.js +2 -0
- package/dist/better-auth/generators/react/better-auth-hooks/index.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-hooks/templates/src/hooks/use-log-out.ts +18 -0
- package/dist/better-auth/generators/react/better-auth-hooks/templates/src/hooks/use-session.ts +30 -0
- package/dist/{auth0/generators/react/auth0-pages/auth0-pages.generator.d.ts → better-auth/generators/react/better-auth-pages/better-auth-pages.generator.d.ts} +15 -6
- package/dist/better-auth/generators/react/better-auth-pages/better-auth-pages.generator.d.ts.map +1 -0
- package/dist/{auth0/generators/react/auth0-pages/auth0-pages.generator.js → better-auth/generators/react/better-auth-pages/better-auth-pages.generator.js} +7 -7
- package/dist/better-auth/generators/react/better-auth-pages/better-auth-pages.generator.js.map +1 -0
- package/dist/{auth0/generators/react/auth0-pages → better-auth/generators/react/better-auth-pages}/generated/index.d.ts +246 -6
- package/dist/{auth0/generators/react/auth0-pages → better-auth/generators/react/better-auth-pages}/generated/index.d.ts.map +1 -1
- package/dist/better-auth/generators/react/better-auth-pages/generated/index.js +9 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/index.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-paths.d.ts +13 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-paths.d.ts.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-paths.js +25 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-paths.js.map +1 -0
- package/dist/{auth0/generators/react/react-auth0 → better-auth/generators/react/better-auth-pages}/generated/template-renderers.d.ts +13 -9
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.d.ts.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.js +44 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts +895 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.js +35 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/index.d.ts +2 -0
- package/dist/better-auth/generators/react/better-auth-pages/index.d.ts.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/index.js +2 -0
- package/dist/better-auth/generators/react/better-auth-pages/index.js.map +1 -0
- package/dist/better-auth/generators/react/better-auth-pages/templates/routes/auth/login.tsx +146 -0
- package/dist/better-auth/generators/react/better-auth-pages/templates/routes/auth/register.tsx +162 -0
- package/dist/better-auth/generators/react/index.d.ts +4 -0
- package/dist/better-auth/generators/react/index.d.ts.map +1 -0
- package/dist/better-auth/generators/react/index.js +4 -0
- package/dist/better-auth/generators/react/index.js.map +1 -0
- package/dist/{auth0/generators/react/react-auth0 → better-auth/generators/react/react-better-auth}/generated/index.d.ts +42 -7
- package/dist/{auth0/generators/react/react-auth0 → better-auth/generators/react/react-better-auth}/generated/index.d.ts.map +1 -1
- package/dist/better-auth/generators/react/react-better-auth/generated/index.js +11 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/index.js.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-paths.d.ts +13 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-paths.d.ts.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-paths.js +25 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-paths.js.map +1 -0
- package/dist/{auth0/generators/react/auth0-pages → better-auth/generators/react/react-better-auth}/generated/template-renderers.d.ts +28 -9
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.d.ts.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.js +51 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.js.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.d.ts +21 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.d.ts.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.js +30 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.js.map +1 -0
- package/dist/{auth0/generators/react/react-auth0 → better-auth/generators/react/react-better-auth}/generated/typed-templates.d.ts +16 -2
- package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.d.ts.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.js +33 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.js.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/index.d.ts +4 -0
- package/dist/better-auth/generators/react/react-better-auth/index.d.ts.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/index.js +3 -0
- package/dist/better-auth/generators/react/react-better-auth/index.js.map +1 -0
- package/dist/{auth0/generators/react/react-auth0/react-auth0.generator.d.ts → better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts} +28 -25
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.js +74 -0
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.js.map +1 -0
- package/dist/better-auth/generators/react/react-better-auth/templates/src/app/auth-loaded-gate.tsx +58 -0
- package/dist/better-auth/generators/react/react-better-auth/templates/src/services/auth-client.ts +15 -0
- package/dist/better-auth/index.d.ts +3 -0
- package/dist/better-auth/index.d.ts.map +1 -0
- package/dist/better-auth/index.js +2 -0
- package/dist/better-auth/index.js.map +1 -0
- package/dist/better-auth/plugin.json +9 -0
- package/dist/better-auth/static/icon.svg +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/local-auth/core/components/local-auth-definition-editor.d.ts.map +1 -1
- package/dist/local-auth/core/components/local-auth-definition-editor.js +11 -11
- 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-email-password/auth-email-password.generator.d.ts +8 -4
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.js +13 -3
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts +24 -14
- package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.d.ts +0 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.js +0 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts +3 -3
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.js +1 -11
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.d.ts +34 -16
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js +6 -23
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/password-reset.mutations.js +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/password-reset.mutations.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/password-reset.mutations.ts +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.js +2 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.ts +2 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.d.ts +3 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js +9 -5
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js.map +1 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.ts +11 -9
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts +11 -0
- 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 +25 -4
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/index.d.ts +24 -0
- package/dist/local-auth/core/generators/auth-module/generated/index.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.d.ts +2 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.js +2 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.js.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.js +25 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.js.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.js +6 -0
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.js.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts +18 -0
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts.map +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.js +30 -0
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.js.map +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.d.ts +6 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.d.ts.map +1 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.js +17 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.js.map +1 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.ts +21 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.d.ts.map +1 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.js.map +1 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +1 -1
- 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 +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js +1 -1
- 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 +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.js +34 -15
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.js.map +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.tsx +58 -15
- package/dist/local-auth/core/node.d.ts.map +1 -1
- package/dist/local-auth/core/node.js +8 -6
- package/dist/local-auth/core/node.js.map +1 -1
- package/dist/local-auth/core/schema/models.d.ts +2 -4
- package/dist/local-auth/core/schema/models.d.ts.map +1 -1
- package/dist/local-auth/core/schema/models.js +254 -252
- package/dist/local-auth/core/schema/models.js.map +1 -1
- package/dist/local-auth/core/schema/plugin-definition.d.ts +2 -2
- package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.d.ts.map +1 -1
- package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js +11 -11
- package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js.map +1 -1
- package/dist/placeholder-auth/core/schema/models.d.ts +2 -4
- package/dist/placeholder-auth/core/schema/models.d.ts.map +1 -1
- package/dist/placeholder-auth/core/schema/models.js +30 -28
- package/dist/placeholder-auth/core/schema/models.js.map +1 -1
- package/dist/web/assets/{__federation_expose_authCoreCommon-D3-Gk9mI.js → __federation_expose_authCoreCommon-CIVhaGqo.js} +3 -3
- package/dist/web/assets/{__federation_expose_authCoreCommon-D3-Gk9mI.js.map → __federation_expose_authCoreCommon-CIVhaGqo.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_authCoreWeb-DZoAij9e.js → __federation_expose_authCoreWeb-N-mh42Bs.js} +6 -6
- package/dist/web/assets/{__federation_expose_authCoreWeb-DZoAij9e.js.map → __federation_expose_authCoreWeb-N-mh42Bs.js.map} +1 -1
- package/dist/web/assets/__federation_expose_better-authCoreCommon-BIU3Fg7K.js +20 -0
- package/dist/web/assets/__federation_expose_better-authCoreCommon-BIU3Fg7K.js.map +1 -0
- package/dist/web/assets/__federation_expose_better-authCoreWeb-CMhPrXPA.js +402 -0
- package/dist/web/assets/__federation_expose_better-authCoreWeb-CMhPrXPA.js.map +1 -0
- package/dist/web/assets/{__federation_expose_local-authAdminCommon-BRHnF0Hn.js → __federation_expose_local-authAdminCommon-DvHe9w29.js} +2 -2
- package/dist/web/assets/{__federation_expose_local-authAdminCommon-BRHnF0Hn.js.map → __federation_expose_local-authAdminCommon-DvHe9w29.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_local-authAdminWeb-dYAIxuqC.js → __federation_expose_local-authAdminWeb-CLU9aEy9.js} +2 -2
- package/dist/web/assets/{__federation_expose_local-authAdminWeb-dYAIxuqC.js.map → __federation_expose_local-authAdminWeb-CLU9aEy9.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_local-authCoreCommon-CIwvOx0d.js → __federation_expose_local-authCoreCommon-DbuvGG7o.js} +3 -3
- package/dist/web/assets/{__federation_expose_local-authCoreCommon-CIwvOx0d.js.map → __federation_expose_local-authCoreCommon-DbuvGG7o.js.map} +1 -1
- package/dist/web/assets/__federation_expose_local-authCoreWeb-BY-mP3uS.js +432 -0
- package/dist/web/assets/__federation_expose_local-authCoreWeb-BY-mP3uS.js.map +1 -0
- package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-gFDSzGjB.js → __federation_expose_placeholder-authCoreCommon-BJBCuZvU.js} +3 -3
- package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-gFDSzGjB.js.map → __federation_expose_placeholder-authCoreCommon-BJBCuZvU.js.map} +1 -1
- package/dist/web/assets/{__federation_expose_placeholder-authCoreWeb-BZLwIkLk.js → __federation_expose_placeholder-authCoreWeb-BaV-Ko2C.js} +61 -53
- package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-BaV-Ko2C.js.map +1 -0
- package/dist/web/assets/{__federation_fn_import-pxYUpmb_.js → __federation_fn_import-BLFDCY-V.js} +2 -2
- package/dist/web/assets/{__federation_fn_import-pxYUpmb_.js.map → __federation_fn_import-BLFDCY-V.js.map} +1 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/{web-BXi2UCP-.js → web-bRU6KpPk.js} +48 -26
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-bRU6KpPk.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/{project-builder-lib-O0clDXMb.js → project-builder-lib-CQKLkNsU.js} +5705 -1957
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-CQKLkNsU.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-BpuFQk6s.js → ui-components-DhyoEUTy.js} +5889 -1194
- package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-DhyoEUTy.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/{utils-UiZ-8JBg.js → utils-9w-0yxVZ.js} +64 -45
- package/dist/web/assets/__federation_shared_@baseplate-dev/utils-9w-0yxVZ.js.map +1 -0
- package/dist/web/assets/__federation_shared_@tanstack/{react-router-BPEAtEJI.js → react-router-CbExBaoL.js} +2 -2
- package/dist/web/assets/__federation_shared_@tanstack/{react-router-BPEAtEJI.js.map → react-router-CbExBaoL.js.map} +1 -1
- package/dist/web/assets/{__federation_shared_zod-B6wbpZ4f.js → __federation_shared_zod-Do7Aa1b5.js} +3431 -2188
- package/dist/web/assets/__federation_shared_zod-Do7Aa1b5.js.map +1 -0
- package/dist/web/assets/{get-auth-plugin-definition-DPsrvQbo.js → get-auth-plugin-definition-BL50g0cJ.js} +2 -2
- package/dist/web/assets/{get-auth-plugin-definition-DPsrvQbo.js.map → get-auth-plugin-definition-BL50g0cJ.js.map} +1 -1
- package/dist/web/assets/{index-CSfs0UAV.js → index-B_A3cgiy.js} +2 -2
- package/dist/web/assets/{index-CSfs0UAV.js.map → index-B_A3cgiy.js.map} +1 -1
- package/dist/web/assets/{index.esm-BoRQu8mM.js → index.esm-BraHxHLB.js} +338 -231
- package/dist/web/assets/index.esm-BraHxHLB.js.map +1 -0
- package/dist/web/assets/{isEqual-BQtm2LNT.js → isEqual-tnzoadW8.js} +18 -18
- package/dist/web/assets/isEqual-tnzoadW8.js.map +1 -0
- package/dist/web/assets/mergeWith-VagwCqUi.js +76 -0
- package/dist/web/assets/mergeWith-VagwCqUi.js.map +1 -0
- package/dist/web/assets/model-utils-BfcjfzCn.js +694 -0
- package/dist/web/assets/model-utils-BfcjfzCn.js.map +1 -0
- package/dist/web/assets/plugin-definition-CXnKUJ1l.js +20 -0
- package/dist/web/assets/plugin-definition-CXnKUJ1l.js.map +1 -0
- package/dist/web/assets/{plugin-definition-DRhTuQas.js → plugin-definition-Ckl5hjD1.js} +2 -2
- package/dist/web/assets/{plugin-definition-DRhTuQas.js.map → plugin-definition-Ckl5hjD1.js.map} +1 -1
- package/dist/web/assets/{plugin-definition-BMYDEj3f.js → plugin-definition-D26rR8AB.js} +2 -2
- package/dist/web/assets/{plugin-definition-BMYDEj3f.js.map → plugin-definition-D26rR8AB.js.map} +1 -1
- package/dist/web/assets/{plugin-definition-j1nJ0FFI.js → plugin-definition-DJzXScRp.js} +12 -19
- package/dist/web/assets/plugin-definition-DJzXScRp.js.map +1 -0
- package/dist/web/assets/{react-CBhSWxr_.js → react-CL9M_wyN.js} +2 -2
- package/dist/web/assets/{react-CBhSWxr_.js.map → react-CL9M_wyN.js.map} +1 -1
- package/dist/web/assets/{registries-19UehlAo.js → registries-Tz_dluz3.js} +51 -13
- package/dist/web/assets/registries-Tz_dluz3.js.map +1 -0
- package/dist/web/assets/remoteEntry.js +14 -14
- package/dist/web/assets/{styles-BbHyE-2h.js → styles-tkrWV-ZE.js} +4 -4
- package/dist/web/assets/{styles-BbHyE-2h.js.map → styles-tkrWV-ZE.js.map} +1 -1
- package/package.json +17 -16
- package/dist/auth0/constants/model-names.d.ts +0 -4
- package/dist/auth0/constants/model-names.d.ts.map +0 -1
- package/dist/auth0/constants/model-names.js +0 -4
- package/dist/auth0/constants/model-names.js.map +0 -1
- package/dist/auth0/constants/packages.d.ts +0 -6
- package/dist/auth0/constants/packages.d.ts.map +0 -1
- package/dist/auth0/constants/packages.js +0 -6
- package/dist/auth0/constants/packages.js.map +0 -1
- package/dist/auth0/core/common.d.ts.map +0 -1
- package/dist/auth0/core/common.js +0 -19
- package/dist/auth0/core/common.js.map +0 -1
- package/dist/auth0/core/components/auth0-definition-editor.d.ts +0 -5
- package/dist/auth0/core/components/auth0-definition-editor.d.ts.map +0 -1
- package/dist/auth0/core/components/auth0-definition-editor.js.map +0 -1
- package/dist/auth0/core/node.d.ts.map +0 -1
- package/dist/auth0/core/node.js.map +0 -1
- package/dist/auth0/core/schema/migrations.d.ts +0 -3
- package/dist/auth0/core/schema/migrations.d.ts.map +0 -1
- package/dist/auth0/core/schema/migrations.js +0 -19
- package/dist/auth0/core/schema/migrations.js.map +0 -1
- package/dist/auth0/core/schema/models.d.ts +0 -5
- package/dist/auth0/core/schema/models.d.ts.map +0 -1
- package/dist/auth0/core/schema/models.js +0 -40
- package/dist/auth0/core/schema/models.js.map +0 -1
- package/dist/auth0/core/schema/plugin-definition.d.ts +0 -5
- package/dist/auth0/core/schema/plugin-definition.d.ts.map +0 -1
- package/dist/auth0/core/schema/plugin-definition.js +0 -4
- package/dist/auth0/core/schema/plugin-definition.js.map +0 -1
- package/dist/auth0/core/web.d.ts.map +0 -1
- package/dist/auth0/core/web.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js +0 -114
- package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/index.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/index.js +0 -11
- package/dist/auth0/generators/fastify/auth0-module/generated/index.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.d.ts +0 -14
- package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.js +0 -24
- package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/template-renderers.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/template-renderers.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.d.ts +0 -10
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.js +0 -23
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/typed-templates.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/generated/typed-templates.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/index.d.ts +0 -2
- package/dist/auth0/generators/fastify/auth0-module/index.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/index.js +0 -2
- package/dist/auth0/generators/fastify/auth0-module/index.js.map +0 -1
- package/dist/auth0/generators/fastify/auth0-module/templates/module/services/management.ts +0 -22
- package/dist/auth0/generators/fastify/auth0-module/templates/module/services/user-session.service.ts +0 -101
- package/dist/auth0/generators/fastify/index.d.ts +0 -2
- package/dist/auth0/generators/fastify/index.d.ts.map +0 -1
- package/dist/auth0/generators/fastify/index.js +0 -2
- package/dist/auth0/generators/fastify/index.js.map +0 -1
- package/dist/auth0/generators/index.d.ts.map +0 -1
- package/dist/auth0/generators/index.js.map +0 -1
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts +0 -10
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js +0 -41
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js.map +0 -1
- package/dist/auth0/generators/react/auth0-apollo/index.d.ts +0 -2
- package/dist/auth0/generators/react/auth0-apollo/index.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-apollo/index.js +0 -2
- package/dist/auth0/generators/react/auth0-apollo/index.js.map +0 -1
- package/dist/auth0/generators/react/auth0-apollo/templates/auth-link.ts +0 -11
- package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.js.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/index.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/index.js +0 -11
- package/dist/auth0/generators/react/auth0-hooks/generated/index.js.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/template-paths.d.ts +0 -14
- package/dist/auth0/generators/react/auth0-hooks/generated/template-paths.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/template-paths.js.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/template-renderers.d.ts +0 -23
- package/dist/auth0/generators/react/auth0-hooks/generated/template-renderers.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/template-renderers.js +0 -38
- package/dist/auth0/generators/react/auth0-hooks/generated/template-renderers.js.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-providers.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-providers.js.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/typed-templates.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/generated/typed-templates.js.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/index.d.ts +0 -2
- package/dist/auth0/generators/react/auth0-hooks/index.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/index.js +0 -2
- package/dist/auth0/generators/react/auth0-hooks/index.js.map +0 -1
- package/dist/auth0/generators/react/auth0-hooks/templates/src/hooks/use-log-out.ts +0 -14
- package/dist/auth0/generators/react/auth0-hooks/templates/src/hooks/use-session.ts +0 -36
- package/dist/auth0/generators/react/auth0-pages/auth0-pages.generator.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/auth0-pages.generator.js.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/generated/index.js +0 -9
- package/dist/auth0/generators/react/auth0-pages/generated/index.js.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/generated/template-paths.d.ts +0 -12
- package/dist/auth0/generators/react/auth0-pages/generated/template-paths.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/generated/template-paths.js +0 -20
- package/dist/auth0/generators/react/auth0-pages/generated/template-paths.js.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/generated/template-renderers.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/generated/template-renderers.js +0 -37
- package/dist/auth0/generators/react/auth0-pages/generated/template-renderers.js.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/generated/typed-templates.d.ts +0 -433
- package/dist/auth0/generators/react/auth0-pages/generated/typed-templates.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/generated/typed-templates.js +0 -18
- package/dist/auth0/generators/react/auth0-pages/generated/typed-templates.js.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/index.d.ts +0 -2
- package/dist/auth0/generators/react/auth0-pages/index.d.ts.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/index.js +0 -2
- package/dist/auth0/generators/react/auth0-pages/index.js.map +0 -1
- package/dist/auth0/generators/react/auth0-pages/templates/routes/login.tsx +0 -31
- package/dist/auth0/generators/react/index.d.ts +0 -5
- package/dist/auth0/generators/react/index.d.ts.map +0 -1
- package/dist/auth0/generators/react/index.js +0 -5
- package/dist/auth0/generators/react/index.js.map +0 -1
- package/dist/auth0/generators/react/react-auth0/generated/index.js +0 -9
- package/dist/auth0/generators/react/react-auth0/generated/index.js.map +0 -1
- package/dist/auth0/generators/react/react-auth0/generated/template-paths.d.ts +0 -12
- package/dist/auth0/generators/react/react-auth0/generated/template-paths.d.ts.map +0 -1
- package/dist/auth0/generators/react/react-auth0/generated/template-paths.js +0 -22
- package/dist/auth0/generators/react/react-auth0/generated/template-paths.js.map +0 -1
- package/dist/auth0/generators/react/react-auth0/generated/template-renderers.d.ts.map +0 -1
- package/dist/auth0/generators/react/react-auth0/generated/template-renderers.js +0 -39
- package/dist/auth0/generators/react/react-auth0/generated/template-renderers.js.map +0 -1
- package/dist/auth0/generators/react/react-auth0/generated/typed-templates.d.ts.map +0 -1
- package/dist/auth0/generators/react/react-auth0/generated/typed-templates.js +0 -17
- package/dist/auth0/generators/react/react-auth0/generated/typed-templates.js.map +0 -1
- package/dist/auth0/generators/react/react-auth0/index.d.ts +0 -2
- package/dist/auth0/generators/react/react-auth0/index.d.ts.map +0 -1
- package/dist/auth0/generators/react/react-auth0/index.js +0 -2
- package/dist/auth0/generators/react/react-auth0/index.js.map +0 -1
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts.map +0 -1
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.js +0 -107
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.js.map +0 -1
- package/dist/auth0/generators/react/react-auth0/templates/src/app/auth-loaded-gate.tsx +0 -78
- package/dist/auth0/plugin.json +0 -9
- package/dist/auth0/static/icon.svg +0 -7
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/auth-verification.service.d.ts.map +0 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/auth-verification.service.js.map +0 -1
- package/dist/web/assets/__federation_expose_auth0CoreCommon-DKJVe6Rd.js +0 -40
- package/dist/web/assets/__federation_expose_auth0CoreCommon-DKJVe6Rd.js.map +0 -1
- package/dist/web/assets/__federation_expose_auth0CoreWeb-CfhSWZsK.js +0 -158
- package/dist/web/assets/__federation_expose_auth0CoreWeb-CfhSWZsK.js.map +0 -1
- package/dist/web/assets/__federation_expose_local-authCoreWeb-Bwooi2qZ.js +0 -424
- package/dist/web/assets/__federation_expose_local-authCoreWeb-Bwooi2qZ.js.map +0 -1
- package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-BZLwIkLk.js.map +0 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-BXi2UCP-.js.map +0 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-O0clDXMb.js.map +0 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-BpuFQk6s.js.map +0 -1
- package/dist/web/assets/__federation_shared_@baseplate-dev/utils-UiZ-8JBg.js.map +0 -1
- package/dist/web/assets/__federation_shared_zod-B6wbpZ4f.js.map +0 -1
- package/dist/web/assets/index.esm-BoRQu8mM.js.map +0 -1
- package/dist/web/assets/isEqual-BQtm2LNT.js.map +0 -1
- package/dist/web/assets/model-merger-CdjliK9v.js +0 -1705
- package/dist/web/assets/model-merger-CdjliK9v.js.map +0 -1
- package/dist/web/assets/plugin-definition-BG6tu7Hh.js +0 -16
- package/dist/web/assets/plugin-definition-BG6tu7Hh.js.map +0 -1
- package/dist/web/assets/plugin-definition-j1nJ0FFI.js.map +0 -1
- package/dist/web/assets/registries-19UehlAo.js.map +0 -1
- package/dist/web/assets/sortBy-BPH_zRB8.js +0 -34
- package/dist/web/assets/sortBy-BPH_zRB8.js.map +0 -1
- /package/dist/{auth0 → better-auth}/core/common.d.ts +0 -0
- /package/dist/{auth0 → better-auth}/core/node.d.ts +0 -0
- /package/dist/{auth0 → better-auth}/core/web.d.ts +0 -0
- /package/dist/{auth0 → better-auth}/generators/index.d.ts +0 -0
- /package/dist/{auth0 → better-auth}/generators/index.js +0 -0
- /package/dist/{auth0/generators/react/auth0-hooks → better-auth/generators/react/better-auth-hooks}/templates/src/hooks/use-required-user-id.ts +0 -0
- /package/dist/local-auth/core/generators/{auth-email-password → auth-module}/templates/module/services/auth-verification.service.d.ts +0 -0
- /package/dist/local-auth/core/generators/{auth-email-password → auth-module}/templates/module/services/auth-verification.service.js +0 -0
- /package/dist/local-auth/core/generators/{auth-email-password → auth-module}/templates/module/services/auth-verification.service.ts +0 -0
|
@@ -1,1705 +0,0 @@
|
|
|
1
|
-
import { importShared } from './__federation_fn_import-pxYUpmb_.js';
|
|
2
|
-
import { g as getSymbols, a as isPlainObject, e as eq } from './isEqual-BQtm2LNT.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates a plugin spec with init and use phases.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const mySpec = createPluginSpec('core/my-spec', {
|
|
10
|
-
* initializer: () => {
|
|
11
|
-
* const items = new Map<string, Item>();
|
|
12
|
-
* return {
|
|
13
|
-
* init: {
|
|
14
|
-
* register: (item: Item) => items.set(item.name, item),
|
|
15
|
-
* },
|
|
16
|
-
* use: () => ({
|
|
17
|
-
* get: (name: string) => items.get(name),
|
|
18
|
-
* getAll: () => [...items.values()],
|
|
19
|
-
* }),
|
|
20
|
-
* };
|
|
21
|
-
* },
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @param name - Unique identifier for the spec (e.g., 'core/my-spec')
|
|
26
|
-
* @param options - Options including the initializer function
|
|
27
|
-
* @returns A plugin spec that can be used with SpecStore
|
|
28
|
-
*/
|
|
29
|
-
function createPluginSpec(name, options) {
|
|
30
|
-
const { initializer } = options;
|
|
31
|
-
return {
|
|
32
|
-
type: 'plugin-spec',
|
|
33
|
-
name,
|
|
34
|
-
initializer,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Plugin context module for tracking the current plugin being initialized.
|
|
40
|
-
*
|
|
41
|
-
* Uses a simple synchronous context that works on both Node and browser platforms.
|
|
42
|
-
* This is safe because plugin initialization is synchronous and single-threaded.
|
|
43
|
-
*/
|
|
44
|
-
// Simple synchronous context - works on both Node and browser
|
|
45
|
-
// Safe because plugin initialization is synchronous and single-threaded
|
|
46
|
-
let currentPluginContext;
|
|
47
|
-
/**
|
|
48
|
-
* Runs a function within a plugin context.
|
|
49
|
-
*
|
|
50
|
-
* This sets the current plugin context for the duration of the function execution,
|
|
51
|
-
* allowing nested functions to access the plugin key via `getPluginContext()`.
|
|
52
|
-
*
|
|
53
|
-
* @param context - The plugin context to set
|
|
54
|
-
* @param fn - The function to run within the context
|
|
55
|
-
* @returns The result of the function
|
|
56
|
-
*/
|
|
57
|
-
function runInPluginContext(context, fn) {
|
|
58
|
-
const prev = currentPluginContext;
|
|
59
|
-
currentPluginContext = context;
|
|
60
|
-
try {
|
|
61
|
-
return fn();
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
currentPluginContext = prev;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Gets the current plugin context if one exists.
|
|
69
|
-
*
|
|
70
|
-
* @returns The current plugin context, or undefined if not in a plugin context
|
|
71
|
-
*/
|
|
72
|
-
function getPluginContext() {
|
|
73
|
-
return currentPluginContext;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const {createFieldMap} = await importShared('@baseplate-dev/utils');
|
|
77
|
-
/**
|
|
78
|
-
* Creates a field map that automatically tracks which plugin registered each value.
|
|
79
|
-
*
|
|
80
|
-
* Similar to `createConfigFieldMap` in the sync package, this utility uses the
|
|
81
|
-
* current plugin context to track the source of registrations. This enables
|
|
82
|
-
* clear error messages when registration conflicts occur.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const fieldMap = createPluginFieldMap((t) => ({
|
|
87
|
-
* transformers: t.map<string, Transformer>(),
|
|
88
|
-
* }));
|
|
89
|
-
*
|
|
90
|
-
* // When a plugin tries to overwrite a value:
|
|
91
|
-
* // Error: Value for key 'myTransformer' has already been set by plugin-auth
|
|
92
|
-
* // and cannot be overwritten by plugin-storage
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @param schemaBuilder - A function that builds the field map schema
|
|
96
|
-
* @returns A field map with automatic source tracking
|
|
97
|
-
*/
|
|
98
|
-
function createPluginFieldMap(schemaBuilder) {
|
|
99
|
-
return createFieldMap(schemaBuilder, {
|
|
100
|
-
getDynamicSource: () => getPluginContext()?.pluginKey,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Creates a plugin spec backed by a FieldMap for automatic source tracking.
|
|
106
|
-
*
|
|
107
|
-
* @param name - Unique identifier for the spec
|
|
108
|
-
* @param schemaBuilder - Function that builds the field map schema
|
|
109
|
-
* @param options - Optional configuration including custom use interface
|
|
110
|
-
*/
|
|
111
|
-
function createFieldMapSpec(name, schemaBuilder, options) {
|
|
112
|
-
return createPluginSpec(name, {
|
|
113
|
-
initializer: () => {
|
|
114
|
-
const fieldMap = createPluginFieldMap(schemaBuilder);
|
|
115
|
-
return {
|
|
116
|
-
init: fieldMap,
|
|
117
|
-
use: () => {
|
|
118
|
-
const values = fieldMap.getValues();
|
|
119
|
-
if (options?.use) {
|
|
120
|
-
return options.use(values);
|
|
121
|
-
}
|
|
122
|
-
return values;
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function isPrimitive(value) {
|
|
130
|
-
return value == null || (typeof value !== 'object' && typeof value !== 'function');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function isTypedArray(x) {
|
|
134
|
-
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new Map(), cloneValue = undefined) {
|
|
138
|
-
const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
|
|
139
|
-
if (cloned != null) {
|
|
140
|
-
return cloned;
|
|
141
|
-
}
|
|
142
|
-
if (isPrimitive(valueToClone)) {
|
|
143
|
-
return valueToClone;
|
|
144
|
-
}
|
|
145
|
-
if (stack.has(valueToClone)) {
|
|
146
|
-
return stack.get(valueToClone);
|
|
147
|
-
}
|
|
148
|
-
if (Array.isArray(valueToClone)) {
|
|
149
|
-
const result = new Array(valueToClone.length);
|
|
150
|
-
stack.set(valueToClone, result);
|
|
151
|
-
for (let i = 0; i < valueToClone.length; i++) {
|
|
152
|
-
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
153
|
-
}
|
|
154
|
-
if (Object.hasOwn(valueToClone, 'index')) {
|
|
155
|
-
result.index = valueToClone.index;
|
|
156
|
-
}
|
|
157
|
-
if (Object.hasOwn(valueToClone, 'input')) {
|
|
158
|
-
result.input = valueToClone.input;
|
|
159
|
-
}
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
if (valueToClone instanceof Date) {
|
|
163
|
-
return new Date(valueToClone.getTime());
|
|
164
|
-
}
|
|
165
|
-
if (valueToClone instanceof RegExp) {
|
|
166
|
-
const result = new RegExp(valueToClone.source, valueToClone.flags);
|
|
167
|
-
result.lastIndex = valueToClone.lastIndex;
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
if (valueToClone instanceof Map) {
|
|
171
|
-
const result = new Map();
|
|
172
|
-
stack.set(valueToClone, result);
|
|
173
|
-
for (const [key, value] of valueToClone) {
|
|
174
|
-
result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
|
|
175
|
-
}
|
|
176
|
-
return result;
|
|
177
|
-
}
|
|
178
|
-
if (valueToClone instanceof Set) {
|
|
179
|
-
const result = new Set();
|
|
180
|
-
stack.set(valueToClone, result);
|
|
181
|
-
for (const value of valueToClone) {
|
|
182
|
-
result.add(cloneDeepWithImpl(value, undefined, objectToClone, stack, cloneValue));
|
|
183
|
-
}
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(valueToClone)) {
|
|
187
|
-
return valueToClone.subarray();
|
|
188
|
-
}
|
|
189
|
-
if (isTypedArray(valueToClone)) {
|
|
190
|
-
const result = new (Object.getPrototypeOf(valueToClone).constructor)(valueToClone.length);
|
|
191
|
-
stack.set(valueToClone, result);
|
|
192
|
-
for (let i = 0; i < valueToClone.length; i++) {
|
|
193
|
-
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
194
|
-
}
|
|
195
|
-
return result;
|
|
196
|
-
}
|
|
197
|
-
if (valueToClone instanceof ArrayBuffer ||
|
|
198
|
-
(typeof SharedArrayBuffer !== 'undefined' && valueToClone instanceof SharedArrayBuffer)) {
|
|
199
|
-
return valueToClone.slice(0);
|
|
200
|
-
}
|
|
201
|
-
if (valueToClone instanceof DataView) {
|
|
202
|
-
const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
|
|
203
|
-
stack.set(valueToClone, result);
|
|
204
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
205
|
-
return result;
|
|
206
|
-
}
|
|
207
|
-
if (typeof File !== 'undefined' && valueToClone instanceof File) {
|
|
208
|
-
const result = new File([valueToClone], valueToClone.name, {
|
|
209
|
-
type: valueToClone.type,
|
|
210
|
-
});
|
|
211
|
-
stack.set(valueToClone, result);
|
|
212
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
|
-
if (valueToClone instanceof Blob) {
|
|
216
|
-
const result = new Blob([valueToClone], { type: valueToClone.type });
|
|
217
|
-
stack.set(valueToClone, result);
|
|
218
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
|
-
if (valueToClone instanceof Error) {
|
|
222
|
-
const result = new valueToClone.constructor();
|
|
223
|
-
stack.set(valueToClone, result);
|
|
224
|
-
result.message = valueToClone.message;
|
|
225
|
-
result.name = valueToClone.name;
|
|
226
|
-
result.stack = valueToClone.stack;
|
|
227
|
-
result.cause = valueToClone.cause;
|
|
228
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
229
|
-
return result;
|
|
230
|
-
}
|
|
231
|
-
if (typeof valueToClone === 'object' && valueToClone !== null) {
|
|
232
|
-
const result = Object.create(Object.getPrototypeOf(valueToClone));
|
|
233
|
-
stack.set(valueToClone, result);
|
|
234
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
return valueToClone;
|
|
238
|
-
}
|
|
239
|
-
function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
|
|
240
|
-
const keys = [...Object.keys(source), ...getSymbols(source)];
|
|
241
|
-
for (let i = 0; i < keys.length; i++) {
|
|
242
|
-
const key = keys[i];
|
|
243
|
-
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
244
|
-
if (descriptor == null || descriptor.writable) {
|
|
245
|
-
target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function cloneDeep(obj) {
|
|
251
|
-
return cloneDeepWithImpl(obj, undefined, obj, new Map(), undefined);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function merge(target, source) {
|
|
255
|
-
const sourceKeys = Object.keys(source);
|
|
256
|
-
for (let i = 0; i < sourceKeys.length; i++) {
|
|
257
|
-
const key = sourceKeys[i];
|
|
258
|
-
const sourceValue = source[key];
|
|
259
|
-
const targetValue = target[key];
|
|
260
|
-
if (Array.isArray(sourceValue)) {
|
|
261
|
-
if (Array.isArray(targetValue)) {
|
|
262
|
-
target[key] = merge(targetValue, sourceValue);
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
target[key] = merge([], sourceValue);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else if (isPlainObject(sourceValue)) {
|
|
269
|
-
if (isPlainObject(targetValue)) {
|
|
270
|
-
target[key] = merge(targetValue, sourceValue);
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
target[key] = merge({}, sourceValue);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
else if (targetValue === undefined || sourceValue !== undefined) {
|
|
277
|
-
target[key] = sourceValue;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return target;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function toMerged(target, source) {
|
|
284
|
-
return merge(cloneDeep(target), source);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function isDeepKey(key) {
|
|
288
|
-
switch (typeof key) {
|
|
289
|
-
case 'number':
|
|
290
|
-
case 'symbol': {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
case 'string': {
|
|
294
|
-
return key.includes('.') || key.includes('[') || key.includes(']');
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function toKey(value) {
|
|
300
|
-
if (Object.is(value, -0)) {
|
|
301
|
-
return '-0';
|
|
302
|
-
}
|
|
303
|
-
return value.toString();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function toPath(deepKey) {
|
|
307
|
-
const result = [];
|
|
308
|
-
const length = deepKey.length;
|
|
309
|
-
if (length === 0) {
|
|
310
|
-
return result;
|
|
311
|
-
}
|
|
312
|
-
let index = 0;
|
|
313
|
-
let key = '';
|
|
314
|
-
let quoteChar = '';
|
|
315
|
-
let bracket = false;
|
|
316
|
-
if (deepKey.charCodeAt(0) === 46) {
|
|
317
|
-
result.push('');
|
|
318
|
-
index++;
|
|
319
|
-
}
|
|
320
|
-
while (index < length) {
|
|
321
|
-
const char = deepKey[index];
|
|
322
|
-
if (quoteChar) {
|
|
323
|
-
if (char === '\\' && index + 1 < length) {
|
|
324
|
-
index++;
|
|
325
|
-
key += deepKey[index];
|
|
326
|
-
}
|
|
327
|
-
else if (char === quoteChar) {
|
|
328
|
-
quoteChar = '';
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
key += char;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
else if (bracket) {
|
|
335
|
-
if (char === '"' || char === "'") {
|
|
336
|
-
quoteChar = char;
|
|
337
|
-
}
|
|
338
|
-
else if (char === ']') {
|
|
339
|
-
bracket = false;
|
|
340
|
-
result.push(key);
|
|
341
|
-
key = '';
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
key += char;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
if (char === '[') {
|
|
349
|
-
bracket = true;
|
|
350
|
-
if (key) {
|
|
351
|
-
result.push(key);
|
|
352
|
-
key = '';
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
else if (char === '.') {
|
|
356
|
-
if (key) {
|
|
357
|
-
result.push(key);
|
|
358
|
-
key = '';
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
key += char;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
index++;
|
|
366
|
-
}
|
|
367
|
-
if (key) {
|
|
368
|
-
result.push(key);
|
|
369
|
-
}
|
|
370
|
-
return result;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function get(object, path, defaultValue) {
|
|
374
|
-
if (object == null) {
|
|
375
|
-
return defaultValue;
|
|
376
|
-
}
|
|
377
|
-
switch (typeof path) {
|
|
378
|
-
case 'string': {
|
|
379
|
-
const result = object[path];
|
|
380
|
-
if (result === undefined) {
|
|
381
|
-
if (isDeepKey(path)) {
|
|
382
|
-
return get(object, toPath(path), defaultValue);
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
return defaultValue;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return result;
|
|
389
|
-
}
|
|
390
|
-
case 'number':
|
|
391
|
-
case 'symbol': {
|
|
392
|
-
if (typeof path === 'number') {
|
|
393
|
-
path = toKey(path);
|
|
394
|
-
}
|
|
395
|
-
const result = object[path];
|
|
396
|
-
if (result === undefined) {
|
|
397
|
-
return defaultValue;
|
|
398
|
-
}
|
|
399
|
-
return result;
|
|
400
|
-
}
|
|
401
|
-
default: {
|
|
402
|
-
if (Array.isArray(path)) {
|
|
403
|
-
return getWithPath(object, path, defaultValue);
|
|
404
|
-
}
|
|
405
|
-
if (Object.is(path?.valueOf(), -0)) {
|
|
406
|
-
path = '-0';
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
path = String(path);
|
|
410
|
-
}
|
|
411
|
-
const result = object[path];
|
|
412
|
-
if (result === undefined) {
|
|
413
|
-
return defaultValue;
|
|
414
|
-
}
|
|
415
|
-
return result;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
function getWithPath(object, path, defaultValue) {
|
|
420
|
-
if (path.length === 0) {
|
|
421
|
-
return defaultValue;
|
|
422
|
-
}
|
|
423
|
-
let current = object;
|
|
424
|
-
for (let index = 0; index < path.length; index++) {
|
|
425
|
-
if (current == null) {
|
|
426
|
-
return defaultValue;
|
|
427
|
-
}
|
|
428
|
-
current = current[path[index]];
|
|
429
|
-
}
|
|
430
|
-
if (current === undefined) {
|
|
431
|
-
return defaultValue;
|
|
432
|
-
}
|
|
433
|
-
return current;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
function isObject(value) {
|
|
437
|
-
return value !== null && (typeof value === 'object' || typeof value === 'function');
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
function isMatch(target, source) {
|
|
441
|
-
if (source === target) {
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
switch (typeof source) {
|
|
445
|
-
case 'object': {
|
|
446
|
-
if (source == null) {
|
|
447
|
-
return true;
|
|
448
|
-
}
|
|
449
|
-
const keys = Object.keys(source);
|
|
450
|
-
if (target == null) {
|
|
451
|
-
return keys.length === 0;
|
|
452
|
-
}
|
|
453
|
-
if (Array.isArray(source)) {
|
|
454
|
-
return isArrayMatch(target, source);
|
|
455
|
-
}
|
|
456
|
-
if (source instanceof Map) {
|
|
457
|
-
return isMapMatch(target, source);
|
|
458
|
-
}
|
|
459
|
-
if (source instanceof Set) {
|
|
460
|
-
return isSetMatch(target, source);
|
|
461
|
-
}
|
|
462
|
-
for (let i = 0; i < keys.length; i++) {
|
|
463
|
-
const key = keys[i];
|
|
464
|
-
if (!isPrimitive(target) && !(key in target)) {
|
|
465
|
-
return false;
|
|
466
|
-
}
|
|
467
|
-
if (source[key] === undefined && target[key] !== undefined) {
|
|
468
|
-
return false;
|
|
469
|
-
}
|
|
470
|
-
if (source[key] === null && target[key] !== null) {
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
if (!isMatch(target[key], source[key])) {
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return true;
|
|
478
|
-
}
|
|
479
|
-
case 'function': {
|
|
480
|
-
if (Object.keys(source).length > 0) {
|
|
481
|
-
return isMatch(target, { ...source });
|
|
482
|
-
}
|
|
483
|
-
return false;
|
|
484
|
-
}
|
|
485
|
-
default: {
|
|
486
|
-
if (!isObject(target)) {
|
|
487
|
-
return eq(target, source);
|
|
488
|
-
}
|
|
489
|
-
return !source;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
function isMapMatch(target, source) {
|
|
494
|
-
if (source.size === 0) {
|
|
495
|
-
return true;
|
|
496
|
-
}
|
|
497
|
-
if (!(target instanceof Map)) {
|
|
498
|
-
return false;
|
|
499
|
-
}
|
|
500
|
-
for (const [key, value] of source.entries()) {
|
|
501
|
-
if (!isMatch(target.get(key), value)) {
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return true;
|
|
506
|
-
}
|
|
507
|
-
function isArrayMatch(target, source) {
|
|
508
|
-
if (source.length === 0) {
|
|
509
|
-
return true;
|
|
510
|
-
}
|
|
511
|
-
if (!Array.isArray(target)) {
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
const countedIndex = new Set();
|
|
515
|
-
for (let i = 0; i < source.length; i++) {
|
|
516
|
-
const sourceItem = source[i];
|
|
517
|
-
const index = target.findIndex((targetItem, index) => {
|
|
518
|
-
return isMatch(targetItem, sourceItem) && !countedIndex.has(index);
|
|
519
|
-
});
|
|
520
|
-
if (index === -1) {
|
|
521
|
-
return false;
|
|
522
|
-
}
|
|
523
|
-
countedIndex.add(index);
|
|
524
|
-
}
|
|
525
|
-
return true;
|
|
526
|
-
}
|
|
527
|
-
function isSetMatch(target, source) {
|
|
528
|
-
if (source.size === 0) {
|
|
529
|
-
return true;
|
|
530
|
-
}
|
|
531
|
-
if (!(target instanceof Set)) {
|
|
532
|
-
return false;
|
|
533
|
-
}
|
|
534
|
-
return isArrayMatch([...target], [...source]);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
538
|
-
function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
|
|
539
|
-
switch (typeof value) {
|
|
540
|
-
case 'number': {
|
|
541
|
-
return Number.isInteger(value) && value >= 0 && value < length;
|
|
542
|
-
}
|
|
543
|
-
case 'symbol': {
|
|
544
|
-
return false;
|
|
545
|
-
}
|
|
546
|
-
case 'string': {
|
|
547
|
-
return IS_UNSIGNED_INTEGER.test(value);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
function set(obj, path, value) {
|
|
553
|
-
const resolvedPath = Array.isArray(path) ? path : typeof path === 'string' ? toPath(path) : [path];
|
|
554
|
-
let current = obj;
|
|
555
|
-
for (let i = 0; i < resolvedPath.length - 1; i++) {
|
|
556
|
-
const key = resolvedPath[i];
|
|
557
|
-
const nextKey = resolvedPath[i + 1];
|
|
558
|
-
if (current[key] == null) {
|
|
559
|
-
current[key] = isIndex(nextKey) ? [] : {};
|
|
560
|
-
}
|
|
561
|
-
current = current[key];
|
|
562
|
-
}
|
|
563
|
-
const lastKey = resolvedPath[resolvedPath.length - 1];
|
|
564
|
-
current[lastKey] = value;
|
|
565
|
-
return obj;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
function mapValues(object, getNewValue) {
|
|
569
|
-
const result = {};
|
|
570
|
-
const keys = Object.keys(object);
|
|
571
|
-
for (let i = 0; i < keys.length; i++) {
|
|
572
|
-
const key = keys[i];
|
|
573
|
-
const value = object[key];
|
|
574
|
-
result[key] = getNewValue(value, key, object);
|
|
575
|
-
}
|
|
576
|
-
return result;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
class DefinitionReferenceMarker {
|
|
580
|
-
value;
|
|
581
|
-
reference;
|
|
582
|
-
constructor(value, reference) {
|
|
583
|
-
this.value = value;
|
|
584
|
-
this.reference = reference;
|
|
585
|
-
}
|
|
586
|
-
toString() {
|
|
587
|
-
return this.value ?? '';
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Marker class for expressions during schema parsing.
|
|
592
|
-
* Similar to `DefinitionReferenceMarker`, this wraps expression values
|
|
593
|
-
* during the Zod parsing phase when `transformReferences` is enabled.
|
|
594
|
-
*/
|
|
595
|
-
class DefinitionExpressionMarker {
|
|
596
|
-
value;
|
|
597
|
-
expression;
|
|
598
|
-
constructor(value, expression) {
|
|
599
|
-
this.value = value;
|
|
600
|
-
this.expression = expression;
|
|
601
|
-
}
|
|
602
|
-
toString() {
|
|
603
|
-
return String(this.value);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
const REF_ANNOTATIONS_MARKER_SYMBOL = Symbol('refAnnotationsMarker');
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* Creates a new ref context slot for the given entity type.
|
|
610
|
-
* Each call creates a unique slot, even for the same entity type.
|
|
611
|
-
*
|
|
612
|
-
* @param name - A descriptive name for debugging (shows in Symbol description)
|
|
613
|
-
* @param entityType - The entity type this slot will be associated with
|
|
614
|
-
* @returns A new unique RefContextSlot instance
|
|
615
|
-
*
|
|
616
|
-
* @example
|
|
617
|
-
* ```typescript
|
|
618
|
-
* const modelSlot = createRefContextSlot('modelSlot', modelEntityType);
|
|
619
|
-
* const anotherModelSlot = createRefContextSlot('anotherModelSlot', modelEntityType);
|
|
620
|
-
*
|
|
621
|
-
* // These are different slots despite same entity type
|
|
622
|
-
* modelSlot.id !== anotherModelSlot.id
|
|
623
|
-
* // modelSlot.id.toString() === 'Symbol(modelSlot)'
|
|
624
|
-
* ```
|
|
625
|
-
*/
|
|
626
|
-
function createRefContextSlot(name, entityType) {
|
|
627
|
-
return {
|
|
628
|
-
entityType,
|
|
629
|
-
id: Symbol(name),
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* Creates a RefContextSlotMap from a slot definition.
|
|
634
|
-
* Used internally by ctx.refContext().
|
|
635
|
-
*
|
|
636
|
-
* @param slotDefinition - Map of slot names to entity types
|
|
637
|
-
* @returns Map of slot names to RefContextSlot instances
|
|
638
|
-
*/
|
|
639
|
-
function createRefContextSlotMap(slotDefinition) {
|
|
640
|
-
return Object.fromEntries(Object.entries(slotDefinition).map(([key, entityType]) => [
|
|
641
|
-
key,
|
|
642
|
-
createRefContextSlot(key, entityType),
|
|
643
|
-
]));
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* Strips the DefinitionReferenceMarker and DefinitionExpressionMarker from the value recursively.
|
|
648
|
-
* @param value - The value to strip the markers from.
|
|
649
|
-
* @returns The value without the markers.
|
|
650
|
-
*/
|
|
651
|
-
function stripRefMarkers(value) {
|
|
652
|
-
if (value instanceof DefinitionReferenceMarker) {
|
|
653
|
-
return value.value;
|
|
654
|
-
}
|
|
655
|
-
if (value instanceof DefinitionExpressionMarker) {
|
|
656
|
-
return value.value;
|
|
657
|
-
}
|
|
658
|
-
if (Array.isArray(value)) {
|
|
659
|
-
return value.map(stripRefMarkers);
|
|
660
|
-
}
|
|
661
|
-
if (typeof value === 'object' && value !== null) {
|
|
662
|
-
return Object.fromEntries(Object.entries(value).map(([key, childValue]) => [
|
|
663
|
-
key,
|
|
664
|
-
stripRefMarkers(childValue),
|
|
665
|
-
]));
|
|
666
|
-
}
|
|
667
|
-
return value;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const {z: z$1} = await importShared('zod');
|
|
671
|
-
function extendParserContextWithRefs({ transformReferences, }) {
|
|
672
|
-
function modifyAnnotations(value, ctx, modifier) {
|
|
673
|
-
if (value === null || value === undefined)
|
|
674
|
-
return value;
|
|
675
|
-
if (typeof value !== 'object') {
|
|
676
|
-
ctx.addIssue({
|
|
677
|
-
code: 'invalid_type',
|
|
678
|
-
expected: 'object',
|
|
679
|
-
message: `Entity must be an object`,
|
|
680
|
-
input: value,
|
|
681
|
-
});
|
|
682
|
-
return value;
|
|
683
|
-
}
|
|
684
|
-
if (transformReferences) {
|
|
685
|
-
const existingAnnotations = REF_ANNOTATIONS_MARKER_SYMBOL in value
|
|
686
|
-
? value[REF_ANNOTATIONS_MARKER_SYMBOL]
|
|
687
|
-
: { entities: [], references: [], slots: [] };
|
|
688
|
-
return {
|
|
689
|
-
...value,
|
|
690
|
-
[REF_ANNOTATIONS_MARKER_SYMBOL]: modifier(existingAnnotations),
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
return value;
|
|
694
|
-
}
|
|
695
|
-
function withRef(reference) {
|
|
696
|
-
return z$1.string().transform((value) => {
|
|
697
|
-
if (transformReferences && value) {
|
|
698
|
-
return new DefinitionReferenceMarker(value, {
|
|
699
|
-
path: [],
|
|
700
|
-
type: reference.type,
|
|
701
|
-
onDelete: reference.onDelete,
|
|
702
|
-
parentSlot: reference.parentSlot,
|
|
703
|
-
provides: reference.provides,
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
return value;
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
function withEnt(schema, entity) {
|
|
710
|
-
return schema.transform((value, ctx) => {
|
|
711
|
-
if (value === null || value === undefined)
|
|
712
|
-
return value;
|
|
713
|
-
if (transformReferences) {
|
|
714
|
-
if (typeof value !== 'object') {
|
|
715
|
-
ctx.addIssue({
|
|
716
|
-
code: 'invalid_type',
|
|
717
|
-
expected: 'object',
|
|
718
|
-
message: `Entity must be an object`,
|
|
719
|
-
input: value,
|
|
720
|
-
});
|
|
721
|
-
return value;
|
|
722
|
-
}
|
|
723
|
-
// Check if the id is valid
|
|
724
|
-
const idPath = entity.idPath ?? ['id'];
|
|
725
|
-
const id = get(value, idPath);
|
|
726
|
-
if (typeof id !== 'string' || !id || !entity.type.isId(id)) {
|
|
727
|
-
ctx.addIssue({
|
|
728
|
-
code: 'custom',
|
|
729
|
-
message: `Unable to find string id field '${entity.idPath?.join('.') ?? 'id'}' in entity ${entity.type.name}`,
|
|
730
|
-
input: value,
|
|
731
|
-
});
|
|
732
|
-
return value;
|
|
733
|
-
}
|
|
734
|
-
const nameResolver = (() => {
|
|
735
|
-
if (entity.getNameResolver) {
|
|
736
|
-
return entity.getNameResolver(stripRefMarkers(value));
|
|
737
|
-
}
|
|
738
|
-
if (!('name' in value) || typeof value.name !== 'string') {
|
|
739
|
-
ctx.addIssue({
|
|
740
|
-
code: 'custom',
|
|
741
|
-
message: `Unable to find string name field in entity ${entity.type.name}`,
|
|
742
|
-
input: value,
|
|
743
|
-
});
|
|
744
|
-
return 'invalid';
|
|
745
|
-
}
|
|
746
|
-
return value.name;
|
|
747
|
-
})();
|
|
748
|
-
const newEntity = {
|
|
749
|
-
id,
|
|
750
|
-
idPath,
|
|
751
|
-
path: [],
|
|
752
|
-
type: entity.type,
|
|
753
|
-
nameResolver,
|
|
754
|
-
parentSlot: entity.parentSlot,
|
|
755
|
-
provides: entity.provides,
|
|
756
|
-
};
|
|
757
|
-
return modifyAnnotations(value, ctx, (annotations) => ({
|
|
758
|
-
...annotations,
|
|
759
|
-
entities: [...annotations.entities, newEntity],
|
|
760
|
-
}));
|
|
761
|
-
}
|
|
762
|
-
return value;
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Creates ref context slots for use within a schema definition.
|
|
767
|
-
* Slots provide type-safe context for parent-child entity relationships.
|
|
768
|
-
*
|
|
769
|
-
* @example
|
|
770
|
-
* ```typescript
|
|
771
|
-
* ctx.refContext(
|
|
772
|
-
* { modelSlot: modelEntityType },
|
|
773
|
-
* ({ modelSlot }) =>
|
|
774
|
-
* ctx.withEnt(schema, {
|
|
775
|
-
* type: modelEntityType,
|
|
776
|
-
* provides: modelSlot,
|
|
777
|
-
* }),
|
|
778
|
-
* );
|
|
779
|
-
* ```
|
|
780
|
-
*/
|
|
781
|
-
function refContext(slotDefinition, schemaBuilder) {
|
|
782
|
-
const slots = createRefContextSlotMap(slotDefinition);
|
|
783
|
-
return schemaBuilder(slots).transform((value, ctx) => modifyAnnotations(value, ctx, (annotations) => ({
|
|
784
|
-
...annotations,
|
|
785
|
-
slots: [
|
|
786
|
-
...annotations.slots,
|
|
787
|
-
...Object.values(slots).map((slot) => ({
|
|
788
|
-
path: [],
|
|
789
|
-
slot,
|
|
790
|
-
})),
|
|
791
|
-
],
|
|
792
|
-
})));
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* Wraps a value with a ref expression parser for deferred validation.
|
|
796
|
-
* The parser handles all parsing, validation, and rename handling.
|
|
797
|
-
*
|
|
798
|
-
* If the parser declares required slots (via TRequiredSlots), they must be
|
|
799
|
-
* provided as the second argument. TypeScript enforces this at compile time.
|
|
800
|
-
*
|
|
801
|
-
* The parser's `schema` property is used for input validation.
|
|
802
|
-
*
|
|
803
|
-
* @example
|
|
804
|
-
* ```typescript
|
|
805
|
-
* // Parser without required slots
|
|
806
|
-
* const expressionSchema = ctx.withExpression(simpleParser);
|
|
807
|
-
*
|
|
808
|
-
* // Parser with required slots (TypeScript enforces the second argument)
|
|
809
|
-
* ctx.refContext(
|
|
810
|
-
* { modelSlot: modelEntityType },
|
|
811
|
-
* ({ modelSlot }) =>
|
|
812
|
-
* z.object({
|
|
813
|
-
* condition: ctx.withExpression(authorizerParser, { model: modelSlot }),
|
|
814
|
-
* })
|
|
815
|
-
* );
|
|
816
|
-
* ```
|
|
817
|
-
*/
|
|
818
|
-
function withExpression(parser, slots) {
|
|
819
|
-
return parser.schema.transform((value) => {
|
|
820
|
-
if (transformReferences && value !== undefined) {
|
|
821
|
-
return new DefinitionExpressionMarker(value, {
|
|
822
|
-
path: [],
|
|
823
|
-
value,
|
|
824
|
-
parser,
|
|
825
|
-
slots,
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
return value;
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
return {
|
|
832
|
-
withRef,
|
|
833
|
-
withEnt,
|
|
834
|
-
refContext,
|
|
835
|
-
withExpression,
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
function isEmpty(value) {
|
|
840
|
-
if (value === undefined || value === null) {
|
|
841
|
-
return true;
|
|
842
|
-
}
|
|
843
|
-
if (Array.isArray(value)) {
|
|
844
|
-
return value.length === 0;
|
|
845
|
-
}
|
|
846
|
-
if (typeof value === 'object' &&
|
|
847
|
-
Object.getPrototypeOf(value) === Object.prototype) {
|
|
848
|
-
return Object.values(value).every((val) => val === undefined);
|
|
849
|
-
}
|
|
850
|
-
if (typeof value === 'string') {
|
|
851
|
-
return value === '';
|
|
852
|
-
}
|
|
853
|
-
return false;
|
|
854
|
-
}
|
|
855
|
-
/**
|
|
856
|
-
* Extends the parser context with default value handling functionality.
|
|
857
|
-
*
|
|
858
|
-
* @param options - The schema creator options containing the defaultMode
|
|
859
|
-
* @returns An object containing the withDefault method
|
|
860
|
-
*/
|
|
861
|
-
function extendParserContextWithDefaults(options) {
|
|
862
|
-
const mode = options.defaultMode ?? 'populate';
|
|
863
|
-
return {
|
|
864
|
-
withDefault: function withDefault(schema, defaultValue) {
|
|
865
|
-
switch (mode) {
|
|
866
|
-
case 'populate': {
|
|
867
|
-
return schema.prefault(defaultValue).optional();
|
|
868
|
-
}
|
|
869
|
-
case 'strip': {
|
|
870
|
-
// Use transform to remove values matching defaults after validation
|
|
871
|
-
return schema
|
|
872
|
-
.transform((value) => {
|
|
873
|
-
if (value === defaultValue)
|
|
874
|
-
return undefined;
|
|
875
|
-
if (isEmpty(value)) {
|
|
876
|
-
return undefined;
|
|
877
|
-
}
|
|
878
|
-
return value;
|
|
879
|
-
})
|
|
880
|
-
.optional();
|
|
881
|
-
}
|
|
882
|
-
case 'preserve': {
|
|
883
|
-
// Return schema with .optional() added
|
|
884
|
-
return schema.transform((x) => x).optional();
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
},
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
function createDefinitionSchemaParserContext(options) {
|
|
892
|
-
return {
|
|
893
|
-
...options,
|
|
894
|
-
...extendParserContextWithRefs(options),
|
|
895
|
-
...extendParserContextWithDefaults(options),
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
function definitionSchema(creator) {
|
|
899
|
-
return (context) => creator(context);
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* Creates a schema that requires slots to be passed from parent schemas.
|
|
903
|
-
* Used when a schema needs to reference entities from a parent context.
|
|
904
|
-
*
|
|
905
|
-
* @example
|
|
906
|
-
* ```typescript
|
|
907
|
-
* // Child schema requiring modelSlot from parent
|
|
908
|
-
* export const createModelScalarFieldSchema = definitionSchemaWithSlots(
|
|
909
|
-
* { modelSlot: modelEntityType },
|
|
910
|
-
* (ctx, { modelSlot }) =>
|
|
911
|
-
* ctx.withEnt(schema, {
|
|
912
|
-
* type: modelScalarFieldEntityType,
|
|
913
|
-
* parentSlot: modelSlot,
|
|
914
|
-
* }),
|
|
915
|
-
* );
|
|
916
|
-
*
|
|
917
|
-
* // Called from parent:
|
|
918
|
-
* createModelScalarFieldSchema(ctx, { modelSlot: parentModelSlot })
|
|
919
|
-
* ```
|
|
920
|
-
*/
|
|
921
|
-
function definitionSchemaWithSlots(slotDefinition, creator) {
|
|
922
|
-
const creatorWithSlots = (context, slots) => creator(context, slots);
|
|
923
|
-
creatorWithSlots.slotDefinition = slotDefinition;
|
|
924
|
-
return creatorWithSlots;
|
|
925
|
-
}
|
|
926
|
-
/**
|
|
927
|
-
* Wraps a schema creator that requires slots with placeholder slots,
|
|
928
|
-
* producing a simple schema creator that can be used for validation-only
|
|
929
|
-
* contexts (e.g., React Hook Form).
|
|
930
|
-
*
|
|
931
|
-
* The placeholder slots allow the schema to parse without actual parent context,
|
|
932
|
-
* which is useful when you only need schema validation without ref extraction.
|
|
933
|
-
*
|
|
934
|
-
* @example
|
|
935
|
-
* ```typescript
|
|
936
|
-
* // Schema that normally requires modelSlot from parent
|
|
937
|
-
* const createModelScalarFieldSchema = definitionSchemaWithSlots(
|
|
938
|
-
* { modelSlot: modelEntityType },
|
|
939
|
-
* (ctx, { modelSlot }) => ctx.withEnt(schema, { parentSlot: modelSlot }),
|
|
940
|
-
* );
|
|
941
|
-
*
|
|
942
|
-
* // For React Hook Form validation, wrap with placeholder slots
|
|
943
|
-
* const fieldSchema = withPlaceholderSlots(createModelScalarFieldSchema);
|
|
944
|
-
* const zodSchema = fieldSchema(ctx); // No slots needed
|
|
945
|
-
* ```
|
|
946
|
-
*/
|
|
947
|
-
function withPlaceholderSlots(schemaCreator) {
|
|
948
|
-
return (ctx) => {
|
|
949
|
-
const placeholderSlots = createRefContextSlotMap(schemaCreator.slotDefinition);
|
|
950
|
-
return schemaCreator(ctx, placeholderSlots);
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
const {randomKey} = await importShared('@baseplate-dev/utils');
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Definition of an entity type.
|
|
958
|
-
*/
|
|
959
|
-
class DefinitionEntityType {
|
|
960
|
-
prefix;
|
|
961
|
-
name;
|
|
962
|
-
parentType;
|
|
963
|
-
/**
|
|
964
|
-
* Creates a new entity type.
|
|
965
|
-
*
|
|
966
|
-
* @param name - The name of the entity type.
|
|
967
|
-
* @param prefix - The prefix of the entity type to use in the ID, defaults to the name.
|
|
968
|
-
* @param parentType - The type of the parent entity if any
|
|
969
|
-
*/
|
|
970
|
-
constructor(name, prefix, parentType) {
|
|
971
|
-
this.name = name;
|
|
972
|
-
this.parentType = parentType;
|
|
973
|
-
this.prefix = prefix ?? name.split('/').pop() ?? name;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Generates a new ID for the entity type.
|
|
977
|
-
*
|
|
978
|
-
* @returns The new ID.
|
|
979
|
-
*/
|
|
980
|
-
generateNewId() {
|
|
981
|
-
return `${this.prefix}:${randomKey()}`;
|
|
982
|
-
}
|
|
983
|
-
idFromKey(key) {
|
|
984
|
-
if (!key) {
|
|
985
|
-
return undefined;
|
|
986
|
-
}
|
|
987
|
-
return `${this.prefix}:${key}`;
|
|
988
|
-
}
|
|
989
|
-
keyFromId(id) {
|
|
990
|
-
return id.split(':')[1];
|
|
991
|
-
}
|
|
992
|
-
isId(id) {
|
|
993
|
-
return id.startsWith(`${this.prefix}:`);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
function createEntityType(name, options) {
|
|
997
|
-
const { parentType, prefix } = options ?? {};
|
|
998
|
-
return new DefinitionEntityType(name, prefix, parentType);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
function omit(obj, keys) {
|
|
1002
|
-
const result = { ...obj };
|
|
1003
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1004
|
-
const key = keys[i];
|
|
1005
|
-
delete result[key];
|
|
1006
|
-
}
|
|
1007
|
-
return result;
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
const modelEntityType = createEntityType('model');
|
|
1011
|
-
const modelScalarFieldEntityType = createEntityType('model-scalar-field', {
|
|
1012
|
-
parentType: modelEntityType,
|
|
1013
|
-
});
|
|
1014
|
-
const modelLocalRelationEntityType = createEntityType('model-local-relation', { parentType: modelEntityType });
|
|
1015
|
-
const modelForeignRelationEntityType = createEntityType('model-foreign-relation', { parentType: modelEntityType });
|
|
1016
|
-
const modelUniqueConstraintEntityType = createEntityType('model-unique-constraint', { parentType: modelEntityType });
|
|
1017
|
-
const modelTransformerEntityType = createEntityType('model-transformer', { parentType: modelEntityType });
|
|
1018
|
-
const modelEnumEntityType = createEntityType('model-enum');
|
|
1019
|
-
const modelEnumValueEntityType = createEntityType('model-enum-value', {
|
|
1020
|
-
parentType: modelEnumEntityType,
|
|
1021
|
-
});
|
|
1022
|
-
|
|
1023
|
-
const {CASE_VALIDATORS} = await importShared('@baseplate-dev/utils');
|
|
1024
|
-
|
|
1025
|
-
const {z} = await importShared('zod');
|
|
1026
|
-
const featureEntityType = createEntityType('feature');
|
|
1027
|
-
const featureNameSchema = CASE_VALIDATORS.KEBAB_CASE;
|
|
1028
|
-
const createFeatureSchema = definitionSchema((ctx) => ctx.withEnt(z.object({
|
|
1029
|
-
id: z.string(),
|
|
1030
|
-
name: z
|
|
1031
|
-
.string()
|
|
1032
|
-
.min(1)
|
|
1033
|
-
.refine((name) => name
|
|
1034
|
-
.split('/')
|
|
1035
|
-
.every((part) => featureNameSchema.safeParse(part).success), {
|
|
1036
|
-
message: 'Feature name must be lowercase and contain only letters, numbers, and dashes',
|
|
1037
|
-
}),
|
|
1038
|
-
parentRef: ctx
|
|
1039
|
-
.withRef({
|
|
1040
|
-
type: featureEntityType,
|
|
1041
|
-
onDelete: 'DELETE_PARENT',
|
|
1042
|
-
})
|
|
1043
|
-
.optional(),
|
|
1044
|
-
}), { type: featureEntityType }));
|
|
1045
|
-
const createFeaturesSchema = definitionSchema((ctx) => z.array(createFeatureSchema(ctx)).default([]));
|
|
1046
|
-
|
|
1047
|
-
function getRootFeatures(projectDefinition) {
|
|
1048
|
-
return projectDefinition.features.filter((f) => !f.parentRef);
|
|
1049
|
-
}
|
|
1050
|
-
function getFeatureById(projectDefinition, featureId) {
|
|
1051
|
-
return projectDefinition.features.find((f) => f.id === featureId);
|
|
1052
|
-
}
|
|
1053
|
-
function getFeatureByIdOrThrow(projectDefinition, featureId) {
|
|
1054
|
-
const feature = getFeatureById(projectDefinition, featureId);
|
|
1055
|
-
if (!feature) {
|
|
1056
|
-
throw new Error(`Could not find feature with ID ${featureId}`);
|
|
1057
|
-
}
|
|
1058
|
-
return feature;
|
|
1059
|
-
}
|
|
1060
|
-
function getFeatureChildren(projectDefinition, featureId) {
|
|
1061
|
-
return projectDefinition.features.filter((f) => f.parentRef === featureId);
|
|
1062
|
-
}
|
|
1063
|
-
function getFeatureName(featureConfig) {
|
|
1064
|
-
return featureConfig.name.split('/').pop() ?? '';
|
|
1065
|
-
}
|
|
1066
|
-
function getFeatureNameById(projectDefinition, featureId) {
|
|
1067
|
-
const feature = getFeatureByIdOrThrow(projectDefinition, featureId);
|
|
1068
|
-
return getFeatureName(feature);
|
|
1069
|
-
}
|
|
1070
|
-
function getFeaturePathById(projectDefinition, featureId) {
|
|
1071
|
-
const feature = getFeatureByIdOrThrow(projectDefinition, featureId);
|
|
1072
|
-
return feature.name;
|
|
1073
|
-
}
|
|
1074
|
-
function validateFeatureName(name) {
|
|
1075
|
-
const nameParts = name.split('/');
|
|
1076
|
-
return nameParts.every((part) => featureNameSchema.safeParse(part).success);
|
|
1077
|
-
}
|
|
1078
|
-
function ensureFeatureByNameRecursively(projectDefinition, nameOrId) {
|
|
1079
|
-
if (featureEntityType.isId(nameOrId)) {
|
|
1080
|
-
return nameOrId;
|
|
1081
|
-
}
|
|
1082
|
-
const nameParts = nameOrId.split('/');
|
|
1083
|
-
let lastName = '';
|
|
1084
|
-
let parentRef = undefined;
|
|
1085
|
-
for (const part of nameParts) {
|
|
1086
|
-
const feature = projectDefinition.features.find((f) => f.name === part && f.parentRef === parentRef);
|
|
1087
|
-
const name = [lastName, part].filter(Boolean).join('/');
|
|
1088
|
-
if (feature) {
|
|
1089
|
-
parentRef = feature.id;
|
|
1090
|
-
}
|
|
1091
|
-
else {
|
|
1092
|
-
const newFeature = {
|
|
1093
|
-
id: featureEntityType.generateNewId(),
|
|
1094
|
-
name,
|
|
1095
|
-
parentRef,
|
|
1096
|
-
};
|
|
1097
|
-
projectDefinition.features.push(newFeature);
|
|
1098
|
-
parentRef = newFeature.id;
|
|
1099
|
-
}
|
|
1100
|
-
lastName = name;
|
|
1101
|
-
}
|
|
1102
|
-
if (!parentRef) {
|
|
1103
|
-
throw new Error('Failed to create feature');
|
|
1104
|
-
}
|
|
1105
|
-
return parentRef;
|
|
1106
|
-
}
|
|
1107
|
-
function getFeatureByName(projectDefinition, name) {
|
|
1108
|
-
return projectDefinition.features.find((f) => f.name === name);
|
|
1109
|
-
}
|
|
1110
|
-
function getFeatureIdByNameOrDefault(projectDefinition, name) {
|
|
1111
|
-
return getFeatureByName(projectDefinition, name)?.id ?? name;
|
|
1112
|
-
}
|
|
1113
|
-
const FeatureUtils = {
|
|
1114
|
-
getRootFeatures,
|
|
1115
|
-
getFeatureById,
|
|
1116
|
-
getFeatureByIdOrThrow,
|
|
1117
|
-
getFeatureChildren,
|
|
1118
|
-
getFeatureName,
|
|
1119
|
-
getFeatureNameById,
|
|
1120
|
-
getFeaturePathById,
|
|
1121
|
-
validateFeatureName,
|
|
1122
|
-
ensureFeatureByNameRecursively,
|
|
1123
|
-
getFeatureByName,
|
|
1124
|
-
getFeatureIdByNameOrDefault,
|
|
1125
|
-
};
|
|
1126
|
-
|
|
1127
|
-
const {PASCAL_CASE_REGEX} = await importShared('@baseplate-dev/utils');
|
|
1128
|
-
|
|
1129
|
-
function byId(projectDefinition, id) {
|
|
1130
|
-
return projectDefinition.models.find((m) => m.id === id);
|
|
1131
|
-
}
|
|
1132
|
-
function byIdOrThrow(projectDefinition, id) {
|
|
1133
|
-
const model = byId(projectDefinition, id);
|
|
1134
|
-
if (!model) {
|
|
1135
|
-
throw new Error(`Could not find model with ID ${id}`);
|
|
1136
|
-
}
|
|
1137
|
-
return model;
|
|
1138
|
-
}
|
|
1139
|
-
function byName(projectDefinition, name) {
|
|
1140
|
-
return projectDefinition.models.find((m) => m.name === name);
|
|
1141
|
-
}
|
|
1142
|
-
function byNameOrThrow(projectDefinition, name) {
|
|
1143
|
-
const model = byName(projectDefinition, name);
|
|
1144
|
-
if (!model) {
|
|
1145
|
-
throw new Error(`Could not find model with name ${name}`);
|
|
1146
|
-
}
|
|
1147
|
-
return model;
|
|
1148
|
-
}
|
|
1149
|
-
function getScalarFieldById(model, id) {
|
|
1150
|
-
const field = model.model.fields.find((f) => f.id === id);
|
|
1151
|
-
if (!field) {
|
|
1152
|
-
throw new Error(`Could not find field with ID ${id}`);
|
|
1153
|
-
}
|
|
1154
|
-
return field;
|
|
1155
|
-
}
|
|
1156
|
-
function getRelationsToModel(projectDefinition, modelId) {
|
|
1157
|
-
return projectDefinition.models.flatMap((m) => m.model.relations
|
|
1158
|
-
?.filter((r) => r.modelRef === modelId)
|
|
1159
|
-
.map((r) => ({ model: m, relation: r })) ?? []);
|
|
1160
|
-
}
|
|
1161
|
-
function getModelsForFeature(projectDefinition, featureId) {
|
|
1162
|
-
return projectDefinition.models.filter((m) => m.featureRef === featureId);
|
|
1163
|
-
}
|
|
1164
|
-
function getModelIdFields(model) {
|
|
1165
|
-
return model.model.primaryKeyFieldRefs;
|
|
1166
|
-
}
|
|
1167
|
-
function hasService(model) {
|
|
1168
|
-
return (model.service.create.enabled ||
|
|
1169
|
-
model.service.update.enabled ||
|
|
1170
|
-
model.service.delete.enabled ||
|
|
1171
|
-
model.service.transformers.length > 0);
|
|
1172
|
-
}
|
|
1173
|
-
function validateModelName(name) {
|
|
1174
|
-
return PASCAL_CASE_REGEX.test(name);
|
|
1175
|
-
}
|
|
1176
|
-
/**
|
|
1177
|
-
* Returns the ID of a model by name, or the name if no model is found.
|
|
1178
|
-
* @param projectDefinition - The project definition.
|
|
1179
|
-
* @param name - The name of the model.
|
|
1180
|
-
* @returns The ID of the model, or the name if no model is found.
|
|
1181
|
-
*/
|
|
1182
|
-
function getModelIdByNameOrDefault(projectDefinition, name) {
|
|
1183
|
-
return projectDefinition.models.find((m) => m.name === name)?.id ?? name;
|
|
1184
|
-
}
|
|
1185
|
-
function getPrimaryKeyFields(model) {
|
|
1186
|
-
const primaryKeyFields = model.model.primaryKeyFieldRefs;
|
|
1187
|
-
return primaryKeyFields.map((id) => getScalarFieldById(model, id));
|
|
1188
|
-
}
|
|
1189
|
-
const ModelUtils = {
|
|
1190
|
-
byId,
|
|
1191
|
-
byIdOrThrow,
|
|
1192
|
-
byName,
|
|
1193
|
-
byNameOrThrow,
|
|
1194
|
-
getScalarFieldById,
|
|
1195
|
-
getRelationsToModel,
|
|
1196
|
-
getModelsForFeature,
|
|
1197
|
-
getModelIdFields,
|
|
1198
|
-
hasService,
|
|
1199
|
-
validateModelName,
|
|
1200
|
-
getModelIdByNameOrDefault,
|
|
1201
|
-
getPrimaryKeyFields,
|
|
1202
|
-
};
|
|
1203
|
-
|
|
1204
|
-
/**
|
|
1205
|
-
* Allows diffing of arbitrary JSON objects.
|
|
1206
|
-
*/
|
|
1207
|
-
class DefinitionDiffField {
|
|
1208
|
-
/**
|
|
1209
|
-
* The name of the field to be presented to the user.
|
|
1210
|
-
*/
|
|
1211
|
-
name;
|
|
1212
|
-
constructor(name) {
|
|
1213
|
-
this.name = name;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* A field that is an array of objects with a unique key.
|
|
1218
|
-
*/
|
|
1219
|
-
class DefinitionDiffKeyedArrayField extends DefinitionDiffField {
|
|
1220
|
-
getKey;
|
|
1221
|
-
options;
|
|
1222
|
-
constructor(name, getKey, options = {}) {
|
|
1223
|
-
super(name);
|
|
1224
|
-
this.getKey = getKey;
|
|
1225
|
-
this.options = options;
|
|
1226
|
-
}
|
|
1227
|
-
diff(current, desired) {
|
|
1228
|
-
const currentValue = current ?? [];
|
|
1229
|
-
const desiredValue = desired ?? [];
|
|
1230
|
-
if (!Array.isArray(currentValue) || !Array.isArray(desiredValue)) {
|
|
1231
|
-
throw new TypeError('Current and desired must be arrays');
|
|
1232
|
-
}
|
|
1233
|
-
const ops = [];
|
|
1234
|
-
const { allowRemove, ignoreFields = ['id'] } = this.options;
|
|
1235
|
-
const currentByKey = new Map(currentValue.map((item) => [this.getKey(item), item]));
|
|
1236
|
-
const desiredByKey = new Map(desiredValue.map((item) => [this.getKey(item), item]));
|
|
1237
|
-
for (const [key, desiredItem] of desiredByKey) {
|
|
1238
|
-
const currentItem = currentByKey.get(key);
|
|
1239
|
-
if (!currentItem) {
|
|
1240
|
-
ops.push({ type: 'add', key, item: desiredItem });
|
|
1241
|
-
continue;
|
|
1242
|
-
}
|
|
1243
|
-
if (!isMatch(omit(currentItem, ignoreFields), omit(desiredItem, ignoreFields))) {
|
|
1244
|
-
ops.push({ type: 'update', key, item: desiredItem });
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
if (allowRemove) {
|
|
1248
|
-
for (const [key, currentItem] of currentByKey) {
|
|
1249
|
-
if (!desiredByKey.has(key)) {
|
|
1250
|
-
ops.push({ type: 'remove', key, item: currentItem });
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
return ops;
|
|
1255
|
-
}
|
|
1256
|
-
apply(current, diff) {
|
|
1257
|
-
const patch = diff;
|
|
1258
|
-
const currentValue = current ?? [];
|
|
1259
|
-
if (!Array.isArray(currentValue)) {
|
|
1260
|
-
throw new TypeError('Current must be array');
|
|
1261
|
-
}
|
|
1262
|
-
const items = [...currentValue];
|
|
1263
|
-
for (const { type, key, item } of patch) {
|
|
1264
|
-
const index = items.findIndex((i) => this.getKey(i) === key);
|
|
1265
|
-
switch (type) {
|
|
1266
|
-
case 'add': {
|
|
1267
|
-
items.push(item);
|
|
1268
|
-
break;
|
|
1269
|
-
}
|
|
1270
|
-
case 'update': {
|
|
1271
|
-
if (index === -1) {
|
|
1272
|
-
throw new Error(`Cannot apply patch. Item with key "${key}" not found.`);
|
|
1273
|
-
}
|
|
1274
|
-
// Preserve existing id if present.
|
|
1275
|
-
items[index] = toMerged(items[index], item);
|
|
1276
|
-
break;
|
|
1277
|
-
}
|
|
1278
|
-
case 'remove': {
|
|
1279
|
-
if (index !== -1) {
|
|
1280
|
-
items.splice(index, 1);
|
|
1281
|
-
}
|
|
1282
|
-
break;
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
return items;
|
|
1287
|
-
}
|
|
1288
|
-
getActionVerb(isNew) {
|
|
1289
|
-
return isNew ? 'created' : 'added or updated';
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
/**
|
|
1293
|
-
* A field that is a replacement for the entire object or array.
|
|
1294
|
-
*/
|
|
1295
|
-
class DefinitionDiffReplacementField extends DefinitionDiffField {
|
|
1296
|
-
diff(current, desired) {
|
|
1297
|
-
if (desired === undefined) {
|
|
1298
|
-
return [];
|
|
1299
|
-
}
|
|
1300
|
-
if (!isMatch(current, desired)) {
|
|
1301
|
-
return [{ type: 'update', key: '*', item: desired }];
|
|
1302
|
-
}
|
|
1303
|
-
return [];
|
|
1304
|
-
}
|
|
1305
|
-
apply(current, diff) {
|
|
1306
|
-
if (diff.length === 0)
|
|
1307
|
-
return current;
|
|
1308
|
-
return diff[0].item;
|
|
1309
|
-
}
|
|
1310
|
-
getActionVerb(isNew) {
|
|
1311
|
-
return isNew ? 'set' : 'replaced';
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
/**
|
|
1315
|
-
* A field that ensures an array contains certain values.
|
|
1316
|
-
* This field type only adds items, never removes them.
|
|
1317
|
-
*/
|
|
1318
|
-
class DefinitionDiffArrayIncludesField extends DefinitionDiffField {
|
|
1319
|
-
getKey;
|
|
1320
|
-
constructor(name, getKey) {
|
|
1321
|
-
super(name);
|
|
1322
|
-
this.getKey = getKey;
|
|
1323
|
-
}
|
|
1324
|
-
diff(current, desired) {
|
|
1325
|
-
const currentValue = current ?? [];
|
|
1326
|
-
const desiredValue = desired ?? [];
|
|
1327
|
-
if (!Array.isArray(currentValue) || !Array.isArray(desiredValue)) {
|
|
1328
|
-
throw new TypeError('Current and desired must be arrays');
|
|
1329
|
-
}
|
|
1330
|
-
const ops = [];
|
|
1331
|
-
const currentSet = new Set(this.getKey ? currentValue.map(this.getKey) : currentValue);
|
|
1332
|
-
for (const item of desiredValue) {
|
|
1333
|
-
const key = this.getKey ? this.getKey(item) : String(item);
|
|
1334
|
-
if (!currentSet.has(key)) {
|
|
1335
|
-
ops.push({ type: 'add', key, item });
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
return ops;
|
|
1339
|
-
}
|
|
1340
|
-
apply(current, diff) {
|
|
1341
|
-
const currentValue = (current ?? []);
|
|
1342
|
-
if (!Array.isArray(currentValue)) {
|
|
1343
|
-
throw new TypeError('Current must be array');
|
|
1344
|
-
}
|
|
1345
|
-
const items = [...currentValue];
|
|
1346
|
-
for (const { type, item } of diff) {
|
|
1347
|
-
if (type === 'add') {
|
|
1348
|
-
items.push(item);
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
return items;
|
|
1352
|
-
}
|
|
1353
|
-
getActionVerb(isNew) {
|
|
1354
|
-
return isNew ? 'created' : 'added';
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
function createDefinitionDiffConfig(config) {
|
|
1358
|
-
return config;
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Creates a diff between two objects.
|
|
1362
|
-
*/
|
|
1363
|
-
function createDefinitionDiff(current, desired, configuration) {
|
|
1364
|
-
const ops = mapValues(configuration, (field, key) => {
|
|
1365
|
-
if (!field)
|
|
1366
|
-
return [];
|
|
1367
|
-
return field.diff(get(current, key), get(desired, key));
|
|
1368
|
-
});
|
|
1369
|
-
if (Object.values(ops).every((ops) => ops.length === 0)) {
|
|
1370
|
-
return undefined;
|
|
1371
|
-
}
|
|
1372
|
-
return ops;
|
|
1373
|
-
}
|
|
1374
|
-
/**
|
|
1375
|
-
* Applies a diff to an object.
|
|
1376
|
-
*/
|
|
1377
|
-
function applyDefinitionDiff(current, diff, configuration) {
|
|
1378
|
-
const clonedCurrent = cloneDeep(current);
|
|
1379
|
-
for (const [key, ops] of Object.entries(diff)) {
|
|
1380
|
-
if (!ops)
|
|
1381
|
-
continue;
|
|
1382
|
-
const field = configuration[key];
|
|
1383
|
-
const currentValue = get(clonedCurrent, key);
|
|
1384
|
-
set(clonedCurrent, key, field.apply(currentValue, ops));
|
|
1385
|
-
}
|
|
1386
|
-
return clonedCurrent;
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
/**
|
|
1390
|
-
* Computes a unique key for a unique constraint by sorting its field refs.
|
|
1391
|
-
*
|
|
1392
|
-
* @param constraint - Unique constraint input.
|
|
1393
|
-
* @returns A key string.
|
|
1394
|
-
*/
|
|
1395
|
-
function getUniqueConstraintKey(constraint) {
|
|
1396
|
-
const fields = constraint.fields.map((f) => f.fieldRef).toSorted();
|
|
1397
|
-
return fields.join('|');
|
|
1398
|
-
}
|
|
1399
|
-
const modelMergerDefinitionDiffConfig = createDefinitionDiffConfig({
|
|
1400
|
-
'model.fields': new DefinitionDiffKeyedArrayField('fields', (f) => f.name),
|
|
1401
|
-
'model.relations': new DefinitionDiffKeyedArrayField('relations', (r) => r.name),
|
|
1402
|
-
'model.uniqueConstraints': new DefinitionDiffKeyedArrayField('unique constraints', (c) => getUniqueConstraintKey(c)),
|
|
1403
|
-
'model.primaryKeyFieldRefs': new DefinitionDiffReplacementField('primary key fields'),
|
|
1404
|
-
'graphql.objectType.enabled': new DefinitionDiffReplacementField('GraphQL object type enabled'),
|
|
1405
|
-
'graphql.objectType.fields': new DefinitionDiffArrayIncludesField('GraphQL object type fields'),
|
|
1406
|
-
'graphql.objectType.localRelations': new DefinitionDiffArrayIncludesField('GraphQL object type local relations'),
|
|
1407
|
-
'graphql.objectType.foreignRelations': new DefinitionDiffArrayIncludesField('GraphQL object type foreign relations'),
|
|
1408
|
-
});
|
|
1409
|
-
/**
|
|
1410
|
-
* Serializes a model merger model input such that all IDs are replaced with
|
|
1411
|
-
* names.
|
|
1412
|
-
*
|
|
1413
|
-
* @param input - The model merger model input.
|
|
1414
|
-
* @param definitionContainer - The definition container.
|
|
1415
|
-
* @returns The serialized model merger model input.
|
|
1416
|
-
*/
|
|
1417
|
-
function serializeModelMergerModelInput(input, definitionContainer, siblingModels) {
|
|
1418
|
-
const siblingModelIds = new Map(siblingModels.map((m) => [m.id, m.name]));
|
|
1419
|
-
const siblingModelFieldIdMap = new Map([
|
|
1420
|
-
...input.model.fields.map((f) => [f.id, f.name]),
|
|
1421
|
-
...siblingModels.flatMap((m) => m.model.fields.map((f) => [f.id, f.name])),
|
|
1422
|
-
]);
|
|
1423
|
-
const siblingModelRelationIdMap = new Map([
|
|
1424
|
-
...(input.model.relations ?? []).map((r) => [r.id, r.name]),
|
|
1425
|
-
...siblingModels.flatMap((m) => (m.model.relations ?? []).map((r) => [r.id, r.name])),
|
|
1426
|
-
...(input.model.relations ?? []).map((r) => [r.foreignId, r.foreignRelationName]),
|
|
1427
|
-
...siblingModels.flatMap((m) => (m.model.relations ?? []).map((r) => [r.foreignId, r.foreignRelationName])),
|
|
1428
|
-
]);
|
|
1429
|
-
const modelFromId = (id) => siblingModelIds.get(id) ?? definitionContainer.nameFromId(id);
|
|
1430
|
-
const fieldNameFromId = (id) => siblingModelFieldIdMap.get(id) ?? definitionContainer.nameFromId(id);
|
|
1431
|
-
const relationNameFromId = (id) => siblingModelRelationIdMap.get(id) ?? definitionContainer.nameFromId(id);
|
|
1432
|
-
return {
|
|
1433
|
-
...input,
|
|
1434
|
-
model: {
|
|
1435
|
-
...input.model,
|
|
1436
|
-
relations: input.model.relations?.map((r) => ({
|
|
1437
|
-
...r,
|
|
1438
|
-
modelRef: modelFromId(r.modelRef),
|
|
1439
|
-
references: r.references.map((reference) => ({
|
|
1440
|
-
...reference,
|
|
1441
|
-
localRef: fieldNameFromId(reference.localRef),
|
|
1442
|
-
foreignRef: fieldNameFromId(reference.foreignRef),
|
|
1443
|
-
})),
|
|
1444
|
-
})),
|
|
1445
|
-
uniqueConstraints: input.model.uniqueConstraints?.map((c) => ({
|
|
1446
|
-
...c,
|
|
1447
|
-
fields: c.fields.map((f) => ({
|
|
1448
|
-
...f,
|
|
1449
|
-
fieldRef: fieldNameFromId(f.fieldRef),
|
|
1450
|
-
})),
|
|
1451
|
-
})),
|
|
1452
|
-
primaryKeyFieldRefs: input.model.primaryKeyFieldRefs.map(fieldNameFromId),
|
|
1453
|
-
},
|
|
1454
|
-
graphql: {
|
|
1455
|
-
...input.graphql,
|
|
1456
|
-
objectType: {
|
|
1457
|
-
...input.graphql?.objectType,
|
|
1458
|
-
fields: input.graphql?.objectType?.fields?.map(fieldNameFromId) ?? [],
|
|
1459
|
-
localRelations: input.graphql?.objectType?.localRelations?.map(relationNameFromId) ??
|
|
1460
|
-
[],
|
|
1461
|
-
foreignRelations: input.graphql?.objectType?.foreignRelations?.map(relationNameFromId) ?? [],
|
|
1462
|
-
},
|
|
1463
|
-
},
|
|
1464
|
-
};
|
|
1465
|
-
}
|
|
1466
|
-
/**
|
|
1467
|
-
* Attaches IDs to the model merger model input.
|
|
1468
|
-
*
|
|
1469
|
-
* @param input - The model merger model input.
|
|
1470
|
-
* @returns The model merger model input with IDs attached.
|
|
1471
|
-
*/
|
|
1472
|
-
function attachIdsToModelMergerModelInput(input) {
|
|
1473
|
-
return {
|
|
1474
|
-
...input,
|
|
1475
|
-
model: {
|
|
1476
|
-
...input.model,
|
|
1477
|
-
fields: input.model.fields.map((f) => ({
|
|
1478
|
-
...f,
|
|
1479
|
-
id: f.id ?? modelScalarFieldEntityType.generateNewId(),
|
|
1480
|
-
})),
|
|
1481
|
-
relations: input.model.relations?.map((r) => ({
|
|
1482
|
-
...r,
|
|
1483
|
-
id: r.id ?? modelLocalRelationEntityType.generateNewId(),
|
|
1484
|
-
foreignId: r.foreignId ?? modelForeignRelationEntityType.generateNewId(),
|
|
1485
|
-
})),
|
|
1486
|
-
uniqueConstraints: input.model.uniqueConstraints?.map((c) => ({
|
|
1487
|
-
...c,
|
|
1488
|
-
id: c.id ?? modelUniqueConstraintEntityType.generateNewId(),
|
|
1489
|
-
})),
|
|
1490
|
-
},
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* Deserializes a model merger model input converting all names to IDs.
|
|
1495
|
-
*
|
|
1496
|
-
* @param input - The model merger model input.
|
|
1497
|
-
* @param resolveForeignFieldRef - A function that resolves the foreign field ref.
|
|
1498
|
-
* @returns The deserialized model merger model input.
|
|
1499
|
-
*/
|
|
1500
|
-
function deserializeModelMergerModelInput(input, resolveForeignFieldRef, resolveForeignRelationRef, resolveModelRef) {
|
|
1501
|
-
const inputWithIds = attachIdsToModelMergerModelInput(input);
|
|
1502
|
-
const resolveLocalFieldName = (name) => {
|
|
1503
|
-
const field = inputWithIds.model.fields.find((f) => f.name === name);
|
|
1504
|
-
if (!field) {
|
|
1505
|
-
throw new Error(`Field ${name} not found`);
|
|
1506
|
-
}
|
|
1507
|
-
return field.id;
|
|
1508
|
-
};
|
|
1509
|
-
const resolveLocalRelationName = (name) => {
|
|
1510
|
-
const relation = inputWithIds.model.relations?.find((r) => r.name === name);
|
|
1511
|
-
if (!relation) {
|
|
1512
|
-
throw new Error(`Relation ${name} not found`);
|
|
1513
|
-
}
|
|
1514
|
-
return relation.id;
|
|
1515
|
-
};
|
|
1516
|
-
return {
|
|
1517
|
-
...inputWithIds,
|
|
1518
|
-
model: {
|
|
1519
|
-
...inputWithIds.model,
|
|
1520
|
-
relations: inputWithIds.model.relations?.map((relation) => ({
|
|
1521
|
-
...relation,
|
|
1522
|
-
modelRef: resolveModelRef(relation.modelRef),
|
|
1523
|
-
references: relation.references.map((reference) => ({
|
|
1524
|
-
...reference,
|
|
1525
|
-
localRef: resolveLocalFieldName(reference.localRef),
|
|
1526
|
-
foreignRef: resolveForeignFieldRef(relation.modelRef, reference.foreignRef),
|
|
1527
|
-
})),
|
|
1528
|
-
})),
|
|
1529
|
-
uniqueConstraints: inputWithIds.model.uniqueConstraints?.map((constraint) => ({
|
|
1530
|
-
...constraint,
|
|
1531
|
-
fields: constraint.fields.map((field) => ({
|
|
1532
|
-
...field,
|
|
1533
|
-
fieldRef: resolveLocalFieldName(field.fieldRef),
|
|
1534
|
-
})),
|
|
1535
|
-
})),
|
|
1536
|
-
primaryKeyFieldRefs: inputWithIds.model.primaryKeyFieldRefs.map((fieldRef) => resolveLocalFieldName(fieldRef)),
|
|
1537
|
-
},
|
|
1538
|
-
graphql: {
|
|
1539
|
-
...inputWithIds.graphql,
|
|
1540
|
-
objectType: {
|
|
1541
|
-
...inputWithIds.graphql?.objectType,
|
|
1542
|
-
fields: inputWithIds.graphql?.objectType?.fields?.map((fieldRef) => resolveLocalFieldName(fieldRef)) ?? [],
|
|
1543
|
-
localRelations: inputWithIds.graphql?.objectType?.localRelations?.map((relationRef) => resolveLocalRelationName(relationRef)) ?? [],
|
|
1544
|
-
foreignRelations: inputWithIds.graphql?.objectType?.foreignRelations?.map((relationRef) => resolveForeignRelationRef(relationRef)) ?? [],
|
|
1545
|
-
},
|
|
1546
|
-
},
|
|
1547
|
-
};
|
|
1548
|
-
}
|
|
1549
|
-
/**
|
|
1550
|
-
* Creates a new blank model config input from a name and feature ref.
|
|
1551
|
-
*
|
|
1552
|
-
* @param name - The name of the model.
|
|
1553
|
-
* @param featureRef - The feature ref of the model.
|
|
1554
|
-
* @returns The new model config input.
|
|
1555
|
-
*/
|
|
1556
|
-
function createNewModelConfigInput(name, featureRef, id) {
|
|
1557
|
-
return {
|
|
1558
|
-
id,
|
|
1559
|
-
name,
|
|
1560
|
-
featureRef,
|
|
1561
|
-
model: {
|
|
1562
|
-
fields: [],
|
|
1563
|
-
primaryKeyFieldRefs: [],
|
|
1564
|
-
},
|
|
1565
|
-
};
|
|
1566
|
-
}
|
|
1567
|
-
/**
|
|
1568
|
-
* Diff the model definition.
|
|
1569
|
-
*
|
|
1570
|
-
* @param current - The current model definition or a new model to be created.
|
|
1571
|
-
* @param desired - The desired model definition.
|
|
1572
|
-
* @param definitionContainer - Project definition container.
|
|
1573
|
-
* @param options - Diff options.
|
|
1574
|
-
* @returns A diff output or undefined if there are no differences.
|
|
1575
|
-
*/
|
|
1576
|
-
function createModelMergerResult(current, desired, definitionContainer, { siblingModels = [] } = {}) {
|
|
1577
|
-
const currentModel = current ??
|
|
1578
|
-
createNewModelConfigInput(desired.name, desired.featureRef, modelEntityType.generateNewId());
|
|
1579
|
-
// resolves all the names of the current model config input
|
|
1580
|
-
const resolvedCurrent = serializeModelMergerModelInput(currentModel, definitionContainer, siblingModels);
|
|
1581
|
-
const diff = createDefinitionDiff(resolvedCurrent, desired, modelMergerDefinitionDiffConfig);
|
|
1582
|
-
if (!diff) {
|
|
1583
|
-
return undefined;
|
|
1584
|
-
}
|
|
1585
|
-
return {
|
|
1586
|
-
isNewModel: !current,
|
|
1587
|
-
id: currentModel.id,
|
|
1588
|
-
name: currentModel.name,
|
|
1589
|
-
featureRef: currentModel.featureRef,
|
|
1590
|
-
changes: diff,
|
|
1591
|
-
};
|
|
1592
|
-
}
|
|
1593
|
-
function doesModelMergerResultsHaveChanges(results) {
|
|
1594
|
-
return Object.values(results).some((result) => result?.changes);
|
|
1595
|
-
}
|
|
1596
|
-
/**
|
|
1597
|
-
* Creates a model merger result for a set of models.
|
|
1598
|
-
*
|
|
1599
|
-
* @param current - A map of model IDs
|
|
1600
|
-
* @param desired - The desired model definition.
|
|
1601
|
-
* @param definitionContainer - Project definition container.
|
|
1602
|
-
* @param options - Diff options.
|
|
1603
|
-
* @returns A model merger result for a set of models.
|
|
1604
|
-
*/
|
|
1605
|
-
function createModelMergerResults(current, desired, definitionContainer, { siblingModels = [] } = {}) {
|
|
1606
|
-
return mapValues(desired, (desired, key) => createModelMergerResult(current[key] && modelEntityType.isId(current[key])
|
|
1607
|
-
? ModelUtils.byIdOrThrow(definitionContainer.definition, current[key])
|
|
1608
|
-
: ModelUtils.byName(definitionContainer.definition, current[key] ?? ''), desired, definitionContainer, {
|
|
1609
|
-
siblingModels,
|
|
1610
|
-
}));
|
|
1611
|
-
}
|
|
1612
|
-
function applyModelMergerDiff(model, diff, definitionContainer, siblingModels = []) {
|
|
1613
|
-
const resolvedCurrent = serializeModelMergerModelInput(model, definitionContainer, siblingModels);
|
|
1614
|
-
const patchedCurrent = applyDefinitionDiff(resolvedCurrent, diff, modelMergerDefinitionDiffConfig);
|
|
1615
|
-
return {
|
|
1616
|
-
...model,
|
|
1617
|
-
...deserializeModelMergerModelInput(patchedCurrent, (modelId, fieldName) => {
|
|
1618
|
-
const siblingModel = siblingModels.find((m) => m.id === modelId || m.name === modelId);
|
|
1619
|
-
if (siblingModel) {
|
|
1620
|
-
const field = siblingModel.model.fields.find((f) => f.name === fieldName);
|
|
1621
|
-
if (!field) {
|
|
1622
|
-
throw new Error(`Field ${fieldName} not found in sibling model ${modelId}`);
|
|
1623
|
-
}
|
|
1624
|
-
return field.id;
|
|
1625
|
-
}
|
|
1626
|
-
const model = ModelUtils.byName(definitionContainer.definition, modelId) ??
|
|
1627
|
-
ModelUtils.byIdOrThrow(definitionContainer.definition, modelId);
|
|
1628
|
-
const field = model.model.fields.find((f) => f.name === fieldName);
|
|
1629
|
-
if (!field) {
|
|
1630
|
-
throw new Error(`Field ${fieldName} not found in model ${model.name}`);
|
|
1631
|
-
}
|
|
1632
|
-
return field.id;
|
|
1633
|
-
}, (relationName) => {
|
|
1634
|
-
// Search sibling model first
|
|
1635
|
-
let relationId;
|
|
1636
|
-
for (const siblingModel of siblingModels) {
|
|
1637
|
-
const relation = siblingModel.model.relations?.find((r) => r.foreignRelationName === relationName);
|
|
1638
|
-
if (relation) {
|
|
1639
|
-
relationId = relation.foreignId;
|
|
1640
|
-
break;
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
if (relationId) {
|
|
1644
|
-
return relationId;
|
|
1645
|
-
}
|
|
1646
|
-
const relations = ModelUtils.getRelationsToModel(definitionContainer.definition, model.id);
|
|
1647
|
-
const relation = relations.find((r) => r.relation.foreignRelationName === relationName &&
|
|
1648
|
-
r.relation.modelRef === model.id);
|
|
1649
|
-
if (!relation) {
|
|
1650
|
-
throw new Error(`Relation ${relationName} not found in model ${model.name}`);
|
|
1651
|
-
}
|
|
1652
|
-
return relation.relation.foreignId;
|
|
1653
|
-
}, (modelRef) => {
|
|
1654
|
-
const siblingModel = siblingModels.find((m) => m.id === modelRef || m.name === modelRef);
|
|
1655
|
-
if (siblingModel) {
|
|
1656
|
-
return siblingModel.id;
|
|
1657
|
-
}
|
|
1658
|
-
const model = ModelUtils.byName(definitionContainer.definition, modelRef) ??
|
|
1659
|
-
ModelUtils.byIdOrThrow(definitionContainer.definition, modelRef);
|
|
1660
|
-
return model.id;
|
|
1661
|
-
}),
|
|
1662
|
-
};
|
|
1663
|
-
}
|
|
1664
|
-
function applyModelMergerResultInPlace(draftConfig, currentModel, result, definitionContainer, { siblingModels = [] } = {}) {
|
|
1665
|
-
const newModel = applyModelMergerDiff(currentModel, result.changes, definitionContainer, siblingModels);
|
|
1666
|
-
if (result.isNewModel) {
|
|
1667
|
-
draftConfig.models.push(newModel);
|
|
1668
|
-
}
|
|
1669
|
-
else {
|
|
1670
|
-
const index = draftConfig.models.findIndex((m) => m.id === result.id);
|
|
1671
|
-
if (index === -1) {
|
|
1672
|
-
throw new Error(`Model ${result.id} not found`);
|
|
1673
|
-
}
|
|
1674
|
-
draftConfig.models[index] = newModel;
|
|
1675
|
-
}
|
|
1676
|
-
return newModel.id;
|
|
1677
|
-
}
|
|
1678
|
-
function createAndApplyModelMergerResults(draftConfig, current, desired, definitionContainer, { siblingModels = [] } = {}) {
|
|
1679
|
-
const results = createModelMergerResults(current, desired, definitionContainer, { siblingModels });
|
|
1680
|
-
const newModels = [];
|
|
1681
|
-
const resultIds = {};
|
|
1682
|
-
// Apply model mergers in order
|
|
1683
|
-
for (const [key, result] of Object.entries(results)) {
|
|
1684
|
-
if (result) {
|
|
1685
|
-
const model = result.isNewModel
|
|
1686
|
-
? createNewModelConfigInput(result.name, result.featureRef, result.id)
|
|
1687
|
-
: ModelUtils.byIdOrThrow(definitionContainer.definition, result.id);
|
|
1688
|
-
applyModelMergerResultInPlace(draftConfig, model, result, definitionContainer, {
|
|
1689
|
-
siblingModels: newModels,
|
|
1690
|
-
});
|
|
1691
|
-
const newModel = draftConfig.models.find((m) => m.id === result.id);
|
|
1692
|
-
if (newModel) {
|
|
1693
|
-
newModels.push(newModel);
|
|
1694
|
-
}
|
|
1695
|
-
resultIds[key] = model.id;
|
|
1696
|
-
}
|
|
1697
|
-
else {
|
|
1698
|
-
resultIds[key] = desired[key].name;
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
return resultIds;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
export { createRefContextSlot as A, createRefContextSlotMap as B, DefinitionEntityType as C, DefinitionReferenceMarker as D, withPlaceholderSlots as E, FeatureUtils as F, featureNameSchema as G, createFeatureSchema as H, modelMergerDefinitionDiffConfig as I, createModelMergerResult as J, doesModelMergerResultsHaveChanges as K, createModelMergerResults as L, ModelUtils as M, applyModelMergerDiff as N, applyModelMergerResultInPlace as O, createAndApplyModelMergerResults as P, DefinitionDiffKeyedArrayField as Q, REF_ANNOTATIONS_MARKER_SYMBOL as R, DefinitionDiffReplacementField as S, DefinitionDiffArrayIncludesField as T, createDefinitionDiffConfig as U, createDefinitionDiff as V, applyDefinitionDiff as W, createEntityType as a, DefinitionExpressionMarker as b, createFieldMapSpec as c, definitionSchemaWithSlots as d, createDefinitionSchemaParserContext as e, set as f, get as g, modelEntityType as h, definitionSchema as i, modelEnumValueEntityType as j, modelEnumEntityType as k, featureEntityType as l, mapValues as m, modelForeignRelationEntityType as n, modelLocalRelationEntityType as o, modelScalarFieldEntityType as p, modelTransformerEntityType as q, modelUniqueConstraintEntityType as r, stripRefMarkers as s, runInPluginContext as t, createFeaturesSchema as u, omit as v, cloneDeep as w, getPluginContext as x, createPluginSpec as y, createPluginFieldMap as z };
|
|
1705
|
-
//# sourceMappingURL=model-merger-CdjliK9v.js.map
|