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 +0,0 @@
1
- {"version":3,"file":"castReferenceToGrokableString.js","sourceRoot":"","sources":["../../../../src/logic/tools/compare/castReferenceToGrokableString.ts"],"names":[],"mappings":";;;AAAA,mDAA2C;AAC3C,qCAAkC;AAClC,mEAAqD;AACrD,uCAAqC;AAErC,6DAAwD;AAIxD,qGAAkG;AAElG;;;;;;;;;GASG;AACU,QAAA,6BAA6B,GAAG,IAAA,uCAAiB,EAC5D,KAAK,EACH,EACE,SAAS,GAGV,EACD,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mC;QAC1D,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACrD;YACE,GAAG;YACH,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAClB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;iBACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;iBACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,mLAAmL;SAC5M,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ;KACF,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,OAAO,cAAc,CAAC;AACxB,CAAC,EACD;IACE,KAAK,EAAE,IAAA,oCAAW,EAAC;QACjB,UAAU,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,iHAAiH;KAChJ,CAAC;IACF,SAAS,EAAE;QACT,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,IAAA,0BAAS,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe;KAC/D;CACF,CACF,CAAC"}
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const domain_objects_1 = require("domain-objects");
4
- const __1 = require("../../..");
5
- const getExampleContext_1 = require("../../../__test_assets__/getExampleContext");
6
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
7
- const castReferenceToGrokableString_1 = require("./castReferenceToGrokableString");
8
- const { exampleContext, exampleMachine, CNCMachine, exampleRegistration, CNCMachineRegistration, } = (0, getExampleContext_1.getExampleContext)();
9
- describe('castReferenceToGrokableString', () => {
10
- describe('shallow', () => {
11
- it('should be able to cast a shallow unique key reference to grokable string', async () => {
12
- const reference = (0, __1.buildRef)(CNCMachine, {
13
- serialNumber: exampleMachine.serialNumber,
14
- });
15
- const string = await (0, castReferenceToGrokableString_1.castReferenceToGrokableString)({ reference }, exampleContext);
16
- console.log(string);
17
- expect(string).toEqual(`CNCMachine.serialNumber:'821'`);
18
- });
19
- });
20
- describe('nested', () => {
21
- class Spaceship extends domain_objects_1.DomainEntity {
22
- }
23
- Spaceship.primary = ['uuid'];
24
- Spaceship.unique = ['serialNumber'];
25
- Spaceship.updatable = ['serialNumber'];
26
- class Address extends domain_objects_1.DomainLiteral {
27
- }
28
- class Spaceport extends domain_objects_1.DomainEntity {
29
- }
30
- Spaceport.primary = ['uuid'];
31
- Spaceport.unique = ['address'];
32
- Spaceport.updatable = ['spaceships'];
33
- Spaceport.nested = {
34
- address: Address,
35
- spaceships: DeclaredResourceReference_1.DeclaredResourceReference,
36
- };
37
- class HumanAgent extends domain_objects_1.DomainEntity {
38
- }
39
- HumanAgent.primary = ['uuid'];
40
- HumanAgent.unique = ['birthCode'];
41
- class Captain extends domain_objects_1.DomainEntity {
42
- }
43
- Captain.primary = ['uuid'];
44
- Captain.unique = ['agent', 'ship'];
45
- Captain.nested = {
46
- agent: DeclaredResourceReference_1.DeclaredResourceReference,
47
- ship: DeclaredResourceReference_1.DeclaredResourceReference,
48
- };
49
- it('should be able to cast a unique key based on referenced entities to a grokable string', async () => {
50
- // instantiate them
51
- const ship = new Spaceship({
52
- serialNumber: '__SHIP_A__',
53
- fuelQuantity: 9001,
54
- passengers: 21,
55
- });
56
- const bob = new HumanAgent({
57
- birthCode: '821',
58
- name: 'Bobby Tables', // https://xkcd.com/327/
59
- });
60
- const captain = new Captain({
61
- agent: (0, __1.getRef)(bob),
62
- ship: (0, __1.getRef)(ship),
63
- });
64
- const string = await (0, castReferenceToGrokableString_1.castReferenceToGrokableString)({ reference: (0, __1.getRef)(captain) }, exampleContext);
65
- expect(string).toEqual(`Captain.agent.birthCode:'821'.ship.serialNumber:'__SHIP_A__'`);
66
- });
67
- it('should be able to cast a unique key based on valueobject to a grokable string', async () => {
68
- // instantiate them
69
- const shipA = new Spaceship({
70
- serialNumber: '__SHIP_A__',
71
- fuelQuantity: 9001,
72
- passengers: 21,
73
- });
74
- const shipB = new Spaceship({
75
- uuid: '821',
76
- serialNumber: '__SHIP_B__',
77
- fuelQuantity: 7000,
78
- passengers: 42,
79
- });
80
- const spaceport = new Spaceport({
81
- uuid: '__SPACEPORT_UUID__',
82
- address: new Address({
83
- galaxy: 'Milky Way',
84
- solarSystem: 'Sun',
85
- planet: 'Earth',
86
- continent: 'North America',
87
- }),
88
- spaceships: [(0, __1.getRef)(shipA), (0, __1.getRef)(shipB)],
89
- });
90
- const string = await (0, castReferenceToGrokableString_1.castReferenceToGrokableString)({ reference: (0, __1.getRef)(spaceport) }, exampleContext);
91
- expect(string).toEqual(`Spaceport.address.galaxy:'Milky Way'.address.solarSystem:'Sun'.address.planet:'Earth'.address.continent:'North America'`);
92
- });
93
- it('should be able to get a grokable string for a primary key reference to a multi-layer nested unique key resource', async () => {
94
- const primaryKeyRef = (0, __1.buildRef)(CNCMachineRegistration, {
95
- uuid: exampleRegistration.uuid,
96
- });
97
- const string = await (0, castReferenceToGrokableString_1.castReferenceToGrokableString)({ reference: primaryKeyRef }, exampleContext);
98
- expect(string).toEqual(`CNCMachineRegistration.machine.serialNumber:'821'`);
99
- });
100
- it('should be able to get a grokable string for a unique key reference w/ a nested primary key reference', async () => {
101
- const uniqueKeyRef = (0, __1.buildRef)(CNCMachineRegistration, {
102
- machine: (0, __1.buildRef)(CNCMachine, {
103
- uuid: exampleMachine.uuid,
104
- }),
105
- });
106
- const string = await (0, castReferenceToGrokableString_1.castReferenceToGrokableString)({ reference: uniqueKeyRef }, exampleContext);
107
- expect(string).toEqual(`CNCMachineRegistration.machine.serialNumber:'821'`);
108
- });
109
- });
110
- });
111
- //# sourceMappingURL=castReferenceToGrokableString.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"castReferenceToGrokableString.test.js","sourceRoot":"","sources":["../../../../src/logic/tools/compare/castReferenceToGrokableString.test.ts"],"names":[],"mappings":";;AAAA,mDAA6D;AAE7D,gCAA4C;AAC5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AAI;iBAC1B,CAAC;aACH,CACF,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,IAAA,6DAA6B,EAChD,EAAE,SAAS,EAAE,YAAY,EAAE,EAC3B,cAAc,CACf,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CACpB,mDAAmD,CACpD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { DetailedDiff } from 'deep-object-diff';
2
- import { DomainObject } from 'domain-objects';
3
- import { VisualogicContext } from 'visualogic';
4
- import { DeclastructContext } from '../../../domain/DeclastructContext';
5
- export declare const detectDifferenceBetweenDesiredAndRemoteStateOfResource: <T extends DomainObject<any>>({ desiredState, remoteState, }: {
6
- desiredState: T | null;
7
- remoteState: T | null;
8
- }, context: DeclastructContext & VisualogicContext) => Promise<{
9
- displayable: string;
10
- usable: DetailedDiff;
11
- }>;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.detectDifferenceBetweenDesiredAndRemoteStateOfResource = void 0;
4
- const deep_object_diff_1 = require("deep-object-diff");
5
- const domain_objects_1 = require("domain-objects");
6
- const jest_diff_1 = require("jest-diff");
7
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
8
- const castReferenceToGrokableString_1 = require("./castReferenceToGrokableString");
9
- /**
10
- * recursively traverse each key of the object and grokify any references found
11
- */
12
- const withReferencesGrokified = async ({ resource }, context) => {
13
- // create a clone of the resources, which we'll mutate keys on
14
- const withKeysGrokified = new resource.constructor(resource);
15
- // for each key holding a reference, replace reference with grokable string
16
- await Promise.all(Object.keys(resource).map(async (key) => {
17
- const value = resource[key];
18
- if (value instanceof DeclaredResourceReference_1.DeclaredResourceReference)
19
- withKeysGrokified[key] = await (0, castReferenceToGrokableString_1.castReferenceToGrokableString)({ reference: value }, context);
20
- else if (Array.isArray(value))
21
- withKeysGrokified[key] = await Promise.all(value.map(async (valueItem) => value instanceof DeclaredResourceReference_1.DeclaredResourceReference
22
- ? await (0, castReferenceToGrokableString_1.castReferenceToGrokableString)({ reference: valueItem }, context)
23
- : await withReferencesGrokified({ resource: valueItem }, context)));
24
- else if (value instanceof domain_objects_1.DomainObject)
25
- withKeysGrokified[key] = await withReferencesGrokified({ resource: value }, context);
26
- }));
27
- // return the fingerprinted object
28
- return withKeysGrokified;
29
- };
30
- const detectDifferenceBetweenDesiredAndRemoteStateOfResource = async ({ desiredState, remoteState, }, context) => {
31
- // replace all nested references with reference fingerprints, for readability
32
- const diffableDesiredState = desiredState
33
- ? // remove the metadata values from the desired state for diff, since these properties dont describe the data, they are just additional data typically generated by the remote state which cant be locally declared (e.g., uuid, createdAt, etc)
34
- (0, domain_objects_1.omitMetadataValues)(await withReferencesGrokified({ resource: desiredState }, context))
35
- : null;
36
- const diffableRemoteState = remoteState
37
- ? // remove the metadata values from the remote state for diff, since these properties dont describe the data, they are just additional data typically generated by the remote state which cant be locally declared (e.g., uuid, createdAt, etc)
38
- (0, domain_objects_1.omitMetadataValues)(await withReferencesGrokified({ resource: remoteState }, context))
39
- : null;
40
- // define a displayable difference
41
- const displayableDifference = (0, jest_diff_1.diff)(diffableDesiredState ?? {}, diffableRemoteState ?? {}, {
42
- omitAnnotationLines: true,
43
- aAnnotation: 'Desired State',
44
- bAnnotation: 'Remote State',
45
- aIndicator: '+',
46
- bIndicator: '-',
47
- });
48
- // replace the "Object {}" placeholder we have to use to represent null state, if present (since jest shows "Comparing two different types of values. Expected object but received null." if we try to use null directly)
49
- const cleanedDisplayableDifference = displayableDifference
50
- ?.replace('- Object {}', '- null')
51
- .replace('+ Object {}', '+ null');
52
- // define a usable difference
53
- const usableDifference = (0, deep_object_diff_1.detailedDiff)(diffableRemoteState ?? {}, diffableDesiredState ?? {}); // TODO: improve the usable difference. use the `objectDiff` and add our own info + make a more useful type
54
- // return both
55
- return {
56
- displayable: cleanedDisplayableDifference,
57
- usable: usableDifference,
58
- };
59
- };
60
- exports.detectDifferenceBetweenDesiredAndRemoteStateOfResource = detectDifferenceBetweenDesiredAndRemoteStateOfResource;
61
- //# sourceMappingURL=detectDifferenceBetweenDesiredAndRemoteStateOfResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detectDifferenceBetweenDesiredAndRemoteStateOfResource.js","sourceRoot":"","sources":["../../../../src/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAC5E,mDAAkE;AAClE,yCAA6C;AAI7C,yFAAsF;AAEtF,mFAAgF;AAEhF;;GAEG;AACH,MAAM,uBAAuB,GAAG,KAAK,EACnC,EAAE,QAAQ,EAAkC,EAC5C,OAA+C,EAC/C,EAAE;IACF,8DAA8D;IAC9D,MAAM,iBAAiB,GACrB,IAAK,QAAQ,CAAC,WAAmC,CAAC,QAAQ,CAAC,CAAC;IAE9D,2EAA2E;IAC3E,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtC,MAAM,KAAK,GAAI,QAAgB,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,KAAK,YAAY,qDAAyB;YAC5C,iBAAiB,CAAC,GAAG,CAAC,GAAG,MAAM,IAAA,6DAA6B,EAC1D,EAAE,SAAS,EAAE,KAAK,EAAE,EACpB,OAAO,CACR,CAAC;aACC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAC3B,iBAAiB,CAAC,GAAG,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CACxC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAC5B,KAAK,YAAY,qDAAyB;gBACxC,CAAC,CAAC,MAAM,IAAA,6DAA6B,EACjC,EAAE,SAAS,EAAE,SAAS,EAAE,EACxB,OAAO,CACR;gBACH,CAAC,CAAC,MA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MAAM,gBAAgB,GAAG,IAAA,+BAAU,EACjC,mBAAmB,IAAI,EAAE,EACzB,oBAAoB,IAAI,EAAE,CAC3B,CAAC,CAAC,2GAA2G;IAE9G,cAAc;IACd,OAAO;QACL,WAAW,EAAE,4BAA4B;QACzC,MAAM,EAAE,gBAAgB;KACzB,CAAC;AACJ,CAAC,CAAC;AA1DW,QAAA,sDAAsD,0DA0DjE"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getExampleContext_1 = require("../../../__test_assets__/getExampleContext");
4
- const detectDifferenceBetweenDesiredAndRemoteStateOfResource_1 = require("./detectDifferenceBetweenDesiredAndRemoteStateOfResource");
5
- const { exampleContext, exampleMachine, CNCMachine } = (0, getExampleContext_1.getExampleContext)();
6
- describe('detectDifferenceBetweenDesiredAndRemoteStateOfResource', () => {
7
- it('should return a helpful displayable difference and usable difference', async () => {
8
- const desiredState = exampleMachine;
9
- const remoteState = new CNCMachine({
10
- ...desiredState,
11
- location: 'moon',
12
- });
13
- const difference = await (0, detectDifferenceBetweenDesiredAndRemoteStateOfResource_1.detectDifferenceBetweenDesiredAndRemoteStateOfResource)({
14
- desiredState,
15
- remoteState,
16
- }, exampleContext);
17
- expect(difference).toMatchSnapshot();
18
- });
19
- it('should show the case where we want to create a new resource well', async () => {
20
- const desiredState = exampleMachine;
21
- const remoteState = null;
22
- const difference = await (0, detectDifferenceBetweenDesiredAndRemoteStateOfResource_1.detectDifferenceBetweenDesiredAndRemoteStateOfResource)({
23
- desiredState,
24
- remoteState,
25
- }, exampleContext);
26
- console.log(difference.displayable);
27
- console.log(difference.usable);
28
- expect(difference).toMatchSnapshot();
29
- });
30
- });
31
- //# sourceMappingURL=detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js","sourceRoot":"","sources":["../../../../src/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.ts"],"names":[],"mappings":";;AAAA,kFAA+E;AAC/E,qIAAkI;AAElI,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAA,qCAAiB,GAAE,CAAC;AAE3E,QAAQ,CAAC,wDAAwD,EAAE,GAAG,EAAE;IACtE,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACpF,MAAM,YAAY,GAAG,cAAc,CAAC;QACpC,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC;YACjC,GAAG,YAAY;YACf,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;QACH,MAAM,UAAU,GACd,MAAM,IAAA,+GAAsD,EAC1D;YACE,YAAY;YACZ,WAAW;SACZ,EACD,cAAc,CACf,CAAC;QACJ,MAAM,CAAC,UAAU,CAAC,CAAC,eAAe,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,kEAAkE,EAAE,KAAK,IAAI,EAAE;QAChF,MAAM,YAAY,GAAG,cAAc,CAAC;QACpC,MAAM,WAAW,GAAG,IAAI,CAAC;QACzB,MAAM,UAAU,GACd,MAAM,IAAA,+GAAsD,EAC1D;YACE,YAAY;YACZ,WAAW;SACZ,EACD,cAAc,CACf,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,CAAC,UAAU,CAAC,CAAC,eAAe,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,21 +0,0 @@
1
- import { VisualogicContext } from 'visualogic';
2
- import { DeclaredResourceReference } from '../../../domain/DeclaredResourceReference';
3
- import { DeclastructContext } from '../../../domain/DeclastructContext';
4
- /**
5
- * resolves a reference to a common form, which any reference can be normalized to, in which it can be compared
6
- * - references can only be compared in fully-expanded unique-key form
7
- * - this function resolves all primary key references into fully-expanded unique-key form
8
- *
9
- * context
10
- * - references to the same resource can be defined by primary-key or unique-key
11
- * - there is no way to determine whether a unique-key reference and a primary-key reference are referring to the same resource
12
- * - the unique-key reference is the only reference form which can be guaranteed to be resolvable
13
- * - a primary-key reference can always be resolved to a unique-key reference (if a resource has a primary key assigned, then it can be looked up by primary key in the remote state)
14
- * - a unique-key reference may not be resolvable into a primary-key reference (the resource may not exist yet, and so there may not exist a primary-key defined for the resource)
15
- * - a unique-key may itself be composed of nested unique keys
16
- * - for example, a `GoogleAdsAdGroup` is unique per `GoogleAdsCampaign` which itself is unique per `GoogleAdsAccount`
17
- * - these nested references must each be resolved
18
- */
19
- export declare const resolveReferenceToCommonComparableForm: <T extends DeclaredResourceReference<any, any, any>>({ reference }: {
20
- reference: T;
21
- }, context: DeclastructContext & VisualogicContext) => Promise<T>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveReferenceToCommonComparableForm = void 0;
4
- const error_fns_1 = require("@ehmpathy/error-fns");
5
- const error_fns_2 = require("@ehmpathy/error-fns");
6
- const __1 = require("../../..");
7
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
8
- const getByReference_1 = require("../reference/getByReference");
9
- const resolveReferencesToCommonComparableForm_1 = require("./resolveReferencesToCommonComparableForm");
10
- /**
11
- * resolves a reference to a common form, which any reference can be normalized to, in which it can be compared
12
- * - references can only be compared in fully-expanded unique-key form
13
- * - this function resolves all primary key references into fully-expanded unique-key form
14
- *
15
- * context
16
- * - references to the same resource can be defined by primary-key or unique-key
17
- * - there is no way to determine whether a unique-key reference and a primary-key reference are referring to the same resource
18
- * - the unique-key reference is the only reference form which can be guaranteed to be resolvable
19
- * - a primary-key reference can always be resolved to a unique-key reference (if a resource has a primary key assigned, then it can be looked up by primary key in the remote state)
20
- * - a unique-key reference may not be resolvable into a primary-key reference (the resource may not exist yet, and so there may not exist a primary-key defined for the resource)
21
- * - a unique-key may itself be composed of nested unique keys
22
- * - for example, a `GoogleAdsAdGroup` is unique per `GoogleAdsCampaign` which itself is unique per `GoogleAdsAccount`
23
- * - these nested references must each be resolved
24
- */
25
- const resolveReferenceToCommonComparableForm = async ({ reference }, context) => {
26
- // if this is a unique key reference, resolve any nested references and return that result
27
- if (reference.identifiedBy.key === DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.UNIQUE_KEY) {
28
- const uniqueKeyValueWithNestedReferencesResolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({
29
- in: reference.identifiedBy.value,
30
- }, context);
31
- return new DeclaredResourceReference_1.DeclaredResourceReference({
32
- referenceOf: reference.referenceOf,
33
- identifiedBy: {
34
- key: reference.identifiedBy.key,
35
- value: uniqueKeyValueWithNestedReferencesResolved,
36
- },
37
- });
38
- }
39
- // if this is a primary key reference, lookup the resource and evaluate common form from there
40
- const resource = await (0, getByReference_1.getByReference)({ reference }, context);
41
- if (!resource)
42
- throw new error_fns_2.BadRequestError('could not find resource by primary key reference. can not resolveReferenceToCommonComparableForm', { reference });
43
- const resolvedShallowReference = (0, __1.getReferenceTo)(resource); // get reference to will produce a reference that may be shallow, since it synchronously computes the deepest reference possible from the available data returned by the interface
44
- if (resolvedShallowReference.identifiedBy.key !==
45
- DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.UNIQUE_KEY // sanity check that the resolved resource reference is defined by unique key; that's what it should normalize to since it's the most common form
46
- )
47
- throw new error_fns_1.UnexpectedCodePathError('should have resolved a reference by unique key from resolved resource', { resource, resolvedReference: resolvedShallowReference });
48
- const resolvedReference = await (0, exports.resolveReferenceToCommonComparableForm)({ reference: resolvedShallowReference }, // now resolve the reference into the deep common form
49
- context);
50
- return resolvedReference;
51
- };
52
- exports.resolveReferenceToCommonComparableForm = resolveReferenceToCommonComparableForm;
53
- //# sourceMappingURL=resolveReferenceToCommonComparableForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveReferenceToCommonCompar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,8CAAsC,EACpE,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,sDAAsD;IAC/F,OAAO,CACR,CAAC;IACF,OAAO,iBAAsB,CAAC;AAChC,CAAC,CAAC;AA/CW,QAAA,sCAAsC,0CA+CjD"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const __1 = require("../../..");
4
- const getExampleContext_1 = require("../../../__test_assets__/getExampleContext");
5
- const resolveReferenceToCommonComparableForm_1 = require("./resolveReferenceToCommonComparableForm");
6
- const { exampleContext, exampleMachine, CNCMachine } = (0, getExampleContext_1.getExampleContext)();
7
- describe('resolveReferenceToCommonComparableForm', () => {
8
- it('should change nothing on a shallow unique key reference', async () => {
9
- const original = (0, __1.buildRef)(CNCMachine, {
10
- serialNumber: exampleMachine.serialNumber,
11
- });
12
- const resolved = await (0, resolveReferenceToCommonComparableForm_1.resolveReferenceToCommonComparableForm)({
13
- reference: original,
14
- }, exampleContext);
15
- expect(resolved).toEqual(original);
16
- });
17
- it('should resolve unique key reference from primary key reference', async () => {
18
- const original = (0, __1.buildRef)(CNCMachine, {
19
- uuid: exampleMachine.uuid,
20
- });
21
- const expected = (0, __1.buildRef)(CNCMachine, {
22
- serialNumber: exampleMachine.serialNumber,
23
- });
24
- const resolved = await (0, resolveReferenceToCommonComparableForm_1.resolveReferenceToCommonComparableForm)({
25
- reference: original,
26
- }, exampleContext);
27
- expect(resolved).toEqual(expected);
28
- });
29
- it.todo('should resolve a primary key reference nested in a unique key reference to unique key form');
30
- });
31
- //# sourceMappingURL=resolveReferenceToCommonComparableForm.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveReferenceToCommonComparableForm.test.js","sourceRoot":"","sources":["../../../../src/logic/tools/compare/resolveReferenceToCommonComparableForm.test.ts"],"names":[],"mappings":";;AAAA,gCAAoC;AACpC,kFAGoD;AACpD,qGAAkG;AAElG,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAA,qCAAiB,GAAE,CAAC;AAE3E,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,EAAE,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;QACvE,MAAM,QAAQ,GAAwB,IAAA,YAAQ,EAAC,UAAU,EAAE;YACzD,YAAY,EAAE,cAAc,CAAC,YAAY;SAC1C,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAA,+EAAsC,EAC3D;YACE,SAAS,EAAE,QAAQ;SACpB,EACD,cAAc,CACf,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,QAAQ,GAAwB,IAAA,YAAQ,EAAC,UAAU,EAAE;YACzD,IAAI,EAAE,cAAc,CAAC,IAAI;SAC1B,CAAC,CAAC;QACH,MAAM,QAAQ,GAAwB,IAAA,YAAQ,EAAC,UAAU,EAAE;YACzD,YAAY,EAAE,cAAc,CAAC,YAAY;SAC1C,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAA,+EAAsC,EAC3D;YACE,SAAS,EAAE,QAAQ;SACpB,EACD,cAAc,CACf,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,IAAI,CACL,4FAA4F,CAC7F,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- import { VisualogicContext } from 'visualogic';
2
- import { DeclastructContext } from '../../../domain/DeclastructContext';
3
- /**
4
- * recursively resolves all references in the given object to their common-comparable-form
5
- *
6
- * see the docs on `resolveReferenceToCommonComparableForm` for more info
7
- */
8
- export declare const resolveReferencesToCommonComparableForm: <T extends unknown>({ in: value }: {
9
- in: T;
10
- }, context: DeclastructContext & VisualogicContext) => Promise<T>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveReferencesToCommonComparableForm = void 0;
4
- const domain_objects_1 = require("domain-objects");
5
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
6
- const resolveReferenceToCommonComparableForm_1 = require("./resolveReferenceToCommonComparableForm");
7
- /**
8
- * recursively resolves all references in the given object to their common-comparable-form
9
- *
10
- * see the docs on `resolveReferenceToCommonComparableForm` for more info
11
- */
12
- const resolveReferencesToCommonComparableForm = async ({ in: value }, context) => {
13
- // if this is not an object, then do nothing to it
14
- if (!Array.isArray(value) && typeof value !== 'object')
15
- return value; // if this value is not an array and is not an object, then it's a literal, so no more preparation required, return it itself
16
- if (value === null)
17
- return value; // if its null, return it too (null is typeof 'object' in js :shrug:)
18
- // if its an array, then `resolve references` on each element
19
- if (Array.isArray(value))
20
- return (await Promise.all(value.map((el) => (0, exports.resolveReferencesToCommonComparableForm)({ in: el }, context))));
21
- // if it's a reference, then resolve the reference
22
- if (value instanceof DeclaredResourceReference_1.DeclaredResourceReference)
23
- return await (0, resolveReferenceToCommonComparableForm_1.resolveReferenceToCommonComparableForm)({ reference: value }, context);
24
- // otherwise, it's a generic object, so resolve the references on each key
25
- const object = value;
26
- const resolvedObject = {};
27
- for (const nestedKey of Object.keys(object)) {
28
- const nestedValue = object[nestedKey];
29
- const resolvedValue = await (0, exports.resolveReferencesToCommonComparableForm)({ in: nestedValue }, context);
30
- resolvedObject[nestedKey] = resolvedValue;
31
- }
32
- // if the object was a declared resource, then instantiate it with the same constructor and return that
33
- if (object instanceof domain_objects_1.DomainObject) {
34
- const DomainObjectConstructor = object.constructor;
35
- return new DomainObjectConstructor(resolvedObject);
36
- }
37
- // otherwise, return the resolved object
38
- return resolvedObject;
39
- };
40
- exports.resolveReferencesToCommonComparableForm = resolveReferencesToCommonComparableForm;
41
- //# sourceMappingURL=resolveReferencesToCommonComparableForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveReferencesToCommonComparableForm.js","sourceRoot":"","sources":["../../../../src/logic/tools/compare/resolveReferencesToCommonComparableForm.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAG9C,yFAAsF;AAEtF,qGAAkG;AAElG;;;;GAIG;AACI,MAAM,uCAAuC,GAAG,KAAK,EAC1D,EAAE,EAAE,EAAE,KAAK,EAAa,EACxB,OAA+C,EACnC,EAAE;IACd,kDAAkD;IAClD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,CAAC,6HAA6H;IACnM,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC,CAAC,qEAAqE;IAEvG,6DAA6D;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACtB,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CACvB,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACf,IAAA,+CAAuC,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAC7D,CACF,CAAM,CAAC;IAEV,kDAAkD;IAClD,IAAI,KAAK,YAAY,qDAAyB;QAC5C,OAAO,MAAM,IAAA,+EAAsC,EACjD,EAAE,SAAS,EAAE,KAAK,EAAE,EACpB,OAAO,CACR,CAAC;IAEJ,0EAA0E;IAC1E,MAAM,MAAM,GAAwB,KAAY,CAAC;IACjD,MAAM,cAAc,GAAwB,EAAE,CAAC;IAC/C,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,aAAa,GAAG,MAAM,IAAA,+CAAuC,EACjE,EAAE,EAAE,EAAE,WAAW,EAAE,EACnB,OAAO,CACR,CAAC;QACF,cAAc,CAAC,SAAS,CAAC,GAAG,aAAa,CAAC;IAC5C,CAAC;IAED,uGAAuG;IACvG,IAAI,MAAM,YAAY,6BAAY,EAAE,CAAC;QACnC,MAAM,uBAAuB,GAAG,MAAM,CAAC,WAAkC,CAAC;QAC1E,OAAO,IAAI,uBAAuB,CAAC,cAAc,CAAM,CAAC;IAC1D,CAAC;IAED,wCAAwC;IACxC,OAAO,cAAmB,CAAC;AAC7B,CAAC,CAAC;AA3CW,QAAA,uCAAuC,2CA2ClD"}
@@ -1,174 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const domain_objects_1 = require("domain-objects");
4
- const __1 = require("../../..");
5
- const getExampleContext_1 = require("../../../__test_assets__/getExampleContext");
6
- const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
7
- const resolveReferencesToCommonComparableForm_1 = require("./resolveReferencesToCommonComparableForm");
8
- const { exampleContext, exampleMachine, CNCMachine, exampleRegistration, CNCMachineRegistration, } = (0, getExampleContext_1.getExampleContext)();
9
- describe('resolveReferencesToCommonComparableForm', () => {
10
- describe('basic types', () => {
11
- it('should resolve strings', async () => {
12
- const original = 'hello!';
13
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
14
- expect(resolved).toEqual(original);
15
- });
16
- it('should resolve numbers', async () => {
17
- const original = 821;
18
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
19
- expect(resolved).toEqual(original);
20
- });
21
- // TODO: fix this
22
- it.skip('should resolve dates', async () => {
23
- const original = new Date('2020-08-21 00:00:00');
24
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
25
- expect(resolved).toEqual(original);
26
- });
27
- it('should resolve undefined', async () => {
28
- const original = undefined;
29
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
30
- expect(resolved).toEqual(original);
31
- });
32
- it('should resolve nulls', async () => {
33
- const original = null;
34
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
35
- expect(resolved).toEqual(original);
36
- });
37
- // TODO: fix this
38
- it.skip('should resolve buffers', async () => {
39
- const original = Buffer.from('821');
40
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
41
- expect(resolved).toEqual(original);
42
- });
43
- });
44
- describe('arrays', () => {
45
- it('should be able to resolve arrays', async () => {
46
- const original = ['821', 721, 'leopard', 7, 'apple', 3];
47
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
48
- expect(resolved).toEqual(original);
49
- });
50
- it('should resolve arrays even if they have objects', async () => {
51
- const original = [
52
- 'banana',
53
- { id: 1, value: 821, meaning: 42 },
54
- 821,
55
- { id: 0, value: undefined, meaning: null }, // should go first, because id is 0
56
- ];
57
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
58
- expect(resolved).toEqual(original);
59
- });
60
- });
61
- describe('objects', () => {
62
- it('should be able to resolve an object with all sorts of types', async () => {
63
- const original = {
64
- color: 'blue',
65
- cost: 821,
66
- orders: [
67
- { id: 1, value: 821, meaning: 42 },
68
- { id: 0, value: undefined, meaning: null },
69
- ],
70
- application: {
71
- type: 'PAINTING',
72
- },
73
- };
74
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
75
- expect(resolved).toEqual(original);
76
- });
77
- });
78
- describe('domain objects', () => {
79
- class Spaceship extends domain_objects_1.DomainEntity {
80
- }
81
- Spaceship.primary = ['uuid'];
82
- Spaceship.unique = ['serialNumber'];
83
- Spaceship.updatable = ['serialNumber'];
84
- class Address extends domain_objects_1.DomainLiteral {
85
- }
86
- class Spaceport extends domain_objects_1.DomainEntity {
87
- }
88
- Spaceport.primary = ['uuid'];
89
- Spaceport.unique = ['uuid'];
90
- Spaceport.updatable = ['spaceships'];
91
- Spaceport.nested = {
92
- address: Address,
93
- spaceships: DeclaredResourceReference_1.DeclaredResourceReference,
94
- };
95
- // run the tests
96
- it('should resolve a domain object with no nested references', async () => {
97
- const ship = new Spaceship({
98
- serialNumber: '__UUID__',
99
- fuelQuantity: 9001,
100
- passengers: 21,
101
- });
102
- const original = ship;
103
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
104
- expect(resolved).toEqual(original);
105
- });
106
- it('should not change nested references already in common form', async () => {
107
- const shipA = new Spaceship({
108
- serialNumber: '__SHIP_A__',
109
- fuelQuantity: 9001,
110
- passengers: 21,
111
- });
112
- const shipB = new Spaceship({
113
- uuid: '821',
114
- serialNumber: '__SHIP_B__',
115
- fuelQuantity: 7000,
116
- passengers: 42,
117
- });
118
- const spaceport = new Spaceport({
119
- uuid: '__SPACEPORT_UUID__',
120
- address: new Address({
121
- galaxy: 'Milky Way',
122
- solarSystem: 'Sun',
123
- planet: 'Earth',
124
- continent: 'North America',
125
- }),
126
- spaceships: [(0, __1.getRef)(shipA), (0, __1.getRef)(shipB)],
127
- });
128
- const original = spaceport;
129
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
130
- expect(resolved).toEqual(original);
131
- });
132
- it('should resolve each nested primary key reference to its common form', async () => {
133
- const primaryKeyRef = (0, __1.buildRef)(CNCMachine, {
134
- uuid: exampleMachine.uuid,
135
- });
136
- const uniqueKeyRef = (0, __1.buildRef)(CNCMachine, {
137
- serialNumber: exampleMachine.serialNumber,
138
- });
139
- const original = {
140
- machine: primaryKeyRef,
141
- };
142
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
143
- expect(resolved).not.toEqual(original);
144
- expect(resolved).toEqual({ machine: uniqueKeyRef }); // should have taken it to common form
145
- });
146
- it('should resolve each nested unique key reference to its common form', async () => {
147
- const uniqueKeyRef = (0, __1.buildRef)(CNCMachine, {
148
- serialNumber: exampleMachine.serialNumber,
149
- });
150
- const original = {
151
- machine: uniqueKeyRef,
152
- };
153
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
154
- expect(resolved).toEqual({ machine: uniqueKeyRef }); // should have taken it to common form
155
- });
156
- it('should resolve a primary key reference to a multi level nested unique key reference common form', async () => {
157
- const primaryKeyRef = (0, __1.buildRef)(CNCMachineRegistration, {
158
- uuid: exampleRegistration.uuid,
159
- });
160
- const uniqueKeyRef = (0, __1.buildRef)(CNCMachineRegistration, {
161
- machine: (0, __1.buildRef)(CNCMachine, {
162
- serialNumber: exampleMachine.serialNumber,
163
- }),
164
- });
165
- const original = {
166
- registration: primaryKeyRef,
167
- };
168
- const resolved = await (0, resolveReferencesToCommonComparableForm_1.resolveReferencesToCommonComparableForm)({ in: original }, exampleContext);
169
- expect(resolved).not.toEqual(original);
170
- expect(resolved).toEqual({ registration: uniqueKeyRef }); // should have taken it to common form});
171
- });
172
- });
173
- });
174
- //# sourceMappingURL=resolveReferencesToCommonComparableForm.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveReferencesToCommonComparableForm.test.js","sourceRoot":"","sources":["../../../../src/logic/tools/compare/resolveReferencesToCommonComparableForm.test.ts"],"names":[],"mappings":";;AAAA,mDAA6D;AAE7D,gCAA4C;AAC5C,kFAIoD;AACpD,yFAAsF;AACtF,uGAAoG;AAEpG,MAAM,EACJ,cAAc,EACd,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,sBAAsB,GACvB,GAAG,IAAA,qCAAiB,GAAE,CAAC;AAExB,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACvD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;Q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ACF,MAAM,QAAQ,GAAG,MAAM,IAAA,iFAAuC,EAC5D,EAAE,EAAE,EAAE,QAAQ,EAAE,EAChB,cAAc,CACf,CAAC;YACF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,sCAAsC;QAC7F,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,iGAAiG,EAAE,KAAK,IAAI,EAAE;YAC/G,MAAM,aAAa,GAAoC,IAAA,YAAQ,EAC7D,sBAAsB,EACtB;gBACE,IAAI,EAAE,mBAAmB,CAAC,IAAI;aAC/B,CACF,CAAC;YACF,MAAM,YAAY,GAAoC,IAAA,YAAQ,EAC5D,sBAAsB,EACtB;gBACE,OAAO,EAAE,IAAA,YAAQ,EAAC,UAAU,EAAE;oBAC5B,YAAY,EAAE,cAAc,CAAC,YAAY;iBAC1C,CAAC;aACH,CACF,CAAC;YACF,MAAM,QAAQ,GAAG;gBACf,YAAY,EAAE,aAAa;aAC5B,CAAC;YACF,MAAM,QAAQ,GAAG,MAAM,IAAA,iFAAuC,EAC5D,EAAE,EAAE,EAAE,QAAQ,EAAE,EAChB,cAAc,CACf,CAAC;YACF,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACvC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,yCAAyC;QACrG,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- import type { LogMethods } from 'simple-leveled-log-methods';
2
- import { VisualogicContext } from 'visualogic';
3
- import { DeclaredResource } from '../../../domain/DeclaredResource';
4
- import { DeclastructContext } from '../../../domain/DeclastructContext';
5
- import { DeclastructProvider } from '../../../domain/DeclastructProvider';
6
- export declare const createDeclastructContext: ({ providers, resources, log, }: {
7
- providers: DeclastructProvider<any>[];
8
- resources: DeclaredResource[];
9
- log: LogMethods;
10
- }) => DeclastructContext & VisualogicContext;