@connectedxm/admin 6.28.1 → 6.28.3

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/CLAUDE.md ADDED
@@ -0,0 +1,65 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Repository purpose
6
+
7
+ `@connectedxm/admin` is a TypeScript SDK for the ConnectedXM Admin API. It exposes two consumption modes from a single source: raw async functions (e.g. `GetAccount`, `CreateAccount`) and React Query hooks (e.g. `useGetAccount`, `useCreateAccount`). The same file defines both — the function calls the API, the hook wraps it with React Query.
8
+
9
+ A separate generated SDK (`@connectedxm/admin-sdk`, typescript-axios) is produced in `sdks/typescript/` from `openapi.json`. That output is generated, not hand-edited.
10
+
11
+ ## Common commands
12
+
13
+ - `npm run lint` — eslint over `src/**/*.ts`
14
+ - `npx tsc` — typecheck (the build uses tsup; tsc is configured with `noEmit`)
15
+ - `npm run build` — bundle to `dist/` via tsup (CJS + ESM + .d.ts)
16
+ - `npm test` — vitest (currently only a placeholder test in [tests/index.test.ts](tests/index.test.ts))
17
+ - `npm run exports` — regenerate every `index.ts` barrel under `src/` (see "Index files" below)
18
+ - `npm run generate` — parse `src/interfaces.ts`, `src/params.ts`, and every query/mutation file via the TypeScript AST to emit `openapi.json`
19
+ - `npm run generate:sdks` — runs OpenAPI Generator over `openapi.json` to produce the typescript-axios SDK in `sdks/typescript/`, then npm-links it
20
+ - `npm run release` — `lint && build` (run before publishing)
21
+
22
+ CI (`.github/workflows/`) runs `lint` + `tsc` + `build` on pushes to `staging`, regenerates `openapi.json` on PRs from `staging` → `main`, and on push to `main` publishes both `@connectedxm/admin` and the generated `@connectedxm/admin-sdk`. The `staging` → `main` PR is the release path; the `baseBranch` for changesets is `staging`.
23
+
24
+ ## Architecture
25
+
26
+ ### Three core wrappers
27
+
28
+ Every query/mutation file delegates auth, error handling, and React Query wiring to one of these helpers in [src/queries/](src/queries/) and [src/mutations/](src/mutations/):
29
+
30
+ - [useConnectedSingleQuery](src/queries/useConnectedSingleQuery.ts) — single GETs. Default `staleTime: 60s`. Translates 401/403/404/460/461 into `onNotAuthorized` / `onModuleForbidden` / `onNotFound` callbacks pulled from `ConnectedXMProvider` and stops retrying for those.
31
+ - [useConnectedInfiniteQuery](src/queries/useConnectedInfiniteQuery.ts) — page-numbered list endpoints. Default `pageSize: 25`. Appends `["SEARCH", search]` to the query key so the cache partitions by search term.
32
+ - [useConnectedCursorQuery](src/queries/useConnectedCursorQuery.ts) — cursor-paginated list endpoints; uses the `cursor` field on `ConnectedXMResponse` for pagination.
33
+ - [useConnectedMutation](src/mutations/useConnectedMutation.ts) — wraps `useMutation`; injects `adminApiParams` and `queryClient` into the mutation function so per-mutation files can invalidate/set query data after a successful response.
34
+
35
+ All four read auth (`apiUrl`, `organizationId`, `getToken`, `getExecuteAs`) from [ConnectedXMProvider](src/ConnectedXMProvider.tsx) via [useConnectedXM](src/hooks/useConnectedXM.ts) and pass it to the API function as `adminApiParams`. The provider also exposes `onNotAuthorized` / `onModuleForbidden` / `onNotFound` / `onMutationError` callbacks for cross-cutting error handling.
36
+
37
+ ### Conventional file shape
38
+
39
+ Each query file exports five things in this order: `*_QUERY_KEY`, `SET_*_QUERY_DATA`, the params interface (extending `SingleQueryParams` / `InfiniteQueryParams` / `CursorQueryParams`), the API function, and the hook. Each mutation file exports a params interface (extending `MutationParams`), the API function (which calls `queryClient.invalidateQueries` / setters on success), and the hook. See [useGetAccount.ts](src/queries/accounts/useGetAccount.ts), [useGetAccounts.ts](src/queries/accounts/useGetAccounts.ts), [useCreateAccount.ts](src/mutations/accounts/useCreateAccount.ts), and [useDeleteAccount.ts](src/mutations/accounts/useDeleteAccount.ts) as canonical examples — new files must mirror these exactly so the AST-based OpenAPI generator can pick them up.
40
+
41
+ The `generate` script's parser ([scripts/generate.ts](scripts/generate.ts)) is strict about this shape: it looks for one exported arrow function (skipping names starting with `use`, `SET_`, or ending in `_QUERY_KEY`) whose first parameter type extends `SingleQueryParams`, `InfiniteQueryParams`, or `MutationParams`, and a return type of `Promise<ConnectedXMResponse<T>>`. Deviations cause the file to be silently dropped from `openapi.json`.
42
+
43
+ ### Where types live
44
+
45
+ - [src/interfaces.ts](src/interfaces.ts) (~5k lines) — every domain type and enum. Response payload shapes.
46
+ - [src/params.ts](src/params.ts) (~3k lines) — every request body / `*Inputs` shape used as a mutation argument.
47
+ - [ConnectedXMResponse&lt;T&gt;](src/interfaces.ts) — the universal envelope: `{ status, message, data: T, count?, cursor? }`. Every API function returns `Promise<ConnectedXMResponse<...>>`.
48
+
49
+ The OpenAPI generator parses both files via the TypeScript AST and turns interfaces / type aliases / enums directly into `components.schemas`. It understands `extends`, `Omit<Base, "x">` in heritage clauses, and string-literal unions (which become enum schemas). Type aliases that aren't pure structural types may not round-trip cleanly — prefer interfaces.
50
+
51
+ ### Path aliases
52
+
53
+ `tsconfig.json` defines `@src/*` → `./src/*` and `@interfaces` → `./src/interfaces`. Files in this repo use both freely. tsup resolves them at build time.
54
+
55
+ ### Index files
56
+
57
+ Per [.cursor/rules/index-exports.mdc](.cursor/rules/index-exports.mdc): **do not hand-edit `index.ts` files.** Run `npm run exports` after adding or moving a file; the script ([scripts/exports.ts](scripts/exports.ts)) regenerates every barrel under `src/` by walking the directory tree.
58
+
59
+ ### OpenAPI tag hierarchy
60
+
61
+ [scripts/generate.ts](scripts/generate.ts) derives OpenAPI tags from the file's path under `queries/` or `mutations/` (e.g. `events/passes/useGetEventPasses.ts` → `Events::Passes`). Adding a new top-level resource folder will create a new tag; the script's `tagDescriptions` and `singularToPlural` maps near the bottom of the file may need updating so the tag normalizes and gets a description.
62
+
63
+ ## Conventions when adding endpoints
64
+
65
+ Cursor rules in [.cursor/rules/](.cursor/rules/) describe the workflow: check [src/params.ts](src/params.ts) and [src/interfaces.ts](src/interfaces.ts) first for existing types; only add new ones if the type doesn't already exist. Then create the file under `src/queries/<resource>/` or `src/mutations/<resource>/` following the canonical example, and run `npm run exports`.
package/dist/index.d.cts CHANGED
@@ -802,6 +802,7 @@ interface BaseCoupon {
802
802
  applyToPassType: boolean;
803
803
  applyToAddOns: boolean;
804
804
  applyToReservation: boolean;
805
+ applyToSessions: boolean;
805
806
  registrationId: string | null;
806
807
  registration: {
807
808
  accountId: string;
@@ -5185,6 +5186,7 @@ interface EventCouponCreateInputs {
5185
5186
  applyToPassType?: boolean;
5186
5187
  applyToAddOns?: boolean;
5187
5188
  applyToReservation?: boolean;
5189
+ applyToSessions?: boolean;
5188
5190
  }
5189
5191
  interface EventCouponUpdateInputs {
5190
5192
  code?: string | null;
@@ -5205,6 +5207,7 @@ interface EventCouponUpdateInputs {
5205
5207
  applyToPassType?: boolean;
5206
5208
  applyToAddOns?: boolean;
5207
5209
  applyToReservation?: boolean;
5210
+ applyToSessions?: boolean;
5208
5211
  }
5209
5212
  interface EventVariantCouponCreateInputs {
5210
5213
  quantity?: number;
package/dist/index.d.ts CHANGED
@@ -802,6 +802,7 @@ interface BaseCoupon {
802
802
  applyToPassType: boolean;
803
803
  applyToAddOns: boolean;
804
804
  applyToReservation: boolean;
805
+ applyToSessions: boolean;
805
806
  registrationId: string | null;
806
807
  registration: {
807
808
  accountId: string;
@@ -5185,6 +5186,7 @@ interface EventCouponCreateInputs {
5185
5186
  applyToPassType?: boolean;
5186
5187
  applyToAddOns?: boolean;
5187
5188
  applyToReservation?: boolean;
5189
+ applyToSessions?: boolean;
5188
5190
  }
5189
5191
  interface EventCouponUpdateInputs {
5190
5192
  code?: string | null;
@@ -5205,6 +5207,7 @@ interface EventCouponUpdateInputs {
5205
5207
  applyToPassType?: boolean;
5206
5208
  applyToAddOns?: boolean;
5207
5209
  applyToReservation?: boolean;
5210
+ applyToSessions?: boolean;
5208
5211
  }
5209
5212
  interface EventVariantCouponCreateInputs {
5210
5213
  quantity?: number;
package/openapi.json CHANGED
@@ -95650,6 +95650,9 @@
95650
95650
  "applyToReservation": {
95651
95651
  "type": "boolean"
95652
95652
  },
95653
+ "applyToSessions": {
95654
+ "type": "boolean"
95655
+ },
95653
95656
  "registrationId": {
95654
95657
  "type": "string",
95655
95658
  "nullable": true
@@ -95689,6 +95692,7 @@
95689
95692
  "applyToPassType",
95690
95693
  "applyToAddOns",
95691
95694
  "applyToReservation",
95695
+ "applyToSessions",
95692
95696
  "registrationId",
95693
95697
  "registration"
95694
95698
  ]
@@ -114187,6 +114191,9 @@
114187
114191
  },
114188
114192
  "applyToReservation": {
114189
114193
  "type": "boolean"
114194
+ },
114195
+ "applyToSessions": {
114196
+ "type": "boolean"
114190
114197
  }
114191
114198
  },
114192
114199
  "required": [
@@ -114312,6 +114319,9 @@
114312
114319
  },
114313
114320
  "applyToReservation": {
114314
114321
  "type": "boolean"
114322
+ },
114323
+ "applyToSessions": {
114324
+ "type": "boolean"
114315
114325
  }
114316
114326
  }
114317
114327
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/admin",
3
- "version": "6.28.1",
3
+ "version": "6.28.3",
4
4
  "description": "Admin API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "type": "module",