@devpad/api 2.0.1 → 2.0.3

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,277 @@
1
+ // src/schema/blog.ts
2
+ import {
3
+ create_cloudflare_backend,
4
+ create_corpus,
5
+ create_memory_backend,
6
+ define_store as define_store2,
7
+ err as err2,
8
+ json_codec as json_codec2,
9
+ ok as ok2
10
+ } from "@f0rbit/corpus";
11
+
12
+ // ../schema/dist/blog/corpus.js
13
+ import { define_store, json_codec } from "@f0rbit/corpus";
14
+ import { z } from "zod";
15
+ var PostContentSchema = z.object({
16
+ title: z.string().min(1),
17
+ content: z.string(),
18
+ description: z.string().optional(),
19
+ format: z.enum(["md", "adoc"])
20
+ });
21
+ var postsStoreDefinition = define_store("posts", json_codec(PostContentSchema));
22
+ var postStoreId = (userId, postUuid) => `posts/${userId}/${postUuid}`;
23
+ var corpusPath = postStoreId;
24
+ var VersionInfoSchema = z.object({
25
+ hash: z.string(),
26
+ parent: z.string().nullable(),
27
+ created_at: z.date()
28
+ });
29
+ var mapCorpusError = (e) => {
30
+ if (e.kind === "not_found") {
31
+ return { kind: "not_found", path: e.store_id, version: e.version };
32
+ }
33
+ if (e.kind === "decode_error" || e.kind === "validation_error") {
34
+ return { kind: "invalid_content", message: e.cause?.message ?? "Decode error" };
35
+ }
36
+ if (e.kind === "storage_error") {
37
+ const drizzle_err = e.cause;
38
+ const underlying = drizzle_err?.cause;
39
+ const message = underlying?.message ?? drizzle_err?.message ?? "Storage error";
40
+ return { kind: "io_error", message };
41
+ }
42
+ return { kind: "io_error", message: "Unknown corpus error" };
43
+ };
44
+ var parsePostContent = PostContentSchema.parse.bind(PostContentSchema);
45
+ var serializePostContent = (content) => JSON.stringify(content);
46
+
47
+ // ../schema/dist/blog/corpus-shim.js
48
+ import { at, fetch_result, first, format_error, last, match, pipe, to_fallback, to_nullable, try_catch, try_catch_async, unwrap_or } from "@f0rbit/corpus";
49
+
50
+ // ../schema/dist/blog/types.js
51
+ import { z as z2 } from "zod";
52
+ import { at as at2, err, fetch_result as fetch_result2, first as first2, format_error as format_error2, last as last2, match as match2, ok, pipe as pipe2, to_fallback as to_fallback2, to_nullable as to_nullable2, try_catch as try_catch2, try_catch_async as try_catch_async2, unwrap_or as unwrap_or2 } from "@f0rbit/corpus";
53
+ var PostRowSchema = z2.object({
54
+ id: z2.number(),
55
+ uuid: z2.string(),
56
+ author_id: z2.string(),
57
+ slug: z2.string(),
58
+ corpus_version: z2.string().nullable(),
59
+ category: z2.string(),
60
+ archived: z2.boolean(),
61
+ publish_at: z2.coerce.date().nullable(),
62
+ created_at: z2.coerce.date(),
63
+ updated_at: z2.coerce.date()
64
+ });
65
+ var PostRowInsertSchema = z2.object({
66
+ id: z2.number().optional(),
67
+ uuid: z2.string(),
68
+ author_id: z2.string(),
69
+ slug: z2.string(),
70
+ corpus_version: z2.string().nullable().optional(),
71
+ category: z2.string().optional(),
72
+ archived: z2.boolean().optional(),
73
+ publish_at: z2.coerce.date().nullable().optional(),
74
+ created_at: z2.coerce.date().optional(),
75
+ updated_at: z2.coerce.date().optional()
76
+ });
77
+ var CategorySchema = z2.object({
78
+ id: z2.number(),
79
+ owner_id: z2.string(),
80
+ name: z2.string(),
81
+ parent: z2.string().nullable()
82
+ });
83
+ var CategoryInsertSchema = z2.object({
84
+ id: z2.number().optional(),
85
+ owner_id: z2.string(),
86
+ name: z2.string(),
87
+ parent: z2.string().nullable().optional()
88
+ });
89
+ var TagSchema = z2.object({
90
+ post_id: z2.number(),
91
+ tag: z2.string()
92
+ });
93
+ var TagInsertSchema = z2.object({
94
+ post_id: z2.number(),
95
+ tag: z2.string()
96
+ });
97
+ var AccessKeyRowSchema = z2.object({
98
+ id: z2.number(),
99
+ user_id: z2.string(),
100
+ key_hash: z2.string(),
101
+ name: z2.string(),
102
+ note: z2.string().nullable(),
103
+ enabled: z2.boolean(),
104
+ created_at: z2.coerce.date()
105
+ });
106
+ var AccessKeySchema = AccessKeyRowSchema.omit({ key_hash: true });
107
+ var AccessKeyInsertSchema = z2.object({
108
+ id: z2.number().optional(),
109
+ user_id: z2.string(),
110
+ key_hash: z2.string(),
111
+ name: z2.string(),
112
+ note: z2.string().nullable().optional(),
113
+ enabled: z2.boolean().optional(),
114
+ created_at: z2.coerce.date().optional()
115
+ });
116
+ var IntegrationSchema = z2.object({
117
+ id: z2.number(),
118
+ user_id: z2.string(),
119
+ source: z2.string(),
120
+ location: z2.string(),
121
+ data: z2.record(z2.unknown()).nullable(),
122
+ last_fetch: z2.coerce.date().nullable(),
123
+ status: z2.string().nullable(),
124
+ created_at: z2.coerce.date()
125
+ });
126
+ var IntegrationInsertSchema = z2.object({
127
+ id: z2.number().optional(),
128
+ user_id: z2.string(),
129
+ source: z2.string(),
130
+ location: z2.string(),
131
+ data: z2.record(z2.unknown()).nullable().optional(),
132
+ last_fetch: z2.coerce.date().nullable().optional(),
133
+ status: z2.string().nullable().optional(),
134
+ created_at: z2.coerce.date().optional()
135
+ });
136
+ var FetchLinkSchema = z2.object({
137
+ id: z2.number(),
138
+ post_id: z2.number(),
139
+ integration_id: z2.number(),
140
+ identifier: z2.string()
141
+ });
142
+ var FetchLinkInsertSchema = z2.object({
143
+ id: z2.number().optional(),
144
+ post_id: z2.number(),
145
+ integration_id: z2.number(),
146
+ identifier: z2.string()
147
+ });
148
+ var PostSchema = z2.object({
149
+ id: z2.number(),
150
+ uuid: z2.string().uuid(),
151
+ author_id: z2.string(),
152
+ slug: z2.string(),
153
+ title: z2.string(),
154
+ content: z2.string(),
155
+ description: z2.string().optional(),
156
+ format: z2.enum(["md", "adoc"]),
157
+ category: z2.string(),
158
+ tags: z2.array(z2.string()),
159
+ archived: z2.boolean(),
160
+ publish_at: z2.coerce.date().nullable(),
161
+ created_at: z2.coerce.date(),
162
+ updated_at: z2.coerce.date(),
163
+ project_ids: z2.array(z2.string()),
164
+ corpus_version: z2.string().nullable()
165
+ });
166
+ var SlugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
167
+ var PostCreateSchema = z2.object({
168
+ slug: z2.string().regex(SlugPattern, "Slug must be lowercase alphanumeric with hyphens"),
169
+ title: z2.string().min(1),
170
+ content: z2.string(),
171
+ description: z2.string().optional(),
172
+ format: z2.enum(["md", "adoc"]).default("md"),
173
+ category: z2.string().default("root"),
174
+ tags: z2.array(z2.string()).default([]),
175
+ publish_at: z2.coerce.date().nullable().optional(),
176
+ project_ids: z2.array(z2.string()).optional()
177
+ });
178
+ var PostUpdateSchema = z2.object({
179
+ slug: z2.string().regex(SlugPattern, "Slug must be lowercase alphanumeric with hyphens").optional(),
180
+ title: z2.string().min(1).optional(),
181
+ content: z2.string().optional(),
182
+ description: z2.string().optional(),
183
+ format: z2.enum(["md", "adoc"]).optional(),
184
+ category: z2.string().optional(),
185
+ tags: z2.array(z2.string()).optional(),
186
+ archived: z2.boolean().optional(),
187
+ publish_at: z2.coerce.date().nullable().optional(),
188
+ project_ids: z2.array(z2.string()).optional()
189
+ });
190
+ var PostListParamsSchema = z2.object({
191
+ category: z2.string().optional(),
192
+ tag: z2.string().optional(),
193
+ project: z2.string().optional(),
194
+ status: z2.enum(["published", "scheduled", "draft", "all"]).default("all"),
195
+ archived: z2.boolean().default(false),
196
+ limit: z2.coerce.number().min(1).max(100).default(10),
197
+ offset: z2.coerce.number().min(0).default(0),
198
+ sort: z2.enum(["created", "updated", "published"]).default("updated")
199
+ });
200
+ var PostsResponseSchema = z2.object({
201
+ posts: z2.array(PostSchema),
202
+ total_posts: z2.number(),
203
+ total_pages: z2.number(),
204
+ per_page: z2.number(),
205
+ current_page: z2.number()
206
+ });
207
+ var isPublished = (post) => post.publish_at !== null && post.publish_at <= /* @__PURE__ */ new Date();
208
+ var isScheduled = (post) => post.publish_at !== null && post.publish_at > /* @__PURE__ */ new Date();
209
+ var isDraft = (post) => post.publish_at === null;
210
+ var postStatus = (post) => {
211
+ if (isDraft(post))
212
+ return "draft";
213
+ if (isScheduled(post))
214
+ return "scheduled";
215
+ return "published";
216
+ };
217
+ var CategoryCreateSchema = z2.object({
218
+ name: z2.string().min(1),
219
+ parent: z2.string().default("root")
220
+ });
221
+ var AccessKeyCreateSchema = z2.object({
222
+ name: z2.string().min(1),
223
+ note: z2.string().optional()
224
+ });
225
+ var AccessKeyUpdateSchema = z2.object({
226
+ name: z2.string().min(1).optional(),
227
+ note: z2.string().optional(),
228
+ enabled: z2.boolean().optional()
229
+ });
230
+ var IntegrationUpsertSchema = z2.object({
231
+ source: z2.string().min(1),
232
+ location: z2.string().min(1),
233
+ data: z2.record(z2.unknown()).optional()
234
+ });
235
+ export {
236
+ AccessKeyCreateSchema,
237
+ AccessKeyInsertSchema,
238
+ AccessKeyRowSchema,
239
+ AccessKeySchema,
240
+ AccessKeyUpdateSchema,
241
+ CategoryCreateSchema,
242
+ CategoryInsertSchema,
243
+ CategorySchema,
244
+ FetchLinkInsertSchema,
245
+ FetchLinkSchema,
246
+ IntegrationInsertSchema,
247
+ IntegrationSchema,
248
+ IntegrationUpsertSchema,
249
+ PostContentSchema,
250
+ PostCreateSchema,
251
+ PostListParamsSchema,
252
+ PostRowInsertSchema,
253
+ PostRowSchema,
254
+ PostSchema,
255
+ PostUpdateSchema,
256
+ PostsResponseSchema,
257
+ TagInsertSchema,
258
+ TagSchema,
259
+ VersionInfoSchema,
260
+ corpusPath,
261
+ create_cloudflare_backend,
262
+ create_corpus,
263
+ create_memory_backend,
264
+ define_store2 as define_store,
265
+ err2 as err,
266
+ isDraft,
267
+ isPublished,
268
+ isScheduled,
269
+ json_codec2 as json_codec,
270
+ mapCorpusError,
271
+ ok2 as ok,
272
+ parsePostContent,
273
+ postStatus,
274
+ postStoreId,
275
+ postsStoreDefinition,
276
+ serializePostContent
277
+ };
@@ -0,0 +1,7 @@
1
+ export { b as ApiError, A as AuthExpiredError, c as BadRequestError, B as BaseError, C as ConflictError, g as CronError, D as DatabaseError, E as EncryptionError, h as ErrorContext, i as ErrorLogEntry, F as ForbiddenError, G as GithubError, a as NetworkError, N as NotFoundError, P as ParseError, f as ProviderError, R as RateLimitedError, d as ScanError, e as ServiceError, S as StoreError, U as UnauthorizedError, V as ValidationError, W as apiError, T as authExpired, $ as badRequest, j as configureErrorLogging, _ as conflict, Z as dbError, Y as encryptionError, a3 as errors, K as forbidden, a2 as githubError, r as isApiError, q as isAuthExpiredError, w as isBadRequestError, v as isConflictError, u as isDatabaseError, t as isEncryptionError, l as isForbiddenError, z as isGithubError, p as isNetworkError, k as isNotFoundError, s as isParseError, n as isRateLimitedError, I as isRetryableError, y as isScanError, H as isServiceError, o as isStoreError, x as isUnauthorizedError, m as isValidationError, Q as networkError, J as notFound, X as parseError, M as rateLimited, a1 as scanError, O as storeError, a0 as unauthorized, L as validation } from '../errors.d-C73AkrdX.js';
2
+ export { c as Action, R as ApiClientConfig, A as ApiKey, a0 as ApiResponse, a5 as ArrayBufferedQueue, a4 as BufferedQueue, C as CodebaseTask, a9 as ConfigSchema, a3 as ConfigSchemaType, L as GetConfigResult, G as Goal, $ as HistoryAction, I as IgnorePath, p as InsertAction, i as InsertApiKey, q as InsertCodebaseTask, n as InsertGoal, u as InsertIgnorePath, m as InsertMilestone, j as InsertProject, h as InsertSession, l as InsertTag, t as InsertTagConfig, k as InsertTask, o as InsertTaskTag, r as InsertTodoUpdate, s as InsertTrackerResult, g as InsertUser, M as Milestone, W as Nullable, P as Project, D as ProjectConfig, J as ProjectWithTasks, V as RequestOptions, E as SaveConfigRequest, F as SaveTagsRequest, Y as ScanStatus, Z as ScanStatusRequest, _ as ScanUpdate, S as Session, N as TAG_COLOURS, a as Tag, O as TagColor, f as TagConfig, K as TagWithColor, Q as TagWithTypedColor, T as Task, b as TaskTag, X as TaskView, H as TaskWithDetails, d as TodoUpdate, e as TrackerResult, B as UpdateAction, a1 as UpdateData, a2 as UpdateUser, z as UpsertGoal, y as UpsertMilestone, v as UpsertProject, x as UpsertTag, w as UpsertTodo, U as User, af as config_schema, ab as project_config, ac as save_config_request, ad as save_tags_request, a8 as update_action, ae as update_user, ah as upsert_goal, ag as upsert_milestone, a6 as upsert_project, aa as upsert_tag, a7 as upsert_todo } from '../types.d-Bj4FU9Op.js';
3
+ import '@f0rbit/corpus';
4
+ import 'drizzle-orm';
5
+ import 'zod';
6
+ import '../schema.d-DALWdx-o.js';
7
+ import 'drizzle-orm/sqlite-core';
@@ -0,0 +1,106 @@
1
+ import {
2
+ ArrayBufferedQueue,
3
+ ConfigSchema,
4
+ TAG_COLOURS,
5
+ config_schema,
6
+ project_config,
7
+ save_config_request,
8
+ save_tags_request,
9
+ update_action,
10
+ update_user,
11
+ upsert_goal,
12
+ upsert_milestone,
13
+ upsert_project,
14
+ upsert_tag,
15
+ upsert_todo
16
+ } from "../chunk-INGCIUMX.js";
17
+ import {
18
+ apiError,
19
+ authExpired,
20
+ badRequest,
21
+ configureErrorLogging,
22
+ conflict,
23
+ dbError,
24
+ encryptionError,
25
+ errors,
26
+ forbidden,
27
+ githubError,
28
+ isApiError,
29
+ isAuthExpiredError,
30
+ isBadRequestError,
31
+ isConflictError,
32
+ isDatabaseError,
33
+ isEncryptionError,
34
+ isForbiddenError,
35
+ isGithubError,
36
+ isNetworkError,
37
+ isNotFoundError,
38
+ isParseError,
39
+ isRateLimitedError,
40
+ isRetryableError,
41
+ isScanError,
42
+ isServiceError,
43
+ isStoreError,
44
+ isUnauthorizedError,
45
+ isValidationError,
46
+ networkError,
47
+ notFound,
48
+ parseError,
49
+ rateLimited,
50
+ scanError,
51
+ storeError,
52
+ unauthorized,
53
+ validation
54
+ } from "../chunk-5X36WMYQ.js";
55
+ export {
56
+ ArrayBufferedQueue,
57
+ ConfigSchema,
58
+ TAG_COLOURS,
59
+ apiError,
60
+ authExpired,
61
+ badRequest,
62
+ config_schema,
63
+ configureErrorLogging,
64
+ conflict,
65
+ dbError,
66
+ encryptionError,
67
+ errors,
68
+ forbidden,
69
+ githubError,
70
+ isApiError,
71
+ isAuthExpiredError,
72
+ isBadRequestError,
73
+ isConflictError,
74
+ isDatabaseError,
75
+ isEncryptionError,
76
+ isForbiddenError,
77
+ isGithubError,
78
+ isNetworkError,
79
+ isNotFoundError,
80
+ isParseError,
81
+ isRateLimitedError,
82
+ isRetryableError,
83
+ isScanError,
84
+ isServiceError,
85
+ isStoreError,
86
+ isUnauthorizedError,
87
+ isValidationError,
88
+ networkError,
89
+ notFound,
90
+ parseError,
91
+ project_config,
92
+ rateLimited,
93
+ save_config_request,
94
+ save_tags_request,
95
+ scanError,
96
+ storeError,
97
+ unauthorized,
98
+ update_action,
99
+ update_user,
100
+ upsert_goal,
101
+ upsert_milestone,
102
+ upsert_project,
103
+ upsert_tag,
104
+ upsert_todo,
105
+ validation
106
+ };