@sourcepress/core 0.1.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.
- package/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test.log +15 -0
- package/LICENSE +21 -0
- package/dist/__tests__/schema.test.d.ts +2 -0
- package/dist/__tests__/schema.test.d.ts.map +1 -0
- package/dist/__tests__/schema.test.js +54 -0
- package/dist/__tests__/schema.test.js.map +1 -0
- package/dist/__tests__/validate.test.d.ts +2 -0
- package/dist/__tests__/validate.test.d.ts.map +1 -0
- package/dist/__tests__/validate.test.js +41 -0
- package/dist/__tests__/validate.test.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +29 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +4 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +53 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +244 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +361 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +118 -0
- package/dist/validate.js.map +1 -0
- package/package.json +27 -0
- package/src/__tests__/schema.test.ts +61 -0
- package/src/__tests__/validate.test.ts +43 -0
- package/src/config.ts +42 -0
- package/src/index.ts +32 -0
- package/src/schema.ts +52 -0
- package/src/types.ts +300 -0
- package/src/validate.ts +132 -0
- package/tsconfig.json +8 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export interface ValidationResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
data?: unknown;
|
|
5
|
+
errors: string[];
|
|
6
|
+
}
|
|
7
|
+
declare const configSchema: z.ZodObject<{
|
|
8
|
+
repository: z.ZodObject<{
|
|
9
|
+
owner: z.ZodString;
|
|
10
|
+
repo: z.ZodString;
|
|
11
|
+
branch: z.ZodString;
|
|
12
|
+
content_path: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
owner: string;
|
|
15
|
+
repo: string;
|
|
16
|
+
branch: string;
|
|
17
|
+
content_path?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
owner: string;
|
|
20
|
+
repo: string;
|
|
21
|
+
branch: string;
|
|
22
|
+
content_path?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
ai: z.ZodObject<{
|
|
25
|
+
provider: z.ZodEnum<["anthropic", "openai", "local"]>;
|
|
26
|
+
model: z.ZodString;
|
|
27
|
+
daily_limit_usd: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
warn_at_usd: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
provider: "anthropic" | "openai" | "local";
|
|
31
|
+
model: string;
|
|
32
|
+
daily_limit_usd?: number | undefined;
|
|
33
|
+
warn_at_usd?: number | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
provider: "anthropic" | "openai" | "local";
|
|
36
|
+
model: string;
|
|
37
|
+
daily_limit_usd?: number | undefined;
|
|
38
|
+
warn_at_usd?: number | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
collections: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
path: z.ZodString;
|
|
43
|
+
format: z.ZodEnum<["mdx", "md", "yaml", "json"]>;
|
|
44
|
+
fields: z.ZodRecord<z.ZodString, z.ZodType<any, z.ZodTypeDef, any>>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
path: string;
|
|
47
|
+
name: string;
|
|
48
|
+
format: "mdx" | "md" | "yaml" | "json";
|
|
49
|
+
fields: Record<string, any>;
|
|
50
|
+
}, {
|
|
51
|
+
path: string;
|
|
52
|
+
name: string;
|
|
53
|
+
format: "mdx" | "md" | "yaml" | "json";
|
|
54
|
+
fields: Record<string, any>;
|
|
55
|
+
}>>;
|
|
56
|
+
knowledge: z.ZodObject<{
|
|
57
|
+
path: z.ZodString;
|
|
58
|
+
graph: z.ZodObject<{
|
|
59
|
+
backend: z.ZodEnum<["local", "vectorize", "turso"]>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
backend: "local" | "vectorize" | "turso";
|
|
62
|
+
}, {
|
|
63
|
+
backend: "local" | "vectorize" | "turso";
|
|
64
|
+
}>;
|
|
65
|
+
ingestion: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
scraping: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
respectRobotsTxt: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
rateLimitMs: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
respectRobotsTxt?: boolean | undefined;
|
|
71
|
+
rateLimitMs?: number | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
respectRobotsTxt?: boolean | undefined;
|
|
74
|
+
rateLimitMs?: number | undefined;
|
|
75
|
+
}>>;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
scraping?: {
|
|
78
|
+
respectRobotsTxt?: boolean | undefined;
|
|
79
|
+
rateLimitMs?: number | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
scraping?: {
|
|
83
|
+
respectRobotsTxt?: boolean | undefined;
|
|
84
|
+
rateLimitMs?: number | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
}>>;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
path: string;
|
|
89
|
+
graph: {
|
|
90
|
+
backend: "local" | "vectorize" | "turso";
|
|
91
|
+
};
|
|
92
|
+
ingestion?: {
|
|
93
|
+
scraping?: {
|
|
94
|
+
respectRobotsTxt?: boolean | undefined;
|
|
95
|
+
rateLimitMs?: number | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
path: string;
|
|
100
|
+
graph: {
|
|
101
|
+
backend: "local" | "vectorize" | "turso";
|
|
102
|
+
};
|
|
103
|
+
ingestion?: {
|
|
104
|
+
scraping?: {
|
|
105
|
+
respectRobotsTxt?: boolean | undefined;
|
|
106
|
+
rateLimitMs?: number | undefined;
|
|
107
|
+
} | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
intent: z.ZodObject<{
|
|
111
|
+
path: z.ZodString;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
path: string;
|
|
114
|
+
}, {
|
|
115
|
+
path: string;
|
|
116
|
+
}>;
|
|
117
|
+
media: z.ZodOptional<z.ZodObject<{
|
|
118
|
+
storage: z.ZodEnum<["git", "r2", "s3"]>;
|
|
119
|
+
path: z.ZodString;
|
|
120
|
+
registry: z.ZodString;
|
|
121
|
+
allowedTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
122
|
+
maxSizeMb: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
transform: z.ZodOptional<z.ZodObject<{
|
|
124
|
+
formats: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
125
|
+
sizes: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
formats?: string[] | undefined;
|
|
128
|
+
sizes?: number[] | undefined;
|
|
129
|
+
}, {
|
|
130
|
+
formats?: string[] | undefined;
|
|
131
|
+
sizes?: number[] | undefined;
|
|
132
|
+
}>>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
path: string;
|
|
135
|
+
storage: "git" | "r2" | "s3";
|
|
136
|
+
registry: string;
|
|
137
|
+
allowedTypes?: string[] | undefined;
|
|
138
|
+
maxSizeMb?: number | undefined;
|
|
139
|
+
transform?: {
|
|
140
|
+
formats?: string[] | undefined;
|
|
141
|
+
sizes?: number[] | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
path: string;
|
|
145
|
+
storage: "git" | "r2" | "s3";
|
|
146
|
+
registry: string;
|
|
147
|
+
allowedTypes?: string[] | undefined;
|
|
148
|
+
maxSizeMb?: number | undefined;
|
|
149
|
+
transform?: {
|
|
150
|
+
formats?: string[] | undefined;
|
|
151
|
+
sizes?: number[] | undefined;
|
|
152
|
+
} | undefined;
|
|
153
|
+
}>>;
|
|
154
|
+
jobs: z.ZodOptional<z.ZodObject<{
|
|
155
|
+
backend: z.ZodEnum<["in-process", "queue", "durable-objects"]>;
|
|
156
|
+
}, "strip", z.ZodTypeAny, {
|
|
157
|
+
backend: "in-process" | "queue" | "durable-objects";
|
|
158
|
+
}, {
|
|
159
|
+
backend: "in-process" | "queue" | "durable-objects";
|
|
160
|
+
}>>;
|
|
161
|
+
evals: z.ZodOptional<z.ZodObject<{
|
|
162
|
+
threshold: z.ZodNumber;
|
|
163
|
+
auto_approve: z.ZodOptional<z.ZodBoolean>;
|
|
164
|
+
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
threshold: number;
|
|
166
|
+
auto_approve?: boolean | undefined;
|
|
167
|
+
}, {
|
|
168
|
+
threshold: number;
|
|
169
|
+
auto_approve?: boolean | undefined;
|
|
170
|
+
}>>;
|
|
171
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
172
|
+
provider: z.ZodEnum<["github-pr", "api", "auto"]>;
|
|
173
|
+
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<["pr", "direct"]>>>;
|
|
174
|
+
auto_approve: z.ZodOptional<z.ZodObject<{
|
|
175
|
+
enabled: z.ZodBoolean;
|
|
176
|
+
min_score: z.ZodNumber;
|
|
177
|
+
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
enabled: boolean;
|
|
179
|
+
min_score: number;
|
|
180
|
+
}, {
|
|
181
|
+
enabled: boolean;
|
|
182
|
+
min_score: number;
|
|
183
|
+
}>>;
|
|
184
|
+
}, "strip", z.ZodTypeAny, {
|
|
185
|
+
provider: "github-pr" | "api" | "auto";
|
|
186
|
+
rules: Record<string, "pr" | "direct">;
|
|
187
|
+
auto_approve?: {
|
|
188
|
+
enabled: boolean;
|
|
189
|
+
min_score: number;
|
|
190
|
+
} | undefined;
|
|
191
|
+
}, {
|
|
192
|
+
provider: "github-pr" | "api" | "auto";
|
|
193
|
+
auto_approve?: {
|
|
194
|
+
enabled: boolean;
|
|
195
|
+
min_score: number;
|
|
196
|
+
} | undefined;
|
|
197
|
+
rules?: Record<string, "pr" | "direct"> | undefined;
|
|
198
|
+
}>>;
|
|
199
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
200
|
+
provider: z.ZodEnum<["github", "api-key", "custom"]>;
|
|
201
|
+
}, "strip", z.ZodTypeAny, {
|
|
202
|
+
provider: "github" | "api-key" | "custom";
|
|
203
|
+
}, {
|
|
204
|
+
provider: "github" | "api-key" | "custom";
|
|
205
|
+
}>>;
|
|
206
|
+
cache: z.ZodOptional<z.ZodObject<{
|
|
207
|
+
backend: z.ZodEnum<["sqlite", "d1", "memory"]>;
|
|
208
|
+
}, "strip", z.ZodTypeAny, {
|
|
209
|
+
backend: "sqlite" | "d1" | "memory";
|
|
210
|
+
}, {
|
|
211
|
+
backend: "sqlite" | "d1" | "memory";
|
|
212
|
+
}>>;
|
|
213
|
+
sync: z.ZodOptional<z.ZodObject<{
|
|
214
|
+
reconciliation_interval: z.ZodString;
|
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
|
216
|
+
reconciliation_interval: string;
|
|
217
|
+
}, {
|
|
218
|
+
reconciliation_interval: string;
|
|
219
|
+
}>>;
|
|
220
|
+
}, "strip", z.ZodTypeAny, {
|
|
221
|
+
repository: {
|
|
222
|
+
owner: string;
|
|
223
|
+
repo: string;
|
|
224
|
+
branch: string;
|
|
225
|
+
content_path?: string | undefined;
|
|
226
|
+
};
|
|
227
|
+
ai: {
|
|
228
|
+
provider: "anthropic" | "openai" | "local";
|
|
229
|
+
model: string;
|
|
230
|
+
daily_limit_usd?: number | undefined;
|
|
231
|
+
warn_at_usd?: number | undefined;
|
|
232
|
+
};
|
|
233
|
+
collections: Record<string, {
|
|
234
|
+
path: string;
|
|
235
|
+
name: string;
|
|
236
|
+
format: "mdx" | "md" | "yaml" | "json";
|
|
237
|
+
fields: Record<string, any>;
|
|
238
|
+
}>;
|
|
239
|
+
knowledge: {
|
|
240
|
+
path: string;
|
|
241
|
+
graph: {
|
|
242
|
+
backend: "local" | "vectorize" | "turso";
|
|
243
|
+
};
|
|
244
|
+
ingestion?: {
|
|
245
|
+
scraping?: {
|
|
246
|
+
respectRobotsTxt?: boolean | undefined;
|
|
247
|
+
rateLimitMs?: number | undefined;
|
|
248
|
+
} | undefined;
|
|
249
|
+
} | undefined;
|
|
250
|
+
};
|
|
251
|
+
intent: {
|
|
252
|
+
path: string;
|
|
253
|
+
};
|
|
254
|
+
media?: {
|
|
255
|
+
path: string;
|
|
256
|
+
storage: "git" | "r2" | "s3";
|
|
257
|
+
registry: string;
|
|
258
|
+
allowedTypes?: string[] | undefined;
|
|
259
|
+
maxSizeMb?: number | undefined;
|
|
260
|
+
transform?: {
|
|
261
|
+
formats?: string[] | undefined;
|
|
262
|
+
sizes?: number[] | undefined;
|
|
263
|
+
} | undefined;
|
|
264
|
+
} | undefined;
|
|
265
|
+
jobs?: {
|
|
266
|
+
backend: "in-process" | "queue" | "durable-objects";
|
|
267
|
+
} | undefined;
|
|
268
|
+
evals?: {
|
|
269
|
+
threshold: number;
|
|
270
|
+
auto_approve?: boolean | undefined;
|
|
271
|
+
} | undefined;
|
|
272
|
+
approval?: {
|
|
273
|
+
provider: "github-pr" | "api" | "auto";
|
|
274
|
+
rules: Record<string, "pr" | "direct">;
|
|
275
|
+
auto_approve?: {
|
|
276
|
+
enabled: boolean;
|
|
277
|
+
min_score: number;
|
|
278
|
+
} | undefined;
|
|
279
|
+
} | undefined;
|
|
280
|
+
auth?: {
|
|
281
|
+
provider: "github" | "api-key" | "custom";
|
|
282
|
+
} | undefined;
|
|
283
|
+
cache?: {
|
|
284
|
+
backend: "sqlite" | "d1" | "memory";
|
|
285
|
+
} | undefined;
|
|
286
|
+
sync?: {
|
|
287
|
+
reconciliation_interval: string;
|
|
288
|
+
} | undefined;
|
|
289
|
+
}, {
|
|
290
|
+
repository: {
|
|
291
|
+
owner: string;
|
|
292
|
+
repo: string;
|
|
293
|
+
branch: string;
|
|
294
|
+
content_path?: string | undefined;
|
|
295
|
+
};
|
|
296
|
+
ai: {
|
|
297
|
+
provider: "anthropic" | "openai" | "local";
|
|
298
|
+
model: string;
|
|
299
|
+
daily_limit_usd?: number | undefined;
|
|
300
|
+
warn_at_usd?: number | undefined;
|
|
301
|
+
};
|
|
302
|
+
collections: Record<string, {
|
|
303
|
+
path: string;
|
|
304
|
+
name: string;
|
|
305
|
+
format: "mdx" | "md" | "yaml" | "json";
|
|
306
|
+
fields: Record<string, any>;
|
|
307
|
+
}>;
|
|
308
|
+
knowledge: {
|
|
309
|
+
path: string;
|
|
310
|
+
graph: {
|
|
311
|
+
backend: "local" | "vectorize" | "turso";
|
|
312
|
+
};
|
|
313
|
+
ingestion?: {
|
|
314
|
+
scraping?: {
|
|
315
|
+
respectRobotsTxt?: boolean | undefined;
|
|
316
|
+
rateLimitMs?: number | undefined;
|
|
317
|
+
} | undefined;
|
|
318
|
+
} | undefined;
|
|
319
|
+
};
|
|
320
|
+
intent: {
|
|
321
|
+
path: string;
|
|
322
|
+
};
|
|
323
|
+
media?: {
|
|
324
|
+
path: string;
|
|
325
|
+
storage: "git" | "r2" | "s3";
|
|
326
|
+
registry: string;
|
|
327
|
+
allowedTypes?: string[] | undefined;
|
|
328
|
+
maxSizeMb?: number | undefined;
|
|
329
|
+
transform?: {
|
|
330
|
+
formats?: string[] | undefined;
|
|
331
|
+
sizes?: number[] | undefined;
|
|
332
|
+
} | undefined;
|
|
333
|
+
} | undefined;
|
|
334
|
+
jobs?: {
|
|
335
|
+
backend: "in-process" | "queue" | "durable-objects";
|
|
336
|
+
} | undefined;
|
|
337
|
+
evals?: {
|
|
338
|
+
threshold: number;
|
|
339
|
+
auto_approve?: boolean | undefined;
|
|
340
|
+
} | undefined;
|
|
341
|
+
approval?: {
|
|
342
|
+
provider: "github-pr" | "api" | "auto";
|
|
343
|
+
auto_approve?: {
|
|
344
|
+
enabled: boolean;
|
|
345
|
+
min_score: number;
|
|
346
|
+
} | undefined;
|
|
347
|
+
rules?: Record<string, "pr" | "direct"> | undefined;
|
|
348
|
+
} | undefined;
|
|
349
|
+
auth?: {
|
|
350
|
+
provider: "github" | "api-key" | "custom";
|
|
351
|
+
} | undefined;
|
|
352
|
+
cache?: {
|
|
353
|
+
backend: "sqlite" | "d1" | "memory";
|
|
354
|
+
} | undefined;
|
|
355
|
+
sync?: {
|
|
356
|
+
reconciliation_interval: string;
|
|
357
|
+
} | undefined;
|
|
358
|
+
}>;
|
|
359
|
+
export declare function validateConfig(raw: unknown): ValidationResult;
|
|
360
|
+
export { configSchema };
|
|
361
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AA2DD,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDhB,CAAC;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAS7D;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Build the full Zod schema for SourcePressConfig
|
|
3
|
+
const repositorySchema = z.object({
|
|
4
|
+
owner: z.string().min(1),
|
|
5
|
+
repo: z.string().min(1),
|
|
6
|
+
branch: z.string().min(1),
|
|
7
|
+
content_path: z.string().optional(),
|
|
8
|
+
});
|
|
9
|
+
const aiSchema = z.object({
|
|
10
|
+
provider: z.enum(["anthropic", "openai", "local"]),
|
|
11
|
+
model: z.string().min(1),
|
|
12
|
+
daily_limit_usd: z.number().optional(),
|
|
13
|
+
warn_at_usd: z.number().optional(),
|
|
14
|
+
});
|
|
15
|
+
const fieldSchema = z.lazy(() => z.union([
|
|
16
|
+
z.object({
|
|
17
|
+
type: z.literal("string"),
|
|
18
|
+
required: z.boolean().optional(),
|
|
19
|
+
default: z.string().optional(),
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
type: z.literal("boolean"),
|
|
23
|
+
required: z.boolean().optional(),
|
|
24
|
+
default: z.boolean().optional(),
|
|
25
|
+
}),
|
|
26
|
+
z.object({
|
|
27
|
+
type: z.literal("number"),
|
|
28
|
+
required: z.boolean().optional(),
|
|
29
|
+
default: z.number().optional(),
|
|
30
|
+
}),
|
|
31
|
+
z.object({
|
|
32
|
+
type: z.literal("image"),
|
|
33
|
+
required: z.boolean().optional(),
|
|
34
|
+
multiple: z.boolean().optional(),
|
|
35
|
+
}),
|
|
36
|
+
z.object({
|
|
37
|
+
type: z.literal("relation-one"),
|
|
38
|
+
collection: z.string(),
|
|
39
|
+
required: z.boolean().optional(),
|
|
40
|
+
}),
|
|
41
|
+
z.object({
|
|
42
|
+
type: z.literal("relation-many"),
|
|
43
|
+
collection: z.string(),
|
|
44
|
+
required: z.boolean().optional(),
|
|
45
|
+
}),
|
|
46
|
+
]));
|
|
47
|
+
const collectionSchema = z.object({
|
|
48
|
+
name: z.string().min(1),
|
|
49
|
+
path: z.string().min(1),
|
|
50
|
+
format: z.enum(["mdx", "md", "yaml", "json"]),
|
|
51
|
+
fields: z.record(fieldSchema),
|
|
52
|
+
});
|
|
53
|
+
const configSchema = z.object({
|
|
54
|
+
repository: repositorySchema,
|
|
55
|
+
ai: aiSchema,
|
|
56
|
+
collections: z.record(collectionSchema),
|
|
57
|
+
knowledge: z.object({
|
|
58
|
+
path: z.string().min(1),
|
|
59
|
+
graph: z.object({
|
|
60
|
+
backend: z.enum(["local", "vectorize", "turso"]),
|
|
61
|
+
}),
|
|
62
|
+
ingestion: z
|
|
63
|
+
.object({
|
|
64
|
+
scraping: z
|
|
65
|
+
.object({
|
|
66
|
+
respectRobotsTxt: z.boolean().optional(),
|
|
67
|
+
rateLimitMs: z.number().optional(),
|
|
68
|
+
})
|
|
69
|
+
.optional(),
|
|
70
|
+
})
|
|
71
|
+
.optional(),
|
|
72
|
+
}),
|
|
73
|
+
intent: z.object({ path: z.string().min(1) }),
|
|
74
|
+
media: z
|
|
75
|
+
.object({
|
|
76
|
+
storage: z.enum(["git", "r2", "s3"]),
|
|
77
|
+
path: z.string(),
|
|
78
|
+
registry: z.string(),
|
|
79
|
+
allowedTypes: z.array(z.string()).optional(),
|
|
80
|
+
maxSizeMb: z.number().optional(),
|
|
81
|
+
transform: z
|
|
82
|
+
.object({
|
|
83
|
+
formats: z.array(z.string()).optional(),
|
|
84
|
+
sizes: z.array(z.number()).optional(),
|
|
85
|
+
})
|
|
86
|
+
.optional(),
|
|
87
|
+
})
|
|
88
|
+
.optional(),
|
|
89
|
+
jobs: z.object({ backend: z.enum(["in-process", "queue", "durable-objects"]) }).optional(),
|
|
90
|
+
evals: z.object({ threshold: z.number(), auto_approve: z.boolean().optional() }).optional(),
|
|
91
|
+
approval: z
|
|
92
|
+
.object({
|
|
93
|
+
provider: z.enum(["github-pr", "api", "auto"]),
|
|
94
|
+
rules: z.record(z.enum(["pr", "direct"])).default({}),
|
|
95
|
+
auto_approve: z
|
|
96
|
+
.object({
|
|
97
|
+
enabled: z.boolean(),
|
|
98
|
+
min_score: z.number().min(0).max(100),
|
|
99
|
+
})
|
|
100
|
+
.optional(),
|
|
101
|
+
})
|
|
102
|
+
.optional(),
|
|
103
|
+
auth: z.object({ provider: z.enum(["github", "api-key", "custom"]) }).optional(),
|
|
104
|
+
cache: z.object({ backend: z.enum(["sqlite", "d1", "memory"]) }).optional(),
|
|
105
|
+
sync: z.object({ reconciliation_interval: z.string() }).optional(),
|
|
106
|
+
});
|
|
107
|
+
export function validateConfig(raw) {
|
|
108
|
+
const result = configSchema.safeParse(raw);
|
|
109
|
+
if (result.success) {
|
|
110
|
+
return { success: true, data: result.data, errors: [] };
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
errors: result.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export { configSchema };
|
|
118
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAA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EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,uBAAuB,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;CAClE,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,GAAY;IAC1C,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACzD,CAAC;IACD,OAAO;QACN,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;KACvF,CAAC;AACH,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sourcepress/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"zod": "^3.23.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0",
|
|
19
|
+
"vitest": "^3.0.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"clean": "rm -rf dist"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { collectionToZod } from "../schema.js";
|
|
3
|
+
import type { CollectionDefinition } from "../types.js";
|
|
4
|
+
|
|
5
|
+
describe("collectionToZod", () => {
|
|
6
|
+
it("creates a Zod schema from a collection definition", () => {
|
|
7
|
+
const collection: CollectionDefinition = {
|
|
8
|
+
name: "Posts",
|
|
9
|
+
path: "content/posts",
|
|
10
|
+
format: "mdx",
|
|
11
|
+
fields: {
|
|
12
|
+
title: { type: "string", required: true },
|
|
13
|
+
draft: { type: "boolean", default: true },
|
|
14
|
+
views: { type: "number" },
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const schema = collectionToZod(collection);
|
|
19
|
+
const valid = schema.safeParse({ title: "Hello", draft: false, views: 10 });
|
|
20
|
+
expect(valid.success).toBe(true);
|
|
21
|
+
|
|
22
|
+
const invalid = schema.safeParse({ draft: true });
|
|
23
|
+
expect(invalid.success).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("handles relation fields", () => {
|
|
27
|
+
const collection: CollectionDefinition = {
|
|
28
|
+
name: "Posts",
|
|
29
|
+
path: "content/posts",
|
|
30
|
+
format: "mdx",
|
|
31
|
+
fields: {
|
|
32
|
+
title: { type: "string", required: true },
|
|
33
|
+
author: { type: "relation-one", collection: "team" },
|
|
34
|
+
tags: { type: "relation-many", collection: "tags" },
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const schema = collectionToZod(collection);
|
|
39
|
+
const valid = schema.safeParse({ title: "Hello", author: "anna", tags: ["tech", "ai"] });
|
|
40
|
+
expect(valid.success).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("handles image fields", () => {
|
|
44
|
+
const collection: CollectionDefinition = {
|
|
45
|
+
name: "Posts",
|
|
46
|
+
path: "content/posts",
|
|
47
|
+
format: "mdx",
|
|
48
|
+
fields: {
|
|
49
|
+
hero: { type: "image", required: true },
|
|
50
|
+
gallery: { type: "image", multiple: true },
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const schema = collectionToZod(collection);
|
|
55
|
+
const valid = schema.safeParse({
|
|
56
|
+
hero: "/assets/hero.webp",
|
|
57
|
+
gallery: ["/assets/1.webp", "/assets/2.webp"],
|
|
58
|
+
});
|
|
59
|
+
expect(valid.success).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { validateConfig } from "../validate.js";
|
|
3
|
+
|
|
4
|
+
describe("validateConfig", () => {
|
|
5
|
+
it("accepts a valid minimal config", () => {
|
|
6
|
+
const config = {
|
|
7
|
+
repository: { owner: "acme", repo: "site", branch: "main" },
|
|
8
|
+
ai: { provider: "anthropic" as const, model: "claude-sonnet-4-5-20250514" },
|
|
9
|
+
collections: {},
|
|
10
|
+
knowledge: { path: "knowledge/", graph: { backend: "local" as const } },
|
|
11
|
+
intent: { path: "intent/" },
|
|
12
|
+
media: { storage: "git" as const, path: "assets/", registry: "media.json" },
|
|
13
|
+
jobs: { backend: "in-process" as const },
|
|
14
|
+
evals: { threshold: 70 },
|
|
15
|
+
approval: { provider: "github-pr" as const, rules: {} },
|
|
16
|
+
auth: { provider: "github" as const },
|
|
17
|
+
cache: { backend: "sqlite" as const },
|
|
18
|
+
sync: { reconciliation_interval: "1h" },
|
|
19
|
+
};
|
|
20
|
+
const result = validateConfig(config);
|
|
21
|
+
expect(result.success).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("rejects config missing repository", () => {
|
|
25
|
+
const result = validateConfig({} as unknown);
|
|
26
|
+
expect(result.success).toBe(false);
|
|
27
|
+
if (!result.success) {
|
|
28
|
+
expect(result.errors.length).toBeGreaterThan(0);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("rejects invalid ai provider", () => {
|
|
33
|
+
const config = {
|
|
34
|
+
repository: { owner: "acme", repo: "site", branch: "main" },
|
|
35
|
+
ai: { provider: "invalid-provider", model: "gpt-4" },
|
|
36
|
+
collections: {},
|
|
37
|
+
knowledge: { path: "knowledge/", graph: { backend: "local" } },
|
|
38
|
+
intent: { path: "intent/" },
|
|
39
|
+
};
|
|
40
|
+
const result = validateConfig(config as unknown);
|
|
41
|
+
expect(result.success).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
});
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BooleanField,
|
|
3
|
+
CollectionDefinition,
|
|
4
|
+
ImageField,
|
|
5
|
+
NumberField,
|
|
6
|
+
RelationManyField,
|
|
7
|
+
RelationOneField,
|
|
8
|
+
SourcePressConfig,
|
|
9
|
+
StringField,
|
|
10
|
+
} from "./types.js";
|
|
11
|
+
|
|
12
|
+
export function defineConfig(config: SourcePressConfig): SourcePressConfig {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function collection(def: CollectionDefinition): CollectionDefinition {
|
|
17
|
+
return def;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const field = {
|
|
21
|
+
string(opts: Omit<StringField, "type"> = {}): StringField {
|
|
22
|
+
return { type: "string", ...opts };
|
|
23
|
+
},
|
|
24
|
+
boolean(opts: Omit<BooleanField, "type"> = {}): BooleanField {
|
|
25
|
+
return { type: "boolean", ...opts };
|
|
26
|
+
},
|
|
27
|
+
number(opts: Omit<NumberField, "type"> = {}): NumberField {
|
|
28
|
+
return { type: "number", ...opts };
|
|
29
|
+
},
|
|
30
|
+
image(opts: Omit<ImageField, "type"> = {}): ImageField {
|
|
31
|
+
return { type: "image", ...opts };
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const relation = {
|
|
36
|
+
one(collectionName: string, opts: { required?: boolean } = {}): RelationOneField {
|
|
37
|
+
return { type: "relation-one", collection: collectionName, ...opts };
|
|
38
|
+
},
|
|
39
|
+
many(collectionName: string, opts: { required?: boolean } = {}): RelationManyField {
|
|
40
|
+
return { type: "relation-many", collection: collectionName, ...opts };
|
|
41
|
+
},
|
|
42
|
+
};
|