alchemy 0.16.0 → 0.16.2
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/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +6 -5
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +31 -31
- package/lib/apply.js.map +1 -1
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +3 -2
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/r2-rest-state-store.d.ts +1 -1
- package/lib/cloudflare/r2-rest-state-store.d.ts.map +1 -1
- package/lib/cloudflare/r2-rest-state-store.js +5 -4
- package/lib/cloudflare/r2-rest-state-store.js.map +1 -1
- package/lib/cloudflare/worker.js +1 -1
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/context.d.ts +1 -1
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js +6 -5
- package/lib/context.js.map +1 -1
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +20 -20
- package/lib/destroy.js.map +1 -1
- package/lib/fs/file-system-state-store.d.ts +1 -1
- package/lib/fs/file-system-state-store.d.ts.map +1 -1
- package/lib/fs/file-system-state-store.js +5 -3
- package/lib/fs/file-system-state-store.js.map +1 -1
- package/lib/os/exec.d.ts +46 -1
- package/lib/os/exec.d.ts.map +1 -1
- package/lib/os/exec.js +47 -1
- package/lib/os/exec.js.map +1 -1
- package/lib/resource.d.ts +15 -11
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +12 -7
- package/lib/resource.js.map +1 -1
- package/lib/scope.d.ts +1 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +2 -1
- package/lib/scope.js.map +1 -1
- package/lib/state.d.ts +3 -2
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +29 -0
- package/lib/state.js.map +1 -1
- package/package.json +1 -1
- package/src/alchemy.ts +13 -6
- package/src/apply.ts +37 -30
- package/src/cloudflare/queue.ts +6 -3
- package/src/cloudflare/r2-rest-state-store.ts +5 -5
- package/src/cloudflare/worker.ts +1 -1
- package/src/context.ts +21 -13
- package/src/destroy.ts +34 -20
- package/src/fs/file-system-state-store.ts +5 -7
- package/src/os/exec.ts +87 -2
- package/src/resource.ts +22 -18
- package/src/scope.ts +2 -2
- package/src/state.ts +42 -2
package/src/state.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ResourceFQN,
|
|
3
|
+
ResourceID,
|
|
4
|
+
ResourceKind,
|
|
5
|
+
ResourceScope,
|
|
6
|
+
ResourceSeq,
|
|
7
|
+
type Resource,
|
|
8
|
+
type ResourceProps,
|
|
9
|
+
} from "./resource.js";
|
|
10
|
+
import { Scope } from "./scope.js";
|
|
11
|
+
import { deserialize } from "./serde.js";
|
|
3
12
|
|
|
4
13
|
export type State<
|
|
5
14
|
Kind extends string = string,
|
|
@@ -41,3 +50,34 @@ export interface StateStore {
|
|
|
41
50
|
set(key: string, value: State): Promise<void>;
|
|
42
51
|
delete(key: string): Promise<void>;
|
|
43
52
|
}
|
|
53
|
+
|
|
54
|
+
export async function deserializeState(
|
|
55
|
+
scope: Scope,
|
|
56
|
+
content: string,
|
|
57
|
+
): Promise<State> {
|
|
58
|
+
const state = (await deserialize(scope, JSON.parse(content))) as State;
|
|
59
|
+
|
|
60
|
+
if (ResourceID in state.output) {
|
|
61
|
+
// this is a new state
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
const output: any = state.output;
|
|
65
|
+
delete output.Kind;
|
|
66
|
+
delete output.ID;
|
|
67
|
+
delete output.FQN;
|
|
68
|
+
delete output.Scope;
|
|
69
|
+
delete output.Seq;
|
|
70
|
+
// fix this bug
|
|
71
|
+
if (state.kind === "scope") {
|
|
72
|
+
state.kind = Scope.KIND;
|
|
73
|
+
}
|
|
74
|
+
output[ResourceKind] = state.kind;
|
|
75
|
+
output[ResourceID] = state.id;
|
|
76
|
+
output[ResourceFQN] = state.fqn;
|
|
77
|
+
output[ResourceScope] = scope;
|
|
78
|
+
output[ResourceSeq] = state.seq;
|
|
79
|
+
state.output = output;
|
|
80
|
+
// re-write the state with the migrated format
|
|
81
|
+
await scope.state.set(state.id, state);
|
|
82
|
+
return state;
|
|
83
|
+
}
|