@acms-subir/client 0.1.15 → 0.1.16
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 +6 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -3
- package/dist/types.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,8 +27,11 @@ raw document. Every method accepts `locale` and `signal` in its options object.
|
|
|
27
27
|
Locale is sent only for routes that support translations. `withLocale` shares
|
|
28
28
|
the cache and transport configuration with the original client. `site()` and
|
|
29
29
|
`pushTopics()` take a language since core 0.3.32; an older site rejects it, so
|
|
30
|
-
the client asks once more without it and gets the main language.
|
|
31
|
-
|
|
30
|
+
the client asks once more without it and gets the main language. `book()`
|
|
31
|
+
sends the client's `locale` in its body, so the booking's emails (and the links
|
|
32
|
+
in them) speak the app's language; a site before core 0.3.38 refuses that field,
|
|
33
|
+
so the client books once more without it, with the same key, in the site's main
|
|
34
|
+
language. Update the site before shipping an app build with a newer client.
|
|
32
35
|
|
|
33
36
|
| Method | Options / behavior |
|
|
34
37
|
| --- | --- |
|
|
@@ -46,7 +49,7 @@ site before shipping an app build with a newer client.
|
|
|
46
49
|
| `resources(opts)`, `resource(slug, opts)` | Public resources; slug lookup scans list pages |
|
|
47
50
|
| `availability(opts)` | Required `resource`, `link`; optional `from`, `days`, `minutes` |
|
|
48
51
|
| `rsvpStatus(slug, { start })` | One event date's RSVP status: `open` or `reason` (`disabled`, `ended`, `cancelled`, `full`), live `going`/`left`, `maxSeats` for one RSVP right now, `autoConfirm`, and `form` (questions and `version`, or `null`). `start` is the occurrence's start exactly as `events()` returns it (a UTC ISO string such as `2026-10-05T14:00:00.000Z`). Never cached |
|
|
49
|
-
| `book(opts)` | Resource booking or RSVP input (`RsvpInput` for an RSVP), optional `idempotencyKey` |
|
|
52
|
+
| `book(opts)` | Resource booking or RSVP input (`RsvpInput` for an RSVP), optional `idempotencyKey`; sends the client's `locale` (or `opts.locale`) for its emails |
|
|
50
53
|
| `openapi()` | Raw OpenAPI document |
|
|
51
54
|
| `registerDevice({ token, platform, locale?, topics?, channels? })` | Register or refresh an Expo push token (call on every app start); `{ created, device }`. `channels`: Android channels the app created (e.g. `['urgent']`) |
|
|
52
55
|
| `updateDevice(token, { topics?, locale?, channels? })` | Change a device's topics, language or channels |
|
package/dist/index.d.ts
CHANGED
|
@@ -255,6 +255,7 @@ export interface AcmsClient {
|
|
|
255
255
|
* RSVP with `book({ event, start, seats, name, email, answers, formVersion: form.version })`.
|
|
256
256
|
*/
|
|
257
257
|
rsvpStatus(slug: string, o: RsvpStatusOptions): Promise<RsvpStatus>;
|
|
258
|
+
/** A room booking or an RSVP. Sends the client's `locale` (or `o.locale`), so its emails and links speak it. */
|
|
258
259
|
book(o: BookOptions): Promise<BookingResult>;
|
|
259
260
|
openapi(o?: RequestOptions): Promise<OpenApiDocument>;
|
|
260
261
|
/** Register or refresh this device's Expo push token. Call on every app start. Requires push on the site. */
|
package/dist/index.js
CHANGED
|
@@ -280,10 +280,22 @@ export function createClient(options) {
|
|
|
280
280
|
calendars: (o = {}) => request('calendars', o),
|
|
281
281
|
availability: (o) => request('availability', o, { resource: o.resource, link: o.link, from: o.from, days: o.days, minutes: o.minutes }),
|
|
282
282
|
rsvpStatus: (slug, o) => request('rsvpStatus', o, { start: o.start }, slug),
|
|
283
|
-
book
|
|
284
|
-
const { locale, signal, idempotencyKey, ...body } = o;
|
|
283
|
+
async book(o) {
|
|
284
|
+
const { locale = options.locale, signal, idempotencyKey, ...body } = o;
|
|
285
285
|
const key = idempotencyKey ?? defaultHeaders.get('Idempotency-Key') ?? uuid();
|
|
286
|
-
|
|
286
|
+
// the client's language rides in the body: the booking's emails and links speak it
|
|
287
|
+
if (locale === undefined)
|
|
288
|
+
return request('book', { signal }, {}, undefined, body, key);
|
|
289
|
+
try {
|
|
290
|
+
return await request('book', { signal }, {}, undefined, { ...body, locale }, key);
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
// sites before core 0.3.38 refuse the field (and one the site doesn't have): book without it, in
|
|
294
|
+
// the site's main language. A refused request doesn't use up the key.
|
|
295
|
+
if (!(error instanceof AcmsError) || error.status !== 400 || !/locale/i.test(JSON.stringify([error.message, error.issues ?? []])))
|
|
296
|
+
throw error;
|
|
297
|
+
return request('book', { signal }, {}, undefined, body, key);
|
|
298
|
+
}
|
|
287
299
|
},
|
|
288
300
|
openapi: (o = {}) => request('openapi', o),
|
|
289
301
|
registerDevice: (input, o = {}) => request('registerDevice', o, {}, undefined, input),
|
package/dist/types.d.ts
CHANGED
|
@@ -251,6 +251,9 @@ export type Event = {
|
|
|
251
251
|
"name": string;
|
|
252
252
|
"color": string;
|
|
253
253
|
}>;
|
|
254
|
+
"notify": {
|
|
255
|
+
"changes": Array<string>;
|
|
256
|
+
};
|
|
254
257
|
};
|
|
255
258
|
export type Events = {
|
|
256
259
|
"locale": string | null;
|
|
@@ -338,6 +341,9 @@ export type Events = {
|
|
|
338
341
|
"name": string;
|
|
339
342
|
"color": string;
|
|
340
343
|
}>;
|
|
344
|
+
"notify": {
|
|
345
|
+
"changes": Array<string>;
|
|
346
|
+
};
|
|
341
347
|
};
|
|
342
348
|
}>;
|
|
343
349
|
};
|
|
@@ -474,6 +480,9 @@ export type SearchResults = {
|
|
|
474
480
|
"name": string;
|
|
475
481
|
"color": string;
|
|
476
482
|
}>;
|
|
483
|
+
"notify": {
|
|
484
|
+
"changes": Array<string>;
|
|
485
|
+
};
|
|
477
486
|
};
|
|
478
487
|
}>;
|
|
479
488
|
"more": {
|
|
@@ -1963,6 +1972,7 @@ export type BookingInput = ({
|
|
|
1963
1972
|
"answers"?: {
|
|
1964
1973
|
[key: string]: (string) | (Array<string>);
|
|
1965
1974
|
};
|
|
1975
|
+
"locale"?: string;
|
|
1966
1976
|
"resource": string;
|
|
1967
1977
|
"link": string;
|
|
1968
1978
|
"minutes"?: number;
|
|
@@ -1974,6 +1984,7 @@ export type BookingInput = ({
|
|
|
1974
1984
|
"answers"?: {
|
|
1975
1985
|
[key: string]: (string) | (Array<string>);
|
|
1976
1986
|
};
|
|
1987
|
+
"locale"?: string;
|
|
1977
1988
|
"event": string;
|
|
1978
1989
|
"seats"?: number;
|
|
1979
1990
|
"formVersion"?: string;
|