declastruct 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/dist/.test/assets/providers/demo.provider.d.ts +32 -0
  2. package/dist/.test/assets/providers/demo.provider.js +101 -0
  3. package/dist/.test/assets/providers/demo.provider.js.map +1 -0
  4. package/dist/contract/cli/apply.d.ts +9 -0
  5. package/dist/contract/cli/apply.integration.test.js +148 -0
  6. package/dist/contract/cli/apply.integration.test.js.map +1 -0
  7. package/dist/contract/cli/apply.js +90 -0
  8. package/dist/contract/cli/apply.js.map +1 -0
  9. package/dist/contract/cli/invoke.d.ts +8 -0
  10. package/dist/contract/cli/invoke.js +58 -0
  11. package/dist/contract/cli/invoke.js.map +1 -0
  12. package/dist/contract/cli/plan.d.ts +10 -0
  13. package/dist/contract/cli/plan.integration.test.js +107 -0
  14. package/dist/contract/cli/plan.integration.test.js.map +1 -0
  15. package/dist/contract/cli/plan.js +94 -0
  16. package/dist/contract/cli/plan.js.map +1 -0
  17. package/dist/contract/sdk/index.d.ts +15 -3
  18. package/dist/contract/sdk/index.js +31 -17
  19. package/dist/contract/sdk/index.js.map +1 -1
  20. package/dist/domain.objects/ContextDeclastruct.d.ts +15 -0
  21. package/dist/{domain/DeclastructContext.js → domain.objects/ContextDeclastruct.js} +1 -1
  22. package/dist/domain.objects/ContextDeclastruct.js.map +1 -0
  23. package/dist/domain.objects/ContextDeclastruct.test.js +41 -0
  24. package/dist/domain.objects/ContextDeclastruct.test.js.map +1 -0
  25. package/dist/domain.objects/DeclastructChange.d.ts +73 -0
  26. package/dist/domain.objects/DeclastructChange.js +35 -0
  27. package/dist/domain.objects/DeclastructChange.js.map +1 -0
  28. package/dist/domain.objects/DeclastructChange.test.js +59 -0
  29. package/dist/domain.objects/DeclastructChange.test.js.map +1 -0
  30. package/dist/domain.objects/DeclastructDao.d.ts +39 -0
  31. package/dist/domain.objects/DeclastructDao.js +8 -0
  32. package/dist/domain.objects/DeclastructDao.js.map +1 -0
  33. package/dist/domain.objects/DeclastructDao.test.js +42 -0
  34. package/dist/domain.objects/DeclastructDao.test.js.map +1 -0
  35. package/dist/domain.objects/DeclastructPlan.d.ts +35 -0
  36. package/dist/domain.objects/DeclastructPlan.js +11 -0
  37. package/dist/domain.objects/DeclastructPlan.js.map +1 -0
  38. package/dist/domain.objects/DeclastructPlan.test.js +31 -0
  39. package/dist/domain.objects/DeclastructPlan.test.js.map +1 -0
  40. package/dist/domain.objects/DeclastructProvider.d.ts +30 -0
  41. package/dist/domain.objects/DeclastructProvider.js +8 -0
  42. package/dist/domain.objects/DeclastructProvider.js.map +1 -0
  43. package/dist/domain.objects/DeclastructProvider.test.js +35 -0
  44. package/dist/domain.objects/DeclastructProvider.test.js.map +1 -0
  45. package/dist/domain.objects/IsoTimestamp.d.ts +6 -0
  46. package/dist/{domain/DeclaredResource.js → domain.objects/IsoTimestamp.js} +1 -1
  47. package/dist/domain.objects/IsoTimestamp.js.map +1 -0
  48. package/dist/domain.objects/IsoTimestamp.test.js +10 -0
  49. package/dist/domain.objects/IsoTimestamp.test.js.map +1 -0
  50. package/dist/domain.operations/apply/applyChange.d.ts +14 -0
  51. package/dist/domain.operations/apply/applyChange.js +64 -0
  52. package/dist/domain.operations/apply/applyChange.js.map +1 -0
  53. package/dist/domain.operations/apply/applyChange.test.d.ts +1 -0
  54. package/dist/domain.operations/apply/applyChange.test.js +247 -0
  55. package/dist/domain.operations/apply/applyChange.test.js.map +1 -0
  56. package/dist/domain.operations/apply/applyChanges.d.ts +18 -0
  57. package/dist/domain.operations/apply/applyChanges.integration.test.d.ts +1 -0
  58. package/dist/domain.operations/apply/applyChanges.integration.test.js +291 -0
  59. package/dist/domain.operations/apply/applyChanges.integration.test.js.map +1 -0
  60. package/dist/domain.operations/apply/applyChanges.js +53 -0
  61. package/dist/domain.operations/apply/applyChanges.js.map +1 -0
  62. package/dist/domain.operations/plan/computeChange.d.ts +11 -0
  63. package/dist/domain.operations/plan/computeChange.js +78 -0
  64. package/dist/domain.operations/plan/computeChange.js.map +1 -0
  65. package/dist/domain.operations/plan/computeChange.test.d.ts +1 -0
  66. package/dist/domain.operations/plan/computeChange.test.js +67 -0
  67. package/dist/domain.operations/plan/computeChange.test.js.map +1 -0
  68. package/dist/domain.operations/plan/extractResourcesFromPlan.d.ts +8 -0
  69. package/dist/domain.operations/plan/extractResourcesFromPlan.js +17 -0
  70. package/dist/domain.operations/plan/extractResourcesFromPlan.js.map +1 -0
  71. package/dist/domain.operations/plan/getDaoByResource.d.ts +12 -0
  72. package/dist/domain.operations/plan/getDaoByResource.js +41 -0
  73. package/dist/domain.operations/plan/getDaoByResource.js.map +1 -0
  74. package/dist/domain.operations/plan/getDaoByResource.test.d.ts +1 -0
  75. package/dist/domain.operations/plan/getDaoByResource.test.js +99 -0
  76. package/dist/domain.operations/plan/getDaoByResource.test.js.map +1 -0
  77. package/dist/domain.operations/plan/hashChanges.d.ts +7 -0
  78. package/dist/domain.operations/plan/hashChanges.js +18 -0
  79. package/dist/domain.operations/plan/hashChanges.js.map +1 -0
  80. package/dist/domain.operations/plan/planChanges.d.ts +15 -0
  81. package/dist/domain.operations/plan/planChanges.integration.test.d.ts +1 -0
  82. package/dist/domain.operations/plan/planChanges.integration.test.js +197 -0
  83. package/dist/domain.operations/plan/planChanges.integration.test.js.map +1 -0
  84. package/dist/domain.operations/plan/planChanges.js +50 -0
  85. package/dist/domain.operations/plan/planChanges.js.map +1 -0
  86. package/dist/domain.operations/plan/validate.d.ts +10 -0
  87. package/dist/domain.operations/plan/validate.js +21 -0
  88. package/dist/domain.operations/plan/validate.js.map +1 -0
  89. package/dist/infra/asIsoTimestamp.d.ts +6 -0
  90. package/dist/infra/asIsoTimestamp.js +12 -0
  91. package/dist/infra/asIsoTimestamp.js.map +1 -0
  92. package/package.json +8 -15
  93. package/readme.md +225 -29
  94. package/dist/__test_assets__/getExampleContext.d.ts +0 -33
  95. package/dist/__test_assets__/getExampleContext.js +0 -87
  96. package/dist/__test_assets__/getExampleContext.js.map +0 -1
  97. package/dist/contract/commands/command.apply.d.ts +0 -6
  98. package/dist/contract/commands/command.apply.js +0 -20
  99. package/dist/contract/commands/command.apply.js.map +0 -1
  100. package/dist/contract/commands/command.plan.d.ts +0 -6
  101. package/dist/contract/commands/command.plan.js +0 -20
  102. package/dist/contract/commands/command.plan.js.map +0 -1
  103. package/dist/contract/commands/utils/resolveCommandInputs.d.ts +0 -17
  104. package/dist/contract/commands/utils/resolveCommandInputs.js +0 -23
  105. package/dist/contract/commands/utils/resolveCommandInputs.js.map +0 -1
  106. package/dist/contract/sdk/refs.d.ts +0 -2
  107. package/dist/contract/sdk/refs.js +0 -19
  108. package/dist/contract/sdk/refs.js.map +0 -1
  109. package/dist/contract/sdk/sync/apply.d.ts +0 -22
  110. package/dist/contract/sdk/sync/apply.js +0 -29
  111. package/dist/contract/sdk/sync/apply.js.map +0 -1
  112. package/dist/contract/sdk/sync/plan.d.ts +0 -22
  113. package/dist/contract/sdk/sync/plan.js +0 -30
  114. package/dist/contract/sdk/sync/plan.js.map +0 -1
  115. package/dist/domain/DeclaredResource.d.ts +0 -2
  116. package/dist/domain/DeclaredResource.js.map +0 -1
  117. package/dist/domain/DeclaredResourceReference.d.ts +0 -66
  118. package/dist/domain/DeclaredResourceReference.js +0 -42
  119. package/dist/domain/DeclaredResourceReference.js.map +0 -1
  120. package/dist/domain/DeclastructChangeProposal.d.ts +0 -61
  121. package/dist/domain/DeclastructChangeProposal.js +0 -37
  122. package/dist/domain/DeclastructChangeProposal.js.map +0 -1
  123. package/dist/domain/DeclastructContext.d.ts +0 -24
  124. package/dist/domain/DeclastructContext.js.map +0 -1
  125. package/dist/domain/DeclastructProvider.d.ts +0 -58
  126. package/dist/domain/DeclastructProvider.js +0 -3
  127. package/dist/domain/DeclastructProvider.js.map +0 -1
  128. package/dist/domain/DeclastructProviderContext.d.ts +0 -30
  129. package/dist/domain/DeclastructProviderContext.js +0 -3
  130. package/dist/domain/DeclastructProviderContext.js.map +0 -1
  131. package/dist/domain/DeclastructProviderResourceRemoteStateInterface.d.ts +0 -156
  132. package/dist/domain/DeclastructProviderResourceRemoteStateInterface.js +0 -3
  133. package/dist/domain/DeclastructProviderResourceRemoteStateInterface.js.map +0 -1
  134. package/dist/logic/actions/execute/canUpdateResource.d.ts +0 -5
  135. package/dist/logic/actions/execute/canUpdateResource.js +0 -12
  136. package/dist/logic/actions/execute/canUpdateResource.js.map +0 -1
  137. package/dist/logic/actions/execute/executeProposal.d.ts +0 -5
  138. package/dist/logic/actions/execute/executeProposal.js +0 -52
  139. package/dist/logic/actions/execute/executeProposal.js.map +0 -1
  140. package/dist/logic/actions/propose/getColoredActionToken.d.ts +0 -4
  141. package/dist/logic/actions/propose/getColoredActionToken.js +0 -22
  142. package/dist/logic/actions/propose/getColoredActionToken.js.map +0 -1
  143. package/dist/logic/actions/propose/getColoredProposalTitle.d.ts +0 -4
  144. package/dist/logic/actions/propose/getColoredProposalTitle.js +0 -34
  145. package/dist/logic/actions/propose/getColoredProposalTitle.js.map +0 -1
  146. package/dist/logic/actions/propose/proposeChangeForResource.d.ts +0 -7
  147. package/dist/logic/actions/propose/proposeChangeForResource.js +0 -65
  148. package/dist/logic/actions/propose/proposeChangeForResource.js.map +0 -1
  149. package/dist/logic/actions/propose/proposeChangeForResource.test.js +0 -48
  150. package/dist/logic/actions/propose/proposeChangeForResource.test.js.map +0 -1
  151. package/dist/logic/commands/command.apply.d.ts +0 -8
  152. package/dist/logic/commands/command.apply.js +0 -77
  153. package/dist/logic/commands/command.apply.js.map +0 -1
  154. package/dist/logic/commands/command.plan.d.ts +0 -13
  155. package/dist/logic/commands/command.plan.js +0 -155
  156. package/dist/logic/commands/command.plan.js.map +0 -1
  157. package/dist/logic/commands/execute.d.ts +0 -15
  158. package/dist/logic/commands/execute.js +0 -63
  159. package/dist/logic/commands/execute.js.map +0 -1
  160. package/dist/logic/tools/compare/castReferenceToGrokableString.d.ts +0 -16
  161. package/dist/logic/tools/compare/castReferenceToGrokableString.js +0 -66
  162. package/dist/logic/tools/compare/castReferenceToGrokableString.js.map +0 -1
  163. package/dist/logic/tools/compare/castReferenceToGrokableString.test.js +0 -111
  164. package/dist/logic/tools/compare/castReferenceToGrokableString.test.js.map +0 -1
  165. package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.d.ts +0 -11
  166. package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.js +0 -61
  167. package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.js.map +0 -1
  168. package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js +0 -31
  169. package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js.map +0 -1
  170. package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.d.ts +0 -21
  171. package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.js +0 -53
  172. package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.js.map +0 -1
  173. package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.test.js +0 -31
  174. package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.test.js.map +0 -1
  175. package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.d.ts +0 -10
  176. package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.js +0 -41
  177. package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.js.map +0 -1
  178. package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.test.js +0 -174
  179. package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.test.js.map +0 -1
  180. package/dist/logic/tools/context/createDeclastructContext.d.ts +0 -10
  181. package/dist/logic/tools/context/createDeclastructContext.js +0 -12
  182. package/dist/logic/tools/context/createDeclastructContext.js.map +0 -1
  183. package/dist/logic/tools/context/destroyDeclastructContext.d.ts +0 -4
  184. package/dist/logic/tools/context/destroyDeclastructContext.js +0 -10
  185. package/dist/logic/tools/context/destroyDeclastructContext.js.map +0 -1
  186. package/dist/logic/tools/provider/castProviderContextToGlobalContext.d.ts +0 -4
  187. package/dist/logic/tools/provider/castProviderContextToGlobalContext.js +0 -10
  188. package/dist/logic/tools/provider/castProviderContextToGlobalContext.js.map +0 -1
  189. package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.d.ts +0 -13
  190. package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.js +0 -29
  191. package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.js.map +0 -1
  192. package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.d.ts +0 -13
  193. package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js +0 -24
  194. package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js.map +0 -1
  195. package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.d.ts +0 -10
  196. package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js +0 -21
  197. package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js.map +0 -1
  198. package/dist/logic/tools/reference/buildPrimaryKeyTo.d.ts +0 -5
  199. package/dist/logic/tools/reference/buildPrimaryKeyTo.js +0 -40
  200. package/dist/logic/tools/reference/buildPrimaryKeyTo.js.map +0 -1
  201. package/dist/logic/tools/reference/buildReferenceTo.d.ts +0 -28
  202. package/dist/logic/tools/reference/buildReferenceTo.js +0 -92
  203. package/dist/logic/tools/reference/buildReferenceTo.js.map +0 -1
  204. package/dist/logic/tools/reference/buildReferenceTo.test.js +0 -119
  205. package/dist/logic/tools/reference/buildReferenceTo.test.js.map +0 -1
  206. package/dist/logic/tools/reference/buildUniqueKeyTo.d.ts +0 -5
  207. package/dist/logic/tools/reference/buildUniqueKeyTo.js +0 -40
  208. package/dist/logic/tools/reference/buildUniqueKeyTo.js.map +0 -1
  209. package/dist/logic/tools/reference/defineReferenceClassOf.d.ts +0 -5
  210. package/dist/logic/tools/reference/defineReferenceClassOf.js +0 -25
  211. package/dist/logic/tools/reference/defineReferenceClassOf.js.map +0 -1
  212. package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.d.ts +0 -13
  213. package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.js +0 -36
  214. package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.js.map +0 -1
  215. package/dist/logic/tools/reference/getByReference.d.ts +0 -15
  216. package/dist/logic/tools/reference/getByReference.js +0 -55
  217. package/dist/logic/tools/reference/getByReference.js.map +0 -1
  218. package/dist/logic/tools/reference/getByReference.test.js +0 -92
  219. package/dist/logic/tools/reference/getByReference.test.js.map +0 -1
  220. package/dist/logic/tools/reference/getByReferencedPrimaryKey.d.ts +0 -6
  221. package/dist/logic/tools/reference/getByReferencedPrimaryKey.js +0 -17
  222. package/dist/logic/tools/reference/getByReferencedPrimaryKey.js.map +0 -1
  223. package/dist/logic/tools/reference/getByReferencedUniqueKey.d.ts +0 -7
  224. package/dist/logic/tools/reference/getByReferencedUniqueKey.js +0 -42
  225. package/dist/logic/tools/reference/getByReferencedUniqueKey.js.map +0 -1
  226. package/dist/logic/tools/reference/getPrimaryKeyByReference.d.ts +0 -15
  227. package/dist/logic/tools/reference/getPrimaryKeyByReference.js +0 -36
  228. package/dist/logic/tools/reference/getPrimaryKeyByReference.js.map +0 -1
  229. package/dist/logic/tools/reference/getReferenceTo.d.ts +0 -18
  230. package/dist/logic/tools/reference/getReferenceTo.js +0 -55
  231. package/dist/logic/tools/reference/getReferenceTo.js.map +0 -1
  232. package/dist/logic/tools/reference/getReferenceTo.test.js +0 -95
  233. package/dist/logic/tools/reference/getReferenceTo.test.js.map +0 -1
  234. package/dist/logic/tools/reference/getUniqueKeyByReference.d.ts +0 -15
  235. package/dist/logic/tools/reference/getUniqueKeyByReference.js +0 -36
  236. package/dist/logic/tools/reference/getUniqueKeyByReference.js.map +0 -1
  237. package/dist/logic/tools/reference/isPrimaryKeyReference.d.ts +0 -6
  238. package/dist/logic/tools/reference/isPrimaryKeyReference.js +0 -7
  239. package/dist/logic/tools/reference/isPrimaryKeyReference.js.map +0 -1
  240. package/dist/logic/tools/reference/isUniqueKeyReference.d.ts +0 -6
  241. package/dist/logic/tools/reference/isUniqueKeyReference.js +0 -7
  242. package/dist/logic/tools/reference/isUniqueKeyReference.js.map +0 -1
  243. /package/dist/{logic/actions/propose/proposeChangeForResource.test.d.ts → contract/cli/apply.integration.test.d.ts} +0 -0
  244. /package/dist/{logic/tools/compare/castReferenceToGrokableString.test.d.ts → contract/cli/plan.integration.test.d.ts} +0 -0
  245. /package/dist/{logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.d.ts → domain.objects/ContextDeclastruct.test.d.ts} +0 -0
  246. /package/dist/{logic/tools/compare/resolveReferenceToCommonComparableForm.test.d.ts → domain.objects/DeclastructChange.test.d.ts} +0 -0
  247. /package/dist/{logic/tools/compare/resolveReferencesToCommonComparableForm.test.d.ts → domain.objects/DeclastructDao.test.d.ts} +0 -0
  248. /package/dist/{logic/tools/reference/buildReferenceTo.test.d.ts → domain.objects/DeclastructPlan.test.d.ts} +0 -0
  249. /package/dist/{logic/tools/reference/getByReference.test.d.ts → domain.objects/DeclastructProvider.test.d.ts} +0 -0
  250. /package/dist/{logic/tools/reference/getReferenceTo.test.d.ts → domain.objects/IsoTimestamp.test.d.ts} +0 -0
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDeclastructContext = void 0;
4
- const createDeclastructContext = ({ providers, resources, log, }) => {
5
- return {
6
- providers,
7
- resources,
8
- log,
9
- };
10
- };
11
- exports.createDeclastructContext = createDeclastructContext;
12
- //# sourceMappingURL=createDeclastructContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createDeclastructContext.js","sourceRoot":"","sources":["../../../../src/logic/tools/context/createDeclastructContext.ts"],"names":[],"mappings":";;;AAOO,MAAM,wBAAwB,GAAG,CAAC,EACvC,SAAS,EACT,SAAS,EACT,GAAG,GAKJ,EAA0C,EAAE;IAC3C,OAAO;QACL,SAAS;QACT,SAAS;QACT,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,wBAAwB,4BAcnC"}
@@ -1,4 +0,0 @@
1
- import { DeclastructContext } from '../../../domain/DeclastructContext';
2
- export declare const destroyDeclastructContext: ({ context, }: {
3
- context: DeclastructContext;
4
- }) => Promise<void>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.destroyDeclastructContext = void 0;
4
- const destroyDeclastructContext = async ({ context, }) => {
5
- // run the "afterall" of each provider
6
- await Promise.all(context.providers.map((provider) => provider.hooks.afterAll ? provider.hooks.afterAll() : undefined));
7
- // todo: mark the context as "destroyed" so it wont be used anymore?
8
- };
9
- exports.destroyDeclastructContext = destroyDeclastructContext;
10
- //# sourceMappingURL=destroyDeclastructContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destroyDeclastructContext.js","sourceRoot":"","sources":["../../../../src/logic/tools/context/destroyDeclastructContext.ts"],"names":[],"mappings":";;;AAEO,MAAM,yBAAyB,GAAG,KAAK,EAAE,EAC9C,OAAO,GAGR,EAAE,EAAE;IACH,sCAAsC;IACtC,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACjC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAChE,CACF,CAAC;IAEF,oEAAoE;AACtE,CAAC,CAAC;AAbW,QAAA,yBAAyB,6BAapC"}
@@ -1,4 +0,0 @@
1
- import { VisualogicContext } from 'visualogic';
2
- import { DeclastructContext } from '../../../domain/DeclastructContext';
3
- import { DeclastructProviderContext } from '../../../domain/DeclastructProviderContext';
4
- export declare const castProviderContextToGlobalContext: (from: DeclastructProviderContext<any>) => DeclastructContext & VisualogicContext;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.castProviderContextToGlobalContext = void 0;
4
- const castProviderContextToGlobalContext = (from) => ({
5
- providers: [from.provider],
6
- resources: from.resources ?? [],
7
- log: from.log,
8
- });
9
- exports.castProviderContextToGlobalContext = castProviderContextToGlobalContext;
10
- //# sourceMappingURL=castProviderContextToGlobalContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"castProviderContextToGlobalContext.js","sourceRoot":"","sources":["../../../../src/logic/tools/provider/castProviderContextToGlobalContext.ts"],"names":[],"mappings":";;;AAKO,MAAM,kCAAkC,GAAG,CAChD,IAAqC,EACG,EAAE,CAAC,CAAC;IAC5C,SAAS,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;IAC/B,GAAG,EAAE,IAAI,CAAC,GAAG;CACd,CAAC,CAAC;AANU,QAAA,kCAAkC,sCAM5C"}
@@ -1,13 +0,0 @@
1
- import { DeclastructContext } from '../../../domain/DeclastructContext';
2
- import { DeclastructProviderAgentOptions } from '../../../domain/DeclastructProvider';
3
- import { DeclastructProviderContext } from '../../../domain/DeclastructProviderContext';
4
- /**
5
- * defines the provider specific context for resources of a specific class, from the full context
6
- *
7
- * relevance
8
- * - we dont share the full declastruct context to providers, due to security, becuase credentials are defined in the full context
9
- * - instead, we only share the the data the user explicitly defined for a particular provider (agentOptions, resources)
10
- */
11
- export declare const getProviderContextFromGlobalContextForResourceClass: <AO extends DeclastructProviderAgentOptions>({ resourceClassName }: {
12
- resourceClassName: string;
13
- }, context: DeclastructContext) => DeclastructProviderContext<AO>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProviderContextFromGlobalContextForResourceClass = void 0;
4
- const error_fns_1 = require("@ehmpathy/error-fns");
5
- /**
6
- * defines the provider specific context for resources of a specific class, from the full context
7
- *
8
- * relevance
9
- * - we dont share the full declastruct context to providers, due to security, becuase credentials are defined in the full context
10
- * - instead, we only share the the data the user explicitly defined for a particular provider (agentOptions, resources)
11
- */
12
- const getProviderContextFromGlobalContextForResourceClass = ({ resourceClassName }, context) => {
13
- // lookup the provider for this resource
14
- const provider = context.providers.find((thisProvider) => resourceClassName in thisProvider.interfaces);
15
- if (!provider)
16
- throw new error_fns_1.UnexpectedCodePathError('could not find provider for resource', {
17
- resourceClassName,
18
- });
19
- // find all of the resources managed by this provider
20
- const resources = context.resources.filter((resource) => resource.constructor.name in provider.interfaces);
21
- // return the context
22
- return {
23
- provider: provider,
24
- resources,
25
- log: context.log,
26
- };
27
- };
28
- exports.getProviderContextFromGlobalContextForResourceClass = getProviderContextFromGlobalContextForResourceClass;
29
- //# sourceMappingURL=getProviderContextFromGlobalContextForResourceClass.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProviderContextFromGlobalContextForResourceClass.js","sourceRoot":"","sources":["../../../../src/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAU9D;;;;;;GAMG;AACI,MAAM,mDAAmD,GAAG,CAGjE,EAAE,iBAAiB,EAAiC,EACpD,OAA2B,EACK,EAAE;IAClC,wCAAwC;IACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CACrC,CAAC,YAAY,EAAE,EAAE,CAAC,iBAAiB,IAAI,YAAY,CAAC,UAAU,CAC/D,CAAC;IACF,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,mCAAuB,CAAC,sCAAsC,EAAE;YACxE,iBAAiB;SAClB,CAAC,CAAC;IAEL,qDAAqD;IACrD,MAAM,SAAS,GAAuB,OAAO,CAAC,SAAS,CAAC,MAAM,CAC5D,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,QAAQ,CAAC,UAAU,CAC/D,CAAC;IAEF,qBAAqB;IACrB,OAAO;QACL,QAAQ,EAAE,QAAmC;QAC7C,SAAS;QACT,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC;AACJ,CAAC,CAAC;AA1BW,QAAA,mDAAmD,uDA0B9D"}
@@ -1,13 +0,0 @@
1
- import { DomainEntity } from 'domain-objects';
2
- import { DeclastructContext } from '../../../domain/DeclastructContext';
3
- import { DeclastructProviderContext } from '../../../domain/DeclastructProviderContext';
4
- import { DeclastructProviderResourceRemoteStateInterface } from '../../../domain/DeclastructProviderResourceRemoteStateInterface';
5
- /**
6
- * returns everything required to execute operations against the remote-state-interface for a resource
7
- */
8
- export declare const getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource: <R extends DomainEntity<any>>({ resource }: {
9
- resource: R;
10
- }, context: DeclastructContext) => {
11
- remoteStateInterface: DeclastructProviderResourceRemoteStateInterface<R, any, any, any>;
12
- providerContext: DeclastructProviderContext<any>;
13
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource = void 0;
4
- const error_fns_1 = require("@ehmpathy/error-fns");
5
- const domain_objects_1 = require("domain-objects");
6
- const getProviderContextFromGlobalContextForResourceClass_1 = require("./getProviderContextFromGlobalContextForResourceClass");
7
- const getProviderResourceRemoteStateInterfaceFromContextForResourceClass_1 = require("./getProviderResourceRemoteStateInterfaceFromContextForResourceClass");
8
- /**
9
- * returns everything required to execute operations against the remote-state-interface for a resource
10
- */
11
- const getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource = ({ resource }, context) => {
12
- // sanity check that resource is a domain entity (otherwise, it cant be created)
13
- if (!(resource instanceof domain_objects_1.DomainEntity))
14
- throw new error_fns_1.UnexpectedCodePathError('can not createResource on a non DomainEntity object', { resource });
15
- const resourceClassName = resource.constructor.name;
16
- // lookup the interface
17
- const remoteStateInterface = (0, getProviderResourceRemoteStateInterfaceFromContextForResourceClass_1.getProviderResourceRemoteStateInterfaceFromContextForResourceClass)({ resourceClassName }, context);
18
- // lookup the provider context
19
- const providerContext = (0, getProviderContextFromGlobalContextForResourceClass_1.getProviderContextFromGlobalContextForResourceClass)({ resourceClassName }, context);
20
- // return the dependencies
21
- return { remoteStateInterface, providerContext };
22
- };
23
- exports.getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource = getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource;
24
- //# sourceMappingURL=getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js","sourceRoot":"","sources":["../../../../src/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAC9D,mDAA8C;AAK9C,+HAA4H;AAC5H,6JAA0J;AAE1J;;GAEG;AACI,MAAM,uEAAuE,GAClF,CACE,EAAE,QAAQ,EAAmB,EAC7B,OAA2B,EAS3B,EAAE;IACF,gFAAgF;IAChF,IAAI,CAAC,CAAC,QAAQ,YAAY,6BAAY,CAAC;QACrC,MAAM,IAAI,mCAAuB,CAC/B,qDAAqD,EACrD,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,MAAM,iBAAiB,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;IAEpD,uBAAuB;IACvB,MAAM,oBAAoB,GACxB,IAAA,uIAAkE,EAKhE,EAAE,iBAAiB,EAAE,EAAE,OAAO,CAAC,CAAC;IAEpC,8BAA8B;IAC9B,MAAM,eAAe,GAAG,IAAA,yGAAmD,EACzE,EAAE,iBAAiB,EAAE,EACrB,OAAO,CACR,CAAC;IAEF,0BAA0B;IAC1B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,CAAC;AACnD,CAAC,CAAC;AAtCS,QAAA,uEAAuE,2EAsChF"}
@@ -1,10 +0,0 @@
1
- import { DeclaredResource } from '../../../domain/DeclaredResource';
2
- import { DeclastructContext } from '../../../domain/DeclastructContext';
3
- import { DeclastructProviderAgentOptions } from '../../../domain/DeclastructProvider';
4
- import { DeclastructProviderResourceRemoteStateInterface } from '../../../domain/DeclastructProviderResourceRemoteStateInterface';
5
- /**
6
- * grabs the appropriate interface for managing resources of this class, by resource class name
7
- */
8
- export declare const getProviderResourceRemoteStateInterfaceFromContextForResourceClass: <R extends DeclaredResource, AO extends DeclastructProviderAgentOptions, P extends keyof R, U extends keyof R>({ resourceClassName }: {
9
- resourceClassName: string;
10
- }, context: DeclastructContext) => DeclastructProviderResourceRemoteStateInterface<R, AO, P, U>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProviderResourceRemoteStateInterfaceFromContextForResourceClass = void 0;
4
- const error_fns_1 = require("@ehmpathy/error-fns");
5
- /**
6
- * grabs the appropriate interface for managing resources of this class, by resource class name
7
- */
8
- const getProviderResourceRemoteStateInterfaceFromContextForResourceClass = ({ resourceClassName }, context) => {
9
- // lookup the provider for this resource
10
- const provider = context.providers.find((thisProvider) => resourceClassName in thisProvider.interfaces);
11
- if (!provider)
12
- throw new error_fns_1.UnexpectedCodePathError('could not find provider for resource', {
13
- resourceClassName,
14
- });
15
- // grab the interface
16
- const resourceInterface = provider.interfaces[resourceClassName];
17
- // return it
18
- return resourceInterface;
19
- };
20
- exports.getProviderResourceRemoteStateInterfaceFromContextForResourceClass = getProviderResourceRemoteStateInterfaceFromContextForResourceClass;
21
- //# sourceMappingURL=getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js","sourceRoot":"","sources":["../../../../src/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAO9D;;GAEG;AACI,MAAM,kEAAkE,GAC7E,CAME,EAAE,iBAAiB,EAAiC,EACpD,OAA2B,EACmC,EAAE;IAChE,wCAAwC;IACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CACrC,CAAC,YAAY,EAAE,EAAE,CAAC,iBAAiB,IAAI,YAAY,CAAC,UAAU,CAC/D,CAAC;IACF,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,mCAAuB,CAC/B,sCAAsC,EACtC;YACE,iBAAiB;SAClB,CACF,CAAC;IAEJ,qBAAqB;IACrB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAC3C,iBAAiB,CACqD,CAAC;IAEzE,YAAY;IACZ,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA7BS,QAAA,kEAAkE,sEA6B3E"}
@@ -1,5 +0,0 @@
1
- import { DomainObject } from 'domain-objects';
2
- /**
3
- * build the primary key of a resource
4
- */
5
- export declare const buildPrimaryKeyTo: <T extends DomainObject<any>, C extends new (props: T) => T, P extends keyof T, K extends Partial<T>>(to: C, using: K) => Required<Pick<T, P>>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildPrimaryKeyTo = void 0;
4
- const buildReferenceTo_1 = require("./buildReferenceTo");
5
- const defineReferenceKeyConstituentsOf_1 = require("./defineReferenceKeyConstituentsOf");
6
- /**
7
- * build the primary key of a resource
8
- */
9
- const buildPrimaryKeyTo = (
10
- /**
11
- * the class this is a reference to
12
- */
13
- to,
14
- /**
15
- * the data to build the reference with
16
- */
17
- using) => {
18
- const referenceOf = to;
19
- const referenceInput = using;
20
- // get the primary key defs for the class
21
- const { primary } = (0, defineReferenceKeyConstituentsOf_1.defineReferenceKeyConstituentsOf)({
22
- class: referenceOf,
23
- });
24
- // assert that the resource has a primary key defined on it
25
- const hasPrimaryKey = primary.every((key) => key in referenceInput);
26
- if (!hasPrimaryKey)
27
- throw new buildReferenceTo_1.CanNotBuildReferenceError({
28
- referenceOf,
29
- referenceInput,
30
- reason: 'the primary key is not present in the reference input',
31
- });
32
- // extract the primary key value
33
- const primaryKey = primary.reduce((summary, thisKeyKey) => {
34
- const thisKeyValue = referenceInput[thisKeyKey];
35
- return { ...summary, [thisKeyKey]: thisKeyValue };
36
- }, {});
37
- return primaryKey;
38
- };
39
- exports.buildPrimaryKeyTo = buildPrimaryKeyTo;
40
- //# sourceMappingURL=buildPrimaryKeyTo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildPrimaryKeyTo.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/buildPrimaryKeyTo.ts"],"names":[],"mappings":";;;AAEA,yDAA+D;AAC/D,yFAAsF;AAEtF;;GAEG;AACI,MAAM,iBAAiB,GAAG;AAkB/B;;GAEG;AACH,EAAK;AAEL;;GAEG;AACH,KAAQ,EACc,EAAE;IACxB,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,MAAM,cAAc,GAAG,KAAK,CAAC;IAE7B,yCAAyC;IACzC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,mEAAgC,EAAC;QACnD,KAAK,EAAE,WAAW;KACnB,CAAC,CAAC;IAEH,2DAA2D;IAC3D,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,cAAc,CAAC,CAAC;IACpE,IAAI,CAAC,aAAa;QAChB,MAAM,IAAI,4CAAyB,CAAC;YAClC,WAAW;YACX,cAAc;YACd,MAAM,EAAE,uDAAuD;SAChE,CAAC,CAAC;IAEL,gCAAgC;IAChC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE;QACxD,MAAM,YAAY,GAChB,cAAc,CAAC,UAAyC,CAAC,CAAC;QAC5D,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IACpD,CAAC,EAAE,EAA0B,CAAC,CAAC;IAC/B,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AApDW,QAAA,iBAAiB,qBAoD5B"}
@@ -1,28 +0,0 @@
1
- import { DomainObject } from 'domain-objects';
2
- import { DeclaredResourceReference } from '../../../domain/DeclaredResourceReference';
3
- export declare class CanNotReferenceDeclaredResourceClassError extends Error {
4
- constructor({ class: ofClass, reason, }: {
5
- class: typeof DomainObject;
6
- reason: string;
7
- });
8
- }
9
- export declare class CanNotBuildReferenceError extends Error {
10
- constructor({ referenceInput, referenceOf, reason, }: {
11
- referenceInput: any;
12
- referenceOf: any;
13
- reason: string;
14
- });
15
- }
16
- /**
17
- * build a reference to a resource of a particular class using a supported key
18
- * - uses the unique key if possible
19
- * - uses the primary key otherwise
20
- *
21
- * note
22
- * - we prefer unique key over primary key because
23
- * - it encodes the most information
24
- * - it is always available for resources
25
- * - it is the common comparable form of reference
26
- */
27
- export declare const buildReferenceTo: <T extends DomainObject<any>, C extends new (props: T) => T, P extends keyof T, U extends keyof T, K extends Partial<T>>(to: C, using: K, as?: new (props: DeclaredResourceReference<T, P, U>) => DeclaredResourceReference<T, P, U>) => DeclaredResourceReference<T, P, U>;
28
- export { buildReferenceTo as buildRef };
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildRef = exports.buildReferenceTo = exports.CanNotBuildReferenceError = exports.CanNotReferenceDeclaredResourceClassError = void 0;
4
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
5
- const buildPrimaryKeyTo_1 = require("./buildPrimaryKeyTo");
6
- const buildUniqueKeyTo_1 = require("./buildUniqueKeyTo");
7
- const defineReferenceClassOf_1 = require("./defineReferenceClassOf");
8
- const defineReferenceKeyConstituentsOf_1 = require("./defineReferenceKeyConstituentsOf");
9
- class CanNotReferenceDeclaredResourceClassError extends Error {
10
- constructor({ class: ofClass, reason, }) {
11
- super(`
12
- Can not reference declared resource of class '${ofClass.name}'. Instances of the class '${ofClass.name}' can not be referenced because ${reason}.
13
- `.trim());
14
- }
15
- }
16
- exports.CanNotReferenceDeclaredResourceClassError = CanNotReferenceDeclaredResourceClassError;
17
- class CanNotBuildReferenceError extends Error {
18
- constructor({ referenceInput, referenceOf, reason, }) {
19
- super(`
20
- Can not build reference ${referenceOf?.name ? `to class '${referenceOf.name}'` : ''} because ${reason}.
21
-
22
- referenceInput
23
- ${JSON.stringify(referenceInput, null, 2)}
24
- `.trim());
25
- }
26
- }
27
- exports.CanNotBuildReferenceError = CanNotBuildReferenceError;
28
- /**
29
- * build a reference to a resource of a particular class using a supported key
30
- * - uses the unique key if possible
31
- * - uses the primary key otherwise
32
- *
33
- * note
34
- * - we prefer unique key over primary key because
35
- * - it encodes the most information
36
- * - it is always available for resources
37
- * - it is the common comparable form of reference
38
- */
39
- const buildReferenceTo = (
40
- /**
41
- * the class this is a reference to
42
- */
43
- to,
44
- /**
45
- * the data to build the reference with
46
- */
47
- using,
48
- /**
49
- * the class to instantiate the reference with
50
- * - defaults to the generic DeclaredResourceReference class
51
- * - allows using a more specific subclass if one was created
52
- */
53
- as) => {
54
- const referenceOf = to;
55
- const referenceInput = using;
56
- const ReferenceConstructor = as ??
57
- (0, defineReferenceClassOf_1.defineReferenceClassOf)({ class: referenceOf }) ??
58
- DeclaredResourceReference_1.DeclaredResourceReference; // todo: start throwing errors if reference is not explicitly declared on the source class; using DeclaredResourceError produces hydration and serialization errors for "alternatives" types
59
- // get the unique and unique key defs for the class
60
- const { unique, primary } = (0, defineReferenceKeyConstituentsOf_1.defineReferenceKeyConstituentsOf)({
61
- class: referenceOf,
62
- });
63
- // if unique key is defined, reference by unique key
64
- const hasUniqueKey = unique.every((key) => key in referenceInput);
65
- if (hasUniqueKey)
66
- return new ReferenceConstructor({
67
- referenceOf: referenceOf.name,
68
- identifiedBy: {
69
- key: DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.UNIQUE_KEY,
70
- value: (0, buildUniqueKeyTo_1.buildUniqueKeyTo)(referenceOf, referenceInput),
71
- },
72
- });
73
- // if primary key is defined, reference by primary key
74
- const hasPrimaryKey = primary.every((key) => key in referenceInput);
75
- if (hasPrimaryKey)
76
- return new ReferenceConstructor({
77
- referenceOf: referenceOf.name,
78
- identifiedBy: {
79
- key: DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.PRIMARY_KEY,
80
- value: (0, buildPrimaryKeyTo_1.buildPrimaryKeyTo)(referenceOf, referenceInput),
81
- },
82
- });
83
- // if has neither, then the reference can not be made
84
- throw new CanNotBuildReferenceError({
85
- referenceOf,
86
- referenceInput,
87
- reason: 'neither the primary key nor unique key is present in the reference key',
88
- });
89
- };
90
- exports.buildReferenceTo = buildReferenceTo;
91
- exports.buildRef = exports.buildReferenceTo;
92
- //# sourceMappingURL=buildReferenceTo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildReferenceTo.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/buildReferenceTo.ts"],"names":[],"mappings":";;;AAEA,yFAGmD;AACnD,2DAAwD;AACxD,yDAAsD;AACtD,qEAAkE;AAClE,yFAAsF;AAEtF,MAAa,yCAA0C,SAAQ,KAAK;IAClE,YAAY,EACV,KAAK,EAAE,OAAO,EACd,MAAM,GAIP;QACC,KAAK,CACH;gDAC0C,OAAO,CAAC,IAAI,8BAA8B,OAAO,CAAC,IAAI,mCAAmC,MAAM;KAC1I,CAAC,IAAI,EAAE,CACP,CAAC;IACJ,CAAC;CACF;AAdD,8FAcC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,EACV,cAAc,EACd,WAAW,EACX,MAAM,GAKP;QACC,KAAK,CACH;0BAEE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EACzD,YAAY,MAAM;;;EAGtB,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAA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AAc,CAAC;aACtD;SACF,CAAuC,CAAC;IAE3C,qDAAqD;IACrD,MAAM,IAAI,yBAAyB,CAAC;QAClC,WAAW;QACX,cAAc;QACd,MAAM,EACJ,wEAAwE;KAC3E,CAAC,CAAC;AACL,CAAC,CAAC;AAlFW,QAAA,gBAAgB,oBAkF3B;AAE2B,mBApFhB,wBAAgB,CAoFQ"}
@@ -1,119 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const domain_objects_1 = require("domain-objects");
4
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
5
- const buildReferenceTo_1 = require("./buildReferenceTo");
6
- // todo: remove the declastruct references in favor of domain-object references
7
- describe.skip('getReferenceTo', () => {
8
- it('should throw a helpful error the class does not have unique key defined', () => {
9
- class CNCMachine extends domain_objects_1.DomainObject {
10
- }
11
- CNCMachine.primary = ['uuid'];
12
- try {
13
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
- const ref = (0, buildReferenceTo_1.buildReferenceTo)(CNCMachine, new CNCMachine({
15
- serialNumber: '821',
16
- size: 'big',
17
- location: 'basement',
18
- }));
19
- throw new Error('should not reach here');
20
- }
21
- catch (error) {
22
- expect(error).toBeInstanceOf(buildReferenceTo_1.CanNotReferenceDeclaredResourceClassError);
23
- expect(error.message).toContain(`the static property 'unique' was not defined as an array of strings`);
24
- expect(error).toMatchSnapshot();
25
- }
26
- });
27
- it('should throw a helpful error the class does not have primary key defined correctly', () => {
28
- class CNCMachine extends domain_objects_1.DomainObject {
29
- }
30
- CNCMachine.primary = 'uuid';
31
- try {
32
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- const ref = (0, buildReferenceTo_1.buildReferenceTo)(CNCMachine, new CNCMachine({
34
- serialNumber: '821',
35
- size: 'big',
36
- location: 'basement',
37
- }));
38
- throw new Error('should not reach here');
39
- }
40
- catch (error) {
41
- expect(error).toBeInstanceOf(buildReferenceTo_1.CanNotReferenceDeclaredResourceClassError);
42
- expect(error.message).toContain(`the static property 'primary' was not defined as an array of strings`);
43
- expect(error).toMatchSnapshot();
44
- }
45
- });
46
- it('should be able to reference by unique key', () => {
47
- class CNCMachine extends domain_objects_1.DomainObject {
48
- }
49
- CNCMachine.primary = ['uuid'];
50
- CNCMachine.unique = ['serialNumber'];
51
- const reference = (0, buildReferenceTo_1.buildReferenceTo)(CNCMachine, new CNCMachine({
52
- serialNumber: '821',
53
- size: 'big',
54
- location: 'basement',
55
- }));
56
- expect(reference).toEqual({
57
- referenceOf: 'CNCMachine',
58
- identifiedBy: {
59
- key: 'UNIQUE_KEY',
60
- value: { serialNumber: '821' },
61
- },
62
- });
63
- expect(reference).toMatchSnapshot(); // log for viewing
64
- });
65
- it('should be able to reference by primary key', () => {
66
- class CNCMachine extends domain_objects_1.DomainObject {
67
- }
68
- CNCMachine.primary = ['uuid'];
69
- CNCMachine.unique = ['serialNumber'];
70
- const reference = (0, buildReferenceTo_1.buildReferenceTo)(CNCMachine, {
71
- uuid: '__UUID__',
72
- });
73
- expect(reference).toEqual({
74
- referenceOf: 'CNCMachine',
75
- identifiedBy: {
76
- key: 'PRIMARY_KEY',
77
- value: { uuid: '__UUID__' },
78
- },
79
- });
80
- expect(reference).toMatchSnapshot(); // log for viewing
81
- });
82
- it('should reference by unique key if both are available', () => {
83
- class CNCMachine extends domain_objects_1.DomainObject {
84
- }
85
- CNCMachine.primary = ['uuid'];
86
- CNCMachine.unique = ['serialNumber'];
87
- const reference = (0, buildReferenceTo_1.buildReferenceTo)(CNCMachine, new CNCMachine({
88
- uuid: 'de0e34ca-ce61-4884-ace5-093a1a32ff92',
89
- serialNumber: '821',
90
- size: 'big',
91
- location: 'basement',
92
- }));
93
- expect(reference).toEqual({
94
- referenceOf: 'CNCMachine',
95
- identifiedBy: {
96
- key: 'UNIQUE_KEY',
97
- value: { serialNumber: '821' },
98
- },
99
- });
100
- expect(reference).toMatchSnapshot(); // log for viewing
101
- });
102
- it('should be able to instantiate with more specific reference class if one exists', () => {
103
- class CNCMachine extends domain_objects_1.DomainObject {
104
- }
105
- CNCMachine.primary = ['uuid'];
106
- CNCMachine.unique = ['serialNumber'];
107
- class CNCMachineReference extends DeclaredResourceReference_1.DeclaredResourceReference {
108
- }
109
- const reference = (0, buildReferenceTo_1.buildReferenceTo)(CNCMachine, new CNCMachine({
110
- uuid: 'de0e34ca-ce61-4884-ace5-093a1a32ff92',
111
- serialNumber: '821',
112
- size: 'big',
113
- location: 'basement',
114
- }), CNCMachineReference);
115
- expect(reference).toBeInstanceOf(CNCMachineReference);
116
- expect(reference).toMatchSnapshot(); // log for viewing
117
- });
118
- });
119
- //# sourceMappingURL=buildReferenceTo.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildReferenceTo.test.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/buildReferenceTo.test.ts"],"names":[],"mappings":";;AAAA,mDAA8C;AAE9C,yFAAsF;AACtF,yDAG4B;AAE5B,+EAA+E;AAC/E,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QAOjF,MAAM,UAAW,SAAQ,6BAAwB;;QACjC,kBAAO,GAAG,CAAC,MAAM,CAAC,CAAC;QAOnC,IAAI,CAAC;YACH,6DAA6D;YAC7D,MAAM,GAAG,GAAwB,IAAA,mCAAgB,EAC/C,UAAU,EACV,IAAI,UAAU,CAAC;gBACb,YAAY,EAAE,KAAK;gBACnB,IAAI,EAAE,KAAK;gBACX,QAAQ,EAAE,UAAU;aACrB,CAAC,CACH,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,4DAAyC,CAAC,CAAC;YACxE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAC7B,qEAAqE,CACtE,CAAC;YACF,M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,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,kBAAkB;IACzD,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gFAAgF,EAAE,GAAG,EAAE;QAOxF,MAAM,UAAW,SAAQ,6BAAwB;;QACjC,kBAAO,GAAG,CAAC,MAAM,CAAC,CAAC;QACnB,iBAAM,GAAG,CAAC,cAAc,CAAC,CAAC;QAE1C,MAAM,mBAAoB,SAAQ,qDAIjC;SAAG;QACJ,MAAM,SAAS,GAAG,IAAA,mCAAgB,EAChC,UAAU,EACV,IAAI,UAAU,CAAC;YACb,IAAI,EAAE,sCAAsC;YAC5C,YAAY,EAAE,KAAK;YACnB,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,UAAU;SACrB,CAAC,EACF,mBAAmB,CACpB,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;QACtD,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,kBAAkB;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- import { DomainObject } from 'domain-objects';
2
- /**
3
- * build the unique key of the resource
4
- */
5
- export declare const buildUniqueKeyTo: <T extends DomainObject<any>, C extends new (props: T) => T, U extends keyof T, K extends Partial<T> | Required<Pick<T, U>>>(to: C, using: K) => Required<Pick<T, U>>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildUniqueKeyTo = void 0;
4
- const buildReferenceTo_1 = require("./buildReferenceTo");
5
- const defineReferenceKeyConstituentsOf_1 = require("./defineReferenceKeyConstituentsOf");
6
- /**
7
- * build the unique key of the resource
8
- */
9
- const buildUniqueKeyTo = (
10
- /**
11
- * the class this is a reference to
12
- */
13
- to,
14
- /**
15
- * the data to build the reference with
16
- */
17
- using) => {
18
- const referenceOf = to;
19
- const referenceInput = using;
20
- // get the unique key defs for the class
21
- const { unique } = (0, defineReferenceKeyConstituentsOf_1.defineReferenceKeyConstituentsOf)({
22
- class: referenceOf,
23
- });
24
- // assert that the resource has a unique key defined on it
25
- const hasUniqueKey = unique.every((key) => key in referenceInput);
26
- if (!hasUniqueKey)
27
- throw new buildReferenceTo_1.CanNotBuildReferenceError({
28
- referenceOf,
29
- referenceInput,
30
- reason: 'the unique key is not present in the reference input',
31
- });
32
- // extract the unique key value
33
- const uniqueKey = unique.reduce((summary, thisKeyKey) => {
34
- const thisKeyValue = referenceInput[thisKeyKey];
35
- return { ...summary, [thisKeyKey]: thisKeyValue };
36
- }, {});
37
- return uniqueKey;
38
- };
39
- exports.buildUniqueKeyTo = buildUniqueKeyTo;
40
- //# sourceMappingURL=buildUniqueKeyTo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildUniqueKeyTo.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/buildUniqueKeyTo.ts"],"names":[],"mappings":";;;AAEA,yDAA+D;AAC/D,yFAAsF;AAEtF;;GAEG;AACI,MAAM,gBAAgB,GAAG;AAkB9B;;GAEG;AACH,EAAK;AAEL;;GAEG;AACH,KAAQ,EACc,EAAE;IACxB,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,MAAM,cAAc,GAAG,KAAK,CAAC;IAE7B,wCAAwC;IACxC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,mEAAgC,EAAC;QAClD,KAAK,EAAE,WAAW;KACnB,CAAC,CAAC;IAEH,0DAA0D;IAC1D,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,cAAc,CAAC,CAAC;IAClE,IAAI,CAAC,YAAY;QACf,MAAM,IAAI,4CAAyB,CAAC;YAClC,WAAW;YACX,cAAc;YACd,MAAM,EAAE,sDAAsD;SAC/D,CAAC,CAAC;IAEL,+BAA+B;IAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE;QACtD,MAAM,YAAY,GAChB,cAAc,CAAC,UAAyC,CAAC,CAAC;QAC5D,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IACpD,CAAC,EAAE,EAA0B,CAAC,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AApDW,QAAA,gBAAgB,oBAoD3B"}
@@ -1,5 +0,0 @@
1
- import { DomainObject } from 'domain-objects';
2
- import { DeclaredResourceReference } from '../../../domain/DeclaredResourceReference';
3
- export declare const defineReferenceClassOf: <T extends DomainObject<any>, C extends new (props: T) => T, P extends keyof T, U extends keyof T>({ class: ofClass, }: {
4
- class: C;
5
- }) => (new (props: DeclaredResourceReference<T, P, U>) => DeclaredResourceReference<T, P, U>) | null;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineReferenceClassOf = void 0;
4
- const type_fns_1 = require("type-fns");
5
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
6
- const defineReferenceKeyConstituentsOf_1 = require("./defineReferenceKeyConstituentsOf");
7
- const defineReferenceClassOf = ({ class: ofClass, }) => {
8
- // grab the reference spec, if any
9
- const referenceSpec = ofClass.reference;
10
- if (!referenceSpec)
11
- return null;
12
- // if its a function, call it to get the reference spec
13
- const referenceSpecResolved = (0, type_fns_1.isAFunction)(referenceSpec)
14
- ? referenceSpec()
15
- : referenceSpec;
16
- // assert that the reference spec is a valid reference spec
17
- if (!(referenceSpecResolved.prototype instanceof DeclaredResourceReference_1.DeclaredResourceReference))
18
- throw new defineReferenceKeyConstituentsOf_1.CanNotReferenceDeclaredResourceClassError({
19
- class: ofClass,
20
- reason: `${ofClass.name}.reference was defined but not as an instance of DeclaredResourceReference`,
21
- });
22
- return referenceSpecResolved;
23
- };
24
- exports.defineReferenceClassOf = defineReferenceClassOf;
25
- //# sourceMappingURL=defineReferenceClassOf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defineReferenceClassOf.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/defineReferenceClassOf.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AAEvC,yFAAsF;AACtF,yFAA+F;AAExF,MAAM,sBAAsB,GAAG,CAiBpC,EACA,KAAK,EAAE,OAAO,GAGf,EAIQ,EAAE;IACT,kCAAkC;IAClC,MAAM,aAAa,GAAI,OAAe,CAAC,SAAS,CAAC;IACjD,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAEhC,uDAAuD;IACvD,MAAM,qBAAqB,GAAG,IAAA,sBAAW,EAAC,aAAa,CAAC;QACtD,CAAC,CAAC,aAAa,EAAE;QACjB,CAAC,CAAC,aAAa,CAAC;IAElB,2DAA2D;IAC3D,IAAI,CAAC,CAAC,qBAAqB,CAAC,SAAS,YAAY,qDAAyB,CAAC;QACzE,MAAM,IAAI,4EAAyC,CAAC;YAClD,KAAK,EAAE,OAAqC;YAC5C,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,4EAA4E;SACpG,CAAC,CAAC;IAEL,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC;AA3CW,QAAA,sBAAsB,0BA2CjC"}
@@ -1,13 +0,0 @@
1
- import { DomainObject } from 'domain-objects';
2
- export declare class CanNotReferenceDeclaredResourceClassError extends Error {
3
- constructor({ class: ofClass, reason, }: {
4
- class: typeof DomainObject;
5
- reason: string;
6
- });
7
- }
8
- export declare const defineReferenceKeyConstituentsOf: ({ class: ofClass, }: {
9
- class: any;
10
- }) => {
11
- primary: string[];
12
- unique: string[];
13
- };