@terraforge/core 0.0.13 → 0.0.15
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 +2 -3
- package/dist/index.mjs +17 -19
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -85,7 +85,6 @@ declare class Stack extends Group {
|
|
|
85
85
|
readonly app: App;
|
|
86
86
|
readonly dependencies: Set<Stack>;
|
|
87
87
|
constructor(app: App, name: string);
|
|
88
|
-
dependsOn(...stacks: Stack[]): this;
|
|
89
88
|
}
|
|
90
89
|
//#endregion
|
|
91
90
|
//#region src/meta.d.ts
|
|
@@ -147,11 +146,11 @@ declare const enableDebug: () => void;
|
|
|
147
146
|
declare const createDebugger: (group: string) => (...args: unknown[]) => void;
|
|
148
147
|
//#endregion
|
|
149
148
|
//#region src/backend/lock.d.ts
|
|
150
|
-
|
|
149
|
+
type LockBackend = {
|
|
151
150
|
insecureReleaseLock(urn: URN): Promise<void>;
|
|
152
151
|
locked(urn: URN): Promise<boolean>;
|
|
153
152
|
lock(urn: URN): Promise<() => Promise<void>>;
|
|
154
|
-
}
|
|
153
|
+
};
|
|
155
154
|
//#endregion
|
|
156
155
|
//#region src/workspace/state.d.ts
|
|
157
156
|
type AppState = {
|
package/dist/index.mjs
CHANGED
|
@@ -76,13 +76,6 @@ var Stack = class extends Group {
|
|
|
76
76
|
super(app, "stack", name);
|
|
77
77
|
this.app = app;
|
|
78
78
|
}
|
|
79
|
-
dependsOn(...stacks) {
|
|
80
|
-
for (const stack of stacks) {
|
|
81
|
-
if (stack.app !== this.app) throw new Error(`Stacks that belong to different apps can't be dependent on each other`);
|
|
82
|
-
this.dependencies.add(stack);
|
|
83
|
-
}
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
79
|
};
|
|
87
80
|
const findParentStack = (group) => {
|
|
88
81
|
if (group instanceof Stack) return group;
|
|
@@ -143,21 +136,23 @@ var Future = class Future {
|
|
|
143
136
|
});
|
|
144
137
|
if (this.status === IDLE) {
|
|
145
138
|
this.status = PENDING;
|
|
146
|
-
|
|
139
|
+
const onResolve = (data) => {
|
|
147
140
|
if (this.status === PENDING) {
|
|
148
141
|
this.status = RESOLVED;
|
|
149
142
|
this.data = data;
|
|
150
143
|
this.listeners.forEach(({ resolve: resolve$2 }) => resolve$2(data));
|
|
151
144
|
this.listeners.clear();
|
|
152
145
|
}
|
|
153
|
-
}
|
|
146
|
+
};
|
|
147
|
+
const onReject = (error) => {
|
|
154
148
|
if (this.status === PENDING) {
|
|
155
149
|
this.status = REJECTED;
|
|
156
150
|
this.error = error;
|
|
157
151
|
this.listeners.forEach(({ reject: reject$1 }) => reject$1?.(error));
|
|
158
152
|
this.listeners.clear();
|
|
159
153
|
}
|
|
160
|
-
}
|
|
154
|
+
};
|
|
155
|
+
Promise.resolve(this.callback(onResolve, onReject)).catch(onReject);
|
|
161
156
|
}
|
|
162
157
|
}
|
|
163
158
|
}
|
|
@@ -186,15 +181,17 @@ const resolveInputs = async (inputs) => {
|
|
|
186
181
|
const responses = await Promise.all(unresolved.map(async ([obj, key]) => {
|
|
187
182
|
const promise = obj[key];
|
|
188
183
|
let timeout;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
184
|
+
try {
|
|
185
|
+
return await Promise.race([promise, new Promise((_, reject) => {
|
|
186
|
+
timeout = setTimeout(() => {
|
|
187
|
+
if (promise instanceof Output) reject(/* @__PURE__ */ new Error(`Resolving Output<${[...promise.dependencies].map((d) => d.urn).join(", ")}> took too long.`));
|
|
188
|
+
else if (promise instanceof Future) reject(/* @__PURE__ */ new Error("Resolving Future took too long."));
|
|
189
|
+
else reject(/* @__PURE__ */ new Error("Resolving Promise took too long."));
|
|
190
|
+
}, 3e3);
|
|
191
|
+
})]);
|
|
192
|
+
} finally {
|
|
193
|
+
clearTimeout(timeout);
|
|
194
|
+
}
|
|
198
195
|
}));
|
|
199
196
|
unresolved.forEach(([props, key], i) => {
|
|
200
197
|
props[key] = responses[i];
|
|
@@ -971,6 +968,7 @@ const deployApp = async (app, opt) => {
|
|
|
971
968
|
if (!ignoreReplace && requiresReplacement(nodeState.input, input, meta$1.config?.replaceOnChanges ?? [])) if (meta$1.config?.createBeforeReplace) {
|
|
972
969
|
const priorState = { ...nodeState };
|
|
973
970
|
newResourceState = await createResource(node, appState.idempotentToken, input, opt);
|
|
971
|
+
if (newResourceState.output) meta$1.resolve(newResourceState.output);
|
|
974
972
|
if (!meta$1.config?.retainOnDelete) replacementDeletes.set(meta$1.urn, priorState);
|
|
975
973
|
} else {
|
|
976
974
|
for (const [dependentUrn, dependentNode] of nodeByUrn.entries()) {
|