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