@homeflare/distilled-proxmox-backup 0.2.0
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/LICENSE +201 -0
- package/README.md +102 -0
- package/dist/credentials.d.ts +50 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +105 -0
- package/dist/credentials.js.map +1 -0
- package/dist/errors.d.ts +100 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +19 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +158 -0
- package/dist/protocol.js.map +1 -0
- package/dist/protocol.test.d.ts +2 -0
- package/dist/protocol.test.d.ts.map +1 -0
- package/dist/protocol.test.js +75 -0
- package/dist/protocol.test.js.map +1 -0
- package/dist/retry.d.ts +53 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +46 -0
- package/dist/retry.js.map +1 -0
- package/dist/services/access.d.ts +587 -0
- package/dist/services/access.d.ts.map +1 -0
- package/dist/services/access.js +787 -0
- package/dist/services/access.js.map +1 -0
- package/dist/services/admin.d.ts +1110 -0
- package/dist/services/admin.d.ts.map +1 -0
- package/dist/services/admin.js +1428 -0
- package/dist/services/admin.js.map +1 -0
- package/dist/services/backup.d.ts +224 -0
- package/dist/services/backup.d.ts.map +1 -0
- package/dist/services/backup.js +325 -0
- package/dist/services/backup.js.map +1 -0
- package/dist/services/config.d.ts +3662 -0
- package/dist/services/config.d.ts.map +1 -0
- package/dist/services/config.js +4445 -0
- package/dist/services/config.js.map +1 -0
- package/dist/services/index.d.ts +14 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +15 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/nodes.d.ts +1441 -0
- package/dist/services/nodes.d.ts.map +1 -0
- package/dist/services/nodes.js +1829 -0
- package/dist/services/nodes.js.map +1 -0
- package/dist/services/ping.d.ts +15 -0
- package/dist/services/ping.d.ts.map +1 -0
- package/dist/services/ping.js +21 -0
- package/dist/services/ping.js.map +1 -0
- package/dist/services/pull.d.ts +54 -0
- package/dist/services/pull.d.ts.map +1 -0
- package/dist/services/pull.js +47 -0
- package/dist/services/pull.js.map +1 -0
- package/dist/services/push.d.ts +50 -0
- package/dist/services/push.d.ts.map +1 -0
- package/dist/services/push.js +45 -0
- package/dist/services/push.js.map +1 -0
- package/dist/services/reader.d.ts +68 -0
- package/dist/services/reader.d.ts.map +1 -0
- package/dist/services/reader.js +89 -0
- package/dist/services/reader.js.map +1 -0
- package/dist/services/root.d.ts +14 -0
- package/dist/services/root.d.ts.map +1 -0
- package/dist/services/root.js +19 -0
- package/dist/services/root.js.map +1 -0
- package/dist/services/status.d.ts +78 -0
- package/dist/services/status.d.ts.map +1 -0
- package/dist/services/status.js +97 -0
- package/dist/services/status.js.map +1 -0
- package/dist/services/tape.d.ts +711 -0
- package/dist/services/tape.d.ts.map +1 -0
- package/dist/services/tape.js +986 -0
- package/dist/services/tape.js.map +1 -0
- package/dist/services/version.d.ts +17 -0
- package/dist/services/version.d.ts.map +1 -0
- package/dist/services/version.js +25 -0
- package/dist/services/version.js.map +1 -0
- package/dist/task.d.ts +48 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +57 -0
- package/dist/task.js.map +1 -0
- package/dist/traits.d.ts +13 -0
- package/dist/traits.d.ts.map +1 -0
- package/dist/traits.js +15 -0
- package/dist/traits.js.map +1 -0
- package/package.json +81 -0
- package/src/credentials.ts +139 -0
- package/src/errors.ts +126 -0
- package/src/index.ts +36 -0
- package/src/protocol.test.ts +128 -0
- package/src/protocol.ts +196 -0
- package/src/retry.ts +79 -0
- package/src/services/access.ts +1787 -0
- package/src/services/admin.ts +3258 -0
- package/src/services/backup.ts +698 -0
- package/src/services/config.ts +10561 -0
- package/src/services/index.ts +14 -0
- package/src/services/nodes.ts +4313 -0
- package/src/services/ping.ts +43 -0
- package/src/services/pull.ts +118 -0
- package/src/services/push.ts +108 -0
- package/src/services/reader.ts +196 -0
- package/src/services/root.ts +39 -0
- package/src/services/status.ts +233 -0
- package/src/services/tape.ts +2257 -0
- package/src/services/version.ts +49 -0
- package/src/task.ts +84 -0
- package/src/traits.ts +46 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (apidoc.js, via scripts/apidoc.ts — see its header). Do not edit.
|
|
2
|
+
import * as S from "@distilled.cloud/core/schema";
|
|
3
|
+
import * as API from "@distilled.cloud/core/api";
|
|
4
|
+
import * as T from "../traits.ts";
|
|
5
|
+
import {
|
|
6
|
+
ProxmoxBackupProtocol,
|
|
7
|
+
type ProxmoxBackupOpError,
|
|
8
|
+
type ProxmoxBackupOpContext,
|
|
9
|
+
} from "../protocol.ts";
|
|
10
|
+
import * as Retry from "../retry.ts";
|
|
11
|
+
|
|
12
|
+
export type { ProxmoxBackupOpError, ProxmoxBackupOpContext };
|
|
13
|
+
|
|
14
|
+
export interface GetVersionRequest {}
|
|
15
|
+
export const GetVersionRequest = /*@__PURE__*/ S.suspend(() =>
|
|
16
|
+
S.Struct({}).pipe(T.Http({ method: "GET", uri: "/version", code: 200 })),
|
|
17
|
+
).annotate({
|
|
18
|
+
identifier: "GetVersionRequest",
|
|
19
|
+
}) as any as S.Schema<GetVersionRequest>;
|
|
20
|
+
|
|
21
|
+
export interface GetVersionResponse {
|
|
22
|
+
release: string;
|
|
23
|
+
repoid: string;
|
|
24
|
+
version: string;
|
|
25
|
+
}
|
|
26
|
+
export const GetVersionResponse = /*@__PURE__*/ S.suspend(() =>
|
|
27
|
+
S.Struct({
|
|
28
|
+
release: S.String,
|
|
29
|
+
repoid: S.String,
|
|
30
|
+
version: S.String,
|
|
31
|
+
}),
|
|
32
|
+
).annotate({
|
|
33
|
+
identifier: "GetVersionResponse",
|
|
34
|
+
}) as any as S.Schema<GetVersionResponse>;
|
|
35
|
+
|
|
36
|
+
export type GetVersionError = ProxmoxBackupOpError;
|
|
37
|
+
/** Proxmox Backup Server API version. */
|
|
38
|
+
export const getVersion: API.OperationMethod<
|
|
39
|
+
GetVersionRequest,
|
|
40
|
+
GetVersionResponse,
|
|
41
|
+
GetVersionError,
|
|
42
|
+
ProxmoxBackupOpContext
|
|
43
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
44
|
+
input: GetVersionRequest,
|
|
45
|
+
output: GetVersionResponse,
|
|
46
|
+
errors: [],
|
|
47
|
+
protocol: ProxmoxBackupProtocol,
|
|
48
|
+
retry: Retry.Retry,
|
|
49
|
+
}));
|
package/src/task.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Awaiting a PBS task — trap (a) from `src/protocol.ts`'s header.
|
|
3
|
+
*
|
|
4
|
+
* Ported from `packages/proxmox/src/task.ts` unchanged in its polling
|
|
5
|
+
* logic and exact-equality check — PBS answers a long-running action
|
|
6
|
+
* (backup, sync job, garbage collection, tape write, …) with HTTP 200 and
|
|
7
|
+
* a bare UPID string the moment the task is QUEUED, the same as PVE. The
|
|
8
|
+
* only way to know whether it actually succeeded is to poll `GET /nodes/
|
|
9
|
+
* {node}/tasks/{upid}/status` — this package's generated
|
|
10
|
+
* `Services.nodes.getNodeTaskStatus` — until the response carries an
|
|
11
|
+
* `exitstatus`, and then check that value.
|
|
12
|
+
*
|
|
13
|
+
* ⛔ `exitstatus` IS COMPARED FOR EXACT EQUALITY TO `"OK"`, NEVER A PREFIX
|
|
14
|
+
* OR SUBSTRING CHECK — carried from PVE's identical warning; not
|
|
15
|
+
* independently re-measured that PBS also answers `"OK (warnings)"`
|
|
16
|
+
* (no live PBS calls in this build), but the exact-equality form is
|
|
17
|
+
* strictly safer than a looser one either way, so there is no reason to
|
|
18
|
+
* weaken it pending that confirmation.
|
|
19
|
+
*
|
|
20
|
+
* `awaitTask` does not itself apply a deadline — wrap the call with
|
|
21
|
+
* `Effect.timeout` (or `Retry.transient`/a caller-supplied policy).
|
|
22
|
+
*
|
|
23
|
+
* NOT carried from PVE: `ClusterNodeUnreachable` in the failure union —
|
|
24
|
+
* see `src/errors.ts`'s header for why PBS has no cluster-forwarding trap.
|
|
25
|
+
*/
|
|
26
|
+
import * as Effect from "effect/Effect";
|
|
27
|
+
import type * as Duration from "effect/Duration";
|
|
28
|
+
import type { ProxmoxBackupOpContext } from "./protocol.ts";
|
|
29
|
+
import { ProxmoxBackupTaskFailed } from "./errors.ts";
|
|
30
|
+
import * as nodes from "./services/nodes.ts";
|
|
31
|
+
import type {
|
|
32
|
+
GetNodeTaskStatusError,
|
|
33
|
+
GetNodeTaskStatusResponse,
|
|
34
|
+
} from "./services/nodes.ts";
|
|
35
|
+
|
|
36
|
+
/** Identifies one PBS task. `node` is always the single PBS host — kept as a field for parity with `@distilled.cloud/proxmox`'s identical shape, and because the vendor schema's own path template names it `{node}` regardless. */
|
|
37
|
+
export interface TaskRef {
|
|
38
|
+
readonly node: string;
|
|
39
|
+
readonly upid: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface AwaitTaskOptions {
|
|
43
|
+
/** Delay between polls. Default 1 second. */
|
|
44
|
+
readonly pollInterval?: Duration.Input;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Poll a task to completion. Resolves with the FINAL status response (so a
|
|
49
|
+
* caller can read `pid`/`starttime`/etc. without a second call) once
|
|
50
|
+
* `exitstatus` is exactly `"OK"`; fails with {@link ProxmoxBackupTaskFailed}
|
|
51
|
+
* for any other `exitstatus`, or with whatever `getNodeTaskStatus` itself
|
|
52
|
+
* failed with.
|
|
53
|
+
*/
|
|
54
|
+
export const awaitTask = (
|
|
55
|
+
ref: TaskRef,
|
|
56
|
+
options: AwaitTaskOptions = {},
|
|
57
|
+
): Effect.Effect<
|
|
58
|
+
GetNodeTaskStatusResponse,
|
|
59
|
+
ProxmoxBackupTaskFailed | GetNodeTaskStatusError,
|
|
60
|
+
ProxmoxBackupOpContext
|
|
61
|
+
> =>
|
|
62
|
+
Effect.gen(function* () {
|
|
63
|
+
const pollInterval = options.pollInterval ?? "1 second";
|
|
64
|
+
while (true) {
|
|
65
|
+
const status = yield* nodes.getNodeTaskStatus({
|
|
66
|
+
node: ref.node,
|
|
67
|
+
upid: ref.upid,
|
|
68
|
+
});
|
|
69
|
+
if (status.exitstatus === undefined) {
|
|
70
|
+
yield* Effect.sleep(pollInterval);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (status.exitstatus !== "OK") {
|
|
74
|
+
return yield* Effect.fail(
|
|
75
|
+
new ProxmoxBackupTaskFailed({
|
|
76
|
+
node: ref.node,
|
|
77
|
+
upid: ref.upid,
|
|
78
|
+
exitstatus: status.exitstatus,
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
return status;
|
|
83
|
+
}
|
|
84
|
+
});
|
package/src/traits.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxmox Backup Server SDK trait surface — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Copied unchanged from `packages/proxmox/src/traits.ts`. Re-exports the
|
|
5
|
+
* generic protocol traits from core so generated operations import
|
|
6
|
+
* everything from one place. PBS speaks form-urlencoded/query REST with a
|
|
7
|
+
* `{"data": …}` envelope and no bare-array response bodies of its own
|
|
8
|
+
* shape beyond what `RawResponse`/`RawResponseRoot` already cover (see
|
|
9
|
+
* `scripts/convert.ts`'s header), so there are no PBS-specific traits.
|
|
10
|
+
*/
|
|
11
|
+
export {
|
|
12
|
+
Body,
|
|
13
|
+
Header,
|
|
14
|
+
Query,
|
|
15
|
+
Label,
|
|
16
|
+
Http,
|
|
17
|
+
ResponseCode,
|
|
18
|
+
HttpBody,
|
|
19
|
+
FormDataFile,
|
|
20
|
+
KeyDictionary,
|
|
21
|
+
UnionCases,
|
|
22
|
+
applyErrorMatchers,
|
|
23
|
+
getErrorMatchers,
|
|
24
|
+
type HttpTrait,
|
|
25
|
+
type ErrorMatcher,
|
|
26
|
+
bodySymbol,
|
|
27
|
+
headerSymbol,
|
|
28
|
+
querySymbol,
|
|
29
|
+
labelSymbol,
|
|
30
|
+
httpSymbol,
|
|
31
|
+
responseCodeSymbol,
|
|
32
|
+
httpBodySymbol,
|
|
33
|
+
formDataFileSymbol,
|
|
34
|
+
keyDictionarySymbol,
|
|
35
|
+
unionCasesSymbol,
|
|
36
|
+
errorMatchersSymbol,
|
|
37
|
+
} from "@distilled.cloud/core/trait";
|
|
38
|
+
|
|
39
|
+
// Bearer-REST protocol traits (bare-payload responses; PBS has no
|
|
40
|
+
// sensitive-member marking today — every generated member is plain).
|
|
41
|
+
export {
|
|
42
|
+
RawResponse,
|
|
43
|
+
RawResponseRoot,
|
|
44
|
+
rawResponseSymbol,
|
|
45
|
+
rawResponseRootSymbol,
|
|
46
|
+
} from "@distilled.cloud/core/protocol-rest";
|