@opra/common 0.23.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.js +298 -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 +9 -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 +11 -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/is-url-string.js +1 -2
- package/cjs/helpers/mixin-utils.js +2 -2
- package/cjs/schema/opra-schema.ns.js +0 -1
- package/cjs/schema/type-guards.js +3 -3
- 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 +5 -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 +11 -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/is-url-string.js +0 -1
- package/esm/helpers/mixin-utils.js +2 -2
- package/esm/schema/opra-schema.ns.js +0 -1
- package/esm/schema/type-guards.js +1 -1
- 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 +4 -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 +8 -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 SOURCE_METADATA = Symbol("SOURCE_METADATA");
|
|
19
|
+
var DECORATOR = Symbol("DECORATOR");
|
|
18
20
|
var NAMESPACE_PATTERN = /([A-Z$_]\w+)(?::.+)?/i;
|
|
19
21
|
var TYPENAME_PATTERN = /^(.*)Type(\d*)$/;
|
|
20
22
|
|
|
@@ -104,7 +106,6 @@ function getStackFileName(position = 1) {
|
|
|
104
106
|
__name(getStackFileName, "getStackFileName");
|
|
105
107
|
|
|
106
108
|
// ../../build/common/esm/helpers/is-url-string.js
|
|
107
|
-
import { URL } from "url";
|
|
108
109
|
var URL_PATTERN = /^(https?:\/\/.)[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/i;
|
|
109
110
|
function isUrlString(url) {
|
|
110
111
|
return URL_PATTERN.test(url);
|
|
@@ -123,9 +124,9 @@ function mergePrototype(targetProto, baseProto, filter) {
|
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
__name(mergePrototype, "mergePrototype");
|
|
126
|
-
function inheritPropertyInitializers(target,
|
|
127
|
+
function inheritPropertyInitializers(target, clazz, isPropertyInherited = (key) => true) {
|
|
127
128
|
try {
|
|
128
|
-
const tempInstance = new
|
|
129
|
+
const tempInstance = new clazz();
|
|
129
130
|
const propertyNames = Object.getOwnPropertyNames(tempInstance);
|
|
130
131
|
propertyNames.filter((propertyName) => typeof tempInstance[propertyName] !== "undefined" && typeof target[propertyName] === "undefined").filter((propertyName) => isPropertyInherited(propertyName)).forEach((propertyName) => {
|
|
131
132
|
target[propertyName] = tempInstance[propertyName];
|
|
@@ -855,7 +856,7 @@ var ResourceNotFoundError = class extends OpraException {
|
|
|
855
856
|
}
|
|
856
857
|
constructor(resource, keyValue, cause) {
|
|
857
858
|
super({
|
|
858
|
-
message: translate(`error:RESOURCE_NOT_FOUND`,
|
|
859
|
+
message: translate(`error:RESOURCE_NOT_FOUND`, `Resource not found`),
|
|
859
860
|
severity: "error",
|
|
860
861
|
code: "RESOURCE_NOT_FOUND",
|
|
861
862
|
details: {
|
|
@@ -896,9 +897,9 @@ __export(opra_schema_ns_exports, {
|
|
|
896
897
|
isDataType: () => isDataType,
|
|
897
898
|
isEnumType: () => isEnumType,
|
|
898
899
|
isMappedType: () => isMappedType,
|
|
899
|
-
isResource: () => isResource,
|
|
900
900
|
isSimpleType: () => isSimpleType,
|
|
901
901
|
isSingleton: () => isSingleton,
|
|
902
|
+
isSource: () => isSource,
|
|
902
903
|
isStorage: () => isStorage,
|
|
903
904
|
isUnionType: () => isUnionType
|
|
904
905
|
});
|
|
@@ -985,10 +986,10 @@ function isEnumType(obj) {
|
|
|
985
986
|
return obj && typeof obj === "object" && obj.kind === EnumType.Kind;
|
|
986
987
|
}
|
|
987
988
|
__name(isEnumType, "isEnumType");
|
|
988
|
-
function
|
|
989
|
+
function isSource(obj) {
|
|
989
990
|
return obj && typeof obj === "object" && (obj.kind === Container.Kind || obj.kind === Collection.Kind || obj.kind === Singleton.Kind);
|
|
990
991
|
}
|
|
991
|
-
__name(
|
|
992
|
+
__name(isSource, "isSource");
|
|
992
993
|
function isCollection(obj) {
|
|
993
994
|
return obj && typeof obj === "object" && obj.kind === Collection.Kind;
|
|
994
995
|
}
|
|
@@ -1091,18 +1092,18 @@ var EnumType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
1091
1092
|
merge2(this, new EnumTypeClass(document, init), { descriptor: true });
|
|
1092
1093
|
return;
|
|
1093
1094
|
}
|
|
1094
|
-
const [
|
|
1095
|
-
const values = Array.isArray(
|
|
1095
|
+
const [enumSource, options] = args;
|
|
1096
|
+
const values = Array.isArray(enumSource) ? enumSource.reduce((obj, v) => {
|
|
1096
1097
|
obj[v] = v;
|
|
1097
1098
|
return obj;
|
|
1098
|
-
}, {}) :
|
|
1099
|
+
}, {}) : enumSource;
|
|
1099
1100
|
const metadata = {
|
|
1100
1101
|
kind: opra_schema_ns_exports.EnumType.Kind,
|
|
1101
1102
|
values
|
|
1102
1103
|
};
|
|
1103
1104
|
if (options)
|
|
1104
1105
|
Object.assign(metadata, omit(options, ["kind", "values"]));
|
|
1105
|
-
Reflect.defineMetadata(
|
|
1106
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, enumSource);
|
|
1106
1107
|
return values;
|
|
1107
1108
|
}, "EnumType");
|
|
1108
1109
|
EnumType2.prototype = EnumTypeClass.prototype;
|
|
@@ -1114,7 +1115,7 @@ var ApiField = /* @__PURE__ */ __name(function(...args) {
|
|
|
1114
1115
|
return function(target, propertyKey) {
|
|
1115
1116
|
if (typeof propertyKey !== "string")
|
|
1116
1117
|
throw new TypeError(`Symbol properties can't be used as a field`);
|
|
1117
|
-
const metadata = Reflect.getOwnMetadata(
|
|
1118
|
+
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target.constructor) || {};
|
|
1118
1119
|
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1119
1120
|
metadata.fields = metadata.fields || {};
|
|
1120
1121
|
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
@@ -1137,13 +1138,13 @@ var ApiField = /* @__PURE__ */ __name(function(...args) {
|
|
|
1137
1138
|
EnumType2(enumObj);
|
|
1138
1139
|
elemMeta.enum = enumObj;
|
|
1139
1140
|
} else {
|
|
1140
|
-
const m = Reflect.getOwnMetadata(
|
|
1141
|
+
const m = Reflect.getOwnMetadata(DATATYPE_METADATA, options?.enum);
|
|
1141
1142
|
if (!opra_schema_ns_exports.isEnumType(m))
|
|
1142
1143
|
throw new TypeError(`Invalid "enum" value. Did you forget to set metadata using EnumType() method?`);
|
|
1143
1144
|
elemMeta.enum = options.enum;
|
|
1144
1145
|
}
|
|
1145
1146
|
}
|
|
1146
|
-
Reflect.defineMetadata(
|
|
1147
|
+
Reflect.defineMetadata(DATATYPE_METADATA, omitUndefined(metadata), target.constructor);
|
|
1147
1148
|
};
|
|
1148
1149
|
}
|
|
1149
1150
|
const [owner, init] = args;
|
|
@@ -1326,10 +1327,10 @@ var ComplexType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
1326
1327
|
const [options] = args;
|
|
1327
1328
|
return function(target) {
|
|
1328
1329
|
const name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1329
|
-
let metadata = Reflect.getOwnMetadata(
|
|
1330
|
+
let metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target);
|
|
1330
1331
|
if (!metadata) {
|
|
1331
1332
|
metadata = {};
|
|
1332
|
-
Reflect.defineMetadata(
|
|
1333
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1333
1334
|
}
|
|
1334
1335
|
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1335
1336
|
metadata.name = name;
|
|
@@ -1620,12 +1621,12 @@ var SimpleType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
1620
1621
|
return function(target) {
|
|
1621
1622
|
let name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1622
1623
|
name = name.charAt(0).toLowerCase() + name.substring(1);
|
|
1623
|
-
const metadata = Reflect.getOwnMetadata(
|
|
1624
|
+
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target) || {};
|
|
1624
1625
|
metadata.kind = opra_schema_ns_exports.SimpleType.Kind;
|
|
1625
1626
|
metadata.name = name;
|
|
1626
1627
|
if (options)
|
|
1627
1628
|
Object.assign(metadata, omit3(options, ["kind", "name"]));
|
|
1628
|
-
Reflect.defineMetadata(
|
|
1629
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1629
1630
|
};
|
|
1630
1631
|
}, "SimpleType");
|
|
1631
1632
|
SimpleType2.prototype = SimpleTypeClass.prototype;
|
|
@@ -1881,10 +1882,10 @@ async function createDocument(init, options) {
|
|
|
1881
1882
|
this.curPath.push("resources");
|
|
1882
1883
|
if (Array.isArray(init.resources)) {
|
|
1883
1884
|
for (const res of init.resources)
|
|
1884
|
-
await this.
|
|
1885
|
+
await this.importSourceClass(res);
|
|
1885
1886
|
} else
|
|
1886
|
-
this.
|
|
1887
|
-
await this.
|
|
1887
|
+
this.sourceQueue.setAll(init.resources);
|
|
1888
|
+
await this.processSourceQueue();
|
|
1888
1889
|
this.curPath.pop();
|
|
1889
1890
|
}
|
|
1890
1891
|
this.document.types.sort();
|
|
@@ -1942,14 +1943,14 @@ __name(createBuiltinTypeDocument, "createBuiltinTypeDocument");
|
|
|
1942
1943
|
// ../../build/common/esm/document/factory/import-resource-class.js
|
|
1943
1944
|
import "reflect-metadata";
|
|
1944
1945
|
async function importResourceClass(thunk) {
|
|
1945
|
-
const { document,
|
|
1946
|
+
const { document, sourceQueue, cache } = this;
|
|
1946
1947
|
const controller = await resolveThunk(thunk);
|
|
1947
1948
|
const cached = cache.get(controller);
|
|
1948
1949
|
if (cached)
|
|
1949
1950
|
return cached;
|
|
1950
1951
|
const ctor = typeof thunk === "function" ? thunk : Object.getPrototypeOf(thunk).constructor;
|
|
1951
|
-
let metadata = Reflect.getMetadata(
|
|
1952
|
-
if (!metadata && opra_schema_ns_exports.
|
|
1952
|
+
let metadata = Reflect.getMetadata(SOURCE_METADATA, ctor);
|
|
1953
|
+
if (!metadata && opra_schema_ns_exports.isSource(metadata))
|
|
1953
1954
|
throw new TypeError(`Class "${ctor.name}" doesn't have a valid Resource metadata`);
|
|
1954
1955
|
metadata = cloneObject(metadata);
|
|
1955
1956
|
const schema = cloneObject(metadata);
|
|
@@ -1969,7 +1970,7 @@ async function importResourceClass(thunk) {
|
|
|
1969
1970
|
await this.extractSingletonSchema(schema, ctor, metadata, controller);
|
|
1970
1971
|
if (opra_schema_ns_exports.isCollection(schema))
|
|
1971
1972
|
await this.extractCollectionSchema(schema, ctor, metadata, controller);
|
|
1972
|
-
|
|
1973
|
+
sourceQueue.set(metadata.name, schema);
|
|
1973
1974
|
}
|
|
1974
1975
|
__name(importResourceClass, "importResourceClass");
|
|
1975
1976
|
async function extractSingletonSchema(target, ctor, metadata, controller) {
|
|
@@ -1990,7 +1991,7 @@ async function importTypeClass(typeThunk) {
|
|
|
1990
1991
|
const dt = document.getDataType(thunk, true);
|
|
1991
1992
|
if (dt && dt.name)
|
|
1992
1993
|
return dt.name;
|
|
1993
|
-
const metadata = Reflect.getMetadata(
|
|
1994
|
+
const metadata = Reflect.getMetadata(DATATYPE_METADATA, thunk);
|
|
1994
1995
|
if (!(metadata && opra_schema_ns_exports.isDataType(metadata))) {
|
|
1995
1996
|
if (isConstructor(thunk))
|
|
1996
1997
|
throw new TypeError(`Class "${thunk.name}" doesn't have a valid DataType metadata`);
|
|
@@ -2022,7 +2023,7 @@ async function importTypeClass(typeThunk) {
|
|
|
2022
2023
|
const enumObject = thunk;
|
|
2023
2024
|
if (opra_schema_ns_exports.isEnumType(schema)) {
|
|
2024
2025
|
let baseType;
|
|
2025
|
-
if (metadata.base && Reflect.hasMetadata(
|
|
2026
|
+
if (metadata.base && Reflect.hasMetadata(DATATYPE_METADATA, metadata.base)) {
|
|
2026
2027
|
baseType = await this.importTypeClass(metadata.base);
|
|
2027
2028
|
}
|
|
2028
2029
|
schema.base = baseType;
|
|
@@ -2034,7 +2035,7 @@ async function importTypeClass(typeThunk) {
|
|
|
2034
2035
|
__name(importTypeClass, "importTypeClass");
|
|
2035
2036
|
async function extractSimpleTypeSchema(target, ctor, metadata) {
|
|
2036
2037
|
const baseClass = Object.getPrototypeOf(ctor.prototype).constructor;
|
|
2037
|
-
if (Reflect.hasMetadata(
|
|
2038
|
+
if (Reflect.hasMetadata(DATATYPE_METADATA, baseClass))
|
|
2038
2039
|
target.base = await this.importTypeClass(baseClass);
|
|
2039
2040
|
if (typeof ctor.prototype.decode === "function")
|
|
2040
2041
|
target.decoder = validator(metadata.name, ctor.prototype.decode);
|
|
@@ -2044,7 +2045,7 @@ async function extractSimpleTypeSchema(target, ctor, metadata) {
|
|
|
2044
2045
|
__name(extractSimpleTypeSchema, "extractSimpleTypeSchema");
|
|
2045
2046
|
async function extractComplexTypeSchema(target, ctor, metadata) {
|
|
2046
2047
|
const baseClass = Object.getPrototypeOf(ctor.prototype).constructor;
|
|
2047
|
-
if (Reflect.hasMetadata(
|
|
2048
|
+
if (Reflect.hasMetadata(DATATYPE_METADATA, baseClass))
|
|
2048
2049
|
target.base = await this.importTypeClass(baseClass);
|
|
2049
2050
|
target.ctor = target.ctor || ctor;
|
|
2050
2051
|
if (metadata.fields) {
|
|
@@ -2101,8 +2102,9 @@ async function extractFieldSchema(target, ctor, metadata, name) {
|
|
|
2101
2102
|
__name(extractFieldSchema, "extractFieldSchema");
|
|
2102
2103
|
|
|
2103
2104
|
// ../../build/common/esm/document/resource/collection.js
|
|
2104
|
-
import
|
|
2105
|
-
|
|
2105
|
+
import merge8 from "putil-merge";
|
|
2106
|
+
|
|
2107
|
+
// ../../build/common/esm/document/resource/collection-class.js
|
|
2106
2108
|
import * as vg4 from "valgen";
|
|
2107
2109
|
|
|
2108
2110
|
// ../../build/common/esm/filter/opra-filter.ns.js
|
|
@@ -9660,32 +9662,32 @@ var MappedType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9660
9662
|
merge5(this, new MappedTypeClass(document, init), { descriptor: true });
|
|
9661
9663
|
return;
|
|
9662
9664
|
}
|
|
9663
|
-
const [
|
|
9665
|
+
const [mappedSource, options] = args;
|
|
9664
9666
|
const isInheritedPredicate = getIsInheritedPredicateFn(options.pick, options.omit);
|
|
9665
9667
|
class MappedClass {
|
|
9666
9668
|
static {
|
|
9667
9669
|
__name(this, "MappedClass");
|
|
9668
9670
|
}
|
|
9669
9671
|
constructor() {
|
|
9670
|
-
inheritPropertyInitializers(this,
|
|
9672
|
+
inheritPropertyInitializers(this, mappedSource, isInheritedPredicate);
|
|
9671
9673
|
}
|
|
9672
9674
|
}
|
|
9673
|
-
mergePrototype(MappedClass.prototype,
|
|
9674
|
-
const m = Reflect.getOwnMetadata(
|
|
9675
|
+
mergePrototype(MappedClass.prototype, mappedSource.prototype);
|
|
9676
|
+
const m = Reflect.getOwnMetadata(DATATYPE_METADATA, mappedSource);
|
|
9675
9677
|
if (!m)
|
|
9676
|
-
throw new TypeError(`Class "${
|
|
9678
|
+
throw new TypeError(`Class "${mappedSource}" doesn't have datatype metadata information`);
|
|
9677
9679
|
if (!(m.kind === opra_schema_ns_exports.ComplexType.Kind))
|
|
9678
|
-
throw new TypeError(`Class "${
|
|
9680
|
+
throw new TypeError(`Class "${mappedSource}" is not a ${opra_schema_ns_exports.ComplexType.Kind}`);
|
|
9679
9681
|
const metadata = {
|
|
9680
9682
|
kind: "MappedType",
|
|
9681
|
-
type:
|
|
9683
|
+
type: mappedSource
|
|
9682
9684
|
};
|
|
9683
9685
|
if (options.pick)
|
|
9684
9686
|
metadata.pick = options.pick;
|
|
9685
9687
|
if (options.omit)
|
|
9686
9688
|
metadata.omit = options.omit;
|
|
9687
|
-
Reflect.defineMetadata(
|
|
9688
|
-
MappedType2._applyMixin(MappedClass,
|
|
9689
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, MappedClass);
|
|
9690
|
+
MappedType2._applyMixin(MappedClass, mappedSource, {
|
|
9689
9691
|
...options,
|
|
9690
9692
|
isInheritedPredicate
|
|
9691
9693
|
});
|
|
@@ -9769,9 +9771,9 @@ var UnionType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9769
9771
|
kind: opra_schema_ns_exports.UnionType.Kind,
|
|
9770
9772
|
types: []
|
|
9771
9773
|
};
|
|
9772
|
-
Reflect.defineMetadata(
|
|
9774
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, UnionClass);
|
|
9773
9775
|
for (const c of clasRefs) {
|
|
9774
|
-
const itemMeta = Reflect.getMetadata(
|
|
9776
|
+
const itemMeta = Reflect.getMetadata(DATATYPE_METADATA, c);
|
|
9775
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)))
|
|
9776
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}`);
|
|
9777
9779
|
metadata.types.push(c);
|
|
@@ -9785,17 +9787,17 @@ UnionType2._applyMixin = () => void 0;
|
|
|
9785
9787
|
|
|
9786
9788
|
// ../../build/common/esm/document/utils/generate-codec.js
|
|
9787
9789
|
function generateCodec(type, codec, options) {
|
|
9788
|
-
return
|
|
9790
|
+
return _generateCodec(type, codec, options);
|
|
9789
9791
|
}
|
|
9790
9792
|
__name(generateCodec, "generateCodec");
|
|
9791
|
-
function
|
|
9793
|
+
function _generateCodec(type, codec, options) {
|
|
9792
9794
|
const schema = {};
|
|
9793
9795
|
for (const f of type.fields.values()) {
|
|
9794
9796
|
let fn;
|
|
9795
9797
|
if (f.type instanceof SimpleType2 || f.type instanceof EnumType2) {
|
|
9796
9798
|
fn = f.type[codec];
|
|
9797
9799
|
} else if (f.type instanceof ComplexType2 || f.type instanceof MappedType2 || f.type instanceof UnionType2) {
|
|
9798
|
-
fn =
|
|
9800
|
+
fn = _generateCodec(f.type, codec, options);
|
|
9799
9801
|
}
|
|
9800
9802
|
if (!fn)
|
|
9801
9803
|
throw new TypeError(`Can't generate codec for (${f.type})`);
|
|
@@ -9810,7 +9812,7 @@ function _generateDecoder(type, codec, options) {
|
|
|
9810
9812
|
caseInSensitive: true
|
|
9811
9813
|
});
|
|
9812
9814
|
}
|
|
9813
|
-
__name(
|
|
9815
|
+
__name(_generateCodec, "_generateCodec");
|
|
9814
9816
|
|
|
9815
9817
|
// ../../build/common/esm/document/resource/resource.js
|
|
9816
9818
|
var Resource = class {
|
|
@@ -9818,16 +9820,24 @@ var Resource = class {
|
|
|
9818
9820
|
__name(this, "Resource");
|
|
9819
9821
|
}
|
|
9820
9822
|
constructor(document, init) {
|
|
9823
|
+
this.actions = new ResponsiveMap();
|
|
9821
9824
|
this.document = document;
|
|
9822
9825
|
this.name = init.name;
|
|
9823
9826
|
this.description = init.description;
|
|
9824
9827
|
this.controller = init.controller;
|
|
9825
9828
|
}
|
|
9826
9829
|
exportSchema() {
|
|
9827
|
-
|
|
9830
|
+
const schema = omitUndefined({
|
|
9828
9831
|
kind: this.kind,
|
|
9829
9832
|
description: this.description
|
|
9830
9833
|
});
|
|
9834
|
+
if (this.actions.size) {
|
|
9835
|
+
const actions = schema.actions = {};
|
|
9836
|
+
for (const [name, r] of this.actions.entries()) {
|
|
9837
|
+
actions[name] = r.exportSchema();
|
|
9838
|
+
}
|
|
9839
|
+
}
|
|
9840
|
+
return schema;
|
|
9831
9841
|
}
|
|
9832
9842
|
toString() {
|
|
9833
9843
|
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name || "#anonymous"}]`;
|
|
@@ -9837,9 +9847,7 @@ var Resource = class {
|
|
|
9837
9847
|
}
|
|
9838
9848
|
};
|
|
9839
9849
|
|
|
9840
|
-
// ../../build/common/esm/document/resource/collection.js
|
|
9841
|
-
var NESTJS_INJECTABLE_WATERMARK = "__injectable__";
|
|
9842
|
-
var NAME_PATTERN = /^(.*)(Resource|Collection)$/;
|
|
9850
|
+
// ../../build/common/esm/document/resource/collection-class.js
|
|
9843
9851
|
var CollectionClass = class extends Resource {
|
|
9844
9852
|
static {
|
|
9845
9853
|
__name(this, "CollectionClass");
|
|
@@ -9862,13 +9870,14 @@ var CollectionClass = class extends Resource {
|
|
|
9862
9870
|
});
|
|
9863
9871
|
}
|
|
9864
9872
|
exportSchema() {
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9873
|
+
return {
|
|
9874
|
+
...super.exportSchema(),
|
|
9875
|
+
...omitUndefined({
|
|
9876
|
+
type: this.type.name || "object",
|
|
9877
|
+
operations: this.operations,
|
|
9878
|
+
primaryKey: this.primaryKey
|
|
9879
|
+
})
|
|
9880
|
+
};
|
|
9872
9881
|
}
|
|
9873
9882
|
parseKeyValue(value) {
|
|
9874
9883
|
if (!this.primaryKey?.length)
|
|
@@ -9964,84 +9973,121 @@ var CollectionClass = class extends Resource {
|
|
|
9964
9973
|
}
|
|
9965
9974
|
return ast;
|
|
9966
9975
|
}
|
|
9967
|
-
getDecoder(
|
|
9968
|
-
let decoder = this._decoders[
|
|
9976
|
+
getDecoder(endpoint) {
|
|
9977
|
+
let decoder = this._decoders[endpoint];
|
|
9969
9978
|
if (decoder)
|
|
9970
9979
|
return decoder;
|
|
9971
9980
|
const options = {
|
|
9972
|
-
partial:
|
|
9981
|
+
partial: endpoint !== "create"
|
|
9973
9982
|
};
|
|
9974
|
-
if (
|
|
9983
|
+
if (endpoint !== "create")
|
|
9975
9984
|
options.omit = [...this.primaryKey];
|
|
9976
9985
|
decoder = generateCodec(this.type, "decode", options);
|
|
9977
|
-
this._decoders[
|
|
9986
|
+
this._decoders[endpoint] = decoder;
|
|
9978
9987
|
return decoder;
|
|
9979
9988
|
}
|
|
9980
|
-
getEncoder(
|
|
9981
|
-
let encoder = this._encoders[
|
|
9989
|
+
getEncoder(endpoint) {
|
|
9990
|
+
let encoder = this._encoders[endpoint];
|
|
9982
9991
|
if (encoder)
|
|
9983
9992
|
return encoder;
|
|
9984
9993
|
const options = {
|
|
9985
9994
|
partial: true
|
|
9986
9995
|
};
|
|
9987
9996
|
encoder = generateCodec(this.type, "encode", options);
|
|
9988
|
-
if (
|
|
9997
|
+
if (endpoint === "findMany")
|
|
9989
9998
|
return vg4.isArray(encoder);
|
|
9990
|
-
this._encoders[
|
|
9999
|
+
this._encoders[endpoint] = encoder;
|
|
9991
10000
|
return encoder;
|
|
9992
10001
|
}
|
|
9993
10002
|
};
|
|
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
|
-
|
|
10019
|
-
|
|
10003
|
+
|
|
10004
|
+
// ../../build/common/esm/document/resource/collection-decorator.js
|
|
10005
|
+
import omit4 from "lodash.omit";
|
|
10006
|
+
import merge7 from "putil-merge";
|
|
10007
|
+
|
|
10008
|
+
// ../../build/common/esm/document/resource/resource-decorator.js
|
|
10009
|
+
var ResourceDecorator = {};
|
|
10010
|
+
ResourceDecorator.Action = function(options) {
|
|
10011
|
+
return (target, propertyKey) => {
|
|
10012
|
+
if (typeof propertyKey !== "string")
|
|
10013
|
+
throw new TypeError(`This decorator can't be used for Symbol keys'`);
|
|
10014
|
+
const actionMeta = { ...options };
|
|
10015
|
+
const resourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
|
|
10016
|
+
resourceMetadata.actions = resourceMetadata.actions || {};
|
|
10017
|
+
resourceMetadata.actions[propertyKey] = actionMeta;
|
|
10018
|
+
Reflect.defineMetadata(SOURCE_METADATA, resourceMetadata, target.constructor);
|
|
10019
|
+
};
|
|
10020
|
+
};
|
|
10021
|
+
|
|
10022
|
+
// ../../build/common/esm/document/resource/collection-decorator.js
|
|
10023
|
+
var NAME_PATTERN = /^(.*)(Resource|Collection|Controller)$/;
|
|
10024
|
+
var operationProperties = ["create", "delete", "deleteMany", "get", "findMany", "update", "updateMany"];
|
|
10025
|
+
function CollectionDecorator(type, options) {
|
|
10026
|
+
return function(target) {
|
|
10027
|
+
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
10028
|
+
const metadata = Reflect.getOwnMetadata(SOURCE_METADATA, target) || {};
|
|
10029
|
+
const baseMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, Object.getPrototypeOf(target));
|
|
10030
|
+
if (baseMetadata) {
|
|
10031
|
+
merge7(metadata, baseMetadata, { deep: true });
|
|
10032
|
+
}
|
|
10033
|
+
metadata.kind = opra_schema_ns_exports.Collection.Kind;
|
|
10034
|
+
metadata.name = name;
|
|
10035
|
+
metadata.type = type;
|
|
10036
|
+
const m = Reflect.getMetadata(SOURCE_METADATA, target);
|
|
10037
|
+
if (m && metadata !== m)
|
|
10038
|
+
Object.assign(metadata, omit4(m), Object.keys(metadata));
|
|
10039
|
+
if (options)
|
|
10040
|
+
Object.assign(metadata, omit4(options, ["kind", "name", "type", "controller"]));
|
|
10041
|
+
Reflect.defineMetadata(SOURCE_METADATA, metadata, target);
|
|
10042
|
+
};
|
|
10043
|
+
}
|
|
10044
|
+
__name(CollectionDecorator, "CollectionDecorator");
|
|
10045
|
+
Object.assign(CollectionDecorator, ResourceDecorator);
|
|
10046
|
+
CollectionDecorator.Create = createOperationDecorator("create");
|
|
10047
|
+
CollectionDecorator.Delete = createOperationDecorator("delete");
|
|
10048
|
+
CollectionDecorator.DeleteMany = createOperationDecorator("deleteMany");
|
|
10049
|
+
CollectionDecorator.Get = createOperationDecorator("get");
|
|
10050
|
+
CollectionDecorator.FindMany = createOperationDecorator("findMany");
|
|
10051
|
+
CollectionDecorator.Update = createOperationDecorator("update");
|
|
10052
|
+
CollectionDecorator.UpdateMany = createOperationDecorator("updateMany");
|
|
10053
|
+
CollectionDecorator.Action = function(options) {
|
|
10054
|
+
const oldDecorator = ResourceDecorator.Action(options);
|
|
10055
|
+
return (target, propertyKey) => {
|
|
10056
|
+
if (typeof propertyKey === "string" && operationProperties.includes(propertyKey))
|
|
10057
|
+
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
10058
|
+
return oldDecorator(target, propertyKey);
|
|
10059
|
+
};
|
|
10060
|
+
};
|
|
10020
10061
|
function createOperationDecorator(operation) {
|
|
10021
10062
|
return (options) => (target, propertyKey) => {
|
|
10022
10063
|
if (propertyKey !== operation)
|
|
10023
10064
|
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10024
10065
|
const operationMeta = { ...options };
|
|
10025
|
-
const
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
Reflect.defineMetadata(
|
|
10066
|
+
const sourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
|
|
10067
|
+
sourceMetadata.operations = sourceMetadata.operations || {};
|
|
10068
|
+
sourceMetadata.operations[operation] = operationMeta;
|
|
10069
|
+
Reflect.defineMetadata(SOURCE_METADATA, sourceMetadata, target.constructor);
|
|
10029
10070
|
};
|
|
10030
10071
|
}
|
|
10031
10072
|
__name(createOperationDecorator, "createOperationDecorator");
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
Collection2
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
Collection2.
|
|
10038
|
-
|
|
10073
|
+
|
|
10074
|
+
// ../../build/common/esm/document/resource/collection.js
|
|
10075
|
+
var Collection2 = /* @__PURE__ */ __name(function(...args) {
|
|
10076
|
+
if (!this) {
|
|
10077
|
+
const [type, options] = args;
|
|
10078
|
+
return Collection2[DECORATOR].call(void 0, type, options);
|
|
10079
|
+
}
|
|
10080
|
+
const [document, init] = args;
|
|
10081
|
+
merge8(this, new CollectionClass(document, init), { descriptor: true });
|
|
10082
|
+
}, "Collection");
|
|
10083
|
+
Collection2.prototype = CollectionClass.prototype;
|
|
10084
|
+
Object.assign(Collection2, CollectionDecorator);
|
|
10085
|
+
Collection2[DECORATOR] = CollectionDecorator;
|
|
10039
10086
|
|
|
10040
10087
|
// ../../build/common/esm/document/resource/singleton.js
|
|
10041
|
-
import
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
var NAME_PATTERN2 = /^(.*)(Resource|Singleton)$/;
|
|
10088
|
+
import merge9 from "putil-merge";
|
|
10089
|
+
|
|
10090
|
+
// ../../build/common/esm/document/resource/singleton-class.js
|
|
10045
10091
|
var SingletonClass = class extends Resource {
|
|
10046
10092
|
static {
|
|
10047
10093
|
__name(this, "SingletonClass");
|
|
@@ -10056,83 +10102,104 @@ var SingletonClass = class extends Resource {
|
|
|
10056
10102
|
this.type = init.type;
|
|
10057
10103
|
}
|
|
10058
10104
|
exportSchema() {
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10105
|
+
return {
|
|
10106
|
+
...super.exportSchema(),
|
|
10107
|
+
...omitUndefined({
|
|
10108
|
+
type: this.type.name || "any",
|
|
10109
|
+
operations: this.operations
|
|
10110
|
+
})
|
|
10111
|
+
};
|
|
10065
10112
|
}
|
|
10066
10113
|
normalizeFieldPath(path2) {
|
|
10067
10114
|
return this.type.normalizeFieldPath(path2);
|
|
10068
10115
|
}
|
|
10069
|
-
getDecoder(
|
|
10070
|
-
let decoder = this._decoders[
|
|
10116
|
+
getDecoder(endpoint) {
|
|
10117
|
+
let decoder = this._decoders[endpoint];
|
|
10071
10118
|
if (decoder)
|
|
10072
10119
|
return decoder;
|
|
10073
10120
|
const options = {
|
|
10074
|
-
partial:
|
|
10121
|
+
partial: endpoint !== "create"
|
|
10075
10122
|
};
|
|
10076
10123
|
decoder = generateCodec(this.type, "decode", options);
|
|
10077
|
-
this._decoders[
|
|
10124
|
+
this._decoders[endpoint] = decoder;
|
|
10078
10125
|
return decoder;
|
|
10079
10126
|
}
|
|
10080
|
-
getEncoder(
|
|
10081
|
-
let encoder = this._encoders[
|
|
10127
|
+
getEncoder(endpoint) {
|
|
10128
|
+
let encoder = this._encoders[endpoint];
|
|
10082
10129
|
if (encoder)
|
|
10083
10130
|
return encoder;
|
|
10084
10131
|
const options = {
|
|
10085
10132
|
partial: true
|
|
10086
10133
|
};
|
|
10087
10134
|
encoder = generateCodec(this.type, "encode", options);
|
|
10088
|
-
this._encoders[
|
|
10135
|
+
this._encoders[endpoint] = encoder;
|
|
10089
10136
|
return encoder;
|
|
10090
10137
|
}
|
|
10091
10138
|
};
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
}
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10139
|
+
|
|
10140
|
+
// ../../build/common/esm/document/resource/singleton-decorator.js
|
|
10141
|
+
import omit5 from "lodash.omit";
|
|
10142
|
+
var NAME_PATTERN2 = /^(.*)(Resource|Singleton|Controller)$/;
|
|
10143
|
+
function SingletonDecorator(type, options) {
|
|
10144
|
+
return function(target) {
|
|
10145
|
+
const name = options?.name || target.name.match(NAME_PATTERN2)?.[1] || target.name;
|
|
10146
|
+
const metadata = Reflect.getOwnMetadata(SOURCE_METADATA, target) || {};
|
|
10147
|
+
metadata.kind = opra_schema_ns_exports.Singleton.Kind;
|
|
10148
|
+
metadata.name = name;
|
|
10149
|
+
metadata.type = type;
|
|
10150
|
+
const m = Reflect.getMetadata(SOURCE_METADATA, target);
|
|
10151
|
+
if (m && metadata !== m)
|
|
10152
|
+
Object.assign(metadata, omit5(m), Object.keys(metadata));
|
|
10153
|
+
if (options)
|
|
10154
|
+
Object.assign(metadata, omit5(options, ["kind", "name", "type", "controller"]));
|
|
10155
|
+
Reflect.defineMetadata(SOURCE_METADATA, metadata, target);
|
|
10156
|
+
};
|
|
10157
|
+
}
|
|
10158
|
+
__name(SingletonDecorator, "SingletonDecorator");
|
|
10159
|
+
Object.assign(SingletonDecorator, ResourceDecorator);
|
|
10160
|
+
SingletonDecorator.Create = createOperationDecorator2("create");
|
|
10161
|
+
SingletonDecorator.Get = createOperationDecorator2("get");
|
|
10162
|
+
SingletonDecorator.Delete = createOperationDecorator2("delete");
|
|
10163
|
+
SingletonDecorator.Update = createOperationDecorator2("update");
|
|
10164
|
+
SingletonDecorator.Action = function(options) {
|
|
10165
|
+
const oldDecorator = ResourceDecorator.Action(options);
|
|
10166
|
+
const operators = ["create", "delete", "get", "update"];
|
|
10167
|
+
return (target, propertyKey) => {
|
|
10168
|
+
if (typeof propertyKey === "string" && operators.includes(propertyKey))
|
|
10169
|
+
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
10170
|
+
return oldDecorator(target, propertyKey);
|
|
10171
|
+
};
|
|
10172
|
+
};
|
|
10114
10173
|
function createOperationDecorator2(operation) {
|
|
10115
10174
|
return (options) => (target, propertyKey) => {
|
|
10116
10175
|
if (propertyKey !== operation)
|
|
10117
10176
|
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10118
10177
|
const operationMeta = { ...options };
|
|
10119
|
-
const
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
Reflect.defineMetadata(
|
|
10178
|
+
const sourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
|
|
10179
|
+
sourceMetadata.operations = sourceMetadata.operations || {};
|
|
10180
|
+
sourceMetadata.operations[operation] = operationMeta;
|
|
10181
|
+
Reflect.defineMetadata(SOURCE_METADATA, sourceMetadata, target.constructor);
|
|
10123
10182
|
};
|
|
10124
10183
|
}
|
|
10125
10184
|
__name(createOperationDecorator2, "createOperationDecorator");
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
Singleton2
|
|
10129
|
-
|
|
10185
|
+
|
|
10186
|
+
// ../../build/common/esm/document/resource/singleton.js
|
|
10187
|
+
var Singleton2 = /* @__PURE__ */ __name(function(...args) {
|
|
10188
|
+
if (!this) {
|
|
10189
|
+
const [type, options] = args;
|
|
10190
|
+
return Singleton2[DECORATOR].call(void 0, type, options);
|
|
10191
|
+
}
|
|
10192
|
+
const [document, init] = args;
|
|
10193
|
+
merge9(this, new SingletonClass(document, init), { descriptor: true });
|
|
10194
|
+
}, "Singleton");
|
|
10195
|
+
Singleton2.prototype = SingletonClass.prototype;
|
|
10196
|
+
Object.assign(Singleton2, SingletonDecorator);
|
|
10197
|
+
Singleton2[DECORATOR] = SingletonDecorator;
|
|
10130
10198
|
|
|
10131
10199
|
// ../../build/common/esm/document/resource/storage.js
|
|
10132
|
-
import
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
var NAME_PATTERN3 = /^(.*)(Resource)$/;
|
|
10200
|
+
import merge10 from "putil-merge";
|
|
10201
|
+
|
|
10202
|
+
// ../../build/common/esm/document/resource/storage-class.js
|
|
10136
10203
|
var StorageClass = class extends Resource {
|
|
10137
10204
|
static {
|
|
10138
10205
|
__name(this, "StorageClass");
|
|
@@ -10144,71 +10211,94 @@ var StorageClass = class extends Resource {
|
|
|
10144
10211
|
this.operations = { ...init.operations };
|
|
10145
10212
|
}
|
|
10146
10213
|
exportSchema() {
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
};
|
|
10154
|
-
var Storage2 = /* @__PURE__ */ __name(function(...args) {
|
|
10155
|
-
if (!this) {
|
|
10156
|
-
const [options] = args;
|
|
10157
|
-
return function(target) {
|
|
10158
|
-
const name = options?.name || target.name.match(NAME_PATTERN3)?.[1] || target.name;
|
|
10159
|
-
const metadata = Reflect.getOwnMetadata(METADATA_KEY, target) || {};
|
|
10160
|
-
metadata.kind = opra_schema_ns_exports.Storage.Kind;
|
|
10161
|
-
metadata.name = name;
|
|
10162
|
-
const m = Reflect.getMetadata(METADATA_KEY, target);
|
|
10163
|
-
if (m && metadata !== m)
|
|
10164
|
-
Object.assign(metadata, omit6(m), Object.keys(metadata));
|
|
10165
|
-
if (options)
|
|
10166
|
-
Object.assign(metadata, omit6(options, ["kind", "name", "type", "controller"]));
|
|
10167
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
10168
|
-
Reflect.defineMetadata(NESTJS_INJECTABLE_WATERMARK3, true, target);
|
|
10214
|
+
return {
|
|
10215
|
+
...super.exportSchema(),
|
|
10216
|
+
...omitUndefined({
|
|
10217
|
+
kind: opra_schema_ns_exports.Storage.Kind,
|
|
10218
|
+
operations: this.operations
|
|
10219
|
+
})
|
|
10169
10220
|
};
|
|
10170
10221
|
}
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10222
|
+
};
|
|
10223
|
+
|
|
10224
|
+
// ../../build/common/esm/document/resource/storage-decorator.js
|
|
10225
|
+
import omit6 from "lodash.omit";
|
|
10226
|
+
var NAME_PATTERN3 = /^(.*)(Resource|Storage|Controller)$/;
|
|
10227
|
+
function StorageDecorator(options) {
|
|
10228
|
+
return function(target) {
|
|
10229
|
+
const name = options?.name || target.name.match(NAME_PATTERN3)?.[1] || target.name;
|
|
10230
|
+
const metadata = Reflect.getOwnMetadata(SOURCE_METADATA, target) || {};
|
|
10231
|
+
metadata.kind = opra_schema_ns_exports.Storage.Kind;
|
|
10232
|
+
metadata.name = name;
|
|
10233
|
+
const m = Reflect.getMetadata(SOURCE_METADATA, target);
|
|
10234
|
+
if (m && metadata !== m)
|
|
10235
|
+
Object.assign(metadata, omit6(m), Object.keys(metadata));
|
|
10236
|
+
if (options)
|
|
10237
|
+
Object.assign(metadata, omit6(options, ["kind", "name", "type", "controller"]));
|
|
10238
|
+
Reflect.defineMetadata(SOURCE_METADATA, metadata, target);
|
|
10239
|
+
};
|
|
10240
|
+
}
|
|
10241
|
+
__name(StorageDecorator, "StorageDecorator");
|
|
10242
|
+
Object.assign(StorageDecorator, ResourceDecorator);
|
|
10243
|
+
StorageDecorator.Delete = createOperationDecorator3("delete");
|
|
10244
|
+
StorageDecorator.Get = createOperationDecorator3("get");
|
|
10245
|
+
StorageDecorator.Post = createOperationDecorator3("post");
|
|
10246
|
+
StorageDecorator.Action = function(options) {
|
|
10247
|
+
const oldDecorator = ResourceDecorator.Action(options);
|
|
10248
|
+
const operators = ["delete", "get", "post"];
|
|
10249
|
+
return (target, propertyKey) => {
|
|
10250
|
+
if (typeof propertyKey === "string" && operators.includes(propertyKey))
|
|
10251
|
+
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
10252
|
+
return oldDecorator(target, propertyKey);
|
|
10253
|
+
};
|
|
10254
|
+
};
|
|
10175
10255
|
function createOperationDecorator3(operation) {
|
|
10176
10256
|
return (options) => (target, propertyKey) => {
|
|
10177
10257
|
if (propertyKey !== operation)
|
|
10178
10258
|
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10179
10259
|
const operationMeta = { ...options };
|
|
10180
|
-
const
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
Reflect.defineMetadata(
|
|
10260
|
+
const sourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
|
|
10261
|
+
sourceMetadata.operations = sourceMetadata.operations || {};
|
|
10262
|
+
sourceMetadata.operations[operation] = operationMeta;
|
|
10263
|
+
Reflect.defineMetadata(SOURCE_METADATA, sourceMetadata, target.constructor);
|
|
10184
10264
|
};
|
|
10185
10265
|
}
|
|
10186
10266
|
__name(createOperationDecorator3, "createOperationDecorator");
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
Storage2
|
|
10267
|
+
|
|
10268
|
+
// ../../build/common/esm/document/resource/storage.js
|
|
10269
|
+
var Storage2 = /* @__PURE__ */ __name(function(...args) {
|
|
10270
|
+
if (!this) {
|
|
10271
|
+
const [options] = args;
|
|
10272
|
+
return Storage2[DECORATOR].call(void 0, options);
|
|
10273
|
+
}
|
|
10274
|
+
const [document, init] = args;
|
|
10275
|
+
merge10(this, new StorageClass(document, init), { descriptor: true });
|
|
10276
|
+
}, "Storage");
|
|
10277
|
+
Storage2.prototype = StorageClass.prototype;
|
|
10278
|
+
Object.assign(Storage2, StorageDecorator);
|
|
10279
|
+
Storage2[DECORATOR] = StorageDecorator;
|
|
10190
10280
|
|
|
10191
10281
|
// ../../build/common/esm/document/factory/process-resources.js
|
|
10192
|
-
async function
|
|
10193
|
-
const { document,
|
|
10194
|
-
const
|
|
10195
|
-
for (const name of
|
|
10196
|
-
const schema =
|
|
10282
|
+
async function processSourceQueue() {
|
|
10283
|
+
const { document, sourceQueue } = this;
|
|
10284
|
+
const sourceNames = Array.from(sourceQueue.keys());
|
|
10285
|
+
for (const name of sourceNames) {
|
|
10286
|
+
const schema = sourceQueue.get(name);
|
|
10197
10287
|
if (!schema)
|
|
10198
10288
|
continue;
|
|
10199
10289
|
try {
|
|
10200
10290
|
if (opra_schema_ns_exports.isCollection(schema)) {
|
|
10201
|
-
const resource = await this.
|
|
10291
|
+
const resource = await this.createCollectionSource(name, schema);
|
|
10202
10292
|
document.resources.set(name, resource);
|
|
10203
10293
|
continue;
|
|
10204
10294
|
}
|
|
10205
10295
|
if (opra_schema_ns_exports.isSingleton(schema)) {
|
|
10206
|
-
const resource = await this.
|
|
10296
|
+
const resource = await this.createSingletonSource(name, schema);
|
|
10207
10297
|
document.resources.set(name, resource);
|
|
10208
10298
|
continue;
|
|
10209
10299
|
}
|
|
10210
10300
|
if (opra_schema_ns_exports.isStorage(schema)) {
|
|
10211
|
-
const resource = await this.
|
|
10301
|
+
const resource = await this.createFileSource(name, schema);
|
|
10212
10302
|
document.resources.set(name, resource);
|
|
10213
10303
|
continue;
|
|
10214
10304
|
}
|
|
@@ -10219,7 +10309,7 @@ async function processResourceQueue() {
|
|
|
10219
10309
|
throw new TypeError(`Invalid Resource schema: ${JSON.stringify(schema).substring(0, 20)}...`);
|
|
10220
10310
|
}
|
|
10221
10311
|
}
|
|
10222
|
-
__name(
|
|
10312
|
+
__name(processSourceQueue, "processSourceQueue");
|
|
10223
10313
|
async function createCollectionResource(name, schema) {
|
|
10224
10314
|
const { document } = this;
|
|
10225
10315
|
const dataType = document.getComplexType(schema.type);
|
|
@@ -10242,7 +10332,7 @@ async function createSingletonResource(name, schema) {
|
|
|
10242
10332
|
return new Singleton2(document, initArgs);
|
|
10243
10333
|
}
|
|
10244
10334
|
__name(createSingletonResource, "createSingletonResource");
|
|
10245
|
-
async function
|
|
10335
|
+
async function createStorageResource(name, schema) {
|
|
10246
10336
|
const { document } = this;
|
|
10247
10337
|
const initArgs = {
|
|
10248
10338
|
...schema,
|
|
@@ -10250,7 +10340,7 @@ async function createFileResource(name, schema) {
|
|
|
10250
10340
|
};
|
|
10251
10341
|
return new Storage2(document, initArgs);
|
|
10252
10342
|
}
|
|
10253
|
-
__name(
|
|
10343
|
+
__name(createStorageResource, "createStorageResource");
|
|
10254
10344
|
|
|
10255
10345
|
// ../../build/common/esm/document/factory/process-types.js
|
|
10256
10346
|
async function processTypes() {
|
|
@@ -10430,7 +10520,7 @@ var DocumentFactory = class _DocumentFactory {
|
|
|
10430
10520
|
constructor() {
|
|
10431
10521
|
this.document = new ApiDocument();
|
|
10432
10522
|
this.typeQueue = new ResponsiveMap();
|
|
10433
|
-
this.
|
|
10523
|
+
this.sourceQueue = new ResponsiveMap();
|
|
10434
10524
|
this.circularRefs = new ResponsiveMap();
|
|
10435
10525
|
this.curPath = [];
|
|
10436
10526
|
this.cache = /* @__PURE__ */ new Map();
|
|
@@ -10468,13 +10558,13 @@ DocumentFactory.designTypeMap = /* @__PURE__ */ new Map();
|
|
|
10468
10558
|
_a2.prototype.processTypes = processTypes;
|
|
10469
10559
|
_a2.prototype.createDataTypeInstance = createDataTypeInstance;
|
|
10470
10560
|
_a2.prototype.addDataType = addDataType;
|
|
10471
|
-
_a2.prototype.
|
|
10561
|
+
_a2.prototype.importSourceClass = importResourceClass;
|
|
10472
10562
|
_a2.prototype.extractSingletonSchema = extractSingletonSchema;
|
|
10473
10563
|
_a2.prototype.extractCollectionSchema = extractCollectionSchema;
|
|
10474
|
-
_a2.prototype.
|
|
10475
|
-
_a2.prototype.
|
|
10476
|
-
_a2.prototype.
|
|
10477
|
-
_a2.prototype.
|
|
10564
|
+
_a2.prototype.processSourceQueue = processSourceQueue;
|
|
10565
|
+
_a2.prototype.createCollectionSource = createCollectionResource;
|
|
10566
|
+
_a2.prototype.createSingletonSource = createSingletonResource;
|
|
10567
|
+
_a2.prototype.createFileSource = createStorageResource;
|
|
10478
10568
|
})();
|
|
10479
10569
|
|
|
10480
10570
|
// ../../build/common/esm/http/opra-url.js
|
|
@@ -11189,6 +11279,8 @@ export {
|
|
|
11189
11279
|
BaseI18n,
|
|
11190
11280
|
Collection2 as Collection,
|
|
11191
11281
|
ComplexType2 as ComplexType,
|
|
11282
|
+
DATATYPE_METADATA,
|
|
11283
|
+
DECORATOR,
|
|
11192
11284
|
DataType,
|
|
11193
11285
|
DocumentFactory,
|
|
11194
11286
|
EnumType2 as EnumType,
|
|
@@ -11200,7 +11292,6 @@ export {
|
|
|
11200
11292
|
I18n,
|
|
11201
11293
|
InternalServerError,
|
|
11202
11294
|
IssueSeverity,
|
|
11203
|
-
METADATA_KEY,
|
|
11204
11295
|
MappedType2 as MappedType,
|
|
11205
11296
|
MethodNotAllowedError,
|
|
11206
11297
|
NAMESPACE_PATTERN,
|
|
@@ -11217,6 +11308,7 @@ export {
|
|
|
11217
11308
|
ResourceConflictError,
|
|
11218
11309
|
ResourceNotFoundError,
|
|
11219
11310
|
ResponsiveMap,
|
|
11311
|
+
SOURCE_METADATA,
|
|
11220
11312
|
SimpleType2 as SimpleType,
|
|
11221
11313
|
Singleton2 as Singleton,
|
|
11222
11314
|
Storage2 as Storage,
|