@soulcraft/sdk 1.6.2 → 1.7.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/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/app-context/index.d.ts +214 -0
- package/dist/modules/app-context/index.d.ts.map +1 -0
- package/dist/modules/app-context/index.js +569 -0
- package/dist/modules/app-context/index.js.map +1 -0
- package/dist/modules/auth/products.d.ts +208 -0
- package/dist/modules/auth/products.d.ts.map +1 -0
- package/dist/modules/auth/products.js +165 -0
- package/dist/modules/auth/products.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/dist/transports/workshop.d.ts +173 -0
- package/dist/transports/workshop.d.ts.map +1 -0
- package/dist/transports/workshop.js +307 -0
- package/dist/transports/workshop.js.map +1 -0
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/docs/ADR-004-product-registry.md +108 -0
- package/package.json +1 -1
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module modules/app-context
|
|
3
|
+
* @description Factory for building a full {@link AppRuntimeContext} from minimal options.
|
|
4
|
+
*
|
|
5
|
+
* `createAppContext()` is the single entry point kit apps use to get a fully-wired
|
|
6
|
+
* runtime context. Both Workshop (dev, WebContainer iframe) and Venue (production,
|
|
7
|
+
* same-origin HTTP) call the same factory — the only difference is which transport
|
|
8
|
+
* the host provides.
|
|
9
|
+
*
|
|
10
|
+
* **Workshop** passes a {@link WorkshopTransport} → all non-brainy API calls go
|
|
11
|
+
* through PostMessage to the parent frame's relay in PreviewFrame.svelte.
|
|
12
|
+
*
|
|
13
|
+
* **Venue** omits `workshopTransport` → all API calls use HTTP fetch to `baseUrl`.
|
|
14
|
+
*
|
|
15
|
+
* Each context property (ai, hall, pulse, files, notify, services, auth) is built
|
|
16
|
+
* by a dedicated proxy builder that accepts either transport mode. The brain property
|
|
17
|
+
* is built from the provided Brainy transport (PostMessage or HTTP) via the existing
|
|
18
|
+
* `createBrainyProxy()`.
|
|
19
|
+
*
|
|
20
|
+
* @example Workshop kit app (WebContainer iframe)
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { createAppContext, PostMessageTransport, WorkshopTransport } from '@soulcraft/sdk/client'
|
|
23
|
+
*
|
|
24
|
+
* const origin = document.referrer ? new URL(document.referrer).origin : '*'
|
|
25
|
+
* const context = createAppContext({
|
|
26
|
+
* transport: new PostMessageTransport(origin),
|
|
27
|
+
* workshopTransport: new WorkshopTransport(origin),
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // Full API surface:
|
|
31
|
+
* const items = await context.brain.find({ query: 'test' })
|
|
32
|
+
* for await (const token of context.ai.chat([{ role: 'user', content: 'hello' }])) { ... }
|
|
33
|
+
* context.pulse.track('page_view', { page: '/home' })
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Venue production app (same-origin HTTP)
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { createAppContext } from '@soulcraft/sdk/client'
|
|
39
|
+
*
|
|
40
|
+
* const context = createAppContext({
|
|
41
|
+
* brain: existingBrainyProxy,
|
|
42
|
+
* auth: { user, role, can, signOut, getToken },
|
|
43
|
+
* kit: kitManifest,
|
|
44
|
+
* slot: '/app',
|
|
45
|
+
* credentials: true,
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
import { WorkshopTransport } from '../../transports/workshop.js';
|
|
50
|
+
import { createBrainyProxy } from '../brainy/proxy.js';
|
|
51
|
+
/**
|
|
52
|
+
* Helper: perform an HTTP fetch with standard JSON conventions.
|
|
53
|
+
*
|
|
54
|
+
* @param config - HTTP proxy config with baseUrl and credentials flag.
|
|
55
|
+
* @param path - API endpoint path.
|
|
56
|
+
* @param method - HTTP method.
|
|
57
|
+
* @param body - Request body (string or FormData).
|
|
58
|
+
* @param extraHeaders - Additional headers.
|
|
59
|
+
* @returns Parsed JSON response.
|
|
60
|
+
*/
|
|
61
|
+
async function httpCall(config, path, method, body, extraHeaders) {
|
|
62
|
+
const headers = { ...extraHeaders };
|
|
63
|
+
if (typeof body === 'string' && !headers['Content-Type']) {
|
|
64
|
+
headers['Content-Type'] = 'application/json';
|
|
65
|
+
}
|
|
66
|
+
const res = await fetch(`${config.baseUrl}${path}`, {
|
|
67
|
+
method,
|
|
68
|
+
headers,
|
|
69
|
+
credentials: config.credentials ? 'include' : 'same-origin',
|
|
70
|
+
...(body != null ? { body } : {}),
|
|
71
|
+
});
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
const text = await res.text();
|
|
74
|
+
throw new Error(`${path} failed (${res.status}): ${text}`);
|
|
75
|
+
}
|
|
76
|
+
const contentType = res.headers.get('content-type') ?? '';
|
|
77
|
+
if (contentType.includes('application/json')) {
|
|
78
|
+
return res.json();
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Helper: perform an HTTP SSE streaming fetch.
|
|
84
|
+
*
|
|
85
|
+
* @param config - HTTP proxy config.
|
|
86
|
+
* @param path - API endpoint path.
|
|
87
|
+
* @param method - HTTP method.
|
|
88
|
+
* @param body - JSON request body.
|
|
89
|
+
* @returns Async iterable of parsed SSE data payloads.
|
|
90
|
+
*/
|
|
91
|
+
async function* httpStream(config, path, method, body) {
|
|
92
|
+
const res = await fetch(`${config.baseUrl}${path}`, {
|
|
93
|
+
method,
|
|
94
|
+
headers: { 'Content-Type': 'application/json' },
|
|
95
|
+
credentials: config.credentials ? 'include' : 'same-origin',
|
|
96
|
+
...(body != null ? { body } : {}),
|
|
97
|
+
});
|
|
98
|
+
if (!res.ok) {
|
|
99
|
+
const text = await res.text();
|
|
100
|
+
throw new Error(`${path} failed (${res.status}): ${text}`);
|
|
101
|
+
}
|
|
102
|
+
const reader = res.body?.getReader();
|
|
103
|
+
if (!reader)
|
|
104
|
+
throw new Error(`No response body from ${path}`);
|
|
105
|
+
const decoder = new TextDecoder();
|
|
106
|
+
let buffer = '';
|
|
107
|
+
while (true) {
|
|
108
|
+
const { done, value } = await reader.read();
|
|
109
|
+
if (done)
|
|
110
|
+
break;
|
|
111
|
+
buffer += decoder.decode(value, { stream: true });
|
|
112
|
+
const lines = buffer.split('\n');
|
|
113
|
+
buffer = lines.pop() ?? '';
|
|
114
|
+
for (const line of lines) {
|
|
115
|
+
if (!line.startsWith('data: '))
|
|
116
|
+
continue;
|
|
117
|
+
const payload = line.slice(6).trim();
|
|
118
|
+
if (payload === '[DONE]')
|
|
119
|
+
return;
|
|
120
|
+
yield payload;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// ── AI proxy ────────────────────────────────────────────────────────────────
|
|
125
|
+
/**
|
|
126
|
+
* Build the AI context proxy.
|
|
127
|
+
*
|
|
128
|
+
* - Workshop (PostMessage): streams via `workshop:stream` chunks
|
|
129
|
+
* - Venue (HTTP): streams via SSE fetch to `/api/ai/chat`
|
|
130
|
+
*
|
|
131
|
+
* @param t - Transport (WorkshopTransport or HTTP config).
|
|
132
|
+
* @returns AI context with `chat()` (async iterable) and `embed()`.
|
|
133
|
+
*/
|
|
134
|
+
function createAIProxy(t) {
|
|
135
|
+
if (t instanceof WorkshopTransport) {
|
|
136
|
+
return {
|
|
137
|
+
async *chat(messages, opts) {
|
|
138
|
+
const body = JSON.stringify({ messages, ...opts });
|
|
139
|
+
for await (const chunk of t.stream('/api/ai/chat', 'POST', body)) {
|
|
140
|
+
// Each chunk is the raw SSE data payload (JSON string).
|
|
141
|
+
// Parse to extract the token, matching Venue's wire format.
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(chunk);
|
|
144
|
+
if (parsed.error)
|
|
145
|
+
throw new Error(parsed.error);
|
|
146
|
+
if (parsed.token)
|
|
147
|
+
yield parsed.token;
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
if (e instanceof SyntaxError)
|
|
151
|
+
continue;
|
|
152
|
+
throw e;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
async embed(text) {
|
|
157
|
+
return t.call('/api/ai/embed', 'POST', JSON.stringify({ text }));
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// HTTP mode (Venue)
|
|
162
|
+
return {
|
|
163
|
+
async *chat(messages, opts) {
|
|
164
|
+
const body = JSON.stringify({ messages, ...opts });
|
|
165
|
+
for await (const payload of httpStream(t, '/api/ai/chat', 'POST', body)) {
|
|
166
|
+
try {
|
|
167
|
+
const parsed = JSON.parse(payload);
|
|
168
|
+
if (parsed.error)
|
|
169
|
+
throw new Error(parsed.error);
|
|
170
|
+
if (parsed.token)
|
|
171
|
+
yield parsed.token;
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
if (e instanceof SyntaxError)
|
|
175
|
+
continue;
|
|
176
|
+
throw e;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
async embed(text) {
|
|
181
|
+
return httpCall(t, '/api/ai/embed', 'POST', JSON.stringify({ text }));
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
// ── Hall proxy ──────────────────────────────────────────────────────────────
|
|
186
|
+
/**
|
|
187
|
+
* Build the Hall context proxy.
|
|
188
|
+
*
|
|
189
|
+
* Manages single-room-at-a-time state. `joinRoom()` calls the backend to get a
|
|
190
|
+
* session token; the actual WebRTC connection is left to the kit app (it can use
|
|
191
|
+
* `joinHallRoom()` from `@soulcraft/sdk/client` with the returned token).
|
|
192
|
+
*
|
|
193
|
+
* @param t - Transport (WorkshopTransport or HTTP config).
|
|
194
|
+
* @returns Hall context with join/leave/on methods.
|
|
195
|
+
*/
|
|
196
|
+
function createHallProxy(t) {
|
|
197
|
+
let hallConnected = false;
|
|
198
|
+
let hallRoomId = null;
|
|
199
|
+
const listeners = new Map();
|
|
200
|
+
async function callJoin(roomId, options) {
|
|
201
|
+
const body = JSON.stringify({ roomId, ...options });
|
|
202
|
+
if (t instanceof WorkshopTransport) {
|
|
203
|
+
return t.call(`/api/hall/rooms/${encodeURIComponent(roomId)}/join`, 'POST', body);
|
|
204
|
+
}
|
|
205
|
+
return httpCall(t, `/api/hall/rooms/${encodeURIComponent(roomId)}/join`, 'POST', body);
|
|
206
|
+
}
|
|
207
|
+
const proxy = {
|
|
208
|
+
async joinRoom(roomId, options) {
|
|
209
|
+
if (hallConnected)
|
|
210
|
+
proxy.leaveRoom();
|
|
211
|
+
await callJoin(roomId, options);
|
|
212
|
+
hallConnected = true;
|
|
213
|
+
hallRoomId = roomId;
|
|
214
|
+
},
|
|
215
|
+
leaveRoom() {
|
|
216
|
+
hallConnected = false;
|
|
217
|
+
hallRoomId = null;
|
|
218
|
+
},
|
|
219
|
+
get connected() {
|
|
220
|
+
return hallConnected;
|
|
221
|
+
},
|
|
222
|
+
get roomId() {
|
|
223
|
+
return hallRoomId;
|
|
224
|
+
},
|
|
225
|
+
on(event, handler) {
|
|
226
|
+
if (!listeners.has(event))
|
|
227
|
+
listeners.set(event, new Set());
|
|
228
|
+
listeners.get(event).add(handler);
|
|
229
|
+
return () => {
|
|
230
|
+
listeners.get(event)?.delete(handler);
|
|
231
|
+
};
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
return proxy;
|
|
235
|
+
}
|
|
236
|
+
// ── Pulse proxy ─────────────────────────────────────────────────────────────
|
|
237
|
+
/**
|
|
238
|
+
* Build the Pulse analytics context proxy.
|
|
239
|
+
*
|
|
240
|
+
* All methods are fire-and-forget — they never throw.
|
|
241
|
+
* In HTTP mode, uses `navigator.sendBeacon` when available for page-unload safety.
|
|
242
|
+
*
|
|
243
|
+
* @param t - Transport (WorkshopTransport or HTTP config).
|
|
244
|
+
* @returns Pulse context with `track()` and `identify()`.
|
|
245
|
+
*/
|
|
246
|
+
function createPulseProxy(t) {
|
|
247
|
+
function send(payload) {
|
|
248
|
+
const body = JSON.stringify(payload);
|
|
249
|
+
if (t instanceof WorkshopTransport) {
|
|
250
|
+
t.call('/api/pulse/track', 'POST', body).catch(() => {
|
|
251
|
+
/* fire-and-forget */
|
|
252
|
+
});
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// HTTP mode — prefer sendBeacon for page-unload resilience.
|
|
256
|
+
if (typeof navigator !== 'undefined' && navigator.sendBeacon) {
|
|
257
|
+
navigator.sendBeacon(`${t.baseUrl}/api/pulse/track`, new Blob([body], { type: 'application/json' }));
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
fetch(`${t.baseUrl}/api/pulse/track`, {
|
|
261
|
+
method: 'POST',
|
|
262
|
+
headers: { 'Content-Type': 'application/json' },
|
|
263
|
+
credentials: t.credentials ? 'include' : 'same-origin',
|
|
264
|
+
body,
|
|
265
|
+
keepalive: true,
|
|
266
|
+
}).catch(() => {
|
|
267
|
+
/* fire-and-forget */
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
track(event, properties) {
|
|
273
|
+
send({ type: 'track', event, properties });
|
|
274
|
+
},
|
|
275
|
+
identify(userId, traits) {
|
|
276
|
+
send({ type: 'identify', userId, traits });
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
// ── Files proxy ─────────────────────────────────────────────────────────────
|
|
281
|
+
/**
|
|
282
|
+
* Build the Files context proxy.
|
|
283
|
+
*
|
|
284
|
+
* In Workshop: routes through PostMessage relay to `/api/files/*` which adapts
|
|
285
|
+
* to Brainy VFS under the hood.
|
|
286
|
+
* In Venue: routes to `/api/files/{slot}` which serves from Venue's CDN VFS.
|
|
287
|
+
*
|
|
288
|
+
* @param t - Transport (WorkshopTransport or HTTP config).
|
|
289
|
+
* @param slot - App slot path for Venue file namespacing.
|
|
290
|
+
* @returns Files context with upload/read/delete/list.
|
|
291
|
+
*/
|
|
292
|
+
function createFilesProxy(t, slot) {
|
|
293
|
+
const filePath = slot ? `/api/files/${slot}` : '/api/files';
|
|
294
|
+
if (t instanceof WorkshopTransport) {
|
|
295
|
+
return {
|
|
296
|
+
async upload(file, path) {
|
|
297
|
+
// Convert File/Blob to base64 for PostMessage serialization.
|
|
298
|
+
const buffer = await file.arrayBuffer();
|
|
299
|
+
const bytes = new Uint8Array(buffer);
|
|
300
|
+
let binary = '';
|
|
301
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
302
|
+
binary += String.fromCharCode(bytes[i]);
|
|
303
|
+
}
|
|
304
|
+
const base64 = btoa(binary);
|
|
305
|
+
const result = (await t.call(`${filePath}`, 'POST', JSON.stringify({
|
|
306
|
+
op: 'upload',
|
|
307
|
+
path,
|
|
308
|
+
data: base64,
|
|
309
|
+
mimeType: file instanceof File ? file.type : 'application/octet-stream',
|
|
310
|
+
})));
|
|
311
|
+
return result.url ?? path;
|
|
312
|
+
},
|
|
313
|
+
async read(path) {
|
|
314
|
+
const result = (await t.call(`${filePath}?op=read&path=${encodeURIComponent(path)}`, 'GET'));
|
|
315
|
+
return new Blob([result.content], { type: 'application/octet-stream' });
|
|
316
|
+
},
|
|
317
|
+
async delete(path) {
|
|
318
|
+
await t.call(`${filePath}?path=${encodeURIComponent(path)}`, 'DELETE');
|
|
319
|
+
},
|
|
320
|
+
async list(prefix) {
|
|
321
|
+
return (await t.call(`${filePath}?op=list&prefix=${encodeURIComponent(prefix)}`, 'GET'));
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
// HTTP mode (Venue)
|
|
326
|
+
return {
|
|
327
|
+
async upload(file, path) {
|
|
328
|
+
const fd = new FormData();
|
|
329
|
+
fd.append('file', file);
|
|
330
|
+
fd.append('path', path);
|
|
331
|
+
const result = (await httpCall(t, filePath, 'POST', fd));
|
|
332
|
+
return result.url;
|
|
333
|
+
},
|
|
334
|
+
async read(path) {
|
|
335
|
+
const res = await fetch(`${t.baseUrl}${filePath}?op=read&path=${encodeURIComponent(path)}`, { credentials: t.credentials ? 'include' : 'same-origin' });
|
|
336
|
+
if (!res.ok)
|
|
337
|
+
throw new Error(`Read failed (${res.status}): ${path}`);
|
|
338
|
+
return res.blob();
|
|
339
|
+
},
|
|
340
|
+
async delete(path) {
|
|
341
|
+
await httpCall(t, `${filePath}?path=${encodeURIComponent(path)}`, 'DELETE');
|
|
342
|
+
},
|
|
343
|
+
async list(prefix) {
|
|
344
|
+
return httpCall(t, `${filePath}?op=list&prefix=${encodeURIComponent(prefix)}`, 'GET');
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
// ── Notify proxy ────────────────────────────────────────────────────────────
|
|
349
|
+
/**
|
|
350
|
+
* Build the Notify context proxy.
|
|
351
|
+
*
|
|
352
|
+
* @param t - Transport (WorkshopTransport or HTTP config).
|
|
353
|
+
* @returns Notify context with email/sms/push.
|
|
354
|
+
*/
|
|
355
|
+
function createNotifyProxy(t) {
|
|
356
|
+
async function post(path, body) {
|
|
357
|
+
const json = JSON.stringify(body);
|
|
358
|
+
if (t instanceof WorkshopTransport) {
|
|
359
|
+
await t.call(path, 'POST', json);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
await httpCall(t, path, 'POST', json);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
async email(to, subject, body, opts) {
|
|
367
|
+
await post('/api/notify/email', { to, subject, body, ...opts });
|
|
368
|
+
},
|
|
369
|
+
async sms(to, message) {
|
|
370
|
+
await post('/api/notify/sms', { to, message });
|
|
371
|
+
},
|
|
372
|
+
async push(userId, payload) {
|
|
373
|
+
await post('/api/notify/push', { userId, payload });
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
// ── Services proxy ──────────────────────────────────────────────────────────
|
|
378
|
+
/**
|
|
379
|
+
* Build the Services context proxy.
|
|
380
|
+
*
|
|
381
|
+
* Services are Venue-only. In Workshop, every method throws a descriptive error
|
|
382
|
+
* directing the kit author to publish to Venue. In Venue, methods delegate to
|
|
383
|
+
* `/api/manage/*` endpoints.
|
|
384
|
+
*
|
|
385
|
+
* @param t - Transport (WorkshopTransport or HTTP config).
|
|
386
|
+
* @returns Services context with all Venue service namespaces.
|
|
387
|
+
*/
|
|
388
|
+
function createServicesProxy(t) {
|
|
389
|
+
// In PostMessage mode (Workshop), services are not available — the backend
|
|
390
|
+
// has no /api/manage/* routes. Return descriptive error throwers.
|
|
391
|
+
if (t instanceof WorkshopTransport) {
|
|
392
|
+
const unavailable = (service) => new Proxy({}, {
|
|
393
|
+
get: (_target, method) => {
|
|
394
|
+
if (typeof method !== 'string')
|
|
395
|
+
return undefined;
|
|
396
|
+
return () => {
|
|
397
|
+
throw new Error(`services.${service}.${method}() is only available when published to Venue`);
|
|
398
|
+
};
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
return {
|
|
402
|
+
bookings: unavailable('bookings'),
|
|
403
|
+
transactions: unavailable('transactions'),
|
|
404
|
+
inventory: unavailable('inventory'),
|
|
405
|
+
customers: unavailable('customers'),
|
|
406
|
+
subscriptions: unavailable('subscriptions'),
|
|
407
|
+
support: unavailable('support'),
|
|
408
|
+
loyalty: unavailable('loyalty'),
|
|
409
|
+
analytics: unavailable('analytics'),
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
// HTTP mode (Venue) — delegate to /api/manage/* endpoints.
|
|
413
|
+
async function managePost(path, body) {
|
|
414
|
+
return httpCall(t, path, 'POST', JSON.stringify(body));
|
|
415
|
+
}
|
|
416
|
+
async function manageGet(path, params) {
|
|
417
|
+
const url = new URL(path, t.baseUrl || window.location.origin);
|
|
418
|
+
if (params) {
|
|
419
|
+
for (const [k, v] of Object.entries(params))
|
|
420
|
+
url.searchParams.set(k, v);
|
|
421
|
+
}
|
|
422
|
+
return httpCall(t, `${url.pathname}${url.search}`, 'GET');
|
|
423
|
+
}
|
|
424
|
+
return {
|
|
425
|
+
bookings: {
|
|
426
|
+
list: (filters) => manageGet('/api/manage/bookings', filters),
|
|
427
|
+
cancel: (bookingId) => managePost('/api/manage/bookings', { _action: 'cancel', bookingId }),
|
|
428
|
+
addNotes: (bookingId, notes) => managePost('/api/manage/bookings', { _action: 'addNotes', bookingId, notes }),
|
|
429
|
+
markNoShow: (bookingId) => managePost('/api/manage/bookings', { _action: 'markNoShow', bookingId }),
|
|
430
|
+
markCompleted: (bookingId) => managePost('/api/manage/bookings', { _action: 'markCompleted', bookingId }),
|
|
431
|
+
},
|
|
432
|
+
transactions: {
|
|
433
|
+
list: (params) => manageGet('/api/manage/financials', params),
|
|
434
|
+
reconcile: (transactionId) => managePost('/api/manage/financials', { _action: 'reconcile', transactionId }),
|
|
435
|
+
},
|
|
436
|
+
inventory: {
|
|
437
|
+
list: () => manageGet('/api/manage/inventory'),
|
|
438
|
+
adjust: (itemId, adjustment, reason) => managePost('/api/manage/inventory', { _action: 'adjust', itemId, adjustment, reason }),
|
|
439
|
+
create: (fields) => managePost('/api/manage/inventory', { _action: 'create', ...fields }),
|
|
440
|
+
update: (itemId, fields) => managePost('/api/manage/inventory', { _action: 'update', itemId, ...fields }),
|
|
441
|
+
deactivate: (itemId) => managePost('/api/manage/inventory', { _action: 'deactivate', itemId }),
|
|
442
|
+
},
|
|
443
|
+
customers: {
|
|
444
|
+
search: (q) => manageGet('/api/manage/customers', { q }),
|
|
445
|
+
getById: (id) => manageGet('/api/manage/customers', { id }),
|
|
446
|
+
merge: (sourceId, targetId) => managePost('/api/manage/customers', { _action: 'merge', sourceId, targetId }),
|
|
447
|
+
},
|
|
448
|
+
subscriptions: {
|
|
449
|
+
list: (params) => manageGet('/api/manage/subscriptions', params),
|
|
450
|
+
cancel: (subscriptionId) => managePost('/api/manage/subscriptions', { _action: 'cancel', subscriptionId }),
|
|
451
|
+
pause: (subscriptionId) => managePost('/api/manage/subscriptions', { _action: 'pause', subscriptionId }),
|
|
452
|
+
resume: (subscriptionId) => managePost('/api/manage/subscriptions', { _action: 'resume', subscriptionId }),
|
|
453
|
+
},
|
|
454
|
+
loyalty: {
|
|
455
|
+
getAccount: (customerId) => manageGet('/api/manage/loyalty', { customerId }),
|
|
456
|
+
adjust: (customerId, points, reason) => managePost('/api/manage/loyalty', { _action: 'adjust', customerId, points, reason }),
|
|
457
|
+
},
|
|
458
|
+
analytics: {
|
|
459
|
+
dashboard: () => manageGet('/api/manage/dashboard'),
|
|
460
|
+
financials: (month) => manageGet('/api/manage/financials', month ? { month } : undefined),
|
|
461
|
+
},
|
|
462
|
+
support: {
|
|
463
|
+
list: () => Promise.reject(new Error('support.list() requires the support feature to be enabled')),
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
// ── Auth proxy ──────────────────────────────────────────────────────────────
|
|
468
|
+
/**
|
|
469
|
+
* Build the Auth context, merging caller-provided auth data with default stubs.
|
|
470
|
+
*
|
|
471
|
+
* In Workshop, auth is minimal (dev user from Workshop's session).
|
|
472
|
+
* In Venue, the caller provides the full auth context from page data.
|
|
473
|
+
*
|
|
474
|
+
* @param t - Transport (WorkshopTransport or HTTP config).
|
|
475
|
+
* @param initial - Partial auth context provided by the host.
|
|
476
|
+
* @returns Full auth context with all required methods.
|
|
477
|
+
*/
|
|
478
|
+
function createAuthProxy(t, initial) {
|
|
479
|
+
return {
|
|
480
|
+
user: initial?.user ?? null,
|
|
481
|
+
role: initial?.role ?? null,
|
|
482
|
+
can: initial?.can ?? (() => false),
|
|
483
|
+
signOut: initial?.signOut ?? (async () => {
|
|
484
|
+
if (t instanceof WorkshopTransport) {
|
|
485
|
+
throw new Error('signOut() is not available in Workshop dev mode');
|
|
486
|
+
}
|
|
487
|
+
await fetch(`${t.baseUrl}/api/auth/sign-out`, {
|
|
488
|
+
method: 'POST',
|
|
489
|
+
credentials: 'include',
|
|
490
|
+
});
|
|
491
|
+
window.location.href = '/';
|
|
492
|
+
}),
|
|
493
|
+
getToken: initial?.getToken ?? (async () => {
|
|
494
|
+
if (t instanceof WorkshopTransport) {
|
|
495
|
+
const result = await t.call('/api/auth/app-token', 'POST');
|
|
496
|
+
return result.token;
|
|
497
|
+
}
|
|
498
|
+
const result = await httpCall(t, '/api/auth/app-token', 'POST');
|
|
499
|
+
return result.token;
|
|
500
|
+
}),
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
// ── WebSocket noop ──────────────────────────────────────────────────────────
|
|
504
|
+
/**
|
|
505
|
+
* No-op WebSocket context.
|
|
506
|
+
*
|
|
507
|
+
* Real-time events in Workshop go through the SSE bridge and Brainy's
|
|
508
|
+
* `onDataChange()` — there's no app-level WebSocket in either Workshop or
|
|
509
|
+
* this initial SDK version. Venue can override this with its WS bridge later.
|
|
510
|
+
*/
|
|
511
|
+
const noopWs = {
|
|
512
|
+
on: (_event, _handler) => () => { },
|
|
513
|
+
emit: (_event, _data) => { },
|
|
514
|
+
connected: false,
|
|
515
|
+
};
|
|
516
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
517
|
+
// Factory
|
|
518
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
519
|
+
/**
|
|
520
|
+
* Build a full {@link AppContext} (structurally matches `AppRuntimeContext`)
|
|
521
|
+
* from minimal options.
|
|
522
|
+
*
|
|
523
|
+
* @param options - Configuration for the app context.
|
|
524
|
+
* @returns A fully-wired app runtime context.
|
|
525
|
+
*
|
|
526
|
+
* @example Workshop kit app
|
|
527
|
+
* ```typescript
|
|
528
|
+
* const context = createAppContext({
|
|
529
|
+
* transport: new PostMessageTransport(origin),
|
|
530
|
+
* workshopTransport: new WorkshopTransport(origin),
|
|
531
|
+
* })
|
|
532
|
+
* export const brainy = context.brain // backward compatible
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @example Venue production app
|
|
536
|
+
* ```typescript
|
|
537
|
+
* const context = createAppContext({
|
|
538
|
+
* brain: existingProxy,
|
|
539
|
+
* auth: appAuth,
|
|
540
|
+
* kit: kitManifest,
|
|
541
|
+
* credentials: true,
|
|
542
|
+
* })
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
export function createAppContext(options) {
|
|
546
|
+
const { baseUrl = '', brain: providedBrain, transport, workshopTransport, auth: initialAuth, kit, slot, config, credentials = false, } = options;
|
|
547
|
+
// Build the Brainy proxy from transport, or use the provided one.
|
|
548
|
+
const brain = providedBrain ?? (transport ? createBrainyProxy(transport) : null);
|
|
549
|
+
if (!brain) {
|
|
550
|
+
throw new Error('createAppContext: either `brain` or `transport` must be provided');
|
|
551
|
+
}
|
|
552
|
+
// Determine the proxy transport for non-brainy calls.
|
|
553
|
+
const proxyTransport = workshopTransport ?? { baseUrl, credentials };
|
|
554
|
+
return {
|
|
555
|
+
brain,
|
|
556
|
+
auth: createAuthProxy(proxyTransport, initialAuth),
|
|
557
|
+
kit: kit ?? {},
|
|
558
|
+
ws: noopWs,
|
|
559
|
+
services: createServicesProxy(proxyTransport),
|
|
560
|
+
ai: createAIProxy(proxyTransport),
|
|
561
|
+
files: createFilesProxy(proxyTransport, slot),
|
|
562
|
+
notify: createNotifyProxy(proxyTransport),
|
|
563
|
+
hall: createHallProxy(proxyTransport),
|
|
564
|
+
pulse: createPulseProxy(proxyTransport),
|
|
565
|
+
config,
|
|
566
|
+
slot,
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/app-context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB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