bloko 0.0.14 → 0.0.15
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/api/collections.d.ts +39 -0
- package/dist/api/collections.d.ts.map +1 -0
- package/dist/api/collections.js +56 -0
- package/dist/api/collections.js.map +1 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +9 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/nodes.d.ts +61 -0
- package/dist/api/nodes.d.ts.map +1 -0
- package/dist/api/nodes.js +115 -0
- package/dist/api/nodes.js.map +1 -0
- package/dist/cli/commands/reinit.d.ts.map +1 -1
- package/dist/cli/commands/reinit.js +44 -1
- package/dist/cli/commands/reinit.js.map +1 -1
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +13 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Crud } from '../crud/index.js';
|
|
2
|
+
export interface NavNode {
|
|
3
|
+
id: string;
|
|
4
|
+
code: string;
|
|
5
|
+
title: string;
|
|
6
|
+
slug: string;
|
|
7
|
+
children: NavNode[];
|
|
8
|
+
}
|
|
9
|
+
export interface CollectionWithNavigation {
|
|
10
|
+
id: string;
|
|
11
|
+
code: string;
|
|
12
|
+
notes: string | null;
|
|
13
|
+
nodes: NavNode[];
|
|
14
|
+
}
|
|
15
|
+
export declare function createCollectionsApi(crud: Crud): {
|
|
16
|
+
/**
|
|
17
|
+
* Find a collection by code
|
|
18
|
+
*/
|
|
19
|
+
findByCode(code: string): Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
code: string;
|
|
22
|
+
notes: string | null;
|
|
23
|
+
} | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Get all collections with basic info
|
|
26
|
+
*/
|
|
27
|
+
findAll(): Promise<Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
code: string;
|
|
30
|
+
notes: string | null;
|
|
31
|
+
}>>;
|
|
32
|
+
/**
|
|
33
|
+
* Get a collection with navigation tree for a specific language
|
|
34
|
+
* Useful for building sidebar navigation
|
|
35
|
+
*/
|
|
36
|
+
getWithNavigation(code: string, lang: string): Promise<CollectionWithNavigation | null>;
|
|
37
|
+
};
|
|
38
|
+
export type CollectionsApi = ReturnType<typeof createCollectionsApi>;
|
|
39
|
+
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/api/collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI;IAE3C;;OAEG;qBACoB,MAAM;;;;;IAU7B;;OAEG;eACc,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IASnF;;;OAGG;4BAC2B,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;EA4BhG;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export function createCollectionsApi(crud) {
|
|
2
|
+
return {
|
|
3
|
+
/**
|
|
4
|
+
* Find a collection by code
|
|
5
|
+
*/
|
|
6
|
+
async findByCode(code) {
|
|
7
|
+
const collection = await crud.collections.findByCode(code);
|
|
8
|
+
if (!collection)
|
|
9
|
+
return null;
|
|
10
|
+
return {
|
|
11
|
+
id: collection.id,
|
|
12
|
+
code: collection.code,
|
|
13
|
+
notes: collection.notes,
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Get all collections with basic info
|
|
18
|
+
*/
|
|
19
|
+
async findAll() {
|
|
20
|
+
const collections = await crud.collections.findAll();
|
|
21
|
+
return collections.map(c => ({
|
|
22
|
+
id: c.id,
|
|
23
|
+
code: c.code,
|
|
24
|
+
notes: c.notes,
|
|
25
|
+
}));
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Get a collection with navigation tree for a specific language
|
|
29
|
+
* Useful for building sidebar navigation
|
|
30
|
+
*/
|
|
31
|
+
async getWithNavigation(code, lang) {
|
|
32
|
+
const collection = await crud.collections.findByCode(code);
|
|
33
|
+
if (!collection)
|
|
34
|
+
return null;
|
|
35
|
+
async function buildNavTree(parentId) {
|
|
36
|
+
const nodes = parentId
|
|
37
|
+
? await crud.nodes.findChildren(parentId)
|
|
38
|
+
: await crud.nodes.findRoots(collection.id);
|
|
39
|
+
return Promise.all(nodes.map(async (node) => ({
|
|
40
|
+
id: node.id,
|
|
41
|
+
code: node.code,
|
|
42
|
+
title: node.title?.[lang] || node.code,
|
|
43
|
+
slug: node.slug?.[lang] || node.code,
|
|
44
|
+
children: await buildNavTree(node.id),
|
|
45
|
+
})));
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
id: collection.id,
|
|
49
|
+
code: collection.code,
|
|
50
|
+
notes: collection.notes,
|
|
51
|
+
nodes: await buildNavTree(null),
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/api/collections.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,oBAAoB,CAAC,IAAU;IAC7C,OAAO;QACL;;WAEG;QACH,KAAK,CAAC,UAAU,CAAC,IAAY;YAC3B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC3D,IAAI,CAAC,UAAU;gBAAE,OAAO,IAAI,CAAC;YAC7B,OAAO;gBACL,EAAE,EAAE,UAAU,CAAC,EAAE;gBACjB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,KAAK,EAAE,UAAU,CAAC,KAAK;aACxB,CAAC;QACJ,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,OAAO;YACX,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACrD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC3B,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,KAAK,EAAE,CAAC,CAAC,KAAK;aACf,CAAC,CAAC,CAAC;QACN,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,iBAAiB,CAAC,IAAY,EAAE,IAAY;YAChD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC3D,IAAI,CAAC,UAAU;gBAAE,OAAO,IAAI,CAAC;YAE7B,KAAK,UAAU,YAAY,CAAC,QAAuB;gBACjD,MAAM,KAAK,GAAG,QAAQ;oBACpB,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC;oBACzC,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,UAAW,CAAC,EAAE,CAAC,CAAC;gBAE/C,OAAO,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;oBACzB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAG,IAAI,CAAC,KAAgC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;oBAClE,IAAI,EAAG,IAAI,CAAC,IAA+B,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;oBAChE,QAAQ,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;iBACtC,CAAC,CAAC,CACJ,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,EAAE,EAAE,UAAU,CAAC,EAAE;gBACjB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,KAAK,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC;aAChC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Crud } from '../crud/index.js';
|
|
2
|
+
import { type NodesApi } from './nodes.js';
|
|
3
|
+
import { type CollectionsApi } from './collections.js';
|
|
4
|
+
export interface Api {
|
|
5
|
+
nodes: NodesApi;
|
|
6
|
+
collections: CollectionsApi;
|
|
7
|
+
}
|
|
8
|
+
export declare function createApi(crud: Crud): Api;
|
|
9
|
+
export type { NodesApi, NodeWithContents, ContentItem, TreeNode, FindByPathResult } from './nodes.js';
|
|
10
|
+
export type { CollectionsApi, CollectionWithNavigation, NavNode } from './collections.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7E,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,WAAW,EAAE,cAAc,CAAC;CAC7B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAKzC;AAGD,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtG,YAAY,EAAE,cAAc,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createNodesApi } from './nodes.js';
|
|
2
|
+
import { createCollectionsApi } from './collections.js';
|
|
3
|
+
export function createApi(crud) {
|
|
4
|
+
return {
|
|
5
|
+
nodes: createNodesApi(crud),
|
|
6
|
+
collections: createCollectionsApi(crud),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAuB,MAAM,kBAAkB,CAAC;AAO7E,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,OAAO;QACL,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC;QAC3B,WAAW,EAAE,oBAAoB,CAAC,IAAI,CAAC;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Crud } from '../crud/index.js';
|
|
2
|
+
export interface NodeWithContents {
|
|
3
|
+
id: string;
|
|
4
|
+
code: string;
|
|
5
|
+
title: Record<string, string>;
|
|
6
|
+
subtitle: Record<string, string>;
|
|
7
|
+
slug: Record<string, string>;
|
|
8
|
+
contents: ContentItem[];
|
|
9
|
+
}
|
|
10
|
+
export interface ContentItem {
|
|
11
|
+
id: string;
|
|
12
|
+
blockCode: string;
|
|
13
|
+
blockTitle: Record<string, string>;
|
|
14
|
+
contentType: string;
|
|
15
|
+
sort: number;
|
|
16
|
+
value: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface TreeNode {
|
|
19
|
+
id: string;
|
|
20
|
+
code: string;
|
|
21
|
+
title: Record<string, string>;
|
|
22
|
+
slug: Record<string, string>;
|
|
23
|
+
children: TreeNode[];
|
|
24
|
+
}
|
|
25
|
+
export interface FindByPathResult {
|
|
26
|
+
node: NodeWithContents;
|
|
27
|
+
breadcrumb: Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
code: string;
|
|
30
|
+
title: Record<string, string>;
|
|
31
|
+
slug: Record<string, string>;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export declare function createNodesApi(crud: Crud): {
|
|
35
|
+
/**
|
|
36
|
+
* Find a node by walking a slug path
|
|
37
|
+
* Returns the node with contents and breadcrumb trail
|
|
38
|
+
*/
|
|
39
|
+
findByPath(lang: string, slugPath: string[], _collectionId?: string): Promise<FindByPathResult | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Get a node by ID with its contents
|
|
42
|
+
*/
|
|
43
|
+
findById(id: string): Promise<NodeWithContents | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a node tree for a collection
|
|
46
|
+
*/
|
|
47
|
+
getTree(collectionId: string, options?: {
|
|
48
|
+
depth?: number;
|
|
49
|
+
lang?: string;
|
|
50
|
+
}): Promise<TreeNode[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Get children of a node with their contents
|
|
53
|
+
*/
|
|
54
|
+
findChildren(parentId: string): Promise<NodeWithContents[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Get root nodes of a collection with their contents
|
|
57
|
+
*/
|
|
58
|
+
findRoots(collectionId: string): Promise<NodeWithContents[]>;
|
|
59
|
+
};
|
|
60
|
+
export type NodesApi = ReturnType<typeof createNodesApi>;
|
|
61
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/api/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;CAC9G;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI;IAiDrC;;;OAGG;qBAEK,MAAM,YACF,MAAM,EAAE,kBACF,MAAM,GACrB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA0BnC;;OAEG;iBACgB,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAM5D;;OAEG;0BAEa,MAAM,YACV;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC1C,OAAO,CAAC,QAAQ,EAAE,CAAC;IAwBtB;;OAEG;2BAC0B,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAKjE;;OAEG;4BAC2B,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;EAKrE;AAED,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export function createNodesApi(crud) {
|
|
2
|
+
/**
|
|
3
|
+
* Build content items with block info for a node
|
|
4
|
+
*/
|
|
5
|
+
async function buildContents(nodeId) {
|
|
6
|
+
const contents = await crud.contents.findByNode(nodeId);
|
|
7
|
+
if (contents.length === 0)
|
|
8
|
+
return [];
|
|
9
|
+
// Get unique block IDs and fetch blocks
|
|
10
|
+
const blockIds = [...new Set(contents.map(c => c._block))];
|
|
11
|
+
const blocks = await Promise.all(blockIds.map(id => crud.blocks.findById(id)));
|
|
12
|
+
const blocksMap = new Map(blocks.filter((b) => b !== null).map(b => [b.id, b]));
|
|
13
|
+
// Build content items
|
|
14
|
+
const items = contents.map(c => {
|
|
15
|
+
const block = blocksMap.get(c._block);
|
|
16
|
+
return {
|
|
17
|
+
id: c.id,
|
|
18
|
+
blockCode: block?.code || 'unknown',
|
|
19
|
+
blockTitle: block?.title || {},
|
|
20
|
+
contentType: block?.content_type || 'text',
|
|
21
|
+
sort: block?.sort || 0,
|
|
22
|
+
value: c.value,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
// Sort by block sort order
|
|
26
|
+
return items.sort((a, b) => a.sort - b.sort);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Convert a node to NodeWithContents format
|
|
30
|
+
*/
|
|
31
|
+
async function toNodeWithContents(node) {
|
|
32
|
+
return {
|
|
33
|
+
id: node.id,
|
|
34
|
+
code: node.code,
|
|
35
|
+
title: node.title || {},
|
|
36
|
+
subtitle: node.subtitle || {},
|
|
37
|
+
slug: node.slug || {},
|
|
38
|
+
contents: await buildContents(node.id),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
/**
|
|
43
|
+
* Find a node by walking a slug path
|
|
44
|
+
* Returns the node with contents and breadcrumb trail
|
|
45
|
+
*/
|
|
46
|
+
async findByPath(lang, slugPath, _collectionId) {
|
|
47
|
+
const breadcrumb = [];
|
|
48
|
+
let parentId = null;
|
|
49
|
+
let node = null;
|
|
50
|
+
for (const slug of slugPath) {
|
|
51
|
+
node = await crud.nodes.findBySlug(lang, slug, parentId);
|
|
52
|
+
if (!node)
|
|
53
|
+
return null;
|
|
54
|
+
breadcrumb.push({
|
|
55
|
+
id: node.id,
|
|
56
|
+
code: node.code,
|
|
57
|
+
title: node.title || {},
|
|
58
|
+
slug: node.slug || {},
|
|
59
|
+
});
|
|
60
|
+
parentId = node.id;
|
|
61
|
+
}
|
|
62
|
+
if (!node)
|
|
63
|
+
return null;
|
|
64
|
+
return {
|
|
65
|
+
node: await toNodeWithContents(node),
|
|
66
|
+
breadcrumb,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Get a node by ID with its contents
|
|
71
|
+
*/
|
|
72
|
+
async findById(id) {
|
|
73
|
+
const node = await crud.nodes.findById(id);
|
|
74
|
+
if (!node)
|
|
75
|
+
return null;
|
|
76
|
+
return toNodeWithContents(node);
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* Get a node tree for a collection
|
|
80
|
+
*/
|
|
81
|
+
async getTree(collectionId, options) {
|
|
82
|
+
const maxDepth = options?.depth ?? 10;
|
|
83
|
+
async function buildTree(parentId, currentDepth) {
|
|
84
|
+
if (currentDepth >= maxDepth)
|
|
85
|
+
return [];
|
|
86
|
+
const nodes = parentId
|
|
87
|
+
? await crud.nodes.findChildren(parentId)
|
|
88
|
+
: await crud.nodes.findRoots(collectionId);
|
|
89
|
+
return Promise.all(nodes.map(async (node) => ({
|
|
90
|
+
id: node.id,
|
|
91
|
+
code: node.code,
|
|
92
|
+
title: node.title || {},
|
|
93
|
+
slug: node.slug || {},
|
|
94
|
+
children: await buildTree(node.id, currentDepth + 1),
|
|
95
|
+
})));
|
|
96
|
+
}
|
|
97
|
+
return buildTree(null, 0);
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Get children of a node with their contents
|
|
101
|
+
*/
|
|
102
|
+
async findChildren(parentId) {
|
|
103
|
+
const children = await crud.nodes.findChildren(parentId);
|
|
104
|
+
return Promise.all(children.map(toNodeWithContents));
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* Get root nodes of a collection with their contents
|
|
108
|
+
*/
|
|
109
|
+
async findRoots(collectionId) {
|
|
110
|
+
const roots = await crud.nodes.findRoots(collectionId);
|
|
111
|
+
return Promise.all(roots.map(toNodeWithContents));
|
|
112
|
+
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IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;oBACrB,QAAQ,EAAE,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,GAAG,CAAC,CAAC;iBACrD,CAAC,CAAC,CACJ,CAAC;YACJ,CAAC;YAED,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5B,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,YAAY,CAAC,QAAgB;YACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACzD,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACvD,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,SAAS,CAAC,YAAoB;YAClC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YACvD,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reinit.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/reinit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reinit.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/reinit.ts"],"names":[],"mappings":"AA0DA,wBAAsB,MAAM,kBA4D3B"}
|
|
@@ -2,11 +2,54 @@ import { readFileSync } from 'fs';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
4
|
import pg from 'pg';
|
|
5
|
-
import {
|
|
5
|
+
import { ListObjectsV2Command, DeleteObjectsCommand } from '@aws-sdk/client-s3';
|
|
6
|
+
import { getConfig, getS3Config } from '../config.js';
|
|
7
|
+
import { createS3Client } from '../../s3/client.js';
|
|
6
8
|
const { Pool } = pg;
|
|
9
|
+
async function clearS3Bucket() {
|
|
10
|
+
const s3Config = getS3Config();
|
|
11
|
+
if (!s3Config) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
console.log(`Clearing S3 bucket "${s3Config.bucket}"...`);
|
|
15
|
+
const s3Client = createS3Client(s3Config);
|
|
16
|
+
try {
|
|
17
|
+
// List and delete all objects in batches
|
|
18
|
+
let continuationToken;
|
|
19
|
+
let totalDeleted = 0;
|
|
20
|
+
do {
|
|
21
|
+
const listResponse = await s3Client.send(new ListObjectsV2Command({
|
|
22
|
+
Bucket: s3Config.bucket,
|
|
23
|
+
ContinuationToken: continuationToken,
|
|
24
|
+
}));
|
|
25
|
+
const objects = listResponse.Contents;
|
|
26
|
+
if (objects && objects.length > 0) {
|
|
27
|
+
await s3Client.send(new DeleteObjectsCommand({
|
|
28
|
+
Bucket: s3Config.bucket,
|
|
29
|
+
Delete: {
|
|
30
|
+
Objects: objects.map((obj) => ({ Key: obj.Key })),
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
totalDeleted += objects.length;
|
|
34
|
+
}
|
|
35
|
+
continuationToken = listResponse.NextContinuationToken;
|
|
36
|
+
} while (continuationToken);
|
|
37
|
+
if (totalDeleted > 0) {
|
|
38
|
+
console.log(`Deleted ${totalDeleted} objects from S3.`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log('S3 bucket was already empty.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.warn('Warning: Could not clear S3 bucket:', error.message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
7
48
|
export async function reinit() {
|
|
8
49
|
const config = getConfig();
|
|
9
50
|
const targetDb = config.database;
|
|
51
|
+
// Clear S3 bucket first
|
|
52
|
+
await clearS3Bucket();
|
|
10
53
|
// Connect to default 'postgres' database to drop/create the target database
|
|
11
54
|
const adminPool = new Pool({
|
|
12
55
|
...config,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reinit.js","sourceRoot":"","sources":["../../../src/cli/commands/reinit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"reinit.js","sourceRoot":"","sources":["../../../src/cli/commands/reinit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAEpB,KAAK,UAAU,aAAa;IAC1B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,MAAM,MAAM,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE1C,IAAI,CAAC;QACH,yCAAyC;QACzC,IAAI,iBAAqC,CAAC;QAC1C,IAAI,YAAY,GAAG,CAAC,CAAC;QAErB,GAAG,CAAC;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,KAAK,EAAE,YAAY,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAEpD,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE5B,OAAO,CAAC,GAAG,CAAC,aAAa,QAAQ,+BAA+B,CAAC,CAAC;IACpE,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/cli/config.d.ts
CHANGED
package/dist/cli/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wBAAgB,SAAS,IAAI,QAAQ,CAapC;AAED,wBAAgB,WAAW,IAAI,QAAQ,GAAG,IAAI,CAa7C"}
|
package/dist/cli/config.js
CHANGED
|
@@ -11,4 +11,17 @@ export function getConfig() {
|
|
|
11
11
|
password,
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
export function getS3Config() {
|
|
15
|
+
const bucket = process.env['BLOKO_S3_BUCKET'];
|
|
16
|
+
if (!bucket) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
endpoint: process.env['BLOKO_S3_ENDPOINT'] ?? '',
|
|
21
|
+
region: process.env['BLOKO_S3_REGION'] ?? 'us-east-1',
|
|
22
|
+
bucket,
|
|
23
|
+
accessKeyId: process.env['BLOKO_S3_ACCESS_KEY'] ?? '',
|
|
24
|
+
secretAccessKey: process.env['BLOKO_S3_SECRET_KEY'] ?? '',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
14
27
|
//# sourceMappingURL=config.js.map
|
package/dist/cli/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,SAAS;IACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,WAAW;QACjD,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,MAAM,EAAE,EAAE,CAAC;QAC1D,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,OAAO;QACrD,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,UAAU;QAChD,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE;QAChD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,WAAW;QACrD,MAAM;QACN,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE;QACrD,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE;KAC1D,CAAC;AACJ,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type DB, type DBConfig } from './db.js';
|
|
2
2
|
import { type Crud } from './crud/index.js';
|
|
3
|
+
import { type Api } from './api/index.js';
|
|
3
4
|
import { type S3Config, type ImageService } from './s3/index.js';
|
|
4
|
-
export declare const VERSION = "0.0.
|
|
5
|
+
export declare const VERSION = "0.0.15";
|
|
5
6
|
export interface BlokoConfig {
|
|
6
7
|
db: DBConfig;
|
|
7
8
|
s3?: S3Config;
|
|
8
9
|
}
|
|
9
|
-
export interface Bloko {
|
|
10
|
+
export interface Bloko extends Api {
|
|
10
11
|
db: DB;
|
|
11
12
|
crud: Crud;
|
|
12
13
|
images?: ImageService;
|
|
@@ -16,5 +17,7 @@ export declare function createBloko(config: BlokoConfig): Bloko;
|
|
|
16
17
|
export * from './types.js';
|
|
17
18
|
export type { DB, DBConfig } from './db.js';
|
|
18
19
|
export type { Crud } from './crud/index.js';
|
|
20
|
+
export type { Api, NodesApi, NodeWithContents, ContentItem, TreeNode, FindByPathResult } from './api/index.js';
|
|
21
|
+
export type { CollectionsApi, CollectionWithNavigation, NavNode } from './api/index.js';
|
|
19
22
|
export type { S3Config, ImageService, VariantConfig, UploadResult } from './s3/index.js';
|
|
20
23
|
//# 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,OAAO,EAAuB,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,iBA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EAAE,cAAc,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxF,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { connect, disconnect } from './db.js';
|
|
2
2
|
import { createCrud } from './crud/index.js';
|
|
3
|
+
import { createApi } from './api/index.js';
|
|
3
4
|
import { createS3Client, createImageService } from './s3/index.js';
|
|
4
|
-
export const VERSION = '0.0.
|
|
5
|
+
export const VERSION = '0.0.15';
|
|
5
6
|
export function createBloko(config) {
|
|
6
7
|
const db = connect(config.db);
|
|
7
8
|
const crud = createCrud(db);
|
|
9
|
+
const api = createApi(crud);
|
|
8
10
|
let images;
|
|
9
11
|
if (config.s3) {
|
|
10
12
|
const s3Client = createS3Client(config.s3);
|
|
@@ -13,6 +15,7 @@ export function createBloko(config) {
|
|
|
13
15
|
return {
|
|
14
16
|
db,
|
|
15
17
|
crud,
|
|
18
|
+
...api, // API (nodes, collections)
|
|
16
19
|
images,
|
|
17
20
|
disconnect,
|
|
18
21
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAA0B,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,UAAU,EAAa,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAoC,MAAM,eAAe,CAAC;AAErG,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAchC,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;IAE5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