@opra/common 0.24.2 → 0.25.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 +368 -314
- package/cjs/document/data-type/complex-type-class.js +151 -0
- package/cjs/document/data-type/complex-type.js +13 -168
- package/cjs/document/data-type/data-type.js +4 -0
- package/cjs/document/data-type/enum-type-class.js +32 -0
- package/cjs/document/data-type/enum-type.js +24 -49
- package/cjs/document/data-type/field-class.js +34 -0
- package/cjs/document/data-type/field-decorator.js +45 -0
- package/cjs/document/data-type/field.js +25 -0
- package/cjs/document/data-type/mapped-type-class.js +48 -0
- package/cjs/document/data-type/mapped-type.js +18 -58
- package/cjs/document/data-type/simple-type-class.js +29 -0
- package/cjs/document/data-type/simple-type.js +12 -43
- package/cjs/document/data-type/union-type-class.js +36 -0
- package/cjs/document/data-type/union-type.js +3 -31
- package/cjs/document/{resource → decorators}/collection-decorator.js +2 -24
- package/cjs/document/decorators/complex-type.decorator.js +23 -0
- package/cjs/document/decorators/resource.decorator.js +38 -0
- package/cjs/document/decorators/simple-type.decorator.js +20 -0
- package/cjs/document/{resource/singleton-decorator.js → decorators/singleton.decorator.js} +2 -19
- package/cjs/document/{resource/storage-decorator.js → decorators/storage.decorator.js} +2 -18
- package/cjs/document/index.js +1 -1
- package/cjs/document/resource/collection.js +4 -3
- package/cjs/document/resource/endpoint.js +44 -0
- package/cjs/document/resource/resource.js +9 -10
- package/cjs/document/resource/singleton.js +5 -1
- package/cjs/document/resource/storage.js +5 -1
- package/cjs/schema/opra-schema.ns.js +1 -0
- package/cjs/schema/resource/endpoint.interface.js +2 -0
- package/esm/document/data-type/complex-type-class.js +147 -0
- package/esm/document/data-type/complex-type.js +13 -168
- package/esm/document/data-type/data-type.js +4 -0
- package/esm/document/data-type/enum-type-class.js +27 -0
- package/esm/document/data-type/enum-type.js +22 -47
- package/esm/document/data-type/field-class.js +30 -0
- package/esm/document/data-type/field-decorator.js +41 -0
- package/esm/document/data-type/field.js +21 -0
- package/esm/document/data-type/mapped-type-class.js +43 -0
- package/esm/document/data-type/mapped-type.js +13 -53
- package/esm/document/data-type/simple-type-class.js +24 -0
- package/esm/document/data-type/simple-type.js +12 -43
- package/esm/document/data-type/union-type-class.js +32 -0
- package/esm/document/data-type/union-type.js +2 -30
- package/esm/document/{resource → decorators}/collection-decorator.js +2 -23
- package/esm/document/decorators/complex-type.decorator.js +18 -0
- package/esm/document/decorators/resource.decorator.js +33 -0
- package/esm/document/decorators/simple-type.decorator.js +15 -0
- package/esm/document/{resource/singleton-decorator.js → decorators/singleton.decorator.js} +2 -18
- package/esm/document/{resource/storage-decorator.js → decorators/storage.decorator.js} +2 -17
- package/esm/document/index.js +1 -1
- package/esm/document/resource/collection.js +4 -3
- package/esm/document/resource/endpoint.js +40 -0
- package/esm/document/resource/resource.js +9 -10
- package/esm/document/resource/singleton.js +5 -1
- package/esm/document/resource/storage.js +5 -1
- package/esm/schema/opra-schema.ns.js +1 -0
- package/esm/schema/resource/endpoint.interface.js +1 -0
- package/package.json +3 -11
- package/types/document/data-type/complex-type-class.d.ts +33 -0
- package/types/document/data-type/complex-type.d.ts +18 -43
- package/types/document/data-type/data-type.d.ts +17 -13
- package/types/document/data-type/enum-type-class.d.ts +17 -0
- package/types/document/data-type/enum-type.d.ts +11 -24
- package/types/document/data-type/field-class.d.ts +20 -0
- package/types/document/data-type/field-decorator.d.ts +5 -0
- package/types/document/data-type/{api-field.d.ts → field.d.ts} +20 -20
- package/types/document/data-type/mapped-type-class.d.ts +21 -0
- package/types/document/data-type/mapped-type.d.ts +24 -39
- package/types/document/data-type/simple-type-class.d.ts +17 -0
- package/types/document/data-type/simple-type.d.ts +21 -31
- package/types/document/data-type/union-type-class.d.ts +18 -0
- package/types/document/data-type/union-type.d.ts +15 -27
- package/types/document/{resource → decorators}/collection-decorator.d.ts +14 -14
- package/types/document/decorators/complex-type.decorator.d.ts +2 -0
- package/types/document/decorators/resource.decorator.d.ts +9 -0
- package/types/document/decorators/simple-type.decorator.d.ts +2 -0
- package/types/document/{resource/singleton-decorator.d.ts → decorators/singleton.decorator.d.ts} +11 -11
- package/types/document/{resource/storage-decorator.d.ts → decorators/storage.decorator.d.ts} +10 -10
- package/types/document/factory/import-type-class.d.ts +1 -1
- package/types/document/index.d.ts +1 -1
- package/types/document/resource/collection.d.ts +16 -12
- package/types/document/resource/endpoint.d.ts +29 -0
- package/types/document/resource/resource.d.ts +15 -14
- package/types/document/resource/singleton.d.ts +15 -8
- package/types/document/resource/storage-class.d.ts +0 -2
- package/types/document/resource/storage.d.ts +12 -8
- package/types/filter/ast/terms/qualified-identifier.d.ts +1 -1
- package/types/schema/opra-schema.ns.d.ts +1 -0
- package/types/schema/resource/collection.interface.d.ts +2 -1
- package/types/schema/resource/endpoint.interface.d.ts +12 -0
- package/types/schema/resource/resource.interface.d.ts +3 -15
- package/types/schema/resource/storage.interface.d.ts +2 -1
- package/cjs/document/data-type/api-field.js +0 -83
- package/cjs/document/resource/action.js +0 -12
- package/cjs/document/resource/resource-decorator.js +0 -16
- package/esm/document/data-type/api-field.js +0 -80
- package/esm/document/resource/action.js +0 -8
- package/esm/document/resource/resource-decorator.js +0 -13
- package/types/document/resource/action.d.ts +0 -11
- package/types/document/resource/resource-decorator.d.ts +0 -5
package/browser.js
CHANGED
|
@@ -1009,14 +1009,25 @@ __name(isContainer, "isContainer");
|
|
|
1009
1009
|
|
|
1010
1010
|
// ../../build/common/esm/document/data-type/complex-type.js
|
|
1011
1011
|
import "reflect-metadata";
|
|
1012
|
-
import
|
|
1013
|
-
import merge3 from "putil-merge";
|
|
1012
|
+
import merge4 from "putil-merge";
|
|
1014
1013
|
|
|
1015
|
-
// ../../build/common/esm/document/
|
|
1016
|
-
import "reflect-metadata";
|
|
1014
|
+
// ../../build/common/esm/document/decorators/complex-type.decorator.js
|
|
1017
1015
|
import omit from "lodash.omit";
|
|
1018
|
-
|
|
1019
|
-
|
|
1016
|
+
function ComplexTypeDecorator(options) {
|
|
1017
|
+
return function(target) {
|
|
1018
|
+
const name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1019
|
+
let metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target);
|
|
1020
|
+
if (!metadata) {
|
|
1021
|
+
metadata = {};
|
|
1022
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1023
|
+
}
|
|
1024
|
+
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1025
|
+
metadata.name = name;
|
|
1026
|
+
if (options)
|
|
1027
|
+
Object.assign(metadata, omit(options, ["kind", "name", "base", "fields"]));
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
__name(ComplexTypeDecorator, "ComplexTypeDecorator");
|
|
1020
1031
|
|
|
1021
1032
|
// ../../build/common/esm/document/utils/inspect.util.js
|
|
1022
1033
|
var nodeInspectCustom = Symbol.for("nodejs.util.inspect.custom");
|
|
@@ -1060,7 +1071,50 @@ var DataType = class _DataType {
|
|
|
1060
1071
|
}
|
|
1061
1072
|
};
|
|
1062
1073
|
|
|
1074
|
+
// ../../build/common/esm/document/data-type/field.js
|
|
1075
|
+
import merge3 from "putil-merge";
|
|
1076
|
+
|
|
1077
|
+
// ../../build/common/esm/document/data-type/field-class.js
|
|
1078
|
+
var FieldClass = class {
|
|
1079
|
+
static {
|
|
1080
|
+
__name(this, "FieldClass");
|
|
1081
|
+
}
|
|
1082
|
+
constructor(owner, init) {
|
|
1083
|
+
this.owner = owner;
|
|
1084
|
+
this.name = init.name;
|
|
1085
|
+
this.origin = init.origin || owner;
|
|
1086
|
+
this.type = init.type;
|
|
1087
|
+
this.description = init.description;
|
|
1088
|
+
this.isArray = init.isArray;
|
|
1089
|
+
this.default = init.default;
|
|
1090
|
+
this.fixed = init.fixed;
|
|
1091
|
+
this.required = init.required;
|
|
1092
|
+
this.exclusive = init.exclusive;
|
|
1093
|
+
this.deprecated = init.deprecated;
|
|
1094
|
+
this.examples = init.examples;
|
|
1095
|
+
}
|
|
1096
|
+
exportSchema() {
|
|
1097
|
+
return omitUndefined({
|
|
1098
|
+
type: this.type.name ? this.type.name : this.type.exportSchema(),
|
|
1099
|
+
description: this.description,
|
|
1100
|
+
isArray: this.isArray,
|
|
1101
|
+
default: this.default,
|
|
1102
|
+
fixed: this.fixed,
|
|
1103
|
+
required: this.required,
|
|
1104
|
+
exclusive: this.exclusive,
|
|
1105
|
+
deprecated: this.deprecated,
|
|
1106
|
+
examples: this.examples
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1063
1111
|
// ../../build/common/esm/document/data-type/enum-type.js
|
|
1112
|
+
import "reflect-metadata";
|
|
1113
|
+
import omit2 from "lodash.omit";
|
|
1114
|
+
import merge2 from "putil-merge";
|
|
1115
|
+
|
|
1116
|
+
// ../../build/common/esm/document/data-type/enum-type-class.js
|
|
1117
|
+
import * as vg from "valgen";
|
|
1064
1118
|
var EnumTypeClass = class extends DataType {
|
|
1065
1119
|
static {
|
|
1066
1120
|
__name(this, "EnumTypeClass");
|
|
@@ -1086,101 +1140,83 @@ var EnumTypeClass = class extends DataType {
|
|
|
1086
1140
|
return out;
|
|
1087
1141
|
}
|
|
1088
1142
|
};
|
|
1143
|
+
|
|
1144
|
+
// ../../build/common/esm/document/data-type/enum-type.js
|
|
1089
1145
|
var EnumType2 = /* @__PURE__ */ __name(function(...args) {
|
|
1090
|
-
if (this) {
|
|
1091
|
-
const [
|
|
1092
|
-
|
|
1093
|
-
|
|
1146
|
+
if (!this) {
|
|
1147
|
+
const [enumSource, options] = args;
|
|
1148
|
+
const values = Array.isArray(enumSource) ? enumSource.reduce((obj, v) => {
|
|
1149
|
+
obj[v] = v;
|
|
1150
|
+
return obj;
|
|
1151
|
+
}, {}) : enumSource;
|
|
1152
|
+
const metadata = {
|
|
1153
|
+
kind: opra_schema_ns_exports.EnumType.Kind,
|
|
1154
|
+
values
|
|
1155
|
+
};
|
|
1156
|
+
if (options)
|
|
1157
|
+
Object.assign(metadata, omit2(options, ["kind", "values"]));
|
|
1158
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, enumSource);
|
|
1159
|
+
return values;
|
|
1094
1160
|
}
|
|
1095
|
-
const [
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
return obj;
|
|
1099
|
-
}, {}) : enumSource;
|
|
1100
|
-
const metadata = {
|
|
1101
|
-
kind: opra_schema_ns_exports.EnumType.Kind,
|
|
1102
|
-
values
|
|
1103
|
-
};
|
|
1104
|
-
if (options)
|
|
1105
|
-
Object.assign(metadata, omit(options, ["kind", "values"]));
|
|
1106
|
-
Reflect.defineMetadata(DATATYPE_METADATA, metadata, enumSource);
|
|
1107
|
-
return values;
|
|
1161
|
+
const [document, init] = args;
|
|
1162
|
+
merge2(this, new EnumTypeClass(document, init), { descriptor: true });
|
|
1163
|
+
return;
|
|
1108
1164
|
}, "EnumType");
|
|
1109
1165
|
EnumType2.prototype = EnumTypeClass.prototype;
|
|
1110
1166
|
|
|
1111
|
-
// ../../build/common/esm/document/data-type/
|
|
1167
|
+
// ../../build/common/esm/document/data-type/field-decorator.js
|
|
1168
|
+
function FieldDecorator(options) {
|
|
1169
|
+
return function(target, propertyKey) {
|
|
1170
|
+
if (typeof propertyKey !== "string")
|
|
1171
|
+
throw new TypeError(`Symbol properties can't be used as a field`);
|
|
1172
|
+
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target.constructor) || {};
|
|
1173
|
+
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1174
|
+
metadata.fields = metadata.fields || {};
|
|
1175
|
+
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
1176
|
+
const elemMeta = metadata.fields[propertyKey] = {
|
|
1177
|
+
...options,
|
|
1178
|
+
enum: void 0,
|
|
1179
|
+
designType
|
|
1180
|
+
};
|
|
1181
|
+
if (designType === Array) {
|
|
1182
|
+
elemMeta.isArray = true;
|
|
1183
|
+
delete elemMeta.designType;
|
|
1184
|
+
}
|
|
1185
|
+
if (options?.enum) {
|
|
1186
|
+
elemMeta.type = void 0;
|
|
1187
|
+
if (Array.isArray(options.enum)) {
|
|
1188
|
+
const enumObj = options.enum.reduce((o, v) => {
|
|
1189
|
+
o[v] = v;
|
|
1190
|
+
return o;
|
|
1191
|
+
}, {});
|
|
1192
|
+
EnumType2(enumObj);
|
|
1193
|
+
elemMeta.enum = enumObj;
|
|
1194
|
+
} else {
|
|
1195
|
+
const m = Reflect.getOwnMetadata(DATATYPE_METADATA, options?.enum);
|
|
1196
|
+
if (!opra_schema_ns_exports.isEnumType(m))
|
|
1197
|
+
throw new TypeError(`Invalid "enum" value. Did you forget to set metadata using EnumType() method?`);
|
|
1198
|
+
elemMeta.enum = options.enum;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
Reflect.defineMetadata(DATATYPE_METADATA, omitUndefined(metadata), target.constructor);
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
__name(FieldDecorator, "FieldDecorator");
|
|
1205
|
+
|
|
1206
|
+
// ../../build/common/esm/document/data-type/field.js
|
|
1112
1207
|
var ApiField = /* @__PURE__ */ __name(function(...args) {
|
|
1113
1208
|
if (!this) {
|
|
1114
1209
|
const [options] = args;
|
|
1115
|
-
return
|
|
1116
|
-
if (typeof propertyKey !== "string")
|
|
1117
|
-
throw new TypeError(`Symbol properties can't be used as a field`);
|
|
1118
|
-
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target.constructor) || {};
|
|
1119
|
-
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1120
|
-
metadata.fields = metadata.fields || {};
|
|
1121
|
-
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
1122
|
-
const elemMeta = metadata.fields[propertyKey] = {
|
|
1123
|
-
...options,
|
|
1124
|
-
enum: void 0,
|
|
1125
|
-
designType
|
|
1126
|
-
};
|
|
1127
|
-
if (designType === Array) {
|
|
1128
|
-
elemMeta.isArray = true;
|
|
1129
|
-
delete elemMeta.designType;
|
|
1130
|
-
}
|
|
1131
|
-
if (options?.enum) {
|
|
1132
|
-
elemMeta.type = void 0;
|
|
1133
|
-
if (Array.isArray(options.enum)) {
|
|
1134
|
-
const enumObj = options.enum.reduce((o, v) => {
|
|
1135
|
-
o[v] = v;
|
|
1136
|
-
return o;
|
|
1137
|
-
}, {});
|
|
1138
|
-
EnumType2(enumObj);
|
|
1139
|
-
elemMeta.enum = enumObj;
|
|
1140
|
-
} else {
|
|
1141
|
-
const m = Reflect.getOwnMetadata(DATATYPE_METADATA, options?.enum);
|
|
1142
|
-
if (!opra_schema_ns_exports.isEnumType(m))
|
|
1143
|
-
throw new TypeError(`Invalid "enum" value. Did you forget to set metadata using EnumType() method?`);
|
|
1144
|
-
elemMeta.enum = options.enum;
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
Reflect.defineMetadata(DATATYPE_METADATA, omitUndefined(metadata), target.constructor);
|
|
1148
|
-
};
|
|
1210
|
+
return ApiField[DECORATOR](options);
|
|
1149
1211
|
}
|
|
1150
1212
|
const [owner, init] = args;
|
|
1151
|
-
|
|
1152
|
-
_this.owner = owner;
|
|
1153
|
-
_this.name = init.name;
|
|
1154
|
-
_this.origin = init.origin || owner;
|
|
1155
|
-
_this.type = init.type;
|
|
1156
|
-
if (init?.description)
|
|
1157
|
-
this.description = init?.description;
|
|
1158
|
-
if (init?.isArray != null)
|
|
1159
|
-
this.isArray = init?.isArray;
|
|
1160
|
-
this.default = init?.default;
|
|
1161
|
-
this.fixed = init?.fixed;
|
|
1162
|
-
if (init?.deprecated != null)
|
|
1163
|
-
this.deprecated = init?.deprecated;
|
|
1164
|
-
if (init?.exclusive != null)
|
|
1165
|
-
this.exclusive = init?.exclusive;
|
|
1166
|
-
if (init?.required != null)
|
|
1167
|
-
this.required = init?.required;
|
|
1213
|
+
merge3(this, new FieldClass(owner, init), { descriptor: true });
|
|
1168
1214
|
}, "ApiField");
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
type: this.type.name ? this.type.name : this.type.exportSchema(),
|
|
1173
|
-
description: this.description,
|
|
1174
|
-
isArray: this.isArray,
|
|
1175
|
-
default: this.default,
|
|
1176
|
-
fixed: this.fixed,
|
|
1177
|
-
required: this.required
|
|
1178
|
-
});
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
1181
|
-
Object.assign(ApiField.prototype, proto);
|
|
1215
|
+
ApiField.prototype = FieldClass.prototype;
|
|
1216
|
+
Object.assign(ApiField, FieldDecorator);
|
|
1217
|
+
ApiField[DECORATOR] = FieldDecorator;
|
|
1182
1218
|
|
|
1183
|
-
// ../../build/common/esm/document/data-type/complex-type.js
|
|
1219
|
+
// ../../build/common/esm/document/data-type/complex-type-class.js
|
|
1184
1220
|
var ComplexTypeClass = class extends DataType {
|
|
1185
1221
|
static {
|
|
1186
1222
|
__name(this, "ComplexTypeClass");
|
|
@@ -1247,6 +1283,7 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1247
1283
|
let curPath = "";
|
|
1248
1284
|
let s;
|
|
1249
1285
|
let i = -1;
|
|
1286
|
+
const ComplexType3 = Object.getPrototypeOf(this).constructor;
|
|
1250
1287
|
return {
|
|
1251
1288
|
[Symbol.iterator]() {
|
|
1252
1289
|
return this;
|
|
@@ -1255,7 +1292,7 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1255
1292
|
i++;
|
|
1256
1293
|
if (i < len) {
|
|
1257
1294
|
s = arr[i];
|
|
1258
|
-
if (dataType && !(dataType instanceof
|
|
1295
|
+
if (dataType && !(dataType instanceof ComplexType3)) {
|
|
1259
1296
|
if (silent)
|
|
1260
1297
|
return { done: true, value: [] };
|
|
1261
1298
|
throw new TypeError(`"${curPath}" field is not a complex type and has no child fields`);
|
|
@@ -1318,27 +1355,19 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1318
1355
|
return false;
|
|
1319
1356
|
}
|
|
1320
1357
|
};
|
|
1358
|
+
|
|
1359
|
+
// ../../build/common/esm/document/data-type/complex-type.js
|
|
1321
1360
|
var ComplexType2 = /* @__PURE__ */ __name(function(...args) {
|
|
1322
|
-
if (this) {
|
|
1323
|
-
const [
|
|
1324
|
-
|
|
1325
|
-
return;
|
|
1361
|
+
if (!this) {
|
|
1362
|
+
const [options] = args;
|
|
1363
|
+
return ComplexType2[DECORATOR](options);
|
|
1326
1364
|
}
|
|
1327
|
-
const [
|
|
1328
|
-
|
|
1329
|
-
const name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1330
|
-
let metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target);
|
|
1331
|
-
if (!metadata) {
|
|
1332
|
-
metadata = {};
|
|
1333
|
-
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1334
|
-
}
|
|
1335
|
-
metadata.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1336
|
-
metadata.name = name;
|
|
1337
|
-
if (options)
|
|
1338
|
-
Object.assign(metadata, omit2(options, ["kind", "name", "base", "fields"]));
|
|
1339
|
-
};
|
|
1365
|
+
const [document, init] = args;
|
|
1366
|
+
merge4(this, new ComplexTypeClass(document, init), { descriptor: true });
|
|
1340
1367
|
}, "ComplexType");
|
|
1341
1368
|
ComplexType2.prototype = ComplexTypeClass.prototype;
|
|
1369
|
+
Object.assign(ComplexType2, ComplexTypeDecorator);
|
|
1370
|
+
ComplexType2[DECORATOR] = ComplexTypeDecorator;
|
|
1342
1371
|
|
|
1343
1372
|
// ../../build/common/esm/document/api-document.js
|
|
1344
1373
|
var ApiDocument = class {
|
|
@@ -1592,8 +1621,25 @@ __name(__decorate, "__decorate");
|
|
|
1592
1621
|
|
|
1593
1622
|
// ../../build/common/esm/document/data-type/simple-type.js
|
|
1594
1623
|
import "reflect-metadata";
|
|
1624
|
+
import merge5 from "putil-merge";
|
|
1625
|
+
|
|
1626
|
+
// ../../build/common/esm/document/decorators/simple-type.decorator.js
|
|
1595
1627
|
import omit3 from "lodash.omit";
|
|
1596
|
-
|
|
1628
|
+
function SimpleTypeDecorator(options) {
|
|
1629
|
+
return function(target) {
|
|
1630
|
+
let name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1631
|
+
name = name.charAt(0).toLowerCase() + name.substring(1);
|
|
1632
|
+
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target) || {};
|
|
1633
|
+
metadata.kind = opra_schema_ns_exports.SimpleType.Kind;
|
|
1634
|
+
metadata.name = name;
|
|
1635
|
+
if (options)
|
|
1636
|
+
Object.assign(metadata, omit3(options, ["kind", "name"]));
|
|
1637
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
__name(SimpleTypeDecorator, "SimpleTypeDecorator");
|
|
1641
|
+
|
|
1642
|
+
// ../../build/common/esm/document/data-type/simple-type-class.js
|
|
1597
1643
|
import * as vg2 from "valgen";
|
|
1598
1644
|
var SimpleTypeClass = class extends DataType {
|
|
1599
1645
|
static {
|
|
@@ -1611,25 +1657,19 @@ var SimpleTypeClass = class extends DataType {
|
|
|
1611
1657
|
return out;
|
|
1612
1658
|
}
|
|
1613
1659
|
};
|
|
1660
|
+
|
|
1661
|
+
// ../../build/common/esm/document/data-type/simple-type.js
|
|
1614
1662
|
var SimpleType2 = /* @__PURE__ */ __name(function(...args) {
|
|
1615
|
-
if (this) {
|
|
1616
|
-
const [
|
|
1617
|
-
|
|
1618
|
-
return;
|
|
1663
|
+
if (!this) {
|
|
1664
|
+
const [options] = args;
|
|
1665
|
+
return SimpleType2[DECORATOR](options);
|
|
1619
1666
|
}
|
|
1620
|
-
const [
|
|
1621
|
-
|
|
1622
|
-
let name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
1623
|
-
name = name.charAt(0).toLowerCase() + name.substring(1);
|
|
1624
|
-
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target) || {};
|
|
1625
|
-
metadata.kind = opra_schema_ns_exports.SimpleType.Kind;
|
|
1626
|
-
metadata.name = name;
|
|
1627
|
-
if (options)
|
|
1628
|
-
Object.assign(metadata, omit3(options, ["kind", "name"]));
|
|
1629
|
-
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
1630
|
-
};
|
|
1667
|
+
const [document, init] = args;
|
|
1668
|
+
merge5(this, new SimpleTypeClass(document, init), { descriptor: true });
|
|
1631
1669
|
}, "SimpleType");
|
|
1632
1670
|
SimpleType2.prototype = SimpleTypeClass.prototype;
|
|
1671
|
+
Object.assign(SimpleType2, SimpleTypeDecorator);
|
|
1672
|
+
SimpleType2[DECORATOR] = SimpleTypeDecorator;
|
|
1633
1673
|
|
|
1634
1674
|
// ../../build/common/esm/document/data-type/builtin/any.type.js
|
|
1635
1675
|
var AnyType = class AnyType2 {
|
|
@@ -2102,7 +2142,77 @@ async function extractFieldSchema(target, ctor, metadata, name) {
|
|
|
2102
2142
|
__name(extractFieldSchema, "extractFieldSchema");
|
|
2103
2143
|
|
|
2104
2144
|
// ../../build/common/esm/document/resource/collection.js
|
|
2105
|
-
import
|
|
2145
|
+
import merge9 from "putil-merge";
|
|
2146
|
+
|
|
2147
|
+
// ../../build/common/esm/document/decorators/resource.decorator.js
|
|
2148
|
+
import omit4 from "lodash.omit";
|
|
2149
|
+
import merge6 from "putil-merge";
|
|
2150
|
+
function ResourceDecorator(kind, options) {
|
|
2151
|
+
const namePattern = new RegExp(`^(.*)(${kind}|Resource|Controller)$`);
|
|
2152
|
+
return function(target) {
|
|
2153
|
+
const name = options?.name || namePattern.exec(target.name)?.[1] || target.name;
|
|
2154
|
+
const metadata = { kind, name };
|
|
2155
|
+
const baseMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, Object.getPrototypeOf(target));
|
|
2156
|
+
if (baseMetadata)
|
|
2157
|
+
merge6(metadata, baseMetadata, { deep: true });
|
|
2158
|
+
const oldMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target);
|
|
2159
|
+
if (oldMetadata)
|
|
2160
|
+
merge6(metadata, oldMetadata, { deep: true });
|
|
2161
|
+
merge6(metadata, {
|
|
2162
|
+
kind,
|
|
2163
|
+
name,
|
|
2164
|
+
...omit4(options, ["kind", "name", "controller"])
|
|
2165
|
+
}, { deep: true });
|
|
2166
|
+
Reflect.defineMetadata(RESOURCE_METADATA, metadata, target);
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
__name(ResourceDecorator, "ResourceDecorator");
|
|
2170
|
+
ResourceDecorator.Action = function(options) {
|
|
2171
|
+
return (target, propertyKey) => {
|
|
2172
|
+
if (typeof propertyKey !== "string")
|
|
2173
|
+
throw new TypeError(`This decorator can't be used for Symbol keys'`);
|
|
2174
|
+
const actionMeta = { ...options };
|
|
2175
|
+
const resourceMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target.constructor) || {};
|
|
2176
|
+
resourceMetadata.actions = resourceMetadata.actions || {};
|
|
2177
|
+
resourceMetadata.actions[propertyKey] = actionMeta;
|
|
2178
|
+
Reflect.defineMetadata(RESOURCE_METADATA, resourceMetadata, target.constructor);
|
|
2179
|
+
};
|
|
2180
|
+
};
|
|
2181
|
+
|
|
2182
|
+
// ../../build/common/esm/document/decorators/collection-decorator.js
|
|
2183
|
+
var operationProperties = ["create", "delete", "deleteMany", "get", "findMany", "update", "updateMany"];
|
|
2184
|
+
function CollectionDecorator(type, options) {
|
|
2185
|
+
return ResourceDecorator(opra_schema_ns_exports.Collection.Kind, { ...options, type });
|
|
2186
|
+
}
|
|
2187
|
+
__name(CollectionDecorator, "CollectionDecorator");
|
|
2188
|
+
Object.assign(CollectionDecorator, ResourceDecorator);
|
|
2189
|
+
CollectionDecorator.Create = createOperationDecorator("create");
|
|
2190
|
+
CollectionDecorator.Delete = createOperationDecorator("delete");
|
|
2191
|
+
CollectionDecorator.DeleteMany = createOperationDecorator("deleteMany");
|
|
2192
|
+
CollectionDecorator.Get = createOperationDecorator("get");
|
|
2193
|
+
CollectionDecorator.FindMany = createOperationDecorator("findMany");
|
|
2194
|
+
CollectionDecorator.Update = createOperationDecorator("update");
|
|
2195
|
+
CollectionDecorator.UpdateMany = createOperationDecorator("updateMany");
|
|
2196
|
+
CollectionDecorator.Action = function(options) {
|
|
2197
|
+
const oldDecorator = ResourceDecorator.Action(options);
|
|
2198
|
+
return (target, propertyKey) => {
|
|
2199
|
+
if (typeof propertyKey === "string" && operationProperties.includes(propertyKey))
|
|
2200
|
+
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
2201
|
+
return oldDecorator(target, propertyKey);
|
|
2202
|
+
};
|
|
2203
|
+
};
|
|
2204
|
+
function createOperationDecorator(operation) {
|
|
2205
|
+
return (options) => (target, propertyKey) => {
|
|
2206
|
+
if (propertyKey !== operation)
|
|
2207
|
+
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
2208
|
+
const operationMeta = { ...options };
|
|
2209
|
+
const sourceMetadata = Reflect.getOwnMetadata(RESOURCE_METADATA, target.constructor) || {};
|
|
2210
|
+
sourceMetadata.operations = sourceMetadata.operations || {};
|
|
2211
|
+
sourceMetadata.operations[operation] = operationMeta;
|
|
2212
|
+
Reflect.defineMetadata(RESOURCE_METADATA, sourceMetadata, target.constructor);
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2215
|
+
__name(createOperationDecorator, "createOperationDecorator");
|
|
2106
2216
|
|
|
2107
2217
|
// ../../build/common/esm/document/resource/collection-class.js
|
|
2108
2218
|
import * as vg4 from "valgen";
|
|
@@ -9623,7 +9733,9 @@ import * as vg3 from "valgen";
|
|
|
9623
9733
|
|
|
9624
9734
|
// ../../build/common/esm/document/data-type/mapped-type.js
|
|
9625
9735
|
import "reflect-metadata";
|
|
9626
|
-
import
|
|
9736
|
+
import merge7 from "putil-merge";
|
|
9737
|
+
|
|
9738
|
+
// ../../build/common/esm/document/data-type/mapped-type-class.js
|
|
9627
9739
|
var MappedTypeClass = class extends DataType {
|
|
9628
9740
|
static {
|
|
9629
9741
|
__name(this, "MappedTypeClass");
|
|
@@ -9656,10 +9768,32 @@ var MappedTypeClass = class extends DataType {
|
|
|
9656
9768
|
return out;
|
|
9657
9769
|
}
|
|
9658
9770
|
};
|
|
9771
|
+
function getIsInheritedPredicateFn(pick, omit5) {
|
|
9772
|
+
const pickKeys = pick?.map((x) => String(x).toLowerCase());
|
|
9773
|
+
const omitKeys = omit5?.map((x) => String(x).toLowerCase());
|
|
9774
|
+
return (propertyName) => {
|
|
9775
|
+
if (omitKeys && omitKeys.includes(propertyName.toLowerCase()))
|
|
9776
|
+
return false;
|
|
9777
|
+
if (pickKeys)
|
|
9778
|
+
return pickKeys.includes(propertyName.toLowerCase());
|
|
9779
|
+
return true;
|
|
9780
|
+
};
|
|
9781
|
+
}
|
|
9782
|
+
__name(getIsInheritedPredicateFn, "getIsInheritedPredicateFn");
|
|
9783
|
+
|
|
9784
|
+
// ../../build/common/esm/document/data-type/mapped-type.js
|
|
9785
|
+
function PickType(classRef, keys) {
|
|
9786
|
+
return MappedType2(classRef, { pick: keys });
|
|
9787
|
+
}
|
|
9788
|
+
__name(PickType, "PickType");
|
|
9789
|
+
function OmitType(classRef, keys) {
|
|
9790
|
+
return MappedType2(classRef, { omit: keys });
|
|
9791
|
+
}
|
|
9792
|
+
__name(OmitType, "OmitType");
|
|
9659
9793
|
var MappedType2 = /* @__PURE__ */ __name(function(...args) {
|
|
9660
9794
|
if (this) {
|
|
9661
9795
|
const [document, init] = args;
|
|
9662
|
-
|
|
9796
|
+
merge7(this, new MappedTypeClass(document, init), { descriptor: true });
|
|
9663
9797
|
return;
|
|
9664
9798
|
}
|
|
9665
9799
|
const [mappedSource, options] = args;
|
|
@@ -9695,30 +9829,12 @@ var MappedType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9695
9829
|
}, "MappedType");
|
|
9696
9830
|
MappedType2.prototype = MappedTypeClass.prototype;
|
|
9697
9831
|
MappedType2._applyMixin = () => void 0;
|
|
9698
|
-
function getIsInheritedPredicateFn(pick, omit7) {
|
|
9699
|
-
const pickKeys = pick?.map((x) => String(x).toLowerCase());
|
|
9700
|
-
const omitKeys = omit7?.map((x) => String(x).toLowerCase());
|
|
9701
|
-
return (propertyName) => {
|
|
9702
|
-
if (omitKeys && omitKeys.includes(propertyName.toLowerCase()))
|
|
9703
|
-
return false;
|
|
9704
|
-
if (pickKeys)
|
|
9705
|
-
return pickKeys.includes(propertyName.toLowerCase());
|
|
9706
|
-
return true;
|
|
9707
|
-
};
|
|
9708
|
-
}
|
|
9709
|
-
__name(getIsInheritedPredicateFn, "getIsInheritedPredicateFn");
|
|
9710
|
-
function PickType(classRef, keys) {
|
|
9711
|
-
return MappedType2(classRef, { pick: keys });
|
|
9712
|
-
}
|
|
9713
|
-
__name(PickType, "PickType");
|
|
9714
|
-
function OmitType(classRef, keys) {
|
|
9715
|
-
return MappedType2(classRef, { omit: keys });
|
|
9716
|
-
}
|
|
9717
|
-
__name(OmitType, "OmitType");
|
|
9718
9832
|
|
|
9719
9833
|
// ../../build/common/esm/document/data-type/union-type.js
|
|
9720
9834
|
import "reflect-metadata";
|
|
9721
|
-
import
|
|
9835
|
+
import merge8 from "putil-merge";
|
|
9836
|
+
|
|
9837
|
+
// ../../build/common/esm/document/data-type/union-type-class.js
|
|
9722
9838
|
var UnionTypeClass = class extends DataType {
|
|
9723
9839
|
static {
|
|
9724
9840
|
__name(this, "UnionTypeClass");
|
|
@@ -9729,8 +9845,9 @@ var UnionTypeClass = class extends DataType {
|
|
|
9729
9845
|
this.fields = new ResponsiveMap();
|
|
9730
9846
|
const own = this.own;
|
|
9731
9847
|
own.types = [];
|
|
9848
|
+
const UnionType3 = Object.getPrototypeOf(this).constructor;
|
|
9732
9849
|
for (const base of init.types) {
|
|
9733
|
-
if (!(base instanceof ComplexType2 || base instanceof
|
|
9850
|
+
if (!(base instanceof ComplexType2 || base instanceof UnionType3 || base instanceof MappedType2))
|
|
9734
9851
|
throw new TypeError(`${opra_schema_ns_exports.UnionType.Kind} shall contain ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.UnionType.Kind} of ${opra_schema_ns_exports.MappedType.Kind} types.`);
|
|
9735
9852
|
own.types.push(base);
|
|
9736
9853
|
if (base.additionalFields)
|
|
@@ -9747,10 +9864,12 @@ var UnionTypeClass = class extends DataType {
|
|
|
9747
9864
|
return out;
|
|
9748
9865
|
}
|
|
9749
9866
|
};
|
|
9867
|
+
|
|
9868
|
+
// ../../build/common/esm/document/data-type/union-type.js
|
|
9750
9869
|
var UnionType2 = /* @__PURE__ */ __name(function(...args) {
|
|
9751
9870
|
if (this) {
|
|
9752
9871
|
const [document, init] = args;
|
|
9753
|
-
|
|
9872
|
+
merge8(this, new UnionTypeClass(document, init), { descriptor: true });
|
|
9754
9873
|
return;
|
|
9755
9874
|
}
|
|
9756
9875
|
const clasRefs = [...args].filter((x) => !!x);
|
|
@@ -9814,18 +9933,52 @@ function _generateCodec(type, codec, options) {
|
|
|
9814
9933
|
}
|
|
9815
9934
|
__name(_generateCodec, "_generateCodec");
|
|
9816
9935
|
|
|
9817
|
-
// ../../build/common/esm/document/resource/
|
|
9818
|
-
var
|
|
9936
|
+
// ../../build/common/esm/document/resource/endpoint.js
|
|
9937
|
+
var Endpoint = class _Endpoint {
|
|
9819
9938
|
static {
|
|
9820
|
-
__name(this, "
|
|
9939
|
+
__name(this, "Endpoint");
|
|
9821
9940
|
}
|
|
9822
9941
|
constructor(init) {
|
|
9942
|
+
this.parameters = new ResponsiveMap();
|
|
9823
9943
|
this.name = init.name;
|
|
9944
|
+
this.description = init.description;
|
|
9945
|
+
if (init.parameters) {
|
|
9946
|
+
for (const [n, p] of Object.entries(init.parameters)) {
|
|
9947
|
+
this.parameters.set(n, new _Endpoint.Parameter(p));
|
|
9948
|
+
}
|
|
9949
|
+
}
|
|
9824
9950
|
}
|
|
9825
9951
|
exportSchema() {
|
|
9826
|
-
|
|
9952
|
+
const schema = omitUndefined({
|
|
9953
|
+
description: this.description
|
|
9954
|
+
});
|
|
9955
|
+
if (this.parameters.size) {
|
|
9956
|
+
schema.parameters = {};
|
|
9957
|
+
for (const [name, param] of this.parameters.entries()) {
|
|
9958
|
+
schema.parameters[name] = param.exportSchema();
|
|
9959
|
+
}
|
|
9960
|
+
}
|
|
9961
|
+
return schema;
|
|
9827
9962
|
}
|
|
9828
9963
|
};
|
|
9964
|
+
(function(Endpoint2) {
|
|
9965
|
+
class Parameter {
|
|
9966
|
+
static {
|
|
9967
|
+
__name(this, "Parameter");
|
|
9968
|
+
}
|
|
9969
|
+
constructor(init) {
|
|
9970
|
+
Object.assign(this, init);
|
|
9971
|
+
}
|
|
9972
|
+
exportSchema() {
|
|
9973
|
+
return omitUndefined({
|
|
9974
|
+
type: typeof this.type === "string" ? this.type : this.type.exportSchema(),
|
|
9975
|
+
description: this.description,
|
|
9976
|
+
isArray: this.isArray
|
|
9977
|
+
});
|
|
9978
|
+
}
|
|
9979
|
+
}
|
|
9980
|
+
Endpoint2.Parameter = Parameter;
|
|
9981
|
+
})(Endpoint || (Endpoint = {}));
|
|
9829
9982
|
|
|
9830
9983
|
// ../../build/common/esm/document/resource/resource.js
|
|
9831
9984
|
var Resource = class {
|
|
@@ -9833,14 +9986,14 @@ var Resource = class {
|
|
|
9833
9986
|
__name(this, "Resource");
|
|
9834
9987
|
}
|
|
9835
9988
|
constructor(document, init) {
|
|
9836
|
-
this.actions =
|
|
9989
|
+
this.actions = new ResponsiveMap();
|
|
9837
9990
|
this.document = document;
|
|
9838
9991
|
this.name = init.name;
|
|
9839
9992
|
this.description = init.description;
|
|
9840
9993
|
this.controller = init.controller;
|
|
9841
9994
|
if (init.actions) {
|
|
9842
9995
|
for (const [name, meta] of Object.entries(init.actions)) {
|
|
9843
|
-
this.actions
|
|
9996
|
+
this.actions.set(name, new Endpoint({ ...meta, name }));
|
|
9844
9997
|
}
|
|
9845
9998
|
}
|
|
9846
9999
|
}
|
|
@@ -9849,14 +10002,12 @@ var Resource = class {
|
|
|
9849
10002
|
kind: this.kind,
|
|
9850
10003
|
description: this.description
|
|
9851
10004
|
});
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
10005
|
+
if (this.actions.size) {
|
|
10006
|
+
schema.actions = {};
|
|
10007
|
+
for (const action of this.actions.values()) {
|
|
10008
|
+
schema.actions[action.name] = action.exportSchema();
|
|
10009
|
+
}
|
|
9857
10010
|
}
|
|
9858
|
-
if (i)
|
|
9859
|
-
schema.actions = actions;
|
|
9860
10011
|
return schema;
|
|
9861
10012
|
}
|
|
9862
10013
|
toString() {
|
|
@@ -10021,64 +10172,42 @@ var CollectionClass = class extends Resource {
|
|
|
10021
10172
|
}
|
|
10022
10173
|
};
|
|
10023
10174
|
|
|
10024
|
-
// ../../build/common/esm/document/resource/collection
|
|
10025
|
-
|
|
10026
|
-
|
|
10175
|
+
// ../../build/common/esm/document/resource/collection.js
|
|
10176
|
+
var Collection2 = /* @__PURE__ */ __name(function(...args) {
|
|
10177
|
+
if (!this) {
|
|
10178
|
+
const [type, options] = args;
|
|
10179
|
+
return Collection2[DECORATOR].call(void 0, type, options);
|
|
10180
|
+
}
|
|
10181
|
+
const [document, init] = args;
|
|
10182
|
+
merge9(this, new CollectionClass(document, init), { descriptor: true });
|
|
10183
|
+
}, "Collection");
|
|
10184
|
+
Collection2.prototype = CollectionClass.prototype;
|
|
10185
|
+
Object.assign(Collection2, CollectionDecorator);
|
|
10186
|
+
Collection2[DECORATOR] = CollectionDecorator;
|
|
10027
10187
|
|
|
10028
|
-
// ../../build/common/esm/document/resource/
|
|
10029
|
-
|
|
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
|
-
};
|
|
10188
|
+
// ../../build/common/esm/document/resource/singleton.js
|
|
10189
|
+
import merge10 from "putil-merge";
|
|
10041
10190
|
|
|
10042
|
-
// ../../build/common/esm/document/
|
|
10043
|
-
|
|
10044
|
-
|
|
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
|
-
};
|
|
10191
|
+
// ../../build/common/esm/document/decorators/singleton.decorator.js
|
|
10192
|
+
function SingletonDecorator(type, options) {
|
|
10193
|
+
return ResourceDecorator(opra_schema_ns_exports.Singleton.Kind, { ...options, type });
|
|
10063
10194
|
}
|
|
10064
|
-
__name(
|
|
10065
|
-
Object.assign(
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
CollectionDecorator.Update = createOperationDecorator("update");
|
|
10072
|
-
CollectionDecorator.UpdateMany = createOperationDecorator("updateMany");
|
|
10073
|
-
CollectionDecorator.Action = function(options) {
|
|
10195
|
+
__name(SingletonDecorator, "SingletonDecorator");
|
|
10196
|
+
Object.assign(SingletonDecorator, ResourceDecorator);
|
|
10197
|
+
SingletonDecorator.Create = createOperationDecorator2("create");
|
|
10198
|
+
SingletonDecorator.Get = createOperationDecorator2("get");
|
|
10199
|
+
SingletonDecorator.Delete = createOperationDecorator2("delete");
|
|
10200
|
+
SingletonDecorator.Update = createOperationDecorator2("update");
|
|
10201
|
+
SingletonDecorator.Action = function(options) {
|
|
10074
10202
|
const oldDecorator = ResourceDecorator.Action(options);
|
|
10203
|
+
const operators = ["create", "delete", "get", "update"];
|
|
10075
10204
|
return (target, propertyKey) => {
|
|
10076
|
-
if (typeof propertyKey === "string" &&
|
|
10205
|
+
if (typeof propertyKey === "string" && operators.includes(propertyKey))
|
|
10077
10206
|
throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
|
|
10078
10207
|
return oldDecorator(target, propertyKey);
|
|
10079
10208
|
};
|
|
10080
10209
|
};
|
|
10081
|
-
function
|
|
10210
|
+
function createOperationDecorator2(operation) {
|
|
10082
10211
|
return (options) => (target, propertyKey) => {
|
|
10083
10212
|
if (propertyKey !== operation)
|
|
10084
10213
|
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
@@ -10089,23 +10218,7 @@ function createOperationDecorator(operation) {
|
|
|
10089
10218
|
Reflect.defineMetadata(RESOURCE_METADATA, sourceMetadata, target.constructor);
|
|
10090
10219
|
};
|
|
10091
10220
|
}
|
|
10092
|
-
__name(
|
|
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;
|
|
10106
|
-
|
|
10107
|
-
// ../../build/common/esm/document/resource/singleton.js
|
|
10108
|
-
import merge9 from "putil-merge";
|
|
10221
|
+
__name(createOperationDecorator2, "createOperationDecorator");
|
|
10109
10222
|
|
|
10110
10223
|
// ../../build/common/esm/document/resource/singleton-class.js
|
|
10111
10224
|
var SingletonClass = class extends Resource {
|
|
@@ -10157,52 +10270,6 @@ var SingletonClass = class extends Resource {
|
|
|
10157
10270
|
}
|
|
10158
10271
|
};
|
|
10159
10272
|
|
|
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
|
-
};
|
|
10193
|
-
function createOperationDecorator2(operation) {
|
|
10194
|
-
return (options) => (target, propertyKey) => {
|
|
10195
|
-
if (propertyKey !== operation)
|
|
10196
|
-
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10197
|
-
const operationMeta = { ...options };
|
|
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);
|
|
10202
|
-
};
|
|
10203
|
-
}
|
|
10204
|
-
__name(createOperationDecorator2, "createOperationDecorator");
|
|
10205
|
-
|
|
10206
10273
|
// ../../build/common/esm/document/resource/singleton.js
|
|
10207
10274
|
var Singleton2 = /* @__PURE__ */ __name(function(...args) {
|
|
10208
10275
|
if (!this) {
|
|
@@ -10210,53 +10277,18 @@ var Singleton2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
10210
10277
|
return Singleton2[DECORATOR].call(void 0, type, options);
|
|
10211
10278
|
}
|
|
10212
10279
|
const [document, init] = args;
|
|
10213
|
-
|
|
10280
|
+
merge10(this, new SingletonClass(document, init), { descriptor: true });
|
|
10214
10281
|
}, "Singleton");
|
|
10215
10282
|
Singleton2.prototype = SingletonClass.prototype;
|
|
10216
10283
|
Object.assign(Singleton2, SingletonDecorator);
|
|
10217
10284
|
Singleton2[DECORATOR] = SingletonDecorator;
|
|
10218
10285
|
|
|
10219
10286
|
// ../../build/common/esm/document/resource/storage.js
|
|
10220
|
-
import
|
|
10221
|
-
|
|
10222
|
-
// ../../build/common/esm/document/resource/storage-class.js
|
|
10223
|
-
var StorageClass = class extends Resource {
|
|
10224
|
-
static {
|
|
10225
|
-
__name(this, "StorageClass");
|
|
10226
|
-
}
|
|
10227
|
-
constructor(document, init) {
|
|
10228
|
-
super(document, init);
|
|
10229
|
-
this.kind = opra_schema_ns_exports.Storage.Kind;
|
|
10230
|
-
this.controller = init.controller;
|
|
10231
|
-
this.operations = { ...init.operations };
|
|
10232
|
-
}
|
|
10233
|
-
exportSchema() {
|
|
10234
|
-
return {
|
|
10235
|
-
...super.exportSchema(),
|
|
10236
|
-
...omitUndefined({
|
|
10237
|
-
kind: opra_schema_ns_exports.Storage.Kind,
|
|
10238
|
-
operations: this.operations
|
|
10239
|
-
})
|
|
10240
|
-
};
|
|
10241
|
-
}
|
|
10242
|
-
};
|
|
10287
|
+
import merge11 from "putil-merge";
|
|
10243
10288
|
|
|
10244
|
-
// ../../build/common/esm/document/
|
|
10245
|
-
import omit6 from "lodash.omit";
|
|
10246
|
-
var NAME_PATTERN3 = /^(.*)(Resource|Storage|Controller)$/;
|
|
10289
|
+
// ../../build/common/esm/document/decorators/storage.decorator.js
|
|
10247
10290
|
function StorageDecorator(options) {
|
|
10248
|
-
return
|
|
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
|
-
};
|
|
10291
|
+
return ResourceDecorator(opra_schema_ns_exports.Storage.Kind, options);
|
|
10260
10292
|
}
|
|
10261
10293
|
__name(StorageDecorator, "StorageDecorator");
|
|
10262
10294
|
Object.assign(StorageDecorator, ResourceDecorator);
|
|
@@ -10285,6 +10317,28 @@ function createOperationDecorator3(operation) {
|
|
|
10285
10317
|
}
|
|
10286
10318
|
__name(createOperationDecorator3, "createOperationDecorator");
|
|
10287
10319
|
|
|
10320
|
+
// ../../build/common/esm/document/resource/storage-class.js
|
|
10321
|
+
var StorageClass = class extends Resource {
|
|
10322
|
+
static {
|
|
10323
|
+
__name(this, "StorageClass");
|
|
10324
|
+
}
|
|
10325
|
+
constructor(document, init) {
|
|
10326
|
+
super(document, init);
|
|
10327
|
+
this.kind = opra_schema_ns_exports.Storage.Kind;
|
|
10328
|
+
this.controller = init.controller;
|
|
10329
|
+
this.operations = { ...init.operations };
|
|
10330
|
+
}
|
|
10331
|
+
exportSchema() {
|
|
10332
|
+
return {
|
|
10333
|
+
...super.exportSchema(),
|
|
10334
|
+
...omitUndefined({
|
|
10335
|
+
kind: opra_schema_ns_exports.Storage.Kind,
|
|
10336
|
+
operations: this.operations
|
|
10337
|
+
})
|
|
10338
|
+
};
|
|
10339
|
+
}
|
|
10340
|
+
};
|
|
10341
|
+
|
|
10288
10342
|
// ../../build/common/esm/document/resource/storage.js
|
|
10289
10343
|
var Storage2 = /* @__PURE__ */ __name(function(...args) {
|
|
10290
10344
|
if (!this) {
|
|
@@ -10292,7 +10346,7 @@ var Storage2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
10292
10346
|
return Storage2[DECORATOR].call(void 0, options);
|
|
10293
10347
|
}
|
|
10294
10348
|
const [document, init] = args;
|
|
10295
|
-
|
|
10349
|
+
merge11(this, new StorageClass(document, init), { descriptor: true });
|
|
10296
10350
|
}, "Storage");
|
|
10297
10351
|
Storage2.prototype = StorageClass.prototype;
|
|
10298
10352
|
Object.assign(Storage2, StorageDecorator);
|