@connectedxm/admin 6.30.1 → 6.32.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/skills/applying-backend-diff/SKILL.md +128 -0
- package/.claude/skills/ship-to-prod/SKILL.md +240 -0
- package/dist/index.cjs +40 -0
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +36 -0
- package/openapi.json +99 -5
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: applying-backend-diff
|
|
3
|
+
description: Use when the user shares a backend PR, patch URL, or diff and asks to mirror, port, or add those API endpoint changes into the @connectedxm/admin-sdk TypeScript SDK (queries/mutations files under src/queries and src/mutations). Triggered by phrases like "update admin sdk with this diff", "mirror this endpoint", "add this to admin-sdk", "port these endpoints", or sharing a backend PR while in the admin-sdk repo or one of its worktrees.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Applying a Backend Diff to admin-sdk
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Backend adds or changes an admin API endpoint → admin-sdk needs a matching query or mutation file. The repo enforces a **strict file shape** because `scripts/generate.ts` walks the AST to emit `openapi.json`, and deviations are silently dropped from the generated OpenAPI spec — and therefore from the downstream `@connectedxm/admin-sdk` typescript-axios package.
|
|
11
|
+
|
|
12
|
+
The repo's [CLAUDE.md](CLAUDE.md) is the source of truth for conventions; this skill is the procedural recipe for going from a backend diff to a working, lint-clean SDK change.
|
|
13
|
+
|
|
14
|
+
## When to use
|
|
15
|
+
|
|
16
|
+
- User shares a backend PR URL (github.com, patch-diff.githubusercontent.com) and asks to update the SDK.
|
|
17
|
+
- User pastes a diff and asks to mirror endpoints in admin-sdk.
|
|
18
|
+
- User asks to "add this endpoint" to admin-sdk and provides backend code.
|
|
19
|
+
|
|
20
|
+
**Don't use** for:
|
|
21
|
+
- Hand-editing the generated `sdks/typescript/` package — it's regenerated from `openapi.json`.
|
|
22
|
+
- Changes that don't involve adding/modifying API endpoints (e.g., dependency bumps, internal refactors).
|
|
23
|
+
|
|
24
|
+
## Workflow
|
|
25
|
+
|
|
26
|
+
### 1. Get the diff
|
|
27
|
+
|
|
28
|
+
If the user gave a GitHub PR URL or a `patch-diff.githubusercontent.com` URL, fetch via `gh` CLI rather than WebFetch — patch-diff URLs redirect through auth and frequently 401:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
gh pr view <num> --repo <owner>/<repo> --json title,body,files,additions,deletions
|
|
32
|
+
gh api repos/<owner>/<repo>/pulls/<num>/files --jq '.[] | {path: .filename, patch: .patch}'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The PR description often names the pattern to mirror ("mirrors the existing X(...)") — read it before scanning code.
|
|
36
|
+
|
|
37
|
+
### 2. Extract, per endpoint
|
|
38
|
+
|
|
39
|
+
- HTTP method + URL path (e.g. `GET /payments/:paymentId/tax-metadata`)
|
|
40
|
+
- Path / query params and their types
|
|
41
|
+
- Request body shape (mutations only)
|
|
42
|
+
- Response `data` shape — including all branches (soft-skip messages, error messages, success payload)
|
|
43
|
+
|
|
44
|
+
### 3. Find the canonical example to mirror
|
|
45
|
+
|
|
46
|
+
Locate the parent resource directory by grepping for an existing endpoint on the same resource:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
grep -rln "/payments/" src/queries/ src/mutations/
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then mirror the closest-matching file:
|
|
53
|
+
|
|
54
|
+
| Endpoint type | Canonical example | Wrapper helper |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| Single GET | `src/queries/<resource>/useGetX.ts` | `useConnectedSingleQuery` |
|
|
57
|
+
| Paginated list | `src/queries/<resource>/useGetXs.ts` | `useConnectedInfiniteQuery` |
|
|
58
|
+
| Cursor list | (find an existing one in the repo) | `useConnectedCursorQuery` |
|
|
59
|
+
| Mutation | `src/mutations/<resource>/useUpdateX.ts` / `useCreateX.ts` / `useDeleteX.ts` | `useConnectedMutation` |
|
|
60
|
+
|
|
61
|
+
### 4. Reuse existing types
|
|
62
|
+
|
|
63
|
+
Before adding to `src/interfaces.ts` or `src/params.ts`, grep both files:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
grep -n "^export.*<TypeName>\b" src/interfaces.ts src/params.ts
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
For **genuinely dynamic** response blobs (e.g., raw third-party transaction data, free-form metadata), `Record<string, any>` is supported by the generator — see `scripts/generate.ts:570`, which maps it to an OpenAPI `object` with `additionalProperties`. Don't invent a misleading concrete interface just to "stay consistent."
|
|
70
|
+
|
|
71
|
+
### 5. Create the file with exact shape
|
|
72
|
+
|
|
73
|
+
The AST parser at `scripts/generate.ts` looks for one exported arrow function whose first parameter type extends `SingleQueryParams` / `InfiniteQueryParams` / `CursorQueryParams` / `MutationParams` and whose return type is `Promise<ConnectedXMResponse<T>>`. Get this wrong and the endpoint silently drops from `openapi.json`.
|
|
74
|
+
|
|
75
|
+
**Query file exports, in order:**
|
|
76
|
+
1. `*_QUERY_KEY` — array key, nested under parent resource's key (e.g. `[...PAYMENT_QUERY_KEY(id), "TAX_METADATA"]`)
|
|
77
|
+
2. `SET_*_QUERY_DATA` — cache setter
|
|
78
|
+
3. Params interface extending `SingleQueryParams` / `InfiniteQueryParams` / `CursorQueryParams`
|
|
79
|
+
4. `async` API function returning `Promise<ConnectedXMResponse<T>>`
|
|
80
|
+
5. `use*` hook calling the appropriate `useConnected*Query`
|
|
81
|
+
|
|
82
|
+
**Mutation file exports, in order:**
|
|
83
|
+
1. Params interface extending `MutationParams`
|
|
84
|
+
2. `async` API function (call `queryClient.invalidateQueries(...)` / setters after the request succeeds so consumers see fresh data)
|
|
85
|
+
3. `use*` hook calling `useConnectedMutation`
|
|
86
|
+
|
|
87
|
+
Path aliases `@src/*` and `@interfaces` are configured — use them.
|
|
88
|
+
|
|
89
|
+
### 6. Regenerate barrels
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm run exports
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Never hand-edit `index.ts` files — `.cursor/rules/index-exports.mdc` forbids it, and the script will overwrite manual edits.
|
|
96
|
+
|
|
97
|
+
### 7. Verify
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx tsc # typecheck (build uses tsup; tsc is noEmit)
|
|
101
|
+
npm run lint
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Both must pass clean before reporting completion.
|
|
105
|
+
|
|
106
|
+
### 8. Do NOT run `npm run generate`
|
|
107
|
+
|
|
108
|
+
CI regenerates `openapi.json` on the `staging` → `main` release PR per [.github/workflows/](.github/workflows/). Running it locally produces noisy unrelated diffs from other in-flight endpoints. Mention to the user that CI handles it.
|
|
109
|
+
|
|
110
|
+
## Common mistakes
|
|
111
|
+
|
|
112
|
+
| Mistake | Fix |
|
|
113
|
+
|---|---|
|
|
114
|
+
| File deviates from canonical shape → generator silently drops it | Diff your new file line-by-line against the closest existing file in the same directory |
|
|
115
|
+
| Adding a new type that already exists in `interfaces.ts` / `params.ts` | Grep both files first; reuse types verbatim |
|
|
116
|
+
| Hand-editing `index.ts` barrels | Run `npm run exports` |
|
|
117
|
+
| Inventing a misleading concrete interface for a dynamic provider blob | Use `Record<string, any>` — the generator handles it |
|
|
118
|
+
| Running `npm run generate` locally | Don't; CI does it on the release PR |
|
|
119
|
+
| Using WebFetch on `github.com/.../pull/N.diff` | Use `gh pr view` and `gh api repos/.../pulls/N/files` instead |
|
|
120
|
+
| `cd`-ing out of the current worktree | Stay in the worktree directory; use absolute paths |
|
|
121
|
+
|
|
122
|
+
## Red flags — stop and reconsider
|
|
123
|
+
|
|
124
|
+
- About to write a new interface without grepping for it first
|
|
125
|
+
- About to edit `src/<dir>/index.ts` by hand
|
|
126
|
+
- File shape doesn't match the canonical example (different export order, missing `SET_*_QUERY_DATA`, return type not `Promise<ConnectedXMResponse<T>>`)
|
|
127
|
+
- Skipping `npx tsc` or `npm run lint` because "the change is small"
|
|
128
|
+
- Running `npm run generate` to "make sure it works" — don't
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ship-to-prod
|
|
3
|
+
description: Open a release PR into `main` in this repo. Handles the full flow — resolves the source branch from the user's prompt or the current checkout (never assumes `staging`), gathers commits, pulls Linear ticket references from commit messages and the PRs that merged in, drafts a title and body that match the repo's PR template, picks reviewers, and (after the user confirms) creates the PR with `gh pr create`. Use this whenever the user says anything along the lines of "open a release PR", "ship to prod", "cut a release", "PR into main", "promote this branch", "ship this branch", "release this", or any variant of opening/preparing a PR that targets `main`. Prefer this skill over running `gh pr create` directly — the manual flow misses Linear references, the version-bump check, and reviewer conventions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Release PR into main
|
|
7
|
+
|
|
8
|
+
Use this when the user wants to open a release PR into `main` in the `connectedxm/admin-sdk` repo (npm package `@connectedxm/admin`). The head branch is whatever the user names in their prompt; if they don't name one, fall back to the currently checked-out branch — never assume `staging`. (Production is `main` here — the backend repo uses `prod`, but this SDK ships from `main`.)
|
|
9
|
+
|
|
10
|
+
Pushing to `main` triggers `publish.yml`, which publishes **two** packages to npm: `@connectedxm/admin` (the source SDK) and the generated `@connectedxm/admin-sdk` (typescript-axios output of `sdks/typescript/`, regenerated from `openapi.json`). There is no manual gate — merging this PR auto-publishes both packages.
|
|
11
|
+
|
|
12
|
+
## What you're producing
|
|
13
|
+
|
|
14
|
+
A draft PR (or, on confirmation, an actual PR via `gh pr create`) with:
|
|
15
|
+
|
|
16
|
+
1. **Base/head**: base `main`, head = the source branch resolved in step 1 — never invent a branch that the user didn't name and isn't the current checkout
|
|
17
|
+
2. **Title** that reflects what's in the diff (see "Writing the title")
|
|
18
|
+
3. **Body** matching `.github/pull_request_template.md`, with Linear refs harvested from commits AND from any sub-PRs they reference, plus the Semantic Versioning section ticked
|
|
19
|
+
4. **Reviewers** drawn from the repo's collaborators (excluding the PR author)
|
|
20
|
+
|
|
21
|
+
The user has asked to **always confirm before creating** the PR. Show the draft, wait for the go-ahead, then push (if needed) and call `gh pr create`.
|
|
22
|
+
|
|
23
|
+
## Workflow
|
|
24
|
+
|
|
25
|
+
### 1. Resolve the branch and sync
|
|
26
|
+
|
|
27
|
+
Pick the head branch for the release PR:
|
|
28
|
+
|
|
29
|
+
- If the user named a branch in their prompt, use that.
|
|
30
|
+
- Otherwise, use the currently checked-out branch (`git rev-parse --abbrev-ref HEAD`).
|
|
31
|
+
|
|
32
|
+
If the resolved branch is `main`, stop and ask the user which branch to ship — you can't PR `main` into `main`. Treat the resolved name as `<source>` everywhere below.
|
|
33
|
+
|
|
34
|
+
Then sync and check there's something to ship:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git fetch origin main <source>
|
|
38
|
+
git log --oneline origin/main..origin/<source>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If the log is empty, tell the user `<source>` has nothing ahead of `main` — there's no PR to open. Stop.
|
|
42
|
+
|
|
43
|
+
If `<source>` is behind `origin/<source>` locally, that's fine — the PR is opened against the remote refs, not your working copy. But mention it so the user knows.
|
|
44
|
+
|
|
45
|
+
If `<source>` exists only locally (not on `origin`), you'll need to push it before `gh pr create` will work. Note that for step 10; don't push yet.
|
|
46
|
+
|
|
47
|
+
If the branch already has an open PR against `main`, mention it (`gh pr list --head <source> --base main --state open`) and ask whether to add commits to that one or close it first. Don't open a duplicate.
|
|
48
|
+
|
|
49
|
+
### 2. Check the version bump (hard gate)
|
|
50
|
+
|
|
51
|
+
`version-check.yml` rejects any PR to `main` whose `package.json` version isn't strictly greater than main's, in plain `x.y.z` semver (no pre-release tags, no build metadata).
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
git show origin/main:package.json | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version"
|
|
55
|
+
git show origin/<source>:package.json | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Compare the two. If `<source>`'s version is **not** strictly greater than main's, stop and tell the user — they need to land a version bump on `<source>` first (recent precedent: `chore: bump version to X.Y.Z` commits) before this release PR can pass CI. Don't open the PR; don't bump for them.
|
|
59
|
+
|
|
60
|
+
If the bump looks right, note which kind it is (major/minor/patch) — you'll tick the matching box in the body's Semantic Versioning section.
|
|
61
|
+
|
|
62
|
+
### 3. Gather the commits
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git log origin/main..origin/<source> --pretty=format:'%H%x09%s%x09%b%x1e'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The `%x1e` (ASCII record separator) lets you split multi-line commit bodies cleanly. You want the subject AND the body — Linear references like `closes ENG-1901` usually live in the body, not the subject.
|
|
69
|
+
|
|
70
|
+
Skip merge commits whose subject starts with `Merge branch` (e.g. `Merge branch 'staging'`, `Merge branch 'main'`) — they're noise from local merges, not a unit of work.
|
|
71
|
+
|
|
72
|
+
### 4. Resolve sub-PRs referenced in commit subjects
|
|
73
|
+
|
|
74
|
+
Squash-merged PRs leave a trail like `feat(accounts): expose tier on account responses (#561)`. The `(#NNNN)` is a real PR with its own body that often holds the Linear reference. Pull each one:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
gh api repos/connectedxm/admin-sdk/pulls/<NNNN> --jq '{title, body}'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Do this for every `(#NNNN)` you find in the commit subjects in step 3. These bodies feed into the Linear extraction below — and sometimes into the PR description summary, when the squashed commit message is terse.
|
|
81
|
+
|
|
82
|
+
### 5. Extract Linear ticket references
|
|
83
|
+
|
|
84
|
+
Linear refs in this repo look like `[A-Z]{2,5}-\d+` — the dominant prefix is `ENG`, with `CXM` and others appearing occasionally. They appear as:
|
|
85
|
+
|
|
86
|
+
- `closes ENG-1234`
|
|
87
|
+
- `ref CXM-1901`
|
|
88
|
+
- bare `[ENG-1913]` in PR titles, e.g. `[ENG-1913] ci: gate auto-approve on AUTO_APPROVE_USERS allowlist`
|
|
89
|
+
|
|
90
|
+
**Important: don't confuse `(#561)` (a GitHub PR number) with `ENG-1234` (a Linear ticket).** Only the latter goes in the Linear Issues section.
|
|
91
|
+
|
|
92
|
+
**`linear-check.yml` is a hard gate.** It runs on every PR to `main` and requires at least one literal `ENG-\d+` somewhere in the PR body. If you can only find `CXM-…` refs, the workflow will fail — flag this to the user before opening so they can decide whether to add an `ENG-…` ref or update the workflow.
|
|
93
|
+
|
|
94
|
+
Collect refs from:
|
|
95
|
+
|
|
96
|
+
- the body of every commit in step 3
|
|
97
|
+
- the title and body of every sub-PR resolved in step 4
|
|
98
|
+
|
|
99
|
+
**Only include refs you actually saw in those sources for this PR.** Don't carry refs over from prior release PRs, recent conversation context, or memory of past releases — even if a ticket "feels relevant," it doesn't go in the list unless it's literally present in the commits/PRs you just gathered. Re-listing a ticket that was already shipped in a previous release is a real failure mode and confuses Linear's auto-close on merge.
|
|
100
|
+
|
|
101
|
+
Dedupe. Preserve the verb the user wrote when possible — if a sub-PR said `closes ENG-1901`, your output should say `closes ENG-1901`, not `ref`. Only fall back to `ref` if the original said `ref` or no verb at all.
|
|
102
|
+
|
|
103
|
+
### 6. Pick reviewers
|
|
104
|
+
|
|
105
|
+
There's no CODEOWNERS file in this repo. Build the candidate list at runtime:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
gh api repos/connectedxm/admin-sdk/collaborators \
|
|
109
|
+
--jq '[.[] | select(.permissions.push == true) | .login]'
|
|
110
|
+
gh api user --jq '.login' # you, the PR author — exclude from candidates
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Use the unfiltered `collaborators` endpoint — do **not** add `?affiliation=direct`, because that excludes org admins (e.g., `swiftoO` is an admin and won't appear with the direct filter). The unfiltered endpoint plus a `permissions.push == true` jq filter gives you the right candidate set.
|
|
114
|
+
|
|
115
|
+
Take everyone with push permission, drop the author. Default to requesting all of them. If the user said something specific about reviewers in their prompt ("just Tyler", "skip Spencer"), honor that and don't ask.
|
|
116
|
+
|
|
117
|
+
If only one candidate remains, just use them — don't bother the user about it.
|
|
118
|
+
|
|
119
|
+
### 7. Write the title
|
|
120
|
+
|
|
121
|
+
Look at what's actually in the diff before reaching for a template. The right title depends on the shape of the changes.
|
|
122
|
+
|
|
123
|
+
**One dominant change:** copy the conventional-commit subject from the main commit/PR. Example: `feat(accounts): expose tier and tags on account responses`.
|
|
124
|
+
|
|
125
|
+
**Several unrelated changes:** use a short generic title like `Release fixes` or a noun phrase that captures the theme. Look at recent release PRs (`gh pr list --base main --state merged --limit 10`) to match the house style — they oscillate between conventional-commit and short noun phrases, both are fine.
|
|
126
|
+
|
|
127
|
+
**Version-bump-only releases.** When the only thing in the diff is `chore: bump version to X.Y.Z`, a short title like `Release X.Y.Z` is fine.
|
|
128
|
+
|
|
129
|
+
Keep it under ~70 characters.
|
|
130
|
+
|
|
131
|
+
### 8. Write the body
|
|
132
|
+
|
|
133
|
+
Use this exact template — it matches `.github/pull_request_template.md`:
|
|
134
|
+
|
|
135
|
+
```markdown
|
|
136
|
+
### Description
|
|
137
|
+
|
|
138
|
+
<2-4 sentence summary of what's shipping. Group by theme if there are several unrelated changes — bullet list is fine when that's clearer than prose. Lead with SDK-visible changes (new hooks, new fields on response/params types, new error codes, OpenAPI schema changes), since this PR triggers an npm publish of both `@connectedxm/admin` and the generated `@connectedxm/admin-sdk`.>
|
|
139
|
+
|
|
140
|
+
### Linear Issues
|
|
141
|
+
|
|
142
|
+
- closes ENG-1234
|
|
143
|
+
- ref CXM-1901
|
|
144
|
+
<one line per ticket; use the verb the source used. Must include at least one ENG-#### or linear-check.yml will fail.>
|
|
145
|
+
|
|
146
|
+
### Testing
|
|
147
|
+
|
|
148
|
+
<Generated testing plan — see "Writing the testing plan" below. Do NOT use the template's default `I have manually tested the changes / New integration tests have been added` checkboxes; replace them with concrete steps grounded in the actual diff.>
|
|
149
|
+
|
|
150
|
+
### Semantic Versioning
|
|
151
|
+
|
|
152
|
+
Indicate the appropriate version bump for this PR:
|
|
153
|
+
|
|
154
|
+
- [ ] Breaking changes - Major version bump
|
|
155
|
+
- [ ] New features / improvements - Minor version bump
|
|
156
|
+
- [ ] Bug fixes - Patch version bump
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Tick the Semantic Versioning box** that matches the actual version delta you noted in step 2 (`X.Y.0` → minor, `X.Y.Z` patch bump only → patch, major version bump → major). If multiple things shipped, tick the highest-impact box (one breaking change makes the whole release major).
|
|
160
|
+
|
|
161
|
+
**Writing the testing plan.** Replace the template's default Testing checkboxes with a per-PR plan derived from what actually changed. The reviewer should be able to read the plan and know exactly what to verify before merging triggers the npm publish. Aim for 3–7 concrete checkbox items.
|
|
162
|
+
|
|
163
|
+
Walk the file diff (`git diff --name-only origin/main..origin/<source>`) and turn it into specific verification steps. This is a TypeScript SDK consumed by other apps (notably `admin-web`), so most verification happens via type-check + a smoke pass from a consumer. Note: this repo also generates a second SDK in `sdks/typescript/` from `openapi.json` via `npm run generate` / `npm run generate:sdks` — interface and param changes can affect what shows up there too.
|
|
164
|
+
|
|
165
|
+
- **Query files** (`src/queries/<resource>/use*.ts`) → "Confirm `useGet*` returns the new field/shape; spot-check the query key and that 401/403/404/460/461 routes through `onNotAuthorized` / `onNotFound` / `onModuleForbidden`."
|
|
166
|
+
- **Mutation files** (`src/mutations/<resource>/use*.ts`) → "Run the mutation from a consumer app and confirm the listed query keys invalidate / `SET_*_QUERY_DATA` updates as expected; on failure confirm `onMutationError` fires."
|
|
167
|
+
- **Interface changes** (`src/interfaces.ts`) → "Run `npm run lint` and `npx tsc` (configured `noEmit`); `npm pack` the SDK and install into `admin-web` — confirm the new fields surface in IDE completions and `tsc` is clean on the consumer side. Run `npm run generate` and spot-check `openapi.json` if the change should appear in the generated SDK."
|
|
168
|
+
- **Param/input shape changes** (`src/params.ts`) → "Confirm callers in `admin-web` still type-check against the new params; if a field became required, the consumer-side update needs to land before publish."
|
|
169
|
+
- **`ConnectedXMProvider` / context changes** (`src/ConnectedXMProvider.tsx`, `src/hooks/useConnectedXM.ts`) → "Mount a consumer with the updated provider and confirm `adminApiParams`, `organizationId`, `getToken`, `getExecuteAs`, and the `onNotAuthorized` / `onModuleForbidden` / `onNotFound` / `onMutationError` callbacks still wire through."
|
|
170
|
+
- **`AdminAPI` / axios changes** (`src/AdminAPI.ts`) → "Confirm `GetAdminAPI(params)` returns an axios instance with the expected `baseURL`, `organization`, `authorization`, `api-key`, and `executeAs` headers (when set)."
|
|
171
|
+
- **OpenAPI generator changes** (`scripts/generate.ts`, `scripts/generate-sdks.ts`) → "Run `npm run generate` and inspect `openapi.json` for the expected diff; if the SDK output is in scope, run `npm run generate:sdks` and confirm `sdks/typescript/` regenerates cleanly. Note: the PR triggers `generate-openapi.yml`, which re-runs the generator on the PR branch."
|
|
172
|
+
- **Index/barrel changes** (`src/index.ts`, per-folder `index.ts`) → "If files were added/moved, confirm `npm run exports` was run (per `.cursor/rules/index-exports.mdc` — don't hand-edit). Then `npm run build` and inspect `dist/index.d.ts` to confirm the new symbols are exported."
|
|
173
|
+
- **CI workflow changes** (`.github/workflows/`) → "Confirm `tests.yml`, `linear-check.yml`, `version-check.yml`, `publish.yml`, `approve.yml`, or `generate-openapi.yml` pass on this branch."
|
|
174
|
+
- **Publish gate** → "After merge, confirm `publish.yml` runs cleanly on `main` and both `@connectedxm/admin@X.Y.Z` and the generated `@connectedxm/admin-sdk@X.Y.Z` are live on npm."
|
|
175
|
+
|
|
176
|
+
Group related items where it tightens the plan. If a single domain dominates the diff (e.g., the whole PR is account/auth polish), it's fine to have all 3–7 items in that domain. If you genuinely cannot derive a plan from the diff (rare — usually means something's wrong with how you read the commits), fall back to the original checkbox pair, but flag this to the user when presenting the draft.
|
|
177
|
+
|
|
178
|
+
Format as a markdown checklist:
|
|
179
|
+
|
|
180
|
+
```markdown
|
|
181
|
+
### Testing
|
|
182
|
+
|
|
183
|
+
- [ ] Run `npm run lint` and `npm run build` and confirm both pass cleanly.
|
|
184
|
+
- [ ] `npm pack` the SDK and install into an `admin-web` checkout — confirm `tsc` passes on the consumer with the new types.
|
|
185
|
+
- [ ] On a staging consumer, exercise the affected mutation/query and confirm the new fields land in the cache.
|
|
186
|
+
- [ ] Run `npm run generate` and confirm `openapi.json` reflects the interface/param diff (CI's `generate-openapi.yml` will also run this on the PR branch).
|
|
187
|
+
- [ ] After merge, confirm `publish.yml` succeeds and both `@connectedxm/admin@X.Y.Z` and `@connectedxm/admin-sdk@X.Y.Z` appear on npm.
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
If there are zero Linear references, omit the bullet list and write `- (none)` under the Linear Issues heading rather than deleting the section — keeps the template recognizable. (But: `linear-check.yml` requires at least one `ENG-####` in the body, so this case will fail CI. Flag it to the user before opening.)
|
|
191
|
+
|
|
192
|
+
### 9. Show the draft and wait
|
|
193
|
+
|
|
194
|
+
Print the title, body, reviewer list, the version delta from step 2, AND the push state from step 1 back to the user, clearly labelled. If a push is needed (`<source>` not on origin or local commits ahead of `origin/<source>`), state explicitly that creating the PR will push first. Ask whether to proceed, modify, or cancel. Don't run `git push` or `gh pr create` until they've said yes.
|
|
195
|
+
|
|
196
|
+
The reason for confirming: the title and body are interpretive — you're summarizing several commits' worth of work. The user knows things you don't (which change is the headline feature, which is incidental cleanup, whether the Semantic Versioning box is right, whether something is already covered by another ticket). Five seconds of their attention up front beats editing the PR after the fact — especially since merging this PR triggers an npm publish.
|
|
197
|
+
|
|
198
|
+
### 10. Push the branch (if needed) and create the PR
|
|
199
|
+
|
|
200
|
+
After confirmation:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Only if step 1 said the branch needed pushing:
|
|
204
|
+
git push -u origin <source> # first push
|
|
205
|
+
# OR
|
|
206
|
+
git push # subsequent push
|
|
207
|
+
|
|
208
|
+
# Then:
|
|
209
|
+
gh pr create \
|
|
210
|
+
--base main \
|
|
211
|
+
--head <source> \
|
|
212
|
+
--title "<title>" \
|
|
213
|
+
--reviewer "<comma,separated,logins>" \
|
|
214
|
+
--body "$(cat <<'EOF'
|
|
215
|
+
<body here>
|
|
216
|
+
EOF
|
|
217
|
+
)"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Return the PR URL from the command output so the user can click straight to it.
|
|
221
|
+
|
|
222
|
+
## Things to watch out for
|
|
223
|
+
|
|
224
|
+
- **`main`, not `prod`.** This repo's production branch is `main` (the backend repo uses `prod`). Don't paste backend instincts here — `gh pr create --base prod` will fail.
|
|
225
|
+
- **Don't assume `staging`.** Most feature work now branches off `main` and PRs directly back into `main`. Resolve the head branch from the user's prompt or the current checkout — never default to `staging`.
|
|
226
|
+
- **Merging this PR publishes two packages to npm.** `publish.yml` runs on push to `main` and publishes both `@connectedxm/admin` (the source SDK) and `@connectedxm/admin-sdk` (the typescript-axios output regenerated from `openapi.json`). There is no manual gate. Take the testing plan seriously.
|
|
227
|
+
- **The version bump is a hard gate.** If `<source>`'s `package.json` version isn't strictly greater than main's in plain `x.y.z` semver, `version-check.yml` will fail. Don't open the PR until the bump is on the source branch.
|
|
228
|
+
- **`linear-check.yml` requires `ENG-####` in the body.** A `CXM-####`-only body will fail CI. If you only found `CXM` refs, surface that to the user before opening.
|
|
229
|
+
- **`generate-openapi.yml` runs on PRs to `main`.** It regenerates `openapi.json` from the source. If the PR branch's `openapi.json` is stale relative to the source, expect this workflow to push a regen commit or fail. Don't be surprised by the extra activity on the PR.
|
|
230
|
+
- **Don't paste `<!-- CURSOR_SUMMARY -->` blocks** from sub-PR bodies into the new PR body. Those are auto-generated by the Cursor Bugbot reviewer and re-including them looks weird.
|
|
231
|
+
- **Don't include the HTML comment placeholders** from the PR template (`<!-- A brief description -->`) in your output — replace them with real content.
|
|
232
|
+
- **Keep the Semantic Versioning section.** Don't drop it from the body — the template explicitly includes it. Tick the box that matches the actual version bump.
|
|
233
|
+
- **`closes` vs `ref`**: `closes` auto-closes the Linear ticket on merge to `main`. `ref` just links it. Preserve whichever the source commit/PR used. When in doubt, `ref` is the safer default — it doesn't change ticket state.
|
|
234
|
+
- **Bot reviews are not human reviews.** Don't infer reviewer preferences from `github-actions` or `cursor` reviews on past PRs — those are automated. Look at human reviewers (`authorAssociation: MEMBER`) only.
|
|
235
|
+
- **The author isn't a reviewer.** GitHub will reject `--reviewer <self>`. Always exclude `gh api user --jq '.login'` from the list.
|
|
236
|
+
- **Don't push without confirmation.** Pushing exposes work to the team and triggers CI. Bundle it with PR creation behind the user's go-ahead.
|
|
237
|
+
|
|
238
|
+
## Why this exists
|
|
239
|
+
|
|
240
|
+
Opening these PRs by hand consistently misses Linear references buried in sub-PR bodies, drops the Semantic Versioning section, and either skips the version-bump check or has to back-patch it after CI fails. Because merging this PR auto-publishes two npm packages, the cost of a botched release is higher than for an app deploy — there's no easy "revert" once a version is live. Hitting the gh API once per sub-PR, comparing versions up front, and templating the body is mechanical work that's easy to get wrong when done manually but easy to get right in a script-shaped flow.
|
package/dist/index.cjs
CHANGED
|
@@ -1212,6 +1212,7 @@ __export(index_exports, {
|
|
|
1212
1212
|
GetOrganizationWebhook: () => GetOrganizationWebhook,
|
|
1213
1213
|
GetOrganizationWebhooks: () => GetOrganizationWebhooks,
|
|
1214
1214
|
GetPayment: () => GetPayment,
|
|
1215
|
+
GetPaymentTaxMetadata: () => GetPaymentTaxMetadata,
|
|
1215
1216
|
GetPayments: () => GetPayments,
|
|
1216
1217
|
GetPreferences: () => GetPreferences,
|
|
1217
1218
|
GetPreset: () => GetPreset,
|
|
@@ -1426,6 +1427,7 @@ __export(index_exports, {
|
|
|
1426
1427
|
OrganizationTriggerType: () => OrganizationTriggerType,
|
|
1427
1428
|
PAYMENTS_QUERY_KEY: () => PAYMENTS_QUERY_KEY,
|
|
1428
1429
|
PAYMENT_QUERY_KEY: () => PAYMENT_QUERY_KEY,
|
|
1430
|
+
PAYMENT_TAX_METADATA_QUERY_KEY: () => PAYMENT_TAX_METADATA_QUERY_KEY,
|
|
1429
1431
|
PREFERENCES_QUERY_KEY: () => PREFERENCES_QUERY_KEY,
|
|
1430
1432
|
PRESETS_QUERY_KEY: () => PRESETS_QUERY_KEY,
|
|
1431
1433
|
PRESET_QUERY_KEY: () => PRESET_QUERY_KEY,
|
|
@@ -1981,6 +1983,7 @@ __export(index_exports, {
|
|
|
1981
1983
|
SET_PASS_TYPE_COUPONS_QUERY_DATA: () => SET_PASS_TYPE_COUPONS_QUERY_DATA,
|
|
1982
1984
|
SET_PAYMENTS_QUERY_DATA: () => SET_PAYMENTS_QUERY_DATA,
|
|
1983
1985
|
SET_PAYMENT_QUERY_DATA: () => SET_PAYMENT_QUERY_DATA,
|
|
1986
|
+
SET_PAYMENT_TAX_METADATA_QUERY_DATA: () => SET_PAYMENT_TAX_METADATA_QUERY_DATA,
|
|
1984
1987
|
SET_PREFERENCES_QUERY_DATA: () => SET_PREFERENCES_QUERY_DATA,
|
|
1985
1988
|
SET_PRESETS_QUERY_DATA: () => SET_PRESETS_QUERY_DATA,
|
|
1986
1989
|
SET_PRESET_QUERY_DATA: () => SET_PRESET_QUERY_DATA,
|
|
@@ -3180,6 +3183,7 @@ __export(index_exports, {
|
|
|
3180
3183
|
useGetOrganizationWebhook: () => useGetOrganizationWebhook,
|
|
3181
3184
|
useGetOrganizationWebhooks: () => useGetOrganizationWebhooks,
|
|
3182
3185
|
useGetPayment: () => useGetPayment,
|
|
3186
|
+
useGetPaymentTaxMetadata: () => useGetPaymentTaxMetadata,
|
|
3183
3187
|
useGetPayments: () => useGetPayments,
|
|
3184
3188
|
useGetPreferences: () => useGetPreferences,
|
|
3185
3189
|
useGetPreset: () => useGetPreset,
|
|
@@ -20859,6 +20863,38 @@ var useGetPayment = (paymentId = "", options = {}) => {
|
|
|
20859
20863
|
);
|
|
20860
20864
|
};
|
|
20861
20865
|
|
|
20866
|
+
// src/queries/organization/payment/useGetPaymentTaxMetadata.ts
|
|
20867
|
+
var PAYMENT_TAX_METADATA_QUERY_KEY = (paymentId) => [
|
|
20868
|
+
...PAYMENT_QUERY_KEY(paymentId),
|
|
20869
|
+
"TAX_METADATA"
|
|
20870
|
+
];
|
|
20871
|
+
var SET_PAYMENT_TAX_METADATA_QUERY_DATA = (client, keyParams, response) => {
|
|
20872
|
+
client.setQueryData(PAYMENT_TAX_METADATA_QUERY_KEY(...keyParams), response);
|
|
20873
|
+
};
|
|
20874
|
+
var GetPaymentTaxMetadata = async ({
|
|
20875
|
+
paymentId,
|
|
20876
|
+
adminApiParams
|
|
20877
|
+
}) => {
|
|
20878
|
+
const adminApi = await GetAdminAPI(adminApiParams);
|
|
20879
|
+
const { data } = await adminApi.get(
|
|
20880
|
+
`/payments/${paymentId}/tax-metadata`
|
|
20881
|
+
);
|
|
20882
|
+
return data;
|
|
20883
|
+
};
|
|
20884
|
+
var useGetPaymentTaxMetadata = (paymentId = "", options = {}) => {
|
|
20885
|
+
return useConnectedSingleQuery(
|
|
20886
|
+
PAYMENT_TAX_METADATA_QUERY_KEY(paymentId),
|
|
20887
|
+
(params) => GetPaymentTaxMetadata({
|
|
20888
|
+
paymentId,
|
|
20889
|
+
...params
|
|
20890
|
+
}),
|
|
20891
|
+
{
|
|
20892
|
+
...options,
|
|
20893
|
+
enabled: !!paymentId && (options.enabled ?? true)
|
|
20894
|
+
}
|
|
20895
|
+
);
|
|
20896
|
+
};
|
|
20897
|
+
|
|
20862
20898
|
// src/queries/organization/sideEffects/useGetOrganizationSideEffects.ts
|
|
20863
20899
|
var ORGANIZATION_SIDE_EFFECTS_QUERY_KEY = (triggerType, triggerId) => {
|
|
20864
20900
|
const keys = [...ORGANIZATION_QUERY_KEY(), "SIDE_EFFECTS"];
|
|
@@ -44695,6 +44731,7 @@ var useUpdateTier = (options = {}) => {
|
|
|
44695
44731
|
GetOrganizationWebhook,
|
|
44696
44732
|
GetOrganizationWebhooks,
|
|
44697
44733
|
GetPayment,
|
|
44734
|
+
GetPaymentTaxMetadata,
|
|
44698
44735
|
GetPayments,
|
|
44699
44736
|
GetPreferences,
|
|
44700
44737
|
GetPreset,
|
|
@@ -44909,6 +44946,7 @@ var useUpdateTier = (options = {}) => {
|
|
|
44909
44946
|
OrganizationTriggerType,
|
|
44910
44947
|
PAYMENTS_QUERY_KEY,
|
|
44911
44948
|
PAYMENT_QUERY_KEY,
|
|
44949
|
+
PAYMENT_TAX_METADATA_QUERY_KEY,
|
|
44912
44950
|
PREFERENCES_QUERY_KEY,
|
|
44913
44951
|
PRESETS_QUERY_KEY,
|
|
44914
44952
|
PRESET_QUERY_KEY,
|
|
@@ -45464,6 +45502,7 @@ var useUpdateTier = (options = {}) => {
|
|
|
45464
45502
|
SET_PASS_TYPE_COUPONS_QUERY_DATA,
|
|
45465
45503
|
SET_PAYMENTS_QUERY_DATA,
|
|
45466
45504
|
SET_PAYMENT_QUERY_DATA,
|
|
45505
|
+
SET_PAYMENT_TAX_METADATA_QUERY_DATA,
|
|
45467
45506
|
SET_PREFERENCES_QUERY_DATA,
|
|
45468
45507
|
SET_PRESETS_QUERY_DATA,
|
|
45469
45508
|
SET_PRESET_QUERY_DATA,
|
|
@@ -46663,6 +46702,7 @@ var useUpdateTier = (options = {}) => {
|
|
|
46663
46702
|
useGetOrganizationWebhook,
|
|
46664
46703
|
useGetOrganizationWebhooks,
|
|
46665
46704
|
useGetPayment,
|
|
46705
|
+
useGetPaymentTaxMetadata,
|
|
46666
46706
|
useGetPayments,
|
|
46667
46707
|
useGetPreferences,
|
|
46668
46708
|
useGetPreset,
|