@terraforge/core 0.0.28 → 0.0.29
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 +10 -1
- package/dist/index.mjs +12 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -252,6 +252,13 @@ type GetDataProps<T = State> = {
|
|
|
252
252
|
type: string;
|
|
253
253
|
state: T;
|
|
254
254
|
};
|
|
255
|
+
type RefreshStateProps<T = State> = {
|
|
256
|
+
type: string;
|
|
257
|
+
tag: 'resource' | 'data';
|
|
258
|
+
priorInputState: T;
|
|
259
|
+
priorOutputState: T;
|
|
260
|
+
refreshedState: T;
|
|
261
|
+
};
|
|
255
262
|
interface Provider {
|
|
256
263
|
ownResource(id: string): boolean;
|
|
257
264
|
getResource(props: GetProps): Promise<{
|
|
@@ -275,6 +282,7 @@ interface Provider {
|
|
|
275
282
|
getData?(props: GetDataProps): Promise<{
|
|
276
283
|
state: State;
|
|
277
284
|
}>;
|
|
285
|
+
isRefreshStateEqual?(props: RefreshStateProps): Promise<boolean> | boolean;
|
|
278
286
|
destroy?(): Promise<void>;
|
|
279
287
|
}
|
|
280
288
|
//#endregion
|
|
@@ -532,7 +540,8 @@ type CustomResourceProvider = Partial<{
|
|
|
532
540
|
state: State;
|
|
533
541
|
requiresReplacement: boolean;
|
|
534
542
|
}>;
|
|
543
|
+
isRefreshStateEqual?(props: Omit<RefreshStateProps, 'type'>): Promise<boolean> | boolean;
|
|
535
544
|
}>;
|
|
536
545
|
declare const createCustomProvider: (providerId: string, resourceProviders: Record<string, CustomResourceProvider>) => Provider;
|
|
537
546
|
//#endregion
|
|
538
|
-
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 };
|
|
547
|
+
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 RefreshStateProps, 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
|
@@ -1133,6 +1133,13 @@ const refresh = async (app, opt) => {
|
|
|
1133
1133
|
type: nodeState.type,
|
|
1134
1134
|
state: nodeState.output
|
|
1135
1135
|
});
|
|
1136
|
+
const hasChanged = !result ? true : provider.isRefreshStateEqual ? !await provider.isRefreshStateEqual({
|
|
1137
|
+
type: nodeState.type,
|
|
1138
|
+
tag: nodeState.tag,
|
|
1139
|
+
priorInputState: nodeState.input,
|
|
1140
|
+
priorOutputState: nodeState.output,
|
|
1141
|
+
refreshedState: result.state
|
|
1142
|
+
}) : !compareState(result.state, nodeState.output);
|
|
1136
1143
|
if (!result) return {
|
|
1137
1144
|
urn,
|
|
1138
1145
|
operation: "delete",
|
|
@@ -1140,7 +1147,7 @@ const refresh = async (app, opt) => {
|
|
|
1140
1147
|
delete stackState.nodes[urn];
|
|
1141
1148
|
}
|
|
1142
1149
|
};
|
|
1143
|
-
else if (
|
|
1150
|
+
else if (hasChanged) {
|
|
1144
1151
|
console.log(urn);
|
|
1145
1152
|
console.log(nodeState.output);
|
|
1146
1153
|
console.log(result?.state);
|
|
@@ -1148,8 +1155,8 @@ const refresh = async (app, opt) => {
|
|
|
1148
1155
|
urn,
|
|
1149
1156
|
operation: "update",
|
|
1150
1157
|
commit() {
|
|
1151
|
-
nodeState.input = result.state;
|
|
1152
1158
|
nodeState.output = result.state;
|
|
1159
|
+
if (nodeState.tag === "resource" && "version" in result) nodeState.version = result.version;
|
|
1153
1160
|
}
|
|
1154
1161
|
};
|
|
1155
1162
|
}
|
|
@@ -1742,6 +1749,9 @@ const createCustomProvider = (providerId, resourceProviders) => {
|
|
|
1742
1749
|
version,
|
|
1743
1750
|
state: await getProvider(type).getData?.(props) ?? {}
|
|
1744
1751
|
};
|
|
1752
|
+
},
|
|
1753
|
+
async isRefreshStateEqual({ type, ...props }) {
|
|
1754
|
+
return await getProvider(type).isRefreshStateEqual?.(props) ?? false;
|
|
1745
1755
|
}
|
|
1746
1756
|
};
|
|
1747
1757
|
};
|