@opra/common 0.26.4 → 0.27.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 (73) hide show
  1. package/browser.js +353 -219
  2. package/cjs/document/data-type/complex-type-class.js +23 -5
  3. package/cjs/document/data-type/enum-type-class.js +4 -0
  4. package/cjs/document/data-type/mapped-type-class.js +0 -1
  5. package/cjs/document/factory/type-document-factory.js +19 -21
  6. package/cjs/document/index.js +8 -4
  7. package/cjs/document/resource/action-decorator.js +6 -0
  8. package/cjs/document/resource/action.js +33 -0
  9. package/cjs/document/resource/collection-class.js +31 -25
  10. package/cjs/document/resource/crud-resource.js +2 -2
  11. package/cjs/document/resource/endpoint.js +4 -4
  12. package/cjs/document/resource/enums/metadata-mode.enum.js +19 -0
  13. package/cjs/document/resource/operation.js +25 -0
  14. package/cjs/document/resource/resource.js +9 -6
  15. package/cjs/document/resource/singleton-class.js +16 -16
  16. package/cjs/document/resource/types/operation-result.type.js +44 -0
  17. package/cjs/document/type-document.js +61 -52
  18. package/cjs/helpers/object-utils.js +2 -2
  19. package/cjs/schema/opra-schema.ns.js +1 -0
  20. package/cjs/schema/resource/action.interface.js +2 -0
  21. package/esm/document/data-type/complex-type-class.js +23 -5
  22. package/esm/document/data-type/enum-type-class.js +4 -0
  23. package/esm/document/data-type/mapped-type-class.js +0 -1
  24. package/esm/document/factory/type-document-factory.js +19 -21
  25. package/esm/document/index.js +8 -4
  26. package/esm/document/resource/action-decorator.js +6 -0
  27. package/esm/document/resource/action.js +28 -0
  28. package/esm/document/resource/collection-class.js +31 -25
  29. package/esm/document/resource/crud-resource.js +2 -2
  30. package/esm/document/resource/endpoint.js +4 -3
  31. package/esm/document/resource/enums/metadata-mode.enum.js +16 -0
  32. package/esm/document/resource/operation.js +20 -0
  33. package/esm/document/resource/resource.js +9 -6
  34. package/esm/document/resource/singleton-class.js +16 -16
  35. package/esm/document/resource/types/operation-result.type.js +41 -0
  36. package/esm/document/type-document.js +61 -52
  37. package/esm/helpers/object-utils.js +2 -2
  38. package/esm/schema/opra-schema.ns.js +1 -0
  39. package/esm/schema/resource/action.interface.js +1 -0
  40. package/package.json +2 -2
  41. package/types/document/data-type/complex-type-class.d.ts +2 -1
  42. package/types/document/data-type/enum-type-class.d.ts +1 -0
  43. package/types/document/data-type/enum-type.d.ts +2 -2
  44. package/types/document/data-type/mapped-type-class.d.ts +1 -1
  45. package/types/document/data-type/simple-type-class.d.ts +1 -2
  46. package/types/document/data-type/union-type-class.d.ts +1 -1
  47. package/types/document/index.d.ts +8 -4
  48. package/types/document/resource/action-decorator.d.ts +4 -2
  49. package/types/document/resource/action.d.ts +30 -0
  50. package/types/document/resource/collection-class.d.ts +8 -8
  51. package/types/document/resource/collection-decorator.d.ts +18 -18
  52. package/types/document/resource/container-decorator.d.ts +4 -4
  53. package/types/document/resource/crud-resource.d.ts +3 -3
  54. package/types/document/resource/endpoint.d.ts +7 -11
  55. package/types/document/resource/enums/metadata-mode.enum.d.ts +5 -0
  56. package/types/document/resource/operation-decorator.d.ts +1 -1
  57. package/types/document/resource/operation.d.ts +25 -0
  58. package/types/document/resource/resource-decorator.d.ts +12 -5
  59. package/types/document/resource/resource.d.ts +6 -5
  60. package/types/document/resource/singleton-class.d.ts +5 -5
  61. package/types/document/resource/singleton-decorator.d.ts +12 -12
  62. package/types/document/resource/storage-class.d.ts +4 -4
  63. package/types/document/resource/storage-decorator.d.ts +10 -10
  64. package/types/document/resource/types/operation-result.type.d.ts +14 -0
  65. package/types/document/type-document.d.ts +14 -3
  66. package/types/schema/data-type/complex-type.interface.d.ts +3 -2
  67. package/types/schema/data-type/data-type.interface.d.ts +2 -2
  68. package/types/schema/data-type/enum-type.interface.d.ts +3 -1
  69. package/types/schema/data-type/simple-type.interface.d.ts +3 -1
  70. package/types/schema/opra-schema.ns.d.ts +1 -0
  71. package/types/schema/resource/action.interface.d.ts +6 -0
  72. package/types/schema/resource/container.interface.d.ts +0 -2
  73. package/types/schema/resource/resource.interface.d.ts +2 -2
package/browser.js CHANGED
@@ -144,8 +144,7 @@ import isPlainObject from "putil-isplainobject";
144
144
  import merge from "putil-merge";
145
145
  function cloneObject(obj, jsonOnly) {
146
146
  return merge({}, obj, {
147
- deep: true,
148
- clone: true,
147
+ deep: (v) => isPlainObject(v) && !v[DATATYPE_METADATA],
149
148
  filter: (source, key) => {
150
149
  const v = source[key];
151
150
  return v != null && !jsonOnly || typeof v !== "function" && (typeof v !== "object" || isPlainObject(v) || Array.isArray(v));
@@ -1023,7 +1022,7 @@ var colorReset = "\x1B[0m";
1023
1022
  var colorFgYellow = "\x1B[33m";
1024
1023
  var colorFgMagenta = "\x1B[35m";
1025
1024
 
1026
- // ../../build/common/esm/document/resource/endpoint.js
1025
+ // ../../build/common/esm/document/resource/action.js
1027
1026
  import * as vg2 from "valgen";
1028
1027
 
1029
1028
  // ../../build/common/esm/document/data-type/data-type.js
@@ -1117,8 +1116,6 @@ var Endpoint = class {
1117
1116
  constructor(resource, name, init) {
1118
1117
  this.resource = resource;
1119
1118
  this.name = name;
1120
- this.decode = vg2.isAny();
1121
- this.encode = vg2.isAny();
1122
1119
  Object.assign(this, init);
1123
1120
  this.parameters = new ResponsiveMap();
1124
1121
  if (init.parameters) {
@@ -1127,6 +1124,9 @@ var Endpoint = class {
1127
1124
  }
1128
1125
  }
1129
1126
  }
1127
+ getFullPath(documentPath) {
1128
+ return this.resource.getFullPath(documentPath) + (this.kind === "action" ? (documentPath ? "/actions/" : "/") + this.name : "");
1129
+ }
1130
1130
  defineParameter(name, init) {
1131
1131
  const type = init.type && init.type instanceof DataType ? init.type : this.resource.document.getDataType(init.type || "any");
1132
1132
  const prm = new Parameter(name, {
@@ -1151,6 +1151,31 @@ var Endpoint = class {
1151
1151
  }
1152
1152
  };
1153
1153
 
1154
+ // ../../build/common/esm/document/resource/action.js
1155
+ var Action = class extends Endpoint {
1156
+ static {
1157
+ __name(this, "Action");
1158
+ }
1159
+ constructor(resource, name, init) {
1160
+ super(resource, name, init);
1161
+ this.resource = resource;
1162
+ this.name = name;
1163
+ this.kind = "action";
1164
+ this.encodeReturning = vg2.isAny();
1165
+ if (init.returnType)
1166
+ this.returnType = init.returnType instanceof DataType ? init.returnType : this.resource.document.getDataType(init.returnType);
1167
+ this.returnMime = init.returnMime;
1168
+ }
1169
+ exportSchema(options) {
1170
+ const schema = super.exportSchema(options);
1171
+ if (this.returnType)
1172
+ schema.returnType = this.returnType.name ? this.returnType.name : this.returnType.exportSchema(options);
1173
+ if (this.returnMime)
1174
+ schema.returnMime = this.returnMime;
1175
+ return schema;
1176
+ }
1177
+ };
1178
+
1154
1179
  // ../../build/common/esm/document/resource/resource.js
1155
1180
  var Resource = class _Resource {
1156
1181
  static {
@@ -1172,14 +1197,17 @@ var Resource = class _Resource {
1172
1197
  this.ctor = init.ctor;
1173
1198
  if (init.actions) {
1174
1199
  for (const [name, meta] of Object.entries(init.actions)) {
1175
- this.actions.set(name, new Endpoint(this, name, meta));
1200
+ this.actions.set(name, new Action(this, name, meta));
1176
1201
  }
1177
1202
  }
1178
1203
  }
1179
- getFullPath() {
1180
- if (this.parent && this.parent.name)
1181
- return this.parent?.getFullPath() + "/" + this.name;
1182
- return this.name;
1204
+ getFullPath(documentPath) {
1205
+ if (this === this.document.root)
1206
+ return documentPath ? "/root" : "/";
1207
+ let out = this.parent?.getFullPath(documentPath);
1208
+ if (!out?.endsWith("/"))
1209
+ out += "/";
1210
+ return out + (documentPath ? "resources/" : "") + this.name;
1183
1211
  }
1184
1212
  exportSchema(options) {
1185
1213
  const schema = omitUndefined({
@@ -1300,6 +1328,12 @@ function createActionDecorator(options, bannedProperties, list) {
1300
1328
  });
1301
1329
  return decorator;
1302
1330
  };
1331
+ decorator.Returns = (t) => {
1332
+ list.push((actionMetadata) => {
1333
+ actionMetadata.returnType = t;
1334
+ });
1335
+ return decorator;
1336
+ };
1303
1337
  return decorator;
1304
1338
  }
1305
1339
  __name(createActionDecorator, "createActionDecorator");
@@ -1340,12 +1374,12 @@ function ContainerDecorator(options) {
1340
1374
  __name(ContainerDecorator, "ContainerDecorator");
1341
1375
  Object.assign(ContainerDecorator, ResourceDecorator);
1342
1376
  (function(ContainerDecorator2) {
1343
- function Action(options) {
1377
+ function Action2(options) {
1344
1378
  const list = [];
1345
1379
  return createActionDecorator(options, [], list);
1346
1380
  }
1347
- __name(Action, "Action");
1348
- ContainerDecorator2.Action = Action;
1381
+ __name(Action2, "Action");
1382
+ ContainerDecorator2.Action = Action2;
1349
1383
  })(ContainerDecorator || (ContainerDecorator = {}));
1350
1384
 
1351
1385
  // ../../build/common/esm/document/resource/container.js
@@ -1625,10 +1659,7 @@ var ComplexTypeClass = class extends DataType {
1625
1659
  return false;
1626
1660
  }
1627
1661
  generateCodec(codec, options) {
1628
- const schema = {};
1629
- for (const f of this.fields.values()) {
1630
- schema[f.name] = f.generateCodec(codec, options);
1631
- }
1662
+ const schema = this._generateCodecSchema(codec, options);
1632
1663
  return vg4.isObject(schema, {
1633
1664
  ctor: this.ctor,
1634
1665
  additionalFields: this.additionalFields ?? false,
@@ -1636,6 +1667,24 @@ var ComplexTypeClass = class extends DataType {
1636
1667
  caseInSensitive: !options?.caseSensitive
1637
1668
  });
1638
1669
  }
1670
+ _generateCodecSchema(codec, options) {
1671
+ const schema = {};
1672
+ const pickOption = (options?.pick || []).map((x) => x.toLowerCase());
1673
+ const omitOption = (options?.omit || []).map((x) => x.toLowerCase());
1674
+ for (const f of this.fields.values()) {
1675
+ const nameLower = f.name.toLowerCase();
1676
+ if (omitOption.find((x) => x === nameLower))
1677
+ continue;
1678
+ if (pickOption.length && !pickOption.find((x) => x === nameLower || x.startsWith(nameLower + ".")))
1679
+ continue;
1680
+ schema[f.name] = f.generateCodec(codec, {
1681
+ ...options,
1682
+ pick: pickOption.filter((x) => x.startsWith(nameLower + ".")).map((x) => x.substring(x.indexOf(".") + 1)),
1683
+ omit: omitOption.filter((x) => x.startsWith(nameLower + ".")).map((x) => x.substring(x.indexOf(".") + 1))
1684
+ });
1685
+ }
1686
+ return schema;
1687
+ }
1639
1688
  };
1640
1689
 
1641
1690
  // ../../build/common/esm/document/data-type/complex-type.js
@@ -1651,6 +1700,83 @@ ComplexType2.prototype = ComplexTypeClass.prototype;
1651
1700
  Object.assign(ComplexType2, ComplexTypeDecorator);
1652
1701
  ComplexType2[DECORATOR] = ComplexTypeDecorator;
1653
1702
 
1703
+ // ../../build/common/esm/document/data-type/enum-type.js
1704
+ import "reflect-metadata";
1705
+ import merge6 from "putil-merge";
1706
+
1707
+ // ../../build/common/esm/document/data-type/enum-type-class.js
1708
+ import * as vg5 from "valgen";
1709
+ var EnumTypeClass = class extends DataType {
1710
+ static {
1711
+ __name(this, "EnumTypeClass");
1712
+ }
1713
+ constructor(document, init) {
1714
+ super(document, init);
1715
+ this.kind = opra_schema_ns_exports.EnumType.Kind;
1716
+ this.enumObject = init.enumObject;
1717
+ this.base = init.base;
1718
+ this.ownValues = { ...init.values };
1719
+ this.values = { ...this.base?.values, ...this.ownValues };
1720
+ this.decode = vg5.isEnum(Object.keys(this.values));
1721
+ this.encode = vg5.isEnum(Object.keys(this.values));
1722
+ }
1723
+ isTypeOf(t) {
1724
+ return t[DATATYPE_METADATA] === this.enumObject?.[DATATYPE_METADATA];
1725
+ }
1726
+ exportSchema() {
1727
+ const out = super.exportSchema();
1728
+ out.values = {};
1729
+ Object.entries(this.values).forEach(([k, i]) => {
1730
+ out.values[k] = omitUndefined({ key: i.key, description: i.description });
1731
+ });
1732
+ return out;
1733
+ }
1734
+ generateCodec(codec) {
1735
+ if (codec === "encode")
1736
+ return this.encode;
1737
+ else
1738
+ return this.decode;
1739
+ }
1740
+ };
1741
+
1742
+ // ../../build/common/esm/document/data-type/enum-type.js
1743
+ var EnumType2 = /* @__PURE__ */ __name(function(...args) {
1744
+ if (!this) {
1745
+ const [enumSource, options] = args;
1746
+ let values = {};
1747
+ if (Array.isArray(enumSource)) {
1748
+ values = {};
1749
+ enumSource.forEach((k) => {
1750
+ const description = options?.meanings?.[k];
1751
+ values[k] = omitUndefined({ description });
1752
+ });
1753
+ } else {
1754
+ Object.keys(enumSource).forEach((k) => {
1755
+ const description = options?.meanings?.[k];
1756
+ values[enumSource[k]] = omitUndefined({ key: k, description });
1757
+ });
1758
+ }
1759
+ const metadata = {
1760
+ kind: opra_schema_ns_exports.EnumType.Kind,
1761
+ values,
1762
+ base: options?.base,
1763
+ name: options?.name,
1764
+ description: options?.description
1765
+ };
1766
+ Object.defineProperty(enumSource, DATATYPE_METADATA, {
1767
+ value: metadata,
1768
+ enumerable: false,
1769
+ configurable: true,
1770
+ writable: true
1771
+ });
1772
+ return metadata;
1773
+ }
1774
+ const [document, init] = args;
1775
+ merge6(this, new EnumTypeClass(document, init), { descriptor: true });
1776
+ return;
1777
+ }, "EnumType");
1778
+ EnumType2.prototype = EnumTypeClass.prototype;
1779
+
1654
1780
  // ../../build/common/esm/document/document-base.js
1655
1781
  var DocumentBase = class {
1656
1782
  static {
@@ -1682,8 +1808,8 @@ var TypeDocument = class extends DocumentBase {
1682
1808
  constructor() {
1683
1809
  super();
1684
1810
  this._designCtorMap = /* @__PURE__ */ new Map();
1685
- this._typeCache = new ResponsiveMap();
1686
- this._typesCacheByCtor = /* @__PURE__ */ new Map();
1811
+ this._typeIndex = /* @__PURE__ */ new Map();
1812
+ this._typeNsMap = /* @__PURE__ */ new Map();
1687
1813
  this.references = new ResponsiveMap();
1688
1814
  this.types = new ResponsiveMap();
1689
1815
  const BigIntConstructor = Object.getPrototypeOf(BigInt(0)).constructor;
@@ -1707,30 +1833,37 @@ var TypeDocument = class extends DocumentBase {
1707
1833
  if (x)
1708
1834
  arg0 = x;
1709
1835
  }
1710
- let dataType;
1711
- let name;
1712
- if (typeof arg0 === "function") {
1713
- const metadata = Reflect.getMetadata(DATATYPE_METADATA, arg0);
1714
- name = metadata?.name || arg0.name;
1715
- } else if (typeof arg0 === "function") {
1716
- const metadata = Reflect.getMetadata(DATATYPE_METADATA, arg0);
1717
- name = metadata?.name;
1718
- } else
1719
- name = String(arg0);
1720
- const t = typeof arg0 === "string" ? this._typeCache.get(arg0) : this._typesCacheByCtor.get(arg0);
1836
+ const t = typeof arg0 === "string" ? this._typeIndex.get(arg0.toLowerCase()) : this._typeIndex.get(arg0);
1721
1837
  if (t)
1722
1838
  return t;
1839
+ let name;
1840
+ if (typeof arg0 === "string")
1841
+ name = arg0;
1842
+ else if (arg0 instanceof DataType)
1843
+ name = arg0.name || "";
1844
+ else {
1845
+ const metadata = typeof arg0 === "function" ? Reflect.getMetadata(DATATYPE_METADATA, arg0) : arg0?.[DATATYPE_METADATA];
1846
+ if (!metadata) {
1847
+ if (!silent)
1848
+ throw new TypeError("Invalid argument");
1849
+ return;
1850
+ }
1851
+ name = metadata.name;
1852
+ }
1723
1853
  if (t === null) {
1724
1854
  if (silent)
1725
1855
  return;
1726
1856
  throw new Error(`Data type "${name}" does not exists`);
1727
1857
  }
1858
+ let dataType;
1859
+ let ns = "";
1728
1860
  if (typeof arg0 === "string" && arg0) {
1729
1861
  const m = NAMESPACE_PATTERN.exec(arg0);
1730
1862
  if (!m)
1731
1863
  throw new TypeError(`Invalid data type name "${name}"`);
1732
1864
  if (m[2]) {
1733
- const ref = this.references.get(m[1]);
1865
+ ns = m[1];
1866
+ const ref = this.references.get(ns);
1734
1867
  if (!ref) {
1735
1868
  if (silent)
1736
1869
  return;
@@ -1740,59 +1873,57 @@ var TypeDocument = class extends DocumentBase {
1740
1873
  } else {
1741
1874
  dataType = this.types.get(arg0);
1742
1875
  if (!dataType) {
1743
- const references = Array.from(this.references.values()).reverse();
1744
- for (const ref of references) {
1876
+ const references = Array.from(this.references.keys()).reverse();
1877
+ for (const refNs of references) {
1878
+ const ref = this.references.get(refNs);
1745
1879
  dataType = ref.getDataType(name, true);
1746
- if (dataType)
1880
+ if (dataType) {
1881
+ ns = refNs;
1747
1882
  break;
1883
+ }
1748
1884
  }
1749
1885
  }
1750
1886
  }
1751
- if (dataType) {
1752
- this._typeCache.set(arg0, dataType);
1753
- return dataType;
1754
- }
1755
- if (!silent)
1756
- throw new NotFoundError(`Data type "${arg0}" does not exists`);
1757
- return;
1758
- }
1759
- if (typeof arg0 === "function") {
1887
+ } else {
1760
1888
  const types = Array.from(this.types.values()).reverse();
1761
1889
  for (const dt of types) {
1762
- if (dt instanceof ComplexType2 && dt.isTypeOf(arg0)) {
1890
+ if (dt === arg0 || (dt instanceof ComplexType2 || dt instanceof EnumType2) && dt.isTypeOf(arg0)) {
1763
1891
  dataType = dt;
1764
1892
  break;
1765
1893
  }
1766
1894
  }
1767
1895
  if (!dataType) {
1768
- const references = Array.from(this.references.values()).reverse();
1769
- for (const ref of references) {
1896
+ const references = Array.from(this.references.keys()).reverse();
1897
+ for (const refNs of references) {
1898
+ const ref = this.references.get(refNs);
1770
1899
  dataType = ref.getDataType(arg0, true);
1771
- if (dataType)
1900
+ if (dataType) {
1901
+ ns = refNs;
1772
1902
  break;
1903
+ }
1773
1904
  }
1774
1905
  }
1775
- if (dataType)
1776
- this._typesCacheByCtor.set(arg0, dataType);
1777
- if (dataType)
1778
- return dataType;
1779
- if (!silent)
1780
- throw new Error(`No data type mapping found for class "${name}"`);
1781
- return;
1782
1906
  }
1783
- if (typeof arg0 === "object") {
1784
- const metadata = arg0[DATATYPE_METADATA];
1785
- if (metadata && metadata.name) {
1786
- dataType = this.getDataType(metadata.name, true);
1787
- if (dataType)
1788
- return dataType;
1789
- if (!silent)
1790
- throw new Error(`No data type mapping found for class "${name}"`);
1791
- }
1907
+ if (dataType) {
1908
+ this._typeIndex.set(arg0, dataType);
1909
+ if (ns)
1910
+ this._typeNsMap.set(dataType, ns);
1911
+ return dataType;
1792
1912
  }
1913
+ if (!silent)
1914
+ throw new NotFoundError(`Data type "${name}" does not exists`);
1915
+ return;
1793
1916
  if (!silent)
1794
1917
  throw new TypeError("Invalid argument");
1795
1918
  }
1919
+ /**
1920
+ *
1921
+ */
1922
+ getDataTypeNs(arg0, silent) {
1923
+ const dt = this.getDataType(arg0, silent);
1924
+ if (dt)
1925
+ return this._typeNsMap.get(dt);
1926
+ }
1796
1927
  getComplexType(nameOrCtor, silent) {
1797
1928
  if (nameOrCtor === Object)
1798
1929
  nameOrCtor = "object";
@@ -1845,8 +1976,8 @@ var TypeDocument = class extends DocumentBase {
1845
1976
  return schema;
1846
1977
  }
1847
1978
  invalidate() {
1848
- this._typeCache.clear();
1849
- this._typesCacheByCtor.clear();
1979
+ this._typeIndex.clear();
1980
+ this._typeNsMap.clear();
1850
1981
  }
1851
1982
  };
1852
1983
 
@@ -1903,7 +2034,7 @@ __name(__decorate, "__decorate");
1903
2034
 
1904
2035
  // ../../build/common/esm/document/data-type/simple-type.js
1905
2036
  import "reflect-metadata";
1906
- import merge6 from "putil-merge";
2037
+ import merge7 from "putil-merge";
1907
2038
 
1908
2039
  // ../../build/common/esm/document/data-type/simple-type.decorator.js
1909
2040
  import omit3 from "lodash.omit";
@@ -1922,7 +2053,7 @@ function SimpleTypeDecorator(options) {
1922
2053
  __name(SimpleTypeDecorator, "SimpleTypeDecorator");
1923
2054
 
1924
2055
  // ../../build/common/esm/document/data-type/simple-type-class.js
1925
- import * as vg5 from "valgen";
2056
+ import * as vg6 from "valgen";
1926
2057
  var SimpleTypeClass = class extends DataType {
1927
2058
  static {
1928
2059
  __name(this, "SimpleTypeClass");
@@ -1931,8 +2062,8 @@ var SimpleTypeClass = class extends DataType {
1931
2062
  super(document, init);
1932
2063
  this.kind = opra_schema_ns_exports.SimpleType.Kind;
1933
2064
  this.base = init.base;
1934
- this.decode = init.decoder || init.base?.decode || vg5.isAny();
1935
- this.encode = init.encoder || init.base?.encode || vg5.isAny();
2065
+ this.decode = init.decoder || init.base?.decode || vg6.isAny();
2066
+ this.encode = init.encoder || init.base?.encode || vg6.isAny();
1936
2067
  }
1937
2068
  exportSchema(options) {
1938
2069
  const out = super.exportSchema(options);
@@ -1958,7 +2089,7 @@ var SimpleType2 = /* @__PURE__ */ __name(function(...args) {
1958
2089
  return SimpleType2[DECORATOR](options);
1959
2090
  }
1960
2091
  const [document, init] = args;
1961
- merge6(this, new SimpleTypeClass(document, init), { descriptor: true });
2092
+ merge7(this, new SimpleTypeClass(document, init), { descriptor: true });
1962
2093
  }, "SimpleType");
1963
2094
  SimpleType2.prototype = SimpleTypeClass.prototype;
1964
2095
  Object.assign(SimpleType2, SimpleTypeDecorator);
@@ -2188,80 +2319,6 @@ TimestampType = __decorate([
2188
2319
  })
2189
2320
  ], TimestampType);
2190
2321
 
2191
- // ../../build/common/esm/document/data-type/enum-type.js
2192
- import "reflect-metadata";
2193
- import merge7 from "putil-merge";
2194
-
2195
- // ../../build/common/esm/document/data-type/enum-type-class.js
2196
- import * as vg6 from "valgen";
2197
- var EnumTypeClass = class extends DataType {
2198
- static {
2199
- __name(this, "EnumTypeClass");
2200
- }
2201
- constructor(document, init) {
2202
- super(document, init);
2203
- this.kind = opra_schema_ns_exports.EnumType.Kind;
2204
- this.enumObject = init.enumObject;
2205
- this.base = init.base;
2206
- this.ownValues = { ...init.values };
2207
- this.values = { ...this.base?.values, ...this.ownValues };
2208
- this.decode = vg6.isEnum(Object.keys(this.values));
2209
- this.encode = vg6.isEnum(Object.keys(this.values));
2210
- }
2211
- exportSchema() {
2212
- const out = super.exportSchema();
2213
- out.values = {};
2214
- Object.entries(this.values).forEach(([k, i]) => {
2215
- out.values[k] = omitUndefined({ key: i.key, description: i.description });
2216
- });
2217
- return out;
2218
- }
2219
- generateCodec(codec) {
2220
- if (codec === "encode")
2221
- return this.encode;
2222
- else
2223
- return this.decode;
2224
- }
2225
- };
2226
-
2227
- // ../../build/common/esm/document/data-type/enum-type.js
2228
- var EnumType2 = /* @__PURE__ */ __name(function(...args) {
2229
- if (!this) {
2230
- const [enumSource, options] = args;
2231
- let values = {};
2232
- if (Array.isArray(enumSource)) {
2233
- values = {};
2234
- enumSource.forEach((k) => {
2235
- const description = options?.meanings?.[k];
2236
- values[k] = omitUndefined({ description });
2237
- });
2238
- } else {
2239
- Object.keys(enumSource).forEach((k) => {
2240
- const description = options?.meanings?.[k];
2241
- values[enumSource[k]] = omitUndefined({ key: k, description });
2242
- });
2243
- }
2244
- const metadata = {
2245
- kind: opra_schema_ns_exports.EnumType.Kind,
2246
- values,
2247
- base: options?.base,
2248
- name: options?.name,
2249
- description: options?.description
2250
- };
2251
- Object.defineProperty(enumSource, DATATYPE_METADATA, {
2252
- value: metadata,
2253
- enumerable: false,
2254
- configurable: true,
2255
- writable: true
2256
- });
2257
- return metadata;
2258
- }
2259
- const [document, init] = args;
2260
- merge7(this, new EnumTypeClass(document, init), { descriptor: true });
2261
- return;
2262
- }, "EnumType");
2263
- EnumType2.prototype = EnumTypeClass.prototype;
2264
-
2265
2322
  // ../../build/common/esm/document/data-type/mapped-type.js
2266
2323
  import "reflect-metadata";
2267
2324
  import merge8 from "putil-merge";
@@ -2287,7 +2344,6 @@ var MappedTypeClass = class extends ComplexTypeClass {
2287
2344
  }
2288
2345
  }
2289
2346
  }
2290
- // @ts-ignore
2291
2347
  exportSchema() {
2292
2348
  const out = super.exportSchema();
2293
2349
  Object.assign(out, omitUndefined({
@@ -2434,6 +2490,66 @@ var UnionType2 = /* @__PURE__ */ __name(function(...args) {
2434
2490
  UnionType2.prototype = UnionTypeClass.prototype;
2435
2491
  UnionType2._applyMixin = () => void 0;
2436
2492
 
2493
+ // ../../build/common/esm/document/resource/enums/metadata-mode.enum.js
2494
+ var MetadataMode;
2495
+ (function(MetadataMode2) {
2496
+ MetadataMode2["none"] = "none";
2497
+ MetadataMode2["minimal"] = "minimal";
2498
+ MetadataMode2["full"] = "full";
2499
+ })(MetadataMode || (MetadataMode = {}));
2500
+ EnumType2(MetadataMode, {
2501
+ name: "MetadataMode",
2502
+ description: 'Parameter "enumeration" that controls how metadata information sent',
2503
+ meanings: {
2504
+ "none": "Specifies that the service will include NO metadata information in the response",
2505
+ "minimal": "Specifies that the service will include ALL metadata information in the response",
2506
+ "full": "Specifies that the service will include MINIMAL metadata information in the response"
2507
+ }
2508
+ });
2509
+
2510
+ // ../../build/common/esm/document/resource/types/operation-result.type.js
2511
+ var OperationResult = class OperationResult2 {
2512
+ static {
2513
+ __name(this, "OperationResult");
2514
+ }
2515
+ constructor(init) {
2516
+ if (init)
2517
+ Object.assign(this, init);
2518
+ }
2519
+ };
2520
+ __decorate([
2521
+ ApiField()
2522
+ ], OperationResult.prototype, "context", void 0);
2523
+ __decorate([
2524
+ ApiField()
2525
+ ], OperationResult.prototype, "contextUrl", void 0);
2526
+ __decorate([
2527
+ ApiField()
2528
+ ], OperationResult.prototype, "type", void 0);
2529
+ __decorate([
2530
+ ApiField()
2531
+ ], OperationResult.prototype, "typeUrl", void 0);
2532
+ __decorate([
2533
+ ApiField()
2534
+ ], OperationResult.prototype, "affected", void 0);
2535
+ __decorate([
2536
+ ApiField()
2537
+ ], OperationResult.prototype, "count", void 0);
2538
+ __decorate([
2539
+ ApiField()
2540
+ ], OperationResult.prototype, "totalMatches", void 0);
2541
+ __decorate([
2542
+ ApiField({ type: "any" })
2543
+ ], OperationResult.prototype, "payload", void 0);
2544
+ __decorate([
2545
+ ApiField({ type: "object" })
2546
+ ], OperationResult.prototype, "errors", void 0);
2547
+ OperationResult = __decorate([
2548
+ ComplexType2({
2549
+ description: "Operation result"
2550
+ })
2551
+ ], OperationResult);
2552
+
2437
2553
  // ../../build/common/esm/document/factory/type-document-factory.js
2438
2554
  var TypeDocumentFactory = class _TypeDocumentFactory {
2439
2555
  static {
@@ -2469,7 +2585,7 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2469
2585
  Object.assign(this.document.info, init.info);
2470
2586
  if (!init?.noBuiltinTypes) {
2471
2587
  const builtinDocument = await this.createBuiltinTypeDocument();
2472
- this.document.references.set("Opra", builtinDocument);
2588
+ this.document.references.set("opra", builtinDocument);
2473
2589
  }
2474
2590
  if (init.references)
2475
2591
  await this.addReferences(init.references);
@@ -2506,14 +2622,10 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2506
2622
  async createBuiltinTypeDocument() {
2507
2623
  const init = {
2508
2624
  version: opra_schema_ns_exports.SpecVersion,
2625
+ url: "https://oprajs.com/spec/v1.0",
2509
2626
  info: {
2510
2627
  version: opra_schema_ns_exports.SpecVersion,
2511
2628
  title: "Opra built-in types",
2512
- contact: [
2513
- {
2514
- url: "https://github.com/oprajs/opra"
2515
- }
2516
- ],
2517
2629
  license: {
2518
2630
  url: "https://github.com/oprajs/opra/blob/main/LICENSE",
2519
2631
  name: "MIT"
@@ -2533,7 +2645,9 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2533
2645
  ObjectIdType,
2534
2646
  StringType,
2535
2647
  TimeType,
2536
- TimestampType
2648
+ TimestampType,
2649
+ OperationResult,
2650
+ MetadataMode
2537
2651
  ]
2538
2652
  };
2539
2653
  const factory = new _TypeDocumentFactory();
@@ -2556,12 +2670,13 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2556
2670
  async importDataType(thunk) {
2557
2671
  thunk = await resolveThunk(thunk);
2558
2672
  let name = "";
2559
- let schema;
2560
2673
  let ctor;
2561
2674
  if (typeof thunk === "string") {
2562
2675
  name = thunk;
2563
- schema = this.typeQueue.get(name);
2564
- } else if (typeof thunk === "function") {
2676
+ thunk = this.typeQueue.get(name);
2677
+ }
2678
+ let initArguments;
2679
+ if (typeof thunk === "function") {
2565
2680
  const metadata = Reflect.getMetadata(DATATYPE_METADATA, thunk);
2566
2681
  if (!metadata) {
2567
2682
  const dataType = this.document.getDataType(thunk, true);
@@ -2570,25 +2685,23 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2570
2685
  throw new TypeError(`Class "${thunk.name}" doesn't have a valid DataType metadata`);
2571
2686
  }
2572
2687
  name = metadata.name;
2573
- schema = metadata;
2688
+ initArguments = cloneObject(metadata);
2574
2689
  ctor = thunk;
2575
2690
  } else if (typeof thunk === "object") {
2576
2691
  if (opra_schema_ns_exports.isDataType(thunk)) {
2577
2692
  name = thunk.name;
2578
2693
  ctor = thunk.ctor || ctor;
2579
- schema = thunk;
2694
+ initArguments = cloneObject(thunk);
2580
2695
  } else {
2581
2696
  const metadata = thunk[DATATYPE_METADATA];
2582
2697
  if (!metadata)
2583
2698
  throw new TypeError(`No EnumType metadata found for object ${JSON.stringify(thunk).substring(0, 20)}...`);
2584
2699
  name = metadata.name;
2585
- const dataType = this.document.getDataType(name, true);
2586
- if (dataType)
2587
- return dataType;
2588
- schema = cloneObject(metadata);
2700
+ initArguments = cloneObject(metadata);
2701
+ initArguments.enumObject = thunk;
2589
2702
  }
2590
2703
  }
2591
- ctor = ctor ?? (schema && isConstructor(schema.ctor) ? schema.ctor : void 0);
2704
+ ctor = ctor ?? (initArguments && isConstructor(initArguments.ctor) ? initArguments.ctor : void 0);
2592
2705
  if (name) {
2593
2706
  if (this.circularRefs.has(name.toLowerCase()))
2594
2707
  throw new TypeError("Circular reference detected");
@@ -2607,12 +2720,11 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2607
2720
  this.circularRefs.set(ctor, 1);
2608
2721
  }
2609
2722
  try {
2610
- if (!opra_schema_ns_exports.isDataType(schema))
2723
+ if (!initArguments)
2611
2724
  throw new TypeError(`No DataType schema determined`);
2612
- const instance = this.createDataTypeInstance(schema.kind, name);
2725
+ const instance = this.createDataTypeInstance(initArguments.kind, name);
2613
2726
  if (name)
2614
2727
  this.document.types.set(name, instance);
2615
- const initArguments = cloneObject(schema);
2616
2728
  await this.prepareDataTypeInitArguments(initArguments, ctor);
2617
2729
  if (initArguments.kind === "ComplexType")
2618
2730
  ComplexType2.apply(instance, [this.document, initArguments]);
@@ -2625,7 +2737,7 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2625
2737
  else if (initArguments.kind === "UnionType")
2626
2738
  UnionType2.apply(instance, [this.document, initArguments]);
2627
2739
  else
2628
- throw new TypeError(`Invalid data type schema: ${String(schema)}`);
2740
+ throw new TypeError(`Invalid data type schema: ${String(initArguments)}`);
2629
2741
  return instance;
2630
2742
  } finally {
2631
2743
  if (name) {
@@ -2675,7 +2787,7 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2675
2787
  if (enumObject[DATATYPE_METADATA]) {
2676
2788
  fieldInit.type = await this.importDataType(enumObject);
2677
2789
  } else {
2678
- const enumMeta = EnumType2(enumObject);
2790
+ const enumMeta = EnumType2(enumObject, { name: "" });
2679
2791
  fieldInit.type = await this.importDataType({ ...enumMeta, kind: "EnumType", base: void 0 });
2680
2792
  }
2681
2793
  } else {
@@ -2739,7 +2851,7 @@ TypeDocumentFactory.designTypeMap = /* @__PURE__ */ new Map();
2739
2851
  import merge10 from "putil-merge";
2740
2852
 
2741
2853
  // ../../build/common/esm/document/resource/collection-class.js
2742
- import * as vg7 from "valgen";
2854
+ import * as vg8 from "valgen";
2743
2855
 
2744
2856
  // ../../build/common/esm/filter/opra-filter.ns.js
2745
2857
  var opra_filter_ns_exports = {};
@@ -10252,6 +10364,24 @@ var _wrapEntryValue = /* @__PURE__ */ __name((v) => {
10252
10364
  return new StringLiteral("" + v);
10253
10365
  }, "_wrapEntryValue");
10254
10366
 
10367
+ // ../../build/common/esm/document/resource/operation.js
10368
+ import * as vg7 from "valgen";
10369
+ var Operation = class extends Endpoint {
10370
+ static {
10371
+ __name(this, "Operation");
10372
+ }
10373
+ constructor(resource, name, init) {
10374
+ super(resource, name, init);
10375
+ this.resource = resource;
10376
+ this.name = name;
10377
+ this.kind = "operation";
10378
+ this.decodeInput = vg7.isAny();
10379
+ this.encodeReturning = vg7.isAny();
10380
+ this.returnType = init.returnType instanceof DataType ? init.returnType : this.resource.document.getDataType(init.returnType || "any");
10381
+ this.encodeReturning = this.returnType.generateCodec("encode");
10382
+ }
10383
+ };
10384
+
10255
10385
  // ../../build/common/esm/document/resource/crud-resource.js
10256
10386
  var CrudResource = class extends Resource {
10257
10387
  static {
@@ -10262,7 +10392,7 @@ var CrudResource = class extends Resource {
10262
10392
  this.operations = new ResponsiveMap();
10263
10393
  if (init.operations) {
10264
10394
  for (const [name, meta] of Object.entries(init.operations)) {
10265
- this.operations.set(name, new Endpoint(this, name, meta));
10395
+ this.operations.set(name, new Operation(this, name, meta));
10266
10396
  }
10267
10397
  }
10268
10398
  }
@@ -10300,20 +10430,20 @@ var CollectionClass = class extends CrudResource {
10300
10430
  });
10301
10431
  let endpoint = this.operations.get("create");
10302
10432
  if (endpoint) {
10303
- endpoint.returnType = this.type;
10304
- endpoint.decode = this.type.generateCodec("decode", {
10433
+ endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10434
+ endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10435
+ endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10436
+ endpoint.decodeInput = this.type.generateCodec("decode", {
10305
10437
  partial: true,
10306
10438
  pick: endpoint.inputPickFields,
10307
10439
  omit: endpoint.inputOmitFields
10308
10440
  });
10309
- endpoint.encode = this.type.generateCodec("encode", {
10441
+ endpoint.returnType = this.type;
10442
+ endpoint.encodeReturning = endpoint.returnType.generateCodec("encode", {
10310
10443
  partial: true,
10311
10444
  pick: endpoint.outputPickFields,
10312
10445
  omit: endpoint.outputOmitFields
10313
10446
  });
10314
- endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10315
- endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10316
- endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10317
10447
  }
10318
10448
  endpoint = this.operations.get("deleteMany");
10319
10449
  if (endpoint) {
@@ -10321,24 +10451,18 @@ var CollectionClass = class extends CrudResource {
10321
10451
  }
10322
10452
  endpoint = this.operations.get("get");
10323
10453
  if (endpoint) {
10454
+ endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10455
+ endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10456
+ endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10324
10457
  endpoint.returnType = this.type;
10325
- endpoint.encode = this.type.generateCodec("encode", {
10458
+ endpoint.encodeReturning = endpoint.returnType.generateCodec("encode", {
10326
10459
  partial: true,
10327
10460
  pick: endpoint.outputPickFields,
10328
10461
  omit: endpoint.outputOmitFields
10329
10462
  });
10330
- endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10331
- endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10332
- endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10333
10463
  }
10334
10464
  endpoint = this.operations.get("findMany");
10335
10465
  if (endpoint) {
10336
- endpoint.returnType = this.type;
10337
- endpoint.encode = vg7.isArray(this.type.generateCodec("encode", {
10338
- partial: true,
10339
- pick: endpoint.outputPickFields,
10340
- omit: endpoint.outputOmitFields
10341
- }));
10342
10466
  endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10343
10467
  endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10344
10468
  endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
@@ -10348,30 +10472,36 @@ var CollectionClass = class extends CrudResource {
10348
10472
  endpoint.defineParameter("skip", { type: "integer", isBuiltin: true });
10349
10473
  endpoint.defineParameter("distinct", { type: "boolean", isBuiltin: true });
10350
10474
  endpoint.defineParameter("count", { type: "boolean", isBuiltin: true });
10475
+ endpoint.returnType = this.type;
10476
+ endpoint.encodeReturning = vg8.isArray(this.type.generateCodec("encode", {
10477
+ partial: true,
10478
+ pick: endpoint.outputPickFields,
10479
+ omit: endpoint.outputOmitFields
10480
+ }));
10351
10481
  }
10352
10482
  endpoint = this.operations.get("update");
10353
10483
  if (endpoint) {
10354
- endpoint.returnType = this.type;
10355
- endpoint.decode = this.type.generateCodec("decode", {
10484
+ endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10485
+ endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10486
+ endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10487
+ endpoint.decodeInput = this.type.generateCodec("decode", {
10356
10488
  pick: endpoint.inputPickFields,
10357
10489
  omit: endpoint.inputOmitFields
10358
10490
  });
10359
- endpoint.encode = this.type.generateCodec("encode", {
10491
+ endpoint.returnType = this.type;
10492
+ endpoint.encodeReturning = endpoint.returnType.generateCodec("encode", {
10360
10493
  partial: true,
10361
10494
  pick: endpoint.outputPickFields,
10362
10495
  omit: endpoint.outputOmitFields
10363
10496
  });
10364
- endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10365
- endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10366
- endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10367
10497
  }
10368
10498
  endpoint = this.operations.get("updateMany");
10369
10499
  if (endpoint) {
10370
- endpoint.decode = this.type.generateCodec("decode", {
10500
+ endpoint.defineParameter("filter", { type: "string", isBuiltin: true });
10501
+ endpoint.decodeInput = this.type.generateCodec("decode", {
10371
10502
  pick: endpoint.inputPickFields,
10372
10503
  omit: endpoint.inputOmitFields
10373
10504
  });
10374
- endpoint.defineParameter("filter", { type: "string", isBuiltin: true });
10375
10505
  }
10376
10506
  }
10377
10507
  getOperation(name) {
@@ -10408,7 +10538,7 @@ var CollectionClass = class extends CrudResource {
10408
10538
  value = value[primaryKey];
10409
10539
  const el = dataType.getField(primaryKey);
10410
10540
  let result;
10411
- if (el.type instanceof SimpleType2)
10541
+ if (value != null && el.type instanceof SimpleType2)
10412
10542
  result = el.type.decode(value);
10413
10543
  if (result == null)
10414
10544
  throw new TypeError(`You must provide value of primary field(s) (${primaryKey})`);
@@ -10515,12 +10645,12 @@ function CollectionDecorator(type, options) {
10515
10645
  __name(CollectionDecorator, "CollectionDecorator");
10516
10646
  Object.assign(CollectionDecorator, ResourceDecorator);
10517
10647
  (function(CollectionDecorator2) {
10518
- function Action(options) {
10648
+ function Action2(options) {
10519
10649
  const list = [];
10520
10650
  return createActionDecorator(options, operationProperties, list);
10521
10651
  }
10522
- __name(Action, "Action");
10523
- CollectionDecorator2.Action = Action;
10652
+ __name(Action2, "Action");
10653
+ CollectionDecorator2.Action = Action2;
10524
10654
  function Create(options) {
10525
10655
  const list = [];
10526
10656
  const decorator = createOperationDecorator("create", options, list);
@@ -10706,48 +10836,48 @@ var SingletonClass = class extends CrudResource {
10706
10836
  this.type = init.type;
10707
10837
  let endpoint = this.operations.get("create");
10708
10838
  if (endpoint) {
10709
- endpoint.returnType = this.type;
10710
- endpoint.decode = this.type.generateCodec("decode", {
10839
+ endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10840
+ endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10841
+ endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10842
+ endpoint.decodeInput = this.type.generateCodec("decode", {
10711
10843
  partial: true,
10712
10844
  pick: endpoint.inputPickFields,
10713
10845
  omit: endpoint.inputOmitFields
10714
10846
  });
10715
- endpoint.encode = this.type.generateCodec("encode", {
10847
+ endpoint.returnType = this.type;
10848
+ endpoint.encodeReturning = endpoint.returnType.generateCodec("encode", {
10716
10849
  partial: true,
10717
10850
  pick: endpoint.outputPickFields,
10718
10851
  omit: endpoint.outputOmitFields
10719
10852
  });
10720
- endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10721
- endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10722
- endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10723
10853
  }
10724
10854
  endpoint = this.operations.get("get");
10725
10855
  if (endpoint) {
10856
+ endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10857
+ endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10858
+ endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10726
10859
  endpoint.returnType = this.type;
10727
- endpoint.encode = this.type.generateCodec("encode", {
10860
+ endpoint.encodeReturning = endpoint.returnType.generateCodec("encode", {
10728
10861
  partial: true,
10729
10862
  pick: endpoint.outputPickFields,
10730
10863
  omit: endpoint.outputOmitFields
10731
10864
  });
10732
- endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10733
- endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10734
- endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10735
10865
  }
10736
10866
  endpoint = this.operations.get("update");
10737
10867
  if (endpoint) {
10738
- endpoint.returnType = this.type;
10739
- endpoint.decode = this.type.generateCodec("decode", {
10868
+ endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10869
+ endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10870
+ endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10871
+ endpoint.decodeInput = this.type.generateCodec("decode", {
10740
10872
  pick: endpoint.inputPickFields,
10741
10873
  omit: endpoint.inputOmitFields
10742
10874
  });
10743
- endpoint.encode = this.type.generateCodec("encode", {
10875
+ endpoint.returnType = this.type;
10876
+ endpoint.encodeReturning = endpoint.returnType.generateCodec("encode", {
10744
10877
  partial: true,
10745
10878
  pick: endpoint.outputPickFields,
10746
10879
  omit: endpoint.outputOmitFields
10747
10880
  });
10748
- endpoint.defineParameter("pick", { type: "string", isArray: true, isBuiltin: true });
10749
- endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10750
- endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10751
10881
  }
10752
10882
  }
10753
10883
  getOperation(name) {
@@ -10772,12 +10902,12 @@ function SingletonDecorator(type, options) {
10772
10902
  __name(SingletonDecorator, "SingletonDecorator");
10773
10903
  Object.assign(SingletonDecorator, ResourceDecorator);
10774
10904
  (function(SingletonDecorator2) {
10775
- function Action(options) {
10905
+ function Action2(options) {
10776
10906
  const list = [];
10777
10907
  return createActionDecorator(options, operationProperties2, list);
10778
10908
  }
10779
- __name(Action, "Action");
10780
- SingletonDecorator2.Action = Action;
10909
+ __name(Action2, "Action");
10910
+ SingletonDecorator2.Action = Action2;
10781
10911
  function Create(options) {
10782
10912
  return CollectionDecorator.Create(options);
10783
10913
  }
@@ -10847,12 +10977,12 @@ function StorageDecorator(options) {
10847
10977
  __name(StorageDecorator, "StorageDecorator");
10848
10978
  Object.assign(StorageDecorator, ResourceDecorator);
10849
10979
  (function(StorageDecorator2) {
10850
- function Action(options) {
10980
+ function Action2(options) {
10851
10981
  const list = [];
10852
10982
  return createActionDecorator(options, operationProperties3, list);
10853
10983
  }
10854
- __name(Action, "Action");
10855
- StorageDecorator2.Action = Action;
10984
+ __name(Action2, "Action");
10985
+ StorageDecorator2.Action = Action2;
10856
10986
  function Delete(options) {
10857
10987
  const list = [];
10858
10988
  return createOperationDecorator("delete", options, list);
@@ -11828,6 +11958,7 @@ var HttpStatusMessages = {
11828
11958
  // ../../build/common/esm/index.js
11829
11959
  import { uid } from "uid";
11830
11960
  export {
11961
+ Action,
11831
11962
  ApiDocument,
11832
11963
  ApiDocumentFactory,
11833
11964
  ApiField,
@@ -11851,11 +11982,14 @@ export {
11851
11982
  InternalServerError,
11852
11983
  IssueSeverity,
11853
11984
  MappedType2 as MappedType,
11985
+ MetadataMode,
11854
11986
  MethodNotAllowedError,
11855
11987
  NAMESPACE_PATTERN,
11856
11988
  NotAcceptableError,
11857
11989
  NotFoundError,
11858
11990
  OmitType,
11991
+ Operation,
11992
+ OperationResult,
11859
11993
  OpraException,
11860
11994
  opra_filter_ns_exports as OpraFilter,
11861
11995
  opra_schema_ns_exports as OpraSchema,