@tai42/api-client 14.0.0 → 16.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.
- package/dist/client.d.ts +597 -253
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -1
- package/dist/client.js.map +1 -1
- package/dist/generated/served-schemas.d.ts +748 -0
- package/dist/generated/served-schemas.d.ts.map +1 -0
- package/dist/generated/served-schemas.js +60 -0
- package/dist/generated/served-schemas.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/schemas.d.ts +1135 -686
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +39 -300
- package/dist/schemas.js.map +1 -1
- package/dist/templated-text.d.ts +30 -0
- package/dist/templated-text.d.ts.map +1 -0
- package/dist/templated-text.js +30 -0
- package/dist/templated-text.js.map +1 -0
- package/package.json +6 -2
- package/src/client.ts +24 -21
- package/src/generated/served-schemas.ts +126 -0
- package/src/index.ts +3 -0
- package/src/schemas.ts +61 -333
- package/src/templated-text.ts +35 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One authored-text value: either inline `content` (text written in place) or a
|
|
5
|
+
* stored template `id` (a template resource fetched and rendered), never both and
|
|
6
|
+
* never neither. `kwargs` are the render parameters and apply in BOTH cases — a
|
|
7
|
+
* prompt with placeholders needs its values whether it was typed inline or fetched.
|
|
8
|
+
* `.strict()` refuses any other key so a drifting field fails the parse loudly.
|
|
9
|
+
*
|
|
10
|
+
* This is the target the generated served-document schemas map every platform
|
|
11
|
+
* `x-tai42-templated-text` field to, so a body can never regenerate as a bare
|
|
12
|
+
* `z.string()`. It lives in its own module because the generated module imports it,
|
|
13
|
+
* and the generated module is imported back by `schemas.ts`.
|
|
14
|
+
*/
|
|
15
|
+
export const templatedText = z
|
|
16
|
+
.object({
|
|
17
|
+
content: z.string().optional(),
|
|
18
|
+
id: z.string().optional(),
|
|
19
|
+
kwargs: z.record(z.string(), z.unknown()).optional(),
|
|
20
|
+
})
|
|
21
|
+
.strict()
|
|
22
|
+
.refine((value) => (value.content === undefined) !== (value.id === undefined), {
|
|
23
|
+
message: 'A templated-text value sets exactly one of `content` or `id`.',
|
|
24
|
+
});
|
|
25
|
+
export type TemplatedText = z.infer<typeof templatedText>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A templated-text value that must carry a source: inline `content` is non-empty, or
|
|
29
|
+
* a stored template `id` is chosen. Used where the platform contract requires a
|
|
30
|
+
* value (e.g. a state binding's subject, an update's adapter when present).
|
|
31
|
+
*/
|
|
32
|
+
export const requiredTemplatedText = templatedText.refine(
|
|
33
|
+
(value) => (value.id !== undefined ? value.id.length > 0 : (value.content ?? '').length > 0),
|
|
34
|
+
{ message: 'Provide inline text or choose a stored template.' },
|
|
35
|
+
);
|