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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/remote/world.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAkB,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,C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C,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACxF,CAAC;AAED,SAAS,OAAO,CAAC,MAA+B,EAAE,GAAW,EAAE,KAAoB;IACjF,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC/B,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B,EAAE,GAAW,EAAE,KAAc;IAC9E,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC/C,CAAC;AAED,sEAAsE;AACtE,KAAK,UAAU,QAAQ,CAAO,KAAmB,EAAE,KAAa,EAAE,EAA2B;IAC3F,MAAM,OAAO,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;QACxB,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACjF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * The `unfazed` backend of Workflow SDK's CLI: a World that reads an app's\n * workflow runs through the platform's inspection API, so\n *\n * ```sh\n * UNFZ_APP=birthday-card npx workflow inspect runs --backend unfazed\n * ```\n *\n * works like `--backend vercel` does. The CLI imports `unfazed` from the\n * project and calls `createWorld()` (see `../index.ts`), which lazily loads\n * this module.\n *\n * Every read is one GraphQL call to the control plane, which relays it to the\n * app's own inspection route over the worker (unfazed docs/workflow-inspect.md):\n * the app reads its runs through its own World and sends display data, which\n * `./values.ts` turns back into the serialized data Workflow SDK's tooling\n * hydrates. Writes are refused, except the two the inspection API offers:\n * cancelling a run (`workflow cancel`, the web UI) and waking a sleeping one\n * (the web UI's \"Wake up\").\n *\n * Only type imports from `@workflow/world`: the root entry stays free of\n * runtime dependencies.\n */\nimport type {\n AnyEventRequest,\n BulkCancelWorkflowRunResult,\n BulkCancelWorkflowRunsRequest,\n BulkCancelWorkflowRunsResult,\n Event,\n GetChunksOptions,\n GetEventParams,\n GetStepParams,\n GetWorkflowRunParams,\n Hook,\n ListEventsByCorrelationIdParams,\n ListEventsParams,\n ListHooksParams,\n ListWorkflowRunsParams,\n ListWorkflowRunStepsParams,\n PaginatedResponse,\n PaginationOptions,\n Step,\n StreamChunksResponse,\n StreamInfoResponse,\n World,\n WorkflowRun,\n} from \"@workflow/world\";\nimport { ENDPOINT_ENV_VAR, TOKEN_ENV_VAR, UnfazedClient, VERSION, type FetchLike } from \"../client.js\";\nimport { UnfazedAuthError, UnfazedGraphQLError, UnfazedHTTPError, UnfazedInspectError } from \"../errors.js\";\nimport { APP_ENV_VAR, currentDirectory, resolveAlias } from \"./app.js\";\nimport * as docs from \"./documents.js\";\nimport {\n chunkValue,\n EVENT_PAYLOAD_FIELDS,\n eventData,\n frame,\n serializedValue,\n structuredError,\n toDate,\n} from \"./values.js\";\n\nexport interface RemoteWorldOptions {\n /** The app's alias. Default: `UNFZ_APP`, else the `alias` (or single `apps[]` entry) of `unfazed.json` in `cwd`. */\n alias?: string;\n /** Bearer token. Default: `UNFZ_API_TOKEN`. Get one at https://unfazed.dev/auth.md. */\n token?: string;\n /** Full GraphQL endpoint. Default: `UNFZ_API_URL`, else https://unfazed.dev/query. */\n endpoint?: string;\n /** Where the defaults above are read from. Default: `process.env`. */\n env?: Record<string, string | undefined>;\n /** Directory whose `unfazed.json` names the app. Default: the current directory. */\n cwd?: string;\n /** Per-request timeout in ms. Default 60 000 (a relay may include the app's cold start). */\n timeoutMs?: number;\n /**\n * How long `streams.get` waits between reads of a stream still being\n * written, at most: it starts at 1 s and doubles up to this. Default 5 000.\n */\n streamPollMs?: number;\n /** Injection point for tests. */\n fetch?: FetchLike;\n}\n\n/**\n * The World `createWorld()` from `unfazed` returns: Workflow SDK's `World`\n * interface over the inspection API. Typed loosely here so the root entry's\n * declarations need no `@workflow/world`; cast to its `World` when you call\n * it from code.\n */\nexport interface RemoteWorld {\n /** The app it reads. */\n readonly alias: string;\n readonly specVersion: number;\n readonly runs: object;\n readonly steps: object;\n readonly events: object;\n readonly hooks: object;\n readonly streams: object;\n close(): Promise<void>;\n}\n\n/**\n * `SPEC_VERSION_CURRENT` of the `@workflow/world` this backend was written\n * against (a test keeps the two equal). Informational: this World creates\n * and replays nothing.\n */\nexport const REMOTE_SPEC_VERSION = 8;\n\n/** A run page is reused for this long, so one CLI or web UI view costs one relay. */\nconst RUN_PAGE_TTL_MS = 2_000;\n/** Active runs searched for a hook that no run page read so far named. */\nconst HOOK_SCAN_RUNS = 20;\n/** Pages of 200 steps read to serve `steps.list` newest first (the API lists oldest first). */\nconst STEP_PAGES_MAX = 10;\nconst STREAM_PAGE = 50;\nconst STREAM_POLL_MIN_MS = 1_000;\nconst CONCURRENCY = 4;\n/** A wake-up's own re-enqueue happens inside the app; the SDK's follow-up `queue()` within this window is a no-op. */\nconst WAKE_QUEUE_WINDOW_MS = 60_000;\n/** Hook tokens never leave the app (contract: hooks are shown by ID, kind and state). */\nconst REDACTED = \"[redacted]\";\n\ntype Env = Record<string, string | undefined>;\n\n/**\n * Creates the CLI backend's World for one app. Throws when there is no token\n * or no app to read, saying what to set.\n */\nexport function createRemoteWorld(options: RemoteWorldOptions = {}): RemoteWorld {\n const env: Env = options.env ?? (globalThis as { process?: { env?: Env } }).process?.env ?? {};\n const token = options.token ?? env[TOKEN_ENV_VAR];\n if (!token?.trim()) {\n const inApp = env[\"UNFZ_STATE_URL\"]\n ? ' Inside an unfazed app the World is unfazed/workflow (its Nitro module, or setWorld(createWorld()) from \"unfazed/workflow\"); ' +\n \"WORKFLOW_TARGET_WORLD=unfazed selects this read-only CLI backend instead.\"\n : \"\";\n throw new UnfazedAuthError(\n `unfazed: no API token. Set ${TOKEN_ENV_VAR} to inspect an app's workflow runs ` +\n `(a token with the unfz:read scope; unfz:deploy too for cancel and wake). Get one at https://unfazed.dev/auth.md.${inApp}`,\n );\n }\n const alias = resolveAlias({ alias: options.alias, env, cwd: options.cwd ?? currentDirectory() });\n const endpointEnv = env[ENDPOINT_ENV_VAR];\n const client = new UnfazedClient({\n token,\n endpoint: options.endpoint ?? (endpointEnv ? normalizeEndpoint(endpointEnv) : undefined),\n timeoutMs: options.timeoutMs ?? 60_000,\n userAgent: `unfazed-sdk/${VERSION} (workflow-cli-backend)`,\n ...(options.fetch ? { fetch: options.fetch } : {}),\n });\n const pollMaxMs = Math.max(1, options.streamPollMs ?? 5_000);\n const pollMinMs = Math.min(STREAM_POLL_MIN_MS, pollMaxMs);\n\n let closed = false;\n /** Pending waits of stream readers; `close()` ends them so no timer outlives the World. */\n const sleepers = new Set<() => void>();\n const sleep = (ms: number) =>\n new Promise<void>((resolve) => {\n const wake = () => {\n clearTimeout(timer);\n sleepers.delete(wake);\n resolve();\n };\n const timer = setTimeout(wake, ms);\n sleepers.add(wake);\n });\n\n // ---- Transport and errors ----\n\n async function call<T>(document: string, variables: Record<string, unknown>, runId?: string): Promise<T> {\n try {\n return await client.request<T>(document, variables);\n } catch (error) {\n throw translate(error, alias, runId);\n }\n }\n\n // ---- Run pages: one relay serves runs.get, hooks, streams.list ----\n\n const runPages = new Map<string, { expires: number; page: Promise<docs.WorkflowRunPage> }>();\n /** hookId → runId, from every run page read: how `hooks.get(hookId)` finds the run. */\n const hookRuns = new Map<string, string>();\n\n function runPage(runId: string): Promise<docs.WorkflowRunPage> {\n const cached = runPages.get(runId);\n if (cached && cached.expires > Date.now()) return cached.page;\n // Never expires while in flight (a relay may wait out a cold start); reused for a moment after.\n const entry = { expires: Number.POSITIVE_INFINITY } as { expires: number; page: Promise<docs.WorkflowRunPage> };\n entry.page = call<docs.RunResult>(docs.RUN, { alias, runID: runId }, runId).then(\n ({ workflowRun }) => {\n for (const hook of workflowRun.hooks) hookRuns.set(hook.hookID, runId);\n entry.expires = Date.now() + RUN_PAGE_TTL_MS;\n return workflowRun;\n },\n (error: unknown) => {\n if (runPages.get(runId) === entry) runPages.delete(runId);\n throw error;\n },\n );\n runPages.set(runId, entry);\n return entry.page;\n }\n\n // ---- Records in the World's shapes ----\n\n function runRecord(run: docs.WorkflowRunSummary, page?: docs.WorkflowRunPage, withData = false): WorkflowRun {\n const record: Record<string, unknown> = {\n runId: run.runID,\n status: run.status.toLowerCase(),\n deploymentId: run.deploymentID,\n workflowName: run.workflowName,\n attributes: Object.fromEntries(run.attributes.map(({ key, value }) => [key, value])),\n createdAt: toDate(run.createdAt),\n updatedAt: toDate(run.updatedAt),\n };\n setDate(record, \"startedAt\", run.startedAt);\n setDate(record, \"completedAt\", run.completedAt);\n setDate(record, \"expiredAt\", run.expiredAt);\n if (run.errorCode !== null) record.errorCode = run.errorCode;\n if (page && withData) {\n setDefined(record, \"input\", serializedValue(page.input));\n setDefined(record, \"output\", serializedValue(page.output));\n }\n if (page?.error) record.error = structuredError(page.error);\n return record as unknown as WorkflowRun;\n }\n\n function stepRecord(\n runId: string,\n step: docs.WorkflowStep,\n detail?: docs.StepResult[\"workflowStep\"],\n withData = false,\n ): Step {\n const record: Record<string, unknown> = {\n runId,\n stepId: step.stepID,\n stepName: step.stepName,\n status: step.status,\n attempt: step.attempt,\n createdAt: toDate(step.createdAt),\n updatedAt: toDate(step.updatedAt),\n };\n setDate(record, \"startedAt\", step.startedAt);\n setDate(record, \"completedAt\", step.completedAt);\n setDate(record, \"retryAfter\", step.retryAfter);\n if (detail && withData) {\n setDefined(record, \"input\", serializedValue(detail.input));\n setDefined(record, \"output\", serializedValue(detail.output));\n }\n if (detail?.error) record.error = structuredError(detail.error);\n return record as unknown as Step;\n }\n\n function eventRecord(runId: string, event: docs.WorkflowEvent, data?: docs.WorkflowValue | null): Event {\n const record: Record<string, unknown> = {\n runId,\n eventId: event.eventID,\n eventType: event.eventType,\n createdAt: toDate(event.createdAt),\n eventData: eventData(event.info),\n };\n if (event.correlationID !== null) record.correlationId = event.correlationID;\n const field = EVENT_PAYLOAD_FIELDS[event.eventType];\n if (field && data) (record.eventData as Record<string, unknown>)[field] = serializedValue(data);\n return record as unknown as Event;\n }\n\n function hookRecord(runId: string, hook: docs.WorkflowHook): Hook {\n const record: Record<string, unknown> = {\n runId,\n hookId: hook.hookID,\n token: REDACTED,\n ownerId: \"\",\n projectId: alias,\n environment: \"production\",\n createdAt: toDate(hook.createdAt),\n isWebhook: hook.kind === \"webhook\",\n isSystem: hook.kind === \"system\",\n // What the inspection API adds: the hook's state from its run's events.\n status: hook.status,\n receivedCount: hook.receivedCount,\n };\n setDate(record, \"lastReceivedAt\", hook.lastReceivedAt);\n setDate(record, \"disposedAt\", hook.disposedAt);\n return record as unknown as Hook;\n }\n\n // ---- Lists ----\n\n async function allSteps(runId: string): Promise<docs.WorkflowStep[]> {\n const steps: docs.WorkflowStep[] = [];\n let cursor: string | null = null;\n for (let page = 0; page < STEP_PAGES_MAX; page++) {\n const { workflowSteps }: docs.StepsResult = await call<docs.StepsResult>(\n docs.STEPS,\n { alias, runID: runId, limit: 200, cursor },\n runId,\n );\n steps.push(...workflowSteps.steps);\n if (!workflowSteps.hasMore || !workflowSteps.nextCursor) break;\n cursor = workflowSteps.nextCursor;\n }\n return steps;\n }\n\n async function activeRuns(limit: number, cursor: string | null) {\n const { workflowRuns } = await call<docs.RunsResult>(docs.RUNS, {\n alias,\n status: [\"RUNNING\", \"PENDING\"],\n limit,\n cursor,\n });\n const pages = await mapLimit(workflowRuns.runs, CONCURRENCY, (run) => runPage(run.runID));\n return { pages, nextCursor: workflowRuns.nextCursor, hasMore: workflowRuns.hasMore };\n }\n\n function hooksOf(page: docs.WorkflowRunPage, onlyActive: boolean): Hook[] {\n return page.hooks\n .filter((hook) => !onlyActive || hook.status === \"active\")\n .map((hook) => hookRecord(page.run.runID, hook));\n }\n\n // ---- Writes the inspection API offers ----\n\n /** Runs woken through this World, for the SDK's follow-up `queue()` (see {@link WAKE_QUEUE_WINDOW_MS}). */\n const woken = new Map<string, number>();\n\n /**\n * Cancels a run; resolves `\"already_cancelled\"` for a run cancelled before,\n * which, as in the upstream Worlds, is not an error. A run that completed or\n * failed is refused with the platform's \"run … already ended (…)\".\n */\n async function cancel(runId: string, reason?: string): Promise<\"cancelled\" | \"already_cancelled\"> {\n try {\n await call<docs.CancelResult>(\n docs.CANCEL,\n // The platform takes at most 512 characters (code points); cut on a character boundary.\n { input: { alias, runID: runId, ...(reason !== undefined ? { reason: Array.from(reason).slice(0, 512).join(\"\") } : {}) } },\n runId,\n );\n return \"cancelled\";\n } catch (error) {\n if (endedAs(error) === \"cancelled\") return \"already_cancelled\";\n throw error;\n } finally {\n runPages.delete(runId);\n }\n }\n\n // ---- The World ----\n\n const world = {\n alias,\n specVersion: REMOTE_SPEC_VERSION,\n capabilities: {},\n\n runs: {\n async get(id: string, params?: GetWorkflowRunParams) {\n const page = await runPage(id);\n return runRecord(page.run, page, params?.resolveData !== \"none\");\n },\n\n async list(params: ListWorkflowRunsParams = {}): Promise<PaginatedResponse<WorkflowRun>> {\n if ((params.pagination?.sortOrder ?? \"desc\") !== \"desc\") {\n throw invalidArgument(\"runs.list\", \"sortOrder\", \"the unfazed backend lists runs newest first only; drop --sort asc\");\n }\n const status =\n params.status === undefined\n ? null\n : (Array.isArray(params.status) ? params.status : [params.status]).map((s) => s.toUpperCase());\n const { workflowRuns } = await call<docs.RunsResult>(docs.RUNS, {\n alias,\n status,\n workflowName: params.workflowName ?? null,\n limit: clamp(params.pagination?.limit ?? 20, 1, 100),\n cursor: params.pagination?.cursor || null,\n });\n return {\n data: workflowRuns.runs.map((run) => runRecord(run)),\n cursor: workflowRuns.hasMore ? workflowRuns.nextCursor : null,\n hasMore: workflowRuns.hasMore,\n };\n },\n\n async cancelMany(request: BulkCancelWorkflowRunsRequest): Promise<BulkCancelWorkflowRunsResult> {\n const results = await mapLimit(request.runIds, CONCURRENCY, async (runId): Promise<BulkCancelWorkflowRunResult> => {\n try {\n return { runId, outcome: await cancel(runId, request.cancelReason) };\n } catch (error) {\n if (error instanceof UnfazedInspectError && (error.status === 401 || error.status === 403)) throw error;\n const ended = endedAs(error);\n if (ended) return { runId, outcome: \"not_cancellable\", status: ended };\n if (error instanceof UnfazedInspectError && error.name === \"WorkflowRunNotFoundError\") {\n return { runId, outcome: \"not_found\" };\n }\n return { runId, outcome: \"failed\", code: \"internal_error\", retryable: true };\n }\n });\n const count = (outcome: BulkCancelWorkflowRunResult[\"outcome\"]) => results.filter((r) => r.outcome === outcome).length;\n return {\n summary: {\n requested: results.length,\n cancelled: count(\"cancelled\"),\n alreadyCancelled: count(\"already_cancelled\"),\n notCancellable: count(\"not_cancellable\"),\n notFound: count(\"not_found\"),\n failed: count(\"failed\"),\n },\n results,\n };\n },\n },\n\n steps: {\n async get(runId: string, stepId: string, params?: GetStepParams) {\n const { workflowStep } = await call<docs.StepResult>(docs.STEP_DETAIL, { alias, runID: runId, stepID: stepId }, runId);\n return stepRecord(runId, workflowStep.step, workflowStep, params?.resolveData !== \"none\");\n },\n\n async list(params: ListWorkflowRunStepsParams): Promise<PaginatedResponse<Step>> {\n const { runId, pagination } = params;\n const limit = clamp(pagination?.limit ?? 20, 1, 200);\n if ((pagination?.sortOrder ?? \"desc\") === \"asc\") {\n if (pagination?.cursor?.startsWith(CURSOR_PREFIX)) throw badCursor(\"steps.list\");\n const { workflowSteps } = await call<docs.StepsResult>(\n docs.STEPS,\n { alias, runID: runId, limit, cursor: pagination?.cursor || null },\n runId,\n );\n return {\n data: workflowSteps.steps.map((step) => stepRecord(runId, step)),\n cursor: workflowSteps.hasMore ? workflowSteps.nextCursor : null,\n hasMore: workflowSteps.hasMore,\n };\n }\n // Newest first: the API pages oldest first, so read the run's steps and page them here.\n const offset = decodeOffset(pagination?.cursor, \"steps.list\");\n const steps = (await allSteps(runId)).reverse();\n return offsetPage(\n steps.map((step) => stepRecord(runId, step)),\n offset,\n limit,\n );\n },\n },\n\n events: {\n async get(runId: string, eventId: string, params?: GetEventParams) {\n const { workflowEvent } = await call<docs.EventResult>(docs.EVENT_DETAIL, { alias, runID: runId, eventID: eventId }, runId);\n return eventRecord(runId, workflowEvent.event, params?.resolveData === \"none\" ? null : workflowEvent.data);\n },\n\n async list(params: ListEventsParams) {\n return listEvents(params.runId, null, params.pagination);\n },\n\n async listByCorrelationId(params: ListEventsByCorrelationIdParams) {\n if (!params.runId) {\n throw invalidArgument(\"events.listByCorrelationId\", \"runId\", \"the unfazed backend reads events per run: pass the run ID\");\n }\n return listEvents(params.runId, params.correlationId, params.pagination);\n },\n\n async create(runId: string | null, data: AnyEventRequest) {\n if (runId && data.eventType === \"run_cancelled\") {\n const reason = (data.eventData as { cancelReason?: unknown } | undefined)?.cancelReason;\n await cancel(runId, typeof reason === \"string\" ? reason : undefined);\n return { event: syntheticEvent(runId, data) };\n }\n if (runId && data.eventType === \"wait_completed\" && data.correlationId) {\n await call<docs.WakeResult>(docs.WAKE, { input: { alias, runID: runId, correlationIDs: [data.correlationId] } }, runId);\n woken.set(runId, Date.now() + WAKE_QUEUE_WINDOW_MS);\n runPages.delete(runId);\n return { event: syntheticEvent(runId, data) };\n }\n throw readOnly(`write a ${data.eventType} event`);\n },\n },\n\n hooks: {\n async get(hookId: string) {\n const known = hookRuns.get(hookId);\n if (known) {\n const hook = (await runPage(known)).hooks.find((h) => h.hookID === hookId);\n if (hook) return hookRecord(known, hook);\n }\n const { pages } = await activeRuns(HOOK_SCAN_RUNS, null);\n for (const page of pages) {\n const hook = page.hooks.find((h) => h.hookID === hookId);\n if (hook) return hookRecord(page.run.runID, hook);\n }\n throw new UnfazedInspectError(\n `Hook ${hookId} not found. The unfazed backend finds a hook through its run, and no run read so far, ` +\n `nor any of the ${HOOK_SCAN_RUNS} newest active runs, has it. List a run's hooks with ` +\n \"`workflow inspect hooks --runId <run-id>`.\",\n { name: \"HookNotFoundError\", status: 404 },\n );\n },\n\n async getByToken(): Promise<Hook> {\n throw readOnly(\"look a hook up by its token (hook tokens never leave the app)\");\n },\n\n async list(params: ListHooksParams): Promise<PaginatedResponse<Hook>> {\n const { runId, pagination } = params;\n const desc = pagination?.sortOrder === \"desc\";\n const byCreated = (a: Hook, b: Hook) => (a.createdAt.getTime() - b.createdAt.getTime()) * (desc ? -1 : 1);\n if (runId) {\n const hooks = hooksOf(await runPage(runId), false).sort(byCreated);\n return offsetPage(hooks, decodeOffset(pagination?.cursor, \"hooks.list\"), clamp(pagination?.limit ?? 100, 1, 500));\n }\n // Every hook of the app: those of its active runs (a finished run's hooks are gone), a page of runs at a time.\n const runsCursor = decodeWrapped(pagination?.cursor, \"runs\", \"hooks.list\");\n const { pages, nextCursor, hasMore } = await activeRuns(clamp(pagination?.limit ?? 20, 1, HOOK_SCAN_RUNS), runsCursor);\n return {\n data: pages.flatMap((page) => hooksOf(page, true)).sort(byCreated),\n cursor: hasMore && nextCursor ? `${CURSOR_PREFIX}runs:${nextCursor}` : null,\n hasMore: hasMore && nextCursor !== null,\n };\n },\n },\n\n streams: {\n async list(runId: string) {\n return (await runPage(runId)).streams.map((stream) => stream.name);\n },\n\n async getInfo(runId: string, name: string): Promise<StreamInfoResponse> {\n const { workflowStream } = await call<docs.StreamResult>(docs.STREAM, { alias, runID: runId, name, limit: 1 }, runId);\n return { tailIndex: workflowStream.tailIndex, done: workflowStream.done };\n },\n\n async getChunks(runId: string, name: string, options?: GetChunksOptions): Promise<StreamChunksResponse> {\n const { workflowStream } = await call<docs.StreamResult>(\n docs.STREAM,\n { alias, runID: runId, name, limit: clamp(options?.limit ?? 100, 1, 200), cursor: options?.cursor || null },\n runId,\n );\n return {\n data: workflowStream.chunks.map((chunk) => ({ index: chunk.index, data: frame(chunkValue(chunk)) })),\n cursor: workflowStream.hasMore ? workflowStream.nextCursor : null,\n hasMore: workflowStream.hasMore,\n done: workflowStream.done,\n };\n },\n\n /**\n * The stream from `startIndex` (negative: from the end), each chunk one\n * frame, read a page at a time and, while the run is still writing it,\n * polled (1 s, doubling up to `streamPollMs`) until it is done.\n */\n async get(runId: string, name: string, startIndex = 0): Promise<ReadableStream<Uint8Array>> {\n let pageCursor: string | null = null;\n let position: number | undefined;\n let delay = pollMinMs;\n let cancelled = false;\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n for (;;) {\n if (cancelled || closed) {\n controller.close();\n return;\n }\n const { workflowStream } = await call<docs.StreamResult>(\n docs.STREAM,\n { alias, runID: runId, name, limit: STREAM_PAGE, cursor: pageCursor },\n runId,\n );\n position ??= startIndex < 0 ? Math.max(0, workflowStream.tailIndex + 1 + startIndex) : startIndex;\n const fresh = workflowStream.chunks.filter((chunk) => chunk.index >= position!);\n // A page with more after it is never read again; the last page is re-read for new chunks.\n if (workflowStream.hasMore && workflowStream.nextCursor) pageCursor = workflowStream.nextCursor;\n if (fresh.length > 0) {\n for (const chunk of fresh) controller.enqueue(frame(chunkValue(chunk)));\n position = fresh[fresh.length - 1]!.index + 1;\n delay = pollMinMs;\n return;\n }\n if (workflowStream.hasMore) continue;\n if (workflowStream.done) {\n controller.close();\n return;\n }\n await sleep(delay);\n delay = Math.min(delay * 2, pollMaxMs);\n }\n },\n cancel() {\n cancelled = true;\n },\n });\n },\n\n async write(): Promise<void> {\n throw readOnly(\"write to a stream\");\n },\n async writeMulti(): Promise<void> {\n throw readOnly(\"write to a stream\");\n },\n async close(): Promise<void> {\n throw readOnly(\"close a stream\");\n },\n },\n\n async getDeploymentId(): Promise<string> {\n throw readOnly(\"start runs (it has no deployment of its own)\");\n },\n\n async queue(_queueName: string, message: unknown) {\n const runId = (message as { runId?: unknown } | null)?.runId;\n const until = typeof runId === \"string\" ? woken.get(runId) : undefined;\n // `wakeUp()` re-enqueues the run after completing its waits; the app already did both.\n if (until !== undefined && until > Date.now()) return { messageId: null };\n throw readOnly(\"enqueue messages\");\n },\n\n createQueueHandler(): (req: Request) => Promise<Response> {\n throw readOnly(\"handle queue deliveries\");\n },\n\n async close() {\n closed = true;\n for (const wake of [...sleepers]) wake();\n },\n };\n\n async function listEvents(runId: string, correlationId: string | null, pagination?: PaginationOptions): Promise<PaginatedResponse<Event>> {\n const { workflowEvents } = await call<docs.EventsResult>(\n docs.EVENTS,\n {\n alias,\n runID: runId,\n correlationID: correlationId,\n newestFirst: pagination?.sortOrder === \"desc\",\n limit: clamp(pagination?.limit ?? 100, 1, 500),\n cursor: pagination?.cursor || null,\n },\n runId,\n );\n return {\n data: workflowEvents.events.map((event) => eventRecord(runId, event)),\n cursor: workflowEvents.hasMore ? workflowEvents.nextCursor : null,\n hasMore: workflowEvents.hasMore,\n };\n }\n\n // Every member exists on Workflow SDK's World (no misspelt or invented method); parameters\n // are the World's own types above. The overloaded return types are not checked here.\n const keys: Implements<typeof world, World & { alias: string }> = true;\n const namespaces: [\n Implements<typeof world.runs, World[\"runs\"]>,\n Implements<typeof world.steps, World[\"steps\"]>,\n Implements<typeof world.events, World[\"events\"]>,\n Implements<typeof world.hooks, World[\"hooks\"]>,\n Implements<typeof world.streams, World[\"streams\"]>,\n ] = [true, true, true, true, true];\n void keys;\n void namespaces;\n return world as unknown as RemoteWorld;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers.\n// ---------------------------------------------------------------------------\n\n/** `true` when every key of `T` is a key of `U`. */\ntype Implements<T, U> = Exclude<keyof T, keyof U> extends never ? true : never;\n\n/** Cursors this backend mints itself (offset pages, wrapped run cursors); the API's own pass through untouched. */\nconst CURSOR_PREFIX = \"unfz:\";\n\nfunction offsetPage<T>(items: T[], offset: number, limit: number): PaginatedResponse<T> {\n const end = offset + limit;\n const hasMore = end < items.length;\n return { data: items.slice(offset, end), cursor: hasMore ? `${CURSOR_PREFIX}offset:${end}` : null, hasMore };\n}\n\nfunction decodeOffset(cursor: string | undefined, method: string): number {\n if (!cursor) return 0;\n const match = /^unfz:offset:(\\d{1,9})$/.exec(cursor);\n if (!match) throw badCursor(method);\n return Number(match[1]);\n}\n\nfunction decodeWrapped(cursor: string | undefined, kind: string, method: string): string | null {\n if (!cursor) return null;\n const prefix = `${CURSOR_PREFIX}${kind}:`;\n if (!cursor.startsWith(prefix) || cursor.length === prefix.length) throw badCursor(method);\n return cursor.slice(prefix.length);\n}\n\nfunction badCursor(method: string): UnfazedInspectError {\n return invalidArgument(method, \"cursor\", \"this cursor came from another listing or sort order\");\n}\n\nfunction invalidArgument(method: string, field: string, why: string): UnfazedInspectError {\n return new UnfazedInspectError(`unfazed: ${method}: ${field}: ${why}.`, { code: \"INVALID_ARGUMENT\" });\n}\n\nfunction readOnly(what: string): UnfazedInspectError {\n return new UnfazedInspectError(\n `unfazed: the \\`unfazed\\` CLI backend is read-only and cannot ${what}. It inspects an app's runs from your ` +\n \"terminal (workflow inspect, workflow cancel, the web UI). Apps use unfazed/workflow: its Nitro module, \" +\n 'or setWorld(createWorld()) from \"unfazed/workflow\", not WORKFLOW_TARGET_WORLD=unfazed.',\n { code: \"READ_ONLY\" },\n );\n}\n\nfunction syntheticEvent(runId: string, data: AnyEventRequest): Event {\n const { correlationId, eventData } = data as { correlationId?: string; eventData?: unknown };\n return {\n runId,\n eventId: \"\",\n eventType: data.eventType,\n createdAt: new Date(),\n ...(correlationId ? { correlationId } : {}),\n ...(eventData ? { eventData } : {}),\n } as unknown as Event;\n}\n\n/**\n * The platform's error as Workflow SDK's tooling expects a World's: a\n * missing run is `WorkflowRunNotFoundError` (404), a refused token says how\n * to get one, a token without the deploy scope says what needs it.\n */\nfunction translate(error: unknown, alias: string, runId: string | undefined): unknown {\n const refused = (status: number, cause: unknown) =>\n new UnfazedInspectError(\n `unfazed: the platform refused the API token (HTTP ${status}). Check ${TOKEN_ENV_VAR}; ` +\n \"get a token at https://unfazed.dev/auth.md.\",\n { status, cause },\n );\n if (error instanceof UnfazedHTTPError) {\n if (error.status === 401 || error.status === 403) return refused(error.status, error);\n return new UnfazedInspectError(error.message, { status: error.status, cause: error });\n }\n if (!(error instanceof UnfazedGraphQLError)) return error;\n const message = error.errors.map((e) => e.message).join(\"; \");\n if (message.trim() === \"authentication required\") return refused(401, error);\n if (/^no such run\\b/.test(message)) {\n return new UnfazedInspectError(runId ? `Workflow run \"${runId}\" not found` : `unfazed: ${message}`, {\n name: \"WorkflowRunNotFoundError\",\n status: 404,\n runId,\n cause: error,\n });\n }\n if (/^no such (step|event|stream)\\b/.test(message)) {\n return new UnfazedInspectError(`unfazed: ${message}`, { status: 404, cause: error });\n }\n if (message.trim() === \"deployment was not found\") {\n return new UnfazedInspectError(\n `unfazed: no app \"${alias}\" that this token can see. Check ${APP_ENV_VAR} (the app's alias) and that ` +\n \"the token's account owns the app or shares its team.\",\n { status: 404, cause: error },\n );\n }\n const scope = /missing OAuth scope (\\S+)/.exec(message);\n if (scope) {\n const needs = scope[1] === \"unfz:deploy\" ? \" (cancel and wake need it, like restarting the app)\" : \"\";\n return new UnfazedInspectError(`unfazed: this API token lacks the ${scope[1]} scope${needs}.`, { status: 403, cause: error });\n }\n return new UnfazedInspectError(`unfazed: ${message}`, { cause: error });\n}\n\n/** The status of the \"run … already ended (<status>)\" refusal (409 `run_terminal`), else undefined. */\nfunction endedAs(error: unknown): string | undefined {\n return /already ended \\(([a-z]+)\\)/.exec(error instanceof Error ? error.message : \"\")?.[1];\n}\n\nfunction normalizeEndpoint(value: string): string {\n const trimmed = value.replace(/\\/+$/, \"\");\n return /\\/query$|\\/graphql$/.test(trimmed) ? trimmed : `${trimmed}/query`;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Number.isFinite(value) ? Math.min(max, Math.max(min, Math.trunc(value))) : min;\n}\n\nfunction setDate(record: Record<string, unknown>, key: string, value: string | null): void {\n const date = toDate(value);\n if (date) record[key] = date;\n}\n\nfunction setDefined(record: Record<string, unknown>, key: string, value: unknown): void {\n if (value !== undefined) record[key] = value;\n}\n\n/** `fn` over `items`, at most `limit` at a time, results in order. */\nasync function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]> {\n const results = new Array<R>(items.length);\n let next = 0;\n const worker = async () => {\n while (next < items.length) {\n const index = next++;\n results[index] = await fn(items[index]!);\n }\n };\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));\n return results;\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Environment as the World reads it. */
|
|
2
|
+
export type WorkflowEnv = Record<string, string | undefined>;
|
|
3
|
+
/**
|
|
4
|
+
* Connection string precedence. `DATABASE_URL_UNPOOLED` comes before
|
|
5
|
+
* `DATABASE_URL` because a Neon pooled (PgBouncer, transaction mode) URL
|
|
6
|
+
* cannot hold the `LISTEN` the streamer and `waitForTerminalStatus` use.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DATABASE_URL_VARS: readonly ["WORKFLOW_POSTGRES_URL", "DATABASE_URL_UNPOOLED", "DATABASE_URL"];
|
|
9
|
+
/** Non-empty value of `name`, or undefined. */
|
|
10
|
+
export declare function envValue(env: WorkflowEnv, name: string): string | undefined;
|
|
11
|
+
/** The first database URL variable that is set, in {@link DATABASE_URL_VARS} order. */
|
|
12
|
+
export declare function resolveDatabaseUrl(env: WorkflowEnv): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Makes a libpq-style URL mean the same thing to node-postgres.
|
|
15
|
+
*
|
|
16
|
+
* libpq reads `sslmode=require` as "encrypt, do not verify the certificate";
|
|
17
|
+
* node-postgres reads it as `verify-full` unless `uselibpqcompat=true` is set,
|
|
18
|
+
* and then refuses the unfazed Postgres integration's self-signed certificate.
|
|
19
|
+
* An explicit `uselibpqcompat` is left alone.
|
|
20
|
+
*/
|
|
21
|
+
export declare function withLibpqCompat(connectionString: string): string;
|
|
22
|
+
/** Positive integer value of `name`, or undefined. */
|
|
23
|
+
export declare function envPositiveInt(env: WorkflowEnv, name: string): number | undefined;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection string precedence. `DATABASE_URL_UNPOOLED` comes before
|
|
3
|
+
* `DATABASE_URL` because a Neon pooled (PgBouncer, transaction mode) URL
|
|
4
|
+
* cannot hold the `LISTEN` the streamer and `waitForTerminalStatus` use.
|
|
5
|
+
*/
|
|
6
|
+
export const DATABASE_URL_VARS = ["WORKFLOW_POSTGRES_URL", "DATABASE_URL_UNPOOLED", "DATABASE_URL"];
|
|
7
|
+
/** Non-empty value of `name`, or undefined. */
|
|
8
|
+
export function envValue(env, name) {
|
|
9
|
+
const value = env[name];
|
|
10
|
+
return value === undefined || value.trim() === "" ? undefined : value;
|
|
11
|
+
}
|
|
12
|
+
/** The first database URL variable that is set, in {@link DATABASE_URL_VARS} order. */
|
|
13
|
+
export function resolveDatabaseUrl(env) {
|
|
14
|
+
for (const name of DATABASE_URL_VARS) {
|
|
15
|
+
const value = envValue(env, name);
|
|
16
|
+
if (value)
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Makes a libpq-style URL mean the same thing to node-postgres.
|
|
23
|
+
*
|
|
24
|
+
* libpq reads `sslmode=require` as "encrypt, do not verify the certificate";
|
|
25
|
+
* node-postgres reads it as `verify-full` unless `uselibpqcompat=true` is set,
|
|
26
|
+
* and then refuses the unfazed Postgres integration's self-signed certificate.
|
|
27
|
+
* An explicit `uselibpqcompat` is left alone.
|
|
28
|
+
*/
|
|
29
|
+
export function withLibpqCompat(connectionString) {
|
|
30
|
+
let url;
|
|
31
|
+
try {
|
|
32
|
+
url = new URL(connectionString);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return connectionString;
|
|
36
|
+
}
|
|
37
|
+
if (url.searchParams.get("sslmode") !== "require" || url.searchParams.has("uselibpqcompat")) {
|
|
38
|
+
return connectionString;
|
|
39
|
+
}
|
|
40
|
+
url.searchParams.set("uselibpqcompat", "true");
|
|
41
|
+
return url.toString();
|
|
42
|
+
}
|
|
43
|
+
/** Positive integer value of `name`, or undefined. */
|
|
44
|
+
export function envPositiveInt(env, name) {
|
|
45
|
+
const parsed = Number.parseInt(env[name] ?? "", 10);
|
|
46
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/workflow/config.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,uBAAuB,EAAE,uBAAuB,EAAE,cAAc,CAAU,CAAC;AAE7G,+CAA+C;AAC/C,MAAM,UAAU,QAAQ,CAAC,GAAgB,EAAE,IAAY;IACrD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACxE,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,kBAAkB,CAAC,GAAgB;IACjD,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IAC1B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,gBAAwB;IACtD,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5F,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,cAAc,CAAC,GAAgB,EAAE,IAAY;IAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC","sourcesContent":["/** Environment as the World reads it. */\nexport type WorkflowEnv = Record<string, string | undefined>;\n\n/**\n * Connection string precedence. `DATABASE_URL_UNPOOLED` comes before\n * `DATABASE_URL` because a Neon pooled (PgBouncer, transaction mode) URL\n * cannot hold the `LISTEN` the streamer and `waitForTerminalStatus` use.\n */\nexport const DATABASE_URL_VARS = [\"WORKFLOW_POSTGRES_URL\", \"DATABASE_URL_UNPOOLED\", \"DATABASE_URL\"] as const;\n\n/** Non-empty value of `name`, or undefined. */\nexport function envValue(env: WorkflowEnv, name: string): string | undefined {\n const value = env[name];\n return value === undefined || value.trim() === \"\" ? undefined : value;\n}\n\n/** The first database URL variable that is set, in {@link DATABASE_URL_VARS} order. */\nexport function resolveDatabaseUrl(env: WorkflowEnv): string | undefined {\n for (const name of DATABASE_URL_VARS) {\n const value = envValue(env, name);\n if (value) return value;\n }\n return undefined;\n}\n\n/**\n * Makes a libpq-style URL mean the same thing to node-postgres.\n *\n * libpq reads `sslmode=require` as \"encrypt, do not verify the certificate\";\n * node-postgres reads it as `verify-full` unless `uselibpqcompat=true` is set,\n * and then refuses the unfazed Postgres integration's self-signed certificate.\n * An explicit `uselibpqcompat` is left alone.\n */\nexport function withLibpqCompat(connectionString: string): string {\n let url: URL;\n try {\n url = new URL(connectionString);\n } catch {\n return connectionString;\n }\n if (url.searchParams.get(\"sslmode\") !== \"require\" || url.searchParams.has(\"uselibpqcompat\")) {\n return connectionString;\n }\n url.searchParams.set(\"uselibpqcompat\", \"true\");\n return url.toString();\n}\n\n/** Positive integer value of `name`, or undefined. */\nexport function envPositiveInt(env: WorkflowEnv, name: string): number | undefined {\n const parsed = Number.parseInt(env[name] ?? \"\", 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { UnfazedError } from "../errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Why the unfazed World refused or failed a call.
|
|
4
|
+
*
|
|
5
|
+
* The queue codes are the wire contract's `error` values; the rest are the
|
|
6
|
+
* World's own configuration problems.
|
|
7
|
+
*/
|
|
8
|
+
export type UnfazedWorkflowErrorCode =
|
|
9
|
+
/** No Postgres connection string in the environment. */
|
|
10
|
+
"no_database"
|
|
11
|
+
/** `UNFZ_STATE_URL` / `UNFZ_STATE_TOKEN` missing: not running inside an unfazed service. */
|
|
12
|
+
| "no_platform"
|
|
13
|
+
/** The platform answered 404 on `/queue/v1`: it has no queue yet. */
|
|
14
|
+
| "queue_not_supported"
|
|
15
|
+
/** 409: this app's queue cannot live here (replicas, App State elsewhere). */
|
|
16
|
+
| "queue_unavailable" | "invalid_request" | "unauthorized" | "payload_too_large" | "quota_exceeded"
|
|
17
|
+
/** 503 or a network failure that outlasted the retry budget. */
|
|
18
|
+
| "unavailable"
|
|
19
|
+
/** Any other status. */
|
|
20
|
+
| "http_error";
|
|
21
|
+
/** Everything `unfazed/workflow` throws on purpose. */
|
|
22
|
+
export declare class UnfazedWorkflowError extends UnfazedError {
|
|
23
|
+
readonly code: UnfazedWorkflowErrorCode;
|
|
24
|
+
/** HTTP status from the platform, when the error came from one. */
|
|
25
|
+
readonly status: number | undefined;
|
|
26
|
+
/** Repeating the same call (same idempotency keys) may succeed. */
|
|
27
|
+
readonly retryable: boolean;
|
|
28
|
+
constructor(code: UnfazedWorkflowErrorCode, message: string, options?: {
|
|
29
|
+
status?: number;
|
|
30
|
+
retryable?: boolean;
|
|
31
|
+
cause?: unknown;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UnfazedError } from "../errors.js";
|
|
2
|
+
/** Everything `unfazed/workflow` throws on purpose. */
|
|
3
|
+
export class UnfazedWorkflowError extends UnfazedError {
|
|
4
|
+
code;
|
|
5
|
+
/** HTTP status from the platform, when the error came from one. */
|
|
6
|
+
status;
|
|
7
|
+
/** Repeating the same call (same idempotency keys) may succeed. */
|
|
8
|
+
retryable;
|
|
9
|
+
constructor(code, message, options) {
|
|
10
|
+
super(message, options?.cause === undefined ? undefined : { cause: options.cause });
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.status = options?.status;
|
|
13
|
+
this.retryable = options?.retryable ?? false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/workflow/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA0B5C,uDAAuD;AACvD,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IAC3C,IAAI,CAA2B;IACxC,mEAAmE;IAC1D,MAAM,CAAqB;IACpC,mEAAmE;IAC1D,SAAS,CAAU;IAE5B,YACE,IAA8B,EAC9B,OAAe,EACf,OAAmE;QAEnE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,KAAK,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { UnfazedError } from \"../errors.js\";\n\n/**\n * Why the unfazed World refused or failed a call.\n *\n * The queue codes are the wire contract's `error` values; the rest are the\n * World's own configuration problems.\n */\nexport type UnfazedWorkflowErrorCode =\n /** No Postgres connection string in the environment. */\n | \"no_database\"\n /** `UNFZ_STATE_URL` / `UNFZ_STATE_TOKEN` missing: not running inside an unfazed service. */\n | \"no_platform\"\n /** The platform answered 404 on `/queue/v1`: it has no queue yet. */\n | \"queue_not_supported\"\n /** 409: this app's queue cannot live here (replicas, App State elsewhere). */\n | \"queue_unavailable\"\n | \"invalid_request\"\n | \"unauthorized\"\n | \"payload_too_large\"\n | \"quota_exceeded\"\n /** 503 or a network failure that outlasted the retry budget. */\n | \"unavailable\"\n /** Any other status. */\n | \"http_error\";\n\n/** Everything `unfazed/workflow` throws on purpose. */\nexport class UnfazedWorkflowError extends UnfazedError {\n readonly code: UnfazedWorkflowErrorCode;\n /** HTTP status from the platform, when the error came from one. */\n readonly status: number | undefined;\n /** Repeating the same call (same idempotency keys) may succeed. */\n readonly retryable: boolean;\n\n constructor(\n code: UnfazedWorkflowErrorCode,\n message: string,\n options?: { status?: number; retryable?: boolean; cause?: unknown },\n ) {\n super(message, options?.cause === undefined ? undefined : { cause: options.cause });\n this.code = code;\n this.status = options?.status;\n this.retryable = options?.retryable ?? false;\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `unfazed/workflow` — the unfazed World for Workflow SDK.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { setWorld } from "workflow/runtime";
|
|
6
|
+
* import { createWorld } from "unfazed/workflow";
|
|
7
|
+
*
|
|
8
|
+
* setWorld(createWorld()); // before the server serves
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* With Nitro, add `"unfazed/workflow/nitro"` to `modules` instead; it does
|
|
12
|
+
* exactly that for you. Requires the optional peers `workflow`,
|
|
13
|
+
* `@workflow/world` and `@workflow/world-postgres`.
|
|
14
|
+
*/
|
|
15
|
+
export { createWorld, LOCAL_DEPLOYMENT_ID } from "./world.js";
|
|
16
|
+
export type { UnfazedWorld, UnfazedWorldOptions } from "./world.js";
|
|
17
|
+
export { UnfazedWorkflowError } from "./errors.js";
|
|
18
|
+
export type { UnfazedWorkflowErrorCode } from "./errors.js";
|
|
19
|
+
export { DATABASE_URL_VARS, resolveDatabaseUrl, withLibpqCompat } from "./config.js";
|
|
20
|
+
export { applyPublicUrl } from "./public-url.js";
|
|
21
|
+
export type { PublicUrlResult } from "./public-url.js";
|
|
22
|
+
export type { WorkflowEnv } from "./config.js";
|
|
23
|
+
export { DELIVERY_HEADERS, QUEUE_API_PATH, verifyQueueToken } from "./queue.js";
|
|
24
|
+
export { createInspectHandler, INSPECT_BASE_PATH, INSPECT_CONTRACT_VERSION } from "./inspect.js";
|
|
25
|
+
export type { InspectHandlerOptions, InspectRunHandle } from "./inspect.js";
|
|
26
|
+
export type { InspectError, InspectValue } from "./inspect-render.js";
|
|
27
|
+
export type { QueueStats, WorkflowFetch } from "./queue.js";
|
|
28
|
+
export { MIGRATIONS_SCHEMA, MIGRATIONS_TABLE } from "./migration-types.js";
|
|
29
|
+
export type { WorkflowMigrations } from "./migration-types.js";
|
|
30
|
+
export { embeddedMigrations } from "./migrations.generated.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `unfazed/workflow` — the unfazed World for Workflow SDK.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { setWorld } from "workflow/runtime";
|
|
6
|
+
* import { createWorld } from "unfazed/workflow";
|
|
7
|
+
*
|
|
8
|
+
* setWorld(createWorld()); // before the server serves
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* With Nitro, add `"unfazed/workflow/nitro"` to `modules` instead; it does
|
|
12
|
+
* exactly that for you. Requires the optional peers `workflow`,
|
|
13
|
+
* `@workflow/world` and `@workflow/world-postgres`.
|
|
14
|
+
*/
|
|
15
|
+
export { createWorld, LOCAL_DEPLOYMENT_ID } from "./world.js";
|
|
16
|
+
export { UnfazedWorkflowError } from "./errors.js";
|
|
17
|
+
export { DATABASE_URL_VARS, resolveDatabaseUrl, withLibpqCompat } from "./config.js";
|
|
18
|
+
export { applyPublicUrl } from "./public-url.js";
|
|
19
|
+
export { DELIVERY_HEADERS, QUEUE_API_PATH, verifyQueueToken } from "./queue.js";
|
|
20
|
+
export { createInspectHandler, INSPECT_BASE_PATH, INSPECT_CONTRACT_VERSION } from "./inspect.js";
|
|
21
|
+
export { MIGRATIONS_SCHEMA, MIGRATIONS_TABLE } from "./migration-types.js";
|
|
22
|
+
export { embeddedMigrations } from "./migrations.generated.js";
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAIjG,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["/**\n * `unfazed/workflow` — the unfazed World for Workflow SDK.\n *\n * ```ts\n * import { setWorld } from \"workflow/runtime\";\n * import { createWorld } from \"unfazed/workflow\";\n *\n * setWorld(createWorld()); // before the server serves\n * ```\n *\n * With Nitro, add `\"unfazed/workflow/nitro\"` to `modules` instead; it does\n * exactly that for you. Requires the optional peers `workflow`,\n * `@workflow/world` and `@workflow/world-postgres`.\n */\nexport { createWorld, LOCAL_DEPLOYMENT_ID } from \"./world.js\";\nexport type { UnfazedWorld, UnfazedWorldOptions } from \"./world.js\";\nexport { UnfazedWorkflowError } from \"./errors.js\";\nexport type { UnfazedWorkflowErrorCode } from \"./errors.js\";\nexport { DATABASE_URL_VARS, resolveDatabaseUrl, withLibpqCompat } from \"./config.js\";\nexport { applyPublicUrl } from \"./public-url.js\";\nexport type { PublicUrlResult } from \"./public-url.js\";\nexport type { WorkflowEnv } from \"./config.js\";\nexport { DELIVERY_HEADERS, QUEUE_API_PATH, verifyQueueToken } from \"./queue.js\";\nexport { createInspectHandler, INSPECT_BASE_PATH, INSPECT_CONTRACT_VERSION } from \"./inspect.js\";\nexport type { InspectHandlerOptions, InspectRunHandle } from \"./inspect.js\";\nexport type { InspectError, InspectValue } from \"./inspect-render.js\";\nexport type { QueueStats, WorkflowFetch } from \"./queue.js\";\nexport { MIGRATIONS_SCHEMA, MIGRATIONS_TABLE } from \"./migration-types.js\";\nexport type { WorkflowMigrations } from \"./migration-types.js\";\nexport { embeddedMigrations } from \"./migrations.generated.js\";\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** A payload as display text (`Value` in the contract). */
|
|
2
|
+
export interface InspectValue {
|
|
3
|
+
text: string;
|
|
4
|
+
/** UTF-8 length of the whole text, before any cut. */
|
|
5
|
+
bytes: number;
|
|
6
|
+
truncated: boolean;
|
|
7
|
+
/** Present (true) only when the payload could not be hydrated; `text` is the reason. */
|
|
8
|
+
error?: true;
|
|
9
|
+
}
|
|
10
|
+
/** A thrown run or step error (`Error` in the contract). */
|
|
11
|
+
export interface InspectError {
|
|
12
|
+
message: string;
|
|
13
|
+
stack: string | null;
|
|
14
|
+
code: string | null;
|
|
15
|
+
truncated: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const MESSAGE_CAP_BYTES: number;
|
|
18
|
+
export declare const STACK_CAP_BYTES: number;
|
|
19
|
+
export declare const INFO_CAP_BYTES: number;
|
|
20
|
+
export interface DisplayOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Strings to replace with `[redacted]` wherever they occur in a string
|
|
23
|
+
* (hook tokens, so neither a token nor a webhook URL built from one leaves).
|
|
24
|
+
*/
|
|
25
|
+
secrets?: readonly string[];
|
|
26
|
+
/** Drop every object key named `token`, at any depth. */
|
|
27
|
+
dropTokenKeys?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const REDACTED = "[redacted]";
|
|
30
|
+
/** Workflow SDK's webhook route; the path segment after it is the hook's token. */
|
|
31
|
+
export declare const WEBHOOK_PATH = "/.well-known/workflow/v1/webhook/";
|
|
32
|
+
/**
|
|
33
|
+
* `text` with the token of every Workflow SDK webhook URL in it replaced by
|
|
34
|
+
* `[redacted]`: `https://app.example/.well-known/workflow/v1/webhook/<token>?a=1`
|
|
35
|
+
* reads `https://app.example/.well-known/workflow/v1/webhook/[redacted]?a=1`.
|
|
36
|
+
* A webhook URL is a capability (anyone holding it resumes the run), so none
|
|
37
|
+
* leaves the route, whatever the app wrote it into.
|
|
38
|
+
*/
|
|
39
|
+
export declare function redactWebhookTokens(text: string): string;
|
|
40
|
+
/** UTF-8 length of `text`. */
|
|
41
|
+
export declare function utf8Length(text: string): number;
|
|
42
|
+
/**
|
|
43
|
+
* `text` cut to at most `capBytes` of UTF-8 on a character boundary, and
|
|
44
|
+
* whether it was cut.
|
|
45
|
+
*/
|
|
46
|
+
export declare function cutUtf8(text: string, capBytes: number): {
|
|
47
|
+
text: string;
|
|
48
|
+
truncated: boolean;
|
|
49
|
+
bytes: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The contract's replacer, as a walk that builds a JSON-safe tree:
|
|
53
|
+
* `bigint` → `"123n"`, `undefined` → `null`, `Map` → `{"$map": [[k, v], …]}`,
|
|
54
|
+
* `Set` → `{"$set": […]}`, bytes → `{"$bytes": n}`, `Error` →
|
|
55
|
+
* `{"$error": {name, message, stack}}`, a function → `"[function name]"`, a
|
|
56
|
+
* cycle → `"[circular]"`; anything with `toJSON()` (the revivers' display
|
|
57
|
+
* objects, `Date`, `URL`) goes through it first, as `JSON.stringify` does.
|
|
58
|
+
*/
|
|
59
|
+
export declare function toDisplayJson(value: unknown, options?: DisplayOptions): unknown;
|
|
60
|
+
/** `JSON.stringify(value, replacer, 2)` of the contract. */
|
|
61
|
+
export declare function displayText(value: unknown, options?: DisplayOptions): string;
|
|
62
|
+
/** A hydrated payload as a `Value`, cut at `capBytes`; `undefined`/`null` is `null`. */
|
|
63
|
+
export declare function renderValue(value: unknown, capBytes: number, options?: DisplayOptions): InspectValue | null;
|
|
64
|
+
/** A payload that failed to hydrate (or to render): the error's message, flagged. */
|
|
65
|
+
export declare function failedValue(error: unknown, capBytes: number): InspectValue;
|
|
66
|
+
/**
|
|
67
|
+
* A hydrated run or step error as the contract's `Error`: `message` at most
|
|
68
|
+
* 4 KiB, `stack` at most 8 KiB or `null`, `code` as given.
|
|
69
|
+
*/
|
|
70
|
+
export declare function renderError(hydrated: unknown, code: string | null, failure: unknown, options?: DisplayOptions): InspectError;
|
|
71
|
+
type InfoJson = string | number | boolean | null | InfoJson[] | {
|
|
72
|
+
[key: string]: InfoJson;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* An event's `info`: its `eventData` as `resolveData: "none"` leaves it, every
|
|
76
|
+
* `token` key removed at any depth, only strings, numbers, booleans, `null`
|
|
77
|
+
* and objects/arrays of those kept (a `Date` becomes its RFC 3339 string); at
|
|
78
|
+
* most 2 KiB serialized, else `{}` and truncated.
|
|
79
|
+
*/
|
|
80
|
+
export declare function eventInfo(eventData: unknown): {
|
|
81
|
+
info: Record<string, InfoJson>;
|
|
82
|
+
truncated: boolean;
|
|
83
|
+
};
|
|
84
|
+
/** RFC 3339 UTC with milliseconds, or `null`. */
|
|
85
|
+
export declare function isoTime(value: unknown): string | null;
|
|
86
|
+
/**
|
|
87
|
+
* A step's input as the SDK's own inspector shows it: its arguments. Workflow
|
|
88
|
+
* SDK stores a step's input as `{ args, closureVars, thisVal }`; this answers
|
|
89
|
+
* `args` alone, or `{ args, closureVars?, thisVal? }` with only the parts that
|
|
90
|
+
* hold something. Anything not exactly that envelope is returned as it is.
|
|
91
|
+
*/
|
|
92
|
+
export declare function stepInputDisplay(input: unknown): unknown;
|
|
93
|
+
export {};
|