@sixb/server 0.0.1

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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/auth/access-token-boundary.d.ts +23 -0
  4. package/dist/auth/access-token-boundary.d.ts.map +1 -0
  5. package/dist/auth/application-access.d.ts +4 -0
  6. package/dist/auth/application-access.d.ts.map +1 -0
  7. package/dist/auth/browser-origin.d.ts +62 -0
  8. package/dist/auth/browser-origin.d.ts.map +1 -0
  9. package/dist/auth/csrf.d.ts +2 -0
  10. package/dist/auth/csrf.d.ts.map +1 -0
  11. package/dist/auth/guard.d.ts +35 -0
  12. package/dist/auth/guard.d.ts.map +1 -0
  13. package/dist/auth/public-routes.d.ts +8 -0
  14. package/dist/auth/public-routes.d.ts.map +1 -0
  15. package/dist/auth/responses.d.ts +11 -0
  16. package/dist/auth/responses.d.ts.map +1 -0
  17. package/dist/auth/return-to.d.ts +3 -0
  18. package/dist/auth/return-to.d.ts.map +1 -0
  19. package/dist/auth/scope.d.ts +43 -0
  20. package/dist/auth/scope.d.ts.map +1 -0
  21. package/dist/auth/session-activity.d.ts +4 -0
  22. package/dist/auth/session-activity.d.ts.map +1 -0
  23. package/dist/auth/session-cookies.d.ts +12 -0
  24. package/dist/auth/session-cookies.d.ts.map +1 -0
  25. package/dist/files/content.d.ts +141 -0
  26. package/dist/files/content.d.ts.map +1 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +11522 -0
  30. package/dist/index.js.map +78 -0
  31. package/dist/openapi/security.d.ts +26 -0
  32. package/dist/openapi/security.d.ts.map +1 -0
  33. package/dist/openapi/tags.d.ts +151 -0
  34. package/dist/openapi/tags.d.ts.map +1 -0
  35. package/dist/registerRoutes.d.ts +31 -0
  36. package/dist/registerRoutes.d.ts.map +1 -0
  37. package/dist/routes/action-runs.d.ts +244 -0
  38. package/dist/routes/action-runs.d.ts.map +1 -0
  39. package/dist/routes/actions.d.ts +183 -0
  40. package/dist/routes/actions.d.ts.map +1 -0
  41. package/dist/routes/agent-api-gateway.d.ts +4 -0
  42. package/dist/routes/agent-api-gateway.d.ts.map +1 -0
  43. package/dist/routes/agents.d.ts +1061 -0
  44. package/dist/routes/agents.d.ts.map +1 -0
  45. package/dist/routes/auth.d.ts +1366 -0
  46. package/dist/routes/auth.d.ts.map +1 -0
  47. package/dist/routes/connectors.d.ts +108 -0
  48. package/dist/routes/connectors.d.ts.map +1 -0
  49. package/dist/routes/datasets.d.ts +339 -0
  50. package/dist/routes/datasets.d.ts.map +1 -0
  51. package/dist/routes/events.d.ts +116 -0
  52. package/dist/routes/events.d.ts.map +1 -0
  53. package/dist/routes/files.d.ts +340 -0
  54. package/dist/routes/files.d.ts.map +1 -0
  55. package/dist/routes/links.d.ts +175 -0
  56. package/dist/routes/links.d.ts.map +1 -0
  57. package/dist/routes/logs.d.ts +88 -0
  58. package/dist/routes/logs.d.ts.map +1 -0
  59. package/dist/routes/objects.d.ts +450 -0
  60. package/dist/routes/objects.d.ts.map +1 -0
  61. package/dist/routes/ontology.d.ts +240 -0
  62. package/dist/routes/ontology.d.ts.map +1 -0
  63. package/dist/routes/pipelines.d.ts +399 -0
  64. package/dist/routes/pipelines.d.ts.map +1 -0
  65. package/dist/routes/project.d.ts +56 -0
  66. package/dist/routes/project.d.ts.map +1 -0
  67. package/dist/routes/projections.d.ts +916 -0
  68. package/dist/routes/projections.d.ts.map +1 -0
  69. package/dist/routes/rules.d.ts +165 -0
  70. package/dist/routes/rules.d.ts.map +1 -0
  71. package/dist/routes/status.d.ts +81 -0
  72. package/dist/routes/status.d.ts.map +1 -0
  73. package/dist/routes/syncs.d.ts +294 -0
  74. package/dist/routes/syncs.d.ts.map +1 -0
  75. package/dist/routes/telemetry.d.ts +241 -0
  76. package/dist/routes/telemetry.d.ts.map +1 -0
  77. package/dist/routes/webhook-runs.d.ts +89 -0
  78. package/dist/routes/webhook-runs.d.ts.map +1 -0
  79. package/dist/routes/webhooks.d.ts +60 -0
  80. package/dist/routes/webhooks.d.ts.map +1 -0
  81. package/dist/routes/workflows.d.ts +973 -0
  82. package/dist/routes/workflows.d.ts.map +1 -0
  83. package/dist/routes/ws/agents.d.ts +99 -0
  84. package/dist/routes/ws/agents.d.ts.map +1 -0
  85. package/dist/routes/ws/events.d.ts +89 -0
  86. package/dist/routes/ws/events.d.ts.map +1 -0
  87. package/dist/routes/ws/index.d.ts +31 -0
  88. package/dist/routes/ws/index.d.ts.map +1 -0
  89. package/dist/routes/ws/log-subscription-hub.d.ts +47 -0
  90. package/dist/routes/ws/log-subscription-hub.d.ts.map +1 -0
  91. package/dist/routes/ws/logs.d.ts +110 -0
  92. package/dist/routes/ws/logs.d.ts.map +1 -0
  93. package/dist/schemas/actions.d.ts +644 -0
  94. package/dist/schemas/actions.d.ts.map +1 -0
  95. package/dist/schemas/agents.d.ts +3157 -0
  96. package/dist/schemas/agents.d.ts.map +1 -0
  97. package/dist/schemas/auth.d.ts +2023 -0
  98. package/dist/schemas/auth.d.ts.map +1 -0
  99. package/dist/schemas/common.d.ts +30 -0
  100. package/dist/schemas/common.d.ts.map +1 -0
  101. package/dist/schemas/connectors.d.ts +82 -0
  102. package/dist/schemas/connectors.d.ts.map +1 -0
  103. package/dist/schemas/datasets.d.ts +744 -0
  104. package/dist/schemas/datasets.d.ts.map +1 -0
  105. package/dist/schemas/event-payloads.d.ts +477 -0
  106. package/dist/schemas/event-payloads.d.ts.map +1 -0
  107. package/dist/schemas/events.d.ts +665 -0
  108. package/dist/schemas/events.d.ts.map +1 -0
  109. package/dist/schemas/files.d.ts +241 -0
  110. package/dist/schemas/files.d.ts.map +1 -0
  111. package/dist/schemas/links.d.ts +90 -0
  112. package/dist/schemas/links.d.ts.map +1 -0
  113. package/dist/schemas/logs.d.ts +231 -0
  114. package/dist/schemas/logs.d.ts.map +1 -0
  115. package/dist/schemas/objects.d.ts +288 -0
  116. package/dist/schemas/objects.d.ts.map +1 -0
  117. package/dist/schemas/ontology.d.ts +778 -0
  118. package/dist/schemas/ontology.d.ts.map +1 -0
  119. package/dist/schemas/pipelines.d.ts +1373 -0
  120. package/dist/schemas/pipelines.d.ts.map +1 -0
  121. package/dist/schemas/project.d.ts +9 -0
  122. package/dist/schemas/project.d.ts.map +1 -0
  123. package/dist/schemas/projections.d.ts +6992 -0
  124. package/dist/schemas/projections.d.ts.map +1 -0
  125. package/dist/schemas/rules.d.ts +204 -0
  126. package/dist/schemas/rules.d.ts.map +1 -0
  127. package/dist/schemas/status.d.ts +189 -0
  128. package/dist/schemas/status.d.ts.map +1 -0
  129. package/dist/schemas/syncs.d.ts +538 -0
  130. package/dist/schemas/syncs.d.ts.map +1 -0
  131. package/dist/schemas/telemetry.d.ts +265 -0
  132. package/dist/schemas/telemetry.d.ts.map +1 -0
  133. package/dist/schemas/webhook-runs.d.ts +169 -0
  134. package/dist/schemas/webhook-runs.d.ts.map +1 -0
  135. package/dist/schemas/workflows.d.ts +1720 -0
  136. package/dist/schemas/workflows.d.ts.map +1 -0
  137. package/dist/server.d.ts +64 -0
  138. package/dist/server.d.ts.map +1 -0
  139. package/dist/tsconfig.json +5 -0
  140. package/dist/utils/http.d.ts +23 -0
  141. package/dist/utils/http.d.ts.map +1 -0
  142. package/dist/utils/request-body.d.ts +15 -0
  143. package/dist/utils/request-body.d.ts.map +1 -0
  144. package/dist/utils/ws.d.ts +10 -0
  145. package/dist/utils/ws.d.ts.map +1 -0
  146. package/package.json +68 -0
  147. package/src/auth/access-token-boundary.ts +68 -0
  148. package/src/auth/application-access.ts +16 -0
  149. package/src/auth/browser-origin.ts +367 -0
  150. package/src/auth/csrf.ts +1 -0
  151. package/src/auth/guard.ts +169 -0
  152. package/src/auth/public-routes.ts +87 -0
  153. package/src/auth/responses.ts +54 -0
  154. package/src/auth/return-to.ts +21 -0
  155. package/src/auth/scope.ts +64 -0
  156. package/src/auth/session-activity.ts +19 -0
  157. package/src/auth/session-cookies.ts +43 -0
  158. package/src/files/content.ts +419 -0
  159. package/src/index.ts +2 -0
  160. package/src/openapi/security.ts +37 -0
  161. package/src/openapi/tags.ts +151 -0
  162. package/src/registerRoutes.ts +49 -0
  163. package/src/routes/action-runs.ts +238 -0
  164. package/src/routes/actions.ts +126 -0
  165. package/src/routes/agent-api-gateway.ts +260 -0
  166. package/src/routes/agents.ts +943 -0
  167. package/src/routes/auth.ts +2233 -0
  168. package/src/routes/connectors.ts +69 -0
  169. package/src/routes/datasets.ts +402 -0
  170. package/src/routes/events.ts +55 -0
  171. package/src/routes/files.ts +675 -0
  172. package/src/routes/links.ts +143 -0
  173. package/src/routes/logs.ts +65 -0
  174. package/src/routes/objects.ts +838 -0
  175. package/src/routes/ontology.ts +138 -0
  176. package/src/routes/pipelines.ts +332 -0
  177. package/src/routes/project.ts +16 -0
  178. package/src/routes/projections.ts +251 -0
  179. package/src/routes/rules.ts +124 -0
  180. package/src/routes/status.ts +53 -0
  181. package/src/routes/syncs.ts +243 -0
  182. package/src/routes/telemetry.ts +207 -0
  183. package/src/routes/webhook-runs.ts +81 -0
  184. package/src/routes/webhooks.ts +508 -0
  185. package/src/routes/workflows.ts +1333 -0
  186. package/src/routes/ws/agents.ts +301 -0
  187. package/src/routes/ws/events.ts +278 -0
  188. package/src/routes/ws/index.ts +12 -0
  189. package/src/routes/ws/log-subscription-hub.ts +375 -0
  190. package/src/routes/ws/logs.ts +117 -0
  191. package/src/schemas/actions.ts +123 -0
  192. package/src/schemas/agents.ts +293 -0
  193. package/src/schemas/auth.ts +317 -0
  194. package/src/schemas/common.ts +60 -0
  195. package/src/schemas/connectors.ts +21 -0
  196. package/src/schemas/datasets.ts +107 -0
  197. package/src/schemas/event-payloads.ts +79 -0
  198. package/src/schemas/events.ts +117 -0
  199. package/src/schemas/files.ts +82 -0
  200. package/src/schemas/links.ts +38 -0
  201. package/src/schemas/logs.ts +76 -0
  202. package/src/schemas/objects.ts +759 -0
  203. package/src/schemas/ontology.ts +77 -0
  204. package/src/schemas/pipelines.ts +150 -0
  205. package/src/schemas/project.ts +5 -0
  206. package/src/schemas/projections.ts +144 -0
  207. package/src/schemas/rules.ts +98 -0
  208. package/src/schemas/status.ts +51 -0
  209. package/src/schemas/syncs.ts +83 -0
  210. package/src/schemas/telemetry.ts +59 -0
  211. package/src/schemas/webhook-runs.ts +40 -0
  212. package/src/schemas/workflows.ts +229 -0
  213. package/src/server.ts +383 -0
  214. package/src/utils/http.ts +108 -0
  215. package/src/utils/request-body.ts +62 -0
  216. package/src/utils/ws.ts +59 -0
@@ -0,0 +1,759 @@
1
+ import type { ElysiaOpenAPIConfig } from "@elysiajs/openapi"
2
+ import { z } from "zod"
3
+ import { JsonValueSchema } from "./common"
4
+
5
+ type OpenApiSchemas = NonNullable<
6
+ NonNullable<ElysiaOpenAPIConfig["documentation"]>["components"]
7
+ >["schemas"]
8
+
9
+ export const ObjectParamsSchema = z.object({
10
+ objectTypeId: z.string().min(1),
11
+ objectId: z.string().min(1),
12
+ })
13
+
14
+ export const ObjectSearchQuerySchema = z.object({
15
+ q: z.string().trim().min(1).max(200),
16
+ limit: z.string().regex(/^\d+$/).optional(),
17
+ })
18
+
19
+ export const ObjectSearchResponseSchema = z.object({
20
+ items: z.array(
21
+ z.object({
22
+ ref: z.object({
23
+ objectTypeId: z.string(),
24
+ primaryId: z.string(),
25
+ }),
26
+ label: z.string(),
27
+ })
28
+ ),
29
+ })
30
+
31
+ const OBJECT_LIST_MAX_LIMIT = 1_000
32
+ const Rfc3339DateSchema = z.string().datetime({ offset: true })
33
+
34
+ function objectListDateSchema(parameter: string) {
35
+ return z
36
+ .string()
37
+ .refine((value) => Rfc3339DateSchema.safeParse(value).success, {
38
+ message: `Invalid query parameter '${parameter}': expected an RFC 3339 timestamp.`,
39
+ })
40
+ .transform((value) => new Date(value))
41
+ }
42
+
43
+ const ObjectListLimitSchema = z
44
+ .string()
45
+ .refine(
46
+ (value) => {
47
+ if (!/^\d+$/.test(value)) return false
48
+ const parsed = Number(value)
49
+ return Number.isSafeInteger(parsed) && parsed <= OBJECT_LIST_MAX_LIMIT
50
+ },
51
+ {
52
+ message: `Invalid query parameter 'limit': expected an integer between 0 and ${OBJECT_LIST_MAX_LIMIT}.`,
53
+ }
54
+ )
55
+ .transform(Number)
56
+
57
+ const ObjectListOffsetSchema = z
58
+ .string()
59
+ .refine((value) => /^\d+$/.test(value) && Number.isSafeInteger(Number(value)), {
60
+ message: "Invalid query parameter 'offset': expected a non-negative safe integer.",
61
+ })
62
+ .transform(Number)
63
+
64
+ export const ObjectsQuerySchema = z
65
+ .object({
66
+ objectTypeId: z.string().optional(),
67
+ idPrefix: z.string().optional(),
68
+ idSuffix: z.string().optional(),
69
+ updatedAfter: objectListDateSchema("updatedAfter").optional(),
70
+ updatedBefore: objectListDateSchema("updatedBefore").optional(),
71
+ createdAfter: objectListDateSchema("createdAfter").optional(),
72
+ createdBefore: objectListDateSchema("createdBefore").optional(),
73
+ limit: ObjectListLimitSchema.optional(),
74
+ offset: ObjectListOffsetSchema.optional(),
75
+ orderBy: z
76
+ .enum(["createdAt", "updatedAt", "primaryId"], {
77
+ errorMap: () => ({
78
+ message:
79
+ "Invalid query parameter 'orderBy': expected one of createdAt, updatedAt, or primaryId.",
80
+ }),
81
+ })
82
+ .optional(),
83
+ order: z
84
+ .enum(["asc", "desc"], {
85
+ errorMap: () => ({
86
+ message: "Invalid query parameter 'order': expected 'asc' or 'desc'.",
87
+ }),
88
+ })
89
+ .optional(),
90
+ })
91
+ .superRefine((query, context) => {
92
+ if (query.updatedAfter && query.updatedBefore && query.updatedAfter > query.updatedBefore) {
93
+ context.addIssue({
94
+ code: z.ZodIssueCode.custom,
95
+ path: ["updatedAfter"],
96
+ message:
97
+ "Invalid query parameter range: 'updatedAfter' must be before or equal to 'updatedBefore'.",
98
+ })
99
+ }
100
+ if (query.createdAfter && query.createdBefore && query.createdAfter > query.createdBefore) {
101
+ context.addIssue({
102
+ code: z.ZodIssueCode.custom,
103
+ path: ["createdAfter"],
104
+ message:
105
+ "Invalid query parameter range: 'createdAfter' must be before or equal to 'createdBefore'.",
106
+ })
107
+ }
108
+ })
109
+
110
+ export const UpsertObjectBodySchema = z.object({
111
+ properties: z.record(z.unknown()),
112
+ })
113
+
114
+ export const ObjectQueryPredicateSchema: z.ZodType<unknown> = z.lazy(() =>
115
+ z.union([
116
+ z
117
+ .object({
118
+ op: z.enum(["and", "or"]),
119
+ items: z.array(ObjectQueryPredicateSchema),
120
+ })
121
+ .strict(),
122
+ z
123
+ .object({
124
+ op: z.literal("not"),
125
+ item: ObjectQueryPredicateSchema,
126
+ })
127
+ .strict(),
128
+ z
129
+ .object({
130
+ op: z.enum(["eq", "neq", "lt", "lte", "gt", "gte"]),
131
+ propertyId: z.string().min(1),
132
+ value: JsonValueSchema,
133
+ })
134
+ .strict(),
135
+ z
136
+ .object({
137
+ op: z.literal("in"),
138
+ propertyId: z.string().min(1),
139
+ values: z.array(JsonValueSchema),
140
+ })
141
+ .strict(),
142
+ z
143
+ .object({
144
+ op: z.literal("exists"),
145
+ propertyId: z.string().min(1),
146
+ value: z.boolean(),
147
+ })
148
+ .strict(),
149
+ z
150
+ .object({
151
+ op: z.literal("contains"),
152
+ propertyId: z.string().min(1),
153
+ value: JsonValueSchema,
154
+ })
155
+ .strict(),
156
+ ])
157
+ )
158
+
159
+ export const ObjectQuerySortFieldSchema = z.union([
160
+ z
161
+ .object({
162
+ kind: z.literal("property"),
163
+ propertyId: z.string().min(1),
164
+ direction: z.enum(["asc", "desc"]).optional(),
165
+ })
166
+ .strict(),
167
+ z
168
+ .object({
169
+ kind: z.literal("relevance"),
170
+ direction: z.enum(["asc", "desc"]).optional(),
171
+ })
172
+ .strict(),
173
+ ])
174
+
175
+ export const ObjectExpansionSchema: z.ZodType<unknown> = z.lazy(() =>
176
+ z
177
+ .object({
178
+ linkId: z.string().min(1),
179
+ direction: z.enum(["outgoing", "incoming"]),
180
+ sourceObjectTypeId: z.string().min(1).optional(),
181
+ limit: z.number().int().nonnegative().optional(),
182
+ orderBy: z.array(ObjectQuerySortFieldSchema).optional(),
183
+ expand: z.array(ObjectExpansionSchema).optional(),
184
+ })
185
+ .strict()
186
+ )
187
+
188
+ export const ObjectQuerySchema: z.ZodType<unknown> = z.lazy(() =>
189
+ z.discriminatedUnion("kind", [
190
+ z
191
+ .object({
192
+ kind: z.literal("start"),
193
+ objectTypeId: z.string().min(1),
194
+ includeSubtypes: z.boolean().optional(),
195
+ })
196
+ .strict(),
197
+ z
198
+ .object({
199
+ kind: z.literal("filter"),
200
+ input: ObjectQuerySchema,
201
+ predicate: ObjectQueryPredicateSchema,
202
+ })
203
+ .strict(),
204
+ z
205
+ .object({
206
+ kind: z.literal("text"),
207
+ input: ObjectQuerySchema,
208
+ query: z.string(),
209
+ fields: z.array(z.string().min(1)).optional(),
210
+ })
211
+ .strict(),
212
+ z
213
+ .object({
214
+ kind: z.literal("vector"),
215
+ input: ObjectQuerySchema,
216
+ vector: z.array(z.number().finite()),
217
+ propertyId: z.string().min(1),
218
+ k: z.number().int().positive(),
219
+ })
220
+ .strict(),
221
+ z
222
+ .object({
223
+ kind: z.literal("traverse"),
224
+ input: ObjectQuerySchema,
225
+ linkId: z.string().min(1),
226
+ direction: z.enum(["outgoing", "incoming"]),
227
+ sourceObjectTypeId: z.string().min(1).optional(),
228
+ })
229
+ .strict(),
230
+ z
231
+ .object({
232
+ kind: z.literal("set"),
233
+ op: z.enum(["union", "intersect", "subtract"]),
234
+ inputs: z.array(ObjectQuerySchema),
235
+ })
236
+ .strict(),
237
+ z
238
+ .object({
239
+ kind: z.literal("sort"),
240
+ input: ObjectQuerySchema,
241
+ fields: z.array(ObjectQuerySortFieldSchema),
242
+ })
243
+ .strict(),
244
+ z
245
+ .object({
246
+ kind: z.literal("limit"),
247
+ input: ObjectQuerySchema,
248
+ limit: z.number().int().nonnegative(),
249
+ })
250
+ .strict(),
251
+ z
252
+ .object({
253
+ kind: z.literal("page"),
254
+ input: ObjectQuerySchema,
255
+ pageSize: z.number().int().positive(),
256
+ pageToken: z.string().optional(),
257
+ })
258
+ .strict(),
259
+ z
260
+ .object({
261
+ kind: z.literal("project"),
262
+ input: ObjectQuerySchema,
263
+ properties: z.array(z.string().min(1)).optional(),
264
+ })
265
+ .strict(),
266
+ z
267
+ .object({
268
+ kind: z.literal("expand"),
269
+ input: ObjectQuerySchema,
270
+ expansions: z.array(ObjectExpansionSchema),
271
+ })
272
+ .strict(),
273
+ ])
274
+ )
275
+
276
+ export const ObjectQueryRequestSchema = z
277
+ .object({
278
+ query: ObjectQuerySchema,
279
+ includeTotal: z.boolean().optional(),
280
+ })
281
+ .strict()
282
+
283
+ export const ObjectQueryCountRequestSchema = z
284
+ .object({
285
+ query: ObjectQuerySchema,
286
+ })
287
+ .strict()
288
+
289
+ export const ObjectQueryExistsRequestSchema = z
290
+ .object({
291
+ query: ObjectQuerySchema,
292
+ })
293
+ .strict()
294
+
295
+ export const ObjectQueryFacetRequestSchema = z
296
+ .object({
297
+ propertyId: z.string().min(1),
298
+ limit: z.number().int().positive(),
299
+ })
300
+ .strict()
301
+
302
+ export const ObjectQueryFacetsRequestSchema = z
303
+ .object({
304
+ query: ObjectQuerySchema,
305
+ facets: z.array(ObjectQueryFacetRequestSchema).min(1),
306
+ })
307
+ .strict()
308
+
309
+ export const TwinObjectSchema = z.object({
310
+ primaryId: z.string(),
311
+ objectTypeId: z.string(),
312
+ properties: z.record(z.unknown()),
313
+ createdAt: z.string(),
314
+ updatedAt: z.string(),
315
+ })
316
+
317
+ export const ObjectListResponseSchema = z.object({
318
+ objects: z.array(TwinObjectSchema),
319
+ hasMore: z.boolean(),
320
+ total: z.number(),
321
+ })
322
+
323
+ const anyJsonValueSchema = {}
324
+ const stringArraySchema = { type: "array", items: { type: "string", minLength: 1 } }
325
+ const objectQueryRef = { $ref: "#/components/schemas/ObjectQuery" }
326
+ const objectQueryPredicateRef = { $ref: "#/components/schemas/ObjectQueryPredicate" }
327
+ const objectQuerySortFieldRef = { $ref: "#/components/schemas/ObjectQuerySortField" }
328
+ const objectExpansionRef = { $ref: "#/components/schemas/ObjectExpansion" }
329
+
330
+ /**
331
+ * zod-to-json-schema currently drops recursive z.lazy schemas when the server's
332
+ * OpenAPI config inlines refs. Keep the HTTP validator above in Zod, and provide
333
+ * the recursive request contract directly for generated clients and docs.
334
+ */
335
+ export const ObjectQueryOpenApiSchemas = {
336
+ ErrorResponse: {
337
+ type: "object",
338
+ required: ["error"],
339
+ additionalProperties: false,
340
+ properties: {
341
+ error: { type: "string" },
342
+ },
343
+ },
344
+ ObjectQueryObject: {
345
+ type: "object",
346
+ required: ["primaryId", "objectTypeId", "properties", "createdAt", "updatedAt"],
347
+ additionalProperties: false,
348
+ properties: {
349
+ primaryId: { type: "string" },
350
+ objectTypeId: { type: "string" },
351
+ properties: { type: "object", additionalProperties: true },
352
+ createdAt: { type: "string" },
353
+ updatedAt: { type: "string" },
354
+ // Populated only on the query route, by an `expand` node: linked objects
355
+ // keyed by link id. Recursive (nested expands), so the value references
356
+ // ObjectQueryObject again. `linkProperties` carries relationship metadata
357
+ // on an expanded child.
358
+ links: {
359
+ type: "object",
360
+ additionalProperties: { $ref: "#/components/schemas/ObjectQueryLinkValue" },
361
+ },
362
+ linkProperties: { type: "object", additionalProperties: true },
363
+ },
364
+ },
365
+ // One expanded link value: a single child ("one" cardinality, or null when
366
+ // absent), or an array of children ("many"). Recurses through ObjectQueryObject.
367
+ ObjectQueryLinkValue: {
368
+ oneOf: [
369
+ { $ref: "#/components/schemas/ObjectQueryObject" },
370
+ { type: "array", items: { $ref: "#/components/schemas/ObjectQueryObject" } },
371
+ ],
372
+ nullable: true,
373
+ },
374
+ ObjectQueryIssue: {
375
+ type: "object",
376
+ required: ["path", "code", "message"],
377
+ additionalProperties: false,
378
+ properties: {
379
+ path: { type: "string" },
380
+ code: { type: "string" },
381
+ message: { type: "string" },
382
+ },
383
+ },
384
+ ObjectQueryPlanSummary: {
385
+ type: "object",
386
+ required: ["mode", "providerIssues", "fallbackIssues", "issues"],
387
+ additionalProperties: false,
388
+ properties: {
389
+ mode: { type: "string", enum: ["pushdown", "fallback", "rejected"] },
390
+ providerIssues: {
391
+ type: "array",
392
+ items: { $ref: "#/components/schemas/ObjectQueryIssue" },
393
+ },
394
+ fallbackIssues: {
395
+ type: "array",
396
+ items: { $ref: "#/components/schemas/ObjectQueryIssue" },
397
+ },
398
+ issues: {
399
+ type: "array",
400
+ items: { $ref: "#/components/schemas/ObjectQueryIssue" },
401
+ },
402
+ fallback: {
403
+ type: "object",
404
+ required: ["maxRows", "requiresExplicitBound"],
405
+ additionalProperties: false,
406
+ properties: {
407
+ maxRows: { type: "number" },
408
+ requiresExplicitBound: { type: "boolean" },
409
+ },
410
+ },
411
+ },
412
+ },
413
+ ObjectQueryResponse: {
414
+ type: "object",
415
+ required: ["objects", "hasMore", "plan"],
416
+ additionalProperties: false,
417
+ properties: {
418
+ objects: {
419
+ type: "array",
420
+ items: { $ref: "#/components/schemas/ObjectQueryObject" },
421
+ },
422
+ hasMore: { type: "boolean" },
423
+ total: { type: "number" },
424
+ nextPageToken: { type: "string" },
425
+ plan: { $ref: "#/components/schemas/ObjectQueryPlanSummary" },
426
+ },
427
+ },
428
+ ObjectQueryCountResponse: {
429
+ type: "object",
430
+ required: ["count", "plan"],
431
+ additionalProperties: false,
432
+ properties: {
433
+ count: { type: "number" },
434
+ plan: { $ref: "#/components/schemas/ObjectQueryPlanSummary" },
435
+ },
436
+ },
437
+ ObjectQueryExistsResponse: {
438
+ type: "object",
439
+ required: ["exists", "plan"],
440
+ additionalProperties: false,
441
+ properties: {
442
+ exists: { type: "boolean" },
443
+ plan: { $ref: "#/components/schemas/ObjectQueryPlanSummary" },
444
+ },
445
+ },
446
+ ObjectQueryFacetBucket: {
447
+ type: "object",
448
+ required: ["value", "count"],
449
+ additionalProperties: false,
450
+ properties: {
451
+ value: anyJsonValueSchema,
452
+ count: { type: "number" },
453
+ },
454
+ },
455
+ ObjectQueryFacetResult: {
456
+ type: "object",
457
+ required: ["propertyId", "buckets"],
458
+ additionalProperties: false,
459
+ properties: {
460
+ propertyId: { type: "string" },
461
+ buckets: {
462
+ type: "array",
463
+ items: { $ref: "#/components/schemas/ObjectQueryFacetBucket" },
464
+ },
465
+ },
466
+ },
467
+ ObjectQueryFacetsResponse: {
468
+ type: "object",
469
+ required: ["facets", "plan"],
470
+ additionalProperties: false,
471
+ properties: {
472
+ facets: {
473
+ type: "array",
474
+ items: { $ref: "#/components/schemas/ObjectQueryFacetResult" },
475
+ },
476
+ plan: { $ref: "#/components/schemas/ObjectQueryPlanSummary" },
477
+ },
478
+ },
479
+ ObjectQueryErrorResponse: {
480
+ type: "object",
481
+ required: ["error"],
482
+ additionalProperties: false,
483
+ properties: {
484
+ error: { type: "string" },
485
+ issues: {
486
+ type: "array",
487
+ items: { $ref: "#/components/schemas/ObjectQueryIssue" },
488
+ },
489
+ },
490
+ },
491
+ ObjectQueryRequest: {
492
+ type: "object",
493
+ required: ["query"],
494
+ additionalProperties: false,
495
+ properties: {
496
+ query: objectQueryRef,
497
+ includeTotal: { type: "boolean" },
498
+ },
499
+ },
500
+ ObjectQueryCountRequest: {
501
+ type: "object",
502
+ required: ["query"],
503
+ additionalProperties: false,
504
+ properties: {
505
+ query: objectQueryRef,
506
+ },
507
+ },
508
+ ObjectQueryExistsRequest: {
509
+ type: "object",
510
+ required: ["query"],
511
+ additionalProperties: false,
512
+ properties: {
513
+ query: objectQueryRef,
514
+ },
515
+ },
516
+ ObjectQueryFacetRequest: {
517
+ type: "object",
518
+ required: ["propertyId", "limit"],
519
+ additionalProperties: false,
520
+ properties: {
521
+ propertyId: { type: "string", minLength: 1 },
522
+ limit: { type: "integer", minimum: 1 },
523
+ },
524
+ },
525
+ ObjectQueryFacetsRequest: {
526
+ type: "object",
527
+ required: ["query", "facets"],
528
+ additionalProperties: false,
529
+ properties: {
530
+ query: objectQueryRef,
531
+ facets: {
532
+ type: "array",
533
+ minItems: 1,
534
+ items: { $ref: "#/components/schemas/ObjectQueryFacetRequest" },
535
+ },
536
+ },
537
+ },
538
+ ObjectQuery: {
539
+ oneOf: [
540
+ {
541
+ type: "object",
542
+ required: ["kind", "objectTypeId"],
543
+ additionalProperties: false,
544
+ properties: {
545
+ kind: { type: "string", enum: ["start"] },
546
+ objectTypeId: { type: "string", minLength: 1 },
547
+ includeSubtypes: { type: "boolean" },
548
+ },
549
+ },
550
+ {
551
+ type: "object",
552
+ required: ["kind", "input", "predicate"],
553
+ additionalProperties: false,
554
+ properties: {
555
+ kind: { type: "string", enum: ["filter"] },
556
+ input: objectQueryRef,
557
+ predicate: objectQueryPredicateRef,
558
+ },
559
+ },
560
+ {
561
+ type: "object",
562
+ required: ["kind", "input", "query"],
563
+ additionalProperties: false,
564
+ properties: {
565
+ kind: { type: "string", enum: ["text"] },
566
+ input: objectQueryRef,
567
+ query: { type: "string" },
568
+ fields: stringArraySchema,
569
+ },
570
+ },
571
+ {
572
+ type: "object",
573
+ required: ["kind", "input", "vector", "propertyId", "k"],
574
+ additionalProperties: false,
575
+ properties: {
576
+ kind: { type: "string", enum: ["vector"] },
577
+ input: objectQueryRef,
578
+ vector: { type: "array", items: { type: "number" } },
579
+ propertyId: { type: "string", minLength: 1 },
580
+ k: { type: "integer", minimum: 1 },
581
+ },
582
+ },
583
+ {
584
+ type: "object",
585
+ required: ["kind", "input", "linkId", "direction"],
586
+ additionalProperties: false,
587
+ properties: {
588
+ kind: { type: "string", enum: ["traverse"] },
589
+ input: objectQueryRef,
590
+ linkId: { type: "string", minLength: 1 },
591
+ direction: { type: "string", enum: ["outgoing", "incoming"] },
592
+ sourceObjectTypeId: { type: "string", minLength: 1 },
593
+ },
594
+ },
595
+ {
596
+ type: "object",
597
+ required: ["kind", "op", "inputs"],
598
+ additionalProperties: false,
599
+ properties: {
600
+ kind: { type: "string", enum: ["set"] },
601
+ op: { type: "string", enum: ["union", "intersect", "subtract"] },
602
+ inputs: { type: "array", items: objectQueryRef },
603
+ },
604
+ },
605
+ {
606
+ type: "object",
607
+ required: ["kind", "input", "fields"],
608
+ additionalProperties: false,
609
+ properties: {
610
+ kind: { type: "string", enum: ["sort"] },
611
+ input: objectQueryRef,
612
+ fields: { type: "array", items: objectQuerySortFieldRef },
613
+ },
614
+ },
615
+ {
616
+ type: "object",
617
+ required: ["kind", "input", "limit"],
618
+ additionalProperties: false,
619
+ properties: {
620
+ kind: { type: "string", enum: ["limit"] },
621
+ input: objectQueryRef,
622
+ limit: { type: "integer", minimum: 0 },
623
+ },
624
+ },
625
+ {
626
+ type: "object",
627
+ required: ["kind", "input", "pageSize"],
628
+ additionalProperties: false,
629
+ properties: {
630
+ kind: { type: "string", enum: ["page"] },
631
+ input: objectQueryRef,
632
+ pageSize: { type: "integer", minimum: 1 },
633
+ pageToken: { type: "string" },
634
+ },
635
+ },
636
+ {
637
+ type: "object",
638
+ required: ["kind", "input"],
639
+ additionalProperties: false,
640
+ properties: {
641
+ kind: { type: "string", enum: ["project"] },
642
+ input: objectQueryRef,
643
+ properties: stringArraySchema,
644
+ },
645
+ },
646
+ {
647
+ type: "object",
648
+ required: ["kind", "input", "expansions"],
649
+ additionalProperties: false,
650
+ properties: {
651
+ kind: { type: "string", enum: ["expand"] },
652
+ input: objectQueryRef,
653
+ expansions: { type: "array", items: objectExpansionRef },
654
+ },
655
+ },
656
+ ],
657
+ discriminator: { propertyName: "kind" },
658
+ },
659
+ ObjectExpansion: {
660
+ type: "object",
661
+ required: ["linkId", "direction"],
662
+ additionalProperties: false,
663
+ properties: {
664
+ linkId: { type: "string", minLength: 1 },
665
+ direction: { type: "string", enum: ["outgoing", "incoming"] },
666
+ sourceObjectTypeId: { type: "string", minLength: 1 },
667
+ limit: { type: "integer", minimum: 0 },
668
+ orderBy: { type: "array", items: objectQuerySortFieldRef },
669
+ expand: { type: "array", items: objectExpansionRef },
670
+ },
671
+ },
672
+ ObjectQueryPredicate: {
673
+ oneOf: [
674
+ {
675
+ type: "object",
676
+ required: ["op", "items"],
677
+ additionalProperties: false,
678
+ properties: {
679
+ op: { type: "string", enum: ["and", "or"] },
680
+ items: { type: "array", items: objectQueryPredicateRef },
681
+ },
682
+ },
683
+ {
684
+ type: "object",
685
+ required: ["op", "item"],
686
+ additionalProperties: false,
687
+ properties: {
688
+ op: { type: "string", enum: ["not"] },
689
+ item: objectQueryPredicateRef,
690
+ },
691
+ },
692
+ {
693
+ type: "object",
694
+ required: ["op", "propertyId", "value"],
695
+ additionalProperties: false,
696
+ properties: {
697
+ op: { type: "string", enum: ["eq", "neq", "lt", "lte", "gt", "gte"] },
698
+ propertyId: { type: "string", minLength: 1 },
699
+ value: anyJsonValueSchema,
700
+ },
701
+ },
702
+ {
703
+ type: "object",
704
+ required: ["op", "propertyId", "values"],
705
+ additionalProperties: false,
706
+ properties: {
707
+ op: { type: "string", enum: ["in"] },
708
+ propertyId: { type: "string", minLength: 1 },
709
+ values: { type: "array", items: anyJsonValueSchema },
710
+ },
711
+ },
712
+ {
713
+ type: "object",
714
+ required: ["op", "propertyId", "value"],
715
+ additionalProperties: false,
716
+ properties: {
717
+ op: { type: "string", enum: ["exists"] },
718
+ propertyId: { type: "string", minLength: 1 },
719
+ value: { type: "boolean" },
720
+ },
721
+ },
722
+ {
723
+ type: "object",
724
+ required: ["op", "propertyId", "value"],
725
+ additionalProperties: false,
726
+ properties: {
727
+ op: { type: "string", enum: ["contains"] },
728
+ propertyId: { type: "string", minLength: 1 },
729
+ value: anyJsonValueSchema,
730
+ },
731
+ },
732
+ ],
733
+ discriminator: { propertyName: "op" },
734
+ },
735
+ ObjectQuerySortField: {
736
+ oneOf: [
737
+ {
738
+ type: "object",
739
+ required: ["kind", "propertyId"],
740
+ additionalProperties: false,
741
+ properties: {
742
+ kind: { type: "string", enum: ["property"] },
743
+ propertyId: { type: "string", minLength: 1 },
744
+ direction: { type: "string", enum: ["asc", "desc"] },
745
+ },
746
+ },
747
+ {
748
+ type: "object",
749
+ required: ["kind"],
750
+ additionalProperties: false,
751
+ properties: {
752
+ kind: { type: "string", enum: ["relevance"] },
753
+ direction: { type: "string", enum: ["asc", "desc"] },
754
+ },
755
+ },
756
+ ],
757
+ discriminator: { propertyName: "kind" },
758
+ },
759
+ } as unknown as OpenApiSchemas