unfazed 0.0.1 → 0.1.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 +21 -0
- package/README.md +300 -1
- package/dist/client.d.ts +134 -0
- package/dist/client.js +266 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +93 -0
- package/dist/errors.js +137 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/gql.d.ts +132 -0
- package/dist/generated/gql.js +41 -0
- package/dist/generated/gql.js.map +1 -0
- package/dist/generated/graphql.d.ts +774 -0
- package/dist/generated/graphql.js +607 -0
- package/dist/generated/graphql.js.map +1 -0
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.js +2 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/operations.d.ts +136 -0
- package/dist/operations.js +461 -0
- package/dist/operations.js.map +1 -0
- package/dist/unfazed.d.ts +445 -0
- package/dist/unfazed.js +510 -0
- package/dist/unfazed.js.map +1 -0
- package/dist/wait.d.ts +57 -0
- package/dist/wait.js +59 -0
- package/dist/wait.js.map +1 -0
- package/package.json +50 -6
- package/schema/SOURCE.json +9 -0
- package/schema/schema.graphqls +1303 -0
- package/index.js +0 -2
package/dist/wait.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knobs for any polling wait.
|
|
3
|
+
*
|
|
4
|
+
* `sleep` and `now` are injectable so the test suite can drive multi-minute
|
|
5
|
+
* backoff schedules instantly and assert the exact interval sequence, instead
|
|
6
|
+
* of actually waiting. Production code never passes them.
|
|
7
|
+
*/
|
|
8
|
+
export interface WaitOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Give up after this long. Default 600_000 (10 minutes) — a cold Bun build
|
|
11
|
+
* plus VM boot and health probe routinely runs into minutes, and the build
|
|
12
|
+
* microVM's own ceiling is 600s.
|
|
13
|
+
*/
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
/** First poll delay in ms. Default 1_000. */
|
|
16
|
+
initialIntervalMs?: number;
|
|
17
|
+
/** Ceiling for the backoff in ms. Default 10_000. */
|
|
18
|
+
maxIntervalMs?: number;
|
|
19
|
+
/** Backoff multiplier. Default 1.5. */
|
|
20
|
+
factor?: number;
|
|
21
|
+
/** Cancels the wait; surfaces as {@link UnfazedTimeoutError}. */
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
/** Injected clock (tests). */
|
|
24
|
+
now?: () => number;
|
|
25
|
+
/** Injected sleep (tests). */
|
|
26
|
+
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export interface ResolvedWaitOptions {
|
|
29
|
+
timeoutMs: number;
|
|
30
|
+
initialIntervalMs: number;
|
|
31
|
+
maxIntervalMs: number;
|
|
32
|
+
factor: number;
|
|
33
|
+
signal: AbortSignal | undefined;
|
|
34
|
+
now: () => number;
|
|
35
|
+
sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export declare function resolveWaitOptions(options?: WaitOptions): ResolvedWaitOptions;
|
|
38
|
+
/** What one poll tick decided. */
|
|
39
|
+
export type PollDecision<T> = {
|
|
40
|
+
done: true;
|
|
41
|
+
value: T;
|
|
42
|
+
} | {
|
|
43
|
+
done: false;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Generic exponential-backoff poll loop.
|
|
47
|
+
*
|
|
48
|
+
* Polls immediately (no initial sleep — most callers have just created the
|
|
49
|
+
* thing and a first read is nearly free), then backs off geometrically up to
|
|
50
|
+
* `maxIntervalMs`. The final sleep is clamped so the loop cannot overshoot
|
|
51
|
+
* `timeoutMs`, which keeps `wait: true` honest as a deadline rather than a
|
|
52
|
+
* suggestion.
|
|
53
|
+
*
|
|
54
|
+
* `onTimeout` builds the error so callers can attach their own context (the
|
|
55
|
+
* last deployment snapshot, say) instead of getting a bare timeout.
|
|
56
|
+
*/
|
|
57
|
+
export declare function pollWithBackoff<T>(poll: () => Promise<PollDecision<T>>, options: ResolvedWaitOptions, onTimeout: () => Error): Promise<T>;
|
package/dist/wait.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { UnfazedTimeoutError } from "./errors.js";
|
|
2
|
+
export function resolveWaitOptions(options = {}) {
|
|
3
|
+
return {
|
|
4
|
+
timeoutMs: options.timeoutMs ?? 600_000,
|
|
5
|
+
initialIntervalMs: options.initialIntervalMs ?? 1_000,
|
|
6
|
+
maxIntervalMs: options.maxIntervalMs ?? 10_000,
|
|
7
|
+
factor: options.factor ?? 1.5,
|
|
8
|
+
signal: options.signal,
|
|
9
|
+
now: options.now ?? (() => Date.now()),
|
|
10
|
+
sleep: options.sleep ?? defaultSleep,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function defaultSleep(ms, signal) {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
if (signal?.aborted) {
|
|
16
|
+
reject(new UnfazedTimeoutError("unfazed: wait aborted"));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const timer = setTimeout(() => {
|
|
20
|
+
signal?.removeEventListener("abort", onAbort);
|
|
21
|
+
resolve();
|
|
22
|
+
}, ms);
|
|
23
|
+
const onAbort = () => {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
reject(new UnfazedTimeoutError("unfazed: wait aborted"));
|
|
26
|
+
};
|
|
27
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generic exponential-backoff poll loop.
|
|
32
|
+
*
|
|
33
|
+
* Polls immediately (no initial sleep — most callers have just created the
|
|
34
|
+
* thing and a first read is nearly free), then backs off geometrically up to
|
|
35
|
+
* `maxIntervalMs`. The final sleep is clamped so the loop cannot overshoot
|
|
36
|
+
* `timeoutMs`, which keeps `wait: true` honest as a deadline rather than a
|
|
37
|
+
* suggestion.
|
|
38
|
+
*
|
|
39
|
+
* `onTimeout` builds the error so callers can attach their own context (the
|
|
40
|
+
* last deployment snapshot, say) instead of getting a bare timeout.
|
|
41
|
+
*/
|
|
42
|
+
export async function pollWithBackoff(poll, options, onTimeout) {
|
|
43
|
+
const { timeoutMs, initialIntervalMs, maxIntervalMs, factor, signal, now, sleep } = options;
|
|
44
|
+
const deadline = now() + timeoutMs;
|
|
45
|
+
let interval = initialIntervalMs;
|
|
46
|
+
for (;;) {
|
|
47
|
+
if (signal?.aborted)
|
|
48
|
+
throw new UnfazedTimeoutError("unfazed: wait aborted");
|
|
49
|
+
const decision = await poll();
|
|
50
|
+
if (decision.done)
|
|
51
|
+
return decision.value;
|
|
52
|
+
const remaining = deadline - now();
|
|
53
|
+
if (remaining <= 0)
|
|
54
|
+
throw onTimeout();
|
|
55
|
+
await sleep(Math.min(interval, remaining), signal);
|
|
56
|
+
interval = Math.min(interval * factor, maxIntervalMs);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=wait.js.map
|
package/dist/wait.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.js","sourceRoot":"","sources":["../src/wait.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAwClD,MAAM,UAAU,kBAAkB,CAAC,UAAuB,EAAE;IAC1D,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,OAAO;QACvC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,KAAK;QACrD,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,MAAM;QAC9C,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,GAAG;QAC7B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAC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E,CAAC;QAC9B,IAAI,QAAQ,CAAC,IAAI;YAAE,OAAO,QAAQ,CAAC,KAAK,CAAC;QAEzC,MAAM,SAAS,GAAG,QAAQ,GAAG,GAAG,EAAE,CAAC;QACnC,IAAI,SAAS,IAAI,CAAC;YAAE,MAAM,SAAS,EAAE,CAAC;QAEtC,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;QACnD,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;AACH,CAAC","sourcesContent":["import { UnfazedTimeoutError } from \"./errors.js\";\n\n/**\n * Knobs for any polling wait.\n *\n * `sleep` and `now` are injectable so the test suite can drive multi-minute\n * backoff schedules instantly and assert the exact interval sequence, instead\n * of actually waiting. Production code never passes them.\n */\nexport interface WaitOptions {\n /**\n * Give up after this long. Default 600_000 (10 minutes) — a cold Bun build\n * plus VM boot and health probe routinely runs into minutes, and the build\n * microVM's own ceiling is 600s.\n */\n timeoutMs?: number;\n /** First poll delay in ms. Default 1_000. */\n initialIntervalMs?: number;\n /** Ceiling for the backoff in ms. Default 10_000. */\n maxIntervalMs?: number;\n /** Backoff multiplier. Default 1.5. */\n factor?: number;\n /** Cancels the wait; surfaces as {@link UnfazedTimeoutError}. */\n signal?: AbortSignal;\n /** Injected clock (tests). */\n now?: () => number;\n /** Injected sleep (tests). */\n sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;\n}\n\nexport interface ResolvedWaitOptions {\n timeoutMs: number;\n initialIntervalMs: number;\n maxIntervalMs: number;\n factor: number;\n signal: AbortSignal | undefined;\n now: () => number;\n sleep: (ms: number, signal?: AbortSignal) => Promise<void>;\n}\n\nexport function resolveWaitOptions(options: WaitOptions = {}): ResolvedWaitOptions {\n return {\n timeoutMs: options.timeoutMs ?? 600_000,\n initialIntervalMs: options.initialIntervalMs ?? 1_000,\n maxIntervalMs: options.maxIntervalMs ?? 10_000,\n factor: options.factor ?? 1.5,\n signal: options.signal,\n now: options.now ?? (() => Date.now()),\n sleep: options.sleep ?? defaultSleep,\n };\n}\n\nfunction defaultSleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(new UnfazedTimeoutError(\"unfazed: wait aborted\"));\n return;\n }\n const timer = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n }, ms);\n const onAbort = () => {\n clearTimeout(timer);\n reject(new UnfazedTimeoutError(\"unfazed: wait aborted\"));\n };\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n\n/** What one poll tick decided. */\nexport type PollDecision<T> = { done: true; value: T } | { done: false };\n\n/**\n * Generic exponential-backoff poll loop.\n *\n * Polls immediately (no initial sleep — most callers have just created the\n * thing and a first read is nearly free), then backs off geometrically up to\n * `maxIntervalMs`. The final sleep is clamped so the loop cannot overshoot\n * `timeoutMs`, which keeps `wait: true` honest as a deadline rather than a\n * suggestion.\n *\n * `onTimeout` builds the error so callers can attach their own context (the\n * last deployment snapshot, say) instead of getting a bare timeout.\n */\nexport async function pollWithBackoff<T>(\n poll: () => Promise<PollDecision<T>>,\n options: ResolvedWaitOptions,\n onTimeout: () => Error,\n): Promise<T> {\n const { timeoutMs, initialIntervalMs, maxIntervalMs, factor, signal, now, sleep } = options;\n const deadline = now() + timeoutMs;\n let interval = initialIntervalMs;\n\n for (;;) {\n if (signal?.aborted) throw new UnfazedTimeoutError(\"unfazed: wait aborted\");\n\n const decision = await poll();\n if (decision.done) return decision.value;\n\n const remaining = deadline - now();\n if (remaining <= 0) throw onTimeout();\n\n await sleep(Math.min(interval, remaining), signal);\n interval = Math.min(interval * factor, maxIntervalMs);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,25 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unfazed",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official TypeScript SDK for unfazed. The code-mode companion to the unfazed MCP server: deploy, wait, tail logs and roll back from one script.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "./index.js",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
8
10
|
"exports": {
|
|
9
|
-
".":
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
10
17
|
},
|
|
11
18
|
"files": [
|
|
12
|
-
"
|
|
19
|
+
"dist",
|
|
20
|
+
"schema/schema.graphqls",
|
|
21
|
+
"schema/SOURCE.json",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
13
24
|
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"engines": {
|
|
27
|
+
"bun": ">=1.2",
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
14
30
|
"keywords": [
|
|
15
|
-
"unfazed"
|
|
31
|
+
"unfazed",
|
|
32
|
+
"deploy",
|
|
33
|
+
"deployment",
|
|
34
|
+
"graphql",
|
|
35
|
+
"sdk",
|
|
36
|
+
"agents",
|
|
37
|
+
"code-mode",
|
|
38
|
+
"mcp",
|
|
39
|
+
"bun"
|
|
16
40
|
],
|
|
17
41
|
"repository": {
|
|
18
42
|
"type": "git",
|
|
19
43
|
"url": "git+https://github.com/jilio/unfazed-packages.git",
|
|
20
44
|
"directory": "packages/unfazed"
|
|
21
45
|
},
|
|
46
|
+
"homepage": "https://unfazed.dev",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/jilio/unfazed-packages/issues"
|
|
49
|
+
},
|
|
22
50
|
"publishConfig": {
|
|
23
51
|
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"sync-schema": "bun run scripts/sync-schema.ts",
|
|
55
|
+
"codegen": "graphql-codegen --config codegen.ts && bun run scripts/postcodegen.ts",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
58
|
+
"test": "bun test",
|
|
59
|
+
"smoke": "bun test/smoke-dist.mjs && node test/smoke-dist.mjs",
|
|
60
|
+
"check": "bun run typecheck && bun test && bun run build && bun run smoke"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@graphql-codegen/cli": "^7.1.2",
|
|
64
|
+
"@graphql-codegen/client-preset": "^6.0.1",
|
|
65
|
+
"@types/bun": "^1.3.9",
|
|
66
|
+
"graphql": "^16.14.2",
|
|
67
|
+
"typescript": "^6.0.3"
|
|
24
68
|
}
|
|
25
69
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Provenance for the vendored copy of graph/schema.graphqls. Written by scripts/sync-schema.ts — do not edit by hand.",
|
|
3
|
+
"repo": "unfazed",
|
|
4
|
+
"path": "graph/schema.graphqls",
|
|
5
|
+
"unfazedCommit": "c7068473bafd49e0f7f8705a53bf1d4b451d855b",
|
|
6
|
+
"schemaLastChangedCommit": "fd278d74ac63bc20c4d5adc274559dd096964dc3",
|
|
7
|
+
"sha256": "508b78d0661ce28c6be5a10625d0d9804846f645bb2b952ae166232645b921ba",
|
|
8
|
+
"syncedAt": "2026-08-27"
|
|
9
|
+
}
|