@takeshape/schema 8.265.2 → 8.268.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util/merge.d.ts +5 -5
- package/dist/util/merge.d.ts.map +1 -1
- package/dist/util/merge.js +41 -41
- package/es/util/merge.js +41 -41
- package/package.json +4 -4
package/dist/util/merge.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FormConfig, ObjectSchema, ProjectSchema } from '../project-schema';
|
|
2
2
|
export declare function mergeObjectSchemas(...args: Array<ObjectSchema | undefined>): ObjectSchema;
|
|
3
|
-
export declare function mergeSchemaProperties(
|
|
4
|
-
export declare function rebaseSchemaProperties(
|
|
5
|
-
export declare function mergeFormProperties(
|
|
6
|
-
export declare function rebaseFormProperties(
|
|
3
|
+
export declare function mergeSchemaProperties(parent: ObjectSchema, overrides: ObjectSchema): ObjectSchema;
|
|
4
|
+
export declare function rebaseSchemaProperties(base: ObjectSchema, parent: ObjectSchema, head: ObjectSchema): ObjectSchema;
|
|
5
|
+
export declare function mergeFormProperties(parent: FormConfig, overrides: FormConfig): FormConfig;
|
|
6
|
+
export declare function rebaseFormProperties(base: FormConfig, parent: FormConfig, head: FormConfig): FormConfig;
|
|
7
7
|
export declare function mergeFormConfigs(...configs: FormConfig[]): FormConfig;
|
|
8
|
-
export declare function mergeProjectSchemas(
|
|
8
|
+
export declare function mergeProjectSchemas(base: ProjectSchema, parent: ProjectSchema, head: ProjectSchema): {
|
|
9
9
|
error: string;
|
|
10
10
|
mergedSchema: undefined;
|
|
11
11
|
} | {
|
package/dist/util/merge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/util/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,aAAa,EAAQ,MAAM,mBAAmB,CAAC;AAYjF,wBAAgB,kBAAkB,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,YAAY,CAEzF;AAED,wBAAgB,qBAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/util/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,aAAa,EAAQ,MAAM,mBAAmB,CAAC;AAYjF,wBAAgB,kBAAkB,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,YAAY,CAEzF;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,GAAG,YAAY,CAgBjG;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,YAAY,CAiBjH;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU,CAezF;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAgBvG;AAED,wBAAgB,gBAAgB,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CAErE;AAoJD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,aAAa,GAClB;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,SAAS,CAAA;CAAC,GAAG;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,aAAa,CAAA;CAAC,CAsC5F"}
|
package/dist/util/merge.js
CHANGED
|
@@ -40,13 +40,13 @@ function mergeObjectSchemas(...args) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function mergeSchemaProperties(
|
|
44
|
-
const result = { ...
|
|
45
|
-
properties: { ...
|
|
43
|
+
function mergeSchemaProperties(parent, overrides) {
|
|
44
|
+
const result = { ...parent,
|
|
45
|
+
properties: { ...parent.properties,
|
|
46
46
|
...overrides.properties
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
const required = (0, _union.default)(
|
|
49
|
+
const required = (0, _union.default)(parent.required, overrides.required);
|
|
50
50
|
|
|
51
51
|
if (required.length) {
|
|
52
52
|
result.required = required;
|
|
@@ -55,22 +55,22 @@ function mergeSchemaProperties(base, overrides) {
|
|
|
55
55
|
return result;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function rebaseSchemaProperties(
|
|
58
|
+
function rebaseSchemaProperties(base, parent, head) {
|
|
59
59
|
const {
|
|
60
60
|
properties: toProperties,
|
|
61
61
|
required: toRequired,
|
|
62
62
|
...toOther
|
|
63
|
-
} =
|
|
63
|
+
} = base;
|
|
64
64
|
const {
|
|
65
65
|
properties: baseProperties,
|
|
66
66
|
required: baseRequired,
|
|
67
67
|
...baseOther
|
|
68
|
-
} =
|
|
68
|
+
} = parent;
|
|
69
69
|
const {
|
|
70
70
|
properties: fromProperties,
|
|
71
71
|
required: fromRequired,
|
|
72
72
|
...fromOther
|
|
73
|
-
} =
|
|
73
|
+
} = head;
|
|
74
74
|
const newSchema = { ...(0, _util.rebaseObject)(toOther, baseOther, fromOther),
|
|
75
75
|
type: 'object',
|
|
76
76
|
properties: (0, _util.rebaseObject)(toProperties, baseProperties, fromProperties)
|
|
@@ -84,13 +84,13 @@ function rebaseSchemaProperties(to, base, from) {
|
|
|
84
84
|
return newSchema;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function mergeFormProperties(
|
|
88
|
-
const result = { ...
|
|
89
|
-
properties: { ...
|
|
87
|
+
function mergeFormProperties(parent, overrides) {
|
|
88
|
+
const result = { ...parent,
|
|
89
|
+
properties: { ...parent.properties,
|
|
90
90
|
...overrides.properties
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
const order = (0, _union.default)(
|
|
93
|
+
const order = (0, _union.default)(parent.order, overrides.order);
|
|
94
94
|
|
|
95
95
|
if (order.length) {
|
|
96
96
|
result.order = order;
|
|
@@ -99,22 +99,22 @@ function mergeFormProperties(base, overrides) {
|
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function rebaseFormProperties(
|
|
102
|
+
function rebaseFormProperties(base, parent, head) {
|
|
103
103
|
const {
|
|
104
104
|
properties: toProperties,
|
|
105
105
|
order: toOrder,
|
|
106
106
|
...toOther
|
|
107
|
-
} =
|
|
107
|
+
} = base;
|
|
108
108
|
const {
|
|
109
109
|
properties: baseProperties,
|
|
110
110
|
order: baseOrder,
|
|
111
111
|
...baseOther
|
|
112
|
-
} =
|
|
112
|
+
} = parent;
|
|
113
113
|
const {
|
|
114
114
|
properties: fromProperties,
|
|
115
115
|
order: fromOrder,
|
|
116
116
|
...fromOther
|
|
117
|
-
} =
|
|
117
|
+
} = head;
|
|
118
118
|
const newForm = { ...(0, _util.rebaseObject)(toOther, baseOther, fromOther),
|
|
119
119
|
properties: (0, _util.rebaseObject)(toProperties, baseProperties, fromProperties)
|
|
120
120
|
};
|
|
@@ -170,8 +170,8 @@ function compareSection(section, original, updated) {
|
|
|
170
170
|
return changes;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
function compareSections(
|
|
174
|
-
return mergeableSections.flatMap(section =>
|
|
173
|
+
function compareSections(parent, branch) {
|
|
174
|
+
return mergeableSections.flatMap(section => parent[section] || branch[section] ? compareSection(section, parent[section] ?? {}, branch[section] ?? {}) : []);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
function findChangedShape(schema, change) {
|
|
@@ -185,14 +185,14 @@ function getChangedShape(schema, change) {
|
|
|
185
185
|
} // eslint-disable-next-line complexity
|
|
186
186
|
|
|
187
187
|
|
|
188
|
-
function attemptToMerge(
|
|
189
|
-
const toShape = getChangedShape(
|
|
190
|
-
const fromShape = getChangedShape(
|
|
188
|
+
function attemptToMerge(base, parent, head, change) {
|
|
189
|
+
const toShape = getChangedShape(base, change);
|
|
190
|
+
const fromShape = getChangedShape(head, change);
|
|
191
191
|
const toSchema = toShape.schema;
|
|
192
192
|
const fromSchema = fromShape.schema;
|
|
193
193
|
|
|
194
194
|
if ((0, _types.isObjectSchema)(toSchema) && (0, _types.isObjectSchema)(fromSchema)) {
|
|
195
|
-
const baseShape = findChangedShape(
|
|
195
|
+
const baseShape = findChangedShape(parent, change);
|
|
196
196
|
const baseSchema = baseShape === null || baseShape === void 0 ? void 0 : baseShape.schema;
|
|
197
197
|
return { ...(baseShape ? (0, _util.rebaseObject)((0, _omit.default)(toShape, 'schema'), (0, _omit.default)(baseShape, 'schema'), (0, _omit.default)(fromShape, 'schema')) : { ...toShape,
|
|
198
198
|
...fromShape
|
|
@@ -210,7 +210,7 @@ function attemptToMerge(to, base, from, change) {
|
|
|
210
210
|
var _findChangedShape;
|
|
211
211
|
|
|
212
212
|
let mergedObjSchema;
|
|
213
|
-
const baseSchema = (_findChangedShape = findChangedShape(
|
|
213
|
+
const baseSchema = (_findChangedShape = findChangedShape(parent, change)) === null || _findChangedShape === void 0 ? void 0 : _findChangedShape.schema;
|
|
214
214
|
|
|
215
215
|
if (change.op === 'update' && baseSchema && (0, _types.isExtendsSchema)(baseSchema)) {
|
|
216
216
|
const baseObj = (0, _last.default)(baseSchema.extends);
|
|
@@ -233,45 +233,45 @@ function attemptToMerge(to, base, from, change) {
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
function applyChange(
|
|
236
|
+
function applyChange(base, parent, head, change) {
|
|
237
237
|
if (change.op === 'remove') {
|
|
238
|
-
(0, _unset.default)(
|
|
238
|
+
(0, _unset.default)(base, change.path);
|
|
239
239
|
} else if (change.op === 'add') {
|
|
240
|
-
(0, _set.default)(
|
|
240
|
+
(0, _set.default)(base, change.path, change.value);
|
|
241
241
|
} else if (change.op === 'update') {
|
|
242
242
|
if (change.section === 'shapes') {
|
|
243
|
-
const mergedShape = attemptToMerge(
|
|
243
|
+
const mergedShape = attemptToMerge(base, parent, head, change);
|
|
244
244
|
|
|
245
245
|
if (mergedShape) {
|
|
246
|
-
(0, _set.default)(
|
|
246
|
+
(0, _set.default)(base, change.path, mergedShape);
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
} else if (change.section === 'forms') {
|
|
250
|
-
var
|
|
250
|
+
var _base$forms, _base$forms$shapeName, _head$forms, _head$forms$shapeName;
|
|
251
251
|
|
|
252
252
|
const shapeName = change.path[1];
|
|
253
|
-
const toForm = (
|
|
254
|
-
const fromForm = (
|
|
253
|
+
const toForm = (_base$forms = base.forms) === null || _base$forms === void 0 ? void 0 : (_base$forms$shapeName = _base$forms[shapeName]) === null || _base$forms$shapeName === void 0 ? void 0 : _base$forms$shapeName.default;
|
|
254
|
+
const fromForm = (_head$forms = head.forms) === null || _head$forms === void 0 ? void 0 : (_head$forms$shapeName = _head$forms[shapeName]) === null || _head$forms$shapeName === void 0 ? void 0 : _head$forms$shapeName.default;
|
|
255
255
|
|
|
256
256
|
if (toForm && fromForm) {
|
|
257
|
-
var
|
|
257
|
+
var _parent$forms, _parent$forms$shapeNa;
|
|
258
258
|
|
|
259
|
-
const baseForm = (
|
|
260
|
-
(0, _set.default)(
|
|
259
|
+
const baseForm = (_parent$forms = parent.forms) === null || _parent$forms === void 0 ? void 0 : (_parent$forms$shapeNa = _parent$forms[shapeName]) === null || _parent$forms$shapeNa === void 0 ? void 0 : _parent$forms$shapeNa.default;
|
|
260
|
+
(0, _set.default)(base, change.path, {
|
|
261
261
|
default: baseForm ? rebaseFormProperties(toForm, baseForm, fromForm) : mergeFormConfigs(toForm, fromForm)
|
|
262
262
|
});
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
(0, _set.default)(
|
|
267
|
+
(0, _set.default)(base, change.path, change.value);
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
function mergeProjectSchemas(
|
|
272
|
-
const changesTo = compareSections(
|
|
273
|
-
const changesFrom = compareSections(
|
|
274
|
-
const mergedSchema = (0, _util.deepClone)(
|
|
271
|
+
function mergeProjectSchemas(base, parent, head) {
|
|
272
|
+
const changesTo = compareSections(parent, base);
|
|
273
|
+
const changesFrom = compareSections(parent, head);
|
|
274
|
+
const mergedSchema = (0, _util.deepClone)(base);
|
|
275
275
|
|
|
276
276
|
for (let change of changesFrom) {
|
|
277
277
|
const potentialConflict = changesTo.find(changeTo => (0, _isEqual.default)(changeTo.path, change.path));
|
|
@@ -286,7 +286,7 @@ function mergeProjectSchemas(to, base, from) {
|
|
|
286
286
|
|
|
287
287
|
if (potentialConflict.op === 'add' && change.op === 'add' || potentialConflict.op === 'update' && change.op === 'update') {
|
|
288
288
|
if (change.section === 'shapes') {
|
|
289
|
-
const mergedValue = attemptToMerge(
|
|
289
|
+
const mergedValue = attemptToMerge(base, parent, head, change); // eslint-disable-next-line max-depth
|
|
290
290
|
|
|
291
291
|
if (!mergedValue) {
|
|
292
292
|
return {
|
|
@@ -307,7 +307,7 @@ function mergeProjectSchemas(to, base, from) {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
applyChange(mergedSchema,
|
|
310
|
+
applyChange(mergedSchema, parent, head, change);
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
return {
|
package/es/util/merge.js
CHANGED
|
@@ -14,13 +14,13 @@ export function mergeObjectSchemas(...args) {
|
|
|
14
14
|
properties: {}
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
export function mergeSchemaProperties(
|
|
18
|
-
const result = { ...
|
|
19
|
-
properties: { ...
|
|
17
|
+
export function mergeSchemaProperties(parent, overrides) {
|
|
18
|
+
const result = { ...parent,
|
|
19
|
+
properties: { ...parent.properties,
|
|
20
20
|
...overrides.properties
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
const required = union(
|
|
23
|
+
const required = union(parent.required, overrides.required);
|
|
24
24
|
|
|
25
25
|
if (required.length) {
|
|
26
26
|
result.required = required;
|
|
@@ -28,22 +28,22 @@ export function mergeSchemaProperties(base, overrides) {
|
|
|
28
28
|
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
|
-
export function rebaseSchemaProperties(
|
|
31
|
+
export function rebaseSchemaProperties(base, parent, head) {
|
|
32
32
|
const {
|
|
33
33
|
properties: toProperties,
|
|
34
34
|
required: toRequired,
|
|
35
35
|
...toOther
|
|
36
|
-
} =
|
|
36
|
+
} = base;
|
|
37
37
|
const {
|
|
38
38
|
properties: baseProperties,
|
|
39
39
|
required: baseRequired,
|
|
40
40
|
...baseOther
|
|
41
|
-
} =
|
|
41
|
+
} = parent;
|
|
42
42
|
const {
|
|
43
43
|
properties: fromProperties,
|
|
44
44
|
required: fromRequired,
|
|
45
45
|
...fromOther
|
|
46
|
-
} =
|
|
46
|
+
} = head;
|
|
47
47
|
const newSchema = { ...rebaseObject(toOther, baseOther, fromOther),
|
|
48
48
|
type: 'object',
|
|
49
49
|
properties: rebaseObject(toProperties, baseProperties, fromProperties)
|
|
@@ -56,13 +56,13 @@ export function rebaseSchemaProperties(to, base, from) {
|
|
|
56
56
|
|
|
57
57
|
return newSchema;
|
|
58
58
|
}
|
|
59
|
-
export function mergeFormProperties(
|
|
60
|
-
const result = { ...
|
|
61
|
-
properties: { ...
|
|
59
|
+
export function mergeFormProperties(parent, overrides) {
|
|
60
|
+
const result = { ...parent,
|
|
61
|
+
properties: { ...parent.properties,
|
|
62
62
|
...overrides.properties
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
const order = union(
|
|
65
|
+
const order = union(parent.order, overrides.order);
|
|
66
66
|
|
|
67
67
|
if (order.length) {
|
|
68
68
|
result.order = order;
|
|
@@ -70,22 +70,22 @@ export function mergeFormProperties(base, overrides) {
|
|
|
70
70
|
|
|
71
71
|
return result;
|
|
72
72
|
}
|
|
73
|
-
export function rebaseFormProperties(
|
|
73
|
+
export function rebaseFormProperties(base, parent, head) {
|
|
74
74
|
const {
|
|
75
75
|
properties: toProperties,
|
|
76
76
|
order: toOrder,
|
|
77
77
|
...toOther
|
|
78
|
-
} =
|
|
78
|
+
} = base;
|
|
79
79
|
const {
|
|
80
80
|
properties: baseProperties,
|
|
81
81
|
order: baseOrder,
|
|
82
82
|
...baseOther
|
|
83
|
-
} =
|
|
83
|
+
} = parent;
|
|
84
84
|
const {
|
|
85
85
|
properties: fromProperties,
|
|
86
86
|
order: fromOrder,
|
|
87
87
|
...fromOther
|
|
88
|
-
} =
|
|
88
|
+
} = head;
|
|
89
89
|
const newForm = { ...rebaseObject(toOther, baseOther, fromOther),
|
|
90
90
|
properties: rebaseObject(toProperties, baseProperties, fromProperties)
|
|
91
91
|
};
|
|
@@ -139,8 +139,8 @@ function compareSection(section, original, updated) {
|
|
|
139
139
|
return changes;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
function compareSections(
|
|
143
|
-
return mergeableSections.flatMap(section =>
|
|
142
|
+
function compareSections(parent, branch) {
|
|
143
|
+
return mergeableSections.flatMap(section => parent[section] || branch[section] ? compareSection(section, parent[section] ?? {}, branch[section] ?? {}) : []);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
function findChangedShape(schema, change) {
|
|
@@ -154,14 +154,14 @@ function getChangedShape(schema, change) {
|
|
|
154
154
|
} // eslint-disable-next-line complexity
|
|
155
155
|
|
|
156
156
|
|
|
157
|
-
function attemptToMerge(
|
|
158
|
-
const toShape = getChangedShape(
|
|
159
|
-
const fromShape = getChangedShape(
|
|
157
|
+
function attemptToMerge(base, parent, head, change) {
|
|
158
|
+
const toShape = getChangedShape(base, change);
|
|
159
|
+
const fromShape = getChangedShape(head, change);
|
|
160
160
|
const toSchema = toShape.schema;
|
|
161
161
|
const fromSchema = fromShape.schema;
|
|
162
162
|
|
|
163
163
|
if (isObjectSchema(toSchema) && isObjectSchema(fromSchema)) {
|
|
164
|
-
const baseShape = findChangedShape(
|
|
164
|
+
const baseShape = findChangedShape(parent, change);
|
|
165
165
|
const baseSchema = baseShape === null || baseShape === void 0 ? void 0 : baseShape.schema;
|
|
166
166
|
return { ...(baseShape ? rebaseObject(omit(toShape, 'schema'), omit(baseShape, 'schema'), omit(fromShape, 'schema')) : { ...toShape,
|
|
167
167
|
...fromShape
|
|
@@ -179,7 +179,7 @@ function attemptToMerge(to, base, from, change) {
|
|
|
179
179
|
var _findChangedShape;
|
|
180
180
|
|
|
181
181
|
let mergedObjSchema;
|
|
182
|
-
const baseSchema = (_findChangedShape = findChangedShape(
|
|
182
|
+
const baseSchema = (_findChangedShape = findChangedShape(parent, change)) === null || _findChangedShape === void 0 ? void 0 : _findChangedShape.schema;
|
|
183
183
|
|
|
184
184
|
if (change.op === 'update' && baseSchema && isExtendsSchema(baseSchema)) {
|
|
185
185
|
const baseObj = last(baseSchema.extends);
|
|
@@ -202,45 +202,45 @@ function attemptToMerge(to, base, from, change) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
function applyChange(
|
|
205
|
+
function applyChange(base, parent, head, change) {
|
|
206
206
|
if (change.op === 'remove') {
|
|
207
|
-
unset(
|
|
207
|
+
unset(base, change.path);
|
|
208
208
|
} else if (change.op === 'add') {
|
|
209
|
-
set(
|
|
209
|
+
set(base, change.path, change.value);
|
|
210
210
|
} else if (change.op === 'update') {
|
|
211
211
|
if (change.section === 'shapes') {
|
|
212
|
-
const mergedShape = attemptToMerge(
|
|
212
|
+
const mergedShape = attemptToMerge(base, parent, head, change);
|
|
213
213
|
|
|
214
214
|
if (mergedShape) {
|
|
215
|
-
set(
|
|
215
|
+
set(base, change.path, mergedShape);
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
218
|
} else if (change.section === 'forms') {
|
|
219
|
-
var
|
|
219
|
+
var _base$forms, _base$forms$shapeName, _head$forms, _head$forms$shapeName;
|
|
220
220
|
|
|
221
221
|
const shapeName = change.path[1];
|
|
222
|
-
const toForm = (
|
|
223
|
-
const fromForm = (
|
|
222
|
+
const toForm = (_base$forms = base.forms) === null || _base$forms === void 0 ? void 0 : (_base$forms$shapeName = _base$forms[shapeName]) === null || _base$forms$shapeName === void 0 ? void 0 : _base$forms$shapeName.default;
|
|
223
|
+
const fromForm = (_head$forms = head.forms) === null || _head$forms === void 0 ? void 0 : (_head$forms$shapeName = _head$forms[shapeName]) === null || _head$forms$shapeName === void 0 ? void 0 : _head$forms$shapeName.default;
|
|
224
224
|
|
|
225
225
|
if (toForm && fromForm) {
|
|
226
|
-
var
|
|
226
|
+
var _parent$forms, _parent$forms$shapeNa;
|
|
227
227
|
|
|
228
|
-
const baseForm = (
|
|
229
|
-
set(
|
|
228
|
+
const baseForm = (_parent$forms = parent.forms) === null || _parent$forms === void 0 ? void 0 : (_parent$forms$shapeNa = _parent$forms[shapeName]) === null || _parent$forms$shapeNa === void 0 ? void 0 : _parent$forms$shapeNa.default;
|
|
229
|
+
set(base, change.path, {
|
|
230
230
|
default: baseForm ? rebaseFormProperties(toForm, baseForm, fromForm) : mergeFormConfigs(toForm, fromForm)
|
|
231
231
|
});
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
set(
|
|
236
|
+
set(base, change.path, change.value);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
export function mergeProjectSchemas(
|
|
241
|
-
const changesTo = compareSections(
|
|
242
|
-
const changesFrom = compareSections(
|
|
243
|
-
const mergedSchema = deepClone(
|
|
240
|
+
export function mergeProjectSchemas(base, parent, head) {
|
|
241
|
+
const changesTo = compareSections(parent, base);
|
|
242
|
+
const changesFrom = compareSections(parent, head);
|
|
243
|
+
const mergedSchema = deepClone(base);
|
|
244
244
|
|
|
245
245
|
for (let change of changesFrom) {
|
|
246
246
|
const potentialConflict = changesTo.find(changeTo => isEqual(changeTo.path, change.path));
|
|
@@ -255,7 +255,7 @@ export function mergeProjectSchemas(to, base, from) {
|
|
|
255
255
|
|
|
256
256
|
if (potentialConflict.op === 'add' && change.op === 'add' || potentialConflict.op === 'update' && change.op === 'update') {
|
|
257
257
|
if (change.section === 'shapes') {
|
|
258
|
-
const mergedValue = attemptToMerge(
|
|
258
|
+
const mergedValue = attemptToMerge(base, parent, head, change); // eslint-disable-next-line max-depth
|
|
259
259
|
|
|
260
260
|
if (!mergedValue) {
|
|
261
261
|
return {
|
|
@@ -276,7 +276,7 @@ export function mergeProjectSchemas(to, base, from) {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
applyChange(mergedSchema,
|
|
279
|
+
applyChange(mergedSchema, parent, head, change);
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.268.0",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"p-reduce": "^2.1.0",
|
|
31
31
|
"semver": "^7.3.2",
|
|
32
32
|
"tiny-invariant": "^1.2.0",
|
|
33
|
-
"@takeshape/errors": "8.
|
|
34
|
-
"@takeshape/json-schema": "8.
|
|
35
|
-
"@takeshape/util": "8.
|
|
33
|
+
"@takeshape/errors": "8.268.0",
|
|
34
|
+
"@takeshape/json-schema": "8.268.0",
|
|
35
|
+
"@takeshape/util": "8.268.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|