@opra/common 0.23.2 → 0.24.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 +319 -206
- package/cjs/document/constants.js +4 -2
- package/cjs/document/data-type/api-field.js +3 -3
- package/cjs/document/data-type/complex-type.js +2 -2
- package/cjs/document/data-type/enum-type.js +5 -5
- package/cjs/document/data-type/mapped-type.js +9 -9
- package/cjs/document/data-type/simple-type.js +2 -2
- package/cjs/document/data-type/union-type.js +2 -2
- package/cjs/document/factory/create-document.js +3 -3
- package/cjs/document/factory/factory.js +6 -6
- package/cjs/document/factory/import-resource-class.js +4 -4
- package/cjs/document/factory/import-type-class.js +4 -4
- package/cjs/document/factory/process-resources.js +12 -12
- package/cjs/document/index.js +3 -2
- package/cjs/document/resource/action.js +12 -0
- package/cjs/document/resource/collection-class.js +174 -0
- package/cjs/document/resource/collection-decorator.js +60 -0
- package/cjs/document/resource/collection.js +7 -212
- package/cjs/document/resource/resource-decorator.js +16 -0
- package/cjs/document/resource/resource.js +18 -2
- package/cjs/document/resource/singleton-class.js +53 -0
- package/cjs/document/resource/singleton-decorator.js +53 -0
- package/cjs/document/resource/singleton.js +7 -85
- package/cjs/document/resource/storage-class.js +24 -0
- package/cjs/document/resource/storage-decorator.js +51 -0
- package/cjs/document/resource/storage.js +7 -53
- package/cjs/document/utils/generate-codec.js +5 -5
- package/cjs/exception/resource-errors/resource-not-found.error.js +1 -1
- package/cjs/helpers/mixin-utils.js +2 -2
- package/cjs/schema/opra-schema.ns.js +0 -1
- package/cjs/schema/type-guards.js +5 -4
- package/esm/document/constants.js +3 -1
- package/esm/document/data-type/api-field.js +4 -4
- package/esm/document/data-type/complex-type.js +3 -3
- package/esm/document/data-type/enum-type.js +6 -6
- package/esm/document/data-type/mapped-type.js +10 -10
- package/esm/document/data-type/simple-type.js +3 -3
- package/esm/document/data-type/union-type.js +3 -3
- package/esm/document/factory/create-document.js +3 -3
- package/esm/document/factory/factory.js +7 -7
- package/esm/document/factory/import-resource-class.js +5 -5
- package/esm/document/factory/import-type-class.js +5 -5
- package/esm/document/factory/process-resources.js +9 -9
- package/esm/document/index.js +3 -2
- package/esm/document/resource/action.js +8 -0
- package/esm/document/resource/collection-class.js +169 -0
- package/esm/document/resource/collection-decorator.js +55 -0
- package/esm/document/resource/collection.js +6 -211
- package/esm/document/resource/resource-decorator.js +13 -0
- package/esm/document/resource/resource.js +18 -2
- package/esm/document/resource/singleton-class.js +49 -0
- package/esm/document/resource/singleton-decorator.js +48 -0
- package/esm/document/resource/singleton.js +6 -84
- package/esm/document/resource/storage-class.js +20 -0
- package/esm/document/resource/storage-decorator.js +46 -0
- package/esm/document/resource/storage.js +6 -52
- package/esm/document/utils/generate-codec.js +3 -3
- package/esm/exception/resource-errors/resource-not-found.error.js +1 -1
- package/esm/helpers/mixin-utils.js +2 -2
- package/esm/schema/opra-schema.ns.js +0 -1
- package/esm/schema/type-guards.js +3 -2
- package/package.json +1 -1
- package/types/document/api-document.d.ts +1 -1
- package/types/document/constants.d.ts +3 -1
- package/types/document/data-type/mapped-type.d.ts +2 -2
- package/types/document/factory/factory.d.ts +7 -7
- package/types/document/factory/process-resources.d.ts +2 -2
- package/types/document/index.d.ts +3 -2
- package/types/document/interfaces/{collection-resource.interface.d.ts → collection.interface.d.ts} +1 -1
- package/types/document/interfaces/{singleton-resource.interface.d.ts → singleton.interface.d.ts} +1 -1
- package/types/document/interfaces/{storage-resource.interface.d.ts → storage.interface.d.ts} +1 -1
- package/types/document/resource/action.d.ts +11 -0
- package/types/document/resource/collection-class.d.ts +24 -0
- package/types/document/resource/collection-decorator.d.ts +30 -0
- package/types/document/resource/collection.d.ts +12 -39
- package/types/document/resource/resource-decorator.d.ts +5 -0
- package/types/document/resource/resource.d.ts +7 -0
- package/types/document/resource/singleton-class.d.ts +20 -0
- package/types/document/resource/singleton-decorator.d.ts +25 -0
- package/types/document/resource/singleton.d.ts +10 -29
- package/types/document/resource/storage-class.d.ts +12 -0
- package/types/document/resource/storage-decorator.d.ts +22 -0
- package/types/document/resource/storage.d.ts +9 -20
- package/types/document/utils/generate-codec.d.ts +1 -1
- package/types/helpers/mixin-utils.d.ts +1 -1
- package/types/schema/document.interface.d.ts +1 -1
- package/types/schema/opra-schema.ns.d.ts +0 -1
- package/types/schema/resource/collection.interface.d.ts +18 -19
- package/types/schema/resource/container.interface.d.ts +4 -2
- package/types/schema/resource/resource.interface.d.ts +14 -0
- package/types/schema/resource/singleton.interface.d.ts +8 -8
- package/types/schema/resource/storage.interface.d.ts +7 -8
- package/types/schema/type-guards.d.ts +1 -1
- package/cjs/schema/resource/operation.interface.js +0 -2
- package/esm/schema/resource/operation.interface.js +0 -1
- package/types/schema/resource/operation.interface.d.ts +0 -3
- /package/cjs/document/interfaces/{collection-resource.interface.js → collection.interface.js} +0 -0
- /package/cjs/document/interfaces/{singleton-resource.interface.js → singleton.interface.js} +0 -0
- /package/cjs/document/interfaces/{storage-resource.interface.js → storage.interface.js} +0 -0
- /package/esm/document/interfaces/{collection-resource.interface.js → collection.interface.js} +0 -0
- /package/esm/document/interfaces/{singleton-resource.interface.js → singleton.interface.js} +0 -0
- /package/esm/document/interfaces/{storage-resource.interface.js → storage.interface.js} +0 -0
package/browser.js
CHANGED
|
@@ -14,7 +14,9 @@ var __export = (target, all) => {
|
|
|
14
14
|
import "reflect-metadata";
|
|
15
15
|
|
|
16
16
|
// ../../build/common/esm/document/constants.js
|
|
17
|
-
var
|
|
17
|
+
var DATATYPE_METADATA = Symbol("DATATYPE_METADATA");
|
|
18
|
+
var RESOURCE_METADATA = Symbol("RESOURCE_METADATA");
|
|
19
|
+
var DECORATOR = Symbol("DECORATOR");
|
|
18
20
|
var NAMESPACE_PATTERN = /([A-Z$_]\w+)(?::.+)?/i;
|
|
19
21
|
var TYPENAME_PATTERN = /^(.*)Type(\d*)$/;
|
|
20
22
|
|
|
@@ -122,9 +124,9 @@ function mergePrototype(targetProto, baseProto, filter) {
|
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
__name(mergePrototype, "mergePrototype");
|
|
125
|
-
function inheritPropertyInitializers(target,
|
|
127
|
+
function inheritPropertyInitializers(target, clazz, isPropertyInherited = (key) => true) {
|
|
126
128
|
try {
|
|
127
|
-
const tempInstance = new
|
|
129
|
+
const tempInstance = new clazz();
|
|
128
130
|
const propertyNames = Object.getOwnPropertyNames(tempInstance);
|
|
129
131
|
propertyNames.filter((propertyName) => typeof tempInstance[propertyName] !== "undefined" && typeof target[propertyName] === "undefined").filter((propertyName) => isPropertyInherited(propertyName)).forEach((propertyName) => {
|
|
130
132
|
target[propertyName] = tempInstance[propertyName];
|
|
@@ -854,7 +856,7 @@ var ResourceNotFoundError = class extends OpraException {
|
|
|
854
856
|
}
|
|
855
857
|
constructor(resource, keyValue, cause) {
|
|
856
858
|
super({
|
|
857
|
-
message: translate(`error:RESOURCE_NOT_FOUND`,
|
|
859
|
+
message: translate(`error:RESOURCE_NOT_FOUND`, `Resource not found`),
|
|
858
860
|
severity: "error",
|
|
859
861
|
code: "RESOURCE_NOT_FOUND",
|
|
860
862
|
details: {
|
|
@@ -895,9 +897,9 @@ __export(opra_schema_ns_exports, {
|
|
|
895
897
|
isDataType: () => isDataType,
|
|
896
898
|
isEnumType: () => isEnumType,
|
|
897
899
|
isMappedType: () => isMappedType,
|
|
898
|
-
isResource: () => isResource,
|
|
899
900
|
isSimpleType: () => isSimpleType,
|
|
900
901
|
isSingleton: () => isSingleton,
|
|
902
|
+
isSource: () => isSource,
|
|
901
903
|
isStorage: () => isStorage,
|
|
902
904
|
isUnionType: () => isUnionType
|
|
903
905
|
});
|
|
@@ -984,10 +986,10 @@ function isEnumType(obj) {
|
|
|
984
986
|
return obj && typeof obj === "object" && obj.kind === EnumType.Kind;
|
|
985
987
|
}
|
|
986
988
|
__name(isEnumType, "isEnumType");
|
|
987
|
-
function
|
|
988
|
-
return obj && typeof obj === "object" && (obj.kind === Container.Kind || obj.kind === Collection.Kind || obj.kind === Singleton.Kind);
|
|
989
|
+
function isSource(obj) {
|
|
990
|
+
return obj && typeof obj === "object" && (obj.kind === Container.Kind || obj.kind === Collection.Kind || obj.kind === Singleton.Kind || obj.kind === Storage.Kind);
|
|
989
991
|
}
|
|
990
|
-
__name(
|
|
992
|
+
__name(isSource, "isSource");
|
|
991
993
|
function isCollection(obj) {
|
|
992
994
|
return obj && typeof obj === "object" && obj.kind === Collection.Kind;
|
|
993
995
|
}
|
|
@@ -1090,18 +1092,18 @@ var EnumType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
1090
1092
|
merge2(this, new EnumTypeClass(document, init), { descriptor: true });
|
|
1091
1093
|
return;
|
|
1092
1094
|
}
|
|
1093
|
-
const [
|
|
1094
|
-
const values = Array.isArray(
|
|
1095
|
+
const [enumSource, options] = args;
|
|
1096
|
+
const values = Array.isArray(enumSource) ? enumSource.reduce((obj, v) => {
|
|
1095
1097
|
obj[v] = v;
|
|
1096
1098
|
return obj;
|
|
1097
|
-
}, {}) :
|
|
1099
|
+
}, {}) : enumSource;
|
|
1098
1100
|
const metadata = {
|
|
1099
1101
|
kind: opra_schema_ns_exports.EnumType.Kind,
|
|
1100
1102
|
values
|
|
1101
1103
|
};
|
|
1102
1104
|
if (options)
|
|
1103
1105
|
Object.assign(metadata, omit(options, ["kind", "values"]));
|
|
1104
|
-
Reflect.defineMetadata(
|
|
1106
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, enumSource);
|
|
1105
1107
|
return values;
|
|
1106
1108
|
}, "EnumType");
|
|
1107
1109
|
EnumType2.prototype = EnumTypeClass.prototype;
|
|
@@ -1113,7 +1115,7 @@ var ApiField = /* @__PURE__ */ __name(function(...args) {
|
|
|
1113
1115
|
return function(target, propertyKey) {
|
|
1114
1116
|
if (typeof propertyKey !== "string")
|
|
1115
1117
|
throw new TypeError(`Symbol properties can't be used as a field`);
|
|
1116
|
-
const metadata = Reflect.getOwnMetadata(
|
|
1118
|
+
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target.constructor) || {};
|
|
1117
1119
|
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1118
1120
|
metadata.fields = metadata.fields || {};
|
|
1119
1121
|
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
@@ -1136,13 +1138,13 @@ var ApiField = /* @__PURE__ */ __name(function(...args) {
|
|
|
1136
1138
|
EnumType2(enumObj);
|
|
1137
1139
|
elemMeta.enum = enumObj;
|
|
1138
1140
|
} else {
|
|
1139
|
-
const m = Reflect.getOwnMetadata(
|
|
1141
|
+
const m = Reflect.getOwnMetadata(DATATYPE_METADATA, options?.enum);
|
|
1140
1142
|
if (!opra_schema_ns_exports.isEnumType(m))
|
|
1141
1143
|
throw new TypeError(`Invalid "enum" value. Did you forget to set metadata using EnumType() method?`);
|
|
1142
1144
|
elemMeta.enum = options.enum;
|
|
1143
1145
|
}
|
|
1144
1146
|
}
|
|
1145
|
-
Reflect.defineMetadata(
|
|
1147
|
+
Reflect.defineMetadata(DATATYPE_METADATA, omitUndefined(metadata), target.constructor);
|
|
1146
1148
|
};
|
|
1147
1149
|
}
|
|
1148
1150
|
const [owner, init] = args;
|
|
@@ -1325,10 +1327,10 @@ var ComplexType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
1325
1327
|
const [options] = args;
|
|
1326
1328
|
return function(target) {
|
|
1327
1329
|
const name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1328
|
-
let metadata = Reflect.getOwnMetadata(
|
|
1330
|
+
let metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target);
|
|
1329
1331
|
if (!metadata) {
|
|
1330
1332
|
metadata = {};
|
|
1331
|
-
Reflect.defineMetadata(
|
|
1333
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1332
1334
|
}
|
|
1333
1335
|
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1334
1336
|
metadata.name = name;
|
|
@@ -1619,12 +1621,12 @@ var SimpleType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
1619
1621
|
return function(target) {
|
|
1620
1622
|
let name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1621
1623
|
name = name.charAt(0).toLowerCase() + name.substring(1);
|
|
1622
|
-
const metadata = Reflect.getOwnMetadata(
|
|
1624
|
+
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target) || {};
|
|
1623
1625
|
metadata.kind = opra_schema_ns_exports.SimpleType.Kind;
|
|
1624
1626
|
metadata.name = name;
|
|
1625
1627
|
if (options)
|
|
1626
1628
|
Object.assign(metadata, omit3(options, ["kind", "name"]));
|
|
1627
|
-
Reflect.defineMetadata(
|
|
1629
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1628
1630
|
};
|
|
1629
1631
|
}, "SimpleType");
|
|
1630
1632
|
SimpleType2.prototype = SimpleTypeClass.prototype;
|
|
@@ -1880,10 +1882,10 @@ async function createDocument(init, options) {
|
|
|
1880
1882
|
this.curPath.push("resources");
|
|
1881
1883
|
if (Array.isArray(init.resources)) {
|
|
1882
1884
|
for (const res of init.resources)
|
|
1883
|
-
await this.
|
|
1885
|
+
await this.importSourceClass(res);
|
|
1884
1886
|
} else
|
|
1885
|
-
this.
|
|
1886
|
-
await this.
|
|
1887
|
+
this.sourceQueue.setAll(init.resources);
|
|
1888
|
+
await this.processSourceQueue();
|
|
1887
1889
|
this.curPath.pop();
|
|
1888
1890
|
}
|
|
1889
1891
|
this.document.types.sort();
|
|
@@ -1941,14 +1943,14 @@ __name(createBuiltinTypeDocument, "createBuiltinTypeDocument");
|
|
|
1941
1943
|
// ../../build/common/esm/document/factory/import-resource-class.js
|
|
1942
1944
|
import "reflect-metadata";
|
|
1943
1945
|
async function importResourceClass(thunk) {
|
|
1944
|
-
const { document,
|
|
1946
|
+
const { document, sourceQueue, cache } = this;
|
|
1945
1947
|
const controller = await resolveThunk(thunk);
|
|
1946
1948
|
const cached = cache.get(controller);
|
|
1947
1949
|
if (cached)
|
|
1948
1950
|
return cached;
|
|
1949
1951
|
const ctor = typeof thunk === "function" ? thunk : Object.getPrototypeOf(thunk).constructor;
|
|
1950
|
-
let metadata = Reflect.getMetadata(
|
|
1951
|
-
if (!metadata && opra_schema_ns_exports.
|
|
1952
|
+
let metadata = Reflect.getMetadata(RESOURCE_METADATA, ctor);
|
|
1953
|
+
if (!metadata && opra_schema_ns_exports.isSource(metadata))
|
|
1952
1954
|
throw new TypeError(`Class "${ctor.name}" doesn't have a valid Resource metadata`);
|
|
1953
1955
|
metadata = cloneObject(metadata);
|
|
1954
1956
|
const schema = cloneObject(metadata);
|
|
@@ -1968,7 +1970,7 @@ async function importResourceClass(thunk) {
|
|
|
1968
1970
|
await this.extractSingletonSchema(schema, ctor, metadata, controller);
|
|
1969
1971
|
if (opra_schema_ns_exports.isCollection(schema))
|
|
1970
1972
|
await this.extractCollectionSchema(schema, ctor, metadata, controller);
|
|
1971
|
-
|
|
1973
|
+
sourceQueue.set(metadata.name, schema);
|
|
1972
1974
|
}
|
|
1973
1975
|
__name(importResourceClass, "importResourceClass");
|
|
1974
1976
|
async function extractSingletonSchema(target, ctor, metadata, controller) {
|
|
@@ -1989,7 +1991,7 @@ async function importTypeClass(typeThunk) {
|
|
|
1989
1991
|
const dt = document.getDataType(thunk, true);
|
|
1990
1992
|
if (dt && dt.name)
|
|
1991
1993
|
return dt.name;
|
|
1992
|
-
const metadata = Reflect.getMetadata(
|
|
1994
|
+
const metadata = Reflect.getMetadata(DATATYPE_METADATA, thunk);
|
|
1993
1995
|
if (!(metadata && opra_schema_ns_exports.isDataType(metadata))) {
|
|
1994
1996
|
if (isConstructor(thunk))
|
|
1995
1997
|
throw new TypeError(`Class "${thunk.name}" doesn't have a valid DataType metadata`);
|
|
@@ -2021,7 +2023,7 @@ async function importTypeClass(typeThunk) {
|
|
|
2021
2023
|
const enumObject = thunk;
|
|
2022
2024
|
if (opra_schema_ns_exports.isEnumType(schema)) {
|
|
2023
2025
|
let baseType;
|
|
2024
|
-
if (metadata.base && Reflect.hasMetadata(
|
|
2026
|
+
if (metadata.base && Reflect.hasMetadata(DATATYPE_METADATA, metadata.base)) {
|
|
2025
2027
|
baseType = await this.importTypeClass(metadata.base);
|
|
2026
2028
|
}
|
|
2027
2029
|
schema.base = baseType;
|
|
@@ -2033,7 +2035,7 @@ async function importTypeClass(typeThunk) {
|
|
|
2033
2035
|
__name(importTypeClass, "importTypeClass");
|
|
2034
2036
|
async function extractSimpleTypeSchema(target, ctor, metadata) {
|
|
2035
2037
|
const baseClass = Object.getPrototypeOf(ctor.prototype).constructor;
|
|
2036
|
-
if (Reflect.hasMetadata(
|
|
2038
|
+
if (Reflect.hasMetadata(DATATYPE_METADATA, baseClass))
|
|
2037
2039
|
target.base = await this.importTypeClass(baseClass);
|
|
2038
2040
|
if (typeof ctor.prototype.decode === "function")
|
|
2039
2041
|
target.decoder = validator(metadata.name, ctor.prototype.decode);
|
|
@@ -2043,7 +2045,7 @@ async function extractSimpleTypeSchema(target, ctor, metadata) {
|
|
|
2043
2045
|
__name(extractSimpleTypeSchema, "extractSimpleTypeSchema");
|
|
2044
2046
|
async function extractComplexTypeSchema(target, ctor, metadata) {
|
|
2045
2047
|
const baseClass = Object.getPrototypeOf(ctor.prototype).constructor;
|
|
2046
|
-
if (Reflect.hasMetadata(
|
|
2048
|
+
if (Reflect.hasMetadata(DATATYPE_METADATA, baseClass))
|
|
2047
2049
|
target.base = await this.importTypeClass(baseClass);
|
|
2048
2050
|
target.ctor = target.ctor || ctor;
|
|
2049
2051
|
if (metadata.fields) {
|
|
@@ -2100,8 +2102,9 @@ async function extractFieldSchema(target, ctor, metadata, name) {
|
|
|
2100
2102
|
__name(extractFieldSchema, "extractFieldSchema");
|
|
2101
2103
|
|
|
2102
2104
|
// ../../build/common/esm/document/resource/collection.js
|
|
2103
|
-
import
|
|
2104
|
-
|
|
2105
|
+
import merge8 from "putil-merge";
|
|
2106
|
+
|
|
2107
|
+
// ../../build/common/esm/document/resource/collection-class.js
|
|
2105
2108
|
import * as vg4 from "valgen";
|
|
2106
2109
|
|
|
2107
2110
|
// ../../build/common/esm/filter/opra-filter.ns.js
|
|
@@ -9659,32 +9662,32 @@ var MappedType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9659
9662
|
merge5(this, new MappedTypeClass(document, init), { descriptor: true });
|
|
9660
9663
|
return;
|
|
9661
9664
|
}
|
|
9662
|
-
const [
|
|
9665
|
+
const [mappedSource, options] = args;
|
|
9663
9666
|
const isInheritedPredicate = getIsInheritedPredicateFn(options.pick, options.omit);
|
|
9664
9667
|
class MappedClass {
|
|
9665
9668
|
static {
|
|
9666
9669
|
__name(this, "MappedClass");
|
|
9667
9670
|
}
|
|
9668
9671
|
constructor() {
|
|
9669
|
-
inheritPropertyInitializers(this,
|
|
9672
|
+
inheritPropertyInitializers(this, mappedSource, isInheritedPredicate);
|
|
9670
9673
|
}
|
|
9671
9674
|
}
|
|
9672
|
-
mergePrototype(MappedClass.prototype,
|
|
9673
|
-
const m = Reflect.getOwnMetadata(
|
|
9675
|
+
mergePrototype(MappedClass.prototype, mappedSource.prototype);
|
|
9676
|
+
const m = Reflect.getOwnMetadata(DATATYPE_METADATA, mappedSource);
|
|
9674
9677
|
if (!m)
|
|
9675
|
-
throw new TypeError(`Class "${
|
|
9678
|
+
throw new TypeError(`Class "${mappedSource}" doesn't have datatype metadata information`);
|
|
9676
9679
|
if (!(m.kind === opra_schema_ns_exports.ComplexType.Kind))
|
|
9677
|
-
throw new TypeError(`Class "${
|
|
9680
|
+
throw new TypeError(`Class "${mappedSource}" is not a ${opra_schema_ns_exports.ComplexType.Kind}`);
|
|
9678
9681
|
const metadata = {
|
|
9679
9682
|
kind: "MappedType",
|
|
9680
|
-
type:
|
|
9683
|
+
type: mappedSource
|
|
9681
9684
|
};
|
|
9682
9685
|
if (options.pick)
|
|
9683
9686
|
metadata.pick = options.pick;
|
|
9684
9687
|
if (options.omit)
|
|
9685
9688
|
metadata.omit = options.omit;
|
|
9686
|
-
Reflect.defineMetadata(
|
|
9687
|
-
MappedType2._applyMixin(MappedClass,
|
|
9689
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, MappedClass);
|
|
9690
|
+
MappedType2._applyMixin(MappedClass, mappedSource, {
|
|
9688
9691
|
...options,
|
|
9689
9692
|
isInheritedPredicate
|
|
9690
9693
|
});
|
|
@@ -9768,9 +9771,9 @@ var UnionType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9768
9771
|
kind: opra_schema_ns_exports.UnionType.Kind,
|
|
9769
9772
|
types: []
|
|
9770
9773
|
};
|
|
9771
|
-
Reflect.defineMetadata(
|
|
9774
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, UnionClass);
|
|
9772
9775
|
for (const c of clasRefs) {
|
|
9773
|
-
const itemMeta = Reflect.getMetadata(
|
|
9776
|
+
const itemMeta = Reflect.getMetadata(DATATYPE_METADATA, c);
|
|
9774
9777
|
if (!(itemMeta && (itemMeta.kind === opra_schema_ns_exports.ComplexType.Kind || itemMeta.kind === opra_schema_ns_exports.UnionType.Kind || itemMeta.kind === opra_schema_ns_exports.MappedType.Kind)))
|
|
9775
9778
|
throw new TypeError(`Class "${c.name}" is not a ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.UnionType.Kind} or ${opra_schema_ns_exports.MappedType.Kind}`);
|
|
9776
9779
|
metadata.types.push(c);
|
|
@@ -9784,17 +9787,17 @@ UnionType2._applyMixin = () => void 0;
|
|
|
9784
9787
|
|
|
9785
9788
|
// ../../build/common/esm/document/utils/generate-codec.js
|
|
9786
9789
|
function generateCodec(type, codec, options) {
|
|
9787
|
-
return
|
|
9790
|
+
return _generateCodec(type, codec, options);
|
|
9788
9791
|
}
|
|
9789
9792
|
__name(generateCodec, "generateCodec");
|
|
9790
|
-
function
|
|
9793
|
+
function _generateCodec(type, codec, options) {
|
|
9791
9794
|
const schema = {};
|
|
9792
9795
|
for (const f of type.fields.values()) {
|
|
9793
9796
|
let fn;
|
|
9794
9797
|
if (f.type instanceof SimpleType2 || f.type instanceof EnumType2) {
|
|
9795
9798
|
fn = f.type[codec];
|
|
9796
9799
|
} else if (f.type instanceof ComplexType2 || f.type instanceof MappedType2 || f.type instanceof UnionType2) {
|
|
9797
|
-
fn =
|
|
9800
|
+
fn = _generateCodec(f.type, codec, options);
|
|
9798
9801
|
}
|
|
9799
9802
|
if (!fn)
|
|
9800
9803
|
throw new TypeError(`Can't generate codec for (${f.type})`);
|
|
@@ -9809,7 +9812,20 @@ function _generateDecoder(type, codec, options) {
|
|
|
9809
9812
|
caseInSensitive: true
|
|
9810
9813
|
});
|
|
9811
9814
|
}
|
|
9812
|
-
__name(
|
|
9815
|
+
__name(_generateCodec, "_generateCodec");
|
|
9816
|
+
|
|
9817
|
+
// ../../build/common/esm/document/resource/action.js
|
|
9818
|
+
var Action = class {
|
|
9819
|
+
static {
|
|
9820
|
+
__name(this, "Action");
|
|
9821
|
+
}
|
|
9822
|
+
constructor(init) {
|
|
9823
|
+
this.name = init.name;
|
|
9824
|
+
}
|
|
9825
|
+
exportSchema() {
|
|
9826
|
+
return {};
|
|
9827
|
+
}
|
|
9828
|
+
};
|
|
9813
9829
|
|
|
9814
9830
|
// ../../build/common/esm/document/resource/resource.js
|
|
9815
9831
|
var Resource = class {
|
|
@@ -9817,16 +9833,31 @@ var Resource = class {
|
|
|
9817
9833
|
__name(this, "Resource");
|
|
9818
9834
|
}
|
|
9819
9835
|
constructor(document, init) {
|
|
9836
|
+
this.actions = {};
|
|
9820
9837
|
this.document = document;
|
|
9821
9838
|
this.name = init.name;
|
|
9822
9839
|
this.description = init.description;
|
|
9823
9840
|
this.controller = init.controller;
|
|
9841
|
+
if (init.actions) {
|
|
9842
|
+
for (const [name, meta] of Object.entries(init.actions)) {
|
|
9843
|
+
this.actions[name.toLowerCase()] = new Action({ ...meta, name });
|
|
9844
|
+
}
|
|
9845
|
+
}
|
|
9824
9846
|
}
|
|
9825
9847
|
exportSchema() {
|
|
9826
|
-
|
|
9848
|
+
const schema = omitUndefined({
|
|
9827
9849
|
kind: this.kind,
|
|
9828
9850
|
description: this.description
|
|
9829
9851
|
});
|
|
9852
|
+
const actions = {};
|
|
9853
|
+
let i = 0;
|
|
9854
|
+
for (const action of Object.values(this.actions)) {
|
|
9855
|
+
actions[action.name] = action.exportSchema();
|
|
9856
|
+
i++;
|
|
9857
|
+
}
|
|
9858
|
+
if (i)
|
|
9859
|
+
schema.actions = actions;
|
|
9860
|
+
return schema;
|
|
9830
9861
|
}
|
|
9831
9862
|
toString() {
|
|
9832
9863
|
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name || "#anonymous"}]`;
|
|
@@ -9836,9 +9867,7 @@ var Resource = class {
|
|
|
9836
9867
|
}
|
|
9837
9868
|
};
|
|
9838
9869
|
|
|
9839
|
-
// ../../build/common/esm/document/resource/collection.js
|
|
9840
|
-
var NESTJS_INJECTABLE_WATERMARK = "__injectable__";
|
|
9841
|
-
var NAME_PATTERN = /^(.*)(Resource|Collection)$/;
|
|
9870
|
+
// ../../build/common/esm/document/resource/collection-class.js
|
|
9842
9871
|
var CollectionClass = class extends Resource {
|
|
9843
9872
|
static {
|
|
9844
9873
|
__name(this, "CollectionClass");
|
|
@@ -9861,13 +9890,14 @@ var CollectionClass = class extends Resource {
|
|
|
9861
9890
|
});
|
|
9862
9891
|
}
|
|
9863
9892
|
exportSchema() {
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9893
|
+
return {
|
|
9894
|
+
...super.exportSchema(),
|
|
9895
|
+
...omitUndefined({
|
|
9896
|
+
type: this.type.name || "object",
|
|
9897
|
+
operations: this.operations,
|
|
9898
|
+
primaryKey: this.primaryKey
|
|
9899
|
+
})
|
|
9900
|
+
};
|
|
9871
9901
|
}
|
|
9872
9902
|
parseKeyValue(value) {
|
|
9873
9903
|
if (!this.primaryKey?.length)
|
|
@@ -9963,84 +9993,121 @@ var CollectionClass = class extends Resource {
|
|
|
9963
9993
|
}
|
|
9964
9994
|
return ast;
|
|
9965
9995
|
}
|
|
9966
|
-
getDecoder(
|
|
9967
|
-
let decoder = this._decoders[
|
|
9996
|
+
getDecoder(endpoint) {
|
|
9997
|
+
let decoder = this._decoders[endpoint];
|
|
9968
9998
|
if (decoder)
|
|
9969
9999
|
return decoder;
|
|
9970
10000
|
const options = {
|
|
9971
|
-
partial:
|
|
10001
|
+
partial: endpoint !== "create"
|
|
9972
10002
|
};
|
|
9973
|
-
if (
|
|
10003
|
+
if (endpoint !== "create")
|
|
9974
10004
|
options.omit = [...this.primaryKey];
|
|
9975
10005
|
decoder = generateCodec(this.type, "decode", options);
|
|
9976
|
-
this._decoders[
|
|
10006
|
+
this._decoders[endpoint] = decoder;
|
|
9977
10007
|
return decoder;
|
|
9978
10008
|
}
|
|
9979
|
-
getEncoder(
|
|
9980
|
-
let encoder = this._encoders[
|
|
10009
|
+
getEncoder(endpoint) {
|
|
10010
|
+
let encoder = this._encoders[endpoint];
|
|
9981
10011
|
if (encoder)
|
|
9982
10012
|
return encoder;
|
|
9983
10013
|
const options = {
|
|
9984
10014
|
partial: true
|
|
9985
10015
|
};
|
|
9986
10016
|
encoder = generateCodec(this.type, "encode", options);
|
|
9987
|
-
if (
|
|
10017
|
+
if (endpoint === "findMany")
|
|
9988
10018
|
return vg4.isArray(encoder);
|
|
9989
|
-
this._encoders[
|
|
10019
|
+
this._encoders[endpoint] = encoder;
|
|
9990
10020
|
return encoder;
|
|
9991
10021
|
}
|
|
9992
10022
|
};
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10023
|
+
|
|
10024
|
+
// ../../build/common/esm/document/resource/collection-decorator.js
|
|
10025
|
+
import omit4 from "lodash.omit";
|
|
10026
|
+
import merge7 from "putil-merge";
|
|
10027
|
+
|
|
10028
|
+
// ../../build/common/esm/document/resource/resource-decorator.js
|
|
10029
|
+
var ResourceDecorator = {};
|
|
10030
|
+
ResourceDecorator.Action = function(options) {
|
|
10031
|
+
return (target, propertyKey) => {
|
|
10032
|
+
if (typeof propertyKey !== "string")
|
|
10033
|
+
throw new TypeError(`This decorator can't be used for Symbol keys'`);
|
|
10034
|
+
const actionMeta = { ...options };
|
|
10035
|
+
const resourceMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target.constructor) || {};
|
|
10036
|
+
resourceMetadata.actions = resourceMetadata.actions || {};
|
|
10037
|
+
resourceMetadata.actions[propertyKey] = actionMeta;
|
|
10038
|
+
Reflect.defineMetadata(RESOURCE_METADATA, resourceMetadata, target.constructor);
|
|
10039
|
+
};
|
|
10040
|
+
};
|
|
10041
|
+
|
|
10042
|
+
// ../../build/common/esm/document/resource/collection-decorator.js
|
|
10043
|
+
var NAME_PATTERN = /^(.*)(Resource|Collection|Controller)$/;
|
|
10044
|
+
var operationProperties = ["create", "delete", "deleteMany", "get", "findMany", "update", "updateMany"];
|
|
10045
|
+
function CollectionDecorator(type, options) {
|
|
10046
|
+
return function(target) {
|
|
10047
|
+
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
10048
|
+
const metadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target) || {};
|
|
10049
|
+
const baseMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, Object.getPrototypeOf(target));
|
|
10050
|
+
if (baseMetadata) {
|
|
10051
|
+
merge7(metadata, baseMetadata, { deep: true });
|
|
10052
|
+
}
|
|
10053
|
+
metadata.kind = opra_schema_ns_exports.Collection.Kind;
|
|
10054
|
+
metadata.name = name;
|
|
10055
|
+
metadata.type = type;
|
|
10056
|
+
const m = Reflect.getMetadata(RESOURCE_METADATA, target);
|
|
10057
|
+
if (m && metadata !== m)
|
|
10058
|
+
Object.assign(metadata, omit4(m), Object.keys(metadata));
|
|
10059
|
+
if (options)
|
|
10060
|
+
Object.assign(metadata, omit4(options, ["kind", "name", "type", "controller"]));
|
|
10061
|
+
Reflect.defineMetadata(RESOURCE_METADATA, metadata, target);
|
|
10062
|
+
};
|
|
10063
|
+
}
|
|
10064
|
+
__name(CollectionDecorator, "CollectionDecorator");
|
|
10065
|
+
Object.assign(CollectionDecorator, ResourceDecorator);
|
|
10066
|
+
CollectionDecorator.Create = createOperationDecorator("create");
|
|
10067
|
+
CollectionDecorator.Delete = createOperationDecorator("delete");
|
|
10068
|
+
CollectionDecorator.DeleteMany = createOperationDecorator("deleteMany");
|
|
10069
|
+
CollectionDecorator.Get = createOperationDecorator("get");
|
|
10070
|
+
CollectionDecorator.FindMany = createOperationDecorator("findMany");
|
|
10071
|
+
CollectionDecorator.Update = createOperationDecorator("update");
|
|
10072
|
+
CollectionDecorator.UpdateMany = createOperationDecorator("updateMany");
|
|
10073
|
+
CollectionDecorator.Action = function(options) {
|
|
10074
|
+
const oldDecorator = ResourceDecorator.Action(options);
|
|
10075
|
+
return (target, propertyKey) => {
|
|
10076
|
+
if (typeof propertyKey === "string" && operationProperties.includes(propertyKey))
|
|
10077
|
+
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
10078
|
+
return oldDecorator(target, propertyKey);
|
|
10079
|
+
};
|
|
10080
|
+
};
|
|
10019
10081
|
function createOperationDecorator(operation) {
|
|
10020
10082
|
return (options) => (target, propertyKey) => {
|
|
10021
10083
|
if (propertyKey !== operation)
|
|
10022
10084
|
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10023
10085
|
const operationMeta = { ...options };
|
|
10024
|
-
const
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
Reflect.defineMetadata(
|
|
10086
|
+
const sourceMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target.constructor) || {};
|
|
10087
|
+
sourceMetadata.operations = sourceMetadata.operations || {};
|
|
10088
|
+
sourceMetadata.operations[operation] = operationMeta;
|
|
10089
|
+
Reflect.defineMetadata(RESOURCE_METADATA, sourceMetadata, target.constructor);
|
|
10028
10090
|
};
|
|
10029
10091
|
}
|
|
10030
10092
|
__name(createOperationDecorator, "createOperationDecorator");
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
Collection2
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
Collection2.
|
|
10037
|
-
|
|
10093
|
+
|
|
10094
|
+
// ../../build/common/esm/document/resource/collection.js
|
|
10095
|
+
var Collection2 = /* @__PURE__ */ __name(function(...args) {
|
|
10096
|
+
if (!this) {
|
|
10097
|
+
const [type, options] = args;
|
|
10098
|
+
return Collection2[DECORATOR].call(void 0, type, options);
|
|
10099
|
+
}
|
|
10100
|
+
const [document, init] = args;
|
|
10101
|
+
merge8(this, new CollectionClass(document, init), { descriptor: true });
|
|
10102
|
+
}, "Collection");
|
|
10103
|
+
Collection2.prototype = CollectionClass.prototype;
|
|
10104
|
+
Object.assign(Collection2, CollectionDecorator);
|
|
10105
|
+
Collection2[DECORATOR] = CollectionDecorator;
|
|
10038
10106
|
|
|
10039
10107
|
// ../../build/common/esm/document/resource/singleton.js
|
|
10040
|
-
import
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
var NAME_PATTERN2 = /^(.*)(Resource|Singleton)$/;
|
|
10108
|
+
import merge9 from "putil-merge";
|
|
10109
|
+
|
|
10110
|
+
// ../../build/common/esm/document/resource/singleton-class.js
|
|
10044
10111
|
var SingletonClass = class extends Resource {
|
|
10045
10112
|
static {
|
|
10046
10113
|
__name(this, "SingletonClass");
|
|
@@ -10055,83 +10122,104 @@ var SingletonClass = class extends Resource {
|
|
|
10055
10122
|
this.type = init.type;
|
|
10056
10123
|
}
|
|
10057
10124
|
exportSchema() {
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10125
|
+
return {
|
|
10126
|
+
...super.exportSchema(),
|
|
10127
|
+
...omitUndefined({
|
|
10128
|
+
type: this.type.name || "any",
|
|
10129
|
+
operations: this.operations
|
|
10130
|
+
})
|
|
10131
|
+
};
|
|
10064
10132
|
}
|
|
10065
10133
|
normalizeFieldPath(path2) {
|
|
10066
10134
|
return this.type.normalizeFieldPath(path2);
|
|
10067
10135
|
}
|
|
10068
|
-
getDecoder(
|
|
10069
|
-
let decoder = this._decoders[
|
|
10136
|
+
getDecoder(endpoint) {
|
|
10137
|
+
let decoder = this._decoders[endpoint];
|
|
10070
10138
|
if (decoder)
|
|
10071
10139
|
return decoder;
|
|
10072
10140
|
const options = {
|
|
10073
|
-
partial:
|
|
10141
|
+
partial: endpoint !== "create"
|
|
10074
10142
|
};
|
|
10075
10143
|
decoder = generateCodec(this.type, "decode", options);
|
|
10076
|
-
this._decoders[
|
|
10144
|
+
this._decoders[endpoint] = decoder;
|
|
10077
10145
|
return decoder;
|
|
10078
10146
|
}
|
|
10079
|
-
getEncoder(
|
|
10080
|
-
let encoder = this._encoders[
|
|
10147
|
+
getEncoder(endpoint) {
|
|
10148
|
+
let encoder = this._encoders[endpoint];
|
|
10081
10149
|
if (encoder)
|
|
10082
10150
|
return encoder;
|
|
10083
10151
|
const options = {
|
|
10084
10152
|
partial: true
|
|
10085
10153
|
};
|
|
10086
10154
|
encoder = generateCodec(this.type, "encode", options);
|
|
10087
|
-
this._encoders[
|
|
10155
|
+
this._encoders[endpoint] = encoder;
|
|
10088
10156
|
return encoder;
|
|
10089
10157
|
}
|
|
10090
10158
|
};
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
}
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10159
|
+
|
|
10160
|
+
// ../../build/common/esm/document/resource/singleton-decorator.js
|
|
10161
|
+
import omit5 from "lodash.omit";
|
|
10162
|
+
var NAME_PATTERN2 = /^(.*)(Resource|Singleton|Controller)$/;
|
|
10163
|
+
function SingletonDecorator(type, options) {
|
|
10164
|
+
return function(target) {
|
|
10165
|
+
const name = options?.name || target.name.match(NAME_PATTERN2)?.[1] || target.name;
|
|
10166
|
+
const metadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target) || {};
|
|
10167
|
+
metadata.kind = opra_schema_ns_exports.Singleton.Kind;
|
|
10168
|
+
metadata.name = name;
|
|
10169
|
+
metadata.type = type;
|
|
10170
|
+
const m = Reflect.getMetadata(RESOURCE_METADATA, target);
|
|
10171
|
+
if (m && metadata !== m)
|
|
10172
|
+
Object.assign(metadata, omit5(m), Object.keys(metadata));
|
|
10173
|
+
if (options)
|
|
10174
|
+
Object.assign(metadata, omit5(options, ["kind", "name", "type", "controller"]));
|
|
10175
|
+
Reflect.defineMetadata(RESOURCE_METADATA, metadata, target);
|
|
10176
|
+
};
|
|
10177
|
+
}
|
|
10178
|
+
__name(SingletonDecorator, "SingletonDecorator");
|
|
10179
|
+
Object.assign(SingletonDecorator, ResourceDecorator);
|
|
10180
|
+
SingletonDecorator.Create = createOperationDecorator2("create");
|
|
10181
|
+
SingletonDecorator.Get = createOperationDecorator2("get");
|
|
10182
|
+
SingletonDecorator.Delete = createOperationDecorator2("delete");
|
|
10183
|
+
SingletonDecorator.Update = createOperationDecorator2("update");
|
|
10184
|
+
SingletonDecorator.Action = function(options) {
|
|
10185
|
+
const oldDecorator = ResourceDecorator.Action(options);
|
|
10186
|
+
const operators = ["create", "delete", "get", "update"];
|
|
10187
|
+
return (target, propertyKey) => {
|
|
10188
|
+
if (typeof propertyKey === "string" && operators.includes(propertyKey))
|
|
10189
|
+
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
10190
|
+
return oldDecorator(target, propertyKey);
|
|
10191
|
+
};
|
|
10192
|
+
};
|
|
10113
10193
|
function createOperationDecorator2(operation) {
|
|
10114
10194
|
return (options) => (target, propertyKey) => {
|
|
10115
10195
|
if (propertyKey !== operation)
|
|
10116
10196
|
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10117
10197
|
const operationMeta = { ...options };
|
|
10118
|
-
const
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
Reflect.defineMetadata(
|
|
10198
|
+
const sourceMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target.constructor) || {};
|
|
10199
|
+
sourceMetadata.operations = sourceMetadata.operations || {};
|
|
10200
|
+
sourceMetadata.operations[operation] = operationMeta;
|
|
10201
|
+
Reflect.defineMetadata(RESOURCE_METADATA, sourceMetadata, target.constructor);
|
|
10122
10202
|
};
|
|
10123
10203
|
}
|
|
10124
10204
|
__name(createOperationDecorator2, "createOperationDecorator");
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
Singleton2
|
|
10128
|
-
|
|
10205
|
+
|
|
10206
|
+
// ../../build/common/esm/document/resource/singleton.js
|
|
10207
|
+
var Singleton2 = /* @__PURE__ */ __name(function(...args) {
|
|
10208
|
+
if (!this) {
|
|
10209
|
+
const [type, options] = args;
|
|
10210
|
+
return Singleton2[DECORATOR].call(void 0, type, options);
|
|
10211
|
+
}
|
|
10212
|
+
const [document, init] = args;
|
|
10213
|
+
merge9(this, new SingletonClass(document, init), { descriptor: true });
|
|
10214
|
+
}, "Singleton");
|
|
10215
|
+
Singleton2.prototype = SingletonClass.prototype;
|
|
10216
|
+
Object.assign(Singleton2, SingletonDecorator);
|
|
10217
|
+
Singleton2[DECORATOR] = SingletonDecorator;
|
|
10129
10218
|
|
|
10130
10219
|
// ../../build/common/esm/document/resource/storage.js
|
|
10131
|
-
import
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
var NAME_PATTERN3 = /^(.*)(Resource)$/;
|
|
10220
|
+
import merge10 from "putil-merge";
|
|
10221
|
+
|
|
10222
|
+
// ../../build/common/esm/document/resource/storage-class.js
|
|
10135
10223
|
var StorageClass = class extends Resource {
|
|
10136
10224
|
static {
|
|
10137
10225
|
__name(this, "StorageClass");
|
|
@@ -10143,71 +10231,94 @@ var StorageClass = class extends Resource {
|
|
|
10143
10231
|
this.operations = { ...init.operations };
|
|
10144
10232
|
}
|
|
10145
10233
|
exportSchema() {
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
};
|
|
10153
|
-
var Storage2 = /* @__PURE__ */ __name(function(...args) {
|
|
10154
|
-
if (!this) {
|
|
10155
|
-
const [options] = args;
|
|
10156
|
-
return function(target) {
|
|
10157
|
-
const name = options?.name || target.name.match(NAME_PATTERN3)?.[1] || target.name;
|
|
10158
|
-
const metadata = Reflect.getOwnMetadata(METADATA_KEY, target) || {};
|
|
10159
|
-
metadata.kind = opra_schema_ns_exports.Storage.Kind;
|
|
10160
|
-
metadata.name = name;
|
|
10161
|
-
const m = Reflect.getMetadata(METADATA_KEY, target);
|
|
10162
|
-
if (m && metadata !== m)
|
|
10163
|
-
Object.assign(metadata, omit6(m), Object.keys(metadata));
|
|
10164
|
-
if (options)
|
|
10165
|
-
Object.assign(metadata, omit6(options, ["kind", "name", "type", "controller"]));
|
|
10166
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
10167
|
-
Reflect.defineMetadata(NESTJS_INJECTABLE_WATERMARK3, true, target);
|
|
10234
|
+
return {
|
|
10235
|
+
...super.exportSchema(),
|
|
10236
|
+
...omitUndefined({
|
|
10237
|
+
kind: opra_schema_ns_exports.Storage.Kind,
|
|
10238
|
+
operations: this.operations
|
|
10239
|
+
})
|
|
10168
10240
|
};
|
|
10169
10241
|
}
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10242
|
+
};
|
|
10243
|
+
|
|
10244
|
+
// ../../build/common/esm/document/resource/storage-decorator.js
|
|
10245
|
+
import omit6 from "lodash.omit";
|
|
10246
|
+
var NAME_PATTERN3 = /^(.*)(Resource|Storage|Controller)$/;
|
|
10247
|
+
function StorageDecorator(options) {
|
|
10248
|
+
return function(target) {
|
|
10249
|
+
const name = options?.name || target.name.match(NAME_PATTERN3)?.[1] || target.name;
|
|
10250
|
+
const metadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target) || {};
|
|
10251
|
+
metadata.kind = opra_schema_ns_exports.Storage.Kind;
|
|
10252
|
+
metadata.name = name;
|
|
10253
|
+
const m = Reflect.getMetadata(RESOURCE_METADATA, target);
|
|
10254
|
+
if (m && metadata !== m)
|
|
10255
|
+
Object.assign(metadata, omit6(m), Object.keys(metadata));
|
|
10256
|
+
if (options)
|
|
10257
|
+
Object.assign(metadata, omit6(options, ["kind", "name", "type", "controller"]));
|
|
10258
|
+
Reflect.defineMetadata(RESOURCE_METADATA, metadata, target);
|
|
10259
|
+
};
|
|
10260
|
+
}
|
|
10261
|
+
__name(StorageDecorator, "StorageDecorator");
|
|
10262
|
+
Object.assign(StorageDecorator, ResourceDecorator);
|
|
10263
|
+
StorageDecorator.Delete = createOperationDecorator3("delete");
|
|
10264
|
+
StorageDecorator.Get = createOperationDecorator3("get");
|
|
10265
|
+
StorageDecorator.Post = createOperationDecorator3("post");
|
|
10266
|
+
StorageDecorator.Action = function(options) {
|
|
10267
|
+
const oldDecorator = ResourceDecorator.Action(options);
|
|
10268
|
+
const operators = ["delete", "get", "post"];
|
|
10269
|
+
return (target, propertyKey) => {
|
|
10270
|
+
if (typeof propertyKey === "string" && operators.includes(propertyKey))
|
|
10271
|
+
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
10272
|
+
return oldDecorator(target, propertyKey);
|
|
10273
|
+
};
|
|
10274
|
+
};
|
|
10174
10275
|
function createOperationDecorator3(operation) {
|
|
10175
10276
|
return (options) => (target, propertyKey) => {
|
|
10176
10277
|
if (propertyKey !== operation)
|
|
10177
10278
|
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10178
10279
|
const operationMeta = { ...options };
|
|
10179
|
-
const
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
Reflect.defineMetadata(
|
|
10280
|
+
const sourceMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target.constructor) || {};
|
|
10281
|
+
sourceMetadata.operations = sourceMetadata.operations || {};
|
|
10282
|
+
sourceMetadata.operations[operation] = operationMeta;
|
|
10283
|
+
Reflect.defineMetadata(RESOURCE_METADATA, sourceMetadata, target.constructor);
|
|
10183
10284
|
};
|
|
10184
10285
|
}
|
|
10185
10286
|
__name(createOperationDecorator3, "createOperationDecorator");
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
Storage2
|
|
10287
|
+
|
|
10288
|
+
// ../../build/common/esm/document/resource/storage.js
|
|
10289
|
+
var Storage2 = /* @__PURE__ */ __name(function(...args) {
|
|
10290
|
+
if (!this) {
|
|
10291
|
+
const [options] = args;
|
|
10292
|
+
return Storage2[DECORATOR].call(void 0, options);
|
|
10293
|
+
}
|
|
10294
|
+
const [document, init] = args;
|
|
10295
|
+
merge10(this, new StorageClass(document, init), { descriptor: true });
|
|
10296
|
+
}, "Storage");
|
|
10297
|
+
Storage2.prototype = StorageClass.prototype;
|
|
10298
|
+
Object.assign(Storage2, StorageDecorator);
|
|
10299
|
+
Storage2[DECORATOR] = StorageDecorator;
|
|
10189
10300
|
|
|
10190
10301
|
// ../../build/common/esm/document/factory/process-resources.js
|
|
10191
|
-
async function
|
|
10192
|
-
const { document,
|
|
10193
|
-
const
|
|
10194
|
-
for (const name of
|
|
10195
|
-
const schema =
|
|
10302
|
+
async function processSourceQueue() {
|
|
10303
|
+
const { document, sourceQueue } = this;
|
|
10304
|
+
const sourceNames = Array.from(sourceQueue.keys());
|
|
10305
|
+
for (const name of sourceNames) {
|
|
10306
|
+
const schema = sourceQueue.get(name);
|
|
10196
10307
|
if (!schema)
|
|
10197
10308
|
continue;
|
|
10198
10309
|
try {
|
|
10199
10310
|
if (opra_schema_ns_exports.isCollection(schema)) {
|
|
10200
|
-
const resource = await this.
|
|
10311
|
+
const resource = await this.createCollectionSource(name, schema);
|
|
10201
10312
|
document.resources.set(name, resource);
|
|
10202
10313
|
continue;
|
|
10203
10314
|
}
|
|
10204
10315
|
if (opra_schema_ns_exports.isSingleton(schema)) {
|
|
10205
|
-
const resource = await this.
|
|
10316
|
+
const resource = await this.createSingletonSource(name, schema);
|
|
10206
10317
|
document.resources.set(name, resource);
|
|
10207
10318
|
continue;
|
|
10208
10319
|
}
|
|
10209
10320
|
if (opra_schema_ns_exports.isStorage(schema)) {
|
|
10210
|
-
const resource = await this.
|
|
10321
|
+
const resource = await this.createFileSource(name, schema);
|
|
10211
10322
|
document.resources.set(name, resource);
|
|
10212
10323
|
continue;
|
|
10213
10324
|
}
|
|
@@ -10218,7 +10329,7 @@ async function processResourceQueue() {
|
|
|
10218
10329
|
throw new TypeError(`Invalid Resource schema: ${JSON.stringify(schema).substring(0, 20)}...`);
|
|
10219
10330
|
}
|
|
10220
10331
|
}
|
|
10221
|
-
__name(
|
|
10332
|
+
__name(processSourceQueue, "processSourceQueue");
|
|
10222
10333
|
async function createCollectionResource(name, schema) {
|
|
10223
10334
|
const { document } = this;
|
|
10224
10335
|
const dataType = document.getComplexType(schema.type);
|
|
@@ -10241,7 +10352,7 @@ async function createSingletonResource(name, schema) {
|
|
|
10241
10352
|
return new Singleton2(document, initArgs);
|
|
10242
10353
|
}
|
|
10243
10354
|
__name(createSingletonResource, "createSingletonResource");
|
|
10244
|
-
async function
|
|
10355
|
+
async function createStorageResource(name, schema) {
|
|
10245
10356
|
const { document } = this;
|
|
10246
10357
|
const initArgs = {
|
|
10247
10358
|
...schema,
|
|
@@ -10249,7 +10360,7 @@ async function createFileResource(name, schema) {
|
|
|
10249
10360
|
};
|
|
10250
10361
|
return new Storage2(document, initArgs);
|
|
10251
10362
|
}
|
|
10252
|
-
__name(
|
|
10363
|
+
__name(createStorageResource, "createStorageResource");
|
|
10253
10364
|
|
|
10254
10365
|
// ../../build/common/esm/document/factory/process-types.js
|
|
10255
10366
|
async function processTypes() {
|
|
@@ -10429,7 +10540,7 @@ var DocumentFactory = class _DocumentFactory {
|
|
|
10429
10540
|
constructor() {
|
|
10430
10541
|
this.document = new ApiDocument();
|
|
10431
10542
|
this.typeQueue = new ResponsiveMap();
|
|
10432
|
-
this.
|
|
10543
|
+
this.sourceQueue = new ResponsiveMap();
|
|
10433
10544
|
this.circularRefs = new ResponsiveMap();
|
|
10434
10545
|
this.curPath = [];
|
|
10435
10546
|
this.cache = /* @__PURE__ */ new Map();
|
|
@@ -10467,13 +10578,13 @@ DocumentFactory.designTypeMap = /* @__PURE__ */ new Map();
|
|
|
10467
10578
|
_a2.prototype.processTypes = processTypes;
|
|
10468
10579
|
_a2.prototype.createDataTypeInstance = createDataTypeInstance;
|
|
10469
10580
|
_a2.prototype.addDataType = addDataType;
|
|
10470
|
-
_a2.prototype.
|
|
10581
|
+
_a2.prototype.importSourceClass = importResourceClass;
|
|
10471
10582
|
_a2.prototype.extractSingletonSchema = extractSingletonSchema;
|
|
10472
10583
|
_a2.prototype.extractCollectionSchema = extractCollectionSchema;
|
|
10473
|
-
_a2.prototype.
|
|
10474
|
-
_a2.prototype.
|
|
10475
|
-
_a2.prototype.
|
|
10476
|
-
_a2.prototype.
|
|
10584
|
+
_a2.prototype.processSourceQueue = processSourceQueue;
|
|
10585
|
+
_a2.prototype.createCollectionSource = createCollectionResource;
|
|
10586
|
+
_a2.prototype.createSingletonSource = createSingletonResource;
|
|
10587
|
+
_a2.prototype.createFileSource = createStorageResource;
|
|
10477
10588
|
})();
|
|
10478
10589
|
|
|
10479
10590
|
// ../../build/common/esm/http/opra-url.js
|
|
@@ -11188,6 +11299,8 @@ export {
|
|
|
11188
11299
|
BaseI18n,
|
|
11189
11300
|
Collection2 as Collection,
|
|
11190
11301
|
ComplexType2 as ComplexType,
|
|
11302
|
+
DATATYPE_METADATA,
|
|
11303
|
+
DECORATOR,
|
|
11191
11304
|
DataType,
|
|
11192
11305
|
DocumentFactory,
|
|
11193
11306
|
EnumType2 as EnumType,
|
|
@@ -11199,7 +11312,6 @@ export {
|
|
|
11199
11312
|
I18n,
|
|
11200
11313
|
InternalServerError,
|
|
11201
11314
|
IssueSeverity,
|
|
11202
|
-
METADATA_KEY,
|
|
11203
11315
|
MappedType2 as MappedType,
|
|
11204
11316
|
MethodNotAllowedError,
|
|
11205
11317
|
NAMESPACE_PATTERN,
|
|
@@ -11212,6 +11324,7 @@ export {
|
|
|
11212
11324
|
OpraURL,
|
|
11213
11325
|
OpraURLPath,
|
|
11214
11326
|
PickType,
|
|
11327
|
+
RESOURCE_METADATA,
|
|
11215
11328
|
Resource,
|
|
11216
11329
|
ResourceConflictError,
|
|
11217
11330
|
ResourceNotFoundError,
|