@devpad/api 2.0.0 → 2.0.2

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.
@@ -0,0 +1,130 @@
1
+ // ../schema/dist/errors.js
2
+ import { err } from "@f0rbit/corpus";
3
+ var defaultLogger = ({ error, context }) => {
4
+ console.error(`[${context.timestamp}] [${error.kind}]`, error.message || error.kind, { ...error, stack: context.stack?.split("\n").slice(2, 5).join("\n"), ...context });
5
+ };
6
+ var errorLogger = defaultLogger;
7
+ var contextProvider = null;
8
+ var configureErrorLogging = (config) => {
9
+ if (config.logger)
10
+ errorLogger = config.logger;
11
+ if (config.contextProvider)
12
+ contextProvider = config.contextProvider;
13
+ };
14
+ var logAndReturn = (error, ctx) => {
15
+ const context = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), stack: new Error().stack, ...contextProvider?.(), ...ctx };
16
+ errorLogger({ error, context });
17
+ return err(error);
18
+ };
19
+ var hasKind = (e, kind) => typeof e === "object" && e !== null && "kind" in e && e.kind === kind;
20
+ var isNotFoundError = (e) => hasKind(e, "not_found");
21
+ var isForbiddenError = (e) => hasKind(e, "forbidden");
22
+ var isValidationError = (e) => hasKind(e, "validation");
23
+ var isRateLimitedError = (e) => hasKind(e, "rate_limited");
24
+ var isStoreError = (e) => hasKind(e, "store_error");
25
+ var isNetworkError = (e) => hasKind(e, "network_error");
26
+ var isAuthExpiredError = (e) => hasKind(e, "auth_expired");
27
+ var isApiError = (e) => hasKind(e, "api_error");
28
+ var isParseError = (e) => hasKind(e, "parse_error");
29
+ var isEncryptionError = (e) => hasKind(e, "encryption_error");
30
+ var isDatabaseError = (e) => hasKind(e, "db_error");
31
+ var isConflictError = (e) => hasKind(e, "conflict");
32
+ var isBadRequestError = (e) => hasKind(e, "bad_request");
33
+ var isUnauthorizedError = (e) => hasKind(e, "unauthorized");
34
+ var isScanError = (e) => hasKind(e, "scan_error");
35
+ var isGithubError = (e) => hasKind(e, "github_error");
36
+ var isServiceError = (e) => isNotFoundError(e) || isForbiddenError(e) || isValidationError(e) || isRateLimitedError(e) || isStoreError(e) || isNetworkError(e) || isAuthExpiredError(e) || isApiError(e) || isParseError(e) || isEncryptionError(e) || isDatabaseError(e) || isConflictError(e) || isBadRequestError(e) || isUnauthorizedError(e) || isScanError(e) || isGithubError(e);
37
+ var isRetryableError = (e) => isRateLimitedError(e) || isNetworkError(e);
38
+ var notFound = (resource, id, ctx) => logAndReturn({ kind: "not_found", resource, ...id && { id } }, ctx);
39
+ var forbidden = (reason, ctx) => logAndReturn({ kind: "forbidden", ...reason && { reason, message: reason } }, ctx);
40
+ var validation = (errors2, ctx) => logAndReturn({ kind: "validation", errors: errors2 }, ctx);
41
+ var rateLimited = (retry_after, ctx) => logAndReturn({ kind: "rate_limited", ...retry_after !== void 0 && { retry_after } }, ctx);
42
+ var storeError = (operation, message, ctx) => logAndReturn({ kind: "store_error", operation, ...message && { message } }, ctx);
43
+ var networkError = (cause, message, ctx) => logAndReturn({ kind: "network_error", ...cause && { cause }, ...message && { message } }, ctx);
44
+ var authExpired = (message, ctx) => logAndReturn({ kind: "auth_expired", ...message && { message } }, ctx);
45
+ var apiError = (status, message, ctx) => logAndReturn({ kind: "api_error", status, ...message && { message } }, ctx);
46
+ var parseError = (message, ctx) => logAndReturn({ kind: "parse_error", ...message && { message } }, ctx);
47
+ var encryptionError = (operation, message, ctx) => logAndReturn({ kind: "encryption_error", operation, ...message && { message } }, ctx);
48
+ var dbError = (message, ctx) => logAndReturn({ kind: "db_error", ...message && { message } }, ctx);
49
+ var conflict = (resource, message, ctx) => logAndReturn({ kind: "conflict", ...resource && { resource }, ...message && { message } }, ctx);
50
+ var badRequest = (message, details, ctx) => logAndReturn({ kind: "bad_request", ...message && { message }, ...details !== void 0 && { details } }, ctx);
51
+ var unauthorized = (message, ctx) => logAndReturn({ kind: "unauthorized", ...message && { message } }, ctx);
52
+ var scanError = (message, ctx) => logAndReturn({ kind: "scan_error", ...message && { message } }, ctx);
53
+ var githubError = (message, ctx) => logAndReturn({ kind: "github_error", ...message && { message } }, ctx);
54
+ var errors = {
55
+ notFound,
56
+ forbidden,
57
+ validation,
58
+ rateLimited,
59
+ storeError,
60
+ networkError,
61
+ authExpired,
62
+ apiError,
63
+ parseError,
64
+ encryptionError,
65
+ dbError,
66
+ conflict,
67
+ badRequest,
68
+ unauthorized,
69
+ scanError,
70
+ githubError,
71
+ is: {
72
+ notFound: isNotFoundError,
73
+ forbidden: isForbiddenError,
74
+ validation: isValidationError,
75
+ rateLimited: isRateLimitedError,
76
+ storeError: isStoreError,
77
+ networkError: isNetworkError,
78
+ authExpired: isAuthExpiredError,
79
+ apiError: isApiError,
80
+ parseError: isParseError,
81
+ encryptionError: isEncryptionError,
82
+ dbError: isDatabaseError,
83
+ conflict: isConflictError,
84
+ badRequest: isBadRequestError,
85
+ unauthorized: isUnauthorizedError,
86
+ scanError: isScanError,
87
+ githubError: isGithubError,
88
+ serviceError: isServiceError,
89
+ retryable: isRetryableError
90
+ }
91
+ };
92
+
93
+ export {
94
+ configureErrorLogging,
95
+ isNotFoundError,
96
+ isForbiddenError,
97
+ isValidationError,
98
+ isRateLimitedError,
99
+ isStoreError,
100
+ isNetworkError,
101
+ isAuthExpiredError,
102
+ isApiError,
103
+ isParseError,
104
+ isEncryptionError,
105
+ isDatabaseError,
106
+ isConflictError,
107
+ isBadRequestError,
108
+ isUnauthorizedError,
109
+ isScanError,
110
+ isGithubError,
111
+ isServiceError,
112
+ isRetryableError,
113
+ notFound,
114
+ forbidden,
115
+ validation,
116
+ rateLimited,
117
+ storeError,
118
+ networkError,
119
+ authExpired,
120
+ apiError,
121
+ parseError,
122
+ encryptionError,
123
+ dbError,
124
+ conflict,
125
+ badRequest,
126
+ unauthorized,
127
+ scanError,
128
+ githubError,
129
+ errors
130
+ };
@@ -0,0 +1,318 @@
1
+ // ../schema/dist/database/schema.js
2
+ import { relations, sql } from "drizzle-orm";
3
+ import { int, integer, primaryKey, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
4
+ var timestamps = () => ({
5
+ created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
6
+ updated_at: text("updated_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
7
+ });
8
+ var deleted = () => ({
9
+ deleted: int("deleted", { mode: "boolean" }).notNull().default(false)
10
+ });
11
+ var owner_id = () => ({
12
+ owner_id: text("owner_id").notNull().references(() => user.id)
13
+ });
14
+ var id = (prefix) => ({
15
+ id: text("id").primaryKey().$defaultFn(() => `${prefix}_${crypto.randomUUID()}`)
16
+ });
17
+ var entity = (prefix) => ({
18
+ ...id(prefix),
19
+ ...timestamps(),
20
+ ...deleted()
21
+ });
22
+ var owned_entity = (prefix) => ({
23
+ ...entity(prefix),
24
+ ...owner_id()
25
+ });
26
+ var user = sqliteTable("user", {
27
+ id: text("id").primaryKey().$defaultFn(() => `user_${crypto.randomUUID()}`),
28
+ github_id: integer("github_id"),
29
+ name: text("name"),
30
+ email: text("email").unique(),
31
+ email_verified: text("email_verified"),
32
+ // timestamp
33
+ image_url: text("image_url"),
34
+ task_view: text("task_view", { enum: ["list", "grid"] }).notNull().default("list")
35
+ });
36
+ var session = sqliteTable("session", {
37
+ id: text("id").notNull().primaryKey(),
38
+ userId: text("user_id").notNull().references(() => user.id),
39
+ expiresAt: integer("expires_at").notNull(),
40
+ access_token: text("access_token")
41
+ });
42
+ var api_keys = sqliteTable("api_keys", {
43
+ ...id("apikey"),
44
+ user_id: text("user_id").notNull().references(() => user.id),
45
+ key_hash: text("key_hash").notNull().unique(),
46
+ name: text("name"),
47
+ note: text("note"),
48
+ scope: text("scope", { enum: ["devpad", "blog", "media", "all"] }).notNull().default("all"),
49
+ enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
50
+ last_used_at: text("last_used_at"),
51
+ ...timestamps(),
52
+ deleted: integer("deleted", { mode: "boolean" }).notNull().default(false)
53
+ });
54
+ var project = sqliteTable("project", {
55
+ ...owned_entity("project"),
56
+ project_id: text("project_id").notNull(),
57
+ name: text("name").notNull(),
58
+ description: text("description"),
59
+ specification: text("specification"),
60
+ repo_url: text("repo_url"),
61
+ repo_id: integer("repo_id"),
62
+ icon_url: text("icon_url"),
63
+ status: text("status", { enum: ["DEVELOPMENT", "PAUSED", "RELEASED", "LIVE", "FINISHED", "ABANDONED", "STOPPED"] }).notNull().default("DEVELOPMENT"),
64
+ link_url: text("link_url"),
65
+ link_text: text("link_text"),
66
+ visibility: text("visibility", { enum: ["PUBLIC", "PRIVATE", "HIDDEN", "ARCHIVED", "DRAFT", "DELETED"] }).notNull().default("PRIVATE"),
67
+ current_version: text("current_version"),
68
+ scan_branch: text("scan_branch")
69
+ });
70
+ var ACTIONS = [
71
+ "CREATE_TASK",
72
+ "UPDATE_TASK",
73
+ "DELETE_TASK",
74
+ "CREATE_PROJECT",
75
+ "UPDATE_PROJECT",
76
+ "DELETE_PROJECT",
77
+ "CREATE_TAG",
78
+ "UPDATE_TAG",
79
+ "DELETE_TAG",
80
+ "CREATE_GOAL",
81
+ "UPDATE_GOAL",
82
+ "DELETE_GOAL",
83
+ "CREATE_MILESTONE",
84
+ "UPDATE_MILESTONE",
85
+ "DELETE_MILESTONE",
86
+ "CREATE_CHECKLIST",
87
+ "UPDATE_CHECKLIST",
88
+ "DELETE_CHECKLIST"
89
+ ];
90
+ var action = sqliteTable("action", {
91
+ ...owned_entity("action"),
92
+ type: text("type", { enum: ACTIONS }).notNull(),
93
+ description: text("description").notNull(),
94
+ data: text("data", { mode: "json" })
95
+ });
96
+ var tracker_result = sqliteTable("tracker_result", {
97
+ id: integer("id").primaryKey({ autoIncrement: true }),
98
+ project_id: text("project_id").notNull().references(() => project.id),
99
+ created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
100
+ data: text("data", { mode: "json" }).notNull(),
101
+ accepted: integer("accepted", { mode: "boolean" }).notNull().default(false)
102
+ });
103
+ var todo_updates = sqliteTable("todo_updates", {
104
+ id: integer("id").primaryKey({ autoIncrement: true }),
105
+ project_id: text("project_id").notNull().references(() => project.id),
106
+ created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
107
+ old_id: integer("old_id").references(() => tracker_result.id),
108
+ new_id: integer("new_id").notNull().references(() => tracker_result.id),
109
+ data: text("data", { mode: "json" }).notNull(),
110
+ status: text("status", { enum: ["PENDING", "ACCEPTED", "REJECTED", "IGNORED"] }).notNull().default("PENDING"),
111
+ branch: text("branch"),
112
+ commit_sha: text("commit_sha"),
113
+ commit_msg: text("commit_msg"),
114
+ commit_url: text("commit_url")
115
+ });
116
+ var update_tracker_relations = relations(todo_updates, ({ one }) => ({
117
+ old: one(tracker_result, { fields: [todo_updates.old_id], references: [tracker_result.id] }),
118
+ new: one(tracker_result, { fields: [todo_updates.new_id], references: [tracker_result.id] })
119
+ }));
120
+ var milestone = sqliteTable("milestone", {
121
+ ...entity("milestone"),
122
+ project_id: text("project_id").notNull().references(() => project.id),
123
+ name: text("name").notNull(),
124
+ description: text("description"),
125
+ target_time: text("target_time"),
126
+ target_version: text("target_version"),
127
+ finished_at: text("finished_at"),
128
+ after_id: text("after_id")
129
+ });
130
+ var goal = sqliteTable("goal", {
131
+ ...entity("goal"),
132
+ milestone_id: text("milestone_id").notNull().references(() => milestone.id),
133
+ name: text("name").notNull(),
134
+ description: text("description"),
135
+ target_time: text("target_time"),
136
+ finished_at: text("finished_at")
137
+ });
138
+ var task = sqliteTable("task", {
139
+ ...owned_entity("task"),
140
+ title: text("title").notNull(),
141
+ progress: text("progress", { enum: ["UNSTARTED", "IN_PROGRESS", "COMPLETED"] }).notNull().default("UNSTARTED"),
142
+ visibility: text("visibility", { enum: ["PUBLIC", "PRIVATE", "HIDDEN", "ARCHIVED", "DRAFT", "DELETED"] }).notNull().default("PRIVATE"),
143
+ goal_id: text("goal_id").references(() => goal.id),
144
+ project_id: text("project_id").references(() => project.id),
145
+ description: text("description"),
146
+ start_time: text("start_time"),
147
+ end_time: text("end_time"),
148
+ summary: text("summary"),
149
+ codebase_task_id: text("codebase_task_id").references(() => codebase_tasks.id),
150
+ priority: text("priority", { enum: ["LOW", "MEDIUM", "HIGH"] }).notNull().default("LOW")
151
+ });
152
+ var checklist = sqliteTable("checklist", {
153
+ ...entity("checklist"),
154
+ task_id: text("task_id").notNull().references(() => task.id),
155
+ name: text("name").notNull()
156
+ });
157
+ var checklist_item = sqliteTable("checklist_item", {
158
+ ...entity("checklist-item"),
159
+ checklist_id: text("checklist_id").notNull().references(() => checklist.id),
160
+ parent_id: text("parent_id"),
161
+ name: text("name").notNull(),
162
+ checked: int("checked", { mode: "boolean" }).notNull().default(false)
163
+ });
164
+ var codebase_tasks = sqliteTable("codebase_tasks", {
165
+ ...entity("codebase-task"),
166
+ branch: text("branch"),
167
+ commit_sha: text("commit_sha"),
168
+ commit_msg: text("commit_msg"),
169
+ commit_url: text("commit_url"),
170
+ type: text("type"),
171
+ text: text("text"),
172
+ file: text("file"),
173
+ line: integer("line"),
174
+ context: text("context", { mode: "json" }),
175
+ recent_scan_id: integer("recent_scan_id").references(() => tracker_result.id)
176
+ });
177
+ var tag = sqliteTable("tag", {
178
+ ...owned_entity("tag"),
179
+ title: text("title").notNull(),
180
+ color: text("color"),
181
+ render: int("render", { mode: "boolean" }).notNull().default(true)
182
+ }, (table) => ({
183
+ tag_unique: unique("tag_unique").on(table.owner_id, table.title)
184
+ }));
185
+ var task_tag = sqliteTable("task_tag", {
186
+ task_id: text("task_id").notNull().references(() => task.id),
187
+ tag_id: text("tag_id").notNull().references(() => tag.id),
188
+ ...timestamps()
189
+ }, (table) => ({
190
+ task_tag_unique: primaryKey({ columns: [table.task_id, table.tag_id] })
191
+ }));
192
+ var commit_detail = sqliteTable("commit_detail", {
193
+ sha: text("sha").primaryKey(),
194
+ message: text("message").notNull(),
195
+ url: text("url").notNull(),
196
+ avatar_url: text("avatar_url"),
197
+ author_user: text("author_user").notNull(),
198
+ author_name: text("author_name"),
199
+ author_email: text("author_email").notNull(),
200
+ date: text("date").notNull()
201
+ });
202
+ var tag_config = sqliteTable("tag_config", {
203
+ ...id("tag_config"),
204
+ project_id: text("project_id").notNull().references(() => project.id),
205
+ // Foreign key to projects
206
+ tag_id: text("tag_id").notNull().references(() => tag.id),
207
+ // Foreign key to tags
208
+ match: text("match").notNull(),
209
+ // Match pattern for this tag
210
+ ...timestamps()
211
+ });
212
+ var ignore_path = sqliteTable("ignore_path", {
213
+ ...id("ignore_path"),
214
+ project_id: text("project_id").notNull().references(() => project.id),
215
+ // Foreign key to projects
216
+ path: text("path").notNull(),
217
+ // Ignore path
218
+ ...timestamps()
219
+ });
220
+ var user_relations = relations(user, ({ many }) => ({
221
+ sessions: many(session),
222
+ api_keys: many(api_keys),
223
+ actions: many(action),
224
+ tasks: many(task),
225
+ tags: many(tag)
226
+ }));
227
+ var session_relations = relations(session, ({ one }) => ({
228
+ user: one(user, { fields: [session.userId], references: [user.id] })
229
+ }));
230
+ var api_keys_relations = relations(api_keys, ({ one }) => ({
231
+ owner: one(user, { fields: [api_keys.user_id], references: [user.id] })
232
+ }));
233
+ var project_relations = relations(project, ({ one, many }) => ({
234
+ owner: one(user, { fields: [project.owner_id], references: [user.id] }),
235
+ tracker_results: many(tracker_result),
236
+ milestones: many(milestone),
237
+ todo_updates: many(todo_updates)
238
+ }));
239
+ var action_relations = relations(action, ({ one }) => ({
240
+ owner: one(user, { fields: [action.owner_id], references: [user.id] })
241
+ }));
242
+ var tracker_result_relations = relations(tracker_result, ({ one }) => ({
243
+ project: one(project, { fields: [tracker_result.project_id], references: [project.id] })
244
+ }));
245
+ var todoUpdatesRelations = relations(todo_updates, ({ one }) => ({
246
+ project: one(project, { fields: [todo_updates.project_id], references: [project.id] }),
247
+ oldTrackerResult: one(tracker_result, { fields: [todo_updates.old_id], references: [tracker_result.id] }),
248
+ newTrackerResult: one(tracker_result, { fields: [todo_updates.new_id], references: [tracker_result.id] })
249
+ }));
250
+ var milestone_relations = relations(milestone, ({ one, many }) => ({
251
+ project: one(project, { fields: [milestone.project_id], references: [project.id] }),
252
+ goals: many(goal)
253
+ }));
254
+ var goal_relations = relations(goal, ({ one }) => ({
255
+ milestone: one(milestone, { fields: [goal.milestone_id], references: [milestone.id] })
256
+ }));
257
+ var task_relations = relations(task, ({ one, many }) => ({
258
+ owner: one(user, { fields: [task.owner_id], references: [user.id] }),
259
+ goal: one(goal, { fields: [task.goal_id], references: [goal.id] }),
260
+ codebase_task: one(codebase_tasks, { fields: [task.codebase_task_id], references: [codebase_tasks.id] }),
261
+ checklists: many(checklist)
262
+ }));
263
+ var checklist_relations = relations(checklist, ({ one, many }) => ({
264
+ task: one(task, { fields: [checklist.task_id], references: [task.id] }),
265
+ items: many(checklist_item)
266
+ }));
267
+ var checklist_item_relations = relations(checklist_item, ({ one }) => ({
268
+ checklist: one(checklist, { fields: [checklist_item.checklist_id], references: [checklist.id] })
269
+ }));
270
+ var tag_relations = relations(tag, ({ one }) => ({
271
+ owner: one(user, { fields: [tag.owner_id], references: [user.id] })
272
+ }));
273
+ var task_tag_relations = relations(task_tag, ({ one }) => ({
274
+ task: one(task, { fields: [task_tag.task_id], references: [task.id] }),
275
+ tag: one(tag, { fields: [task_tag.tag_id], references: [tag.id] })
276
+ }));
277
+
278
+ export {
279
+ timestamps,
280
+ deleted,
281
+ owner_id,
282
+ id,
283
+ entity,
284
+ owned_entity,
285
+ user,
286
+ session,
287
+ api_keys,
288
+ project,
289
+ action,
290
+ tracker_result,
291
+ todo_updates,
292
+ update_tracker_relations,
293
+ milestone,
294
+ goal,
295
+ task,
296
+ checklist,
297
+ checklist_item,
298
+ codebase_tasks,
299
+ tag,
300
+ task_tag,
301
+ commit_detail,
302
+ tag_config,
303
+ ignore_path,
304
+ user_relations,
305
+ session_relations,
306
+ api_keys_relations,
307
+ project_relations,
308
+ action_relations,
309
+ tracker_result_relations,
310
+ todoUpdatesRelations,
311
+ milestone_relations,
312
+ goal_relations,
313
+ task_relations,
314
+ checklist_relations,
315
+ checklist_item_relations,
316
+ tag_relations,
317
+ task_tag_relations
318
+ };
@@ -0,0 +1,166 @@
1
+ // ../schema/dist/types.js
2
+ var TAG_COLOURS = {
3
+ red: { colour: "#F28B82", text: "#faeeef", border: "#F5A5A5" },
4
+ green: { colour: "#CCFF90", text: "#2E7D32", border: "#A5D6A7" },
5
+ blue: { colour: "#82B1FF", text: "#0D47A1", border: "#90CAF9" },
6
+ yellow: { colour: "#FFF176", text: "#F57F17", border: "#FFF59D" },
7
+ purple: { colour: "#E1BEE7", text: "#4A148C", border: "#CE93D8" },
8
+ orange: { colour: "#FFCC80", text: "#E65100", border: "#FFB74D" },
9
+ teal: { colour: "#80CBC4", text: "#004D40", border: "#4DB6AC" },
10
+ pink: { colour: "#F8BBD9", text: "#880E4F", border: "#F48FB1" },
11
+ gray: { colour: "#CFD8DC", text: "#37474F", border: "#B0BEC5" },
12
+ cyan: { colour: "#84FFFF", text: "#006064", border: "#4DD0E1" },
13
+ lime: { colour: "#ddf0bc", text: "#88b47f", border: "#becca5" }
14
+ };
15
+ var ArrayBufferedQueue = class {
16
+ constructor(_capacity) {
17
+ this._capacity = _capacity;
18
+ this._entries = [];
19
+ this._head = 0;
20
+ this._tail = 0;
21
+ this._size = 0;
22
+ }
23
+ latest() {
24
+ if (this._size === 0)
25
+ return null;
26
+ return this._entries[this._tail - 1] ?? null;
27
+ }
28
+ list() {
29
+ if (this._size === 0)
30
+ return [];
31
+ if (this._head < this._tail) {
32
+ return this._entries.slice(this._head, this._tail);
33
+ }
34
+ return this._entries.slice(this._head).concat(this._entries.slice(0, this._tail));
35
+ }
36
+ add(item) {
37
+ if (this._size === this._capacity) {
38
+ this._head = (this._head + 1) % this._capacity;
39
+ } else {
40
+ this._size++;
41
+ }
42
+ this._entries[this._tail] = item;
43
+ this._tail = (this._tail + 1) % this._capacity;
44
+ }
45
+ size() {
46
+ return this._size;
47
+ }
48
+ clear() {
49
+ this._entries = [];
50
+ this._head = 0;
51
+ this._tail = 0;
52
+ this._size = 0;
53
+ }
54
+ };
55
+
56
+ // ../schema/dist/validation.js
57
+ import { z } from "zod";
58
+ var upsert_project = z.object({
59
+ id: z.string().optional().nullable(),
60
+ project_id: z.string(),
61
+ owner_id: z.string().optional(),
62
+ name: z.string(),
63
+ description: z.string().nullable(),
64
+ specification: z.string().nullable(),
65
+ repo_url: z.string().nullable(),
66
+ repo_id: z.number().nullable(),
67
+ icon_url: z.string().nullable(),
68
+ status: z.union([z.literal("DEVELOPMENT"), z.literal("PAUSED"), z.literal("RELEASED"), z.literal("LIVE"), z.literal("FINISHED"), z.literal("ABANDONED"), z.literal("STOPPED")]).optional(),
69
+ deleted: z.boolean().optional().default(false),
70
+ link_url: z.string().nullable(),
71
+ link_text: z.string().nullable(),
72
+ visibility: z.union([z.literal("PUBLIC"), z.literal("PRIVATE"), z.literal("HIDDEN"), z.literal("ARCHIVED"), z.literal("DRAFT"), z.literal("DELETED")]).optional(),
73
+ current_version: z.string().nullable()
74
+ });
75
+ var upsert_todo = z.object({
76
+ id: z.string().optional().nullable(),
77
+ title: z.string().optional(),
78
+ summary: z.string().optional().nullable(),
79
+ description: z.string().optional().nullable(),
80
+ progress: z.union([z.literal("UNSTARTED"), z.literal("IN_PROGRESS"), z.literal("COMPLETED")]).optional(),
81
+ visibility: z.union([z.literal("PUBLIC"), z.literal("PRIVATE"), z.literal("HIDDEN"), z.literal("ARCHIVED"), z.literal("DRAFT"), z.literal("DELETED")]).optional(),
82
+ start_time: z.string().optional().nullable(),
83
+ end_time: z.string().optional().nullable(),
84
+ priority: z.union([z.literal("LOW"), z.literal("MEDIUM"), z.literal("HIGH")]).optional(),
85
+ owner_id: z.string(),
86
+ project_id: z.string().optional().nullable(),
87
+ goal_id: z.string().optional().nullable()
88
+ });
89
+ var update_action = z.union([z.literal("CONFIRM"), z.literal("UNLINK"), z.literal("CREATE"), z.literal("IGNORE"), z.literal("DELETE"), z.literal("COMPLETE")]);
90
+ var ConfigSchema = z.object({
91
+ tags: z.array(z.object({
92
+ name: z.string(),
93
+ match: z.array(z.string())
94
+ })),
95
+ ignore: z.array(z.string().regex(/^[^]*$/, "Invalid path"))
96
+ });
97
+ var upsert_tag = z.object({
98
+ id: z.string().optional(),
99
+ title: z.string(),
100
+ color: z.union([z.literal("red"), z.literal("green"), z.literal("blue"), z.literal("yellow"), z.literal("purple"), z.literal("orange"), z.literal("teal"), z.literal("pink"), z.literal("gray"), z.literal("cyan"), z.literal("lime")]).nullable().optional(),
101
+ deleted: z.boolean().optional().default(false),
102
+ render: z.boolean().optional().default(true),
103
+ owner_id: z.string()
104
+ });
105
+ var project_config = z.object({
106
+ tags: z.array(z.object({
107
+ name: z.string(),
108
+ match: z.array(z.string())
109
+ })),
110
+ ignore: z.array(z.string())
111
+ });
112
+ var save_config_request = z.object({
113
+ id: z.string(),
114
+ config: project_config,
115
+ scan_branch: z.string().optional()
116
+ });
117
+ var save_tags_request = z.array(upsert_tag);
118
+ var update_user = z.object({
119
+ id: z.string(),
120
+ name: z.string().optional(),
121
+ image_url: z.string().optional(),
122
+ task_view: z.union([z.literal("list"), z.literal("grid")]).optional(),
123
+ email_verified: z.boolean().optional()
124
+ });
125
+ var config_schema = z.object({
126
+ tags: z.array(z.object({
127
+ name: z.string(),
128
+ match: z.array(z.string())
129
+ })),
130
+ ignore: z.array(z.string().regex(/^[^]*$/, "Invalid path"))
131
+ });
132
+ var upsert_milestone = z.object({
133
+ id: z.string().optional().nullable(),
134
+ project_id: z.string(),
135
+ name: z.string().min(1).max(200),
136
+ description: z.string().nullable().optional(),
137
+ target_time: z.string().nullable().optional(),
138
+ target_version: z.string().nullable().optional(),
139
+ finished_at: z.string().nullable().optional(),
140
+ after_id: z.string().nullable().optional()
141
+ });
142
+ var upsert_goal = z.object({
143
+ id: z.string().optional().nullable(),
144
+ milestone_id: z.string(),
145
+ name: z.string().min(1).max(200),
146
+ description: z.string().nullable().optional(),
147
+ target_time: z.string().nullable().optional(),
148
+ finished_at: z.string().nullable().optional()
149
+ });
150
+
151
+ export {
152
+ TAG_COLOURS,
153
+ ArrayBufferedQueue,
154
+ upsert_project,
155
+ upsert_todo,
156
+ update_action,
157
+ ConfigSchema,
158
+ upsert_tag,
159
+ project_config,
160
+ save_config_request,
161
+ save_tags_request,
162
+ update_user,
163
+ config_schema,
164
+ upsert_milestone,
165
+ upsert_goal
166
+ };