@baseplate-dev/plugin-auth 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +27 -0
  2. package/dist/auth/core/common.d.ts +1 -0
  3. package/dist/auth/core/common.d.ts.map +1 -1
  4. package/dist/auth/core/common.js.map +1 -1
  5. package/dist/auth/core/schema/models.d.ts.map +1 -1
  6. package/dist/auth/core/schema/models.js +11 -0
  7. package/dist/auth/core/schema/models.js.map +1 -1
  8. package/dist/auth0/core/schema/models.d.ts.map +1 -1
  9. package/dist/auth0/core/schema/models.js +6 -0
  10. package/dist/auth0/core/schema/models.js.map +1 -1
  11. package/dist/web/assets/{__federation_expose_auth0CoreCommon--n6esVYP.js → __federation_expose_auth0CoreCommon-DCwCR5dZ.js} +3 -3
  12. package/dist/web/assets/{__federation_expose_auth0CoreCommon--n6esVYP.js.map → __federation_expose_auth0CoreCommon-DCwCR5dZ.js.map} +1 -1
  13. package/dist/web/assets/{__federation_expose_auth0CoreWeb-Ql6gpX5q.js → __federation_expose_auth0CoreWeb-BlCwYpTq.js} +11 -5
  14. package/dist/web/assets/__federation_expose_auth0CoreWeb-BlCwYpTq.js.map +1 -0
  15. package/dist/web/assets/{__federation_fn_import-BiwmVFwy.js → __federation_fn_import-dzKjrTzS.js} +2 -2
  16. package/dist/web/assets/{__federation_fn_import-BiwmVFwy.js.map → __federation_fn_import-dzKjrTzS.js.map} +1 -1
  17. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/{web-CY8oz43s.js → web-BXHJHUXP.js} +18 -7
  18. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-BXHJHUXP.js.map +1 -0
  19. package/dist/web/assets/__federation_shared_@baseplate-dev/{project-builder-lib-B62IPizQ.js → project-builder-lib-GtzVuDsM.js} +17 -675
  20. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-GtzVuDsM.js.map +1 -0
  21. package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-BU2QTWNs.js → ui-components-ChoqtPkg.js} +11 -6
  22. package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-ChoqtPkg.js.map +1 -0
  23. package/dist/web/assets/{index-CgJx-krK.js → index-BxDOOHD-.js} +2 -2
  24. package/dist/web/assets/{index-CgJx-krK.js.map → index-BxDOOHD-.js.map} +1 -1
  25. package/dist/web/assets/{index.esm-BcxPd7Ha.js → index.esm-BZEyAv4m.js} +2 -2
  26. package/dist/web/assets/{index.esm-BcxPd7Ha.js.map → index.esm-BZEyAv4m.js.map} +1 -1
  27. package/dist/web/assets/{model-utils-CbQJy1wE.js → model-merger-CdV-7CWE.js} +780 -4
  28. package/dist/web/assets/model-merger-CdV-7CWE.js.map +1 -0
  29. package/dist/web/assets/{plugin-definition-BQRupXoQ.js → plugin-definition-C9Q-BrBQ.js} +2 -2
  30. package/dist/web/assets/{plugin-definition-BQRupXoQ.js.map → plugin-definition-C9Q-BrBQ.js.map} +1 -1
  31. package/dist/web/assets/{react-2jQE8aG0.js → react-BfiX28GO.js} +2 -2
  32. package/dist/web/assets/{react-2jQE8aG0.js.map → react-BfiX28GO.js.map} +1 -1
  33. package/dist/web/assets/remoteEntry.js +2 -2
  34. package/package.json +17 -14
  35. package/dist/web/assets/__federation_expose_auth0CoreWeb-Ql6gpX5q.js.map +0 -1
  36. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-CY8oz43s.js.map +0 -1
  37. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-B62IPizQ.js.map +0 -1
  38. package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-BU2QTWNs.js.map +0 -1
  39. package/dist/web/assets/model-utils-CbQJy1wE.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { c as createPluginSpec, g as getSymbols, i as isPlainObject$2, a as isEqual, b as createEntityType, z as zodPluginSymbol, e as eq, Z as ZodRefWrapper, d as get$1, s as set$1, C as CASE_VALIDATORS, f as zRef, h as zEnt, j as createDefinitionEntityNameResolver, k as ZodRef, l as featureEntityType, m as zRefBuilder, n as zRefId, o as featuresSchema, M as ModelUtils, p as zPluginWrapper } from '../model-utils-CbQJy1wE.js';
2
- export { D as DefinitionEntityType, F as FeatureUtils, q as ZodPluginWrapper, t as ZodRefBuilder, r as createInitializedPluginSpec, u as featureNameSchema, v as featureSchema } from '../model-utils-CbQJy1wE.js';
3
- import { importShared } from '../__federation_fn_import-BiwmVFwy.js';
1
+ import { c as createPluginSpec, i as isEqual, m as mapValues, a as createEntityType, z as zodPluginSymbol, Z as ZodRefWrapper, g as get$1, s as set$1, C as CASE_VALIDATORS, b as zRef, d as modelForeignRelationEntityType, e as modelLocalRelationEntityType, f as modelScalarFieldEntityType, h as zEnt, j as modelTransformerEntityType, k as createDefinitionEntityNameResolver, l as modelEntityType, n as ZodRef, o as modelEnumValueEntityType, p as featureEntityType, q as modelEnumEntityType, r as zRefBuilder, t as zRefId, u as modelUniqueConstraintEntityType, v as featuresSchema, M as ModelUtils, w as zPluginWrapper, x as omit, y as cloneDeep } from '../model-merger-CdV-7CWE.js';
2
+ export { R as DefinitionDiffArrayIncludesField, P as DefinitionDiffKeyedArrayField, Q as DefinitionDiffReplacementField, E as DefinitionEntityType, F as FeatureUtils, A as ZodPluginWrapper, D as ZodRefBuilder, U as applyDefinitionDiff, L as applyModelMergerDiff, N as applyModelMergerResultInPlace, O as createAndApplyModelMergerResults, T as createDefinitionDiff, S as createDefinitionDiffConfig, B as createInitializedPluginSpec, J as createModelMergerResult, K as createModelMergerResults, G as featureNameSchema, H as featureSchema, I as modelMergerDefinitionDiffConfig } from '../model-merger-CdV-7CWE.js';
3
+ import { importShared } from '../__federation_fn_import-dzKjrTzS.js';
4
4
 
5
5
  function createAdminCrudInputCompilerImplementation() {
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -99,171 +99,6 @@ function flow(...funcs) {
99
99
  };
100
100
  }
101
101
 
102
- function isPrimitive(value) {
103
- return value == null || (typeof value !== 'object' && typeof value !== 'function');
104
- }
105
-
106
- function isTypedArray(x) {
107
- return ArrayBuffer.isView(x) && !(x instanceof DataView);
108
- }
109
-
110
- function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new Map(), cloneValue = undefined) {
111
- const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
112
- if (cloned != null) {
113
- return cloned;
114
- }
115
- if (isPrimitive(valueToClone)) {
116
- return valueToClone;
117
- }
118
- if (stack.has(valueToClone)) {
119
- return stack.get(valueToClone);
120
- }
121
- if (Array.isArray(valueToClone)) {
122
- const result = new Array(valueToClone.length);
123
- stack.set(valueToClone, result);
124
- for (let i = 0; i < valueToClone.length; i++) {
125
- result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
126
- }
127
- if (Object.hasOwn(valueToClone, 'index')) {
128
- result.index = valueToClone.index;
129
- }
130
- if (Object.hasOwn(valueToClone, 'input')) {
131
- result.input = valueToClone.input;
132
- }
133
- return result;
134
- }
135
- if (valueToClone instanceof Date) {
136
- return new Date(valueToClone.getTime());
137
- }
138
- if (valueToClone instanceof RegExp) {
139
- const result = new RegExp(valueToClone.source, valueToClone.flags);
140
- result.lastIndex = valueToClone.lastIndex;
141
- return result;
142
- }
143
- if (valueToClone instanceof Map) {
144
- const result = new Map();
145
- stack.set(valueToClone, result);
146
- for (const [key, value] of valueToClone) {
147
- result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
148
- }
149
- return result;
150
- }
151
- if (valueToClone instanceof Set) {
152
- const result = new Set();
153
- stack.set(valueToClone, result);
154
- for (const value of valueToClone) {
155
- result.add(cloneDeepWithImpl(value, undefined, objectToClone, stack, cloneValue));
156
- }
157
- return result;
158
- }
159
- if (typeof Buffer !== 'undefined' && Buffer.isBuffer(valueToClone)) {
160
- return valueToClone.subarray();
161
- }
162
- if (isTypedArray(valueToClone)) {
163
- const result = new (Object.getPrototypeOf(valueToClone).constructor)(valueToClone.length);
164
- stack.set(valueToClone, result);
165
- for (let i = 0; i < valueToClone.length; i++) {
166
- result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
167
- }
168
- return result;
169
- }
170
- if (valueToClone instanceof ArrayBuffer ||
171
- (typeof SharedArrayBuffer !== 'undefined' && valueToClone instanceof SharedArrayBuffer)) {
172
- return valueToClone.slice(0);
173
- }
174
- if (valueToClone instanceof DataView) {
175
- const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
176
- stack.set(valueToClone, result);
177
- copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
178
- return result;
179
- }
180
- if (typeof File !== 'undefined' && valueToClone instanceof File) {
181
- const result = new File([valueToClone], valueToClone.name, {
182
- type: valueToClone.type,
183
- });
184
- stack.set(valueToClone, result);
185
- copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
186
- return result;
187
- }
188
- if (valueToClone instanceof Blob) {
189
- const result = new Blob([valueToClone], { type: valueToClone.type });
190
- stack.set(valueToClone, result);
191
- copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
192
- return result;
193
- }
194
- if (valueToClone instanceof Error) {
195
- const result = new valueToClone.constructor();
196
- stack.set(valueToClone, result);
197
- result.message = valueToClone.message;
198
- result.name = valueToClone.name;
199
- result.stack = valueToClone.stack;
200
- result.cause = valueToClone.cause;
201
- copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
202
- return result;
203
- }
204
- if (typeof valueToClone === 'object' && valueToClone !== null) {
205
- const result = Object.create(Object.getPrototypeOf(valueToClone));
206
- stack.set(valueToClone, result);
207
- copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
208
- return result;
209
- }
210
- return valueToClone;
211
- }
212
- function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
213
- const keys = [...Object.keys(source), ...getSymbols(source)];
214
- for (let i = 0; i < keys.length; i++) {
215
- const key = keys[i];
216
- const descriptor = Object.getOwnPropertyDescriptor(target, key);
217
- if (descriptor == null || descriptor.writable) {
218
- target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
219
- }
220
- }
221
- }
222
-
223
- function cloneDeep(obj) {
224
- return cloneDeepWithImpl(obj, undefined, obj, new Map(), undefined);
225
- }
226
-
227
- function mapValues(object, getNewValue) {
228
- const result = {};
229
- const keys = Object.keys(object);
230
- for (let i = 0; i < keys.length; i++) {
231
- const key = keys[i];
232
- const value = object[key];
233
- result[key] = getNewValue(value, key, object);
234
- }
235
- return result;
236
- }
237
-
238
- function merge(target, source) {
239
- const sourceKeys = Object.keys(source);
240
- for (let i = 0; i < sourceKeys.length; i++) {
241
- const key = sourceKeys[i];
242
- const sourceValue = source[key];
243
- const targetValue = target[key];
244
- if (Array.isArray(sourceValue)) {
245
- if (Array.isArray(targetValue)) {
246
- target[key] = merge(targetValue, sourceValue);
247
- }
248
- else {
249
- target[key] = merge([], sourceValue);
250
- }
251
- }
252
- else if (isPlainObject$2(sourceValue)) {
253
- if (isPlainObject$2(targetValue)) {
254
- target[key] = merge(targetValue, sourceValue);
255
- }
256
- else {
257
- target[key] = merge({}, sourceValue);
258
- }
259
- }
260
- else if (targetValue === undefined || sourceValue !== undefined) {
261
- target[key] = sourceValue;
262
- }
263
- }
264
- return target;
265
- }
266
-
267
102
  function isObjectLike(value) {
268
103
  return typeof value === 'object' && value !== null;
269
104
  }
@@ -291,15 +126,6 @@ function mergeWith(target, source, merge) {
291
126
  return target;
292
127
  }
293
128
 
294
- function omit(obj, keys) {
295
- const result = { ...obj };
296
- for (let i = 0; i < keys.length; i++) {
297
- const key = keys[i];
298
- delete result[key];
299
- }
300
- return result;
301
- }
302
-
303
129
  function pickBy(obj, shouldPick) {
304
130
  const result = {};
305
131
  const keys = Object.keys(obj);
@@ -313,13 +139,9 @@ function pickBy(obj, shouldPick) {
313
139
  return result;
314
140
  }
315
141
 
316
- function toMerged(target, source) {
317
- return merge(cloneDeep(target), source);
318
- }
319
-
320
142
  // adapted from https://github.com/AitoDotAI/json-stringify-pretty-compact
321
143
  // allows { } to be presented as {} to better mirror prettier formatting
322
- function isObject$1(obj) {
144
+ function isObject(obj) {
323
145
  return typeof obj === 'object' && obj !== null;
324
146
  }
325
147
  function forEach(obj, cb) {
@@ -327,7 +149,7 @@ function forEach(obj, cb) {
327
149
  // eslint-disable-next-line unicorn/no-array-for-each
328
150
  obj.forEach(cb);
329
151
  }
330
- else if (isObject$1(obj)) {
152
+ else if (isObject(obj)) {
331
153
  for (const key of Object.keys(obj)) {
332
154
  const val = obj[key];
333
155
  cb(val, key);
@@ -336,9 +158,9 @@ function forEach(obj, cb) {
336
158
  }
337
159
  function getTreeDepth(obj) {
338
160
  let depth = 0;
339
- if (Array.isArray(obj) || isObject$1(obj)) {
161
+ if (Array.isArray(obj) || isObject(obj)) {
340
162
  forEach(obj, (val) => {
341
- if (Array.isArray(val) || isObject$1(val)) {
163
+ if (Array.isArray(val) || isObject(val)) {
342
164
  const tmpDepth = getTreeDepth(val);
343
165
  if (tmpDepth > depth) {
344
166
  depth = tmpDepth;
@@ -409,7 +231,7 @@ function stringifyPrettyCompact(rootObj, options = {}) {
409
231
  return prettified;
410
232
  }
411
233
  }
412
- if (isObject$1(obj)) {
234
+ if (isObject(obj)) {
413
235
  const nextIndent = currentIndent + indent;
414
236
  const items = [];
415
237
  let delimiters;
@@ -2448,107 +2270,6 @@ const AppUtils = {
2448
2270
  getBackendRelativePath,
2449
2271
  };
2450
2272
 
2451
- function isObject(value) {
2452
- return value !== null && (typeof value === 'object' || typeof value === 'function');
2453
- }
2454
-
2455
- function isMatch(target, source) {
2456
- if (source === target) {
2457
- return true;
2458
- }
2459
- switch (typeof source) {
2460
- case 'object': {
2461
- if (source == null) {
2462
- return true;
2463
- }
2464
- const keys = Object.keys(source);
2465
- if (target == null) {
2466
- return keys.length === 0;
2467
- }
2468
- if (Array.isArray(source)) {
2469
- return isArrayMatch(target, source);
2470
- }
2471
- if (source instanceof Map) {
2472
- return isMapMatch(target, source);
2473
- }
2474
- if (source instanceof Set) {
2475
- return isSetMatch(target, source);
2476
- }
2477
- for (let i = 0; i < keys.length; i++) {
2478
- const key = keys[i];
2479
- if (!isPrimitive(target) && !(key in target)) {
2480
- return false;
2481
- }
2482
- if (source[key] === undefined && target[key] !== undefined) {
2483
- return false;
2484
- }
2485
- if (source[key] === null && target[key] !== null) {
2486
- return false;
2487
- }
2488
- if (!isMatch(target[key], source[key])) {
2489
- return false;
2490
- }
2491
- }
2492
- return true;
2493
- }
2494
- case 'function': {
2495
- if (Object.keys(source).length > 0) {
2496
- return isMatch(target, { ...source });
2497
- }
2498
- return false;
2499
- }
2500
- default: {
2501
- if (!isObject(target)) {
2502
- return eq(target, source);
2503
- }
2504
- return !source;
2505
- }
2506
- }
2507
- }
2508
- function isMapMatch(target, source) {
2509
- if (source.size === 0) {
2510
- return true;
2511
- }
2512
- if (!(target instanceof Map)) {
2513
- return false;
2514
- }
2515
- for (const [key, value] of source.entries()) {
2516
- if (!isMatch(target.get(key), value)) {
2517
- return false;
2518
- }
2519
- }
2520
- return true;
2521
- }
2522
- function isArrayMatch(target, source) {
2523
- if (source.length === 0) {
2524
- return true;
2525
- }
2526
- if (!Array.isArray(target)) {
2527
- return false;
2528
- }
2529
- const countedIndex = new Set();
2530
- for (let i = 0; i < source.length; i++) {
2531
- const sourceItem = source[i];
2532
- const index = target.findIndex((targetItem, index) => {
2533
- return isMatch(targetItem, sourceItem) && !countedIndex.has(index);
2534
- });
2535
- if (index === -1) {
2536
- return false;
2537
- }
2538
- countedIndex.add(index);
2539
- }
2540
- return true;
2541
- }
2542
- function isSetMatch(target, source) {
2543
- if (source.size === 0) {
2544
- return true;
2545
- }
2546
- if (!(target instanceof Set)) {
2547
- return false;
2548
- }
2549
- return isArrayMatch([...target], [...source]);
2550
- }
2551
-
2552
2273
  /**
2553
2274
  * Resolves entity names in a ZodRefPayload.
2554
2275
  *
@@ -2877,19 +2598,6 @@ const VALIDATORS = {
2877
2598
  .optional(),
2878
2599
  };
2879
2600
 
2880
- const modelEntityType = createEntityType('model');
2881
- const modelScalarFieldEntityType = createEntityType('model-scalar-field', {
2882
- parentType: modelEntityType,
2883
- });
2884
- const modelLocalRelationEntityType = createEntityType('model-local-relation', { parentType: modelEntityType });
2885
- const modelForeignRelationEntityType = createEntityType('model-foreign-relation', { parentType: modelEntityType });
2886
- const modelUniqueConstraintEntityType = createEntityType('model-unique-constraint', { parentType: modelEntityType });
2887
- const modelTransformerEntityType = createEntityType('model-transformer', { parentType: modelEntityType });
2888
- const modelEnumEntityType = createEntityType('model-enum');
2889
- const modelEnumValueEntityType = createEntityType('model-enum-value', {
2890
- parentType: modelEnumEntityType,
2891
- });
2892
-
2893
2601
  const {z: z$g} = await importShared('zod');
2894
2602
  const roleArray = z$g
2895
2603
  .array(zRef(z$g.string(), {
@@ -9112,6 +8820,12 @@ function createTestProjectDefinition(input = {}) {
9112
8820
  ...input,
9113
8821
  };
9114
8822
  }
8823
+ function createTestProjectDefinitionInput(input = {}) {
8824
+ return {
8825
+ ...createTestProjectDefinition(),
8826
+ ...input,
8827
+ };
8828
+ }
9115
8829
  function createTestProjectDefinitionContainer(input = {}) {
9116
8830
  const pluginStore = {
9117
8831
  availablePlugins: [],
@@ -9121,384 +8835,12 @@ function createTestProjectDefinitionContainer(input = {}) {
9121
8835
  plugins: pluginImplementationStore,
9122
8836
  });
9123
8837
  const schemaWithPlugins = zPluginWrapper(projectDefinitionSchema, pluginImplementationStore);
9124
- const resolvedRefPayload = deserializeSchemaWithReferences(schemaWithPlugins, createTestProjectDefinition(input));
8838
+ const resolvedRefPayload = deserializeSchemaWithReferences(schemaWithPlugins, createTestProjectDefinitionInput(input));
9125
8839
  return new ProjectDefinitionContainer(resolvedRefPayload, { pluginStore }, pluginImplementationStore);
9126
8840
  }
9127
8841
 
9128
8842
  const AVAILABLE_FLAGS = ['TEMPLATE_EXTRACTOR'];
9129
8843
 
9130
- /**
9131
- * Allows diffing of arbitrary JSON objects.
9132
- */
9133
- class DefinitionDiffField {
9134
- constructor(
9135
- /**
9136
- * The name of the field to be presented to the user.
9137
- */
9138
- name) {
9139
- Object.defineProperty(this, "name", {
9140
- enumerable: true,
9141
- configurable: true,
9142
- writable: true,
9143
- value: name
9144
- });
9145
- }
9146
- }
9147
- /**
9148
- * A field that is an array of objects with a unique key.
9149
- */
9150
- class DefinitionDiffKeyedArrayField extends DefinitionDiffField {
9151
- constructor(name, getKey, options = {}) {
9152
- super(name);
9153
- Object.defineProperty(this, "getKey", {
9154
- enumerable: true,
9155
- configurable: true,
9156
- writable: true,
9157
- value: getKey
9158
- });
9159
- Object.defineProperty(this, "options", {
9160
- enumerable: true,
9161
- configurable: true,
9162
- writable: true,
9163
- value: options
9164
- });
9165
- this.getKey = getKey;
9166
- }
9167
- diff(current, desired) {
9168
- const currentValue = current ?? [];
9169
- const desiredValue = desired ?? [];
9170
- if (!Array.isArray(currentValue) || !Array.isArray(desiredValue)) {
9171
- throw new TypeError('Current and desired must be arrays');
9172
- }
9173
- const ops = [];
9174
- const { allowRemove, ignoreFields = ['id'] } = this.options;
9175
- const currentByKey = new Map(currentValue.map((item) => [this.getKey(item), item]));
9176
- const desiredByKey = new Map(desiredValue.map((item) => [this.getKey(item), item]));
9177
- for (const [key, desiredItem] of desiredByKey) {
9178
- const currentItem = currentByKey.get(key);
9179
- if (!currentItem) {
9180
- ops.push({ type: 'add', key, item: desiredItem });
9181
- continue;
9182
- }
9183
- if (!isMatch(omit(currentItem, ignoreFields), omit(desiredItem, ignoreFields))) {
9184
- ops.push({ type: 'update', key, item: desiredItem });
9185
- }
9186
- }
9187
- if (allowRemove) {
9188
- for (const [key, currentItem] of currentByKey) {
9189
- if (!desiredByKey.has(key)) {
9190
- ops.push({ type: 'remove', key, item: currentItem });
9191
- }
9192
- }
9193
- }
9194
- return ops;
9195
- }
9196
- apply(current, diff) {
9197
- const patch = diff;
9198
- const currentValue = current ?? [];
9199
- if (!Array.isArray(currentValue)) {
9200
- throw new TypeError('Current must be array');
9201
- }
9202
- const items = [...currentValue];
9203
- for (const { type, key, item } of patch) {
9204
- const index = items.findIndex((i) => this.getKey(i) === key);
9205
- switch (type) {
9206
- case 'add': {
9207
- items.push(item);
9208
- break;
9209
- }
9210
- case 'update': {
9211
- if (index === -1) {
9212
- throw new Error(`Cannot apply patch. Item with key "${key}" not found.`);
9213
- }
9214
- // Preserve existing id if present.
9215
- items[index] = toMerged(items[index], item);
9216
- break;
9217
- }
9218
- case 'remove': {
9219
- if (index !== -1) {
9220
- items.splice(index, 1);
9221
- }
9222
- break;
9223
- }
9224
- }
9225
- }
9226
- return items;
9227
- }
9228
- }
9229
- /**
9230
- * A field that is a replacement for the entire object or array.
9231
- */
9232
- class DefinitionDiffReplacementField extends DefinitionDiffField {
9233
- diff(current, desired) {
9234
- if (!isMatch(current, desired)) {
9235
- return [{ type: 'update', key: '*', item: desired }];
9236
- }
9237
- return [];
9238
- }
9239
- apply(current, diff) {
9240
- if (diff.length === 0)
9241
- return current;
9242
- return diff[0].item;
9243
- }
9244
- }
9245
- function createDefinitionDiffConfig(config) {
9246
- return config;
9247
- }
9248
- /**
9249
- * Creates a diff between two objects.
9250
- */
9251
- function createDefinitionDiff(current, desired, configuration) {
9252
- const ops = mapValues(configuration, (field, key) => {
9253
- if (!field)
9254
- return [];
9255
- return field.diff(get$1(current, key), get$1(desired, key));
9256
- });
9257
- if (Object.values(ops).every((ops) => ops.length === 0)) {
9258
- return undefined;
9259
- }
9260
- return ops;
9261
- }
9262
- /**
9263
- * Applies a diff to an object.
9264
- */
9265
- function applyDefinitionDiff(current, diff, configuration) {
9266
- const clonedCurrent = cloneDeep(current);
9267
- for (const [key, ops] of Object.entries(diff)) {
9268
- if (!ops)
9269
- continue;
9270
- const field = configuration[key];
9271
- const currentValue = get$1(clonedCurrent, key);
9272
- set$1(clonedCurrent, key, field.apply(currentValue, ops));
9273
- }
9274
- return clonedCurrent;
9275
- }
9276
-
9277
- /**
9278
- * Computes a unique key for a unique constraint by sorting its field refs.
9279
- *
9280
- * @param constraint - Unique constraint input.
9281
- * @returns A key string.
9282
- */
9283
- function getUniqueConstraintKey(constraint) {
9284
- const fields = constraint.fields.map((f) => f.fieldRef).sort();
9285
- return fields.join('|');
9286
- }
9287
- const modelMergerDefinitionDiffConfig = createDefinitionDiffConfig({
9288
- 'model.fields': new DefinitionDiffKeyedArrayField('fields', (f) => f.name),
9289
- 'model.relations': new DefinitionDiffKeyedArrayField('relations', (r) => r.name),
9290
- 'model.uniqueConstraints': new DefinitionDiffKeyedArrayField('uniqueConstraints', (c) => getUniqueConstraintKey(c)),
9291
- 'model.primaryKeyFieldRefs': new DefinitionDiffReplacementField('primaryKeyFieldRefs'),
9292
- });
9293
- /**
9294
- * Serializes a model merger model input such that all IDs are replaced with
9295
- * names.
9296
- *
9297
- * @param input - The model merger model input.
9298
- * @param definitionContainer - The definition container.
9299
- * @returns The serialized model merger model input.
9300
- */
9301
- function serializeModelMergerModelInput(input, definitionContainer, siblingModels) {
9302
- const siblingModelFieldIdMap = new Map([
9303
- ...input.model.fields.map((f) => [f.id, f.name]),
9304
- ...siblingModels.flatMap((m) => m.model.fields.map((f) => [f.id, f.name])),
9305
- ]);
9306
- const nameFromId = (id) => siblingModelFieldIdMap.get(id) ?? definitionContainer.nameFromId(id);
9307
- return {
9308
- ...input,
9309
- model: {
9310
- ...input.model,
9311
- relations: input.model.relations?.map((r) => ({
9312
- ...r,
9313
- references: r.references.map((reference) => ({
9314
- ...reference,
9315
- localRef: nameFromId(reference.localRef),
9316
- foreignRef: nameFromId(reference.foreignRef),
9317
- })),
9318
- })),
9319
- uniqueConstraints: input.model.uniqueConstraints?.map((c) => ({
9320
- ...c,
9321
- fields: c.fields.map((f) => ({
9322
- ...f,
9323
- fieldRef: nameFromId(f.fieldRef),
9324
- })),
9325
- })),
9326
- primaryKeyFieldRefs: input.model.primaryKeyFieldRefs.map(nameFromId),
9327
- },
9328
- };
9329
- }
9330
- /**
9331
- * Attaches IDs to the model merger model input.
9332
- *
9333
- * @param input - The model merger model input.
9334
- * @returns The model merger model input with IDs attached.
9335
- */
9336
- function attachIdsToModelMergerModelInput(input) {
9337
- return {
9338
- ...input,
9339
- model: {
9340
- ...input.model,
9341
- fields: input.model.fields.map((f) => ({
9342
- ...f,
9343
- id: f.id ?? modelScalarFieldEntityType.generateNewId(),
9344
- })),
9345
- relations: input.model.relations?.map((r) => ({
9346
- ...r,
9347
- id: r.id ?? modelLocalRelationEntityType.generateNewId(),
9348
- foreignId: r.foreignId ?? modelForeignRelationEntityType.generateNewId(),
9349
- })),
9350
- uniqueConstraints: input.model.uniqueConstraints?.map((c) => ({
9351
- ...c,
9352
- id: c.id ?? modelUniqueConstraintEntityType.generateNewId(),
9353
- })),
9354
- },
9355
- };
9356
- }
9357
- /**
9358
- * Deserializes a model merger model input converting all names to IDs.
9359
- *
9360
- * @param input - The model merger model input.
9361
- * @param resolveForeignFieldRef - A function that resolves the foreign field ref.
9362
- * @returns The deserialized model merger model input.
9363
- */
9364
- function deserializeModelMergerModelInput(input, resolveForeignFieldRef) {
9365
- const inputWithIds = attachIdsToModelMergerModelInput(input);
9366
- const resolveLocalFieldName = (name) => {
9367
- const field = inputWithIds.model.fields.find((f) => f.name === name);
9368
- if (!field) {
9369
- throw new Error(`Field ${name} not found`);
9370
- }
9371
- return field.id;
9372
- };
9373
- return {
9374
- ...inputWithIds,
9375
- model: {
9376
- ...inputWithIds.model,
9377
- relations: inputWithIds.model.relations?.map((relation) => ({
9378
- ...relation,
9379
- references: relation.references.map((reference) => ({
9380
- ...reference,
9381
- localRef: resolveLocalFieldName(reference.localRef),
9382
- foreignRef: resolveForeignFieldRef(relation.modelRef, reference.foreignRef),
9383
- })),
9384
- })),
9385
- uniqueConstraints: inputWithIds.model.uniqueConstraints?.map((constraint) => ({
9386
- ...constraint,
9387
- fields: constraint.fields.map((field) => ({
9388
- ...field,
9389
- fieldRef: resolveLocalFieldName(field.fieldRef),
9390
- })),
9391
- })),
9392
- primaryKeyFieldRefs: inputWithIds.model.primaryKeyFieldRefs.map((fieldRef) => resolveLocalFieldName(fieldRef)),
9393
- },
9394
- };
9395
- }
9396
- /**
9397
- * Creates a new blank model config input from a name and feature ref.
9398
- *
9399
- * @param name - The name of the model.
9400
- * @param featureRef - The feature ref of the model.
9401
- * @returns The new model config input.
9402
- */
9403
- function createNewModelConfigInput(name, featureRef) {
9404
- return {
9405
- id: modelEntityType.generateNewId(),
9406
- name,
9407
- featureRef,
9408
- model: {
9409
- fields: [],
9410
- primaryKeyFieldRefs: [],
9411
- },
9412
- };
9413
- }
9414
- /**
9415
- * Diff the model definition.
9416
- *
9417
- * @param current - The current model definition or a new model to be created.
9418
- * @param desired - The desired model definition.
9419
- * @param definitionContainer - Project definition container.
9420
- * @param options - Diff options.
9421
- * @returns A diff output or undefined if there are no differences.
9422
- */
9423
- function createModelMergerResult(current, desired, definitionContainer, { siblingModels = [] } = {}) {
9424
- const currentModel = current ?? createNewModelConfigInput(desired.name, desired.featureRef);
9425
- // resolves all the names of the current model config input
9426
- const resolvedCurrent = serializeModelMergerModelInput(currentModel, definitionContainer, siblingModels);
9427
- const diff = createDefinitionDiff(resolvedCurrent, desired, modelMergerDefinitionDiffConfig);
9428
- if (!diff) {
9429
- return undefined;
9430
- }
9431
- return {
9432
- isNewModel: !current,
9433
- id: currentModel.id,
9434
- name: currentModel.name,
9435
- featureRef: currentModel.featureRef,
9436
- changes: diff,
9437
- };
9438
- }
9439
- /**
9440
- * Creates a model merger result for a set of models.
9441
- *
9442
- * @param current - A map of model IDs
9443
- * @param desired - The desired model definition.
9444
- * @param definitionContainer - Project definition container.
9445
- * @param options - Diff options.
9446
- * @returns A model merger result for a set of models.
9447
- */
9448
- function createModelMergerResults(current, desired, definitionContainer, { siblingModels = [] } = {}) {
9449
- return mapValues(desired, (desired, key) => createModelMergerResult(current[key] && modelEntityType.isId(current[key])
9450
- ? ModelUtils.byIdOrThrow(definitionContainer.definition, current[key])
9451
- : undefined, desired, definitionContainer, {
9452
- siblingModels,
9453
- }));
9454
- }
9455
- function applyModelMergerDiff(model, diff, definitionContainer, siblingModels = []) {
9456
- const resolvedCurrent = serializeModelMergerModelInput(model, definitionContainer, siblingModels);
9457
- const patchedCurrent = applyDefinitionDiff(resolvedCurrent, diff, modelMergerDefinitionDiffConfig);
9458
- return {
9459
- ...model,
9460
- ...deserializeModelMergerModelInput(patchedCurrent, (modelId, fieldName) => {
9461
- const siblingModel = siblingModels.find((m) => m.id === modelId);
9462
- if (siblingModel) {
9463
- const field = siblingModel.model.fields.find((f) => f.name === fieldName);
9464
- if (!field) {
9465
- throw new Error(`Field ${fieldName} not found in sibling model ${modelId}`);
9466
- }
9467
- return field.id;
9468
- }
9469
- const model = ModelUtils.byIdOrThrow(definitionContainer.definition, modelId);
9470
- const field = model.model.fields.find((f) => f.name === fieldName);
9471
- if (!field) {
9472
- throw new Error(`Field ${fieldName} not found in model ${model.name}`);
9473
- }
9474
- return field.id;
9475
- }),
9476
- };
9477
- }
9478
- function applyModelMergerResultInPlace(draftConfig, result, definitionContainer, { siblingModels = [] } = {}) {
9479
- const model = result.isNewModel
9480
- ? createNewModelConfigInput(result.name, result.featureRef)
9481
- : ModelUtils.byIdOrThrow(definitionContainer.definition, result.id);
9482
- const newModel = applyModelMergerDiff(model, result.changes, definitionContainer, siblingModels);
9483
- if (result.isNewModel) {
9484
- draftConfig.models.push(newModel);
9485
- }
9486
- else {
9487
- const index = draftConfig.models.findIndex((m) => m.id === result.id);
9488
- if (index === -1) {
9489
- throw new Error(`Model ${result.id} not found`);
9490
- }
9491
- draftConfig.models[index] = newModel;
9492
- }
9493
- return newModel.id;
9494
- }
9495
- function createAndApplyModelMergerResults(draftConfig, current, desired, definitionContainer, { siblingModels = [] } = {}) {
9496
- const results = createModelMergerResults(current, desired, definitionContainer, { siblingModels });
9497
- return mapValues(results, (result, key) => result
9498
- ? applyModelMergerResultInPlace(draftConfig, result, definitionContainer, { siblingModels })
9499
- : desired[key].name);
9500
- }
9501
-
9502
8844
  /**
9503
8845
  * Convert a color name to a hex color. Can be one of the following:
9504
8846
  * - A fixed color name (e.g. 'white', 'black').
@@ -10555,5 +9897,5 @@ function generateDefaultTheme() {
10555
9897
  };
10556
9898
  }
10557
9899
 
10558
- export { AVAILABLE_FLAGS, AppUtils, BUILT_IN_ADMIN_CRUD_INPUTS, BUILT_IN_TRANSFORMERS, COLOR_PALETTES, DefinitionDiffKeyedArrayField, DefinitionDiffReplacementField, EnumUtils, FIXED_COLOR_MAPPINGS, ModelFieldUtils, ModelTransformerUtils, ModelUtils, PALETTE_SHADES, PluginImplementationStore, PluginUtils, ProjectDefinitionContainer, REFERENTIAL_ACTIONS, SCALAR_FIELD_TYPES, SCHEMA_MIGRATIONS, SchemaMigrationError, THEME_COLORS, THEME_COLOR_KEYS, VALIDATORS, ZodRef, ZodRefWrapper, ZodWithPlugins, adminAppEntryType, adminAppSchema, adminCrudDisplaySchema, adminCrudDisplayTypes, adminCrudEmbeddedFormEntityType, adminCrudEmbeddedFormSchema, adminCrudEmbeddedInputSchema, adminCrudEmbeddedInputType, adminCrudEmbeddedListSchema, adminCrudEmbeddedLocalInputSchema, adminCrudEmbeddedLocalInputType, adminCrudEmbeddedObjectSchema, adminCrudEnumInputSchema, adminCrudForeignDisplaySchema, adminCrudForeignInputSchema, adminCrudInputCompilerSpec, adminCrudInputSchema, adminCrudInputSpec, adminCrudPasswordInputSchema, adminCrudSectionSchema, adminCrudTableColumnSchema, adminCrudTextDisplaySchema, adminCrudTextInputSchema, adminSectionEntityType, adminSectionSchema, appCompilerSpec, appEntityType, appSchema, applyDefinitionDiff, applyModelMergerDiff, applyModelMergerResultInPlace, authConfigSpec, authRoleEntityType, backendAppEntryType, backendAppSchema, baseAdminCrudInputSchema, baseAdminSectionValidators, baseAppSchema, baseAppValidators, basePluginDefinitionSchema, baseTransformerFields, baseTransformerSchema, convertColorNameToOklch, convertHexToOklch, convertOklchToColorName, convertOklchToHex, createAdminCrudInputCompilerImplementation, createAdminCrudInputImplementation, createAdminCrudInputType, createAndApplyModelMergerResults, createAppCompiler, createAppCompilerPlugin, createAppEntryType, createDefinitionDiff, createDefinitionDiffConfig, createDefinitionEntityNameResolver, createEntityType, createModelMergerResult, createModelMergerResults, createModelTransformerCompilerImplementation, createModelTransformerImplementation, createModelTransformerType, createPlatformPluginExport, createPluginConfigImplementation, createPluginImplementationStore, createPluginSpec, createProjectDefinitionSchema, createProjectDefinitionSchemaWithContext, createSettingsSchema, createTestProjectDefinition, createTestProjectDefinitionContainer, createWebConfigImplementation, definitionSchema, deserializeSchemaWithReferences, embeddedRelationTransformerSchema, enumBaseSchema, enumSchema, enumValueSchema, featureEntityType, featuresSchema, fixRefDeletions, generalSettingsSchema, generateCssFromThemeConfig, generateDefaultTheme, generateThemeColorsFromShade, getBackendRelativePath, getDefaultThemeColorFromShade, getLatestMigrationVersion, initializePlugins, isMigrateableProjectDefinition, modelBaseSchema, modelEntityType, modelEnumEntityType, modelEnumValueEntityType, modelForeignRelationEntityType, modelGraphqlSchema, modelLocalRelationEntityType, modelMergerDefinitionDiffConfig, modelRelationFieldSchema, modelScalarFieldEntityType, modelScalarFieldSchema, modelSchema, modelServiceSchema, modelTransformerCompilerSpec, modelTransformerEntityType, modelTransformerSpec, modelUniqueConstraintEntityType, modelUniqueConstraintSchema, oklchColor, paletteSchema, palettesSchema, parseOklch, parseProjectDefinitionWithContext, parseProjectDefinitionWithReferences, passwordTransformerSchema, pluginConfigSpec, pluginEntityType, pluginManifestJsonSchema, pluginMetadataSchema, pluginSpecDependencySchema, pluginSpecSupportSchema, pluginWithConfigSchema, pluginsSchema, runPluginMigrations, runSchemaMigrations, serializeSchema, serializeSchemaFromRefPayload, stripEmptyGeneratorChildren, stripUndefinedValues, templateExtractorSchema, themeColorSchema, themeSchema, transformerSchema, undefinedIfEmpty, undefinedIfFalsy, webAppEntryType, webAppSchema, webConfigSpec, zEnt, zPluginWrapper, zRef, zRefBuilder, zRefId, zWithPlugins };
10559
- //# sourceMappingURL=project-builder-lib-B62IPizQ.js.map
9900
+ export { AVAILABLE_FLAGS, AppUtils, BUILT_IN_ADMIN_CRUD_INPUTS, BUILT_IN_TRANSFORMERS, COLOR_PALETTES, EnumUtils, FIXED_COLOR_MAPPINGS, ModelFieldUtils, ModelTransformerUtils, ModelUtils, PALETTE_SHADES, PluginImplementationStore, PluginUtils, ProjectDefinitionContainer, REFERENTIAL_ACTIONS, SCALAR_FIELD_TYPES, SCHEMA_MIGRATIONS, SchemaMigrationError, THEME_COLORS, THEME_COLOR_KEYS, VALIDATORS, ZodRef, ZodRefWrapper, ZodWithPlugins, adminAppEntryType, adminAppSchema, adminCrudDisplaySchema, adminCrudDisplayTypes, adminCrudEmbeddedFormEntityType, adminCrudEmbeddedFormSchema, adminCrudEmbeddedInputSchema, adminCrudEmbeddedInputType, adminCrudEmbeddedListSchema, adminCrudEmbeddedLocalInputSchema, adminCrudEmbeddedLocalInputType, adminCrudEmbeddedObjectSchema, adminCrudEnumInputSchema, adminCrudForeignDisplaySchema, adminCrudForeignInputSchema, adminCrudInputCompilerSpec, adminCrudInputSchema, adminCrudInputSpec, adminCrudPasswordInputSchema, adminCrudSectionSchema, adminCrudTableColumnSchema, adminCrudTextDisplaySchema, adminCrudTextInputSchema, adminSectionEntityType, adminSectionSchema, appCompilerSpec, appEntityType, appSchema, authConfigSpec, authRoleEntityType, backendAppEntryType, backendAppSchema, baseAdminCrudInputSchema, baseAdminSectionValidators, baseAppSchema, baseAppValidators, basePluginDefinitionSchema, baseTransformerFields, baseTransformerSchema, convertColorNameToOklch, convertHexToOklch, convertOklchToColorName, convertOklchToHex, createAdminCrudInputCompilerImplementation, createAdminCrudInputImplementation, createAdminCrudInputType, createAppCompiler, createAppCompilerPlugin, createAppEntryType, createDefinitionEntityNameResolver, createEntityType, createModelTransformerCompilerImplementation, createModelTransformerImplementation, createModelTransformerType, createPlatformPluginExport, createPluginConfigImplementation, createPluginImplementationStore, createPluginSpec, createProjectDefinitionSchema, createProjectDefinitionSchemaWithContext, createSettingsSchema, createTestProjectDefinition, createTestProjectDefinitionContainer, createTestProjectDefinitionInput, createWebConfigImplementation, definitionSchema, deserializeSchemaWithReferences, embeddedRelationTransformerSchema, enumBaseSchema, enumSchema, enumValueSchema, featureEntityType, featuresSchema, fixRefDeletions, generalSettingsSchema, generateCssFromThemeConfig, generateDefaultTheme, generateThemeColorsFromShade, getBackendRelativePath, getDefaultThemeColorFromShade, getLatestMigrationVersion, initializePlugins, isMigrateableProjectDefinition, modelBaseSchema, modelEntityType, modelEnumEntityType, modelEnumValueEntityType, modelForeignRelationEntityType, modelGraphqlSchema, modelLocalRelationEntityType, modelRelationFieldSchema, modelScalarFieldEntityType, modelScalarFieldSchema, modelSchema, modelServiceSchema, modelTransformerCompilerSpec, modelTransformerEntityType, modelTransformerSpec, modelUniqueConstraintEntityType, modelUniqueConstraintSchema, oklchColor, paletteSchema, palettesSchema, parseOklch, parseProjectDefinitionWithContext, parseProjectDefinitionWithReferences, passwordTransformerSchema, pluginConfigSpec, pluginEntityType, pluginManifestJsonSchema, pluginMetadataSchema, pluginSpecDependencySchema, pluginSpecSupportSchema, pluginWithConfigSchema, pluginsSchema, runPluginMigrations, runSchemaMigrations, serializeSchema, serializeSchemaFromRefPayload, stripEmptyGeneratorChildren, stripUndefinedValues, templateExtractorSchema, themeColorSchema, themeSchema, transformerSchema, undefinedIfEmpty, undefinedIfFalsy, webAppEntryType, webAppSchema, webConfigSpec, zEnt, zPluginWrapper, zRef, zRefBuilder, zRefId, zWithPlugins };
9901
+ //# sourceMappingURL=project-builder-lib-GtzVuDsM.js.map