@terraforge/core 0.0.27 → 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 +23 -11
- 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,9 +1133,13 @@ const refresh = async (app, opt) => {
|
|
|
1133
1133
|
type: nodeState.type,
|
|
1134
1134
|
state: nodeState.output
|
|
1135
1135
|
});
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
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);
|
|
1139
1143
|
if (!result) return {
|
|
1140
1144
|
urn,
|
|
1141
1145
|
operation: "delete",
|
|
@@ -1143,14 +1147,19 @@ const refresh = async (app, opt) => {
|
|
|
1143
1147
|
delete stackState.nodes[urn];
|
|
1144
1148
|
}
|
|
1145
1149
|
};
|
|
1146
|
-
else if (
|
|
1147
|
-
urn
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1150
|
+
else if (hasChanged) {
|
|
1151
|
+
console.log(urn);
|
|
1152
|
+
console.log(nodeState.output);
|
|
1153
|
+
console.log(result?.state);
|
|
1154
|
+
return {
|
|
1155
|
+
urn,
|
|
1156
|
+
operation: "update",
|
|
1157
|
+
commit() {
|
|
1158
|
+
nodeState.output = result.state;
|
|
1159
|
+
if (nodeState.tag === "resource" && "version" in result) nodeState.version = result.version;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1154
1163
|
});
|
|
1155
1164
|
}));
|
|
1156
1165
|
}))).flat().filter((op) => !!op);
|
|
@@ -1740,6 +1749,9 @@ const createCustomProvider = (providerId, resourceProviders) => {
|
|
|
1740
1749
|
version,
|
|
1741
1750
|
state: await getProvider(type).getData?.(props) ?? {}
|
|
1742
1751
|
};
|
|
1752
|
+
},
|
|
1753
|
+
async isRefreshStateEqual({ type, ...props }) {
|
|
1754
|
+
return await getProvider(type).isRefreshStateEqual?.(props) ?? false;
|
|
1743
1755
|
}
|
|
1744
1756
|
};
|
|
1745
1757
|
};
|