@ingram-cloud/sdk 1.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 (64) hide show
  1. package/README.md +74 -0
  2. package/dist/client.js +460 -0
  3. package/dist/events.js +108 -0
  4. package/dist/index.js +19 -0
  5. package/dist/responses.js +12 -0
  6. package/dist/schemas.js +4 -0
  7. package/dist/zod/_page.js +17 -0
  8. package/dist/zod/agents.js +176 -0
  9. package/dist/zod/approvals.js +38 -0
  10. package/dist/zod/budgets.js +62 -0
  11. package/dist/zod/catalog.js +49 -0
  12. package/dist/zod/connections.js +75 -0
  13. package/dist/zod/conversations.js +91 -0
  14. package/dist/zod/customers.js +53 -0
  15. package/dist/zod/deployments.js +81 -0
  16. package/dist/zod/discord.js +32 -0
  17. package/dist/zod/email.js +45 -0
  18. package/dist/zod/files.js +55 -0
  19. package/dist/zod/index.js +35 -0
  20. package/dist/zod/mcp.js +107 -0
  21. package/dist/zod/memories.js +43 -0
  22. package/dist/zod/observability.js +133 -0
  23. package/dist/zod/projects.js +58 -0
  24. package/dist/zod/runs.js +119 -0
  25. package/dist/zod/schedules.js +71 -0
  26. package/dist/zod/slack.js +69 -0
  27. package/dist/zod/smith-revisions.js +42 -0
  28. package/dist/zod/smiths.js +108 -0
  29. package/dist/zod/telegram.js +36 -0
  30. package/dist/zod/tenant.js +219 -0
  31. package/dist/zod/vector-stores.js +251 -0
  32. package/dist/zod/whatsapp.js +47 -0
  33. package/package.json +56 -0
  34. package/ts/client.ts +1187 -0
  35. package/ts/events.ts +119 -0
  36. package/ts/index.ts +20 -0
  37. package/ts/responses.ts +83 -0
  38. package/ts/schemas.ts +4 -0
  39. package/ts/zod/_page.ts +18 -0
  40. package/ts/zod/agents.ts +202 -0
  41. package/ts/zod/approvals.ts +44 -0
  42. package/ts/zod/budgets.ts +75 -0
  43. package/ts/zod/catalog.ts +57 -0
  44. package/ts/zod/connections.ts +87 -0
  45. package/ts/zod/conversations.ts +103 -0
  46. package/ts/zod/customers.ts +62 -0
  47. package/ts/zod/deployments.ts +93 -0
  48. package/ts/zod/discord.ts +39 -0
  49. package/ts/zod/email.ts +52 -0
  50. package/ts/zod/files.ts +62 -0
  51. package/ts/zod/index.ts +35 -0
  52. package/ts/zod/mcp.ts +123 -0
  53. package/ts/zod/memories.ts +53 -0
  54. package/ts/zod/observability.ts +155 -0
  55. package/ts/zod/projects.ts +68 -0
  56. package/ts/zod/runs.ts +135 -0
  57. package/ts/zod/schedules.ts +82 -0
  58. package/ts/zod/slack.ts +79 -0
  59. package/ts/zod/smith-revisions.ts +50 -0
  60. package/ts/zod/smiths.ts +118 -0
  61. package/ts/zod/telegram.ts +43 -0
  62. package/ts/zod/tenant.ts +267 -0
  63. package/ts/zod/vector-stores.ts +296 -0
  64. package/ts/zod/whatsapp.ts +54 -0
@@ -0,0 +1,296 @@
1
+ /**
2
+ * Hand-authored Zod schemas for the `vector_stores` resource — the wire's
3
+ * source of truth, mapped onto the OpenAI **Vector Stores API** so an OpenAI
4
+ * client library talks to it unchanged.
5
+ *
6
+ * Standards mapping: objects, statuses, chunking strategies, the attribute
7
+ * filter grammar, and the `search_results.page` envelope are OpenAI's, wart for
8
+ * wart (modify is `POST`, the batch object is `vector_store.files_batch`, the
9
+ * search page uses a `next_page` token while CRUD lists use `first_id`/
10
+ * `last_id`). `smith_id` is the one documented IC extension: it scopes a store
11
+ * to a single smith ("" = tenant-wide), the same isolation boundary every other
12
+ * smith-owned resource has. Expiration policies (`expires_after`), query
13
+ * rewriting, and rankers are not implemented — the fields don't exist here
14
+ * rather than being accepted and ignored.
15
+ */
16
+ import { z } from "zod";
17
+
18
+ // ── Chunking ─────────────────────────────────────────────────────────────────
19
+
20
+ /** Static chunking params. Overlap must not exceed half the chunk size. */
21
+ export const StaticChunkingConfig = z
22
+ .object({
23
+ max_chunk_size_tokens: z.number().int().min(100).max(4096),
24
+ chunk_overlap_tokens: z.number().int().min(0),
25
+ })
26
+ .refine((v) => v.chunk_overlap_tokens <= Math.floor(v.max_chunk_size_tokens / 2), {
27
+ message: "chunk_overlap_tokens must not exceed max_chunk_size_tokens / 2",
28
+ });
29
+
30
+ /** Request-side chunking strategy: `auto` (800/400) or explicit `static`. */
31
+ export const ChunkingStrategyIn = z
32
+ .union([
33
+ z.object({ type: z.literal("auto") }),
34
+ z.object({ type: z.literal("static"), static: StaticChunkingConfig }),
35
+ ])
36
+ .meta({ id: "ChunkingStrategyIn" });
37
+
38
+ /** Response-side strategy: always the resolved `static` values (never `auto`). */
39
+ export const ChunkingStrategyOut = z
40
+ .object({
41
+ type: z.literal("static"),
42
+ static: z.object({
43
+ max_chunk_size_tokens: z.number().int(),
44
+ chunk_overlap_tokens: z.number().int(),
45
+ }),
46
+ })
47
+ .meta({ id: "ChunkingStrategyOut" });
48
+
49
+ // ── Attributes & filters ─────────────────────────────────────────────────────
50
+
51
+ /** File attributes: ≤16 keys, key ≤64 chars, value string(≤512)|number|bool. */
52
+ export const VectorStoreAttributes = z
53
+ .record(z.string().max(64), z.union([z.string().max(512), z.number(), z.boolean()]))
54
+ .refine((v) => Object.keys(v).length <= 16, { message: "at most 16 attribute keys" });
55
+
56
+ /** A filter node: a comparison (`type` eq/ne/gt/gte/lt/lte/in/nin over `key`/
57
+ * `value`) or a compound (`type` and/or over nested `filters`). The grammar is
58
+ * recursive; the schema validates one node and the API validates nested nodes
59
+ * when it compiles the filter (the OpenAPI generator cannot express the
60
+ * recursion).
61
+ */
62
+ export const VectorStoreFilter = z
63
+ .object({
64
+ type: z.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "and", "or"]),
65
+ key: z.string().optional(),
66
+ value: z
67
+ .union([
68
+ z.string(),
69
+ z.number(),
70
+ z.boolean(),
71
+ z.array(z.union([z.string(), z.number()])),
72
+ ])
73
+ .optional(),
74
+ filters: z.array(z.record(z.string(), z.unknown())).optional(),
75
+ })
76
+ .meta({ id: "VectorStoreFilter" });
77
+
78
+ export type ICVectorStoreFilter =
79
+ | {
80
+ type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "nin";
81
+ key: string;
82
+ value: string | number | boolean | Array<string | number>;
83
+ }
84
+ | { type: "and" | "or"; filters: ICVectorStoreFilter[] };
85
+
86
+ // ── Vector store ─────────────────────────────────────────────────────────────
87
+
88
+ export const VectorStoreIn = z
89
+ .object({
90
+ name: z.string().optional(),
91
+ description: z.string().optional(),
92
+ /** Files to attach at create; more can be attached later. */
93
+ file_ids: z.array(z.string()).max(500).optional(),
94
+ chunking_strategy: ChunkingStrategyIn.optional(),
95
+ metadata: z.record(z.string(), z.unknown()).optional(),
96
+ /** IC extension: own the store to one smith ("" / omitted = tenant-wide). */
97
+ smith_id: z.string().optional(),
98
+ })
99
+ .meta({ id: "VectorStoreIn" });
100
+
101
+ export const VectorStoreFileCounts = z.object({
102
+ in_progress: z.number().int(),
103
+ completed: z.number().int(),
104
+ failed: z.number().int(),
105
+ cancelled: z.number().int(),
106
+ total: z.number().int(),
107
+ });
108
+
109
+ /** The OpenAI vector store object (+ `smith_id`, the IC extension). */
110
+ export const VectorStoreOut = z
111
+ .object({
112
+ id: z.string(),
113
+ object: z.literal("vector_store"),
114
+ /** Unix seconds, like every OpenAI object. */
115
+ created_at: z.number().int(),
116
+ name: z.string(),
117
+ description: z.string().nullable(),
118
+ usage_bytes: z.number().int(),
119
+ /** `in_progress` while any attached file is still indexing. */
120
+ status: z.enum(["in_progress", "completed"]),
121
+ file_counts: VectorStoreFileCounts,
122
+ /** Unix seconds of the last search against the store. */
123
+ last_active_at: z.number().int().nullable(),
124
+ metadata: z.record(z.string(), z.unknown()),
125
+ /** IC extension: the owning smith ("" = tenant-wide). */
126
+ smith_id: z.string(),
127
+ })
128
+ .meta({ id: "VectorStoreOut" });
129
+
130
+ /** Vector stores, in OpenAI's `list` envelope. */
131
+ export const VectorStoreListOut = z
132
+ .object({
133
+ object: z.literal("list"),
134
+ data: z.array(VectorStoreOut),
135
+ first_id: z.string().nullable(),
136
+ last_id: z.string().nullable(),
137
+ has_more: z.boolean(),
138
+ })
139
+ .meta({ id: "VectorStoreListOut" });
140
+
141
+ /** Modify body (OpenAI uses `POST`, not `PATCH`). */
142
+ export const VectorStorePatch = z
143
+ .object({
144
+ name: z.string().nullish(),
145
+ description: z.string().nullish(),
146
+ metadata: z.record(z.string(), z.unknown()).nullish(),
147
+ })
148
+ .meta({ id: "VectorStorePatch" });
149
+
150
+ export const VectorStoreDeleted = z
151
+ .object({
152
+ id: z.string(),
153
+ object: z.literal("vector_store.deleted"),
154
+ deleted: z.literal(true),
155
+ })
156
+ .meta({ id: "VectorStoreDeleted" });
157
+
158
+ // ── Vector store files ───────────────────────────────────────────────────────
159
+
160
+ export const VectorStoreFileIn = z
161
+ .object({
162
+ file_id: z.string(),
163
+ attributes: VectorStoreAttributes.nullish(),
164
+ chunking_strategy: ChunkingStrategyIn.optional(),
165
+ })
166
+ .meta({ id: "VectorStoreFileIn" });
167
+
168
+ /** The OpenAI vector store file object. Its `id` IS the Files-API file id. */
169
+ export const VectorStoreFileOut = z
170
+ .object({
171
+ id: z.string(),
172
+ object: z.literal("vector_store.file"),
173
+ usage_bytes: z.number().int(),
174
+ created_at: z.number().int(),
175
+ vector_store_id: z.string(),
176
+ status: z.enum(["in_progress", "completed", "failed", "cancelled"]),
177
+ last_error: z
178
+ .object({
179
+ code: z.enum(["server_error", "unsupported_file", "invalid_file"]),
180
+ message: z.string(),
181
+ })
182
+ .nullable(),
183
+ chunking_strategy: ChunkingStrategyOut,
184
+ attributes: VectorStoreAttributes.nullable(),
185
+ })
186
+ .meta({ id: "VectorStoreFileOut" });
187
+
188
+ export const VectorStoreFileListOut = z
189
+ .object({
190
+ object: z.literal("list"),
191
+ data: z.array(VectorStoreFileOut),
192
+ first_id: z.string().nullable(),
193
+ last_id: z.string().nullable(),
194
+ has_more: z.boolean(),
195
+ })
196
+ .meta({ id: "VectorStoreFileListOut" });
197
+
198
+ /** Update body: attributes only (chunking is frozen once indexed). */
199
+ export const VectorStoreFileUpdate = z
200
+ .object({
201
+ attributes: VectorStoreAttributes.nullable(),
202
+ })
203
+ .meta({ id: "VectorStoreFileUpdate" });
204
+
205
+ export const VectorStoreFileDeleted = z
206
+ .object({
207
+ id: z.string(),
208
+ object: z.literal("vector_store.file.deleted"),
209
+ deleted: z.literal(true),
210
+ })
211
+ .meta({ id: "VectorStoreFileDeleted" });
212
+
213
+ // ── File batches ─────────────────────────────────────────────────────────────
214
+
215
+ /** Batch create: either flat `file_ids` (shared attributes/chunking) or
216
+ * per-file `files` entries — exactly one of the two. */
217
+ export const VectorStoreFileBatchIn = z
218
+ .object({
219
+ file_ids: z.array(z.string()).min(1).max(2000).optional(),
220
+ attributes: VectorStoreAttributes.nullish(),
221
+ chunking_strategy: ChunkingStrategyIn.optional(),
222
+ files: z
223
+ .array(
224
+ z.object({
225
+ file_id: z.string(),
226
+ attributes: VectorStoreAttributes.nullish(),
227
+ chunking_strategy: ChunkingStrategyIn.optional(),
228
+ }),
229
+ )
230
+ .min(1)
231
+ .max(2000)
232
+ .optional(),
233
+ })
234
+ .refine((v) => !!v.file_ids !== !!v.files, {
235
+ message: "provide exactly one of file_ids or files",
236
+ })
237
+ .meta({ id: "VectorStoreFileBatchIn" });
238
+
239
+ /** The batch object — wire `object` is `vector_store.files_batch` (plural,
240
+ * matching OpenAI's spec; their docs prose says `file_batch`). */
241
+ export const VectorStoreFileBatchOut = z
242
+ .object({
243
+ id: z.string(),
244
+ object: z.literal("vector_store.files_batch"),
245
+ created_at: z.number().int(),
246
+ vector_store_id: z.string(),
247
+ status: z.enum(["in_progress", "completed", "cancelled", "failed"]),
248
+ file_counts: VectorStoreFileCounts,
249
+ })
250
+ .meta({ id: "VectorStoreFileBatchOut" });
251
+
252
+ // ── Search ───────────────────────────────────────────────────────────────────
253
+
254
+ export const VectorStoreSearchIn = z
255
+ .object({
256
+ query: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
257
+ max_num_results: z.number().int().min(1).max(50).optional(),
258
+ filters: VectorStoreFilter.nullish(),
259
+ ranking_options: z
260
+ .object({
261
+ score_threshold: z.number().min(0).max(1).optional(),
262
+ })
263
+ .optional(),
264
+ })
265
+ .meta({ id: "VectorStoreSearchIn" });
266
+
267
+ export const VectorStoreSearchResult = z
268
+ .object({
269
+ file_id: z.string(),
270
+ filename: z.string(),
271
+ /** Cosine similarity in [0, 1]. */
272
+ score: z.number(),
273
+ attributes: VectorStoreAttributes.nullable(),
274
+ content: z.array(z.object({ type: z.literal("text"), text: z.string() })),
275
+ })
276
+ .meta({ id: "VectorStoreSearchResult" });
277
+
278
+ /** The search page — OpenAI's `search_results.page` envelope. `search_query`
279
+ * is an array even for a single query, per the OpenAI spec. */
280
+ export const VectorStoreSearchOut = z
281
+ .object({
282
+ object: z.literal("vector_store.search_results.page"),
283
+ search_query: z.array(z.string()),
284
+ data: z.array(VectorStoreSearchResult),
285
+ has_more: z.boolean(),
286
+ next_page: z.string().nullable(),
287
+ })
288
+ .meta({ id: "VectorStoreSearchOut" });
289
+
290
+ // ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
291
+
292
+ export type ICVectorStore = z.infer<typeof VectorStoreOut>;
293
+ export type ICVectorStoreFile = z.infer<typeof VectorStoreFileOut>;
294
+ export type ICVectorStoreFileBatch = z.infer<typeof VectorStoreFileBatchOut>;
295
+ export type ICVectorStoreSearchPage = z.infer<typeof VectorStoreSearchOut>;
296
+ export type ICVectorStoreAttributes = z.infer<typeof VectorStoreAttributes>;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Hand-authored Zod schemas for the `whatsapp` channel-config resource — the
3
+ * wire's source of truth, replacing the loose generated shapes for this
4
+ * resource.
5
+ *
6
+ * One source, three outputs: the API imports these into its `createRoute`
7
+ * definitions (validation + emitted OpenAPI), and the consumer-facing `IC*`
8
+ * types are `z.infer`red from them here and re-exported by `../responses`. No
9
+ * Zod is pulled into a type-only consumer — `responses.ts` re-exports these as
10
+ * `export type`.
11
+ *
12
+ * `.meta({ id })` names the component so the emitted OpenAPI references it as
13
+ * `#/components/schemas/<id>` rather than inlining it.
14
+ */
15
+ import { z } from "zod";
16
+
17
+ /**
18
+ * A tenant's WhatsApp number as hosted under Ingram Cloud's shared Meta app.
19
+ * Secrets are never returned; the optional fields are present only once
20
+ * `configured` is true. `display_phone_number` is the E.164 number Meta has on
21
+ * file for the registered `phone_number_id`, and can be null until Meta reports
22
+ * it. `webhook_url` is IC's single app-level webhook (informational — IC
23
+ * subscribes the number to it for you).
24
+ */
25
+ export const WhatsAppConfigOut = z
26
+ .object({
27
+ configured: z.boolean(),
28
+ phone_number_id: z.string().optional(),
29
+ display_phone_number: z.string().nullable().optional(),
30
+ waba_id: z.string().nullable().optional(),
31
+ webhook_url: z.string().optional(),
32
+ })
33
+ .meta({ id: "WhatsAppConfigOut" });
34
+
35
+ // ── Request bodies ──────────────────────────────────────────────────────────
36
+
37
+ /**
38
+ * Register (or rotate) a tenant's WhatsApp number. IC validates the token,
39
+ * subscribes its shared app to the WABA so inbound flows to the app-level
40
+ * webhook, and stores the mapping. All three fields are required; they're
41
+ * optional at the shape layer so the handler returns its specific
42
+ * `empty_config` code rather than a pre-handler `invalid_request`.
43
+ */
44
+ export const WhatsAppConfigIn = z
45
+ .object({
46
+ phone_number_id: z.string().optional(),
47
+ access_token: z.string().optional(),
48
+ waba_id: z.string().optional(),
49
+ })
50
+ .meta({ id: "WhatsAppConfigIn" });
51
+
52
+ // ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
53
+
54
+ export type ICWhatsAppConfig = z.infer<typeof WhatsAppConfigOut>;