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
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env tsx
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.executePlanCommand = void 0;
31
+ const bottleneck_1 = __importDefault(require("bottleneck"));
32
+ const fs_1 = require("fs");
33
+ const promises_1 = require("fs/promises");
34
+ const helpful_errors_1 = require("helpful-errors");
35
+ const path_1 = require("path");
36
+ const planChanges_1 = require("../../domain.operations/plan/planChanges");
37
+ const log = console;
38
+ /**
39
+ * .what = executes the plan command to generate an infrastructure change plan
40
+ * .why = provides CLI interface for planning infrastructure changes
41
+ * .note = requires wish file with getResources() and getProviders() exports
42
+ */
43
+ const executePlanCommand = async ({ wishFilePath, planFilePath, }) => {
44
+ // resolve paths
45
+ const resolvedWishPath = (0, path_1.resolve)(process.cwd(), wishFilePath);
46
+ const resolvedPlanPath = (0, path_1.resolve)(process.cwd(), planFilePath);
47
+ // validate wish file exists
48
+ if (!(0, fs_1.existsSync)(resolvedWishPath)) {
49
+ throw new helpful_errors_1.BadRequestError(`Wish file not found: ${resolvedWishPath}`);
50
+ }
51
+ log.info('🌊 declastruct plan');
52
+ log.info(` wish: ${resolvedWishPath}`);
53
+ log.info(` plan: ${resolvedPlanPath}`);
54
+ log.info('');
55
+ // import wish file
56
+ const wish = await Promise.resolve(`${resolvedWishPath}`).then(s => __importStar(require(s)));
57
+ // validate exports
58
+ if (typeof wish.getResources !== 'function') {
59
+ throw new helpful_errors_1.BadRequestError('Wish file must export getResources() function');
60
+ }
61
+ if (typeof wish.getProviders !== 'function') {
62
+ throw new helpful_errors_1.BadRequestError('Wish file must export getProviders() function');
63
+ }
64
+ // get resources and providers
65
+ const resources = await wish.getResources();
66
+ const providers = await wish.getProviders();
67
+ // initialize providers
68
+ log.info('✨ start providers...');
69
+ await Promise.all(providers.map((p) => p.hooks.beforeAll()));
70
+ // create context
71
+ const context = {
72
+ bottleneck: new bottleneck_1.default({ maxConcurrent: 10 }),
73
+ log,
74
+ };
75
+ // plan changes (logs emitted in real-time by planChanges)
76
+ log.info('🔮 plan changes...');
77
+ log.info('');
78
+ const plan = await (0, planChanges_1.planChanges)({
79
+ resources,
80
+ providers,
81
+ wishFilePath: resolvedWishPath,
82
+ }, context);
83
+ // write plan to file
84
+ await (0, promises_1.writeFile)(resolvedPlanPath, JSON.stringify(plan, null, 2), 'utf-8');
85
+ // cleanup providers
86
+ log.info('✨ stop providers...');
87
+ await Promise.all(providers.map((p) => p.hooks.afterAll()));
88
+ // log summary
89
+ log.info('');
90
+ log.info(`🌊 planned for ${plan.changes.length} resources`);
91
+ log.info(` into ${resolvedPlanPath}`);
92
+ };
93
+ exports.executePlanCommand = executePlanCommand;
94
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../../src/contract/cli/plan.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAAoC;AACpC,2BAAgC;AAChC,0CAAwC;AACxC,mDAAiD;AACjD,+BAA+B;AAE/B,0EAAuE;AAEvE,MAAM,GAAG,GAAG,OAAO,CAAC;AAEpB;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,YAAY,EACZ,YAAY,GAIb,EAAiB,EAAE;IAClB,gBAAgB;IAChB,MAAM,gBAAgB,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAC9D,MAAM,gBAAgB,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAE9D,4BAA4B;IAC5B,IAAI,CAAC,IAAA,eAAU,EAAC,gBAAgB,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,gCAAe,CAAC,wBAAwB,gBAAgB,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAChC,GAAG,CAAC,IAAI,CAAC,YAAY,gBAAgB,EAAE,CAAC,CAAC;IACzC,GAAG,CAAC,IAAI,CAAC,YAAY,gBAAgB,EAAE,CAAC,CAAC;IACzC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEb,mBAAmB;IACnB,MAAM,IAAI,GAAG,yBAAa,gBAAgB,uCAAC,CAAC;IAE5C,mBAAmB;IACnB,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,gCAAe,CAAC,+CAA+C,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,gCAAe,CAAC,+CAA+C,CAAC,CAAC;IAC7E,CAAC;IAED,8BAA8B;IAC9B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;IAE5C,uBAAuB;IACvB,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACjC,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAElE,iBAAiB;IACjB,MAAM,OAAO,GAAG;QACd,UAAU,EAAE,IAAI,oBAAU,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;QACjD,GAAG;KACJ,CAAC;IAEF,0DAA0D;IAC1D,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC/B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAW,EAC5B;QACE,SAAS;QACT,SAAS;QACT,YAAY,EAAE,gBAAgB;KAC/B,EACD,OAAO,CACR,CAAC;IAEF,qBAAqB;IACrB,MAAM,IAAA,oBAAS,EAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAE1E,oBAAoB;IACpB,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAChC,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAEjE,cAAc;IACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,OAAO,CAAC,MAAM,YAAY,CAAC,CAAC;IAC5D,GAAG,CAAC,IAAI,CAAC,WAAW,gBAAgB,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC;AArEW,QAAA,kBAAkB,sBAqE7B"}
@@ -1,3 +1,15 @@
1
- export * from './refs';
2
- export * from './sync/plan';
3
- export * from './sync/apply';
1
+ export { IsoTimestamp } from '../../domain.objects/IsoTimestamp';
2
+ export { DeclastructChange, DeclastructChangeAction, } from '../../domain.objects/DeclastructChange';
3
+ export { DeclastructDao } from '../../domain.objects/DeclastructDao';
4
+ export { DeclastructProvider } from '../../domain.objects/DeclastructProvider';
5
+ export { DeclastructPlan } from '../../domain.objects/DeclastructPlan';
6
+ export { ContextDeclastruct } from '../../domain.objects/ContextDeclastruct';
7
+ export { getDaoByResource } from '../../domain.operations/plan/getDaoByResource';
8
+ export { computeChange } from '../../domain.operations/plan/computeChange';
9
+ export { planChanges } from '../../domain.operations/plan/planChanges';
10
+ export { assertPlanStillValid } from '../../domain.operations/plan/validate';
11
+ export { hashChanges } from '../../domain.operations/plan/hashChanges';
12
+ export { extractResourcesFromPlan } from '../../domain.operations/plan/extractResourcesFromPlan';
13
+ export { asIsoTimestamp } from '../../infra/asIsoTimestamp';
14
+ export { applyChange } from '../../domain.operations/apply/applyChange';
15
+ export { applyChanges } from '../../domain.operations/apply/applyChanges';
@@ -1,20 +1,34 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./refs"), exports);
18
- __exportStar(require("./sync/plan"), exports);
19
- __exportStar(require("./sync/apply"), exports);
3
+ exports.applyChanges = exports.applyChange = exports.asIsoTimestamp = exports.extractResourcesFromPlan = exports.hashChanges = exports.assertPlanStillValid = exports.planChanges = exports.computeChange = exports.getDaoByResource = exports.DeclastructPlan = exports.DeclastructProvider = exports.DeclastructDao = exports.DeclastructChangeAction = exports.DeclastructChange = void 0;
4
+ var DeclastructChange_1 = require("../../domain.objects/DeclastructChange");
5
+ Object.defineProperty(exports, "DeclastructChange", { enumerable: true, get: function () { return DeclastructChange_1.DeclastructChange; } });
6
+ Object.defineProperty(exports, "DeclastructChangeAction", { enumerable: true, get: function () { return DeclastructChange_1.DeclastructChangeAction; } });
7
+ var DeclastructDao_1 = require("../../domain.objects/DeclastructDao");
8
+ Object.defineProperty(exports, "DeclastructDao", { enumerable: true, get: function () { return DeclastructDao_1.DeclastructDao; } });
9
+ var DeclastructProvider_1 = require("../../domain.objects/DeclastructProvider");
10
+ Object.defineProperty(exports, "DeclastructProvider", { enumerable: true, get: function () { return DeclastructProvider_1.DeclastructProvider; } });
11
+ var DeclastructPlan_1 = require("../../domain.objects/DeclastructPlan");
12
+ Object.defineProperty(exports, "DeclastructPlan", { enumerable: true, get: function () { return DeclastructPlan_1.DeclastructPlan; } });
13
+ // domain operations - plan
14
+ var getDaoByResource_1 = require("../../domain.operations/plan/getDaoByResource");
15
+ Object.defineProperty(exports, "getDaoByResource", { enumerable: true, get: function () { return getDaoByResource_1.getDaoByResource; } });
16
+ var computeChange_1 = require("../../domain.operations/plan/computeChange");
17
+ Object.defineProperty(exports, "computeChange", { enumerable: true, get: function () { return computeChange_1.computeChange; } });
18
+ var planChanges_1 = require("../../domain.operations/plan/planChanges");
19
+ Object.defineProperty(exports, "planChanges", { enumerable: true, get: function () { return planChanges_1.planChanges; } });
20
+ var validate_1 = require("../../domain.operations/plan/validate");
21
+ Object.defineProperty(exports, "assertPlanStillValid", { enumerable: true, get: function () { return validate_1.assertPlanStillValid; } });
22
+ var hashChanges_1 = require("../../domain.operations/plan/hashChanges");
23
+ Object.defineProperty(exports, "hashChanges", { enumerable: true, get: function () { return hashChanges_1.hashChanges; } });
24
+ var extractResourcesFromPlan_1 = require("../../domain.operations/plan/extractResourcesFromPlan");
25
+ Object.defineProperty(exports, "extractResourcesFromPlan", { enumerable: true, get: function () { return extractResourcesFromPlan_1.extractResourcesFromPlan; } });
26
+ // infra
27
+ var asIsoTimestamp_1 = require("../../infra/asIsoTimestamp");
28
+ Object.defineProperty(exports, "asIsoTimestamp", { enumerable: true, get: function () { return asIsoTimestamp_1.asIsoTimestamp; } });
29
+ // domain operations - apply
30
+ var applyChange_1 = require("../../domain.operations/apply/applyChange");
31
+ Object.defineProperty(exports, "applyChange", { enumerable: true, get: function () { return applyChange_1.applyChange; } });
32
+ var applyChanges_1 = require("../../domain.operations/apply/applyChanges");
33
+ Object.defineProperty(exports, "applyChanges", { enumerable: true, get: function () { return applyChanges_1.applyChanges; } });
20
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,8CAA4B;AAC5B,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdk/index.ts"],"names":[],"mappings":";;;AAEA,4EAGgD;AAF9C,sHAAA,iBAAiB,OAAA;AACjB,4HAAA,uBAAuB,OAAA;AAEzB,sEAAqE;AAA5D,gHAAA,cAAc,OAAA;AACvB,gFAA+E;AAAtE,0HAAA,mBAAmB,OAAA;AAC5B,wEAAuE;AAA9D,kHAAA,eAAe,OAAA;AAGxB,2BAA2B;AAC3B,kFAAiF;AAAxE,oHAAA,gBAAgB,OAAA;AACzB,4EAA2E;AAAlE,8GAAA,aAAa,OAAA;AACtB,wEAAuE;AAA9D,0GAAA,WAAW,OAAA;AACpB,kEAA6E;AAApE,gHAAA,oBAAoB,OAAA;AAC7B,wEAAuE;AAA9D,0GAAA,WAAW,OAAA;AACpB,kGAAiG;AAAxF,oIAAA,wBAAwB,OAAA;AAEjC,QAAQ;AACR,6DAA4D;AAAnD,gHAAA,cAAc,OAAA;AAEvB,4BAA4B;AAC5B,yEAAwE;AAA/D,0GAAA,WAAW,OAAA;AACpB,2EAA0E;AAAjE,4GAAA,YAAY,OAAA"}
@@ -0,0 +1,15 @@
1
+ import Bottleneck from 'bottleneck';
2
+ /**
3
+ * .what = standard context for all declastruct operations
4
+ * .why = provides concurrency control and log trail
5
+ * .note = bottleneck can be a single instance or separate instances for plan/apply operations
6
+ */
7
+ export type ContextDeclastruct = {
8
+ /**
9
+ * concurrency control - either single bottleneck or separate for plan/apply
10
+ */
11
+ bottleneck: Bottleneck | {
12
+ onPlan: Bottleneck;
13
+ onApply: Bottleneck;
14
+ };
15
+ };
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=DeclastructContext.js.map
3
+ //# sourceMappingURL=ContextDeclastruct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextDeclastruct.js","sourceRoot":"","sources":["../../src/domain.objects/ContextDeclastruct.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const bottleneck_1 = __importDefault(require("bottleneck"));
7
+ describe('ContextDeclastruct', () => {
8
+ it('should accept single bottleneck configuration', () => {
9
+ const context = {
10
+ bottleneck: new bottleneck_1.default({ maxConcurrent: 5 }),
11
+ };
12
+ expect(context.bottleneck).toBeInstanceOf(bottleneck_1.default);
13
+ });
14
+ it('should accept split bottleneck configuration', () => {
15
+ const context = {
16
+ bottleneck: {
17
+ onPlan: new bottleneck_1.default({ maxConcurrent: 10 }),
18
+ onApply: new bottleneck_1.default({ maxConcurrent: 1 }),
19
+ },
20
+ };
21
+ expect(context.bottleneck).toHaveProperty('onPlan');
22
+ expect(context.bottleneck).toHaveProperty('onApply');
23
+ expect(context.bottleneck.onPlan).toBeInstanceOf(bottleneck_1.default);
24
+ expect(context.bottleneck.onApply).toBeInstanceOf(bottleneck_1.default);
25
+ });
26
+ it('should be able to intersect with ContextLogTrail', () => {
27
+ // type verification
28
+ const context = {
29
+ bottleneck: new bottleneck_1.default({ maxConcurrent: 5 }),
30
+ log: {
31
+ info: () => { },
32
+ warn: () => { },
33
+ error: () => { },
34
+ debug: () => { },
35
+ },
36
+ };
37
+ expect(context.bottleneck).toBeDefined();
38
+ expect(context.log).toBeDefined();
39
+ });
40
+ });
41
+ //# sourceMappingURL=ContextDeclastruct.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextDeclastruct.test.js","sourceRoot":"","sources":["../../src/domain.objects/ContextDeclastruct.test.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAKpC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,OAAO,GAAuB;YAClC,UAAU,EAAE,IAAI,oBAAU,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;SACjD,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,oBAAU,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,OAAO,GAAuB;YAClC,UAAU,EAAE;gBACV,MAAM,EAAE,IAAI,oBAAU,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;gBAC7C,OAAO,EAAE,IAAI,oBAAU,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;aAC9C;SACF,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,CAAE,OAAO,CAAC,UAAkB,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,oBAAU,CAAC,CAAC;QACtE,MAAM,CAAE,OAAO,CAAC,UAAkB,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,oBAAU,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,oBAAoB;QACpB,MAAM,OAAO,GAAyC;YACpD,UAAU,EAAE,IAAI,oBAAU,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;YAChD,GAAG,EAAE;gBACH,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;gBACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;gBACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;gBACf,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;aAChB;SACF,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { DomainEntity, DomainLiteral } from 'domain-objects';
2
+ /**
3
+ * .what = actions that can be proposed for a resource
4
+ * .why = clearly defines the type of change declastruct will execute
5
+ */
6
+ export declare enum DeclastructChangeAction {
7
+ /**
8
+ * keep the resource as is
9
+ */
10
+ KEEP = "KEEP",
11
+ /**
12
+ * create a new resource
13
+ */
14
+ CREATE = "CREATE",
15
+ /**
16
+ * update an existing resource
17
+ */
18
+ UPDATE = "UPDATE",
19
+ /**
20
+ * destroy an existing resource
21
+ */
22
+ DESTROY = "DESTROY",
23
+ /**
24
+ * replace an existing resource (delete then create)
25
+ */
26
+ REPLACE = "REPLACE"
27
+ }
28
+ /**
29
+ * .what = describes a single change required to align remote state with desired state
30
+ * .why = enables observable, auditable infrastructure changes
31
+ */
32
+ export interface DeclastructChange<TResource extends DomainEntity<any> = DomainEntity<any>> {
33
+ /**
34
+ * which resource this change is for
35
+ */
36
+ forResource: {
37
+ /**
38
+ * class name of the resource being changed
39
+ */
40
+ class: string;
41
+ /**
42
+ * scannable identifier of this specific resource
43
+ */
44
+ slug: string;
45
+ };
46
+ /**
47
+ * action to execute
48
+ */
49
+ action: DeclastructChangeAction;
50
+ /**
51
+ * the states of the resource
52
+ */
53
+ state: {
54
+ /**
55
+ * the desired state of the resource
56
+ *
57
+ * .note = null if the resource should be deleted
58
+ */
59
+ desired: TResource | null;
60
+ /**
61
+ * the remote state of the resource
62
+ *
63
+ * .note = null if the resource doesn't exist remotely
64
+ */
65
+ remote: TResource | null;
66
+ /**
67
+ * human-readable diff of changes
68
+ */
69
+ difference: string | null;
70
+ };
71
+ }
72
+ export declare class DeclastructChange<TResource extends DomainEntity<any> = DomainEntity<any>> extends DomainLiteral<DeclastructChange<TResource>> implements DeclastructChange<TResource> {
73
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeclastructChange = exports.DeclastructChangeAction = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ /**
6
+ * .what = actions that can be proposed for a resource
7
+ * .why = clearly defines the type of change declastruct will execute
8
+ */
9
+ var DeclastructChangeAction;
10
+ (function (DeclastructChangeAction) {
11
+ /**
12
+ * keep the resource as is
13
+ */
14
+ DeclastructChangeAction["KEEP"] = "KEEP";
15
+ /**
16
+ * create a new resource
17
+ */
18
+ DeclastructChangeAction["CREATE"] = "CREATE";
19
+ /**
20
+ * update an existing resource
21
+ */
22
+ DeclastructChangeAction["UPDATE"] = "UPDATE";
23
+ /**
24
+ * destroy an existing resource
25
+ */
26
+ DeclastructChangeAction["DESTROY"] = "DESTROY";
27
+ /**
28
+ * replace an existing resource (delete then create)
29
+ */
30
+ DeclastructChangeAction["REPLACE"] = "REPLACE";
31
+ })(DeclastructChangeAction || (exports.DeclastructChangeAction = DeclastructChangeAction = {}));
32
+ class DeclastructChange extends domain_objects_1.DomainLiteral {
33
+ }
34
+ exports.DeclastructChange = DeclastructChange;
35
+ //# sourceMappingURL=DeclastructChange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeclastructChange.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructChange.ts"],"names":[],"mappings":";;;AAAA,mDAA6D;AAE7D;;;GAGG;AACH,IAAY,uBAyBX;AAzBD,WAAY,uBAAuB;IACjC;;OAEG;IACH,wCAAa,CAAA;IAEb;;OAEG;IACH,4CAAiB,CAAA;IAEjB;;OAEG;IACH,4CAAiB,CAAA;IAEjB;;OAEG;IACH,8CAAmB,CAAA;IAEnB;;OAEG;IACH,8CAAmB,CAAA;AACrB,CAAC,EAzBW,uBAAuB,uCAAvB,uBAAuB,QAyBlC;AAsDD,MAAa,iBAGX,SAAQ,8BAA2C;CACT;AAJ5C,8CAI4C"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const domain_objects_1 = require("domain-objects");
4
+ const DeclastructChange_1 = require("./DeclastructChange");
5
+ describe('DeclastructChange', () => {
6
+ describe('DeclastructChangeAction', () => {
7
+ it('should export all 5 action types', () => {
8
+ expect(DeclastructChange_1.DeclastructChangeAction.KEEP).toBe('KEEP');
9
+ expect(DeclastructChange_1.DeclastructChangeAction.CREATE).toBe('CREATE');
10
+ expect(DeclastructChange_1.DeclastructChangeAction.UPDATE).toBe('UPDATE');
11
+ expect(DeclastructChange_1.DeclastructChangeAction.DESTROY).toBe('DESTROY');
12
+ expect(DeclastructChange_1.DeclastructChangeAction.REPLACE).toBe('REPLACE');
13
+ });
14
+ });
15
+ describe('DeclastructChange class', () => {
16
+ class DemoResource extends domain_objects_1.DomainEntity {
17
+ }
18
+ DemoResource.unique = ['id'];
19
+ it('should build a change with all required properties', () => {
20
+ const change = new DeclastructChange_1.DeclastructChange({
21
+ forResource: {
22
+ class: DemoResource.constructor.name,
23
+ slug: 'demo-1',
24
+ },
25
+ action: DeclastructChange_1.DeclastructChangeAction.CREATE,
26
+ state: {
27
+ desired: new DemoResource({ id: 'demo-1', name: 'Demo' }),
28
+ remote: null,
29
+ difference: null,
30
+ },
31
+ });
32
+ expect(change.forResource.class).toBe(DemoResource.constructor.name);
33
+ expect(change.forResource.slug).toBe('demo-1');
34
+ expect(change.action).toBe(DeclastructChange_1.DeclastructChangeAction.CREATE);
35
+ expect(change.state.desired).toBeDefined();
36
+ expect(change.state.remote).toBeNull();
37
+ expect(change.state.difference).toBeNull();
38
+ });
39
+ it('should handle KEEP action with matching desired and remote state', () => {
40
+ const resource = new DemoResource({ id: 'demo-2', name: 'Demo' });
41
+ const change = new DeclastructChange_1.DeclastructChange({
42
+ forResource: {
43
+ class: DemoResource.constructor.name,
44
+ slug: 'demo-2',
45
+ },
46
+ action: DeclastructChange_1.DeclastructChangeAction.KEEP,
47
+ state: {
48
+ desired: resource,
49
+ remote: resource,
50
+ difference: null,
51
+ },
52
+ });
53
+ expect(change.action).toBe(DeclastructChange_1.DeclastructChangeAction.KEEP);
54
+ expect(change.state.difference).toBeNull();
55
+ expect(change.state.desired).toBe(change.state.remote);
56
+ });
57
+ });
58
+ });
59
+ //# sourceMappingURL=DeclastructChange.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeclastructChange.test.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructChange.test.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,39 @@
1
+ import { DomainEntity, DomainLiteral, Ref, Refable, RefByPrimary, RefByUnique } from 'domain-objects';
2
+ import { HasMetadata } from 'type-fns';
3
+ /**
4
+ * .what = standardized data access interface for any resource type
5
+ * .why = enforces idempotent semantics and consistent access patterns across all providers
6
+ * .note = TResourceClass is the class constructor (e.g., typeof MyResource) with static unique/primary properties
7
+ */
8
+ export interface DeclastructDao<TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext = never> {
9
+ get: {
10
+ /**
11
+ * required - fetch by unique keys (enables idempotency)
12
+ */
13
+ byUnique: (input: RefByUnique<TResourceClass>, context: TContext) => Promise<TResource | null>;
14
+ /**
15
+ * optional - fetch by primary keys (if resource supports them)
16
+ */
17
+ byPrimary?: (input: RefByPrimary<TResourceClass>, context: TContext) => Promise<TResource | null>;
18
+ /**
19
+ * required - fetch by any supported reference type
20
+ */
21
+ byRef: (input: Ref<TResourceClass>, context: TContext) => Promise<TResource | null>;
22
+ };
23
+ set: {
24
+ /**
25
+ * required - find or insert resource (idempotent create)
26
+ */
27
+ finsert: (input: TResource, context: TContext) => Promise<HasMetadata<TResource>>;
28
+ /**
29
+ * optional - create or update resource (idempotent upsert)
30
+ */
31
+ upsert?: (input: TResource, context: TContext) => Promise<HasMetadata<TResource>>;
32
+ /**
33
+ * optional - delete resource
34
+ */
35
+ delete?: (input: Ref<TResourceClass>, context: TContext) => Promise<void>;
36
+ };
37
+ }
38
+ export declare class DeclastructDao<TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext> extends DomainLiteral<DeclastructDao<TResource, TResourceClass, TContext>> implements DeclastructDao<TResource, TResourceClass, TContext> {
39
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeclastructDao = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class DeclastructDao extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.DeclastructDao = DeclastructDao;
8
+ //# sourceMappingURL=DeclastructDao.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeclastructDao.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.ts"],"names":[],"mappings":";;;AAAA,mDAOwB;AA+DxB,MAAa,cAKX,SAAQ,8BAAkE;CACT;AANnE,wCAMmE"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const domain_objects_1 = require("domain-objects");
4
+ describe('DeclastructDao', () => {
5
+ class DemoResource extends domain_objects_1.DomainEntity {
6
+ }
7
+ DemoResource.unique = ['id'];
8
+ it('should implement the interface structure', () => {
9
+ // type verification
10
+ const dao = {
11
+ get: {
12
+ byUnique: async () => null,
13
+ byRef: async () => null,
14
+ },
15
+ set: {
16
+ finsert: async (input) => input,
17
+ },
18
+ };
19
+ expect(dao.get.byUnique).toBeDefined();
20
+ expect(dao.get.byRef).toBeDefined();
21
+ expect(dao.set.finsert).toBeDefined();
22
+ });
23
+ it('should support optional methods', () => {
24
+ // type verification
25
+ const dao = {
26
+ get: {
27
+ byUnique: async () => null,
28
+ byPrimary: async () => null,
29
+ byRef: async () => null,
30
+ },
31
+ set: {
32
+ finsert: async (input) => input,
33
+ upsert: async (input) => input,
34
+ delete: async () => { },
35
+ },
36
+ };
37
+ expect(dao.get.byPrimary).toBeDefined();
38
+ expect(dao.set.upsert).toBeDefined();
39
+ expect(dao.set.delete).toBeDefined();
40
+ });
41
+ });
42
+ //# sourceMappingURL=DeclastructDao.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeclastructDao.test.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.test.ts"],"names":[],"mappings":";;AAAA,mDAA8C;AAI9C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAK9B,MAAM,YACJ,SAAQ,6BAA0B;;IAGpB,mBAAM,GAAG,CAAC,IAAI,CAAU,CAAC;IAGzC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,oBAAoB;QACpB,MAAM,GAAG,GAAsD;YAC7D,GAAG,EAAE;gBACH,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;gBAC1B,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;aACxB;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAY;aACvC;SACF,CAAC;QAEF,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;QACvC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,oBAAoB;QACpB,MAAM,GAAG,GAAsD;YAC7D,GAAG,EAAE;gBACH,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;gBAC1B,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;gBAC3B,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;aACxB;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAY;gBACtC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAY;gBACrC,MAAM,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;aACvB;SACF,CAAC;QAEF,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { DomainEntity } from 'domain-objects';
2
+ import { DeclastructChange } from './DeclastructChange';
3
+ import { IsoTimestamp } from './IsoTimestamp';
4
+ /**
5
+ * .what = collection of all planned changes required to fulfill a wish
6
+ * .why = enables review, version control, and validation of infrastructure changes
7
+ */
8
+ export interface DeclastructPlan {
9
+ /**
10
+ * hash of the proposed changes (for validation on apply)
11
+ */
12
+ hash: string;
13
+ /**
14
+ * timestamp when plan was created
15
+ */
16
+ createdAt: IsoTimestamp;
17
+ /**
18
+ * reference to the wish file
19
+ */
20
+ wish: {
21
+ /**
22
+ * file path URI to the wish file containing resources and providers
23
+ */
24
+ uri: string;
25
+ };
26
+ /**
27
+ * all proposed changes
28
+ */
29
+ changes: DeclastructChange[];
30
+ }
31
+ export declare class DeclastructPlan extends DomainEntity<DeclastructPlan> implements DeclastructPlan {
32
+ static primary: readonly ["hash"];
33
+ static unique: readonly ["hash"];
34
+ static updatable: readonly [];
35
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeclastructPlan = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class DeclastructPlan extends domain_objects_1.DomainEntity {
6
+ }
7
+ exports.DeclastructPlan = DeclastructPlan;
8
+ DeclastructPlan.primary = ['hash'];
9
+ DeclastructPlan.unique = ['hash'];
10
+ DeclastructPlan.updatable = [];
11
+ //# sourceMappingURL=DeclastructPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeclastructPlan.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructPlan.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAoC9C,MAAa,eACX,SAAQ,6BAA6B;;AADvC,0CAOC;AAHe,uBAAO,GAAG,CAAC,MAAM,CAAU,CAAC;AAC5B,sBAAM,GAAG,CAAC,MAAM,CAAU,CAAC;AAC3B,yBAAS,GAAG,EAAW,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const DeclastructPlan_1 = require("./DeclastructPlan");
4
+ describe('DeclastructPlan', () => {
5
+ it('should build a plan with all required properties', () => {
6
+ const plan = new DeclastructPlan_1.DeclastructPlan({
7
+ hash: 'abc123',
8
+ createdAt: '2025-11-22T10:30:00.000Z',
9
+ wish: { uri: '/path/to/wish.ts' },
10
+ changes: [],
11
+ });
12
+ expect(plan.hash).toBe('abc123');
13
+ expect(plan.createdAt).toBe('2025-11-22T10:30:00.000Z');
14
+ expect(plan.wish.uri).toBe('/path/to/wish.ts');
15
+ expect(plan.changes).toEqual([]);
16
+ });
17
+ it('should have unique key set to hash', () => {
18
+ expect(DeclastructPlan_1.DeclastructPlan.unique).toEqual(['hash']);
19
+ });
20
+ it('should extend DomainEntity', () => {
21
+ const plan = new DeclastructPlan_1.DeclastructPlan({
22
+ hash: 'test-hash',
23
+ createdAt: '2025-11-22T10:30:00.000Z',
24
+ wish: { uri: '/test' },
25
+ changes: [],
26
+ });
27
+ // domain entities should have constructor.name
28
+ expect(plan.constructor.name).toBe('DeclastructPlan');
29
+ });
30
+ });
31
+ //# sourceMappingURL=DeclastructPlan.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeclastructPlan.test.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructPlan.test.ts"],"names":[],"mappings":";;AAAA,uDAAoD;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,IAAI,GAAG,IAAI,iCAAe,CAAC;YAC/B,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,0BAA0B;YACrC,IAAI,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE;YACjC,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,iCAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,IAAI,GAAG,IAAI,iCAAe,CAAC;YAC/B,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,0BAA0B;YACrC,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;YACtB,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC;QAEH,+CAA+C;QAC/C,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}