@opra/common 0.23.2 → 0.24.1

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