@aopslab/domain-cli-docman 0.1.4
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/LICENSE +202 -0
- package/NOTICE +6 -0
- package/dist/cli-types.d.ts +29 -0
- package/dist/cli-types.js +1 -0
- package/dist/command-surface.d.ts +16 -0
- package/dist/command-surface.js +69 -0
- package/dist/config-host.d.ts +2 -0
- package/dist/config-host.js +1 -0
- package/dist/env-bootstrap.d.ts +1 -0
- package/dist/env-bootstrap.js +96 -0
- package/dist/host-registration.d.ts +39 -0
- package/dist/host-registration.js +101 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +1524 -0
- package/dist/manifests/host-registration.json +44 -0
- package/dist/sqlite-bootstrap.d.ts +1 -0
- package/dist/sqlite-bootstrap.js +79 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -0
- package/package.json +52 -0
- package/resources/sqlite-bootstrap.sql +361 -0
- package/src/cli-types.ts +33 -0
- package/src/command-surface.ts +87 -0
- package/src/config-host.ts +24 -0
- package/src/env-bootstrap.ts +111 -0
- package/src/host-registration.ts +155 -0
- package/src/main.ts +1747 -0
- package/src/sqlite-bootstrap.ts +84 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "aops-host-registration",
|
|
3
|
+
"registrationVersion": "1",
|
|
4
|
+
"domain": "docman",
|
|
5
|
+
"displayName": "Docman",
|
|
6
|
+
"packageName": "@aopslab/domain-cli-docman",
|
|
7
|
+
"description": "Document graph and content-structure tooling for documents, sections, pages, snippets, embeds, rendering, and version workflows.",
|
|
8
|
+
"baseDir": "../..",
|
|
9
|
+
"notes": [
|
|
10
|
+
"Prefer registering from `docman manifest host-registration` when docman is installed outside the AOPS workspace.",
|
|
11
|
+
"Provide `DOCMAN_REPO_URL`, `DOCMAN_SQLITE_URL`, or `DOCMAN_PG_URL` for explicit host runtime binding; standalone docman without a Docman-specific repo source falls back to `~/.aops/docman.aops.sqlite`.",
|
|
12
|
+
"HRM is runtime registration metadata only. Capability/discovery truth still comes from DCM."
|
|
13
|
+
],
|
|
14
|
+
"pluginLoader": {
|
|
15
|
+
"allowlist": [
|
|
16
|
+
"../docman-host-plugin/dist/index.js"
|
|
17
|
+
],
|
|
18
|
+
"strictAllowlist": false,
|
|
19
|
+
"tolerantBootstrap": false
|
|
20
|
+
},
|
|
21
|
+
"manifestProviders": [
|
|
22
|
+
{
|
|
23
|
+
"id": "docman-dcm",
|
|
24
|
+
"domain": "docman",
|
|
25
|
+
"enabled": true,
|
|
26
|
+
"module": "../docman-tooling/dist/index.js",
|
|
27
|
+
"exportName": "buildDocmanDomainCapabilityManifest",
|
|
28
|
+
"options": {
|
|
29
|
+
"includeDocs": true
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"plugins": [
|
|
34
|
+
{
|
|
35
|
+
"domain": "docman",
|
|
36
|
+
"enabled": true,
|
|
37
|
+
"module": "../docman-host-plugin/dist/index.js",
|
|
38
|
+
"factory": "createDocmanPlugin",
|
|
39
|
+
"options": {
|
|
40
|
+
"defaultScopeId": "00000000-0000-4000-8000-000000000000"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ensureDocmanSqliteSchemaReady(repoUrlRaw: string | undefined): void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
const SQLITE_TABLE_SENTINEL = 'docman_documents';
|
|
6
|
+
const cliRoot = fileURLToPath(new URL('../', import.meta.url));
|
|
7
|
+
const sqliteBootstrapSqlPath = resolve(cliRoot, 'resources', 'sqlite-bootstrap.sql');
|
|
8
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
9
|
+
function requireNodeSqlite() {
|
|
10
|
+
return nodeRequire('node:sqlite');
|
|
11
|
+
}
|
|
12
|
+
function isSqliteRepoUrl(repoUrl) {
|
|
13
|
+
const normalized = repoUrl.trim().toLowerCase();
|
|
14
|
+
if (!normalized)
|
|
15
|
+
return false;
|
|
16
|
+
if (normalized === ':memory:')
|
|
17
|
+
return true;
|
|
18
|
+
if (normalized.startsWith('sqlite:') || normalized.startsWith('file:'))
|
|
19
|
+
return true;
|
|
20
|
+
return normalized.endsWith('.db') || normalized.endsWith('.sqlite') || normalized.endsWith('.sqlite3');
|
|
21
|
+
}
|
|
22
|
+
function resolveSqliteFilename(repoUrl) {
|
|
23
|
+
const trimmed = repoUrl.trim();
|
|
24
|
+
if (trimmed === ':memory:')
|
|
25
|
+
return ':memory:';
|
|
26
|
+
const stripScheme = (value, scheme) => value.startsWith(scheme) ? value.slice(scheme.length).replace(/^\/\//, '') : value;
|
|
27
|
+
const noSqlite = stripScheme(trimmed, 'sqlite:');
|
|
28
|
+
const noFile = stripScheme(noSqlite, 'file:');
|
|
29
|
+
return noFile || trimmed;
|
|
30
|
+
}
|
|
31
|
+
function hasDocmanSchema(filename) {
|
|
32
|
+
const { DatabaseSync } = requireNodeSqlite();
|
|
33
|
+
const db = new DatabaseSync(filename);
|
|
34
|
+
try {
|
|
35
|
+
const found = db
|
|
36
|
+
.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='${SQLITE_TABLE_SENTINEL}'`)
|
|
37
|
+
.get();
|
|
38
|
+
return found?.name === SQLITE_TABLE_SENTINEL;
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
db.close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function applyBootstrapSql(filename) {
|
|
45
|
+
if (!existsSync(sqliteBootstrapSqlPath)) {
|
|
46
|
+
throw new Error(`missing_sqlite_bootstrap_sql:${sqliteBootstrapSqlPath}`);
|
|
47
|
+
}
|
|
48
|
+
const { DatabaseSync } = requireNodeSqlite();
|
|
49
|
+
const sql = readFileSync(sqliteBootstrapSqlPath, 'utf8');
|
|
50
|
+
const db = new DatabaseSync(filename);
|
|
51
|
+
try {
|
|
52
|
+
db.exec(sql);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
db.close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function ensureDocmanSqliteSchemaReady(repoUrlRaw) {
|
|
59
|
+
const repoUrl = String(repoUrlRaw ?? '').trim();
|
|
60
|
+
if (!repoUrl || !isSqliteRepoUrl(repoUrl))
|
|
61
|
+
return;
|
|
62
|
+
const filename = resolveSqliteFilename(repoUrl);
|
|
63
|
+
if (filename === ':memory:')
|
|
64
|
+
return;
|
|
65
|
+
mkdirSync(dirname(filename), { recursive: true });
|
|
66
|
+
if (!existsSync(filename)) {
|
|
67
|
+
const fd = openSync(filename, 'a');
|
|
68
|
+
closeSync(fd);
|
|
69
|
+
}
|
|
70
|
+
if (hasDocmanSchema(filename))
|
|
71
|
+
return;
|
|
72
|
+
try {
|
|
73
|
+
applyBootstrapSql(filename);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
77
|
+
throw new Error(`sqlite_schema_bootstrap_failed:${message}`);
|
|
78
|
+
}
|
|
79
|
+
}
|