shopstack 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -39
- package/SKILL.md +45 -32
- package/bin/shopstack +1 -3
- package/package.json +13 -23
- package/specs/openapi.json +3293 -0
- package/src/checkout-monitor.js +126 -0
- package/src/cli.js +232 -142
- package/src/client.d.ts +258 -26
- package/src/client.js +188 -173
- package/src/config.d.ts +7 -0
- package/src/config.js +12 -0
- package/src/reservation-progress.js +132 -0
- package/LICENSE +0 -21
package/src/client.d.ts
CHANGED
|
@@ -2,7 +2,98 @@ export interface ShopstackClientOptions {
|
|
|
2
2
|
apiKey?: string;
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
fetch?: typeof fetch;
|
|
5
|
-
|
|
5
|
+
/** Uses the runtime WebSocket when available; null selects bounded HTTP waits. */
|
|
6
|
+
webSocket?: typeof WebSocket | null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ShippingAddress {
|
|
10
|
+
city: string;
|
|
11
|
+
country: string;
|
|
12
|
+
line1: string;
|
|
13
|
+
line2?: string;
|
|
14
|
+
postal_code: string;
|
|
15
|
+
region?: string;
|
|
16
|
+
suburb?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CreateCheckoutRequest {
|
|
20
|
+
currency: string;
|
|
21
|
+
customer: {
|
|
22
|
+
/** When absent or blank, the service uses a checkout-scoped temporary inbox. */
|
|
23
|
+
email?: string;
|
|
24
|
+
name: string;
|
|
25
|
+
phone?: string;
|
|
26
|
+
shipping_address: ShippingAddress;
|
|
27
|
+
};
|
|
28
|
+
external_reference?: string;
|
|
29
|
+
instructions?: string;
|
|
30
|
+
item_url: string;
|
|
31
|
+
maximum_amount: string;
|
|
32
|
+
model_handle?: "qwen";
|
|
33
|
+
payment_provider?: "link";
|
|
34
|
+
proxy?: {
|
|
35
|
+
country?: string;
|
|
36
|
+
/** Explicit browser locale; the service does not infer it from country. */
|
|
37
|
+
locale?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ReservationDiner {
|
|
42
|
+
country: string;
|
|
43
|
+
first_name: string;
|
|
44
|
+
last_name: string;
|
|
45
|
+
phone_number: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface CreateReservationRequest {
|
|
49
|
+
diner: ReservationDiner;
|
|
50
|
+
external_reference?: string;
|
|
51
|
+
/** The service resolves this place name and its local time zone. */
|
|
52
|
+
location: { query: string };
|
|
53
|
+
/** Include all known search details. The service asks for missing information. */
|
|
54
|
+
request: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ReservationProgress {
|
|
58
|
+
type: "progress";
|
|
59
|
+
request_id: string;
|
|
60
|
+
sequence: number;
|
|
61
|
+
call_id: number;
|
|
62
|
+
operation:
|
|
63
|
+
| "resolve_location"
|
|
64
|
+
| "get_search_filters"
|
|
65
|
+
| "search_restaurants"
|
|
66
|
+
| "prepare_booking"
|
|
67
|
+
| "confirm_booking"
|
|
68
|
+
| "decline_booking"
|
|
69
|
+
| "ask_user"
|
|
70
|
+
| "reply"
|
|
71
|
+
| "request"
|
|
72
|
+
| "model_decision"
|
|
73
|
+
| "model_request"
|
|
74
|
+
| "model_retry_wait"
|
|
75
|
+
| "restaurant_request"
|
|
76
|
+
| "provider_session"
|
|
77
|
+
| "location_lookup"
|
|
78
|
+
| "availability_recheck"
|
|
79
|
+
| "slot_lock"
|
|
80
|
+
| "slot_unlock"
|
|
81
|
+
| "guest_profile"
|
|
82
|
+
| "booking_submit"
|
|
83
|
+
| "booking_status"
|
|
84
|
+
| "booking_cancel"
|
|
85
|
+
| "guest_inbox";
|
|
86
|
+
phase: "started" | "completed" | "failed" | "selected";
|
|
87
|
+
elapsed_ms: number;
|
|
88
|
+
duration_ms?: number;
|
|
89
|
+
http_status?: number;
|
|
90
|
+
failure?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ReservationMutationOptions {
|
|
94
|
+
idempotencyKey?: string;
|
|
95
|
+
/** Display only. Callback failure does not retry or cancel the operation. */
|
|
96
|
+
onProgress?: (event: ReservationProgress) => unknown;
|
|
6
97
|
}
|
|
7
98
|
|
|
8
99
|
export interface PaymentCard {
|
|
@@ -34,6 +125,7 @@ export interface Checkout {
|
|
|
34
125
|
| "failed"
|
|
35
126
|
| "cancelled";
|
|
36
127
|
revision: number;
|
|
128
|
+
/** Monotonic display version; it can advance without a lifecycle change. */
|
|
37
129
|
presentation_revision: number;
|
|
38
130
|
activity: string;
|
|
39
131
|
intent?: {
|
|
@@ -42,6 +134,7 @@ export interface Checkout {
|
|
|
42
134
|
updated_at: string;
|
|
43
135
|
};
|
|
44
136
|
item_url: string;
|
|
137
|
+
/** Present this exact owner-only URL verbatim. Never reconstruct its token. */
|
|
45
138
|
live_view_url?: string;
|
|
46
139
|
required_input?: { type: "payment_card" };
|
|
47
140
|
approval?: PaymentApproval;
|
|
@@ -52,9 +145,124 @@ export interface Checkout {
|
|
|
52
145
|
expires_at: string;
|
|
53
146
|
}
|
|
54
147
|
|
|
148
|
+
export interface Reservation {
|
|
149
|
+
id: string;
|
|
150
|
+
status:
|
|
151
|
+
| "active"
|
|
152
|
+
| "confirmation_required"
|
|
153
|
+
| "confirmed"
|
|
154
|
+
| "cancelled"
|
|
155
|
+
| "booking_unknown"
|
|
156
|
+
| "cancellation_unknown";
|
|
157
|
+
revision: number;
|
|
158
|
+
turn: ReservationTurn;
|
|
159
|
+
created_at: string;
|
|
160
|
+
updated_at: string;
|
|
161
|
+
/** Search-session expiry; it does not end the life of a confirmed booking. */
|
|
162
|
+
expires_at: string;
|
|
163
|
+
/** Last retained time for reading and managing the confirmed booking. */
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type ReservationTurn =
|
|
167
|
+
| { type: "question" | "message"; message: string }
|
|
168
|
+
| {
|
|
169
|
+
type: "location_options";
|
|
170
|
+
message: string;
|
|
171
|
+
locations: { location_id: string; label: string }[];
|
|
172
|
+
}
|
|
173
|
+
| {
|
|
174
|
+
type: "options";
|
|
175
|
+
message: string;
|
|
176
|
+
options: ReservationCompactOption[];
|
|
177
|
+
more_available: number;
|
|
178
|
+
}
|
|
179
|
+
| {
|
|
180
|
+
type: "confirmation_required";
|
|
181
|
+
message: string;
|
|
182
|
+
confirmation_prompt: {
|
|
183
|
+
restaurant: string;
|
|
184
|
+
address: string;
|
|
185
|
+
date_time: string;
|
|
186
|
+
party_size: number;
|
|
187
|
+
option_id: string;
|
|
188
|
+
time_id: string;
|
|
189
|
+
diner: ReservationDiner;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
| {
|
|
193
|
+
type: "confirmation";
|
|
194
|
+
message: string;
|
|
195
|
+
confirmation: {
|
|
196
|
+
confirmation_number: string;
|
|
197
|
+
restaurant: string;
|
|
198
|
+
date_time: string;
|
|
199
|
+
party_size: number;
|
|
200
|
+
status: string;
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
| {
|
|
204
|
+
type: "cancellation";
|
|
205
|
+
message: string;
|
|
206
|
+
cancellation: { confirmation_number: string; status: string };
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export interface ReservationTime {
|
|
210
|
+
date_time: string;
|
|
211
|
+
time_id: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface ReservationCompactOption {
|
|
215
|
+
address: string;
|
|
216
|
+
available_times: ReservationTime[];
|
|
217
|
+
caveats: string[];
|
|
218
|
+
cuisines: string[];
|
|
219
|
+
cover_photo_url?: string;
|
|
220
|
+
description_excerpt?: string;
|
|
221
|
+
fit: string[];
|
|
222
|
+
name: string;
|
|
223
|
+
option_id: string;
|
|
224
|
+
price_label?: string;
|
|
225
|
+
rating?: number;
|
|
226
|
+
review_count?: number;
|
|
227
|
+
tags: ("more_availability" | "most_proven")[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface ReservationOption extends Omit<
|
|
231
|
+
ReservationCompactOption,
|
|
232
|
+
| "available_times"
|
|
233
|
+
| "caveats"
|
|
234
|
+
| "cover_photo_url"
|
|
235
|
+
| "description_excerpt"
|
|
236
|
+
| "fit"
|
|
237
|
+
| "tags"
|
|
238
|
+
> {
|
|
239
|
+
description?: string;
|
|
240
|
+
match_reasons: string[];
|
|
241
|
+
photo_urls: string[];
|
|
242
|
+
times: ReservationTime[];
|
|
243
|
+
unverified: string[];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface ReservationOptionPage {
|
|
247
|
+
limit: number;
|
|
248
|
+
more_available: number;
|
|
249
|
+
next_offset?: number;
|
|
250
|
+
offset: number;
|
|
251
|
+
options: ReservationCompactOption[];
|
|
252
|
+
total_available: number;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface RunReservationOptions {
|
|
256
|
+
idempotencyKey?: string;
|
|
257
|
+
onTurn?(reservation: Reservation): void | Promise<void>;
|
|
258
|
+
respond?(
|
|
259
|
+
reservation: Reservation,
|
|
260
|
+
): string | Promise<string | undefined> | undefined;
|
|
261
|
+
}
|
|
262
|
+
|
|
55
263
|
export interface RunCheckoutOptions {
|
|
56
264
|
idempotencyKey?: string;
|
|
57
|
-
|
|
265
|
+
/** @deprecated Checkout monitoring uses revision notifications and bounded waits. */
|
|
58
266
|
pollIntervalMs?: number;
|
|
59
267
|
timeoutMs?: number;
|
|
60
268
|
onProgress?(checkout: Checkout): void | Promise<void>;
|
|
@@ -70,18 +278,6 @@ export interface RunCheckoutOptions {
|
|
|
70
278
|
): string | Promise<string | undefined> | undefined;
|
|
71
279
|
}
|
|
72
280
|
|
|
73
|
-
export interface CheckoutUpdateSubscription {
|
|
74
|
-
socket_url: string;
|
|
75
|
-
protocol: "shopstack.v1";
|
|
76
|
-
token: string;
|
|
77
|
-
expires_at: string;
|
|
78
|
-
presentation_revision: number;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface LiveViewCapability {
|
|
82
|
-
live_view_url: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
281
|
export interface AccountSignupStarted {
|
|
86
282
|
id: string;
|
|
87
283
|
account_type: "personal" | "developer";
|
|
@@ -117,6 +313,8 @@ export interface SignupOptions {
|
|
|
117
313
|
export interface PendingSignupState {
|
|
118
314
|
accountType: "personal" | "developer";
|
|
119
315
|
attemptId: string;
|
|
316
|
+
/** Exact API base URL that issued this signup; never send its capabilities elsewhere. */
|
|
317
|
+
baseUrl?: string;
|
|
120
318
|
email: string;
|
|
121
319
|
expiresAt?: string;
|
|
122
320
|
idempotencyKey: string;
|
|
@@ -165,6 +363,7 @@ export class ShopstackApiError extends Error {
|
|
|
165
363
|
|
|
166
364
|
export class ShopstackClient {
|
|
167
365
|
constructor(options?: ShopstackClientOptions);
|
|
366
|
+
baseUrl: string;
|
|
168
367
|
startAccountSignup(input: {
|
|
169
368
|
accountType: "personal" | "developer";
|
|
170
369
|
email: string;
|
|
@@ -199,23 +398,57 @@ export class ShopstackClient {
|
|
|
199
398
|
paymentProvider?: "link",
|
|
200
399
|
options?: { idempotencyKey?: string },
|
|
201
400
|
): Promise<Record<string, unknown>>;
|
|
401
|
+
createReservation(
|
|
402
|
+
reservation: CreateReservationRequest,
|
|
403
|
+
options?: ReservationMutationOptions,
|
|
404
|
+
): Promise<Reservation>;
|
|
405
|
+
getReservation(reservationId: string): Promise<Reservation>;
|
|
406
|
+
listReservationOptions(
|
|
407
|
+
reservationId: string,
|
|
408
|
+
options?: { limit?: number; offset?: number },
|
|
409
|
+
): Promise<ReservationOptionPage>;
|
|
410
|
+
getReservationOption(
|
|
411
|
+
reservationId: string,
|
|
412
|
+
optionId: string,
|
|
413
|
+
): Promise<ReservationOption>;
|
|
414
|
+
sendReservationMessage(
|
|
415
|
+
reservationId: string,
|
|
416
|
+
content: string,
|
|
417
|
+
expectedRevision: number,
|
|
418
|
+
options?: ReservationMutationOptions,
|
|
419
|
+
): Promise<Reservation>;
|
|
420
|
+
cancelReservation(
|
|
421
|
+
reservationId: string,
|
|
422
|
+
expectedRevision: number,
|
|
423
|
+
options?: ReservationMutationOptions,
|
|
424
|
+
): Promise<Reservation>;
|
|
425
|
+
runReservation(
|
|
426
|
+
reservation: CreateReservationRequest,
|
|
427
|
+
options?: RunReservationOptions,
|
|
428
|
+
): Promise<Reservation>;
|
|
202
429
|
createCheckout(
|
|
203
|
-
checkout:
|
|
430
|
+
checkout: CreateCheckoutRequest,
|
|
204
431
|
options?: { idempotencyKey?: string },
|
|
205
432
|
): Promise<Checkout>;
|
|
206
433
|
getCheckout(checkoutId: string): Promise<Checkout>;
|
|
207
|
-
createLiveView(
|
|
208
|
-
checkoutId: string,
|
|
209
|
-
options?: { idempotencyKey?: string },
|
|
210
|
-
): Promise<LiveViewCapability>;
|
|
211
|
-
createCheckoutUpdateSubscription(
|
|
212
|
-
checkoutId: string,
|
|
213
|
-
): Promise<CheckoutUpdateSubscription>;
|
|
214
434
|
waitForCheckoutUpdate(
|
|
215
435
|
checkoutId: string,
|
|
216
|
-
|
|
217
|
-
waitSeconds?: number,
|
|
436
|
+
options: { after: number; wait?: number; signal?: AbortSignal },
|
|
218
437
|
): Promise<Checkout | undefined>;
|
|
438
|
+
subscribeToCheckoutUpdates(
|
|
439
|
+
checkoutId: string,
|
|
440
|
+
options?: { signal?: AbortSignal },
|
|
441
|
+
): Promise<{
|
|
442
|
+
socket_url: string;
|
|
443
|
+
protocol: "shopstack.v1";
|
|
444
|
+
token: string;
|
|
445
|
+
expires_at: string;
|
|
446
|
+
presentation_revision: number;
|
|
447
|
+
}>;
|
|
448
|
+
createLiveView(
|
|
449
|
+
checkoutId: string,
|
|
450
|
+
options?: { idempotencyKey?: string },
|
|
451
|
+
): Promise<{ live_view_url: string }>;
|
|
219
452
|
cancelCheckout(
|
|
220
453
|
checkoutId: string,
|
|
221
454
|
options?: { idempotencyKey?: string },
|
|
@@ -227,7 +460,6 @@ export class ShopstackClient {
|
|
|
227
460
|
): Promise<Record<string, unknown>>;
|
|
228
461
|
listMessages(checkoutId: string): Promise<Record<string, unknown>>;
|
|
229
462
|
listEvents(checkoutId: string): Promise<Record<string, unknown>>;
|
|
230
|
-
listArtifacts(checkoutId: string): Promise<Record<string, unknown>>;
|
|
231
463
|
providePaymentDetails(
|
|
232
464
|
checkoutId: string,
|
|
233
465
|
card: PaymentCard,
|
|
@@ -240,7 +472,7 @@ export class ShopstackClient {
|
|
|
240
472
|
options?: { idempotencyKey?: string },
|
|
241
473
|
): Promise<Checkout>;
|
|
242
474
|
runCheckout(
|
|
243
|
-
checkout:
|
|
475
|
+
checkout: CreateCheckoutRequest,
|
|
244
476
|
options?: RunCheckoutOptions,
|
|
245
477
|
): Promise<Checkout>;
|
|
246
478
|
}
|