@homeflare/alchemy 0.37.2 → 0.37.3
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/proxmox/backup-job-config.d.ts +95 -0
- package/dist/proxmox/backup-job-config.d.ts.map +1 -0
- package/dist/proxmox/backup-job-distilled.d.ts +46 -0
- package/dist/proxmox/backup-job-distilled.d.ts.map +1 -0
- package/dist/proxmox/backup-job.d.ts +9 -26
- package/dist/proxmox/backup-job.d.ts.map +1 -1
- package/dist/proxmox/distilled-pbs.d.ts +12 -0
- package/dist/proxmox/distilled-pbs.d.ts.map +1 -0
- package/dist/proxmox/fake-pbs-jobs.d.ts +23 -0
- package/dist/proxmox/fake-pbs-jobs.d.ts.map +1 -0
- package/dist/proxmox/fake-pbs-notify.d.ts.map +1 -1
- package/dist/proxmox/fake-pve.d.ts +1 -1
- package/dist/proxmox/fake-pve.d.ts.map +1 -1
- package/dist/proxmox/index.js +1501 -607
- package/dist/proxmox/index.js.map +48 -24
- package/dist/proxmox/live-core-fixtures.d.ts +40 -0
- package/dist/proxmox/live-core-fixtures.d.ts.map +1 -0
- package/dist/proxmox/metric-server-config.d.ts +49 -0
- package/dist/proxmox/metric-server-config.d.ts.map +1 -0
- package/dist/proxmox/metric-server-distilled.d.ts +43 -0
- package/dist/proxmox/metric-server-distilled.d.ts.map +1 -0
- package/dist/proxmox/metric-server.d.ts +2 -10
- package/dist/proxmox/metric-server.d.ts.map +1 -1
- package/dist/proxmox/notification-matcher-distilled.d.ts +9 -0
- package/dist/proxmox/notification-matcher-distilled.d.ts.map +1 -0
- package/dist/proxmox/notification-matcher-lifecycle.d.ts +27 -0
- package/dist/proxmox/notification-matcher-lifecycle.d.ts.map +1 -0
- package/dist/proxmox/notification-matcher.d.ts +5 -5
- package/dist/proxmox/notification-matcher.d.ts.map +1 -1
- package/dist/proxmox/notification-sdk-input.d.ts +22 -0
- package/dist/proxmox/notification-sdk-input.d.ts.map +1 -0
- package/dist/proxmox/notification-target-distilled.d.ts +12 -0
- package/dist/proxmox/notification-target-distilled.d.ts.map +1 -0
- package/dist/proxmox/notification-target-form.d.ts +2 -0
- package/dist/proxmox/notification-target-form.d.ts.map +1 -1
- package/dist/proxmox/notification-target-lifecycle.d.ts +29 -0
- package/dist/proxmox/notification-target-lifecycle.d.ts.map +1 -0
- package/dist/proxmox/notification-target-spec.d.ts +5 -0
- package/dist/proxmox/notification-target-spec.d.ts.map +1 -0
- package/dist/proxmox/notification-target.d.ts +4 -5
- package/dist/proxmox/notification-target.d.ts.map +1 -1
- package/dist/proxmox/pbs-datastore-endpoint.d.ts +1 -1
- package/dist/proxmox/pbs-datastore-form.d.ts +18 -42
- package/dist/proxmox/pbs-datastore-form.d.ts.map +1 -1
- package/dist/proxmox/pbs-datastore-guard.d.ts +7 -4
- package/dist/proxmox/pbs-datastore-guard.d.ts.map +1 -1
- package/dist/proxmox/pbs-datastore-lifecycle.d.ts +56 -0
- package/dist/proxmox/pbs-datastore-lifecycle.d.ts.map +1 -0
- package/dist/proxmox/pbs-datastore-wire.d.ts +21 -0
- package/dist/proxmox/pbs-datastore-wire.d.ts.map +1 -0
- package/dist/proxmox/pbs-datastore.d.ts +5 -6
- package/dist/proxmox/pbs-datastore.d.ts.map +1 -1
- package/dist/proxmox/pbs-notification-input.d.ts +18 -0
- package/dist/proxmox/pbs-notification-input.d.ts.map +1 -0
- package/dist/proxmox/pbs-notification-matcher-distilled.d.ts +11 -0
- package/dist/proxmox/pbs-notification-matcher-distilled.d.ts.map +1 -0
- package/dist/proxmox/pbs-notification-matcher.d.ts +4 -3
- package/dist/proxmox/pbs-notification-matcher.d.ts.map +1 -1
- package/dist/proxmox/pbs-notification-target-distilled.d.ts +20 -0
- package/dist/proxmox/pbs-notification-target-distilled.d.ts.map +1 -0
- package/dist/proxmox/pbs-notification-target-lifecycle.d.ts +4 -4
- package/dist/proxmox/pbs-notification-target-lifecycle.d.ts.map +1 -1
- package/dist/proxmox/pbs-notification-target.d.ts +1 -1
- package/dist/proxmox/pbs-prune-job-lifecycle.d.ts +22 -0
- package/dist/proxmox/pbs-prune-job-lifecycle.d.ts.map +1 -0
- package/dist/proxmox/pbs-prune-job-spec.d.ts +5 -0
- package/dist/proxmox/pbs-prune-job-spec.d.ts.map +1 -0
- package/dist/proxmox/pbs-prune-job-wire.d.ts +11 -0
- package/dist/proxmox/pbs-prune-job-wire.d.ts.map +1 -0
- package/dist/proxmox/pbs-prune-job.d.ts +9 -8
- package/dist/proxmox/pbs-prune-job.d.ts.map +1 -1
- package/dist/proxmox/pbs-sync-job-attributes.d.ts +34 -0
- package/dist/proxmox/pbs-sync-job-attributes.d.ts.map +1 -0
- package/dist/proxmox/pbs-sync-job-form.d.ts +21 -22
- package/dist/proxmox/pbs-sync-job-form.d.ts.map +1 -1
- package/dist/proxmox/pbs-sync-job-lifecycle.d.ts +22 -0
- package/dist/proxmox/pbs-sync-job-lifecycle.d.ts.map +1 -0
- package/dist/proxmox/pbs-sync-job-wire.d.ts +11 -0
- package/dist/proxmox/pbs-sync-job-wire.d.ts.map +1 -0
- package/dist/proxmox/pbs-sync-job.d.ts +9 -39
- package/dist/proxmox/pbs-sync-job.d.ts.map +1 -1
- package/dist/proxmox/pbs-verify-job-lifecycle.d.ts +22 -0
- package/dist/proxmox/pbs-verify-job-lifecycle.d.ts.map +1 -0
- package/dist/proxmox/pbs-verify-job-spec.d.ts +16 -0
- package/dist/proxmox/pbs-verify-job-spec.d.ts.map +1 -0
- package/dist/proxmox/pbs-verify-job-wire.d.ts +11 -0
- package/dist/proxmox/pbs-verify-job-wire.d.ts.map +1 -0
- package/dist/proxmox/pbs-verify-job.d.ts +12 -12
- package/dist/proxmox/pbs-verify-job.d.ts.map +1 -1
- package/dist/proxmox/pool.d.ts +10 -1
- package/dist/proxmox/pool.d.ts.map +1 -1
- package/docs/pbs-distilled-jobs.md +31 -0
- package/docs/pbs-notifications.md +8 -2
- package/docs/proxmox-notification-sdk.md +28 -0
- package/docs/proxmox-sdk-migration.md +60 -0
- package/docs/upstream-conformance-families.md +6 -2
- package/package.json +1 -1
- package/src/proxmox/adopt-noop.test.ts +4 -5
- package/src/proxmox/backup-job-config.ts +95 -0
- package/src/proxmox/backup-job-distilled.ts +86 -0
- package/src/proxmox/backup-job.ts +78 -116
- package/src/proxmox/constraints.test.ts +9 -8
- package/src/proxmox/distilled-pbs.test.ts +87 -0
- package/src/proxmox/distilled-pbs.ts +50 -0
- package/src/proxmox/fake-pbs-jobs.ts +99 -0
- package/src/proxmox/fake-pbs-notify.ts +4 -1
- package/src/proxmox/fake-pve.ts +3 -2
- package/src/proxmox/live-core-fixtures.ts +126 -0
- package/src/proxmox/live-core-lifecycle.test.ts +115 -0
- package/src/proxmox/live-core-wire.test.ts +190 -0
- package/src/proxmox/metric-server-config.ts +87 -0
- package/src/proxmox/metric-server-distilled.ts +81 -0
- package/src/proxmox/metric-server.ts +77 -88
- package/src/proxmox/notification-distilled.test.ts +162 -0
- package/src/proxmox/notification-matcher-distilled.ts +60 -0
- package/src/proxmox/notification-matcher-lifecycle.ts +71 -0
- package/src/proxmox/notification-matcher.ts +9 -26
- package/src/proxmox/notification-replacement.test.ts +190 -0
- package/src/proxmox/notification-sdk-input.ts +39 -0
- package/src/proxmox/notification-target-distilled.ts +160 -0
- package/src/proxmox/notification-target-form.ts +2 -0
- package/src/proxmox/notification-target-lifecycle.ts +75 -0
- package/src/proxmox/notification-target-spec.ts +68 -0
- package/src/proxmox/notification-target.ts +6 -68
- package/src/proxmox/pbs-datastore-endpoint.ts +1 -1
- package/src/proxmox/pbs-datastore-form.ts +18 -49
- package/src/proxmox/pbs-datastore-guard.ts +7 -4
- package/src/proxmox/pbs-datastore-lifecycle.ts +114 -0
- package/src/proxmox/pbs-datastore-wire.ts +94 -0
- package/src/proxmox/pbs-datastore.ts +7 -133
- package/src/proxmox/pbs-jobs-delete.test.ts +40 -0
- package/src/proxmox/pbs-jobs-sdk.test.ts +215 -0
- package/src/proxmox/pbs-notification-errors.test.ts +93 -0
- package/src/proxmox/pbs-notification-input.ts +25 -0
- package/src/proxmox/pbs-notification-mail.test.ts +64 -0
- package/src/proxmox/pbs-notification-matcher-distilled.ts +65 -0
- package/src/proxmox/pbs-notification-matcher.ts +70 -17
- package/src/proxmox/pbs-notification-target-distilled.ts +124 -0
- package/src/proxmox/pbs-notification-target-lifecycle.ts +26 -17
- package/src/proxmox/pbs-notification-target.ts +1 -1
- package/src/proxmox/pbs-notifications-stack.test.ts +25 -0
- package/src/proxmox/pbs-prune-job-lifecycle.ts +52 -0
- package/src/proxmox/pbs-prune-job-spec.ts +53 -0
- package/src/proxmox/pbs-prune-job-wire.ts +68 -0
- package/src/proxmox/pbs-prune-job.ts +10 -58
- package/src/proxmox/pbs-sync-job-attributes.ts +33 -0
- package/src/proxmox/pbs-sync-job-form.ts +7 -6
- package/src/proxmox/pbs-sync-job-lifecycle.ts +46 -0
- package/src/proxmox/pbs-sync-job-wire.ts +71 -0
- package/src/proxmox/pbs-sync-job.ts +10 -41
- package/src/proxmox/pbs-verify-job-lifecycle.ts +52 -0
- package/src/proxmox/pbs-verify-job-spec.ts +76 -0
- package/src/proxmox/pbs-verify-job-wire.ts +58 -0
- package/src/proxmox/pbs-verify-job.ts +13 -85
- package/src/proxmox/pool.ts +92 -10
package/src/proxmox/pool.ts
CHANGED
|
@@ -16,14 +16,17 @@
|
|
|
16
16
|
* reconcile needs, so widening stays a deliberate act rather than a reaction to a 403.
|
|
17
17
|
*/
|
|
18
18
|
import { Resource } from 'alchemy';
|
|
19
|
+
import { isResolved } from 'alchemy/Diff';
|
|
19
20
|
import * as Provider from 'alchemy/Provider';
|
|
21
|
+
import * as pools from '@distilled.cloud/proxmox/pools';
|
|
22
|
+
import { ProxmoxParseError } from '@distilled.cloud/proxmox/Errors';
|
|
23
|
+
import * as Schema from 'effect/Schema';
|
|
20
24
|
import * as Effect from 'effect/Effect';
|
|
21
|
-
import type {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from './
|
|
26
|
-
import { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';
|
|
25
|
+
import type { PoolsPoolidPutParams, PoolsPostParams } from './generated/pve.ts';
|
|
26
|
+
import type { PveRequirements, PveSpec, WithTarget } from './resource-spec.ts';
|
|
27
|
+
import { runPve } from './distilled-pve.ts';
|
|
28
|
+
import { specGuards } from './resource-guard.ts';
|
|
29
|
+
import { formToSend } from './update-guard.ts';
|
|
27
30
|
|
|
28
31
|
export interface PoolProps extends WithTarget {
|
|
29
32
|
/** PVE's primary key for a pool. Changing it is a replace, not an update. */
|
|
@@ -60,9 +63,9 @@ export const poolUpdateForm = (props: PoolProps): Pick<PoolsPoolidPutParams, 'co
|
|
|
60
63
|
comment: props.comment ?? '',
|
|
61
64
|
});
|
|
62
65
|
|
|
63
|
-
const
|
|
66
|
+
const spec = {
|
|
64
67
|
attributes: (live, props) => {
|
|
65
|
-
const row = live
|
|
68
|
+
const row = live;
|
|
66
69
|
return {
|
|
67
70
|
comment: typeof row.comment === 'string' ? row.comment : '',
|
|
68
71
|
members: Array.isArray(row.members) ? row.members.length : 0,
|
|
@@ -76,7 +79,86 @@ const handlers = pveHandlers<PoolProps, PoolAttributes>({
|
|
|
76
79
|
matches: (attributes, props) => attributes.comment === (props.comment ?? ''),
|
|
77
80
|
path: (props) => `pools/${props.poolid}`,
|
|
78
81
|
updateForm: poolUpdateForm,
|
|
79
|
-
}
|
|
82
|
+
} satisfies PveSpec<PoolProps, PoolAttributes>;
|
|
83
|
+
|
|
84
|
+
const { guardCreate, guardUpdate } = specGuards(spec);
|
|
85
|
+
|
|
86
|
+
/** Pool absence is PVE's typed 500, not a catch-all; pve-manager 9.2.11. */
|
|
87
|
+
export const readPool = (props: PoolProps) =>
|
|
88
|
+
runPve(props.target, 'read', false, pools.getPool({ poolid: props.poolid })).pipe(
|
|
89
|
+
Effect.flatMap((live) =>
|
|
90
|
+
Schema.decodeUnknownEffect(Schema.toType(pools.GetPoolResponse))(live).pipe(
|
|
91
|
+
Effect.mapError(
|
|
92
|
+
() =>
|
|
93
|
+
new ProxmoxParseError({
|
|
94
|
+
body: undefined,
|
|
95
|
+
cause: 'Pool response does not match its vendor schema',
|
|
96
|
+
}),
|
|
97
|
+
),
|
|
98
|
+
Effect.as(live),
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
Effect.map((live) => spec.attributes({ ...live }, props)),
|
|
102
|
+
Effect.catchTag('PoolNotFound', () => Effect.succeed(undefined)),
|
|
103
|
+
Effect.catchTag('NotFound', () => Effect.succeed(undefined)),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
export const deletePool = (props: PoolProps) =>
|
|
107
|
+
runPve(props.target, 'provision', true, pools.deletePool({ poolid: props.poolid })).pipe(
|
|
108
|
+
Effect.catchTag('PoolNotFound', () => Effect.void),
|
|
109
|
+
Effect.catchTag('NotFound', () => Effect.void),
|
|
110
|
+
);
|
|
80
111
|
|
|
81
112
|
export const ProxmoxPoolProvider = () =>
|
|
82
|
-
Provider.effect(
|
|
113
|
+
Provider.effect(
|
|
114
|
+
ProxmoxPool,
|
|
115
|
+
Effect.succeed(
|
|
116
|
+
ProxmoxPool.Provider.of({
|
|
117
|
+
/** Pools are adopted explicitly; an index must not silently claim every existing pool. */
|
|
118
|
+
list: () => Effect.succeed([]),
|
|
119
|
+
read: ({ olds }) => readPool(olds),
|
|
120
|
+
diff: Effect.fn(function* ({ news, output }) {
|
|
121
|
+
if (!isResolved(news)) return undefined;
|
|
122
|
+
yield* guardCreate(news, output === undefined);
|
|
123
|
+
yield* guardUpdate(news);
|
|
124
|
+
if (output === undefined) return undefined;
|
|
125
|
+
const live = yield* readPool(news);
|
|
126
|
+
if (live === undefined) {
|
|
127
|
+
yield* guardCreate(news, true);
|
|
128
|
+
return { action: 'update' } as const;
|
|
129
|
+
}
|
|
130
|
+
return { action: spec.matches(live, news) ? 'noop' : 'update' } as const;
|
|
131
|
+
}),
|
|
132
|
+
reconcile: Effect.fn(function* ({ news }) {
|
|
133
|
+
const live = yield* readPool(news);
|
|
134
|
+
yield* guardCreate(news, live === undefined);
|
|
135
|
+
yield* guardUpdate(news);
|
|
136
|
+
if (live === undefined) {
|
|
137
|
+
yield* runPve(news.target, 'provision', true, pools.createPool(poolCreateForm(news)));
|
|
138
|
+
} else {
|
|
139
|
+
const form = formToSend(spec.matches, live, news, poolUpdateForm(news));
|
|
140
|
+
if (form !== undefined)
|
|
141
|
+
yield* runPve(
|
|
142
|
+
news.target,
|
|
143
|
+
'provision',
|
|
144
|
+
true,
|
|
145
|
+
pools.putPool({
|
|
146
|
+
...form,
|
|
147
|
+
poolid: news.poolid,
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
const after = yield* readPool(news);
|
|
152
|
+
if (after === undefined)
|
|
153
|
+
return yield* Effect.fail(
|
|
154
|
+
new Error(
|
|
155
|
+
`pools/${news.poolid}: write returned success but the pool is still absent`,
|
|
156
|
+
),
|
|
157
|
+
);
|
|
158
|
+
return after;
|
|
159
|
+
}),
|
|
160
|
+
/** A nonempty-pool refusal still propagates; there is no force-delete fallback. */
|
|
161
|
+
delete: ({ olds }) => deletePool(olds),
|
|
162
|
+
}),
|
|
163
|
+
),
|
|
164
|
+
);
|