@tai42/api-client 19.2.1 → 20.0.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.
Files changed (45) hide show
  1. package/dist/client/auth-client.d.ts +51 -0
  2. package/dist/client/auth-client.d.ts.map +1 -1
  3. package/dist/client/auth-client.js +16 -0
  4. package/dist/client/auth-client.js.map +1 -1
  5. package/dist/client/conversations-client.d.ts +4 -4
  6. package/dist/client/index.d.ts +51 -12
  7. package/dist/client/index.d.ts.map +1 -1
  8. package/dist/client/interactions-client.d.ts +10 -0
  9. package/dist/client/interactions-client.d.ts.map +1 -1
  10. package/dist/client/interactions-client.js +11 -0
  11. package/dist/client/interactions-client.js.map +1 -1
  12. package/dist/client/notifications-client.d.ts +1 -8
  13. package/dist/client/notifications-client.d.ts.map +1 -1
  14. package/dist/generated/served-schemas.d.ts +1 -45
  15. package/dist/generated/served-schemas.d.ts.map +1 -1
  16. package/dist/generated/served-schemas.js +1 -27
  17. package/dist/generated/served-schemas.js.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/schemas/conversations.d.ts +7 -7
  22. package/dist/schemas/index.d.ts +1 -0
  23. package/dist/schemas/index.d.ts.map +1 -1
  24. package/dist/schemas/index.js +1 -0
  25. package/dist/schemas/index.js.map +1 -1
  26. package/dist/schemas/interactions.d.ts +137 -4
  27. package/dist/schemas/interactions.d.ts.map +1 -1
  28. package/dist/schemas/interactions.js +76 -0
  29. package/dist/schemas/interactions.js.map +1 -1
  30. package/dist/schemas/members.d.ts +154 -0
  31. package/dist/schemas/members.d.ts.map +1 -0
  32. package/dist/schemas/members.js +105 -0
  33. package/dist/schemas/members.js.map +1 -0
  34. package/dist/schemas/notifications.d.ts +2 -28
  35. package/dist/schemas/notifications.d.ts.map +1 -1
  36. package/dist/schemas/served.d.ts +1 -14
  37. package/dist/schemas/served.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/client/auth-client.ts +35 -0
  40. package/src/client/interactions-client.ts +12 -0
  41. package/src/generated/served-schemas.ts +1 -45
  42. package/src/index.ts +15 -0
  43. package/src/schemas/index.ts +1 -0
  44. package/src/schemas/interactions.ts +90 -0
  45. package/src/schemas/members.ts +121 -0
@@ -91,14 +91,51 @@ export const formData = z.object({
91
91
  });
92
92
  export type FormData = z.infer<typeof formData>;
93
93
 
94
+ /** The kind of an ordered display block a page may carry alongside its input fields. */
95
+ export const displayBlockKind = z.enum(['heading', 'body', 'image']);
96
+ export type DisplayBlockKind = z.infer<typeof displayBlockKind>;
97
+
98
+ /**
99
+ * One ordered, display-only block on a form page (never an input): a `heading` or
100
+ * `body` text block, or an `image`. `text` carries a heading/body's words; `src`/`alt`
101
+ * carry an image's source and alt text. An optional `slot` names a data key whose value
102
+ * the block shows in place of static `text` — filled from `format_payload.data` at send
103
+ * and/or by a reaction's `display` update (so a computed total is a display slot, not a
104
+ * special case). Every text field is `.nullish()` (absent OR explicit `null` both parse
105
+ * to absent) so a block that omits a key — or sends an explicit `null` — is not a
106
+ * whole-page parse failure. Applied per block by the preview (safeParsed via its page),
107
+ * so a malformed block is a loud notice, never silent.
108
+ */
109
+ export const displayBlock = z.object({
110
+ kind: displayBlockKind,
111
+ text: z.string().nullish(),
112
+ src: z.string().nullish(),
113
+ alt: z.string().nullish(),
114
+ slot: z.string().nullish(),
115
+ });
116
+ export type DisplayBlock = z.infer<typeof displayBlock>;
117
+
118
+ /** A page's role: an ordinary `input` page (default) or a terminal `review` summary. */
119
+ export const formPageKind = z.enum(['input', 'review']);
120
+ export type FormPageKind = z.infer<typeof formPageKind>;
121
+
94
122
  /**
95
123
  * One page of a stepped `form`: a `title` and the ordered top-level property names it
96
124
  * groups. `format_payload.pages` is the ordered list of these; absent = one page. The
97
125
  * form preview safeParses the list, so a malformed page is a loud notice, never silent.
126
+ *
127
+ * `display` is the ordered list of display-only blocks the page shows alongside (or
128
+ * instead of, for a review page) its input fields; it defaults to empty, so a page that
129
+ * carries none renders exactly as before. `kind` marks a `review` page — a terminal
130
+ * summary step that shows the readback of entered values and the confirm/submit footer
131
+ * and carries no new input fields; it defaults to `input`. Both are additive: an older
132
+ * payload ({title, fields}) parses unchanged.
98
133
  */
99
134
  export const formPage = z.object({
100
135
  title: z.string(),
101
136
  fields: z.array(z.string()),
137
+ display: z.array(displayBlock).default([]),
138
+ kind: formPageKind.default('input'),
102
139
  });
103
140
  export type FormPage = z.infer<typeof formPage>;
104
141
 
@@ -106,6 +143,59 @@ export type FormPage = z.infer<typeof formPage>;
106
143
  export const formPages = z.array(formPage);
107
144
  export type FormPages = z.infer<typeof formPages>;
108
145
 
146
+ /**
147
+ * When a `form` reacts while it is open (`format_payload.reactions`): the plain,
148
+ * renderer-readable description of WHEN the form calls its reaction handler. Absent ⇒ a
149
+ * static (non-reacting) form, exactly as before. `field_changed` names the fields whose
150
+ * change triggers a reaction; `page_advanced` names the pages (by title) whose advance
151
+ * triggers one; `submitted` is true when the submission is checked by a reaction before
152
+ * acceptance; `choices` names the fields whose CHOICE LISTS a reaction may replace while
153
+ * the form is open (for such a field the send-time option list is advisory — the consumer
154
+ * owns membership at the `submitted` event). Every member defaults to empty/false so a
155
+ * partial declaration parses; a malformed block is a loud notice via the preview.
156
+ */
157
+ export const formReactions = z.object({
158
+ field_changed: z.array(z.string()).default([]),
159
+ page_advanced: z.array(z.string()).default([]),
160
+ submitted: z.boolean().default(false),
161
+ choices: z.array(z.string()).default([]),
162
+ });
163
+ export type FormReactions = z.infer<typeof formReactions>;
164
+
165
+ /**
166
+ * The form update a reaction door returns (`POST /api/interactions/{id}/react`): the
167
+ * same kind of data a form is sent with, applied to the open form. `values` sets field
168
+ * values; `options` replaces the per-send choice list of option-bearing fields; `errors`
169
+ * shows per-field messages (keyed by field name); `display` fills display slots (keyed by
170
+ * slot name) — a computed total among them. Every member defaults to empty, so a reaction
171
+ * that touches only one of them returns only that one. The door response is safeParsed, so
172
+ * a malformed update surfaces loudly rather than applying a half-understood change.
173
+ */
174
+ export const formUpdate = z.object({
175
+ values: z.record(z.string(), z.unknown()).default({}),
176
+ options: z.record(z.string(), z.array(formOption)).default({}),
177
+ errors: z.record(z.string(), z.string()).default({}),
178
+ display: z.record(z.string(), z.unknown()).default({}),
179
+ });
180
+ export type FormUpdate = z.infer<typeof formUpdate>;
181
+
182
+ /**
183
+ * The event a reaction round-trip reports to the door: `kind` is which of the three
184
+ * declared events fired, `field` names the changed field for a `field_changed` event, and
185
+ * `page` names the advanced-from page (by title) for a `page_advanced` event. A
186
+ * `submitted` event carries neither. The body also carries the partial `values` filled so
187
+ * far (see {@link interactionsClient}'s `reactInteraction`).
188
+ */
189
+ export const reactionEventKind = z.enum(['field_changed', 'page_advanced', 'submitted']);
190
+ export type ReactionEventKind = z.infer<typeof reactionEventKind>;
191
+
192
+ export const reactionEvent = z.object({
193
+ kind: reactionEventKind,
194
+ field: z.string().optional(),
195
+ page: z.string().optional(),
196
+ });
197
+ export type ReactionEvent = z.infer<typeof reactionEvent>;
198
+
109
199
  export const interaction = z.object({
110
200
  interaction_id: z.string(),
111
201
  group_id: z.string(),
@@ -0,0 +1,121 @@
1
+ /** Member, invite, directory and member-action schemas for the generic Members view. */
2
+ import { z } from 'zod';
3
+
4
+ import { jsonSchema } from './shared';
5
+
6
+ /**
7
+ * Where a declared member action renders: a page-level button, a member-row menu
8
+ * item, or an invite-row menu item. A provider classifies each of its own actions
9
+ * into one of these three places; Studio only joins by `scope`, never reads the
10
+ * provider's meaning behind it.
11
+ */
12
+ export const memberActionScope = z.enum(['page', 'member_row', 'invite_row']);
13
+ export type MemberActionScope = z.infer<typeof memberActionScope>;
14
+
15
+ /**
16
+ * One platform principal a member holds (`GET /api/auth/members` →
17
+ * `members[].principals[]`). `user_id` is the platform principal id; `disabled` is
18
+ * taken from that principal's own record (the store the principals listing reads),
19
+ * never from a provider.
20
+ */
21
+ export const memberPrincipalState = z.object({
22
+ user_id: z.string(),
23
+ disabled: z.boolean(),
24
+ });
25
+ export type MemberPrincipalState = z.infer<typeof memberPrincipalState>;
26
+
27
+ /**
28
+ * One person an accounts provider owns, as the directory door returns them
29
+ * (`GET /api/auth/members` → `members[]`). `id` is the provider's stable handle for
30
+ * the person (a list key, not shown). `email` is the sign-in identity; `role` names
31
+ * the platform role the person holds (the NAME only — the role definition is read
32
+ * from the role listing). `principals` carries each principal's platform-joined
33
+ * state; `disabled` is derived True only when EVERY principal is disabled, so a
34
+ * person with any enabled principal still reads active while the per-principal truth
35
+ * stays visible. `handle` routes an invoke back to the producing provider and pins
36
+ * this row; `action_keys` are the opaque catalog keys of the actions applicable to
37
+ * it — Studio joins and echoes both, never parses them. `created_at` is an ISO-8601
38
+ * instant.
39
+ */
40
+ export const memberRow = z.object({
41
+ id: z.string(),
42
+ email: z.string(),
43
+ role: z.string(),
44
+ created_at: z.string(),
45
+ principals: z.array(memberPrincipalState),
46
+ disabled: z.boolean(),
47
+ handle: z.string(),
48
+ action_keys: z.array(z.string()),
49
+ });
50
+ export type MemberRow = z.infer<typeof memberRow>;
51
+
52
+ /**
53
+ * One outstanding invitation an accounts provider holds, as the directory door
54
+ * returns them (`GET /api/auth/members` → `invites[]`). `id` is the provider's
55
+ * stable handle for the invited person; `email` is the invited address; `role` names
56
+ * the platform role they will hold (name only, as on {@link memberRow}). An
57
+ * invitation holds no principal, so it carries no principal state. `handle` and
58
+ * `action_keys` are the opaque routing tokens (see {@link memberRow}). `created_at`
59
+ * and `expires_at` are ISO-8601 instants.
60
+ */
61
+ export const inviteRow = z.object({
62
+ id: z.string(),
63
+ email: z.string(),
64
+ role: z.string(),
65
+ created_at: z.string(),
66
+ expires_at: z.string(),
67
+ handle: z.string(),
68
+ action_keys: z.array(z.string()),
69
+ });
70
+ export type InviteRow = z.infer<typeof inviteRow>;
71
+
72
+ /**
73
+ * The deployment-wide membership (`GET /api/auth/members`): every accounts
74
+ * provider's people and outstanding invitations, aggregated and platform-joined by
75
+ * the backend into one view so a generic Members screen renders without naming any
76
+ * provider.
77
+ */
78
+ export const memberDirectory = z.object({
79
+ members: z.array(memberRow),
80
+ invites: z.array(inviteRow),
81
+ });
82
+ export type MemberDirectory = z.infer<typeof memberDirectory>;
83
+
84
+ /**
85
+ * One declared member action, serialized for the catalog (`GET
86
+ * /api/auth/member-actions` → `actions[]`). `key` is the opaque catalog key a caller
87
+ * joins and echoes, never parses. `label` is the resolved wording. `scope` places
88
+ * the action; `destructive` asks for a confirm before invoking. `input_schema` and
89
+ * `result_schema` are the declared models' JSON Schema — a caller renders an input
90
+ * form and a read-only result view from them generically, with no provider field
91
+ * name known to Studio.
92
+ */
93
+ export const memberActionDescriptor = z.object({
94
+ key: z.string(),
95
+ label: z.string(),
96
+ scope: memberActionScope,
97
+ destructive: z.boolean(),
98
+ input_schema: jsonSchema,
99
+ result_schema: jsonSchema,
100
+ });
101
+ export type MemberActionDescriptor = z.infer<typeof memberActionDescriptor>;
102
+
103
+ /**
104
+ * Every declared member action across the registered accounts providers (`GET
105
+ * /api/auth/member-actions`). ADMIN-ONLY (`secret`) — a non-admin projection never
106
+ * reaches the route, exactly as the members listing.
107
+ */
108
+ export const memberActionCatalog = z.object({
109
+ actions: z.array(memberActionDescriptor),
110
+ });
111
+ export type MemberActionCatalog = z.infer<typeof memberActionCatalog>;
112
+
113
+ /**
114
+ * The invoke-door result (`POST /api/auth/member-actions/invoke`): the provider's
115
+ * result-model dump, carried opaquely. `result` is rendered through the action's
116
+ * `result_schema`; Studio reads no field of it by name.
117
+ */
118
+ export const invokeMemberActionResult = z.object({
119
+ result: jsonSchema,
120
+ });
121
+ export type InvokeMemberActionResult = z.infer<typeof invokeMemberActionResult>;