@opra/common 0.23.2 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/browser.js +298 -205
  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 +9 -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 +11 -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 +3 -3
  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 +5 -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 +11 -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 +1 -1
  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 +4 -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 +8 -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 SOURCE_METADATA = Symbol("SOURCE_METADATA");
19
+ var DECORATOR = Symbol("DECORATOR");
18
20
  var NAMESPACE_PATTERN = /([A-Z$_]\w+)(?::.+)?/i;
19
21
  var TYPENAME_PATTERN = /^(.*)Type(\d*)$/;
20
22
 
@@ -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) {
989
+ function isSource(obj) {
988
990
  return obj && typeof obj === "object" && (obj.kind === Container.Kind || obj.kind === Collection.Kind || obj.kind === Singleton.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(SOURCE_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,7 @@ function _generateDecoder(type, codec, options) {
9809
9812
  caseInSensitive: true
9810
9813
  });
9811
9814
  }
9812
- __name(_generateDecoder, "_generateDecoder");
9815
+ __name(_generateCodec, "_generateCodec");
9813
9816
 
9814
9817
  // ../../build/common/esm/document/resource/resource.js
9815
9818
  var Resource = class {
@@ -9817,16 +9820,24 @@ var Resource = class {
9817
9820
  __name(this, "Resource");
9818
9821
  }
9819
9822
  constructor(document, init) {
9823
+ this.actions = new ResponsiveMap();
9820
9824
  this.document = document;
9821
9825
  this.name = init.name;
9822
9826
  this.description = init.description;
9823
9827
  this.controller = init.controller;
9824
9828
  }
9825
9829
  exportSchema() {
9826
- return omitUndefined({
9830
+ const schema = omitUndefined({
9827
9831
  kind: this.kind,
9828
9832
  description: this.description
9829
9833
  });
9834
+ if (this.actions.size) {
9835
+ const actions = schema.actions = {};
9836
+ for (const [name, r] of this.actions.entries()) {
9837
+ actions[name] = r.exportSchema();
9838
+ }
9839
+ }
9840
+ return schema;
9830
9841
  }
9831
9842
  toString() {
9832
9843
  return `[${Object.getPrototypeOf(this).constructor.name} ${this.name || "#anonymous"}]`;
@@ -9836,9 +9847,7 @@ var Resource = class {
9836
9847
  }
9837
9848
  };
9838
9849
 
9839
- // ../../build/common/esm/document/resource/collection.js
9840
- var NESTJS_INJECTABLE_WATERMARK = "__injectable__";
9841
- var NAME_PATTERN = /^(.*)(Resource|Collection)$/;
9850
+ // ../../build/common/esm/document/resource/collection-class.js
9842
9851
  var CollectionClass = class extends Resource {
9843
9852
  static {
9844
9853
  __name(this, "CollectionClass");
@@ -9861,13 +9870,14 @@ var CollectionClass = class extends Resource {
9861
9870
  });
9862
9871
  }
9863
9872
  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;
9873
+ return {
9874
+ ...super.exportSchema(),
9875
+ ...omitUndefined({
9876
+ type: this.type.name || "object",
9877
+ operations: this.operations,
9878
+ primaryKey: this.primaryKey
9879
+ })
9880
+ };
9871
9881
  }
9872
9882
  parseKeyValue(value) {
9873
9883
  if (!this.primaryKey?.length)
@@ -9963,84 +9973,121 @@ var CollectionClass = class extends Resource {
9963
9973
  }
9964
9974
  return ast;
9965
9975
  }
9966
- getDecoder(operation) {
9967
- let decoder = this._decoders[operation];
9976
+ getDecoder(endpoint) {
9977
+ let decoder = this._decoders[endpoint];
9968
9978
  if (decoder)
9969
9979
  return decoder;
9970
9980
  const options = {
9971
- partial: operation !== "create"
9981
+ partial: endpoint !== "create"
9972
9982
  };
9973
- if (operation !== "create")
9983
+ if (endpoint !== "create")
9974
9984
  options.omit = [...this.primaryKey];
9975
9985
  decoder = generateCodec(this.type, "decode", options);
9976
- this._decoders[operation] = decoder;
9986
+ this._decoders[endpoint] = decoder;
9977
9987
  return decoder;
9978
9988
  }
9979
- getEncoder(operation) {
9980
- let encoder = this._encoders[operation];
9989
+ getEncoder(endpoint) {
9990
+ let encoder = this._encoders[endpoint];
9981
9991
  if (encoder)
9982
9992
  return encoder;
9983
9993
  const options = {
9984
9994
  partial: true
9985
9995
  };
9986
9996
  encoder = generateCodec(this.type, "encode", options);
9987
- if (operation === "findMany")
9997
+ if (endpoint === "findMany")
9988
9998
  return vg4.isArray(encoder);
9989
- this._encoders[operation] = encoder;
9999
+ this._encoders[endpoint] = encoder;
9990
10000
  return encoder;
9991
10001
  }
9992
10002
  };
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;
10003
+
10004
+ // ../../build/common/esm/document/resource/collection-decorator.js
10005
+ import omit4 from "lodash.omit";
10006
+ import merge7 from "putil-merge";
10007
+
10008
+ // ../../build/common/esm/document/resource/resource-decorator.js
10009
+ var ResourceDecorator = {};
10010
+ ResourceDecorator.Action = function(options) {
10011
+ return (target, propertyKey) => {
10012
+ if (typeof propertyKey !== "string")
10013
+ throw new TypeError(`This decorator can't be used for Symbol keys'`);
10014
+ const actionMeta = { ...options };
10015
+ const resourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
10016
+ resourceMetadata.actions = resourceMetadata.actions || {};
10017
+ resourceMetadata.actions[propertyKey] = actionMeta;
10018
+ Reflect.defineMetadata(SOURCE_METADATA, resourceMetadata, target.constructor);
10019
+ };
10020
+ };
10021
+
10022
+ // ../../build/common/esm/document/resource/collection-decorator.js
10023
+ var NAME_PATTERN = /^(.*)(Resource|Collection|Controller)$/;
10024
+ var operationProperties = ["create", "delete", "deleteMany", "get", "findMany", "update", "updateMany"];
10025
+ function CollectionDecorator(type, options) {
10026
+ return function(target) {
10027
+ const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
10028
+ const metadata = Reflect.getOwnMetadata(SOURCE_METADATA, target) || {};
10029
+ const baseMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, Object.getPrototypeOf(target));
10030
+ if (baseMetadata) {
10031
+ merge7(metadata, baseMetadata, { deep: true });
10032
+ }
10033
+ metadata.kind = opra_schema_ns_exports.Collection.Kind;
10034
+ metadata.name = name;
10035
+ metadata.type = type;
10036
+ const m = Reflect.getMetadata(SOURCE_METADATA, target);
10037
+ if (m && metadata !== m)
10038
+ Object.assign(metadata, omit4(m), Object.keys(metadata));
10039
+ if (options)
10040
+ Object.assign(metadata, omit4(options, ["kind", "name", "type", "controller"]));
10041
+ Reflect.defineMetadata(SOURCE_METADATA, metadata, target);
10042
+ };
10043
+ }
10044
+ __name(CollectionDecorator, "CollectionDecorator");
10045
+ Object.assign(CollectionDecorator, ResourceDecorator);
10046
+ CollectionDecorator.Create = createOperationDecorator("create");
10047
+ CollectionDecorator.Delete = createOperationDecorator("delete");
10048
+ CollectionDecorator.DeleteMany = createOperationDecorator("deleteMany");
10049
+ CollectionDecorator.Get = createOperationDecorator("get");
10050
+ CollectionDecorator.FindMany = createOperationDecorator("findMany");
10051
+ CollectionDecorator.Update = createOperationDecorator("update");
10052
+ CollectionDecorator.UpdateMany = createOperationDecorator("updateMany");
10053
+ CollectionDecorator.Action = function(options) {
10054
+ const oldDecorator = ResourceDecorator.Action(options);
10055
+ return (target, propertyKey) => {
10056
+ if (typeof propertyKey === "string" && operationProperties.includes(propertyKey))
10057
+ throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
10058
+ return oldDecorator(target, propertyKey);
10059
+ };
10060
+ };
10019
10061
  function createOperationDecorator(operation) {
10020
10062
  return (options) => (target, propertyKey) => {
10021
10063
  if (propertyKey !== operation)
10022
10064
  throw new TypeError(`Name of the handler name should be '${operation}'`);
10023
10065
  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);
10066
+ const sourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
10067
+ sourceMetadata.operations = sourceMetadata.operations || {};
10068
+ sourceMetadata.operations[operation] = operationMeta;
10069
+ Reflect.defineMetadata(SOURCE_METADATA, sourceMetadata, target.constructor);
10028
10070
  };
10029
10071
  }
10030
10072
  __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");
10073
+
10074
+ // ../../build/common/esm/document/resource/collection.js
10075
+ var Collection2 = /* @__PURE__ */ __name(function(...args) {
10076
+ if (!this) {
10077
+ const [type, options] = args;
10078
+ return Collection2[DECORATOR].call(void 0, type, options);
10079
+ }
10080
+ const [document, init] = args;
10081
+ merge8(this, new CollectionClass(document, init), { descriptor: true });
10082
+ }, "Collection");
10083
+ Collection2.prototype = CollectionClass.prototype;
10084
+ Object.assign(Collection2, CollectionDecorator);
10085
+ Collection2[DECORATOR] = CollectionDecorator;
10038
10086
 
10039
10087
  // ../../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)$/;
10088
+ import merge9 from "putil-merge";
10089
+
10090
+ // ../../build/common/esm/document/resource/singleton-class.js
10044
10091
  var SingletonClass = class extends Resource {
10045
10092
  static {
10046
10093
  __name(this, "SingletonClass");
@@ -10055,83 +10102,104 @@ var SingletonClass = class extends Resource {
10055
10102
  this.type = init.type;
10056
10103
  }
10057
10104
  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;
10105
+ return {
10106
+ ...super.exportSchema(),
10107
+ ...omitUndefined({
10108
+ type: this.type.name || "any",
10109
+ operations: this.operations
10110
+ })
10111
+ };
10064
10112
  }
10065
10113
  normalizeFieldPath(path2) {
10066
10114
  return this.type.normalizeFieldPath(path2);
10067
10115
  }
10068
- getDecoder(operation) {
10069
- let decoder = this._decoders[operation];
10116
+ getDecoder(endpoint) {
10117
+ let decoder = this._decoders[endpoint];
10070
10118
  if (decoder)
10071
10119
  return decoder;
10072
10120
  const options = {
10073
- partial: operation !== "create"
10121
+ partial: endpoint !== "create"
10074
10122
  };
10075
10123
  decoder = generateCodec(this.type, "decode", options);
10076
- this._decoders[operation] = decoder;
10124
+ this._decoders[endpoint] = decoder;
10077
10125
  return decoder;
10078
10126
  }
10079
- getEncoder(operation) {
10080
- let encoder = this._encoders[operation];
10127
+ getEncoder(endpoint) {
10128
+ let encoder = this._encoders[endpoint];
10081
10129
  if (encoder)
10082
10130
  return encoder;
10083
10131
  const options = {
10084
10132
  partial: true
10085
10133
  };
10086
10134
  encoder = generateCodec(this.type, "encode", options);
10087
- this._encoders[operation] = encoder;
10135
+ this._encoders[endpoint] = encoder;
10088
10136
  return encoder;
10089
10137
  }
10090
10138
  };
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;
10139
+
10140
+ // ../../build/common/esm/document/resource/singleton-decorator.js
10141
+ import omit5 from "lodash.omit";
10142
+ var NAME_PATTERN2 = /^(.*)(Resource|Singleton|Controller)$/;
10143
+ function SingletonDecorator(type, options) {
10144
+ return function(target) {
10145
+ const name = options?.name || target.name.match(NAME_PATTERN2)?.[1] || target.name;
10146
+ const metadata = Reflect.getOwnMetadata(SOURCE_METADATA, target) || {};
10147
+ metadata.kind = opra_schema_ns_exports.Singleton.Kind;
10148
+ metadata.name = name;
10149
+ metadata.type = type;
10150
+ const m = Reflect.getMetadata(SOURCE_METADATA, target);
10151
+ if (m && metadata !== m)
10152
+ Object.assign(metadata, omit5(m), Object.keys(metadata));
10153
+ if (options)
10154
+ Object.assign(metadata, omit5(options, ["kind", "name", "type", "controller"]));
10155
+ Reflect.defineMetadata(SOURCE_METADATA, metadata, target);
10156
+ };
10157
+ }
10158
+ __name(SingletonDecorator, "SingletonDecorator");
10159
+ Object.assign(SingletonDecorator, ResourceDecorator);
10160
+ SingletonDecorator.Create = createOperationDecorator2("create");
10161
+ SingletonDecorator.Get = createOperationDecorator2("get");
10162
+ SingletonDecorator.Delete = createOperationDecorator2("delete");
10163
+ SingletonDecorator.Update = createOperationDecorator2("update");
10164
+ SingletonDecorator.Action = function(options) {
10165
+ const oldDecorator = ResourceDecorator.Action(options);
10166
+ const operators = ["create", "delete", "get", "update"];
10167
+ return (target, propertyKey) => {
10168
+ if (typeof propertyKey === "string" && operators.includes(propertyKey))
10169
+ throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
10170
+ return oldDecorator(target, propertyKey);
10171
+ };
10172
+ };
10113
10173
  function createOperationDecorator2(operation) {
10114
10174
  return (options) => (target, propertyKey) => {
10115
10175
  if (propertyKey !== operation)
10116
10176
  throw new TypeError(`Name of the handler name should be '${operation}'`);
10117
10177
  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);
10178
+ const sourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
10179
+ sourceMetadata.operations = sourceMetadata.operations || {};
10180
+ sourceMetadata.operations[operation] = operationMeta;
10181
+ Reflect.defineMetadata(SOURCE_METADATA, sourceMetadata, target.constructor);
10122
10182
  };
10123
10183
  }
10124
10184
  __name(createOperationDecorator2, "createOperationDecorator");
10125
- Singleton2.Create = createOperationDecorator2("create");
10126
- Singleton2.Get = createOperationDecorator2("get");
10127
- Singleton2.Delete = createOperationDecorator2("delete");
10128
- Singleton2.Update = createOperationDecorator2("update");
10185
+
10186
+ // ../../build/common/esm/document/resource/singleton.js
10187
+ var Singleton2 = /* @__PURE__ */ __name(function(...args) {
10188
+ if (!this) {
10189
+ const [type, options] = args;
10190
+ return Singleton2[DECORATOR].call(void 0, type, options);
10191
+ }
10192
+ const [document, init] = args;
10193
+ merge9(this, new SingletonClass(document, init), { descriptor: true });
10194
+ }, "Singleton");
10195
+ Singleton2.prototype = SingletonClass.prototype;
10196
+ Object.assign(Singleton2, SingletonDecorator);
10197
+ Singleton2[DECORATOR] = SingletonDecorator;
10129
10198
 
10130
10199
  // ../../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)$/;
10200
+ import merge10 from "putil-merge";
10201
+
10202
+ // ../../build/common/esm/document/resource/storage-class.js
10135
10203
  var StorageClass = class extends Resource {
10136
10204
  static {
10137
10205
  __name(this, "StorageClass");
@@ -10143,71 +10211,94 @@ var StorageClass = class extends Resource {
10143
10211
  this.operations = { ...init.operations };
10144
10212
  }
10145
10213
  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);
10214
+ return {
10215
+ ...super.exportSchema(),
10216
+ ...omitUndefined({
10217
+ kind: opra_schema_ns_exports.Storage.Kind,
10218
+ operations: this.operations
10219
+ })
10168
10220
  };
10169
10221
  }
10170
- const [document, init] = args;
10171
- merge9(this, new StorageClass(document, init), { descriptor: true });
10172
- }, "Storage");
10173
- Storage2.prototype = StorageClass.prototype;
10222
+ };
10223
+
10224
+ // ../../build/common/esm/document/resource/storage-decorator.js
10225
+ import omit6 from "lodash.omit";
10226
+ var NAME_PATTERN3 = /^(.*)(Resource|Storage|Controller)$/;
10227
+ function StorageDecorator(options) {
10228
+ return function(target) {
10229
+ const name = options?.name || target.name.match(NAME_PATTERN3)?.[1] || target.name;
10230
+ const metadata = Reflect.getOwnMetadata(SOURCE_METADATA, target) || {};
10231
+ metadata.kind = opra_schema_ns_exports.Storage.Kind;
10232
+ metadata.name = name;
10233
+ const m = Reflect.getMetadata(SOURCE_METADATA, target);
10234
+ if (m && metadata !== m)
10235
+ Object.assign(metadata, omit6(m), Object.keys(metadata));
10236
+ if (options)
10237
+ Object.assign(metadata, omit6(options, ["kind", "name", "type", "controller"]));
10238
+ Reflect.defineMetadata(SOURCE_METADATA, metadata, target);
10239
+ };
10240
+ }
10241
+ __name(StorageDecorator, "StorageDecorator");
10242
+ Object.assign(StorageDecorator, ResourceDecorator);
10243
+ StorageDecorator.Delete = createOperationDecorator3("delete");
10244
+ StorageDecorator.Get = createOperationDecorator3("get");
10245
+ StorageDecorator.Post = createOperationDecorator3("post");
10246
+ StorageDecorator.Action = function(options) {
10247
+ const oldDecorator = ResourceDecorator.Action(options);
10248
+ const operators = ["delete", "get", "post"];
10249
+ return (target, propertyKey) => {
10250
+ if (typeof propertyKey === "string" && operators.includes(propertyKey))
10251
+ throw new TypeError(`The "${propertyKey}" property is reserved for "${propertyKey}" operations and cannot be used as an action'`);
10252
+ return oldDecorator(target, propertyKey);
10253
+ };
10254
+ };
10174
10255
  function createOperationDecorator3(operation) {
10175
10256
  return (options) => (target, propertyKey) => {
10176
10257
  if (propertyKey !== operation)
10177
10258
  throw new TypeError(`Name of the handler name should be '${operation}'`);
10178
10259
  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);
10260
+ const sourceMetadata = Reflect.getOwnMetadata(SOURCE_METADATA, target.constructor) || {};
10261
+ sourceMetadata.operations = sourceMetadata.operations || {};
10262
+ sourceMetadata.operations[operation] = operationMeta;
10263
+ Reflect.defineMetadata(SOURCE_METADATA, sourceMetadata, target.constructor);
10183
10264
  };
10184
10265
  }
10185
10266
  __name(createOperationDecorator3, "createOperationDecorator");
10186
- Storage2.Delete = createOperationDecorator3("delete");
10187
- Storage2.Get = createOperationDecorator3("get");
10188
- Storage2.Post = createOperationDecorator3("post");
10267
+
10268
+ // ../../build/common/esm/document/resource/storage.js
10269
+ var Storage2 = /* @__PURE__ */ __name(function(...args) {
10270
+ if (!this) {
10271
+ const [options] = args;
10272
+ return Storage2[DECORATOR].call(void 0, options);
10273
+ }
10274
+ const [document, init] = args;
10275
+ merge10(this, new StorageClass(document, init), { descriptor: true });
10276
+ }, "Storage");
10277
+ Storage2.prototype = StorageClass.prototype;
10278
+ Object.assign(Storage2, StorageDecorator);
10279
+ Storage2[DECORATOR] = StorageDecorator;
10189
10280
 
10190
10281
  // ../../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);
10282
+ async function processSourceQueue() {
10283
+ const { document, sourceQueue } = this;
10284
+ const sourceNames = Array.from(sourceQueue.keys());
10285
+ for (const name of sourceNames) {
10286
+ const schema = sourceQueue.get(name);
10196
10287
  if (!schema)
10197
10288
  continue;
10198
10289
  try {
10199
10290
  if (opra_schema_ns_exports.isCollection(schema)) {
10200
- const resource = await this.createCollectionResource(name, schema);
10291
+ const resource = await this.createCollectionSource(name, schema);
10201
10292
  document.resources.set(name, resource);
10202
10293
  continue;
10203
10294
  }
10204
10295
  if (opra_schema_ns_exports.isSingleton(schema)) {
10205
- const resource = await this.createSingletonResource(name, schema);
10296
+ const resource = await this.createSingletonSource(name, schema);
10206
10297
  document.resources.set(name, resource);
10207
10298
  continue;
10208
10299
  }
10209
10300
  if (opra_schema_ns_exports.isStorage(schema)) {
10210
- const resource = await this.createFileResource(name, schema);
10301
+ const resource = await this.createFileSource(name, schema);
10211
10302
  document.resources.set(name, resource);
10212
10303
  continue;
10213
10304
  }
@@ -10218,7 +10309,7 @@ async function processResourceQueue() {
10218
10309
  throw new TypeError(`Invalid Resource schema: ${JSON.stringify(schema).substring(0, 20)}...`);
10219
10310
  }
10220
10311
  }
10221
- __name(processResourceQueue, "processResourceQueue");
10312
+ __name(processSourceQueue, "processSourceQueue");
10222
10313
  async function createCollectionResource(name, schema) {
10223
10314
  const { document } = this;
10224
10315
  const dataType = document.getComplexType(schema.type);
@@ -10241,7 +10332,7 @@ async function createSingletonResource(name, schema) {
10241
10332
  return new Singleton2(document, initArgs);
10242
10333
  }
10243
10334
  __name(createSingletonResource, "createSingletonResource");
10244
- async function createFileResource(name, schema) {
10335
+ async function createStorageResource(name, schema) {
10245
10336
  const { document } = this;
10246
10337
  const initArgs = {
10247
10338
  ...schema,
@@ -10249,7 +10340,7 @@ async function createFileResource(name, schema) {
10249
10340
  };
10250
10341
  return new Storage2(document, initArgs);
10251
10342
  }
10252
- __name(createFileResource, "createFileResource");
10343
+ __name(createStorageResource, "createStorageResource");
10253
10344
 
10254
10345
  // ../../build/common/esm/document/factory/process-types.js
10255
10346
  async function processTypes() {
@@ -10429,7 +10520,7 @@ var DocumentFactory = class _DocumentFactory {
10429
10520
  constructor() {
10430
10521
  this.document = new ApiDocument();
10431
10522
  this.typeQueue = new ResponsiveMap();
10432
- this.resourceQueue = new ResponsiveMap();
10523
+ this.sourceQueue = new ResponsiveMap();
10433
10524
  this.circularRefs = new ResponsiveMap();
10434
10525
  this.curPath = [];
10435
10526
  this.cache = /* @__PURE__ */ new Map();
@@ -10467,13 +10558,13 @@ DocumentFactory.designTypeMap = /* @__PURE__ */ new Map();
10467
10558
  _a2.prototype.processTypes = processTypes;
10468
10559
  _a2.prototype.createDataTypeInstance = createDataTypeInstance;
10469
10560
  _a2.prototype.addDataType = addDataType;
10470
- _a2.prototype.importResourceClass = importResourceClass;
10561
+ _a2.prototype.importSourceClass = importResourceClass;
10471
10562
  _a2.prototype.extractSingletonSchema = extractSingletonSchema;
10472
10563
  _a2.prototype.extractCollectionSchema = extractCollectionSchema;
10473
- _a2.prototype.processResourceQueue = processResourceQueue;
10474
- _a2.prototype.createCollectionResource = createCollectionResource;
10475
- _a2.prototype.createSingletonResource = createSingletonResource;
10476
- _a2.prototype.createFileResource = createFileResource;
10564
+ _a2.prototype.processSourceQueue = processSourceQueue;
10565
+ _a2.prototype.createCollectionSource = createCollectionResource;
10566
+ _a2.prototype.createSingletonSource = createSingletonResource;
10567
+ _a2.prototype.createFileSource = createStorageResource;
10477
10568
  })();
10478
10569
 
10479
10570
  // ../../build/common/esm/http/opra-url.js
@@ -11188,6 +11279,8 @@ export {
11188
11279
  BaseI18n,
11189
11280
  Collection2 as Collection,
11190
11281
  ComplexType2 as ComplexType,
11282
+ DATATYPE_METADATA,
11283
+ DECORATOR,
11191
11284
  DataType,
11192
11285
  DocumentFactory,
11193
11286
  EnumType2 as EnumType,
@@ -11199,7 +11292,6 @@ export {
11199
11292
  I18n,
11200
11293
  InternalServerError,
11201
11294
  IssueSeverity,
11202
- METADATA_KEY,
11203
11295
  MappedType2 as MappedType,
11204
11296
  MethodNotAllowedError,
11205
11297
  NAMESPACE_PATTERN,
@@ -11216,6 +11308,7 @@ export {
11216
11308
  ResourceConflictError,
11217
11309
  ResourceNotFoundError,
11218
11310
  ResponsiveMap,
11311
+ SOURCE_METADATA,
11219
11312
  SimpleType2 as SimpleType,
11220
11313
  Singleton2 as Singleton,
11221
11314
  Storage2 as Storage,