@mantajs/sdk 0.2.0-beta.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/dist/client.d.ts +103 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +204 -0
- package/dist/client.js.map +1 -0
- package/dist/hooks.d.ts +121 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +314 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +24 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +38 -0
- package/dist/provider.js.map +1 -0
- package/dist/query-helpers.d.ts +44 -0
- package/dist/query-helpers.d.ts.map +1 -0
- package/dist/query-helpers.js +54 -0
- package/dist/query-helpers.js.map +1 -0
- package/dist/workflow-types.d.ts +105 -0
- package/dist/workflow-types.d.ts.map +1 -0
- package/dist/workflow-types.js +12 -0
- package/dist/workflow-types.js.map +1 -0
- package/package.json +26 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { RunResult, WorkflowRunSnapshot } from './workflow-types';
|
|
2
|
+
export interface MantaClientOptions {
|
|
3
|
+
/** Context name (e.g. 'admin', 'store'). Determines the API base path. */
|
|
4
|
+
context: string;
|
|
5
|
+
/** Base URL of the Manta backend. Default: '' (same origin). */
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
/** Custom function to get the auth token. Default: reads from localStorage. */
|
|
8
|
+
getToken?: () => string | null;
|
|
9
|
+
/** Called on 401 — should refresh the token and return true if successful. */
|
|
10
|
+
onUnauthorized?: () => Promise<boolean>;
|
|
11
|
+
}
|
|
12
|
+
export declare class MantaClient {
|
|
13
|
+
private _context;
|
|
14
|
+
private _baseUrl;
|
|
15
|
+
private _getToken;
|
|
16
|
+
private _onUnauthorized;
|
|
17
|
+
constructor(options: MantaClientOptions);
|
|
18
|
+
get basePath(): string;
|
|
19
|
+
private _headers;
|
|
20
|
+
/** Fetch with automatic 401 retry after token refresh. */
|
|
21
|
+
private _fetch;
|
|
22
|
+
/**
|
|
23
|
+
* Execute a command (POST /api/{ctx}/command/{name}).
|
|
24
|
+
*
|
|
25
|
+
* Returns the bare result for inline success.
|
|
26
|
+
* For async responses (HTTP 202), returns `undefined` — callers that care
|
|
27
|
+
* about the runId should use {@link runCommand} which returns a
|
|
28
|
+
* discriminated {@link RunResult} instead.
|
|
29
|
+
*
|
|
30
|
+
* Throws {@link MantaSDKError} on HTTP failure.
|
|
31
|
+
*/
|
|
32
|
+
command<TInput = unknown, TOutput = unknown>(name: string, input: TInput): Promise<TOutput | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Execute a command and return the full {@link RunResult} envelope.
|
|
35
|
+
*
|
|
36
|
+
* See WORKFLOW_PROGRESS.md §6.1:
|
|
37
|
+
* - `{ status: 'succeeded', result, runId? }` — workflow finished within the
|
|
38
|
+
* 300ms inline window (HTTP 200).
|
|
39
|
+
* - `{ status: 'failed', error }` — workflow failed inline.
|
|
40
|
+
* - `{ status: 'running', runId }` — workflow still running; poll
|
|
41
|
+
* `GET /api/admin/_workflow/:runId` (HTTP 202).
|
|
42
|
+
*
|
|
43
|
+
* This method does NOT throw on inline failure — the error is returned as
|
|
44
|
+
* part of the discriminated union. Transport-level failures (network errors,
|
|
45
|
+
* non-JSON bodies) still throw.
|
|
46
|
+
*/
|
|
47
|
+
runCommand<TInput = unknown, TOutput = unknown>(name: string, input: TInput): Promise<RunResult<TOutput>>;
|
|
48
|
+
/**
|
|
49
|
+
* Fetch the merged snapshot for a workflow run.
|
|
50
|
+
* GET /api/admin/_workflow/:runId — see WORKFLOW_PROGRESS.md §6.5.
|
|
51
|
+
*/
|
|
52
|
+
getWorkflowRun(runId: string): Promise<WorkflowRunSnapshot>;
|
|
53
|
+
/**
|
|
54
|
+
* Request cancellation of a running workflow.
|
|
55
|
+
* DELETE /api/admin/_workflow/:runId — idempotent (server-side no-op on
|
|
56
|
+
* terminal runs). See WORKFLOW_PROGRESS.md §6.5.
|
|
57
|
+
*/
|
|
58
|
+
cancelWorkflowRun(runId: string): Promise<void>;
|
|
59
|
+
/** Execute a named query (GET /api/{ctx}/{queryName}?params). */
|
|
60
|
+
query<TOutput = unknown>(name: string, params?: Record<string, unknown>): Promise<TOutput>;
|
|
61
|
+
/** Execute a graph query (POST /api/{ctx}/graph). */
|
|
62
|
+
graphQuery<TOutput = unknown>(config: GraphQueryInput): Promise<TOutput>;
|
|
63
|
+
/** Login and store token. */
|
|
64
|
+
login(email: string, password: string): Promise<{
|
|
65
|
+
token: string;
|
|
66
|
+
refreshToken: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Logout and clear token. */
|
|
69
|
+
logout(): Promise<void>;
|
|
70
|
+
/** Get current user. */
|
|
71
|
+
me<T = unknown>(): Promise<T>;
|
|
72
|
+
}
|
|
73
|
+
/** Entity name — autocompletes from codegen when @mantajs/core types are loaded. */
|
|
74
|
+
declare global {
|
|
75
|
+
interface MantaGeneratedEntities {
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
type EntityNameArg = keyof MantaGeneratedEntities extends never ? string : keyof MantaGeneratedEntities | (string & {});
|
|
79
|
+
/** Graph query input shape. */
|
|
80
|
+
export interface GraphQueryInput {
|
|
81
|
+
entity: EntityNameArg;
|
|
82
|
+
filters?: Record<string, unknown>;
|
|
83
|
+
pagination?: {
|
|
84
|
+
limit?: number;
|
|
85
|
+
offset?: number;
|
|
86
|
+
};
|
|
87
|
+
sort?: {
|
|
88
|
+
field?: string;
|
|
89
|
+
order?: 'asc' | 'desc';
|
|
90
|
+
};
|
|
91
|
+
relations?: string[];
|
|
92
|
+
fields?: string[];
|
|
93
|
+
/** Full-text search query — searches across all searchable fields of the entity. */
|
|
94
|
+
q?: string;
|
|
95
|
+
}
|
|
96
|
+
/** SDK error with type and status. */
|
|
97
|
+
export declare class MantaSDKError extends Error {
|
|
98
|
+
type: string;
|
|
99
|
+
status: number;
|
|
100
|
+
constructor(type: string, message: string, status: number);
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEtE,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAA;IACf,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;IAC9B,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CACxC;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,eAAe,CAAiC;gBAE5C,OAAO,EAAE,kBAAkB;IAcvC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,OAAO,CAAC,QAAQ;IAOhB,0DAA0D;YAC5C,MAAM;IAWpB;;;;;;;;;OASG;IACG,OAAO,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAQ7G;;;;;;;;;;;;;OAaG;IACG,UAAU,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IA+B/G;;;OAGG;IACG,cA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CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;KAAE,CAAA;IACjD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,oFAAoF;IACpF,CAAC,CAAC,EAAE,MAAM,CAAA;CACX;AAED,sCAAsC;AACtC,qBAAa,aAAc,SAAQ,KAAK;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;gBACF,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM1D"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Manta SDK — HTTP client for CQRS endpoints
|
|
2
|
+
// Handles context resolution, JWT injection, and response parsing.
|
|
3
|
+
export class MantaClient {
|
|
4
|
+
_context;
|
|
5
|
+
_baseUrl;
|
|
6
|
+
_getToken;
|
|
7
|
+
_onUnauthorized;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this._context = options.context;
|
|
10
|
+
this._baseUrl = options.baseUrl ?? '';
|
|
11
|
+
this._onUnauthorized = options.onUnauthorized ?? null;
|
|
12
|
+
this._getToken =
|
|
13
|
+
options.getToken ??
|
|
14
|
+
(() => {
|
|
15
|
+
if (typeof localStorage !== 'undefined') {
|
|
16
|
+
return localStorage.getItem(`manta:token:${this._context}`);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
get basePath() {
|
|
22
|
+
return `${this._baseUrl}/api/${this._context}`;
|
|
23
|
+
}
|
|
24
|
+
_headers() {
|
|
25
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
26
|
+
const token = this._getToken();
|
|
27
|
+
if (token)
|
|
28
|
+
headers.Authorization = `Bearer ${token}`;
|
|
29
|
+
return headers;
|
|
30
|
+
}
|
|
31
|
+
/** Fetch with automatic 401 retry after token refresh. */
|
|
32
|
+
async _fetch(url, init) {
|
|
33
|
+
let res = await fetch(url, { ...init, headers: this._headers() });
|
|
34
|
+
if (res.status === 401 && this._onUnauthorized) {
|
|
35
|
+
const refreshed = await this._onUnauthorized();
|
|
36
|
+
if (refreshed) {
|
|
37
|
+
res = await fetch(url, { ...init, headers: this._headers() });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return res;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Execute a command (POST /api/{ctx}/command/{name}).
|
|
44
|
+
*
|
|
45
|
+
* Returns the bare result for inline success.
|
|
46
|
+
* For async responses (HTTP 202), returns `undefined` — callers that care
|
|
47
|
+
* about the runId should use {@link runCommand} which returns a
|
|
48
|
+
* discriminated {@link RunResult} instead.
|
|
49
|
+
*
|
|
50
|
+
* Throws {@link MantaSDKError} on HTTP failure.
|
|
51
|
+
*/
|
|
52
|
+
async command(name, input) {
|
|
53
|
+
const run = await this.runCommand(name, input);
|
|
54
|
+
if (run.status === 'succeeded')
|
|
55
|
+
return run.result;
|
|
56
|
+
if (run.status === 'failed')
|
|
57
|
+
throw run.error;
|
|
58
|
+
// 'running' — inline-only callers can't wait; see runCommand for runId-aware usage.
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Execute a command and return the full {@link RunResult} envelope.
|
|
63
|
+
*
|
|
64
|
+
* See WORKFLOW_PROGRESS.md §6.1:
|
|
65
|
+
* - `{ status: 'succeeded', result, runId? }` — workflow finished within the
|
|
66
|
+
* 300ms inline window (HTTP 200).
|
|
67
|
+
* - `{ status: 'failed', error }` — workflow failed inline.
|
|
68
|
+
* - `{ status: 'running', runId }` — workflow still running; poll
|
|
69
|
+
* `GET /api/admin/_workflow/:runId` (HTTP 202).
|
|
70
|
+
*
|
|
71
|
+
* This method does NOT throw on inline failure — the error is returned as
|
|
72
|
+
* part of the discriminated union. Transport-level failures (network errors,
|
|
73
|
+
* non-JSON bodies) still throw.
|
|
74
|
+
*/
|
|
75
|
+
async runCommand(name, input) {
|
|
76
|
+
const res = await this._fetch(`${this.basePath}/command/${name}`, {
|
|
77
|
+
method: 'POST',
|
|
78
|
+
body: JSON.stringify(input),
|
|
79
|
+
});
|
|
80
|
+
const body = await res.json();
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
return {
|
|
83
|
+
status: 'failed',
|
|
84
|
+
error: new MantaSDKError(body?.type ?? 'ERROR', body?.message ?? res.statusText, res.status),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Envelope shapes (set by packages/cli/.../cqrs-routes.ts):
|
|
88
|
+
// inline success: { data: { status: 'succeeded', result, runId } }
|
|
89
|
+
// OR legacy: { data: <bareResult> } for sync commands that
|
|
90
|
+
// didn't go through the workflow manager.
|
|
91
|
+
// async: { data: { runId, status: 'running', href } }
|
|
92
|
+
const envelope = body?.data;
|
|
93
|
+
if (envelope && typeof envelope === 'object') {
|
|
94
|
+
const { status, result, runId } = envelope;
|
|
95
|
+
if (status === 'succeeded') {
|
|
96
|
+
return { status: 'succeeded', result: result, runId };
|
|
97
|
+
}
|
|
98
|
+
if (status === 'running' && typeof runId === 'string') {
|
|
99
|
+
return { status: 'running', runId };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Legacy or unwrapped shape — treat `body.data` as the bare result.
|
|
103
|
+
return { status: 'succeeded', result: envelope };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Fetch the merged snapshot for a workflow run.
|
|
107
|
+
* GET /api/admin/_workflow/:runId — see WORKFLOW_PROGRESS.md §6.5.
|
|
108
|
+
*/
|
|
109
|
+
async getWorkflowRun(runId) {
|
|
110
|
+
const res = await this._fetch(`${this._baseUrl}/api/admin/_workflow/${runId}`, { method: 'GET' });
|
|
111
|
+
const body = await res.json();
|
|
112
|
+
if (!res.ok)
|
|
113
|
+
throw new MantaSDKError(body?.type ?? 'ERROR', body?.message ?? res.statusText, res.status);
|
|
114
|
+
return body?.data;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Request cancellation of a running workflow.
|
|
118
|
+
* DELETE /api/admin/_workflow/:runId — idempotent (server-side no-op on
|
|
119
|
+
* terminal runs). See WORKFLOW_PROGRESS.md §6.5.
|
|
120
|
+
*/
|
|
121
|
+
async cancelWorkflowRun(runId) {
|
|
122
|
+
const res = await this._fetch(`${this._baseUrl}/api/admin/_workflow/${runId}`, { method: 'DELETE' });
|
|
123
|
+
if (!res.ok) {
|
|
124
|
+
const body = await res.json().catch(() => ({}));
|
|
125
|
+
throw new MantaSDKError(body?.type ?? 'ERROR', body?.message ?? res.statusText, res.status);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Execute a named query (GET /api/{ctx}/{queryName}?params). */
|
|
129
|
+
async query(name, params) {
|
|
130
|
+
const url = new URL(`${this.basePath}/${name}`, window.location.origin);
|
|
131
|
+
if (params) {
|
|
132
|
+
for (const [key, value] of Object.entries(params)) {
|
|
133
|
+
if (value !== undefined && value !== null) {
|
|
134
|
+
url.searchParams.set(key, String(value));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const res = await this._fetch(url.toString(), {});
|
|
139
|
+
const data = await res.json();
|
|
140
|
+
if (!res.ok)
|
|
141
|
+
throw new MantaSDKError(data.type ?? 'ERROR', data.message ?? res.statusText, res.status);
|
|
142
|
+
return data.data ?? data;
|
|
143
|
+
}
|
|
144
|
+
/** Execute a graph query (POST /api/{ctx}/graph). */
|
|
145
|
+
async graphQuery(config) {
|
|
146
|
+
const res = await this._fetch(`${this.basePath}/graph`, {
|
|
147
|
+
method: 'POST',
|
|
148
|
+
body: JSON.stringify(config),
|
|
149
|
+
});
|
|
150
|
+
const data = await res.json();
|
|
151
|
+
if (!res.ok)
|
|
152
|
+
throw new MantaSDKError(data.type ?? 'ERROR', data.message ?? res.statusText, res.status);
|
|
153
|
+
// Preserve count for pagination: return { items: [...], count: N } if count is present
|
|
154
|
+
if (Array.isArray(data.data) && data.count != null) {
|
|
155
|
+
return { items: data.data, count: data.count };
|
|
156
|
+
}
|
|
157
|
+
return data.data ?? data;
|
|
158
|
+
}
|
|
159
|
+
/** Login and store token. */
|
|
160
|
+
async login(email, password) {
|
|
161
|
+
const res = await fetch(`${this.basePath}/login`, {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers: { 'Content-Type': 'application/json' },
|
|
164
|
+
body: JSON.stringify({ email, password }),
|
|
165
|
+
});
|
|
166
|
+
const data = await res.json();
|
|
167
|
+
if (!res.ok)
|
|
168
|
+
throw new MantaSDKError(data.type ?? 'ERROR', data.message ?? res.statusText, res.status);
|
|
169
|
+
if (typeof localStorage !== 'undefined') {
|
|
170
|
+
localStorage.setItem(`manta:token:${this._context}`, data.token);
|
|
171
|
+
if (data.refreshToken)
|
|
172
|
+
localStorage.setItem(`manta:refresh:${this._context}`, data.refreshToken);
|
|
173
|
+
}
|
|
174
|
+
return data;
|
|
175
|
+
}
|
|
176
|
+
/** Logout and clear token. */
|
|
177
|
+
async logout() {
|
|
178
|
+
try {
|
|
179
|
+
await fetch(`${this.basePath}/logout`, { method: 'DELETE', headers: this._headers() });
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
if (typeof localStorage !== 'undefined') {
|
|
183
|
+
localStorage.removeItem(`manta:token:${this._context}`);
|
|
184
|
+
localStorage.removeItem(`manta:refresh:${this._context}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** Get current user. */
|
|
189
|
+
async me() {
|
|
190
|
+
return this.query('me');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** SDK error with type and status. */
|
|
194
|
+
export class MantaSDKError extends Error {
|
|
195
|
+
type;
|
|
196
|
+
status;
|
|
197
|
+
constructor(type, message, status) {
|
|
198
|
+
super(message);
|
|
199
|
+
this.name = 'MantaSDKError';
|
|
200
|
+
this.type = type;
|
|
201
|
+
this.status = status;
|
|
202
|
+
}
|
|
203
|
+
}
|
|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C,KAAK,CAAI,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF;AAoBD,sCAAsC;AACtC,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,IAAI,CAAQ;IACZ,MAAM,CAAQ;IACd,YAAY,IAAY,EAAE,OAAe,EAAE,MAAc;QACvD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CACF"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { type UseMutationResult, type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { GraphQueryInput, MantaSDKError } from './client';
|
|
3
|
+
import { type ProgressSnapshot, type RunResult, type StepState, type UseCommandResult, type UseCommandStatus, type WorkflowError, type WorkflowRunSnapshot } from './workflow-types';
|
|
4
|
+
declare global {
|
|
5
|
+
interface MantaGeneratedCommands {
|
|
6
|
+
}
|
|
7
|
+
interface MantaGeneratedQueries {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
type CommandName = keyof MantaGeneratedCommands extends never ? string : keyof MantaGeneratedCommands | (string & {});
|
|
11
|
+
type QueryName = keyof MantaGeneratedQueries extends never ? string : keyof MantaGeneratedQueries | (string & {});
|
|
12
|
+
export declare const WORKFLOW_POLL_INTERVAL_MS = 1000;
|
|
13
|
+
/** Internal hook state — exported for unit testing of the pure reducers below. */
|
|
14
|
+
export interface CommandState<TOutput> {
|
|
15
|
+
status: UseCommandStatus;
|
|
16
|
+
runId: string | undefined;
|
|
17
|
+
steps: StepState[] | undefined;
|
|
18
|
+
progress: ProgressSnapshot | undefined;
|
|
19
|
+
result: TOutput | undefined;
|
|
20
|
+
error: MantaSDKError | WorkflowError | undefined;
|
|
21
|
+
}
|
|
22
|
+
export declare function idleState<TOutput>(): CommandState<TOutput>;
|
|
23
|
+
export declare function readOnlyInitialState<TOutput>(runId: string): CommandState<TOutput>;
|
|
24
|
+
/**
|
|
25
|
+
* Reducer: merge a polled WorkflowRunSnapshot into the previous hook state.
|
|
26
|
+
* Pure — safe to call from tests or the React useEffect.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mergePollSnapshot<TOutput>(prev: CommandState<TOutput>, snap: WorkflowRunSnapshot): CommandState<TOutput>;
|
|
29
|
+
/**
|
|
30
|
+
* Reducer: derive the post-run() state from the HTTP envelope returned by
|
|
31
|
+
* `MantaClient.runCommand()`. Pure — safe to call from tests.
|
|
32
|
+
*/
|
|
33
|
+
export declare function stateFromRunResult<TOutput>(envelope: RunResult<TOutput>): CommandState<TOutput>;
|
|
34
|
+
/**
|
|
35
|
+
* Execute a command and observe its execution.
|
|
36
|
+
*
|
|
37
|
+
* See WORKFLOW_PROGRESS.md §7 for the full contract.
|
|
38
|
+
*
|
|
39
|
+
* Primary API:
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const { run, runId, status, steps, progress, result, error, cancel } = useCommand('import-products')
|
|
42
|
+
*
|
|
43
|
+
* async function onClick() {
|
|
44
|
+
* const r = await run({ file })
|
|
45
|
+
* if (r.status === 'running') navigate(`/_runs/${r.runId}`)
|
|
46
|
+
* else if (r.status === 'succeeded') toast.success('Imported')
|
|
47
|
+
* else toast.error(r.error.message)
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* Read-only (observe an existing run):
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const { status, steps, progress } = useCommand('import-products', { runId: 'abc-123' })
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Back-compat aliases (`mutateAsync`, `mutate`, `isPending`, `isSuccess`, `isError`,
|
|
57
|
+
* `reset`, `data`) preserve the old React-Query shape for existing call sites.
|
|
58
|
+
*/
|
|
59
|
+
export declare function useCommand<TInput = unknown, TOutput = unknown>(name: CommandName, options?: {
|
|
60
|
+
runId?: string;
|
|
61
|
+
}): UseCommandResult<TInput, TOutput>;
|
|
62
|
+
/**
|
|
63
|
+
* Execute a named query (read-only).
|
|
64
|
+
* Queries are defined with defineQuery() on the backend.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* const { data, isLoading } = useQuery('list-products', { status: 'active', limit: 10 })
|
|
69
|
+
*
|
|
70
|
+
* if (isLoading) return <div>Loading...</div>
|
|
71
|
+
* return <ul>{data?.map(p => <li key={p.id}>{p.title}</li>)}</ul>
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function useQuery<TOutput = unknown>(name: QueryName, params?: Record<string, unknown>, options?: {
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
staleTime?: number;
|
|
77
|
+
refetchInterval?: number;
|
|
78
|
+
}): UseQueryResult<TOutput, Error>;
|
|
79
|
+
/**
|
|
80
|
+
* Execute a graph query (flexible entity + relations + filters).
|
|
81
|
+
* Only works if defineQueryGraph() is declared for the current context.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* const { data } = useGraphQuery({
|
|
86
|
+
* entity: 'product',
|
|
87
|
+
* filters: { status: 'active' },
|
|
88
|
+
* relations: ['inventory_item'],
|
|
89
|
+
* pagination: { limit: 20 },
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function useGraphQuery<TOutput = unknown>(config: GraphQueryInput, options?: {
|
|
94
|
+
enabled?: boolean;
|
|
95
|
+
staleTime?: number;
|
|
96
|
+
refetchInterval?: number;
|
|
97
|
+
}): UseQueryResult<TOutput, Error>;
|
|
98
|
+
/**
|
|
99
|
+
* Auth helpers for the current context.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* const { login, logout, me } = useAuth()
|
|
104
|
+
*
|
|
105
|
+
* await login('admin@example.com', 'password')
|
|
106
|
+
* const user = await me()
|
|
107
|
+
* await logout()
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function useAuth(): {
|
|
111
|
+
login: (email: string, password: string) => Promise<{
|
|
112
|
+
token: string;
|
|
113
|
+
refreshToken: string;
|
|
114
|
+
}>;
|
|
115
|
+
logout: () => Promise<void>;
|
|
116
|
+
me: UseQueryResult<unknown, Error>;
|
|
117
|
+
isAuthenticated: boolean;
|
|
118
|
+
isLoading: boolean;
|
|
119
|
+
};
|
|
120
|
+
export type { UseMutationResult };
|
|
121
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE9D,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAA;AAOzB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,sBAAsB;KAAG;IACnC,UAAU,qBAAqB;KAAG;CACnC;AAED,KAAK,WAAW,GAAG,MAAM,sBAAsB,SAAS,KAAK,GAAG,MAAM,GAAG,MAAM,sBAAsB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AACrH,KAAK,SAAS,GAAG,MAAM,qBAAqB,SAAS,KAAK,GAAG,MAAM,GAAG,MAAM,qBAAqB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAIjH,eAAO,MAAM,yBAAyB,OAAO,CAAA;AAE7C,kFAAkF;AAClF,MAAM,WAAW,YAAY,CAAC,OAAO;IACnC,MAAM,EAAE,gB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CAAE,GAC5E,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAqBhC;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAG,OAAO,EAC7C,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5E,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAgBhC;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO;mBAoBJ,MAAM,YAAY,MAAM;;;;;;;;EAM1C;AAKD,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// Manta SDK — React hooks for CQRS endpoints
|
|
2
|
+
// useCommand, useQuery, useGraphQuery
|
|
3
|
+
import { useMutation, useQuery as useReactQuery, } from '@tanstack/react-query';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useMantaClient } from './provider';
|
|
6
|
+
import { isTerminalStatus, } from './workflow-types';
|
|
7
|
+
// ── useCommand ─────────────────────────────────────────
|
|
8
|
+
export const WORKFLOW_POLL_INTERVAL_MS = 1000;
|
|
9
|
+
export function idleState() {
|
|
10
|
+
return {
|
|
11
|
+
status: 'idle',
|
|
12
|
+
runId: undefined,
|
|
13
|
+
steps: undefined,
|
|
14
|
+
progress: undefined,
|
|
15
|
+
result: undefined,
|
|
16
|
+
error: undefined,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function readOnlyInitialState(runId) {
|
|
20
|
+
return {
|
|
21
|
+
status: 'running',
|
|
22
|
+
runId,
|
|
23
|
+
steps: undefined,
|
|
24
|
+
progress: undefined,
|
|
25
|
+
result: undefined,
|
|
26
|
+
error: undefined,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reducer: merge a polled WorkflowRunSnapshot into the previous hook state.
|
|
31
|
+
* Pure — safe to call from tests or the React useEffect.
|
|
32
|
+
*/
|
|
33
|
+
export function mergePollSnapshot(prev, snap) {
|
|
34
|
+
if (!prev.runId || prev.runId !== snap.id)
|
|
35
|
+
return prev;
|
|
36
|
+
// Map WorkflowStatus → UseCommandStatus. `pending` (pre-run) is surfaced as
|
|
37
|
+
// `running` since the hook is already past idle once we have a runId.
|
|
38
|
+
const nextStatus = snap.status === 'pending' ? 'running' : snap.status;
|
|
39
|
+
return {
|
|
40
|
+
...prev,
|
|
41
|
+
status: nextStatus,
|
|
42
|
+
steps: snap.steps,
|
|
43
|
+
progress: snap.inFlightProgress ?? prev.progress,
|
|
44
|
+
result: nextStatus === 'succeeded' ? snap.output : prev.result,
|
|
45
|
+
error: nextStatus === 'failed' ? snap.error : prev.error,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reducer: derive the post-run() state from the HTTP envelope returned by
|
|
50
|
+
* `MantaClient.runCommand()`. Pure — safe to call from tests.
|
|
51
|
+
*/
|
|
52
|
+
export function stateFromRunResult(envelope) {
|
|
53
|
+
if (envelope.status === 'succeeded') {
|
|
54
|
+
return {
|
|
55
|
+
status: 'succeeded',
|
|
56
|
+
runId: envelope.runId,
|
|
57
|
+
steps: undefined,
|
|
58
|
+
progress: undefined,
|
|
59
|
+
result: envelope.result,
|
|
60
|
+
error: undefined,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (envelope.status === 'failed') {
|
|
64
|
+
return {
|
|
65
|
+
status: 'failed',
|
|
66
|
+
runId: undefined,
|
|
67
|
+
steps: undefined,
|
|
68
|
+
progress: undefined,
|
|
69
|
+
result: undefined,
|
|
70
|
+
error: envelope.error,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
status: 'running',
|
|
75
|
+
runId: envelope.runId,
|
|
76
|
+
steps: undefined,
|
|
77
|
+
progress: undefined,
|
|
78
|
+
result: undefined,
|
|
79
|
+
error: undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Execute a command and observe its execution.
|
|
84
|
+
*
|
|
85
|
+
* See WORKFLOW_PROGRESS.md §7 for the full contract.
|
|
86
|
+
*
|
|
87
|
+
* Primary API:
|
|
88
|
+
* ```tsx
|
|
89
|
+
* const { run, runId, status, steps, progress, result, error, cancel } = useCommand('import-products')
|
|
90
|
+
*
|
|
91
|
+
* async function onClick() {
|
|
92
|
+
* const r = await run({ file })
|
|
93
|
+
* if (r.status === 'running') navigate(`/_runs/${r.runId}`)
|
|
94
|
+
* else if (r.status === 'succeeded') toast.success('Imported')
|
|
95
|
+
* else toast.error(r.error.message)
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* Read-only (observe an existing run):
|
|
100
|
+
* ```tsx
|
|
101
|
+
* const { status, steps, progress } = useCommand('import-products', { runId: 'abc-123' })
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* Back-compat aliases (`mutateAsync`, `mutate`, `isPending`, `isSuccess`, `isError`,
|
|
105
|
+
* `reset`, `data`) preserve the old React-Query shape for existing call sites.
|
|
106
|
+
*/
|
|
107
|
+
export function useCommand(name, options) {
|
|
108
|
+
const client = useMantaClient();
|
|
109
|
+
const initialRunId = options?.runId;
|
|
110
|
+
const [state, setState] = useState(() => initialRunId ? readOnlyInitialState(initialRunId) : idleState());
|
|
111
|
+
// Keep the latest state in a ref so mutateAsync's effect can read it without
|
|
112
|
+
// re-subscribing to every render.
|
|
113
|
+
const stateRef = useRef(state);
|
|
114
|
+
stateRef.current = state;
|
|
115
|
+
// Pending promise plumbing for mutateAsync's "await terminal" semantics is NOT
|
|
116
|
+
// implemented here — per the PR-5 plan we take the simpler path: mutateAsync
|
|
117
|
+
// awaits only the initial HTTP. For 'running' responses, it resolves with
|
|
118
|
+
// `undefined` + a dev warning. See the JSDoc on UseCommandResult.mutateAsync.
|
|
119
|
+
// ── Polling ─────────────────────────────────────────
|
|
120
|
+
const shouldPoll = !!state.runId && !isTerminalStatus(state.status);
|
|
121
|
+
const pollQuery = useReactQuery({
|
|
122
|
+
queryKey: ['manta', 'workflow-run', state.runId],
|
|
123
|
+
queryFn: () => client.getWorkflowRun(state.runId),
|
|
124
|
+
enabled: shouldPoll,
|
|
125
|
+
refetchInterval: (query) => {
|
|
126
|
+
const data = query.state.data;
|
|
127
|
+
if (!data)
|
|
128
|
+
return WORKFLOW_POLL_INTERVAL_MS;
|
|
129
|
+
return isTerminalStatus(data.status) ? false : WORKFLOW_POLL_INTERVAL_MS;
|
|
130
|
+
},
|
|
131
|
+
refetchIntervalInBackground: false,
|
|
132
|
+
retry: false,
|
|
133
|
+
});
|
|
134
|
+
// Merge polled snapshots into local state.
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
const snap = pollQuery.data;
|
|
137
|
+
if (!snap)
|
|
138
|
+
return;
|
|
139
|
+
setState((prev) => mergePollSnapshot(prev, snap));
|
|
140
|
+
}, [pollQuery.data]);
|
|
141
|
+
// ── run ────────────────────────────────────────────
|
|
142
|
+
const run = useCallback(async (input) => {
|
|
143
|
+
// Optimistic: flip to running with no runId so UI can show a spinner.
|
|
144
|
+
setState({
|
|
145
|
+
status: 'running',
|
|
146
|
+
runId: undefined,
|
|
147
|
+
steps: undefined,
|
|
148
|
+
progress: undefined,
|
|
149
|
+
result: undefined,
|
|
150
|
+
error: undefined,
|
|
151
|
+
});
|
|
152
|
+
const envelope = await client.runCommand(name, input);
|
|
153
|
+
setState(stateFromRunResult(envelope));
|
|
154
|
+
return envelope;
|
|
155
|
+
}, [client, name]);
|
|
156
|
+
// ── cancel ─────────────────────────────────────────
|
|
157
|
+
const cancel = useCallback(async () => {
|
|
158
|
+
const current = stateRef.current;
|
|
159
|
+
if (!current.runId || isTerminalStatus(current.status))
|
|
160
|
+
return;
|
|
161
|
+
await client.cancelWorkflowRun(current.runId);
|
|
162
|
+
// Polling continues — the server will report status: 'cancelled' and the
|
|
163
|
+
// polling effect above will merge it into state.
|
|
164
|
+
}, [client]);
|
|
165
|
+
// ── reset ──────────────────────────────────────────
|
|
166
|
+
const reset = useCallback(() => {
|
|
167
|
+
setState(idleState());
|
|
168
|
+
}, []);
|
|
169
|
+
// ── Back-compat aliases ────────────────────────────
|
|
170
|
+
const mutateAsync = useCallback(async (input) => {
|
|
171
|
+
const r = await run(input);
|
|
172
|
+
if (r.status === 'succeeded')
|
|
173
|
+
return r.result;
|
|
174
|
+
if (r.status === 'failed')
|
|
175
|
+
throw r.error;
|
|
176
|
+
// 'running' — mutateAsync historically returned the bare result. For
|
|
177
|
+
// async workflows we can't deliver that without blocking on polling;
|
|
178
|
+
// return undefined and warn so callers migrate to run() + runId.
|
|
179
|
+
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
|
|
180
|
+
console.warn(`[useCommand] '${name}' returned async (runId=${r.runId}). mutateAsync resolved with undefined. ` +
|
|
181
|
+
'Migrate to run() + runId to observe the workflow — see WORKFLOW_PROGRESS.md §7.');
|
|
182
|
+
}
|
|
183
|
+
return undefined;
|
|
184
|
+
}, [run, name]);
|
|
185
|
+
const mutate = useCallback((input) => {
|
|
186
|
+
void run(input).catch(() => {
|
|
187
|
+
/* fire-and-forget: error is stored in state.error */
|
|
188
|
+
});
|
|
189
|
+
}, [run]);
|
|
190
|
+
return {
|
|
191
|
+
// Primary API
|
|
192
|
+
run,
|
|
193
|
+
runId: state.runId,
|
|
194
|
+
status: state.status,
|
|
195
|
+
steps: state.steps,
|
|
196
|
+
progress: state.progress,
|
|
197
|
+
result: state.result,
|
|
198
|
+
error: state.error,
|
|
199
|
+
cancel,
|
|
200
|
+
// Back-compat aliases
|
|
201
|
+
mutateAsync,
|
|
202
|
+
mutate,
|
|
203
|
+
isPending: state.status === 'running',
|
|
204
|
+
isSuccess: state.status === 'succeeded',
|
|
205
|
+
isError: state.status === 'failed',
|
|
206
|
+
reset,
|
|
207
|
+
data: state.result,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
// ── useQuery ───────────────────────────────────────────
|
|
211
|
+
/**
|
|
212
|
+
* Execute a named query (read-only).
|
|
213
|
+
* Queries are defined with defineQuery() on the backend.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```tsx
|
|
217
|
+
* const { data, isLoading } = useQuery('list-products', { status: 'active', limit: 10 })
|
|
218
|
+
*
|
|
219
|
+
* if (isLoading) return <div>Loading...</div>
|
|
220
|
+
* return <ul>{data?.map(p => <li key={p.id}>{p.title}</li>)}</ul>
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export function useQuery(name, params, options) {
|
|
224
|
+
const client = useMantaClient();
|
|
225
|
+
// Block queries with unresolved :param placeholders (e.g., id=":id" before useParams resolves)
|
|
226
|
+
const hasUnresolved = params && Object.values(params).some((v) => typeof v === 'string' && v.startsWith(':'));
|
|
227
|
+
const enabled = (options?.enabled ?? true) && !hasUnresolved;
|
|
228
|
+
return useReactQuery({
|
|
229
|
+
queryKey: ['manta', 'query', name, params],
|
|
230
|
+
queryFn: () => client.query(name, params),
|
|
231
|
+
enabled,
|
|
232
|
+
staleTime: options?.staleTime,
|
|
233
|
+
refetchInterval: options?.refetchInterval,
|
|
234
|
+
// Keep previous data on pagination/filter changes within the SAME named
|
|
235
|
+
// query — but NOT when navigating to a different query (we'd display the
|
|
236
|
+
// old query's rows under the new query's columns until the fetch lands).
|
|
237
|
+
placeholderData: ((prev, prevQuery) => {
|
|
238
|
+
if (!prev)
|
|
239
|
+
return undefined;
|
|
240
|
+
const prevName = prevQuery?.queryKey?.[2];
|
|
241
|
+
return prevName === name ? prev : undefined;
|
|
242
|
+
}),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// ── useGraphQuery ──────────────────────────────────────
|
|
246
|
+
/**
|
|
247
|
+
* Execute a graph query (flexible entity + relations + filters).
|
|
248
|
+
* Only works if defineQueryGraph() is declared for the current context.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```tsx
|
|
252
|
+
* const { data } = useGraphQuery({
|
|
253
|
+
* entity: 'product',
|
|
254
|
+
* filters: { status: 'active' },
|
|
255
|
+
* relations: ['inventory_item'],
|
|
256
|
+
* pagination: { limit: 20 },
|
|
257
|
+
* })
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
export function useGraphQuery(config, options) {
|
|
261
|
+
const client = useMantaClient();
|
|
262
|
+
return useReactQuery({
|
|
263
|
+
queryKey: ['manta', 'graph', config.entity, config],
|
|
264
|
+
queryFn: () => client.graphQuery(config),
|
|
265
|
+
enabled: options?.enabled,
|
|
266
|
+
staleTime: options?.staleTime,
|
|
267
|
+
refetchInterval: options?.refetchInterval,
|
|
268
|
+
// Same scoping as useQuery: only keep previous when staying on the same
|
|
269
|
+
// entity (pagination, filters), not when navigating to a different one.
|
|
270
|
+
placeholderData: ((prev, prevQuery) => {
|
|
271
|
+
if (!prev)
|
|
272
|
+
return undefined;
|
|
273
|
+
const prevEntity = prevQuery?.queryKey?.[2];
|
|
274
|
+
return prevEntity === config.entity ? prev : undefined;
|
|
275
|
+
}),
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
// ── useAuth ────────────────────────────────────────────
|
|
279
|
+
/**
|
|
280
|
+
* Auth helpers for the current context.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```tsx
|
|
284
|
+
* const { login, logout, me } = useAuth()
|
|
285
|
+
*
|
|
286
|
+
* await login('admin@example.com', 'password')
|
|
287
|
+
* const user = await me()
|
|
288
|
+
* await logout()
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
export function useAuth() {
|
|
292
|
+
const client = useMantaClient();
|
|
293
|
+
const loginMutation = useMutation({
|
|
294
|
+
mutationKey: ['manta', 'auth', 'login'],
|
|
295
|
+
mutationFn: ({ email, password }) => client.login(email, password),
|
|
296
|
+
});
|
|
297
|
+
const logoutMutation = useMutation({
|
|
298
|
+
mutationKey: ['manta', 'auth', 'logout'],
|
|
299
|
+
mutationFn: () => client.logout(),
|
|
300
|
+
});
|
|
301
|
+
const meQuery = useReactQuery({
|
|
302
|
+
queryKey: ['manta', 'auth', 'me'],
|
|
303
|
+
queryFn: () => client.me(),
|
|
304
|
+
retry: false,
|
|
305
|
+
});
|
|
306
|
+
return {
|
|
307
|
+
login: (email, password) => loginMutation.mutateAsync({ email, password }),
|
|
308
|
+
logout: () => logoutMutation.mutateAsync(),
|
|
309
|
+
me: meQuery,
|
|
310
|
+
isAuthenticated: !!meQuery.data && !meQuery.isError,
|
|
311
|
+
isLoading: meQuery.isLoading,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,sCAAsC;AAEtC,OAAO,EAGL,WAAW,EACX,QAAQ,IAAI,aAAa,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EACL,gBAAgB,GAQjB,MAAM,kBAAkB,CAAA;AAezB,0DAA0D;AAE1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAA;AAY7C,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,SAAS;QACjB,KAAK,EAAE,SAAS;KACjB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAU,KAAa;IACzD,OAAO;QACL,MAAM,EAAE,SA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AED,0DAA0D;AAE1D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAE/B,MAAM,aAAa,GAAG,WAAW,CAAC;QAChC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;QACvC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAuC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC;KACxG,CAAC,CAAA;IAEF,MAAM,cAAc,GAAG,WAAW,CAAC;QACjC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;QACxC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;KAClC,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,aAAa,CAAC;QAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC;QACjC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE;QAC1B,KAAK,EAAE,KAAK;KACb,CAAC,CAAA;IAEF,OAAO;QACL,KAAK,EAAE,CAAC,KAAa,EAAE,QAAgB,EAAE,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAC1F,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,EAAE;QAC1C,EAAE,EAAE,OAAO;QACX,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO;QACnD,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { GraphQueryInput, MantaClientOptions } from './client';
|
|
2
|
+
export { MantaClient, MantaSDKError } from './client';
|
|
3
|
+
export { useAuth, useCommand, useGraphQuery, useQuery } from './hooks';
|
|
4
|
+
export type { MantaProviderProps } from './provider';
|
|
5
|
+
export { MantaProvider, useMantaClient } from './provider';
|
|
6
|
+
export { listParams, retrieveParams } from './query-helpers';
|
|
7
|
+
export type { ProgressSnapshot, RunResult, StepState, StepStatus, UseCommandResult, UseCommandStatus, WorkflowError, WorkflowRunSnapshot, WorkflowStatus, } from './workflow-types';
|
|
8
|
+
export { isTerminalStatus } from './workflow-types';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEnE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAErD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG1D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5D,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,cAAc,GACf,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @mantajs/sdk — Frontend SDK for Manta applications
|
|
2
|
+
//
|
|
3
|
+
// Hooks:
|
|
4
|
+
// useCommand('create-product') — execute a command (mutation)
|
|
5
|
+
// useQuery('list-products', {...}) — execute a named query (read)
|
|
6
|
+
// useGraphQuery({entity, ...}) — execute a graph query (flexible)
|
|
7
|
+
// useAuth() — login, logout, me
|
|
8
|
+
//
|
|
9
|
+
// Provider:
|
|
10
|
+
// <MantaProvider context="admin"> — wraps app with SDK context
|
|
11
|
+
//
|
|
12
|
+
// Client (headless):
|
|
13
|
+
// new MantaClient({ context: 'admin' }) — for non-React usage
|
|
14
|
+
// Client (headless — usable without React)
|
|
15
|
+
export { MantaClient, MantaSDKError } from './client';
|
|
16
|
+
// React hooks
|
|
17
|
+
export { useAuth, useCommand, useGraphQuery, useQuery } from './hooks';
|
|
18
|
+
// Provider
|
|
19
|
+
export { MantaProvider, useMantaClient } from './provider';
|
|
20
|
+
// Query helpers (for defineQuery input composition)
|
|
21
|
+
export { listParams, retrieveParams } from './query-helpers';
|
|
22
|
+
// Workflow types — shared with the backend via HTTP (shapes match @mantajs/core)
|
|
23
|
+
export { isTerminalStatus } from './workflow-types';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,SAAS;AACT,oEAAoE;AACpE,oEAAoE;AACpE,wEAAwE;AACxE,yDAAyD;AACzD,EAAE;AACF,YAAY;AACZ,iEAAiE;AACjE,EAAE;AACF,qBAAqB;AACrB,gEAAgE;AAGhE,2CAA2C;AAC3C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACrD,cAAc;AACd,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEtE,WAAW;AACX,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE1D,oDAAoD;AACpD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAY5D,iFAAiF;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
import { MantaClient, type MantaClientOptions } from './client';
|
|
4
|
+
export interface MantaProviderProps extends MantaClientOptions {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Custom React Query client. Default: built-in with 30s stale time. */
|
|
7
|
+
queryClient?: QueryClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* MantaProvider — wraps your app with Manta SDK context.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <MantaProvider context="admin">
|
|
15
|
+
* <App />
|
|
16
|
+
* </MantaProvider>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function MantaProvider({ children, queryClient, ...clientOptions }: MantaProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* Get the MantaClient from context. Throws if not inside MantaProvider.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useMantaClient(): MantaClient;
|
|
24
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAuB,MAAM,uBAAuB,CAAA;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAU/D,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,wEAAwE;IACxE,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,aAAa,EAAE,EAAE,kBAAkB,2CAS5F;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAM5C"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// MantaProvider — React context provider for the SDK
|
|
3
|
+
// Provides the MantaClient to all hooks (useCommand, useQuery, useGraphQuery)
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
5
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
6
|
+
import { MantaClient } from './client';
|
|
7
|
+
const MantaContext = createContext(null);
|
|
8
|
+
const defaultQueryClient = new QueryClient({
|
|
9
|
+
defaultOptions: {
|
|
10
|
+
queries: { staleTime: 30_000, retry: 1 },
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* MantaProvider — wraps your app with Manta SDK context.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <MantaProvider context="admin">
|
|
19
|
+
* <App />
|
|
20
|
+
* </MantaProvider>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function MantaProvider({ children, queryClient, ...clientOptions }) {
|
|
24
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: only recreate on context/baseUrl change
|
|
25
|
+
const client = useMemo(() => new MantaClient(clientOptions), [clientOptions.context, clientOptions.baseUrl]);
|
|
26
|
+
return (_jsx(MantaContext.Provider, { value: client, children: _jsx(QueryClientProvider, { client: queryClient ?? defaultQueryClient, children: children }) }));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the MantaClient from context. Throws if not inside MantaProvider.
|
|
30
|
+
*/
|
|
31
|
+
export function useMantaClient() {
|
|
32
|
+
const client = useContext(MantaContext);
|
|
33
|
+
if (!client) {
|
|
34
|
+
throw new Error('useMantaClient must be used inside <MantaProvider>');
|
|
35
|
+
}
|
|
36
|
+
return client;
|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AA;AACf,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Standard list params: limit, offset, sort, search.
|
|
4
|
+
* Spread into your defineQuery input schema.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* export default defineQuery({
|
|
9
|
+
* name: 'list-products',
|
|
10
|
+
* input: z.object({
|
|
11
|
+
* status: z.string().optional(),
|
|
12
|
+
* ...listParams(),
|
|
13
|
+
* }),
|
|
14
|
+
* handler: async (input, { query }) => { ... },
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function listParams(defaults?: {
|
|
19
|
+
limit?: number;
|
|
20
|
+
maxLimit?: number;
|
|
21
|
+
}): {
|
|
22
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
25
|
+
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
26
|
+
search: z.ZodOptional<z.ZodString>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Standard retrieve params: id + optional fields.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* export default defineQuery({
|
|
34
|
+
* name: 'get-product',
|
|
35
|
+
* input: z.object({ ...retrieveParams() }),
|
|
36
|
+
* handler: async (input, { query }) => { ... },
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function retrieveParams(): {
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=query-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-helpers.d.ts","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,QAAQ,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;EAc1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc;;;EAK7B"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Query input helpers — reusable Zod fragments for common query patterns
|
|
2
|
+
// Not part of the React hooks — used in defineQuery() backend code.
|
|
3
|
+
// Re-exported from @mantajs/sdk for convenience.
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/**
|
|
6
|
+
* Standard list params: limit, offset, sort, search.
|
|
7
|
+
* Spread into your defineQuery input schema.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* export default defineQuery({
|
|
12
|
+
* name: 'list-products',
|
|
13
|
+
* input: z.object({
|
|
14
|
+
* status: z.string().optional(),
|
|
15
|
+
* ...listParams(),
|
|
16
|
+
* }),
|
|
17
|
+
* handler: async (input, { query }) => { ... },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function listParams(defaults) {
|
|
22
|
+
const maxLimit = defaults?.maxLimit ?? 100;
|
|
23
|
+
return {
|
|
24
|
+
limit: z
|
|
25
|
+
.number()
|
|
26
|
+
.int()
|
|
27
|
+
.min(1)
|
|
28
|
+
.max(maxLimit)
|
|
29
|
+
.default(defaults?.limit ?? 20),
|
|
30
|
+
offset: z.number().int().min(0).default(0),
|
|
31
|
+
sort: z.string().optional(),
|
|
32
|
+
order: z.enum(['asc', 'desc']).default('desc'),
|
|
33
|
+
search: z.string().optional(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Standard retrieve params: id + optional fields.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* export default defineQuery({
|
|
42
|
+
* name: 'get-product',
|
|
43
|
+
* input: z.object({ ...retrieveParams() }),
|
|
44
|
+
* handler: async (input, { query }) => { ... },
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function retrieveParams() {
|
|
49
|
+
return {
|
|
50
|
+
id: z.string(),
|
|
51
|
+
fields: z.array(z.string()).optional(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=query-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-helpers.js","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,oEAAoE;AACpE,iDAAiD;AAEjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgD;IACzE,MAAM,QAAQ,GAAG,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAA;IAC1C,OAAO;QACL,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,QAAQ,CAAC;aACb,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;QACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC9B,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;QACd,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KACvC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { MantaSDKError } from './client';
|
|
2
|
+
/** Overall workflow run status — matches core `WorkflowStatus`. */
|
|
3
|
+
export type WorkflowStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
4
|
+
/** Per-step status — matches core `StepStatus`. */
|
|
5
|
+
export type StepStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'compensated';
|
|
6
|
+
/** Step state as returned by `GET /_workflow/:id` — matches core `StepState`. */
|
|
7
|
+
export interface StepState {
|
|
8
|
+
name: string;
|
|
9
|
+
status: StepStatus;
|
|
10
|
+
started_at?: string;
|
|
11
|
+
completed_at?: string;
|
|
12
|
+
error?: {
|
|
13
|
+
message: string;
|
|
14
|
+
code?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** In-flight progress snapshot from the Redis liveness channel. */
|
|
18
|
+
export interface ProgressSnapshot {
|
|
19
|
+
stepName: string;
|
|
20
|
+
current: number;
|
|
21
|
+
total: number | null;
|
|
22
|
+
message?: string;
|
|
23
|
+
at: number;
|
|
24
|
+
}
|
|
25
|
+
/** Workflow error payload (JSON-serialised — not a MantaError instance). */
|
|
26
|
+
export interface WorkflowError {
|
|
27
|
+
message: string;
|
|
28
|
+
code?: string;
|
|
29
|
+
stack?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Full snapshot returned by `GET /api/admin/_workflow/:id`.
|
|
33
|
+
* See packages/cli/src/bootstrap/phases/wire/wire-workflow-routes.ts for the
|
|
34
|
+
* authoritative server shape.
|
|
35
|
+
*/
|
|
36
|
+
export interface WorkflowRunSnapshot {
|
|
37
|
+
id: string;
|
|
38
|
+
command_name: string;
|
|
39
|
+
status: WorkflowStatus;
|
|
40
|
+
steps: StepState[];
|
|
41
|
+
inFlightProgress?: ProgressSnapshot;
|
|
42
|
+
output?: unknown;
|
|
43
|
+
error?: WorkflowError;
|
|
44
|
+
started_at?: string;
|
|
45
|
+
completed_at?: string;
|
|
46
|
+
cancel_requested_at?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result returned by `useCommand().run(input)`.
|
|
50
|
+
* Three cases, matching WORKFLOW_PROGRESS.md §6.1:
|
|
51
|
+
* - `succeeded` — workflow finished within the 300ms inline window.
|
|
52
|
+
* - `failed` — workflow failed within the 300ms inline window.
|
|
53
|
+
* - `running` — workflow is still running; use `runId` to poll.
|
|
54
|
+
*/
|
|
55
|
+
export type RunResult<T> = {
|
|
56
|
+
status: 'succeeded';
|
|
57
|
+
result: T;
|
|
58
|
+
runId?: string;
|
|
59
|
+
} | {
|
|
60
|
+
status: 'failed';
|
|
61
|
+
error: MantaSDKError;
|
|
62
|
+
} | {
|
|
63
|
+
status: 'running';
|
|
64
|
+
runId: string;
|
|
65
|
+
};
|
|
66
|
+
/** Hook-local status — superset of `WorkflowStatus` plus `idle`. */
|
|
67
|
+
export type UseCommandStatus = 'idle' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
68
|
+
/**
|
|
69
|
+
* Return shape of `useCommand` — see WORKFLOW_PROGRESS.md §7.
|
|
70
|
+
*
|
|
71
|
+
* The primary API is `{ run, runId, status, steps, progress, result, error, cancel }`.
|
|
72
|
+
*
|
|
73
|
+
* Back-compat aliases (`mutateAsync`, `mutate`, `isPending`, `isSuccess`, `isError`,
|
|
74
|
+
* `reset`, `data`) preserve the shape of the pre-PR-4 React-Query mutation so
|
|
75
|
+
* existing call sites continue to work. New code should use the primary API.
|
|
76
|
+
*/
|
|
77
|
+
export interface UseCommandResult<TInput, TOutput> {
|
|
78
|
+
run: (input: TInput) => Promise<RunResult<TOutput>>;
|
|
79
|
+
runId: string | undefined;
|
|
80
|
+
status: UseCommandStatus;
|
|
81
|
+
steps: StepState[] | undefined;
|
|
82
|
+
progress: ProgressSnapshot | undefined;
|
|
83
|
+
result: TOutput | undefined;
|
|
84
|
+
error: MantaSDKError | WorkflowError | undefined;
|
|
85
|
+
cancel: () => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Awaits the initial HTTP response only. On inline success, resolves with
|
|
88
|
+
* `result`. On inline failure, throws the `MantaSDKError`. On async response
|
|
89
|
+
* (`status: 'running'`), resolves with `undefined` and emits a dev-warning —
|
|
90
|
+
* migrate such call sites to the new `run()` + `runId` API.
|
|
91
|
+
*/
|
|
92
|
+
mutateAsync: (input: TInput) => Promise<TOutput | undefined>;
|
|
93
|
+
/** Fire-and-forget variant of `run()`. Ignores errors. */
|
|
94
|
+
mutate: (input: TInput) => void;
|
|
95
|
+
isPending: boolean;
|
|
96
|
+
isSuccess: boolean;
|
|
97
|
+
isError: boolean;
|
|
98
|
+
/** Resets the hook to its idle state. */
|
|
99
|
+
reset: () => void;
|
|
100
|
+
/** Alias for `result`. */
|
|
101
|
+
data: TOutput | undefined;
|
|
102
|
+
}
|
|
103
|
+
/** Terminal states — polling stops once any of these is reached. */
|
|
104
|
+
export declare function isTerminalStatus(status: UseCommandStatus | WorkflowStatus | undefined): boolean;
|
|
105
|
+
//# sourceMappingURL=workflow-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-types.d.ts","sourceRoot":"","sources":["../src/workflow-types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,mEAAmE;AACnE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEzF,mDAAmD;AACnD,MAAM,MAA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,MAAM,EAAE,gBAAgB,GAAG,cAAc,GAAG,SAAS,GAAG,OAAO,CAE/F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Workflow-related types for the SDK.
|
|
2
|
+
// See WORKFLOW_PROGRESS.md §5 (data model), §6.1 (RunResult), §7 (useCommand shape).
|
|
3
|
+
//
|
|
4
|
+
// These are deliberately duplicated from @mantajs/core rather than imported, so the
|
|
5
|
+
// SDK bundle stays free of server-only dependencies (drizzle-orm, zod, etc.). The
|
|
6
|
+
// shapes MUST stay in sync with packages/core/src/ports/workflow-store.ts and
|
|
7
|
+
// packages/core/src/ports/progress-channel.ts.
|
|
8
|
+
/** Terminal states — polling stops once any of these is reached. */
|
|
9
|
+
export function isTerminalStatus(status) {
|
|
10
|
+
return status === 'succeeded' || status === 'failed' || status === 'cancelled';
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=workflow-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-types.js","sourceRoot":"","sources":["../src/workflow-types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,qFAAqF;AACrF,EAAE;AACF,oFAAoF;AACpF,kFAAkF;AAClF,8EAA8E;AAC9E,+CAA+C;AA2G/C,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAAC,MAAqD;IACpF,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,WAAW,CAAA;AAChF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mantajs/sdk",
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@tanstack/query-core": "^5.90.20",
|
|
9
|
+
"@tanstack/react-query": "^5.0.0",
|
|
10
|
+
"react": "^19.0.0",
|
|
11
|
+
"zod": "^3.23.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/react": "^19.0.0"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
]
|
|
26
|
+
}
|