feat: typed customFields generics + optional companyId#22
Merged
Conversation
- @typescript/native-preview 20260405.1 -> 20260505.1 - AGENTS.md regenerated by `vp config` after vite-plus bump - ky 2.x renamed `prefixUrl` to `prefix` — update transport options accordingly Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Token validation previously required `clientId + companyId` together for client tokens. `companyId` is now fully optional alongside `clientId`: - TokenPayloadSchema refine: requires only `internalUserId` or `clientId` - AssemblyToken.isClientUser: checks only `clientId` - ensureIsClient error message updated - Tests adjusted: client token with only `clientId` is accepted; flipped the rejection case to "companyId-only without clientId" instead `AssemblyKit` already delegates to `AssemblyToken` for these checks, so the relaxation flows through automatically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add optional generic parameters to `AssemblyKit` / `createAssemblyKit` so
consumers can type the `customFields` shape returned from clients and
companies endpoints:
```ts
const kit = createAssemblyKit<{ roles: string[] }>({ apiKey, workspaceId });
const c = await kit.clients.retrieve("id");
// ^? customFields: { roles: string[] } | null | undefined
```
- `AssemblyKit<TClientCustomFields, TCompanyCustomFields = TClientCustomFields>`
with both defaulting to `Record<string, unknown>` (fully backward compatible)
- `ClientsResource<T>` / `CompaniesResource<T>` thread the generic through
`list`, `listAll`, `retrieve`, `create`, `update`
- `ClientsResponse<T>` / `CompaniesResponse<T>` are now generic
- Runtime Zod schemas unchanged — generics only narrow at type level
- Consumer-facing CLAUDE.md documents the new pattern
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
customFieldsgenerics:createAssemblyKit/AssemblyKitnow accept optionalTClientCustomFieldsandTCompanyCustomFieldsgenerics that flow throughkit.clients.*andkit.companies.*. Defaults toRecord<string, unknown>so existing callers are unaffected.companyIdin tokens: client tokens no longer requirecompanyId. Schema refine now requires onlyinternalUserIdorclientId;isClientUserandensureIsClientupdated accordingly.@typescript/native-previewto latest dev build; transport updated forky2.xprefixUrl→prefixrename.AGENTS.mdregenerated byvp configpost-bump.Usage (new generic)
Both generics are optional — passing none keeps the previous
Record<string, unknown>behavior.Test plan
bun run checkpasses (lint, format, types —isolatedDeclarationsenabled)bun run test— all 172 existing tests pass; added a positive case forclientId-only client tokens and flipped the negative case tocompanyId-onlykit.clients.retrieve()infers the suppliedcustomFieldsshape🤖 Generated with Claude Code