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.
- package/dist/.test/assets/providers/demo.provider.d.ts +32 -0
- package/dist/.test/assets/providers/demo.provider.js +101 -0
- package/dist/.test/assets/providers/demo.provider.js.map +1 -0
- package/dist/contract/cli/apply.d.ts +9 -0
- package/dist/contract/cli/apply.integration.test.js +148 -0
- package/dist/contract/cli/apply.integration.test.js.map +1 -0
- package/dist/contract/cli/apply.js +90 -0
- package/dist/contract/cli/apply.js.map +1 -0
- package/dist/contract/cli/invoke.d.ts +8 -0
- package/dist/contract/cli/invoke.js +58 -0
- package/dist/contract/cli/invoke.js.map +1 -0
- package/dist/contract/cli/plan.d.ts +10 -0
- package/dist/contract/cli/plan.integration.test.js +107 -0
- package/dist/contract/cli/plan.integration.test.js.map +1 -0
- package/dist/contract/cli/plan.js +94 -0
- package/dist/contract/cli/plan.js.map +1 -0
- package/dist/contract/sdk/index.d.ts +15 -3
- package/dist/contract/sdk/index.js +31 -17
- package/dist/contract/sdk/index.js.map +1 -1
- package/dist/domain.objects/ContextDeclastruct.d.ts +15 -0
- package/dist/{domain/DeclastructContext.js → domain.objects/ContextDeclastruct.js} +1 -1
- package/dist/domain.objects/ContextDeclastruct.js.map +1 -0
- package/dist/domain.objects/ContextDeclastruct.test.js +41 -0
- package/dist/domain.objects/ContextDeclastruct.test.js.map +1 -0
- package/dist/domain.objects/DeclastructChange.d.ts +73 -0
- package/dist/domain.objects/DeclastructChange.js +35 -0
- package/dist/domain.objects/DeclastructChange.js.map +1 -0
- package/dist/domain.objects/DeclastructChange.test.js +59 -0
- package/dist/domain.objects/DeclastructChange.test.js.map +1 -0
- package/dist/domain.objects/DeclastructDao.d.ts +39 -0
- package/dist/domain.objects/DeclastructDao.js +8 -0
- package/dist/domain.objects/DeclastructDao.js.map +1 -0
- package/dist/domain.objects/DeclastructDao.test.js +42 -0
- package/dist/domain.objects/DeclastructDao.test.js.map +1 -0
- package/dist/domain.objects/DeclastructPlan.d.ts +35 -0
- package/dist/domain.objects/DeclastructPlan.js +11 -0
- package/dist/domain.objects/DeclastructPlan.js.map +1 -0
- package/dist/domain.objects/DeclastructPlan.test.js +31 -0
- package/dist/domain.objects/DeclastructPlan.test.js.map +1 -0
- package/dist/domain.objects/DeclastructProvider.d.ts +30 -0
- package/dist/domain.objects/DeclastructProvider.js +8 -0
- package/dist/domain.objects/DeclastructProvider.js.map +1 -0
- package/dist/domain.objects/DeclastructProvider.test.js +35 -0
- package/dist/domain.objects/DeclastructProvider.test.js.map +1 -0
- package/dist/domain.objects/IsoTimestamp.d.ts +6 -0
- package/dist/{domain/DeclaredResource.js → domain.objects/IsoTimestamp.js} +1 -1
- package/dist/domain.objects/IsoTimestamp.js.map +1 -0
- package/dist/domain.objects/IsoTimestamp.test.js +10 -0
- package/dist/domain.objects/IsoTimestamp.test.js.map +1 -0
- package/dist/domain.operations/apply/applyChange.d.ts +14 -0
- package/dist/domain.operations/apply/applyChange.js +64 -0
- package/dist/domain.operations/apply/applyChange.js.map +1 -0
- package/dist/domain.operations/apply/applyChange.test.d.ts +1 -0
- package/dist/domain.operations/apply/applyChange.test.js +247 -0
- package/dist/domain.operations/apply/applyChange.test.js.map +1 -0
- package/dist/domain.operations/apply/applyChanges.d.ts +18 -0
- package/dist/domain.operations/apply/applyChanges.integration.test.d.ts +1 -0
- package/dist/domain.operations/apply/applyChanges.integration.test.js +291 -0
- package/dist/domain.operations/apply/applyChanges.integration.test.js.map +1 -0
- package/dist/domain.operations/apply/applyChanges.js +53 -0
- package/dist/domain.operations/apply/applyChanges.js.map +1 -0
- package/dist/domain.operations/plan/computeChange.d.ts +11 -0
- package/dist/domain.operations/plan/computeChange.js +78 -0
- package/dist/domain.operations/plan/computeChange.js.map +1 -0
- package/dist/domain.operations/plan/computeChange.test.d.ts +1 -0
- package/dist/domain.operations/plan/computeChange.test.js +67 -0
- package/dist/domain.operations/plan/computeChange.test.js.map +1 -0
- package/dist/domain.operations/plan/extractResourcesFromPlan.d.ts +8 -0
- package/dist/domain.operations/plan/extractResourcesFromPlan.js +17 -0
- package/dist/domain.operations/plan/extractResourcesFromPlan.js.map +1 -0
- package/dist/domain.operations/plan/getDaoByResource.d.ts +12 -0
- package/dist/domain.operations/plan/getDaoByResource.js +41 -0
- package/dist/domain.operations/plan/getDaoByResource.js.map +1 -0
- package/dist/domain.operations/plan/getDaoByResource.test.d.ts +1 -0
- package/dist/domain.operations/plan/getDaoByResource.test.js +99 -0
- package/dist/domain.operations/plan/getDaoByResource.test.js.map +1 -0
- package/dist/domain.operations/plan/hashChanges.d.ts +7 -0
- package/dist/domain.operations/plan/hashChanges.js +18 -0
- package/dist/domain.operations/plan/hashChanges.js.map +1 -0
- package/dist/domain.operations/plan/planChanges.d.ts +15 -0
- package/dist/domain.operations/plan/planChanges.integration.test.d.ts +1 -0
- package/dist/domain.operations/plan/planChanges.integration.test.js +197 -0
- package/dist/domain.operations/plan/planChanges.integration.test.js.map +1 -0
- package/dist/domain.operations/plan/planChanges.js +50 -0
- package/dist/domain.operations/plan/planChanges.js.map +1 -0
- package/dist/domain.operations/plan/validate.d.ts +10 -0
- package/dist/domain.operations/plan/validate.js +21 -0
- package/dist/domain.operations/plan/validate.js.map +1 -0
- package/dist/infra/asIsoTimestamp.d.ts +6 -0
- package/dist/infra/asIsoTimestamp.js +12 -0
- package/dist/infra/asIsoTimestamp.js.map +1 -0
- package/package.json +8 -15
- package/readme.md +225 -29
- package/dist/__test_assets__/getExampleContext.d.ts +0 -33
- package/dist/__test_assets__/getExampleContext.js +0 -87
- package/dist/__test_assets__/getExampleContext.js.map +0 -1
- package/dist/contract/commands/command.apply.d.ts +0 -6
- package/dist/contract/commands/command.apply.js +0 -20
- package/dist/contract/commands/command.apply.js.map +0 -1
- package/dist/contract/commands/command.plan.d.ts +0 -6
- package/dist/contract/commands/command.plan.js +0 -20
- package/dist/contract/commands/command.plan.js.map +0 -1
- package/dist/contract/commands/utils/resolveCommandInputs.d.ts +0 -17
- package/dist/contract/commands/utils/resolveCommandInputs.js +0 -23
- package/dist/contract/commands/utils/resolveCommandInputs.js.map +0 -1
- package/dist/contract/sdk/refs.d.ts +0 -2
- package/dist/contract/sdk/refs.js +0 -19
- package/dist/contract/sdk/refs.js.map +0 -1
- package/dist/contract/sdk/sync/apply.d.ts +0 -22
- package/dist/contract/sdk/sync/apply.js +0 -29
- package/dist/contract/sdk/sync/apply.js.map +0 -1
- package/dist/contract/sdk/sync/plan.d.ts +0 -22
- package/dist/contract/sdk/sync/plan.js +0 -30
- package/dist/contract/sdk/sync/plan.js.map +0 -1
- package/dist/domain/DeclaredResource.d.ts +0 -2
- package/dist/domain/DeclaredResource.js.map +0 -1
- package/dist/domain/DeclaredResourceReference.d.ts +0 -66
- package/dist/domain/DeclaredResourceReference.js +0 -42
- package/dist/domain/DeclaredResourceReference.js.map +0 -1
- package/dist/domain/DeclastructChangeProposal.d.ts +0 -61
- package/dist/domain/DeclastructChangeProposal.js +0 -37
- package/dist/domain/DeclastructChangeProposal.js.map +0 -1
- package/dist/domain/DeclastructContext.d.ts +0 -24
- package/dist/domain/DeclastructContext.js.map +0 -1
- package/dist/domain/DeclastructProvider.d.ts +0 -58
- package/dist/domain/DeclastructProvider.js +0 -3
- package/dist/domain/DeclastructProvider.js.map +0 -1
- package/dist/domain/DeclastructProviderContext.d.ts +0 -30
- package/dist/domain/DeclastructProviderContext.js +0 -3
- package/dist/domain/DeclastructProviderContext.js.map +0 -1
- package/dist/domain/DeclastructProviderResourceRemoteStateInterface.d.ts +0 -156
- package/dist/domain/DeclastructProviderResourceRemoteStateInterface.js +0 -3
- package/dist/domain/DeclastructProviderResourceRemoteStateInterface.js.map +0 -1
- package/dist/logic/actions/execute/canUpdateResource.d.ts +0 -5
- package/dist/logic/actions/execute/canUpdateResource.js +0 -12
- package/dist/logic/actions/execute/canUpdateResource.js.map +0 -1
- package/dist/logic/actions/execute/executeProposal.d.ts +0 -5
- package/dist/logic/actions/execute/executeProposal.js +0 -52
- package/dist/logic/actions/execute/executeProposal.js.map +0 -1
- package/dist/logic/actions/propose/getColoredActionToken.d.ts +0 -4
- package/dist/logic/actions/propose/getColoredActionToken.js +0 -22
- package/dist/logic/actions/propose/getColoredActionToken.js.map +0 -1
- package/dist/logic/actions/propose/getColoredProposalTitle.d.ts +0 -4
- package/dist/logic/actions/propose/getColoredProposalTitle.js +0 -34
- package/dist/logic/actions/propose/getColoredProposalTitle.js.map +0 -1
- package/dist/logic/actions/propose/proposeChangeForResource.d.ts +0 -7
- package/dist/logic/actions/propose/proposeChangeForResource.js +0 -65
- package/dist/logic/actions/propose/proposeChangeForResource.js.map +0 -1
- package/dist/logic/actions/propose/proposeChangeForResource.test.js +0 -48
- package/dist/logic/actions/propose/proposeChangeForResource.test.js.map +0 -1
- package/dist/logic/commands/command.apply.d.ts +0 -8
- package/dist/logic/commands/command.apply.js +0 -77
- package/dist/logic/commands/command.apply.js.map +0 -1
- package/dist/logic/commands/command.plan.d.ts +0 -13
- package/dist/logic/commands/command.plan.js +0 -155
- package/dist/logic/commands/command.plan.js.map +0 -1
- package/dist/logic/commands/execute.d.ts +0 -15
- package/dist/logic/commands/execute.js +0 -63
- package/dist/logic/commands/execute.js.map +0 -1
- package/dist/logic/tools/compare/castReferenceToGrokableString.d.ts +0 -16
- package/dist/logic/tools/compare/castReferenceToGrokableString.js +0 -66
- package/dist/logic/tools/compare/castReferenceToGrokableString.js.map +0 -1
- package/dist/logic/tools/compare/castReferenceToGrokableString.test.js +0 -111
- package/dist/logic/tools/compare/castReferenceToGrokableString.test.js.map +0 -1
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.d.ts +0 -11
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.js +0 -61
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.js.map +0 -1
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js +0 -31
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js.map +0 -1
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.d.ts +0 -21
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.js +0 -53
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.js.map +0 -1
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.test.js +0 -31
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.test.js.map +0 -1
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.d.ts +0 -10
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.js +0 -41
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.js.map +0 -1
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.test.js +0 -174
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.test.js.map +0 -1
- package/dist/logic/tools/context/createDeclastructContext.d.ts +0 -10
- package/dist/logic/tools/context/createDeclastructContext.js +0 -12
- package/dist/logic/tools/context/createDeclastructContext.js.map +0 -1
- package/dist/logic/tools/context/destroyDeclastructContext.d.ts +0 -4
- package/dist/logic/tools/context/destroyDeclastructContext.js +0 -10
- package/dist/logic/tools/context/destroyDeclastructContext.js.map +0 -1
- package/dist/logic/tools/provider/castProviderContextToGlobalContext.d.ts +0 -4
- package/dist/logic/tools/provider/castProviderContextToGlobalContext.js +0 -10
- package/dist/logic/tools/provider/castProviderContextToGlobalContext.js.map +0 -1
- package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.d.ts +0 -13
- package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.js +0 -29
- package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.js.map +0 -1
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.d.ts +0 -13
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js +0 -24
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js.map +0 -1
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.d.ts +0 -10
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js +0 -21
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js.map +0 -1
- package/dist/logic/tools/reference/buildPrimaryKeyTo.d.ts +0 -5
- package/dist/logic/tools/reference/buildPrimaryKeyTo.js +0 -40
- package/dist/logic/tools/reference/buildPrimaryKeyTo.js.map +0 -1
- package/dist/logic/tools/reference/buildReferenceTo.d.ts +0 -28
- package/dist/logic/tools/reference/buildReferenceTo.js +0 -92
- package/dist/logic/tools/reference/buildReferenceTo.js.map +0 -1
- package/dist/logic/tools/reference/buildReferenceTo.test.js +0 -119
- package/dist/logic/tools/reference/buildReferenceTo.test.js.map +0 -1
- package/dist/logic/tools/reference/buildUniqueKeyTo.d.ts +0 -5
- package/dist/logic/tools/reference/buildUniqueKeyTo.js +0 -40
- package/dist/logic/tools/reference/buildUniqueKeyTo.js.map +0 -1
- package/dist/logic/tools/reference/defineReferenceClassOf.d.ts +0 -5
- package/dist/logic/tools/reference/defineReferenceClassOf.js +0 -25
- package/dist/logic/tools/reference/defineReferenceClassOf.js.map +0 -1
- package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.d.ts +0 -13
- package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.js +0 -36
- package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.js.map +0 -1
- package/dist/logic/tools/reference/getByReference.d.ts +0 -15
- package/dist/logic/tools/reference/getByReference.js +0 -55
- package/dist/logic/tools/reference/getByReference.js.map +0 -1
- package/dist/logic/tools/reference/getByReference.test.js +0 -92
- package/dist/logic/tools/reference/getByReference.test.js.map +0 -1
- package/dist/logic/tools/reference/getByReferencedPrimaryKey.d.ts +0 -6
- package/dist/logic/tools/reference/getByReferencedPrimaryKey.js +0 -17
- package/dist/logic/tools/reference/getByReferencedPrimaryKey.js.map +0 -1
- package/dist/logic/tools/reference/getByReferencedUniqueKey.d.ts +0 -7
- package/dist/logic/tools/reference/getByReferencedUniqueKey.js +0 -42
- package/dist/logic/tools/reference/getByReferencedUniqueKey.js.map +0 -1
- package/dist/logic/tools/reference/getPrimaryKeyByReference.d.ts +0 -15
- package/dist/logic/tools/reference/getPrimaryKeyByReference.js +0 -36
- package/dist/logic/tools/reference/getPrimaryKeyByReference.js.map +0 -1
- package/dist/logic/tools/reference/getReferenceTo.d.ts +0 -18
- package/dist/logic/tools/reference/getReferenceTo.js +0 -55
- package/dist/logic/tools/reference/getReferenceTo.js.map +0 -1
- package/dist/logic/tools/reference/getReferenceTo.test.js +0 -95
- package/dist/logic/tools/reference/getReferenceTo.test.js.map +0 -1
- package/dist/logic/tools/reference/getUniqueKeyByReference.d.ts +0 -15
- package/dist/logic/tools/reference/getUniqueKeyByReference.js +0 -36
- package/dist/logic/tools/reference/getUniqueKeyByReference.js.map +0 -1
- package/dist/logic/tools/reference/isPrimaryKeyReference.d.ts +0 -6
- package/dist/logic/tools/reference/isPrimaryKeyReference.js +0 -7
- package/dist/logic/tools/reference/isPrimaryKeyReference.js.map +0 -1
- package/dist/logic/tools/reference/isUniqueKeyReference.d.ts +0 -6
- package/dist/logic/tools/reference/isUniqueKeyReference.js +0 -7
- package/dist/logic/tools/reference/isUniqueKeyReference.js.map +0 -1
- /package/dist/{logic/actions/propose/proposeChangeForResource.test.d.ts → contract/cli/apply.integration.test.d.ts} +0 -0
- /package/dist/{logic/tools/compare/castReferenceToGrokableString.test.d.ts → contract/cli/plan.integration.test.d.ts} +0 -0
- /package/dist/{logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.d.ts → domain.objects/ContextDeclastruct.test.d.ts} +0 -0
- /package/dist/{logic/tools/compare/resolveReferenceToCommonComparableForm.test.d.ts → domain.objects/DeclastructChange.test.d.ts} +0 -0
- /package/dist/{logic/tools/compare/resolveReferencesToCommonComparableForm.test.d.ts → domain.objects/DeclastructDao.test.d.ts} +0 -0
- /package/dist/{logic/tools/reference/buildReferenceTo.test.d.ts → domain.objects/DeclastructPlan.test.d.ts} +0 -0
- /package/dist/{logic/tools/reference/getByReference.test.d.ts → domain.objects/DeclastructProvider.test.d.ts} +0 -0
- /package/dist/{logic/tools/reference/getReferenceTo.test.d.ts → domain.objects/IsoTimestamp.test.d.ts} +0 -0
package/readme.md
CHANGED
|
@@ -3,54 +3,250 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declarative control for any resource constructs, batteries included
|
|
7
|
+
|
|
8
|
+
# intro
|
|
9
|
+
|
|
10
|
+
Add declarative control to any resource construct. Declare, plan, and apply within an observable pit-of-success.
|
|
7
11
|
|
|
8
12
|
Declare the structures you want. Plan to see the changes required. Apply to make it so 🪄
|
|
9
13
|
|
|
10
|
-
# benefits
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
## what is it?
|
|
16
|
+
|
|
17
|
+
`declastruct` is a framework for managing any resource construct declaratively using TypeScript.
|
|
18
|
+
|
|
19
|
+
declare what you want, plan the changes, and apply them safely — all without managing separate state files or learning a new language.
|
|
20
|
+
|
|
21
|
+
works with:
|
|
22
|
+
- **infrastructure** — AWS, GCP, Azure resources
|
|
23
|
+
- **SaaS platforms** — Stripe customers, GitHub repos, Slack channels, etc
|
|
24
|
+
- **databases** — application data models
|
|
25
|
+
- **any API** — anything with a remote state you want to control
|
|
26
|
+
|
|
27
|
+
think Terraform, but:
|
|
28
|
+
- **no state files to manage** — compares directly against live remote state
|
|
29
|
+
- **no new language to learn** — uses TypeScript and your existing domain objects
|
|
30
|
+
- **pit-of-success by default** — enforces idempotency, clear unique keys, and safe operations
|
|
31
|
+
- **not just infrastructure** — works with any resource construct (saas, databases, apis, etc)
|
|
32
|
+
|
|
33
|
+
# usage
|
|
15
34
|
|
|
16
|
-
|
|
17
|
-
- no awkward new-language limitations
|
|
18
|
-
- reuse your existing domain language to manage your resources
|
|
35
|
+
## install
|
|
19
36
|
|
|
20
|
-
|
|
37
|
+
```sh
|
|
38
|
+
npm install declastruct --save-dev
|
|
39
|
+
```
|
|
21
40
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
## use
|
|
42
|
+
|
|
43
|
+
### 1. **declare** your desired state ✨
|
|
44
|
+
|
|
45
|
+
define resource constructs with strongly-typed domain objects:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { getDeclastructAwsProvider, DeclaredAwsS3Bucket } from 'declastruct-aws';
|
|
49
|
+
import { getDeclastructStripeProvider, DeclaredStripeCustomer } from 'declastruct-stripe';
|
|
50
|
+
|
|
51
|
+
// define which providers support your resource constructs
|
|
52
|
+
export const getProviders = async () => [
|
|
53
|
+
await getDeclastructAwsProvider({
|
|
54
|
+
profile: process.env.AWS_PROFILE,
|
|
55
|
+
}),
|
|
56
|
+
await getDeclastructStripeProvider({
|
|
57
|
+
apiKey: process.env.STRIPE_SECRET_KEY,
|
|
58
|
+
}),
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
// declare the resource constructs you want and their desired state
|
|
62
|
+
export const getResources = async () => {
|
|
63
|
+
const bucket = DeclaredAwsS3Bucket.as({
|
|
64
|
+
name: 'your-s3-bucket',
|
|
65
|
+
versioning: true,
|
|
66
|
+
encryption: 'AES256',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const customer = DeclaredStripeCustomer.as({
|
|
70
|
+
email: 'user@example.com',
|
|
71
|
+
name: 'John Doe',
|
|
72
|
+
metadata: { source: 'app-web' },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return [bucket, customer];
|
|
76
|
+
};
|
|
77
|
+
```
|
|
25
78
|
|
|
26
|
-
|
|
27
|
-
- manage resource states declaratively
|
|
79
|
+
### 2. **plan** the required changes 🔮
|
|
28
80
|
|
|
29
|
-
|
|
30
|
-
- standard shape for any operation for interaction with resources
|
|
31
|
-
- plug and play handlers of resources (interface w/ many remote state stores for the same resource via prebuilt providers)
|
|
81
|
+
see exactly what will change before applying:
|
|
32
82
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
83
|
+
```sh
|
|
84
|
+
npx declastruct plan \
|
|
85
|
+
--wish provision/resources.ts \
|
|
86
|
+
--into provision/.temp/plan.json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
output:
|
|
90
|
+
```
|
|
91
|
+
planned changes:
|
|
92
|
+
CREATE: DeclaredAwsS3Bucket.your-s3-bucket
|
|
93
|
+
+ name: "your-s3-bucket"
|
|
94
|
+
+ versioning: true
|
|
95
|
+
+ encryption: "AES256"
|
|
96
|
+
|
|
97
|
+
CREATE: DeclaredStripeCustomer.user@example.com
|
|
98
|
+
+ email: "user@example.com"
|
|
99
|
+
+ name: "John Doe"
|
|
100
|
+
+ metadata: { source: "app-web" }
|
|
101
|
+
```
|
|
37
102
|
|
|
103
|
+
### 3. **apply** the plan 🪄
|
|
38
104
|
|
|
39
|
-
|
|
105
|
+
execute the plan to make your desired state reality:
|
|
40
106
|
|
|
41
107
|
```sh
|
|
42
|
-
|
|
108
|
+
npx declastruct apply --plan provision/.temp/plan.json
|
|
43
109
|
```
|
|
44
110
|
|
|
45
|
-
#
|
|
111
|
+
# benefits - why declastruct?
|
|
112
|
+
|
|
113
|
+
## summary
|
|
114
|
+
|
|
115
|
+
✅ **stateless** — no state files to manage, compare directly against reality
|
|
116
|
+
|
|
117
|
+
✅ **type-safe** — full TypeScript support with domain objects
|
|
118
|
+
|
|
119
|
+
✅ **idempotent** — safe to run plans multiple times
|
|
120
|
+
|
|
121
|
+
✅ **observable** — see exactly what will change before applying
|
|
122
|
+
|
|
123
|
+
✅ **composable** — reuse domain objects and operations across application code and resource management
|
|
124
|
+
|
|
125
|
+
✅ **pit-of-success** — enforced best practices via idempotent dao interfaces
|
|
126
|
+
|
|
127
|
+
✅ **universal** — works with any resource construct (infrastructure, saas platforms, databases, apis, etc)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## details
|
|
131
|
+
|
|
132
|
+
### no state file management
|
|
133
|
+
|
|
134
|
+
traditional declarative tools (like Terraform) require maintaining a separate state file that tracks what resources exist. this creates problems:
|
|
135
|
+
- state files can drift from reality
|
|
136
|
+
- state locking issues in team environments
|
|
137
|
+
- state files must be carefully secured and backed up
|
|
138
|
+
|
|
139
|
+
**declastruct eliminates state files entirely.** it compares your desired resource constructs directly against live remote state using unique keys, so the source of truth is always reality itself.
|
|
46
140
|
|
|
47
|
-
###
|
|
141
|
+
### use your existing domain language
|
|
48
142
|
|
|
49
|
-
|
|
143
|
+
instead of learning HCL, YAML, or another DSL:
|
|
144
|
+
- declare resource constructs as TypeScript using `domain-objects`
|
|
145
|
+
- reuse the same domain objects across your application code and remote resource management
|
|
146
|
+
- leverage TypeScript's type safety, IDE autocomplete, and refactoring tools
|
|
147
|
+
- compose and test resource definitions like any other code
|
|
148
|
+
|
|
149
|
+
### enforced best practices
|
|
150
|
+
|
|
151
|
+
declastruct providers follow a pit-of-success pattern that guarantees:
|
|
152
|
+
|
|
153
|
+
**idempotency** — all operations can be safely retried
|
|
154
|
+
- `finsert`: find-or-insert (safe create)
|
|
155
|
+
- `upsert`: update-or-insert (safe update)
|
|
156
|
+
- running the same plan multiple times produces the same result
|
|
157
|
+
|
|
158
|
+
**explicit unique keys** — every resource declares how to uniquely identify it
|
|
159
|
+
- prevents accidental duplicates
|
|
160
|
+
- enables accurate comparison against live state
|
|
161
|
+
- makes resource relationships clear, typesafe, and composable
|
|
162
|
+
|
|
163
|
+
**observable change plans** — see exactly what will change before applying
|
|
164
|
+
- diff view shows before & after for each resource
|
|
165
|
+
- change actions: CREATE, UPDATE, KEEP, DESTROY
|
|
166
|
+
- no surprises in production
|
|
167
|
+
|
|
168
|
+
### provider ecosystem
|
|
169
|
+
|
|
170
|
+
declastruct is designed to support any resource construct through adapters:
|
|
171
|
+
|
|
172
|
+
**available providers:**
|
|
173
|
+
- `declastruct-aws` — AWS infrastructure (S3, Lambda, RDS, EC2, etc.)
|
|
174
|
+
- `declastruct-stripe` — Stripe SaaS resources (customers, subscriptions, products, etc.)
|
|
175
|
+
- `declastruct-github` — Github resources (repos, branches, protection, etc.)
|
|
176
|
+
- etc
|
|
177
|
+
|
|
178
|
+
**build your own provider** for any resource construct (GitHub repos, Slack channels, database records, etc.) by implementing the `DeclastructDao` and `DeclastructProvider` interfaces.
|
|
179
|
+
|
|
180
|
+
## use cases
|
|
181
|
+
|
|
182
|
+
- **infrastructure as code** — manage AWS, GCP, Azure resources declaratively
|
|
183
|
+
- **SaaS platform management** — manage Stripe customers, GitHub repos, Slack channels, etc declaratively
|
|
184
|
+
- **database state management** — control database resource states declaratively
|
|
185
|
+
- **api state management** — control remote resource state through api's declaratively
|
|
186
|
+
- **multi-platform orchestration** — coordinate resources across different providers in one plan
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# concepts
|
|
190
|
+
|
|
191
|
+
## domain
|
|
192
|
+
|
|
193
|
+
### DeclastructDao
|
|
194
|
+
|
|
195
|
+
the core abstraction that defines how to interact with a resource type:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
interface DeclastructDao<TResource, TResourceClass, TContext> {
|
|
199
|
+
get: {
|
|
200
|
+
byUnique: (ref: RefByUnique, context) => Promise<TResource | null>;
|
|
201
|
+
byPrimary?: (ref: RefByPrimary, context) => Promise<TResource | null>;
|
|
202
|
+
byRef: (ref: Ref, context) => Promise<TResource | null>;
|
|
203
|
+
};
|
|
204
|
+
set: {
|
|
205
|
+
finsert: (resource: TResource, context) => Promise<TResource>;
|
|
206
|
+
upsert?: (resource: TResource, context) => Promise<TResource>;
|
|
207
|
+
delete?: (ref: Ref, context) => Promise<void>;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
every resource class gets a DeclastructDao that enforces safe, idempotent operations.
|
|
213
|
+
|
|
214
|
+
### DeclastructProvider
|
|
215
|
+
|
|
216
|
+
bundles related DAOs and provider context:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
interface DeclastructProvider<TDaos, TContext> {
|
|
220
|
+
name: string; // provider identifier
|
|
221
|
+
daos: TDaos; // map of resource types to DAOs
|
|
222
|
+
context: TContext; // auth, region, etc.
|
|
223
|
+
hooks: {
|
|
224
|
+
beforeAll: () => Promise<void>;
|
|
225
|
+
afterAll: () => Promise<void>;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### DeclastructPlan
|
|
231
|
+
|
|
232
|
+
captures the changes needed to achieve desired state:
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
interface DeclastructPlan {
|
|
236
|
+
changes: DeclastructChange[]; // ordered list of changes
|
|
237
|
+
createdAt: IsoTimestamp; // when plan was created
|
|
238
|
+
hash: string; // fingerprint for validation
|
|
239
|
+
}
|
|
240
|
+
```
|
|
50
241
|
|
|
51
|
-
|
|
242
|
+
each `DeclastructChange` includes:
|
|
243
|
+
- `action`: CREATE | UPDATE | KEEP | DESTROY
|
|
244
|
+
- `forResource`: which resource this affects
|
|
245
|
+
- `state.desired`: what you want
|
|
246
|
+
- `state.remote`: what exists now
|
|
247
|
+
- `state.difference`: human-readable diff
|
|
52
248
|
|
|
53
249
|
|
|
54
|
-
|
|
250
|
+
## inspiration
|
|
55
251
|
|
|
56
|
-
|
|
252
|
+
inspired by Terraform's declarative approach, but designed to eliminate state management overhead, work with any resource construct, and leverage TypeScript's type system for safer declarative resource management.
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { DomainEntity } from 'domain-objects';
|
|
2
|
-
import { VisualogicContext } from 'visualogic';
|
|
3
|
-
import { DeclaredResourceReference } from '../domain/DeclaredResourceReference';
|
|
4
|
-
import { DeclastructContext } from '../domain/DeclastructContext';
|
|
5
|
-
interface CNCMachine {
|
|
6
|
-
uuid?: string;
|
|
7
|
-
serialNumber: string;
|
|
8
|
-
size: string;
|
|
9
|
-
location: string;
|
|
10
|
-
}
|
|
11
|
-
declare class CNCMachine extends DomainEntity<CNCMachine> implements CNCMachine {
|
|
12
|
-
static primary: readonly ["uuid"];
|
|
13
|
-
static unique: string[];
|
|
14
|
-
}
|
|
15
|
-
export type CNCMachineReference = DeclaredResourceReference<CNCMachine, 'uuid', 'serialNumber'>;
|
|
16
|
-
interface CNCMachineRegistration {
|
|
17
|
-
uuid?: string;
|
|
18
|
-
machine: CNCMachineReference;
|
|
19
|
-
registeredBy: string;
|
|
20
|
-
}
|
|
21
|
-
declare class CNCMachineRegistration extends DomainEntity<CNCMachineRegistration> implements CNCMachineRegistration {
|
|
22
|
-
static primary: readonly ["uuid"];
|
|
23
|
-
static unique: string[];
|
|
24
|
-
}
|
|
25
|
-
export type CNCMachineRegistrationReference = DeclaredResourceReference<CNCMachineRegistration, 'uuid', 'machine'>;
|
|
26
|
-
export declare const getExampleContext: () => {
|
|
27
|
-
exampleContext: DeclastructContext & VisualogicContext;
|
|
28
|
-
exampleMachine: Required<CNCMachine>;
|
|
29
|
-
CNCMachine: typeof CNCMachine;
|
|
30
|
-
exampleRegistration: Required<CNCMachineRegistration>;
|
|
31
|
-
CNCMachineRegistration: typeof CNCMachineRegistration;
|
|
32
|
-
};
|
|
33
|
-
export {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExampleContext = void 0;
|
|
4
|
-
const domain_objects_1 = require("domain-objects");
|
|
5
|
-
const __1 = require("..");
|
|
6
|
-
const DeclaredResourceReference_1 = require("../domain/DeclaredResourceReference");
|
|
7
|
-
const log = console;
|
|
8
|
-
class CNCMachine extends domain_objects_1.DomainEntity {
|
|
9
|
-
}
|
|
10
|
-
CNCMachine.primary = ['uuid'];
|
|
11
|
-
CNCMachine.unique = ['serialNumber'];
|
|
12
|
-
class CNCMachineRegistration extends domain_objects_1.DomainEntity {
|
|
13
|
-
}
|
|
14
|
-
CNCMachineRegistration.primary = ['uuid'];
|
|
15
|
-
CNCMachineRegistration.unique = ['machine'];
|
|
16
|
-
const exampleMachine = new CNCMachine({
|
|
17
|
-
uuid: 'de0e34ca-ce61-4884-ace5-093a1a32ff92',
|
|
18
|
-
serialNumber: '821',
|
|
19
|
-
size: 'big',
|
|
20
|
-
location: 'basement',
|
|
21
|
-
});
|
|
22
|
-
const exampleRegistration = new CNCMachineRegistration({
|
|
23
|
-
uuid: '9857cc32-8bcf-4291-8850-aef94c2081f9',
|
|
24
|
-
machine: (0, __1.getRef)(exampleMachine),
|
|
25
|
-
registeredBy: 'bob',
|
|
26
|
-
});
|
|
27
|
-
const cncMachineRemoteStateInterface = {
|
|
28
|
-
for: CNCMachine.name,
|
|
29
|
-
findByPrimary: async ({ uuid }) => {
|
|
30
|
-
if (uuid === exampleMachine.uuid)
|
|
31
|
-
return exampleMachine;
|
|
32
|
-
return null;
|
|
33
|
-
},
|
|
34
|
-
findByUnique: async ({ serialNumber }) => {
|
|
35
|
-
if (serialNumber === exampleMachine.serialNumber)
|
|
36
|
-
return exampleMachine;
|
|
37
|
-
return null;
|
|
38
|
-
},
|
|
39
|
-
create: () => Promise.reject(new Error('todo')),
|
|
40
|
-
update: () => Promise.reject(new Error('todo')),
|
|
41
|
-
destroy: () => Promise.reject(new Error('todo')),
|
|
42
|
-
};
|
|
43
|
-
const cncMachineRegistrationRemoteStateInterface = {
|
|
44
|
-
for: CNCMachineRegistration.name,
|
|
45
|
-
findByPrimary: async ({ uuid }) => {
|
|
46
|
-
if (uuid === exampleRegistration.uuid)
|
|
47
|
-
return exampleRegistration;
|
|
48
|
-
return null;
|
|
49
|
-
},
|
|
50
|
-
findByUnique: async ({ machine: machineRef }) => {
|
|
51
|
-
if (machineRef.identifiedBy.key ===
|
|
52
|
-
DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.PRIMARY_KEY &&
|
|
53
|
-
machineRef.identifiedBy.value.uuid === exampleMachine.uuid)
|
|
54
|
-
return exampleRegistration;
|
|
55
|
-
if (machineRef.identifiedBy.key ===
|
|
56
|
-
DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.UNIQUE_KEY &&
|
|
57
|
-
machineRef.identifiedBy.value.serialNumber === exampleMachine.serialNumber)
|
|
58
|
-
return exampleRegistration;
|
|
59
|
-
return null;
|
|
60
|
-
},
|
|
61
|
-
create: () => Promise.reject(new Error('todo')),
|
|
62
|
-
destroy: () => Promise.reject(new Error('todo')),
|
|
63
|
-
};
|
|
64
|
-
const exampleContext = {
|
|
65
|
-
log,
|
|
66
|
-
providers: [
|
|
67
|
-
{
|
|
68
|
-
agentOptions: {},
|
|
69
|
-
interfaces: {
|
|
70
|
-
[cncMachineRemoteStateInterface.for]: cncMachineRemoteStateInterface,
|
|
71
|
-
[cncMachineRegistrationRemoteStateInterface.for]: cncMachineRegistrationRemoteStateInterface,
|
|
72
|
-
}, // TODO: fix types to make this assertion not needed
|
|
73
|
-
hooks: {},
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
resources: [], // no resources needed in context for this test
|
|
77
|
-
};
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
79
|
-
const getExampleContext = () => ({
|
|
80
|
-
exampleContext,
|
|
81
|
-
exampleMachine,
|
|
82
|
-
CNCMachine,
|
|
83
|
-
exampleRegistration,
|
|
84
|
-
CNCMachineRegistration,
|
|
85
|
-
});
|
|
86
|
-
exports.getExampleContext = getExampleContext;
|
|
87
|
-
//# sourceMappingURL=getExampleContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getExampleContext.js","sourceRoot":"","sources":["../../src/__test_assets__/getExampleContext.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { VisualogicContext } from 'visualogic';
|
|
2
|
-
import { DeclastructCommandInput } from './utils/resolveCommandInputs';
|
|
3
|
-
/**
|
|
4
|
-
* applies the planned actions required to update the remote state to match the declared state
|
|
5
|
-
*/
|
|
6
|
-
export declare const apply: (input: DeclastructCommandInput, context: VisualogicContext) => Promise<void>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apply = void 0;
|
|
4
|
-
const execute_1 = require("../../logic/commands/execute");
|
|
5
|
-
const resolveCommandInputs_1 = require("./utils/resolveCommandInputs");
|
|
6
|
-
/**
|
|
7
|
-
* applies the planned actions required to update the remote state to match the declared state
|
|
8
|
-
*/
|
|
9
|
-
const apply = async (input, context) => {
|
|
10
|
-
// resolve the inputs
|
|
11
|
-
const { resources, providers } = await (0, resolveCommandInputs_1.resolveCommandInputs)({ input });
|
|
12
|
-
// execute the command
|
|
13
|
-
await (0, execute_1.executeCommand)({
|
|
14
|
-
option: execute_1.DeclastructCommandOption.APPLY,
|
|
15
|
-
resources,
|
|
16
|
-
providers,
|
|
17
|
-
}, context);
|
|
18
|
-
};
|
|
19
|
-
exports.apply = apply;
|
|
20
|
-
//# sourceMappingURL=command.apply.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.apply.js","sourceRoot":"","sources":["../../../src/contract/commands/command.apply.ts"],"names":[],"mappings":";;;AAEA,0DAGsC;AACtC,uEAGsC;AAEtC;;GAEG;AACI,MAAM,KAAK,GAAG,KAAK,EACxB,KAA8B,EAC9B,OAA0B,EACX,EAAE;IACjB,qBAAqB;IACrB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,2CAAoB,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvE,sBAAsB;IACtB,MAAM,IAAA,wBAAc,EAClB;QACE,MAAM,EAAE,kCAAwB,CAAC,KAAK;QACtC,SAAS;QACT,SAAS;KACV,EACD,OAAO,CACR,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,KAAK,SAgBhB"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { VisualogicContext } from 'visualogic';
|
|
2
|
-
import { DeclastructCommandInput } from './utils/resolveCommandInputs';
|
|
3
|
-
/**
|
|
4
|
-
* applies the planned actions required to update the remote state to match the declared state
|
|
5
|
-
*/
|
|
6
|
-
export declare const plan: (input: DeclastructCommandInput, context: VisualogicContext) => Promise<void>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.plan = void 0;
|
|
4
|
-
const execute_1 = require("../../logic/commands/execute");
|
|
5
|
-
const resolveCommandInputs_1 = require("./utils/resolveCommandInputs");
|
|
6
|
-
/**
|
|
7
|
-
* applies the planned actions required to update the remote state to match the declared state
|
|
8
|
-
*/
|
|
9
|
-
const plan = async (input, context) => {
|
|
10
|
-
// resolve the inputs
|
|
11
|
-
const { resources, providers } = await (0, resolveCommandInputs_1.resolveCommandInputs)({ input });
|
|
12
|
-
// execute the command
|
|
13
|
-
await (0, execute_1.executeCommand)({
|
|
14
|
-
option: execute_1.DeclastructCommandOption.PLAN,
|
|
15
|
-
resources,
|
|
16
|
-
providers,
|
|
17
|
-
}, context);
|
|
18
|
-
};
|
|
19
|
-
exports.plan = plan;
|
|
20
|
-
//# sourceMappingURL=command.plan.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.plan.js","sourceRoot":"","sources":["../../../src/contract/commands/command.plan.ts"],"names":[],"mappings":";;;AAEA,0DAGsC;AACtC,uEAGsC;AAEtC;;GAEG;AACI,MAAM,IAAI,GAAG,KAAK,EACvB,KAA8B,EAC9B,OAA0B,EACX,EAAE;IACjB,qBAAqB;IACrB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,2CAAoB,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvE,sBAAsB;IACtB,MAAM,IAAA,wBAAc,EAClB;QACE,MAAM,EAAE,kCAAwB,CAAC,IAAI;QACrC,SAAS;QACT,SAAS;KACV,EACD,OAAO,CACR,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,IAAI,QAgBf"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DeclaredResource } from '../../../domain/DeclaredResource';
|
|
2
|
-
import { DeclastructProvider } from '../../../domain/DeclastructProvider';
|
|
3
|
-
export interface DeclastructCommandInput {
|
|
4
|
-
resources: DeclaredResource[] | (() => Promise<DeclaredResource[]>);
|
|
5
|
-
providers: DeclastructProvider<any>[] | (() => Promise<DeclastructProvider<any>[]>);
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* a utility method for resolving the command inputs from user definition
|
|
9
|
-
* - we allow users to specify the inputs directly or from a function that promises the inputs
|
|
10
|
-
* - this method awaits the inputs if needed
|
|
11
|
-
*/
|
|
12
|
-
export declare const resolveCommandInputs: ({ input, }: {
|
|
13
|
-
input: DeclastructCommandInput;
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
resources: DeclaredResource[];
|
|
16
|
-
providers: DeclastructProvider<any>[];
|
|
17
|
-
}>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveCommandInputs = void 0;
|
|
4
|
-
const type_fns_1 = require("type-fns");
|
|
5
|
-
/**
|
|
6
|
-
* a utility method for resolving the command inputs from user definition
|
|
7
|
-
* - we allow users to specify the inputs directly or from a function that promises the inputs
|
|
8
|
-
* - this method awaits the inputs if needed
|
|
9
|
-
*/
|
|
10
|
-
const resolveCommandInputs = async ({ input, }) => {
|
|
11
|
-
const resources = (0, type_fns_1.isAFunction)(input.resources)
|
|
12
|
-
? await input.resources()
|
|
13
|
-
: input.resources;
|
|
14
|
-
const providers = (0, type_fns_1.isAFunction)(input.providers)
|
|
15
|
-
? await input.providers()
|
|
16
|
-
: input.providers;
|
|
17
|
-
return {
|
|
18
|
-
resources,
|
|
19
|
-
providers,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.resolveCommandInputs = resolveCommandInputs;
|
|
23
|
-
//# sourceMappingURL=resolveCommandInputs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveCommandInputs.js","sourceRoot":"","sources":["../../../../src/contract/commands/utils/resolveCommandInputs.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAavC;;;;GAIG;AACI,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACzC,KAAK,GAGN,EAAE,EAAE;IACH,MAAM,SAAS,GAAuB,IAAA,sBAAW,EAAC,KAAK,CAAC,SAAS,CAAC;QAChE,CAAC,CAAC,MAAM,KAAK,CAAC,SAAS,EAAE;QACzB,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IACpB,MAAM,SAAS,GAA+B,IAAA,sBAAW,EAAC,KAAK,CAAC,SAAS,CAAC;QACxE,CAAC,CAAC,MAAM,KAAK,CAAC,SAAS,EAAE;QACzB,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IACpB,OAAO;QACL,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,oBAAoB,wBAe/B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../../logic/tools/reference/getReferenceTo"), exports);
|
|
18
|
-
__exportStar(require("../../logic/tools/reference/buildReferenceTo"), exports);
|
|
19
|
-
//# sourceMappingURL=refs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../../src/contract/sdk/refs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6EAA2D;AAC3D,+EAA6D"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { VisualogicContext } from 'visualogic';
|
|
2
|
-
import { DeclaredResource } from '../../../domain/DeclaredResource';
|
|
3
|
-
import { DeclastructChangeProposal } from '../../../domain/DeclastructChangeProposal';
|
|
4
|
-
import { DeclastructProvider } from '../../../domain/DeclastructProvider';
|
|
5
|
-
/**
|
|
6
|
-
* tactic: apply plans to synchronize resources
|
|
7
|
-
* objective:
|
|
8
|
-
* - synchronize the remote state of the resource to the declared state
|
|
9
|
-
* impact:
|
|
10
|
-
* - ensures the remote state matches the declared state
|
|
11
|
-
*
|
|
12
|
-
* strategy
|
|
13
|
-
* - define a context for these resources
|
|
14
|
-
* - apply the plan for these resources
|
|
15
|
-
*/
|
|
16
|
-
export declare const applyPlansToSynchronize: <R extends DeclaredResource>({ resources, plans, }: {
|
|
17
|
-
resources: R[];
|
|
18
|
-
plans: DeclastructChangeProposal<R>[];
|
|
19
|
-
}, { providers, log, }: {
|
|
20
|
-
providers: DeclastructProvider<any>[];
|
|
21
|
-
} & VisualogicContext) => Promise<Required<R>[]>;
|
|
22
|
-
export { applyPlansToSynchronize as applyPlans };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyPlans = exports.applyPlansToSynchronize = void 0;
|
|
4
|
-
const executeProposal_1 = require("../../../logic/actions/execute/executeProposal");
|
|
5
|
-
const createDeclastructContext_1 = require("../../../logic/tools/context/createDeclastructContext");
|
|
6
|
-
/**
|
|
7
|
-
* tactic: apply plans to synchronize resources
|
|
8
|
-
* objective:
|
|
9
|
-
* - synchronize the remote state of the resource to the declared state
|
|
10
|
-
* impact:
|
|
11
|
-
* - ensures the remote state matches the declared state
|
|
12
|
-
*
|
|
13
|
-
* strategy
|
|
14
|
-
* - define a context for these resources
|
|
15
|
-
* - apply the plan for these resources
|
|
16
|
-
*/
|
|
17
|
-
const applyPlansToSynchronize = async ({ resources, plans, }, { providers, log, }) => {
|
|
18
|
-
// define the context for these resources
|
|
19
|
-
const context = await (0, createDeclastructContext_1.createDeclastructContext)({
|
|
20
|
-
providers,
|
|
21
|
-
resources,
|
|
22
|
-
log,
|
|
23
|
-
});
|
|
24
|
-
// get the plan for this one resource
|
|
25
|
-
return await Promise.all(plans.map((plan) => (0, executeProposal_1.executeProposal)({ proposal: plan }, context)));
|
|
26
|
-
};
|
|
27
|
-
exports.applyPlansToSynchronize = applyPlansToSynchronize;
|
|
28
|
-
exports.applyPlans = exports.applyPlansToSynchronize;
|
|
29
|
-
//# sourceMappingURL=apply.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../src/contract/sdk/sync/apply.ts"],"names":[],"mappings":";;;AAKA,oFAAiF;AACjF,oGAAiG;AAEjG;;;;;;;;;;GAUG;AACI,MAAM,uBAAuB,GAAG,KAAK,EAC1C,EACE,SAAS,EACT,KAAK,GACqD,EAC5D,EACE,SAAS,EACT,GAAG,GAC2D,EACxC,EAAE;IAC1B,yCAAyC;IACzC,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,KAAK,CAAC,GAAG,CACP,CAAC,IAAI,EAAE,EAAE,CACP,IAAA,iCAAe,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,CAAyB,CACvE,CACF,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,uBAAuB,2BAwBlC;AAGkC,qBA3BvB,+BAAuB,CA2BU"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { VisualogicContext } from 'visualogic';
|
|
2
|
-
import { DeclaredResource } from '../../../domain/DeclaredResource';
|
|
3
|
-
import { DeclastructChangeProposal } from '../../../domain/DeclastructChangeProposal';
|
|
4
|
-
import { DeclastructProvider } from '../../../domain/DeclastructProvider';
|
|
5
|
-
/**
|
|
6
|
-
* tactic: get plan to synchronize one resource
|
|
7
|
-
* objective:
|
|
8
|
-
* - get a plan for synchronizing the remote state of the resource to the declared state
|
|
9
|
-
* impact:
|
|
10
|
-
* - enable comparing the difference between the remote state and declared state
|
|
11
|
-
* - enable applying the plan to synchronize the remote state to the declared state
|
|
12
|
-
*
|
|
13
|
-
* strategy
|
|
14
|
-
* - define a context for this one resource
|
|
15
|
-
* - get the plan for this one resource
|
|
16
|
-
*/
|
|
17
|
-
export declare const getPlansToSynchronize: <R extends DeclaredResource>({ resources }: {
|
|
18
|
-
resources: R[];
|
|
19
|
-
}, { providers, log, }: {
|
|
20
|
-
providers: DeclastructProvider<any>[];
|
|
21
|
-
} & VisualogicContext) => Promise<DeclastructChangeProposal<R>[]>;
|
|
22
|
-
export { getPlansToSynchronize as getPlans };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPlans = exports.getPlansToSynchronize = void 0;
|
|
4
|
-
const proposeChangeForResource_1 = require("../../../logic/actions/propose/proposeChangeForResource");
|
|
5
|
-
const createDeclastructContext_1 = require("../../../logic/tools/context/createDeclastructContext");
|
|
6
|
-
/**
|
|
7
|
-
* tactic: get plan to synchronize one resource
|
|
8
|
-
* objective:
|
|
9
|
-
* - get a plan for synchronizing the remote state of the resource to the declared state
|
|
10
|
-
* impact:
|
|
11
|
-
* - enable comparing the difference between the remote state and declared state
|
|
12
|
-
* - enable applying the plan to synchronize the remote state to the declared state
|
|
13
|
-
*
|
|
14
|
-
* strategy
|
|
15
|
-
* - define a context for this one resource
|
|
16
|
-
* - get the plan for this one resource
|
|
17
|
-
*/
|
|
18
|
-
const getPlansToSynchronize = async ({ resources }, { providers, log, }) => {
|
|
19
|
-
// define the context for this one resource
|
|
20
|
-
const context = await (0, createDeclastructContext_1.createDeclastructContext)({
|
|
21
|
-
providers,
|
|
22
|
-
resources,
|
|
23
|
-
log,
|
|
24
|
-
});
|
|
25
|
-
// get the plan for this one resource
|
|
26
|
-
return await Promise.all(resources.map((resource) => (0, proposeChangeForResource_1.proposeChangeForResource)({ resource }, context)));
|
|
27
|
-
};
|
|
28
|
-
exports.getPlansToSynchronize = getPlansToSynchronize;
|
|
29
|
-
exports.getPlans = exports.getPlansToSynchronize;
|
|
30
|
-
//# sourceMappingURL=plan.js.map
|