@terraforge/core 0.0.20 → 0.0.22
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/README.md +5 -3
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +27 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,13 +18,15 @@ npm i @terraforge/core @terraforge/terraform @terraforge/aws
|
|
|
18
18
|
## Example
|
|
19
19
|
|
|
20
20
|
First, you need to create a workspace instance and pass in the cloud providers that you will use.
|
|
21
|
-
We also need to give it a lock
|
|
21
|
+
We also need to give it a lock backend & state backend.
|
|
22
22
|
|
|
23
23
|
- A cloud provider is used to create resources on a specific cloud provider. We have built-in cloud providers for AWS resources, but you could simply add your own as well.
|
|
24
24
|
|
|
25
|
-
- The state
|
|
25
|
+
- The state backend is used for storing the latest deployment state.
|
|
26
26
|
|
|
27
|
-
- The lock
|
|
27
|
+
- The lock backend is used for acquiring a lock when you deploy your app. This will guarantee that multiple people can never deploy the same application at the same time.
|
|
28
|
+
|
|
29
|
+
- The activity log backend is used for storing the activity log when every you deploy / delete your app.
|
|
28
30
|
|
|
29
31
|
In this example, we will use a local file lock & state provider.
|
|
30
32
|
|
package/dist/index.d.mts
CHANGED
|
@@ -215,7 +215,7 @@ type LogProps = {
|
|
|
215
215
|
};
|
|
216
216
|
type Log = LogProps & {
|
|
217
217
|
user?: string;
|
|
218
|
-
date
|
|
218
|
+
date: number;
|
|
219
219
|
};
|
|
220
220
|
type ActivityLogBackend = {
|
|
221
221
|
log(urn: URN, log: LogProps): Promise<void>;
|
|
@@ -453,14 +453,14 @@ declare class FileLockBackend implements LockBackend {
|
|
|
453
453
|
lock(urn: URN): Promise<() => Promise<void>>;
|
|
454
454
|
}
|
|
455
455
|
//#endregion
|
|
456
|
-
//#region src/backend/aws/
|
|
456
|
+
//#region src/backend/aws/dynamo-activity-log.d.ts
|
|
457
457
|
type Props$2 = {
|
|
458
458
|
credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider;
|
|
459
459
|
region: string;
|
|
460
460
|
tableName: string;
|
|
461
461
|
user?: string;
|
|
462
462
|
};
|
|
463
|
-
declare class
|
|
463
|
+
declare class DynamoActivityLogBackend implements ActivityLogBackend {
|
|
464
464
|
private props;
|
|
465
465
|
protected client: DynamoDB;
|
|
466
466
|
constructor(props: Props$2);
|
|
@@ -468,7 +468,7 @@ declare class DynamoDBActivityLogBackend implements ActivityLogBackend {
|
|
|
468
468
|
tail(urn: URN, limit?: number): Promise<Log[]>;
|
|
469
469
|
}
|
|
470
470
|
//#endregion
|
|
471
|
-
//#region src/backend/aws/
|
|
471
|
+
//#region src/backend/aws/dynamo-lock.d.ts
|
|
472
472
|
type Props$1 = {
|
|
473
473
|
credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider;
|
|
474
474
|
region: string;
|
|
@@ -528,4 +528,4 @@ type CustomResourceProvider = Partial<{
|
|
|
528
528
|
}>;
|
|
529
529
|
declare const createCustomProvider: (providerId: string, resourceProviders: Record<string, CustomResourceProvider>) => Provider;
|
|
530
530
|
//#endregion
|
|
531
|
-
export { ActivityLogBackend, App, AppError, type Config, type CreateProps, type CustomResourceProvider, type DataSource, type DataSourceFunction, type DataSourceMeta, type DeleteProps,
|
|
531
|
+
export { ActivityLogBackend, App, AppError, type Config, type CreateProps, type CustomResourceProvider, type DataSource, type DataSourceFunction, type DataSourceMeta, type DeleteProps, DynamoActivityLogBackend, DynamoLockBackend, FileActivityLogBackend, FileLockBackend, FileStateBackend, Future, type GetDataProps, type GetProps, Group, type Input, LockBackend, Log, LogProps, MemoryActivityLogBackend, MemoryLockBackend, MemoryStateBackend, type Meta, type Node, type OptionalInput, type OptionalOutput, Output, type PlanProps, type ProcedureOptions, type Provider, type Resource, ResourceAlreadyExists, type ResourceClass, type ResourceConfig, ResourceError, type ResourceMeta, ResourceNotFound, type ResourceStatus, type ResourceStatusInfo, S3StateBackend, Stack, type StackStatusInfo, type State, StateBackend, type Tag, type URN, type UpdateProps, WorkSpace, type WorkSpaceOptions, createCustomProvider, createCustomResourceClass, createDebugger, createMeta, deferredOutput, enableDebug, findInputDeps, getMeta, isDataSource, isNode, isResource, nodeMetaSymbol, output, resolveInputs };
|
package/dist/index.mjs
CHANGED
|
@@ -984,25 +984,31 @@ const deployApp = async (app, opt) => {
|
|
|
984
984
|
let newResourceState;
|
|
985
985
|
const ignoreReplace = forcedUpdateDependents.has(meta$1.urn);
|
|
986
986
|
if (!ignoreReplace && requiresReplacement(nodeState.input, input, meta$1.config?.replaceOnChanges ?? [])) if (meta$1.config?.createBeforeReplace) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
987
|
+
meta$1.resolve(input);
|
|
988
|
+
try {
|
|
989
|
+
for (const [dependentUrn, dependentNode] of nodeByUrn.entries()) {
|
|
990
|
+
if (!isResource(dependentNode)) continue;
|
|
991
|
+
const dependentMeta = getMeta(dependentNode);
|
|
992
|
+
if (!dependentMeta.dependencies.has(meta$1.urn)) continue;
|
|
993
|
+
const dependentStackState = stackStates.get(dependentMeta.stack.urn);
|
|
994
|
+
const dependentState = dependentStackState?.nodes[dependentUrn];
|
|
995
|
+
if (!dependentStackState || !dependentState) continue;
|
|
996
|
+
const dependencyPaths = findDependencyPaths(dependentMeta.input, meta$1.urn);
|
|
997
|
+
if (dependencyPaths.length === 0) continue;
|
|
998
|
+
const dependentProvider = findProvider(opt.providers, dependentMeta.provider);
|
|
999
|
+
if (dependentProvider.planResourceChange) {
|
|
1000
|
+
const dependentProposedInput = await resolveInputs(dependentMeta.input);
|
|
1001
|
+
if ((await dependentProvider.planResourceChange({
|
|
1002
|
+
type: dependentMeta.type,
|
|
1003
|
+
priorState: dependentState.output,
|
|
1004
|
+
proposedState: dependentProposedInput
|
|
1005
|
+
})).requiresReplacement) {
|
|
1006
|
+
if (!allowsDependentReplace(dependentMeta.config?.replaceOnChanges, dependencyPaths)) throw ResourceError.wrap(dependentMeta.urn, dependentMeta.type, "update", /* @__PURE__ */ new Error(`Replacing ${meta$1.urn} requires ${dependentMeta.urn} to set replaceOnChanges for its dependency fields.`));
|
|
1007
|
+
}
|
|
1004
1008
|
}
|
|
1005
1009
|
}
|
|
1010
|
+
} finally {
|
|
1011
|
+
meta$1.resolve(nodeState.output);
|
|
1006
1012
|
}
|
|
1007
1013
|
const priorState = { ...nodeState };
|
|
1008
1014
|
newResourceState = await createResource(node, appState.idempotentToken, input, opt);
|
|
@@ -1464,8 +1470,8 @@ var FileLockBackend = class {
|
|
|
1464
1470
|
};
|
|
1465
1471
|
|
|
1466
1472
|
//#endregion
|
|
1467
|
-
//#region src/backend/aws/
|
|
1468
|
-
var
|
|
1473
|
+
//#region src/backend/aws/dynamo-activity-log.ts
|
|
1474
|
+
var DynamoActivityLogBackend = class {
|
|
1469
1475
|
client;
|
|
1470
1476
|
constructor(props) {
|
|
1471
1477
|
this.props = props;
|
|
@@ -1497,7 +1503,7 @@ var DynamoDBActivityLogBackend = class {
|
|
|
1497
1503
|
};
|
|
1498
1504
|
|
|
1499
1505
|
//#endregion
|
|
1500
|
-
//#region src/backend/aws/
|
|
1506
|
+
//#region src/backend/aws/dynamo-lock.ts
|
|
1501
1507
|
var DynamoLockBackend = class {
|
|
1502
1508
|
client;
|
|
1503
1509
|
constructor(props) {
|
|
@@ -1691,4 +1697,4 @@ const createCustomProvider = (providerId, resourceProviders) => {
|
|
|
1691
1697
|
};
|
|
1692
1698
|
|
|
1693
1699
|
//#endregion
|
|
1694
|
-
export { App, AppError,
|
|
1700
|
+
export { App, AppError, DynamoActivityLogBackend, DynamoLockBackend, FileActivityLogBackend, FileLockBackend, FileStateBackend, Future, Group, MemoryActivityLogBackend, MemoryLockBackend, MemoryStateBackend, Output, ResourceAlreadyExists, ResourceError, ResourceNotFound, S3StateBackend, Stack, WorkSpace, createCustomProvider, createCustomResourceClass, createDebugger, createMeta, deferredOutput, enableDebug, findInputDeps, getMeta, isDataSource, isNode, isResource, nodeMetaSymbol, output, resolveInputs };
|