@ourofoundation/ouro-js 1.1.4 → 2.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 (104) hide show
  1. package/dist/index.cjs +801 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +8045 -0
  4. package/dist/index.d.ts +8045 -18
  5. package/dist/index.js +740 -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,801 @@
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
+ }).extend({
320
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
321
+ });
322
+
323
+ // src/schema/conversations.ts
324
+ var ConversationSchema = AssetSchema.extend({
325
+ metadata: zod.z.object({
326
+ members: zod.z.array(zod.z.string())
327
+ }),
328
+ asset_type: AssetTypeSchema.default("conversation")
329
+ });
330
+ var CreateConversationSchema = ConversationSchema.omit({
331
+ org_id: true,
332
+ team_id: true,
333
+ user_id: true,
334
+ created_at: true,
335
+ last_updated: true
336
+ }).extend({
337
+ id: zod.z.string().uuid().default(() => uuidv7.uuidv7()),
338
+ org_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
339
+ team_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
340
+ monetization: MonetizationSchema.default("none"),
341
+ visibility: VisibilitySchema.default("private")
342
+ });
343
+ var UpdateConversationSchema = CreateConversationSchema.omit({
344
+ id: true,
345
+ org_id: true,
346
+ team_id: true,
347
+ team: true,
348
+ user: true
349
+ }).partial();
350
+ var MessageSchema = zod.z.object({
351
+ id: zod.z.string().uuid(),
352
+ conversation_id: zod.z.string().uuid(),
353
+ user_id: zod.z.string().uuid(),
354
+ created_at: zod.z.string().datetime(),
355
+ last_updated: zod.z.string().datetime(),
356
+ viewers: zod.z.array(zod.z.string().uuid()),
357
+ json: TipTapSchema,
358
+ text: zod.z.string(),
359
+ metadata: zod.z.object({}).passthrough().nullable().optional()
360
+ });
361
+ var DatasetFromFileMetadataSchema = zod.z.object({
362
+ type: zod.z.string(),
363
+ size: zod.z.number(),
364
+ path: zod.z.string(),
365
+ name: zod.z.string(),
366
+ id: zod.z.string().uuid(),
367
+ // storage file object id,
368
+ bucket: zod.z.enum(["public-files", "files"])
369
+ });
370
+ var DatasetMetadataSchema = zod.z.object({
371
+ table_name: zod.z.string(),
372
+ schema: zod.z.literal("datasets").default("datasets"),
373
+ columns: zod.z.array(zod.z.string())
374
+ });
375
+ var DatasetSchema = AssetSchema.extend({
376
+ asset_type: zod.z.literal("dataset").default("dataset"),
377
+ metadata: DatasetMetadataSchema.extend({
378
+ ...DatasetFromFileMetadataSchema.partial().shape
379
+ }),
380
+ preview: zod.z.array(zod.z.object({}).passthrough())
381
+ });
382
+ var CreateDatasetFromFileSchema = CreateAssetSchema.extend({
383
+ asset_type: zod.z.literal("dataset").default("dataset"),
384
+ metadata: DatasetMetadataSchema.extend({
385
+ ...DatasetFromFileMetadataSchema.shape
386
+ }),
387
+ preview: zod.z.array(zod.z.object({}).passthrough())
388
+ });
389
+ var CreateDatasetFromSchemaSchema = CreateAssetSchema.extend({
390
+ asset_type: zod.z.literal("dataset").default("dataset"),
391
+ metadata: DatasetMetadataSchema,
392
+ preview: zod.z.array(zod.z.object({}).passthrough())
393
+ });
394
+ var updateDatasetSchema = DatasetSchema.partial().omit({
395
+ user_id: true,
396
+ id: true,
397
+ created_at: true,
398
+ last_updated: true
399
+ }).extend({
400
+ asset_type: zod.z.literal("dataset").default("dataset"),
401
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
402
+ });
403
+ var FileMetadataSchema = zod.z.object({
404
+ id: zod.z.string().uuid(),
405
+ // The id of the file object
406
+ path: zod.z.string(),
407
+ // The path of the file in storage
408
+ bucket: zod.z.enum(["public-files", "files"]),
409
+ name: zod.z.string(),
410
+ type: zod.z.string(),
411
+ size: zod.z.number(),
412
+ // If the file is an image, we store width and height
413
+ width: zod.z.number().optional(),
414
+ height: zod.z.number().optional()
415
+ });
416
+ var FileSchema = AssetSchema.extend({
417
+ asset_type: zod.z.literal("file").default("file"),
418
+ metadata: FileMetadataSchema
419
+ });
420
+ var CreateFileSchema = zod.z.discriminatedUnion("state", [
421
+ // Success state, file is ready
422
+ CreateAssetSchema.extend({
423
+ asset_type: zod.z.literal("file").default("file"),
424
+ state: zod.z.literal("success").default("success"),
425
+ metadata: FileMetadataSchema
426
+ }),
427
+ // In-progress state, file is being processed
428
+ CreateAssetSchema.extend({
429
+ asset_type: zod.z.literal("file").default("file"),
430
+ state: zod.z.literal("in-progress").default("in-progress"),
431
+ metadata: zod.z.object({
432
+ type: zod.z.string()
433
+ })
434
+ })
435
+ ]);
436
+ var updateFileSchema = FileSchema.partial().omit({
437
+ user_id: true,
438
+ id: true,
439
+ created_at: true,
440
+ last_updated: true
441
+ }).extend({
442
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
443
+ });
444
+ var NotificationTypeSchema = zod.z.enum([
445
+ "follow",
446
+ "like",
447
+ "comment",
448
+ "reply",
449
+ "mention",
450
+ "reference",
451
+ "invite",
452
+ "payment",
453
+ "event",
454
+ "share",
455
+ "other"
456
+ ]);
457
+ var NotificationSchema = zod.z.object({
458
+ id: zod.z.string().uuid(),
459
+ source_user_id: zod.z.string().uuid(),
460
+ destination_user_id: zod.z.string().uuid(),
461
+ org_id: zod.z.string().uuid(),
462
+ asset_id: zod.z.string().uuid().optional().nullable(),
463
+ type: NotificationTypeSchema,
464
+ content: zod.z.object({
465
+ text: zod.z.string().optional(),
466
+ asset: zod.z.object({
467
+ assetId: zod.z.string(),
468
+ assetType: AssetTypeSchema
469
+ }).optional(),
470
+ mention: zod.z.object({}).optional(),
471
+ event: zod.z.object({
472
+ type: zod.z.enum(["success", "error"])
473
+ }).optional()
474
+ }),
475
+ viewed: zod.z.boolean(),
476
+ created_at: zod.z.string(),
477
+ last_updated: zod.z.string()
478
+ });
479
+ var authType = zod.z.enum(["Personal Access Token", "None", "OAuth 2.0"]);
480
+ var serviceSchema = zod.z.object({
481
+ id: zod.z.string(),
482
+ user_id: zod.z.string(),
483
+ org_id: zod.z.string().nullable().optional(),
484
+ name: zod.z.string(),
485
+ description: zod.z.string().nullable().optional(),
486
+ visibility: VisibilitySchema,
487
+ version: zod.z.string().nullable().optional(),
488
+ authentication: authType,
489
+ base_url: zod.z.string(),
490
+ spec_path: zod.z.string(),
491
+ created_at: zod.z.string(),
492
+ last_updated: zod.z.string()
493
+ });
494
+ var routeSchema = zod.z.object({
495
+ id: zod.z.string(),
496
+ user_id: zod.z.string(),
497
+ service_id: zod.z.string(),
498
+ path: zod.z.string(),
499
+ method: zod.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]),
500
+ summary: zod.z.string().nullable().optional(),
501
+ parameters: zod.z.array(zod.z.object({}).passthrough()).nullable().optional(),
502
+ request_body: zod.z.object({}).passthrough().nullable().optional(),
503
+ responses: zod.z.array(zod.z.object({}).passthrough()).nullable().optional(),
504
+ security: zod.z.object({}).passthrough().nullable().optional(),
505
+ // created_at: z.string(),
506
+ rate_limit: zod.z.number().nullable().optional(),
507
+ last_updated: zod.z.string()
508
+ });
509
+ var ReplicationSchema = AssetSchema.extend({
510
+ asset_type: AssetTypeSchema.refine((val) => val === "replication"),
511
+ metadata: zod.z.object({
512
+ schedule: zod.z.object({
513
+ cron: zod.z.string()
514
+ }).passthrough().optional()
515
+ }).passthrough()
516
+ });
517
+ var CreateReplicationSchema = ReplicationSchema.partial().extend({
518
+ id: zod.z.string().uuid().default(() => uuidv7.uuidv7()),
519
+ team_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
520
+ org_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
521
+ name_url_slug: zod.z.string()
522
+ });
523
+ var UpdateReplicationSchema = zod.z.object({
524
+ team_id: zod.z.string().uuid().nullable().optional(),
525
+ name_url_slug: zod.z.string().nullable().optional(),
526
+ name: zod.z.string().nullable().optional(),
527
+ description: zod.z.string().nullable().optional(),
528
+ visibility: VisibilitySchema.nullable().optional(),
529
+ metadata: zod.z.object({}).passthrough().optional().nullable(),
530
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
531
+ });
532
+ var BlueprintSchema = AssetSchema.extend({
533
+ asset_type: AssetTypeSchema.refine((val) => val === "blueprint")
534
+ });
535
+ var CreateBlueprintSchema = AssetSchema.partial().extend({
536
+ id: zod.z.string().uuid().default(() => uuidv7.uuidv7()),
537
+ team_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
538
+ org_id: zod.z.string().uuid().default("00000000-0000-0000-0000-000000000000"),
539
+ name_url_slug: zod.z.string(),
540
+ metadata: zod.z.object({
541
+ edges: zod.z.array(zod.z.object({}).passthrough()),
542
+ nodes: zod.z.array(zod.z.object({}).passthrough())
543
+ }).passthrough()
544
+ });
545
+ var UpdateBlueprintSchema = zod.z.object({
546
+ team_id: zod.z.string().uuid().nullable().optional(),
547
+ name_url_slug: zod.z.string().nullable().optional(),
548
+ name: zod.z.string().nullable().optional(),
549
+ description: zod.z.string().nullable().optional(),
550
+ visibility: VisibilitySchema.nullable().optional(),
551
+ metadata: zod.z.object({}).passthrough().optional().nullable(),
552
+ last_updated: zod.z.string().default(() => (/* @__PURE__ */ new Date()).toISOString())
553
+ });
554
+
555
+ // src/utils/dataset.ts
556
+ function filterListToString(filters, onlyActive = false) {
557
+ if (!filters || !Array.isArray(filters)) return "";
558
+ return filters.map((filter) => {
559
+ if (onlyActive && (filter.hasOwnProperty("active") ? !filter.active : false))
560
+ return "";
561
+ return `${filter.column}.${filter.operator}.${filter.value}`;
562
+ }).join(",");
563
+ }
564
+
565
+ // src/utils/navigate.ts
566
+ var createNameUrlSlug = (name) => {
567
+ return name.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[\s\/\_]+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
568
+ };
569
+ var createUrlSlug = (asset) => {
570
+ if (asset.asset_type === "conversation") {
571
+ return `/conversations/${asset.id}`;
572
+ }
573
+ if (asset.asset_type === "comment") {
574
+ return `/comments/${asset.id}`;
575
+ }
576
+ const entityName = asset.org_id !== "00000000-0000-0000-0000-000000000000" ? asset.organization.name : asset.user.username;
577
+ const name = asset.name ? createNameUrlSlug(asset.name) : asset.id;
578
+ const assetType = asset.asset_type;
579
+ return `/${assetType}s/${entityName}/${name}`;
580
+ };
581
+ var getAssetUrl = (asset, config) => {
582
+ (asset == null ? void 0 : asset.asset_type) || (asset == null ? void 0 : asset.assetType);
583
+ const slug = (asset == null ? void 0 : asset.slug) || createUrlSlug(asset);
584
+ const pathPostfix = (config == null ? void 0 : config.intent) ? `?intent=${config.intent}` : "";
585
+ let url = `${slug}${pathPostfix}`;
586
+ if (config == null ? void 0 : config.filters) {
587
+ url += `?filters=${filterListToString(config.filters)}`;
588
+ }
589
+ return url;
590
+ };
591
+ var katexParser = {
592
+ name: "katex",
593
+ level: "inline",
594
+ start(src) {
595
+ const match = src.match(/\\\[|\\\(/);
596
+ return match ? match.index : void 0;
597
+ },
598
+ end(src) {
599
+ var _a, _b, _c;
600
+ const match = src.match(/\s\\\]|\s\\\)/);
601
+ return match ? ((_a = match.index) != null ? _a : 0) + ((_c = (_b = match[0]) == null ? void 0 : _b.length) != null ? _c : 0) : void 0;
602
+ },
603
+ tokenizer(src, tokens) {
604
+ const displayRule = /^\\\[([\s\S]*?)\\\]/;
605
+ const inlineRule = /^\\\(([\s\S]*?)\\\)/;
606
+ let match = displayRule.exec(src);
607
+ if (match) {
608
+ return {
609
+ type: "katex",
610
+ raw: match[0],
611
+ latex: match[1].trim(),
612
+ displayMode: true
613
+ };
614
+ }
615
+ match = inlineRule.exec(src);
616
+ if (match) {
617
+ return {
618
+ type: "katex",
619
+ raw: match[0],
620
+ latex: match[1].trim(),
621
+ displayMode: false
622
+ };
623
+ }
624
+ },
625
+ renderer(token) {
626
+ return `<span data-latex="${token.latex}" data-display-mode="${token.displayMode}"></span>`;
627
+ }
628
+ };
629
+ var assetComponentExtension = {
630
+ name: "assetComponent",
631
+ level: "block",
632
+ start(src) {
633
+ var _a;
634
+ return (_a = src.match(/^```assetComponent/)) == null ? void 0 : _a.index;
635
+ },
636
+ end(src) {
637
+ var _a;
638
+ return (_a = src.match(/^```/)) == null ? void 0 : _a.index;
639
+ },
640
+ tokenizer(src, tokens) {
641
+ const rule = /^```assetComponent\s+(\{[\s\S]*?\})\n```/;
642
+ const match = rule.exec(src);
643
+ if (match) {
644
+ const token = {
645
+ type: "assetComponent",
646
+ raw: match[0],
647
+ properties: match[1],
648
+ tokens: []
649
+ };
650
+ return token;
651
+ }
652
+ },
653
+ renderer(token) {
654
+ let properties;
655
+ try {
656
+ properties = JSON.parse(token.properties);
657
+ } catch (e) {
658
+ console.error("Invalid JSON in assetComponent properties:", e);
659
+ properties = {};
660
+ }
661
+ const componentHtml = `
662
+ <asset-component ${Object.entries(properties).map(([key, value]) => `${key}="${value}"`).join(" ")}></asset-component>`;
663
+ return componentHtml;
664
+ }
665
+ };
666
+ var userMentionExtension = {
667
+ name: "userMention",
668
+ level: "inline",
669
+ start(src) {
670
+ var _a;
671
+ return (_a = src.match(/`\{@/)) == null ? void 0 : _a.index;
672
+ },
673
+ end(src) {
674
+ var _a;
675
+ return (_a = src.match(/\}`/)) == null ? void 0 : _a.index;
676
+ },
677
+ tokenizer(src, tokens) {
678
+ const rule = /^`\{@([a-zA-Z0-9_]+)\}`/;
679
+ const match = rule.exec(src);
680
+ if (match) {
681
+ return {
682
+ type: "userMention",
683
+ raw: match[0],
684
+ username: match[1]
685
+ };
686
+ }
687
+ },
688
+ renderer(token) {
689
+ return `<user-mention username="${token.username}" data-label="${token.username}"></user-mention>`;
690
+ }
691
+ };
692
+ marked.marked.use({
693
+ gfm: true,
694
+ extensions: [assetComponentExtension, userMentionExtension, katexParser]
695
+ });
696
+ function parseMarkdown(markdown) {
697
+ return marked.marked.parse(markdown);
698
+ }
699
+
700
+ // src/utils/air/index.ts
701
+ var extractContent = (item) => {
702
+ if (Array.isArray(item)) return item.map(extractContent);
703
+ if (item == null ? void 0 : item.content) {
704
+ if (Array.isArray(item.content))
705
+ return item.content.map(extractContent).flat();
706
+ else return extractContent(item.content);
707
+ } else return item;
708
+ };
709
+ function getReferencesInContent(json) {
710
+ if (!json || !(json == null ? void 0 : json.content)) return { users: [], assets: [] };
711
+ const content = json.content.map(extractContent).flat();
712
+ const users = content.filter((item) => item.type === "mention").map((item) => ({
713
+ user_id: item.attrs.id,
714
+ username: item.attrs.label || item.attrs.username
715
+ })).reduce((unique, item) => {
716
+ if (!unique.some((u) => u.user_id === item.user_id)) {
717
+ unique.push(item);
718
+ }
719
+ return unique;
720
+ }, []);
721
+ const assets = content.filter(
722
+ (item) => {
723
+ var _a, _b;
724
+ return item.type === "assetComponent" && ((_a = item.attrs) == null ? void 0 : _a.id) && !((_b = item.attrs) == null ? void 0 : _b.partial);
725
+ }
726
+ ).map(({ attrs }) => ({
727
+ id: attrs.id,
728
+ assetType: attrs.assetType
729
+ })).reduce((unique, item) => {
730
+ if (!unique.some((u) => u.id === item.id)) {
731
+ unique.push(item);
732
+ }
733
+ return unique;
734
+ }, []);
735
+ return {
736
+ users,
737
+ assets
738
+ };
739
+ }
740
+
741
+ exports.AssetSchema = AssetSchema;
742
+ exports.AssetTypeSchema = AssetTypeSchema;
743
+ exports.BlueprintSchema = BlueprintSchema;
744
+ exports.CommentSchema = CommentSchema;
745
+ exports.ConnectionSchema = ConnectionSchema;
746
+ exports.ContentSchema = ContentSchema;
747
+ exports.ConversationSchema = ConversationSchema;
748
+ exports.CreateAssetSchema = CreateAssetSchema;
749
+ exports.CreateBlueprintSchema = CreateBlueprintSchema;
750
+ exports.CreateCommentSchema = CreateCommentSchema;
751
+ exports.CreateConversationSchema = CreateConversationSchema;
752
+ exports.CreateDatasetFromFileSchema = CreateDatasetFromFileSchema;
753
+ exports.CreateDatasetFromSchemaSchema = CreateDatasetFromSchemaSchema;
754
+ exports.CreateFileSchema = CreateFileSchema;
755
+ exports.CreatePostSchema = CreatePostSchema;
756
+ exports.CreateReplicationSchema = CreateReplicationSchema;
757
+ exports.CreateTeamSchema = CreateTeamSchema;
758
+ exports.DatasetSchema = DatasetSchema;
759
+ exports.EmbeddingSchema = EmbeddingSchema;
760
+ exports.FileSchema = FileSchema;
761
+ exports.ListPostsSchema = ListPostsSchema;
762
+ exports.MembershipSchema = MembershipSchema;
763
+ exports.MessageSchema = MessageSchema;
764
+ exports.MonetizationSchema = MonetizationSchema;
765
+ exports.NotificationSchema = NotificationSchema;
766
+ exports.OrganizationsSchema = OrganizationsSchema;
767
+ exports.PermissionSchema = PermissionSchema;
768
+ exports.PostSchema = PostSchema;
769
+ exports.ProfileSchema = ProfileSchema;
770
+ exports.PurchaseAssetSchema = PurchaseAssetSchema;
771
+ exports.ReadPostSchema = ReadPostSchema;
772
+ exports.ReadPostsSchema = ReadPostsSchema;
773
+ exports.ReadProfileSchema = ReadProfileSchema;
774
+ exports.ReadTeamSchema = ReadTeamSchema;
775
+ exports.ReadTeamsSchema = ReadTeamsSchema;
776
+ exports.ReplicationSchema = ReplicationSchema;
777
+ exports.RoleSchema = RoleSchema;
778
+ exports.StatusSchema = StatusSchema;
779
+ exports.TeamSchema = TeamSchema;
780
+ exports.TipTapSchema = TipTapSchema;
781
+ exports.UpdateAssetSchema = UpdateAssetSchema;
782
+ exports.UpdateBlueprintSchema = UpdateBlueprintSchema;
783
+ exports.UpdateConversationSchema = UpdateConversationSchema;
784
+ exports.UpdatePostSchema = UpdatePostSchema;
785
+ exports.UpdateProfileSchema = UpdateProfileSchema;
786
+ exports.UpdateReplicationSchema = UpdateReplicationSchema;
787
+ exports.UpdateTeamSchema = UpdateTeamSchema;
788
+ exports.VisibilitySchema = VisibilitySchema;
789
+ exports.authType = authType;
790
+ exports.createNameUrlSlug = createNameUrlSlug;
791
+ exports.createUrlSlug = createUrlSlug;
792
+ exports.filterListToString = filterListToString;
793
+ exports.getAssetUrl = getAssetUrl;
794
+ exports.getReferencesInContent = getReferencesInContent;
795
+ exports.parseMarkdown = parseMarkdown;
796
+ exports.routeSchema = routeSchema;
797
+ exports.serviceSchema = serviceSchema;
798
+ exports.updateDatasetSchema = updateDatasetSchema;
799
+ exports.updateFileSchema = updateFileSchema;
800
+ //# sourceMappingURL=index.cjs.map
801
+ //# sourceMappingURL=index.cjs.map