@baseplate-dev/plugin-auth 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/auth/core/components/auth-definition-editor.js +1 -1
  2. package/dist/auth/core/components/auth-definition-editor.js.map +1 -1
  3. package/dist/auth/core/schema/plugin-definition.d.ts +6 -39
  4. package/dist/auth/core/schema/plugin-definition.d.ts.map +1 -1
  5. package/dist/auth/core/schema/roles/schema.d.ts +7 -27
  6. package/dist/auth/core/schema/roles/schema.d.ts.map +1 -1
  7. package/dist/auth/core/schema/roles/schema.js +1 -1
  8. package/dist/auth/core/schema/roles/schema.js.map +1 -1
  9. package/dist/auth0/core/components/auth0-definition-editor.js +1 -1
  10. package/dist/auth0/core/components/auth0-definition-editor.js.map +1 -1
  11. package/dist/auth0/core/schema/plugin-definition.d.ts +1 -1
  12. package/dist/auth0/core/schema/plugin-definition.d.ts.map +1 -1
  13. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts +1 -1
  14. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts +1 -1
  15. package/dist/auth0/generators/react/auth0-pages/auth0-pages.generator.d.ts +1 -1
  16. package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts +1 -1
  17. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.js +1 -1
  18. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.js.map +1 -1
  19. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.js +1 -1
  20. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.js.map +1 -1
  21. package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +1 -1
  22. package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.js +1 -1
  23. package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.js.map +1 -1
  24. package/dist/local-auth/admin/schema/manage-role-action.d.ts +5 -11
  25. package/dist/local-auth/admin/schema/manage-role-action.d.ts.map +1 -1
  26. package/dist/local-auth/admin/schema/reset-password-action.d.ts +5 -11
  27. package/dist/local-auth/admin/schema/reset-password-action.d.ts.map +1 -1
  28. package/dist/local-auth/admin/schema/roles-column.d.ts +1 -10
  29. package/dist/local-auth/admin/schema/roles-column.d.ts.map +1 -1
  30. package/dist/local-auth/core/components/local-auth-definition-editor.js +1 -1
  31. package/dist/local-auth/core/components/local-auth-definition-editor.js.map +1 -1
  32. package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.d.ts +2 -2
  33. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.d.ts.map +1 -1
  34. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js +0 -1
  35. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js.map +1 -1
  36. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.ts +0 -1
  37. package/dist/local-auth/core/generators/auth-hooks/auth-hooks.generator.d.ts +2 -2
  38. package/dist/local-auth/core/generators/auth-hooks/generated/index.d.ts +2 -2
  39. package/dist/local-auth/core/generators/auth-hooks/generated/template-renderers.d.ts +1 -1
  40. package/dist/local-auth/core/generators/auth-hooks/generated/typed-templates.d.ts +2 -2
  41. package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +2 -2
  42. package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +3 -3
  43. package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +1 -1
  44. package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +4 -4
  45. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.d.ts +3 -11
  46. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.d.ts.map +1 -1
  47. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +1 -4
  48. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js.map +1 -1
  49. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +1 -4
  50. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.d.ts +3 -11
  51. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.d.ts.map +1 -1
  52. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js +1 -4
  53. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js.map +1 -1
  54. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.tsx +1 -4
  55. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/route.d.ts +1 -1
  56. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/route.d.ts.map +1 -1
  57. package/dist/local-auth/core/generators/react-auth/react-auth.generator.d.ts +1 -1
  58. package/dist/local-auth/core/generators/react-session/generated/index.d.ts +1 -1
  59. package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.d.ts +3 -3
  60. package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.js +2 -2
  61. package/dist/local-auth/core/generators/react-session/generated/typed-templates.js +1 -1
  62. package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +2 -2
  63. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.d.ts.map +1 -1
  64. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js +16 -0
  65. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js.map +1 -1
  66. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.tsx +17 -0
  67. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.d.ts.map +1 -1
  68. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js +8 -2
  69. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js.map +1 -1
  70. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.ts +8 -2
  71. package/dist/local-auth/core/schema/plugin-definition.d.ts +3 -9
  72. package/dist/local-auth/core/schema/plugin-definition.d.ts.map +1 -1
  73. package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js +1 -1
  74. package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js.map +1 -1
  75. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/placeholder-auth-hooks.generator.d.ts +1 -1
  76. package/dist/placeholder-auth/core/generators/placeholder-auth-module/auth-module.generator.d.ts +1 -1
  77. package/dist/placeholder-auth/core/generators/placeholder-react-auth/react-auth.generator.d.ts +1 -1
  78. package/dist/placeholder-auth/core/schema/plugin-definition.d.ts +1 -1
  79. package/dist/placeholder-auth/core/schema/plugin-definition.d.ts.map +1 -1
  80. package/dist/web/assets/{__federation_expose_auth0CoreCommon-xk1Gj1WU.js → __federation_expose_auth0CoreCommon-DxPG_Wc0.js} +3 -3
  81. package/dist/web/assets/{__federation_expose_auth0CoreCommon-xk1Gj1WU.js.map → __federation_expose_auth0CoreCommon-DxPG_Wc0.js.map} +1 -1
  82. package/dist/web/assets/{__federation_expose_auth0CoreWeb-CAiUkJwE.js → __federation_expose_auth0CoreWeb-B9jV1EyN.js} +7 -7
  83. package/dist/web/assets/__federation_expose_auth0CoreWeb-B9jV1EyN.js.map +1 -0
  84. package/dist/web/assets/{__federation_expose_authCoreCommon-K21saJbW.js → __federation_expose_authCoreCommon-Cxa_7fkO.js} +3 -3
  85. package/dist/web/assets/{__federation_expose_authCoreCommon-K21saJbW.js.map → __federation_expose_authCoreCommon-Cxa_7fkO.js.map} +1 -1
  86. package/dist/web/assets/{__federation_expose_authCoreWeb-L7mv-Kl9.js → __federation_expose_authCoreWeb-CTQI1rXb.js} +9 -9
  87. package/dist/web/assets/__federation_expose_authCoreWeb-CTQI1rXb.js.map +1 -0
  88. package/dist/web/assets/{__federation_expose_local-authAdminCommon-BcMGRCCu.js → __federation_expose_local-authAdminCommon-C0_ovnDb.js} +2 -2
  89. package/dist/web/assets/{__federation_expose_local-authAdminCommon-BcMGRCCu.js.map → __federation_expose_local-authAdminCommon-C0_ovnDb.js.map} +1 -1
  90. package/dist/web/assets/{__federation_expose_local-authAdminWeb-DUY1rKEt.js → __federation_expose_local-authAdminWeb-GqHU6av7.js} +2 -2
  91. package/dist/web/assets/{__federation_expose_local-authAdminWeb-DUY1rKEt.js.map → __federation_expose_local-authAdminWeb-GqHU6av7.js.map} +1 -1
  92. package/dist/web/assets/{__federation_expose_local-authCoreCommon-B1wtgXDT.js → __federation_expose_local-authCoreCommon-PHXPCKoj.js} +3 -3
  93. package/dist/web/assets/{__federation_expose_local-authCoreCommon-B1wtgXDT.js.map → __federation_expose_local-authCoreCommon-PHXPCKoj.js.map} +1 -1
  94. package/dist/web/assets/{__federation_expose_local-authCoreWeb-CSWj3XON.js → __federation_expose_local-authCoreWeb-Dz4oU0uP.js} +7 -7
  95. package/dist/web/assets/__federation_expose_local-authCoreWeb-Dz4oU0uP.js.map +1 -0
  96. package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-BTZdABuy.js → __federation_expose_placeholder-authCoreCommon-CrB_sJO_.js} +3 -3
  97. package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-BTZdABuy.js.map → __federation_expose_placeholder-authCoreCommon-CrB_sJO_.js.map} +1 -1
  98. package/dist/web/assets/{__federation_expose_placeholder-authCoreWeb-DXc_X2aO.js → __federation_expose_placeholder-authCoreWeb-KJ8YuuIQ.js} +7 -7
  99. package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-KJ8YuuIQ.js.map +1 -0
  100. package/dist/web/assets/{__federation_fn_import-BVpKhyMw.js → __federation_fn_import-CVjKjdRb.js} +2 -2
  101. package/dist/web/assets/{__federation_fn_import-BVpKhyMw.js.map → __federation_fn_import-CVjKjdRb.js.map} +1 -1
  102. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/{web-gdwlRH2l.js → web-BTmJxb08.js} +11 -6
  103. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-BTmJxb08.js.map +1 -0
  104. package/dist/web/assets/__federation_shared_@baseplate-dev/{project-builder-lib-BvJ1_iif.js → project-builder-lib-FK4Jv94w.js} +620 -644
  105. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-FK4Jv94w.js.map +1 -0
  106. package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-E30UR3cY.js → ui-components-jZLf5m_y.js} +5 -5
  107. package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-E30UR3cY.js.map → ui-components-jZLf5m_y.js.map} +1 -1
  108. package/dist/web/assets/__federation_shared_@baseplate-dev/{utils-Ciu7eAT9.js → utils-CAgM5SRt.js} +47 -48
  109. package/dist/web/assets/__federation_shared_@baseplate-dev/utils-CAgM5SRt.js.map +1 -0
  110. package/dist/web/assets/__federation_shared_@tanstack/{react-router-AU7vpPwr.js → react-router-DynsSbJG.js} +2541 -2240
  111. package/dist/web/assets/__federation_shared_@tanstack/react-router-DynsSbJG.js.map +1 -0
  112. package/dist/web/assets/__federation_shared_zod-B6wbpZ4f.js +12007 -0
  113. package/dist/web/assets/__federation_shared_zod-B6wbpZ4f.js.map +1 -0
  114. package/dist/web/assets/{get-auth-plugin-definition-CHOjVGaq.js → get-auth-plugin-definition-DqZ2Eg7c.js} +2 -2
  115. package/dist/web/assets/{get-auth-plugin-definition-CHOjVGaq.js.map → get-auth-plugin-definition-DqZ2Eg7c.js.map} +1 -1
  116. package/dist/web/assets/{index-DqPqnxYC.js → index-Dccn3WBN.js} +2 -2
  117. package/dist/web/assets/{index-DqPqnxYC.js.map → index-Dccn3WBN.js.map} +1 -1
  118. package/dist/web/assets/{index.esm-DUunUtBj.js → index.esm-DeCjXqFv.js} +2 -2
  119. package/dist/web/assets/{index.esm-DUunUtBj.js.map → index.esm-DeCjXqFv.js.map} +1 -1
  120. package/dist/web/assets/{model-merger-CI1pu411.js → model-merger-kOQ_dmiE.js} +326 -170
  121. package/dist/web/assets/model-merger-kOQ_dmiE.js.map +1 -0
  122. package/dist/web/assets/{plugin-definition-CIiMl7Zf.js → plugin-definition-CxKhFkmJ.js} +3 -3
  123. package/dist/web/assets/plugin-definition-CxKhFkmJ.js.map +1 -0
  124. package/dist/web/assets/{plugin-definition--cfUfY5Z.js → plugin-definition-DKygiFuR.js} +2 -2
  125. package/dist/web/assets/{plugin-definition--cfUfY5Z.js.map → plugin-definition-DKygiFuR.js.map} +1 -1
  126. package/dist/web/assets/{plugin-definition-BzhiPIBh.js → plugin-definition-JFxKP18O.js} +2 -2
  127. package/dist/web/assets/{plugin-definition-BzhiPIBh.js.map → plugin-definition-JFxKP18O.js.map} +1 -1
  128. package/dist/web/assets/{plugin-definition-BYzEIUL9.js → plugin-definition-qkkt1X28.js} +2 -2
  129. package/dist/web/assets/{plugin-definition-BYzEIUL9.js.map → plugin-definition-qkkt1X28.js.map} +1 -1
  130. package/dist/web/assets/{react-DW8S9iUr.js → react-DA5A88WZ.js} +2 -2
  131. package/dist/web/assets/{react-DW8S9iUr.js.map → react-DA5A88WZ.js.map} +1 -1
  132. package/dist/web/assets/registries-19UehlAo.js +1081 -0
  133. package/dist/web/assets/registries-19UehlAo.js.map +1 -0
  134. package/dist/web/assets/remoteEntry.js +10 -10
  135. package/dist/web/assets/styles-CfTjrsB-.js +59 -0
  136. package/dist/web/assets/styles-CfTjrsB-.js.map +1 -0
  137. package/package.json +15 -15
  138. package/dist/index.js.map +0 -1
  139. package/dist/web/assets/__federation_expose_auth0CoreWeb-CAiUkJwE.js.map +0 -1
  140. package/dist/web/assets/__federation_expose_authCoreWeb-L7mv-Kl9.js.map +0 -1
  141. package/dist/web/assets/__federation_expose_local-authCoreWeb-CSWj3XON.js.map +0 -1
  142. package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-DXc_X2aO.js.map +0 -1
  143. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-gdwlRH2l.js.map +0 -1
  144. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-BvJ1_iif.js.map +0 -1
  145. package/dist/web/assets/__federation_shared_@baseplate-dev/utils-Ciu7eAT9.js.map +0 -1
  146. package/dist/web/assets/__federation_shared_@tanstack/react-router-AU7vpPwr.js.map +0 -1
  147. package/dist/web/assets/__federation_shared_zod-BGUJlEOa.js +0 -4291
  148. package/dist/web/assets/__federation_shared_zod-BGUJlEOa.js.map +0 -1
  149. package/dist/web/assets/model-merger-CI1pu411.js.map +0 -1
  150. package/dist/web/assets/plugin-definition-CIiMl7Zf.js.map +0 -1
  151. package/dist/web/assets/styles-N05E1ZaS.js +0 -58
  152. package/dist/web/assets/styles-N05E1ZaS.js.map +0 -1
  153. package/dist/web-export.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { importShared } from './__federation_fn_import-BVpKhyMw.js';
1
+ import { importShared } from './__federation_fn_import-CVjKjdRb.js';
2
2
  import { g as getSymbols, a as isPlainObject, e as eq } from './isEqual-DAXqKRba.js';
3
3
 
4
4
  function createInitializedPluginSpec(spec, implementation) {
@@ -243,171 +243,6 @@ function createEntityType(name, options) {
243
243
  return new DefinitionEntityType(name, prefix, parentType);
244
244
  }
245
245
 
246
- class DefinitionReferenceMarker {
247
- value;
248
- reference;
249
- constructor(value, reference) {
250
- this.value = value;
251
- this.reference = reference;
252
- }
253
- toString() {
254
- return this.value ?? '';
255
- }
256
- }
257
- const REF_ANNOTATIONS_MARKER_SYMBOL = Symbol('refAnnotationsMarker');
258
-
259
- const {z: z$2} = await importShared('zod');
260
- function extendParserContextWithRefs({ transformReferences, }) {
261
- function withRef(reference) {
262
- return z$2.string().transform((value) => {
263
- if (transformReferences && value) {
264
- return new DefinitionReferenceMarker(value, reference);
265
- }
266
- return value;
267
- });
268
- }
269
- function withEnt(schema, entity) {
270
- if (!('id' in schema.shape)) {
271
- throw new Error(`Entity must have an id field. Entity type: ${entity.type.name}. Schema keys: ${Object.keys(schema.shape).join(', ')}`);
272
- }
273
- return schema.transform((value) => {
274
- // Check if the id is valid
275
- if (!('id' in value) || !entity.type.isId(value.id)) {
276
- throw new Error(`Invalid id for entity ${entity.type.name}. Id: ${value.id}`);
277
- }
278
- if (transformReferences) {
279
- const existingAnnotations = REF_ANNOTATIONS_MARKER_SYMBOL in value
280
- ? value[REF_ANNOTATIONS_MARKER_SYMBOL]
281
- : undefined;
282
- return {
283
- ...value,
284
- [REF_ANNOTATIONS_MARKER_SYMBOL]: {
285
- entities: [...(existingAnnotations?.entities ?? []), entity],
286
- references: existingAnnotations?.references ?? [],
287
- contextPaths: existingAnnotations?.contextPaths ?? [],
288
- },
289
- };
290
- }
291
- return value;
292
- });
293
- }
294
- function withRefBuilder(schema, builder) {
295
- return schema.transform((value) => {
296
- if (!value) {
297
- return value;
298
- }
299
- if (typeof value !== 'object') {
300
- throw new TypeError(`refBuilder requires an object, but got ${typeof value}`);
301
- }
302
- const existingAnnotations = REF_ANNOTATIONS_MARKER_SYMBOL in value
303
- ? value[REF_ANNOTATIONS_MARKER_SYMBOL]
304
- : undefined;
305
- const entities = existingAnnotations?.entities ?? [];
306
- const references = existingAnnotations?.references ?? [];
307
- const contextPaths = existingAnnotations?.contextPaths ?? [];
308
- const refBuilder = {
309
- addReference: (reference) => {
310
- references.push(reference);
311
- },
312
- addEntity: (entity) => {
313
- entities.push(entity);
314
- },
315
- addPathToContext: (path, type, context) => {
316
- contextPaths.push({ path, type, context });
317
- },
318
- };
319
- builder?.(refBuilder, value);
320
- if (transformReferences) {
321
- return {
322
- ...value,
323
- [REF_ANNOTATIONS_MARKER_SYMBOL]: {
324
- entities,
325
- references,
326
- contextPaths,
327
- },
328
- };
329
- }
330
- return value;
331
- });
332
- }
333
- return {
334
- withRef,
335
- withEnt,
336
- withRefBuilder,
337
- };
338
- }
339
-
340
- const {z: z$1} = await importShared('zod');
341
-
342
- function isEmpty(value) {
343
- if (value === undefined || value === null) {
344
- return true;
345
- }
346
- if (Array.isArray(value)) {
347
- return value.length === 0;
348
- }
349
- if (typeof value === 'object' &&
350
- Object.getPrototypeOf(value) === Object.prototype) {
351
- return Object.values(value).every((val) => val === undefined);
352
- }
353
- if (typeof value === 'string') {
354
- return value === '';
355
- }
356
- return false;
357
- }
358
- /**
359
- * Extends the parser context with default value handling functionality.
360
- *
361
- * @param options - The schema creator options containing the defaultMode
362
- * @returns An object containing the withDefault method
363
- */
364
- function extendParserContextWithDefaults(options) {
365
- const mode = options.defaultMode ?? 'populate';
366
- return {
367
- withDefault: function withDefault(schema, defaultValue) {
368
- // Auto-add .optional() to the schema
369
- const optionalSchema = schema.optional();
370
- switch (mode) {
371
- case 'populate': {
372
- // Use preprocess to inject defaults before validation
373
- return z$1.preprocess((value) => {
374
- if (value === undefined) {
375
- return defaultValue;
376
- }
377
- return value;
378
- }, optionalSchema);
379
- }
380
- case 'strip': {
381
- // Use transform to remove values matching defaults after validation
382
- return optionalSchema.transform((value) => {
383
- if (isEmpty(value)) {
384
- return undefined;
385
- }
386
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- it's typed to a generic
387
- return value;
388
- });
389
- }
390
- case 'preserve': {
391
- // Return schema with .optional() added
392
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- it's typed to a generic
393
- return optionalSchema.transform((x) => x);
394
- }
395
- }
396
- },
397
- };
398
- }
399
-
400
- function createDefinitionSchemaParserContext(options) {
401
- return {
402
- ...options,
403
- ...extendParserContextWithRefs(options),
404
- ...extendParserContextWithDefaults(options),
405
- };
406
- }
407
- function definitionSchema(creator) {
408
- return (context) => creator(context);
409
- }
410
-
411
246
  function isDeepKey(key) {
412
247
  switch (typeof key) {
413
248
  case 'number':
@@ -689,6 +524,324 @@ function set(obj, path, value) {
689
524
  return obj;
690
525
  }
691
526
 
527
+ class DefinitionReferenceMarker {
528
+ value;
529
+ reference;
530
+ constructor(value, reference) {
531
+ this.value = value;
532
+ this.reference = reference;
533
+ }
534
+ toString() {
535
+ return this.value ?? '';
536
+ }
537
+ }
538
+ const REF_ANNOTATIONS_MARKER_SYMBOL = Symbol('refAnnotationsMarker');
539
+
540
+ /**
541
+ * Creates a new ref context slot for the given entity type.
542
+ * Each call creates a unique slot, even for the same entity type.
543
+ *
544
+ * @param name - A descriptive name for debugging (shows in Symbol description)
545
+ * @param entityType - The entity type this slot will be associated with
546
+ * @returns A new unique RefContextSlot instance
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * const modelSlot = createRefContextSlot('modelSlot', modelEntityType);
551
+ * const anotherModelSlot = createRefContextSlot('anotherModelSlot', modelEntityType);
552
+ *
553
+ * // These are different slots despite same entity type
554
+ * modelSlot.id !== anotherModelSlot.id
555
+ * // modelSlot.id.toString() === 'Symbol(modelSlot)'
556
+ * ```
557
+ */
558
+ function createRefContextSlot(name, entityType) {
559
+ return {
560
+ entityType,
561
+ id: Symbol(name),
562
+ };
563
+ }
564
+ /**
565
+ * Creates a RefContextSlotMap from a slot definition.
566
+ * Used internally by ctx.refContext().
567
+ *
568
+ * @param slotDefinition - Map of slot names to entity types
569
+ * @returns Map of slot names to RefContextSlot instances
570
+ */
571
+ function createRefContextSlotMap(slotDefinition) {
572
+ return Object.fromEntries(Object.entries(slotDefinition).map(([key, entityType]) => [
573
+ key,
574
+ createRefContextSlot(key, entityType),
575
+ ]));
576
+ }
577
+
578
+ /**
579
+ * Strips the DefinitionReferenceMarker from the value recursively.
580
+ * @param value - The value to strip the DefinitionReferenceMarker from.
581
+ * @returns The value without the DefinitionReferenceMarker.
582
+ */
583
+ function stripRefMarkers(value) {
584
+ if (value instanceof DefinitionReferenceMarker) {
585
+ return value.value;
586
+ }
587
+ if (Array.isArray(value)) {
588
+ return value.map(stripRefMarkers);
589
+ }
590
+ if (typeof value === 'object' && value !== null) {
591
+ return Object.fromEntries(Object.entries(value).map(([key, childValue]) => [
592
+ key,
593
+ stripRefMarkers(childValue),
594
+ ]));
595
+ }
596
+ return value;
597
+ }
598
+
599
+ const {z: z$1} = await importShared('zod');
600
+ function extendParserContextWithRefs({ transformReferences, }) {
601
+ function modifyAnnotations(value, ctx, modifier) {
602
+ if (value === null || value === undefined)
603
+ return value;
604
+ if (typeof value !== 'object') {
605
+ ctx.addIssue({
606
+ code: 'invalid_type',
607
+ expected: 'object',
608
+ message: `Entity must be an object`,
609
+ input: value,
610
+ });
611
+ return value;
612
+ }
613
+ if (transformReferences) {
614
+ const existingAnnotations = REF_ANNOTATIONS_MARKER_SYMBOL in value
615
+ ? value[REF_ANNOTATIONS_MARKER_SYMBOL]
616
+ : { entities: [], references: [], slots: [] };
617
+ return {
618
+ ...value,
619
+ [REF_ANNOTATIONS_MARKER_SYMBOL]: modifier(existingAnnotations),
620
+ };
621
+ }
622
+ return value;
623
+ }
624
+ function withRef(reference) {
625
+ return z$1.string().transform((value) => {
626
+ if (transformReferences && value) {
627
+ return new DefinitionReferenceMarker(value, {
628
+ path: [],
629
+ type: reference.type,
630
+ onDelete: reference.onDelete,
631
+ parentSlot: reference.parentSlot,
632
+ provides: reference.provides,
633
+ });
634
+ }
635
+ return value;
636
+ });
637
+ }
638
+ function withEnt(schema, entity) {
639
+ return schema.transform((value, ctx) => {
640
+ if (value === null || value === undefined)
641
+ return value;
642
+ if (transformReferences) {
643
+ if (typeof value !== 'object') {
644
+ ctx.addIssue({
645
+ code: 'invalid_type',
646
+ expected: 'object',
647
+ message: `Entity must be an object`,
648
+ input: value,
649
+ });
650
+ return value;
651
+ }
652
+ // Check if the id is valid
653
+ const idPath = entity.idPath ?? ['id'];
654
+ const id = get(value, idPath);
655
+ if (typeof id !== 'string' || !id || !entity.type.isId(id)) {
656
+ ctx.addIssue({
657
+ code: 'custom',
658
+ message: `Unable to find string id field '${entity.idPath?.join('.') ?? 'id'}' in entity ${entity.type.name}`,
659
+ input: value,
660
+ });
661
+ return value;
662
+ }
663
+ const nameResolver = (() => {
664
+ if (entity.getNameResolver) {
665
+ return entity.getNameResolver(stripRefMarkers(value));
666
+ }
667
+ if (!('name' in value) || typeof value.name !== 'string') {
668
+ ctx.addIssue({
669
+ code: 'custom',
670
+ message: `Unable to find string name field in entity ${entity.type.name}`,
671
+ input: value,
672
+ });
673
+ return 'invalid';
674
+ }
675
+ return value.name;
676
+ })();
677
+ const newEntity = {
678
+ id,
679
+ idPath,
680
+ path: [],
681
+ type: entity.type,
682
+ nameResolver,
683
+ parentSlot: entity.parentSlot,
684
+ provides: entity.provides,
685
+ };
686
+ return modifyAnnotations(value, ctx, (annotations) => ({
687
+ ...annotations,
688
+ entities: [...annotations.entities, newEntity],
689
+ }));
690
+ }
691
+ return value;
692
+ });
693
+ }
694
+ /**
695
+ * Creates ref context slots for use within a schema definition.
696
+ * Slots provide type-safe context for parent-child entity relationships.
697
+ *
698
+ * @example
699
+ * ```typescript
700
+ * ctx.refContext(
701
+ * { modelSlot: modelEntityType },
702
+ * ({ modelSlot }) =>
703
+ * ctx.withEnt(schema, {
704
+ * type: modelEntityType,
705
+ * provides: modelSlot,
706
+ * }),
707
+ * );
708
+ * ```
709
+ */
710
+ function refContext(slotDefinition, schemaBuilder) {
711
+ const slots = createRefContextSlotMap(slotDefinition);
712
+ return schemaBuilder(slots).transform((value, ctx) => modifyAnnotations(value, ctx, (annotations) => ({
713
+ ...annotations,
714
+ slots: [
715
+ ...annotations.slots,
716
+ ...Object.values(slots).map((slot) => ({
717
+ path: [],
718
+ slot,
719
+ })),
720
+ ],
721
+ })));
722
+ }
723
+ return {
724
+ withRef,
725
+ withEnt,
726
+ refContext,
727
+ };
728
+ }
729
+
730
+ function isEmpty(value) {
731
+ if (value === undefined || value === null) {
732
+ return true;
733
+ }
734
+ if (Array.isArray(value)) {
735
+ return value.length === 0;
736
+ }
737
+ if (typeof value === 'object' &&
738
+ Object.getPrototypeOf(value) === Object.prototype) {
739
+ return Object.values(value).every((val) => val === undefined);
740
+ }
741
+ if (typeof value === 'string') {
742
+ return value === '';
743
+ }
744
+ return false;
745
+ }
746
+ /**
747
+ * Extends the parser context with default value handling functionality.
748
+ *
749
+ * @param options - The schema creator options containing the defaultMode
750
+ * @returns An object containing the withDefault method
751
+ */
752
+ function extendParserContextWithDefaults(options) {
753
+ const mode = options.defaultMode ?? 'populate';
754
+ return {
755
+ withDefault: function withDefault(schema, defaultValue) {
756
+ switch (mode) {
757
+ case 'populate': {
758
+ return schema.prefault(defaultValue).optional();
759
+ }
760
+ case 'strip': {
761
+ // Use transform to remove values matching defaults after validation
762
+ return schema
763
+ .transform((value) => {
764
+ if (value === defaultValue)
765
+ return undefined;
766
+ if (isEmpty(value)) {
767
+ return undefined;
768
+ }
769
+ return value;
770
+ })
771
+ .optional();
772
+ }
773
+ case 'preserve': {
774
+ // Return schema with .optional() added
775
+ return schema.transform((x) => x).optional();
776
+ }
777
+ }
778
+ },
779
+ };
780
+ }
781
+
782
+ function createDefinitionSchemaParserContext(options) {
783
+ return {
784
+ ...options,
785
+ ...extendParserContextWithRefs(options),
786
+ ...extendParserContextWithDefaults(options),
787
+ };
788
+ }
789
+ function definitionSchema(creator) {
790
+ return (context) => creator(context);
791
+ }
792
+ /**
793
+ * Creates a schema that requires slots to be passed from parent schemas.
794
+ * Used when a schema needs to reference entities from a parent context.
795
+ *
796
+ * @example
797
+ * ```typescript
798
+ * // Child schema requiring modelSlot from parent
799
+ * export const createModelScalarFieldSchema = definitionSchemaWithSlots(
800
+ * { modelSlot: modelEntityType },
801
+ * (ctx, { modelSlot }) =>
802
+ * ctx.withEnt(schema, {
803
+ * type: modelScalarFieldEntityType,
804
+ * parentSlot: modelSlot,
805
+ * }),
806
+ * );
807
+ *
808
+ * // Called from parent:
809
+ * createModelScalarFieldSchema(ctx, { modelSlot: parentModelSlot })
810
+ * ```
811
+ */
812
+ function definitionSchemaWithSlots(slotDefinition, creator) {
813
+ const creatorWithSlots = (context, slots) => creator(context, slots);
814
+ creatorWithSlots.slotDefinition = slotDefinition;
815
+ return creatorWithSlots;
816
+ }
817
+ /**
818
+ * Wraps a schema creator that requires slots with placeholder slots,
819
+ * producing a simple schema creator that can be used for validation-only
820
+ * contexts (e.g., React Hook Form).
821
+ *
822
+ * The placeholder slots allow the schema to parse without actual parent context,
823
+ * which is useful when you only need schema validation without ref extraction.
824
+ *
825
+ * @example
826
+ * ```typescript
827
+ * // Schema that normally requires modelSlot from parent
828
+ * const createModelScalarFieldSchema = definitionSchemaWithSlots(
829
+ * { modelSlot: modelEntityType },
830
+ * (ctx, { modelSlot }) => ctx.withEnt(schema, { parentSlot: modelSlot }),
831
+ * );
832
+ *
833
+ * // For React Hook Form validation, wrap with placeholder slots
834
+ * const fieldSchema = withPlaceholderSlots(createModelScalarFieldSchema);
835
+ * const zodSchema = fieldSchema(ctx); // No slots needed
836
+ * ```
837
+ */
838
+ function withPlaceholderSlots(schemaCreator) {
839
+ return (ctx) => {
840
+ const placeholderSlots = createRefContextSlotMap(schemaCreator.slotDefinition);
841
+ return schemaCreator(ctx, placeholderSlots);
842
+ };
843
+ }
844
+
692
845
  const {CASE_VALIDATORS} = await importShared('@baseplate-dev/utils');
693
846
 
694
847
  const {z} = await importShared('zod');
@@ -1300,7 +1453,8 @@ function applyModelMergerDiff(model, diff, definitionContainer, siblingModels =
1300
1453
  }
1301
1454
  return field.id;
1302
1455
  }
1303
- const model = ModelUtils.byIdOrThrow(definitionContainer.definition, modelId);
1456
+ const model = ModelUtils.byName(definitionContainer.definition, modelId) ??
1457
+ ModelUtils.byIdOrThrow(definitionContainer.definition, modelId);
1304
1458
  const field = model.model.fields.find((f) => f.name === fieldName);
1305
1459
  if (!field) {
1306
1460
  throw new Error(`Field ${fieldName} not found in model ${model.name}`);
@@ -1331,7 +1485,9 @@ function applyModelMergerDiff(model, diff, definitionContainer, siblingModels =
1331
1485
  if (siblingModel) {
1332
1486
  return siblingModel.id;
1333
1487
  }
1334
- return modelRef;
1488
+ const model = ModelUtils.byName(definitionContainer.definition, modelRef) ??
1489
+ ModelUtils.byIdOrThrow(definitionContainer.definition, modelRef);
1490
+ return model.id;
1335
1491
  }),
1336
1492
  };
1337
1493
  }
@@ -1375,5 +1531,5 @@ function createAndApplyModelMergerResults(draftConfig, current, desired, definit
1375
1531
  return resultIds;
1376
1532
  }
1377
1533
 
1378
- export { createModelMergerResults as A, applyModelMergerDiff as B, applyModelMergerResultInPlace as C, DefinitionReferenceMarker as D, createAndApplyModelMergerResults as E, FeatureUtils as F, DefinitionDiffKeyedArrayField as G, DefinitionDiffReplacementField as H, DefinitionDiffArrayIncludesField as I, createDefinitionDiffConfig as J, createDefinitionDiff as K, applyDefinitionDiff as L, ModelUtils as M, REF_ANNOTATIONS_MARKER_SYMBOL as R, createEntityType as a, createDefinitionSchemaParserContext as b, createPluginSpec as c, definitionSchema as d, modelForeignRelationEntityType as e, modelLocalRelationEntityType as f, get as g, modelScalarFieldEntityType as h, modelEntityType as i, modelTransformerEntityType as j, modelEnumValueEntityType as k, featureEntityType as l, mapValues as m, modelEnumEntityType as n, modelUniqueConstraintEntityType as o, createFeaturesSchema as p, omit as q, cloneDeep as r, set as s, createInitializedPluginSpec as t, DefinitionEntityType as u, featureNameSchema as v, createFeatureSchema as w, modelMergerDefinitionDiffConfig as x, createModelMergerResult as y, doesModelMergerResultsHaveChanges as z };
1379
- //# sourceMappingURL=model-merger-CI1pu411.js.map
1534
+ export { featureNameSchema as A, createFeatureSchema as B, modelMergerDefinitionDiffConfig as C, DefinitionReferenceMarker as D, createModelMergerResult as E, FeatureUtils as F, doesModelMergerResultsHaveChanges as G, createModelMergerResults as H, applyModelMergerDiff as I, applyModelMergerResultInPlace as J, createAndApplyModelMergerResults as K, DefinitionDiffKeyedArrayField as L, ModelUtils as M, DefinitionDiffReplacementField as N, DefinitionDiffArrayIncludesField as O, createDefinitionDiffConfig as P, createDefinitionDiff as Q, REF_ANNOTATIONS_MARKER_SYMBOL as R, applyDefinitionDiff as S, createEntityType as a, createDefinitionSchemaParserContext as b, createPluginSpec as c, definitionSchemaWithSlots as d, set as e, definitionSchema as f, get as g, modelForeignRelationEntityType as h, modelLocalRelationEntityType as i, modelScalarFieldEntityType as j, modelEntityType as k, modelTransformerEntityType as l, mapValues as m, modelEnumValueEntityType as n, modelEnumEntityType as o, featureEntityType as p, modelUniqueConstraintEntityType as q, createFeaturesSchema as r, stripRefMarkers as s, omit as t, cloneDeep as u, createInitializedPluginSpec as v, createRefContextSlot as w, createRefContextSlotMap as x, DefinitionEntityType as y, withPlaceholderSlots as z };
1535
+ //# sourceMappingURL=model-merger-kOQ_dmiE.js.map