@opra/common 0.30.1 → 0.31.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.
- package/browser.js +56 -47
- package/cjs/document/data-type/complex-type-class.js +2 -2
- package/cjs/document/data-type/field-class.js +5 -1
- package/cjs/document/data-type/{union-type-class.js → mixin-type-class.js} +8 -8
- package/cjs/document/data-type/{union-type.js → mixin-type.js} +16 -16
- package/cjs/document/factory/type-document-factory.js +7 -6
- package/cjs/document/index.js +1 -1
- package/cjs/document/resource/collection-class.js +2 -1
- package/cjs/document/resource/crud-resource.js +5 -2
- package/cjs/schema/data-type/mixin-type.interface.js +7 -0
- package/cjs/schema/opra-schema.ns.js +1 -1
- package/cjs/schema/type-guards.js +6 -6
- package/esm/document/data-type/complex-type-class.js +2 -2
- package/esm/document/data-type/field-class.js +5 -1
- package/esm/document/data-type/{union-type-class.js → mixin-type-class.js} +6 -6
- package/esm/document/data-type/{union-type.js → mixin-type.js} +15 -15
- package/esm/document/factory/type-document-factory.js +7 -6
- package/esm/document/index.js +1 -1
- package/esm/document/resource/collection-class.js +2 -1
- package/esm/document/resource/crud-resource.js +5 -2
- package/esm/schema/data-type/mixin-type.interface.js +4 -0
- package/esm/schema/opra-schema.ns.js +1 -1
- package/esm/schema/type-guards.js +4 -4
- package/package.json +1 -1
- package/types/document/data-type/complex-type-class.d.ts +2 -2
- package/types/document/data-type/complex-type.d.ts +2 -2
- package/types/document/data-type/field-class.d.ts +3 -1
- package/types/document/data-type/mapped-type-class.d.ts +2 -2
- package/types/document/data-type/{union-type-class.d.ts → mixin-type-class.d.ts} +5 -5
- package/types/document/data-type/{union-type.d.ts → mixin-type.d.ts} +16 -16
- package/types/document/factory/type-document-factory.d.ts +5 -5
- package/types/document/index.d.ts +1 -1
- package/types/document/resource/crud-resource.d.ts +1 -1
- package/types/schema/data-type/complex-type.interface.d.ts +2 -2
- package/types/schema/data-type/data-type.interface.d.ts +3 -3
- package/types/schema/data-type/field.interface.d.ts +35 -4
- package/types/schema/data-type/mixin-type.interface.d.ts +12 -0
- package/types/schema/opra-schema.ns.d.ts +1 -1
- package/types/schema/type-guards.d.ts +2 -2
- package/cjs/schema/data-type/union-type.interface.js +0 -7
- package/esm/schema/data-type/union-type.interface.js +0 -4
- package/types/schema/data-type/union-type.interface.d.ts +0 -12
package/browser.js
CHANGED
|
@@ -871,22 +871,22 @@ __export(opra_schema_ns_exports, {
|
|
|
871
871
|
Container: () => Container,
|
|
872
872
|
EnumType: () => EnumType,
|
|
873
873
|
MappedType: () => MappedType,
|
|
874
|
+
MixinType: () => MixinType,
|
|
874
875
|
SimpleType: () => SimpleType,
|
|
875
876
|
Singleton: () => Singleton,
|
|
876
877
|
SpecVersion: () => SpecVersion,
|
|
877
878
|
Storage: () => Storage,
|
|
878
|
-
UnionType: () => UnionType,
|
|
879
879
|
isCollection: () => isCollection,
|
|
880
880
|
isComplexType: () => isComplexType,
|
|
881
881
|
isContainer: () => isContainer,
|
|
882
882
|
isDataType: () => isDataType,
|
|
883
883
|
isEnumType: () => isEnumType,
|
|
884
884
|
isMappedType: () => isMappedType,
|
|
885
|
+
isMixinType: () => isMixinType,
|
|
885
886
|
isResource: () => isResource,
|
|
886
887
|
isSimpleType: () => isSimpleType,
|
|
887
888
|
isSingleton: () => isSingleton,
|
|
888
|
-
isStorage: () => isStorage
|
|
889
|
-
isUnionType: () => isUnionType
|
|
889
|
+
isStorage: () => isStorage
|
|
890
890
|
});
|
|
891
891
|
|
|
892
892
|
// ../../build/common/esm/schema/data-type/complex-type.interface.js
|
|
@@ -913,11 +913,11 @@ var MappedType;
|
|
|
913
913
|
MappedType3.Kind = "MappedType";
|
|
914
914
|
})(MappedType || (MappedType = {}));
|
|
915
915
|
|
|
916
|
-
// ../../build/common/esm/schema/data-type/
|
|
917
|
-
var
|
|
918
|
-
(function(
|
|
919
|
-
|
|
920
|
-
})(
|
|
916
|
+
// ../../build/common/esm/schema/data-type/mixin-type.interface.js
|
|
917
|
+
var MixinType;
|
|
918
|
+
(function(MixinType3) {
|
|
919
|
+
MixinType3.Kind = "MixinType";
|
|
920
|
+
})(MixinType || (MixinType = {}));
|
|
921
921
|
|
|
922
922
|
// ../../build/common/esm/schema/resource/collection.interface.js
|
|
923
923
|
var Collection;
|
|
@@ -948,7 +948,7 @@ var SpecVersion = "1.0";
|
|
|
948
948
|
|
|
949
949
|
// ../../build/common/esm/schema/type-guards.js
|
|
950
950
|
function isDataType(obj) {
|
|
951
|
-
return obj && typeof obj === "object" && (obj.kind === ComplexType.Kind || obj.kind === EnumType.Kind || obj.kind === MappedType.Kind || obj.kind === SimpleType.Kind || obj.kind ===
|
|
951
|
+
return obj && typeof obj === "object" && (obj.kind === ComplexType.Kind || obj.kind === EnumType.Kind || obj.kind === MappedType.Kind || obj.kind === SimpleType.Kind || obj.kind === MixinType.Kind);
|
|
952
952
|
}
|
|
953
953
|
__name(isDataType, "isDataType");
|
|
954
954
|
function isComplexType(obj) {
|
|
@@ -959,10 +959,10 @@ function isSimpleType(obj) {
|
|
|
959
959
|
return obj && typeof obj === "object" && obj.kind === SimpleType.Kind;
|
|
960
960
|
}
|
|
961
961
|
__name(isSimpleType, "isSimpleType");
|
|
962
|
-
function
|
|
963
|
-
return obj && typeof obj === "object" && obj.kind ===
|
|
962
|
+
function isMixinType(obj) {
|
|
963
|
+
return obj && typeof obj === "object" && obj.kind === MixinType.Kind;
|
|
964
964
|
}
|
|
965
|
-
__name(
|
|
965
|
+
__name(isMixinType, "isMixinType");
|
|
966
966
|
function isMappedType(obj) {
|
|
967
967
|
return obj && typeof obj === "object" && obj.kind === MappedType.Kind;
|
|
968
968
|
}
|
|
@@ -1427,11 +1427,13 @@ var FieldClass = class {
|
|
|
1427
1427
|
this.default = init.default;
|
|
1428
1428
|
this.fixed = init.fixed;
|
|
1429
1429
|
this.required = init.required;
|
|
1430
|
+
this.nullish = init.nullish;
|
|
1430
1431
|
this.readonly = init.readonly;
|
|
1431
1432
|
this.writeonly = init.writeonly;
|
|
1432
1433
|
this.exclusive = init.exclusive;
|
|
1433
1434
|
this.deprecated = init.deprecated;
|
|
1434
1435
|
this.examples = init.examples;
|
|
1436
|
+
this.format = init.format;
|
|
1435
1437
|
}
|
|
1436
1438
|
exportSchema(options) {
|
|
1437
1439
|
return omitUndefined({
|
|
@@ -1441,11 +1443,13 @@ var FieldClass = class {
|
|
|
1441
1443
|
default: this.default,
|
|
1442
1444
|
fixed: this.fixed,
|
|
1443
1445
|
required: this.required,
|
|
1446
|
+
nullish: this.nullish,
|
|
1444
1447
|
readonly: this.readonly,
|
|
1445
1448
|
writeonly: this.writeonly,
|
|
1446
1449
|
exclusive: this.exclusive,
|
|
1447
1450
|
deprecated: this.deprecated,
|
|
1448
|
-
examples: this.examples
|
|
1451
|
+
examples: this.examples,
|
|
1452
|
+
format: this.format
|
|
1449
1453
|
});
|
|
1450
1454
|
}
|
|
1451
1455
|
generateCodec(codec, options) {
|
|
@@ -1507,8 +1511,8 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1507
1511
|
const own = this.own = {};
|
|
1508
1512
|
own.ctor = init.ctor;
|
|
1509
1513
|
if (init.base) {
|
|
1510
|
-
if (!(init.base.kind === "ComplexType" || init.base.kind === "MappedType" || init.base.kind === "
|
|
1511
|
-
throw new TypeError('"base" argument must be one of ComplexType or MappedType or
|
|
1514
|
+
if (!(init.base.kind === "ComplexType" || init.base.kind === "MappedType" || init.base.kind === "MixinType"))
|
|
1515
|
+
throw new TypeError('"base" argument must be one of ComplexType or MappedType or MixinType');
|
|
1512
1516
|
own.ctor = own.ctor || init.base.ctor;
|
|
1513
1517
|
}
|
|
1514
1518
|
own.additionalFields = init?.additionalFields;
|
|
@@ -2408,24 +2412,24 @@ var MappedType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
2408
2412
|
MappedType2.prototype = MappedTypeClass.prototype;
|
|
2409
2413
|
MappedType2._applyMixin = () => void 0;
|
|
2410
2414
|
|
|
2411
|
-
// ../../build/common/esm/document/data-type/
|
|
2415
|
+
// ../../build/common/esm/document/data-type/mixin-type.js
|
|
2412
2416
|
import "reflect-metadata";
|
|
2413
2417
|
import merge9 from "putil-merge";
|
|
2414
2418
|
|
|
2415
|
-
// ../../build/common/esm/document/data-type/
|
|
2416
|
-
var
|
|
2419
|
+
// ../../build/common/esm/document/data-type/mixin-type-class.js
|
|
2420
|
+
var MixinTypeClass = class extends ComplexType2 {
|
|
2417
2421
|
static {
|
|
2418
|
-
__name(this, "
|
|
2422
|
+
__name(this, "MixinTypeClass");
|
|
2419
2423
|
}
|
|
2420
2424
|
constructor(document, init) {
|
|
2421
2425
|
super(document, init);
|
|
2422
|
-
this.kind = opra_schema_ns_exports.
|
|
2426
|
+
this.kind = opra_schema_ns_exports.MixinType.Kind;
|
|
2423
2427
|
const own = this.own;
|
|
2424
2428
|
own.types = [];
|
|
2425
|
-
const
|
|
2429
|
+
const MixinType3 = Object.getPrototypeOf(this).constructor;
|
|
2426
2430
|
for (const base of init.types) {
|
|
2427
|
-
if (!(base instanceof ComplexType2 || base instanceof
|
|
2428
|
-
throw new TypeError(`${opra_schema_ns_exports.
|
|
2431
|
+
if (!(base instanceof ComplexType2 || base instanceof MixinType3 || base instanceof MappedType2))
|
|
2432
|
+
throw new TypeError(`${opra_schema_ns_exports.MixinType.Kind} shall contain ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.MixinType.Kind} of ${opra_schema_ns_exports.MappedType.Kind} types.`);
|
|
2429
2433
|
own.types.push(base);
|
|
2430
2434
|
if (base.additionalFields === true && this.additionalFields !== true) {
|
|
2431
2435
|
this.additionalFields = true;
|
|
@@ -2444,11 +2448,11 @@ var UnionTypeClass = class extends ComplexType2 {
|
|
|
2444
2448
|
}
|
|
2445
2449
|
};
|
|
2446
2450
|
|
|
2447
|
-
// ../../build/common/esm/document/data-type/
|
|
2448
|
-
var
|
|
2451
|
+
// ../../build/common/esm/document/data-type/mixin-type.js
|
|
2452
|
+
var MixinType2 = /* @__PURE__ */ __name(function(...args) {
|
|
2449
2453
|
if (this) {
|
|
2450
2454
|
const [document, init] = args;
|
|
2451
|
-
merge9(this, new
|
|
2455
|
+
merge9(this, new MixinTypeClass(document, init), { descriptor: true });
|
|
2452
2456
|
return;
|
|
2453
2457
|
}
|
|
2454
2458
|
const clasRefs = [...args].filter((x) => !!x);
|
|
@@ -2456,9 +2460,9 @@ var UnionType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
2456
2460
|
throw new TypeError("No Class has been provided");
|
|
2457
2461
|
if (clasRefs.length === 1)
|
|
2458
2462
|
return clasRefs[0];
|
|
2459
|
-
class
|
|
2463
|
+
class MixinClass {
|
|
2460
2464
|
static {
|
|
2461
|
-
__name(this, "
|
|
2465
|
+
__name(this, "MixinClass");
|
|
2462
2466
|
}
|
|
2463
2467
|
constructor() {
|
|
2464
2468
|
for (const c of clasRefs)
|
|
@@ -2466,22 +2470,22 @@ var UnionType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
2466
2470
|
}
|
|
2467
2471
|
}
|
|
2468
2472
|
const metadata = {
|
|
2469
|
-
kind: opra_schema_ns_exports.
|
|
2473
|
+
kind: opra_schema_ns_exports.MixinType.Kind,
|
|
2470
2474
|
types: []
|
|
2471
2475
|
};
|
|
2472
|
-
Reflect.defineMetadata(DATATYPE_METADATA, metadata,
|
|
2476
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, MixinClass);
|
|
2473
2477
|
for (const c of clasRefs) {
|
|
2474
2478
|
const itemMeta = Reflect.getMetadata(DATATYPE_METADATA, c);
|
|
2475
|
-
if (!(itemMeta && (itemMeta.kind === opra_schema_ns_exports.ComplexType.Kind || itemMeta.kind === opra_schema_ns_exports.
|
|
2476
|
-
throw new TypeError(`Class "${c.name}" is not a ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.
|
|
2479
|
+
if (!(itemMeta && (itemMeta.kind === opra_schema_ns_exports.ComplexType.Kind || itemMeta.kind === opra_schema_ns_exports.MixinType.Kind || itemMeta.kind === opra_schema_ns_exports.MappedType.Kind)))
|
|
2480
|
+
throw new TypeError(`Class "${c.name}" is not a ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.MixinType.Kind} or ${opra_schema_ns_exports.MappedType.Kind}`);
|
|
2477
2481
|
metadata.types.push(c);
|
|
2478
|
-
mergePrototype(
|
|
2482
|
+
mergePrototype(MixinType2.prototype, c.prototype);
|
|
2479
2483
|
}
|
|
2480
|
-
|
|
2481
|
-
return
|
|
2482
|
-
}, "
|
|
2483
|
-
|
|
2484
|
-
|
|
2484
|
+
MixinType2._applyMixin(MixinClass, ...clasRefs);
|
|
2485
|
+
return MixinClass;
|
|
2486
|
+
}, "MixinType");
|
|
2487
|
+
MixinType2.prototype = MixinTypeClass.prototype;
|
|
2488
|
+
MixinType2._applyMixin = () => void 0;
|
|
2485
2489
|
|
|
2486
2490
|
// ../../build/common/esm/document/resource/enums/metadata-mode.enum.js
|
|
2487
2491
|
var MetadataMode;
|
|
@@ -2573,6 +2577,7 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
|
|
|
2573
2577
|
return document;
|
|
2574
2578
|
}
|
|
2575
2579
|
async initDocument(init) {
|
|
2580
|
+
init.version = init.version || opra_schema_ns_exports.SpecVersion;
|
|
2576
2581
|
this.document.url = init.url;
|
|
2577
2582
|
if (init.info)
|
|
2578
2583
|
Object.assign(this.document.info, init.info);
|
|
@@ -2729,8 +2734,8 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
|
|
|
2729
2734
|
EnumType2.apply(instance, [this.document, initArguments]);
|
|
2730
2735
|
else if (initArguments.kind === "MappedType")
|
|
2731
2736
|
MappedType2.apply(instance, [this.document, initArguments]);
|
|
2732
|
-
else if (initArguments.kind === "
|
|
2733
|
-
|
|
2737
|
+
else if (initArguments.kind === "MixinType")
|
|
2738
|
+
MixinType2.apply(instance, [this.document, initArguments]);
|
|
2734
2739
|
else
|
|
2735
2740
|
throw new TypeError(`Invalid data type schema: ${String(initArguments)}`);
|
|
2736
2741
|
return instance;
|
|
@@ -2804,7 +2809,7 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
|
|
|
2804
2809
|
throw new TypeError("MappedType.type property must address to a ComplexType");
|
|
2805
2810
|
initArguments.base = dataType;
|
|
2806
2811
|
}
|
|
2807
|
-
if (initArguments.kind === "
|
|
2812
|
+
if (initArguments.kind === "MixinType") {
|
|
2808
2813
|
const oldTypes = initArguments.types;
|
|
2809
2814
|
initArguments.types = [];
|
|
2810
2815
|
for (const type of oldTypes)
|
|
@@ -2831,8 +2836,8 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
|
|
|
2831
2836
|
case opra_schema_ns_exports.SimpleType.Kind:
|
|
2832
2837
|
Object.setPrototypeOf(dataType, SimpleType2.prototype);
|
|
2833
2838
|
break;
|
|
2834
|
-
case opra_schema_ns_exports.
|
|
2835
|
-
Object.setPrototypeOf(dataType,
|
|
2839
|
+
case opra_schema_ns_exports.MixinType.Kind:
|
|
2840
|
+
Object.setPrototypeOf(dataType, MixinType2.prototype);
|
|
2836
2841
|
break;
|
|
2837
2842
|
default:
|
|
2838
2843
|
throw new TypeError(`Unknown DataType kind (${kind})`);
|
|
@@ -10411,8 +10416,11 @@ var CrudResource = class extends Resource {
|
|
|
10411
10416
|
}
|
|
10412
10417
|
}
|
|
10413
10418
|
}
|
|
10414
|
-
getOperation(
|
|
10415
|
-
|
|
10419
|
+
getOperation(operation) {
|
|
10420
|
+
const op = this.operations.get(operation);
|
|
10421
|
+
if (!op)
|
|
10422
|
+
throw new Error(`${this.name} resource does not support "${operation}" operations`);
|
|
10423
|
+
return op;
|
|
10416
10424
|
}
|
|
10417
10425
|
exportSchema(options) {
|
|
10418
10426
|
const schema = super.exportSchema(options);
|
|
@@ -10449,7 +10457,7 @@ var CollectionClass = class extends CrudResource {
|
|
|
10449
10457
|
endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
|
|
10450
10458
|
endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
|
|
10451
10459
|
endpoint.decodeInput = this.type.generateCodec("decode", {
|
|
10452
|
-
partial:
|
|
10460
|
+
partial: false,
|
|
10453
10461
|
pick: endpoint.options.inputPickFields,
|
|
10454
10462
|
omit: endpoint.options.inputOmitFields,
|
|
10455
10463
|
operation: "write",
|
|
@@ -10508,6 +10516,7 @@ var CollectionClass = class extends CrudResource {
|
|
|
10508
10516
|
endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
|
|
10509
10517
|
endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
|
|
10510
10518
|
endpoint.decodeInput = this.type.generateCodec("decode", {
|
|
10519
|
+
partial: true,
|
|
10511
10520
|
pick: endpoint.options.inputPickFields,
|
|
10512
10521
|
omit: endpoint.options.inputOmitFields,
|
|
10513
10522
|
operation: "write",
|
|
@@ -12087,6 +12096,7 @@ export {
|
|
|
12087
12096
|
MappedType2 as MappedType,
|
|
12088
12097
|
MetadataMode,
|
|
12089
12098
|
MethodNotAllowedError,
|
|
12099
|
+
MixinType2 as MixinType,
|
|
12090
12100
|
NAMESPACE_PATTERN,
|
|
12091
12101
|
NotAcceptableError,
|
|
12092
12102
|
NotFoundError,
|
|
@@ -12112,7 +12122,6 @@ export {
|
|
|
12112
12122
|
TypeDocument,
|
|
12113
12123
|
TypeDocumentFactory,
|
|
12114
12124
|
UnauthorizedError,
|
|
12115
|
-
UnionType2 as UnionType,
|
|
12116
12125
|
UnprocessableEntityError,
|
|
12117
12126
|
ValidationError,
|
|
12118
12127
|
cloneObject,
|
|
@@ -19,8 +19,8 @@ class ComplexTypeClass extends data_type_js_1.DataType {
|
|
|
19
19
|
const own = this.own = {};
|
|
20
20
|
own.ctor = init.ctor;
|
|
21
21
|
if (init.base) {
|
|
22
|
-
if (!(init.base.kind === 'ComplexType' || init.base.kind === 'MappedType' || init.base.kind === '
|
|
23
|
-
throw new TypeError('"base" argument must be one of ComplexType or MappedType or
|
|
22
|
+
if (!(init.base.kind === 'ComplexType' || init.base.kind === 'MappedType' || init.base.kind === 'MixinType'))
|
|
23
|
+
throw new TypeError('"base" argument must be one of ComplexType or MappedType or MixinType');
|
|
24
24
|
own.ctor = own.ctor || init.base.ctor;
|
|
25
25
|
}
|
|
26
26
|
own.additionalFields = init?.additionalFields;
|
|
@@ -15,11 +15,13 @@ class FieldClass {
|
|
|
15
15
|
this.default = init.default;
|
|
16
16
|
this.fixed = init.fixed;
|
|
17
17
|
this.required = init.required;
|
|
18
|
+
this.nullish = init.nullish;
|
|
18
19
|
this.readonly = init.readonly;
|
|
19
20
|
this.writeonly = init.writeonly;
|
|
20
21
|
this.exclusive = init.exclusive;
|
|
21
22
|
this.deprecated = init.deprecated;
|
|
22
23
|
this.examples = init.examples;
|
|
24
|
+
this.format = init.format;
|
|
23
25
|
}
|
|
24
26
|
exportSchema(options) {
|
|
25
27
|
return (0, index_js_1.omitUndefined)({
|
|
@@ -30,11 +32,13 @@ class FieldClass {
|
|
|
30
32
|
default: this.default,
|
|
31
33
|
fixed: this.fixed,
|
|
32
34
|
required: this.required,
|
|
35
|
+
nullish: this.nullish,
|
|
33
36
|
readonly: this.readonly,
|
|
34
37
|
writeonly: this.writeonly,
|
|
35
38
|
exclusive: this.exclusive,
|
|
36
39
|
deprecated: this.deprecated,
|
|
37
|
-
examples: this.examples
|
|
40
|
+
examples: this.examples,
|
|
41
|
+
format: this.format,
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
generateCodec(codec, options) {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MixinTypeClass = void 0;
|
|
4
4
|
const index_js_1 = require("../../schema/index.js");
|
|
5
5
|
const complex_type_js_1 = require("./complex-type.js");
|
|
6
6
|
const mapped_type_js_1 = require("./mapped-type.js");
|
|
7
|
-
class
|
|
7
|
+
class MixinTypeClass extends complex_type_js_1.ComplexType {
|
|
8
8
|
constructor(document, init) {
|
|
9
9
|
super(document, init);
|
|
10
|
-
this.kind = index_js_1.OpraSchema.
|
|
10
|
+
this.kind = index_js_1.OpraSchema.MixinType.Kind;
|
|
11
11
|
const own = this.own;
|
|
12
12
|
own.types = [];
|
|
13
|
-
const
|
|
13
|
+
const MixinType = Object.getPrototypeOf(this).constructor;
|
|
14
14
|
for (const base of init.types) {
|
|
15
|
-
if (!(base instanceof complex_type_js_1.ComplexType || base instanceof
|
|
16
|
-
throw new TypeError(`${index_js_1.OpraSchema.
|
|
17
|
-
`${index_js_1.OpraSchema.
|
|
15
|
+
if (!(base instanceof complex_type_js_1.ComplexType || base instanceof MixinType || base instanceof mapped_type_js_1.MappedType))
|
|
16
|
+
throw new TypeError(`${index_js_1.OpraSchema.MixinType.Kind} shall contain ${index_js_1.OpraSchema.ComplexType.Kind}, ` +
|
|
17
|
+
`${index_js_1.OpraSchema.MixinType.Kind} of ${index_js_1.OpraSchema.MappedType.Kind} types.`);
|
|
18
18
|
own.types.push(base);
|
|
19
19
|
if (base.additionalFields === true && this.additionalFields !== true) {
|
|
20
20
|
// @ts-ignore
|
|
@@ -35,4 +35,4 @@ class UnionTypeClass extends complex_type_js_1.ComplexType {
|
|
|
35
35
|
return out;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
exports.
|
|
38
|
+
exports.MixinTypeClass = MixinTypeClass;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MixinType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
require("reflect-metadata");
|
|
6
6
|
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
7
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
8
8
|
const index_js_2 = require("../../schema/index.js");
|
|
9
9
|
const constants_js_1 = require("../constants.js");
|
|
10
|
-
const
|
|
10
|
+
const mixin_type_class_js_1 = require("./mixin-type-class.js");
|
|
11
11
|
/**
|
|
12
|
-
* @class
|
|
12
|
+
* @class MixinType
|
|
13
13
|
*/
|
|
14
|
-
exports.
|
|
14
|
+
exports.MixinType = function (...args) {
|
|
15
15
|
// Constructor
|
|
16
16
|
if (this) {
|
|
17
17
|
const [document, init] = args;
|
|
18
|
-
(0, putil_merge_1.default)(this, new
|
|
18
|
+
(0, putil_merge_1.default)(this, new mixin_type_class_js_1.MixinTypeClass(document, init), { descriptor: true });
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
//
|
|
21
|
+
// MixinType helper
|
|
22
22
|
// Filter undefined items
|
|
23
23
|
const clasRefs = [...args].filter(x => !!x);
|
|
24
24
|
if (!clasRefs.length)
|
|
25
25
|
throw new TypeError('No Class has been provided');
|
|
26
26
|
if (clasRefs.length === 1)
|
|
27
27
|
return clasRefs[0];
|
|
28
|
-
class
|
|
28
|
+
class MixinClass {
|
|
29
29
|
constructor() {
|
|
30
30
|
for (const c of clasRefs)
|
|
31
31
|
(0, index_js_1.inheritPropertyInitializers)(this, c);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
const metadata = {
|
|
35
|
-
kind: index_js_2.OpraSchema.
|
|
35
|
+
kind: index_js_2.OpraSchema.MixinType.Kind,
|
|
36
36
|
types: []
|
|
37
37
|
};
|
|
38
|
-
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata,
|
|
38
|
+
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, MixinClass);
|
|
39
39
|
for (const c of clasRefs) {
|
|
40
40
|
const itemMeta = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, c);
|
|
41
|
-
if (!(itemMeta && (itemMeta.kind === index_js_2.OpraSchema.ComplexType.Kind || itemMeta.kind === index_js_2.OpraSchema.
|
|
41
|
+
if (!(itemMeta && (itemMeta.kind === index_js_2.OpraSchema.ComplexType.Kind || itemMeta.kind === index_js_2.OpraSchema.MixinType.Kind ||
|
|
42
42
|
itemMeta.kind === index_js_2.OpraSchema.MappedType.Kind)))
|
|
43
|
-
throw new TypeError(`Class "${c.name}" is not a ${index_js_2.OpraSchema.ComplexType.Kind}, ${index_js_2.OpraSchema.
|
|
43
|
+
throw new TypeError(`Class "${c.name}" is not a ${index_js_2.OpraSchema.ComplexType.Kind}, ${index_js_2.OpraSchema.MixinType.Kind} or ${index_js_2.OpraSchema.MappedType.Kind}`);
|
|
44
44
|
metadata.types.push(c);
|
|
45
|
-
(0, index_js_1.mergePrototype)(
|
|
45
|
+
(0, index_js_1.mergePrototype)(exports.MixinType.prototype, c.prototype);
|
|
46
46
|
}
|
|
47
|
-
exports.
|
|
48
|
-
return
|
|
47
|
+
exports.MixinType._applyMixin(MixinClass, ...clasRefs);
|
|
48
|
+
return MixinClass;
|
|
49
49
|
};
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
50
|
+
exports.MixinType.prototype = mixin_type_class_js_1.MixinTypeClass.prototype;
|
|
51
|
+
exports.MixinType._applyMixin = () => void 0;
|
|
@@ -9,8 +9,8 @@ const index_js_3 = require("../data-type/builtin/index.js");
|
|
|
9
9
|
const complex_type_js_1 = require("../data-type/complex-type.js");
|
|
10
10
|
const enum_type_js_1 = require("../data-type/enum-type.js");
|
|
11
11
|
const mapped_type_js_1 = require("../data-type/mapped-type.js");
|
|
12
|
+
const mixin_type_js_1 = require("../data-type/mixin-type.js");
|
|
12
13
|
const simple_type_js_1 = require("../data-type/simple-type.js");
|
|
13
|
-
const union_type_js_1 = require("../data-type/union-type.js");
|
|
14
14
|
const metadata_mode_enum_js_1 = require("../resource/enums/metadata-mode.enum.js");
|
|
15
15
|
const operation_result_type_js_1 = require("../resource/types/operation-result.type.js");
|
|
16
16
|
const type_document_js_1 = require("../type-document.js");
|
|
@@ -43,6 +43,7 @@ class TypeDocumentFactory {
|
|
|
43
43
|
return document;
|
|
44
44
|
}
|
|
45
45
|
async initDocument(init) {
|
|
46
|
+
init.version = init.version || index_js_2.OpraSchema.SpecVersion;
|
|
46
47
|
this.document.url = init.url;
|
|
47
48
|
if (init.info)
|
|
48
49
|
Object.assign(this.document.info, init.info);
|
|
@@ -200,8 +201,8 @@ class TypeDocumentFactory {
|
|
|
200
201
|
enum_type_js_1.EnumType.apply(instance, [this.document, initArguments]);
|
|
201
202
|
else if (initArguments.kind === 'MappedType')
|
|
202
203
|
mapped_type_js_1.MappedType.apply(instance, [this.document, initArguments]);
|
|
203
|
-
else if (initArguments.kind === '
|
|
204
|
-
|
|
204
|
+
else if (initArguments.kind === 'MixinType')
|
|
205
|
+
mixin_type_js_1.MixinType.apply(instance, [this.document, initArguments]);
|
|
205
206
|
else
|
|
206
207
|
throw new TypeError(`Invalid data type schema: ${String(initArguments)}`);
|
|
207
208
|
return instance;
|
|
@@ -285,7 +286,7 @@ class TypeDocumentFactory {
|
|
|
285
286
|
throw new TypeError('MappedType.type property must address to a ComplexType');
|
|
286
287
|
initArguments.base = dataType;
|
|
287
288
|
}
|
|
288
|
-
if (initArguments.kind === '
|
|
289
|
+
if (initArguments.kind === 'MixinType') {
|
|
289
290
|
const oldTypes = initArguments.types;
|
|
290
291
|
initArguments.types = [];
|
|
291
292
|
for (const type of oldTypes)
|
|
@@ -312,8 +313,8 @@ class TypeDocumentFactory {
|
|
|
312
313
|
case index_js_2.OpraSchema.SimpleType.Kind:
|
|
313
314
|
Object.setPrototypeOf(dataType, simple_type_js_1.SimpleType.prototype);
|
|
314
315
|
break;
|
|
315
|
-
case index_js_2.OpraSchema.
|
|
316
|
-
Object.setPrototypeOf(dataType,
|
|
316
|
+
case index_js_2.OpraSchema.MixinType.Kind:
|
|
317
|
+
Object.setPrototypeOf(dataType, mixin_type_js_1.MixinType.prototype);
|
|
317
318
|
break;
|
|
318
319
|
default:
|
|
319
320
|
throw new TypeError(`Unknown DataType kind (${kind})`);
|
package/cjs/document/index.js
CHANGED
|
@@ -13,7 +13,7 @@ tslib_1.__exportStar(require("./data-type/field.js"), exports);
|
|
|
13
13
|
tslib_1.__exportStar(require("./data-type/enum-type.js"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./data-type/mapped-type.js"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./data-type/simple-type.js"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./data-type/
|
|
16
|
+
tslib_1.__exportStar(require("./data-type/mixin-type.js"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./resource/action.js"), exports);
|
|
18
18
|
tslib_1.__exportStar(require("./resource/collection.js"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./resource/container.js"), exports);
|
|
@@ -33,7 +33,7 @@ class CollectionClass extends crud_resource_js_1.CrudResource {
|
|
|
33
33
|
endpoint.defineParameter('omit', { type: 'string', isArray: true, isBuiltin: true });
|
|
34
34
|
endpoint.defineParameter('include', { type: 'string', isArray: true, isBuiltin: true });
|
|
35
35
|
endpoint.decodeInput = this.type.generateCodec('decode', {
|
|
36
|
-
partial:
|
|
36
|
+
partial: false,
|
|
37
37
|
pick: endpoint.options.inputPickFields,
|
|
38
38
|
omit: endpoint.options.inputOmitFields,
|
|
39
39
|
operation: 'write',
|
|
@@ -100,6 +100,7 @@ class CollectionClass extends crud_resource_js_1.CrudResource {
|
|
|
100
100
|
endpoint.defineParameter('omit', { type: 'string', isArray: true, isBuiltin: true });
|
|
101
101
|
endpoint.defineParameter('include', { type: 'string', isArray: true, isBuiltin: true });
|
|
102
102
|
endpoint.decodeInput = this.type.generateCodec('decode', {
|
|
103
|
+
partial: true,
|
|
103
104
|
pick: endpoint.options.inputPickFields,
|
|
104
105
|
omit: endpoint.options.inputOmitFields,
|
|
105
106
|
operation: 'write',
|
|
@@ -14,8 +14,11 @@ class CrudResource extends resource_js_1.Resource {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
getOperation(
|
|
18
|
-
|
|
17
|
+
getOperation(operation) {
|
|
18
|
+
const op = this.operations.get(operation);
|
|
19
|
+
if (!op)
|
|
20
|
+
throw new Error(`${this.name} resource does not support "${operation}" operations`);
|
|
21
|
+
return op;
|
|
19
22
|
}
|
|
20
23
|
exportSchema(options) {
|
|
21
24
|
const schema = super.exportSchema(options);
|
|
@@ -7,7 +7,7 @@ tslib_1.__exportStar(require("./data-type/enum-type.interface.js"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./data-type/field.interface.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./data-type/simple-type.interface.js"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./data-type/mapped-type.interface.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./data-type/
|
|
10
|
+
tslib_1.__exportStar(require("./data-type/mixin-type.interface.js"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./resource/action.interface.js"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./resource/endpoint.interface.js"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./resource/collection.interface.js"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isContainer = exports.isStorage = exports.isSingleton = exports.isCollection = exports.isResource = exports.isEnumType = exports.isMappedType = exports.
|
|
3
|
+
exports.isContainer = exports.isStorage = exports.isSingleton = exports.isCollection = exports.isResource = exports.isEnumType = exports.isMappedType = exports.isMixinType = exports.isSimpleType = exports.isComplexType = exports.isDataType = void 0;
|
|
4
4
|
const complex_type_interface_js_1 = require("./data-type/complex-type.interface.js");
|
|
5
5
|
const enum_type_interface_js_1 = require("./data-type/enum-type.interface.js");
|
|
6
6
|
const mapped_type_interface_js_1 = require("./data-type/mapped-type.interface.js");
|
|
7
|
+
const mixin_type_interface_js_1 = require("./data-type/mixin-type.interface.js");
|
|
7
8
|
const simple_type_interface_js_1 = require("./data-type/simple-type.interface.js");
|
|
8
|
-
const union_type_interface_js_1 = require("./data-type/union-type.interface.js");
|
|
9
9
|
const collection_interface_js_1 = require("./resource/collection.interface.js");
|
|
10
10
|
const container_interface_js_1 = require("./resource/container.interface.js");
|
|
11
11
|
const singleton_interface_js_1 = require("./resource/singleton.interface.js");
|
|
@@ -16,7 +16,7 @@ function isDataType(obj) {
|
|
|
16
16
|
obj.kind === enum_type_interface_js_1.EnumType.Kind ||
|
|
17
17
|
obj.kind === mapped_type_interface_js_1.MappedType.Kind ||
|
|
18
18
|
obj.kind === simple_type_interface_js_1.SimpleType.Kind ||
|
|
19
|
-
obj.kind ===
|
|
19
|
+
obj.kind === mixin_type_interface_js_1.MixinType.Kind);
|
|
20
20
|
}
|
|
21
21
|
exports.isDataType = isDataType;
|
|
22
22
|
function isComplexType(obj) {
|
|
@@ -27,10 +27,10 @@ function isSimpleType(obj) {
|
|
|
27
27
|
return obj && typeof obj === 'object' && obj.kind === simple_type_interface_js_1.SimpleType.Kind;
|
|
28
28
|
}
|
|
29
29
|
exports.isSimpleType = isSimpleType;
|
|
30
|
-
function
|
|
31
|
-
return obj && typeof obj === 'object' && obj.kind ===
|
|
30
|
+
function isMixinType(obj) {
|
|
31
|
+
return obj && typeof obj === 'object' && obj.kind === mixin_type_interface_js_1.MixinType.Kind;
|
|
32
32
|
}
|
|
33
|
-
exports.
|
|
33
|
+
exports.isMixinType = isMixinType;
|
|
34
34
|
function isMappedType(obj) {
|
|
35
35
|
return obj && typeof obj === 'object' && obj.kind === mapped_type_interface_js_1.MappedType.Kind;
|
|
36
36
|
}
|
|
@@ -15,8 +15,8 @@ export class ComplexTypeClass extends DataType {
|
|
|
15
15
|
const own = this.own = {};
|
|
16
16
|
own.ctor = init.ctor;
|
|
17
17
|
if (init.base) {
|
|
18
|
-
if (!(init.base.kind === 'ComplexType' || init.base.kind === 'MappedType' || init.base.kind === '
|
|
19
|
-
throw new TypeError('"base" argument must be one of ComplexType or MappedType or
|
|
18
|
+
if (!(init.base.kind === 'ComplexType' || init.base.kind === 'MappedType' || init.base.kind === 'MixinType'))
|
|
19
|
+
throw new TypeError('"base" argument must be one of ComplexType or MappedType or MixinType');
|
|
20
20
|
own.ctor = own.ctor || init.base.ctor;
|
|
21
21
|
}
|
|
22
22
|
own.additionalFields = init?.additionalFields;
|
|
@@ -11,11 +11,13 @@ export class FieldClass {
|
|
|
11
11
|
this.default = init.default;
|
|
12
12
|
this.fixed = init.fixed;
|
|
13
13
|
this.required = init.required;
|
|
14
|
+
this.nullish = init.nullish;
|
|
14
15
|
this.readonly = init.readonly;
|
|
15
16
|
this.writeonly = init.writeonly;
|
|
16
17
|
this.exclusive = init.exclusive;
|
|
17
18
|
this.deprecated = init.deprecated;
|
|
18
19
|
this.examples = init.examples;
|
|
20
|
+
this.format = init.format;
|
|
19
21
|
}
|
|
20
22
|
exportSchema(options) {
|
|
21
23
|
return omitUndefined({
|
|
@@ -26,11 +28,13 @@ export class FieldClass {
|
|
|
26
28
|
default: this.default,
|
|
27
29
|
fixed: this.fixed,
|
|
28
30
|
required: this.required,
|
|
31
|
+
nullish: this.nullish,
|
|
29
32
|
readonly: this.readonly,
|
|
30
33
|
writeonly: this.writeonly,
|
|
31
34
|
exclusive: this.exclusive,
|
|
32
35
|
deprecated: this.deprecated,
|
|
33
|
-
examples: this.examples
|
|
36
|
+
examples: this.examples,
|
|
37
|
+
format: this.format,
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
generateCodec(codec, options) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { OpraSchema } from '../../schema/index.js';
|
|
2
2
|
import { ComplexType } from './complex-type.js';
|
|
3
3
|
import { MappedType } from './mapped-type.js';
|
|
4
|
-
export class
|
|
4
|
+
export class MixinTypeClass extends ComplexType {
|
|
5
5
|
constructor(document, init) {
|
|
6
6
|
super(document, init);
|
|
7
|
-
this.kind = OpraSchema.
|
|
7
|
+
this.kind = OpraSchema.MixinType.Kind;
|
|
8
8
|
const own = this.own;
|
|
9
9
|
own.types = [];
|
|
10
|
-
const
|
|
10
|
+
const MixinType = Object.getPrototypeOf(this).constructor;
|
|
11
11
|
for (const base of init.types) {
|
|
12
|
-
if (!(base instanceof ComplexType || base instanceof
|
|
13
|
-
throw new TypeError(`${OpraSchema.
|
|
14
|
-
`${OpraSchema.
|
|
12
|
+
if (!(base instanceof ComplexType || base instanceof MixinType || base instanceof MappedType))
|
|
13
|
+
throw new TypeError(`${OpraSchema.MixinType.Kind} shall contain ${OpraSchema.ComplexType.Kind}, ` +
|
|
14
|
+
`${OpraSchema.MixinType.Kind} of ${OpraSchema.MappedType.Kind} types.`);
|
|
15
15
|
own.types.push(base);
|
|
16
16
|
if (base.additionalFields === true && this.additionalFields !== true) {
|
|
17
17
|
// @ts-ignore
|
|
@@ -3,45 +3,45 @@ import merge from 'putil-merge';
|
|
|
3
3
|
import { inheritPropertyInitializers, mergePrototype, } from '../../helpers/index.js';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import { DATATYPE_METADATA } from '../constants.js';
|
|
6
|
-
import {
|
|
6
|
+
import { MixinTypeClass } from './mixin-type-class.js';
|
|
7
7
|
/**
|
|
8
|
-
* @class
|
|
8
|
+
* @class MixinType
|
|
9
9
|
*/
|
|
10
|
-
export const
|
|
10
|
+
export const MixinType = function (...args) {
|
|
11
11
|
// Constructor
|
|
12
12
|
if (this) {
|
|
13
13
|
const [document, init] = args;
|
|
14
|
-
merge(this, new
|
|
14
|
+
merge(this, new MixinTypeClass(document, init), { descriptor: true });
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
//
|
|
17
|
+
// MixinType helper
|
|
18
18
|
// Filter undefined items
|
|
19
19
|
const clasRefs = [...args].filter(x => !!x);
|
|
20
20
|
if (!clasRefs.length)
|
|
21
21
|
throw new TypeError('No Class has been provided');
|
|
22
22
|
if (clasRefs.length === 1)
|
|
23
23
|
return clasRefs[0];
|
|
24
|
-
class
|
|
24
|
+
class MixinClass {
|
|
25
25
|
constructor() {
|
|
26
26
|
for (const c of clasRefs)
|
|
27
27
|
inheritPropertyInitializers(this, c);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
const metadata = {
|
|
31
|
-
kind: OpraSchema.
|
|
31
|
+
kind: OpraSchema.MixinType.Kind,
|
|
32
32
|
types: []
|
|
33
33
|
};
|
|
34
|
-
Reflect.defineMetadata(DATATYPE_METADATA, metadata,
|
|
34
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, MixinClass);
|
|
35
35
|
for (const c of clasRefs) {
|
|
36
36
|
const itemMeta = Reflect.getMetadata(DATATYPE_METADATA, c);
|
|
37
|
-
if (!(itemMeta && (itemMeta.kind === OpraSchema.ComplexType.Kind || itemMeta.kind === OpraSchema.
|
|
37
|
+
if (!(itemMeta && (itemMeta.kind === OpraSchema.ComplexType.Kind || itemMeta.kind === OpraSchema.MixinType.Kind ||
|
|
38
38
|
itemMeta.kind === OpraSchema.MappedType.Kind)))
|
|
39
|
-
throw new TypeError(`Class "${c.name}" is not a ${OpraSchema.ComplexType.Kind}, ${OpraSchema.
|
|
39
|
+
throw new TypeError(`Class "${c.name}" is not a ${OpraSchema.ComplexType.Kind}, ${OpraSchema.MixinType.Kind} or ${OpraSchema.MappedType.Kind}`);
|
|
40
40
|
metadata.types.push(c);
|
|
41
|
-
mergePrototype(
|
|
41
|
+
mergePrototype(MixinType.prototype, c.prototype);
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
return
|
|
43
|
+
MixinType._applyMixin(MixinClass, ...clasRefs);
|
|
44
|
+
return MixinClass;
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
MixinType.prototype = MixinTypeClass.prototype;
|
|
47
|
+
MixinType._applyMixin = () => void 0;
|
|
@@ -6,8 +6,8 @@ import { AnyType, Base64Type, BigintType, BooleanType, DateType, IntegerType, Nu
|
|
|
6
6
|
import { ComplexType } from '../data-type/complex-type.js';
|
|
7
7
|
import { EnumType } from '../data-type/enum-type.js';
|
|
8
8
|
import { MappedType } from '../data-type/mapped-type.js';
|
|
9
|
+
import { MixinType } from '../data-type/mixin-type.js';
|
|
9
10
|
import { SimpleType } from '../data-type/simple-type.js';
|
|
10
|
-
import { UnionType } from '../data-type/union-type.js';
|
|
11
11
|
import { MetadataMode } from '../resource/enums/metadata-mode.enum.js';
|
|
12
12
|
import { OperationResult } from '../resource/types/operation-result.type.js';
|
|
13
13
|
import { TypeDocument } from '../type-document.js';
|
|
@@ -40,6 +40,7 @@ export class TypeDocumentFactory {
|
|
|
40
40
|
return document;
|
|
41
41
|
}
|
|
42
42
|
async initDocument(init) {
|
|
43
|
+
init.version = init.version || OpraSchema.SpecVersion;
|
|
43
44
|
this.document.url = init.url;
|
|
44
45
|
if (init.info)
|
|
45
46
|
Object.assign(this.document.info, init.info);
|
|
@@ -197,8 +198,8 @@ export class TypeDocumentFactory {
|
|
|
197
198
|
EnumType.apply(instance, [this.document, initArguments]);
|
|
198
199
|
else if (initArguments.kind === 'MappedType')
|
|
199
200
|
MappedType.apply(instance, [this.document, initArguments]);
|
|
200
|
-
else if (initArguments.kind === '
|
|
201
|
-
|
|
201
|
+
else if (initArguments.kind === 'MixinType')
|
|
202
|
+
MixinType.apply(instance, [this.document, initArguments]);
|
|
202
203
|
else
|
|
203
204
|
throw new TypeError(`Invalid data type schema: ${String(initArguments)}`);
|
|
204
205
|
return instance;
|
|
@@ -282,7 +283,7 @@ export class TypeDocumentFactory {
|
|
|
282
283
|
throw new TypeError('MappedType.type property must address to a ComplexType');
|
|
283
284
|
initArguments.base = dataType;
|
|
284
285
|
}
|
|
285
|
-
if (initArguments.kind === '
|
|
286
|
+
if (initArguments.kind === 'MixinType') {
|
|
286
287
|
const oldTypes = initArguments.types;
|
|
287
288
|
initArguments.types = [];
|
|
288
289
|
for (const type of oldTypes)
|
|
@@ -309,8 +310,8 @@ export class TypeDocumentFactory {
|
|
|
309
310
|
case OpraSchema.SimpleType.Kind:
|
|
310
311
|
Object.setPrototypeOf(dataType, SimpleType.prototype);
|
|
311
312
|
break;
|
|
312
|
-
case OpraSchema.
|
|
313
|
-
Object.setPrototypeOf(dataType,
|
|
313
|
+
case OpraSchema.MixinType.Kind:
|
|
314
|
+
Object.setPrototypeOf(dataType, MixinType.prototype);
|
|
314
315
|
break;
|
|
315
316
|
default:
|
|
316
317
|
throw new TypeError(`Unknown DataType kind (${kind})`);
|
package/esm/document/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export * from './data-type/field.js';
|
|
|
10
10
|
export * from './data-type/enum-type.js';
|
|
11
11
|
export * from './data-type/mapped-type.js';
|
|
12
12
|
export * from './data-type/simple-type.js';
|
|
13
|
-
export * from './data-type/
|
|
13
|
+
export * from './data-type/mixin-type.js';
|
|
14
14
|
export * from './resource/action.js';
|
|
15
15
|
export * from './resource/collection.js';
|
|
16
16
|
export * from './resource/container.js';
|
|
@@ -29,7 +29,7 @@ export class CollectionClass extends CrudResource {
|
|
|
29
29
|
endpoint.defineParameter('omit', { type: 'string', isArray: true, isBuiltin: true });
|
|
30
30
|
endpoint.defineParameter('include', { type: 'string', isArray: true, isBuiltin: true });
|
|
31
31
|
endpoint.decodeInput = this.type.generateCodec('decode', {
|
|
32
|
-
partial:
|
|
32
|
+
partial: false,
|
|
33
33
|
pick: endpoint.options.inputPickFields,
|
|
34
34
|
omit: endpoint.options.inputOmitFields,
|
|
35
35
|
operation: 'write',
|
|
@@ -96,6 +96,7 @@ export class CollectionClass extends CrudResource {
|
|
|
96
96
|
endpoint.defineParameter('omit', { type: 'string', isArray: true, isBuiltin: true });
|
|
97
97
|
endpoint.defineParameter('include', { type: 'string', isArray: true, isBuiltin: true });
|
|
98
98
|
endpoint.decodeInput = this.type.generateCodec('decode', {
|
|
99
|
+
partial: true,
|
|
99
100
|
pick: endpoint.options.inputPickFields,
|
|
100
101
|
omit: endpoint.options.inputOmitFields,
|
|
101
102
|
operation: 'write',
|
|
@@ -11,8 +11,11 @@ export class CrudResource extends Resource {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
getOperation(
|
|
15
|
-
|
|
14
|
+
getOperation(operation) {
|
|
15
|
+
const op = this.operations.get(operation);
|
|
16
|
+
if (!op)
|
|
17
|
+
throw new Error(`${this.name} resource does not support "${operation}" operations`);
|
|
18
|
+
return op;
|
|
16
19
|
}
|
|
17
20
|
exportSchema(options) {
|
|
18
21
|
const schema = super.exportSchema(options);
|
|
@@ -4,7 +4,7 @@ export * from './data-type/enum-type.interface.js';
|
|
|
4
4
|
export * from './data-type/field.interface.js';
|
|
5
5
|
export * from './data-type/simple-type.interface.js';
|
|
6
6
|
export * from './data-type/mapped-type.interface.js';
|
|
7
|
-
export * from './data-type/
|
|
7
|
+
export * from './data-type/mixin-type.interface.js';
|
|
8
8
|
export * from './resource/action.interface.js';
|
|
9
9
|
export * from './resource/endpoint.interface.js';
|
|
10
10
|
export * from './resource/collection.interface.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ComplexType } from './data-type/complex-type.interface.js';
|
|
2
2
|
import { EnumType } from './data-type/enum-type.interface.js';
|
|
3
3
|
import { MappedType } from './data-type/mapped-type.interface.js';
|
|
4
|
+
import { MixinType } from './data-type/mixin-type.interface.js';
|
|
4
5
|
import { SimpleType } from './data-type/simple-type.interface.js';
|
|
5
|
-
import { UnionType } from './data-type/union-type.interface.js';
|
|
6
6
|
import { Collection } from './resource/collection.interface.js';
|
|
7
7
|
import { Container } from './resource/container.interface.js';
|
|
8
8
|
import { Singleton } from './resource/singleton.interface.js';
|
|
@@ -13,7 +13,7 @@ export function isDataType(obj) {
|
|
|
13
13
|
obj.kind === EnumType.Kind ||
|
|
14
14
|
obj.kind === MappedType.Kind ||
|
|
15
15
|
obj.kind === SimpleType.Kind ||
|
|
16
|
-
obj.kind ===
|
|
16
|
+
obj.kind === MixinType.Kind);
|
|
17
17
|
}
|
|
18
18
|
export function isComplexType(obj) {
|
|
19
19
|
return obj && typeof obj === 'object' && obj.kind === ComplexType.Kind;
|
|
@@ -21,8 +21,8 @@ export function isComplexType(obj) {
|
|
|
21
21
|
export function isSimpleType(obj) {
|
|
22
22
|
return obj && typeof obj === 'object' && obj.kind === SimpleType.Kind;
|
|
23
23
|
}
|
|
24
|
-
export function
|
|
25
|
-
return obj && typeof obj === 'object' && obj.kind ===
|
|
24
|
+
export function isMixinType(obj) {
|
|
25
|
+
return obj && typeof obj === 'object' && obj.kind === MixinType.Kind;
|
|
26
26
|
}
|
|
27
27
|
export function isMappedType(obj) {
|
|
28
28
|
return obj && typeof obj === 'object' && obj.kind === MappedType.Kind;
|
package/package.json
CHANGED
|
@@ -7,14 +7,14 @@ import type { ComplexType } from './complex-type.js';
|
|
|
7
7
|
import { DataType } from './data-type.js';
|
|
8
8
|
import { ApiField } from './field.js';
|
|
9
9
|
import type { MappedType } from './mapped-type.js';
|
|
10
|
-
import type {
|
|
10
|
+
import type { MixinType } from './mixin-type.js';
|
|
11
11
|
/**
|
|
12
12
|
* @class ComplexType
|
|
13
13
|
*/
|
|
14
14
|
export declare class ComplexTypeClass extends DataType {
|
|
15
15
|
readonly kind: OpraSchema.DataType.Kind;
|
|
16
16
|
readonly ctor: Type;
|
|
17
|
-
readonly base?: ComplexType |
|
|
17
|
+
readonly base?: ComplexType | MixinType | MappedType;
|
|
18
18
|
readonly own: ComplexType.OwnProperties;
|
|
19
19
|
readonly fields: ResponsiveMap<ApiField>;
|
|
20
20
|
readonly abstract?: boolean;
|
|
@@ -8,7 +8,7 @@ import { ComplexTypeClass } from './complex-type-class.js';
|
|
|
8
8
|
import { DataType } from './data-type.js';
|
|
9
9
|
import { ApiField } from './field.js';
|
|
10
10
|
import type { MappedType } from './mapped-type.js';
|
|
11
|
-
import type {
|
|
11
|
+
import type { MixinType } from './mixin-type.js';
|
|
12
12
|
/**
|
|
13
13
|
* Callable class pattern for ComplexType
|
|
14
14
|
*/
|
|
@@ -29,7 +29,7 @@ export declare const ComplexType: ComplexTypeConstructor;
|
|
|
29
29
|
*/
|
|
30
30
|
export declare namespace ComplexType {
|
|
31
31
|
interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.ComplexType, 'ctor' | 'abstract'> {
|
|
32
|
-
base?: ComplexType | MappedType |
|
|
32
|
+
base?: ComplexType | MappedType | MixinType;
|
|
33
33
|
fields?: Record<string, ApiField.InitArguments>;
|
|
34
34
|
additionalFields?: boolean | DataType | 'error';
|
|
35
35
|
}
|
|
@@ -11,13 +11,15 @@ export declare class FieldClass {
|
|
|
11
11
|
description?: string;
|
|
12
12
|
isArray?: boolean;
|
|
13
13
|
default?: any;
|
|
14
|
-
fixed?: string | number;
|
|
14
|
+
fixed?: string | number | boolean;
|
|
15
15
|
required?: boolean;
|
|
16
|
+
nullish?: boolean;
|
|
16
17
|
readonly?: boolean;
|
|
17
18
|
writeonly?: boolean;
|
|
18
19
|
exclusive?: boolean;
|
|
19
20
|
deprecated?: boolean | string;
|
|
20
21
|
examples?: any[] | Record<string, any>;
|
|
22
|
+
format?: string;
|
|
21
23
|
constructor(owner: ComplexType, init: ApiField.InitArguments);
|
|
22
24
|
exportSchema(options?: {
|
|
23
25
|
webSafe?: boolean;
|
|
@@ -4,11 +4,11 @@ import type { ApiDocument } from '../api-document.js';
|
|
|
4
4
|
import type { ComplexType } from './complex-type.js';
|
|
5
5
|
import { ComplexTypeClass } from './complex-type-class.js';
|
|
6
6
|
import type { MappedType } from './mapped-type.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { MixinType } from './mixin-type';
|
|
8
8
|
export declare class MappedTypeClass extends ComplexTypeClass {
|
|
9
9
|
readonly kind: OpraSchema.DataType.Kind;
|
|
10
10
|
readonly own: MappedType.OwnProperties;
|
|
11
|
-
readonly base: ComplexType |
|
|
11
|
+
readonly base: ComplexType | MixinType | MappedType;
|
|
12
12
|
readonly omit?: Field.Name[];
|
|
13
13
|
readonly pick?: Field.Name[];
|
|
14
14
|
constructor(document: ApiDocument, init: MappedType.InitArguments);
|
|
@@ -2,11 +2,11 @@ import { OpraSchema } from '../../schema/index.js';
|
|
|
2
2
|
import type { ApiDocument } from '../api-document.js';
|
|
3
3
|
import { ComplexType } from './complex-type.js';
|
|
4
4
|
import { MappedType } from './mapped-type.js';
|
|
5
|
-
import type {
|
|
6
|
-
export declare class
|
|
5
|
+
import type { MixinType } from './mixin-type';
|
|
6
|
+
export declare class MixinTypeClass extends ComplexType {
|
|
7
7
|
readonly kind: OpraSchema.DataType.Kind;
|
|
8
|
-
readonly own:
|
|
9
|
-
readonly types: (ComplexType |
|
|
10
|
-
constructor(document: ApiDocument, init:
|
|
8
|
+
readonly own: MixinType.OwnProperties;
|
|
9
|
+
readonly types: (ComplexType | MixinType | MappedType)[];
|
|
10
|
+
constructor(document: ApiDocument, init: MixinType.InitArguments);
|
|
11
11
|
exportSchema(): any;
|
|
12
12
|
}
|
|
@@ -4,40 +4,40 @@ import { OpraSchema } from '../../schema/index.js';
|
|
|
4
4
|
import type { ApiDocument } from '../api-document.js';
|
|
5
5
|
import { ComplexType } from './complex-type.js';
|
|
6
6
|
import { MappedType } from './mapped-type.js';
|
|
7
|
-
import {
|
|
7
|
+
import { MixinTypeClass } from './mixin-type-class.js';
|
|
8
8
|
/**
|
|
9
|
-
* Type definition of
|
|
10
|
-
* @type
|
|
9
|
+
* Type definition of MixinType constructor type
|
|
10
|
+
* @type MixinTypeConstructor
|
|
11
11
|
*/
|
|
12
|
-
export interface
|
|
13
|
-
prototype:
|
|
14
|
-
new (document: ApiDocument, init:
|
|
12
|
+
export interface MixinTypeConstructor {
|
|
13
|
+
prototype: MixinType;
|
|
14
|
+
new (document: ApiDocument, init: MixinType.InitArguments): MixinType;
|
|
15
15
|
<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3?: Class<A3, I3, S3>, c4?: Class<A4, I4, S4>): Class<any[], I1 & I2 & I3 & I4, S1 & S2 & S3 & S4>;
|
|
16
16
|
_applyMixin(target: Type, ...sources: [Type]): void;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Type definition of
|
|
20
|
-
* @type
|
|
19
|
+
* Type definition of MixinType prototype
|
|
20
|
+
* @type MixinType
|
|
21
21
|
*/
|
|
22
|
-
export interface
|
|
22
|
+
export interface MixinType extends MixinTypeClass {
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* @class
|
|
25
|
+
* @class MixinType
|
|
26
26
|
*/
|
|
27
|
-
export declare const
|
|
27
|
+
export declare const MixinType: MixinTypeConstructor;
|
|
28
28
|
/**
|
|
29
|
-
* @namespace
|
|
29
|
+
* @namespace MixinType
|
|
30
30
|
*/
|
|
31
|
-
export declare namespace
|
|
31
|
+
export declare namespace MixinType {
|
|
32
32
|
interface InitArguments extends ComplexType.InitArguments {
|
|
33
|
-
types: (ComplexType |
|
|
33
|
+
types: (ComplexType | MixinType | MappedType)[];
|
|
34
34
|
}
|
|
35
35
|
interface Metadata extends StrictOmit<ComplexType.Metadata, 'kind' | 'base' | 'name'> {
|
|
36
|
-
kind: OpraSchema.
|
|
36
|
+
kind: OpraSchema.MixinType.Kind;
|
|
37
37
|
base?: Type;
|
|
38
38
|
types: Type[];
|
|
39
39
|
}
|
|
40
40
|
interface OwnProperties extends ComplexType.OwnProperties {
|
|
41
|
-
types: (ComplexType |
|
|
41
|
+
types: (ComplexType | MixinType | MappedType)[];
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StrictOmit, Type } from 'ts-gems';
|
|
1
|
+
import { PartialSome, StrictOmit, Type } from 'ts-gems';
|
|
2
2
|
import { ResponsiveMap } from '../../helpers/index.js';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import { ThunkAsync } from '../../types.js';
|
|
@@ -7,11 +7,11 @@ import { ComplexType } from '../data-type/complex-type.js';
|
|
|
7
7
|
import { DataType } from '../data-type/data-type.js';
|
|
8
8
|
import { EnumType } from '../data-type/enum-type.js';
|
|
9
9
|
import { MappedType } from '../data-type/mapped-type.js';
|
|
10
|
+
import { MixinType } from '../data-type/mixin-type.js';
|
|
10
11
|
import { SimpleType } from '../data-type/simple-type.js';
|
|
11
|
-
import { UnionType } from '../data-type/union-type.js';
|
|
12
12
|
import { TypeDocument } from '../type-document.js';
|
|
13
13
|
export declare namespace TypeDocumentFactory {
|
|
14
|
-
interface InitArguments extends StrictOmit<OpraSchema.TypeDocument, 'references' | 'types'> {
|
|
14
|
+
interface InitArguments extends PartialSome<StrictOmit<OpraSchema.TypeDocument, 'references' | 'types'>, 'version'> {
|
|
15
15
|
references?: Record<string, string | OpraSchema.ApiDocument | ApiDocument>;
|
|
16
16
|
types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[] | Record<string, OpraSchema.DataType>;
|
|
17
17
|
noBuiltinTypes?: boolean;
|
|
@@ -20,8 +20,8 @@ export declare namespace TypeDocumentFactory {
|
|
|
20
20
|
kind: OpraSchema.ComplexType.Kind;
|
|
21
21
|
}) | (SimpleType.InitArguments & {
|
|
22
22
|
kind: OpraSchema.SimpleType.Kind;
|
|
23
|
-
}) | (
|
|
24
|
-
kind: OpraSchema.
|
|
23
|
+
}) | (MixinType.InitArguments & {
|
|
24
|
+
kind: OpraSchema.MixinType.Kind;
|
|
25
25
|
}) | (MappedType.InitArguments & {
|
|
26
26
|
kind: OpraSchema.MappedType.Kind;
|
|
27
27
|
}) | (EnumType.InitArguments & {
|
|
@@ -10,7 +10,7 @@ export * from './data-type/field.js';
|
|
|
10
10
|
export * from './data-type/enum-type.js';
|
|
11
11
|
export * from './data-type/mapped-type.js';
|
|
12
12
|
export * from './data-type/simple-type.js';
|
|
13
|
-
export * from './data-type/
|
|
13
|
+
export * from './data-type/mixin-type.js';
|
|
14
14
|
export * from './resource/action.js';
|
|
15
15
|
export * from './resource/collection.js';
|
|
16
16
|
export * from './resource/container.js';
|
|
@@ -7,7 +7,7 @@ import { Resource } from './resource.js';
|
|
|
7
7
|
export declare abstract class CrudResource extends Resource {
|
|
8
8
|
operations: ResponsiveMap<CrudOperation>;
|
|
9
9
|
protected constructor(parent: ApiDocument | Container, init: Resource.InitArguments);
|
|
10
|
-
getOperation(
|
|
10
|
+
getOperation(operation: string): CrudOperation | undefined;
|
|
11
11
|
exportSchema(options?: {
|
|
12
12
|
webSafe?: boolean;
|
|
13
13
|
}): OpraSchema.ResourceBase & {
|
|
@@ -2,11 +2,11 @@ import { StrictOmit, Type } from 'ts-gems';
|
|
|
2
2
|
import type { DataType, DataTypeBase } from './data-type.interface.js';
|
|
3
3
|
import type { Field } from './field.interface.js';
|
|
4
4
|
import type { MappedType } from './mapped-type.interface.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { MixinType } from './mixin-type.interface.js';
|
|
6
6
|
export interface ComplexType extends StrictOmit<DataTypeBase, 'kind'> {
|
|
7
7
|
kind: ComplexType.Kind;
|
|
8
8
|
ctor?: Type;
|
|
9
|
-
base?: DataType.Name | ComplexType |
|
|
9
|
+
base?: DataType.Name | ComplexType | MixinType | MappedType;
|
|
10
10
|
abstract?: boolean;
|
|
11
11
|
fields?: Record<Field.Name, Field | DataType.Name>;
|
|
12
12
|
additionalFields?: boolean | 'error' | string | DataType;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ComplexType } from './complex-type.interface.js';
|
|
2
2
|
import type { EnumType } from './enum-type.interface.js';
|
|
3
3
|
import type { MappedType } from './mapped-type.interface.js';
|
|
4
|
+
import type { MixinType } from './mixin-type.interface';
|
|
4
5
|
import type { SimpleType } from './simple-type.interface.js';
|
|
5
|
-
|
|
6
|
-
export type DataType = SimpleType | EnumType | ComplexType | MappedType | UnionType;
|
|
6
|
+
export type DataType = SimpleType | EnumType | ComplexType | MappedType | MixinType;
|
|
7
7
|
export declare namespace DataType {
|
|
8
8
|
type Name = string;
|
|
9
|
-
type Kind = ComplexType.Kind | EnumType.Kind | MappedType.Kind | SimpleType.Kind |
|
|
9
|
+
type Kind = ComplexType.Kind | EnumType.Kind | MappedType.Kind | SimpleType.Kind | MixinType.Kind;
|
|
10
10
|
}
|
|
11
11
|
export interface DataTypeBase {
|
|
12
12
|
kind: DataType.Kind;
|
|
@@ -5,19 +5,50 @@ export declare namespace Field {
|
|
|
5
5
|
}
|
|
6
6
|
export type Field = {
|
|
7
7
|
type: DataType.Name | DataType;
|
|
8
|
+
/**
|
|
9
|
+
* Defines the description of the field
|
|
10
|
+
*/
|
|
8
11
|
description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Defines if the field value is an array
|
|
14
|
+
*/
|
|
9
15
|
isArray?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Defines the default value of the field
|
|
18
|
+
*/
|
|
10
19
|
default?: any;
|
|
20
|
+
/**
|
|
21
|
+
* Defines the fixed value of the field. The value of the field can not be any other value.
|
|
22
|
+
*/
|
|
23
|
+
fixed?: string | number | boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Defines if field value required in create operation
|
|
26
|
+
*/
|
|
11
27
|
required?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Defines if field value be nullish (undefined, null or empty)
|
|
30
|
+
*/
|
|
31
|
+
nullish?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Defines if the field is readonly
|
|
34
|
+
*/
|
|
12
35
|
readonly?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Defines if the field is writeonly
|
|
38
|
+
*/
|
|
13
39
|
writeonly?: boolean;
|
|
14
|
-
format?: string;
|
|
15
|
-
fixed?: string | number;
|
|
16
|
-
examples?: any[] | Record<string, any>;
|
|
17
|
-
deprecated?: boolean | string;
|
|
18
40
|
/**
|
|
19
41
|
* If true, this Field will not be included in results by default.
|
|
20
42
|
* The client side should include the Field name in the "include" query parameter.
|
|
21
43
|
*/
|
|
22
44
|
exclusive?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Defines example values for the field
|
|
47
|
+
*/
|
|
48
|
+
examples?: any[] | Record<string, any>;
|
|
49
|
+
/**
|
|
50
|
+
* Defines if the field is deprecated and can be removed in the next
|
|
51
|
+
*/
|
|
52
|
+
deprecated?: boolean | string;
|
|
53
|
+
format?: string;
|
|
23
54
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrictOmit } from 'ts-gems';
|
|
2
|
+
import type { ComplexType } from './complex-type.interface.js';
|
|
3
|
+
import type { DataType } from './data-type.interface.js';
|
|
4
|
+
import type { MappedType } from './mapped-type.interface.js';
|
|
5
|
+
export interface MixinType extends StrictOmit<ComplexType, 'kind'> {
|
|
6
|
+
kind: MixinType.Kind;
|
|
7
|
+
types: (DataType.Name | ComplexType | MixinType | MappedType)[];
|
|
8
|
+
}
|
|
9
|
+
export declare namespace MixinType {
|
|
10
|
+
const Kind = "MixinType";
|
|
11
|
+
type Kind = 'MixinType';
|
|
12
|
+
}
|
|
@@ -4,7 +4,7 @@ export * from './data-type/enum-type.interface.js';
|
|
|
4
4
|
export * from './data-type/field.interface.js';
|
|
5
5
|
export * from './data-type/simple-type.interface.js';
|
|
6
6
|
export * from './data-type/mapped-type.interface.js';
|
|
7
|
-
export * from './data-type/
|
|
7
|
+
export * from './data-type/mixin-type.interface.js';
|
|
8
8
|
export * from './resource/action.interface.js';
|
|
9
9
|
export * from './resource/endpoint.interface.js';
|
|
10
10
|
export * from './resource/collection.interface.js';
|
|
@@ -2,8 +2,8 @@ import { ComplexType } from './data-type/complex-type.interface.js';
|
|
|
2
2
|
import { DataType } from './data-type/data-type.interface.js';
|
|
3
3
|
import { EnumType } from './data-type/enum-type.interface.js';
|
|
4
4
|
import { MappedType } from './data-type/mapped-type.interface.js';
|
|
5
|
+
import { MixinType } from './data-type/mixin-type.interface.js';
|
|
5
6
|
import { SimpleType } from './data-type/simple-type.interface.js';
|
|
6
|
-
import { UnionType } from './data-type/union-type.interface.js';
|
|
7
7
|
import { Collection } from './resource/collection.interface.js';
|
|
8
8
|
import { Container } from './resource/container.interface.js';
|
|
9
9
|
import { Resource } from './resource/resource.interface.js';
|
|
@@ -12,7 +12,7 @@ import { Storage } from './resource/storage.interface.js';
|
|
|
12
12
|
export declare function isDataType(obj: any): obj is DataType;
|
|
13
13
|
export declare function isComplexType(obj: any): obj is ComplexType;
|
|
14
14
|
export declare function isSimpleType(obj: any): obj is SimpleType;
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function isMixinType(obj: any): obj is MixinType;
|
|
16
16
|
export declare function isMappedType(obj: any): obj is MappedType;
|
|
17
17
|
export declare function isEnumType(obj: any): obj is EnumType;
|
|
18
18
|
export declare function isResource(obj: any): obj is Resource;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { StrictOmit } from 'ts-gems';
|
|
2
|
-
import type { ComplexType } from './complex-type.interface.js';
|
|
3
|
-
import type { DataType } from './data-type.interface.js';
|
|
4
|
-
import type { MappedType } from './mapped-type.interface.js';
|
|
5
|
-
export interface UnionType extends StrictOmit<ComplexType, 'kind'> {
|
|
6
|
-
kind: UnionType.Kind;
|
|
7
|
-
types: (DataType.Name | ComplexType | UnionType | MappedType)[];
|
|
8
|
-
}
|
|
9
|
-
export declare namespace UnionType {
|
|
10
|
-
const Kind = "UnionType";
|
|
11
|
-
type Kind = 'UnionType';
|
|
12
|
-
}
|