@takeshape/schema 9.58.0 → 9.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util/merge.d.ts.map +1 -1
- package/dist/util/merge.js +17 -7
- package/es/util/merge.js +17 -7
- package/package.json +5 -5
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,iBAAiB,EAAY,MAAM,mBAAmB,CAAC;AAazF,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;
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/util/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAY,MAAM,mBAAmB,CAAC;AAazF,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;AAmLD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,iBAAiB,GACtB;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,SAAS,CAAA;CAAC,GAAG;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,iBAAiB,CAAA;CAAC,CAwChG"}
|
package/dist/util/merge.js
CHANGED
|
@@ -192,6 +192,12 @@ function getChangedShape(schema, change) {
|
|
|
192
192
|
const shape = findChangedShape(schema, change);
|
|
193
193
|
(0, _tinyInvariant.default)(shape, 'Expected shape not found');
|
|
194
194
|
return shape;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function rebaseShapeProperties(toShape, fromShape, baseShape) {
|
|
198
|
+
return baseShape ? (0, _util.rebaseObject)((0, _omit.default)(toShape, 'schema'), (0, _omit.default)(baseShape, 'schema'), (0, _omit.default)(fromShape, 'schema')) : { ...toShape,
|
|
199
|
+
...fromShape
|
|
200
|
+
};
|
|
195
201
|
} // eslint-disable-next-line complexity
|
|
196
202
|
|
|
197
203
|
|
|
@@ -201,12 +207,17 @@ function attemptToMerge(base, parent, head, change) {
|
|
|
201
207
|
const toSchema = toShape.schema;
|
|
202
208
|
const fromSchema = fromShape.schema;
|
|
203
209
|
|
|
210
|
+
if ((0, _isEqual.default)(toSchema, fromSchema)) {
|
|
211
|
+
const baseShape = findChangedShape(parent, change);
|
|
212
|
+
return { ...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
213
|
+
schema: toSchema
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
204
217
|
if ((0, _types.isObjectSchema)(toSchema) && (0, _types.isObjectSchema)(fromSchema)) {
|
|
205
218
|
const baseShape = findChangedShape(parent, change);
|
|
206
219
|
const baseSchema = baseShape === null || baseShape === void 0 ? void 0 : baseShape.schema;
|
|
207
|
-
return { ...(
|
|
208
|
-
...fromShape
|
|
209
|
-
}),
|
|
220
|
+
return { ...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
210
221
|
schema: change.op === 'update' && baseSchema && (0, _types.isObjectSchema)(baseSchema) ? rebaseSchemaProperties(toSchema, baseSchema, fromSchema) : mergeSchemaProperties(toSchema, fromSchema)
|
|
211
222
|
};
|
|
212
223
|
}
|
|
@@ -217,10 +228,9 @@ function attemptToMerge(base, parent, head, change) {
|
|
|
217
228
|
const fromObj = (0, _last.default)(fromSchema.extends);
|
|
218
229
|
|
|
219
230
|
if (toObj && (0, _types.isObjectSchema)(toObj) && fromObj && (0, _types.isObjectSchema)(fromObj) && toSchema.extends.slice(0, toSchema.extends.length - 1).every((item, i) => (0, _isEqual.default)(item, fromExtends[i]))) {
|
|
220
|
-
var _findChangedShape;
|
|
221
|
-
|
|
222
231
|
let mergedObjSchema;
|
|
223
|
-
const
|
|
232
|
+
const baseShape = findChangedShape(parent, change);
|
|
233
|
+
const baseSchema = baseShape === null || baseShape === void 0 ? void 0 : baseShape.schema;
|
|
224
234
|
|
|
225
235
|
if (change.op === 'update' && baseSchema && (0, _types.isExtendsSchema)(baseSchema)) {
|
|
226
236
|
const baseObj = (0, _last.default)(baseSchema.extends);
|
|
@@ -234,7 +244,7 @@ function attemptToMerge(base, parent, head, change) {
|
|
|
234
244
|
mergedObjSchema = mergeSchemaProperties(toObj, fromObj);
|
|
235
245
|
}
|
|
236
246
|
|
|
237
|
-
return { ...fromShape,
|
|
247
|
+
return { ...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
238
248
|
schema: {
|
|
239
249
|
extends: [...toSchema.extends.slice(0, toSchema.extends.length - 1), mergedObjSchema]
|
|
240
250
|
}
|
package/es/util/merge.js
CHANGED
|
@@ -160,6 +160,12 @@ function getChangedShape(schema, change) {
|
|
|
160
160
|
const shape = findChangedShape(schema, change);
|
|
161
161
|
invariant(shape, 'Expected shape not found');
|
|
162
162
|
return shape;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function rebaseShapeProperties(toShape, fromShape, baseShape) {
|
|
166
|
+
return baseShape ? rebaseObject(omit(toShape, 'schema'), omit(baseShape, 'schema'), omit(fromShape, 'schema')) : { ...toShape,
|
|
167
|
+
...fromShape
|
|
168
|
+
};
|
|
163
169
|
} // eslint-disable-next-line complexity
|
|
164
170
|
|
|
165
171
|
|
|
@@ -169,12 +175,17 @@ function attemptToMerge(base, parent, head, change) {
|
|
|
169
175
|
const toSchema = toShape.schema;
|
|
170
176
|
const fromSchema = fromShape.schema;
|
|
171
177
|
|
|
178
|
+
if (isEqual(toSchema, fromSchema)) {
|
|
179
|
+
const baseShape = findChangedShape(parent, change);
|
|
180
|
+
return { ...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
181
|
+
schema: toSchema
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
172
185
|
if (isObjectSchema(toSchema) && isObjectSchema(fromSchema)) {
|
|
173
186
|
const baseShape = findChangedShape(parent, change);
|
|
174
187
|
const baseSchema = baseShape === null || baseShape === void 0 ? void 0 : baseShape.schema;
|
|
175
|
-
return { ...(
|
|
176
|
-
...fromShape
|
|
177
|
-
}),
|
|
188
|
+
return { ...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
178
189
|
schema: change.op === 'update' && baseSchema && isObjectSchema(baseSchema) ? rebaseSchemaProperties(toSchema, baseSchema, fromSchema) : mergeSchemaProperties(toSchema, fromSchema)
|
|
179
190
|
};
|
|
180
191
|
}
|
|
@@ -185,10 +196,9 @@ function attemptToMerge(base, parent, head, change) {
|
|
|
185
196
|
const fromObj = last(fromSchema.extends);
|
|
186
197
|
|
|
187
198
|
if (toObj && isObjectSchema(toObj) && fromObj && isObjectSchema(fromObj) && toSchema.extends.slice(0, toSchema.extends.length - 1).every((item, i) => isEqual(item, fromExtends[i]))) {
|
|
188
|
-
var _findChangedShape;
|
|
189
|
-
|
|
190
199
|
let mergedObjSchema;
|
|
191
|
-
const
|
|
200
|
+
const baseShape = findChangedShape(parent, change);
|
|
201
|
+
const baseSchema = baseShape === null || baseShape === void 0 ? void 0 : baseShape.schema;
|
|
192
202
|
|
|
193
203
|
if (change.op === 'update' && baseSchema && isExtendsSchema(baseSchema)) {
|
|
194
204
|
const baseObj = last(baseSchema.extends);
|
|
@@ -202,7 +212,7 @@ function attemptToMerge(base, parent, head, change) {
|
|
|
202
212
|
mergedObjSchema = mergeSchemaProperties(toObj, fromObj);
|
|
203
213
|
}
|
|
204
214
|
|
|
205
|
-
return { ...fromShape,
|
|
215
|
+
return { ...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
206
216
|
schema: {
|
|
207
217
|
extends: [...toSchema.extends.slice(0, toSchema.extends.length - 1), mergedObjSchema]
|
|
208
218
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "9.58.
|
|
3
|
+
"version": "9.58.2",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"p-reduce": "^2.1.0",
|
|
29
29
|
"semver": "^7.3.2",
|
|
30
30
|
"tiny-invariant": "^1.2.0",
|
|
31
|
-
"@takeshape/
|
|
32
|
-
"@takeshape/util": "9.58.
|
|
33
|
-
"@takeshape/
|
|
31
|
+
"@takeshape/errors": "9.58.2",
|
|
32
|
+
"@takeshape/util": "9.58.2",
|
|
33
|
+
"@takeshape/json-schema": "9.58.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"meow": "^9.0.0",
|
|
47
47
|
"p-map": "^5.0.0",
|
|
48
48
|
"shortid": "^2.2.15",
|
|
49
|
-
"@takeshape/typescript-jest-junit-reporter": "9.58.
|
|
49
|
+
"@takeshape/typescript-jest-junit-reporter": "9.58.2"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=16"
|