@cyberismo/backend 0.0.15 → 0.0.16
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/app.d.ts +21 -0
- package/dist/app.js +9 -3
- package/dist/app.js.map +1 -1
- package/dist/common/validationSchemas.d.ts +48 -0
- package/dist/domain/calculations/index.d.ts +15 -0
- package/dist/domain/calculations/schema.d.ts +16 -0
- package/dist/domain/calculations/service.d.ts +14 -0
- package/dist/domain/cardTypes/index.d.ts +15 -0
- package/dist/domain/cardTypes/schema.d.ts +17 -0
- package/dist/domain/cardTypes/service.d.ts +15 -0
- package/dist/domain/cards/index.d.ts +15 -0
- package/dist/domain/cards/index.js +22 -6
- package/dist/domain/cards/index.js.map +1 -1
- package/dist/domain/cards/lib.d.ts +29 -0
- package/dist/domain/cards/lib.js +73 -2
- package/dist/domain/cards/lib.js.map +1 -1
- package/dist/domain/cards/service.d.ts +61 -0
- package/dist/domain/cards/service.js +20 -12
- package/dist/domain/cards/service.js.map +1 -1
- package/dist/domain/fieldTypes/index.d.ts +15 -0
- package/dist/domain/fieldTypes/schema.d.ts +28 -0
- package/dist/domain/fieldTypes/service.d.ts +16 -0
- package/dist/domain/graphModels/index.d.ts +15 -0
- package/dist/domain/graphModels/schema.d.ts +16 -0
- package/dist/domain/graphModels/service.d.ts +14 -0
- package/dist/domain/graphViews/index.d.ts +15 -0
- package/dist/domain/graphViews/schema.d.ts +4 -0
- package/dist/domain/graphViews/service.d.ts +14 -0
- package/dist/domain/labels/index.d.ts +15 -0
- package/dist/domain/labels/index.js +33 -0
- package/dist/domain/labels/index.js.map +1 -0
- package/dist/domain/labels/service.d.ts +19 -0
- package/dist/domain/labels/service.js +21 -0
- package/dist/domain/labels/service.js.map +1 -0
- package/dist/domain/linkTypes/index.d.ts +15 -0
- package/dist/domain/linkTypes/schema.d.ts +16 -0
- package/dist/domain/linkTypes/service.d.ts +15 -0
- package/dist/domain/logicPrograms/index.d.ts +15 -0
- package/dist/domain/logicPrograms/service.d.ts +15 -0
- package/dist/domain/reports/index.d.ts +15 -0
- package/dist/domain/reports/schema.d.ts +16 -0
- package/dist/domain/reports/service.d.ts +14 -0
- package/dist/domain/resources/index.d.ts +15 -0
- package/dist/domain/resources/schema.d.ts +60 -0
- package/dist/domain/resources/service.d.ts +36 -0
- package/dist/domain/templates/index.d.ts +15 -0
- package/dist/domain/templates/index.js +1 -1
- package/dist/domain/templates/index.js.map +1 -1
- package/dist/domain/templates/schema.d.ts +22 -0
- package/dist/domain/templates/service.d.ts +16 -0
- package/dist/domain/tree/index.d.ts +15 -0
- package/dist/domain/tree/index.js +3 -2
- package/dist/domain/tree/index.js.map +1 -1
- package/dist/domain/tree/service.d.ts +22 -0
- package/dist/domain/tree/service.js +10 -2
- package/dist/domain/tree/service.js.map +1 -1
- package/dist/domain/workflows/index.d.ts +15 -0
- package/dist/domain/workflows/schema.d.ts +16 -0
- package/dist/domain/workflows/service.d.ts +14 -0
- package/dist/export.d.ts +42 -0
- package/dist/export.js +48 -152
- package/dist/export.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/middleware/commandManager.d.ts +20 -0
- package/dist/middleware/tree.d.ts +9 -0
- package/dist/middleware/tree.js +13 -0
- package/dist/middleware/tree.js.map +1 -0
- package/dist/middleware/zvalidator.d.ts +9 -0
- package/dist/public/THIRD-PARTY.txt +53 -53
- package/dist/public/assets/{index-Dtn1rQ-9.js → index-D410yunq.js} +26486 -26409
- package/dist/public/index.html +1 -1
- package/dist/types.d.ts +29 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +0 -32
- package/dist/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/app.ts +11 -4
- package/src/domain/cards/index.ts +31 -6
- package/src/domain/cards/lib.ts +93 -3
- package/src/domain/cards/service.ts +36 -24
- package/src/domain/labels/index.ts +36 -0
- package/src/domain/labels/service.ts +23 -0
- package/src/domain/resources/service.ts +3 -3
- package/src/domain/templates/index.ts +1 -1
- package/src/domain/tree/index.ts +10 -3
- package/src/domain/tree/service.ts +15 -1
- package/src/export.ts +59 -192
- package/src/index.ts +5 -1
- package/src/middleware/tree.ts +17 -0
- package/src/types.ts +13 -0
- package/src/utils.ts +0 -39
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import { Hono } from 'hono';
|
|
14
|
+
declare const router: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
15
|
+
export default router;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { Hono } from 'hono';
|
|
14
14
|
import * as treeService from './service.js';
|
|
15
|
-
import { isSSGContext } from '
|
|
15
|
+
import { isSSGContext } from 'hono/ssg';
|
|
16
16
|
const router = new Hono();
|
|
17
17
|
/**
|
|
18
18
|
* @swagger
|
|
@@ -30,8 +30,9 @@ const router = new Hono();
|
|
|
30
30
|
*/
|
|
31
31
|
router.get('/', async (c) => {
|
|
32
32
|
const commands = c.get('commands');
|
|
33
|
+
const tree = c.get('tree');
|
|
33
34
|
try {
|
|
34
|
-
const response = await treeService.getCardTree(commands, isSSGContext(c));
|
|
35
|
+
const response = await treeService.getCardTree(commands, isSSGContext(c), tree?.cardKey, tree?.recursive);
|
|
35
36
|
return c.json(response);
|
|
36
37
|
}
|
|
37
38
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/tree/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/tree/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAa,EAAE,EAAE;IACtC,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE3B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,WAAW,CAC5C,QAAQ,EACR,YAAY,CAAC,CAAC,CAAC,EACf,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,SAAS,CAChB,CAAC;QACF,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,CAAC,IAAI,CACX;YACE,KAAK,EAAE,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,cAAc,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;SACvG,EACD,GAAG,CACJ,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import type { CommandManager } from '@cyberismo/data-handler';
|
|
14
|
+
/**
|
|
15
|
+
* Returns the card tree of the project
|
|
16
|
+
* @param commands command manager used for the query
|
|
17
|
+
* @param isSsg whether the context is static site generation
|
|
18
|
+
* @param cardKey optional card key to start the tree from
|
|
19
|
+
* @param recursive if false, includes only the given card. Otherwise, includes all child cards recursively.
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCardTree(commands: CommandManager, isSsg: boolean, cardKey?: string, recursive?: boolean): ReturnType<typeof commands.calculateCmd.runQuery>;
|
|
@@ -10,8 +10,16 @@
|
|
|
10
10
|
details. You should have received a copy of the GNU Affero General Public
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Returns the card tree of the project
|
|
15
|
+
* @param commands command manager used for the query
|
|
16
|
+
* @param isSsg whether the context is static site generation
|
|
17
|
+
* @param cardKey optional card key to start the tree from
|
|
18
|
+
* @param recursive if false, includes only the given card. Otherwise, includes all child cards recursively.
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export async function getCardTree(commands, isSsg, cardKey, recursive) {
|
|
14
22
|
await commands.calculateCmd.generate();
|
|
15
|
-
return commands.calculateCmd.runQuery('tree', isSsg ? 'exportedSite' : 'localApp');
|
|
23
|
+
return commands.calculateCmd.runQuery('tree', isSsg ? 'exportedSite' : 'localApp', { cardKey, recursive });
|
|
16
24
|
}
|
|
17
25
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/domain/tree/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAIF,MAAM,CAAC,KAAK,UAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/domain/tree/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAIF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,QAAwB,EACxB,KAAc,EACd,OAAgB,EAChB,SAAmB;IAEnB,MAAM,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACvC,OAAO,QAAQ,CAAC,YAAY,CAAC,QAAQ,CACnC,MAAM,EACN,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,EACnC,EAAE,OAAO,EAAE,SAAS,EAAE,CACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import { Hono } from 'hono';
|
|
14
|
+
declare const router: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
15
|
+
export default router;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
export declare const createWorkflowSchema: z.ZodObject<{
|
|
15
|
+
identifier: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import type { CommandManager } from '@cyberismo/data-handler';
|
|
14
|
+
export declare function createWorkflow(commands: CommandManager, workflowName: string): Promise<void>;
|
package/dist/export.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import type { QueryResult } from '@cyberismo/data-handler/types/queries';
|
|
14
|
+
import type { TreeOptions } from './types.js';
|
|
15
|
+
/**
|
|
16
|
+
* DO NO USE DIRECTLY. This resets the callOnce map, allowing you to redo the export.
|
|
17
|
+
* Also resets the card query promise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function reset(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get the card query result for a given card key. Should only be called during
|
|
22
|
+
* static site generation
|
|
23
|
+
* @param projectPath - Path to the project.
|
|
24
|
+
* @param cardKey - Key of the card to get the query result for.
|
|
25
|
+
* @returns The card query result for the given card key.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getCardQueryResult(projectPath: string, cardKey?: string): Promise<QueryResult<'card'>[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Export the site to a given directory.
|
|
30
|
+
* Note: Do not call this function in parallel.
|
|
31
|
+
* @param projectPath - Path to the project.
|
|
32
|
+
* @param options - Export options.
|
|
33
|
+
* @param options.recursive - Whether to export cards recursively.
|
|
34
|
+
* @param options.cardKey - Key of the card to export. If not provided, all cards will be exported.
|
|
35
|
+
* @param exportDir - Directory to export to.
|
|
36
|
+
* @param level - Log level for the operation.
|
|
37
|
+
* @param onProgress - Optional progress callback function.
|
|
38
|
+
* @returns An object containing any errors that occurred during export.
|
|
39
|
+
*/
|
|
40
|
+
export declare function exportSite(projectPath: string, exportDir?: string, options?: TreeOptions, level?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal', onProgress?: (current: number, total: number) => void): Promise<{
|
|
41
|
+
errors: string[];
|
|
42
|
+
}>;
|
package/dist/export.js
CHANGED
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
13
|
import path from 'node:path';
|
|
14
|
-
import {
|
|
14
|
+
import fs, { readFile } from 'node:fs/promises';
|
|
15
15
|
import { CommandManager } from '@cyberismo/data-handler';
|
|
16
16
|
import { createApp } from './app.js';
|
|
17
17
|
import { cp, writeFile } from 'node:fs/promises';
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
18
|
+
import { staticFrontendDirRelative } from './utils.js';
|
|
19
|
+
import { toSSG } from 'hono/ssg';
|
|
20
|
+
import { findAllCards, findRelevantAttachments, } from './domain/cards/service.js';
|
|
20
21
|
let _cardQueryPromise = null;
|
|
22
|
+
const OVERHEAD_CALLS = 6; // estimated number of overhead calls during export in addition to card exports
|
|
21
23
|
/**
|
|
22
24
|
* DO NO USE DIRECTLY. This resets the callOnce map, allowing you to redo the export.
|
|
23
25
|
* Also resets the card query promise.
|
|
@@ -53,13 +55,22 @@ export async function getCardQueryResult(projectPath, cardKey) {
|
|
|
53
55
|
* Export the site to a given directory.
|
|
54
56
|
* Note: Do not call this function in parallel.
|
|
55
57
|
* @param projectPath - Path to the project.
|
|
58
|
+
* @param options - Export options.
|
|
59
|
+
* @param options.recursive - Whether to export cards recursively.
|
|
60
|
+
* @param options.cardKey - Key of the card to export. If not provided, all cards will be exported.
|
|
56
61
|
* @param exportDir - Directory to export to.
|
|
57
62
|
* @param level - Log level for the operation.
|
|
58
63
|
* @param onProgress - Optional progress callback function.
|
|
64
|
+
* @returns An object containing any errors that occurred during export.
|
|
59
65
|
*/
|
|
60
|
-
export async function exportSite(projectPath, exportDir, level, onProgress) {
|
|
66
|
+
export async function exportSite(projectPath, exportDir, options, level, onProgress) {
|
|
61
67
|
exportDir = exportDir || 'static';
|
|
62
|
-
const
|
|
68
|
+
const opts = {
|
|
69
|
+
recursive: false,
|
|
70
|
+
cardKey: undefined,
|
|
71
|
+
...options,
|
|
72
|
+
};
|
|
73
|
+
const app = createApp(projectPath, opts);
|
|
63
74
|
// copy whole frontend to the same directory
|
|
64
75
|
await cp(staticFrontendDirRelative, exportDir, { recursive: true });
|
|
65
76
|
// read config file and change export to true
|
|
@@ -70,159 +81,44 @@ export async function exportSite(projectPath, exportDir, level, onProgress) {
|
|
|
70
81
|
const commands = await CommandManager.getInstance(projectPath, {
|
|
71
82
|
logLevel: level,
|
|
72
83
|
});
|
|
73
|
-
await toSsg(app, commands, exportDir, onProgress);
|
|
74
|
-
}
|
|
75
|
-
async function getRoutes(app) {
|
|
76
|
-
const routes = new Set();
|
|
77
|
-
for (const route of app.routes) {
|
|
78
|
-
if (route.method === 'GET')
|
|
79
|
-
routes.add(route.path);
|
|
80
|
-
}
|
|
81
|
-
// handles both routes with and without dynamic parameters
|
|
82
|
-
const filteredRoutes = [];
|
|
83
|
-
for (const route of routes) {
|
|
84
|
-
if (!route.includes(':')) {
|
|
85
|
-
filteredRoutes.push(route);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const response = await createSsgRequest(app, route, true);
|
|
89
|
-
if (response.ok) {
|
|
90
|
-
const params = await response.json();
|
|
91
|
-
if (Array.isArray(params) && params.length > 0) {
|
|
92
|
-
for (const param of params) {
|
|
93
|
-
let newRoute = route;
|
|
94
|
-
for (const [key, value] of Object.entries(param)) {
|
|
95
|
-
newRoute = newRoute.replace(`:${key}`, `${value}`);
|
|
96
|
-
}
|
|
97
|
-
filteredRoutes.push(newRoute);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return filteredRoutes;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* This is similar to hono's ssg function, but it only calls middlewares once
|
|
106
|
-
* @param app
|
|
107
|
-
* @param onProgress
|
|
108
|
-
*/
|
|
109
|
-
async function toSsg(app, commands, dir, onProgress) {
|
|
110
84
|
reset();
|
|
111
85
|
await commands.project.calculationEngine.generate();
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
let
|
|
116
|
-
|
|
86
|
+
// estimate total based on the number of cards to export
|
|
87
|
+
const cards = await findAllCards(commands, opts);
|
|
88
|
+
const attachments = await findRelevantAttachments(commands, opts);
|
|
89
|
+
let total = cards.length + attachments.length + OVERHEAD_CALLS;
|
|
90
|
+
// Actual export with progress reporting
|
|
91
|
+
let done = 0;
|
|
92
|
+
onProgress?.(done, total);
|
|
117
93
|
const errors = [];
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
await done(new Error(`Failed to export route ${route}: ${error.error}`));
|
|
94
|
+
await toSSG(app, fs, {
|
|
95
|
+
dir: exportDir,
|
|
96
|
+
concurrency: 5,
|
|
97
|
+
plugins: [
|
|
98
|
+
{
|
|
99
|
+
afterResponseHook: async (response) => {
|
|
100
|
+
if (![200, 201, 204].includes(response.status)) {
|
|
101
|
+
const error = await response.json();
|
|
102
|
+
if (typeof error === 'object' &&
|
|
103
|
+
error != null &&
|
|
104
|
+
'error' in error &&
|
|
105
|
+
typeof error.error === 'string') {
|
|
106
|
+
errors.push(error.error);
|
|
107
|
+
}
|
|
108
|
+
return false; // ignore route
|
|
134
109
|
}
|
|
135
|
-
|
|
136
|
-
|
|
110
|
+
done++;
|
|
111
|
+
if (done > total) {
|
|
112
|
+
total = done; // adjust total if underestimated
|
|
137
113
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
catch (error) {
|
|
144
|
-
await done(error instanceof Error ? error : new Error(String(error)));
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
await runInParallel(promises, 5);
|
|
149
|
-
if (failed) {
|
|
150
|
-
const message = `Errors:\n${errors.map((e) => e.message).join('\n')}`;
|
|
151
|
-
throw new Error(message);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get the file content and file ending for a given response and route.
|
|
156
|
-
* @param response - The response to get the file content and file ending for.
|
|
157
|
-
* @param route - The route to get the file content and file ending for.
|
|
158
|
-
* @returns The file content and file ending for the given response and route.
|
|
159
|
-
* If the route already has a file ending, it will be returned as an empty string.
|
|
160
|
-
*/
|
|
161
|
-
async function getFileContent(response, route) {
|
|
162
|
-
// Check if route already has an extension
|
|
163
|
-
const routeExtension = path.extname(route);
|
|
164
|
-
if (routeExtension) {
|
|
165
|
-
// Trust the existing extension in the route
|
|
166
|
-
const content = await response.arrayBuffer();
|
|
167
|
-
return {
|
|
168
|
-
content,
|
|
169
|
-
fileEnding: '',
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
// No extension in route, fall back to content type detection
|
|
173
|
-
const contentType = response.headers.get('content-type');
|
|
174
|
-
if (!contentType) {
|
|
175
|
-
throw new Error('No content type');
|
|
176
|
-
}
|
|
177
|
-
const extension = mime.extension(contentType);
|
|
178
|
-
if (!extension) {
|
|
179
|
-
throw new Error('Unsupported content type');
|
|
180
|
-
}
|
|
181
|
-
// Use ArrayBuffer for all content types
|
|
182
|
-
const content = await response.arrayBuffer();
|
|
183
|
-
return {
|
|
184
|
-
content,
|
|
185
|
-
fileEnding: `.${extension}`,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
async function writeFileToDir(dir, response, route) {
|
|
189
|
-
const { content, fileEnding } = await getFileContent(response, route);
|
|
190
|
-
let filePath = path.join(dir, route);
|
|
191
|
-
// if route does not have a file ending, add it based on the content type
|
|
192
|
-
if (!route.endsWith(fileEnding)) {
|
|
193
|
-
filePath += fileEnding;
|
|
194
|
-
}
|
|
195
|
-
await mkdir(path.dirname(filePath), { recursive: true });
|
|
196
|
-
await writeFile(filePath, Buffer.from(content));
|
|
197
|
-
}
|
|
198
|
-
// findroutes = if this request is used to find the routes in the app
|
|
199
|
-
function createSsgRequest(app, route, findRoutes = true) {
|
|
200
|
-
return app.request(route, {
|
|
201
|
-
headers: new Headers({
|
|
202
|
-
'x-ssg': 'true',
|
|
203
|
-
'x-ssg-find': findRoutes ? 'true' : 'false',
|
|
204
|
-
}),
|
|
114
|
+
onProgress?.(done, total);
|
|
115
|
+
return response;
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
205
119
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
* Check if the request is a static site generation request.
|
|
209
|
-
* @param c - The context of the request.
|
|
210
|
-
* @returns True if the request is a static site generation request.
|
|
211
|
-
*/
|
|
212
|
-
export function isSSGContext(c) {
|
|
213
|
-
return c.req.header('x-ssg') === 'true';
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* This middleware is used to find the routes in the app.
|
|
217
|
-
* @param fn - The function to call to get the parameters for the route.
|
|
218
|
-
* @returns The middleware handler.
|
|
219
|
-
*/
|
|
220
|
-
export function ssgParams(fn) {
|
|
221
|
-
return async (c, next) => {
|
|
222
|
-
if (c.req.header('x-ssg-find') === 'true') {
|
|
223
|
-
return fn ? c.json(await fn(c)) : c.json([]);
|
|
224
|
-
}
|
|
225
|
-
return next();
|
|
120
|
+
return {
|
|
121
|
+
errors,
|
|
226
122
|
};
|
|
227
123
|
}
|
|
228
124
|
//# sourceMappingURL=export.js.map
|
package/dist/export.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EACL,YAAY,EACZ,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAEnC,IAAI,iBAAiB,GAA0C,IAAI,CAAC;AACpE,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,+EAA+E;AAEzG;;;GAGG;AACH,MAAM,UAAU,KAAK;IACnB,iBAAiB,GAAG,IAAI,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,OAAgB;IAEhB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAC/D,kBAAkB;QAClB,iBAAiB,GAAG,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAC7D,MA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,OAAO,KAAK,CAAC,CAAC,eAAe;oBAC/B,CAAC;oBACD,IAAI,EAAE,CAAC;oBACP,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC;wBACjB,KAAK,GAAG,IAAI,CAAC,CAAC,iCAAiC;oBACjD,CAAC;oBACD,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oBAC1B,OAAO,QAAQ,CAAC;gBAClB,CAAC;aACF;SACF;KACF,CAAC,CAAC;IACH,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { exportSite } from './export.js';
|
|
2
|
+
/**
|
|
3
|
+
* Preview the exported site
|
|
4
|
+
* @param dir - Directory to preview
|
|
5
|
+
* @param findPort - If true, find a free port
|
|
6
|
+
*/
|
|
7
|
+
export declare function previewSite(dir: string, findPort?: boolean): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Start the server
|
|
10
|
+
* @param projectPath - Path to the project
|
|
11
|
+
* @param findPort - If true, find a free port
|
|
12
|
+
*/
|
|
13
|
+
export declare function startServer(projectPath?: string, findPort?: boolean): Promise<void>;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AACF,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AACF,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EA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C,CAAC;IAErE,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CACf,GAAkB,EAClB,IAAY;IAEZ,KAAK,CACH;QACE,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,IAAI,EAAE,IAAI;KACX,EACD,CAAC,IAAI,EAAE,EAAE;QACP,OAAO,CAAC,GAAG,CAAC,6CAA6C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IAC1C,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
6
|
+
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
8
|
+
|
|
9
|
+
You should have received a copy of the GNU Affero General Public
|
|
10
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
|
+
*/
|
|
12
|
+
import type { MiddlewareHandler } from 'hono';
|
|
13
|
+
import { CommandManager } from '@cyberismo/data-handler';
|
|
14
|
+
declare module 'hono' {
|
|
15
|
+
interface ContextVariableMap {
|
|
16
|
+
commands: CommandManager;
|
|
17
|
+
projectPath: string;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export declare const attachCommandManager: (projectPath?: string) => MiddlewareHandler;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Next } from 'hono';
|
|
2
|
+
import type { AppContext, TreeOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Injects tree options into the context for each request
|
|
5
|
+
* @param opts Options to inject
|
|
6
|
+
* @returns Middleware function
|
|
7
|
+
*/
|
|
8
|
+
declare const treeMiddleware: (opts?: TreeOptions) => (c: AppContext, next: Next) => Promise<void>;
|
|
9
|
+
export default treeMiddleware;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injects tree options into the context for each request
|
|
3
|
+
* @param opts Options to inject
|
|
4
|
+
* @returns Middleware function
|
|
5
|
+
*/
|
|
6
|
+
const treeMiddleware = (opts) => async (c, next) => {
|
|
7
|
+
if (opts) {
|
|
8
|
+
c.set('tree', { recursive: opts.recursive, cardKey: opts.cardKey });
|
|
9
|
+
}
|
|
10
|
+
await next();
|
|
11
|
+
};
|
|
12
|
+
export default treeMiddleware;
|
|
13
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/middleware/tree.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,cAAc,GAClB,CAAC,IAAkB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAa,EAAE,IAAU,EAAE,EAAE;IAC1D,IAAI,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,MAAM,IAAI,EAAE,CAAC;AACf,CAAC,CAAC;AAEJ,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
import type { ValidationTargets } from 'hono';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export declare const zValidator: <T extends ZodType, Target extends keyof ValidationTargets>(target: Target, schema: T) => import("hono").MiddlewareHandler<import("hono").Env, string, {
|
|
5
|
+
in: (undefined extends (T extends import("zod/v3").ZodType<any, import("zod/v3").ZodTypeDef, any> ? import("zod/v3").input<T> : T extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? z.core.input<T> : never) ? true : false) extends true ? { [K in Target]?: ((T extends import("zod/v3").ZodType<any, import("zod/v3").ZodTypeDef, any> ? import("zod/v3").input<T> : T extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? z.core.input<T> : never) extends infer T_1 ? T_1 extends (T extends import("zod/v3").ZodType<any, import("zod/v3").ZodTypeDef, any> ? import("zod/v3").input<T> : T extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? z.core.input<T> : never) ? T_1 extends ValidationTargets[K] ? T_1 : { [K2 in keyof T_1]?: (T_1[K2] extends ValidationTargets[K][K2] ? T_1[K2] : ValidationTargets[K][K2]) | undefined; } : never : never) | undefined; } : { [K_1 in Target]: (T extends import("zod/v3").ZodType<any, import("zod/v3").ZodTypeDef, any> ? import("zod/v3").input<T> : T extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? z.core.input<T> : never) extends infer T_1 ? T_1 extends (T extends import("zod/v3").ZodType<any, import("zod/v3").ZodTypeDef, any> ? import("zod/v3").input<T> : T extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? z.core.input<T> : never) ? T_1 extends ValidationTargets[K_1] ? T_1 : { [K2 in keyof T_1]: T_1[K2] extends ValidationTargets[K_1][K2] ? T_1[K2] : ValidationTargets[K_1][K2]; } : never : never; };
|
|
6
|
+
out: { [K_2 in Target]: T extends import("zod/v3").ZodType<any, import("zod/v3").ZodTypeDef, any> ? import("zod/v3").output<T> : T extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? z.core.output<T> : never; };
|
|
7
|
+
}, import("hono").TypedResponse<{
|
|
8
|
+
error: string;
|
|
9
|
+
}, 400, "json">>;
|