@api-client/core 0.18.57 → 0.18.59

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 (132) hide show
  1. package/build/src/decorators/observed.d.ts.map +1 -1
  2. package/build/src/decorators/observed.js +15 -1
  3. package/build/src/decorators/observed.js.map +1 -1
  4. package/build/src/modeling/ApiModel.d.ts +7 -5
  5. package/build/src/modeling/ApiModel.d.ts.map +1 -1
  6. package/build/src/modeling/ApiModel.js +35 -16
  7. package/build/src/modeling/ApiModel.js.map +1 -1
  8. package/build/src/modeling/ExposedEntity.d.ts +5 -2
  9. package/build/src/modeling/ExposedEntity.d.ts.map +1 -1
  10. package/build/src/modeling/ExposedEntity.js +11 -8
  11. package/build/src/modeling/ExposedEntity.js.map +1 -1
  12. package/build/src/modeling/actions/Action.d.ts +41 -0
  13. package/build/src/modeling/actions/Action.d.ts.map +1 -0
  14. package/build/src/modeling/actions/Action.js +64 -0
  15. package/build/src/modeling/actions/Action.js.map +1 -0
  16. package/build/src/modeling/actions/CreateAction.d.ts +20 -0
  17. package/build/src/modeling/actions/CreateAction.d.ts.map +1 -0
  18. package/build/src/modeling/actions/CreateAction.js +43 -0
  19. package/build/src/modeling/actions/CreateAction.js.map +1 -0
  20. package/build/src/modeling/actions/DeleteAction.d.ts +36 -0
  21. package/build/src/modeling/actions/DeleteAction.d.ts.map +1 -0
  22. package/build/src/modeling/actions/DeleteAction.js +63 -0
  23. package/build/src/modeling/actions/DeleteAction.js.map +1 -0
  24. package/build/src/modeling/actions/ListAction.d.ts +39 -0
  25. package/build/src/modeling/actions/ListAction.d.ts.map +1 -0
  26. package/build/src/modeling/actions/ListAction.js +76 -0
  27. package/build/src/modeling/actions/ListAction.js.map +1 -0
  28. package/build/src/modeling/actions/ReadAction.d.ts +20 -0
  29. package/build/src/modeling/actions/ReadAction.d.ts.map +1 -0
  30. package/build/src/modeling/actions/ReadAction.js +43 -0
  31. package/build/src/modeling/actions/ReadAction.js.map +1 -0
  32. package/build/src/modeling/actions/SearchAction.d.ts +26 -0
  33. package/build/src/modeling/actions/SearchAction.d.ts.map +1 -0
  34. package/build/src/modeling/actions/SearchAction.js +53 -0
  35. package/build/src/modeling/actions/SearchAction.js.map +1 -0
  36. package/build/src/modeling/actions/UpdateAction.d.ts +29 -0
  37. package/build/src/modeling/actions/UpdateAction.d.ts.map +1 -0
  38. package/build/src/modeling/actions/UpdateAction.js +53 -0
  39. package/build/src/modeling/actions/UpdateAction.js.map +1 -0
  40. package/build/src/modeling/actions/index.d.ts +24 -0
  41. package/build/src/modeling/actions/index.d.ts.map +1 -0
  42. package/build/src/modeling/actions/index.js +9 -0
  43. package/build/src/modeling/actions/index.js.map +1 -0
  44. package/build/src/modeling/index.d.ts +12 -0
  45. package/build/src/modeling/index.d.ts.map +1 -0
  46. package/build/src/modeling/index.js +12 -0
  47. package/build/src/modeling/index.js.map +1 -0
  48. package/build/src/modeling/rules/AccessRule.d.ts +17 -0
  49. package/build/src/modeling/rules/AccessRule.d.ts.map +1 -0
  50. package/build/src/modeling/rules/AccessRule.js +19 -0
  51. package/build/src/modeling/rules/AccessRule.js.map +1 -0
  52. package/build/src/modeling/rules/AllowAuthenticated.d.ts +19 -0
  53. package/build/src/modeling/rules/AllowAuthenticated.d.ts.map +1 -0
  54. package/build/src/modeling/rules/AllowAuthenticated.js +14 -0
  55. package/build/src/modeling/rules/AllowAuthenticated.js.map +1 -0
  56. package/build/src/modeling/rules/AllowPublic.d.ts +19 -0
  57. package/build/src/modeling/rules/AllowPublic.d.ts.map +1 -0
  58. package/build/src/modeling/rules/AllowPublic.js +14 -0
  59. package/build/src/modeling/rules/AllowPublic.js.map +1 -0
  60. package/build/src/modeling/rules/MatchEmailDomain.d.ts +25 -0
  61. package/build/src/modeling/rules/MatchEmailDomain.d.ts.map +1 -0
  62. package/build/src/modeling/rules/MatchEmailDomain.js +40 -0
  63. package/build/src/modeling/rules/MatchEmailDomain.js.map +1 -0
  64. package/build/src/modeling/rules/MatchResourceOwner.d.ts +29 -0
  65. package/build/src/modeling/rules/MatchResourceOwner.d.ts.map +1 -0
  66. package/build/src/modeling/rules/MatchResourceOwner.js +40 -0
  67. package/build/src/modeling/rules/MatchResourceOwner.js.map +1 -0
  68. package/build/src/modeling/rules/MatchUserProperty.d.ts +28 -0
  69. package/build/src/modeling/rules/MatchUserProperty.d.ts.map +1 -0
  70. package/build/src/modeling/rules/MatchUserProperty.js +49 -0
  71. package/build/src/modeling/rules/MatchUserProperty.js.map +1 -0
  72. package/build/src/modeling/rules/MatchUserRole.d.ts +29 -0
  73. package/build/src/modeling/rules/MatchUserRole.d.ts.map +1 -0
  74. package/build/src/modeling/rules/MatchUserRole.js +40 -0
  75. package/build/src/modeling/rules/MatchUserRole.js.map +1 -0
  76. package/build/src/modeling/rules/RateLimitRule.d.ts +61 -0
  77. package/build/src/modeling/rules/RateLimitRule.d.ts.map +1 -0
  78. package/build/src/modeling/rules/RateLimitRule.js +101 -0
  79. package/build/src/modeling/rules/RateLimitRule.js.map +1 -0
  80. package/build/src/modeling/rules/RateLimitingConfiguration.d.ts +18 -0
  81. package/build/src/modeling/rules/RateLimitingConfiguration.d.ts.map +1 -0
  82. package/build/src/modeling/rules/RateLimitingConfiguration.js +35 -0
  83. package/build/src/modeling/rules/RateLimitingConfiguration.js.map +1 -0
  84. package/build/src/modeling/rules/index.d.ts +14 -0
  85. package/build/src/modeling/rules/index.d.ts.map +1 -0
  86. package/build/src/modeling/rules/index.js +11 -0
  87. package/build/src/modeling/rules/index.js.map +1 -0
  88. package/build/src/modeling/types.d.ts +6 -257
  89. package/build/src/modeling/types.d.ts.map +1 -1
  90. package/build/src/modeling/types.js.map +1 -1
  91. package/build/tsconfig.tsbuildinfo +1 -1
  92. package/data/models/example-generator-api.json +6 -6
  93. package/package.json +1 -1
  94. package/src/decorators/observed.ts +15 -1
  95. package/src/modeling/ApiModel.ts +21 -19
  96. package/src/modeling/ExposedEntity.ts +13 -18
  97. package/src/modeling/actions/Action.ts +64 -0
  98. package/src/modeling/actions/CreateAction.ts +38 -0
  99. package/src/modeling/actions/DeleteAction.ts +59 -0
  100. package/src/modeling/actions/ListAction.ts +66 -0
  101. package/src/modeling/actions/ReadAction.ts +40 -0
  102. package/src/modeling/actions/SearchAction.ts +46 -0
  103. package/src/modeling/actions/UpdateAction.ts +49 -0
  104. package/src/modeling/rules/AccessRule.ts +29 -0
  105. package/src/modeling/rules/AllowAuthenticated.ts +24 -0
  106. package/src/modeling/rules/AllowPublic.ts +24 -0
  107. package/src/modeling/rules/MatchEmailDomain.ts +39 -0
  108. package/src/modeling/rules/MatchResourceOwner.ts +43 -0
  109. package/src/modeling/rules/MatchUserProperty.ts +44 -0
  110. package/src/modeling/rules/MatchUserRole.ts +43 -0
  111. package/src/modeling/rules/RateLimitRule.ts +104 -0
  112. package/src/modeling/rules/RateLimitingConfiguration.ts +32 -0
  113. package/src/modeling/types.ts +6 -276
  114. package/tests/unit/decorators/observed.spec.ts +42 -0
  115. package/tests/unit/modeling/actions/Action.spec.ts +109 -0
  116. package/tests/unit/modeling/actions/CreateAction.spec.ts +65 -0
  117. package/tests/unit/modeling/actions/DeleteAction.spec.ts +78 -0
  118. package/tests/unit/modeling/actions/ListAction.spec.ts +106 -0
  119. package/tests/unit/modeling/actions/ReadAction.spec.ts +77 -0
  120. package/tests/unit/modeling/actions/SearchAction.spec.ts +73 -0
  121. package/tests/unit/modeling/actions/UpdateAction.spec.ts +73 -0
  122. package/tests/unit/modeling/api_model.spec.ts +48 -3
  123. package/tests/unit/modeling/exposed_entity.spec.ts +73 -0
  124. package/tests/unit/modeling/rules/AccessRule.spec.ts +42 -0
  125. package/tests/unit/modeling/rules/AllowAuthenticated.spec.ts +28 -0
  126. package/tests/unit/modeling/rules/AllowPublic.spec.ts +28 -0
  127. package/tests/unit/modeling/rules/MatchEmailDomain.spec.ts +52 -0
  128. package/tests/unit/modeling/rules/MatchResourceOwner.spec.ts +37 -0
  129. package/tests/unit/modeling/rules/MatchUserProperty.spec.ts +58 -0
  130. package/tests/unit/modeling/rules/MatchUserRole.spec.ts +52 -0
  131. package/tests/unit/modeling/rules/RateLimitRule.spec.ts +70 -0
  132. package/tests/unit/modeling/rules/RateLimitingConfiguration.spec.ts +61 -0
@@ -1 +1 @@
1
- {"version":3,"file":"observed.d.ts","sourceRoot":"","sources":["../../../src/decorators/observed.ts"],"names":[],"mappings":"AAIA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE;QAAE,YAAY,IAAI,IAAI,CAAA;KAAE,CAAA;IACjC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAEhC,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,EAC1B,MAAM,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1C,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAErC,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,EAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAC1B,OAAO,EAAE,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,GACzC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAC/B;AAED,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC5G,KAAK,sBAAsB,CAAC,CAAC,EAAE,CAAC,IAAI,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAAA;AAE7F,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;;;;GAKG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AAC,GAAG,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC5G,KAAK,sBAAsB,CAAC,CAAC,EAAE,CAAC,IAAI,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAAA;AAE7F,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAiBzF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,QAAQ,CAAC,MAAM,GAAE,aAAkB,GAAG,iBAAiB,CAiHtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,KACpB,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,WAAW,GAAG,SAAS,EACjE,QAAQ,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,EACpC,SAAS,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,KACrC,GAAG,CAiEP"}
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  const reactiveSymbol = Symbol('reactive');
3
3
  const proxySymbol = Symbol('proxy');
4
+ const rawSymbol = Symbol('raw');
4
5
  /**
5
6
  * Reads the raw value of the object, that is, not proxied object.
6
7
  * @param source The source object that contains the object
@@ -8,6 +9,13 @@ const proxySymbol = Symbol('proxy');
8
9
  * @returns The not proxied object or undefined
9
10
  */
10
11
  export function toRaw(source, target) {
12
+ if (target && target[rawSymbol]) {
13
+ let raw = target[rawSymbol];
14
+ while (raw && raw[rawSymbol]) {
15
+ raw = raw[rawSymbol];
16
+ }
17
+ return raw;
18
+ }
11
19
  const proxies = Reflect.get(source, proxySymbol);
12
20
  if (!proxies) {
13
21
  return undefined;
@@ -65,12 +73,18 @@ export function observed(config = {}) {
65
73
  Reflect.set(this, proxySymbol, proxies);
66
74
  }
67
75
  if (proxies.has(obj)) {
68
- return obj;
76
+ return proxies.get(obj);
69
77
  }
70
78
  // eslint-disable-next-line @typescript-eslint/no-this-alias
71
79
  const targetObject = this;
72
80
  const proxy = new Proxy(obj, {
73
81
  get(target, prop) {
82
+ if (prop === proxySymbol) {
83
+ return Reflect.get(target, prop);
84
+ }
85
+ if (prop === rawSymbol) {
86
+ return target;
87
+ }
74
88
  const value = Reflect.get(target, prop);
75
89
  return createDeepProxy.bind(targetObject)(value, notifyChange);
76
90
  },
@@ -1 +1 @@
1
- {"version":3,"file":"observed.js","sourceRoot":"","sources":["../../../src/decorators/observed.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;AACzC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AA+BnC;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAA4B,MAAc,EAAE,MAAS;IACxE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAwB,CAAA;IACvE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7C,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,OAAO,GAAQ,CAAA;QACjB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAwB,EAAE;IACjD,OAAO,CACL,MAAoC,EACpC,OAAsC,EACjC,EAAE;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;QACxB,MAAM,EAAE,IA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ED,GAAG;oBACD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,CAAA;oBACnD,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC1B,CAAC;aACF,CAAA;QACH,CAAC;aAAM,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;YACxB,OAAO,UAAgC,KAAQ;gBAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAA4B,CAAiB,CAAA;gBACnE,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;oBACvB,OAAM;gBACR,CAAC;gBACD,CAAC;gBAAC,MAA6B,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;gBACjD,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;oBACxB,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;gBACjD,CAAC;gBACD,IAAI,KAAK,EAAE,CAAC;oBACV,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;oBAC7B,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;gBAC3C,CAAC;YACH,CAAC,CAAA;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,EAAE,CAAC,CAAA;IAC5D,CAAC,CAAA;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nconst reactiveSymbol = Symbol('reactive')\nconst proxySymbol = Symbol('proxy')\n\ninterface DomainInstance {\n domain?: { notifyChange(): void }\n notifyChange?: () => void\n}\n\nexport interface PropertyDecorator {\n // accessor decorator signature\n <C extends DomainInstance, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>\n // setter decorator signature\n <C extends DomainInstance, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void\n}\n\ntype StandardPropertyContext<C, V> = ClassAccessorDecoratorContext<C, V> | ClassSetterDecoratorContext<C, V>\ntype StandardPropertyTarget<C, V> = ClassAccessorDecoratorTarget<C, V> | ((value: V) => void)\n\nexport interface ObserveConfig {\n /**\n * To be used when observing an object and not a primitive.\n * It creates a proxy that observes changes in the object.\n */\n deep?: boolean\n}\n\n/**\n * Reads the raw value of the object, that is, not proxied object.\n * @param source The source object that contains the object\n * @param target The target object set on the source object\n * @returns The not proxied object or undefined\n */\nexport function toRaw<T extends object = object>(source: object, target: T): T | undefined {\n const proxies = Reflect.get(source, proxySymbol) as Map<object, object>\n if (!proxies) {\n return undefined\n }\n for (const [key, value] of proxies.entries()) {\n if (value === target) {\n return key as T\n }\n }\n}\n\n/**\n * Turns a class property or a setter into an observed property\n * that notifies the root domain when changed.\n *\n * A property has to be declared with the `accessor` type to be\n * observed.\n *\n * ```typescript\n * @observed() accessor name: string | undefined\n *\n * @observed()\n * set height(value: number) {\n * this.#height = value\n * }\n *\n * get height(): number {\n * return this.#height\n * }\n * ```\n *\n * The decorator can be used in the following ways:\n * - As a class property decorator\n * - As a class setter decorator\n *\n * The property class either has to have the `domain` property\n * or a `notifyChange` method. The decorator will call the\n * `notifyChange` method if it exists. Otherwise, it will\n * call the `notifyChange` method of the root domain (the `domain` property).\n */\nexport function observed(config: ObserveConfig = {}): PropertyDecorator {\n return <C extends DomainInstance, V>(\n target: StandardPropertyTarget<C, V>,\n context: StandardPropertyContext<C, V>\n ): any => {\n const { kind } = context\n const { deep } = config\n\n function createDeepProxy(this: DomainInstance, obj: unknown, notifyChange: () => void): any {\n if (typeof obj !== 'object' || obj === null) {\n return obj\n }\n // instead of using the target object to store the proxy info, we\n // reflect the proxy info to the object itself. This way we can\n // keep the stored values clean, which helps with testing (deep equal would include symbols)\n // Keys are original objects, values are proxies\n let proxies = Reflect.get(this, proxySymbol) as Map<object, object>\n if (!proxies) {\n proxies = new Map()\n Reflect.set(this, proxySymbol, proxies)\n }\n\n if (proxies.has(obj)) {\n return obj\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const targetObject = this\n\n const proxy = new Proxy(obj, {\n get(target, prop) {\n const value = Reflect.get(target, prop)\n return createDeepProxy.bind(targetObject)(value, notifyChange)\n },\n set(target, prop, value) {\n const oldValue = Reflect.get(target, prop)\n if (oldValue !== value) {\n Reflect.set(target, prop, value)\n notifyChange()\n }\n return true\n },\n deleteProperty(target, prop) {\n Reflect.deleteProperty(target, prop)\n notifyChange()\n return true\n },\n })\n proxies.set(obj, proxy)\n return proxy\n }\n\n if (kind === 'accessor') {\n return {\n set(this: DomainInstance, value: V): void {\n let map = Reflect.get(this, reactiveSymbol)\n if (!map) {\n map = {}\n Reflect.set(this, reactiveSymbol, map)\n }\n if (map[context.name] === value) {\n return\n }\n const notify = () => {\n if (this.domain) {\n this.domain.notifyChange()\n } else if (this.notifyChange) {\n this.notifyChange()\n }\n }\n if (deep) {\n value = createDeepProxy.bind(this)(value, notify)\n }\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete map[context.name]\n } else {\n map[context.name] = value\n }\n notify()\n },\n\n get(): V {\n const map = Reflect.get(this, reactiveSymbol) || {}\n return map[context.name]\n },\n }\n } else if (kind === 'setter') {\n const { name } = context\n return function (this: DomainInstance, value: V): void {\n const oldValue = this[name as keyof DomainInstance]\n if (value === oldValue) {\n return\n }\n const notify = () => {\n if (this.domain) {\n this.domain.notifyChange()\n } else if (this.notifyChange) {\n this.notifyChange()\n }\n }\n ;(target as (value: V) => void).call(this, value)\n notify()\n }\n }\n throw new Error(`Unsupported decorator location: ${kind}`)\n }\n}\n\n/**\n * A decorator that can be used to retarget the change event\n * of a property to the root domain.\n *\n * This decorator should not be used with the `observed` decorator.\n * It does the same thing. It will notify about a change to the\n * property itself.\n */\nexport function retargetChange() {\n return <C extends DomainInstance, V extends EventTarget | undefined>(\n target: StandardPropertyTarget<C, V>,\n context: StandardPropertyContext<C, V>\n ): any => {\n const { kind } = context\n function observer(this: DomainInstance) {\n if (this.domain) {\n this.domain.notifyChange()\n }\n }\n let binding: ((this: DomainInstance) => void) | undefined\n if (kind === 'accessor') {\n return {\n set(this: DomainInstance, value: V): void {\n let map = Reflect.get(this, reactiveSymbol)\n if (!map) {\n map = {}\n Reflect.set(this, reactiveSymbol, map)\n }\n if (map[context.name] === value) {\n return\n }\n const oldValue = map[context.name]\n if (oldValue === value) {\n return\n }\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete map[context.name]\n } else {\n map[context.name] = value\n }\n if (oldValue && binding) {\n oldValue.removeEventListener('change', binding)\n }\n if (value) {\n binding = observer.bind(this)\n value.addEventListener('change', binding)\n }\n if (this.domain) {\n this.domain.notifyChange()\n }\n },\n\n get(): V {\n const map = Reflect.get(this, reactiveSymbol) || {}\n return map[context.name]\n },\n }\n } else if (kind === 'setter') {\n const { name } = context\n return function (this: DomainInstance, value: V): void {\n const oldValue = this[name as keyof DomainInstance] as unknown as V\n if (value === oldValue) {\n return\n }\n ;(target as (value: V) => void).call(this, value)\n if (oldValue && binding) {\n oldValue.removeEventListener('change', binding)\n }\n if (value) {\n binding = observer.bind(this)\n value.addEventListener('change', binding)\n }\n }\n }\n throw new Error(`Unsupported decorator location: ${kind}`)\n }\n}\n"]}
1
+ {"version":3,"file":"observed.js","sourceRoot":"","sources":["../../../src/decorators/observed.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;AACzC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AACnC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AA+B/B;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAA4B,MAAc,EAAE,MAAS;IACxE,IAAI,MAAM,IAAK,MAAc,C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QAAQ,EAAE,CAAC;YAC7B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;YACxB,OAAO,UAAgC,KAAQ;gBAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAA4B,CAAiB,CAAA;gBACnE,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;oBACvB,OAAM;gBACR,CAAC;gBACD,CAAC;gBAAC,MAA6B,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;gBACjD,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;oBACxB,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;gBACjD,CAAC;gBACD,IAAI,KAAK,EAAE,CAAC;oBACV,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;oBAC7B,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;gBAC3C,CAAC;YACH,CAAC,CAAA;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,EAAE,CAAC,CAAA;IAC5D,CAAC,CAAA;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nconst reactiveSymbol = Symbol('reactive')\nconst proxySymbol = Symbol('proxy')\nconst rawSymbol = Symbol('raw')\n\ninterface DomainInstance {\n domain?: { notifyChange(): void }\n notifyChange?: () => void\n}\n\nexport interface PropertyDecorator {\n // accessor decorator signature\n <C extends DomainInstance, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>\n // setter decorator signature\n <C extends DomainInstance, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void\n}\n\ntype StandardPropertyContext<C, V> = ClassAccessorDecoratorContext<C, V> | ClassSetterDecoratorContext<C, V>\ntype StandardPropertyTarget<C, V> = ClassAccessorDecoratorTarget<C, V> | ((value: V) => void)\n\nexport interface ObserveConfig {\n /**\n * To be used when observing an object and not a primitive.\n * It creates a proxy that observes changes in the object.\n */\n deep?: boolean\n}\n\n/**\n * Reads the raw value of the object, that is, not proxied object.\n * @param source The source object that contains the object\n * @param target The target object set on the source object\n * @returns The not proxied object or undefined\n */\nexport function toRaw<T extends object = object>(source: object, target: T): T | undefined {\n if (target && (target as any)[rawSymbol]) {\n let raw = (target as any)[rawSymbol]\n while (raw && (raw as any)[rawSymbol]) {\n raw = (raw as any)[rawSymbol]\n }\n return raw as T\n }\n const proxies = Reflect.get(source, proxySymbol) as Map<object, object>\n if (!proxies) {\n return undefined\n }\n for (const [key, value] of proxies.entries()) {\n if (value === target) {\n return key as T\n }\n }\n}\n\n/**\n * Turns a class property or a setter into an observed property\n * that notifies the root domain when changed.\n *\n * A property has to be declared with the `accessor` type to be\n * observed.\n *\n * ```typescript\n * @observed() accessor name: string | undefined\n *\n * @observed()\n * set height(value: number) {\n * this.#height = value\n * }\n *\n * get height(): number {\n * return this.#height\n * }\n * ```\n *\n * The decorator can be used in the following ways:\n * - As a class property decorator\n * - As a class setter decorator\n *\n * The property class either has to have the `domain` property\n * or a `notifyChange` method. The decorator will call the\n * `notifyChange` method if it exists. Otherwise, it will\n * call the `notifyChange` method of the root domain (the `domain` property).\n */\nexport function observed(config: ObserveConfig = {}): PropertyDecorator {\n return <C extends DomainInstance, V>(\n target: StandardPropertyTarget<C, V>,\n context: StandardPropertyContext<C, V>\n ): any => {\n const { kind } = context\n const { deep } = config\n\n function createDeepProxy(this: DomainInstance, obj: unknown, notifyChange: () => void): any {\n if (typeof obj !== 'object' || obj === null) {\n return obj\n }\n // instead of using the target object to store the proxy info, we\n // reflect the proxy info to the object itself. This way we can\n // keep the stored values clean, which helps with testing (deep equal would include symbols)\n // Keys are original objects, values are proxies\n let proxies = Reflect.get(this, proxySymbol) as Map<object, object>\n if (!proxies) {\n proxies = new Map()\n Reflect.set(this, proxySymbol, proxies)\n }\n\n if (proxies.has(obj)) {\n return proxies.get(obj)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const targetObject = this\n\n const proxy = new Proxy(obj, {\n get(target, prop) {\n if (prop === proxySymbol) {\n return Reflect.get(target, prop)\n }\n if (prop === rawSymbol) {\n return target\n }\n const value = Reflect.get(target, prop)\n return createDeepProxy.bind(targetObject)(value, notifyChange)\n },\n set(target, prop, value) {\n const oldValue = Reflect.get(target, prop)\n if (oldValue !== value) {\n Reflect.set(target, prop, value)\n notifyChange()\n }\n return true\n },\n deleteProperty(target, prop) {\n Reflect.deleteProperty(target, prop)\n notifyChange()\n return true\n },\n })\n proxies.set(obj, proxy)\n return proxy\n }\n\n if (kind === 'accessor') {\n return {\n set(this: DomainInstance, value: V): void {\n let map = Reflect.get(this, reactiveSymbol)\n if (!map) {\n map = {}\n Reflect.set(this, reactiveSymbol, map)\n }\n if (map[context.name] === value) {\n return\n }\n const notify = () => {\n if (this.domain) {\n this.domain.notifyChange()\n } else if (this.notifyChange) {\n this.notifyChange()\n }\n }\n if (deep) {\n value = createDeepProxy.bind(this)(value, notify)\n }\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete map[context.name]\n } else {\n map[context.name] = value\n }\n notify()\n },\n\n get(): V {\n const map = Reflect.get(this, reactiveSymbol) || {}\n return map[context.name]\n },\n }\n } else if (kind === 'setter') {\n const { name } = context\n return function (this: DomainInstance, value: V): void {\n const oldValue = this[name as keyof DomainInstance]\n if (value === oldValue) {\n return\n }\n const notify = () => {\n if (this.domain) {\n this.domain.notifyChange()\n } else if (this.notifyChange) {\n this.notifyChange()\n }\n }\n ;(target as (value: V) => void).call(this, value)\n notify()\n }\n }\n throw new Error(`Unsupported decorator location: ${kind}`)\n }\n}\n\n/**\n * A decorator that can be used to retarget the change event\n * of a property to the root domain.\n *\n * This decorator should not be used with the `observed` decorator.\n * It does the same thing. It will notify about a change to the\n * property itself.\n */\nexport function retargetChange() {\n return <C extends DomainInstance, V extends EventTarget | undefined>(\n target: StandardPropertyTarget<C, V>,\n context: StandardPropertyContext<C, V>\n ): any => {\n const { kind } = context\n function observer(this: DomainInstance) {\n if (this.domain) {\n this.domain.notifyChange()\n }\n }\n let binding: ((this: DomainInstance) => void) | undefined\n if (kind === 'accessor') {\n return {\n set(this: DomainInstance, value: V): void {\n let map = Reflect.get(this, reactiveSymbol)\n if (!map) {\n map = {}\n Reflect.set(this, reactiveSymbol, map)\n }\n if (map[context.name] === value) {\n return\n }\n const oldValue = map[context.name]\n if (oldValue === value) {\n return\n }\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete map[context.name]\n } else {\n map[context.name] = value\n }\n if (oldValue && binding) {\n oldValue.removeEventListener('change', binding)\n }\n if (value) {\n binding = observer.bind(this)\n value.addEventListener('change', binding)\n }\n if (this.domain) {\n this.domain.notifyChange()\n }\n },\n\n get(): V {\n const map = Reflect.get(this, reactiveSymbol) || {}\n return map[context.name]\n },\n }\n } else if (kind === 'setter') {\n const { name } = context\n return function (this: DomainInstance, value: V): void {\n const oldValue = this[name as keyof DomainInstance] as unknown as V\n if (value === oldValue) {\n return\n }\n ;(target as (value: V) => void).call(this, value)\n if (oldValue && binding) {\n oldValue.removeEventListener('change', binding)\n }\n if (value) {\n binding = observer.bind(this)\n value.addEventListener('change', binding)\n }\n }\n }\n throw new Error(`Unsupported decorator location: ${kind}`)\n }\n}\n"]}
@@ -1,9 +1,11 @@
1
1
  import { ApiModelKind } from '../models/kinds.js';
2
2
  import { type IThing, Thing } from '../models/Thing.js';
3
- import type { AccessRule, AssociationTarget, AuthenticationConfiguration, AuthorizationConfiguration, ExposedEntitySchema, RateLimitingConfiguration, SessionConfiguration, ExposeOptions } from './types.js';
3
+ import type { AssociationTarget, AuthenticationConfiguration, AuthorizationConfiguration, ExposedEntitySchema, SessionConfiguration, ExposeOptions } from './types.js';
4
4
  import { DataDomain } from './DataDomain.js';
5
5
  import { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js';
6
6
  import { ExposedEntity } from './ExposedEntity.js';
7
+ import { AccessRule, AccessRuleSchema } from './rules/AccessRule.js';
8
+ import { RateLimitingConfiguration, RateLimitingConfigurationSchema } from './rules/RateLimitingConfiguration.js';
7
9
  /**
8
10
  * Contact information for the exposed API.
9
11
  */
@@ -83,12 +85,12 @@ export interface ApiModelSchema extends DependentModelSchema {
83
85
  * These rules apply to all exposed entities and actions. An API action
84
86
  * can declare its own access rules, which will override these.
85
87
  */
86
- accessRule?: AccessRule[];
88
+ accessRule?: AccessRuleSchema[];
87
89
  /**
88
90
  * Optional configuration for API-wide rate limiting and throttling.
89
91
  * Defines rules to protect the API from overuse.
90
92
  */
91
- rateLimiting?: RateLimitingConfiguration;
93
+ rateLimiting?: RateLimitingConfigurationSchema;
92
94
  /**
93
95
  * A URL to the Terms of Service for the API.
94
96
  */
@@ -152,12 +154,12 @@ export declare class ApiModel extends DependentModel {
152
154
  * These rules apply to all exposed entities and actions. An API action
153
155
  * can declare its own access rules, which will override these.
154
156
  */
155
- accessRule?: AccessRule[];
157
+ accessor accessRule: AccessRule[];
156
158
  /**
157
159
  * Optional configuration for API-wide rate limiting and throttling.
158
160
  * Defines rules to protect the API from overuse.
159
161
  */
160
- rateLimiting?: RateLimitingConfiguration;
162
+ accessor rateLimiting: RateLimitingConfiguration | undefined;
161
163
  /**
162
164
  * A URL to the Terms of Service for the API.
163
165
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ApiModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/ApiModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAqC,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EAEzB,oBAAoB,EAEpB,aAAa,EACd,MAA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,QAAQ,CAAC,YAAY,EAAE,yBAAyB,GAAG,SAAS,CAAA;IACxE;;OAEG;IACS,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;IACvD;;OAEG;IACuB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAA;IAClE;;OAEG;IACuB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAA;IAgBlE;;;;;;;OAOG;IACH,IAAI,MAAM,IAAI,UAAU,GAAG,SAAS,CAMnC;IAED,MAAM,CAAC,YAAY,CAAC,KAAK,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,cAAc;gBA0C5D,KAAK,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB;IA8DtE,MAAM,IAAI,cAAc;IAwCxB;;;;OAIG;IACH,YAAY;IAYZ;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa;IA0D/E;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IA0GhC;;;;;OAKG;IACH,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQtC,OAAO,CAAC,kBAAkB;IAwB1B;;;;OAIG;IACH,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,GAAG,SAAS;IAItE;;;;OAIG;IACH,oBAAoB,IAAI,IAAI;IAkB5B;;;;;;OAMG;IACH,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAS3C"}
@@ -8,11 +8,19 @@ import { observed, toRaw } from '../decorators/observed.js';
8
8
  import pluralize from '@jarrodek/pluralize';
9
9
  import { createDomainKey } from './helpers/keying.js';
10
10
  import { ExposedEntity } from './ExposedEntity.js';
11
+ import { AccessRule } from './rules/AccessRule.js';
12
+ import { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js';
11
13
  let ApiModel = (() => {
12
14
  let _classSuper = DependentModel;
13
15
  let _exposes_decorators;
14
16
  let _exposes_initializers = [];
15
17
  let _exposes_extraInitializers = [];
18
+ let _accessRule_decorators;
19
+ let _accessRule_initializers = [];
20
+ let _accessRule_extraInitializers = [];
21
+ let _rateLimiting_decorators;
22
+ let _rateLimiting_initializers = [];
23
+ let _rateLimiting_extraInitializers = [];
16
24
  let _termsOfService_decorators;
17
25
  let _termsOfService_initializers = [];
18
26
  let _termsOfService_extraInitializers = [];
@@ -26,10 +34,14 @@ let ApiModel = (() => {
26
34
  static {
27
35
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
28
36
  _exposes_decorators = [observed({ deep: true })];
37
+ _accessRule_decorators = [observed({ deep: true })];
38
+ _rateLimiting_decorators = [observed()];
29
39
  _termsOfService_decorators = [observed()];
30
40
  _contact_decorators = [observed({ deep: true })];
31
41
  _license_decorators = [observed({ deep: true })];
32
42
  __esDecorate(this, null, _exposes_decorators, { kind: "accessor", name: "exposes", static: false, private: false, access: { has: obj => "exposes" in obj, get: obj => obj.exposes, set: (obj, value) => { obj.exposes = value; } }, metadata: _metadata }, _exposes_initializers, _exposes_extraInitializers);
43
+ __esDecorate(this, null, _accessRule_decorators, { kind: "accessor", name: "accessRule", static: false, private: false, access: { has: obj => "accessRule" in obj, get: obj => obj.accessRule, set: (obj, value) => { obj.accessRule = value; } }, metadata: _metadata }, _accessRule_initializers, _accessRule_extraInitializers);
44
+ __esDecorate(this, null, _rateLimiting_decorators, { kind: "accessor", name: "rateLimiting", static: false, private: false, access: { has: obj => "rateLimiting" in obj, get: obj => obj.rateLimiting, set: (obj, value) => { obj.rateLimiting = value; } }, metadata: _metadata }, _rateLimiting_initializers, _rateLimiting_extraInitializers);
33
45
  __esDecorate(this, null, _termsOfService_decorators, { kind: "accessor", name: "termsOfService", static: false, private: false, access: { has: obj => "termsOfService" in obj, get: obj => obj.termsOfService, set: (obj, value) => { obj.termsOfService = value; } }, metadata: _metadata }, _termsOfService_initializers, _termsOfService_extraInitializers);
34
46
  __esDecorate(this, null, _contact_decorators, { kind: "accessor", name: "contact", static: false, private: false, access: { has: obj => "contact" in obj, get: obj => obj.contact, set: (obj, value) => { obj.contact = value; } }, metadata: _metadata }, _contact_initializers, _contact_extraInitializers);
35
47
  __esDecorate(this, null, _license_decorators, { kind: "accessor", name: "license", static: false, private: false, access: { has: obj => "license" in obj, get: obj => obj.license, set: (obj, value) => { obj.license = value; } }, metadata: _metadata }, _license_initializers, _license_extraInitializers);
@@ -77,6 +89,7 @@ let ApiModel = (() => {
77
89
  */
78
90
  get exposes() { return this.#exposes_accessor_storage; }
79
91
  set exposes(value) { this.#exposes_accessor_storage = value; }
92
+ #accessRule_accessor_storage = (__runInitializers(this, _exposes_extraInitializers), __runInitializers(this, _accessRule_initializers, void 0));
80
93
  /**
81
94
  * Optional array of access rules that define the access control policies
82
95
  * for the API. These rules are used to enforce security and permissions
@@ -85,13 +98,16 @@ let ApiModel = (() => {
85
98
  * These rules apply to all exposed entities and actions. An API action
86
99
  * can declare its own access rules, which will override these.
87
100
  */
88
- accessRule = __runInitializers(this, _exposes_extraInitializers);
101
+ get accessRule() { return this.#accessRule_accessor_storage; }
102
+ set accessRule(value) { this.#accessRule_accessor_storage = value; }
103
+ #rateLimiting_accessor_storage = (__runInitializers(this, _accessRule_extraInitializers), __runInitializers(this, _rateLimiting_initializers, void 0));
89
104
  /**
90
105
  * Optional configuration for API-wide rate limiting and throttling.
91
106
  * Defines rules to protect the API from overuse.
92
107
  */
93
- rateLimiting;
94
- #termsOfService_accessor_storage = __runInitializers(this, _termsOfService_initializers, void 0);
108
+ get rateLimiting() { return this.#rateLimiting_accessor_storage; }
109
+ set rateLimiting(value) { this.#rateLimiting_accessor_storage = value; }
110
+ #termsOfService_accessor_storage = (__runInitializers(this, _rateLimiting_extraInitializers), __runInitializers(this, _termsOfService_initializers, void 0));
95
111
  /**
96
112
  * A URL to the Terms of Service for the API.
97
113
  */
@@ -146,25 +162,25 @@ let ApiModel = (() => {
146
162
  exposes,
147
163
  };
148
164
  if (input.user) {
149
- result.user = { ...input.user };
165
+ result.user = structuredClone(input.user);
150
166
  }
151
167
  if (input.dependencyList) {
152
168
  result.dependencyList = structuredClone(input.dependencyList);
153
169
  }
154
170
  if (input.authentication) {
155
- result.authentication = input.authentication;
171
+ result.authentication = structuredClone(input.authentication);
156
172
  }
157
173
  if (input.authorization) {
158
- result.authorization = input.authorization;
174
+ result.authorization = structuredClone(input.authorization);
159
175
  }
160
176
  if (input.session) {
161
- result.session = input.session;
177
+ result.session = structuredClone(input.session);
162
178
  }
163
- if (input.accessRule) {
164
- result.accessRule = input.accessRule;
179
+ if (Array.isArray(input.accessRule)) {
180
+ result.accessRule = structuredClone(input.accessRule);
165
181
  }
166
182
  if (input.rateLimiting) {
167
- result.rateLimiting = input.rateLimiting;
183
+ result.rateLimiting = structuredClone(input.rateLimiting);
168
184
  }
169
185
  if (input.termsOfService) {
170
186
  result.termsOfService = input.termsOfService;
@@ -219,11 +235,14 @@ let ApiModel = (() => {
219
235
  else {
220
236
  this.exposes = [];
221
237
  }
222
- if (init.accessRule) {
223
- this.accessRule = structuredClone(init.accessRule);
238
+ if (Array.isArray(init.accessRule)) {
239
+ this.accessRule = init.accessRule.map((rule) => new AccessRule(rule));
240
+ }
241
+ else {
242
+ this.accessRule = [];
224
243
  }
225
244
  if (init.rateLimiting) {
226
- this.rateLimiting = structuredClone(init.rateLimiting);
245
+ this.rateLimiting = new RateLimitingConfiguration(init.rateLimiting);
227
246
  }
228
247
  if (init.termsOfService) {
229
248
  this.termsOfService = init.termsOfService;
@@ -261,11 +280,11 @@ let ApiModel = (() => {
261
280
  if (this.session) {
262
281
  result.session = structuredClone(this.session);
263
282
  }
264
- if (this.accessRule) {
265
- result.accessRule = structuredClone(this.accessRule);
283
+ if (Array.isArray(this.accessRule) && this.accessRule.length > 0) {
284
+ result.accessRule = this.accessRule.map((rule) => rule.toJSON());
266
285
  }
267
286
  if (this.rateLimiting) {
268
- result.rateLimiting = structuredClone(this.rateLimiting);
287
+ result.rateLimiting = this.rateLimiting.toJSON();
269
288
  }
270
289
  if (this.termsOfService) {
271
290
  result.termsOfService = this.termsOfService;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiModel.js","sourceRoot":"","sources":["../../../src/modeling/ApiModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAavD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAoD,MAAM,qBAAqB,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;IA4GrC,QAAQ;sBAAS,cAAc;;;;;;;;;;;;;iBAA/B,QAAS,SAAQ,WAAc;;;mCA4CzC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;0CAkBxB,QAAQ,EAAE;mCAIV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;mCAIxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YA1BC,0KAAS,OAAO,6BAAP,OAAO,yFAAiB;YAkB/C,+LAAS,cAAc,6BAAd,cAAc,uGAAoB;YAI7B,0KAAS,OAAO,6BAAP,OAAO,yFAAwB;YAIxC,0KAAS,OAAO,6BAAP,OAAO,yFAAwB;;;QArElE;;WAEG;QACH,IAAI,CAAqB;QACzB;;;WAGG;QACH,GAAG,CAAQ;QAE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AAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YACzC,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;YACzE,IAAI,CAAC,YAAY,EAAE,CAAA;QACrB,CAAC;;;SAjhBU,QAAQ","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { ApiModelKind, DataDomainKind, ExposedEntityKind } from '../models/kinds.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport type {\n AccessRule,\n AssociationTarget,\n AuthenticationConfiguration,\n AuthorizationConfiguration,\n ExposedEntitySchema,\n RateLimitingConfiguration,\n RolesBasedAccessControl,\n SessionConfiguration,\n UsernamePasswordConfiguration,\n ExposeOptions,\n} from './types.js'\nimport { DataDomain } from './DataDomain.js'\nimport { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'\nimport { observed, toRaw } from '../decorators/observed.js'\nimport pluralize from '@jarrodek/pluralize'\nimport { createDomainKey } from './helpers/keying.js'\nimport { ExposedEntity } from './ExposedEntity.js'\n\n/**\n * Contact information for the exposed API.\n */\nexport interface ApiContact {\n /**\n * The identifying name of the contact person/organization.\n */\n name?: string\n /**\n * The URL pointing to the contact information. MUST be in the format of a URL.\n */\n url?: string\n /**\n * The email address of the contact person/organization. MUST be in the format of an email address.\n */\n email?: string\n}\n\n/**\n * License information for the exposed API.\n */\nexport interface ApiLicense {\n /**\n * The license name used for the API. It is recommended to be an SPDX license identifier.\n */\n name: string\n /**\n * A URL to the license used for the API. MUST be in the format of a URL.\n */\n url?: string\n}\n\nexport interface ApiModelSchema extends DependentModelSchema {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the API model schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n /**\n * Contains the name, display name, description, and the version of the API model schema.\n */\n info: IThing\n\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity should be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n exposes: ExposedEntitySchema[]\n\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * A URL to the Terms of Service for the API.\n */\n termsOfService?: string\n /**\n * The contact information for the exposed API.\n */\n contact?: ApiContact\n /**\n * The license information for the API.\n */\n license?: ApiLicense\n}\n\nexport class ApiModel extends DependentModel {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the data domain schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * The description of the domain property.\n */\n info: Thing\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity must be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n @observed({ deep: true }) accessor exposes: ExposedEntity[]\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * A URL to the Terms of Service for the API.\n */\n @observed() accessor termsOfService: string | undefined\n /**\n * The contact information for the exposed API.\n */\n @observed({ deep: true }) accessor contact: ApiContact | undefined\n /**\n * The license information for the API.\n */\n @observed({ deep: true }) accessor license: ApiLicense | undefined\n\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n\n /**\n * A convenience getter that returns the DataDomain associated with this API model.\n * Since the API model can have only one DataDomain,\n * this getter returns the first dependency in the list.\n *\n * The parent interface `DependentModel` allows for multiple dependencies,\n * to unify the dependency management across different models.\n */\n get domain(): DataDomain | undefined {\n if (this.dependencyList.length === 0) {\n return undefined\n }\n const domain = this.dependencyList[0]\n return this.dependencies.get(domain.key)\n }\n\n static createSchema(input: Partial<ApiModelSchema> = {}): ApiModelSchema {\n const { key = nanoid(), exposes = [] } = input\n const info = Thing.fromJSON(input.info, { name: 'Unnamed API' }).toJSON()\n const result: ApiModelSchema = {\n kind: ApiModelKind,\n key,\n info,\n exposes,\n }\n if (input.user) {\n result.user = { ...input.user }\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.authentication) {\n result.authentication = input.authentication\n }\n if (input.authorization) {\n result.authorization = input.authorization\n }\n if (input.session) {\n result.session = input.session\n }\n if (input.accessRule) {\n result.accessRule = input.accessRule\n }\n if (input.rateLimiting) {\n result.rateLimiting = input.rateLimiting\n }\n if (input.termsOfService) {\n result.termsOfService = input.termsOfService\n }\n if (input.contact) {\n result.contact = structuredClone(input.contact)\n }\n if (input.license) {\n result.license = structuredClone(input.license)\n }\n return result\n }\n\n constructor(state?: Partial<ApiModelSchema>, domain?: DomainDependency) {\n const init = ApiModel.createSchema(state)\n const instances: DataDomain[] = []\n if (domain instanceof DataDomain) {\n instances.push(domain)\n } else if (typeof domain === 'object' && domain.kind === DataDomainKind) {\n instances.push(new DataDomain(domain))\n } else if (domain) {\n throw new Error(`Invalid domain provided. Expected a DataDomain instance or schema.`)\n }\n // Note that since we're using the `DependentModel` class, but the API Model can have only one dependency,\n // we keep the reference to the data domain under the `dependencyList` property.\n // It is all handled by the parent class `DependentModel`. This way we simplify the dependency management (loading)\n // process when the API model is loaded from the API.\n if (domain) {\n if (!domain.info.version) {\n throw new Error(`Domain ${domain.key} must have a version.`)\n }\n init.dependencyList = [{ key: domain.key, version: domain.info.version }]\n }\n super(init.dependencyList, instances)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.user = init.user\n if (init.authentication) {\n this.authentication = structuredClone(init.authentication)\n }\n if (init.authorization) {\n this.authorization = structuredClone(init.authorization)\n }\n if (init.session) {\n this.session = structuredClone(init.session)\n }\n if (Array.isArray(init.exposes)) {\n this.exposes = init.exposes.map((e) => new ExposedEntity(this, e))\n } else {\n this.exposes = []\n }\n if (init.accessRule) {\n this.accessRule = structuredClone(init.accessRule)\n }\n if (init.rateLimiting) {\n this.rateLimiting = structuredClone(init.rateLimiting)\n }\n if (init.termsOfService) {\n this.termsOfService = init.termsOfService\n }\n if (init.contact) {\n this.contact = init.contact\n }\n if (init.license) {\n this.license = init.license\n }\n this.#initializing = false\n this.info.addEventListener('change', () => {\n this.notifyChange()\n })\n }\n\n toJSON(): ApiModelSchema {\n const result: ApiModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n exposes: this.exposes.map((e) => e.toJSON()),\n }\n if (this.user) {\n result.user = { ...this.user }\n }\n if (this.dependencyList.length > 0) {\n result.dependencyList = structuredClone(this.dependencyList)\n }\n if (this.authentication) {\n result.authentication = structuredClone(this.authentication)\n }\n if (this.authorization) {\n result.authorization = structuredClone(this.authorization)\n }\n if (this.session) {\n result.session = structuredClone(this.session)\n }\n if (this.accessRule) {\n result.accessRule = structuredClone(this.accessRule)\n }\n if (this.rateLimiting) {\n result.rateLimiting = structuredClone(this.rateLimiting)\n }\n if (this.termsOfService) {\n result.termsOfService = this.termsOfService\n }\n if (this.contact) {\n result.contact = structuredClone(toRaw(this, this.contact))\n }\n if (this.license) {\n result.license = structuredClone(toRaw(this, this.license))\n }\n return result\n }\n\n /**\n * This function is used internally by all domain elements to notify that something has changed.\n * Since we want to notify listeners after the operation commits, we use microtask\n * to ensure that the event is dispatched after the current operation.\n */\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n })\n }\n\n /**\n * Exposes a new entity in the API model.\n * If the entity already exists, it returns the existing one.\n *\n * The logic regarding exposing an entity:\n * - If the entity is already exposed as a root entity, it returns the existing one.\n * - If the entity has an association, we expose that entity as a nested entity (by setting the parent property).\n * - If the associated entity is already exposed as a root entity, we do not follow the association.\n *\n * @param entity The entity key and domain to expose.\n * @returns The exposed entity.\n */\n exposeEntity(entity: AssociationTarget, options?: ExposeOptions): ExposedEntity {\n const domain = this.domain\n if (!domain) {\n throw new Error(`No domain attached to API model`)\n }\n // checks whether the entity is already exposed as a root exposure.\n const existing = this.exposes.find(\n (e) => e.isRoot && e.entity.key === entity.key && e.entity.domain === entity.domain\n )\n if (existing) {\n // quietly return the existing exposure\n // TBD: should we throw an error here?\n return existing\n }\n const domainEntity = domain.findEntity(entity.key, entity.domain)\n if (!domainEntity) {\n throw new Error(`Entity not found in domain: ${entity.key}`)\n }\n const name = domainEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n // Check for root path collision and resolve by appending a number\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.exposes.some((e) => e.isRoot && e.collectionPath === relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n const newEntity: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...entity },\n actions: [],\n isRoot: true,\n collectionPath: relativeCollectionPath,\n resourcePath: relativeResourcePath,\n hasCollection: true,\n }\n if (options) {\n newEntity.exposeOptions = { ...options }\n }\n const created = new ExposedEntity(this, newEntity)\n this.exposes.push(created)\n\n // Follow associations if requested\n if (options?.followAssociations) {\n if (options?.maxDepth === undefined || options.maxDepth > 0) {\n this.followEntityAssociations(newEntity, options)\n }\n }\n this.notifyChange()\n return created\n }\n\n /**\n * Follows associations for a newly exposed entity if configured to do so.\n * This creates nested exposures based on the entity's associations.\n *\n * @param parentExposure The root exposure to follow associations from\n * @param options The expose options containing follow configuration\n */\n private followEntityAssociations(parentExposure: ExposedEntitySchema, options: ExposeOptions): void {\n const domain = this.domain\n if (!domain) {\n return\n }\n const maxDepth = options.maxDepth ?? 6\n const follow = (currentEntity: AssociationTarget, parentKey: string, depth: number, currentPath: string[]) => {\n // Find the domain entity\n const domainEntity = domain.findEntity(currentEntity.key, currentEntity.domain)\n if (!domainEntity) return\n\n // Iterate through associations\n for (const association of domainEntity.listAssociations()) {\n for (const target of association.targets) {\n // Skip self-referencing associations\n if (target.key === currentEntity.key && target.domain === currentEntity.domain) {\n continue\n }\n\n const targetKeys = createDomainKey(target)\n // Circular dependency check: if this entity is already in our *current* traversal path\n if (currentPath.includes(targetKeys)) {\n continue\n }\n\n // Check if this entity is ALREADY exposed anywhere in the model\n const existingExposure = this.getExposedEntity(target)\n\n if (existingExposure) {\n // If it's already exposed and NOT root (i.e., it's currently a nested child of someone else),\n // promote it to ROOT to avoid duplicating it or deeply nesting it in multiple places.\n if (!existingExposure.isRoot) {\n // 1. Calculate new root paths (handling collisions)\n const targetDomEntity = domain.findEntity(target.key, target.domain)\n if (targetDomEntity) {\n const name = targetDomEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.exposes.some((e) => e.isRoot && e.collectionPath === relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n // 2. Update properties to make it root\n existingExposure.isRoot = true\n existingExposure.parent = undefined\n existingExposure.collectionPath = relativeCollectionPath\n existingExposure.resourcePath = relativeResourcePath\n existingExposure.hasCollection = true\n }\n }\n // Whether it was already root or we just promoted it, we stop following here.\n continue\n }\n\n // Find the target domain entity for path generation\n const targetDomainEntity = domain.findEntity(target.key, target.domain)\n if (!targetDomainEntity) continue\n\n const name = association.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n const isCollection = association.multiple !== false\n const relativeCollectionPath = isCollection ? `/${segment}` : undefined\n const relativeResourcePath = isCollection ? `/${segment}/{id}` : `/${segment}`\n // Create nested exposure\n const nestedExposure: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...target },\n actions: [],\n isRoot: false,\n collectionPath: relativeCollectionPath,\n resourcePath: relativeResourcePath,\n hasCollection: isCollection,\n parent: {\n key: parentKey,\n association: {\n key: association.key,\n domain: currentEntity.domain,\n },\n depth: depth + 1,\n },\n }\n\n this.exposes.push(new ExposedEntity(this, nestedExposure))\n if (depth + 1 >= maxDepth) {\n nestedExposure.truncated = true\n } else {\n // Recursively follow associations\n follow(target, nestedExposure.key, depth + 1, [...currentPath, targetKeys])\n }\n }\n }\n }\n\n // Start following from the root exposure\n // Initial path contains the root entity itself\n const rootKey = createDomainKey(parentExposure.entity)\n follow(parentExposure.entity, parentExposure.key, 0, [rootKey])\n }\n\n /**\n * Removes an exposed entity from the API model.\n * This also removes any nested exposed entities that are children of the removed entity.\n *\n * @param key The key of the exposed entity to remove.\n */\n removeExposedEntity(key: string): void {\n const index = this.exposes.findIndex((e) => e.key === key)\n if (index < 0) {\n throw new Error(`Exposed entity with key \"${key}\" not found.`)\n }\n this.removeWithChildren(key)\n }\n\n private removeWithChildren(key: string): void {\n const index = this.exposes.findIndex((e) => e.key === key)\n if (index < 0) {\n return\n }\n // Remove the parent itself\n this.exposes.splice(index, 1)\n // Remove all children recursively\n const removeChildren = (parentKey: string) => {\n // Find all exposures whose parent.key matches parentKey\n const children = this.exposes.filter((e) => e.parent?.key === parentKey)\n for (const child of children) {\n removeChildren(child.key)\n const childIndex = this.exposes.findIndex((e) => e.key === child.key)\n if (childIndex >= 0) {\n this.exposes.splice(childIndex, 1)\n }\n }\n }\n // Then also remove children\n removeChildren(key)\n this.notifyChange()\n }\n\n /**\n * Returns the exposed entity by its key.\n * @param entityKey The key of the entity to find.\n * @returns The exposed entity or undefined if not found.\n */\n getExposedEntity(entity: AssociationTarget): ExposedEntity | undefined {\n return this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain)\n }\n\n /**\n * Clears the API model for a new data domain change.\n * This method resets the dependencies, exposes, user,\n * authentication, authorization, and session properties.\n */\n cleanForDomainChange(): void {\n this.dependencies.clear()\n this.dependencyList = []\n this.exposes = []\n this.user = undefined\n if (this.session) {\n this.session.properties = []\n }\n if (this.authentication && this.authentication.strategy === 'UsernamePassword') {\n const typed = this.authentication as UsernamePasswordConfiguration\n typed.passwordKey = undefined\n }\n if (this.authorization && this.authorization.strategy == 'RBAC') {\n const typed = this.authorization as RolesBasedAccessControl\n typed.roleKey = ''\n }\n }\n\n /**\n * Attaches a DataDomain to this API model.\n * This method clears any existing dependencies and sets the new domain.\n *\n * @param domain The DataDomain to attach to this API model.\n * @throws Error if the domain does not have a version set in its info.\n */\n attachDataDomain(domain: DataDomain): void {\n if (!domain.info.version) {\n throw new Error(`Cannot attach DataDomain without a version. Please set the version in the domain info.`)\n }\n this.cleanForDomainChange()\n this.dependencies.set(domain.key, domain)\n this.dependencyList = [{ key: domain.key, version: domain.info.version }]\n this.notifyChange()\n }\n}\n"]}
1
+ {"version":3,"file":"ApiModel.js","sourceRoot":"","sources":["../../../src/modeling/ApiModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAWvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAoD,MAAM,qBAAqB,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAoB,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAmC,MAAM,sCAAsC,CAAA;IA4GpG,QAAQ;sBAAS,cAAc;;;;;;;;;;;;;;;;;;;iBAA/B,QAAS,SAAQ,WAAc;;;mCA4CzC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;sCASxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;wCAKxB,QAAQ,EAAE;0CAIV,QAAQ,EAAE;mCAIV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;mCAIxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE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AAc,GAAG,EAAE,CAAA;YACxB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;YACjB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAA;YACrB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAA;YAC9B,CAAC;YACD,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,KAAK,kBAAkB,EAAE,CAAC;gBAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,cAA+C,CAAA;gBAClE,KAAK,CAAC,WAAW,GAAG,SAAS,CAAA;YAC/B,CAAC;YACD,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,IAAI,MAAM,EAAE,CAAC;gBAChE,MAAM,KAAK,GAAG,IAAI,CAAC,aAAwC,CAAA;gBAC3D,KAAK,CAAC,OAAO,GAAG,EAAE,CAAA;YACpB,CAAC;QACH,CAAC;QAED;;;;;;WAMG;QACH,gBAAgB,CAAC,MAAkB;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAA;YAC3G,CAAC;YACD,IAAI,CAAC,oBAAoB,EAAE,CAAA;YAC3B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YACzC,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;YACzE,IAAI,CAAC,YAAY,EAAE,CAAA;QACrB,CAAC;;;SAnhBU,QAAQ","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { ApiModelKind, DataDomainKind, ExposedEntityKind } from '../models/kinds.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport type {\n AssociationTarget,\n AuthenticationConfiguration,\n AuthorizationConfiguration,\n ExposedEntitySchema,\n RolesBasedAccessControl,\n SessionConfiguration,\n UsernamePasswordConfiguration,\n ExposeOptions,\n} from './types.js'\nimport { DataDomain } from './DataDomain.js'\nimport { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'\nimport { observed, toRaw } from '../decorators/observed.js'\nimport pluralize from '@jarrodek/pluralize'\nimport { createDomainKey } from './helpers/keying.js'\nimport { ExposedEntity } from './ExposedEntity.js'\nimport { AccessRule, AccessRuleSchema } from './rules/AccessRule.js'\nimport { RateLimitingConfiguration, RateLimitingConfigurationSchema } from './rules/RateLimitingConfiguration.js'\n\n/**\n * Contact information for the exposed API.\n */\nexport interface ApiContact {\n /**\n * The identifying name of the contact person/organization.\n */\n name?: string\n /**\n * The URL pointing to the contact information. MUST be in the format of a URL.\n */\n url?: string\n /**\n * The email address of the contact person/organization. MUST be in the format of an email address.\n */\n email?: string\n}\n\n/**\n * License information for the exposed API.\n */\nexport interface ApiLicense {\n /**\n * The license name used for the API. It is recommended to be an SPDX license identifier.\n */\n name: string\n /**\n * A URL to the license used for the API. MUST be in the format of a URL.\n */\n url?: string\n}\n\nexport interface ApiModelSchema extends DependentModelSchema {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the API model schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n /**\n * Contains the name, display name, description, and the version of the API model schema.\n */\n info: IThing\n\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity should be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n exposes: ExposedEntitySchema[]\n\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n accessRule?: AccessRuleSchema[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfigurationSchema\n /**\n * A URL to the Terms of Service for the API.\n */\n termsOfService?: string\n /**\n * The contact information for the exposed API.\n */\n contact?: ApiContact\n /**\n * The license information for the API.\n */\n license?: ApiLicense\n}\n\nexport class ApiModel extends DependentModel {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the data domain schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * The description of the domain property.\n */\n info: Thing\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity must be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n @observed({ deep: true }) accessor exposes: ExposedEntity[]\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n @observed({ deep: true }) accessor accessRule: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\n /**\n * A URL to the Terms of Service for the API.\n */\n @observed() accessor termsOfService: string | undefined\n /**\n * The contact information for the exposed API.\n */\n @observed({ deep: true }) accessor contact: ApiContact | undefined\n /**\n * The license information for the API.\n */\n @observed({ deep: true }) accessor license: ApiLicense | undefined\n\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n\n /**\n * A convenience getter that returns the DataDomain associated with this API model.\n * Since the API model can have only one DataDomain,\n * this getter returns the first dependency in the list.\n *\n * The parent interface `DependentModel` allows for multiple dependencies,\n * to unify the dependency management across different models.\n */\n get domain(): DataDomain | undefined {\n if (this.dependencyList.length === 0) {\n return undefined\n }\n const domain = this.dependencyList[0]\n return this.dependencies.get(domain.key)\n }\n\n static createSchema(input: Partial<ApiModelSchema> = {}): ApiModelSchema {\n const { key = nanoid(), exposes = [] } = input\n const info = Thing.fromJSON(input.info, { name: 'Unnamed API' }).toJSON()\n const result: ApiModelSchema = {\n kind: ApiModelKind,\n key,\n info,\n exposes,\n }\n if (input.user) {\n result.user = structuredClone(input.user)\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.authentication) {\n result.authentication = structuredClone(input.authentication)\n }\n if (input.authorization) {\n result.authorization = structuredClone(input.authorization)\n }\n if (input.session) {\n result.session = structuredClone(input.session)\n }\n if (Array.isArray(input.accessRule)) {\n result.accessRule = structuredClone(input.accessRule)\n }\n if (input.rateLimiting) {\n result.rateLimiting = structuredClone(input.rateLimiting)\n }\n if (input.termsOfService) {\n result.termsOfService = input.termsOfService\n }\n if (input.contact) {\n result.contact = structuredClone(input.contact)\n }\n if (input.license) {\n result.license = structuredClone(input.license)\n }\n return result\n }\n\n constructor(state?: Partial<ApiModelSchema>, domain?: DomainDependency) {\n const init = ApiModel.createSchema(state)\n const instances: DataDomain[] = []\n if (domain instanceof DataDomain) {\n instances.push(domain)\n } else if (typeof domain === 'object' && domain.kind === DataDomainKind) {\n instances.push(new DataDomain(domain))\n } else if (domain) {\n throw new Error(`Invalid domain provided. Expected a DataDomain instance or schema.`)\n }\n // Note that since we're using the `DependentModel` class, but the API Model can have only one dependency,\n // we keep the reference to the data domain under the `dependencyList` property.\n // It is all handled by the parent class `DependentModel`. This way we simplify the dependency management (loading)\n // process when the API model is loaded from the API.\n if (domain) {\n if (!domain.info.version) {\n throw new Error(`Domain ${domain.key} must have a version.`)\n }\n init.dependencyList = [{ key: domain.key, version: domain.info.version }]\n }\n super(init.dependencyList, instances)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.user = init.user\n if (init.authentication) {\n this.authentication = structuredClone(init.authentication)\n }\n if (init.authorization) {\n this.authorization = structuredClone(init.authorization)\n }\n if (init.session) {\n this.session = structuredClone(init.session)\n }\n if (Array.isArray(init.exposes)) {\n this.exposes = init.exposes.map((e) => new ExposedEntity(this, e))\n } else {\n this.exposes = []\n }\n if (Array.isArray(init.accessRule)) {\n this.accessRule = init.accessRule.map((rule) => new AccessRule(rule))\n } else {\n this.accessRule = []\n }\n if (init.rateLimiting) {\n this.rateLimiting = new RateLimitingConfiguration(init.rateLimiting)\n }\n if (init.termsOfService) {\n this.termsOfService = init.termsOfService\n }\n if (init.contact) {\n this.contact = init.contact\n }\n if (init.license) {\n this.license = init.license\n }\n this.#initializing = false\n this.info.addEventListener('change', () => {\n this.notifyChange()\n })\n }\n\n toJSON(): ApiModelSchema {\n const result: ApiModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n exposes: this.exposes.map((e) => e.toJSON()),\n }\n if (this.user) {\n result.user = { ...this.user }\n }\n if (this.dependencyList.length > 0) {\n result.dependencyList = structuredClone(this.dependencyList)\n }\n if (this.authentication) {\n result.authentication = structuredClone(this.authentication)\n }\n if (this.authorization) {\n result.authorization = structuredClone(this.authorization)\n }\n if (this.session) {\n result.session = structuredClone(this.session)\n }\n if (Array.isArray(this.accessRule) && this.accessRule.length > 0) {\n result.accessRule = this.accessRule.map((rule) => rule.toJSON())\n }\n if (this.rateLimiting) {\n result.rateLimiting = this.rateLimiting.toJSON()\n }\n if (this.termsOfService) {\n result.termsOfService = this.termsOfService\n }\n if (this.contact) {\n result.contact = structuredClone(toRaw(this, this.contact))\n }\n if (this.license) {\n result.license = structuredClone(toRaw(this, this.license))\n }\n return result\n }\n\n /**\n * This function is used internally by all domain elements to notify that something has changed.\n * Since we want to notify listeners after the operation commits, we use microtask\n * to ensure that the event is dispatched after the current operation.\n */\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n })\n }\n\n /**\n * Exposes a new entity in the API model.\n * If the entity already exists, it returns the existing one.\n *\n * The logic regarding exposing an entity:\n * - If the entity is already exposed as a root entity, it returns the existing one.\n * - If the entity has an association, we expose that entity as a nested entity (by setting the parent property).\n * - If the associated entity is already exposed as a root entity, we do not follow the association.\n *\n * @param entity The entity key and domain to expose.\n * @returns The exposed entity.\n */\n exposeEntity(entity: AssociationTarget, options?: ExposeOptions): ExposedEntity {\n const domain = this.domain\n if (!domain) {\n throw new Error(`No domain attached to API model`)\n }\n // checks whether the entity is already exposed as a root exposure.\n const existing = this.exposes.find(\n (e) => e.isRoot && e.entity.key === entity.key && e.entity.domain === entity.domain\n )\n if (existing) {\n // quietly return the existing exposure\n // TBD: should we throw an error here?\n return existing\n }\n const domainEntity = domain.findEntity(entity.key, entity.domain)\n if (!domainEntity) {\n throw new Error(`Entity not found in domain: ${entity.key}`)\n }\n const name = domainEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n // Check for root path collision and resolve by appending a number\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.exposes.some((e) => e.isRoot && e.collectionPath === relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n const newEntity: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...entity },\n actions: [],\n isRoot: true,\n collectionPath: relativeCollectionPath,\n resourcePath: relativeResourcePath,\n hasCollection: true,\n }\n if (options) {\n newEntity.exposeOptions = { ...options }\n }\n const created = new ExposedEntity(this, newEntity)\n this.exposes.push(created)\n\n // Follow associations if requested\n if (options?.followAssociations) {\n if (options?.maxDepth === undefined || options.maxDepth > 0) {\n this.followEntityAssociations(newEntity, options)\n }\n }\n this.notifyChange()\n return created\n }\n\n /**\n * Follows associations for a newly exposed entity if configured to do so.\n * This creates nested exposures based on the entity's associations.\n *\n * @param parentExposure The root exposure to follow associations from\n * @param options The expose options containing follow configuration\n */\n private followEntityAssociations(parentExposure: ExposedEntitySchema, options: ExposeOptions): void {\n const domain = this.domain\n if (!domain) {\n return\n }\n const maxDepth = options.maxDepth ?? 6\n const follow = (currentEntity: AssociationTarget, parentKey: string, depth: number, currentPath: string[]) => {\n // Find the domain entity\n const domainEntity = domain.findEntity(currentEntity.key, currentEntity.domain)\n if (!domainEntity) return\n\n // Iterate through associations\n for (const association of domainEntity.listAssociations()) {\n for (const target of association.targets) {\n // Skip self-referencing associations\n if (target.key === currentEntity.key && target.domain === currentEntity.domain) {\n continue\n }\n\n const targetKeys = createDomainKey(target)\n // Circular dependency check: if this entity is already in our *current* traversal path\n if (currentPath.includes(targetKeys)) {\n continue\n }\n\n // Check if this entity is ALREADY exposed anywhere in the model\n const existingExposure = this.getExposedEntity(target)\n\n if (existingExposure) {\n // If it's already exposed and NOT root (i.e., it's currently a nested child of someone else),\n // promote it to ROOT to avoid duplicating it or deeply nesting it in multiple places.\n if (!existingExposure.isRoot) {\n // 1. Calculate new root paths (handling collisions)\n const targetDomEntity = domain.findEntity(target.key, target.domain)\n if (targetDomEntity) {\n const name = targetDomEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.exposes.some((e) => e.isRoot && e.collectionPath === relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n // 2. Update properties to make it root\n existingExposure.isRoot = true\n existingExposure.parent = undefined\n existingExposure.collectionPath = relativeCollectionPath\n existingExposure.resourcePath = relativeResourcePath\n existingExposure.hasCollection = true\n }\n }\n // Whether it was already root or we just promoted it, we stop following here.\n continue\n }\n\n // Find the target domain entity for path generation\n const targetDomainEntity = domain.findEntity(target.key, target.domain)\n if (!targetDomainEntity) continue\n\n const name = association.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n const isCollection = association.multiple !== false\n const relativeCollectionPath = isCollection ? `/${segment}` : undefined\n const relativeResourcePath = isCollection ? `/${segment}/{id}` : `/${segment}`\n // Create nested exposure\n const nestedExposure: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...target },\n actions: [],\n isRoot: false,\n collectionPath: relativeCollectionPath,\n resourcePath: relativeResourcePath,\n hasCollection: isCollection,\n parent: {\n key: parentKey,\n association: {\n key: association.key,\n domain: currentEntity.domain,\n },\n depth: depth + 1,\n },\n }\n\n this.exposes.push(new ExposedEntity(this, nestedExposure))\n if (depth + 1 >= maxDepth) {\n nestedExposure.truncated = true\n } else {\n // Recursively follow associations\n follow(target, nestedExposure.key, depth + 1, [...currentPath, targetKeys])\n }\n }\n }\n }\n\n // Start following from the root exposure\n // Initial path contains the root entity itself\n const rootKey = createDomainKey(parentExposure.entity)\n follow(parentExposure.entity, parentExposure.key, 0, [rootKey])\n }\n\n /**\n * Removes an exposed entity from the API model.\n * This also removes any nested exposed entities that are children of the removed entity.\n *\n * @param key The key of the exposed entity to remove.\n */\n removeExposedEntity(key: string): void {\n const index = this.exposes.findIndex((e) => e.key === key)\n if (index < 0) {\n throw new Error(`Exposed entity with key \"${key}\" not found.`)\n }\n this.removeWithChildren(key)\n }\n\n private removeWithChildren(key: string): void {\n const index = this.exposes.findIndex((e) => e.key === key)\n if (index < 0) {\n return\n }\n // Remove the parent itself\n this.exposes.splice(index, 1)\n // Remove all children recursively\n const removeChildren = (parentKey: string) => {\n // Find all exposures whose parent.key matches parentKey\n const children = this.exposes.filter((e) => e.parent?.key === parentKey)\n for (const child of children) {\n removeChildren(child.key)\n const childIndex = this.exposes.findIndex((e) => e.key === child.key)\n if (childIndex >= 0) {\n this.exposes.splice(childIndex, 1)\n }\n }\n }\n // Then also remove children\n removeChildren(key)\n this.notifyChange()\n }\n\n /**\n * Returns the exposed entity by its key.\n * @param entityKey The key of the entity to find.\n * @returns The exposed entity or undefined if not found.\n */\n getExposedEntity(entity: AssociationTarget): ExposedEntity | undefined {\n return this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain)\n }\n\n /**\n * Clears the API model for a new data domain change.\n * This method resets the dependencies, exposes, user,\n * authentication, authorization, and session properties.\n */\n cleanForDomainChange(): void {\n this.dependencies.clear()\n this.dependencyList = []\n this.exposes = []\n this.user = undefined\n if (this.session) {\n this.session.properties = []\n }\n if (this.authentication && this.authentication.strategy === 'UsernamePassword') {\n const typed = this.authentication as UsernamePasswordConfiguration\n typed.passwordKey = undefined\n }\n if (this.authorization && this.authorization.strategy == 'RBAC') {\n const typed = this.authorization as RolesBasedAccessControl\n typed.roleKey = ''\n }\n }\n\n /**\n * Attaches a DataDomain to this API model.\n * This method clears any existing dependencies and sets the new domain.\n *\n * @param domain The DataDomain to attach to this API model.\n * @throws Error if the domain does not have a version set in its info.\n */\n attachDataDomain(domain: DataDomain): void {\n if (!domain.info.version) {\n throw new Error(`Cannot attach DataDomain without a version. Please set the version in the domain info.`)\n }\n this.cleanForDomainChange()\n this.dependencies.set(domain.key, domain)\n this.dependencyList = [{ key: domain.key, version: domain.info.version }]\n this.notifyChange()\n }\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import { ExposedEntityKind } from '../models/kinds.js';
2
+ import { Action } from './actions/Action.js';
2
3
  import type { ApiModel } from './ApiModel.js';
3
- import type { AccessRule, ApiAction, AssociationTarget, ExposeOptions, ExposeParentRef, RateLimitingConfiguration, ExposedEntitySchema } from './types.js';
4
+ import { AccessRule } from './rules/AccessRule.js';
5
+ import { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js';
6
+ import type { AssociationTarget, ExposeOptions, ExposeParentRef, ExposedEntitySchema } from './types.js';
4
7
  /**
5
8
  * A class that specializes in representing an exposed Data Entity within an API Model.
6
9
  *
@@ -71,7 +74,7 @@ export declare class ExposedEntity extends EventTarget {
71
74
  /**
72
75
  * The list of enabled API actions for this exposure (List/Read/Create/etc.)
73
76
  */
74
- accessor actions: ApiAction[];
77
+ accessor actions: Action[];
75
78
  /**
76
79
  * Optional array of access rules that define the access control policies for this exposure.
77
80
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ExposedEntity.d.ts","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;GAaG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAC5C;;OAEG;IACH,IAAI,EAAE,OAAO,iBAAiB,CAAA;IAE9B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;OAEG;IACS,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAE9C;;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AE,QAAQ,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAoBjE,YAAY;IAYZ,MAAM,IAAI,mBAAmB;IAiC7B;;;;;;;;OAQG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAqC9B;;;;;;;;OAQG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM;IAgD5B;;;;;OAKG;IACH,uBAAuB,IAAI,MAAM;IAcjC;;;;;;OAMG;IACH,yBAAyB,IAAI,MAAM,GAAG,SAAS;CAchD"}
@@ -2,7 +2,10 @@ import { __esDecorate, __runInitializers } from "tslib";
2
2
  import { observed } from '../decorators/observed.js';
3
3
  import { ExposedEntityKind } from '../models/kinds.js';
4
4
  import { nanoid } from '../nanoid.js';
5
+ import { Action } from './actions/Action.js';
5
6
  import { ensureLeadingSlash, joinPaths } from './helpers/endpointHelpers.js';
7
+ import { AccessRule } from './rules/AccessRule.js';
8
+ import { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js';
6
9
  /**
7
10
  * A class that specializes in representing an exposed Data Entity within an API Model.
8
11
  *
@@ -173,7 +176,7 @@ let ExposedEntity = (() => {
173
176
  if (exposeOptions !== undefined) {
174
177
  result.exposeOptions = { ...exposeOptions };
175
178
  }
176
- if (accessRule !== undefined) {
179
+ if (Array.isArray(accessRule)) {
177
180
  result.accessRule = accessRule.map((ar) => ({ ...ar }));
178
181
  }
179
182
  if (rateLimiting !== undefined) {
@@ -197,9 +200,9 @@ let ExposedEntity = (() => {
197
200
  this.isRoot = init.isRoot;
198
201
  this.parent = init.parent;
199
202
  this.exposeOptions = init.exposeOptions;
200
- this.actions = init.actions;
201
- this.accessRule = init.accessRule;
202
- this.rateLimiting = init.rateLimiting;
203
+ this.actions = init.actions ? init.actions.map((a) => new Action(a)) : [];
204
+ this.accessRule = init.accessRule ? init.accessRule.map((ar) => new AccessRule(ar)) : [];
205
+ this.rateLimiting = init.rateLimiting ? new RateLimitingConfiguration(init.rateLimiting) : undefined;
203
206
  this.truncated = init.truncated;
204
207
  this.#initializing = false;
205
208
  }
@@ -220,7 +223,7 @@ let ExposedEntity = (() => {
220
223
  key: this.key,
221
224
  entity: { ...this.entity },
222
225
  resourcePath: this.resourcePath,
223
- actions: this.actions.map((a) => ({ ...a })),
226
+ actions: this.actions.map((a) => a.toJSON()),
224
227
  hasCollection: this.hasCollection,
225
228
  };
226
229
  if (this.collectionPath !== undefined) {
@@ -235,11 +238,11 @@ let ExposedEntity = (() => {
235
238
  if (this.exposeOptions !== undefined) {
236
239
  result.exposeOptions = { ...this.exposeOptions };
237
240
  }
238
- if (this.accessRule !== undefined) {
239
- result.accessRule = this.accessRule.map((ar) => ({ ...ar }));
241
+ if (Array.isArray(this.accessRule) && this.accessRule.length > 0) {
242
+ result.accessRule = this.accessRule.map((ar) => ar.toJSON());
240
243
  }
241
244
  if (this.rateLimiting !== undefined) {
242
- result.rateLimiting = { ...this.rateLimiting };
245
+ result.rateLimiting = this.rateLimiting.toJSON();
243
246
  }
244
247
  if (this.truncated !== undefined) {
245
248
  result.truncated = this.truncated;