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":"plan.js","sourceRoot":"","sources":["../../../../src/contract/sdk/sync/plan.ts"],"names":[],"mappings":";;;AAKA,sGAAmG;AACnG,oGAAiG;AAEjG;;;;;;;;;;;GAWG;AACI,MAAM,qBAAqB,GAAG,KAAK,EACxC,EAAE,SAAS,EAAsB,EACjC,EACE,SAAS,EACT,GAAG,GAC2D,EACvB,EAAE;IAC3C,2CAA2C;IAC3C,MAAM,OAAO,GAAG,MAAM,IAAA,mDAAwB,EAAC;QAC7C,SAAS;QACT,SAAS;QACT,GAAG;KACJ,CAAC,CAAC;IAEH,qCAAqC;IACrC,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzB,IAAA,mDAAwB,EAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAChD,CACF,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,qBAAqB,yBAoBhC;AAGgC,mBAvBrB,6BAAqB,CAuBQ"}
@@ -1,2 +0,0 @@
1
- import { DomainObject } from 'domain-objects';
2
- export type DeclaredResource<R extends Record<string, any> = {}> = DomainObject<R>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeclaredResource.js","sourceRoot":"","sources":["../../src/domain/DeclaredResource.ts"],"names":[],"mappings":""}
@@ -1,66 +0,0 @@
1
- import { DomainLiteral } from 'domain-objects';
2
- import Joi from 'joi';
3
- export declare enum DeclaredResourceReferenceKeyType {
4
- PRIMARY_KEY = "PRIMARY_KEY",
5
- UNIQUE_KEY = "UNIQUE_KEY"
6
- }
7
- /**
8
- * a value that a declared resource reference identifier specifies to identify the resource
9
- */
10
- export declare class DeclaredResourceReferenceIdentifierValue<V extends Record<string, any>> extends DomainLiteral<V> {
11
- }
12
- /**
13
- * an identifier for a declared resource reference
14
- */
15
- export interface DeclaredResourceReferenceIdentifier<KT extends DeclaredResourceReferenceKeyType, T, K extends keyof T> {
16
- key: KT;
17
- value: Required<Pick<T, K>>;
18
- }
19
- export declare class DeclaredResourceReferenceIdentifier<KT extends DeclaredResourceReferenceKeyType, T, K extends keyof T> extends DomainLiteral<DeclaredResourceReferenceIdentifier<KT, T, K>> implements DeclaredResourceReferenceIdentifier<KT, T, K> {
20
- static nested: {
21
- value: typeof DeclaredResourceReferenceIdentifierValue;
22
- };
23
- }
24
- /**
25
- * a reference to a resource
26
- * - allows reference by primary key (i.e., can specify just the primary)
27
- * - allows reference by unique key (i.e., can specify the unique traits of the entity)
28
- */
29
- export interface DeclaredResourceReference<T,
30
- /**
31
- * the names of the primary key attributes
32
- */
33
- P extends keyof T,
34
- /**
35
- * the names of the unique key attributes
36
- */
37
- U extends keyof T> {
38
- /**
39
- * the class.name of the resource being referenced
40
- */
41
- referenceOf: string;
42
- /**
43
- * the mechanism used to reference
44
- */
45
- identifiedBy: {
46
- key: DeclaredResourceReferenceKeyType.PRIMARY_KEY;
47
- value: Required<Pick<T, P>>;
48
- } | {
49
- key: DeclaredResourceReferenceKeyType.UNIQUE_KEY;
50
- value: Required<Pick<T, U>>;
51
- };
52
- }
53
- export declare class DeclaredResourceReference<T,
54
- /**
55
- * the names of the primary key attributes
56
- */
57
- P extends keyof T,
58
- /**
59
- * the names of the unique key attributes
60
- */
61
- U extends keyof T> extends DomainLiteral<DeclaredResourceReference<T, P, U>> implements DeclaredResourceReference<T, P, U> {
62
- static schema: Joi.AlternativesSchema<any>;
63
- static nested: {
64
- identifiedBy: typeof DeclaredResourceReferenceIdentifier;
65
- };
66
- }
@@ -1,42 +0,0 @@
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
- exports.DeclaredResourceReference = exports.DeclaredResourceReferenceIdentifier = exports.DeclaredResourceReferenceIdentifierValue = exports.DeclaredResourceReferenceKeyType = void 0;
7
- const domain_objects_1 = require("domain-objects");
8
- const joi_1 = __importDefault(require("joi"));
9
- var DeclaredResourceReferenceKeyType;
10
- (function (DeclaredResourceReferenceKeyType) {
11
- DeclaredResourceReferenceKeyType["PRIMARY_KEY"] = "PRIMARY_KEY";
12
- DeclaredResourceReferenceKeyType["UNIQUE_KEY"] = "UNIQUE_KEY";
13
- })(DeclaredResourceReferenceKeyType || (exports.DeclaredResourceReferenceKeyType = DeclaredResourceReferenceKeyType = {}));
14
- /**
15
- * a value that a declared resource reference identifier specifies to identify the resource
16
- */
17
- class DeclaredResourceReferenceIdentifierValue extends domain_objects_1.DomainLiteral {
18
- }
19
- exports.DeclaredResourceReferenceIdentifierValue = DeclaredResourceReferenceIdentifierValue;
20
- class DeclaredResourceReferenceIdentifier extends domain_objects_1.DomainLiteral {
21
- }
22
- exports.DeclaredResourceReferenceIdentifier = DeclaredResourceReferenceIdentifier;
23
- DeclaredResourceReferenceIdentifier.nested = { value: DeclaredResourceReferenceIdentifierValue };
24
- const schema = joi_1.default.alternatives(joi_1.default.object().keys({
25
- _dobj: joi_1.default.string().optional(), // may be specified if hydrating from serialized form (e.g., a cache)
26
- referenceOf: joi_1.default.string().required(),
27
- identifiedBy: joi_1.default.object().keys({
28
- _dobj: joi_1.default.string().optional(), // may be specified if hydrating from serialized form (e.g., a cache)
29
- key: joi_1.default.string()
30
- .valid(...Object.values(DeclaredResourceReferenceKeyType))
31
- .required(),
32
- value: joi_1.default.object(),
33
- }),
34
- }), joi_1.default.string().required());
35
- class DeclaredResourceReference extends domain_objects_1.DomainLiteral {
36
- }
37
- exports.DeclaredResourceReference = DeclaredResourceReference;
38
- DeclaredResourceReference.schema = schema;
39
- DeclaredResourceReference.nested = {
40
- identifiedBy: DeclaredResourceReferenceIdentifier,
41
- };
42
- //# sourceMappingURL=DeclaredResourceReference.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeclaredResourceReference.js","sourceRoot":"","sources":["../../src/domain/DeclaredResourceReference.ts"],"names":[],"mappings":";;;;;;AAAA,mDAA+C;AAC/C,8CAAsB;AAEtB,IAAY,gCAGX;AAHD,WAAY,gCAAgC;IAC1C,+DAA2B,CAAA;IAC3B,6DAAyB,CAAA;AAC3B,CAAC,EAHW,gCAAgC,gDAAhC,gCAAgC,QAG3C;AAED;;GAEG;AACH,MAAa,wCAEX,SAAQ,8BAAgB;CAAG;AAF7B,4FAE6B;AAa7B,MAAa,mCAKX,SAAQ,8BAA4D;;AALtE,kFASC;AADe,0CAAM,GAAG,EAAE,KAAK,EAAE,wCAAwC,EAAE,CAAC;AAG7E,MAAM,MAAM,GAAG,aAAG,CAAC,YAAY,CAC7B,aAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;IAChB,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,qEAAqE;IACrG,WAAW,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,YAAY,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QAC9B,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,qEAAqE;QACrG,GAAG,EAAE,aAAG,CAAC,MAAM,EAAE;aACd,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;aACzD,QAAQ,EAAE;QACb,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE;KACpB,CAAC;CACH,CAAC,EACF,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CACxB,CAAC;AA+CF,MAAa,yBAWX,SAAQ,8BAAiD;;AAX3D,8DAkBC;AAJe,gCAAM,GAAG,MAAM,CAAC;AAChB,gCAAM,GAAG;IACrB,YAAY,EAAE,mCAAmC;CAClD,CAAC"}
@@ -1,61 +0,0 @@
1
- import { DomainObject } from 'domain-objects';
2
- import { DeclaredResource } from './DeclaredResource';
3
- /**
4
- * an action that can be proposed
5
- */
6
- export declare enum DeclastructChangeProposalAction {
7
- /**
8
- * do nothing, the resource is already in the desired state
9
- */
10
- DO_NOTHING = "DO_NOTHING",
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
25
- *
26
- * note
27
- * - this is a `delete` followed by a `create`
28
- */
29
- REPLACE = "REPLACE"
30
- }
31
- /**
32
- * a change that declastruct has proposed in order to update the remote state to reflect the declared state
33
- */
34
- export interface DeclastructChangeProposal<R extends DeclaredResource> {
35
- /**
36
- * the name of the class of resource this proposal is for
37
- */
38
- forResourceClassName: string;
39
- /**
40
- * the grokable identity string of the resource this proposal is for
41
- */
42
- forGrokableIdentifier: string;
43
- /**
44
- * the remote-state the resource is currently in, from which we will be changing it
45
- */
46
- fromRemoteState: R | null;
47
- /**
48
- * the desired-state the resource should be in, to which we will be changing it
49
- */
50
- toDesiredState: R | null;
51
- /**
52
- * the action we plan to execute in order to fulfil this proposed change
53
- */
54
- action: DeclastructChangeProposalAction;
55
- /**
56
- * the displayable difference made by the change
57
- */
58
- difference: string | null;
59
- }
60
- export declare class DeclastructChangeProposal<R extends DeclaredResource> extends DomainObject<DeclastructChangeProposal<R>> implements DeclastructChangeProposal<R> {
61
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeclastructChangeProposal = exports.DeclastructChangeProposalAction = void 0;
4
- const domain_objects_1 = require("domain-objects");
5
- /**
6
- * an action that can be proposed
7
- */
8
- var DeclastructChangeProposalAction;
9
- (function (DeclastructChangeProposalAction) {
10
- /**
11
- * do nothing, the resource is already in the desired state
12
- */
13
- DeclastructChangeProposalAction["DO_NOTHING"] = "DO_NOTHING";
14
- /**
15
- * create a new resource
16
- */
17
- DeclastructChangeProposalAction["CREATE"] = "CREATE";
18
- /**
19
- * update an existing resource
20
- */
21
- DeclastructChangeProposalAction["UPDATE"] = "UPDATE";
22
- /**
23
- * destroy an existing resource
24
- */
25
- DeclastructChangeProposalAction["DESTROY"] = "DESTROY";
26
- /**
27
- * replace an existing resource
28
- *
29
- * note
30
- * - this is a `delete` followed by a `create`
31
- */
32
- DeclastructChangeProposalAction["REPLACE"] = "REPLACE";
33
- })(DeclastructChangeProposalAction || (exports.DeclastructChangeProposalAction = DeclastructChangeProposalAction = {}));
34
- class DeclastructChangeProposal extends domain_objects_1.DomainObject {
35
- }
36
- exports.DeclastructChangeProposal = DeclastructChangeProposal;
37
- //# sourceMappingURL=DeclastructChangeProposal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeclastructChangeProposal.js","sourceRoot":"","sources":["../../src/domain/DeclastructChangeProposal.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAI9C;;GAEG;AACH,IAAY,+BA4BX;AA5BD,WAAY,+BAA+B;IACzC;;OAEG;IACH,4DAAyB,CAAA;IAEzB;;OAEG;IACH,oDAAiB,CAAA;IAEjB;;OAEG;IACH,oDAAiB,CAAA;IAEjB;;OAEG;IACH,sDAAmB,CAAA;IAEnB;;;;;OAKG;IACH,sDAAmB,CAAA;AACrB,CAAC,EA5BW,+BAA+B,+CAA/B,+BAA+B,QA4B1C;AAqCD,MAAa,yBACX,SAAQ,6BAA0C;CACR;AAF5C,8DAE4C"}
@@ -1,24 +0,0 @@
1
- import type { LogMethods } from 'simple-leveled-log-methods';
2
- import { DeclaredResource } from './DeclaredResource';
3
- import { DeclastructProvider } from './DeclastructProvider';
4
- /**
5
- * the declastruct context defines all of the providers and resources declared by the user
6
- *
7
- * note:
8
- * - this is the global context available to declastruct methods
9
- * - this is _not_ the provider context available to provider methods
10
- */
11
- export interface DeclastructContext {
12
- /**
13
- * the providers loaded by the user
14
- */
15
- providers: DeclastructProvider<any>[];
16
- /**
17
- * all of the resources declared by the user
18
- */
19
- resources: DeclaredResource[];
20
- /**
21
- * the log context to use
22
- */
23
- log: LogMethods;
24
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeclastructContext.js","sourceRoot":"","sources":["../../src/domain/DeclastructContext.ts"],"names":[],"mappings":""}
@@ -1,58 +0,0 @@
1
- import type { LogMethods } from 'simple-leveled-log-methods';
2
- import { DeclaredResource } from './DeclaredResource';
3
- import { DeclastructProviderContext } from './DeclastructProviderContext';
4
- import { DeclastructProviderResourceRemoteStateInterface } from './DeclastructProviderResourceRemoteStateInterface';
5
- /**
6
- * the class name of a declared resource
7
- *
8
- * note
9
- * - it is just a string, but we distinguish it with its own type for clarity when defining other types
10
- */
11
- export type DeclaredResourceClassName = string;
12
- /**
13
- * agent options can take any shape
14
- *
15
- * typically, agent options include
16
- * - credentials
17
- * - caching mechanisms
18
- * - request throttling mechanisms
19
- */
20
- export type DeclastructProviderAgentOptions = {
21
- log: LogMethods;
22
- };
23
- /**
24
- * a provider exposes the agent, interfaces, and resource definitions required to declaratively manage resources
25
- */
26
- export interface DeclastructProvider<AO extends DeclastructProviderAgentOptions> {
27
- /**
28
- * defines the options available to agents of this provider
29
- *
30
- * relevance
31
- * - agents act on the behalf of the user to manage their resources
32
- * - typically, agent options include
33
- * - credentials
34
- * - caching mechanisms
35
- * - request throttling mechanisms
36
- */
37
- agentOptions: AO;
38
- /**
39
- * defines the interfaces exposed by the provider for managing the remote state of resources
40
- *
41
- * note
42
- * - specified as a "name" to "interface" lookup table, for convenient usage
43
- */
44
- interfaces: Record<DeclaredResourceClassName, DeclastructProviderResourceRemoteStateInterface<DeclaredResource, DeclastructProviderContext<AO>, keyof DeclaredResource, keyof DeclaredResource>>;
45
- /**
46
- * defines hooks that we should execute in conjunction with managing resources
47
- */
48
- hooks: {
49
- /**
50
- * a hook to run before any operations for this provider
51
- */
52
- beforeAll?: () => {};
53
- /**
54
- * a hook to run after all operations for this provider
55
- */
56
- afterAll?: () => {};
57
- };
58
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=DeclastructProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeclastructProvider.js","sourceRoot":"","sources":["../../src/domain/DeclastructProvider.ts"],"names":[],"mappings":""}
@@ -1,30 +0,0 @@
1
- import type { LogMethods } from 'simple-leveled-log-methods';
2
- import { DeclaredResource } from './DeclaredResource';
3
- import { DeclastructProvider, DeclastructProviderAgentOptions } from './DeclastructProvider';
4
- /**
5
- * defines the context in which declastruct is being run, accessible a provider
6
- *
7
- * specifically
8
- * - the options that were inititialized for the provider
9
- * - the resources that were defined for the provider
10
- *
11
- * note
12
- * - we do not expose the full declastruct context to any provider for security
13
- * - i.e., ProviderA will never be able to see context related to ProviderB
14
- * - otherwise, MaliciousProvider may be able to access the credentials defined for CriticalProvider, and steal them
15
- * - therefore, only the information explicitly given by the user to ProviderA is accessible to ProviderA
16
- */
17
- export interface DeclastructProviderContext<AO extends DeclastructProviderAgentOptions> {
18
- /**
19
- * the options instantiated for the provider itself
20
- */
21
- provider: DeclastructProvider<AO>;
22
- /**
23
- * the resources for this provider that were declared in this invocation
24
- */
25
- resources?: DeclaredResource[];
26
- /**
27
- * the log context to use
28
- */
29
- log: LogMethods;
30
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=DeclastructProviderContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeclastructProviderContext.js","sourceRoot":"","sources":["../../src/domain/DeclastructProviderContext.ts"],"names":[],"mappings":""}
@@ -1,156 +0,0 @@
1
- import { PickOne } from 'type-fns';
2
- import { DeclaredResource } from './DeclaredResource';
3
- import { DeclaredResourceClassName, DeclastructProviderAgentOptions } from './DeclastructProvider';
4
- import { DeclastructProviderContext } from './DeclastructProviderContext';
5
- /**
6
- * an interface which enables the management of the remote state of a resource
7
- * - capable of crud operations on the resource
8
- * - conforms to a standard shape for interoperability
9
- */
10
- export interface DeclastructProviderResourceRemoteStateInterface<
11
- /**
12
- * the class of resource being managed by this dao
13
- */
14
- R extends DeclaredResource,
15
- /**
16
- * the shape of options given to the agent of this resource's provider
17
- */
18
- AO extends DeclastructProviderAgentOptions,
19
- /**
20
- * the names of the primary key attributes
21
- */
22
- P extends keyof R,
23
- /**
24
- * the names of the unique key attributes
25
- */
26
- U extends keyof R,
27
- /**
28
- * the shape of the resources search filter options
29
- */
30
- F extends undefined | null | Record<string, any> = undefined,
31
- /**
32
- * the shape of the resources search sort options
33
- */
34
- S extends undefined | Record<string, any | null> = undefined> {
35
- /**
36
- * the name of the resource this interface manages
37
- */
38
- for: DeclaredResourceClassName;
39
- /**
40
- * a method capable of finding the state of a resource of this class, by primary-key
41
- */
42
- findByPrimary: (
43
- /**
44
- * the primary key to lookup the resource by
45
- */
46
- primary: Required<Pick<R, P>>,
47
- /**
48
- * the declastruct context available to interfaces of this provider
49
- */
50
- context: DeclastructProviderContext<AO>) => Promise<Required<R> | null>;
51
- /**
52
- * a method capable of finding the state of a resource of this class, by unique-key
53
- */
54
- findByUnique: (
55
- /**
56
- * the unique key to lookup the resource by
57
- */
58
- unique: Required<Pick<R, U>>,
59
- /**
60
- * the declastruct context available to interfaces of this provider
61
- */
62
- context: DeclastructProviderContext<AO>) => Promise<Required<R> | null>;
63
- /**
64
- * a method capable of finding all instances of a resource of this class, by some filtering criteria
65
- *
66
- * note
67
- * - may not be supported if search is not possible
68
- */
69
- findAll?: (
70
- /**
71
- * the criteria to search with
72
- */
73
- criteria: {
74
- /**
75
- * what to filter the results to list by
76
- *
77
- * note
78
- * - if null is supported and specified, no filter will be applied
79
- */
80
- filter: F;
81
- /**
82
- * what to sort the results by
83
- *
84
- * note
85
- * - this dictates the order of results
86
- * - this dictates the offset key for pagination
87
- *
88
- * tip
89
- * - if you're seeing "never" when trying to use this, please make sure you're using the instantiated type of the resource, not the generic type
90
- */
91
- sort: PickOne<{
92
- /**
93
- * descending sort
94
- */
95
- until: S;
96
- /**
97
- * ascending sort
98
- */
99
- since: S;
100
- }>;
101
- /**
102
- * how many results to return
103
- *
104
- * note
105
- * - combine this with the sort option to paginate results
106
- */
107
- limit: number;
108
- },
109
- /**
110
- * the declastruct context available to interfaces of this provider
111
- */
112
- context: DeclastructProviderContext<AO>) => Promise<Required<R>[]>;
113
- /**
114
- * a method capable of creating a resource of this class
115
- */
116
- create: (
117
- /**
118
- * the state we want to create the resource with
119
- */
120
- resource: R,
121
- /**
122
- * the declastruct context available to interfaces of this provider
123
- */
124
- context: DeclastructProviderContext<AO>) => Promise<Required<R>>;
125
- /**
126
- * a method capable of destroying a resource of this class
127
- */
128
- destroy: (
129
- /**
130
- * the primary key of the resource we want to destroy
131
- */
132
- primary: Required<Pick<R, P>>,
133
- /**
134
- * the declastruct context available to interfaces of this provider
135
- */
136
- context: DeclastructProviderContext<AO>) => Promise<Required<R>>;
137
- /**
138
- * a method capable of creating a resource of this class
139
- *
140
- * note
141
- * - may not be supported if resource is immutable
142
- */
143
- update?: (
144
- /**
145
- * the state we want to update the resource to
146
- *
147
- * note
148
- * - either primary or unique key must be defined
149
- * - any updatable keys defined will be persisted
150
- */
151
- resource: R,
152
- /**
153
- * the declastruct context available to interfaces of this provider
154
- */
155
- context: DeclastructProviderContext<AO>) => Promise<Required<R>>;
156
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=DeclastructProviderResourceRemoteStateInterface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeclastructProviderResourceRemoteStateInterface.js","sourceRoot":"","sources":["../../src/domain/DeclastructProviderResourceRemoteStateInterface.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { DomainEntity } from 'domain-objects';
2
- import { DeclastructContext } from '../../../domain/DeclastructContext';
3
- export declare const canUpdateResource: <R extends DomainEntity<any>>({ resource }: {
4
- resource: R;
5
- }, context: DeclastructContext) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canUpdateResource = void 0;
4
- const getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource_1 = require("../../tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource");
5
- const canUpdateResource = ({ resource }, context) => {
6
- // grab the interface for the resource
7
- const { remoteStateInterface } = (0, getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource_1.getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource)({ resource }, context);
8
- // check if it has defined the update method
9
- return !!remoteStateInterface.update;
10
- };
11
- exports.canUpdateResource = canUpdateResource;
12
- //# sourceMappingURL=canUpdateResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canUpdateResource.js","sourceRoot":"","sources":["../../../../src/logic/actions/execute/canUpdateResource.ts"],"names":[],"mappings":";;;AAGA,0LAAuL;AAEhL,MAAM,iBAAiB,GAAG,CAC/B,EAAE,QAAQ,EAAmB,EAC7B,OAA2B,EAClB,EAAE;IACX,sCAAsC;IACtC,MAAM,EAAE,oBAAoB,EAAE,GAC5B,IAAA,iJAAuE,EACrE,EAAE,QAAQ,EAAE,EACZ,OAAO,CACR,CAAC;IAEJ,4CAA4C;IAC5C,OAAO,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC;AACvC,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B"}
@@ -1,5 +0,0 @@
1
- import { DeclastructChangeProposal } from '../../../domain/DeclastructChangeProposal';
2
- import { DeclastructContext } from '../../../domain/DeclastructContext';
3
- export declare const executeProposal: ({ proposal }: {
4
- proposal: DeclastructChangeProposal<any>;
5
- }, context: DeclastructContext) => Promise<Required<any>>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeProposal = void 0;
4
- const error_fns_1 = require("@ehmpathy/error-fns");
5
- const DeclastructChangeProposal_1 = require("../../../domain/DeclastructChangeProposal");
6
- const getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource_1 = require("../../tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource");
7
- const executeProposal = async ({ proposal }, context) => {
8
- // grab the interface and context for the resource
9
- const { remoteStateInterface, providerContext } = (0, getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource_1.getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource)({ resource: proposal.toDesiredState ?? proposal.fromRemoteState }, context);
10
- // if the proposed action was to do nothing, just return its current state
11
- if (proposal.action === DeclastructChangeProposal_1.DeclastructChangeProposalAction.DO_NOTHING) {
12
- // look up the resource
13
- const found = await remoteStateInterface.findByUnique(proposal.toDesiredState, providerContext);
14
- // sanity check that the resource does really exist
15
- if (!found)
16
- throw new error_fns_1.UnexpectedCodePathError('proposal was to do nothing but resource does not exist. how is that possible?', { proposal, found });
17
- // return the state of the resource
18
- return found;
19
- }
20
- // if the proposed action was to create it, create it
21
- if (proposal.action === DeclastructChangeProposal_1.DeclastructChangeProposalAction.CREATE) {
22
- // sanity check that the entity does not already exist
23
- const found = await remoteStateInterface.findByUnique(proposal.toDesiredState, providerContext);
24
- if (found) {
25
- // done if already found it, we must have created it as part of another operation (or the plan was wrong)
26
- // console.log(' * found this resource by unique instead of creating it');
27
- return found;
28
- }
29
- // create it
30
- await remoteStateInterface.create(proposal.toDesiredState, providerContext);
31
- // prove we can find it now
32
- const foundNow = await remoteStateInterface.findByUnique(proposal.toDesiredState, providerContext);
33
- if (!foundNow)
34
- throw new error_fns_1.UnexpectedCodePathError('could not find resource after creating it', {
35
- forClassName: proposal.forResourceClassName,
36
- forGrokableIdentifier: proposal.forGrokableIdentifier,
37
- });
38
- return foundNow;
39
- }
40
- // if the proposed action was to update it, update it
41
- if (proposal.action === DeclastructChangeProposal_1.DeclastructChangeProposalAction.UPDATE) {
42
- if (!remoteStateInterface.update)
43
- throw new error_fns_1.UnexpectedCodePathError(`should not have attempted to update a resource who's remote state interface does not support updates`, { resourceClassName: proposal.forResourceClassName });
44
- return await remoteStateInterface.update(proposal.toDesiredState, providerContext);
45
- }
46
- // otherwise, throw an error, since we couldn't handle it
47
- throw new error_fns_1.UnexpectedCodePathError('unsupported proposal action', {
48
- proposal,
49
- });
50
- };
51
- exports.executeProposal = executeProposal;
52
- //# sourceMappingURL=executeProposal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executeProposal.js","sourceRoot":"","sources":["../../../../src/logic/actions/execute/executeProposal.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAE9D,yFAGmD;AAEnD,0LAAuL;AAEhL,MAAM,eAAe,GAAG,KAAK,EAClC,EAAE,QAAQ,EAAgD,EAC1D,OAA2B,EAC3B,EAAE;IACF,kDAAkD;IAClD,MAAM,EAAE,oBAAoB,EAAE,eAAe,EAAE,GAC7C,IAAA,iJAAuE,EACrE,EAAE,QAAQ,EAAE,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,eAAe,EAAE,EACjE,OAAO,CACR,CAAC;IAEJ,0EAA0E;IAC1E,IAAI,QAAQ,CAAC,MAAM,KAAK,2DAA+B,CAAC,UAAU,EAAE,CAAC;QACnE,uBAAuB;QACvB,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,YAAY,CACnD,QAAQ,CAAC,cAAc,EACvB,eAAe,CAChB,CAAC;QAEF,mDAAmD;QACnD,IAAI,CAAC,KAAK;YACR,MAAM,IAAI,mCAAuB,CAC/B,+EAA+E,EAC/E,EAAE,QAAQ,EAAE,KAAK,EAAE,CACpB,CAAC;QAEJ,mCAAmC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,qDAAqD;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,2DAA+B,CAAC,MAAM,EAAE,CAAC;QAC/D,sDAAsD;QACtD,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,YAAY,CACnD,QAAQ,CAAC,cAAc,EACvB,eAAe,CAChB,CAAC;QACF,IAAI,KAAK,EAAE,CAAC;YACV,yGAAyG;YACzG,6EAA6E;YAC7E,OAAO,KAAK,CAAC;QACf,CAAC;QAED,YAAY;QACZ,MAAM,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;QAE5E,2BAA2B;QAC3B,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,YAAY,CACtD,QAAQ,CAAC,cAAc,EACvB,eAAe,CAChB,CAAC;QACF,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,mCAAuB,CAC/B,2CAA2C,EAC3C;gBACE,YAAY,EAAE,QAAQ,CAAC,oBAAoB;gBAC3C,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB;aACtD,CACF,CAAC;QACJ,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,qDAAqD;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,2DAA+B,CAAC,MAAM,EAAE,CAAC;QAC/D,IAAI,CAAC,oBAAoB,CAAC,MAAM;YAC9B,MAAM,IAAI,mCAAuB,CAC/B,sGAAsG,EACtG,EAAE,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CACrD,CAAC;QACJ,OAAO,MAAM,oBAAoB,CAAC,MAAM,CACtC,QAAQ,CAAC,cAAc,EACvB,eAAe,CAChB,CAAC;IACJ,CAAC;IAED,yDAAyD;IACzD,MAAM,IAAI,mCAAuB,CAAC,6BAA6B,EAAE;QAC/D,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CAAC;AA/EW,QAAA,eAAe,mBA+E1B"}
@@ -1,4 +0,0 @@
1
- import { DeclastructChangeProposalAction } from '../../../domain/DeclastructChangeProposal';
2
- export declare const getColoredActionToken: ({ action, }: {
3
- action: DeclastructChangeProposalAction;
4
- }) => string;
@@ -1,22 +0,0 @@
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
- exports.getColoredActionToken = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const DeclastructChangeProposal_1 = require("../../../domain/DeclastructChangeProposal");
9
- const getColoredActionToken = ({ action, }) => {
10
- // define action color
11
- const actionChalk = {
12
- [DeclastructChangeProposal_1.DeclastructChangeProposalAction.CREATE]: chalk_1.default.green,
13
- [DeclastructChangeProposal_1.DeclastructChangeProposalAction.DO_NOTHING]: chalk_1.default.gray,
14
- [DeclastructChangeProposal_1.DeclastructChangeProposalAction.UPDATE]: chalk_1.default.yellow,
15
- [DeclastructChangeProposal_1.DeclastructChangeProposalAction.REPLACE]: chalk_1.default.red,
16
- [DeclastructChangeProposal_1.DeclastructChangeProposalAction.DESTROY]: chalk_1.default.red,
17
- }[action];
18
- // return the token
19
- return chalk_1.default.bold(actionChalk(`[${action}]`));
20
- };
21
- exports.getColoredActionToken = getColoredActionToken;
22
- //# sourceMappingURL=getColoredActionToken.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getColoredActionToken.js","sourceRoot":"","sources":["../../../../src/logic/actions/propose/getColoredActionToken.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,yFAA4F;AAErF,MAAM,qBAAqB,GAAG,CAAC,EACpC,MAAM,GAGP,EAAE,EAAE;IACH,sBAAsB;IACtB,MAAM,WAAW,GAAG;QAClB,CAAC,2DAA+B,CAAC,MAAM,CAAC,EAAE,eAAK,CAAC,KAAK;QACrD,CAAC,2DAA+B,CAAC,UAAU,CAAC,EAAE,eAAK,CAAC,IAAI;QACxD,CAAC,2DAA+B,CAAC,MAAM,CAAC,EAAE,eAAK,CAAC,MAAM;QACtD,CAAC,2DAA+B,CAAC,OAAO,CAAC,EAAE,eAAK,CAAC,GAAG;QACpD,CAAC,2DAA+B,CAAC,OAAO,CAAC,EAAE,eAAK,CAAC,GAAG;KACrD,CAAC,MAAM,CAAC,CAAC;IAEV,mBAAmB;IACnB,OAAO,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC;AAhBW,QAAA,qBAAqB,yBAgBhC"}