@idelio/contracts 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/api-keys.d.ts +44 -0
- package/dist/api-keys.js +19 -0
- package/dist/assets.d.ts +188 -0
- package/dist/assets.js +107 -0
- package/dist/billing.d.ts +94 -0
- package/dist/billing.js +67 -0
- package/dist/brands.d.ts +641 -0
- package/dist/brands.js +364 -0
- package/dist/catalog.d.ts +26 -0
- package/dist/catalog.js +53 -0
- package/dist/consent.d.ts +60 -0
- package/dist/consent.js +65 -0
- package/dist/creative-direction.d.ts +333 -0
- package/dist/creative-direction.js +681 -0
- package/dist/credits.d.ts +38 -0
- package/dist/credits.js +31 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.js +22 -0
- package/dist/events.d.ts +20 -0
- package/dist/events.js +29 -0
- package/dist/ids.d.ts +28 -0
- package/dist/ids.js +29 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/jobs.d.ts +100 -0
- package/dist/jobs.js +81 -0
- package/dist/me.d.ts +77 -0
- package/dist/me.js +45 -0
- package/dist/notifications.d.ts +17 -0
- package/dist/notifications.js +26 -0
- package/dist/pricing.d.ts +38 -0
- package/dist/pricing.js +105 -0
- package/dist/rate-limits.d.ts +8 -0
- package/dist/rate-limits.js +18 -0
- package/dist/usage.d.ts +22 -0
- package/dist/usage.js +11 -0
- package/dist/waitlist.d.ts +34 -0
- package/dist/waitlist.js +27 -0
- package/dist/webhooks.d.ts +74 -0
- package/dist/webhooks.js +26 -0
- package/openapi/openapi.yaml +3026 -0
- package/package.json +54 -0
package/dist/brands.js
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { brandStyles, creativeDirectionSchema } from "./creative-direction.js";
|
|
3
|
+
export const brandStatuses = ["draft", "generating", "ready", "failed"];
|
|
4
|
+
export const teamTiers = ["flash", "studio", "elite"];
|
|
5
|
+
export const assetKinds = [
|
|
6
|
+
"logo",
|
|
7
|
+
"logo_alternative",
|
|
8
|
+
"logo_wordmark",
|
|
9
|
+
"color_palette",
|
|
10
|
+
"font_pairing",
|
|
11
|
+
"logo_mono",
|
|
12
|
+
"logo_reversed",
|
|
13
|
+
"favicon",
|
|
14
|
+
"brand_guide",
|
|
15
|
+
"profile_avatar",
|
|
16
|
+
"social_x",
|
|
17
|
+
"social_linkedin",
|
|
18
|
+
"social_linkedin_personal",
|
|
19
|
+
"social_facebook",
|
|
20
|
+
"social_youtube",
|
|
21
|
+
"social_post",
|
|
22
|
+
"social_story",
|
|
23
|
+
"app_icon",
|
|
24
|
+
"og_image",
|
|
25
|
+
"email_signature",
|
|
26
|
+
"hero_image",
|
|
27
|
+
"play_feature_graphic",
|
|
28
|
+
"business_card",
|
|
29
|
+
"letterhead",
|
|
30
|
+
"mockup",
|
|
31
|
+
"custom_image",
|
|
32
|
+
];
|
|
33
|
+
export const requiredAssetKinds = [
|
|
34
|
+
"logo",
|
|
35
|
+
"logo_alternative",
|
|
36
|
+
"logo_wordmark",
|
|
37
|
+
"color_palette",
|
|
38
|
+
"font_pairing",
|
|
39
|
+
];
|
|
40
|
+
export function isRequiredAssetKind(kind) {
|
|
41
|
+
return requiredAssetKinds.includes(kind);
|
|
42
|
+
}
|
|
43
|
+
export const defaultLockedAssetKinds = requiredAssetKinds;
|
|
44
|
+
export function isDefaultLockedAssetKind(kind) {
|
|
45
|
+
return defaultLockedAssetKinds.includes(kind);
|
|
46
|
+
}
|
|
47
|
+
export const templatedAssetKinds = ["hero_image"];
|
|
48
|
+
export const flashUnavailableAssetKinds = ["mockup", ...templatedAssetKinds];
|
|
49
|
+
export const expandableAssetKinds = assetKinds.filter((kind) => kind !== "logo");
|
|
50
|
+
export const regenerableAssetKinds = [
|
|
51
|
+
"color_palette",
|
|
52
|
+
"font_pairing",
|
|
53
|
+
"logo_wordmark",
|
|
54
|
+
"business_card",
|
|
55
|
+
"letterhead",
|
|
56
|
+
"mockup",
|
|
57
|
+
"og_image",
|
|
58
|
+
"email_signature",
|
|
59
|
+
"hero_image",
|
|
60
|
+
"play_feature_graphic",
|
|
61
|
+
"social_x",
|
|
62
|
+
"social_linkedin",
|
|
63
|
+
"social_linkedin_personal",
|
|
64
|
+
"social_facebook",
|
|
65
|
+
"social_youtube",
|
|
66
|
+
"social_post",
|
|
67
|
+
"social_story",
|
|
68
|
+
];
|
|
69
|
+
export const suggestableAssetKinds = [
|
|
70
|
+
"logo_alternative",
|
|
71
|
+
"logo_wordmark",
|
|
72
|
+
"logo_mono",
|
|
73
|
+
"logo_reversed",
|
|
74
|
+
"favicon",
|
|
75
|
+
"brand_guide",
|
|
76
|
+
"profile_avatar",
|
|
77
|
+
"social_x",
|
|
78
|
+
"social_linkedin",
|
|
79
|
+
"social_linkedin_personal",
|
|
80
|
+
"social_facebook",
|
|
81
|
+
"social_youtube",
|
|
82
|
+
"social_post",
|
|
83
|
+
"social_story",
|
|
84
|
+
"app_icon",
|
|
85
|
+
"og_image",
|
|
86
|
+
"email_signature",
|
|
87
|
+
"hero_image",
|
|
88
|
+
"play_feature_graphic",
|
|
89
|
+
"business_card",
|
|
90
|
+
"letterhead",
|
|
91
|
+
"mockup",
|
|
92
|
+
];
|
|
93
|
+
export const suggestionItemKinds = [...suggestableAssetKinds, "custom_image"];
|
|
94
|
+
export function nextSuggestableKinds(owned, count = 3) {
|
|
95
|
+
const ownedSet = new Set(owned);
|
|
96
|
+
return suggestableAssetKinds.filter((kind) => !ownedSet.has(kind)).slice(0, count);
|
|
97
|
+
}
|
|
98
|
+
export const composedAssetKinds = [
|
|
99
|
+
"favicon",
|
|
100
|
+
"app_icon",
|
|
101
|
+
"business_card",
|
|
102
|
+
"letterhead",
|
|
103
|
+
"og_image",
|
|
104
|
+
"email_signature",
|
|
105
|
+
"play_feature_graphic",
|
|
106
|
+
"profile_avatar",
|
|
107
|
+
"social_x",
|
|
108
|
+
"social_linkedin",
|
|
109
|
+
"social_linkedin_personal",
|
|
110
|
+
"social_facebook",
|
|
111
|
+
"social_youtube",
|
|
112
|
+
"social_post",
|
|
113
|
+
"social_story",
|
|
114
|
+
];
|
|
115
|
+
export function isComposedAssetKind(kind) {
|
|
116
|
+
return composedAssetKinds.includes(kind);
|
|
117
|
+
}
|
|
118
|
+
export const markRequiringAssetKinds = [
|
|
119
|
+
"logo_alternative",
|
|
120
|
+
"logo_mono",
|
|
121
|
+
"logo_reversed",
|
|
122
|
+
"brand_guide",
|
|
123
|
+
...composedAssetKinds,
|
|
124
|
+
];
|
|
125
|
+
export function isMarkRequiringAssetKind(kind) {
|
|
126
|
+
return markRequiringAssetKinds.includes(kind);
|
|
127
|
+
}
|
|
128
|
+
export const generationLocksSchema = z.object({
|
|
129
|
+
colors: z.boolean().default(false),
|
|
130
|
+
typography: z.boolean().default(false),
|
|
131
|
+
icon: z.boolean().default(false),
|
|
132
|
+
});
|
|
133
|
+
export const createBrandRequestSchema = z
|
|
134
|
+
.object({
|
|
135
|
+
prompt: z.string().min(8).optional(),
|
|
136
|
+
template_id: z.string().optional(),
|
|
137
|
+
name: z.string().min(1).max(80).optional(),
|
|
138
|
+
tagline: z.string().min(1).max(60).optional(),
|
|
139
|
+
assets: z.array(z.enum(assetKinds)).optional(),
|
|
140
|
+
team: z.enum(teamTiers).default("studio"),
|
|
141
|
+
customize: z
|
|
142
|
+
.object({
|
|
143
|
+
palette: z.record(z.string(), z.string()).optional(),
|
|
144
|
+
typography: z.record(z.string(), z.string()).optional(),
|
|
145
|
+
logo_direction: z.string().optional(),
|
|
146
|
+
})
|
|
147
|
+
.optional(),
|
|
148
|
+
creative_direction: creativeDirectionSchema.optional(),
|
|
149
|
+
auto_select_logo: z.boolean().optional(),
|
|
150
|
+
})
|
|
151
|
+
.refine((v) => v.prompt !== undefined || v.template_id !== undefined, {
|
|
152
|
+
message: "either prompt or template_id is required",
|
|
153
|
+
})
|
|
154
|
+
.superRefine((v, ctx) => {
|
|
155
|
+
if (v.assets === undefined || v.assets.length === 0)
|
|
156
|
+
return;
|
|
157
|
+
const missing = requiredAssetKinds.filter((kind) => !v.assets?.includes(kind));
|
|
158
|
+
if (missing.length > 0) {
|
|
159
|
+
ctx.addIssue({
|
|
160
|
+
code: "custom",
|
|
161
|
+
path: ["assets"],
|
|
162
|
+
params: { code: "required_assets_missing" },
|
|
163
|
+
message: `Every new brand includes ${requiredAssetKinds.join(", ")}; missing: ${missing.join(", ")}`,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
const generationLocksPatchSchema = z.object({
|
|
168
|
+
colors: z.boolean().optional(),
|
|
169
|
+
typography: z.boolean().optional(),
|
|
170
|
+
icon: z.boolean().optional(),
|
|
171
|
+
});
|
|
172
|
+
export const updateBrandRequestSchema = z.object({
|
|
173
|
+
name: z.string().min(1).optional(),
|
|
174
|
+
slug: z.string().min(1).optional(),
|
|
175
|
+
locks: generationLocksPatchSchema.optional(),
|
|
176
|
+
});
|
|
177
|
+
export const brandPreviewSchema = z.object({
|
|
178
|
+
palette: z.array(z.string()),
|
|
179
|
+
cover: z.string().nullable(),
|
|
180
|
+
asset_count: z.number().int().nonnegative(),
|
|
181
|
+
logo_url: z.string().nullable(),
|
|
182
|
+
gradient_stops: z.array(z.string()),
|
|
183
|
+
});
|
|
184
|
+
export const brandSchema = z.object({
|
|
185
|
+
id: z.string(),
|
|
186
|
+
workspace_id: z.string(),
|
|
187
|
+
name: z.string(),
|
|
188
|
+
slug: z.string(),
|
|
189
|
+
status: z.enum(brandStatuses),
|
|
190
|
+
current_version_id: z.string().nullable(),
|
|
191
|
+
locks: generationLocksSchema,
|
|
192
|
+
preview: brandPreviewSchema.optional(),
|
|
193
|
+
created_at: z.string().datetime(),
|
|
194
|
+
updated_at: z.string().datetime(),
|
|
195
|
+
});
|
|
196
|
+
export const customImageFormats = [
|
|
197
|
+
"square_1_1",
|
|
198
|
+
"portrait_4_5",
|
|
199
|
+
"story_9_16",
|
|
200
|
+
"landscape_16_9",
|
|
201
|
+
"wide_21_9",
|
|
202
|
+
"photo_3_2",
|
|
203
|
+
"poster_2_3",
|
|
204
|
+
"standard_4_3",
|
|
205
|
+
"auto",
|
|
206
|
+
"instagram_post",
|
|
207
|
+
"story",
|
|
208
|
+
"linkedin_post",
|
|
209
|
+
"ad_banner",
|
|
210
|
+
"custom",
|
|
211
|
+
];
|
|
212
|
+
export const OFFERED_CUSTOM_IMAGE_FORMATS = [
|
|
213
|
+
"square_1_1",
|
|
214
|
+
"portrait_4_5",
|
|
215
|
+
"story_9_16",
|
|
216
|
+
"landscape_16_9",
|
|
217
|
+
"wide_21_9",
|
|
218
|
+
"photo_3_2",
|
|
219
|
+
"poster_2_3",
|
|
220
|
+
"standard_4_3",
|
|
221
|
+
"auto",
|
|
222
|
+
];
|
|
223
|
+
export const MODEL_ASPECT_RATIOS = [
|
|
224
|
+
"auto",
|
|
225
|
+
"21:9",
|
|
226
|
+
"16:9",
|
|
227
|
+
"3:2",
|
|
228
|
+
"4:3",
|
|
229
|
+
"5:4",
|
|
230
|
+
"1:1",
|
|
231
|
+
"4:5",
|
|
232
|
+
"3:4",
|
|
233
|
+
"2:3",
|
|
234
|
+
"9:16",
|
|
235
|
+
];
|
|
236
|
+
export const CUSTOM_IMAGE_ASPECT_RATIOS = {
|
|
237
|
+
square_1_1: "1:1",
|
|
238
|
+
portrait_4_5: "4:5",
|
|
239
|
+
story_9_16: "9:16",
|
|
240
|
+
landscape_16_9: "16:9",
|
|
241
|
+
wide_21_9: "21:9",
|
|
242
|
+
photo_3_2: "3:2",
|
|
243
|
+
poster_2_3: "2:3",
|
|
244
|
+
standard_4_3: "4:3",
|
|
245
|
+
auto: "auto",
|
|
246
|
+
instagram_post: "1:1",
|
|
247
|
+
story: "9:16",
|
|
248
|
+
linkedin_post: "5:4",
|
|
249
|
+
ad_banner: "16:9",
|
|
250
|
+
custom: "1:1",
|
|
251
|
+
};
|
|
252
|
+
export const customSuggestionSchema = z.object({
|
|
253
|
+
name: z
|
|
254
|
+
.string()
|
|
255
|
+
.trim()
|
|
256
|
+
.min(1)
|
|
257
|
+
.max(60)
|
|
258
|
+
.regex(/^[^\u0000-\u001f\u007f]+$/u, "must not contain control characters"),
|
|
259
|
+
prompt: z.string().trim().min(1).max(500),
|
|
260
|
+
format: z.enum(OFFERED_CUSTOM_IMAGE_FORMATS),
|
|
261
|
+
});
|
|
262
|
+
export const brandSuggestionItemSchema = z.object({
|
|
263
|
+
kind: z.enum(suggestionItemKinds),
|
|
264
|
+
tag: z.string(),
|
|
265
|
+
title: z.string(),
|
|
266
|
+
desc: z.string(),
|
|
267
|
+
state: z.enum(["idle", "generating", "ready"]),
|
|
268
|
+
asset_id: z.string().nullable(),
|
|
269
|
+
custom: customSuggestionSchema.nullable().default(null),
|
|
270
|
+
});
|
|
271
|
+
export const brandSuggestionsResponseSchema = z.object({
|
|
272
|
+
items: z.array(brandSuggestionItemSchema),
|
|
273
|
+
});
|
|
274
|
+
export const workspaceSuggestionItemSchema = brandSuggestionItemSchema.extend({
|
|
275
|
+
job_id: z.string().nullable(),
|
|
276
|
+
brand: z.object({
|
|
277
|
+
id: z.string(),
|
|
278
|
+
name: z.string(),
|
|
279
|
+
preview: brandPreviewSchema.optional(),
|
|
280
|
+
}),
|
|
281
|
+
});
|
|
282
|
+
export const workspaceSuggestionsResponseSchema = z.object({
|
|
283
|
+
items: z.array(workspaceSuggestionItemSchema),
|
|
284
|
+
});
|
|
285
|
+
export const surpriseBriefResponseSchema = z.object({
|
|
286
|
+
name: z.string(),
|
|
287
|
+
tagline: z.string(),
|
|
288
|
+
description: z.string(),
|
|
289
|
+
styles: z.array(z.enum(brandStyles)),
|
|
290
|
+
});
|
|
291
|
+
export const nameStyles = ["compound", "abstract", "evocative", "playful"];
|
|
292
|
+
export const nameIdeasRequestSchema = z.object({
|
|
293
|
+
style: z.enum(nameStyles),
|
|
294
|
+
keyword: z.string().max(80).optional(),
|
|
295
|
+
description: z.string().max(500).optional(),
|
|
296
|
+
});
|
|
297
|
+
export const nameIdeaSchema = z.object({
|
|
298
|
+
name: z.string(),
|
|
299
|
+
hint: z.string(),
|
|
300
|
+
});
|
|
301
|
+
export const nameIdeasResponseSchema = z.object({
|
|
302
|
+
items: z.array(nameIdeaSchema).min(1),
|
|
303
|
+
});
|
|
304
|
+
export const expandBrandRequestSchema = z.object({
|
|
305
|
+
assets: z.array(z.enum(assetKinds)).min(1),
|
|
306
|
+
team: z.enum(teamTiers).optional(),
|
|
307
|
+
custom_image_prompt: z.string().min(1).max(500).optional(),
|
|
308
|
+
custom_image_format: z.enum(customImageFormats).optional(),
|
|
309
|
+
custom_image_name: z
|
|
310
|
+
.string()
|
|
311
|
+
.trim()
|
|
312
|
+
.min(1)
|
|
313
|
+
.max(60)
|
|
314
|
+
.regex(/^[^\u0000-\u001f\u007f]+$/u, "must not contain control characters")
|
|
315
|
+
.optional(),
|
|
316
|
+
});
|
|
317
|
+
export const brandRefineRequestSchema = z.object({
|
|
318
|
+
message: z.string().min(1).max(500),
|
|
319
|
+
});
|
|
320
|
+
export const brandDnaSchema = z.object({
|
|
321
|
+
brief: z
|
|
322
|
+
.object({
|
|
323
|
+
industry: z.string(),
|
|
324
|
+
audience: z.string(),
|
|
325
|
+
tone: z.string(),
|
|
326
|
+
keywords: z.array(z.string()),
|
|
327
|
+
constraints: z.array(z.string()),
|
|
328
|
+
})
|
|
329
|
+
.partial(),
|
|
330
|
+
strategy: z
|
|
331
|
+
.object({
|
|
332
|
+
positioning: z.string(),
|
|
333
|
+
archetype: z.string(),
|
|
334
|
+
values: z.array(z.string()),
|
|
335
|
+
name: z.string(),
|
|
336
|
+
tagline: z.string(),
|
|
337
|
+
name_rationale: z.string(),
|
|
338
|
+
})
|
|
339
|
+
.partial(),
|
|
340
|
+
visual_system: z
|
|
341
|
+
.object({
|
|
342
|
+
palette: z
|
|
343
|
+
.object({ tokens: z.array(z.object({ name: z.string(), hex: z.string() })) })
|
|
344
|
+
.partial(),
|
|
345
|
+
typography: z
|
|
346
|
+
.object({
|
|
347
|
+
heading_font: z.string(),
|
|
348
|
+
body_font: z.string(),
|
|
349
|
+
mono_font: z.string().nullable(),
|
|
350
|
+
})
|
|
351
|
+
.partial(),
|
|
352
|
+
})
|
|
353
|
+
.partial()
|
|
354
|
+
.optional(),
|
|
355
|
+
});
|
|
356
|
+
export const brandVersionSummarySchema = z.object({
|
|
357
|
+
id: z.string(),
|
|
358
|
+
version_no: z.number().int(),
|
|
359
|
+
message: z.string().nullable(),
|
|
360
|
+
created_by: z.string(),
|
|
361
|
+
qa_score: z.number().int().nullable(),
|
|
362
|
+
created_at: z.string().datetime(),
|
|
363
|
+
is_current: z.boolean(),
|
|
364
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const aiTeamSchema: z.ZodObject<{
|
|
3
|
+
tier: z.ZodEnum<{
|
|
4
|
+
flash: "flash";
|
|
5
|
+
studio: "studio";
|
|
6
|
+
elite: "elite";
|
|
7
|
+
}>;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
multiplier: z.ZodNumber;
|
|
10
|
+
tagline: z.ZodString;
|
|
11
|
+
variants: z.ZodNumber;
|
|
12
|
+
agents_label: z.ZodString;
|
|
13
|
+
speed: z.ZodString;
|
|
14
|
+
qa: z.ZodBoolean;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const templateSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
category: z.ZodString;
|
|
20
|
+
description: z.ZodString;
|
|
21
|
+
prompt: z.ZodString;
|
|
22
|
+
accent: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type AiTeam = z.infer<typeof aiTeamSchema>;
|
|
25
|
+
export type Template = z.infer<typeof templateSchema>;
|
|
26
|
+
export declare const AI_TEAMS: AiTeam[];
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { teamTiers } from "./brands.js";
|
|
3
|
+
import { CREDIT_MULTIPLIERS } from "./pricing.js";
|
|
4
|
+
export const aiTeamSchema = z.object({
|
|
5
|
+
tier: z.enum(teamTiers),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
multiplier: z.number(),
|
|
8
|
+
tagline: z.string(),
|
|
9
|
+
variants: z.number().int(),
|
|
10
|
+
agents_label: z.string(),
|
|
11
|
+
speed: z.string(),
|
|
12
|
+
qa: z.boolean(),
|
|
13
|
+
});
|
|
14
|
+
export const templateSchema = z.object({
|
|
15
|
+
id: z.string(),
|
|
16
|
+
name: z.string(),
|
|
17
|
+
category: z.string(),
|
|
18
|
+
description: z.string(),
|
|
19
|
+
prompt: z.string(),
|
|
20
|
+
accent: z.string(),
|
|
21
|
+
});
|
|
22
|
+
export const AI_TEAMS = [
|
|
23
|
+
{
|
|
24
|
+
tier: "flash",
|
|
25
|
+
name: "Flash",
|
|
26
|
+
multiplier: CREDIT_MULTIPLIERS.flash,
|
|
27
|
+
tagline: "Fast drafts from a lean team. One variant per asset.",
|
|
28
|
+
variants: 1,
|
|
29
|
+
agents_label: "3 agents",
|
|
30
|
+
speed: "Fastest",
|
|
31
|
+
qa: false,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
tier: "studio",
|
|
35
|
+
name: "Studio",
|
|
36
|
+
multiplier: CREDIT_MULTIPLIERS.studio,
|
|
37
|
+
tagline: "The balanced default. Opus strategy and 2-3 variants.",
|
|
38
|
+
variants: 3,
|
|
39
|
+
agents_label: "5 agents",
|
|
40
|
+
speed: "Balanced",
|
|
41
|
+
qa: false,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
tier: "elite",
|
|
45
|
+
name: "Elite",
|
|
46
|
+
multiplier: CREDIT_MULTIPLIERS.elite,
|
|
47
|
+
tagline: "Extra variants plus a Brand Guardian QA pass.",
|
|
48
|
+
variants: 6,
|
|
49
|
+
agents_label: "6 agents",
|
|
50
|
+
speed: "Most thorough",
|
|
51
|
+
qa: true,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CONSENT_TYPES: readonly ["cookie_consent", "privacy_choice", "terms_acceptance", "purchase_disclosure"];
|
|
3
|
+
export type ConsentType = (typeof CONSENT_TYPES)[number];
|
|
4
|
+
export declare const TERMS_CHECKBOX_TEXT = "I agree to the Terms of Service.";
|
|
5
|
+
export declare const ACCEPTED_VERSIONS: {
|
|
6
|
+
readonly terms: "1.0";
|
|
7
|
+
readonly aup: "1.0";
|
|
8
|
+
};
|
|
9
|
+
export declare function isCanonicalTermsAcceptance(input: {
|
|
10
|
+
checkbox_text: string;
|
|
11
|
+
accepted_versions: Record<string, string>;
|
|
12
|
+
}): boolean;
|
|
13
|
+
export declare const consentRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
14
|
+
client_id: z.ZodString;
|
|
15
|
+
type: z.ZodLiteral<"cookie_consent">;
|
|
16
|
+
region: z.ZodString;
|
|
17
|
+
categories: z.ZodArray<z.ZodString>;
|
|
18
|
+
banner_version: z.ZodNumber;
|
|
19
|
+
gpc: z.ZodBoolean;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
client_id: z.ZodString;
|
|
22
|
+
type: z.ZodLiteral<"privacy_choice">;
|
|
23
|
+
region: z.ZodString;
|
|
24
|
+
choices: z.ZodRecord<z.ZodString, z.ZodBoolean>;
|
|
25
|
+
gpc: z.ZodBoolean;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
client_id: z.ZodString;
|
|
28
|
+
type: z.ZodLiteral<"terms_acceptance">;
|
|
29
|
+
checkbox_text: z.ZodString;
|
|
30
|
+
accepted_versions: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
31
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
32
|
+
client_id: z.ZodString;
|
|
33
|
+
type: z.ZodLiteral<"purchase_disclosure">;
|
|
34
|
+
idempotency_key: z.ZodString;
|
|
35
|
+
price_id: z.ZodString;
|
|
36
|
+
kind: z.ZodEnum<{
|
|
37
|
+
plan: "plan";
|
|
38
|
+
topup: "topup";
|
|
39
|
+
}>;
|
|
40
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
studio: "studio";
|
|
42
|
+
pro: "pro";
|
|
43
|
+
agency: "agency";
|
|
44
|
+
}>>;
|
|
45
|
+
credits: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<100>, z.ZodLiteral<300>, z.ZodLiteral<1000>]>>;
|
|
46
|
+
amount: z.ZodString;
|
|
47
|
+
currency: z.ZodString;
|
|
48
|
+
billing_period: z.ZodEnum<{
|
|
49
|
+
month: "month";
|
|
50
|
+
one_time: "one_time";
|
|
51
|
+
}>;
|
|
52
|
+
renewal_text: z.ZodOptional<z.ZodString>;
|
|
53
|
+
disclosure_version: z.ZodNumber;
|
|
54
|
+
}, z.core.$strip>], "type">;
|
|
55
|
+
export type ConsentRequest = z.infer<typeof consentRequestSchema>;
|
|
56
|
+
export declare const consentResponseSchema: z.ZodObject<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
recorded_at: z.ZodString;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type ConsentResponse = z.infer<typeof consentResponseSchema>;
|
package/dist/consent.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const CONSENT_TYPES = [
|
|
3
|
+
"cookie_consent",
|
|
4
|
+
"privacy_choice",
|
|
5
|
+
"terms_acceptance",
|
|
6
|
+
"purchase_disclosure",
|
|
7
|
+
];
|
|
8
|
+
const base = { client_id: z.string().min(1).max(128) };
|
|
9
|
+
const MAX_RECORD_KEYS = 32;
|
|
10
|
+
const withKeyCap = (schema) => schema.refine((value) => Object.keys(value).length <= MAX_RECORD_KEYS, { message: `Too many keys (max ${MAX_RECORD_KEYS}).` });
|
|
11
|
+
const cookieConsent = z.object({
|
|
12
|
+
type: z.literal("cookie_consent"),
|
|
13
|
+
region: z.string().min(1).max(16),
|
|
14
|
+
categories: z.array(z.string().min(1).max(64)).max(16),
|
|
15
|
+
banner_version: z.number().int().nonnegative(),
|
|
16
|
+
gpc: z.boolean(),
|
|
17
|
+
...base,
|
|
18
|
+
});
|
|
19
|
+
const privacyChoice = z.object({
|
|
20
|
+
type: z.literal("privacy_choice"),
|
|
21
|
+
region: z.string().min(1).max(16),
|
|
22
|
+
choices: withKeyCap(z.record(z.string().min(1).max(64), z.boolean())),
|
|
23
|
+
gpc: z.boolean(),
|
|
24
|
+
...base,
|
|
25
|
+
});
|
|
26
|
+
const termsAcceptance = z.object({
|
|
27
|
+
type: z.literal("terms_acceptance"),
|
|
28
|
+
checkbox_text: z.string().min(1).max(512),
|
|
29
|
+
accepted_versions: withKeyCap(z.record(z.string().min(1).max(64), z.string().max(32))),
|
|
30
|
+
...base,
|
|
31
|
+
});
|
|
32
|
+
export const TERMS_CHECKBOX_TEXT = "I agree to the Terms of Service.";
|
|
33
|
+
export const ACCEPTED_VERSIONS = { terms: "1.0", aup: "1.0" };
|
|
34
|
+
export function isCanonicalTermsAcceptance(input) {
|
|
35
|
+
if (input.checkbox_text !== TERMS_CHECKBOX_TEXT)
|
|
36
|
+
return false;
|
|
37
|
+
const expected = Object.entries(ACCEPTED_VERSIONS);
|
|
38
|
+
if (Object.keys(input.accepted_versions).length !== expected.length)
|
|
39
|
+
return false;
|
|
40
|
+
return expected.every(([document, version]) => input.accepted_versions[document] === version);
|
|
41
|
+
}
|
|
42
|
+
const purchaseDisclosure = z.object({
|
|
43
|
+
type: z.literal("purchase_disclosure"),
|
|
44
|
+
idempotency_key: z.string().min(1).max(128),
|
|
45
|
+
price_id: z.string().min(1).max(255),
|
|
46
|
+
kind: z.enum(["plan", "topup"]),
|
|
47
|
+
plan: z.enum(["pro", "studio", "agency"]).optional(),
|
|
48
|
+
credits: z.union([z.literal(100), z.literal(300), z.literal(1000)]).optional(),
|
|
49
|
+
amount: z.string().min(1).max(32),
|
|
50
|
+
currency: z.string().min(1).max(8),
|
|
51
|
+
billing_period: z.enum(["month", "one_time"]),
|
|
52
|
+
renewal_text: z.string().min(1).max(512).optional(),
|
|
53
|
+
disclosure_version: z.number().int().nonnegative(),
|
|
54
|
+
...base,
|
|
55
|
+
});
|
|
56
|
+
export const consentRequestSchema = z.discriminatedUnion("type", [
|
|
57
|
+
cookieConsent,
|
|
58
|
+
privacyChoice,
|
|
59
|
+
termsAcceptance,
|
|
60
|
+
purchaseDisclosure,
|
|
61
|
+
]);
|
|
62
|
+
export const consentResponseSchema = z.object({
|
|
63
|
+
id: z.string(),
|
|
64
|
+
recorded_at: z.string().datetime(),
|
|
65
|
+
});
|