unfazed 0.5.0 → 0.6.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/README.md +321 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +25 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/remote/app.d.ts +18 -0
- package/dist/remote/app.js +76 -0
- package/dist/remote/app.js.map +1 -0
- package/dist/remote/documents.d.ts +175 -0
- package/dist/remote/documents.js +122 -0
- package/dist/remote/documents.js.map +1 -0
- package/dist/remote/values.d.ts +67 -0
- package/dist/remote/values.js +156 -0
- package/dist/remote/values.js.map +1 -0
- package/dist/remote/world.d.ts +50 -0
- package/dist/remote/world.js +612 -0
- package/dist/remote/world.js.map +1 -0
- package/dist/workflow/config.d.ts +23 -0
- package/dist/workflow/config.js +48 -0
- package/dist/workflow/config.js.map +1 -0
- package/dist/workflow/errors.d.ts +33 -0
- package/dist/workflow/errors.js +16 -0
- package/dist/workflow/errors.js.map +1 -0
- package/dist/workflow/index.d.ts +30 -0
- package/dist/workflow/index.js +23 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/inspect-render.d.ts +93 -0
- package/dist/workflow/inspect-render.js +302 -0
- package/dist/workflow/inspect-render.js.map +1 -0
- package/dist/workflow/inspect.d.ts +52 -0
- package/dist/workflow/inspect.js +879 -0
- package/dist/workflow/inspect.js.map +1 -0
- package/dist/workflow/migration-files.d.ts +13 -0
- package/dist/workflow/migration-files.js +52 -0
- package/dist/workflow/migration-files.js.map +1 -0
- package/dist/workflow/migration-types.d.ts +19 -0
- package/dist/workflow/migration-types.js +8 -0
- package/dist/workflow/migration-types.js.map +1 -0
- package/dist/workflow/migrations.d.ts +12 -0
- package/dist/workflow/migrations.generated.d.ts +2 -0
- package/dist/workflow/migrations.generated.js +34 -0
- package/dist/workflow/migrations.generated.js.map +1 -0
- package/dist/workflow/migrations.js +94 -0
- package/dist/workflow/migrations.js.map +1 -0
- package/dist/workflow/nitro-flow-guard.d.ts +4 -0
- package/dist/workflow/nitro-flow-guard.js +19 -0
- package/dist/workflow/nitro-flow-guard.js.map +1 -0
- package/dist/workflow/nitro-inspect.d.ts +3 -0
- package/dist/workflow/nitro-inspect.js +19 -0
- package/dist/workflow/nitro-inspect.js.map +1 -0
- package/dist/workflow/nitro-plugin.d.ts +1 -0
- package/dist/workflow/nitro-plugin.js +13 -0
- package/dist/workflow/nitro-plugin.js.map +1 -0
- package/dist/workflow/nitro.d.ts +70 -0
- package/dist/workflow/nitro.js +213 -0
- package/dist/workflow/nitro.js.map +1 -0
- package/dist/workflow/public-url.d.ts +27 -0
- package/dist/workflow/public-url.js +45 -0
- package/dist/workflow/public-url.js.map +1 -0
- package/dist/workflow/queue.d.ts +128 -0
- package/dist/workflow/queue.js +375 -0
- package/dist/workflow/queue.js.map +1 -0
- package/dist/workflow/state.d.ts +25 -0
- package/dist/workflow/state.js +15 -0
- package/dist/workflow/state.js.map +1 -0
- package/dist/workflow/transport.d.ts +12 -0
- package/dist/workflow/transport.js +29 -0
- package/dist/workflow/transport.js.map +1 -0
- package/dist/workflow/world.d.ts +123 -0
- package/dist/workflow/world.js +375 -0
- package/dist/workflow/world.js.map +1 -0
- package/package.json +66 -5
package/dist/index.js
CHANGED
|
@@ -24,6 +24,28 @@
|
|
|
24
24
|
export { Unfazed } from "./unfazed.js";
|
|
25
25
|
export { UnfazedClient, DEFAULT_BASE_URL, DEFAULT_ENDPOINT, ENDPOINT_ENV_VAR, GRAPHQL_PATH, TOKEN_ENV_VAR, VERSION, } from "./client.js";
|
|
26
26
|
export { DEPLOYMENT_NOT_FOUND, UnfazedAuthError, UnfazedConfigError, UnfazedConflictError, UnfazedDeployError, UnfazedError, UnfazedGraphQLError, UnfazedHTTPError, UnfazedNotFoundError, UnfazedRunError, UnfazedTimeoutError, WORKSPACE_NOT_FOUND, isDuplicateWorkspaceName, isNotFoundSentinel, } from "./errors.js";
|
|
27
|
+
export { UnfazedInspectError } from "./errors.js";
|
|
28
|
+
export { APP_ENV_VAR } from "./remote/app.js";
|
|
29
|
+
/**
|
|
30
|
+
* The `unfazed` backend of Workflow SDK's CLI: a read-mostly World over the
|
|
31
|
+
* platform's workflow inspection API, for one app.
|
|
32
|
+
*
|
|
33
|
+
* ```sh
|
|
34
|
+
* export UNFZ_API_TOKEN=... # https://unfazed.dev/auth.md
|
|
35
|
+
* UNFZ_APP=birthday-card npx workflow inspect runs --backend unfazed
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* The CLI (and its `--web` UI) resolve `unfazed` from the project and call
|
|
39
|
+
* this with no arguments. The app is `UNFZ_APP`, else the `alias` (or the
|
|
40
|
+
* single `apps[]` entry) of `unfazed.json` in the current directory. Reads
|
|
41
|
+
* and `workflow cancel` work; every other write throws, since an app's own
|
|
42
|
+
* World is `unfazed/workflow`. The module behind it loads on first call, so
|
|
43
|
+
* `import "unfazed"` stays as light as before.
|
|
44
|
+
*/
|
|
45
|
+
export async function createWorld(options) {
|
|
46
|
+
const { createRemoteWorld } = await import("./remote/world.js");
|
|
47
|
+
return createRemoteWorld(options);
|
|
48
|
+
}
|
|
27
49
|
/**
|
|
28
50
|
* Every operation document the workflow layer uses, for callers that want the
|
|
29
51
|
* typed documents but not the wrapper methods.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAuBvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,OAAO,GACR,MAAM,aAAa,CAAC;AAUrB,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA4B;IAC5D,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC","sourcesContent":["/**\n * unfazed — official TypeScript SDK.\n *\n * The code-mode companion to the unfazed MCP server: write one script that\n * deploys, waits, reads logs and filters them locally, instead of chaining a\n * dozen tool calls through a model's context.\n *\n * ```ts\n * import { Unfazed } from \"unfazed\";\n *\n * const unfazed = new Unfazed(); // reads UNFZ_API_TOKEN\n * const ws = await unfazed.createWorkspace(\"hello\");\n * await unfazed.writeFiles(ws.id, {\n * \"server.ts\": `export default { fetch: () => new Response(\"hi\") }`,\n * });\n * const app = await unfazed.deployService({ workspaceId: ws.id, alias: \"hello\", wait: true });\n * console.log(app.url);\n * ```\n *\n * Two layers, both public:\n * - {@link Unfazed} — the workflow layer (deploy + wait, batch writes, one-call rollback).\n * - {@link UnfazedClient} — the typed GraphQL transport, for anything not wrapped.\n */\n\nimport type { RemoteWorld, RemoteWorldOptions } from \"./remote/world.js\";\n\nexport { Unfazed } from \"./unfazed.js\";\nexport type {\n CreateRunOptions,\n FollowUpRunOptions,\n DeleteDeploymentOptions,\n DeleteWorkspaceOptions,\n Deployment,\n DeployBoxOptions,\n DeployOptions,\n DeployServiceOptions,\n DeployStaticOptions,\n EnvVar,\n FileContent,\n FilesMap,\n ListRunsFilter,\n RollbackOptions,\n Run,\n UnfazedOptions,\n Workspace,\n WorkspaceFile,\n WriteFilesOptions,\n} from \"./unfazed.js\";\n\nexport {\n UnfazedClient,\n DEFAULT_BASE_URL,\n DEFAULT_ENDPOINT,\n ENDPOINT_ENV_VAR,\n GRAPHQL_PATH,\n TOKEN_ENV_VAR,\n VERSION,\n} from \"./client.js\";\nexport type {\n ClientOptions,\n FetchLike,\n GraphQLDocument,\n RequestOptions,\n ResultOf,\n VariablesOf,\n} from \"./client.js\";\n\nexport {\n DEPLOYMENT_NOT_FOUND,\n UnfazedAuthError,\n UnfazedConfigError,\n UnfazedConflictError,\n UnfazedDeployError,\n UnfazedError,\n UnfazedGraphQLError,\n UnfazedHTTPError,\n UnfazedNotFoundError,\n UnfazedRunError,\n UnfazedTimeoutError,\n WORKSPACE_NOT_FOUND,\n isDuplicateWorkspaceName,\n isNotFoundSentinel,\n} from \"./errors.js\";\nexport type { GraphQLResponseError } from \"./errors.js\";\n\nexport type { WaitOptions } from \"./wait.js\";\n\nexport { UnfazedInspectError } from \"./errors.js\";\nexport { APP_ENV_VAR } from \"./remote/app.js\";\nexport type { RemoteWorld, RemoteWorldOptions } from \"./remote/world.js\";\n\n/**\n * The `unfazed` backend of Workflow SDK's CLI: a read-mostly World over the\n * platform's workflow inspection API, for one app.\n *\n * ```sh\n * export UNFZ_API_TOKEN=... # https://unfazed.dev/auth.md\n * UNFZ_APP=birthday-card npx workflow inspect runs --backend unfazed\n * ```\n *\n * The CLI (and its `--web` UI) resolve `unfazed` from the project and call\n * this with no arguments. The app is `UNFZ_APP`, else the `alias` (or the\n * single `apps[]` entry) of `unfazed.json` in the current directory. Reads\n * and `workflow cancel` work; every other write throws, since an app's own\n * World is `unfazed/workflow`. The module behind it loads on first call, so\n * `import \"unfazed\"` stays as light as before.\n */\nexport async function createWorld(options?: RemoteWorldOptions): Promise<RemoteWorld> {\n const { createRemoteWorld } = await import(\"./remote/world.js\");\n return createRemoteWorld(options);\n}\n\n/**\n * Every operation document the workflow layer uses, for callers that want the\n * typed documents but not the wrapper methods.\n */\nexport * as operations from \"./operations.js\";\n\n/**\n * Schema types generated from the platform's `graph/schema.graphqls`: enums\n * (`DeploymentStatus`, `ServiceMode`, ...), input objects\n * (`CreateDeploymentInput`, ...) and every operation's result type.\n */\nexport type * from \"./generated/graphql.js\";\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Environment variable naming the app (its alias) the CLI backend reads. */
|
|
2
|
+
export declare const APP_ENV_VAR = "UNFZ_APP";
|
|
3
|
+
/** The project file the alias is read from when `UNFZ_APP` is unset. */
|
|
4
|
+
export declare const MANIFEST_FILE = "unfazed.json";
|
|
5
|
+
type Env = Record<string, string | undefined>;
|
|
6
|
+
/**
|
|
7
|
+
* The app alias: `alias` when given, else `UNFZ_APP`, else `unfazed.json` in
|
|
8
|
+
* `cwd`: its `alias`, or the alias of its only `apps[]` entry. Throws
|
|
9
|
+
* {@link UnfazedConfigError} saying what to set when none of them names one.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveAlias(options: {
|
|
12
|
+
alias?: string;
|
|
13
|
+
env: Env;
|
|
14
|
+
cwd: string;
|
|
15
|
+
}): string;
|
|
16
|
+
/** The current directory, or `"."` where there is no `process`. */
|
|
17
|
+
export declare function currentDirectory(): string;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which app the `unfazed` CLI backend reads: `UNFZ_APP`, else the alias the
|
|
3
|
+
* current directory's `unfazed.json` names.
|
|
4
|
+
*/
|
|
5
|
+
import { UnfazedConfigError } from "../errors.js";
|
|
6
|
+
/** Environment variable naming the app (its alias) the CLI backend reads. */
|
|
7
|
+
export const APP_ENV_VAR = "UNFZ_APP";
|
|
8
|
+
/** The project file the alias is read from when `UNFZ_APP` is unset. */
|
|
9
|
+
export const MANIFEST_FILE = "unfazed.json";
|
|
10
|
+
/**
|
|
11
|
+
* The app alias: `alias` when given, else `UNFZ_APP`, else `unfazed.json` in
|
|
12
|
+
* `cwd`: its `alias`, or the alias of its only `apps[]` entry. Throws
|
|
13
|
+
* {@link UnfazedConfigError} saying what to set when none of them names one.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveAlias(options) {
|
|
16
|
+
const explicit = options.alias?.trim() || options.env[APP_ENV_VAR]?.trim();
|
|
17
|
+
if (explicit)
|
|
18
|
+
return explicit;
|
|
19
|
+
const path = joinPath(options.cwd, MANIFEST_FILE);
|
|
20
|
+
const text = readText(path);
|
|
21
|
+
const hint = `Set ${APP_ENV_VAR} to the app's alias (the <alias> of https://<alias>.unfz.to), e.g.\n` +
|
|
22
|
+
` ${APP_ENV_VAR}=my-app npx workflow inspect runs --backend unfazed\n` +
|
|
23
|
+
`or run it from the app's directory with "alias" in its ${MANIFEST_FILE}.`;
|
|
24
|
+
if (text === undefined)
|
|
25
|
+
throw new UnfazedConfigError(`unfazed: which app? ${APP_ENV_VAR} is not set and there is no ${path}. ${hint}`);
|
|
26
|
+
let manifest;
|
|
27
|
+
try {
|
|
28
|
+
manifest = JSON.parse(text);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new UnfazedConfigError(`unfazed: ${path} is not valid JSON (${error.message}). ${hint}`);
|
|
32
|
+
}
|
|
33
|
+
if (typeof manifest.alias === "string" && manifest.alias.trim())
|
|
34
|
+
return manifest.alias.trim();
|
|
35
|
+
const aliases = (Array.isArray(manifest.apps) ? manifest.apps : [])
|
|
36
|
+
.map((app) => (typeof app?.alias === "string" ? app.alias.trim() : ""))
|
|
37
|
+
.filter((alias) => alias !== "");
|
|
38
|
+
if (aliases.length === 1)
|
|
39
|
+
return aliases[0];
|
|
40
|
+
if (aliases.length > 1) {
|
|
41
|
+
throw new UnfazedConfigError(`unfazed: ${path} deploys ${aliases.length} apps (${aliases.join(", ")}). ` +
|
|
42
|
+
`Set ${APP_ENV_VAR} to the one to inspect, e.g. ${APP_ENV_VAR}=${aliases[0]}.`);
|
|
43
|
+
}
|
|
44
|
+
throw new UnfazedConfigError(`unfazed: which app? ${path} names no "alias" and no apps[]. ${hint}`);
|
|
45
|
+
}
|
|
46
|
+
/** The current directory, or `"."` where there is no `process`. */
|
|
47
|
+
export function currentDirectory() {
|
|
48
|
+
const proc = globalThis.process;
|
|
49
|
+
return proc?.cwd?.() ?? ".";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A file's text, or `undefined` when it does not exist. `node:fs` comes from
|
|
53
|
+
* `process.getBuiltinModule` (Node >= 20.16, Bun, Deno), never from an
|
|
54
|
+
* import: the root entry stays free of Node imports, so a browser bundle of
|
|
55
|
+
* `unfazed` does not trip over them.
|
|
56
|
+
*/
|
|
57
|
+
function readText(path) {
|
|
58
|
+
const proc = globalThis.process;
|
|
59
|
+
const fs = proc?.getBuiltinModule?.("node:fs");
|
|
60
|
+
if (!fs) {
|
|
61
|
+
throw new UnfazedConfigError(`unfazed: cannot read ${path} on this runtime (it needs process.getBuiltinModule: Node >= 20.16, Bun or Deno). ` +
|
|
62
|
+
`Set ${APP_ENV_VAR} to the app's alias.`);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
return fs.readFileSync(path, "utf8");
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error.code === "ENOENT")
|
|
69
|
+
return undefined;
|
|
70
|
+
throw new UnfazedConfigError(`unfazed: could not read ${path}: ${error.message}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function joinPath(dir, file) {
|
|
74
|
+
return dir.endsWith("/") || dir.endsWith("\\") ? dir + file : `${dir}/${file}`;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/remote/app.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Which app the `unfazed` CLI backend reads: `UNFZ_APP`, else the alias the\n * current directory's `unfazed.json` names.\n */\nimport { UnfazedConfigError } from \"../errors.js\";\n\n/** Environment variable naming the app (its alias) the CLI backend reads. */\nexport const APP_ENV_VAR = \"UNFZ_APP\";\n\n/** The project file the alias is read from when `UNFZ_APP` is unset. */\nexport const MANIFEST_FILE = \"unfazed.json\";\n\ntype Env = Record<string, string | undefined>;\n\ninterface Manifest {\n alias?: unknown;\n apps?: { alias?: unknown; rootDir?: unknown }[];\n}\n\n/**\n * The app alias: `alias` when given, else `UNFZ_APP`, else `unfazed.json` in\n * `cwd`: its `alias`, or the alias of its only `apps[]` entry. Throws\n * {@link UnfazedConfigError} saying what to set when none of them names one.\n */\nexport function resolveAlias(options: { alias?: string; env: Env; cwd: string }): string {\n const explicit = options.alias?.trim() || options.env[APP_ENV_VAR]?.trim();\n if (explicit) return explicit;\n\n const path = joinPath(options.cwd, MANIFEST_FILE);\n const text = readText(path);\n const hint =\n `Set ${APP_ENV_VAR} to the app's alias (the <alias> of https://<alias>.unfz.to), e.g.\\n` +\n ` ${APP_ENV_VAR}=my-app npx workflow inspect runs --backend unfazed\\n` +\n `or run it from the app's directory with \"alias\" in its ${MANIFEST_FILE}.`;\n if (text === undefined) throw new UnfazedConfigError(`unfazed: which app? ${APP_ENV_VAR} is not set and there is no ${path}. ${hint}`);\n\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch (error) {\n throw new UnfazedConfigError(`unfazed: ${path} is not valid JSON (${(error as Error).message}). ${hint}`);\n }\n if (typeof manifest.alias === \"string\" && manifest.alias.trim()) return manifest.alias.trim();\n const aliases = (Array.isArray(manifest.apps) ? manifest.apps : [])\n .map((app) => (typeof app?.alias === \"string\" ? app.alias.trim() : \"\"))\n .filter((alias) => alias !== \"\");\n if (aliases.length === 1) return aliases[0]!;\n if (aliases.length > 1) {\n throw new UnfazedConfigError(\n `unfazed: ${path} deploys ${aliases.length} apps (${aliases.join(\", \")}). ` +\n `Set ${APP_ENV_VAR} to the one to inspect, e.g. ${APP_ENV_VAR}=${aliases[0]}.`,\n );\n }\n throw new UnfazedConfigError(`unfazed: which app? ${path} names no \"alias\" and no apps[]. ${hint}`);\n}\n\n/** The current directory, or `\".\"` where there is no `process`. */\nexport function currentDirectory(): string {\n const proc = (globalThis as { process?: { cwd?: () => string } }).process;\n return proc?.cwd?.() ?? \".\";\n}\n\n/**\n * A file's text, or `undefined` when it does not exist. `node:fs` comes from\n * `process.getBuiltinModule` (Node >= 20.16, Bun, Deno), never from an\n * import: the root entry stays free of Node imports, so a browser bundle of\n * `unfazed` does not trip over them.\n */\nfunction readText(path: string): string | undefined {\n const proc = (globalThis as { process?: { getBuiltinModule?: (id: string) => unknown } }).process;\n const fs = proc?.getBuiltinModule?.(\"node:fs\") as\n | { readFileSync(path: string, encoding: \"utf8\"): string }\n | undefined;\n if (!fs) {\n throw new UnfazedConfigError(\n `unfazed: cannot read ${path} on this runtime (it needs process.getBuiltinModule: Node >= 20.16, Bun or Deno). ` +\n `Set ${APP_ENV_VAR} to the app's alias.`,\n );\n }\n try {\n return fs.readFileSync(path, \"utf8\");\n } catch (error) {\n if ((error as { code?: string }).code === \"ENOENT\") return undefined;\n throw new UnfazedConfigError(`unfazed: could not read ${path}: ${(error as Error).message}`);\n }\n}\n\nfunction joinPath(dir: string, file: string): string {\n return dir.endsWith(\"/\") || dir.endsWith(\"\\\\\") ? dir + file : `${dir}/${file}`;\n}\n"]}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The GraphQL documents the `unfazed` CLI backend sends: the platform's
|
|
3
|
+
* workflow inspection API (unfazed docs/workflow-inspect.md, "GraphQL").
|
|
4
|
+
*
|
|
5
|
+
* Written by hand rather than through codegen because the vendored schema
|
|
6
|
+
* predates these fields; `test/remote/documents.test.ts` validates every
|
|
7
|
+
* document against a copy of the inspection schema, so a misspelt field fails
|
|
8
|
+
* there instead of on the platform.
|
|
9
|
+
*/
|
|
10
|
+
/** `WorkflowValue`: a payload as display text, cut at the route's cap. */
|
|
11
|
+
export interface WorkflowValue {
|
|
12
|
+
text: string;
|
|
13
|
+
bytes: number;
|
|
14
|
+
truncated: boolean;
|
|
15
|
+
error: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** `WorkflowError`: a thrown run or step error. */
|
|
18
|
+
export interface WorkflowError {
|
|
19
|
+
message: string;
|
|
20
|
+
stack: string | null;
|
|
21
|
+
code: string | null;
|
|
22
|
+
truncated: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type WorkflowRunStatus = "PENDING" | "RUNNING" | "COMPLETED" | "FAILED" | "CANCELLED";
|
|
25
|
+
export interface WorkflowRunSummary {
|
|
26
|
+
runID: string;
|
|
27
|
+
workflowName: string;
|
|
28
|
+
displayName: string;
|
|
29
|
+
module: string;
|
|
30
|
+
status: WorkflowRunStatus;
|
|
31
|
+
deploymentID: string;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
startedAt: string | null;
|
|
34
|
+
completedAt: string | null;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
expiredAt: string | null;
|
|
37
|
+
errorCode: string | null;
|
|
38
|
+
attributes: {
|
|
39
|
+
key: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}[];
|
|
42
|
+
}
|
|
43
|
+
export interface WorkflowStep {
|
|
44
|
+
stepID: string;
|
|
45
|
+
stepName: string;
|
|
46
|
+
displayName: string;
|
|
47
|
+
module: string;
|
|
48
|
+
status: string;
|
|
49
|
+
attempt: number;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
startedAt: string | null;
|
|
52
|
+
completedAt: string | null;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
retryAfter: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface WorkflowEvent {
|
|
57
|
+
eventID: string;
|
|
58
|
+
eventType: string;
|
|
59
|
+
correlationID: string | null;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
info: Record<string, unknown>;
|
|
62
|
+
infoTruncated: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface WorkflowWait {
|
|
65
|
+
correlationID: string;
|
|
66
|
+
status: string;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
resumeAt: string | null;
|
|
69
|
+
completedAt: string | null;
|
|
70
|
+
}
|
|
71
|
+
export interface WorkflowHook {
|
|
72
|
+
hookID: string;
|
|
73
|
+
kind: string;
|
|
74
|
+
status: string;
|
|
75
|
+
createdAt: string;
|
|
76
|
+
receivedCount: number;
|
|
77
|
+
lastReceivedAt: string | null;
|
|
78
|
+
disposedAt: string | null;
|
|
79
|
+
}
|
|
80
|
+
export interface WorkflowStreamInfo {
|
|
81
|
+
name: string;
|
|
82
|
+
tailIndex: number | null;
|
|
83
|
+
done: boolean | null;
|
|
84
|
+
}
|
|
85
|
+
export interface WorkflowStreamChunk {
|
|
86
|
+
index: number;
|
|
87
|
+
bytes: number;
|
|
88
|
+
encoding: string;
|
|
89
|
+
text: string;
|
|
90
|
+
truncated: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface WorkflowRunPage {
|
|
93
|
+
run: WorkflowRunSummary;
|
|
94
|
+
input: WorkflowValue | null;
|
|
95
|
+
output: WorkflowValue | null;
|
|
96
|
+
error: WorkflowError | null;
|
|
97
|
+
steps: WorkflowStep[];
|
|
98
|
+
stepsNextCursor: string | null;
|
|
99
|
+
stepsHasMore: boolean;
|
|
100
|
+
waits: WorkflowWait[];
|
|
101
|
+
waitsTruncated: boolean;
|
|
102
|
+
hooks: WorkflowHook[];
|
|
103
|
+
hooksTruncated: boolean;
|
|
104
|
+
streams: WorkflowStreamInfo[];
|
|
105
|
+
eventsScanned: number;
|
|
106
|
+
eventsComplete: boolean;
|
|
107
|
+
}
|
|
108
|
+
export declare const RUNS = "\n query SdkWorkflowRuns($alias: String!, $status: [WorkflowRunStatus!], $workflowName: String, $limit: Int, $cursor: String) {\n workflowRuns(alias: $alias, status: $status, workflowName: $workflowName, limit: $limit, cursor: $cursor) {\n runs { runID workflowName displayName module status deploymentID createdAt startedAt completedAt\n updatedAt expiredAt errorCode attributes { key value } }\n nextCursor\n hasMore\n }\n }\n";
|
|
109
|
+
export interface RunsResult {
|
|
110
|
+
workflowRuns: {
|
|
111
|
+
runs: WorkflowRunSummary[];
|
|
112
|
+
nextCursor: string | null;
|
|
113
|
+
hasMore: boolean;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export declare const RUN = "\n query SdkWorkflowRun($alias: String!, $runID: ID!) {\n workflowRun(alias: $alias, runID: $runID) {\n run { runID workflowName displayName module status deploymentID createdAt startedAt completedAt\n updatedAt expiredAt errorCode attributes { key value } }\n input { text bytes truncated error }\n output { text bytes truncated error }\n error { message stack code truncated }\n steps { stepID stepName displayName module status attempt createdAt startedAt completedAt updatedAt retryAfter }\n stepsNextCursor\n stepsHasMore\n waits { correlationID status createdAt resumeAt completedAt }\n waitsTruncated\n hooks { hookID kind status createdAt receivedCount lastReceivedAt disposedAt }\n hooksTruncated\n streams { name tailIndex done }\n eventsScanned\n eventsComplete\n }\n }\n";
|
|
117
|
+
export interface RunResult {
|
|
118
|
+
workflowRun: WorkflowRunPage;
|
|
119
|
+
}
|
|
120
|
+
export declare const STEPS = "\n query SdkWorkflowSteps($alias: String!, $runID: ID!, $limit: Int, $cursor: String) {\n workflowSteps(alias: $alias, runID: $runID, limit: $limit, cursor: $cursor) {\n steps { stepID stepName displayName module status attempt createdAt startedAt completedAt updatedAt retryAfter }\n nextCursor\n hasMore\n }\n }\n";
|
|
121
|
+
export interface StepsResult {
|
|
122
|
+
workflowSteps: {
|
|
123
|
+
steps: WorkflowStep[];
|
|
124
|
+
nextCursor: string | null;
|
|
125
|
+
hasMore: boolean;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export declare const STEP_DETAIL = "\n query SdkWorkflowStep($alias: String!, $runID: ID!, $stepID: ID!) {\n workflowStep(alias: $alias, runID: $runID, stepID: $stepID) {\n step { stepID stepName displayName module status attempt createdAt startedAt completedAt updatedAt retryAfter }\n input { text bytes truncated error }\n output { text bytes truncated error }\n error { message stack code truncated }\n }\n }\n";
|
|
129
|
+
export interface StepResult {
|
|
130
|
+
workflowStep: {
|
|
131
|
+
step: WorkflowStep;
|
|
132
|
+
input: WorkflowValue | null;
|
|
133
|
+
output: WorkflowValue | null;
|
|
134
|
+
error: WorkflowError | null;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export declare const EVENTS = "\n query SdkWorkflowEvents(\n $alias: String!\n $runID: ID!\n $correlationID: String\n $newestFirst: Boolean\n $limit: Int\n $cursor: String\n ) {\n workflowEvents(\n alias: $alias\n runID: $runID\n correlationID: $correlationID\n newestFirst: $newestFirst\n limit: $limit\n cursor: $cursor\n ) {\n events { eventID eventType correlationID createdAt info infoTruncated }\n nextCursor\n hasMore\n }\n }\n";
|
|
138
|
+
export interface EventsResult {
|
|
139
|
+
workflowEvents: {
|
|
140
|
+
events: WorkflowEvent[];
|
|
141
|
+
nextCursor: string | null;
|
|
142
|
+
hasMore: boolean;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export declare const EVENT_DETAIL = "\n query SdkWorkflowEvent($alias: String!, $runID: ID!, $eventID: ID!) {\n workflowEvent(alias: $alias, runID: $runID, eventID: $eventID) {\n event { eventID eventType correlationID createdAt info infoTruncated }\n data { text bytes truncated error }\n }\n }\n";
|
|
146
|
+
export interface EventResult {
|
|
147
|
+
workflowEvent: {
|
|
148
|
+
event: WorkflowEvent;
|
|
149
|
+
data: WorkflowValue | null;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export declare const STREAM = "\n query SdkWorkflowStream($alias: String!, $runID: ID!, $name: String!, $limit: Int, $cursor: String) {\n workflowStream(alias: $alias, runID: $runID, name: $name, limit: $limit, cursor: $cursor) {\n name\n chunks { index bytes encoding text truncated }\n nextCursor\n hasMore\n done\n tailIndex\n }\n }\n";
|
|
153
|
+
export interface StreamResult {
|
|
154
|
+
workflowStream: {
|
|
155
|
+
name: string;
|
|
156
|
+
chunks: WorkflowStreamChunk[];
|
|
157
|
+
nextCursor: string | null;
|
|
158
|
+
hasMore: boolean;
|
|
159
|
+
done: boolean;
|
|
160
|
+
tailIndex: number;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export declare const CANCEL = "\n mutation SdkCancelWorkflowRun($input: CancelWorkflowRunInput!) {\n cancelWorkflowRun(input: $input) {\n runID\n status\n }\n }\n";
|
|
164
|
+
export interface CancelResult {
|
|
165
|
+
cancelWorkflowRun: {
|
|
166
|
+
runID: string;
|
|
167
|
+
status: WorkflowRunStatus;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
export declare const WAKE = "\n mutation SdkWakeWorkflowRun($input: WakeWorkflowRunInput!) {\n wakeWorkflowRun(input: $input) {\n stoppedCount\n }\n }\n";
|
|
171
|
+
export interface WakeResult {
|
|
172
|
+
wakeWorkflowRun: {
|
|
173
|
+
stoppedCount: number;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The GraphQL documents the `unfazed` CLI backend sends: the platform's
|
|
3
|
+
* workflow inspection API (unfazed docs/workflow-inspect.md, "GraphQL").
|
|
4
|
+
*
|
|
5
|
+
* Written by hand rather than through codegen because the vendored schema
|
|
6
|
+
* predates these fields; `test/remote/documents.test.ts` validates every
|
|
7
|
+
* document against a copy of the inspection schema, so a misspelt field fails
|
|
8
|
+
* there instead of on the platform.
|
|
9
|
+
*/
|
|
10
|
+
const VALUE = "text bytes truncated error";
|
|
11
|
+
const ERROR = "message stack code truncated";
|
|
12
|
+
const RUN_SUMMARY = `runID workflowName displayName module status deploymentID createdAt startedAt completedAt
|
|
13
|
+
updatedAt expiredAt errorCode attributes { key value }`;
|
|
14
|
+
const STEP = "stepID stepName displayName module status attempt createdAt startedAt completedAt updatedAt retryAfter";
|
|
15
|
+
const EVENT = "eventID eventType correlationID createdAt info infoTruncated";
|
|
16
|
+
export const RUNS = `
|
|
17
|
+
query SdkWorkflowRuns($alias: String!, $status: [WorkflowRunStatus!], $workflowName: String, $limit: Int, $cursor: String) {
|
|
18
|
+
workflowRuns(alias: $alias, status: $status, workflowName: $workflowName, limit: $limit, cursor: $cursor) {
|
|
19
|
+
runs { ${RUN_SUMMARY} }
|
|
20
|
+
nextCursor
|
|
21
|
+
hasMore
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
export const RUN = `
|
|
26
|
+
query SdkWorkflowRun($alias: String!, $runID: ID!) {
|
|
27
|
+
workflowRun(alias: $alias, runID: $runID) {
|
|
28
|
+
run { ${RUN_SUMMARY} }
|
|
29
|
+
input { ${VALUE} }
|
|
30
|
+
output { ${VALUE} }
|
|
31
|
+
error { ${ERROR} }
|
|
32
|
+
steps { ${STEP} }
|
|
33
|
+
stepsNextCursor
|
|
34
|
+
stepsHasMore
|
|
35
|
+
waits { correlationID status createdAt resumeAt completedAt }
|
|
36
|
+
waitsTruncated
|
|
37
|
+
hooks { hookID kind status createdAt receivedCount lastReceivedAt disposedAt }
|
|
38
|
+
hooksTruncated
|
|
39
|
+
streams { name tailIndex done }
|
|
40
|
+
eventsScanned
|
|
41
|
+
eventsComplete
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
export const STEPS = `
|
|
46
|
+
query SdkWorkflowSteps($alias: String!, $runID: ID!, $limit: Int, $cursor: String) {
|
|
47
|
+
workflowSteps(alias: $alias, runID: $runID, limit: $limit, cursor: $cursor) {
|
|
48
|
+
steps { ${STEP} }
|
|
49
|
+
nextCursor
|
|
50
|
+
hasMore
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export const STEP_DETAIL = `
|
|
55
|
+
query SdkWorkflowStep($alias: String!, $runID: ID!, $stepID: ID!) {
|
|
56
|
+
workflowStep(alias: $alias, runID: $runID, stepID: $stepID) {
|
|
57
|
+
step { ${STEP} }
|
|
58
|
+
input { ${VALUE} }
|
|
59
|
+
output { ${VALUE} }
|
|
60
|
+
error { ${ERROR} }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
export const EVENTS = `
|
|
65
|
+
query SdkWorkflowEvents(
|
|
66
|
+
$alias: String!
|
|
67
|
+
$runID: ID!
|
|
68
|
+
$correlationID: String
|
|
69
|
+
$newestFirst: Boolean
|
|
70
|
+
$limit: Int
|
|
71
|
+
$cursor: String
|
|
72
|
+
) {
|
|
73
|
+
workflowEvents(
|
|
74
|
+
alias: $alias
|
|
75
|
+
runID: $runID
|
|
76
|
+
correlationID: $correlationID
|
|
77
|
+
newestFirst: $newestFirst
|
|
78
|
+
limit: $limit
|
|
79
|
+
cursor: $cursor
|
|
80
|
+
) {
|
|
81
|
+
events { ${EVENT} }
|
|
82
|
+
nextCursor
|
|
83
|
+
hasMore
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
export const EVENT_DETAIL = `
|
|
88
|
+
query SdkWorkflowEvent($alias: String!, $runID: ID!, $eventID: ID!) {
|
|
89
|
+
workflowEvent(alias: $alias, runID: $runID, eventID: $eventID) {
|
|
90
|
+
event { ${EVENT} }
|
|
91
|
+
data { ${VALUE} }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
export const STREAM = `
|
|
96
|
+
query SdkWorkflowStream($alias: String!, $runID: ID!, $name: String!, $limit: Int, $cursor: String) {
|
|
97
|
+
workflowStream(alias: $alias, runID: $runID, name: $name, limit: $limit, cursor: $cursor) {
|
|
98
|
+
name
|
|
99
|
+
chunks { index bytes encoding text truncated }
|
|
100
|
+
nextCursor
|
|
101
|
+
hasMore
|
|
102
|
+
done
|
|
103
|
+
tailIndex
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
export const CANCEL = `
|
|
108
|
+
mutation SdkCancelWorkflowRun($input: CancelWorkflowRunInput!) {
|
|
109
|
+
cancelWorkflowRun(input: $input) {
|
|
110
|
+
runID
|
|
111
|
+
status
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
export const WAKE = `
|
|
116
|
+
mutation SdkWakeWorkflowRun($input: WakeWorkflowRunInput!) {
|
|
117
|
+
wakeWorkflowRun(input: $input) {
|
|
118
|
+
stoppedCount
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/remote/documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4GH,MAAM,KAAK,GAAG,4BAA4B,CAAC;AAC3C,MAAM,KAAK,GAAG,8BAA8B,CAAC;AAC7C,MAAM,WAAW,GAAG;6DACyC,CAAC;AAC9D,MAAM,IAAI,GAAG,wGAAwG,CAAC;AACtH,MAAM,KAAK,GAAG,8DAA8D,CAAC;AAE7E,MAAM,CAAC,MAAM,IAAI,GAAG;;;eAGL,WAAW;;;;;CAKzB,CAAC;AAKF,MAAM,CAAC,MAAM,GAAG,GAAG;;;cAGL,WAAW;gBACT,KAAK;iBACJ,KAAK;gBACN,KAAK;gBACL,IAAI;;;;;;;;;;;;CAYnB,CAAC;AAKF,MAAM,CAAC,MAAM,KAAK,GAAG;;;gBAGL,IAAI;;;;;CAKnB,CAAC;AAKF,MAAM,CAAC,MAAM,WAAW,GAAG;;;eAGZ,IAAI;gBACH,KAAK;iBACJ,KAAK;gBACN,KAAK;;;CAGpB,CAAC;AAUF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;iBAiBL,KAAK;;;;;CAKrB,CAAC;AAKF,MAAM,CAAC,MAAM,YAAY,GAAG;;;gBAGZ,KAAK;eACN,KAAK;;;CAGnB,CAAC;AAKF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;CAWrB,CAAC;AAYF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;CAOrB,CAAC;AAKF,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;CAMnB,CAAC","sourcesContent":["/**\n * The GraphQL documents the `unfazed` CLI backend sends: the platform's\n * workflow inspection API (unfazed docs/workflow-inspect.md, \"GraphQL\").\n *\n * Written by hand rather than through codegen because the vendored schema\n * predates these fields; `test/remote/documents.test.ts` validates every\n * document against a copy of the inspection schema, so a misspelt field fails\n * there instead of on the platform.\n */\n\n/** `WorkflowValue`: a payload as display text, cut at the route's cap. */\nexport interface WorkflowValue {\n text: string;\n bytes: number;\n truncated: boolean;\n error: boolean;\n}\n\n/** `WorkflowError`: a thrown run or step error. */\nexport interface WorkflowError {\n message: string;\n stack: string | null;\n code: string | null;\n truncated: boolean;\n}\n\nexport type WorkflowRunStatus = \"PENDING\" | \"RUNNING\" | \"COMPLETED\" | \"FAILED\" | \"CANCELLED\";\n\nexport interface WorkflowRunSummary {\n runID: string;\n workflowName: string;\n displayName: string;\n module: string;\n status: WorkflowRunStatus;\n deploymentID: string;\n createdAt: string;\n startedAt: string | null;\n completedAt: string | null;\n updatedAt: string;\n expiredAt: string | null;\n errorCode: string | null;\n attributes: { key: string; value: string }[];\n}\n\nexport interface WorkflowStep {\n stepID: string;\n stepName: string;\n displayName: string;\n module: string;\n status: string;\n attempt: number;\n createdAt: string;\n startedAt: string | null;\n completedAt: string | null;\n updatedAt: string;\n retryAfter: string | null;\n}\n\nexport interface WorkflowEvent {\n eventID: string;\n eventType: string;\n correlationID: string | null;\n createdAt: string;\n info: Record<string, unknown>;\n infoTruncated: boolean;\n}\n\nexport interface WorkflowWait {\n correlationID: string;\n status: string;\n createdAt: string;\n resumeAt: string | null;\n completedAt: string | null;\n}\n\nexport interface WorkflowHook {\n hookID: string;\n kind: string;\n status: string;\n createdAt: string;\n receivedCount: number;\n lastReceivedAt: string | null;\n disposedAt: string | null;\n}\n\nexport interface WorkflowStreamInfo {\n name: string;\n tailIndex: number | null;\n done: boolean | null;\n}\n\nexport interface WorkflowStreamChunk {\n index: number;\n bytes: number;\n encoding: string;\n text: string;\n truncated: boolean;\n}\n\nexport interface WorkflowRunPage {\n run: WorkflowRunSummary;\n input: WorkflowValue | null;\n output: WorkflowValue | null;\n error: WorkflowError | null;\n steps: WorkflowStep[];\n stepsNextCursor: string | null;\n stepsHasMore: boolean;\n waits: WorkflowWait[];\n waitsTruncated: boolean;\n hooks: WorkflowHook[];\n hooksTruncated: boolean;\n streams: WorkflowStreamInfo[];\n eventsScanned: number;\n eventsComplete: boolean;\n}\n\nconst VALUE = \"text bytes truncated error\";\nconst ERROR = \"message stack code truncated\";\nconst RUN_SUMMARY = `runID workflowName displayName module status deploymentID createdAt startedAt completedAt\n updatedAt expiredAt errorCode attributes { key value }`;\nconst STEP = \"stepID stepName displayName module status attempt createdAt startedAt completedAt updatedAt retryAfter\";\nconst EVENT = \"eventID eventType correlationID createdAt info infoTruncated\";\n\nexport const RUNS = `\n query SdkWorkflowRuns($alias: String!, $status: [WorkflowRunStatus!], $workflowName: String, $limit: Int, $cursor: String) {\n workflowRuns(alias: $alias, status: $status, workflowName: $workflowName, limit: $limit, cursor: $cursor) {\n runs { ${RUN_SUMMARY} }\n nextCursor\n hasMore\n }\n }\n`;\nexport interface RunsResult {\n workflowRuns: { runs: WorkflowRunSummary[]; nextCursor: string | null; hasMore: boolean };\n}\n\nexport const RUN = `\n query SdkWorkflowRun($alias: String!, $runID: ID!) {\n workflowRun(alias: $alias, runID: $runID) {\n run { ${RUN_SUMMARY} }\n input { ${VALUE} }\n output { ${VALUE} }\n error { ${ERROR} }\n steps { ${STEP} }\n stepsNextCursor\n stepsHasMore\n waits { correlationID status createdAt resumeAt completedAt }\n waitsTruncated\n hooks { hookID kind status createdAt receivedCount lastReceivedAt disposedAt }\n hooksTruncated\n streams { name tailIndex done }\n eventsScanned\n eventsComplete\n }\n }\n`;\nexport interface RunResult {\n workflowRun: WorkflowRunPage;\n}\n\nexport const STEPS = `\n query SdkWorkflowSteps($alias: String!, $runID: ID!, $limit: Int, $cursor: String) {\n workflowSteps(alias: $alias, runID: $runID, limit: $limit, cursor: $cursor) {\n steps { ${STEP} }\n nextCursor\n hasMore\n }\n }\n`;\nexport interface StepsResult {\n workflowSteps: { steps: WorkflowStep[]; nextCursor: string | null; hasMore: boolean };\n}\n\nexport const STEP_DETAIL = `\n query SdkWorkflowStep($alias: String!, $runID: ID!, $stepID: ID!) {\n workflowStep(alias: $alias, runID: $runID, stepID: $stepID) {\n step { ${STEP} }\n input { ${VALUE} }\n output { ${VALUE} }\n error { ${ERROR} }\n }\n }\n`;\nexport interface StepResult {\n workflowStep: {\n step: WorkflowStep;\n input: WorkflowValue | null;\n output: WorkflowValue | null;\n error: WorkflowError | null;\n };\n}\n\nexport const EVENTS = `\n query SdkWorkflowEvents(\n $alias: String!\n $runID: ID!\n $correlationID: String\n $newestFirst: Boolean\n $limit: Int\n $cursor: String\n ) {\n workflowEvents(\n alias: $alias\n runID: $runID\n correlationID: $correlationID\n newestFirst: $newestFirst\n limit: $limit\n cursor: $cursor\n ) {\n events { ${EVENT} }\n nextCursor\n hasMore\n }\n }\n`;\nexport interface EventsResult {\n workflowEvents: { events: WorkflowEvent[]; nextCursor: string | null; hasMore: boolean };\n}\n\nexport const EVENT_DETAIL = `\n query SdkWorkflowEvent($alias: String!, $runID: ID!, $eventID: ID!) {\n workflowEvent(alias: $alias, runID: $runID, eventID: $eventID) {\n event { ${EVENT} }\n data { ${VALUE} }\n }\n }\n`;\nexport interface EventResult {\n workflowEvent: { event: WorkflowEvent; data: WorkflowValue | null };\n}\n\nexport const STREAM = `\n query SdkWorkflowStream($alias: String!, $runID: ID!, $name: String!, $limit: Int, $cursor: String) {\n workflowStream(alias: $alias, runID: $runID, name: $name, limit: $limit, cursor: $cursor) {\n name\n chunks { index bytes encoding text truncated }\n nextCursor\n hasMore\n done\n tailIndex\n }\n }\n`;\nexport interface StreamResult {\n workflowStream: {\n name: string;\n chunks: WorkflowStreamChunk[];\n nextCursor: string | null;\n hasMore: boolean;\n done: boolean;\n tailIndex: number;\n };\n}\n\nexport const CANCEL = `\n mutation SdkCancelWorkflowRun($input: CancelWorkflowRunInput!) {\n cancelWorkflowRun(input: $input) {\n runID\n status\n }\n }\n`;\nexport interface CancelResult {\n cancelWorkflowRun: { runID: string; status: WorkflowRunStatus };\n}\n\nexport const WAKE = `\n mutation SdkWakeWorkflowRun($input: WakeWorkflowRunInput!) {\n wakeWorkflowRun(input: $input) {\n stoppedCount\n }\n }\n`;\nexport interface WakeResult {\n wakeWorkflowRun: { stoppedCount: number };\n}\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the `unfazed` CLI backend turns the inspection API's display data back
|
|
3
|
+
* into what Workflow SDK's tooling reads from a World.
|
|
4
|
+
*
|
|
5
|
+
* The app's inspection route hydrates every payload inside the app and sends
|
|
6
|
+
* it as display text (`JSON.stringify` of the hydrated value, cut at the
|
|
7
|
+
* route's caps). The CLI and the web UI expect a World to hand them serialized
|
|
8
|
+
* data, which they hydrate themselves: a `Uint8Array` with a 4-byte format
|
|
9
|
+
* prefix, `devl` followed by devalue text. So each value is parsed back from
|
|
10
|
+
* its display text and re-encoded as `devl` + devalue, which every Workflow
|
|
11
|
+
* SDK reader hydrates to the same plain value. A value that was cut, or that
|
|
12
|
+
* the app could not hydrate, becomes a string that says so.
|
|
13
|
+
*
|
|
14
|
+
* Pure functions, no dependencies.
|
|
15
|
+
*/
|
|
16
|
+
import type { WorkflowError, WorkflowStreamChunk, WorkflowValue } from "./documents.js";
|
|
17
|
+
/**
|
|
18
|
+
* devalue's `stringify` for the values JSON can hold (what `JSON.parse`
|
|
19
|
+
* returns, plus `undefined`): a flat array whose first entry is the root,
|
|
20
|
+
* where an object or array refers to its members by index. Strings,
|
|
21
|
+
* numbers, booleans and `null` sit in the array as themselves, so the
|
|
22
|
+
* encoding never produces devalue's typed tuples (`["Date", …]`), and every
|
|
23
|
+
* reviver set reads it the same way.
|
|
24
|
+
*/
|
|
25
|
+
export declare function devalueStringify(value: unknown): string;
|
|
26
|
+
/** `value` as Workflow SDK serialized data: `devl` + devalue text. */
|
|
27
|
+
export declare function serialize(value: unknown): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* One stream frame as Workflow SDK's stream writer writes it: a 4-byte
|
|
30
|
+
* big-endian length, then the serialized value. `getDeserializeStream()`
|
|
31
|
+
* (what `workflow inspect stream` and the web UI read streams with) turns
|
|
32
|
+
* each frame back into the value.
|
|
33
|
+
*/
|
|
34
|
+
export declare function frame(value: unknown): Uint8Array;
|
|
35
|
+
/** What a payload cut at the inspection route's cap ends with. */
|
|
36
|
+
export declare function truncationNote(bytes: number): string;
|
|
37
|
+
/** What a payload the app could not hydrate reads as. */
|
|
38
|
+
export declare function unreadable(reason: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* The value behind a `WorkflowValue`: its display JSON parsed back, a string
|
|
41
|
+
* marked as cut when the route cut it (the cut text is not valid JSON), or a
|
|
42
|
+
* string with the reason when the app could not hydrate it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function displayValue(value: WorkflowValue): unknown;
|
|
45
|
+
/** A `WorkflowValue` as serialized data, or `undefined` for an absent payload. */
|
|
46
|
+
export declare function serializedValue(value: WorkflowValue | null | undefined): Uint8Array | undefined;
|
|
47
|
+
/** A run or step error as Workflow SDK's `StructuredError`. */
|
|
48
|
+
export declare function structuredError(error: WorkflowError): {
|
|
49
|
+
message: string;
|
|
50
|
+
stack?: string;
|
|
51
|
+
code?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The value of one stream chunk: `json` chunks (what `getWritable()` writes)
|
|
55
|
+
* parsed back, `utf8` chunks as their text, `base64` chunks (bytes that are
|
|
56
|
+
* not UTF-8) as `{ $bytes, base64 }`, the route's display form for bytes.
|
|
57
|
+
*/
|
|
58
|
+
export declare function chunkValue(chunk: WorkflowStreamChunk): unknown;
|
|
59
|
+
/** An RFC 3339 time as a `Date`, or `undefined`. */
|
|
60
|
+
export declare function toDate(value: string | null | undefined): Date | undefined;
|
|
61
|
+
/** An event's `info` as `eventData`, its date fields as `Date`s. */
|
|
62
|
+
export declare function eventData(info: Record<string, unknown> | null | undefined): Record<string, unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* The payload field of each event type, as `getEventDataRefFields()` in
|
|
65
|
+
* `@workflow/world` lists them: where `events.get` puts the event's data.
|
|
66
|
+
*/
|
|
67
|
+
export declare const EVENT_PAYLOAD_FIELDS: Readonly<Record<string, string>>;
|