@getcliqio/hug-frontend 0.0.0-stage → 1.15.32
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/README.md +31 -2
- package/dist/base_css.d.ts +6 -0
- package/dist/base_css.d.ts.map +1 -0
- package/dist/base_css.js +28 -0
- package/dist/base_css.js.map +1 -0
- package/dist/build.d.ts +45 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +44 -0
- package/dist/build.js.map +1 -0
- package/dist/current.d.ts +10 -0
- package/dist/current.d.ts.map +1 -0
- package/dist/current.js +14 -0
- package/dist/current.js.map +1 -0
- package/dist/define.d.ts +12 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +9 -0
- package/dist/define.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/host.d.ts +137 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +368 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mount.d.ts +64 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +106 -0
- package/dist/mount.js.map +1 -0
- package/dist/paths.d.ts +12 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +42 -0
- package/dist/paths.js.map +1 -0
- package/dist/react.d.ts +63 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +149 -0
- package/dist/react.js.map +1 -0
- package/dist/runtime.d.ts +140 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +284 -0
- package/dist/runtime.js.map +1 -0
- package/dist/shared/bridge/index.d.ts +16 -0
- package/dist/shared/bridge/index.d.ts.map +1 -0
- package/dist/shared/bridge/index.js +14 -0
- package/dist/shared/bridge/index.js.map +1 -0
- package/dist/shared/bridge/messages.d.ts +559 -0
- package/dist/shared/bridge/messages.d.ts.map +1 -0
- package/dist/shared/bridge/messages.js +166 -0
- package/dist/shared/bridge/messages.js.map +1 -0
- package/dist/shared/context.d.ts +54 -0
- package/dist/shared/context.d.ts.map +1 -0
- package/dist/shared/context.js +28 -0
- package/dist/shared/context.js.map +1 -0
- package/dist/shared/define.d.ts +116 -0
- package/dist/shared/define.d.ts.map +1 -0
- package/dist/shared/define.js +120 -0
- package/dist/shared/define.js.map +1 -0
- package/dist/shared/definitions/approval.d.ts +216 -0
- package/dist/shared/definitions/approval.d.ts.map +1 -0
- package/dist/shared/definitions/approval.js +51 -0
- package/dist/shared/definitions/approval.js.map +1 -0
- package/dist/shared/definitions/common.d.ts +122 -0
- package/dist/shared/definitions/common.d.ts.map +1 -0
- package/dist/shared/definitions/common.js +71 -0
- package/dist/shared/definitions/common.js.map +1 -0
- package/dist/shared/definitions/form.d.ts +197 -0
- package/dist/shared/definitions/form.d.ts.map +1 -0
- package/dist/shared/definitions/form.js +30 -0
- package/dist/shared/definitions/form.js.map +1 -0
- package/dist/shared/definitions/index.d.ts +10 -0
- package/dist/shared/definitions/index.d.ts.map +1 -0
- package/dist/shared/definitions/index.js +9 -0
- package/dist/shared/definitions/index.js.map +1 -0
- package/dist/shared/problems.d.ts +35 -0
- package/dist/shared/problems.d.ts.map +1 -0
- package/dist/shared/problems.js +54 -0
- package/dist/shared/problems.js.map +1 -0
- package/dist/shared/requested_inputs.d.ts +190 -0
- package/dist/shared/requested_inputs.d.ts.map +1 -0
- package/dist/shared/requested_inputs.js +221 -0
- package/dist/shared/requested_inputs.js.map +1 -0
- package/dist/shared/schema_for_inputs.d.ts +20 -0
- package/dist/shared/schema_for_inputs.d.ts.map +1 -0
- package/dist/shared/schema_for_inputs.js +96 -0
- package/dist/shared/schema_for_inputs.js.map +1 -0
- package/dist/state.d.ts +58 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +124 -0
- package/dist/state.js.map +1 -0
- package/dist/testing.d.ts +96 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +156 -0
- package/dist/testing.js.map +1 -0
- package/dist/theme.d.ts +15 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +18 -0
- package/dist/theme.js.map +1 -0
- package/dist/transport.d.ts +19 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +21 -0
- package/dist/transport.js.map +1 -0
- package/dist/ui/base.d.ts +33 -0
- package/dist/ui/base.d.ts.map +1 -0
- package/dist/ui/base.js +99 -0
- package/dist/ui/base.js.map +1 -0
- package/dist/ui/choices.d.ts +46 -0
- package/dist/ui/choices.d.ts.map +1 -0
- package/dist/ui/choices.js +121 -0
- package/dist/ui/choices.js.map +1 -0
- package/dist/ui/fields.d.ts +46 -0
- package/dist/ui/fields.d.ts.map +1 -0
- package/dist/ui/fields.js +169 -0
- package/dist/ui/fields.js.map +1 -0
- package/dist/ui/files.d.ts +80 -0
- package/dist/ui/files.d.ts.map +1 -0
- package/dist/ui/files.js +342 -0
- package/dist/ui/files.js.map +1 -0
- package/dist/ui/fonts.css +7 -0
- package/dist/ui/fonts_css.d.ts +3 -0
- package/dist/ui/fonts_css.d.ts.map +1 -0
- package/dist/ui/fonts_css.js +4 -0
- package/dist/ui/fonts_css.js.map +1 -0
- package/dist/ui/index.d.ts +24 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +32 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/markdown.d.ts +46 -0
- package/dist/ui/markdown.d.ts.map +1 -0
- package/dist/ui/markdown.js +318 -0
- package/dist/ui/markdown.js.map +1 -0
- package/dist/view.d.ts +49 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +136 -0
- package/dist/view.js.map +1 -0
- package/dist/zod_config.d.ts +2 -0
- package/dist/zod_config.d.ts.map +1 -0
- package/dist/zod_config.js +10 -0
- package/dist/zod_config.js.map +1 -0
- package/fonts/LICENSE.txt +92 -0
- package/package.json +82 -5
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `form` — the built-in hug that asks for some answers (PLAN-hug-widgets §10.1). Its params list the fields
|
|
3
|
+
* (`inputs`), so its answer schema, upload slots and summary are built from them.
|
|
4
|
+
*
|
|
5
|
+
* Answer: one key per input (required ones enforced) and an optional `comment`; or, when the person can't answer,
|
|
6
|
+
* `{ declined: "<reason>" }` and nothing else. The same rules as today's `form_v1` (the parity is tested).
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
/** The answer keys `form` adds itself; inputs can't use them. */
|
|
10
|
+
export declare const FORM_OWN_KEYS: readonly ["comment", "declined"];
|
|
11
|
+
/** `form`'s params. */
|
|
12
|
+
export declare const FormParams: z.ZodObject<{
|
|
13
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
14
|
+
context: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<"markdown">;
|
|
16
|
+
text: z.ZodString;
|
|
17
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"artifact">;
|
|
19
|
+
artifact_id: z.ZodString;
|
|
20
|
+
label: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"checks">;
|
|
23
|
+
results: z.ZodArray<z.ZodObject<{
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
ok: z.ZodBoolean;
|
|
26
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strict>>;
|
|
28
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"transcript">;
|
|
30
|
+
turns: z.ZodArray<z.ZodObject<{
|
|
31
|
+
role: z.ZodString;
|
|
32
|
+
content: z.ZodString;
|
|
33
|
+
}, z.core.$strict>>;
|
|
34
|
+
}, z.core.$strict>], "type">>>;
|
|
35
|
+
inputs: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"text">;
|
|
37
|
+
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
+
min_length: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
max_length: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
label: z.ZodOptional<z.ZodString>;
|
|
42
|
+
help: z.ZodOptional<z.ZodString>;
|
|
43
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
45
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
46
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
47
|
+
type: z.ZodLiteral<"number">;
|
|
48
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
integer: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
name: z.ZodString;
|
|
52
|
+
label: z.ZodOptional<z.ZodString>;
|
|
53
|
+
help: z.ZodOptional<z.ZodString>;
|
|
54
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
56
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"boolean">;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
label: z.ZodOptional<z.ZodString>;
|
|
61
|
+
help: z.ZodOptional<z.ZodString>;
|
|
62
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
64
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
type: z.ZodLiteral<"enum">;
|
|
67
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
68
|
+
value: z.ZodString;
|
|
69
|
+
label: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
name: z.ZodString;
|
|
73
|
+
label: z.ZodOptional<z.ZodString>;
|
|
74
|
+
help: z.ZodOptional<z.ZodString>;
|
|
75
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
77
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
78
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"file">;
|
|
80
|
+
accept: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
81
|
+
max_bytes: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
label: z.ZodOptional<z.ZodString>;
|
|
85
|
+
help: z.ZodOptional<z.ZodString>;
|
|
86
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
88
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
89
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
90
|
+
type: z.ZodLiteral<"channel">;
|
|
91
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
label: z.ZodOptional<z.ZodString>;
|
|
94
|
+
help: z.ZodOptional<z.ZodString>;
|
|
95
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
97
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
98
|
+
}, z.core.$strict>], "type">>>;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
/** `form`'s params. */
|
|
101
|
+
export type FormParams = z.infer<typeof FormParams>;
|
|
102
|
+
/** A `form` answer: the inputs and a comment, or `declined`. */
|
|
103
|
+
export type FormValues = {
|
|
104
|
+
declined: string;
|
|
105
|
+
} | ({
|
|
106
|
+
comment?: string | null;
|
|
107
|
+
} & Record<string, unknown>);
|
|
108
|
+
/** The built-in `form` hug. */
|
|
109
|
+
export declare const form: import("../define.js").HugDefinition<{
|
|
110
|
+
inputs: ({
|
|
111
|
+
type: "text";
|
|
112
|
+
name: string;
|
|
113
|
+
multiline?: boolean | undefined;
|
|
114
|
+
min_length?: number | undefined;
|
|
115
|
+
max_length?: number | undefined;
|
|
116
|
+
label?: string | undefined;
|
|
117
|
+
help?: string | undefined;
|
|
118
|
+
required?: boolean | undefined;
|
|
119
|
+
default?: unknown;
|
|
120
|
+
ui?: Record<string, unknown> | undefined;
|
|
121
|
+
} | {
|
|
122
|
+
type: "number";
|
|
123
|
+
name: string;
|
|
124
|
+
min?: number | undefined;
|
|
125
|
+
max?: number | undefined;
|
|
126
|
+
integer?: boolean | undefined;
|
|
127
|
+
label?: string | undefined;
|
|
128
|
+
help?: string | undefined;
|
|
129
|
+
required?: boolean | undefined;
|
|
130
|
+
default?: unknown;
|
|
131
|
+
ui?: Record<string, unknown> | undefined;
|
|
132
|
+
} | {
|
|
133
|
+
type: "boolean";
|
|
134
|
+
name: string;
|
|
135
|
+
label?: string | undefined;
|
|
136
|
+
help?: string | undefined;
|
|
137
|
+
required?: boolean | undefined;
|
|
138
|
+
default?: unknown;
|
|
139
|
+
ui?: Record<string, unknown> | undefined;
|
|
140
|
+
} | {
|
|
141
|
+
type: "enum";
|
|
142
|
+
choices: {
|
|
143
|
+
value: string;
|
|
144
|
+
label?: string | undefined;
|
|
145
|
+
}[];
|
|
146
|
+
name: string;
|
|
147
|
+
multiple?: boolean | undefined;
|
|
148
|
+
label?: string | undefined;
|
|
149
|
+
help?: string | undefined;
|
|
150
|
+
required?: boolean | undefined;
|
|
151
|
+
default?: unknown;
|
|
152
|
+
ui?: Record<string, unknown> | undefined;
|
|
153
|
+
} | {
|
|
154
|
+
type: "file";
|
|
155
|
+
name: string;
|
|
156
|
+
accept?: string[] | undefined;
|
|
157
|
+
max_bytes?: number | undefined;
|
|
158
|
+
multiple?: boolean | undefined;
|
|
159
|
+
label?: string | undefined;
|
|
160
|
+
help?: string | undefined;
|
|
161
|
+
required?: boolean | undefined;
|
|
162
|
+
default?: unknown;
|
|
163
|
+
ui?: Record<string, unknown> | undefined;
|
|
164
|
+
} | {
|
|
165
|
+
type: "channel";
|
|
166
|
+
name: string;
|
|
167
|
+
multiple?: boolean | undefined;
|
|
168
|
+
label?: string | undefined;
|
|
169
|
+
help?: string | undefined;
|
|
170
|
+
required?: boolean | undefined;
|
|
171
|
+
default?: unknown;
|
|
172
|
+
ui?: Record<string, unknown> | undefined;
|
|
173
|
+
})[];
|
|
174
|
+
prompt?: string | undefined;
|
|
175
|
+
context?: ({
|
|
176
|
+
type: "markdown";
|
|
177
|
+
text: string;
|
|
178
|
+
} | {
|
|
179
|
+
type: "artifact";
|
|
180
|
+
artifact_id: string;
|
|
181
|
+
label?: string | undefined;
|
|
182
|
+
} | {
|
|
183
|
+
type: "checks";
|
|
184
|
+
results: {
|
|
185
|
+
name: string;
|
|
186
|
+
ok: boolean;
|
|
187
|
+
summary?: string | undefined;
|
|
188
|
+
}[];
|
|
189
|
+
} | {
|
|
190
|
+
type: "transcript";
|
|
191
|
+
turns: {
|
|
192
|
+
role: string;
|
|
193
|
+
content: string;
|
|
194
|
+
}[];
|
|
195
|
+
})[] | undefined;
|
|
196
|
+
}, FormValues>;
|
|
197
|
+
//# sourceMappingURL=form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../src/shared/definitions/form.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,iEAAiE;AACjE,eAAO,MAAM,aAAa,kCAAmC,CAAC;AAE9D,uBAAuB;AACvB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAsE,CAAC;AAC9F,uBAAuB;AACvB,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAExG,+BAA+B;AAC/B,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAWf,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// GENERATED by packages/hug-frontend/scripts/sync_shared.mjs from cliq-sdk/src/hug — do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* `form` — the built-in hug that asks for some answers (PLAN-hug-widgets §10.1). Its params list the fields
|
|
4
|
+
* (`inputs`), so its answer schema, upload slots and summary are built from them.
|
|
5
|
+
*
|
|
6
|
+
* Answer: one key per input (required ones enforced) and an optional `comment`; or, when the person can't answer,
|
|
7
|
+
* `{ declined: "<reason>" }` and nothing else. The same rules as today's `form_v1` (the parity is tested).
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { define_hug } from '../define.js';
|
|
11
|
+
import { schema_for_inputs } from '../schema_for_inputs.js';
|
|
12
|
+
import { base_params, file_inputs, first_answer, no_own_keys, note } from './common.js';
|
|
13
|
+
/** The answer keys `form` adds itself; inputs can't use them. */
|
|
14
|
+
export const FORM_OWN_KEYS = ['comment', 'declined'];
|
|
15
|
+
/** `form`'s params. */
|
|
16
|
+
export const FormParams = z.strictObject(base_params).superRefine(no_own_keys(FORM_OWN_KEYS));
|
|
17
|
+
/** The built-in `form` hug. */
|
|
18
|
+
export const form = define_hug({
|
|
19
|
+
name: 'form',
|
|
20
|
+
title: 'Form',
|
|
21
|
+
description: 'Asks people for a few values (text, numbers, yes/no, choices, files) and an optional comment; they may say they can\'t answer.',
|
|
22
|
+
params: FormParams,
|
|
23
|
+
values: (p) => z.union([
|
|
24
|
+
z.strictObject({ declined: note(true) }),
|
|
25
|
+
z.strictObject({ ...schema_for_inputs(p.inputs).shape, comment: note(false) }),
|
|
26
|
+
]),
|
|
27
|
+
files: (p) => file_inputs(p.inputs),
|
|
28
|
+
summary: (v, p) => ('declined' in v && typeof v.declined === 'string' ? "Couldn't answer" : first_answer(p.inputs, v) ?? 'Responded'),
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../../src/shared/definitions/form.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExF,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,UAAU,CAAU,CAAC;AAE9D,uBAAuB;AACvB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;AAO9F,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAyB;IACnD,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,gIAAgI;IAC7I,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACnB,CAAC,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;KACjF,CAAqC;IACtC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,WAAW,CAAC;CACxI,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in hugs' definitions (PLAN-hug-widgets §4.2, §9.1), published as `@getcliqio/cliq-sdk/hugs`: imported by
|
|
3
|
+
* their bundles in cliq-agents and by every agent that asks with them (the gate, `LlmAgent`, `CliAgent`, any
|
|
4
|
+
* `ctx.ask(form, …)`). Browser-safe.
|
|
5
|
+
*/
|
|
6
|
+
export { form, FormParams, FORM_OWN_KEYS } from './form.js';
|
|
7
|
+
export type { FormValues } from './form.js';
|
|
8
|
+
export { approval, ApprovalParams, APPROVAL_OWN_KEYS } from './approval.js';
|
|
9
|
+
export type { ApprovalValues } from './approval.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/definitions/index.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC5D,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// GENERATED by packages/hug-frontend/scripts/sync_shared.mjs from cliq-sdk/src/hug — do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* The built-in hugs' definitions (PLAN-hug-widgets §4.2, §9.1), published as `@getcliqio/cliq-sdk/hugs`: imported by
|
|
4
|
+
* their bundles in cliq-agents and by every agent that asks with them (the gate, `LlmAgent`, `CliAgent`, any
|
|
5
|
+
* `ctx.ask(form, …)`). Browser-safe.
|
|
6
|
+
*/
|
|
7
|
+
export { form, FormParams, FORM_OWN_KEYS } from './form.js';
|
|
8
|
+
export { approval, ApprovalParams, APPROVAL_OWN_KEYS } from './approval.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/definitions/index.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Problems with an answer or params (PLAN-hug-widgets §9.2): a message and, when it is about one field, the path to it
|
|
3
|
+
* (`severity`, `verdicts[2].note`). Shared by `define_hug` checks, the frontend SDK and the agent SDK.
|
|
4
|
+
*
|
|
5
|
+
* Browser-safe: imports only `zod`.
|
|
6
|
+
*/
|
|
7
|
+
import type { z } from 'zod';
|
|
8
|
+
/** One problem: what is wrong, and where (a field path like `rows[3].total`; absent for the whole answer). */
|
|
9
|
+
export interface Problem {
|
|
10
|
+
readonly path?: string;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
}
|
|
13
|
+
/** A checked value, or the problems that stopped it. */
|
|
14
|
+
export type Checked<T> = {
|
|
15
|
+
readonly ok: true;
|
|
16
|
+
readonly value: T;
|
|
17
|
+
} | {
|
|
18
|
+
readonly ok: false;
|
|
19
|
+
readonly problems: Problem[];
|
|
20
|
+
};
|
|
21
|
+
/** `verdicts[2].note` for the Zod path `['verdicts', 2, 'note']`; undefined for the root. */
|
|
22
|
+
export declare function path_of(path: readonly PropertyKey[]): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* The problems in a failed Zod parse.
|
|
25
|
+
*
|
|
26
|
+
* A union that matched no branch reports the branch that came closest (the fewest issues), so the person sees "reason:
|
|
27
|
+
* required" rather than "doesn't match any of 2 shapes". Each unrecognized key counts as an issue: an answer with four
|
|
28
|
+
* filled fields is far from `form`'s `{ declined }` branch, however Zod groups them.
|
|
29
|
+
*
|
|
30
|
+
* @param error - The `error` of a failed `safeParse`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function problems_from_zod(error: z.ZodError): Problem[];
|
|
33
|
+
/** Problems as one line each (`verdicts[2].note: required`), for logs and LLM resends. */
|
|
34
|
+
export declare function problems_text(problems: readonly Problem[]): string[];
|
|
35
|
+
//# sourceMappingURL=problems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problems.d.ts","sourceRoot":"","sources":["../../src/shared/problems.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,8GAA8G;AAC9G,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC5B;AAED,wDAAwD;AACxD,MAAM,MAAM,OAAO,CAAC,CAAC,IACf;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAE3D,6FAA6F;AAC7F,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,GAAG,SAAS,CAQxE;AAKD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,GAAG,OAAO,EAAE,CAe9D;AAOD,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,CAEpE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// GENERATED by packages/hug-frontend/scripts/sync_shared.mjs from cliq-sdk/src/hug — do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* Problems with an answer or params (PLAN-hug-widgets §9.2): a message and, when it is about one field, the path to it
|
|
4
|
+
* (`severity`, `verdicts[2].note`). Shared by `define_hug` checks, the frontend SDK and the agent SDK.
|
|
5
|
+
*
|
|
6
|
+
* Browser-safe: imports only `zod`.
|
|
7
|
+
*/
|
|
8
|
+
/** `verdicts[2].note` for the Zod path `['verdicts', 2, 'note']`; undefined for the root. */
|
|
9
|
+
export function path_of(path) {
|
|
10
|
+
let out = '';
|
|
11
|
+
for (const part of path) {
|
|
12
|
+
if (typeof part === 'number')
|
|
13
|
+
out += `[${part}]`;
|
|
14
|
+
else if (out === '')
|
|
15
|
+
out = String(part);
|
|
16
|
+
else
|
|
17
|
+
out += `.${String(part)}`;
|
|
18
|
+
}
|
|
19
|
+
return out === '' ? undefined : out;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The problems in a failed Zod parse.
|
|
23
|
+
*
|
|
24
|
+
* A union that matched no branch reports the branch that came closest (the fewest issues), so the person sees "reason:
|
|
25
|
+
* required" rather than "doesn't match any of 2 shapes". Each unrecognized key counts as an issue: an answer with four
|
|
26
|
+
* filled fields is far from `form`'s `{ declined }` branch, however Zod groups them.
|
|
27
|
+
*
|
|
28
|
+
* @param error - The `error` of a failed `safeParse`.
|
|
29
|
+
*/
|
|
30
|
+
export function problems_from_zod(error) {
|
|
31
|
+
const out = [];
|
|
32
|
+
const walk = (issues, prefix) => {
|
|
33
|
+
for (const issue of issues) {
|
|
34
|
+
const path = [...prefix, ...issue.path];
|
|
35
|
+
if (issue.code === 'invalid_union' && issue.errors.length > 0) {
|
|
36
|
+
const best = [...issue.errors].sort((a, b) => distance(a) - distance(b))[0];
|
|
37
|
+
walk(best, path);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
out.push({ ...(path_of(path) ? { path: path_of(path) } : {}), message: issue.message });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
walk(error.issues, []);
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
/** How far a union branch was from matching: its issues, counting each unrecognized key as one. */
|
|
47
|
+
function distance(issues) {
|
|
48
|
+
return issues.reduce((n, i) => n + (i.code === 'unrecognized_keys' ? Math.max(1, i.keys.length) : 1), 0);
|
|
49
|
+
}
|
|
50
|
+
/** Problems as one line each (`verdicts[2].note: required`), for logs and LLM resends. */
|
|
51
|
+
export function problems_text(problems) {
|
|
52
|
+
return problems.map((p) => (p.path ? `${p.path}: ${p.message}` : p.message));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=problems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problems.js","sourceRoot":"","sources":["../../src/shared/problems.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG;;;;;GAKG;AAeH,6FAA6F;AAC7F,MAAM,UAAU,OAAO,CAAC,IAA4B;IAChD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC;aAC5C,IAAI,GAAG,KAAK,EAAE;YAAE,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;;YACnC,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACnC,CAAC;IACD,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;AACxC,CAAC;AAKD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAiB;IAC/C,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,MAAM,IAAI,GAAG,CAAC,MAAwB,EAAE,MAA8B,EAAQ,EAAE;QAC5E,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5D,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5E,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACjB,SAAS;YACb,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5F,CAAC;IACL,CAAC,CAAC;IACF,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,OAAO,GAAG,CAAC;AACf,CAAC;AAED,mGAAmG;AACnG,SAAS,QAAQ,CAAC,MAAwB;IACtC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7G,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,QAA4B;IACtD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requested inputs — what a Hug asks people for (PLAN-hug-requests §7).
|
|
3
|
+
*
|
|
4
|
+
* The one definition of the contract: cliq-sdk validates a Hug's `requested_inputs` when an
|
|
5
|
+
* agent opens it, CliqHub Core validates them again on create and validates every response's
|
|
6
|
+
* values on respond, and the Hub UI and the CLI prompt render them. Labels, help and `ui` are
|
|
7
|
+
* presentation and are never validated beyond their type.
|
|
8
|
+
*
|
|
9
|
+
* Types: text, number, boolean, enum, file, channel.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
/** Most requested inputs one Hug may have. */
|
|
13
|
+
export declare const MAX_REQUESTED_INPUTS = 50;
|
|
14
|
+
/** Longest text value accepted. */
|
|
15
|
+
export declare const MAX_TEXT_LENGTH = 100000;
|
|
16
|
+
/** Most files one `multiple` file input takes. */
|
|
17
|
+
export declare const MAX_FILES_PER_INPUT = 10;
|
|
18
|
+
/** One requested input. */
|
|
19
|
+
export declare const RequestedInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"text">;
|
|
21
|
+
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
min_length: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
max_length: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
label: z.ZodOptional<z.ZodString>;
|
|
26
|
+
help: z.ZodOptional<z.ZodString>;
|
|
27
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
29
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"number">;
|
|
32
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
integer: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
label: z.ZodOptional<z.ZodString>;
|
|
37
|
+
help: z.ZodOptional<z.ZodString>;
|
|
38
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
40
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
41
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
42
|
+
type: z.ZodLiteral<"boolean">;
|
|
43
|
+
name: z.ZodString;
|
|
44
|
+
label: z.ZodOptional<z.ZodString>;
|
|
45
|
+
help: z.ZodOptional<z.ZodString>;
|
|
46
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
48
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
type: z.ZodLiteral<"enum">;
|
|
51
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
52
|
+
value: z.ZodString;
|
|
53
|
+
label: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
name: z.ZodString;
|
|
57
|
+
label: z.ZodOptional<z.ZodString>;
|
|
58
|
+
help: z.ZodOptional<z.ZodString>;
|
|
59
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
61
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"file">;
|
|
64
|
+
accept: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
max_bytes: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
label: z.ZodOptional<z.ZodString>;
|
|
69
|
+
help: z.ZodOptional<z.ZodString>;
|
|
70
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
72
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
73
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<"channel">;
|
|
75
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
label: z.ZodOptional<z.ZodString>;
|
|
78
|
+
help: z.ZodOptional<z.ZodString>;
|
|
79
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
81
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
82
|
+
}, z.core.$strict>], "type">;
|
|
83
|
+
/** One requested input. */
|
|
84
|
+
export type RequestedInput = z.infer<typeof RequestedInputSchema>;
|
|
85
|
+
/** The type names a requested input can have. */
|
|
86
|
+
export type RequestedInputType = RequestedInput['type'];
|
|
87
|
+
/** A Hug's `requested_inputs`: 0–50 inputs with unique names. */
|
|
88
|
+
export declare const RequestedInputsSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"text">;
|
|
90
|
+
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
min_length: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
max_length: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
name: z.ZodString;
|
|
94
|
+
label: z.ZodOptional<z.ZodString>;
|
|
95
|
+
help: z.ZodOptional<z.ZodString>;
|
|
96
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
98
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
99
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
100
|
+
type: z.ZodLiteral<"number">;
|
|
101
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
integer: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
+
name: z.ZodString;
|
|
105
|
+
label: z.ZodOptional<z.ZodString>;
|
|
106
|
+
help: z.ZodOptional<z.ZodString>;
|
|
107
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
108
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
109
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
110
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
+
type: z.ZodLiteral<"boolean">;
|
|
112
|
+
name: z.ZodString;
|
|
113
|
+
label: z.ZodOptional<z.ZodString>;
|
|
114
|
+
help: z.ZodOptional<z.ZodString>;
|
|
115
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
117
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
118
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
119
|
+
type: z.ZodLiteral<"enum">;
|
|
120
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
121
|
+
value: z.ZodString;
|
|
122
|
+
label: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strict>>;
|
|
124
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
125
|
+
name: z.ZodString;
|
|
126
|
+
label: z.ZodOptional<z.ZodString>;
|
|
127
|
+
help: z.ZodOptional<z.ZodString>;
|
|
128
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
129
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
130
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
131
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
132
|
+
type: z.ZodLiteral<"file">;
|
|
133
|
+
accept: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
134
|
+
max_bytes: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
136
|
+
name: z.ZodString;
|
|
137
|
+
label: z.ZodOptional<z.ZodString>;
|
|
138
|
+
help: z.ZodOptional<z.ZodString>;
|
|
139
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
140
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
141
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
142
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
143
|
+
type: z.ZodLiteral<"channel">;
|
|
144
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
145
|
+
name: z.ZodString;
|
|
146
|
+
label: z.ZodOptional<z.ZodString>;
|
|
147
|
+
help: z.ZodOptional<z.ZodString>;
|
|
148
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
149
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
150
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
151
|
+
}, z.core.$strict>], "type">>;
|
|
152
|
+
/** A file as a responder submits it: the id `artifacts/upload` returned. */
|
|
153
|
+
export interface FileRef {
|
|
154
|
+
readonly artifact_id: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A file as the requester receives it: a reference with its metadata (Core, or cliqd's local store,
|
|
158
|
+
* fills it in). The bytes stay in storage — read them with `ctx.download` (PLAN-hug-requests Step 11).
|
|
159
|
+
*/
|
|
160
|
+
export interface FileValue extends FileRef {
|
|
161
|
+
readonly name: string;
|
|
162
|
+
readonly size: number;
|
|
163
|
+
readonly content_type: string;
|
|
164
|
+
readonly sha256: string;
|
|
165
|
+
}
|
|
166
|
+
/** Outcome of validating definitions or values. */
|
|
167
|
+
export type ValidationResult<T> = {
|
|
168
|
+
readonly ok: true;
|
|
169
|
+
readonly value: T;
|
|
170
|
+
} | {
|
|
171
|
+
readonly ok: false;
|
|
172
|
+
readonly problems: string[];
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Validate a Hug's `requested_inputs` definitions.
|
|
176
|
+
*
|
|
177
|
+
* @returns the parsed definitions, or every problem (`requested_inputs[2].name: …`).
|
|
178
|
+
*/
|
|
179
|
+
export declare function validate_requested_inputs(raw: unknown): ValidationResult<RequestedInput[]>;
|
|
180
|
+
/**
|
|
181
|
+
* Validate a response's values against the Hug's requested inputs.
|
|
182
|
+
*
|
|
183
|
+
* Required inputs must be present; unknown keys are refused. File values are checked for shape
|
|
184
|
+
* (`{ artifact_id }`, or a list when `multiple`); that the artifact exists, belongs to the Hug and
|
|
185
|
+
* matches `accept` / `max_bytes` is Core's check against the stored artifact.
|
|
186
|
+
*
|
|
187
|
+
* @returns the values (unchanged), or every problem keyed by input name.
|
|
188
|
+
*/
|
|
189
|
+
export declare function validate_values(inputs: readonly RequestedInput[], raw: unknown): ValidationResult<Record<string, unknown>>;
|
|
190
|
+
//# sourceMappingURL=requested_inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requested_inputs.d.ts","sourceRoot":"","sources":["../../src/shared/requested_inputs.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8CAA8C;AAC9C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,mCAAmC;AACnC,eAAO,MAAM,eAAe,SAAU,CAAC;AACvC,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,KAAK,CAAC;AA2DtC,2BAA2B;AAC3B,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAE/B,CAAC;AACH,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,iDAAiD;AACjD,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAExD,iEAAiE;AACjE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAOhC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,OAAO;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B;AAED,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAI1F;AAOD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkB1H"}
|