zelos-recad 0.1.0 → 0.2.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/README.md +18 -5
- package/UPSTREAM-LICENSE +21 -21
- package/build-info.json +26 -0
- package/mcp/index.js +2 -1
- package/package.json +22 -10
- package/protocol/src/bundle.d.ts +7 -1
- package/protocol/src/contracts.d.ts +18 -6
- package/protocol/src/contracts.js +20 -7
- package/protocol/src/native-evidence.d.ts +20 -0
- package/service/app.js +4 -2
- package/service/options.d.ts +2 -1
- package/service/options.js +2 -1
- package/shared/build-identity.d.mts +6 -0
- package/shared/build-identity.mjs +63 -0
- package/shared/client.d.mts +1 -0
- package/shared/client.mjs +9 -0
- package/shared/command.d.mts +1 -0
- package/shared/command.mjs +22 -4
- package/shared/contracts/src/paths.d.ts +3 -0
- package/shared/contracts/src/paths.js +31 -0
- package/shared/mcp.d.mts +1 -0
- package/shared/service-storage/src/capacity.d.ts +36 -0
- package/shared/service-storage/src/capacity.js +71 -0
- package/shared/service-storage/src/consumption.d.ts +15 -0
- package/shared/service-storage/src/consumption.js +27 -0
- package/shared/service-storage/src/documents.d.ts +43 -0
- package/shared/service-storage/src/documents.js +210 -0
- package/shared/service-storage/src/downloads.d.ts +10 -0
- package/shared/service-storage/src/downloads.js +58 -0
- package/shared/service-storage/src/files.d.ts +18 -0
- package/shared/service-storage/src/files.js +118 -0
- package/shared/service-storage/src/footprint.d.ts +14 -0
- package/shared/service-storage/src/footprint.js +72 -0
- package/shared/service-storage/src/process-temp.d.ts +22 -0
- package/shared/service-storage/src/process-temp.js +181 -0
- package/shared/service-storage/src/quota.d.ts +30 -0
- package/shared/service-storage/src/quota.js +166 -0
- package/shared/service-storage/src/retention.d.ts +38 -0
- package/shared/service-storage/src/retention.js +148 -0
- package/shared/service-storage/src/staging.d.ts +15 -0
- package/shared/service-storage/src/staging.js +116 -0
- package/source/README.md +1 -3
- package/source/mcp/index.ts +2 -1
- package/source/package.json +4 -2
- package/source/protocol/src/contracts.ts +20 -7
- package/source/protocol/src/native-evidence.ts +21 -0
- package/source/rebuild.mjs +12 -4
- package/source/service/app.ts +6 -2
- package/source/service/options.ts +3 -2
- package/source/shared/build-identity.d.mts +6 -0
- package/source/shared/build-identity.mjs +63 -0
- package/source/shared/client.d.mts +1 -0
- package/source/shared/client.mjs +9 -0
- package/source/shared/command.d.mts +1 -0
- package/source/shared/command.mjs +22 -4
- package/source/shared/contracts/src/paths.ts +33 -0
- package/source/shared/mcp.d.mts +1 -0
- package/source/shared/service-storage/src/capacity.ts +101 -0
- package/source/shared/service-storage/src/consumption.ts +45 -0
- package/source/shared/service-storage/src/documents.ts +262 -0
- package/source/shared/service-storage/src/downloads.ts +62 -0
- package/source/shared/service-storage/src/files.ts +135 -0
- package/source/shared/service-storage/src/footprint.ts +78 -0
- package/source/shared/service-storage/src/process-temp.ts +205 -0
- package/source/shared/service-storage/src/quota.ts +198 -0
- package/source/shared/service-storage/src/retention.ts +180 -0
- package/source/shared/service-storage/src/staging.ts +106 -0
- package/source/src/application-objects.ts +2 -2
- package/source/src/assets.ts +15 -0
- package/source/src/block-clip.ts +1 -1
- package/source/src/block-metadata.ts +12 -5
- package/source/src/build-info.ts +15 -0
- package/source/src/cad-engine.ts +18 -8
- package/source/src/command.ts +2 -2
- package/source/src/constraints.ts +2 -2
- package/source/src/conversion.ts +2 -0
- package/source/src/dwg-fallback.ts +2 -0
- package/source/src/dwg.ts +7 -0
- package/source/src/dxf-export.ts +3 -3
- package/source/src/dxf.ts +7 -4
- package/source/src/native-evidence.ts +33 -1
- package/source/src/native-segmented-path.ts +22 -35
- package/source/src/point-dictionaries.ts +65 -0
- package/source/src/readback.ts +7 -6
- package/source/src/reader.ts +19 -10
- package/source/src/render-operation.ts +39 -7
- package/source/src/runner.ts +5 -4
- package/source/src/runtime/documents.ts +23 -142
- package/source/src/runtime/index.ts +71 -17
- package/source/src/runtime/jobs.ts +176 -153
- package/source/src/runtime/managed-worker.ts +37 -0
- package/source/src/runtime/storage-policy.ts +39 -0
- package/source/src/runtime/storage.ts +9 -44
- package/source/src/source-scene.ts +125 -23
- package/source/src/text/glyphs.ts +63 -0
- package/source/src/text/ink-bounds.ts +7 -36
- package/source/src/text/scene-geometry.ts +92 -0
- package/source/src/text/source-fonts.ts +31 -0
- package/source/src/vendor-object-data.ts +265 -0
- package/source/src/xref.ts +4 -3
- package/source/tsconfig.json +4 -2
- package/src/application-objects.js +2 -2
- package/src/assets.d.ts +9 -0
- package/src/assets.js +14 -0
- package/src/block-clip.js +1 -1
- package/src/block-metadata.js +11 -5
- package/src/build-info.d.ts +2 -0
- package/src/build-info.js +14 -0
- package/src/cad-engine.js +19 -8
- package/src/command.js +2 -2
- package/src/constraints.js +2 -2
- package/src/conversion.d.ts +2 -0
- package/src/conversion.js +2 -0
- package/src/dwg-fallback.d.ts +1 -0
- package/src/dwg-fallback.js +2 -0
- package/src/dwg.d.ts +3 -0
- package/src/dwg.js +7 -0
- package/src/dxf-export.js +3 -3
- package/src/dxf.d.ts +14 -1
- package/src/dxf.js +7 -3
- package/src/native-evidence.d.ts +33 -1
- package/src/native-evidence.js +33 -0
- package/src/native-segmented-path.js +1 -3
- package/src/point-dictionaries.d.ts +12 -0
- package/src/point-dictionaries.js +88 -0
- package/src/readback.d.ts +12 -4
- package/src/readback.js +7 -6
- package/src/reader.d.ts +12 -1
- package/src/reader.js +22 -11
- package/src/render-operation.js +36 -7
- package/src/runner.js +5 -4
- package/src/runtime/documents.d.ts +8 -20
- package/src/runtime/documents.js +17 -116
- package/src/runtime/index.d.ts +41 -4
- package/src/runtime/index.js +72 -18
- package/src/runtime/jobs.d.ts +21 -2
- package/src/runtime/jobs.js +120 -100
- package/src/runtime/managed-worker.d.ts +8 -0
- package/src/runtime/managed-worker.js +29 -0
- package/src/runtime/storage-policy.d.ts +25 -0
- package/src/runtime/storage-policy.js +29 -0
- package/src/runtime/storage.d.ts +1 -7
- package/src/runtime/storage.js +1 -38
- package/src/source-scene.d.ts +4 -2
- package/src/source-scene.js +136 -20
- package/src/text/glyphs.d.ts +12 -0
- package/src/text/glyphs.js +53 -0
- package/src/text/ink-bounds.d.ts +2 -1
- package/src/text/ink-bounds.js +6 -34
- package/src/text/scene-geometry.d.ts +21 -0
- package/src/text/scene-geometry.js +70 -0
- package/src/text/source-fonts.d.ts +7 -0
- package/src/text/source-fonts.js +30 -0
- package/src/vendor-object-data.d.ts +19 -0
- package/src/vendor-object-data.js +241 -0
- package/src/xref.js +3 -3
- package/vendor/libredwg/COPYING +674 -674
- package/vendor/libredwg/Dockerfile +2 -0
- package/vendor/libredwg/README.md +41 -28
- package/vendor/libredwg/build-local.sh +1 -1
- package/vendor/libredwg/libredwg-web.wasm +0 -0
- package/vendor/libredwg/manifest.json +5 -3
- package/vendor/libredwg/opaque-object-binding.patch +29 -0
- package/vendor/libredwg/rebuild.mjs +2 -1
- package/source/service/README.md +0 -152
- package/source/src/text/UPSTREAM.md +0 -26
package/shared/command.mjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { parseArgs } from 'node:util'
|
|
2
2
|
|
|
3
3
|
/** One command grammar for both engines; engine and transport lifecycle remain injectable. */
|
|
4
|
-
export async function runDocumentCommand({ engine, startMcp, serve, doctor, setup, run }) {
|
|
4
|
+
export async function runDocumentCommand({ engine, defaultPorts, startMcp, serve, doctor, setup, run }) {
|
|
5
5
|
const { values, positionals } = parseArgs({ allowPositionals: true, options: {
|
|
6
6
|
transport: { type: 'string', default: 'stdio' }, backend: { type: 'string', default: 'local' }, url: { type: 'string' },
|
|
7
7
|
'data-dir': { type: 'string' }, 'input-root': { type: 'string', multiple: true }, 'output-root': { type: 'string' },
|
|
8
8
|
host: { type: 'string' }, port: { type: 'string' }, python: { type: 'string' }, resources: { type: 'string' },
|
|
9
9
|
concurrency: { type: 'string' }, 'timeout-ms': { type: 'string' }, 'retention-days': { type: 'string' }, 'max-storage-mib': { type: 'string' },
|
|
10
|
+
'worker-storage-mib': { type: 'string' }, 'min-free-gib': { type: 'string' }, 'resume-extra-gib': { type: 'string' }, 'storage-estimate-factor': { type: 'string' },
|
|
10
11
|
'allowed-host': { type: 'string', multiple: true }, 'allowed-origin': { type: 'string', multiple: true },
|
|
11
12
|
input: { type: 'string' }, output: { type: 'string' }, request: { type: 'string' }, help: { type: 'boolean', short: 'h' },
|
|
12
13
|
} })
|
|
13
14
|
const command = positionals[0], env = key => process.env[engine.toUpperCase() + '_' + key]
|
|
14
15
|
if (values.help || !command) {
|
|
15
|
-
console.log(`zelos-${engine} <serve|mcp|doctor|setup|run>\n\nserve: REST document service; --host --port --data-dir\nmcp: --transport stdio|http --backend local|remote --url URL\n --input-root PATH (repeatable, stdio) --output-root PATH\n --allowed-host HOST:PORT --allowed-origin ORIGIN (HTTP)\nrun: --input FILE --output NEW_DIRECTORY --request REQUEST_JSON\n\nCredentials: ${engine.toUpperCase()}_TOKEN for HTTP, ${engine.toUpperCase()}_BACKEND_TOKEN for remote engines.\nData/config: --data-dir, --python (CAD), --resources (CAD), --concurrency 1..4,\n--timeout-ms, --retention-days, --max-storage-mib; matching ${engine.toUpperCase()}_* environment variables supported.`)
|
|
16
|
+
console.log(`zelos-${engine} <serve|mcp|doctor|setup|run>\n\nserve: REST document service; --host --port --data-dir\nmcp: --transport stdio|http --backend local|remote --url URL\n --input-root PATH (repeatable, stdio) --output-root PATH\n --allowed-host HOST:PORT --allowed-origin ORIGIN (HTTP)\nrun: --input FILE --output NEW_DIRECTORY --request REQUEST_JSON\n\nCredentials: ${engine.toUpperCase()}_TOKEN for HTTP, ${engine.toUpperCase()}_BACKEND_TOKEN for remote engines.\nData/config: --data-dir, --python (CAD), --resources (CAD), --concurrency 1..4,\n--timeout-ms, --retention-days, --max-storage-mib.\nCAD storage: --worker-storage-mib, --min-free-gib, --resume-extra-gib,\n--storage-estimate-factor; matching ${engine.toUpperCase()}_* environment variables supported.`)
|
|
16
17
|
return
|
|
17
18
|
}
|
|
18
19
|
if (positionals.length !== 1) throw new Error('Expected one subcommand')
|
|
@@ -22,6 +23,10 @@ export async function runDocumentCommand({ engine, startMcp, serve, doctor, setu
|
|
|
22
23
|
if (!Number.isFinite(parsed) || parsed < min || parsed > max || (integer && !Number.isInteger(parsed))) throw new Error(name + ' is outside its supported range')
|
|
23
24
|
return parsed
|
|
24
25
|
}
|
|
26
|
+
const amount = (name, value, unit, min, max) => {
|
|
27
|
+
const parsed = number(name, value, min, max)
|
|
28
|
+
return parsed === undefined ? undefined : Math.ceil(parsed * unit)
|
|
29
|
+
}
|
|
25
30
|
const options = {
|
|
26
31
|
transport: values.transport, backend: values.backend, url: values.url || env('BACKEND_URL'), backendToken: env('BACKEND_TOKEN'),
|
|
27
32
|
data: values['data-dir'] || env('DATA_DIR'), python: values.python || env('PYTHON'), resources: values.resources || env('RESOURCES'),
|
|
@@ -30,8 +35,12 @@ export async function runDocumentCommand({ engine, startMcp, serve, doctor, setu
|
|
|
30
35
|
allowedHosts: values['allowed-host'], allowedOrigins: values['allowed-origin'],
|
|
31
36
|
concurrency: number('concurrency', values.concurrency || env('CONCURRENCY') || '1', 1, 4, true),
|
|
32
37
|
timeoutMs: number('timeout-ms', values['timeout-ms'] || env('TIMEOUT_MS'), 1, 86400000, true),
|
|
33
|
-
retentionMs:
|
|
34
|
-
maxStorageBytes:
|
|
38
|
+
retentionMs: amount('retention-days', values['retention-days'] || env('RETENTION_DAYS'), 86400000, 0.001, 36500),
|
|
39
|
+
maxStorageBytes: amount('max-storage-mib', values['max-storage-mib'] || env('MAX_STORAGE_MIB'), 1024 ** 2, 0, 1e9),
|
|
40
|
+
workerStorageBytes: amount('worker-storage-mib', values['worker-storage-mib'] || env('WORKER_STORAGE_MIB'), 1024 ** 2, 0.001, 1e9),
|
|
41
|
+
minimumFreeBytes: amount('min-free-gib', values['min-free-gib'], 1024 ** 3, 0, 1e6),
|
|
42
|
+
resumeExtraBytes: amount('resume-extra-gib', values['resume-extra-gib'], 1024 ** 3, 0, 1e6),
|
|
43
|
+
storageEstimateFactor: number('storage-estimate-factor', values['storage-estimate-factor'], 1, 100),
|
|
35
44
|
}
|
|
36
45
|
if (!['local', 'remote'].includes(options.backend) || !['stdio', 'http'].includes(options.transport)) throw new Error('Use backend local|remote and transport stdio|http')
|
|
37
46
|
if (command === 'doctor') { const result = await doctor(options); console.log(JSON.stringify(result)); if (!result.ready) process.exitCode = 1; return }
|
|
@@ -39,6 +48,8 @@ export async function runDocumentCommand({ engine, startMcp, serve, doctor, setu
|
|
|
39
48
|
if (command === 'run') { await run(values); return }
|
|
40
49
|
if (!['serve', 'mcp'].includes(command)) throw new Error('Unknown command: ' + command)
|
|
41
50
|
if (command === 'serve' && options.backend === 'remote') throw new Error('serve owns a local engine; use mcp --backend remote for a gateway')
|
|
51
|
+
options.port ??= defaultPorts?.[command];
|
|
52
|
+
const managed = process.connected === true
|
|
42
53
|
const active = command === 'serve' ? await serve(options) : await startMcp(options)
|
|
43
54
|
if (active.address) console.error(`zelos-${engine} ${command}: ${active.address}`)
|
|
44
55
|
let closing
|
|
@@ -46,11 +57,18 @@ export async function runDocumentCommand({ engine, startMcp, serve, doctor, setu
|
|
|
46
57
|
if (parentTimer) clearInterval(parentTimer)
|
|
47
58
|
process.stdin.pause()
|
|
48
59
|
process.removeListener('SIGINT', close); process.removeListener('SIGTERM', close)
|
|
60
|
+
process.removeListener('message', shutdown); process.removeListener('disconnect', close)
|
|
61
|
+
if (process.connected) process.disconnect()
|
|
49
62
|
})
|
|
63
|
+
const shutdown = message => { if (message?.type === 'shutdown') void close() }
|
|
50
64
|
const stdio = command === 'mcp' && options.transport === 'stdio'
|
|
51
65
|
const parent = process.ppid
|
|
52
66
|
const parentTimer = stdio ? setInterval(() => { try { process.kill(parent, 0) } catch { void close() } }, 1000) : undefined
|
|
53
67
|
parentTimer?.unref()
|
|
54
68
|
process.once('SIGINT', close); process.once('SIGTERM', close)
|
|
69
|
+
if (managed) {
|
|
70
|
+
process.on('message', shutdown); process.once('disconnect', close)
|
|
71
|
+
if (!process.connected) await close()
|
|
72
|
+
}
|
|
55
73
|
if (stdio) { process.stdin.once('end', close); if (process.stdin.readableEnded) await close() }
|
|
56
74
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync, realpathSync, lstatSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export function containedPath(root, relative) {
|
|
4
|
+
// Task reports can originate on Windows and resume in a Linux container.
|
|
5
|
+
// Interpret both separators consistently before absolute/containment checks.
|
|
6
|
+
relative = relative.replaceAll('\\', '/');
|
|
7
|
+
if (!relative || relative.includes('\0') || relative.includes(':') || path.isAbsolute(relative))
|
|
8
|
+
throw new Error('路径必须相对于任务目录');
|
|
9
|
+
const target = path.resolve(root, relative);
|
|
10
|
+
const rel = path.relative(path.resolve(root), target);
|
|
11
|
+
if (!rel || rel.startsWith('..' + path.sep) || rel === '..' || path.isAbsolute(rel))
|
|
12
|
+
throw new Error('路径超出任务目录');
|
|
13
|
+
// Resolve every existing ancestor: junctions/symlinks must never bypass containment.
|
|
14
|
+
let ancestor = target;
|
|
15
|
+
while (!existsSync(ancestor))
|
|
16
|
+
ancestor = path.dirname(ancestor);
|
|
17
|
+
const realRoot = realpathSync(root);
|
|
18
|
+
const realAncestor = realpathSync(ancestor);
|
|
19
|
+
const resolved = path.relative(realRoot, realAncestor);
|
|
20
|
+
if (resolved === '..' || resolved.startsWith('..' + path.sep) || path.isAbsolute(resolved))
|
|
21
|
+
throw new Error('不允许链接到任务目录之外');
|
|
22
|
+
if (existsSync(target) && lstatSync(target).isSymbolicLink())
|
|
23
|
+
throw new Error('不接受符号链接文件');
|
|
24
|
+
return target;
|
|
25
|
+
}
|
|
26
|
+
/** Relativize native absolute inputs in one namespace; callers still enforce containment. */
|
|
27
|
+
export function relativeInputPath(root, file) {
|
|
28
|
+
return path.isAbsolute(file)
|
|
29
|
+
? path.relative(path.toNamespacedPath(path.resolve(root)), path.toNamespacedPath(file))
|
|
30
|
+
: file;
|
|
31
|
+
}
|
package/shared/mcp.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ export interface McpOptions {
|
|
|
4
4
|
backend?: 'local' | 'remote'; transport?: 'stdio' | 'http'; url?: string; backendToken?: string;
|
|
5
5
|
data?: string; python?: string; resources?: string; inputRoots?: string[]; outputRoot?: string;
|
|
6
6
|
concurrency?: number; timeoutMs?: number; retentionMs?: number; maxStorageBytes?: number;
|
|
7
|
+
workerStorageBytes?: number; minimumFreeBytes?: number; resumeExtraBytes?: number; storageEstimateFactor?: number;
|
|
7
8
|
host?: string; port?: number; token?: string; allowedOrigins?: string[]; allowedHosts?: string[];
|
|
8
9
|
sessionTtlMs?: number; maxSessions?: number;
|
|
9
10
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const capacityPolicy: {
|
|
2
|
+
version: string;
|
|
3
|
+
safetyBytes: number;
|
|
4
|
+
resumeExtraBytes: number;
|
|
5
|
+
estimateFactor: number;
|
|
6
|
+
};
|
|
7
|
+
export type CapacityPolicy = typeof capacityPolicy;
|
|
8
|
+
export type VolumeSpace = {
|
|
9
|
+
id: string;
|
|
10
|
+
path: string;
|
|
11
|
+
freeBytes: number;
|
|
12
|
+
totalBytes: number;
|
|
13
|
+
};
|
|
14
|
+
export type CapacityAllocation = {
|
|
15
|
+
key: string;
|
|
16
|
+
directory: string;
|
|
17
|
+
estimatedBytes: number;
|
|
18
|
+
materializedBytes?: number;
|
|
19
|
+
};
|
|
20
|
+
export type CapacityVolume = VolumeSpace & {
|
|
21
|
+
estimatedBytes: number;
|
|
22
|
+
materializedBytes: number;
|
|
23
|
+
remainingBytes: number;
|
|
24
|
+
otherReservedBytes: number;
|
|
25
|
+
requiredBytes: number;
|
|
26
|
+
shortageBytes: number;
|
|
27
|
+
};
|
|
28
|
+
/** Device identity merges directories and mount aliases on the same local volume. */
|
|
29
|
+
export declare function volumeSpace(directory: string): VolumeSpace;
|
|
30
|
+
/** Pure admission calculation; the caller owns atomic reservations and watermark persistence. */
|
|
31
|
+
export declare function capacityVolumes(allocations: CapacityAllocation[], reserved: (id: string) => number, paused: (id: string) => boolean, probe?: typeof volumeSpace, policy?: {
|
|
32
|
+
version: string;
|
|
33
|
+
safetyBytes: number;
|
|
34
|
+
resumeExtraBytes: number;
|
|
35
|
+
estimateFactor: number;
|
|
36
|
+
}): CapacityVolume[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { existsSync, realpathSync, statSync, statfsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const GiB = 1024 ** 3;
|
|
4
|
+
export const capacityPolicy = {
|
|
5
|
+
version: '2026.11.09.1',
|
|
6
|
+
safetyBytes: 5 * GiB,
|
|
7
|
+
resumeExtraBytes: 2 * GiB,
|
|
8
|
+
estimateFactor: 1.2,
|
|
9
|
+
};
|
|
10
|
+
/** Device identity merges directories and mount aliases on the same local volume. */
|
|
11
|
+
export function volumeSpace(directory) {
|
|
12
|
+
let ancestor = path.resolve(directory);
|
|
13
|
+
while (!existsSync(ancestor)) {
|
|
14
|
+
const parent = path.dirname(ancestor);
|
|
15
|
+
if (parent === ancestor)
|
|
16
|
+
throw new Error('存储卷路径不存在:' + directory);
|
|
17
|
+
ancestor = parent;
|
|
18
|
+
}
|
|
19
|
+
ancestor = realpathSync(ancestor);
|
|
20
|
+
const stat = statSync(ancestor, { bigint: true }), disk = statfsSync(ancestor, { bigint: true });
|
|
21
|
+
return {
|
|
22
|
+
id: process.platform + ':' + stat.dev,
|
|
23
|
+
path: ancestor,
|
|
24
|
+
freeBytes: Number(disk.bavail * disk.bsize),
|
|
25
|
+
totalBytes: Number(disk.blocks * disk.bsize),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Pure admission calculation; the caller owns atomic reservations and watermark persistence. */
|
|
29
|
+
export function capacityVolumes(allocations, reserved, paused, probe = volumeSpace, policy = capacityPolicy) {
|
|
30
|
+
if (!allocations.length ||
|
|
31
|
+
new Set(allocations.map((item) => item.key)).size !== allocations.length)
|
|
32
|
+
throw new Error('容量申请需要唯一的分配项');
|
|
33
|
+
const groups = new Map();
|
|
34
|
+
for (const item of allocations) {
|
|
35
|
+
if (!Number.isSafeInteger(item.estimatedBytes) ||
|
|
36
|
+
item.estimatedBytes < 0 ||
|
|
37
|
+
!Number.isSafeInteger(item.materializedBytes || 0) ||
|
|
38
|
+
(item.materializedBytes || 0) < 0)
|
|
39
|
+
throw new Error('容量估计与已落盘字节需要为非负整数');
|
|
40
|
+
const space = probe(item.directory), group = groups.get(space.id) || {
|
|
41
|
+
...space,
|
|
42
|
+
estimatedBytes: 0,
|
|
43
|
+
materializedBytes: 0,
|
|
44
|
+
remainingBytes: 0,
|
|
45
|
+
otherReservedBytes: 0,
|
|
46
|
+
requiredBytes: 0,
|
|
47
|
+
shortageBytes: 0,
|
|
48
|
+
};
|
|
49
|
+
group.freeBytes = Math.min(group.freeBytes, space.freeBytes);
|
|
50
|
+
const estimated = Math.ceil(item.estimatedBytes * policy.estimateFactor);
|
|
51
|
+
group.estimatedBytes += estimated;
|
|
52
|
+
group.materializedBytes += Math.min(estimated, item.materializedBytes || 0);
|
|
53
|
+
groups.set(space.id, group);
|
|
54
|
+
}
|
|
55
|
+
for (const group of groups.values()) {
|
|
56
|
+
group.remainingBytes = group.estimatedBytes - group.materializedBytes;
|
|
57
|
+
group.otherReservedBytes = reserved(group.id);
|
|
58
|
+
const wasPaused = paused(group.id);
|
|
59
|
+
group.requiredBytes =
|
|
60
|
+
group.otherReservedBytes +
|
|
61
|
+
group.remainingBytes +
|
|
62
|
+
policy.safetyBytes +
|
|
63
|
+
(wasPaused ? policy.resumeExtraBytes : 0);
|
|
64
|
+
group.shortageBytes = Math.max(0, group.requiredBytes - group.freeBytes);
|
|
65
|
+
if (group.shortageBytes && !wasPaused) {
|
|
66
|
+
group.requiredBytes += policy.resumeExtraBytes;
|
|
67
|
+
group.shortageBytes = Math.max(0, group.requiredBytes - group.freeBytes);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [...groups.values()];
|
|
71
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ConsumptionReceipt {
|
|
2
|
+
status: 'succeeded' | 'failed' | 'cancelled' | 'interrupted';
|
|
3
|
+
sourceSha256?: string;
|
|
4
|
+
artifacts: {
|
|
5
|
+
name: string;
|
|
6
|
+
bytes: number;
|
|
7
|
+
sha256: string;
|
|
8
|
+
}[];
|
|
9
|
+
}
|
|
10
|
+
export interface Consumption {
|
|
11
|
+
at: string;
|
|
12
|
+
sha256: string;
|
|
13
|
+
}
|
|
14
|
+
/** Order-independent, complete receipt: missing, extra, duplicate or changed artifacts conflict. */
|
|
15
|
+
export declare function consumptionHash(raw: unknown): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { canonical, hash, StorageError } from "./files.js";
|
|
2
|
+
/** Order-independent, complete receipt: missing, extra, duplicate or changed artifacts conflict. */
|
|
3
|
+
export function consumptionHash(raw) {
|
|
4
|
+
const value = raw;
|
|
5
|
+
if (!value ||
|
|
6
|
+
!['succeeded', 'failed', 'cancelled', 'interrupted'].includes(value.status) ||
|
|
7
|
+
(value.sourceSha256 !== undefined && !/^[a-f0-9]{64}$/.test(value.sourceSha256)) ||
|
|
8
|
+
!Array.isArray(value.artifacts) ||
|
|
9
|
+
value.artifacts.length > 10000)
|
|
10
|
+
throw new StorageError('CONSUMPTION_RECEIPT', '消费回执格式无效');
|
|
11
|
+
const seen = new Set();
|
|
12
|
+
const artifacts = value.artifacts
|
|
13
|
+
.map((artifact) => {
|
|
14
|
+
if (!artifact ||
|
|
15
|
+
typeof artifact.name !== 'string' ||
|
|
16
|
+
!/^[^\\/:\x00-\x1f]{1,255}$/.test(artifact.name) ||
|
|
17
|
+
!Number.isSafeInteger(artifact.bytes) ||
|
|
18
|
+
artifact.bytes < 0 ||
|
|
19
|
+
!/^[a-f0-9]{64}$/.test(artifact.sha256) ||
|
|
20
|
+
seen.has(artifact.name))
|
|
21
|
+
throw new StorageError('CONSUMPTION_RECEIPT', '消费回执的成果清单无效');
|
|
22
|
+
seen.add(artifact.name);
|
|
23
|
+
return { name: artifact.name, bytes: artifact.bytes, sha256: artifact.sha256 };
|
|
24
|
+
})
|
|
25
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
26
|
+
return hash(JSON.stringify(canonical({ status: value.status, sourceSha256: value.sourceSha256, artifacts })));
|
|
27
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Readable } from 'node:stream';
|
|
2
|
+
import { StorageQuota } from './quota.js';
|
|
3
|
+
export interface StoredDocument {
|
|
4
|
+
id: string;
|
|
5
|
+
path: string;
|
|
6
|
+
bytes: number;
|
|
7
|
+
sha256: string;
|
|
8
|
+
fileName: string;
|
|
9
|
+
accessedAt: number;
|
|
10
|
+
}
|
|
11
|
+
export interface DocumentFormat {
|
|
12
|
+
sourceName: string;
|
|
13
|
+
defaultName: string;
|
|
14
|
+
fileName: RegExp;
|
|
15
|
+
inputBytes: number;
|
|
16
|
+
validPrefix?: (prefix: Buffer) => boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Store a private writable upload, or share a verified immutable document. */
|
|
19
|
+
export declare function storeSource(source: Buffer | StoredDocument, target: string, quota: StorageQuota): "shared" | "copied" | "written";
|
|
20
|
+
export declare class DocumentStore {
|
|
21
|
+
private data;
|
|
22
|
+
private format;
|
|
23
|
+
private retentionMs;
|
|
24
|
+
private quota;
|
|
25
|
+
readonly root: string;
|
|
26
|
+
readonly storageWarnings: {
|
|
27
|
+
directory: string;
|
|
28
|
+
message: string;
|
|
29
|
+
}[];
|
|
30
|
+
private timer;
|
|
31
|
+
private staging;
|
|
32
|
+
private contents;
|
|
33
|
+
constructor(data: string, format: DocumentFormat, retentionMs?: number, maxStorageBytes?: number, quota?: StorageQuota);
|
|
34
|
+
close(): void;
|
|
35
|
+
private key;
|
|
36
|
+
private remember;
|
|
37
|
+
private shared;
|
|
38
|
+
private read;
|
|
39
|
+
get(id: string): StoredDocument;
|
|
40
|
+
upload(stream: Readable, fileName?: string): Promise<StoredDocument>;
|
|
41
|
+
cleanup(now?: number): void;
|
|
42
|
+
private warn;
|
|
43
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { createWriteStream, mkdirSync, readFileSync, existsSync, lstatSync, readdirSync, writeFileSync, renameSync, rmSync, } from 'node:fs';
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
|
+
import { Transform } from 'node:stream';
|
|
4
|
+
import { pipeline } from 'node:stream/promises';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { atomicJson, checkedId, fileHash, linkImmutable, idPattern, dataRoot, removeJob, StorageError, } from "./files.js";
|
|
7
|
+
import { DEFAULT_RETENTION_MS } from "./retention.js";
|
|
8
|
+
import { StorageQuota } from "./quota.js";
|
|
9
|
+
import { StagedDirectories } from "./staging.js";
|
|
10
|
+
function verifySource(source) {
|
|
11
|
+
const stat = lstatSync(source.path);
|
|
12
|
+
if (stat.isSymbolicLink() ||
|
|
13
|
+
!stat.isFile() ||
|
|
14
|
+
stat.size !== source.bytes ||
|
|
15
|
+
fileHash(source.path) !== source.sha256)
|
|
16
|
+
throw new StorageError('DOCUMENT_CHANGED', '源文档内容与登记不一致', 409);
|
|
17
|
+
}
|
|
18
|
+
/** Store a private writable upload, or share a verified immutable document. */
|
|
19
|
+
export function storeSource(source, target, quota) {
|
|
20
|
+
if (Buffer.isBuffer(source)) {
|
|
21
|
+
quota.require(source.length);
|
|
22
|
+
writeFileSync(target, source, { flag: 'wx', flush: true });
|
|
23
|
+
return 'written';
|
|
24
|
+
}
|
|
25
|
+
verifySource(source);
|
|
26
|
+
return linkImmutable(source.path, target, () => quota.require(source.bytes));
|
|
27
|
+
}
|
|
28
|
+
export class DocumentStore {
|
|
29
|
+
data;
|
|
30
|
+
format;
|
|
31
|
+
retentionMs;
|
|
32
|
+
quota;
|
|
33
|
+
root;
|
|
34
|
+
storageWarnings = [];
|
|
35
|
+
timer;
|
|
36
|
+
staging;
|
|
37
|
+
contents = new Map();
|
|
38
|
+
constructor(data, format, retentionMs = DEFAULT_RETENTION_MS, maxStorageBytes = 0, quota = new StorageQuota(data, maxStorageBytes)) {
|
|
39
|
+
this.data = data;
|
|
40
|
+
this.format = format;
|
|
41
|
+
this.retentionMs = retentionMs;
|
|
42
|
+
this.quota = quota;
|
|
43
|
+
this.data = dataRoot(data);
|
|
44
|
+
this.root = path.join(this.data, '.documents');
|
|
45
|
+
mkdirSync(this.root, { recursive: true });
|
|
46
|
+
if (lstatSync(this.root).isSymbolicLink())
|
|
47
|
+
throw new StorageError('STORAGE_LINK', '源文档目录包含链接');
|
|
48
|
+
this.staging = new StagedDirectories(this.root, path.join(this.data, '.staging-documents'), 'document.json', (id, error) => this.warn(id, error));
|
|
49
|
+
this.staging.cleanup();
|
|
50
|
+
for (const id of readdirSync(this.root).filter((id) => idPattern.test(id))) {
|
|
51
|
+
try {
|
|
52
|
+
this.remember(this.read(id));
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.warn(id, error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.timer = setInterval(() => this.cleanup(), 60000);
|
|
59
|
+
this.timer.unref();
|
|
60
|
+
}
|
|
61
|
+
close() {
|
|
62
|
+
clearInterval(this.timer);
|
|
63
|
+
}
|
|
64
|
+
key(document) {
|
|
65
|
+
return document.sha256 + ':' + document.bytes;
|
|
66
|
+
}
|
|
67
|
+
remember(document) {
|
|
68
|
+
const key = this.key(document), ids = this.contents.get(key) ?? new Set();
|
|
69
|
+
ids.add(document.id);
|
|
70
|
+
this.contents.set(key, ids);
|
|
71
|
+
}
|
|
72
|
+
shared(document) {
|
|
73
|
+
const key = this.key(document), ids = this.contents.get(key);
|
|
74
|
+
for (const id of ids ?? []) {
|
|
75
|
+
try {
|
|
76
|
+
const stored = this.read(id);
|
|
77
|
+
if (this.key(stored) !== key)
|
|
78
|
+
throw new StorageError('DOCUMENT_CHANGED', '共享源文档内容与登记不一致', 409);
|
|
79
|
+
verifySource(stored);
|
|
80
|
+
return stored;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
ids.delete(id);
|
|
84
|
+
this.warn(id, error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (!ids?.size)
|
|
88
|
+
this.contents.delete(key);
|
|
89
|
+
}
|
|
90
|
+
read(id) {
|
|
91
|
+
const folder = path.join(this.root, checkedId(id)), file = path.join(folder, this.format.sourceName), receipt = path.join(folder, 'document.json');
|
|
92
|
+
if (!existsSync(receipt))
|
|
93
|
+
throw new StorageError('DOCUMENT_EXPIRED', '源文档已过期,请重新上传', 410);
|
|
94
|
+
if ([folder, file, receipt].some((p) => lstatSync(p).isSymbolicLink()) ||
|
|
95
|
+
!lstatSync(file).isFile())
|
|
96
|
+
throw new StorageError('STORAGE_LINK', '源文档路径包含链接');
|
|
97
|
+
const stored = JSON.parse(readFileSync(receipt, 'utf8'));
|
|
98
|
+
if (stored.id !== id ||
|
|
99
|
+
stored.bytes !== lstatSync(file).size ||
|
|
100
|
+
!/^[a-f0-9]{64}$/.test(stored.sha256))
|
|
101
|
+
throw new StorageError('DOCUMENT_CHANGED', '源文档登记不一致');
|
|
102
|
+
stored.path = file;
|
|
103
|
+
return stored;
|
|
104
|
+
}
|
|
105
|
+
get(id) {
|
|
106
|
+
const stored = this.read(id);
|
|
107
|
+
stored.accessedAt = Date.now();
|
|
108
|
+
atomicJson(path.join(this.root, id, 'document.json'), stored);
|
|
109
|
+
return stored;
|
|
110
|
+
}
|
|
111
|
+
async upload(stream, fileName = this.format.defaultName) {
|
|
112
|
+
if (!this.format.fileName.test(fileName))
|
|
113
|
+
throw new StorageError('INPUT_NAME', '请提供支持格式的源文件名');
|
|
114
|
+
const id = randomUUID(), folder = path.join(this.root, id), file = path.join(folder, this.format.sourceName);
|
|
115
|
+
const stage = this.staging.begin(id), reservation = this.quota.upload(file);
|
|
116
|
+
let bytes = 0, prefix = Buffer.alloc(0);
|
|
117
|
+
const digest = createHash('sha256');
|
|
118
|
+
const inputBytes = this.format.inputBytes;
|
|
119
|
+
const counter = new Transform({
|
|
120
|
+
transform(chunk, _encoding, callback) {
|
|
121
|
+
bytes += chunk.length;
|
|
122
|
+
if (bytes > inputBytes)
|
|
123
|
+
return callback(new StorageError('INPUT_SIZE', '源文件超过单文件大小上限', 413));
|
|
124
|
+
try {
|
|
125
|
+
reservation.ensure(bytes);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
return callback(error);
|
|
129
|
+
}
|
|
130
|
+
if (prefix.length < 1024)
|
|
131
|
+
prefix = Buffer.concat([prefix, chunk.subarray(0, 1024 - prefix.length)]);
|
|
132
|
+
digest.update(chunk);
|
|
133
|
+
callback(null, chunk);
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
try {
|
|
137
|
+
await pipeline(stream, counter, createWriteStream(file, { flags: 'wx', flush: true }));
|
|
138
|
+
if (!bytes || (this.format.validPrefix && !this.format.validPrefix(prefix)))
|
|
139
|
+
throw new StorageError('INPUT_FORMAT', '请选择有效的源文件');
|
|
140
|
+
const stored = {
|
|
141
|
+
id,
|
|
142
|
+
path: file,
|
|
143
|
+
bytes,
|
|
144
|
+
sha256: digest.digest('hex'),
|
|
145
|
+
fileName,
|
|
146
|
+
accessedAt: Date.now(),
|
|
147
|
+
};
|
|
148
|
+
reservation.release();
|
|
149
|
+
const shared = this.shared(stored);
|
|
150
|
+
if (shared) {
|
|
151
|
+
// Keep the independently verified upload until the shared/copy target
|
|
152
|
+
// exists. StagedDirectories owns both paths until the receipt commits.
|
|
153
|
+
const uploaded = path.join(folder, 'upload.part');
|
|
154
|
+
renameSync(file, uploaded);
|
|
155
|
+
linkImmutable(shared.path, file, () => this.quota.require(shared.bytes));
|
|
156
|
+
rmSync(uploaded);
|
|
157
|
+
}
|
|
158
|
+
this.quota.require(Buffer.byteLength(JSON.stringify(stored, null, 2) + '\n'));
|
|
159
|
+
atomicJson(path.join(folder, 'document.json'), stored);
|
|
160
|
+
stage.commit();
|
|
161
|
+
this.remember(stored);
|
|
162
|
+
return stored;
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
reservation.release();
|
|
166
|
+
stage.close();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
cleanup(now = Date.now()) {
|
|
170
|
+
this.staging.cleanup();
|
|
171
|
+
let entries;
|
|
172
|
+
try {
|
|
173
|
+
entries = readdirSync(this.root);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
this.warn('.', error);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
for (const id of entries) {
|
|
180
|
+
if (!idPattern.test(id))
|
|
181
|
+
continue;
|
|
182
|
+
const folder = path.join(this.root, id), receipt = path.join(folder, 'document.json');
|
|
183
|
+
try {
|
|
184
|
+
if (lstatSync(folder).isSymbolicLink() ||
|
|
185
|
+
!existsSync(receipt) ||
|
|
186
|
+
lstatSync(receipt).isSymbolicLink())
|
|
187
|
+
continue;
|
|
188
|
+
const value = JSON.parse(readFileSync(receipt, 'utf8'));
|
|
189
|
+
if (value.id === id &&
|
|
190
|
+
Number.isFinite(value.accessedAt) &&
|
|
191
|
+
now - value.accessedAt > this.retentionMs &&
|
|
192
|
+
path.dirname(folder) === this.root) {
|
|
193
|
+
removeJob(this.root, id);
|
|
194
|
+
const key = this.key(value), ids = this.contents.get(key);
|
|
195
|
+
ids?.delete(id);
|
|
196
|
+
if (!ids?.size)
|
|
197
|
+
this.contents.delete(key);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
this.warn(id, error);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
warn(directory, error) {
|
|
206
|
+
const message = String(error);
|
|
207
|
+
if (!this.storageWarnings.some((w) => w.directory === directory && w.message === message))
|
|
208
|
+
this.storageWarnings.push({ directory, message });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class DownloadLeases {
|
|
2
|
+
private counts;
|
|
3
|
+
has(id: string): boolean;
|
|
4
|
+
hold(id: string): () => void;
|
|
5
|
+
}
|
|
6
|
+
/** The lease spans hash verification and streaming; both use the same open file. */
|
|
7
|
+
export declare function artifactStream(folder: string, name: string, receipt: {
|
|
8
|
+
bytes: number;
|
|
9
|
+
sha256: string;
|
|
10
|
+
}, release: () => void): Promise<import("fs").ReadStream>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstatSync } from 'node:fs';
|
|
3
|
+
import { open } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { StorageError } from "./files.js";
|
|
6
|
+
export class DownloadLeases {
|
|
7
|
+
counts = new Map();
|
|
8
|
+
has(id) {
|
|
9
|
+
return this.counts.has(id);
|
|
10
|
+
}
|
|
11
|
+
hold(id) {
|
|
12
|
+
this.counts.set(id, (this.counts.get(id) ?? 0) + 1);
|
|
13
|
+
let released = false;
|
|
14
|
+
return () => {
|
|
15
|
+
if (released)
|
|
16
|
+
return;
|
|
17
|
+
released = true;
|
|
18
|
+
const remaining = this.counts.get(id) - 1;
|
|
19
|
+
if (remaining)
|
|
20
|
+
this.counts.set(id, remaining);
|
|
21
|
+
else
|
|
22
|
+
this.counts.delete(id);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The lease spans hash verification and streaming; both use the same open file. */
|
|
27
|
+
export async function artifactStream(folder, name, receipt, release) {
|
|
28
|
+
let handle;
|
|
29
|
+
try {
|
|
30
|
+
const file = path.resolve(folder, name);
|
|
31
|
+
if (path.dirname(file) !== path.resolve(folder) ||
|
|
32
|
+
lstatSync(folder).isSymbolicLink() ||
|
|
33
|
+
lstatSync(file).isSymbolicLink() ||
|
|
34
|
+
!lstatSync(file).isFile())
|
|
35
|
+
throw new StorageError('ARTIFACT_CHANGED', '成果路径发生变化');
|
|
36
|
+
handle = await open(file, 'r');
|
|
37
|
+
const digest = createHash('sha256');
|
|
38
|
+
let size = 0;
|
|
39
|
+
for await (const chunk of handle.createReadStream({ autoClose: false })) {
|
|
40
|
+
size += chunk.length;
|
|
41
|
+
digest.update(chunk);
|
|
42
|
+
}
|
|
43
|
+
if (size !== receipt.bytes || digest.digest('hex') !== receipt.sha256)
|
|
44
|
+
throw new StorageError('ARTIFACT_CHANGED', '成果与登记哈希不一致');
|
|
45
|
+
const stream = handle.createReadStream({ start: 0, autoClose: true });
|
|
46
|
+
stream.once('close', release);
|
|
47
|
+
return stream;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
try {
|
|
51
|
+
await handle?.close();
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
release();
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { containedPath } from '../../contracts/src/paths.js';
|
|
2
|
+
export declare class StorageError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly statusCode: number;
|
|
5
|
+
constructor(code: string, message: string, statusCode?: number);
|
|
6
|
+
}
|
|
7
|
+
export declare const idPattern: RegExp;
|
|
8
|
+
export declare function checkedId(value: unknown): string;
|
|
9
|
+
export declare const hash: (bytes: Uint8Array | string) => string;
|
|
10
|
+
export declare function fileHash(file: string): string;
|
|
11
|
+
/** Only published, immutable content may share a file identity. */
|
|
12
|
+
export declare function linkImmutable(source: string, target: string, beforeCopy?: () => void): "shared" | "copied";
|
|
13
|
+
export declare function atomicJson(file: string, value: unknown): void;
|
|
14
|
+
export declare function dataRoot(directory: string): string;
|
|
15
|
+
/** Validate every descendant before measuring or deleting owned storage. */
|
|
16
|
+
export declare function directoryBytes(directory: string, allowMissing?: boolean): number;
|
|
17
|
+
export declare function removeJob(data: string, id: string): void;
|
|
18
|
+
export declare function canonical(value: any): any;
|