@acms-subir/client 0.1.19 → 0.1.20

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 CHANGED
@@ -54,8 +54,10 @@ language. Update the site before shipping an app build with a newer client.
54
54
  | `openapi()` | Raw OpenAPI document |
55
55
  | `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']`) |
56
56
  | `updateDevice(token, { topics?, locale?, channels? })` | Change a device's topics, language or channels |
57
- | `unregisterDevice(token)` | Opt out (idempotent) |
57
+ | `unregisterDevice(token)` | Opt out (idempotent); also unlinks a staff test phone |
58
58
  | `pushTopics()` | Topics to offer as notification toggles, named in the client's language (built-in and the site's own, `kind: 'site'`) |
59
+ | `linkStaffPhone(token, code)` | Staff only: link this registered device with the 6-digit code from the admin's Test phones, so it gets that person's test notifications; `{ linked, staff: { name } }`. A wrong, used or expired code is a 400, too many tries a 429; never retried |
60
+ | `unlinkStaffPhone(token)` | Unlink it (idempotent); `{ linked: false, staff: null }` |
59
61
  | `links()` | The links page: profile, socials and visible blocks (`link`, `email`, `phone`, `contact`, `heading`, `text`, `spacer`, `live`, `embed`) |
60
62
  | `live()` | Live video: the current broadcast (`snapshot` or `null`), `serverNow` and the owner's `display` choices. Never cached; 404 while `site.features.live` is false |
61
63
  | `announcements({ kind?, pinned?, page?, limit? })`, `announcement(id)`, `paginate.announcements()` | Announcements up right now in the client's language, newest first (`pinned: true`: the banners, urgent first); 404 while `site.features.announcements` is false |
@@ -181,6 +183,18 @@ await client.updateDevice(token, { topics: ['events'] });
181
183
  await client.unregisterDevice(token);
182
184
  ```
183
185
 
186
+ Staff can link their own phone for test notifications ("Send test to my
187
+ phone" in the admin): the admin's Test phones panel shows a one-time 6-digit
188
+ code (10 minutes, single use) that the app sends with this phone's token.
189
+ `device.staff` (from `registerDevice` and `updateDevice`) and the link
190
+ response name who it's linked to (their name only), or `null`. Test pushes
191
+ carry `data.test: true`.
192
+
193
+ ```ts
194
+ const { staff } = await client.linkStaffPhone(token, '123456'); // { name: 'Ana López' }; 400 for a wrong, used or expired code
195
+ await client.unlinkStaffPhone(token); // turning notifications off unlinks it too
196
+ ```
197
+
184
198
  ## Live video
185
199
 
186
200
  `site.features.live` is true while the site's live video (Integrations → Live
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Site, Theme, Page, Content, Post, ContentList, SearchResults, Links, Form, FormReceipt, FormResponseInput, ManagedBooking, RescheduleInput, ManageAvailabilityQuery, GuestCodeSent, GuestToken, GuestBookings, GuestBookingsQuery, GuestSignedOut, Events, Event, Calendars, Resources, Resource, Availability, BookingInput, BookingResult, RsvpStatus, Device, DeviceInput, DeviceUpdate, DeviceRegistration, DeviceRemoved, PushTopics, LiveStatus, Announcements, AnnouncementDetail, EventDetail } from './types.js';
1
+ import type { Site, Theme, Page, Content, Post, ContentList, SearchResults, Links, Form, FormReceipt, FormResponseInput, ManagedBooking, RescheduleInput, ManageAvailabilityQuery, GuestCodeSent, GuestToken, GuestBookings, GuestBookingsQuery, GuestSignedOut, Events, Event, Calendars, Resources, Resource, Availability, BookingInput, BookingResult, RsvpStatus, Device, DeviceInput, DeviceUpdate, DeviceRegistration, DeviceRemoved, StaffLink, PushTopics, LiveStatus, Announcements, AnnouncementDetail, EventDetail } from './types.js';
2
2
  export { AcmsError, isAcmsError } from './errors.js';
3
3
  export type * from './types.js';
4
4
  export * from './editor.js';
@@ -169,6 +169,14 @@ export declare const endpoints: {
169
169
  readonly method: "GET";
170
170
  readonly path: "/push/topics";
171
171
  };
172
+ readonly linkStaffPhone: {
173
+ readonly method: "POST";
174
+ readonly path: "/devices/{token}/staff-link";
175
+ };
176
+ readonly unlinkStaffPhone: {
177
+ readonly method: "DELETE";
178
+ readonly path: "/devices/{token}/staff-link";
179
+ };
172
180
  readonly links: {
173
181
  readonly method: "GET";
174
182
  readonly path: "/links";
@@ -279,6 +287,14 @@ export interface AcmsClient {
279
287
  unregisterDevice(token: string, o?: RequestOptions): Promise<DeviceRemoved>;
280
288
  /** Topics the app can offer as notification toggles. */
281
289
  pushTopics(o?: RequestOptions): Promise<PushTopics>;
290
+ /**
291
+ * Staff only: link this registered device to the staff member whose one-time code (Admin → Test phones) it sends,
292
+ * so it gets their test notifications. `{ linked: true, staff: { name } }`. A wrong, used or expired code is a 400;
293
+ * too many tries a 429 (never retried). Sites without it (or with push off) answer 404.
294
+ */
295
+ linkStaffPhone(token: string, code: string, o?: RequestOptions): Promise<StaffLink>;
296
+ /** Unlink it (idempotent). Turning notifications off (`unregisterDevice`) unlinks it too. */
297
+ unlinkStaffPhone(token: string, o?: RequestOptions): Promise<StaffLink>;
282
298
  /** The links page: profile, socials and visible blocks. Requires `site.features.links`. */
283
299
  links(o?: RequestOptions): Promise<Links>;
284
300
  /**
package/dist/index.js CHANGED
@@ -15,6 +15,8 @@ export const endpoints = {
15
15
  // push notifications (only when the site enables push; 404 otherwise)
16
16
  registerDevice: { method: 'POST', path: '/devices' }, updateDevice: { method: 'PUT', path: '/devices/{token}' },
17
17
  unregisterDevice: { method: 'DELETE', path: '/devices/{token}' }, pushTopics: { method: 'GET', path: '/push/topics' },
18
+ // a staff member's own test phone (a one-time code from the admin's Test phones)
19
+ linkStaffPhone: { method: 'POST', path: '/devices/{token}/staff-link' }, unlinkStaffPhone: { method: 'DELETE', path: '/devices/{token}/staff-link' },
18
20
  // links page and forms (owner switches in Admin → Mobile app)
19
21
  links: { method: 'GET', path: '/links' }, form: { method: 'GET', path: '/forms/{id}' }, submitForm: { method: 'POST', path: '/forms/{id}/responses' },
20
22
  // live video status (404 while the site's live video is off)
@@ -313,6 +315,8 @@ export function createClient(options) {
313
315
  updateDevice: (token, input, o = {}) => request('updateDevice', o, {}, token, input),
314
316
  unregisterDevice: (token, o = {}) => request('unregisterDevice', o, {}, token),
315
317
  pushTopics: (o = {}) => request('pushTopics', o),
318
+ linkStaffPhone: (token, code, o = {}) => request('linkStaffPhone', o, {}, token, { code }),
319
+ unlinkStaffPhone: (token, o = {}) => request('unlinkStaffPhone', o, {}, token),
316
320
  links: (o = {}) => request('links', o),
317
321
  live: (o = {}) => request('live', o),
318
322
  form: (id, o = {}) => request('form', o, {}, id),
package/dist/types.d.ts CHANGED
@@ -943,6 +943,9 @@ export type Device = {
943
943
  "channels": Array<string>;
944
944
  "registeredAt": string;
945
945
  "lastSeenAt": string;
946
+ "staff": ({
947
+ "name": string;
948
+ }) | (null);
946
949
  };
947
950
  export type DeviceRegistration = {
948
951
  "created": boolean;
@@ -954,12 +957,21 @@ export type DeviceRegistration = {
954
957
  "channels": Array<string>;
955
958
  "registeredAt": string;
956
959
  "lastSeenAt": string;
960
+ "staff": ({
961
+ "name": string;
962
+ }) | (null);
957
963
  };
958
964
  };
959
965
  export type DeviceRemoved = {
960
966
  "token": string;
961
967
  "deleted": true;
962
968
  };
969
+ export type StaffLink = {
970
+ "linked": boolean;
971
+ "staff": ({
972
+ "name": string;
973
+ }) | (null);
974
+ };
963
975
  export type PushTopics = {
964
976
  "locale": string | null;
965
977
  "topics": Array<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acms-subir/client",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Typed, dependency-free client for the ACMS public mobile API.",
5
5
  "type": "module",
6
6
  "license": "MIT",