@acms-subir/client 0.1.17 → 0.1.18

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
@@ -44,7 +44,8 @@ language. Update the site before shipping an app build with a newer client.
44
44
  | `pages(opts)` | Page **summaries**, with pagination; use `page()` for sections |
45
45
  | `search(text, opts)` | Top matches in `posts`, `pages` and `events`, plus `more` per group; `types`, `collection`, `limit` (1–20, default 5). Blank text resolves empty without a request |
46
46
  | `events(opts)` | Occurrences with `from`, `to`, `calendar`, `tag`, `excludeTag`, `q`, pagination |
47
- | `event(slug, opts)` | First matching event from occurrences in the requested window |
47
+ | `event(slug, opts)` | One event by slug, whatever its date (`GET /events/{slug}`; on sites older than core 0.3.40, the first match in the requested window) |
48
+ | `eventDetail(slug, { on? })` | The event and its next occurrence, or the one on `on` (`YYYY-MM-DD`) |
48
49
  | `calendars()` | Public calendars |
49
50
  | `resources(opts)`, `resource(slug, opts)` | Public resources; slug lookup scans list pages |
50
51
  | `availability(opts)` | Required `resource`, `link`; optional `from`, `days`, `minutes` |
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 } 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, 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';
@@ -125,6 +125,10 @@ export declare const endpoints: {
125
125
  readonly method: "GET";
126
126
  readonly path: "/events";
127
127
  };
128
+ readonly eventDetail: {
129
+ readonly method: "GET";
130
+ readonly path: "/events/{slug}";
131
+ };
128
132
  readonly calendars: {
129
133
  readonly method: "GET";
130
134
  readonly path: "/calendars";
@@ -244,7 +248,12 @@ export interface AcmsClient {
244
248
  /** Ranked matches across posts, pages and events, the top few per group. Requires `site.features.search`. */
245
249
  search(q: string, o?: SearchOptions): Promise<SearchResults>;
246
250
  events(o?: EventOptions): Promise<Events>;
251
+ /** One event by slug, whatever its date (older sites: searched in the window). */
247
252
  event(slug: string, o?: EventOptions): Promise<Event>;
253
+ /** One event by slug or id with its next occurrence, or the one on `on` (YYYY-MM-DD, like the website's ?on=). */
254
+ eventDetail(slug: string, o?: RequestOptions & {
255
+ on?: string;
256
+ }): Promise<EventDetail>;
248
257
  calendars(o?: RequestOptions): Promise<Calendars>;
249
258
  resources(o?: ListOptions): Promise<Resources>;
250
259
  resource(slug: string, o?: RequestOptions): Promise<Resource>;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export const endpoints = {
7
7
  home: { method: 'GET', path: '/pages/home' }, page: { method: 'GET', path: '/pages/{slug}' },
8
8
  content: { method: 'GET', path: '/content' }, contentById: { method: 'GET', path: '/content/{id}' },
9
9
  search: { method: 'GET', path: '/search' },
10
- events: { method: 'GET', path: '/events' }, calendars: { method: 'GET', path: '/calendars' },
10
+ events: { method: 'GET', path: '/events' }, eventDetail: { method: 'GET', path: '/events/{slug}' }, calendars: { method: 'GET', path: '/calendars' },
11
11
  // an event date's RSVP status: live seats and questions (never cached); RSVP with book()
12
12
  rsvpStatus: { method: 'GET', path: '/events/{slug}/rsvp' },
13
13
  resources: { method: 'GET', path: '/resources' }, availability: { method: 'GET', path: '/availability' },
@@ -30,7 +30,7 @@ export const endpoints = {
30
30
  guestBookings: { method: 'GET', path: '/guest/bookings' }, guestSignOut: { method: 'POST', path: '/guest/revoke' },
31
31
  };
32
32
  // site: its legal links; pushTopics: topic names
33
- const localized = new Set(['home', 'page', 'content', 'contentById', 'search', 'events', 'rsvpStatus', 'site', 'pushTopics', 'announcements', 'announcement']);
33
+ const localized = new Set(['home', 'page', 'content', 'contentById', 'search', 'events', 'rsvpStatus', 'site', 'pushTopics', 'announcements', 'announcement', 'eventDetail']);
34
34
  // localized since core 0.3.32; older sites answer ?locale= with a 400, so ask them again without it
35
35
  const lateLocalized = new Set(['site', 'pushTopics']);
36
36
  function uuid() {
@@ -264,8 +264,17 @@ export function createClient(options) {
264
264
  return request('contentById', o, { kind: 'post' }, item.id);
265
265
  throw new AcmsError(404, 'not_found', 'Post not found.');
266
266
  },
267
- /** Searches occurrences in the supplied window (server default: next 30 UTC days). */
267
+ eventDetail: (slug, o = {}) => request('eventDetail', o, { on: o.on }, slug),
268
+ /** One event by slug, whatever its date. Sites older than core 0.3.40 have no such route: then it searches occurrences in the window (default: next 30 days). */
268
269
  async event(slug, o = {}) {
270
+ try {
271
+ return (await request('eventDetail', o, {}, slug)).event;
272
+ }
273
+ catch (e) {
274
+ // a real "not found" comes as JSON with code not_found; an older site answers its HTML 404 page
275
+ if (!(e instanceof AcmsError) || e.status !== 404 || e.code === 'not_found')
276
+ throw e;
277
+ }
269
278
  for await (const item of paginate.events(o))
270
279
  if (item.event.slug === slug)
271
280
  return item.event;
package/dist/types.d.ts CHANGED
@@ -351,6 +351,92 @@ export type Events = {
351
351
  };
352
352
  }>;
353
353
  };
354
+ export type EventDetail = {
355
+ "locale": string | null;
356
+ "occurrence": ({
357
+ "id": string;
358
+ "start": string;
359
+ "end": string;
360
+ "allDay": boolean;
361
+ "cancelled": boolean;
362
+ }) | (null);
363
+ "event": {
364
+ "id": string;
365
+ "slug": string;
366
+ "title": string;
367
+ "excerpt": string;
368
+ "status": "draft" | "scheduled" | "published" | "archived";
369
+ "cancelled": boolean;
370
+ "featured": boolean;
371
+ "start": string;
372
+ "end": string;
373
+ "allDay": boolean;
374
+ "timezone": string;
375
+ "rrule": string;
376
+ "exdates": Array<string>;
377
+ "cancelledDates": Array<string>;
378
+ "location": {
379
+ "name": string;
380
+ "address": string;
381
+ "url": string;
382
+ "lat": number | null;
383
+ "lng": number | null;
384
+ "placeId": string;
385
+ "showMap": boolean;
386
+ "mapImage": string;
387
+ "mapImageDark": string;
388
+ };
389
+ "cta": {
390
+ "label": string;
391
+ "href": string;
392
+ "style": "primary" | "outline";
393
+ };
394
+ "tags": Array<string>;
395
+ "fields": {
396
+ [key: string]: string;
397
+ };
398
+ "rsvp": {
399
+ "enabled": boolean;
400
+ "capacity": number;
401
+ "autoConfirm": boolean;
402
+ "maxSeats": number;
403
+ "closesAt": string | null;
404
+ "closeBefore": number;
405
+ "form"?: {
406
+ "title": string;
407
+ "intro": string;
408
+ "submitLabel": string;
409
+ "confirmation": string;
410
+ "fields": Array<{
411
+ "id": string;
412
+ "type": "text" | "textarea" | "email" | "phone" | "number" | "select" | "checkbox" | "date" | "radio" | "checkboxes" | "url" | "consent" | "heading";
413
+ "label": string;
414
+ "required": boolean;
415
+ "help": string;
416
+ "options": Array<string>;
417
+ "placeholder"?: string;
418
+ "width"?: "full" | "half";
419
+ "allowOther"?: boolean;
420
+ }>;
421
+ };
422
+ };
423
+ "url": string;
424
+ "icsUrl": string;
425
+ "repeats": string;
426
+ "image": string;
427
+ "imageAlt": string;
428
+ "updatedAt": string;
429
+ "calendars": Array<{
430
+ "id": string;
431
+ "slug": string;
432
+ "name": string;
433
+ "color": string;
434
+ }>;
435
+ "notify": {
436
+ "changes": Array<string>;
437
+ };
438
+ };
439
+ };
354
440
  export type SearchResults = {
355
441
  "locale": string | null;
356
442
  "query": string;
@@ -1162,6 +1248,7 @@ export type EditorDocument = {
1162
1248
  "maxSeats": number;
1163
1249
  "closesAt": string | null;
1164
1250
  "closeBefore": number;
1251
+ "notifyStaff": boolean;
1165
1252
  "form"?: {
1166
1253
  "title": string;
1167
1254
  "intro": string;
@@ -2094,6 +2181,7 @@ export type EditorSaveInput = {
2094
2181
  "maxSeats": number;
2095
2182
  "closesAt"?: (string) | (null);
2096
2183
  "closeBefore"?: number;
2184
+ "notifyStaff"?: boolean;
2097
2185
  "form"?: {
2098
2186
  "title"?: string;
2099
2187
  "intro"?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acms-subir/client",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Typed, dependency-free client for the ACMS public mobile API.",
5
5
  "type": "module",
6
6
  "license": "MIT",