@baseplate-dev/project-builder-lib 0.4.4 → 0.5.1

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 (252) hide show
  1. package/dist/compiler/admin-crud-action-compiler.d.ts +18 -0
  2. package/dist/compiler/admin-crud-action-compiler.d.ts.map +1 -0
  3. package/dist/compiler/admin-crud-action-compiler.js +6 -0
  4. package/dist/compiler/admin-crud-action-compiler.js.map +1 -0
  5. package/dist/compiler/admin-crud-column-compiler-spec.d.ts +6 -12
  6. package/dist/compiler/admin-crud-column-compiler-spec.d.ts.map +1 -1
  7. package/dist/compiler/admin-crud-column-compiler-spec.js +6 -29
  8. package/dist/compiler/admin-crud-column-compiler-spec.js.map +1 -1
  9. package/dist/compiler/admin-crud-input-spec.d.ts +6 -11
  10. package/dist/compiler/admin-crud-input-spec.d.ts.map +1 -1
  11. package/dist/compiler/admin-crud-input-spec.js +6 -26
  12. package/dist/compiler/admin-crud-input-spec.js.map +1 -1
  13. package/dist/compiler/app-compiler-spec.d.ts +8 -12
  14. package/dist/compiler/app-compiler-spec.d.ts.map +1 -1
  15. package/dist/compiler/app-compiler-spec.js +11 -18
  16. package/dist/compiler/app-compiler-spec.js.map +1 -1
  17. package/dist/compiler/index.d.ts +1 -1
  18. package/dist/compiler/index.d.ts.map +1 -1
  19. package/dist/compiler/index.js +1 -1
  20. package/dist/compiler/index.js.map +1 -1
  21. package/dist/compiler/model-transformer-compiler-spec.d.ts +6 -11
  22. package/dist/compiler/model-transformer-compiler-spec.d.ts.map +1 -1
  23. package/dist/compiler/model-transformer-compiler-spec.js +6 -26
  24. package/dist/compiler/model-transformer-compiler-spec.js.map +1 -1
  25. package/dist/definition/index.d.ts +1 -0
  26. package/dist/definition/index.d.ts.map +1 -1
  27. package/dist/definition/index.js +1 -0
  28. package/dist/definition/index.js.map +1 -1
  29. package/dist/definition/model/model-field-utils.d.ts +2 -0
  30. package/dist/definition/model/model-field-utils.d.ts.map +1 -1
  31. package/dist/definition/model/model-field-utils.js +8 -0
  32. package/dist/definition/model/model-field-utils.js.map +1 -1
  33. package/dist/definition/model/model-transformer-utils.d.ts +4 -6
  34. package/dist/definition/model/model-transformer-utils.d.ts.map +1 -1
  35. package/dist/definition/model/model-transformer-utils.js +8 -10
  36. package/dist/definition/model/model-transformer-utils.js.map +1 -1
  37. package/dist/definition/model/model-utils.d.ts +2 -0
  38. package/dist/definition/model/model-utils.d.ts.map +1 -1
  39. package/dist/definition/model/model-utils.js +5 -0
  40. package/dist/definition/model/model-utils.js.map +1 -1
  41. package/dist/definition/packages/package-utils.d.ts +18 -0
  42. package/dist/definition/packages/package-utils.d.ts.map +1 -0
  43. package/dist/definition/packages/package-utils.js +34 -0
  44. package/dist/definition/packages/package-utils.js.map +1 -0
  45. package/dist/definition/plugins/plugin-utils.d.ts.map +1 -1
  46. package/dist/definition/plugins/plugin-utils.js +2 -2
  47. package/dist/definition/plugins/plugin-utils.js.map +1 -1
  48. package/dist/definition/project-definition-container.d.ts +3 -3
  49. package/dist/definition/project-definition-container.d.ts.map +1 -1
  50. package/dist/definition/project-definition-container.js +2 -2
  51. package/dist/definition/project-definition-container.js.map +1 -1
  52. package/dist/definition/project-definition-container.test-utils.d.ts.map +1 -1
  53. package/dist/definition/project-definition-container.test-utils.js +8 -4
  54. package/dist/definition/project-definition-container.test-utils.js.map +1 -1
  55. package/dist/index.d.ts +1 -0
  56. package/dist/index.js +1 -0
  57. package/dist/migrations/index.d.ts.map +1 -1
  58. package/dist/migrations/index.js +2 -0
  59. package/dist/migrations/index.js.map +1 -1
  60. package/dist/migrations/migration-022-rename-packages-to-libraries.d.ts +37 -0
  61. package/dist/migrations/migration-022-rename-packages-to-libraries.d.ts.map +1 -0
  62. package/dist/migrations/migration-022-rename-packages-to-libraries.js +45 -0
  63. package/dist/migrations/migration-022-rename-packages-to-libraries.js.map +1 -0
  64. package/dist/parser/parser.d.ts +4 -4
  65. package/dist/parser/parser.d.ts.map +1 -1
  66. package/dist/parser/parser.js +17 -42
  67. package/dist/parser/parser.js.map +1 -1
  68. package/dist/plugin-tools/plugin-loader.js +3 -3
  69. package/dist/plugin-tools/plugin-loader.js.map +1 -1
  70. package/dist/plugins/context/index.d.ts +2 -0
  71. package/dist/plugins/context/index.d.ts.map +1 -0
  72. package/dist/plugins/context/index.js +2 -0
  73. package/dist/plugins/context/index.js.map +1 -0
  74. package/dist/plugins/context/plugin-context.d.ts +30 -0
  75. package/dist/plugins/context/plugin-context.d.ts.map +1 -0
  76. package/dist/plugins/context/plugin-context.js +38 -0
  77. package/dist/plugins/context/plugin-context.js.map +1 -0
  78. package/dist/plugins/imports/loader.d.ts +11 -20
  79. package/dist/plugins/imports/loader.d.ts.map +1 -1
  80. package/dist/plugins/imports/loader.js +28 -69
  81. package/dist/plugins/imports/loader.js.map +1 -1
  82. package/dist/plugins/imports/types.d.ts +72 -13
  83. package/dist/plugins/imports/types.d.ts.map +1 -1
  84. package/dist/plugins/imports/types.js +17 -1
  85. package/dist/plugins/imports/types.js.map +1 -1
  86. package/dist/plugins/index.d.ts +3 -1
  87. package/dist/plugins/index.d.ts.map +1 -1
  88. package/dist/plugins/index.js +3 -1
  89. package/dist/plugins/index.js.map +1 -1
  90. package/dist/plugins/migrations/run-migrations.d.ts +2 -2
  91. package/dist/plugins/migrations/run-migrations.d.ts.map +1 -1
  92. package/dist/plugins/migrations/run-migrations.js +2 -2
  93. package/dist/plugins/migrations/run-migrations.js.map +1 -1
  94. package/dist/plugins/spec/auth-config-spec.d.ts +13 -9
  95. package/dist/plugins/spec/auth-config-spec.d.ts.map +1 -1
  96. package/dist/plugins/spec/auth-config-spec.js +16 -3
  97. package/dist/plugins/spec/auth-config-spec.js.map +1 -1
  98. package/dist/plugins/spec/auth-models-spec.d.ts +16 -0
  99. package/dist/plugins/spec/auth-models-spec.d.ts.map +1 -0
  100. package/dist/plugins/spec/auth-models-spec.js +16 -0
  101. package/dist/plugins/spec/auth-models-spec.js.map +1 -0
  102. package/dist/plugins/spec/config-spec.d.ts +8 -13
  103. package/dist/plugins/spec/config-spec.d.ts.map +1 -1
  104. package/dist/plugins/spec/config-spec.js +20 -35
  105. package/dist/plugins/spec/config-spec.js.map +1 -1
  106. package/dist/plugins/spec/index.d.ts +1 -1
  107. package/dist/plugins/spec/index.d.ts.map +1 -1
  108. package/dist/plugins/spec/index.js +1 -1
  109. package/dist/plugins/spec/index.js.map +1 -1
  110. package/dist/plugins/spec/types.d.ts +66 -25
  111. package/dist/plugins/spec/types.d.ts.map +1 -1
  112. package/dist/plugins/spec/types.js +27 -10
  113. package/dist/plugins/spec/types.js.map +1 -1
  114. package/dist/plugins/spec/web-config-spec.d.ts +7 -10
  115. package/dist/plugins/spec/web-config-spec.d.ts.map +1 -1
  116. package/dist/plugins/spec/web-config-spec.js +6 -19
  117. package/dist/plugins/spec/web-config-spec.js.map +1 -1
  118. package/dist/plugins/store/index.d.ts.map +1 -0
  119. package/dist/plugins/store/index.js.map +1 -0
  120. package/dist/plugins/store/store.d.ts +23 -0
  121. package/dist/plugins/store/store.d.ts.map +1 -0
  122. package/dist/plugins/store/store.js +36 -0
  123. package/dist/plugins/store/store.js.map +1 -0
  124. package/dist/plugins/utils/create-field-map-spec.d.ts +17 -0
  125. package/dist/plugins/utils/create-field-map-spec.d.ts.map +1 -0
  126. package/dist/plugins/utils/create-field-map-spec.js +27 -0
  127. package/dist/plugins/utils/create-field-map-spec.js.map +1 -0
  128. package/dist/plugins/utils/create-plugin-field-map.d.ts +24 -0
  129. package/dist/plugins/utils/create-plugin-field-map.d.ts.map +1 -0
  130. package/dist/plugins/utils/create-plugin-field-map.js +29 -0
  131. package/dist/plugins/utils/create-plugin-field-map.js.map +1 -0
  132. package/dist/plugins/utils/index.d.ts +3 -0
  133. package/dist/plugins/utils/index.d.ts.map +1 -0
  134. package/dist/plugins/utils/index.js +3 -0
  135. package/dist/plugins/utils/index.js.map +1 -0
  136. package/dist/schema/apps/backend/index.d.ts +0 -2
  137. package/dist/schema/apps/backend/index.d.ts.map +1 -1
  138. package/dist/schema/apps/backend/index.js +0 -1
  139. package/dist/schema/apps/backend/index.js.map +1 -1
  140. package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.d.ts +6 -13
  141. package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.d.ts.map +1 -1
  142. package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.js +5 -26
  143. package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.js.map +1 -1
  144. package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.d.ts.map +1 -1
  145. package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.js +1 -3
  146. package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.js.map +1 -1
  147. package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.d.ts +6 -12
  148. package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.d.ts.map +1 -1
  149. package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.js +5 -26
  150. package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.js.map +1 -1
  151. package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.d.ts.map +1 -1
  152. package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.js +1 -3
  153. package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.js.map +1 -1
  154. package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.d.ts.map +1 -1
  155. package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.js +1 -3
  156. package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.js.map +1 -1
  157. package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.d.ts +7 -13
  158. package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.d.ts.map +1 -1
  159. package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.js +5 -26
  160. package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.js.map +1 -1
  161. package/dist/schema/creator/types.d.ts +3 -3
  162. package/dist/schema/creator/types.d.ts.map +1 -1
  163. package/dist/schema/index.d.ts +1 -0
  164. package/dist/schema/index.d.ts.map +1 -1
  165. package/dist/schema/index.js +1 -0
  166. package/dist/schema/index.js.map +1 -1
  167. package/dist/schema/libraries/base.d.ts +13 -0
  168. package/dist/schema/libraries/base.d.ts.map +1 -0
  169. package/dist/schema/libraries/base.js +10 -0
  170. package/dist/schema/libraries/base.js.map +1 -0
  171. package/dist/schema/libraries/index.d.ts +3 -0
  172. package/dist/schema/libraries/index.d.ts.map +1 -0
  173. package/dist/schema/libraries/index.js +3 -0
  174. package/dist/schema/libraries/index.js.map +1 -0
  175. package/dist/schema/libraries/library.d.ts +19 -0
  176. package/dist/schema/libraries/library.d.ts.map +1 -0
  177. package/dist/schema/libraries/library.js +13 -0
  178. package/dist/schema/libraries/library.js.map +1 -0
  179. package/dist/schema/libraries/types.d.ts +2 -0
  180. package/dist/schema/libraries/types.d.ts.map +1 -0
  181. package/dist/schema/libraries/types.js +3 -0
  182. package/dist/schema/libraries/types.js.map +1 -0
  183. package/dist/schema/models/transformers/model-transformer-spec.d.ts +5 -11
  184. package/dist/schema/models/transformers/model-transformer-spec.d.ts.map +1 -1
  185. package/dist/schema/models/transformers/model-transformer-spec.js +5 -30
  186. package/dist/schema/models/transformers/model-transformer-spec.js.map +1 -1
  187. package/dist/schema/models/transformers/transformers.d.ts.map +1 -1
  188. package/dist/schema/models/transformers/transformers.js +2 -4
  189. package/dist/schema/models/transformers/transformers.js.map +1 -1
  190. package/dist/schema/plugins/definition.js +1 -1
  191. package/dist/schema/plugins/definition.js.map +1 -1
  192. package/dist/schema/project-definition.d.ts +18 -8
  193. package/dist/schema/project-definition.d.ts.map +1 -1
  194. package/dist/schema/project-definition.js +2 -0
  195. package/dist/schema/project-definition.js.map +1 -1
  196. package/dist/schema/settings/monorepo.d.ts +2 -2
  197. package/dist/schema/settings/monorepo.d.ts.map +1 -1
  198. package/dist/schema/settings/monorepo.js +17 -2
  199. package/dist/schema/settings/monorepo.js.map +1 -1
  200. package/dist/schema/settings/settings.d.ts +1 -0
  201. package/dist/schema/settings/settings.d.ts.map +1 -1
  202. package/dist/specs/index.d.ts +2 -0
  203. package/dist/specs/index.d.ts.map +1 -0
  204. package/dist/specs/index.js +2 -0
  205. package/dist/specs/index.js.map +1 -0
  206. package/dist/specs/packages/index.d.ts +3 -0
  207. package/dist/specs/packages/index.d.ts.map +1 -0
  208. package/dist/specs/packages/index.js +3 -0
  209. package/dist/specs/packages/index.js.map +1 -0
  210. package/dist/specs/packages/library-type-spec.d.ts +76 -0
  211. package/dist/specs/packages/library-type-spec.d.ts.map +1 -0
  212. package/dist/specs/packages/library-type-spec.js +31 -0
  213. package/dist/specs/packages/library-type-spec.js.map +1 -0
  214. package/dist/specs/packages/package-compiler-types.d.ts +111 -0
  215. package/dist/specs/packages/package-compiler-types.d.ts.map +1 -0
  216. package/dist/specs/packages/package-compiler-types.js +85 -0
  217. package/dist/specs/packages/package-compiler-types.js.map +1 -0
  218. package/dist/web/hooks/use-project-definition.d.ts +2 -2
  219. package/dist/web/hooks/use-project-definition.d.ts.map +1 -1
  220. package/dist/web/specs/admin-crud-action-web-spec.d.ts +6 -12
  221. package/dist/web/specs/admin-crud-action-web-spec.d.ts.map +1 -1
  222. package/dist/web/specs/admin-crud-action-web-spec.js +6 -29
  223. package/dist/web/specs/admin-crud-action-web-spec.js.map +1 -1
  224. package/dist/web/specs/admin-crud-column-web-spec.d.ts +6 -12
  225. package/dist/web/specs/admin-crud-column-web-spec.d.ts.map +1 -1
  226. package/dist/web/specs/admin-crud-column-web-spec.js +6 -29
  227. package/dist/web/specs/admin-crud-column-web-spec.js.map +1 -1
  228. package/dist/web/specs/admin-crud-input-web-spec.d.ts +6 -12
  229. package/dist/web/specs/admin-crud-input-web-spec.d.ts.map +1 -1
  230. package/dist/web/specs/admin-crud-input-web-spec.js +6 -29
  231. package/dist/web/specs/admin-crud-input-web-spec.js.map +1 -1
  232. package/dist/web/specs/model-transformer-web-spec.d.ts +8 -13
  233. package/dist/web/specs/model-transformer-web-spec.d.ts.map +1 -1
  234. package/dist/web/specs/model-transformer-web-spec.js +16 -28
  235. package/dist/web/specs/model-transformer-web-spec.js.map +1 -1
  236. package/package.json +6 -6
  237. package/dist/compiler/admin-crud-action-spec.d.ts +0 -26
  238. package/dist/compiler/admin-crud-action-spec.d.ts.map +0 -1
  239. package/dist/compiler/admin-crud-action-spec.js +0 -29
  240. package/dist/compiler/admin-crud-action-spec.js.map +0 -1
  241. package/dist/plugins/schema/index.d.ts.map +0 -1
  242. package/dist/plugins/schema/index.js.map +0 -1
  243. package/dist/plugins/schema/store.d.ts +0 -8
  244. package/dist/plugins/schema/store.d.ts.map +0 -1
  245. package/dist/plugins/schema/store.js +0 -17
  246. package/dist/plugins/schema/store.js.map +0 -1
  247. package/dist/plugins/spec/auth-model-config-spec.d.ts +0 -14
  248. package/dist/plugins/spec/auth-model-config-spec.d.ts.map +0 -1
  249. package/dist/plugins/spec/auth-model-config-spec.js +0 -6
  250. package/dist/plugins/spec/auth-model-config-spec.js.map +0 -1
  251. /package/dist/plugins/{schema → store}/index.d.ts +0 -0
  252. /package/dist/plugins/{schema → store}/index.js +0 -0
@@ -0,0 +1,16 @@
1
+ import { createFieldMapSpec } from '../utils/create-field-map-spec.js';
2
+ export const authModelsSpec = createFieldMapSpec('core/auth-models', (t) => ({
3
+ getAuthModels: t.scalar(),
4
+ }), {
5
+ use: (values) => ({
6
+ getAuthModels: (definition) => values.getAuthModels?.(definition),
7
+ getAuthModelsOrThrow: (definition) => {
8
+ const authModels = values.getAuthModels?.(definition);
9
+ if (!authModels) {
10
+ throw new Error('Auth models not found');
11
+ }
12
+ return authModels;
13
+ },
14
+ }),
15
+ });
16
+ //# sourceMappingURL=auth-models-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-models-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/auth-models-spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAMvE,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAC9C,kBAAkB,EAClB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACN,aAAa,EAAE,CAAC,CAAC,MAAM,EAAoB;CAC5C,CAAC,EACF;IACE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChB,aAAa,EAAE,CAAC,UAA6B,EAAE,EAAE,CAC/C,MAAM,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC;QACpC,oBAAoB,EAAE,CAAC,UAA6B,EAAE,EAAE;YACtD,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,CAAC;YACtD,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;CACH,CACF,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import type { DefinitionSchemaCreator } from '#src/schema/index.js';
2
- import type { PluginSpecImplementation } from './types.js';
3
2
  export interface PluginMigrationResult {
4
3
  updatedConfig?: unknown;
5
4
  updateProjectDefinition?: (draft: unknown) => void;
@@ -16,17 +15,6 @@ export interface PluginConfigMigration {
16
15
  */
17
16
  migrate: (config: unknown, projectDefinition: unknown) => PluginMigrationResult;
18
17
  }
19
- /**
20
- * Spec for registering plugin config schema
21
- */
22
- export interface PluginConfigSpec extends PluginSpecImplementation {
23
- registerSchemaCreator: (pluginKey: string, schemaCreator: DefinitionSchemaCreator) => void;
24
- registerMigrations: (pluginKey: string, migrations: PluginConfigMigration[]) => void;
25
- getSchemaCreator(pluginKey: string): DefinitionSchemaCreator | undefined;
26
- getMigrations(pluginKey: string): PluginConfigMigration[] | undefined;
27
- getLastMigrationVersion(pluginKey: string): number | undefined;
28
- }
29
- export declare function createPluginConfigImplementation(): PluginConfigSpec;
30
18
  /**
31
19
  * Spec for adding config for the plugin in the core plugin e.g.
32
20
  * {
@@ -38,5 +26,12 @@ export declare function createPluginConfigImplementation(): PluginConfigSpec;
38
26
  * }]
39
27
  * }
40
28
  */
41
- export declare const pluginConfigSpec: import("./types.js").PluginSpecWithInitializer<PluginConfigSpec>;
29
+ export declare const pluginConfigSpec: import("./types.js").PluginSpec<{
30
+ schemas: import("@baseplate-dev/utils").MapContainer<string, DefinitionSchemaCreator>;
31
+ migrations: import("@baseplate-dev/utils").MapContainer<string, PluginConfigMigration[]>;
32
+ }, {
33
+ getSchemaCreator: (pluginKey: string) => DefinitionSchemaCreator | undefined;
34
+ getMigrations: (pluginKey: string) => PluginConfigMigration[] | undefined;
35
+ getLastMigrationVersion: (pluginKey: string) => number | undefined;
36
+ }>;
42
37
  //# sourceMappingURL=config-spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAI3D,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,OAAO,EAAE,CACP,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,OAAO,KACvB,qBAAqB,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,wBAAwB;IAChE,qBAAqB,EAAE,CACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,uBAAuB,KACnC,IAAI,CAAC;IACV,kBAAkB,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,qBAAqB,EAAE,KAChC,IAAI,CAAC;IACV,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS,CAAC;IACzE,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,EAAE,GAAG,SAAS,CAAC;IACtE,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAChE;AAoBD,wBAAgB,gCAAgC,IAAI,gBAAgB,CA+BnE;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,kEAE3B,CAAC"}
1
+ {"version":3,"file":"config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAIpE,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,OAAO,EAAE,CACP,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,OAAO,KACvB,qBAAqB,CAAC;CAC5B;AAyBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;kCAcS,MAAM;+BACT,MAAM;yCAEI,MAAM;EAOlD,CAAC"}
@@ -1,46 +1,18 @@
1
- import { createPluginSpec } from './types.js';
2
- function sortAndValidateMigrations(migrations) {
1
+ import { mapValuesOfMap } from '@baseplate-dev/utils';
2
+ import { createFieldMapSpec } from '../utils/create-field-map-spec.js';
3
+ function sortAndValidateMigrations(migrations, pluginKey) {
3
4
  // make sure migrations are sorted by version and they are all unique
4
5
  const sortedMigrations = [...migrations].sort((a, b) => a.version - b.version);
5
6
  if (sortedMigrations.some((m) => m.version <= 0)) {
6
- throw new Error(`Migration version must be a positive integer`);
7
+ throw new Error(`All migrations for plugin ${pluginKey} must have a positive version`);
7
8
  }
8
9
  for (let i = 0; i < sortedMigrations.length - 1; i++) {
9
10
  if (sortedMigrations[i].version === sortedMigrations[i + 1].version) {
10
- throw new Error(`Migration versions must be unique`);
11
+ throw new Error(`All migrations for plugin ${pluginKey} must have a unique version`);
11
12
  }
12
13
  }
13
14
  return sortedMigrations;
14
15
  }
15
- export function createPluginConfigImplementation() {
16
- const schemas = new Map();
17
- const migrationsMap = new Map();
18
- return {
19
- registerSchemaCreator(pluginKey, schemaCreator) {
20
- if (schemas.has(pluginKey)) {
21
- throw new Error(`Schema for plugin ${pluginKey} is already registered`);
22
- }
23
- schemas.set(pluginKey, schemaCreator);
24
- },
25
- registerMigrations(pluginKey, migrations) {
26
- if (migrationsMap.has(pluginKey)) {
27
- throw new Error(`Migrations for plugin ${pluginKey} are already registered`);
28
- }
29
- const sortedMigrations = sortAndValidateMigrations(migrations);
30
- migrationsMap.set(pluginKey, sortedMigrations);
31
- },
32
- getSchemaCreator(pluginKey) {
33
- return schemas.get(pluginKey);
34
- },
35
- getMigrations(pluginKey) {
36
- return migrationsMap.get(pluginKey);
37
- },
38
- getLastMigrationVersion(pluginKey) {
39
- const migrations = migrationsMap.get(pluginKey);
40
- return migrations?.[migrations.length - 1]?.version;
41
- },
42
- };
43
- }
44
16
  /**
45
17
  * Spec for adding config for the plugin in the core plugin e.g.
46
18
  * {
@@ -52,7 +24,20 @@ export function createPluginConfigImplementation() {
52
24
  * }]
53
25
  * }
54
26
  */
55
- export const pluginConfigSpec = createPluginSpec('core/plugin-config', {
56
- defaultInitializer: createPluginConfigImplementation,
27
+ export const pluginConfigSpec = createFieldMapSpec('core/plugin-config', (t) => ({
28
+ schemas: t.map(),
29
+ migrations: t.map(),
30
+ }), {
31
+ use: (values) => {
32
+ const validatedMigrations = mapValuesOfMap(values.migrations, (migrations, pluginKey) => sortAndValidateMigrations(migrations, pluginKey));
33
+ return {
34
+ getSchemaCreator: (pluginKey) => values.schemas.get(pluginKey),
35
+ getMigrations: (pluginKey) => validatedMigrations.get(pluginKey),
36
+ getLastMigrationVersion: (pluginKey) => {
37
+ const migrations = values.migrations.get(pluginKey);
38
+ return migrations?.[migrations.length - 1]?.version;
39
+ },
40
+ };
41
+ },
57
42
  });
58
43
  //# sourceMappingURL=config-spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAwC9C,SAAS,yBAAyB,CAChC,UAAmC;IAEnC,qEAAqE;IACrE,MAAM,gBAAgB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAC3C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAChC,CAAC;IACF,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gCAAgC;IAC9C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAmC,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmC,CAAC;IAEjE,OAAO;QACL,qBAAqB,CAAC,SAAS,EAAE,aAAa;YAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,qBAAqB,SAAS,wBAAwB,CAAC,CAAC;YAC1E,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACxC,CAAC;QACD,kBAAkB,CAAC,SAAS,EAAE,UAAU;YACtC,IAAI,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CACb,yBAAyB,SAAS,yBAAyB,CAC5D,CAAC;YACJ,CAAC;YACD,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;YAC/D,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACjD,CAAC;QACD,gBAAgB,CAAC,SAAS;YACxB,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;QACD,aAAa,CAAC,SAAS;YACrB,OAAO,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QACD,uBAAuB,CAAC,SAAS;YAC/B,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAChD,OAAO,UAAU,EAAE,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,oBAAoB,EAAE;IACrE,kBAAkB,EAAE,gCAAgC;CACrD,CAAC,CAAC"}
1
+ {"version":3,"file":"config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAuBvE,SAAS,yBAAyB,CAChC,UAAmC,EACnC,SAAiB;IAEjB,qEAAqE;IACrE,MAAM,gBAAgB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAC3C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAChC,CAAC;IACF,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CACb,6BAA6B,SAAS,+BAA+B,CACtE,CAAC;IACJ,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CACb,6BAA6B,SAAS,6BAA6B,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAChD,oBAAoB,EACpB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,GAAG,EAAmC;IACjD,UAAU,EAAE,CAAC,CAAC,GAAG,EAAmC;CACrD,CAAC,EACF;IACE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,mBAAmB,GAAG,cAAc,CACxC,MAAM,CAAC,UAAU,EACjB,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CACxB,yBAAyB,CAAC,UAAU,EAAE,SAAS,CAAC,CACnD,CAAC;QACF,OAAO;YACL,gBAAgB,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;YACtE,aAAa,EAAE,CAAC,SAAiB,EAAE,EAAE,CACnC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC;YACpC,uBAAuB,EAAE,CAAC,SAAiB,EAAE,EAAE;gBAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACpD,OAAO,UAAU,EAAE,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC;YACtD,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export * from './auth-config-spec.js';
2
- export * from './auth-model-config-spec.js';
2
+ export * from './auth-models-spec.js';
3
3
  export * from './config-spec.js';
4
4
  export * from './types.js';
5
5
  export * from './web-config-spec.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export * from './auth-config-spec.js';
2
- export * from './auth-model-config-spec.js';
2
+ export * from './auth-models-spec.js';
3
3
  export * from './config-spec.js';
4
4
  export * from './types.js';
5
5
  export * from './web-config-spec.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
@@ -1,29 +1,70 @@
1
- type PluginSpecPlatform = 'web' | 'node';
2
- export type PluginSpecImplementation = Record<string, unknown>;
3
- export interface PluginSpec<T = PluginSpecImplementation> {
4
- readonly type: 'plugin-spec';
5
- readonly name: string;
6
- readonly platforms?: PluginSpecPlatform[];
7
- readonly placeholderType?: T;
8
- readonly isOptional: boolean;
9
- optional(): PluginSpec<T | undefined>;
10
- defaultInitializer?: () => T;
1
+ export type PluginSpecPlatform = 'web' | 'node';
2
+ /**
3
+ * Result returned by a plugin spec initializer.
4
+ * Contains separate interfaces for init (mutable) and use (read-only) phases.
5
+ */
6
+ export interface PluginSpecInitializerResult<TInit extends object = object, TUse extends object = object> {
7
+ /** Init interface - mutable methods for registration during plugin initialization */
8
+ init: TInit;
9
+ /** Use interface - read-only methods for consumption after initialization */
10
+ use: () => TUse;
11
11
  }
12
- export interface PluginSpecWithInitializer<T = PluginSpecImplementation> extends PluginSpec<T> {
13
- defaultInitializer: () => T;
12
+ /**
13
+ * Options for creating a plugin spec.
14
+ */
15
+ export interface PluginSpecOptions<TInit extends object, TUse extends object> {
16
+ /** Initializer function that creates the init and use interfaces */
17
+ initializer: () => PluginSpecInitializerResult<TInit, TUse>;
14
18
  }
15
- export interface InitializedPluginSpec<T = PluginSpecImplementation> {
16
- spec: PluginSpec<T>;
17
- implementation: T;
19
+ /**
20
+ * A plugin spec defines a shared capability that can be registered to during
21
+ * plugin initialization and consumed afterwards.
22
+ *
23
+ * Specs use two separate interfaces:
24
+ * - `init`: Mutable interface used during plugin initialization for registration
25
+ * - `use`: Read-only interface used after initialization (compilation, UI, etc.)
26
+ *
27
+ * This separation is enforced by TypeScript - callers must explicitly choose
28
+ * which interface to use, preventing accidental mutations after initialization.
29
+ */
30
+ export interface PluginSpec<TInit extends object = object, TUse extends object = object> {
31
+ readonly type: 'plugin-spec';
32
+ readonly name: string;
33
+ /** Initializer function that creates the init and use interfaces */
34
+ readonly initializer: () => PluginSpecInitializerResult<TInit, TUse>;
18
35
  }
19
- export declare function createInitializedPluginSpec<T = PluginSpecImplementation>(spec: PluginSpec<T>, implementation: T): InitializedPluginSpec<T>;
20
- export type PluginSpecImplementationFromSpec<T extends PluginSpec> = T extends PluginSpec<infer TImplementation> ? TImplementation : never;
21
- export declare function createPluginSpec<T = PluginSpecImplementation>(name: string, options: {
22
- platforms?: PluginSpecPlatform | PluginSpecPlatform[];
23
- defaultInitializer: () => T;
24
- }): PluginSpecWithInitializer<T>;
25
- export declare function createPluginSpec<T = PluginSpecImplementation>(name: string, options?: {
26
- platforms?: PluginSpecPlatform | PluginSpecPlatform[];
27
- }): PluginSpec<T>;
28
- export {};
36
+ /**
37
+ * Extracts the init type from a PluginSpec.
38
+ */
39
+ export type InferPluginSpecInit<T> = T extends PluginSpec<infer I> ? I : never;
40
+ /**
41
+ * Extracts the use type from a PluginSpec.
42
+ */
43
+ export type InferPluginSpecUse<T> = T extends PluginSpec<object, infer U> ? U : never;
44
+ /**
45
+ * Creates a plugin spec with init and use phases.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const mySpec = createPluginSpec('core/my-spec', {
50
+ * initializer: () => {
51
+ * const items = new Map<string, Item>();
52
+ * return {
53
+ * init: {
54
+ * register: (item: Item) => items.set(item.name, item),
55
+ * },
56
+ * use: () => ({
57
+ * get: (name: string) => items.get(name),
58
+ * getAll: () => [...items.values()],
59
+ * }),
60
+ * };
61
+ * },
62
+ * });
63
+ * ```
64
+ *
65
+ * @param name - Unique identifier for the spec (e.g., 'core/my-spec')
66
+ * @param options - Options including the initializer function
67
+ * @returns A plugin spec that can be used with SpecStore
68
+ */
69
+ export declare function createPluginSpec<TInit extends object, TUse extends object>(name: string, options: PluginSpecOptions<TInit, TUse>): PluginSpec<TInit, TUse>;
29
70
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/types.ts"],"names":[],"mappings":"AAAA,KAAK,kBAAkB,GAAG,KAAK,GAAG,MAAM,CAAC;AAEzC,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/D,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,wBAAwB;IACtD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAE1C,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAE7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,QAAQ,IAAI,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAEtC,kBAAkB,CAAC,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,yBAAyB,CAAC,CAAC,GAAG,wBAAwB,CACrE,SAAQ,UAAU,CAAC,CAAC,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,wBAAwB;IACjE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACpB,cAAc,EAAE,CAAC,CAAC;CACnB;AAED,wBAAgB,2BAA2B,CAAC,CAAC,GAAG,wBAAwB,EACtE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,cAAc,EAAE,CAAC,GAChB,qBAAqB,CAAC,CAAC,CAAC,CAE1B;AAED,MAAM,MAAM,gCAAgC,CAAC,CAAC,SAAS,UAAU,IAC/D,CAAC,SAAS,UAAU,CAAC,MAAM,eAAe,CAAC,GAAG,eAAe,GAAG,KAAK,CAAC;AAExE,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,wBAAwB,EAC3D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,SAAS,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;IACtD,kBAAkB,EAAE,MAAM,CAAC,CAAC;CAC7B,GACA,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAChC,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,wBAAwB,EAC3D,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;CACvD,GACA,UAAU,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,2BAA2B,CAC1C,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,IAAI,SAAS,MAAM,GAAG,MAAM;IAE5B,qFAAqF;IACrF,IAAI,EAAE,KAAK,CAAC;IACZ,6EAA6E;IAC7E,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM;IAC1E,oEAAoE;IACpE,WAAW,EAAE,MAAM,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;CAC7D;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU,CACzB,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,IAAI,SAAS,MAAM,GAAG,MAAM;IAE5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAC9B,CAAC,SAAS,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,EACxE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,GACtC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAOzB"}
@@ -1,17 +1,34 @@
1
- export function createInitializedPluginSpec(spec, implementation) {
2
- return { spec, implementation };
3
- }
1
+ /**
2
+ * Creates a plugin spec with init and use phases.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const mySpec = createPluginSpec('core/my-spec', {
7
+ * initializer: () => {
8
+ * const items = new Map<string, Item>();
9
+ * return {
10
+ * init: {
11
+ * register: (item: Item) => items.set(item.name, item),
12
+ * },
13
+ * use: () => ({
14
+ * get: (name: string) => items.get(name),
15
+ * getAll: () => [...items.values()],
16
+ * }),
17
+ * };
18
+ * },
19
+ * });
20
+ * ```
21
+ *
22
+ * @param name - Unique identifier for the spec (e.g., 'core/my-spec')
23
+ * @param options - Options including the initializer function
24
+ * @returns A plugin spec that can be used with SpecStore
25
+ */
4
26
  export function createPluginSpec(name, options) {
5
- const { platforms, defaultInitializer } = options ?? {};
27
+ const { initializer } = options;
6
28
  return {
7
29
  type: 'plugin-spec',
8
30
  name,
9
- platforms: platforms && (Array.isArray(platforms) ? platforms : [platforms]),
10
- isOptional: false,
11
- optional() {
12
- return { ...this, isOptional: true };
13
- },
14
- defaultInitializer,
31
+ initializer,
15
32
  };
16
33
  }
17
34
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/spec/types.ts"],"names":[],"mappings":"AA6BA,MAAM,UAAU,2BAA2B,CACzC,IAAmB,EACnB,cAAiB;IAEjB,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;AAClC,CAAC;AAkBD,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAGC;IAED,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACxD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI;QACJ,SAAS,EACP,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACnE,UAAU,EAAE,KAAK;QACjB,QAAQ;YACN,OAAO,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACvC,CAAC;QACD,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/spec/types.ts"],"names":[],"mappings":"AAwDA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAAuC;IAEvC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI;QACJ,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -1,22 +1,19 @@
1
1
  import type React from 'react';
2
2
  import type { BasePluginDefinition } from '#src/schema/index.js';
3
3
  import type { PluginMetadataWithPaths } from '../metadata/types.js';
4
- import type { PluginSpecImplementation } from './types.js';
5
4
  export interface WebConfigProps {
6
5
  definition: BasePluginDefinition | undefined;
7
6
  metadata: PluginMetadataWithPaths;
8
7
  onSave: () => void;
9
8
  }
10
- /**
11
- * Spec for allowing the plugin to be configured from the plugins page
12
- */
13
- export interface WebConfigSpec extends PluginSpecImplementation {
14
- registerWebConfigComponent: (pluginKey: string, ConfigComponent: React.FC<WebConfigProps>) => void;
15
- getWebConfigComponent: (pluginKey: string) => React.FC<WebConfigProps> | undefined;
16
- }
17
- export declare function createWebConfigImplementation(): WebConfigSpec;
18
9
  /**
19
10
  * Spec for adding config component for plugin
11
+ *
12
+ * Keyed by plugin key, value is the config component.
20
13
  */
21
- export declare const webConfigSpec: import("./types.js").PluginSpecWithInitializer<WebConfigSpec>;
14
+ export declare const webConfigSpec: import("./types.js").PluginSpec<{
15
+ components: import("@baseplate-dev/utils").MapContainer<string, React.FC<WebConfigProps>>;
16
+ }, import("@baseplate-dev/utils").FieldMapValues<{
17
+ components: import("@baseplate-dev/utils").MapContainer<string, React.FC<WebConfigProps>>;
18
+ }>>;
22
19
  //# sourceMappingURL=web-config-spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/web-config-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAI3D,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAC7C,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,wBAAwB;IAC7D,0BAA0B,EAAE,CAC1B,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,KACtC,IAAI,CAAC;IACV,qBAAqB,EAAE,CACrB,SAAS,EAAE,MAAM,KACd,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;CAC3C;AAED,wBAAgB,6BAA6B,IAAI,aAAa,CAgB7D;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,+DAGxB,CAAC"}
1
+ {"version":3,"file":"web-config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/web-config-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAIpE,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAC7C,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;GAEvB,CAAC"}
@@ -1,23 +1,10 @@
1
- import { createPluginSpec } from './types.js';
2
- export function createWebConfigImplementation() {
3
- const components = new Map();
4
- return {
5
- registerWebConfigComponent(pluginKey, ConfigComponent) {
6
- if (components.has(pluginKey)) {
7
- throw new Error(`Web config component for plugin ${pluginKey} is already registered`);
8
- }
9
- components.set(pluginKey, ConfigComponent);
10
- },
11
- getWebConfigComponent(pluginKey) {
12
- return components.get(pluginKey);
13
- },
14
- };
15
- }
1
+ import { createFieldMapSpec } from '../utils/create-field-map-spec.js';
16
2
  /**
17
3
  * Spec for adding config component for plugin
4
+ *
5
+ * Keyed by plugin key, value is the config component.
18
6
  */
19
- export const webConfigSpec = createPluginSpec('core/web-config', {
20
- platforms: 'web',
21
- defaultInitializer: createWebConfigImplementation,
22
- });
7
+ export const webConfigSpec = createFieldMapSpec('core/web-config', (t) => ({
8
+ components: t.map(),
9
+ }));
23
10
  //# sourceMappingURL=web-config-spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/web-config-spec.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqB9C,MAAM,UAAU,6BAA6B;IAC3C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAoC,CAAC;IAE/D,OAAO;QACL,0BAA0B,CAAC,SAAS,EAAE,eAAe;YACnD,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CACb,mCAAmC,SAAS,wBAAwB,CACrE,CAAC;YACJ,CAAC;YACD,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAC7C,CAAC;QACD,qBAAqB,CAAC,SAAS;YAC7B,OAAO,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC,iBAAiB,EAAE;IAC/D,SAAS,EAAE,KAAK;IAChB,kBAAkB,EAAE,6BAA6B;CAClD,CAAC,CAAC"}
1
+ {"version":3,"file":"web-config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/web-config-spec.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAQvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzE,UAAU,EAAE,CAAC,CAAC,GAAG,EAAoC;CACtD,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { PluginSpec, PluginSpecInitializerResult } from '../spec/types.js';
2
+ /**
3
+ * Store for managing plugin spec instances with lazy initialization.
4
+ *
5
+ * Each spec is initialized once on first access, and both its init and use
6
+ * interfaces are cached for subsequent access.
7
+ */
8
+ export declare class PluginSpecStore {
9
+ private instances;
10
+ private useInstances;
11
+ constructor(instances?: Map<string, PluginSpecInitializerResult<object, object>>);
12
+ /**
13
+ * Gets the use interface for a spec.
14
+ *
15
+ * Use this after initialization to access registered items.
16
+ * The use interface provides read-only methods for consumption.
17
+ *
18
+ * @param spec - The plugin spec to get the use interface for
19
+ * @returns The use interface for the spec
20
+ */
21
+ use<TUse extends object, TInit extends object>(spec: PluginSpec<TInit, TUse>): TUse;
22
+ }
23
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/plugins/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,YAAY,CAA6B;gBAErC,SAAS,2DAAiD;IAItE;;;;;;;;OAQG;IACH,GAAG,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,EAC3C,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,GAC5B,IAAI;CAiBR"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Store for managing plugin spec instances with lazy initialization.
3
+ *
4
+ * Each spec is initialized once on first access, and both its init and use
5
+ * interfaces are cached for subsequent access.
6
+ */
7
+ export class PluginSpecStore {
8
+ instances;
9
+ useInstances = new Map();
10
+ constructor(instances = new Map()) {
11
+ this.instances = instances;
12
+ }
13
+ /**
14
+ * Gets the use interface for a spec.
15
+ *
16
+ * Use this after initialization to access registered items.
17
+ * The use interface provides read-only methods for consumption.
18
+ *
19
+ * @param spec - The plugin spec to get the use interface for
20
+ * @returns The use interface for the spec
21
+ */
22
+ use(spec) {
23
+ let specInstance = this.instances.get(spec.name);
24
+ if (!specInstance) {
25
+ specInstance = spec.initializer();
26
+ this.instances.set(spec.name, specInstance);
27
+ }
28
+ let useInstance = this.useInstances.get(spec.name);
29
+ if (!useInstance) {
30
+ useInstance = specInstance.use();
31
+ this.useInstances.set(spec.name, useInstance);
32
+ }
33
+ return useInstance;
34
+ }
35
+ }
36
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/plugins/store/store.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAClB,SAAS,CAA2C;IACpD,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEjD,YAAY,YAAY,IAAI,GAAG,EAAuC;QACpE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;;;;OAQG;IACH,GAAG,CACD,IAA6B;QAE7B,IAAI,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAElC,CAAC;QACd,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAClC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;YACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,WAAmB,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ import type { FieldMapSchema, FieldMapSchemaBuilder, FieldMapValues } from '@baseplate-dev/utils';
2
+ import type { PluginSpec } from '../spec/types.js';
3
+ /**
4
+ * Creates a plugin spec backed by a FieldMap for automatic source tracking.
5
+ *
6
+ * @param name - Unique identifier for the spec
7
+ * @param schemaBuilder - Function that builds the field map schema
8
+ * @param options - Optional configuration including custom use interface
9
+ */
10
+ export declare function createFieldMapSpec<T extends FieldMapSchema, TUse extends object = FieldMapValues<T>>(name: string, schemaBuilder: (t: FieldMapSchemaBuilder) => T, options?: {
11
+ /**
12
+ * Custom use interface builder. Receives the field map values and returns
13
+ * the use interface. If not provided, returns the raw field map values.
14
+ */
15
+ use?: (values: FieldMapValues<T>) => TUse;
16
+ }): PluginSpec<T, TUse>;
17
+ //# sourceMappingURL=create-field-map-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-field-map-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/utils/create-field-map-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,cAAc,EACxB,IAAI,SAAS,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,EAEvC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,CAAC,CAAC,EAAE,qBAAqB,KAAK,CAAC,EAC9C,OAAO,CAAC,EAAE;IACR;;;OAGG;IACH,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAC3C,GACA,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAgBrB"}
@@ -0,0 +1,27 @@
1
+ import { createPluginSpec } from '../spec/types.js';
2
+ import { createPluginFieldMap } from './create-plugin-field-map.js';
3
+ /**
4
+ * Creates a plugin spec backed by a FieldMap for automatic source tracking.
5
+ *
6
+ * @param name - Unique identifier for the spec
7
+ * @param schemaBuilder - Function that builds the field map schema
8
+ * @param options - Optional configuration including custom use interface
9
+ */
10
+ export function createFieldMapSpec(name, schemaBuilder, options) {
11
+ return createPluginSpec(name, {
12
+ initializer: () => {
13
+ const fieldMap = createPluginFieldMap(schemaBuilder);
14
+ return {
15
+ init: fieldMap,
16
+ use: () => {
17
+ const values = fieldMap.getValues();
18
+ if (options?.use) {
19
+ return options.use(values);
20
+ }
21
+ return values;
22
+ },
23
+ };
24
+ },
25
+ });
26
+ }
27
+ //# sourceMappingURL=create-field-map-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-field-map-spec.js","sourceRoot":"","sources":["../../../src/plugins/utils/create-field-map-spec.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAIhC,IAAY,EACZ,aAA8C,EAC9C,OAMC;IAED,OAAO,gBAAgB,CAAC,IAAI,EAAE;QAC5B,WAAW,EAAE,GAAG,EAAE;YAChB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;YACrD,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,GAAG,EAAE,GAAG,EAAE;oBACR,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;oBACpC,IAAI,OAAO,EAAE,GAAG,EAAE,CAAC;wBACjB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;oBAC7B,CAAC;oBACD,OAAO,MAAc,CAAC;gBACxB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { FieldMap, FieldMapSchema, FieldMapSchemaBuilder } from '@baseplate-dev/utils';
2
+ /**
3
+ * Creates a field map that automatically tracks which plugin registered each value.
4
+ *
5
+ * Similar to `createConfigFieldMap` in the sync package, this utility uses the
6
+ * current plugin context to track the source of registrations. This enables
7
+ * clear error messages when registration conflicts occur.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const fieldMap = createPluginFieldMap((t) => ({
12
+ * transformers: t.map<string, Transformer>(),
13
+ * }));
14
+ *
15
+ * // When a plugin tries to overwrite a value:
16
+ * // Error: Value for key 'myTransformer' has already been set by plugin-auth
17
+ * // and cannot be overwritten by plugin-storage
18
+ * ```
19
+ *
20
+ * @param schemaBuilder - A function that builds the field map schema
21
+ * @returns A field map with automatic source tracking
22
+ */
23
+ export declare function createPluginFieldMap<S extends FieldMapSchema>(schemaBuilder: (t: FieldMapSchemaBuilder) => S): FieldMap<S>;
24
+ //# sourceMappingURL=create-plugin-field-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-plugin-field-map.d.ts","sourceRoot":"","sources":["../../../src/plugins/utils/create-plugin-field-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAM9B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,cAAc,EAC3D,aAAa,EAAE,CAAC,CAAC,EAAE,qBAAqB,KAAK,CAAC,GAC7C,QAAQ,CAAC,CAAC,CAAC,CAIb"}
@@ -0,0 +1,29 @@
1
+ import { createFieldMap } from '@baseplate-dev/utils';
2
+ import { getPluginContext } from '../context/plugin-context.js';
3
+ /**
4
+ * Creates a field map that automatically tracks which plugin registered each value.
5
+ *
6
+ * Similar to `createConfigFieldMap` in the sync package, this utility uses the
7
+ * current plugin context to track the source of registrations. This enables
8
+ * clear error messages when registration conflicts occur.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const fieldMap = createPluginFieldMap((t) => ({
13
+ * transformers: t.map<string, Transformer>(),
14
+ * }));
15
+ *
16
+ * // When a plugin tries to overwrite a value:
17
+ * // Error: Value for key 'myTransformer' has already been set by plugin-auth
18
+ * // and cannot be overwritten by plugin-storage
19
+ * ```
20
+ *
21
+ * @param schemaBuilder - A function that builds the field map schema
22
+ * @returns A field map with automatic source tracking
23
+ */
24
+ export function createPluginFieldMap(schemaBuilder) {
25
+ return createFieldMap(schemaBuilder, {
26
+ getDynamicSource: () => getPluginContext()?.pluginKey,
27
+ });
28
+ }
29
+ //# sourceMappingURL=create-plugin-field-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-plugin-field-map.js","sourceRoot":"","sources":["../../../src/plugins/utils/create-plugin-field-map.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,oBAAoB,CAClC,aAA8C;IAE9C,OAAO,cAAc,CAAC,aAAa,EAAE;QACnC,gBAAgB,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,SAAS;KACtD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './create-field-map-spec.js';
2
+ export * from './create-plugin-field-map.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC"}