@terraforge/core 0.0.15 → 0.0.17
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/index.d.mts +23 -1
- package/dist/index.mjs +76 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -145,6 +145,24 @@ declare class App extends Group {
|
|
|
145
145
|
declare const enableDebug: () => void;
|
|
146
146
|
declare const createDebugger: (group: string) => (...args: unknown[]) => void;
|
|
147
147
|
//#endregion
|
|
148
|
+
//#region src/workspace/procedure/status.d.ts
|
|
149
|
+
/**
|
|
150
|
+
* The status of a resource comparing local config with state file.
|
|
151
|
+
*
|
|
152
|
+
* - `created`: Resource exists in state and matches current config
|
|
153
|
+
* - `changed`: Resource exists in state but config has changed
|
|
154
|
+
* - `pending`: Resource exists in config but not yet deployed (no state)
|
|
155
|
+
* - `stale`: Resource exists in state but was removed from config
|
|
156
|
+
*/
|
|
157
|
+
type ResourceStatus = 'created' | 'changed' | 'pending' | 'stale';
|
|
158
|
+
type ResourceStatusInfo = {
|
|
159
|
+
urn: URN;
|
|
160
|
+
type: string;
|
|
161
|
+
provider: string;
|
|
162
|
+
tag: 'resource' | 'data';
|
|
163
|
+
status: ResourceStatus;
|
|
164
|
+
};
|
|
165
|
+
//#endregion
|
|
148
166
|
//#region src/backend/lock.d.ts
|
|
149
167
|
type LockBackend = {
|
|
150
168
|
insecureReleaseLock(urn: URN): Promise<void>;
|
|
@@ -317,6 +335,10 @@ declare class WorkSpace {
|
|
|
317
335
|
* Refresh the state of the resources & data-sources inside your app.
|
|
318
336
|
*/
|
|
319
337
|
refresh(app: App): Promise<void>;
|
|
338
|
+
/**
|
|
339
|
+
* Get the status of all resources in the app by comparing current config with state file.
|
|
340
|
+
*/
|
|
341
|
+
status(app: App): Promise<ResourceStatusInfo[]>;
|
|
320
342
|
protected destroyProviders(): Promise<void>;
|
|
321
343
|
}
|
|
322
344
|
//#endregion
|
|
@@ -443,4 +465,4 @@ type CustomResourceProvider = Partial<{
|
|
|
443
465
|
}>;
|
|
444
466
|
declare const createCustomProvider: (providerId: string, resourceProviders: Record<string, CustomResourceProvider>) => Provider;
|
|
445
467
|
//#endregion
|
|
446
|
-
export { App, AppError, type Config, type CreateProps, type CustomResourceProvider, type DataSource, type DataSourceFunction, type DataSourceMeta, type DeleteProps, DynamoLockBackend, FileLockBackend, FileStateBackend, Future, type GetDataProps, type GetProps, Group, type Input, LockBackend, 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, S3StateBackend, Stack, 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 };
|
|
468
|
+
export { App, AppError, type Config, type CreateProps, type CustomResourceProvider, type DataSource, type DataSourceFunction, type DataSourceMeta, type DeleteProps, DynamoLockBackend, FileLockBackend, FileStateBackend, Future, type GetDataProps, type GetProps, Group, type Input, LockBackend, 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 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
|
@@ -1009,6 +1009,7 @@ const deployApp = async (app, opt) => {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
1011
|
newResourceState = await replaceResource(node, appState.idempotentToken, nodeState.input, nodeState.output, input, opt);
|
|
1012
|
+
if (newResourceState.output) meta$1.resolve(newResourceState.output);
|
|
1012
1013
|
}
|
|
1013
1014
|
else {
|
|
1014
1015
|
newResourceState = await updateResource(node, appState.idempotentToken, nodeState.input, nodeState.output, input, opt);
|
|
@@ -1093,6 +1094,75 @@ const refresh = async (app, opt) => {
|
|
|
1093
1094
|
}
|
|
1094
1095
|
};
|
|
1095
1096
|
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region src/workspace/procedure/status.ts
|
|
1099
|
+
/**
|
|
1100
|
+
* Extract static values from inputs, replacing Output/Future/Promise with a placeholder.
|
|
1101
|
+
* This allows comparing config without needing to resolve dependencies.
|
|
1102
|
+
*/
|
|
1103
|
+
const extractStaticInputs = (inputs) => {
|
|
1104
|
+
if (inputs instanceof Output || inputs instanceof Future || inputs instanceof Promise) return "__unresolved__";
|
|
1105
|
+
if (Array.isArray(inputs)) return inputs.map(extractStaticInputs);
|
|
1106
|
+
if (inputs !== null && typeof inputs === "object" && inputs.constructor === Object) {
|
|
1107
|
+
const result = {};
|
|
1108
|
+
for (const [key, value] of Object.entries(inputs)) result[key] = extractStaticInputs(value);
|
|
1109
|
+
return result;
|
|
1110
|
+
}
|
|
1111
|
+
return inputs;
|
|
1112
|
+
};
|
|
1113
|
+
const status = async (app, opt) => {
|
|
1114
|
+
const appState = await opt.backend.state.get(app.urn);
|
|
1115
|
+
const resources = [];
|
|
1116
|
+
const configuredUrns = /* @__PURE__ */ new Set();
|
|
1117
|
+
for (const stack of app.stacks) for (const node of stack.nodes) configuredUrns.add(getMeta(node).urn);
|
|
1118
|
+
for (const stack of app.stacks) {
|
|
1119
|
+
const stackState = appState?.stacks[stack.urn];
|
|
1120
|
+
for (const node of stack.nodes) {
|
|
1121
|
+
const meta = getMeta(node);
|
|
1122
|
+
const nodeState = stackState?.nodes[meta.urn];
|
|
1123
|
+
const baseInfo = {
|
|
1124
|
+
urn: meta.urn,
|
|
1125
|
+
type: meta.type,
|
|
1126
|
+
provider: meta.provider,
|
|
1127
|
+
tag: isResource(node) ? "resource" : "data"
|
|
1128
|
+
};
|
|
1129
|
+
if (!nodeState) {
|
|
1130
|
+
resources.push({
|
|
1131
|
+
...baseInfo,
|
|
1132
|
+
status: "pending"
|
|
1133
|
+
});
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
const currentInput = extractStaticInputs(meta.input);
|
|
1137
|
+
const hasChanged = !compareState(extractStaticInputs(nodeState.input), currentInput);
|
|
1138
|
+
resources.push({
|
|
1139
|
+
...baseInfo,
|
|
1140
|
+
status: hasChanged ? "changed" : "created"
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
if (stackState) {
|
|
1144
|
+
for (const [urn, nodeState] of Object.entries(stackState.nodes)) if (!configuredUrns.has(urn)) resources.push({
|
|
1145
|
+
urn,
|
|
1146
|
+
type: nodeState.type,
|
|
1147
|
+
provider: nodeState.provider,
|
|
1148
|
+
tag: nodeState.tag,
|
|
1149
|
+
status: "stale"
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
if (appState) {
|
|
1154
|
+
const configuredStackUrns = new Set(app.stacks.map((s) => s.urn));
|
|
1155
|
+
for (const [stackUrn, stackState] of Object.entries(appState.stacks)) if (!configuredStackUrns.has(stackUrn)) for (const [urn, nodeState] of Object.entries(stackState.nodes)) resources.push({
|
|
1156
|
+
urn,
|
|
1157
|
+
type: nodeState.type,
|
|
1158
|
+
provider: nodeState.provider,
|
|
1159
|
+
tag: nodeState.tag,
|
|
1160
|
+
status: "stale"
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
return resources;
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1096
1166
|
//#endregion
|
|
1097
1167
|
//#region src/workspace/workspace.ts
|
|
1098
1168
|
var WorkSpace = class {
|
|
@@ -1147,6 +1217,12 @@ var WorkSpace = class {
|
|
|
1147
1217
|
}
|
|
1148
1218
|
});
|
|
1149
1219
|
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Get the status of all resources in the app by comparing current config with state file.
|
|
1222
|
+
*/
|
|
1223
|
+
status(app) {
|
|
1224
|
+
return status(app, this.props);
|
|
1225
|
+
}
|
|
1150
1226
|
async destroyProviders() {
|
|
1151
1227
|
await Promise.all(this.props.providers.map((p) => {
|
|
1152
1228
|
return p.destroy?.();
|