@naturalcycles/nodejs-lib 15.63.0 → 15.63.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.
|
@@ -242,9 +242,9 @@ export declare class JsonSchemaObjectBuilder<IN extends AnyObject, OUT extends A
|
|
|
242
242
|
/**
|
|
243
243
|
* Concatenates another schema to the current schema.
|
|
244
244
|
*
|
|
245
|
-
* It expects
|
|
246
|
-
*
|
|
247
|
-
*
|
|
245
|
+
* It expects you to use `isOfType<T>()` in the chain,
|
|
246
|
+
* otherwise the validation will throw. This is to ensure
|
|
247
|
+
* that the schemas you concatenated match the intended final type.
|
|
248
248
|
*
|
|
249
249
|
* ```ts
|
|
250
250
|
* interface Foo { foo: string }
|
|
@@ -254,11 +254,10 @@ export declare class JsonSchemaObjectBuilder<IN extends AnyObject, OUT extends A
|
|
|
254
254
|
* const barSchema = j.object<Bar>({ bar: j.number() })
|
|
255
255
|
*
|
|
256
256
|
* interface Shu { foo: string, bar: number }
|
|
257
|
-
* const shuSchema = fooSchema.concat<Shu
|
|
257
|
+
* const shuSchema = fooSchema.concat(barSchema).isOfType<Shu>() // important
|
|
258
258
|
* ```
|
|
259
259
|
*/
|
|
260
|
-
concat(other: any):
|
|
261
|
-
concat<NEW_TYPE extends AnyObject, OUT2 extends AnyObject>(other: JsonSchemaObjectBuilder<any, OUT2, any>): ExactMatch<NEW_TYPE, OUT & OUT2> extends true ? JsonSchemaObjectBuilder<NEW_TYPE, NEW_TYPE, false> : never;
|
|
260
|
+
concat<IN2 extends AnyObject, OUT2 extends AnyObject>(other: JsonSchemaObjectBuilder<IN2, OUT2, any>): JsonSchemaObjectBuilder<IN & IN2, OUT & OUT2, false>;
|
|
262
261
|
/**
|
|
263
262
|
* Extends the current schema with `id`, `created` and `updated` according to NC DB conventions.
|
|
264
263
|
*/
|
|
@@ -595,9 +595,28 @@ export class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
|
|
|
595
595
|
_objectAssign(clone.schema, { hasIsOfTypeCheck });
|
|
596
596
|
return clone;
|
|
597
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Concatenates another schema to the current schema.
|
|
600
|
+
*
|
|
601
|
+
* It expects you to use `isOfType<T>()` in the chain,
|
|
602
|
+
* otherwise the validation will throw. This is to ensure
|
|
603
|
+
* that the schemas you concatenated match the intended final type.
|
|
604
|
+
*
|
|
605
|
+
* ```ts
|
|
606
|
+
* interface Foo { foo: string }
|
|
607
|
+
* const fooSchema = j.object<Foo>({ foo: j.string() })
|
|
608
|
+
*
|
|
609
|
+
* interface Bar { bar: number }
|
|
610
|
+
* const barSchema = j.object<Bar>({ bar: j.number() })
|
|
611
|
+
*
|
|
612
|
+
* interface Shu { foo: string, bar: number }
|
|
613
|
+
* const shuSchema = fooSchema.concat(barSchema).isOfType<Shu>() // important
|
|
614
|
+
* ```
|
|
615
|
+
*/
|
|
598
616
|
concat(other) {
|
|
599
617
|
const clone = this.clone();
|
|
600
618
|
mergeJsonSchemaObjects(clone.schema, other.schema);
|
|
619
|
+
_objectAssign(clone.schema, { hasIsOfTypeCheck: false });
|
|
601
620
|
return clone;
|
|
602
621
|
}
|
|
603
622
|
/**
|
package/package.json
CHANGED
|
@@ -851,9 +851,9 @@ export class JsonSchemaObjectBuilder<
|
|
|
851
851
|
/**
|
|
852
852
|
* Concatenates another schema to the current schema.
|
|
853
853
|
*
|
|
854
|
-
* It expects
|
|
855
|
-
*
|
|
856
|
-
*
|
|
854
|
+
* It expects you to use `isOfType<T>()` in the chain,
|
|
855
|
+
* otherwise the validation will throw. This is to ensure
|
|
856
|
+
* that the schemas you concatenated match the intended final type.
|
|
857
857
|
*
|
|
858
858
|
* ```ts
|
|
859
859
|
* interface Foo { foo: string }
|
|
@@ -863,19 +863,16 @@ export class JsonSchemaObjectBuilder<
|
|
|
863
863
|
* const barSchema = j.object<Bar>({ bar: j.number() })
|
|
864
864
|
*
|
|
865
865
|
* interface Shu { foo: string, bar: number }
|
|
866
|
-
* const shuSchema = fooSchema.concat<Shu
|
|
866
|
+
* const shuSchema = fooSchema.concat(barSchema).isOfType<Shu>() // important
|
|
867
867
|
* ```
|
|
868
868
|
*/
|
|
869
|
-
concat
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
): ExactMatch<NEW_TYPE, OUT & OUT2> extends true
|
|
873
|
-
? JsonSchemaObjectBuilder<NEW_TYPE, NEW_TYPE, false>
|
|
874
|
-
: never
|
|
875
|
-
concat(other: any): any {
|
|
869
|
+
concat<IN2 extends AnyObject, OUT2 extends AnyObject>(
|
|
870
|
+
other: JsonSchemaObjectBuilder<IN2, OUT2, any>,
|
|
871
|
+
): JsonSchemaObjectBuilder<IN & IN2, OUT & OUT2, false> {
|
|
876
872
|
const clone = this.clone()
|
|
877
|
-
mergeJsonSchemaObjects(clone.schema as any, other.schema)
|
|
878
|
-
|
|
873
|
+
mergeJsonSchemaObjects(clone.schema as any, other.schema as any)
|
|
874
|
+
_objectAssign(clone.schema, { hasIsOfTypeCheck: false })
|
|
875
|
+
return clone as unknown as JsonSchemaObjectBuilder<IN & IN2, OUT & OUT2, false>
|
|
879
876
|
}
|
|
880
877
|
|
|
881
878
|
/**
|