@major-tech/workflows-client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/client.d.ts +7 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +17 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +2 -2
- package/dist/next/index.cjs +17 -0
- package/dist/next/index.cjs.map +2 -2
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +17 -0
- package/dist/next/index.js.map +2 -2
- package/dist/types.d.ts +56 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ const { runId } = await leadEnrichmentWorkflowClient.run({ input: { leadId } });
|
|
|
10
10
|
|
|
11
11
|
- `run({ input? })` runs the workflow's published version. From a sandbox preview, the run's calls back to this
|
|
12
12
|
app go to that preview.
|
|
13
|
+
- `getRun({ runId })` reads back a run this app started: `run.status`, then `document.output` once it completed or
|
|
14
|
+
`run.error` once it failed or was canceled.
|
|
13
15
|
- Generate a client per workflow: `npx @major-tech/workflows-client add <workflow_id> <name> --framework nextjs`.
|
|
14
16
|
Deploy grants the app permission to start the workflows its generated clients name.
|
|
15
17
|
- For a Vite app with a Hono backend, run the generator in the backend package with `--framework hono`. The backend must install Hono’s `contextStorage()` middleware to forward the viewer JWT.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { WorkflowsClientConfig, RunWorkflowRequest, RunWorkflowResponse } from "./types";
|
|
1
|
+
import type { WorkflowsClientConfig, RunWorkflowRequest, RunWorkflowResponse, GetWorkflowRunRequest, GetWorkflowRunResponse } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
* Client for starting Major workflow runs from a deployed app or sandbox preview.
|
|
3
|
+
* Client for starting Major workflow runs, and reading back the runs it started, from a deployed app or sandbox preview.
|
|
4
4
|
*
|
|
5
5
|
* Prefer the `createWorkflowsClient()` factory — it reads platform-managed env
|
|
6
6
|
* vars and (when imported from `@major-tech/workflows-client/next`) wires up
|
|
@@ -19,6 +19,11 @@ export declare class WorkflowsClient {
|
|
|
19
19
|
* preview, the run's calls back to this app go to that preview.
|
|
20
20
|
*/
|
|
21
21
|
run(request?: RunWorkflowRequest): Promise<RunWorkflowResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Read back a run this app started: its status, and once finished its output
|
|
24
|
+
* (`document.output`) or error (`run.error`). Any other run is not found.
|
|
25
|
+
*/
|
|
26
|
+
getRun(request: GetWorkflowRunRequest): Promise<GetWorkflowRunResponse>;
|
|
22
27
|
private request;
|
|
23
28
|
}
|
|
24
29
|
/**
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AASjB;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiE;IAC5F,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;gBAE7B,MAAM,GAAE,qBAA0B;IAiB9C;;;;OAIG;IACG,GAAG,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAazE;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAe/D,OAAO;CAmCtB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,qBAA0B,GAAG,eAAe,CAEzF"}
|
package/dist/index.cjs
CHANGED
|
@@ -102,6 +102,23 @@ var WorkflowsClient = class {
|
|
|
102
102
|
input: request.input
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Read back a run this app started: its status, and once finished its output
|
|
107
|
+
* (`document.output`) or error (`run.error`). Any other run is not found.
|
|
108
|
+
*/
|
|
109
|
+
async getRun(request) {
|
|
110
|
+
const workflowId = request.workflowId ?? this.workflowId;
|
|
111
|
+
if (!workflowId) {
|
|
112
|
+
throw new WorkflowsValidationError(
|
|
113
|
+
"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client)."
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return this.request(
|
|
117
|
+
"GET",
|
|
118
|
+
`/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,
|
|
119
|
+
void 0
|
|
120
|
+
);
|
|
121
|
+
}
|
|
105
122
|
async request(method, path, body) {
|
|
106
123
|
const headers = { "Content-Type": "application/json" };
|
|
107
124
|
const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/errors.ts", "../src/client.ts"],
|
|
4
|
-
"sourcesContent": ["export { WorkflowsClient, createWorkflowsClient } from \"./client\";\nexport type {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA,EACjE,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,qBAAN,cAAiC,qBAAqB;AAAA,EAC3D,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,wBAAN,cAAoC,qBAAqB;AAAA,EAC9D,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,6BAAN,cAAyC,qBAAqB;AAAA,EACnE,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;;;
|
|
4
|
+
"sourcesContent": ["export { WorkflowsClient, createWorkflowsClient } from \"./client\";\nexport type {\n WorkflowsClientConfig,\n RunWorkflowRequest,\n RunWorkflowResponse,\n GetWorkflowRunRequest,\n GetWorkflowRunResponse,\n WorkflowRun,\n WorkflowRunDocument,\n} from \"./types\";\nexport {\n WorkflowsClientError,\n WorkflowsValidationError,\n WorkflowsAuthError,\n WorkflowNotFoundError,\n WorkflowRunNotStartedError,\n} from \"./errors\";\n", "/**\n * Error hierarchy for the Major workflows client. Every error extends\n * {@link WorkflowsClientError}, which carries the HTTP status (when the failure\n * came from a response) and the server's `x-request-id` for support/debugging.\n */\nexport class WorkflowsClientError extends Error {\n readonly httpStatus?: number;\n readonly requestId?: string;\n\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message);\n this.name = \"WorkflowsClientError\";\n this.httpStatus = httpStatus;\n this.requestId = requestId;\n }\n}\n\n/** The request was rejected as invalid, e.g. input failing the workflow's `input_schema` (HTTP 400). */\nexport class WorkflowsValidationError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 400, requestId);\n this.name = \"WorkflowsValidationError\";\n }\n}\n\n/**\n * Authentication or authorization failed (HTTP 401/403): no caller token, or\n * the app or its deployer may not use this workflow.\n */\nexport class WorkflowsAuthError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowsAuthError\";\n }\n}\n\n/** The workflow or version could not be found (HTTP 404). */\nexport class WorkflowNotFoundError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 404, requestId);\n this.name = \"WorkflowNotFoundError\";\n }\n}\n\n/**\n * The run could not be started: the workflow is not published (HTTP 409), or a\n * transport error prevented the request.\n */\nexport class WorkflowRunNotStartedError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowRunNotStartedError\";\n }\n}\n", "import type {\n WorkflowsClientConfig,\n RunWorkflowRequest,\n RunWorkflowResponse,\n GetWorkflowRunRequest,\n GetWorkflowRunResponse,\n} from \"./types\";\nimport {\n WorkflowsClientError,\n WorkflowsValidationError,\n WorkflowsAuthError,\n WorkflowNotFoundError,\n WorkflowRunNotStartedError,\n} from \"./errors\";\n\n/**\n * Client for starting Major workflow runs, and reading back the runs it started, from a deployed app or sandbox preview.\n *\n * Prefer the `createWorkflowsClient()` factory \u2014 it reads platform-managed env\n * vars and (when imported from `@major-tech/workflows-client/next`) wires up\n * auto-forwarding of the inbound viewer JWT.\n */\nexport class WorkflowsClient {\n private readonly baseUrl: string;\n private readonly majorJwtToken: string | undefined;\n private readonly workflowId: string | undefined;\n private readonly getHeaders: () => Promise<Record<string, string>> | Record<string, string>;\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: WorkflowsClientConfig = {}) {\n const baseUrl = config.baseUrl ?? process.env.MAJOR_API_BASE_URL;\n if (!baseUrl) {\n throw new WorkflowsClientError(\n \"WorkflowsClient: baseUrl is required (set MAJOR_API_BASE_URL or pass baseUrl explicitly).\",\n );\n }\n\n // The JWT is read lazily so generated module-scope singletons can load during\n // `next build` page-data collection (MAJOR_JWT_TOKEN is injected at runtime).\n this.baseUrl = baseUrl.replace(/\\/$/, \"\");\n this.majorJwtToken = config.majorJwtToken;\n this.workflowId = config.workflowId;\n this.getHeaders = config.getHeaders ?? (() => ({}));\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n }\n\n /**\n * Start a run. Returns as soon as the run is accepted; the workflow runs\n * asynchronously. It runs the workflow's published version; from a sandbox\n * preview, the run's calls back to this app go to that preview.\n */\n async run(request: RunWorkflowRequest = {}): Promise<RunWorkflowResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.run: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<RunWorkflowResponse>(\"POST\", `/workflows/${encodeURIComponent(workflowId)}/runs`, {\n input: request.input,\n });\n }\n\n /**\n * Read back a run this app started: its status, and once finished its output\n * (`document.output`) or error (`run.error`). Any other run is not found.\n */\n async getRun(request: GetWorkflowRunRequest): Promise<GetWorkflowRunResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<GetWorkflowRunResponse>(\n \"GET\",\n `/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,\n undefined,\n );\n }\n\n private async request<T>(method: string, path: string, body: unknown): Promise<T> {\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;\n if (majorJwtToken) {\n headers[\"x-major-jwt\"] = majorJwtToken;\n }\n Object.assign(headers, await this.getHeaders());\n\n if (!headers[\"x-major-jwt\"] && !headers[\"x-major-user-jwt\"]) {\n throw new WorkflowsAuthError(\n \"WorkflowsClient: no credentials (set MAJOR_JWT_TOKEN, or call from a request that carries x-major-user-jwt).\",\n );\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new WorkflowRunNotStartedError(`Failed to reach Major API: ${message}`);\n }\n\n const requestId = response.headers.get(\"x-request-id\") ?? undefined;\n\n if (response.ok) {\n return (await response.json()) as T;\n }\n\n const errorMessage = await readErrorMessage(response);\n throw toWorkflowsError(response.status, errorMessage, requestId);\n }\n}\n\n/**\n * Factory equivalent to `new WorkflowsClient(config)`.\n *\n * In Next.js apps, prefer `createWorkflowsClient` from\n * `@major-tech/workflows-client/next` \u2014 it auto-forwards `x-major-user-jwt` from\n * the inbound request headers.\n */\nexport function createWorkflowsClient(config: WorkflowsClientConfig = {}): WorkflowsClient {\n return new WorkflowsClient(config);\n}\n\nfunction toWorkflowsError(status: number, message: string, requestId?: string): WorkflowsClientError {\n if (status === 400) {\n return new WorkflowsValidationError(message, requestId);\n }\n if (status === 401 || status === 403) {\n return new WorkflowsAuthError(message, status, requestId);\n }\n if (status === 404) {\n return new WorkflowNotFoundError(message, requestId);\n }\n return new WorkflowRunNotStartedError(message, status, requestId);\n}\n\nasync function readErrorMessage(response: Response): Promise<string> {\n try {\n const data = (await response.json()) as { error?: unknown; message?: unknown };\n if (typeof data.error === \"string\") {\n return data.error;\n }\n if (typeof data.message === \"string\") {\n return data.message;\n }\n } catch {\n // Non-JSON body: fall through to the status text.\n }\n return `HTTP ${response.status} ${response.statusText}`;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AM,YAAY,SAAS,QAAQ,IAAI,cAAc,KAAK;AAE1D,QAAI,SAAS,IAAI;AACf,aAAQ,MAAM,SAAS,KAAK;AAAA,IAC9B;AAEA,UAAM,eAAe,MAAM,iBAAiB,QAAQ;AACpD,UAAM,iBAAiB,SAAS,QAAQ,cAAc,SAAS;AAAA,EACjE;AACF;AASO,SAAS,sBAAsB,SAAgC,CAAC,GAAoB;AACzF,SAAO,IAAI,gBAAgB,MAAM;AACnC;AAEA,SAAS,iBAAiB,QAAgB,SAAiB,WAA0C;AACnG,MAAI,WAAW,KAAK;AAClB,WAAO,IAAI,yBAAyB,SAAS,SAAS;AAAA,EACxD;AACA,MAAI,WAAW,OAAO,WAAW,KAAK;AACpC,WAAO,IAAI,mBAAmB,SAAS,QAAQ,SAAS;AAAA,EAC1D;AACA,MAAI,WAAW,KAAK;AAClB,WAAO,IAAI,sBAAsB,SAAS,SAAS;AAAA,EACrD;AACA,SAAO,IAAI,2BAA2B,SAAS,QAAQ,SAAS;AAClE;AAEA,eAAe,iBAAiB,UAAqC;AACnE,MAAI;AACF,UAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,QAAI,OAAO,KAAK,UAAU,UAAU;AAClC,aAAO,KAAK;AAAA,IACd;AACA,QAAI,OAAO,KAAK,YAAY,UAAU;AACpC,aAAO,KAAK;AAAA,IACd;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO,QAAQ,SAAS,MAAM,IAAI,SAAS,UAAU;AACvD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { WorkflowsClient, createWorkflowsClient } from "./client";
|
|
2
|
-
export type { WorkflowsClientConfig, RunWorkflowRequest, RunWorkflowResponse } from "./types";
|
|
2
|
+
export type { WorkflowsClientConfig, RunWorkflowRequest, RunWorkflowResponse, GetWorkflowRunRequest, GetWorkflowRunResponse, WorkflowRun, WorkflowRunDocument, } from "./types";
|
|
3
3
|
export { WorkflowsClientError, WorkflowsValidationError, WorkflowsAuthError, WorkflowNotFoundError, WorkflowRunNotStartedError, } from "./errors";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAClE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAClE,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,23 @@ var WorkflowsClient = class {
|
|
|
70
70
|
input: request.input
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Read back a run this app started: its status, and once finished its output
|
|
75
|
+
* (`document.output`) or error (`run.error`). Any other run is not found.
|
|
76
|
+
*/
|
|
77
|
+
async getRun(request) {
|
|
78
|
+
const workflowId = request.workflowId ?? this.workflowId;
|
|
79
|
+
if (!workflowId) {
|
|
80
|
+
throw new WorkflowsValidationError(
|
|
81
|
+
"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client)."
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return this.request(
|
|
85
|
+
"GET",
|
|
86
|
+
`/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,
|
|
87
|
+
void 0
|
|
88
|
+
);
|
|
89
|
+
}
|
|
73
90
|
async request(method, path, body) {
|
|
74
91
|
const headers = { "Content-Type": "application/json" };
|
|
75
92
|
const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/errors.ts", "../src/client.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Error hierarchy for the Major workflows client. Every error extends\n * {@link WorkflowsClientError}, which carries the HTTP status (when the failure\n * came from a response) and the server's `x-request-id` for support/debugging.\n */\nexport class WorkflowsClientError extends Error {\n readonly httpStatus?: number;\n readonly requestId?: string;\n\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message);\n this.name = \"WorkflowsClientError\";\n this.httpStatus = httpStatus;\n this.requestId = requestId;\n }\n}\n\n/** The request was rejected as invalid, e.g. input failing the workflow's `input_schema` (HTTP 400). */\nexport class WorkflowsValidationError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 400, requestId);\n this.name = \"WorkflowsValidationError\";\n }\n}\n\n/**\n * Authentication or authorization failed (HTTP 401/403): no caller token, or\n * the app or its deployer may not use this workflow.\n */\nexport class WorkflowsAuthError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowsAuthError\";\n }\n}\n\n/** The workflow or version could not be found (HTTP 404). */\nexport class WorkflowNotFoundError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 404, requestId);\n this.name = \"WorkflowNotFoundError\";\n }\n}\n\n/**\n * The run could not be started: the workflow is not published (HTTP 409), or a\n * transport error prevented the request.\n */\nexport class WorkflowRunNotStartedError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowRunNotStartedError\";\n }\n}\n", "import type {
|
|
5
|
-
"mappings": ";AAKO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA,EACjE,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,qBAAN,cAAiC,qBAAqB;AAAA,EAC3D,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,wBAAN,cAAoC,qBAAqB;AAAA,EAC9D,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,6BAAN,cAAyC,qBAAqB;AAAA,EACnE,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;;;
|
|
4
|
+
"sourcesContent": ["/**\n * Error hierarchy for the Major workflows client. Every error extends\n * {@link WorkflowsClientError}, which carries the HTTP status (when the failure\n * came from a response) and the server's `x-request-id` for support/debugging.\n */\nexport class WorkflowsClientError extends Error {\n readonly httpStatus?: number;\n readonly requestId?: string;\n\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message);\n this.name = \"WorkflowsClientError\";\n this.httpStatus = httpStatus;\n this.requestId = requestId;\n }\n}\n\n/** The request was rejected as invalid, e.g. input failing the workflow's `input_schema` (HTTP 400). */\nexport class WorkflowsValidationError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 400, requestId);\n this.name = \"WorkflowsValidationError\";\n }\n}\n\n/**\n * Authentication or authorization failed (HTTP 401/403): no caller token, or\n * the app or its deployer may not use this workflow.\n */\nexport class WorkflowsAuthError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowsAuthError\";\n }\n}\n\n/** The workflow or version could not be found (HTTP 404). */\nexport class WorkflowNotFoundError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 404, requestId);\n this.name = \"WorkflowNotFoundError\";\n }\n}\n\n/**\n * The run could not be started: the workflow is not published (HTTP 409), or a\n * transport error prevented the request.\n */\nexport class WorkflowRunNotStartedError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowRunNotStartedError\";\n }\n}\n", "import type {\n WorkflowsClientConfig,\n RunWorkflowRequest,\n RunWorkflowResponse,\n GetWorkflowRunRequest,\n GetWorkflowRunResponse,\n} from \"./types\";\nimport {\n WorkflowsClientError,\n WorkflowsValidationError,\n WorkflowsAuthError,\n WorkflowNotFoundError,\n WorkflowRunNotStartedError,\n} from \"./errors\";\n\n/**\n * Client for starting Major workflow runs, and reading back the runs it started, from a deployed app or sandbox preview.\n *\n * Prefer the `createWorkflowsClient()` factory \u2014 it reads platform-managed env\n * vars and (when imported from `@major-tech/workflows-client/next`) wires up\n * auto-forwarding of the inbound viewer JWT.\n */\nexport class WorkflowsClient {\n private readonly baseUrl: string;\n private readonly majorJwtToken: string | undefined;\n private readonly workflowId: string | undefined;\n private readonly getHeaders: () => Promise<Record<string, string>> | Record<string, string>;\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: WorkflowsClientConfig = {}) {\n const baseUrl = config.baseUrl ?? process.env.MAJOR_API_BASE_URL;\n if (!baseUrl) {\n throw new WorkflowsClientError(\n \"WorkflowsClient: baseUrl is required (set MAJOR_API_BASE_URL or pass baseUrl explicitly).\",\n );\n }\n\n // The JWT is read lazily so generated module-scope singletons can load during\n // `next build` page-data collection (MAJOR_JWT_TOKEN is injected at runtime).\n this.baseUrl = baseUrl.replace(/\\/$/, \"\");\n this.majorJwtToken = config.majorJwtToken;\n this.workflowId = config.workflowId;\n this.getHeaders = config.getHeaders ?? (() => ({}));\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n }\n\n /**\n * Start a run. Returns as soon as the run is accepted; the workflow runs\n * asynchronously. It runs the workflow's published version; from a sandbox\n * preview, the run's calls back to this app go to that preview.\n */\n async run(request: RunWorkflowRequest = {}): Promise<RunWorkflowResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.run: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<RunWorkflowResponse>(\"POST\", `/workflows/${encodeURIComponent(workflowId)}/runs`, {\n input: request.input,\n });\n }\n\n /**\n * Read back a run this app started: its status, and once finished its output\n * (`document.output`) or error (`run.error`). Any other run is not found.\n */\n async getRun(request: GetWorkflowRunRequest): Promise<GetWorkflowRunResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<GetWorkflowRunResponse>(\n \"GET\",\n `/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,\n undefined,\n );\n }\n\n private async request<T>(method: string, path: string, body: unknown): Promise<T> {\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;\n if (majorJwtToken) {\n headers[\"x-major-jwt\"] = majorJwtToken;\n }\n Object.assign(headers, await this.getHeaders());\n\n if (!headers[\"x-major-jwt\"] && !headers[\"x-major-user-jwt\"]) {\n throw new WorkflowsAuthError(\n \"WorkflowsClient: no credentials (set MAJOR_JWT_TOKEN, or call from a request that carries x-major-user-jwt).\",\n );\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new WorkflowRunNotStartedError(`Failed to reach Major API: ${message}`);\n }\n\n const requestId = response.headers.get(\"x-request-id\") ?? undefined;\n\n if (response.ok) {\n return (await response.json()) as T;\n }\n\n const errorMessage = await readErrorMessage(response);\n throw toWorkflowsError(response.status, errorMessage, requestId);\n }\n}\n\n/**\n * Factory equivalent to `new WorkflowsClient(config)`.\n *\n * In Next.js apps, prefer `createWorkflowsClient` from\n * `@major-tech/workflows-client/next` \u2014 it auto-forwards `x-major-user-jwt` from\n * the inbound request headers.\n */\nexport function createWorkflowsClient(config: WorkflowsClientConfig = {}): WorkflowsClient {\n return new WorkflowsClient(config);\n}\n\nfunction toWorkflowsError(status: number, message: string, requestId?: string): WorkflowsClientError {\n if (status === 400) {\n return new WorkflowsValidationError(message, requestId);\n }\n if (status === 401 || status === 403) {\n return new WorkflowsAuthError(message, status, requestId);\n }\n if (status === 404) {\n return new WorkflowNotFoundError(message, requestId);\n }\n return new WorkflowRunNotStartedError(message, status, requestId);\n}\n\nasync function readErrorMessage(response: Response): Promise<string> {\n try {\n const data = (await response.json()) as { error?: unknown; message?: unknown };\n if (typeof data.error === \"string\") {\n return data.error;\n }\n if (typeof data.message === \"string\") {\n return data.message;\n }\n } catch {\n // Non-JSON body: fall through to the status text.\n }\n return `HTTP ${response.status} ${response.statusText}`;\n}\n"],
|
|
5
|
+
"mappings": ";AAKO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA,EACjE,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;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SAAiB,WAA0C;AACnG,MAAI,WAAW,KAAK;AAClB,WAAO,IAAI,yBAAyB,SAAS,SAAS;AAAA,EACxD;AACA,MAAI,WAAW,OAAO,WAAW,KAAK;AACpC,WAAO,IAAI,mBAAmB,SAAS,QAAQ,SAAS;AAAA,EAC1D;AACA,MAAI,WAAW,KAAK;AAClB,WAAO,IAAI,sBAAsB,SAAS,SAAS;AAAA,EACrD;AACA,SAAO,IAAI,2BAA2B,SAAS,QAAQ,SAAS;AAClE;AAEA,eAAe,iBAAiB,UAAqC;AACnE,MAAI;AACF,UAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,QAAI,OAAO,KAAK,UAAU,UAAU;AAClC,aAAO,KAAK;AAAA,IACd;AACA,QAAI,OAAO,KAAK,YAAY,UAAU;AACpC,aAAO,KAAK;AAAA,IACd;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO,QAAQ,SAAS,MAAM,IAAI,SAAS,UAAU;AACvD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/next/index.cjs
CHANGED
|
@@ -102,6 +102,23 @@ var WorkflowsClient = class {
|
|
|
102
102
|
input: request.input
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Read back a run this app started: its status, and once finished its output
|
|
107
|
+
* (`document.output`) or error (`run.error`). Any other run is not found.
|
|
108
|
+
*/
|
|
109
|
+
async getRun(request) {
|
|
110
|
+
const workflowId = request.workflowId ?? this.workflowId;
|
|
111
|
+
if (!workflowId) {
|
|
112
|
+
throw new WorkflowsValidationError(
|
|
113
|
+
"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client)."
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return this.request(
|
|
117
|
+
"GET",
|
|
118
|
+
`/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,
|
|
119
|
+
void 0
|
|
120
|
+
);
|
|
121
|
+
}
|
|
105
122
|
async request(method, path, body) {
|
|
106
123
|
const headers2 = { "Content-Type": "application/json" };
|
|
107
124
|
const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;
|
package/dist/next/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/next/index.ts", "../../src/errors.ts", "../../src/client.ts", "../../src/next/auth.ts"],
|
|
4
|
-
"sourcesContent": ["import { WorkflowsClient } from \"../client\";\nimport type { WorkflowsClientConfig } from \"../types\";\nimport { defaultGetHeaders } from \"./auth\";\n\n/**\n * Next.js-aware factory: identical to the base `createWorkflowsClient`, but\n * defaults `getHeaders` to lift `x-major-user-jwt` from the inbound request.\n * Pass an explicit `getHeaders` to override.\n */\nexport function createWorkflowsClient(config: WorkflowsClientConfig = {}): WorkflowsClient {\n return new WorkflowsClient({\n ...config,\n getHeaders: config.getHeaders ?? defaultGetHeaders,\n });\n}\n\nexport { WorkflowsClient } from \"../client\";\nexport type {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA,EACjE,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,qBAAN,cAAiC,qBAAqB;AAAA,EAC3D,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,wBAAN,cAAoC,qBAAqB;AAAA,EAC9D,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,6BAAN,cAAyC,qBAAqB;AAAA,EACnE,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;;;
|
|
4
|
+
"sourcesContent": ["import { WorkflowsClient } from \"../client\";\nimport type { WorkflowsClientConfig } from \"../types\";\nimport { defaultGetHeaders } from \"./auth\";\n\n/**\n * Next.js-aware factory: identical to the base `createWorkflowsClient`, but\n * defaults `getHeaders` to lift `x-major-user-jwt` from the inbound request.\n * Pass an explicit `getHeaders` to override.\n */\nexport function createWorkflowsClient(config: WorkflowsClientConfig = {}): WorkflowsClient {\n return new WorkflowsClient({\n ...config,\n getHeaders: config.getHeaders ?? defaultGetHeaders,\n });\n}\n\nexport { WorkflowsClient } from \"../client\";\nexport type {\n WorkflowsClientConfig,\n RunWorkflowRequest,\n RunWorkflowResponse,\n GetWorkflowRunRequest,\n GetWorkflowRunResponse,\n WorkflowRun,\n WorkflowRunDocument,\n} from \"../types\";\nexport {\n WorkflowsClientError,\n WorkflowsValidationError,\n WorkflowsAuthError,\n WorkflowNotFoundError,\n WorkflowRunNotStartedError,\n} from \"../errors\";\n", "/**\n * Error hierarchy for the Major workflows client. Every error extends\n * {@link WorkflowsClientError}, which carries the HTTP status (when the failure\n * came from a response) and the server's `x-request-id` for support/debugging.\n */\nexport class WorkflowsClientError extends Error {\n readonly httpStatus?: number;\n readonly requestId?: string;\n\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message);\n this.name = \"WorkflowsClientError\";\n this.httpStatus = httpStatus;\n this.requestId = requestId;\n }\n}\n\n/** The request was rejected as invalid, e.g. input failing the workflow's `input_schema` (HTTP 400). */\nexport class WorkflowsValidationError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 400, requestId);\n this.name = \"WorkflowsValidationError\";\n }\n}\n\n/**\n * Authentication or authorization failed (HTTP 401/403): no caller token, or\n * the app or its deployer may not use this workflow.\n */\nexport class WorkflowsAuthError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowsAuthError\";\n }\n}\n\n/** The workflow or version could not be found (HTTP 404). */\nexport class WorkflowNotFoundError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 404, requestId);\n this.name = \"WorkflowNotFoundError\";\n }\n}\n\n/**\n * The run could not be started: the workflow is not published (HTTP 409), or a\n * transport error prevented the request.\n */\nexport class WorkflowRunNotStartedError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowRunNotStartedError\";\n }\n}\n", "import type {\n WorkflowsClientConfig,\n RunWorkflowRequest,\n RunWorkflowResponse,\n GetWorkflowRunRequest,\n GetWorkflowRunResponse,\n} from \"./types\";\nimport {\n WorkflowsClientError,\n WorkflowsValidationError,\n WorkflowsAuthError,\n WorkflowNotFoundError,\n WorkflowRunNotStartedError,\n} from \"./errors\";\n\n/**\n * Client for starting Major workflow runs, and reading back the runs it started, from a deployed app or sandbox preview.\n *\n * Prefer the `createWorkflowsClient()` factory \u2014 it reads platform-managed env\n * vars and (when imported from `@major-tech/workflows-client/next`) wires up\n * auto-forwarding of the inbound viewer JWT.\n */\nexport class WorkflowsClient {\n private readonly baseUrl: string;\n private readonly majorJwtToken: string | undefined;\n private readonly workflowId: string | undefined;\n private readonly getHeaders: () => Promise<Record<string, string>> | Record<string, string>;\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: WorkflowsClientConfig = {}) {\n const baseUrl = config.baseUrl ?? process.env.MAJOR_API_BASE_URL;\n if (!baseUrl) {\n throw new WorkflowsClientError(\n \"WorkflowsClient: baseUrl is required (set MAJOR_API_BASE_URL or pass baseUrl explicitly).\",\n );\n }\n\n // The JWT is read lazily so generated module-scope singletons can load during\n // `next build` page-data collection (MAJOR_JWT_TOKEN is injected at runtime).\n this.baseUrl = baseUrl.replace(/\\/$/, \"\");\n this.majorJwtToken = config.majorJwtToken;\n this.workflowId = config.workflowId;\n this.getHeaders = config.getHeaders ?? (() => ({}));\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n }\n\n /**\n * Start a run. Returns as soon as the run is accepted; the workflow runs\n * asynchronously. It runs the workflow's published version; from a sandbox\n * preview, the run's calls back to this app go to that preview.\n */\n async run(request: RunWorkflowRequest = {}): Promise<RunWorkflowResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.run: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<RunWorkflowResponse>(\"POST\", `/workflows/${encodeURIComponent(workflowId)}/runs`, {\n input: request.input,\n });\n }\n\n /**\n * Read back a run this app started: its status, and once finished its output\n * (`document.output`) or error (`run.error`). Any other run is not found.\n */\n async getRun(request: GetWorkflowRunRequest): Promise<GetWorkflowRunResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<GetWorkflowRunResponse>(\n \"GET\",\n `/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,\n undefined,\n );\n }\n\n private async request<T>(method: string, path: string, body: unknown): Promise<T> {\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;\n if (majorJwtToken) {\n headers[\"x-major-jwt\"] = majorJwtToken;\n }\n Object.assign(headers, await this.getHeaders());\n\n if (!headers[\"x-major-jwt\"] && !headers[\"x-major-user-jwt\"]) {\n throw new WorkflowsAuthError(\n \"WorkflowsClient: no credentials (set MAJOR_JWT_TOKEN, or call from a request that carries x-major-user-jwt).\",\n );\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new WorkflowRunNotStartedError(`Failed to reach Major API: ${message}`);\n }\n\n const requestId = response.headers.get(\"x-request-id\") ?? undefined;\n\n if (response.ok) {\n return (await response.json()) as T;\n }\n\n const errorMessage = await readErrorMessage(response);\n throw toWorkflowsError(response.status, errorMessage, requestId);\n }\n}\n\n/**\n * Factory equivalent to `new WorkflowsClient(config)`.\n *\n * In Next.js apps, prefer `createWorkflowsClient` from\n * `@major-tech/workflows-client/next` \u2014 it auto-forwards `x-major-user-jwt` from\n * the inbound request headers.\n */\nexport function createWorkflowsClient(config: WorkflowsClientConfig = {}): WorkflowsClient {\n return new WorkflowsClient(config);\n}\n\nfunction toWorkflowsError(status: number, message: string, requestId?: string): WorkflowsClientError {\n if (status === 400) {\n return new WorkflowsValidationError(message, requestId);\n }\n if (status === 401 || status === 403) {\n return new WorkflowsAuthError(message, status, requestId);\n }\n if (status === 404) {\n return new WorkflowNotFoundError(message, requestId);\n }\n return new WorkflowRunNotStartedError(message, status, requestId);\n}\n\nasync function readErrorMessage(response: Response): Promise<string> {\n try {\n const data = (await response.json()) as { error?: unknown; message?: unknown };\n if (typeof data.error === \"string\") {\n return data.error;\n }\n if (typeof data.message === \"string\") {\n return data.message;\n }\n } catch {\n // Non-JSON body: fall through to the status text.\n }\n return `HTTP ${response.status} ${response.statusText}`;\n}\n", "import { headers } from \"next/headers\";\n\n/**\n * Lifts `x-major-user-jwt` from the current Next.js request headers and returns\n * it as a header bag suitable for `WorkflowsClientConfig.getHeaders`.\n *\n * Returns `{}` when called outside a Next.js request scope (`headers()` throws\n * there) or when the inbound request carried no `x-major-user-jwt`.\n */\nexport async function defaultGetHeaders(): Promise<Record<string, string>> {\n let userJwt: string | null = null;\n\n try {\n userJwt = (await headers()).get(\"x-major-user-jwt\");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AAO,CAAC;AAAA,EACV;AAEA,SAAO,EAAE,oBAAoB,QAAQ;AACvC;;;AHdO,SAAS,sBAAsB,SAAgC,CAAC,GAAoB;AACzF,SAAO,IAAI,gBAAgB;AAAA,IACzB,GAAG;AAAA,IACH,YAAY,OAAO,cAAc;AAAA,EACnC,CAAC;AACH;",
|
|
6
6
|
"names": ["headers"]
|
|
7
7
|
}
|
package/dist/next/index.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ import type { WorkflowsClientConfig } from "../types";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function createWorkflowsClient(config?: WorkflowsClientConfig): WorkflowsClient;
|
|
9
9
|
export { WorkflowsClient } from "../client";
|
|
10
|
-
export type { WorkflowsClientConfig, RunWorkflowRequest, RunWorkflowResponse } from "../types";
|
|
10
|
+
export type { WorkflowsClientConfig, RunWorkflowRequest, RunWorkflowResponse, GetWorkflowRunRequest, GetWorkflowRunResponse, WorkflowRun, WorkflowRunDocument, } from "../types";
|
|
11
11
|
export { WorkflowsClientError, WorkflowsValidationError, WorkflowsAuthError, WorkflowNotFoundError, WorkflowRunNotStartedError, } from "../errors";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/next/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,qBAA0B,GAAG,eAAe,CAKzF;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,qBAA0B,GAAG,eAAe,CAKzF;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,WAAW,CAAC"}
|
package/dist/next/index.js
CHANGED
|
@@ -70,6 +70,23 @@ var WorkflowsClient = class {
|
|
|
70
70
|
input: request.input
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Read back a run this app started: its status, and once finished its output
|
|
75
|
+
* (`document.output`) or error (`run.error`). Any other run is not found.
|
|
76
|
+
*/
|
|
77
|
+
async getRun(request) {
|
|
78
|
+
const workflowId = request.workflowId ?? this.workflowId;
|
|
79
|
+
if (!workflowId) {
|
|
80
|
+
throw new WorkflowsValidationError(
|
|
81
|
+
"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client)."
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return this.request(
|
|
85
|
+
"GET",
|
|
86
|
+
`/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,
|
|
87
|
+
void 0
|
|
88
|
+
);
|
|
89
|
+
}
|
|
73
90
|
async request(method, path, body) {
|
|
74
91
|
const headers2 = { "Content-Type": "application/json" };
|
|
75
92
|
const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;
|
package/dist/next/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/errors.ts", "../../src/client.ts", "../../src/next/auth.ts", "../../src/next/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Error hierarchy for the Major workflows client. Every error extends\n * {@link WorkflowsClientError}, which carries the HTTP status (when the failure\n * came from a response) and the server's `x-request-id` for support/debugging.\n */\nexport class WorkflowsClientError extends Error {\n readonly httpStatus?: number;\n readonly requestId?: string;\n\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message);\n this.name = \"WorkflowsClientError\";\n this.httpStatus = httpStatus;\n this.requestId = requestId;\n }\n}\n\n/** The request was rejected as invalid, e.g. input failing the workflow's `input_schema` (HTTP 400). */\nexport class WorkflowsValidationError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 400, requestId);\n this.name = \"WorkflowsValidationError\";\n }\n}\n\n/**\n * Authentication or authorization failed (HTTP 401/403): no caller token, or\n * the app or its deployer may not use this workflow.\n */\nexport class WorkflowsAuthError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowsAuthError\";\n }\n}\n\n/** The workflow or version could not be found (HTTP 404). */\nexport class WorkflowNotFoundError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 404, requestId);\n this.name = \"WorkflowNotFoundError\";\n }\n}\n\n/**\n * The run could not be started: the workflow is not published (HTTP 409), or a\n * transport error prevented the request.\n */\nexport class WorkflowRunNotStartedError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowRunNotStartedError\";\n }\n}\n", "import type {
|
|
5
|
-
"mappings": ";AAKO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA,EACjE,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,qBAAN,cAAiC,qBAAqB;AAAA,EAC3D,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,wBAAN,cAAoC,qBAAqB;AAAA,EAC9D,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,6BAAN,cAAyC,qBAAqB;AAAA,EACnE,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;;;
|
|
4
|
+
"sourcesContent": ["/**\n * Error hierarchy for the Major workflows client. Every error extends\n * {@link WorkflowsClientError}, which carries the HTTP status (when the failure\n * came from a response) and the server's `x-request-id` for support/debugging.\n */\nexport class WorkflowsClientError extends Error {\n readonly httpStatus?: number;\n readonly requestId?: string;\n\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message);\n this.name = \"WorkflowsClientError\";\n this.httpStatus = httpStatus;\n this.requestId = requestId;\n }\n}\n\n/** The request was rejected as invalid, e.g. input failing the workflow's `input_schema` (HTTP 400). */\nexport class WorkflowsValidationError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 400, requestId);\n this.name = \"WorkflowsValidationError\";\n }\n}\n\n/**\n * Authentication or authorization failed (HTTP 401/403): no caller token, or\n * the app or its deployer may not use this workflow.\n */\nexport class WorkflowsAuthError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowsAuthError\";\n }\n}\n\n/** The workflow or version could not be found (HTTP 404). */\nexport class WorkflowNotFoundError extends WorkflowsClientError {\n constructor(message: string, requestId?: string) {\n super(message, 404, requestId);\n this.name = \"WorkflowNotFoundError\";\n }\n}\n\n/**\n * The run could not be started: the workflow is not published (HTTP 409), or a\n * transport error prevented the request.\n */\nexport class WorkflowRunNotStartedError extends WorkflowsClientError {\n constructor(message: string, httpStatus?: number, requestId?: string) {\n super(message, httpStatus, requestId);\n this.name = \"WorkflowRunNotStartedError\";\n }\n}\n", "import type {\n WorkflowsClientConfig,\n RunWorkflowRequest,\n RunWorkflowResponse,\n GetWorkflowRunRequest,\n GetWorkflowRunResponse,\n} from \"./types\";\nimport {\n WorkflowsClientError,\n WorkflowsValidationError,\n WorkflowsAuthError,\n WorkflowNotFoundError,\n WorkflowRunNotStartedError,\n} from \"./errors\";\n\n/**\n * Client for starting Major workflow runs, and reading back the runs it started, from a deployed app or sandbox preview.\n *\n * Prefer the `createWorkflowsClient()` factory \u2014 it reads platform-managed env\n * vars and (when imported from `@major-tech/workflows-client/next`) wires up\n * auto-forwarding of the inbound viewer JWT.\n */\nexport class WorkflowsClient {\n private readonly baseUrl: string;\n private readonly majorJwtToken: string | undefined;\n private readonly workflowId: string | undefined;\n private readonly getHeaders: () => Promise<Record<string, string>> | Record<string, string>;\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: WorkflowsClientConfig = {}) {\n const baseUrl = config.baseUrl ?? process.env.MAJOR_API_BASE_URL;\n if (!baseUrl) {\n throw new WorkflowsClientError(\n \"WorkflowsClient: baseUrl is required (set MAJOR_API_BASE_URL or pass baseUrl explicitly).\",\n );\n }\n\n // The JWT is read lazily so generated module-scope singletons can load during\n // `next build` page-data collection (MAJOR_JWT_TOKEN is injected at runtime).\n this.baseUrl = baseUrl.replace(/\\/$/, \"\");\n this.majorJwtToken = config.majorJwtToken;\n this.workflowId = config.workflowId;\n this.getHeaders = config.getHeaders ?? (() => ({}));\n this.fetchImpl = config.fetch ?? globalThis.fetch;\n }\n\n /**\n * Start a run. Returns as soon as the run is accepted; the workflow runs\n * asynchronously. It runs the workflow's published version; from a sandbox\n * preview, the run's calls back to this app go to that preview.\n */\n async run(request: RunWorkflowRequest = {}): Promise<RunWorkflowResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.run: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<RunWorkflowResponse>(\"POST\", `/workflows/${encodeURIComponent(workflowId)}/runs`, {\n input: request.input,\n });\n }\n\n /**\n * Read back a run this app started: its status, and once finished its output\n * (`document.output`) or error (`run.error`). Any other run is not found.\n */\n async getRun(request: GetWorkflowRunRequest): Promise<GetWorkflowRunResponse> {\n const workflowId = request.workflowId ?? this.workflowId;\n if (!workflowId) {\n throw new WorkflowsValidationError(\n \"WorkflowsClient.getRun: workflowId is required (pass it in the request or bind it on the client).\",\n );\n }\n\n return this.request<GetWorkflowRunResponse>(\n \"GET\",\n `/workflows/${encodeURIComponent(workflowId)}/runs/${encodeURIComponent(request.runId)}`,\n undefined,\n );\n }\n\n private async request<T>(method: string, path: string, body: unknown): Promise<T> {\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n const majorJwtToken = this.majorJwtToken ?? process.env.MAJOR_JWT_TOKEN;\n if (majorJwtToken) {\n headers[\"x-major-jwt\"] = majorJwtToken;\n }\n Object.assign(headers, await this.getHeaders());\n\n if (!headers[\"x-major-jwt\"] && !headers[\"x-major-user-jwt\"]) {\n throw new WorkflowsAuthError(\n \"WorkflowsClient: no credentials (set MAJOR_JWT_TOKEN, or call from a request that carries x-major-user-jwt).\",\n );\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new WorkflowRunNotStartedError(`Failed to reach Major API: ${message}`);\n }\n\n const requestId = response.headers.get(\"x-request-id\") ?? undefined;\n\n if (response.ok) {\n return (await response.json()) as T;\n }\n\n const errorMessage = await readErrorMessage(response);\n throw toWorkflowsError(response.status, errorMessage, requestId);\n }\n}\n\n/**\n * Factory equivalent to `new WorkflowsClient(config)`.\n *\n * In Next.js apps, prefer `createWorkflowsClient` from\n * `@major-tech/workflows-client/next` \u2014 it auto-forwards `x-major-user-jwt` from\n * the inbound request headers.\n */\nexport function createWorkflowsClient(config: WorkflowsClientConfig = {}): WorkflowsClient {\n return new WorkflowsClient(config);\n}\n\nfunction toWorkflowsError(status: number, message: string, requestId?: string): WorkflowsClientError {\n if (status === 400) {\n return new WorkflowsValidationError(message, requestId);\n }\n if (status === 401 || status === 403) {\n return new WorkflowsAuthError(message, status, requestId);\n }\n if (status === 404) {\n return new WorkflowNotFoundError(message, requestId);\n }\n return new WorkflowRunNotStartedError(message, status, requestId);\n}\n\nasync function readErrorMessage(response: Response): Promise<string> {\n try {\n const data = (await response.json()) as { error?: unknown; message?: unknown };\n if (typeof data.error === \"string\") {\n return data.error;\n }\n if (typeof data.message === \"string\") {\n return data.message;\n }\n } catch {\n // Non-JSON body: fall through to the status text.\n }\n return `HTTP ${response.status} ${response.statusText}`;\n}\n", "import { headers } from \"next/headers\";\n\n/**\n * Lifts `x-major-user-jwt` from the current Next.js request headers and returns\n * it as a header bag suitable for `WorkflowsClientConfig.getHeaders`.\n *\n * Returns `{}` when called outside a Next.js request scope (`headers()` throws\n * there) or when the inbound request carried no `x-major-user-jwt`.\n */\nexport async function defaultGetHeaders(): Promise<Record<string, string>> {\n let userJwt: string | null = null;\n\n try {\n userJwt = (await headers()).get(\"x-major-user-jwt\");\n } catch {\n return {};\n }\n\n if (!userJwt) {\n return {};\n }\n\n return { \"x-major-user-jwt\": userJwt };\n}\n", "import { WorkflowsClient } from \"../client\";\nimport type { WorkflowsClientConfig } from \"../types\";\nimport { defaultGetHeaders } from \"./auth\";\n\n/**\n * Next.js-aware factory: identical to the base `createWorkflowsClient`, but\n * defaults `getHeaders` to lift `x-major-user-jwt` from the inbound request.\n * Pass an explicit `getHeaders` to override.\n */\nexport function createWorkflowsClient(config: WorkflowsClientConfig = {}): WorkflowsClient {\n return new WorkflowsClient({\n ...config,\n getHeaders: config.getHeaders ?? defaultGetHeaders,\n });\n}\n\nexport { WorkflowsClient } from \"../client\";\nexport type {\n WorkflowsClientConfig,\n RunWorkflowRequest,\n RunWorkflowResponse,\n GetWorkflowRunRequest,\n GetWorkflowRunResponse,\n WorkflowRun,\n WorkflowRunDocument,\n} from \"../types\";\nexport {\n WorkflowsClientError,\n WorkflowsValidationError,\n WorkflowsAuthError,\n WorkflowNotFoundError,\n WorkflowRunNotStartedError,\n} from \"../errors\";\n"],
|
|
5
|
+
"mappings": ";AAKO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA,EACjE,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,qBAAN,cAAiC,qBAAqB;AAAA,EAC3D,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,wBAAN,cAAoC,qBAAqB;AAAA,EAC9D,YAAY,SAAiB,WAAoB;AAC/C,UAAM,SAAS,KAAK,SAAS;AAC7B,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,6BAAN,cAAyC,qBAAqB;AAAA,EACnE,YAAY,SAAiB,YAAqB,WAAoB;AACpE,UAAM,SAAS,YAAY,SAAS;AACpC,SAAK,OAAO;AAAA,EACd;AACF;;;AC/BO,IAAM,kBAAN,MAAsB;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,SAAg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;AACvD;;;AC7JA,SAAS,eAAe;AASxB,eAAsB,oBAAqD;AACzE,MAAI,UAAyB;AAE7B,MAAI;AACF,eAAW,MAAM,QAAQ,GAAG,IAAI,kBAAkB;AAAA,EACpD,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,CAAC,SAAS;AACZ,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,EAAE,oBAAoB,QAAQ;AACvC;;;ACdO,SAAS,sBAAsB,SAAgC,CAAC,GAAoB;AACzF,SAAO,IAAI,gBAAgB;AAAA,IACzB,GAAG;AAAA,IACH,YAAY,OAAO,cAAc;AAAA,EACnC,CAAC;AACH;",
|
|
6
6
|
"names": ["headers"]
|
|
7
7
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface WorkflowsClientConfig {
|
|
|
24
24
|
fetch?: typeof fetch;
|
|
25
25
|
/**
|
|
26
26
|
* Bound workflow id for a generated per-workflow singleton. Used as the
|
|
27
|
-
* default for `run` when the call omits `workflowId`.
|
|
27
|
+
* default for `run` and `getRun` when the call omits `workflowId`.
|
|
28
28
|
*/
|
|
29
29
|
workflowId?: string;
|
|
30
30
|
}
|
|
@@ -46,4 +46,59 @@ export interface RunWorkflowResponse {
|
|
|
46
46
|
/** Id of the started run. */
|
|
47
47
|
runId: string;
|
|
48
48
|
}
|
|
49
|
+
/** Request input for `WorkflowsClient.getRun`. */
|
|
50
|
+
export interface GetWorkflowRunRequest {
|
|
51
|
+
/** Id of the run, as returned by `run`. */
|
|
52
|
+
runId: string;
|
|
53
|
+
/** Id of the run's workflow. Optional when the client was constructed with a bound `workflowId`. */
|
|
54
|
+
workflowId?: string;
|
|
55
|
+
}
|
|
56
|
+
/** A workflow run row. Mirrors the Major API's `WorkflowRunSchema`. */
|
|
57
|
+
export interface WorkflowRun {
|
|
58
|
+
id: string;
|
|
59
|
+
workflowId: string;
|
|
60
|
+
status: "running" | "completed" | "failed" | "canceled";
|
|
61
|
+
triggerType: "cron" | "invocation" | "connector-event" | "webhook" | "app";
|
|
62
|
+
triggerId: string | null;
|
|
63
|
+
workflowVersionId: string;
|
|
64
|
+
version: number;
|
|
65
|
+
scheduledAt: string | null;
|
|
66
|
+
eventType: string | null;
|
|
67
|
+
startedAt: string;
|
|
68
|
+
completedAt: string | null;
|
|
69
|
+
/** Set when the run failed or was canceled. */
|
|
70
|
+
error: string | null;
|
|
71
|
+
singleNodeId: string | null;
|
|
72
|
+
name: string | null;
|
|
73
|
+
createdBy: string;
|
|
74
|
+
}
|
|
75
|
+
/** The run's trace document. Mirrors the Major API's `WorkflowRunDocumentSchema`. */
|
|
76
|
+
export interface WorkflowRunDocument {
|
|
77
|
+
run_id: string;
|
|
78
|
+
workflow_id: string;
|
|
79
|
+
workflow_version_id: string;
|
|
80
|
+
status: "running" | "completed" | "failed";
|
|
81
|
+
trigger: {
|
|
82
|
+
id: string;
|
|
83
|
+
type: WorkflowRun["triggerType"];
|
|
84
|
+
input?: Record<string, unknown>;
|
|
85
|
+
triggered_at: string;
|
|
86
|
+
};
|
|
87
|
+
/** Per-node execution records, keyed by execution id. */
|
|
88
|
+
executions: Record<string, unknown>;
|
|
89
|
+
/** The run's output, once it completed. */
|
|
90
|
+
output?: unknown;
|
|
91
|
+
error?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Successful response from `WorkflowsClient.getRun`. Mirrors the body the Major
|
|
95
|
+
* API returns at `GET /workflows/:workflowId/runs/:runId`.
|
|
96
|
+
*/
|
|
97
|
+
export interface GetWorkflowRunResponse {
|
|
98
|
+
run: WorkflowRun;
|
|
99
|
+
/** Null until the run has written its trace. */
|
|
100
|
+
document: WorkflowRunDocument | null;
|
|
101
|
+
/** The definition text of the version the run executes. */
|
|
102
|
+
definitionText: string;
|
|
103
|
+
}
|
|
49
104
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mGAAmG;IACnG,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;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