@ourofoundation/ouro-js 1.1.4 → 2.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 (104) hide show
  1. package/dist/index.cjs +816 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +7751 -0
  4. package/dist/index.d.ts +7751 -18
  5. package/dist/index.js +755 -1
  6. package/dist/index.js.map +1 -1
  7. package/package.json +19 -36
  8. package/tsup.config.ts +12 -0
  9. package/dist/index.esm.js +0 -2
  10. package/dist/index.esm.js.map +0 -1
  11. package/dist/schema/assets.d.ts +0 -611
  12. package/dist/schema/assets.esm.js +0 -2
  13. package/dist/schema/assets.esm.js.map +0 -1
  14. package/dist/schema/assets.js +0 -2
  15. package/dist/schema/assets.js.map +0 -1
  16. package/dist/schema/blueprints.d.ts +0 -553
  17. package/dist/schema/blueprints.esm.js +0 -2
  18. package/dist/schema/blueprints.esm.js.map +0 -1
  19. package/dist/schema/blueprints.js +0 -2
  20. package/dist/schema/blueprints.js.map +0 -1
  21. package/dist/schema/comments.d.ts +0 -537
  22. package/dist/schema/comments.esm.js +0 -2
  23. package/dist/schema/comments.esm.js.map +0 -1
  24. package/dist/schema/comments.js +0 -2
  25. package/dist/schema/comments.js.map +0 -1
  26. package/dist/schema/common.d.ts +0 -138
  27. package/dist/schema/common.esm.js +0 -2
  28. package/dist/schema/common.esm.js.map +0 -1
  29. package/dist/schema/common.js +0 -2
  30. package/dist/schema/common.js.map +0 -1
  31. package/dist/schema/conversations.d.ts +0 -709
  32. package/dist/schema/conversations.esm.js +0 -2
  33. package/dist/schema/conversations.esm.js.map +0 -1
  34. package/dist/schema/conversations.js +0 -2
  35. package/dist/schema/conversations.js.map +0 -1
  36. package/dist/schema/datasets.d.ts +0 -1056
  37. package/dist/schema/datasets.esm.js +0 -2
  38. package/dist/schema/datasets.esm.js.map +0 -1
  39. package/dist/schema/datasets.js +0 -2
  40. package/dist/schema/datasets.js.map +0 -1
  41. package/dist/schema/files.d.ts +0 -1024
  42. package/dist/schema/files.esm.js +0 -2
  43. package/dist/schema/files.esm.js.map +0 -1
  44. package/dist/schema/files.js +0 -2
  45. package/dist/schema/files.js.map +0 -1
  46. package/dist/schema/index.d.ts +0 -14
  47. package/dist/schema/index.js +0 -63
  48. package/dist/schema/notifications.d.ts +0 -97
  49. package/dist/schema/notifications.esm.js +0 -2
  50. package/dist/schema/notifications.esm.js.map +0 -1
  51. package/dist/schema/notifications.js +0 -2
  52. package/dist/schema/notifications.js.map +0 -1
  53. package/dist/schema/organizations.d.ts +0 -70
  54. package/dist/schema/organizations.esm.js +0 -2
  55. package/dist/schema/organizations.esm.js.map +0 -1
  56. package/dist/schema/organizations.js +0 -2
  57. package/dist/schema/organizations.js.map +0 -1
  58. package/dist/schema/posts.d.ts +0 -1848
  59. package/dist/schema/posts.esm.js +0 -2
  60. package/dist/schema/posts.esm.js.map +0 -1
  61. package/dist/schema/posts.js +0 -2
  62. package/dist/schema/posts.js.map +0 -1
  63. package/dist/schema/replications.d.ts +0 -610
  64. package/dist/schema/replications.esm.js +0 -2
  65. package/dist/schema/replications.esm.js.map +0 -1
  66. package/dist/schema/replications.js +0 -2
  67. package/dist/schema/replications.js.map +0 -1
  68. package/dist/schema/services.d.ts +0 -86
  69. package/dist/schema/services.esm.js +0 -2
  70. package/dist/schema/services.esm.js.map +0 -1
  71. package/dist/schema/services.js +0 -2
  72. package/dist/schema/services.js.map +0 -1
  73. package/dist/schema/teams.d.ts +0 -528
  74. package/dist/schema/teams.esm.js +0 -2
  75. package/dist/schema/teams.esm.js.map +0 -1
  76. package/dist/schema/teams.js +0 -2
  77. package/dist/schema/teams.js.map +0 -1
  78. package/dist/schema/users.d.ts +0 -132
  79. package/dist/schema/users.esm.js +0 -2
  80. package/dist/schema/users.esm.js.map +0 -1
  81. package/dist/schema/users.js +0 -2
  82. package/dist/schema/users.js.map +0 -1
  83. package/dist/types/index.d.ts +0 -14
  84. package/dist/utils/air/index.d.ts +0 -24
  85. package/dist/utils/air/index.esm.js +0 -2
  86. package/dist/utils/air/index.esm.js.map +0 -1
  87. package/dist/utils/air/index.js +0 -2
  88. package/dist/utils/air/index.js.map +0 -1
  89. package/dist/utils/air/markdown-parser.d.ts +0 -1
  90. package/dist/utils/air/markdown-parser.esm.js +0 -2
  91. package/dist/utils/air/markdown-parser.esm.js.map +0 -1
  92. package/dist/utils/air/markdown-parser.js +0 -2
  93. package/dist/utils/air/markdown-parser.js.map +0 -1
  94. package/dist/utils/dataset.d.ts +0 -7
  95. package/dist/utils/dataset.esm.js +0 -2
  96. package/dist/utils/dataset.esm.js.map +0 -1
  97. package/dist/utils/dataset.js +0 -2
  98. package/dist/utils/dataset.js.map +0 -1
  99. package/dist/utils/navigate.d.ts +0 -11
  100. package/dist/utils/navigate.esm.js +0 -2
  101. package/dist/utils/navigate.esm.js.map +0 -1
  102. package/dist/utils/navigate.js +0 -2
  103. package/dist/utils/navigate.js.map +0 -1
  104. package/rollup.config.js +0 -52
package/dist/index.cjs ADDED
@@ -0,0 +1,816 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+ var uuidv7 = require('uuidv7');
5
+ var marked = require('marked');
6
+
7
+ // src/schema/assets.ts
8
+ var AssetTypeSchema = zod.z.enum([
9
+ "user",
10
+ "organization",
11
+ "team",
12
+ "dataset",
13
+ "file",
14
+ "service",
15
+ "route",
16
+ "post",
17
+ "comment",
18
+ "conversation",
19
+ "blueprint",
20
+ "replication"
21
+ ]);
22
+ var VisibilitySchema = zod.z.enum([
23
+ "public",
24
+ "private",
25
+ "organization",
26
+ "monetized",
27
+ "inherit"
28
+ ]);
29
+ var RoleSchema = zod.z.enum(["admin", "read", "write", "none"]);
30
+ var MonetizationSchema = zod.z.enum(["none", "pay-to-unlock", "pay-per-use"]);
31
+ var EmbeddingSchema = zod.z.object({
32
+ id: zod.z.string(),
33
+ user_id: zod.z.string(),
34
+ org_id: zod.z.string().nullable().optional(),
35
+ embedding: zod.z.array(zod.z.number()),
36
+ content: zod.z.string(),
37
+ asset_type: AssetTypeSchema,
38
+ asset_id: zod.z.string(),
39
+ metadata: zod.z.object({}).passthrough().nullable().optional(),
40
+ created_at: zod.z.string(),
41
+ last_updated: zod.z.string()
42
+ });
43
+ var ConnectionTypeSchema = zod.z.enum([
44
+ "comment",
45
+ "reference",
46
+ "mention",
47
+ "action",
48
+ "component"
49
+ ]);
50
+ var ConnectionSchema = zod.z.object({
51
+ id: zod.z.string().uuid(),
52
+ user_id: zod.z.string().uuid(),
53
+ type: ConnectionTypeSchema,
54
+ action_id: zod.z.string().uuid().optional().nullable(),
55
+ source_id: zod.z.string().uuid(),
56
+ target_id: zod.z.string().uuid(),
57
+ source_asset_type: AssetTypeSchema,
58
+ target_asset_type: AssetTypeSchema,
59
+ created_at: zod.z.string(),
60
+ last_updated: zod.z.string()
61
+ });
62
+ var PurchaseAssetSchema = zod.z.object({
63
+ assetId: zod.z.string().uuid(),
64
+ method: zod.z.enum(["checkout", "api"]),
65
+ assetType: AssetTypeSchema
66
+ });
67
+ var PermissionSchema = zod.z.object({
68
+ id: zod.z.string().uuid(),
69
+ role: RoleSchema,
70
+ user: zod.z.object({
71
+ user_id: zod.z.string().uuid()
72
+ }),
73
+ user_id: zod.z.string().uuid().nullable(),
74
+ org_id: zod.z.string().uuid().nullable(),
75
+ asset_type: AssetTypeSchema,
76
+ asset_id: zod.z.string().uuid(),
77
+ created_at: zod.z.string(),
78
+ last_updated: zod.z.string()
79
+ });
80
+ var StatusSchema = zod.z.enum(["queued", "in-progress", "success", "error"]);
81
+ var OrganizationsSchema = zod.z.object({
82
+ id: zod.z.string().uuid(),
83
+ name: zod.z.string(),
84
+ avatar_path: zod.z.string().nullable().optional(),
85
+ mission: zod.z.string().nullable().optional(),
86
+ size: zod.z.string(),
87
+ email: zod.z.string().nullable().optional(),
88
+ domain: zod.z.string().nullable().optional(),
89
+ urls: zod.z.array(
90
+ zod.z.object({
91
+ value: zod.z.string()
92
+ })
93
+ ).nullable().optional(),
94
+ base_role: RoleSchema.default("write")
95
+ });
96
+ var MembershipSchema = zod.z.object({
97
+ id: zod.z.string().uuid(),
98
+ user_id: zod.z.string().uuid(),
99
+ org_id: zod.z.string().uuid(),
100
+ team_id: zod.z.string().uuid(),
101
+ role: RoleSchema,
102
+ added_at: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString()),
103
+ visibility: VisibilitySchema.default("public")
104
+ });
105
+ var ProfileSchema = zod.z.object({
106
+ id: zod.z.string().uuid(),
107
+ user_id: zod.z.string().uuid(),
108
+ username: zod.z.string().optional().nullable(),
109
+ avatar_path: zod.z.string().optional().nullable(),
110
+ bio: zod.z.string().optional().nullable(),
111
+ urls: zod.z.array(
112
+ zod.z.object({
113
+ value: zod.z.string().url()
114
+ })
115
+ ).optional(),
116
+ post_id: zod.z.string().uuid().optional().nullable(),
117
+ last_active: zod.z.string()
118
+ });
119
+ var ReadProfileSchema = ProfileSchema.extend({
120
+ is_agent: zod.z.boolean(),
121
+ isFollowing: zod.z.boolean(),
122
+ isFollowed: zod.z.boolean(),
123
+ isSelf: zod.z.boolean(),
124
+ followers: zod.z.number().default(0),
125
+ following: zod.z.number().default(0)
126
+ });
127
+ var UpdateProfileSchema = ProfileSchema.partial().omit({
128
+ id: true,
129
+ user_id: true,
130
+ last_active: true
131
+ // username: true, // once set, users cannot update their username
132
+ });
133
+
134
+ // src/schema/teams.ts
135
+ var TeamSchema = zod.z.object({
136
+ id: zod.z.string().uuid(),
137
+ org_id: zod.z.string().uuid(),
138
+ name: zod.z.string(),
139
+ description: zod.z.string().nullable().optional(),
140
+ default_role: RoleSchema,
141
+ visibility: VisibilitySchema,
142
+ created_at: zod.z.string()
143
+ });
144
+ var CreateTeamSchema = TeamSchema.extend({
145
+ id: zod.z.string().default(() => uuidv7.uuidv7()),
146
+ default_role: RoleSchema.default("write").refine(
147
+ (v) => v === "read" || v === "write"
148
+ ),
149
+ visibility: VisibilitySchema.default("public").refine(
150
+ (v) => v === "public" || v === "organization"
151
+ ),
152
+ created_at: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
153
+ });
154
+ var ReadTeamSchema = TeamSchema.extend({
155
+ userMembership: zod.z.object({
156
+ user_id: zod.z.string().uuid(),
157
+ role: RoleSchema
158
+ }).optional().nullable(),
159
+ memberCount: zod.z.number(),
160
+ members: zod.z.array(
161
+ zod.z.object({
162
+ user_id: zod.z.string().uuid(),
163
+ role: RoleSchema,
164
+ user: ProfileSchema.partial().optional().nullable()
165
+ })
166
+ ),
167
+ organization: OrganizationsSchema.partial().optional().nullable()
168
+ });
169
+ var ReadTeamsSchema = zod.z.array(
170
+ ReadTeamSchema.extend({
171
+ label: zod.z.string(),
172
+ value: zod.z.string()
173
+ })
174
+ );
175
+ var UpdateTeamSchema = TeamSchema.partial().omit({
176
+ org_id: true,
177
+ created_at: true
178
+ }).extend({
179
+ id: zod.z.string().uuid()
180
+ });
181
+ var AssetSchema = zod.z.object({
182
+ id: zod.z.string().uuid(),
183
+ user_id: zod.z.string().uuid(),
184
+ user: ProfileSchema.partial().optional(),
185
+ org_id: zod.z.string().uuid(),
186
+ organization: OrganizationsSchema.partial().optional(),
187
+ team_id: zod.z.string().uuid(),
188
+ team: TeamSchema.partial().optional(),
189
+ parent_id: zod.z.string().uuid().optional().nullable(),
190
+ // parent: z.lazy(() => AssetSchema.partial()).optional(),
191
+ parent: zod.z.object({}).passthrough().optional(),
192
+ asset_type: AssetTypeSchema,
193
+ name: zod.z.string(),
194
+ name_url_slug: zod.z.string().optional().nullable(),
195
+ slug: zod.z.string().optional().nullable(),
196
+ description: zod.z.string().nullable().optional(),
197
+ visibility: VisibilitySchema,
198
+ // Product information
199
+ monetization: MonetizationSchema,
200
+ price: zod.z.number().nullable().optional(),
201
+ unit_cost: zod.z.number().nullable().optional(),
202
+ cost_accounting: zod.z.enum(["fixed", "variable"]).optional().nullable(),
203
+ cost_unit: zod.z.string().optional().nullable(),
204
+ product_id: zod.z.string().optional().nullable(),
205
+ price_id: zod.z.string().optional().nullable(),
206
+ // Metadata information
207
+ metadata: zod.z.object({}).passthrough().optional().nullable(),
208
+ preview: zod.z.array(zod.z.object({}).passthrough()).optional().nullable(),
209
+ state: StatusSchema.optional().nullable(),
210
+ created_at: zod.z.string(),
211
+ last_updated: zod.z.string()
212
+ });
213
+ var CreateAssetSchema = AssetSchema.partial().omit({
214
+ user_id: true,
215
+ // Remove extended foreign fields
216
+ user: true,
217
+ organization: true,
218
+ team: true,
219
+ // remove added slug
220
+ slug: true
221
+ }).extend({
222
+ id: zod.z.string().uuid().default(() => uuidv7.uuidv7()),
223
+ team_id: zod.z.string().uuid().nullish().default("00000000-0000-0000-0000-000000000000"),
224
+ org_id: zod.z.string().uuid().nullish().default("00000000-0000-0000-0000-000000000000"),
225
+ name: zod.z.string().min(1, {
226
+ message: "Name cannot be empty"
227
+ }).max(255, {
228
+ message: "Name must be less than 255 characters"
229
+ }),
230
+ // name is required for all assets but posts and conversations
231
+ name_url_slug: zod.z.string().optional().nullable(),
232
+ state: StatusSchema.optional().default("success"),
233
+ visibility: VisibilitySchema.optional().default("public"),
234
+ created_at: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString()),
235
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
236
+ });
237
+ var UpdateAssetSchema = AssetSchema.partial().omit({
238
+ id: true,
239
+ user_id: true,
240
+ created_at: true,
241
+ // Remove extended foreign fields
242
+ user: true,
243
+ organization: true,
244
+ team: true,
245
+ // remove added slug
246
+ slug: true
247
+ });
248
+ var CommentSchema = AssetSchema.extend({
249
+ asset_type: zod.z.literal("comment").default("comment"),
250
+ preview: zod.z.object({
251
+ type: zod.z.string().refine((x) => x === "doc"),
252
+ content: zod.z.array(zod.z.object({}).passthrough())
253
+ }).optional().nullable().default({ type: "doc", content: [] })
254
+ });
255
+ var CreateCommentSchema = CommentSchema.partial().omit({
256
+ id: true,
257
+ user_id: true
258
+ }).extend({
259
+ asset_type: zod.z.literal("comment").default("comment"),
260
+ id: zod.z.string().default(() => uuidv7.uuidv7()),
261
+ name: zod.z.string().default(""),
262
+ created_at: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString()),
263
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
264
+ });
265
+ var TipTapNode = zod.z.lazy(
266
+ () => zod.z.object({
267
+ type: zod.z.string(),
268
+ content: zod.z.array(TipTapNode).optional(),
269
+ attrs: zod.z.record(zod.z.any()).optional(),
270
+ marks: zod.z.array(
271
+ zod.z.object({
272
+ type: zod.z.string(),
273
+ attrs: zod.z.record(zod.z.any()).optional()
274
+ })
275
+ ).optional(),
276
+ text: zod.z.string().optional()
277
+ // For text nodes
278
+ })
279
+ );
280
+ var TipTapSchema = zod.z.object({
281
+ type: zod.z.literal("doc"),
282
+ content: zod.z.array(TipTapNode)
283
+ });
284
+ var ContentSchema = zod.z.object({
285
+ json: TipTapSchema,
286
+ text: zod.z.string()
287
+ }).default({ json: { type: "doc", content: [] }, text: "" });
288
+ var PostSchema = AssetSchema.extend({
289
+ name: zod.z.string().nullable(),
290
+ asset_type: AssetTypeSchema.refine((x) => ["post", "comment"].includes(x)),
291
+ // TODO: make this ContentSchema
292
+ preview: TipTapSchema.default({ type: "doc", content: [] }),
293
+ content: ContentSchema
294
+ });
295
+ var CreatePostSchema = CreateAssetSchema.extend({
296
+ asset_type: zod.z.literal("post").default("post"),
297
+ name: zod.z.string().optional().nullable().default("").transform((x) => x == null ? void 0 : x.trim()).transform((x) => x || null),
298
+ preview: TipTapSchema
299
+ });
300
+ var ReadPostSchema = PostSchema.extend({
301
+ content: ContentSchema.optional().nullable().default({
302
+ json: { type: "doc", content: [] },
303
+ text: ""
304
+ }),
305
+ reactions: zod.z.array(zod.z.object({}).passthrough()).default([]),
306
+ views: zod.z.number().default(0),
307
+ commentCount: zod.z.number().default(0),
308
+ // We have this on asset now
309
+ // parent: ConnectionSchema.optional().nullable(),
310
+ pinned: zod.z.boolean().default(false)
311
+ });
312
+ var ReadPostsSchema = zod.z.array(ReadPostSchema);
313
+ var ListPostsSchema = zod.z.array(PostSchema);
314
+ var UpdatePostSchema = PostSchema.partial().omit({
315
+ user_id: true,
316
+ id: true,
317
+ created_at: true,
318
+ last_updated: true,
319
+ content: true,
320
+ organization: true,
321
+ user: true,
322
+ team: true,
323
+ slug: true
324
+ }).extend({
325
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
326
+ });
327
+
328
+ // src/schema/conversations.ts
329
+ var ConversationSchema = AssetSchema.extend({
330
+ metadata: zod.z.object({
331
+ members: zod.z.array(zod.z.string())
332
+ }),
333
+ asset_type: AssetTypeSchema.default("conversation")
334
+ });
335
+ var CreateConversationSchema = ConversationSchema.omit({
336
+ org_id: true,
337
+ team_id: true,
338
+ user_id: true,
339
+ created_at: true,
340
+ last_updated: true
341
+ }).extend({
342
+ id: zod.z.string().uuid().default(() => uuidv7.uuidv7()),
343
+ org_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
344
+ team_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
345
+ monetization: MonetizationSchema.default("none"),
346
+ visibility: VisibilitySchema.default("private")
347
+ });
348
+ var UpdateConversationSchema = CreateConversationSchema.omit({
349
+ id: true,
350
+ org_id: true,
351
+ team_id: true,
352
+ team: true,
353
+ user: true,
354
+ organization: true,
355
+ slug: true
356
+ }).partial();
357
+ var MessageSchema = zod.z.object({
358
+ id: zod.z.string().uuid(),
359
+ conversation_id: zod.z.string().uuid(),
360
+ user_id: zod.z.string().uuid(),
361
+ created_at: zod.z.string().datetime(),
362
+ last_updated: zod.z.string().datetime(),
363
+ viewers: zod.z.array(zod.z.string().uuid()),
364
+ json: TipTapSchema,
365
+ text: zod.z.string(),
366
+ metadata: zod.z.object({}).passthrough().nullable().optional()
367
+ });
368
+ var DatasetFromFileMetadataSchema = zod.z.object({
369
+ type: zod.z.string(),
370
+ size: zod.z.number(),
371
+ path: zod.z.string(),
372
+ name: zod.z.string(),
373
+ id: zod.z.string().uuid(),
374
+ // storage file object id,
375
+ bucket: zod.z.enum(["public-files", "files"])
376
+ });
377
+ var DatasetMetadataSchema = zod.z.object({
378
+ table_name: zod.z.string(),
379
+ schema: zod.z.literal("datasets").default("datasets"),
380
+ columns: zod.z.array(zod.z.string())
381
+ });
382
+ var DatasetSchema = AssetSchema.extend({
383
+ asset_type: zod.z.literal("dataset").default("dataset"),
384
+ metadata: DatasetMetadataSchema.extend({
385
+ ...DatasetFromFileMetadataSchema.partial().shape
386
+ }),
387
+ preview: zod.z.array(zod.z.object({}).passthrough())
388
+ });
389
+ var CreateDatasetFromFileSchema = CreateAssetSchema.extend({
390
+ asset_type: zod.z.literal("dataset").default("dataset"),
391
+ metadata: DatasetMetadataSchema.extend({
392
+ ...DatasetFromFileMetadataSchema.shape
393
+ }),
394
+ preview: zod.z.array(zod.z.object({}).passthrough())
395
+ });
396
+ var CreateDatasetFromSchemaSchema = CreateAssetSchema.extend({
397
+ asset_type: zod.z.literal("dataset").default("dataset"),
398
+ metadata: DatasetMetadataSchema,
399
+ preview: zod.z.array(zod.z.object({}).passthrough())
400
+ });
401
+ var updateDatasetSchema = DatasetSchema.partial().omit({
402
+ user_id: true,
403
+ id: true,
404
+ created_at: true,
405
+ last_updated: true,
406
+ organization: true,
407
+ user: true,
408
+ team: true,
409
+ slug: true
410
+ }).extend({
411
+ asset_type: zod.z.literal("dataset").default("dataset"),
412
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
413
+ });
414
+ var FileMetadataSchema = zod.z.object({
415
+ id: zod.z.string().uuid(),
416
+ // The id of the file object
417
+ path: zod.z.string(),
418
+ // The path of the file in storage
419
+ bucket: zod.z.enum(["public-files", "files"]),
420
+ name: zod.z.string(),
421
+ type: zod.z.string(),
422
+ size: zod.z.number(),
423
+ // If the file is an image, we store width and height
424
+ width: zod.z.number().optional(),
425
+ height: zod.z.number().optional()
426
+ });
427
+ var FileSchema = AssetSchema.extend({
428
+ asset_type: zod.z.literal("file").default("file"),
429
+ metadata: FileMetadataSchema
430
+ });
431
+ var CreateFileSchema = zod.z.discriminatedUnion("state", [
432
+ // Success state, file is ready
433
+ CreateAssetSchema.extend({
434
+ asset_type: zod.z.literal("file").default("file"),
435
+ state: zod.z.literal("success").default("success"),
436
+ metadata: FileMetadataSchema
437
+ }),
438
+ // In-progress state, file is being processed
439
+ CreateAssetSchema.extend({
440
+ asset_type: zod.z.literal("file").default("file"),
441
+ state: zod.z.literal("in-progress").default("in-progress"),
442
+ metadata: zod.z.object({
443
+ type: zod.z.string()
444
+ })
445
+ })
446
+ ]);
447
+ var updateFileSchema = FileSchema.partial().omit({
448
+ user_id: true,
449
+ id: true,
450
+ created_at: true,
451
+ last_updated: true,
452
+ organization: true,
453
+ user: true,
454
+ team: true,
455
+ slug: true
456
+ }).extend({
457
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
458
+ });
459
+ var NotificationTypeSchema = zod.z.enum([
460
+ "follow",
461
+ "like",
462
+ "comment",
463
+ "reply",
464
+ "mention",
465
+ "reference",
466
+ "invite",
467
+ "payment",
468
+ "event",
469
+ "share",
470
+ "other"
471
+ ]);
472
+ var NotificationSchema = zod.z.object({
473
+ id: zod.z.string().uuid(),
474
+ source_user_id: zod.z.string().uuid(),
475
+ destination_user_id: zod.z.string().uuid(),
476
+ org_id: zod.z.string().uuid(),
477
+ asset_id: zod.z.string().uuid().optional().nullable(),
478
+ type: NotificationTypeSchema,
479
+ content: zod.z.object({
480
+ text: zod.z.string().optional(),
481
+ asset: zod.z.object({
482
+ assetId: zod.z.string(),
483
+ assetType: AssetTypeSchema
484
+ }).optional(),
485
+ mention: zod.z.object({}).optional(),
486
+ event: zod.z.object({
487
+ type: zod.z.enum(["success", "error"])
488
+ }).optional()
489
+ }),
490
+ viewed: zod.z.boolean(),
491
+ created_at: zod.z.string(),
492
+ last_updated: zod.z.string()
493
+ });
494
+ var authType = zod.z.enum(["Personal Access Token", "None", "OAuth 2.0"]);
495
+ var serviceSchema = zod.z.object({
496
+ id: zod.z.string(),
497
+ user_id: zod.z.string(),
498
+ org_id: zod.z.string().nullable().optional(),
499
+ name: zod.z.string(),
500
+ description: zod.z.string().nullable().optional(),
501
+ visibility: VisibilitySchema,
502
+ version: zod.z.string().nullable().optional(),
503
+ authentication: authType,
504
+ base_url: zod.z.string(),
505
+ spec_path: zod.z.string(),
506
+ created_at: zod.z.string(),
507
+ last_updated: zod.z.string()
508
+ });
509
+ var routeSchema = zod.z.object({
510
+ id: zod.z.string(),
511
+ user_id: zod.z.string(),
512
+ service_id: zod.z.string(),
513
+ path: zod.z.string(),
514
+ method: zod.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]),
515
+ summary: zod.z.string().nullable().optional(),
516
+ parameters: zod.z.array(zod.z.object({}).passthrough()).nullable().optional(),
517
+ request_body: zod.z.object({}).passthrough().nullable().optional(),
518
+ responses: zod.z.array(zod.z.object({}).passthrough()).nullable().optional(),
519
+ security: zod.z.object({}).passthrough().nullable().optional(),
520
+ // created_at: z.string(),
521
+ rate_limit: zod.z.number().nullable().optional(),
522
+ last_updated: zod.z.string()
523
+ });
524
+ var ReplicationSchema = AssetSchema.extend({
525
+ asset_type: AssetTypeSchema.refine((val) => val === "replication"),
526
+ metadata: zod.z.object({
527
+ schedule: zod.z.object({
528
+ cron: zod.z.string()
529
+ }).passthrough().optional()
530
+ }).passthrough()
531
+ });
532
+ var CreateReplicationSchema = ReplicationSchema.partial().extend({
533
+ id: zod.z.string().uuid().default(() => uuidv7.uuidv7()),
534
+ team_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
535
+ org_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
536
+ name_url_slug: zod.z.string()
537
+ });
538
+ var UpdateReplicationSchema = zod.z.object({
539
+ team_id: zod.z.string().uuid().nullable().optional(),
540
+ name_url_slug: zod.z.string().nullable().optional(),
541
+ name: zod.z.string().nullable().optional(),
542
+ description: zod.z.string().nullable().optional(),
543
+ visibility: VisibilitySchema.nullable().optional(),
544
+ metadata: zod.z.object({}).passthrough().optional().nullable(),
545
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
546
+ });
547
+ var BlueprintSchema = AssetSchema.extend({
548
+ asset_type: AssetTypeSchema.refine((val) => val === "blueprint")
549
+ });
550
+ var CreateBlueprintSchema = AssetSchema.partial().extend({
551
+ id: zod.z.string().uuid().default(() => uuidv7.uuidv7()),
552
+ team_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
553
+ org_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
554
+ name_url_slug: zod.z.string(),
555
+ metadata: zod.z.object({
556
+ edges: zod.z.array(zod.z.object({}).passthrough()),
557
+ nodes: zod.z.array(zod.z.object({}).passthrough())
558
+ }).passthrough()
559
+ });
560
+ var UpdateBlueprintSchema = zod.z.object({
561
+ team_id: zod.z.string().uuid().nullable().optional(),
562
+ name_url_slug: zod.z.string().nullable().optional(),
563
+ name: zod.z.string().nullable().optional(),
564
+ description: zod.z.string().nullable().optional(),
565
+ visibility: VisibilitySchema.nullable().optional(),
566
+ metadata: zod.z.object({}).passthrough().optional().nullable(),
567
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
568
+ });
569
+
570
+ // src/utils/dataset.ts
571
+ function filterListToString(filters, onlyActive = false) {
572
+ if (!filters || !Array.isArray(filters)) return "";
573
+ return filters.map((filter) => {
574
+ if (onlyActive && (filter.hasOwnProperty("active") ? !filter.active : false))
575
+ return "";
576
+ return `${filter.column}.${filter.operator}.${filter.value}`;
577
+ }).join(",");
578
+ }
579
+
580
+ // src/utils/navigate.ts
581
+ var createNameUrlSlug = (name) => {
582
+ return name.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[\s\/\_]+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
583
+ };
584
+ var createUrlSlug = (asset) => {
585
+ if (asset.asset_type === "conversation") {
586
+ return `/conversations/${asset.id}`;
587
+ }
588
+ if (asset.asset_type === "comment") {
589
+ return `/comments/${asset.id}`;
590
+ }
591
+ const entityName = asset.org_id !== "00000000-0000-0000-0000-000000000000" ? asset.organization.name : asset.user.username;
592
+ const name = asset.name ? createNameUrlSlug(asset.name) : asset.id;
593
+ const assetType = asset.asset_type;
594
+ return `/${assetType}s/${entityName}/${name}`;
595
+ };
596
+ var getAssetUrl = (asset, config) => {
597
+ (asset == null ? void 0 : asset.asset_type) || (asset == null ? void 0 : asset.assetType);
598
+ const slug = (asset == null ? void 0 : asset.slug) || createUrlSlug(asset);
599
+ const pathPostfix = (config == null ? void 0 : config.intent) ? `?intent=${config.intent}` : "";
600
+ let url = `${slug}${pathPostfix}`;
601
+ if (config == null ? void 0 : config.filters) {
602
+ url += `?filters=${filterListToString(config.filters)}`;
603
+ }
604
+ return url;
605
+ };
606
+ var katexParser = {
607
+ name: "katex",
608
+ level: "inline",
609
+ start(src) {
610
+ const match = src.match(/\\\[|\\\(/);
611
+ return match ? match.index : void 0;
612
+ },
613
+ end(src) {
614
+ var _a, _b, _c;
615
+ const match = src.match(/\s\\\]|\s\\\)/);
616
+ return match ? ((_a = match.index) != null ? _a : 0) + ((_c = (_b = match[0]) == null ? void 0 : _b.length) != null ? _c : 0) : void 0;
617
+ },
618
+ tokenizer(src, tokens) {
619
+ const displayRule = /^\\\[([\s\S]*?)\\\]/;
620
+ const inlineRule = /^\\\(([\s\S]*?)\\\)/;
621
+ let match = displayRule.exec(src);
622
+ if (match) {
623
+ return {
624
+ type: "katex",
625
+ raw: match[0],
626
+ latex: match[1].trim(),
627
+ displayMode: true
628
+ };
629
+ }
630
+ match = inlineRule.exec(src);
631
+ if (match) {
632
+ return {
633
+ type: "katex",
634
+ raw: match[0],
635
+ latex: match[1].trim(),
636
+ displayMode: false
637
+ };
638
+ }
639
+ },
640
+ renderer(token) {
641
+ return `<span data-latex="${token.latex}" data-display-mode="${token.displayMode}"></span>`;
642
+ }
643
+ };
644
+ var assetComponentExtension = {
645
+ name: "assetComponent",
646
+ level: "block",
647
+ start(src) {
648
+ var _a;
649
+ return (_a = src.match(/^```assetComponent/)) == null ? void 0 : _a.index;
650
+ },
651
+ end(src) {
652
+ var _a;
653
+ return (_a = src.match(/^```/)) == null ? void 0 : _a.index;
654
+ },
655
+ tokenizer(src, tokens) {
656
+ const rule = /^```assetComponent\s+(\{[\s\S]*?\})\n```/;
657
+ const match = rule.exec(src);
658
+ if (match) {
659
+ const token = {
660
+ type: "assetComponent",
661
+ raw: match[0],
662
+ properties: match[1],
663
+ tokens: []
664
+ };
665
+ return token;
666
+ }
667
+ },
668
+ renderer(token) {
669
+ let properties;
670
+ try {
671
+ properties = JSON.parse(token.properties);
672
+ } catch (e) {
673
+ console.error("Invalid JSON in assetComponent properties:", e);
674
+ properties = {};
675
+ }
676
+ const componentHtml = `
677
+ <asset-component ${Object.entries(properties).map(([key, value]) => `${key}="${value}"`).join(" ")}></asset-component>`;
678
+ return componentHtml;
679
+ }
680
+ };
681
+ var userMentionExtension = {
682
+ name: "userMention",
683
+ level: "inline",
684
+ start(src) {
685
+ var _a;
686
+ return (_a = src.match(/`\{@/)) == null ? void 0 : _a.index;
687
+ },
688
+ end(src) {
689
+ var _a;
690
+ return (_a = src.match(/\}`/)) == null ? void 0 : _a.index;
691
+ },
692
+ tokenizer(src, tokens) {
693
+ const rule = /^`\{@([a-zA-Z0-9_]+)\}`/;
694
+ const match = rule.exec(src);
695
+ if (match) {
696
+ return {
697
+ type: "userMention",
698
+ raw: match[0],
699
+ username: match[1]
700
+ };
701
+ }
702
+ },
703
+ renderer(token) {
704
+ return `<user-mention username="${token.username}" data-label="${token.username}"></user-mention>`;
705
+ }
706
+ };
707
+ marked.marked.use({
708
+ gfm: true,
709
+ extensions: [assetComponentExtension, userMentionExtension, katexParser]
710
+ });
711
+ function parseMarkdown(markdown) {
712
+ return marked.marked.parse(markdown);
713
+ }
714
+
715
+ // src/utils/air/index.ts
716
+ var extractContent = (item) => {
717
+ if (Array.isArray(item)) return item.map(extractContent);
718
+ if (item == null ? void 0 : item.content) {
719
+ if (Array.isArray(item.content))
720
+ return item.content.map(extractContent).flat();
721
+ else return extractContent(item.content);
722
+ } else return item;
723
+ };
724
+ function getReferencesInContent(json) {
725
+ if (!json || !(json == null ? void 0 : json.content)) return { users: [], assets: [] };
726
+ const content = json.content.map(extractContent).flat();
727
+ const users = content.filter((item) => item.type === "mention").map((item) => ({
728
+ user_id: item.attrs.id,
729
+ username: item.attrs.label || item.attrs.username
730
+ })).reduce((unique, item) => {
731
+ if (!unique.some((u) => u.user_id === item.user_id)) {
732
+ unique.push(item);
733
+ }
734
+ return unique;
735
+ }, []);
736
+ const assets = content.filter(
737
+ (item) => {
738
+ var _a, _b;
739
+ return item.type === "assetComponent" && ((_a = item.attrs) == null ? void 0 : _a.id) && !((_b = item.attrs) == null ? void 0 : _b.partial);
740
+ }
741
+ ).map(({ attrs }) => ({
742
+ id: attrs.id,
743
+ assetType: attrs.assetType
744
+ })).reduce((unique, item) => {
745
+ if (!unique.some((u) => u.id === item.id)) {
746
+ unique.push(item);
747
+ }
748
+ return unique;
749
+ }, []);
750
+ return {
751
+ users,
752
+ assets
753
+ };
754
+ }
755
+
756
+ exports.AssetSchema = AssetSchema;
757
+ exports.AssetTypeSchema = AssetTypeSchema;
758
+ exports.BlueprintSchema = BlueprintSchema;
759
+ exports.CommentSchema = CommentSchema;
760
+ exports.ConnectionSchema = ConnectionSchema;
761
+ exports.ContentSchema = ContentSchema;
762
+ exports.ConversationSchema = ConversationSchema;
763
+ exports.CreateAssetSchema = CreateAssetSchema;
764
+ exports.CreateBlueprintSchema = CreateBlueprintSchema;
765
+ exports.CreateCommentSchema = CreateCommentSchema;
766
+ exports.CreateConversationSchema = CreateConversationSchema;
767
+ exports.CreateDatasetFromFileSchema = CreateDatasetFromFileSchema;
768
+ exports.CreateDatasetFromSchemaSchema = CreateDatasetFromSchemaSchema;
769
+ exports.CreateFileSchema = CreateFileSchema;
770
+ exports.CreatePostSchema = CreatePostSchema;
771
+ exports.CreateReplicationSchema = CreateReplicationSchema;
772
+ exports.CreateTeamSchema = CreateTeamSchema;
773
+ exports.DatasetSchema = DatasetSchema;
774
+ exports.EmbeddingSchema = EmbeddingSchema;
775
+ exports.FileSchema = FileSchema;
776
+ exports.ListPostsSchema = ListPostsSchema;
777
+ exports.MembershipSchema = MembershipSchema;
778
+ exports.MessageSchema = MessageSchema;
779
+ exports.MonetizationSchema = MonetizationSchema;
780
+ exports.NotificationSchema = NotificationSchema;
781
+ exports.OrganizationsSchema = OrganizationsSchema;
782
+ exports.PermissionSchema = PermissionSchema;
783
+ exports.PostSchema = PostSchema;
784
+ exports.ProfileSchema = ProfileSchema;
785
+ exports.PurchaseAssetSchema = PurchaseAssetSchema;
786
+ exports.ReadPostSchema = ReadPostSchema;
787
+ exports.ReadPostsSchema = ReadPostsSchema;
788
+ exports.ReadProfileSchema = ReadProfileSchema;
789
+ exports.ReadTeamSchema = ReadTeamSchema;
790
+ exports.ReadTeamsSchema = ReadTeamsSchema;
791
+ exports.ReplicationSchema = ReplicationSchema;
792
+ exports.RoleSchema = RoleSchema;
793
+ exports.StatusSchema = StatusSchema;
794
+ exports.TeamSchema = TeamSchema;
795
+ exports.TipTapSchema = TipTapSchema;
796
+ exports.UpdateAssetSchema = UpdateAssetSchema;
797
+ exports.UpdateBlueprintSchema = UpdateBlueprintSchema;
798
+ exports.UpdateConversationSchema = UpdateConversationSchema;
799
+ exports.UpdatePostSchema = UpdatePostSchema;
800
+ exports.UpdateProfileSchema = UpdateProfileSchema;
801
+ exports.UpdateReplicationSchema = UpdateReplicationSchema;
802
+ exports.UpdateTeamSchema = UpdateTeamSchema;
803
+ exports.VisibilitySchema = VisibilitySchema;
804
+ exports.authType = authType;
805
+ exports.createNameUrlSlug = createNameUrlSlug;
806
+ exports.createUrlSlug = createUrlSlug;
807
+ exports.filterListToString = filterListToString;
808
+ exports.getAssetUrl = getAssetUrl;
809
+ exports.getReferencesInContent = getReferencesInContent;
810
+ exports.parseMarkdown = parseMarkdown;
811
+ exports.routeSchema = routeSchema;
812
+ exports.serviceSchema = serviceSchema;
813
+ exports.updateDatasetSchema = updateDatasetSchema;
814
+ exports.updateFileSchema = updateFileSchema;
815
+ //# sourceMappingURL=index.cjs.map
816
+ //# sourceMappingURL=index.cjs.map