@beechcms/core 0.4.0-preview.10 → 0.4.0-preview.11
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/dist/content.repository.d.ts +95 -0
- package/dist/content.repository.d.ts.map +1 -0
- package/dist/content.repository.js +29 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +76 -12
- package/dist/idempotency.repository.d.ts +13 -0
- package/dist/idempotency.repository.d.ts.map +1 -0
- package/dist/idempotency.repository.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +8 -2
- package/package.json +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Seed, SelectOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base Repository Error
|
|
4
|
+
*/
|
|
5
|
+
export declare class RepositoryError extends Error {
|
|
6
|
+
cause?: unknown | undefined;
|
|
7
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Thrown when an entry is not found by ID or Slug
|
|
11
|
+
*/
|
|
12
|
+
export declare class EntryNotFoundError extends RepositoryError {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Thrown when a slug already exists for a content type
|
|
17
|
+
*/
|
|
18
|
+
export declare class SlugConflictError extends RepositoryError {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Interface defining the standard operations for content persistence.
|
|
23
|
+
* This is platform-agnostic and should be implemented for specific databases (e.g., D1).
|
|
24
|
+
*/
|
|
25
|
+
export interface ContentRepository {
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves a paginated and filtered list of entries.
|
|
28
|
+
*/
|
|
29
|
+
findMany(seed: Seed, options: SelectOptions): Promise<{
|
|
30
|
+
items: Record<string, any>[];
|
|
31
|
+
total: number;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Finds a single entry by its unique ID.
|
|
35
|
+
* Throws EntryNotFoundError if not found.
|
|
36
|
+
*/
|
|
37
|
+
findById(seed: Seed, id: string): Promise<Record<string, any>>;
|
|
38
|
+
/**
|
|
39
|
+
* Finds a single entry by its unique slug.
|
|
40
|
+
* Throws EntryNotFoundError if not found.
|
|
41
|
+
*/
|
|
42
|
+
findBySlug(seed: Seed, slug: string): Promise<Record<string, any>>;
|
|
43
|
+
/**
|
|
44
|
+
* Computes facets (status counts and distinct tags) for a content type.
|
|
45
|
+
*/
|
|
46
|
+
getFacets(seed: Seed): Promise<{
|
|
47
|
+
statuses: Record<string, number>;
|
|
48
|
+
tagsByColumn: Record<string, string[]>;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new content entry in the live table.
|
|
52
|
+
* Throws SlugConflictError if the slug is already taken.
|
|
53
|
+
*/
|
|
54
|
+
create(seed: Seed, id: string, slug: string, status: string, data: Record<string, any>): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Partially updates an existing entry in the live table.
|
|
57
|
+
* Throws EntryNotFoundError if the ID does not exist.
|
|
58
|
+
*/
|
|
59
|
+
update(seed: Seed, id: string, data: Record<string, any>, status?: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Deletes an entry from the live table.
|
|
62
|
+
* Returns the deleted row data (useful for media cleanup).
|
|
63
|
+
* Throws EntryNotFoundError if the ID does not exist.
|
|
64
|
+
*/
|
|
65
|
+
delete(seed: Seed, id: string): Promise<{
|
|
66
|
+
row: Record<string, any>;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Saves or updates a pending draft in the mirror table.
|
|
70
|
+
*/
|
|
71
|
+
saveDraft(seed: Seed, entryId: string, data: Record<string, any>): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves the pending draft for a given entry.
|
|
74
|
+
* Returns null if no draft exists.
|
|
75
|
+
*/
|
|
76
|
+
getDraft(seed: Seed, entryId: string): Promise<Record<string, any> | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Atomic promotion of a draft to the live table.
|
|
79
|
+
* Must use a transaction (db.batch) to update live and delete draft.
|
|
80
|
+
*/
|
|
81
|
+
publishDraft(seed: Seed, entryId: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Discards the pending draft.
|
|
84
|
+
*/
|
|
85
|
+
deleteDraft(seed: Seed, entryId: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Checks if a slug is already taken by another entry.
|
|
88
|
+
*/
|
|
89
|
+
existsSlug(seed: Seed, slug: string, excludeId?: string): Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* Checks if an entry has a pending draft.
|
|
92
|
+
*/
|
|
93
|
+
hasDraft(seed: Seed, entryId: string): Promise<boolean>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=content.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.repository.d.ts","sourceRoot":"","sources":["../src/content.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACJ,KAAK,CAAC,EAAE,OAAO;gBAAvC,OAAO,EAAE,MAAM,EAAS,KAAK,CAAC,EAAE,OAAO,YAAA;CAIpD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE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SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhF;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IAE1E;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE1E;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACxD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Repository Error
|
|
3
|
+
*/
|
|
4
|
+
export class RepositoryError extends Error {
|
|
5
|
+
cause;
|
|
6
|
+
constructor(message, cause) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.cause = cause;
|
|
9
|
+
this.name = 'RepositoryError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown when an entry is not found by ID or Slug
|
|
14
|
+
*/
|
|
15
|
+
export class EntryNotFoundError extends RepositoryError {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'EntryNotFoundError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Thrown when a slug already exists for a content type
|
|
23
|
+
*/
|
|
24
|
+
export class SlugConflictError extends RepositoryError {
|
|
25
|
+
constructor(message) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'SlugConflictError';
|
|
28
|
+
}
|
|
29
|
+
}
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,IAAI,EACJ,MAAM,EAKN,aAAa,EACb,kBAAkB,EACnB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,IAAI,EACJ,MAAM,EAKN,aAAa,EACb,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAgFnB;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAsBtD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAuB5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAkBpD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAc1D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAgCxD;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,aAAkB,GAAG,kBAAkB,CAqE5F;AA+GD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,OAAO,CAAA;CACd;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,EAAE,CAc7D;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAmCrF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CA6BzE"}
|
package/dist/engine.js
CHANGED
|
@@ -6,6 +6,7 @@ const BRANCH_TYPE_SQL = {
|
|
|
6
6
|
json: { sqlType: 'TEXT' }, // JSON serializzato
|
|
7
7
|
richtext: { sqlType: 'TEXT' },
|
|
8
8
|
file: { sqlType: 'TEXT' }, // URL singolo o JSON array di URL
|
|
9
|
+
tags: { sqlType: 'TEXT' }, // JSON array di stringhe
|
|
9
10
|
};
|
|
10
11
|
const SYSTEM_COLUMNS = new Set(['id', 'slug', 'status', 'created_at', 'updated_at']);
|
|
11
12
|
// ---- Private helpers ----
|
|
@@ -277,6 +278,32 @@ export function buildSelectQuery(seed, options = {}) {
|
|
|
277
278
|
}
|
|
278
279
|
return { sql, bindings };
|
|
279
280
|
}
|
|
281
|
+
function normalizeFilterValue(type, value) {
|
|
282
|
+
if (value === null || value === undefined)
|
|
283
|
+
return null;
|
|
284
|
+
if (type === 'date') {
|
|
285
|
+
if (typeof value === 'number')
|
|
286
|
+
return value;
|
|
287
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
288
|
+
const d = new Date(value);
|
|
289
|
+
return isNaN(d.getTime()) ? null : Math.floor(d.getTime() / 1000);
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
if (type === 'boolean') {
|
|
294
|
+
return value ? 1 : 0;
|
|
295
|
+
}
|
|
296
|
+
if (type === 'number') {
|
|
297
|
+
if (typeof value === 'number')
|
|
298
|
+
return value;
|
|
299
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
300
|
+
const n = Number(value);
|
|
301
|
+
return isNaN(n) ? null : n;
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
return value;
|
|
306
|
+
}
|
|
280
307
|
function buildFilterCondition(col, type, cond, bindings) {
|
|
281
308
|
const { op, value } = cond;
|
|
282
309
|
if (op === 'is_empty') {
|
|
@@ -285,23 +312,58 @@ function buildFilterCondition(col, type, cond, bindings) {
|
|
|
285
312
|
if (op === 'is_not_empty') {
|
|
286
313
|
return type === 'text' ? `(${col} IS NOT NULL AND ${col} != '')` : `${col} IS NOT NULL`;
|
|
287
314
|
}
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
315
|
+
if (op === 'in' || op === 'not_in') {
|
|
316
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
317
|
+
return null;
|
|
318
|
+
const normalizedValues = value
|
|
319
|
+
.map((v) => normalizeFilterValue(type, v))
|
|
320
|
+
.filter((v) => v !== null);
|
|
321
|
+
if (normalizedValues.length === 0)
|
|
322
|
+
return null;
|
|
323
|
+
const placeholders = normalizedValues.map(() => '?').join(', ');
|
|
324
|
+
bindings.push(...normalizedValues);
|
|
325
|
+
return `${col} ${op === 'in' ? 'IN' : 'NOT IN'} (${placeholders})`;
|
|
293
326
|
}
|
|
294
|
-
if (op === '
|
|
295
|
-
if (type
|
|
296
|
-
|
|
297
|
-
|
|
327
|
+
if (op === 'has_tag' || op === 'has_any_tag' || op === 'has_all_tags') {
|
|
328
|
+
if (type !== 'tags' && type !== 'json')
|
|
329
|
+
return null;
|
|
330
|
+
const tags = (op === 'has_tag' ? [value] : Array.isArray(value) ? value : [value])
|
|
331
|
+
.map(t => String(t));
|
|
332
|
+
if (tags.length === 0)
|
|
333
|
+
return null;
|
|
334
|
+
if (op === 'has_tag' || op === 'has_any_tag') {
|
|
335
|
+
const placeholders = tags.map(() => '?').join(', ');
|
|
336
|
+
bindings.push(...tags);
|
|
337
|
+
return `EXISTS (SELECT 1 FROM json_each(${col}) WHERE value IN (${placeholders}))`;
|
|
298
338
|
}
|
|
299
|
-
|
|
300
|
-
|
|
339
|
+
// has_all_tags: each tag must exist
|
|
340
|
+
const clauses = tags.map(() => `EXISTS (SELECT 1 FROM json_each(${col}) WHERE value = ?)`);
|
|
341
|
+
bindings.push(...tags);
|
|
342
|
+
return `(${clauses.join(' AND ')})`;
|
|
343
|
+
}
|
|
344
|
+
const normalized = normalizeFilterValue(type, value);
|
|
345
|
+
if (normalized === null)
|
|
346
|
+
return null;
|
|
347
|
+
if (op === 'eq' || op === 'neq') {
|
|
348
|
+
const sqlOp = op === 'eq' ? '=' : '!=';
|
|
349
|
+
bindings.push(normalized);
|
|
350
|
+
return `${col} ${sqlOp} ?`;
|
|
351
|
+
}
|
|
352
|
+
if (op === 'contains' || op === 'not_contains' || op === 'starts_with' || op === 'ends_with') {
|
|
353
|
+
const sqlOp = op === 'not_contains' ? 'NOT LIKE' : 'LIKE';
|
|
354
|
+
let pattern = String(value);
|
|
355
|
+
if (op === 'contains' || op === 'not_contains')
|
|
356
|
+
pattern = `%${pattern}%`;
|
|
357
|
+
else if (op === 'starts_with')
|
|
358
|
+
pattern = `${pattern}%`;
|
|
359
|
+
else if (op === 'ends_with')
|
|
360
|
+
pattern = `%${pattern}`;
|
|
361
|
+
bindings.push(pattern);
|
|
362
|
+
return `${col} ${sqlOp} ?`;
|
|
301
363
|
}
|
|
302
364
|
const mathOps = { gt: '>', gte: '>=', lt: '<', lte: '<=' };
|
|
303
365
|
if (mathOps[op]) {
|
|
304
|
-
bindings.push(
|
|
366
|
+
bindings.push(normalized);
|
|
305
367
|
return `${col} ${mathOps[op]} ?`;
|
|
306
368
|
}
|
|
307
369
|
return null;
|
|
@@ -337,6 +399,7 @@ export function serializeForDb(branch, value) {
|
|
|
337
399
|
case 'boolean':
|
|
338
400
|
return value ? 1 : 0;
|
|
339
401
|
case 'json':
|
|
402
|
+
case 'tags':
|
|
340
403
|
case 'richtext':
|
|
341
404
|
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
342
405
|
case 'date': {
|
|
@@ -374,6 +437,7 @@ export function deserializeFromDb(branch, value) {
|
|
|
374
437
|
case 'boolean':
|
|
375
438
|
return value === 1 || value === true;
|
|
376
439
|
case 'json':
|
|
440
|
+
case 'tags':
|
|
377
441
|
case 'richtext': {
|
|
378
442
|
if (typeof value === 'string') {
|
|
379
443
|
try {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IdempotencyRecord {
|
|
2
|
+
key: string;
|
|
3
|
+
fingerprint: string;
|
|
4
|
+
responseStatus: number;
|
|
5
|
+
responseBody: string;
|
|
6
|
+
expiresAt: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IdempotencyRepository {
|
|
9
|
+
lookup(key: string): Promise<IdempotencyRecord | null>;
|
|
10
|
+
store(record: IdempotencyRecord): Promise<void>;
|
|
11
|
+
cleanup(now: number): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=idempotency.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idempotency.repository.d.ts","sourceRoot":"","sources":["../src/idempotency.repository.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IACtD,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -15,5 +15,7 @@ export * from './validation.js';
|
|
|
15
15
|
export * from './richtext.js';
|
|
16
16
|
export * from './richtext-render.js';
|
|
17
17
|
export * from './slug-utils.js';
|
|
18
|
+
export * from './content.repository.js';
|
|
19
|
+
export * from './idempotency.repository.js';
|
|
18
20
|
export * from './policies.js';
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,4 +15,6 @@ export * from './validation.js';
|
|
|
15
15
|
export * from './richtext.js';
|
|
16
16
|
export * from './richtext-render.js';
|
|
17
17
|
export * from './slug-utils.js';
|
|
18
|
+
export * from './content.repository.js';
|
|
19
|
+
export * from './idempotency.repository.js';
|
|
18
20
|
export * from './policies.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type BranchType = 'text' | 'number' | 'boolean' | 'json' | 'date' | 'richtext' | 'file';
|
|
1
|
+
export type BranchType = 'text' | 'number' | 'boolean' | 'json' | 'date' | 'richtext' | 'file' | 'tags';
|
|
2
2
|
/** Branch: definizione di una proprietà. alias = nome colonna SQL. */
|
|
3
3
|
export interface Branch {
|
|
4
4
|
/** Alias human-readable, usato nel payload API e come nome colonna SQL nella tabella dedicata */
|
|
@@ -96,8 +96,8 @@ export interface Seed {
|
|
|
96
96
|
/** Optional dashboard-specific UI config. Ignored by the Botanical Engine. */
|
|
97
97
|
dashboard?: DashboardSeedConfig;
|
|
98
98
|
}
|
|
99
|
-
export type FilterOperator = 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'is_empty' | 'is_not_empty';
|
|
100
|
-
export type FilterType = 'text' | 'number' | 'date' | 'boolean' | 'tags' | 'select' | 'system';
|
|
99
|
+
export type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | 'is_empty' | 'is_not_empty' | 'in' | 'not_in' | 'has_tag' | 'has_any_tag' | 'has_all_tags';
|
|
100
|
+
export type FilterType = 'text' | 'number' | 'date' | 'boolean' | 'tags' | 'select' | 'system' | 'json';
|
|
101
101
|
export interface FilterCondition {
|
|
102
102
|
op: FilterOperator;
|
|
103
103
|
value: string | number | boolean | null;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;AAEvG,sEAAsE;AACtE,MAAM,WAAW,MAAM;IACrB,iGAAiG;IACjG,KAAK,EAAE,MAAM,CAAA;IACb,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,sBAAsB;IACtB,IAAI,EAAE,UAAU,CAAA;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,CAAA;IAC3E;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,mCAAmC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE;QACT,yDAAyD;QACzD,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;QACtC,0EAA0E;QAC1E,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;QACzC,yEAAyE;QACzE,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,mFAAmF;QACnF,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,wFAAwF;QACxF,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,wEAAwE;QACxE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,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AA6fD;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,GAAE,0BAA+B,GACvC,yBAAyB,CA6G3B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,GAAG,QAAQ,GAAG,WAAW,CAE9F;AAED;;;;;GAKG"}
|
package/dist/validation.js
CHANGED
|
@@ -278,7 +278,8 @@ function buildBranchSchema(branch, options) {
|
|
|
278
278
|
.refine((value) => isIsoDateString(value), { message: 'Expected date(ISO)' });
|
|
279
279
|
return nullable ? z.union([schema, nullable]) : schema;
|
|
280
280
|
}
|
|
281
|
-
case 'json':
|
|
281
|
+
case 'json':
|
|
282
|
+
case 'tags': {
|
|
282
283
|
const schema = jsonObjectOrArraySchema;
|
|
283
284
|
return nullable ? z.union([schema, nullable]) : schema;
|
|
284
285
|
}
|
|
@@ -316,6 +317,8 @@ function buildBranchSchema(branch, options) {
|
|
|
316
317
|
.pipe(z.url());
|
|
317
318
|
return nullable ? z.union([schema, nullable]) : schema;
|
|
318
319
|
}
|
|
320
|
+
default:
|
|
321
|
+
throw new Error(`Unhandled branch type: ${branch.type}`);
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
324
|
const compiledSchemaCache = new Map();
|
|
@@ -422,7 +425,8 @@ function validateBranchValue(branch, alias, rawValue, options) {
|
|
|
422
425
|
}
|
|
423
426
|
return { ok: true, value };
|
|
424
427
|
}
|
|
425
|
-
case 'json':
|
|
428
|
+
case 'json':
|
|
429
|
+
case 'tags': {
|
|
426
430
|
const isValidJsonLike = (typeof rawValue === 'object' && rawValue !== null) || Array.isArray(rawValue);
|
|
427
431
|
if (!isValidJsonLike || typeof rawValue === 'string') {
|
|
428
432
|
return { ok: false, detail: makeDetail(alias, 'object|array', rawValue) };
|
|
@@ -443,6 +447,8 @@ function validateBranchValue(branch, alias, rawValue, options) {
|
|
|
443
447
|
}
|
|
444
448
|
return { ok: true, value: singleUrl };
|
|
445
449
|
}
|
|
450
|
+
default:
|
|
451
|
+
throw new Error(`Unhandled branch type: ${branch.type}`);
|
|
446
452
|
}
|
|
447
453
|
}
|
|
448
454
|
/**
|