@spoketech/hub-client 0.4.0 → 0.6.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 CHANGED
@@ -95,6 +95,42 @@ if (activation.settled && activation.command.result) {
95
95
  console.log(activation.command.result.outcome);
96
96
  }
97
97
 
98
+ // Member create requests check Hub and the venue before creating anyone.
99
+ const [creation, creationError] = await client.members.requestCreation({
100
+ organizationId: "org_123",
101
+ payload: {
102
+ idempotencyKey: "application-123-attempt-1",
103
+ waitMs: 10_000,
104
+ // Omit, or send false, until the applicant has authorized renewal at this rate.
105
+ allowRenewalOnDuplicate: false,
106
+ member: {
107
+ firstName: "Jane",
108
+ lastName: "Smith",
109
+ dob: "1988-06-14",
110
+ membershipTypeId: "12",
111
+ },
112
+ },
113
+ });
114
+
115
+ if (creationError !== null) {
116
+ throw creationError;
117
+ }
118
+
119
+ switch (creation.settled ? creation.command.result?.outcome : undefined) {
120
+ case "created":
121
+ case "matched_active":
122
+ case "renewed_existing":
123
+ console.log(creation.command.result);
124
+ break;
125
+ case "renewal_required":
126
+ // Nothing was changed. Ask for renewal authorization, then submit again with
127
+ // allowRenewalOnDuplicate: true and a new idempotency key.
128
+ break;
129
+ default:
130
+ // Pending, review, or failure: keep the application open and follow the command.
131
+ break;
132
+ }
133
+
98
134
  const [guests, guestsError] = await client.guests.list({
99
135
  organizationId: "org_123",
100
136
  name: "Jane",
@@ -283,6 +319,7 @@ All routes below are relative to `/api/v1`. The promise client and the Effect cl
283
319
  | Client method | Route | Request | Returns |
284
320
  | --- | --- | --- | --- |
285
321
  | `client.organizations.listOrganizations({ query })` | `GET /organizations` | optional `page`, `pageSize`, `name` | `PaginatedOrganizations` |
322
+ | `client.organizations.getOrganization({ params })` | `GET /organizations/:organizationId` | `params.organizationId` (`organizations:read`) | `Organization` |
286
323
  | `client.organizations.createOrganization({ payload })` | `POST /organizations` | `CreateOrganizationInput` | `Organization` |
287
324
  | `client.organizations.updateOrganization({ params, payload })` | `PATCH /organizations/:organizationId` | `params.organizationId`, `UpdateOrganizationInput` | `Organization` |
288
325
  | `client.organizations.deleteOrganization({ params, payload })` | `DELETE /organizations/:organizationId` | `params.organizationId`, `DeletePayload` | `void` |
@@ -292,11 +329,13 @@ All routes below are relative to `/api/v1`. The promise client and the Effect cl
292
329
  | Client method | Route | Request | Returns |
293
330
  | --- | --- | --- | --- |
294
331
  | `client.members.listOrganizationMembers({ params, query })` | `GET /organizations/:organizationId/members` | `params.organizationId`, optional paging and search `query` | `OrganizationMembersListResponse` |
332
+ | `client.members.getOrganizationMemberSummary({ params })` | `GET /organizations/:organizationId/members/summary` | `params.organizationId` (`members:read`) | `OrganizationMemberSummary` |
295
333
  | `client.members.getOrganizationMember({ params, query })` | `GET /organizations/:organizationId/members/:memberId` | `params.organizationId`, `params.memberId`, optional `responseMode` | `MemberResponse` |
296
334
  | `client.members.getOrganizationMemberByExternalSystemId({ params, query })` | `GET /organizations/:organizationId/members/by-external-system-id/:externalSystemMemberId` | `params.organizationId`, `params.externalSystemMemberId`, optional `responseMode` | One `MemberResponse`; 404 when missing |
297
335
  | `client.members.listOrganizationMemberMembershipTypes({ params, query })` | `GET /organizations/:organizationId/members/membership-types` | `params.organizationId`, optional `page`, `pageSize` | `PaginatedOrganizationMemberMembershipTypes` |
298
336
  | `client.members.listOrganizationMemberRatingGrades({ params, query })` | `GET /organizations/:organizationId/members/rating-grades` | `params.organizationId`, optional `page`, `pageSize` | `PaginatedOrganizationMemberRatingGrades` |
299
337
  | `client.members.createOrganizationMember({ params, payload })` | `POST /organizations/:organizationId/members` | `params.organizationId`, `CreateMemberInput` for local-member creation | `Member` |
338
+ | `client.members.requestMemberCreation({ params, payload })` | `POST /organizations/:organizationId/members/create-requests` | `params.organizationId`, `RequestMemberCreationInput` | `EnsureActiveMembershipResponse` |
300
339
  | `client.members.ensureActiveMembership({ params, payload })` | `POST /organizations/:organizationId/members/ensure-active` | `params.organizationId`, `RequestEnsureActiveMembershipInput` | `EnsureActiveMembershipResponse` |
301
340
  | `client.members.requestSourceManagedMemberCreate({ params, payload })` | `POST /organizations/:organizationId/members/source-create` | `params.organizationId`, `RequestSourceManagedMemberCreateInput` for Odyssey/onsite source creation | `OrganizationMemberSourceCommand` |
302
341
  | `client.members.requestSourceManagedMemberRenewal({ params, payload })` | `POST /organizations/:organizationId/members/:memberId/source-renewal` | `params.organizationId`, `params.memberId`, `RequestSourceManagedMemberRenewalInput` for Odyssey/onsite source renewal | `OrganizationMemberSourceCommand` |
@@ -315,9 +354,49 @@ All routes below are relative to `/api/v1`. The promise client and the Effect cl
315
354
  | `client.memberSources.upsertOrganizationMemberSourceCsvMapping({ params, payload })` | `PUT /organizations/:organizationId/member-source/csv-mapping` | `params.organizationId`, `UpsertOrganizationMemberSourceCsvMappingInput` | `OrganizationMemberSourceCsvMapping` |
316
355
  | `client.memberSources.createOrganizationInitialMembershipUpload({ params, payload })` | `POST /organizations/:organizationId/initial-membership-uploads` | `params.organizationId`, `{ fileName: "members.xlsx" }` | `CreateOrganizationInitialMembershipUploadResponse` |
317
356
  | `client.memberSources.createOrganizationMemberSourceCsvUpload({ params, payload })` | `POST /organizations/:organizationId/member-source/csv-uploads` | `params.organizationId`, `CreateOrganizationMemberSourceCsvUploadInput` | `CreateOrganizationMemberSourceCsvUploadResponse` |
318
- | `client.memberSources.listOrganizationMemberSyncRuns({ params, query })` | `GET /organizations/:organizationId/member-source/runs` | `params.organizationId`, optional `page`, `pageSize` | `PaginatedOrganizationMemberSyncRuns` |
319
- | `client.memberSources.listOrganizationMemberSourceCommands({ params, query })` | `GET /organizations/:organizationId/member-source/commands` | `params.organizationId`, optional `page`, `pageSize` | `PaginatedOrganizationMemberSourceCommands` |
320
- | `client.memberSources.triggerOrganizationMemberSync({ params, payload })` | `POST /organizations/:organizationId/member-source/sync` | `params.organizationId`, `TriggerOrganizationMemberSyncInput` | `OrganizationMemberSyncRun` |
357
+ | `client.memberSources.listOrganizationMemberSyncRuns({ params, query })` | `GET /organizations/:organizationId/member-source/runs` | `params.organizationId`, optional `page`, `pageSize`, [history filters](#history-filters), `trigger`, `hideUnchanged` | `PaginatedOrganizationMemberSyncRuns` |
358
+ | `client.memberSources.listOrganizationMemberSourceCommands({ params, query })` | `GET /organizations/:organizationId/member-source/commands` | `params.organizationId`, optional `page`, `pageSize`, [history filters](#history-filters), `kind` | `PaginatedOrganizationMemberSourceCommands` |
359
+ | `client.memberSources.triggerOrganizationMemberSync({ params, payload })` | `POST /organizations/:organizationId/member-source/sync` | `params.organizationId`, `TriggerOrganizationMemberSyncInput` (optional `mode`, `inputReference`, `updatedAfter`) | `OrganizationMemberSyncRun` |
360
+
361
+ #### History filters
362
+
363
+ Sync runs, source commands and voucher commands accept the same optional query filters:
364
+ `status` (comma-separated), `from` and `to` (ISO-8601 instants, inclusive, matched against the
365
+ start or request time) and `sort` (`newest`, the default, or `oldest`). Sync runs also accept
366
+ `trigger` (`manual`, `scheduled`, `bucket`, `live_feed`) and `hideUnchanged=true`, which leaves
367
+ out successful runs that inserted, updated and archived nothing and reported no errors. Source and
368
+ voucher commands accept `kind`. Unknown values return `400`.
369
+
370
+ The convenience client takes arrays and `Date`s:
371
+
372
+ ```ts
373
+ const [runs] = await spoke.memberSources.runs.list({
374
+ organizationId,
375
+ statuses: ["failure", "partial_failure"],
376
+ triggers: "scheduled",
377
+ from: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
378
+ sort: "oldest",
379
+ hideUnchanged: true,
380
+ });
381
+
382
+ const [commands] = await spoke.memberSources.commands.list({
383
+ organizationId,
384
+ kinds: ["create_member", "update_member"],
385
+ statuses: "failed",
386
+ });
387
+ ```
388
+
389
+ For a one-off delta sync from a specific time, pass `updatedAfter` as a venue wall time with no
390
+ offset (`YYYY-MM-DDTHH:mm[:ss[.SSS]]`). It applies to that run only, and the saved cursor advances
391
+ normally when the run succeeds. It is supported for Odyssey and eBet onsite agent delta syncs. eBet
392
+ requests are rejected while the member source settings pin a delta start override.
393
+
394
+ ```ts
395
+ await spoke.memberSources.runs.trigger({
396
+ organizationId,
397
+ payload: { mode: "delta", updatedAfter: "2026-11-20T06:00" },
398
+ });
399
+ ```
321
400
 
322
401
  ### Vouchers
323
402
 
@@ -326,7 +405,7 @@ All routes below are relative to `/api/v1`. The promise client and the Effect cl
326
405
  | `client.vouchers.getOrganizationVoucherProvider({ params })` | `GET /organizations/:organizationId/voucher-provider` | `params.organizationId` | `OrganizationVoucherProvider \| null` |
327
406
  | `client.vouchers.upsertOrganizationVoucherProvider({ params, payload })` | `PUT /organizations/:organizationId/voucher-provider` | `params.organizationId`, `UpsertOrganizationVoucherProviderInput` | `OrganizationVoucherProvider` |
328
407
  | `client.vouchers.requestVoucherIssue({ params, payload })` | `POST /organizations/:organizationId/vouchers/issue` | `params.organizationId`, `RequestVoucherIssueInput` | `OrganizationVoucherCommand` |
329
- | `client.vouchers.listOrganizationVoucherCommands({ params, query })` | `GET /organizations/:organizationId/voucher-commands` | `params.organizationId`, optional `query.page`, `query.pageSize` | `PaginatedOrganizationVoucherCommands` |
408
+ | `client.vouchers.listOrganizationVoucherCommands({ params, query })` | `GET /organizations/:organizationId/voucher-commands` | `params.organizationId`, optional `query.page`, `query.pageSize`, [history filters](#history-filters), `kind` | `PaginatedOrganizationVoucherCommands` |
330
409
  | `client.vouchers.retryVoucherCommand({ params, payload })` | `POST /organizations/:organizationId/voucher-commands/:commandId/retry` | `params.organizationId`, `params.commandId`, `{ confirmedDuplicateRisk: true }` | `OrganizationVoucherCommand` |
331
410
  | `client.vouchers.pollOnsiteVoucherCommand({ params })` | `POST /organizations/:organizationId/onsite-voucher-commands/poll` | `params.organizationId` | `OnsiteVoucherCommand \| null` |
332
411
  | `client.vouchers.completeOnsiteVoucherCommand({ params, payload })` | `POST /organizations/:organizationId/onsite-voucher-commands/:commandId/complete` | `params.organizationId`, `params.commandId`, `CompleteOnsiteVoucherCommandInput` | `OrganizationVoucherCommand` |
@@ -423,10 +502,15 @@ const [capabilities, error] = await client.organizations.capabilities({ organiza
423
502
  ```
424
503
 
425
504
  The raw client exposes `client.organizations.getOrganizationCapabilities({ params: { organizationId } })`.
505
+ `client.organizations.get({ organizationId })` returns the organization itself, and
506
+ `client.members.summary({ organizationId })` returns member counts by status.
426
507
  The response contains `organizationId`, `points`, `vouchers`, `onsiteMemberLookup`,
427
- and `memberCreation`. Each capability has `supported`, `enabled`, and a nullable
508
+ `memberCreation`, and `memberCreateRequests`. Each capability has `supported`, `enabled`, and a nullable
428
509
  machine-readable `reason`. Member creation also has `mode`: `local` for Hub member
429
510
  creation, or `source_managed` for Odyssey Ensure Active Membership.
511
+ `memberCreateRequests` is enabled once the venue's Odyssey onsite agent advertises the
512
+ version 2 contract (`agent_upgrade_required` until then). Other venues report it as unsupported
513
+ and keep using their existing create path.
430
514
 
431
515
  `points` describes live provider points operations, and `vouchers` describes
432
516
  provider voucher issuing. `supported` means the configured integration supports
@@ -580,6 +664,31 @@ requested permissions as part of profile preparation before renewal. Demo creati
580
664
  supports the same object. Nexus creation and the permission update remain separate
581
665
  calls, not an atomic operation.
582
666
 
667
+ ## Member create requests (0.6.0)
668
+
669
+ `client.members.requestCreation` submits `POST /organizations/:organizationId/members/create-requests`.
670
+ Hub checks its own members and then the venue system before anything is created, so a person who is
671
+ already a member is never duplicated. The response has the same shape as Ensure Active Membership:
672
+ `settled`, `timedOut`, and an `ensure_active_membership` command whose `result.outcome` is one of:
673
+
674
+ | Outcome | Meaning |
675
+ | --- | --- |
676
+ | `created` | A new member was created. Use `result.memberId`. |
677
+ | `matched_active` | A verified existing member is current. Their rate and profile are unchanged; use the returned `membershipTypeId` and `membershipExpiry`. |
678
+ | `renewed_existing` | An expired existing member was renewed because `allowRenewalOnDuplicate` was `true`. |
679
+ | `renewal_required` | A verified existing member has expired. Nothing was changed. `memberId`, `membershipTypeId`, and the past `membershipExpiry` are included. |
680
+ | `ambiguous_identity_match`, `unsupported_source_status`, `indeterminate_membership_expiry`, `manual_review_required`, `failed` | Keep the application open; the venue must resolve the member. |
681
+
682
+ - `allowRenewalOnDuplicate` defaults to `false`. Send `true` only once renewal at the requested rate
683
+ has been authorized for this attempt, with a new `idempotencyKey`.
684
+ - The idempotency comparison covers the whole request, including the flag and `membershipTypeId`.
685
+ Replaying the same request returns the same command; changing it under the same key returns `409`.
686
+ - A pending command keeps its ID. Follow it with
687
+ `client.memberSources.commands.get({ organizationId, commandId })` or the signed member-source
688
+ command webhook; both report the same outcome.
689
+ - The route is available where `memberCreateRequests.enabled` is `true` in the organization
690
+ capabilities. Requests to a venue whose onsite agent has not been upgraded return `409`.
691
+
583
692
  ## Display-only offer catalogue (0.2.0)
584
693
 
585
694
  Use `client.offers.catalogue.list({ organizationId })` or