@connectedxm/admin 6.28.2 → 6.29.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/CLAUDE.md +65 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/openapi.json +7 -0
- package/package.json +1 -1
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<T>](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
|
@@ -1657,6 +1657,7 @@ interface Organization extends BaseOrganization {
|
|
|
1657
1657
|
maxVideoMins: number | null;
|
|
1658
1658
|
locales: string[];
|
|
1659
1659
|
inviteOnly: boolean;
|
|
1660
|
+
autoTranslate: boolean;
|
|
1660
1661
|
googleTagManagerId: string | null;
|
|
1661
1662
|
options: object | null;
|
|
1662
1663
|
}
|
|
@@ -6000,6 +6001,7 @@ interface OrganizationUpdateInputs {
|
|
|
6000
6001
|
locale?: string | null;
|
|
6001
6002
|
locales?: string[] | null;
|
|
6002
6003
|
inviteOnly?: boolean;
|
|
6004
|
+
autoTranslate?: boolean;
|
|
6003
6005
|
googleTagManagerId?: string | null;
|
|
6004
6006
|
options?: object | null;
|
|
6005
6007
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1657,6 +1657,7 @@ interface Organization extends BaseOrganization {
|
|
|
1657
1657
|
maxVideoMins: number | null;
|
|
1658
1658
|
locales: string[];
|
|
1659
1659
|
inviteOnly: boolean;
|
|
1660
|
+
autoTranslate: boolean;
|
|
1660
1661
|
googleTagManagerId: string | null;
|
|
1661
1662
|
options: object | null;
|
|
1662
1663
|
}
|
|
@@ -6000,6 +6001,7 @@ interface OrganizationUpdateInputs {
|
|
|
6000
6001
|
locale?: string | null;
|
|
6001
6002
|
locales?: string[] | null;
|
|
6002
6003
|
inviteOnly?: boolean;
|
|
6004
|
+
autoTranslate?: boolean;
|
|
6003
6005
|
googleTagManagerId?: string | null;
|
|
6004
6006
|
options?: object | null;
|
|
6005
6007
|
}
|
package/openapi.json
CHANGED
|
@@ -99190,6 +99190,9 @@
|
|
|
99190
99190
|
"inviteOnly": {
|
|
99191
99191
|
"type": "boolean"
|
|
99192
99192
|
},
|
|
99193
|
+
"autoTranslate": {
|
|
99194
|
+
"type": "boolean"
|
|
99195
|
+
},
|
|
99193
99196
|
"googleTagManagerId": {
|
|
99194
99197
|
"type": "string",
|
|
99195
99198
|
"nullable": true
|
|
@@ -99259,6 +99262,7 @@
|
|
|
99259
99262
|
"maxVideoMins",
|
|
99260
99263
|
"locales",
|
|
99261
99264
|
"inviteOnly",
|
|
99265
|
+
"autoTranslate",
|
|
99262
99266
|
"googleTagManagerId",
|
|
99263
99267
|
"options"
|
|
99264
99268
|
]
|
|
@@ -117559,6 +117563,9 @@
|
|
|
117559
117563
|
"inviteOnly": {
|
|
117560
117564
|
"type": "boolean"
|
|
117561
117565
|
},
|
|
117566
|
+
"autoTranslate": {
|
|
117567
|
+
"type": "boolean"
|
|
117568
|
+
},
|
|
117562
117569
|
"googleTagManagerId": {
|
|
117563
117570
|
"type": "string",
|
|
117564
117571
|
"nullable": true
|