unfazed 0.8.0 → 0.8.1
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/CHANGELOG.md +36 -0
- package/README.md +3 -3
- package/REFERENCE.md +25 -11
- package/dist/cli/login.d.ts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/generated/gql.d.ts +14 -2
- package/dist/generated/gql.js +5 -2
- package/dist/generated/gql.js.map +1 -1
- package/dist/generated/graphql.d.ts +82 -1
- package/dist/generated/graphql.js +87 -1
- package/dist/generated/graphql.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/operations.d.ts +29 -1
- package/dist/operations.js +70 -1
- package/dist/operations.js.map +1 -1
- package/dist/reference.generated.js +1 -1
- package/dist/reference.generated.js.map +1 -1
- package/dist/unfazed.d.ts +71 -17
- package/dist/unfazed.js +204 -50
- package/dist/unfazed.js.map +1 -1
- package/package.json +1 -1
- package/schema/SOURCE.json +3 -3
- package/schema/schema.graphqls +81 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
Follows the platform's final `waitForDeployment` and timings contract
|
|
6
|
+
(schema synced from unfazed `4be60456`). Needs that platform:
|
|
7
|
+
`restoreVersion`, `getEvents` and `getDeploymentTimings` ask for fields an
|
|
8
|
+
older one does not have. A deploy's `wait: true` and `waitForDeployment` by
|
|
9
|
+
id still work on one.
|
|
10
|
+
|
|
11
|
+
**Changed**
|
|
12
|
+
|
|
13
|
+
- `restoreVersion({ wait: true })` waits for its deploy on the platform by
|
|
14
|
+
commit (`gitCommit: sha`, `alias: deployAlias`, `after: waitAfter`): one
|
|
15
|
+
request per up to 45 s instead of polling the git source, and the answer is
|
|
16
|
+
the READY deployment itself. A failed import throws `UnfazedDeployError`
|
|
17
|
+
with the import's error, a failed build with the build's. A link with
|
|
18
|
+
unfazed.json `apps[]` (no `deployAlias`) deploys once per app, so it still
|
|
19
|
+
follows the import until every deployment it made is done.
|
|
20
|
+
- `RestoreVersionResult` carries `workspaceID` and `waitAfter`.
|
|
21
|
+
- `getDeploymentTimings(id)` reads `Deployment.timings`, which the platform
|
|
22
|
+
parses from all of the deployment's events (it read the latest 100 events
|
|
23
|
+
before, which a busy service could outgrow).
|
|
24
|
+
- `parseDeploymentTimings(events)` prefers the `timings` the platform parsed
|
|
25
|
+
into each timing event, and reads metadata exactly as the platform does:
|
|
26
|
+
a duration is a whole, non-negative number of milliseconds; negative,
|
|
27
|
+
fractional and non-numeric values are dropped (they were kept), an empty
|
|
28
|
+
`build_mode` is null and a `build_memory_mib` of 0 is null.
|
|
29
|
+
|
|
30
|
+
**Added**
|
|
31
|
+
|
|
32
|
+
- `waitForDeployment({ workspaceId, gitCommit, alias?, after? })`: the wait
|
|
33
|
+
by commit, for the deploy a restore, push or sync makes before any id
|
|
34
|
+
exists. It covers the import too; past the platform's cap on waits in
|
|
35
|
+
progress it backs off and asks again.
|
|
36
|
+
- `DeploymentEvent.timings`: a timing event's phases as numbers.
|
|
37
|
+
- Types `CommitDeploymentTarget` and `TimingEvent`.
|
|
38
|
+
|
|
3
39
|
## 0.8.0
|
|
4
40
|
|
|
5
41
|
Fixes from a hands-on Code Mode test (2026-10-22), and the MCP tools the SDK
|
package/README.md
CHANGED
|
@@ -243,7 +243,7 @@ The chains an agent actually performs. Reach `client` from it any time:
|
|
|
243
243
|
| `deployStatic(opts)` | `spaMode` for single-page apps |
|
|
244
244
|
| `deployBox(opts)` | persistent Linux VM; result carries `sshCommand` |
|
|
245
245
|
| `deploy(input, opts?)` | raw `CreateDeploymentInput` escape hatch |
|
|
246
|
-
| `waitForDeployment(id, opts?)` | the server-side wait (MCP `wait_for_deployment`); polls on older platforms |
|
|
246
|
+
| `waitForDeployment(id \| { workspaceId, gitCommit, alias?, after? }, opts?)` | the server-side wait (MCP `wait_for_deployment`), by id or by the commit a git import deploys; by id it polls on older platforms |
|
|
247
247
|
| `getDeployment(id)` / `getDeploymentByAlias(alias)` | |
|
|
248
248
|
| `listDeployments(filter?)` | |
|
|
249
249
|
|
|
@@ -253,7 +253,7 @@ The chains an agent actually performs. Reach `client` from it any time:
|
|
|
253
253
|
| `getLogs(id, { tailBytes })` | stdout + stderr tail |
|
|
254
254
|
| `getStatus(id)` | health, in-flight, restarts, `memSizeMiB` |
|
|
255
255
|
| `getEvents(id, limit?)` | lifecycle events; `type` is the dotted name MCP shows (`deployment.build_finished`), `typeEnum` the GraphQL enum |
|
|
256
|
-
| `getDeploymentTimings(id)` | the platform's measured phases, as numbers |
|
|
256
|
+
| `getDeploymentTimings(id)` | the platform's measured phases, as numbers (`Deployment.timings`) |
|
|
257
257
|
| `restartService(id)` / `stopService(id)` | |
|
|
258
258
|
| `deleteDeployment(id, opts?)` | `ignoreNotFound` for idempotent cleanup |
|
|
259
259
|
|
|
@@ -277,7 +277,7 @@ The chains an agent actually performs. Reach `client` from it any time:
|
|
|
277
277
|
| --- | --- |
|
|
278
278
|
| `listCommits(wsId, { limit?, before? })` | newest first; `deployed` says what each alias runs (MCP `list_commits`) |
|
|
279
279
|
| `getCommit(wsId, sha)` | the changed paths and a unified diff (MCP `get_commit`) |
|
|
280
|
-
| `restoreVersion({ workspaceId, sha, wait? })` | one new commit with that commit's files; `wait: true`
|
|
280
|
+
| `restoreVersion({ workspaceId, sha, wait? })` | one new commit with that commit's files; `wait: true` waits for its deploy by commit to READY (MCP `restore_version`) |
|
|
281
281
|
|
|
282
282
|
**App errors**
|
|
283
283
|
| Method | Notes |
|
package/REFERENCE.md
CHANGED
|
@@ -126,13 +126,20 @@ A persistent Linux VM over SSH (`sshCommand`). Always pass `alias`.
|
|
|
126
126
|
### `deploy(input: CreateDeploymentInput, options?: { wait?, waitOptions?, timings? }): Promise<DeployResult>`
|
|
127
127
|
Any `createDeployment` input.
|
|
128
128
|
|
|
129
|
-
### `waitForDeployment(
|
|
129
|
+
### `waitForDeployment(target: string | { workspaceId, gitCommit, alias?, after? }, waitOptions?: WaitOptions): Promise<Deployment>`
|
|
130
130
|
Waits server-side (MCP `wait_for_deployment`: one request per 45 s at most,
|
|
131
131
|
answered when the status changes) until READY; throws `UnfazedDeployError`
|
|
132
132
|
on FAILED or timeout. A new app's landing on its server is waited for too.
|
|
133
133
|
`waitOptions: { timeoutMs?, signal?, mode?: "server" | "poll" }`. The
|
|
134
134
|
platform holds at most 16 waits of one account at once; past that a wait
|
|
135
|
-
polls instead.
|
|
135
|
+
by id polls instead.
|
|
136
|
+
|
|
137
|
+
Instead of an id, name the deploy a git import makes of a commit (a
|
|
138
|
+
restore, a push or a sync deploys before any id exists): `{ workspaceId,
|
|
139
|
+
gitCommit, alias?, after? }`. The wait covers the import too, and a failed
|
|
140
|
+
import throws `UnfazedDeployError` with its error. `alias` is required when
|
|
141
|
+
several apps (`apps[]`) deployed the commit; `after` (a restore's
|
|
142
|
+
`waitAfter`) counts only deployments begun after it.
|
|
136
143
|
|
|
137
144
|
### `getDeployment(deploymentId: string): Promise<Deployment | null>`
|
|
138
145
|
|
|
@@ -161,15 +168,18 @@ Filter in the script: `logs.stderr.split("\n").filter((l) => l.includes("ERROR")
|
|
|
161
168
|
|
|
162
169
|
### `getEvents(deploymentId: string, limit?: number): Promise<DeploymentEvent[]>`
|
|
163
170
|
The latest `limit` (default 20) lifecycle events, oldest first: `{ type,
|
|
164
|
-
typeEnum, severity, message, vmID, metadata, createdAt }`. `type`
|
|
165
|
-
event's own name, as MCP reports it: `"deployment.build_finished"`,
|
|
171
|
+
typeEnum, severity, message, vmID, metadata, timings, createdAt }`. `type`
|
|
172
|
+
is the event's own name, as MCP reports it: `"deployment.build_finished"`,
|
|
166
173
|
`"deployment.phases"`, `"service.vm_started"`. `typeEnum` is the GraphQL
|
|
167
|
-
enum (`UNKNOWN` for names it lacks); match on `type`.
|
|
174
|
+
enum (`UNKNOWN` for names it lacks); match on `type`. A timing event's
|
|
175
|
+
`timings` is what it measured, parsed by the platform; null otherwise.
|
|
168
176
|
|
|
169
177
|
### `getDeploymentTimings(deploymentId: string): Promise<PlatformTimings | null>`
|
|
170
|
-
A deploy's measured phases (ms)
|
|
171
|
-
buildMs, promoteMs, phases, buildMode,
|
|
172
|
-
`parseDeploymentTimings(events)` does
|
|
178
|
+
A deploy's measured phases (ms), as the platform reads them from all its
|
|
179
|
+
timing events: `{ totalMs, buildMs, promoteMs, phases, buildMode,
|
|
180
|
+
artifactTransport, buildMemoryMiB }`. `parseDeploymentTimings(events)` does
|
|
181
|
+
the same for events you already read, preferring each event's `timings`;
|
|
182
|
+
durations are whole, non-negative milliseconds (anything else is dropped).
|
|
173
183
|
|
|
174
184
|
### `restartService(deploymentId: string)` / `stopService(deploymentId: string)`
|
|
175
185
|
|
|
@@ -206,9 +216,13 @@ deletions }` (MCP `get_commit`).
|
|
|
206
216
|
|
|
207
217
|
### `restoreVersion(options: { workspaceId, sha, expectedHead?, commitMessage?, wait?, waitOptions? }): Promise<RestoreVersionResult>`
|
|
208
218
|
One new commit with that commit's files (MCP `restore_version`): `{ sha,
|
|
209
|
-
committed, deploys, message, branch, deployAlias,
|
|
210
|
-
With `deploys` and `wait: true` it also
|
|
211
|
-
|
|
219
|
+
committed, deploys, message, workspaceID, branch, deployAlias,
|
|
220
|
+
restoredFrom, parent, waitAfter }`. With `deploys` and `wait: true` it also
|
|
221
|
+
waits for its deploy by commit (`waitForDeployment({ workspaceId, gitCommit:
|
|
222
|
+
sha, alias: deployAlias, after: waitAfter })`) and adds `deployments`
|
|
223
|
+
(READY), or throws `UnfazedDeployError` with the build's or the import's
|
|
224
|
+
error. A link with `apps[]` (no `deployAlias`) deploys once per app; then
|
|
225
|
+
it follows the import until every deployment it made is done.
|
|
212
226
|
|
|
213
227
|
```ts
|
|
214
228
|
const { commits } = await unfazed.listCommits(ws.id);
|
package/dist/cli/login.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type StoredCredentials } from "../credentials.js";
|
|
2
2
|
import { UnfazedError } from "../errors.js";
|
|
3
|
-
export declare const USER_AGENT = "unfazed-cli/0.8.
|
|
3
|
+
export declare const USER_AGENT = "unfazed-cli/0.8.1 (+https://unfazed.dev/auth.md)";
|
|
4
4
|
/** What a login asks for: reading and deploying, like an MCP client. */
|
|
5
5
|
export declare const DEFAULT_SCOPE = "unfz:read unfz:deploy";
|
|
6
6
|
export declare const CLIENT_NAME = "unfazed CLI";
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LOGIN_COMMAND, openStoredLogin } from "./credentials.js";
|
|
2
2
|
import { UnfazedAuthError, UnfazedConfigError, UnfazedGraphQLError, UnfazedHTTPError, UnfazedTimeoutError, } from "./errors.js";
|
|
3
3
|
/** SDK version, sent as the User-Agent. Keep in sync with package.json. */
|
|
4
|
-
export const VERSION = "0.8.
|
|
4
|
+
export const VERSION = "0.8.1";
|
|
5
5
|
/**
|
|
6
6
|
* Default GraphQL endpoint.
|
|
7
7
|
*
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AAErB,2EAA2E;AAC3E,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAE5D,iFAAiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY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E,CAAC;QAC1C,OAAO;YACL,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK;SACxB,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,KAAgD,CAAC;IAErD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,QAAQ,GAAG,IAAI,CAAC;YAChB,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC;IAED,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACjD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,QAAQ,CAAC,OAAO;YAAE,UAAU,CAAC,KAAK,EAAE,CAAC;;YACpC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,KAAK,KAAK,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YAC7C,QAAQ,EAAE,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAC1D,CAAC;QACD,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { LOGIN_COMMAND, openStoredLogin, type StoredLogin } from \"./credentials.js\";\nimport {\n UnfazedAuthError,\n UnfazedConfigError,\n UnfazedGraphQLError,\n UnfazedHTTPError,\n UnfazedTimeoutError,\n type GraphQLResponseError,\n} from \"./errors.js\";\n\n/** SDK version, sent as the User-Agent. Keep in sync with package.json. */\nexport const VERSION = \"0.8.0\";\n\n/**\n * Default GraphQL endpoint.\n *\n * Note this is the FULL endpoint, not an origin: the platform's own documented\n * convention (`UNFZ_API_URL=\"https://unfazed.dev/query\"`, and cmd/showcase-deploy\n * in the unfazed repo) treats the /query URL as the configurable unit, so the\n * SDK matches it rather than inventing a base-URL convention.\n */\nexport const DEFAULT_ENDPOINT = \"https://unfazed.dev/query\";\n\n/** Platform origin, used to derive the endpoint when only `baseUrl` is given. */\nexport const DEFAULT_BASE_URL = \"https://unfazed.dev\";\n\n/** Path of the GraphQL endpoint under an origin. */\nexport const GRAPHQL_PATH = \"/query\";\n\n/**\n * Environment variable holding the bearer token.\n *\n * This is the platform's documented name (docs/agent-deployments.md,\n * internal/agentdocs/reference.md). It accepts either an operator API token or\n * an agent access token from POST /agents/register — /query takes both as\n * plain bearers.\n */\nexport const TOKEN_ENV_VAR = \"UNFZ_API_TOKEN\";\n\n/** Environment variable holding the full GraphQL endpoint URL. */\nexport const ENDPOINT_ENV_VAR = \"UNFZ_API_URL\";\n\n/** Minimal structural type of the `fetch` the transport needs. */\nexport type FetchLike = (\n input: string,\n init: {\n method: string;\n headers: Record<string, string>;\n body: string;\n signal?: AbortSignal;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n text(): Promise<string>;\n}>;\n\nexport interface ClientOptions {\n /**\n * Bearer token. Falls back to `UNFZ_API_TOKEN`, then to the login\n * `npx unfazed login` stored (see {@link ClientOptions.login}). An agent gets\n * one from https://unfazed.dev/auth.md — the same token the MCP server uses.\n */\n token?: string;\n /**\n * Use the stored login of `npx unfazed login`\n * (`${XDG_CONFIG_HOME:-~/.config}/unfazed/credentials.json`) when no token\n * is passed and `UNFZ_API_TOKEN` is unset. Its access token is refreshed\n * before it expires and when the platform refuses it. Default `true`; it is\n * only used for the endpoint it was issued by, and is the endpoint when none\n * is configured.\n */\n login?: boolean;\n /**\n * Where `UNFZ_API_TOKEN`, `UNFZ_API_URL` and the stored login's location\n * (`XDG_CONFIG_HOME`, `HOME`) are read from. Default: `process.env`.\n */\n env?: Record<string, string | undefined>;\n /**\n * Full GraphQL endpoint URL. Wins over `baseUrl`. Falls back to\n * `UNFZ_API_URL`, then the stored login's endpoint, then\n * {@link DEFAULT_ENDPOINT}.\n */\n endpoint?: string;\n /**\n * Platform origin; `/query` is appended. Convenience for self-hosted or\n * staging control planes where only the host differs.\n */\n baseUrl?: string;\n /** Extra headers merged into every request. Authorization always wins. */\n headers?: Record<string, string>;\n /**\n * Per-request timeout in ms. Default 60_000. Pass 0 to disable.\n *\n * Bounds the WHOLE request — connect, headers and reading the response body —\n * so a proxy that answers with headers and then stalls still fails on time.\n */\n timeoutMs?: number;\n /** Injection point for tests and instrumented/proxied transports. */\n fetch?: FetchLike;\n /** Overrides the default `unfazed-sdk/<version>` User-Agent. */\n userAgent?: string;\n}\n\n/**\n * A GraphQL document.\n *\n * Structural rather than `string & {...}` on purpose: graphql-codegen emits\n * `TypedDocumentString`, a String SUBCLASS, which is not assignable to the\n * primitive `string`. Requiring only `toString()` plus the optional phantom\n * `__apiType` lets three things through with full inference:\n *\n * - generated `TypedDocumentString` documents (types inferred),\n * - documents assembled at runtime, like the batched writeFiles mutation,\n * - plain template-literal strings a caller wrote by hand.\n */\nexport interface GraphQLDocument<TResult, TVariables> {\n /** Phantom type carrier. Never called; present only to bind the generics. */\n __apiType?: (variables: TVariables) => TResult;\n toString(): string;\n}\n\n/** Result type carried by a typed document. */\nexport type ResultOf<T> = T extends GraphQLDocument<infer R, infer _V> ? R : unknown;\n\n/** Variables type carried by a typed document. */\nexport type VariablesOf<T> = T extends GraphQLDocument<infer _R, infer V> ? V : never;\n\n/** Per-request knobs. */\nexport interface RequestOptions {\n signal?: AbortSignal;\n timeoutMs?: number;\n operationName?: string;\n}\n\n/**\n * Layer 1 — a typed, dependency-free GraphQL transport over `fetch`.\n *\n * This is the SDK's entire networking surface. It understands auth, timeouts\n * and the GraphQL error envelope, and nothing about deployments. The workflow\n * layer ({@link import(\"./unfazed.js\").Unfazed}) is built strictly on top of\n * it, so you can always drop down here for any operation the workflow layer\n * does not wrap — the schema has ~660 fields and the workflow layer\n * deliberately covers only the agent-facing ones.\n *\n * ```ts\n * const client = new UnfazedClient(); // UNFZ_API_TOKEN, else `npx unfazed login`\n * const data = await client.query<{ whoami: { name: string } }, never>(\n * `query { whoami { name } }`,\n * );\n * ```\n */\nexport class UnfazedClient {\n /** Resolved GraphQL endpoint URL. */\n readonly endpoint: string;\n\n /** A fixed bearer token, or the stored login handing out refreshed ones. */\n readonly #auth: { token: string } | { login: StoredLogin };\n readonly #headers: Record<string, string>;\n readonly #timeoutMs: number;\n readonly #fetch: FetchLike;\n\n constructor(options: ClientOptions = {}) {\n const env = options.env ?? processEnv();\n\n const injected = options.fetch;\n if (injected) {\n this.#fetch = injected;\n } else {\n const globalFetch = (globalThis as { fetch?: unknown }).fetch;\n if (typeof globalFetch !== \"function\") {\n throw new UnfazedConfigError(\n \"unfazed: no global fetch. Use Bun, Node >= 20, or pass { fetch } to the client.\",\n );\n }\n this.#fetch = globalFetch.bind(globalThis) as FetchLike;\n }\n\n const ua = options.userAgent ?? `unfazed-sdk/${VERSION}`;\n\n const configured = configuredEndpoint(options, env);\n const token = options.token ?? env[TOKEN_ENV_VAR];\n if (token?.trim()) {\n this.#auth = { token: token.trim() };\n this.endpoint = configured ?? DEFAULT_ENDPOINT;\n } else {\n const stored =\n options.login === false\n ? {}\n : openStoredLogin({\n env,\n ...(configured ? { endpoint: configured } : {}),\n fetch: this.#fetch,\n // The edge refuses some generic agents; always name ourselves.\n userAgent: ua || `unfazed-sdk/${VERSION}`,\n });\n if (!stored.login) {\n throw new UnfazedAuthError(noTokenMessage(configured, stored.other?.endpoint));\n }\n this.#auth = { login: stored.login };\n this.endpoint = stored.login.endpoint;\n }\n\n this.#headers = { ...(options.headers ?? {}) };\n this.#timeoutMs = options.timeoutMs ?? 60_000;\n if (ua) this.#headers[\"User-Agent\"] = ua;\n }\n\n /**\n * Where the bearer token comes from: `\"token\"` (passed or\n * `UNFZ_API_TOKEN`) or `\"login\"` (the stored login of `npx unfazed login`).\n */\n get authSource(): \"token\" | \"login\" {\n return \"login\" in this.#auth ? \"login\" : \"token\";\n }\n\n /** Runs a query document. Identical wire behaviour to {@link mutate}. */\n query<TResult, TVariables>(\n document: GraphQLDocument<TResult, TVariables>,\n variables?: TVariables,\n options?: RequestOptions,\n ): Promise<TResult> {\n return this.request(document, variables, options);\n }\n\n /**\n * Runs a mutation document. Distinct from {@link query} for call-site\n * readability only — GraphQL over HTTP POST makes no distinction.\n */\n mutate<TResult, TVariables>(\n document: GraphQLDocument<TResult, TVariables>,\n variables?: TVariables,\n options?: RequestOptions,\n ): Promise<TResult> {\n return this.request(document, variables, options);\n }\n\n /**\n * The single code path behind {@link query} and {@link mutate}.\n *\n * Throws {@link UnfazedHTTPError} on non-2xx, {@link UnfazedGraphQLError}\n * when the body carries `errors`, {@link UnfazedTimeoutError} on timeout or\n * abort. Resolves to the `data` object on success.\n */\n async request<TResult = unknown>(\n document: string | { toString(): string },\n variables?: unknown,\n options: RequestOptions = {},\n ): Promise<TResult> {\n const timeoutMs = options.timeoutMs ?? this.#timeoutMs;\n\n // `document` may be a TypedDocumentString (a String object). JSON.stringify\n // would serialise that fine, but String(...) keeps the wire body a plain\n // primitive regardless of how the caller obtained the document.\n const body = JSON.stringify({\n query: String(document),\n ...(variables === undefined ? {} : { variables }),\n ...(options.operationName ? { operationName: options.operationName } : {}),\n });\n\n let token = await this.#token();\n let { response, text } = await this.#send(body, token, timeoutMs, options.signal);\n // A stored login's access token can be refused before its recorded\n // expiry (the clock, a sign-out elsewhere): refresh once and retry. A\n // fixed token has nothing to refresh.\n if (response.status === 401 && \"login\" in this.#auth) {\n token = await this.#auth.login.refresh(token);\n ({ response, text } = await this.#send(body, token, timeoutMs, options.signal));\n }\n\n if (!response.ok) {\n throw new UnfazedHTTPError(response.status, text, this.endpoint);\n }\n\n let parsed: { data?: TResult; errors?: GraphQLResponseError[] };\n try {\n parsed = JSON.parse(text) as typeof parsed;\n } catch {\n throw new UnfazedHTTPError(response.status, text, this.endpoint);\n }\n\n // A GraphQL 200 can still be a failure, and can be a PARTIAL failure: the\n // batched writeFiles document resolves each aliased field independently.\n // Attaching `data` to the error is what lets a caller see which writes\n // landed before the failing one.\n if (parsed.errors?.length) {\n throw new UnfazedGraphQLError(parsed.errors, parsed.data);\n }\n if (parsed.data === undefined || parsed.data === null) {\n throw new UnfazedGraphQLError(\n [{ message: \"response contained neither data nor errors\" }],\n undefined,\n );\n }\n return parsed.data;\n }\n\n #token(): Promise<string> {\n return \"login\" in this.#auth ? this.#auth.login.token() : Promise.resolve(this.#auth.token);\n }\n\n async #send(\n body: string,\n token: string,\n timeoutMs: number,\n external: AbortSignal | undefined,\n ): Promise<{ response: Awaited<ReturnType<FetchLike>>; text: string }> {\n const { signal, cleanup, didTimeout } = makeSignal(timeoutMs, external);\n // The deadline covers BOTH phases — headers AND body. A proxy that answers\n // with headers and then stalls the body is a real failure mode, and\n // stopping the clock at the end of `fetch()` would leave `response.text()`\n // hanging forever. `untilAborted` additionally races the signal itself, so\n // an injected transport that ignores `signal` still cannot outlive the\n // timeout.\n try {\n const response = await untilAborted(\n this.#fetch(this.endpoint, {\n method: \"POST\",\n headers: {\n ...this.#headers,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${token}`,\n },\n body,\n ...(signal ? { signal } : {}),\n }),\n signal,\n );\n const text = await untilAborted(response.text(), signal);\n return { response, text };\n } catch (cause) {\n if (didTimeout()) {\n throw new UnfazedTimeoutError(`unfazed: request timed out after ${timeoutMs}ms`, { cause });\n }\n if (isAbort(cause)) {\n throw new UnfazedTimeoutError(\"unfazed: request aborted\", { cause });\n }\n throw cause;\n } finally {\n cleanup();\n }\n }\n}\n\n/** The endpoint the options or `UNFZ_API_URL` name, or undefined for the default. */\nfunction configuredEndpoint(options: ClientOptions, env: Record<string, string | undefined>): string | undefined {\n if (options.endpoint) return options.endpoint;\n if (options.baseUrl) return trimSlash(options.baseUrl) + GRAPHQL_PATH;\n const fromEnv = env[ENDPOINT_ENV_VAR];\n // UNFZ_API_URL is documented as the full /query URL and is used verbatim.\n // Tolerate a bare origin anyway, since that is the obvious mistake and\n // guessing right costs nothing.\n if (fromEnv) {\n const trimmed = trimSlash(fromEnv);\n return /\\/query$|\\/graphql$/.test(trimmed) ? trimmed : trimmed + GRAPHQL_PATH;\n }\n return undefined;\n}\n\nfunction noTokenMessage(endpoint: string | undefined, otherLogin: string | undefined): string {\n if (endpoint && otherLogin) {\n return (\n `unfazed: no API token for ${endpoint}: the stored login is for ${otherLogin}. ` +\n `Run \\`${ENDPOINT_ENV_VAR}=${endpoint} ${LOGIN_COMMAND}\\`, or pass { token } / set ${TOKEN_ENV_VAR}.`\n );\n }\n return (\n `unfazed: not signed in. Run \\`${LOGIN_COMMAND}\\` to sign in with your account, ` +\n `or pass { token } / set ${TOKEN_ENV_VAR} (an agent token: ${DEFAULT_BASE_URL}/auth.md).`\n );\n}\n\nfunction processEnv(): Record<string, string | undefined> {\n // Guarded: the SDK must also work in a browser or worker, where there is no\n // `process` at all.\n return (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env ?? {};\n}\n\nfunction trimSlash(u: string): string {\n return u.replace(/\\/+$/, \"\");\n}\n\nfunction isAbort(e: unknown): boolean {\n return typeof e === \"object\" && e !== null && (e as { name?: string }).name === \"AbortError\";\n}\n\nfunction abortError(): Error {\n const e = new Error(\"The operation was aborted.\");\n e.name = \"AbortError\";\n return e;\n}\n\n/**\n * Settles with `promise`, or rejects the moment `signal` aborts.\n *\n * A global `fetch` honours the signal for headers and body alike, but an\n * injected {@link FetchLike} — a proxy, an instrumented transport, a test\n * double — need not. Racing the signal makes the timeout an upper bound on the\n * whole request regardless of what the transport does with it. The loser's\n * rejection is swallowed by the already-settled promise rather than surfacing\n * as an unhandled rejection.\n */\nfunction untilAborted<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T> {\n if (!signal) return promise;\n if (signal.aborted) return Promise.reject(abortError());\n return new Promise<T>((resolve, reject) => {\n const onAbort = () => reject(abortError());\n signal.addEventListener(\"abort\", onAbort, { once: true });\n const done = () => signal.removeEventListener(\"abort\", onAbort);\n promise.then(\n (value) => {\n done();\n resolve(value);\n },\n (error: unknown) => {\n done();\n reject(error as Error);\n },\n );\n });\n}\n\n/**\n * Combines the request timeout with any caller-supplied signal.\n *\n * `didTimeout` is tracked separately from the abort so a caller's own\n * cancellation is not mislabelled as a timeout in the thrown message.\n */\nfunction makeSignal(\n timeoutMs: number,\n external?: AbortSignal,\n): { signal?: AbortSignal; cleanup: () => void; didTimeout: () => boolean } {\n if (!timeoutMs && !external) return { cleanup: () => {}, didTimeout: () => false };\n if (typeof AbortController !== \"function\") {\n return {\n ...(external ? { signal: external } : {}),\n cleanup: () => {},\n didTimeout: () => false,\n };\n }\n\n const controller = new AbortController();\n let timedOut = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n if (timeoutMs > 0) {\n timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs);\n }\n\n const onExternalAbort = () => controller.abort();\n if (external) {\n if (external.aborted) controller.abort();\n else external.addEventListener(\"abort\", onExternalAbort, { once: true });\n }\n\n return {\n signal: controller.signal,\n cleanup: () => {\n if (timer !== undefined) clearTimeout(timer);\n external?.removeEventListener(\"abort\", onExternalAbort);\n },\n didTimeout: () => timedOut,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GAEpB,MAAM,aAAa,CA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Q,EAAE,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAC1D,CAAC;QACD,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { LOGIN_COMMAND, openStoredLogin, type StoredLogin } from \"./credentials.js\";\nimport {\n UnfazedAuthError,\n UnfazedConfigError,\n UnfazedGraphQLError,\n UnfazedHTTPError,\n UnfazedTimeoutError,\n type GraphQLResponseError,\n} from \"./errors.js\";\n\n/** SDK version, sent as the User-Agent. Keep in sync with package.json. */\nexport const VERSION = \"0.8.1\";\n\n/**\n * Default GraphQL endpoint.\n *\n * Note this is the FULL endpoint, not an origin: the platform's own documented\n * convention (`UNFZ_API_URL=\"https://unfazed.dev/query\"`, and cmd/showcase-deploy\n * in the unfazed repo) treats the /query URL as the configurable unit, so the\n * SDK matches it rather than inventing a base-URL convention.\n */\nexport const DEFAULT_ENDPOINT = \"https://unfazed.dev/query\";\n\n/** Platform origin, used to derive the endpoint when only `baseUrl` is given. */\nexport const DEFAULT_BASE_URL = \"https://unfazed.dev\";\n\n/** Path of the GraphQL endpoint under an origin. */\nexport const GRAPHQL_PATH = \"/query\";\n\n/**\n * Environment variable holding the bearer token.\n *\n * This is the platform's documented name (docs/agent-deployments.md,\n * internal/agentdocs/reference.md). It accepts either an operator API token or\n * an agent access token from POST /agents/register — /query takes both as\n * plain bearers.\n */\nexport const TOKEN_ENV_VAR = \"UNFZ_API_TOKEN\";\n\n/** Environment variable holding the full GraphQL endpoint URL. */\nexport const ENDPOINT_ENV_VAR = \"UNFZ_API_URL\";\n\n/** Minimal structural type of the `fetch` the transport needs. */\nexport type FetchLike = (\n input: string,\n init: {\n method: string;\n headers: Record<string, string>;\n body: string;\n signal?: AbortSignal;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n text(): Promise<string>;\n}>;\n\nexport interface ClientOptions {\n /**\n * Bearer token. Falls back to `UNFZ_API_TOKEN`, then to the login\n * `npx unfazed login` stored (see {@link ClientOptions.login}). An agent gets\n * one from https://unfazed.dev/auth.md — the same token the MCP server uses.\n */\n token?: string;\n /**\n * Use the stored login of `npx unfazed login`\n * (`${XDG_CONFIG_HOME:-~/.config}/unfazed/credentials.json`) when no token\n * is passed and `UNFZ_API_TOKEN` is unset. Its access token is refreshed\n * before it expires and when the platform refuses it. Default `true`; it is\n * only used for the endpoint it was issued by, and is the endpoint when none\n * is configured.\n */\n login?: boolean;\n /**\n * Where `UNFZ_API_TOKEN`, `UNFZ_API_URL` and the stored login's location\n * (`XDG_CONFIG_HOME`, `HOME`) are read from. Default: `process.env`.\n */\n env?: Record<string, string | undefined>;\n /**\n * Full GraphQL endpoint URL. Wins over `baseUrl`. Falls back to\n * `UNFZ_API_URL`, then the stored login's endpoint, then\n * {@link DEFAULT_ENDPOINT}.\n */\n endpoint?: string;\n /**\n * Platform origin; `/query` is appended. Convenience for self-hosted or\n * staging control planes where only the host differs.\n */\n baseUrl?: string;\n /** Extra headers merged into every request. Authorization always wins. */\n headers?: Record<string, string>;\n /**\n * Per-request timeout in ms. Default 60_000. Pass 0 to disable.\n *\n * Bounds the WHOLE request — connect, headers and reading the response body —\n * so a proxy that answers with headers and then stalls still fails on time.\n */\n timeoutMs?: number;\n /** Injection point for tests and instrumented/proxied transports. */\n fetch?: FetchLike;\n /** Overrides the default `unfazed-sdk/<version>` User-Agent. */\n userAgent?: string;\n}\n\n/**\n * A GraphQL document.\n *\n * Structural rather than `string & {...}` on purpose: graphql-codegen emits\n * `TypedDocumentString`, a String SUBCLASS, which is not assignable to the\n * primitive `string`. Requiring only `toString()` plus the optional phantom\n * `__apiType` lets three things through with full inference:\n *\n * - generated `TypedDocumentString` documents (types inferred),\n * - documents assembled at runtime, like the batched writeFiles mutation,\n * - plain template-literal strings a caller wrote by hand.\n */\nexport interface GraphQLDocument<TResult, TVariables> {\n /** Phantom type carrier. Never called; present only to bind the generics. */\n __apiType?: (variables: TVariables) => TResult;\n toString(): string;\n}\n\n/** Result type carried by a typed document. */\nexport type ResultOf<T> = T extends GraphQLDocument<infer R, infer _V> ? R : unknown;\n\n/** Variables type carried by a typed document. */\nexport type VariablesOf<T> = T extends GraphQLDocument<infer _R, infer V> ? V : never;\n\n/** Per-request knobs. */\nexport interface RequestOptions {\n signal?: AbortSignal;\n timeoutMs?: number;\n operationName?: string;\n}\n\n/**\n * Layer 1 — a typed, dependency-free GraphQL transport over `fetch`.\n *\n * This is the SDK's entire networking surface. It understands auth, timeouts\n * and the GraphQL error envelope, and nothing about deployments. The workflow\n * layer ({@link import(\"./unfazed.js\").Unfazed}) is built strictly on top of\n * it, so you can always drop down here for any operation the workflow layer\n * does not wrap — the schema has ~660 fields and the workflow layer\n * deliberately covers only the agent-facing ones.\n *\n * ```ts\n * const client = new UnfazedClient(); // UNFZ_API_TOKEN, else `npx unfazed login`\n * const data = await client.query<{ whoami: { name: string } }, never>(\n * `query { whoami { name } }`,\n * );\n * ```\n */\nexport class UnfazedClient {\n /** Resolved GraphQL endpoint URL. */\n readonly endpoint: string;\n\n /** A fixed bearer token, or the stored login handing out refreshed ones. */\n readonly #auth: { token: string } | { login: StoredLogin };\n readonly #headers: Record<string, string>;\n readonly #timeoutMs: number;\n readonly #fetch: FetchLike;\n\n constructor(options: ClientOptions = {}) {\n const env = options.env ?? processEnv();\n\n const injected = options.fetch;\n if (injected) {\n this.#fetch = injected;\n } else {\n const globalFetch = (globalThis as { fetch?: unknown }).fetch;\n if (typeof globalFetch !== \"function\") {\n throw new UnfazedConfigError(\n \"unfazed: no global fetch. Use Bun, Node >= 20, or pass { fetch } to the client.\",\n );\n }\n this.#fetch = globalFetch.bind(globalThis) as FetchLike;\n }\n\n const ua = options.userAgent ?? `unfazed-sdk/${VERSION}`;\n\n const configured = configuredEndpoint(options, env);\n const token = options.token ?? env[TOKEN_ENV_VAR];\n if (token?.trim()) {\n this.#auth = { token: token.trim() };\n this.endpoint = configured ?? DEFAULT_ENDPOINT;\n } else {\n const stored =\n options.login === false\n ? {}\n : openStoredLogin({\n env,\n ...(configured ? { endpoint: configured } : {}),\n fetch: this.#fetch,\n // The edge refuses some generic agents; always name ourselves.\n userAgent: ua || `unfazed-sdk/${VERSION}`,\n });\n if (!stored.login) {\n throw new UnfazedAuthError(noTokenMessage(configured, stored.other?.endpoint));\n }\n this.#auth = { login: stored.login };\n this.endpoint = stored.login.endpoint;\n }\n\n this.#headers = { ...(options.headers ?? {}) };\n this.#timeoutMs = options.timeoutMs ?? 60_000;\n if (ua) this.#headers[\"User-Agent\"] = ua;\n }\n\n /**\n * Where the bearer token comes from: `\"token\"` (passed or\n * `UNFZ_API_TOKEN`) or `\"login\"` (the stored login of `npx unfazed login`).\n */\n get authSource(): \"token\" | \"login\" {\n return \"login\" in this.#auth ? \"login\" : \"token\";\n }\n\n /** Runs a query document. Identical wire behaviour to {@link mutate}. */\n query<TResult, TVariables>(\n document: GraphQLDocument<TResult, TVariables>,\n variables?: TVariables,\n options?: RequestOptions,\n ): Promise<TResult> {\n return this.request(document, variables, options);\n }\n\n /**\n * Runs a mutation document. Distinct from {@link query} for call-site\n * readability only — GraphQL over HTTP POST makes no distinction.\n */\n mutate<TResult, TVariables>(\n document: GraphQLDocument<TResult, TVariables>,\n variables?: TVariables,\n options?: RequestOptions,\n ): Promise<TResult> {\n return this.request(document, variables, options);\n }\n\n /**\n * The single code path behind {@link query} and {@link mutate}.\n *\n * Throws {@link UnfazedHTTPError} on non-2xx, {@link UnfazedGraphQLError}\n * when the body carries `errors`, {@link UnfazedTimeoutError} on timeout or\n * abort. Resolves to the `data` object on success.\n */\n async request<TResult = unknown>(\n document: string | { toString(): string },\n variables?: unknown,\n options: RequestOptions = {},\n ): Promise<TResult> {\n const timeoutMs = options.timeoutMs ?? this.#timeoutMs;\n\n // `document` may be a TypedDocumentString (a String object). JSON.stringify\n // would serialise that fine, but String(...) keeps the wire body a plain\n // primitive regardless of how the caller obtained the document.\n const body = JSON.stringify({\n query: String(document),\n ...(variables === undefined ? {} : { variables }),\n ...(options.operationName ? { operationName: options.operationName } : {}),\n });\n\n let token = await this.#token();\n let { response, text } = await this.#send(body, token, timeoutMs, options.signal);\n // A stored login's access token can be refused before its recorded\n // expiry (the clock, a sign-out elsewhere): refresh once and retry. A\n // fixed token has nothing to refresh.\n if (response.status === 401 && \"login\" in this.#auth) {\n token = await this.#auth.login.refresh(token);\n ({ response, text } = await this.#send(body, token, timeoutMs, options.signal));\n }\n\n if (!response.ok) {\n throw new UnfazedHTTPError(response.status, text, this.endpoint);\n }\n\n let parsed: { data?: TResult; errors?: GraphQLResponseError[] };\n try {\n parsed = JSON.parse(text) as typeof parsed;\n } catch {\n throw new UnfazedHTTPError(response.status, text, this.endpoint);\n }\n\n // A GraphQL 200 can still be a failure, and can be a PARTIAL failure: the\n // batched writeFiles document resolves each aliased field independently.\n // Attaching `data` to the error is what lets a caller see which writes\n // landed before the failing one.\n if (parsed.errors?.length) {\n throw new UnfazedGraphQLError(parsed.errors, parsed.data);\n }\n if (parsed.data === undefined || parsed.data === null) {\n throw new UnfazedGraphQLError(\n [{ message: \"response contained neither data nor errors\" }],\n undefined,\n );\n }\n return parsed.data;\n }\n\n #token(): Promise<string> {\n return \"login\" in this.#auth ? this.#auth.login.token() : Promise.resolve(this.#auth.token);\n }\n\n async #send(\n body: string,\n token: string,\n timeoutMs: number,\n external: AbortSignal | undefined,\n ): Promise<{ response: Awaited<ReturnType<FetchLike>>; text: string }> {\n const { signal, cleanup, didTimeout } = makeSignal(timeoutMs, external);\n // The deadline covers BOTH phases — headers AND body. A proxy that answers\n // with headers and then stalls the body is a real failure mode, and\n // stopping the clock at the end of `fetch()` would leave `response.text()`\n // hanging forever. `untilAborted` additionally races the signal itself, so\n // an injected transport that ignores `signal` still cannot outlive the\n // timeout.\n try {\n const response = await untilAborted(\n this.#fetch(this.endpoint, {\n method: \"POST\",\n headers: {\n ...this.#headers,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${token}`,\n },\n body,\n ...(signal ? { signal } : {}),\n }),\n signal,\n );\n const text = await untilAborted(response.text(), signal);\n return { response, text };\n } catch (cause) {\n if (didTimeout()) {\n throw new UnfazedTimeoutError(`unfazed: request timed out after ${timeoutMs}ms`, { cause });\n }\n if (isAbort(cause)) {\n throw new UnfazedTimeoutError(\"unfazed: request aborted\", { cause });\n }\n throw cause;\n } finally {\n cleanup();\n }\n }\n}\n\n/** The endpoint the options or `UNFZ_API_URL` name, or undefined for the default. */\nfunction configuredEndpoint(options: ClientOptions, env: Record<string, string | undefined>): string | undefined {\n if (options.endpoint) return options.endpoint;\n if (options.baseUrl) return trimSlash(options.baseUrl) + GRAPHQL_PATH;\n const fromEnv = env[ENDPOINT_ENV_VAR];\n // UNFZ_API_URL is documented as the full /query URL and is used verbatim.\n // Tolerate a bare origin anyway, since that is the obvious mistake and\n // guessing right costs nothing.\n if (fromEnv) {\n const trimmed = trimSlash(fromEnv);\n return /\\/query$|\\/graphql$/.test(trimmed) ? trimmed : trimmed + GRAPHQL_PATH;\n }\n return undefined;\n}\n\nfunction noTokenMessage(endpoint: string | undefined, otherLogin: string | undefined): string {\n if (endpoint && otherLogin) {\n return (\n `unfazed: no API token for ${endpoint}: the stored login is for ${otherLogin}. ` +\n `Run \\`${ENDPOINT_ENV_VAR}=${endpoint} ${LOGIN_COMMAND}\\`, or pass { token } / set ${TOKEN_ENV_VAR}.`\n );\n }\n return (\n `unfazed: not signed in. Run \\`${LOGIN_COMMAND}\\` to sign in with your account, ` +\n `or pass { token } / set ${TOKEN_ENV_VAR} (an agent token: ${DEFAULT_BASE_URL}/auth.md).`\n );\n}\n\nfunction processEnv(): Record<string, string | undefined> {\n // Guarded: the SDK must also work in a browser or worker, where there is no\n // `process` at all.\n return (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env ?? {};\n}\n\nfunction trimSlash(u: string): string {\n return u.replace(/\\/+$/, \"\");\n}\n\nfunction isAbort(e: unknown): boolean {\n return typeof e === \"object\" && e !== null && (e as { name?: string }).name === \"AbortError\";\n}\n\nfunction abortError(): Error {\n const e = new Error(\"The operation was aborted.\");\n e.name = \"AbortError\";\n return e;\n}\n\n/**\n * Settles with `promise`, or rejects the moment `signal` aborts.\n *\n * A global `fetch` honours the signal for headers and body alike, but an\n * injected {@link FetchLike} — a proxy, an instrumented transport, a test\n * double — need not. Racing the signal makes the timeout an upper bound on the\n * whole request regardless of what the transport does with it. The loser's\n * rejection is swallowed by the already-settled promise rather than surfacing\n * as an unhandled rejection.\n */\nfunction untilAborted<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T> {\n if (!signal) return promise;\n if (signal.aborted) return Promise.reject(abortError());\n return new Promise<T>((resolve, reject) => {\n const onAbort = () => reject(abortError());\n signal.addEventListener(\"abort\", onAbort, { once: true });\n const done = () => signal.removeEventListener(\"abort\", onAbort);\n promise.then(\n (value) => {\n done();\n resolve(value);\n },\n (error: unknown) => {\n done();\n reject(error as Error);\n },\n );\n });\n}\n\n/**\n * Combines the request timeout with any caller-supplied signal.\n *\n * `didTimeout` is tracked separately from the abort so a caller's own\n * cancellation is not mislabelled as a timeout in the thrown message.\n */\nfunction makeSignal(\n timeoutMs: number,\n external?: AbortSignal,\n): { signal?: AbortSignal; cleanup: () => void; didTimeout: () => boolean } {\n if (!timeoutMs && !external) return { cleanup: () => {}, didTimeout: () => false };\n if (typeof AbortController !== \"function\") {\n return {\n ...(external ? { signal: external } : {}),\n cleanup: () => {},\n didTimeout: () => false,\n };\n }\n\n const controller = new AbortController();\n let timedOut = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n if (timeoutMs > 0) {\n timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs);\n }\n\n const onExternalAbort = () => controller.abort();\n if (external) {\n if (external.aborted) controller.abort();\n else external.addEventListener(\"abort\", onExternalAbort, { once: true });\n }\n\n return {\n signal: controller.signal,\n cleanup: () => {\n if (timer !== undefined) clearTimeout(timer);\n external?.removeEventListener(\"abort\", onExternalAbort);\n },\n didTimeout: () => timedOut,\n };\n}\n"]}
|
package/dist/generated/gql.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare function graphql(source: "\n query SdkAppCommit($workspaceID: ID
|
|
|
61
61
|
/**
|
|
62
62
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
63
63
|
*/
|
|
64
|
-
export declare function graphql(source: "\n mutation SdkRestoreVersion(\n $workspaceID: ID!\n $sha: String!\n $expectedHead: String\n $message: String\n ) {\n restoreAppVersion(\n input: { workspaceID: $workspaceID, sha: $sha, expectedHead: $expectedHead, message: $message }\n ) {\n sha\n committed\n deploys\n message\n branch\n deployAlias\n restoredFrom\n parent\n }\n }\n"): typeof import('./graphql.js').SdkRestoreVersionDocument;
|
|
64
|
+
export declare function graphql(source: "\n mutation SdkRestoreVersion(\n $workspaceID: ID!\n $sha: String!\n $expectedHead: String\n $message: String\n ) {\n restoreAppVersion(\n input: { workspaceID: $workspaceID, sha: $sha, expectedHead: $expectedHead, message: $message }\n ) {\n sha\n committed\n deploys\n message\n workspaceID\n branch\n deployAlias\n restoredFrom\n parent\n waitAfter\n }\n }\n"): typeof import('./graphql.js').SdkRestoreVersionDocument;
|
|
65
65
|
/**
|
|
66
66
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
67
67
|
*/
|
|
@@ -153,11 +153,23 @@ export declare function graphql(source: "\n query SdkServiceLogs($deploymentID:
|
|
|
153
153
|
/**
|
|
154
154
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
155
155
|
*/
|
|
156
|
-
export declare function graphql(source: "\n
|
|
156
|
+
export declare function graphql(source: "\n fragment DeploymentTimingsFields on DeploymentTimings {\n totalMs\n buildMs\n promoteMs\n phases\n buildMode\n artifactTransport\n buildMemoryMiB\n }\n"): typeof import('./graphql.js').DeploymentTimingsFieldsFragmentDoc;
|
|
157
|
+
/**
|
|
158
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
159
|
+
*/
|
|
160
|
+
export declare function graphql(source: "\n query SdkDeploymentEvents($deploymentID: ID!, $limit: Int) {\n deploymentEvents(deploymentID: $deploymentID, limit: $limit) {\n id\n deploymentID\n type\n rawType\n severity\n message\n vmID\n metadata\n timings {\n ...DeploymentTimingsFields\n }\n createdAt\n }\n }\n"): typeof import('./graphql.js').SdkDeploymentEventsDocument;
|
|
161
|
+
/**
|
|
162
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
163
|
+
*/
|
|
164
|
+
export declare function graphql(source: "\n query SdkDeploymentTimings($id: ID!) {\n deployment(id: $id) {\n id\n timings {\n ...DeploymentTimingsFields\n }\n }\n }\n"): typeof import('./graphql.js').SdkDeploymentTimingsDocument;
|
|
157
165
|
/**
|
|
158
166
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
159
167
|
*/
|
|
160
168
|
export declare function graphql(source: "\n query SdkWaitForDeployment($id: ID!, $timeoutSeconds: Int) {\n waitForDeployment(id: $id, timeoutSeconds: $timeoutSeconds) {\n timedOut\n waitedMs\n placement\n deployment {\n ...DeploymentFields\n }\n }\n }\n"): typeof import('./graphql.js').SdkWaitForDeploymentDocument;
|
|
169
|
+
/**
|
|
170
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
171
|
+
*/
|
|
172
|
+
export declare function graphql(source: "\n query SdkWaitForCommitDeployment(\n $workspaceID: ID!\n $gitCommit: String!\n $alias: String\n $after: Int\n $timeoutSeconds: Int\n ) {\n waitForDeployment(\n workspaceID: $workspaceID\n gitCommit: $gitCommit\n alias: $alias\n after: $after\n timeoutSeconds: $timeoutSeconds\n ) {\n status\n importStatus\n importError\n timedOut\n waitedMs\n deployment {\n ...DeploymentFields\n }\n }\n }\n"): typeof import('./graphql.js').SdkWaitForCommitDeploymentDocument;
|
|
161
173
|
/**
|
|
162
174
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
163
175
|
*/
|
package/dist/generated/gql.js
CHANGED
|
@@ -16,7 +16,7 @@ const documents = {
|
|
|
16
16
|
"\n query SdkAppCommitsWaiting($workspaceID: ID!) {\n appCommits(workspaceID: $workspaceID, limit: 1) {\n branch\n head\n waitingCommits\n waitingSince\n }\n }\n": types.SdkAppCommitsWaitingDocument,
|
|
17
17
|
"\n query SdkWorkspaceGitSource($id: ID!) {\n workspace(id: $id) {\n id\n gitSource {\n branch\n autoDeploy\n deployAlias\n lastImportedCommit\n lastImportedAt\n lastImportStatus\n lastImportError\n }\n }\n }\n": types.SdkWorkspaceGitSourceDocument,
|
|
18
18
|
"\n query SdkAppCommit($workspaceID: ID!, $sha: String!) {\n appCommit(workspaceID: $workspaceID, sha: $sha) {\n commit {\n sha\n message\n authorName\n authorEmail\n authoredAt\n filesChanged\n deployedTo\n }\n files {\n path\n status\n }\n patch\n truncated\n additions\n deletions\n }\n }\n": types.SdkAppCommitDocument,
|
|
19
|
-
"\n mutation SdkRestoreVersion(\n $workspaceID: ID!\n $sha: String!\n $expectedHead: String\n $message: String\n ) {\n restoreAppVersion(\n input: { workspaceID: $workspaceID, sha: $sha, expectedHead: $expectedHead, message: $message }\n ) {\n sha\n committed\n deploys\n message\n branch\n deployAlias\n restoredFrom\n parent\n }\n }\n": types.SdkRestoreVersionDocument,
|
|
19
|
+
"\n mutation SdkRestoreVersion(\n $workspaceID: ID!\n $sha: String!\n $expectedHead: String\n $message: String\n ) {\n restoreAppVersion(\n input: { workspaceID: $workspaceID, sha: $sha, expectedHead: $expectedHead, message: $message }\n ) {\n sha\n committed\n deploys\n message\n workspaceID\n branch\n deployAlias\n restoredFrom\n parent\n waitAfter\n }\n }\n": types.SdkRestoreVersionDocument,
|
|
20
20
|
"\n fragment AppErrorGroupFields on AppErrorGroup {\n id\n title\n type\n culprit\n level\n status\n count\n storedEvents\n firstSeen\n lastSeen\n firstDeploymentID\n firstGitCommit\n lastDeploymentID\n lastGitCommit\n resolvedInDeploymentID\n resolvedAt\n mutedAt\n regressedAt\n }\n": types.AppErrorGroupFieldsFragmentDoc,
|
|
21
21
|
"\n query SdkAppErrors(\n $workspaceID: ID!\n $alias: String!\n $status: String\n $limit: Int\n $cursor: String\n ) {\n appErrors(\n workspaceID: $workspaceID\n alias: $alias\n status: $status\n limit: $limit\n cursor: $cursor\n ) {\n groups {\n ...AppErrorGroupFields\n }\n nextCursor\n note\n }\n }\n": types.SdkAppErrorsDocument,
|
|
22
22
|
"\n query SdkAppErrorGroup($workspaceID: ID!, $alias: String!, $groupID: ID!) {\n appErrorGroup(workspaceID: $workspaceID, alias: $alias, groupID: $groupID) {\n group {\n ...AppErrorGroupFields\n }\n latestEvent\n firstEvent {\n eventID\n at\n deploymentID\n level\n }\n recentEvents {\n eventID\n at\n deploymentID\n level\n }\n deployments {\n deploymentID\n gitCommit\n current\n count\n firstSeen\n lastSeen\n }\n fatal\n vmID\n }\n }\n": types.SdkAppErrorGroupDocument,
|
|
@@ -39,8 +39,11 @@ const documents = {
|
|
|
39
39
|
"\n mutation SdkRollback(\n $deploymentID: ID!\n $expectedCurrentDeploymentID: ID!\n $expectedCurrentAliasRevision: String!\n ) {\n rollbackDeployment(\n input: {\n deploymentID: $deploymentID\n expectedCurrentDeploymentID: $expectedCurrentDeploymentID\n expectedCurrentAliasRevision: $expectedCurrentAliasRevision\n }\n ) {\n ...DeploymentFields\n }\n }\n": types.SdkRollbackDocument,
|
|
40
40
|
"\n query SdkServiceStatus($deploymentID: ID!) {\n serviceStatus(deploymentID: $deploymentID) {\n deploymentID\n alias\n serviceMode\n running\n health\n vmID\n inFlight\n alwaysOn\n memSizeMiB\n startedAt\n lastUsedAt\n lastStoppedAt\n restartCount\n lastError\n }\n }\n": types.SdkServiceStatusDocument,
|
|
41
41
|
"\n query SdkServiceLogs($deploymentID: ID!, $tailBytes: Int) {\n serviceLogs(deploymentID: $deploymentID, tailBytes: $tailBytes) {\n deploymentID\n stdout\n stderr\n truncated\n stdoutBytes\n stderrBytes\n tailBytes\n }\n }\n": types.SdkServiceLogsDocument,
|
|
42
|
-
"\n
|
|
42
|
+
"\n fragment DeploymentTimingsFields on DeploymentTimings {\n totalMs\n buildMs\n promoteMs\n phases\n buildMode\n artifactTransport\n buildMemoryMiB\n }\n": types.DeploymentTimingsFieldsFragmentDoc,
|
|
43
|
+
"\n query SdkDeploymentEvents($deploymentID: ID!, $limit: Int) {\n deploymentEvents(deploymentID: $deploymentID, limit: $limit) {\n id\n deploymentID\n type\n rawType\n severity\n message\n vmID\n metadata\n timings {\n ...DeploymentTimingsFields\n }\n createdAt\n }\n }\n": types.SdkDeploymentEventsDocument,
|
|
44
|
+
"\n query SdkDeploymentTimings($id: ID!) {\n deployment(id: $id) {\n id\n timings {\n ...DeploymentTimingsFields\n }\n }\n }\n": types.SdkDeploymentTimingsDocument,
|
|
43
45
|
"\n query SdkWaitForDeployment($id: ID!, $timeoutSeconds: Int) {\n waitForDeployment(id: $id, timeoutSeconds: $timeoutSeconds) {\n timedOut\n waitedMs\n placement\n deployment {\n ...DeploymentFields\n }\n }\n }\n": types.SdkWaitForDeploymentDocument,
|
|
46
|
+
"\n query SdkWaitForCommitDeployment(\n $workspaceID: ID!\n $gitCommit: String!\n $alias: String\n $after: Int\n $timeoutSeconds: Int\n ) {\n waitForDeployment(\n workspaceID: $workspaceID\n gitCommit: $gitCommit\n alias: $alias\n after: $after\n timeoutSeconds: $timeoutSeconds\n ) {\n status\n importStatus\n importError\n timedOut\n waitedMs\n deployment {\n ...DeploymentFields\n }\n }\n }\n": types.SdkWaitForCommitDeploymentDocument,
|
|
44
47
|
"\n mutation SdkRestartService($deploymentID: ID!) {\n restartService(input: { deploymentID: $deploymentID }) {\n deploymentID\n running\n health\n vmID\n restartCount\n lastError\n }\n }\n": types.SdkRestartServiceDocument,
|
|
45
48
|
"\n mutation SdkStopService($deploymentID: ID!) {\n stopService(input: { deploymentID: $deploymentID }) {\n deploymentID\n running\n health\n vmID\n restartCount\n lastError\n }\n }\n": types.SdkStopServiceDocument,
|
|
46
49
|
"\n mutation SdkDeleteDeployment($deploymentID: ID!) {\n deleteDeployment(input: { deploymentID: $deploymentID }) {\n ok\n }\n }\n": types.SdkDeleteDeploymentDocument,
|