@synopackageland/cli 0.3.10 → 0.4.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 +20 -9
- package/dist/bin.js +1 -2
- package/dist/build-spk/generator.d.ts +0 -3
- package/dist/build-spk/generator.js +135 -287
- package/dist/build-spk/native-lifecycle.js +0 -3
- package/dist/build-spk/native-payload.js +0 -1
- package/dist/cli.js +171 -151
- package/dist/compose/analyze.d.ts +1 -2
- package/dist/compose/analyze.js +5 -48
- package/dist/contract/unsupported-types.d.ts +10 -0
- package/dist/contract/unsupported-types.js +49 -0
- package/dist/contract/validate.js +25 -2
- package/dist/contract/web-launch.js +0 -2
- package/dist/deploy/deploy.d.ts +1 -4
- package/dist/deploy/deploy.js +45 -156
- package/dist/deploy/homes-values.js +1 -1
- package/dist/deploy/plan.d.ts +18 -0
- package/dist/deploy/plan.js +54 -0
- package/dist/deploy/spk-version.d.ts +2 -14
- package/dist/deploy/spk-version.js +25 -111
- package/dist/dev.d.ts +1 -3
- package/dist/dev.js +14 -28
- package/dist/error-registry.js +810 -862
- package/dist/host/dsm-client.js +12 -272
- package/dist/host/dsm-port-profile.d.ts +0 -1
- package/dist/host/dsm-port-profile.js +0 -2
- package/dist/host/types.d.ts +1 -83
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -6
- package/dist/info.d.ts +0 -1
- package/dist/info.js +3 -10
- package/dist/init.d.ts +11 -1
- package/dist/init.js +112 -4
- package/dist/log.js +2 -3
- package/dist/native/validate.js +0 -1
- package/dist/standalone/binary.d.ts +9 -0
- package/dist/standalone/binary.js +67 -0
- package/dist/standalone/build.d.ts +25 -0
- package/dist/standalone/build.js +108 -0
- package/dist/standalone/dsm-window.d.ts +26 -0
- package/dist/standalone/dsm-window.js +251 -0
- package/dist/standalone/helper.d.ts +31 -0
- package/dist/standalone/helper.js +104 -0
- package/dist/standalone/i18n.d.ts +28 -0
- package/dist/standalone/i18n.js +161 -0
- package/dist/standalone/inspect-spk.d.ts +21 -0
- package/dist/standalone/inspect-spk.js +160 -0
- package/dist/standalone/manifest.d.ts +71 -0
- package/dist/standalone/manifest.js +276 -0
- package/dist/standalone/root-messages.d.ts +7 -0
- package/dist/standalone/root-messages.js +250 -0
- package/dist/standalone/root-ops.d.ts +42 -0
- package/dist/standalone/root-ops.js +101 -0
- package/dist/standalone/root-window.d.ts +35 -0
- package/dist/standalone/root-window.js +290 -0
- package/dist/standalone/spk.d.ts +22 -0
- package/dist/standalone/spk.js +205 -0
- package/dist/templates/binary/synology-app.yaml +7 -0
- package/dist/templates/hello-files/compose.yaml +0 -1
- package/dist/templates/hello-web/compose.yaml +13 -10
- package/dist/templates/hello-web/html/app.js +1 -23
- package/dist/templates/hello-web/html/index.html +1 -3
- package/dist/templates/hello-web-page/compose.yaml +13 -10
- package/dist/templates/hello-web-page/html/app.js +1 -23
- package/dist/templates/hello-web-page/html/index.html +1 -3
- package/dist/templates/native-go/README.md +268 -0
- package/dist/templates/native-go/backend/cmd/app/main.go +49 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/dist/templates/native-go/backend/go.mod +3 -0
- package/dist/templates/native-go/backend/internal/api/errors.go +33 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +94 -0
- package/dist/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/dist/templates/native-go/backend/internal/api/server.go +155 -0
- package/dist/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +127 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +167 -0
- package/dist/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/dist/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +219 -0
- package/dist/templates/native-go/backend/internal/helper/control_test.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +167 -0
- package/dist/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/status_test.go +205 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +84 -0
- package/dist/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +192 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +302 -0
- package/dist/templates/native-go/dsm-package.yaml +58 -0
- package/dist/templates/native-go/gitignore +1 -0
- package/dist/templates/native-go/i18n/glossary.json +662 -0
- package/dist/templates/native-go/i18n/messages/de.json +28 -0
- package/dist/templates/native-go/i18n/messages/en.json +28 -0
- package/dist/templates/native-go/i18n/messages/es.json +28 -0
- package/dist/templates/native-go/i18n/messages/fr.json +28 -0
- package/dist/templates/native-go/i18n/messages/it.json +28 -0
- package/dist/templates/native-go/i18n/messages/ja.json +28 -0
- package/dist/templates/native-go/i18n/messages/ko.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/dist/templates/native-go/ui/app.css +35 -0
- package/dist/templates/native-go/ui/app.js +94 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/dist/templates/native-go-better-auth/node/app.mjs +72 -0
- package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
- package/dist/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/dist/templates/native-go-better-auth/node/package.json +1 -0
- package/dist/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/dist/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/dist/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/dist/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/dist/templates/native-go-root/root/whoami.sh +6 -0
- package/dist/templates/native-go-vue/README.md +110 -0
- package/dist/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +2507 -0
- package/dist/templates/native-go-vue/frontend/package.json +6 -0
- package/dist/templates/native-go-vue/frontend/src/App.vue +132 -0
- package/dist/templates/native-go-vue/frontend/src/context.ts +17 -0
- package/dist/templates/native-go-vue/frontend/src/main.ts +26 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +14 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +148 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +8 -0
- package/dist/templates/native-go-vue/gitignore +2 -0
- package/dist/types.d.ts +1 -1
- package/dist/validate.js +11 -7
- package/package.json +3 -7
- package/schema/synology-app.schema.json +36 -37
- package/skills/SKILL.md +4 -48
- package/skills/reference/create.md +11 -83
- package/skills/reference/deploy.md +7 -78
- package/skills/reference/diagnose.md +4 -101
- package/skills/reference/files.md +5 -41
- package/skills/reference/identity.md +3 -29
- package/skills/reference/wrap.md +0 -2
- package/templates/binary/synology-app.yaml +7 -0
- package/templates/hello-files/compose.yaml +0 -1
- package/templates/hello-web/compose.yaml +13 -10
- package/templates/hello-web/html/app.js +1 -23
- package/templates/hello-web/html/index.html +1 -3
- package/templates/hello-web-page/compose.yaml +13 -10
- package/templates/hello-web-page/html/app.js +1 -23
- package/templates/hello-web-page/html/index.html +1 -3
- package/templates/native-go/README.md +268 -0
- package/templates/native-go/backend/cmd/app/main.go +49 -0
- package/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/templates/native-go/backend/go.mod +3 -0
- package/templates/native-go/backend/internal/api/errors.go +33 -0
- package/templates/native-go/backend/internal/api/registry.go +94 -0
- package/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/templates/native-go/backend/internal/api/server.go +155 -0
- package/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/templates/native-go/backend/internal/app/routes.go +127 -0
- package/templates/native-go/backend/internal/app/routes_test.go +167 -0
- package/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/templates/native-go/backend/internal/helper/control.go +219 -0
- package/templates/native-go/backend/internal/helper/control_test.go +242 -0
- package/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +167 -0
- package/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +83 -0
- package/templates/native-go/backend/internal/helper/status.go +271 -0
- package/templates/native-go/backend/internal/helper/status_test.go +205 -0
- package/templates/native-go/backend/internal/helper/supervision.go +84 -0
- package/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +192 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +302 -0
- package/templates/native-go/dsm-package.yaml +58 -0
- package/templates/native-go/gitignore +1 -0
- package/templates/native-go/i18n/glossary.json +662 -0
- package/templates/native-go/i18n/messages/de.json +28 -0
- package/templates/native-go/i18n/messages/en.json +28 -0
- package/templates/native-go/i18n/messages/es.json +28 -0
- package/templates/native-go/i18n/messages/fr.json +28 -0
- package/templates/native-go/i18n/messages/it.json +28 -0
- package/templates/native-go/i18n/messages/ja.json +28 -0
- package/templates/native-go/i18n/messages/ko.json +28 -0
- package/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/templates/native-go/ui/app.css +35 -0
- package/templates/native-go/ui/app.js +94 -0
- package/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/templates/native-go-better-auth/node/app.mjs +72 -0
- package/templates/native-go-better-auth/node/build.mjs +2 -0
- package/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/templates/native-go-better-auth/node/package.json +1 -0
- package/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/templates/native-go-root/root/whoami.sh +6 -0
- package/templates/native-go-vue/README.md +110 -0
- package/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/templates/native-go-vue/frontend/package-lock.json +2507 -0
- package/templates/native-go-vue/frontend/package.json +6 -0
- package/templates/native-go-vue/frontend/src/App.vue +132 -0
- package/templates/native-go-vue/frontend/src/context.ts +17 -0
- package/templates/native-go-vue/frontend/src/main.ts +26 -0
- package/templates/native-go-vue/frontend/src/style.css +14 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +148 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/templates/native-go-vue/frontend/vite.config.ts +8 -0
- package/templates/native-go-vue/gitignore +2 -0
- package/dist/attestation/app-package.d.ts +0 -86
- package/dist/attestation/app-package.js +0 -206
- package/dist/attestation/install-on-host.d.ts +0 -14
- package/dist/attestation/install-on-host.js +0 -52
- package/dist/attestation/keyring.d.ts +0 -21
- package/dist/attestation/keyring.js +0 -168
- package/dist/attestation/platform-service.d.ts +0 -70
- package/dist/attestation/platform-service.js +0 -250
- package/dist/build-spk/broker-glue.d.ts +0 -16
- package/dist/build-spk/broker-glue.js +0 -40
- package/dist/deploy/catalog-publish.d.ts +0 -3
- package/dist/deploy/catalog-publish.js +0 -7
- package/dist/doctor.d.ts +0 -22
- package/dist/doctor.js +0 -822
- package/dist/error-collector.d.ts +0 -2
- package/dist/error-collector.js +0 -46
- package/dist/host/broker-paths.d.ts +0 -1
- package/dist/host/broker-paths.js +0 -1
- package/dist/host/broker-upgrade-preflight.d.ts +0 -61
- package/dist/host/broker-upgrade-preflight.js +0 -156
- package/dist/host/digests.d.ts +0 -5
- package/dist/host/digests.js +0 -63
- package/dist/host/fake-nas.d.ts +0 -49
- package/dist/host/fake-nas.js +0 -193
- package/dist/mock-broker/bootstrap.d.ts +0 -2
- package/dist/mock-broker/bootstrap.js +0 -8
- package/dist/mock-broker/files.d.ts +0 -60
- package/dist/mock-broker/files.js +0 -408
- package/dist/mock-broker/oidc.d.ts +0 -31
- package/dist/mock-broker/oidc.js +0 -161
- package/dist/mock-broker/path.d.ts +0 -9
- package/dist/mock-broker/path.js +0 -50
- package/dist/mock-broker/server.d.ts +0 -19
- package/dist/mock-broker/server.js +0 -350
- package/dist/publish/build-ledger.d.ts +0 -22
- package/dist/publish/build-ledger.js +0 -26
- package/dist/publish/community-path.d.ts +0 -6
- package/dist/publish/community-path.js +0 -41
- package/dist/publish/curated-release.d.ts +0 -78
- package/dist/publish/curated-release.js +0 -883
- package/dist/publish/file-build-ledger.d.ts +0 -18
- package/dist/publish/file-build-ledger.js +0 -268
- package/dist/publish/github-pr.d.ts +0 -25
- package/dist/publish/github-pr.js +0 -85
- package/dist/publish/github-repo.d.ts +0 -8
- package/dist/publish/github-repo.js +0 -21
- package/dist/publish/platform-service-release.d.ts +0 -60
- package/dist/publish/platform-service-release.js +0 -333
- package/dist/publish/preflight.d.ts +0 -24
- package/dist/publish/preflight.js +0 -138
- package/dist/publish/publish.d.ts +0 -27
- package/dist/publish/publish.js +0 -136
- package/dist/publish/sync-definition.d.ts +0 -4
- package/dist/publish/sync-definition.js +0 -48
- package/dist/release-bin.d.ts +0 -2
- package/dist/release-bin.js +0 -23
- package/dist/templates/hello-web/html/sdk.js +0 -68
- package/dist/templates/hello-web-page/html/sdk.js +0 -68
- package/dist/templates/native/synology-app.yaml +0 -7
- package/dist/test-host.d.ts +0 -15
- package/dist/test-host.js +0 -37
- package/templates/hello-web/html/sdk.js +0 -68
- package/templates/hello-web-page/html/sdk.js +0 -68
- package/templates/native/synology-app.yaml +0 -7
- /package/dist/templates/{native → binary}/native.yaml +0 -0
- /package/templates/{native → binary}/native.yaml +0 -0
package/dist/error-collector.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { ERROR_REGISTRY } from "../src/error-registry.js";
|
|
4
|
-
function getAllTsFiles(dir, excludeDirs = []) {
|
|
5
|
-
const files = [];
|
|
6
|
-
for (const entry of readdirSync(dir)) {
|
|
7
|
-
const fullPath = join(dir, entry);
|
|
8
|
-
if (statSync(fullPath).isDirectory()) {
|
|
9
|
-
if (!excludeDirs.includes(entry)) {
|
|
10
|
-
files.push(...getAllTsFiles(fullPath, excludeDirs));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
else if (fullPath.endsWith(".ts")) {
|
|
14
|
-
files.push(fullPath);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return files;
|
|
18
|
-
}
|
|
19
|
-
export function extractReferencedErrorCodes(srcDirectory) {
|
|
20
|
-
const tsFiles = getAllTsFiles(srcDirectory, ["mock-broker"]).filter((f) => !f.endsWith("error-registry.ts"));
|
|
21
|
-
const referenced = new Set();
|
|
22
|
-
for (const file of tsFiles) {
|
|
23
|
-
const content = readFileSync(file, "utf8");
|
|
24
|
-
for (const code of Object.keys(ERROR_REGISTRY)) {
|
|
25
|
-
// Check if `code` appears as a string literal or identifier in the file
|
|
26
|
-
if (content.includes(`"${code}"`) || content.includes(`'${code}'`) || content.includes(`\`${code}\``)) {
|
|
27
|
-
referenced.add(code);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return referenced;
|
|
32
|
-
}
|
|
33
|
-
export function extractAllStringLiterals(srcDirectory) {
|
|
34
|
-
const tsFiles = getAllTsFiles(srcDirectory, ["mock-broker"]).filter((f) => !f.endsWith("error-registry.ts"));
|
|
35
|
-
const literals = new Set();
|
|
36
|
-
const codeRegex = /["']([A-Z][A-Z0-9_]{2,})["']/g;
|
|
37
|
-
for (const file of tsFiles) {
|
|
38
|
-
const content = readFileSync(file, "utf8");
|
|
39
|
-
codeRegex.lastIndex = 0;
|
|
40
|
-
let match;
|
|
41
|
-
while ((match = codeRegex.exec(content)) !== null) {
|
|
42
|
-
literals.add(match[1]);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return literals;
|
|
46
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const IDENTITY_CGI_PATH = "/webman/3rdparty/SynoPkgLandService/index.cgi";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const IDENTITY_CGI_PATH = "/webman/3rdparty/SynoPkgLandService/index.cgi";
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export declare const BROKER_UPGRADE_TARGET_HOST = "10.17.83.200";
|
|
2
|
-
export type DsmUpgradeResponseKind = "error-4552" | "success" | "consent" | "unknown";
|
|
3
|
-
export interface ConsentDialogEvidence {
|
|
4
|
-
consentDialog: {
|
|
5
|
-
dependers: string[];
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
export interface BrokerUpgradeDependerBaseline {
|
|
9
|
-
packageIdentity: string;
|
|
10
|
-
version: string;
|
|
11
|
-
status: string;
|
|
12
|
-
running: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface BrokerUpgradeDepender extends BrokerUpgradeDependerBaseline {
|
|
15
|
-
healthCheckOk: boolean;
|
|
16
|
-
a23Classified: boolean;
|
|
17
|
-
dataSnapshotOk: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface BrokerUpgradePreflightInput {
|
|
20
|
-
targetHost: string;
|
|
21
|
-
broker: {
|
|
22
|
-
version: string;
|
|
23
|
-
status: string;
|
|
24
|
-
running: boolean;
|
|
25
|
-
};
|
|
26
|
-
dependers: BrokerUpgradeDepender[];
|
|
27
|
-
previousSpk: {
|
|
28
|
-
available: boolean;
|
|
29
|
-
sha256?: string;
|
|
30
|
-
};
|
|
31
|
-
canonicalizeGateSatisfied: boolean;
|
|
32
|
-
catalogEntry: {
|
|
33
|
-
version: string;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export type PreflightDecision = {
|
|
37
|
-
ok: true;
|
|
38
|
-
} | {
|
|
39
|
-
ok: false;
|
|
40
|
-
codes: string[];
|
|
41
|
-
};
|
|
42
|
-
export interface Evaluate4552BranchInput {
|
|
43
|
-
response: unknown;
|
|
44
|
-
dependers: BrokerUpgradeDependerBaseline[];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Classify only already-parsed DSM evidence. Strings are deliberately never
|
|
48
|
-
* parsed or searched: a textual mention of 4552 is not a DSM error response.
|
|
49
|
-
*/
|
|
50
|
-
export declare function classifyDsmUpgradeResponse(raw: unknown): DsmUpgradeResponseKind;
|
|
51
|
-
/**
|
|
52
|
-
* Evaluate every local prerequisite without performing an upgrade or
|
|
53
|
-
* proposing a stop/start action. A missing or malformed prerequisite is a
|
|
54
|
-
* failure, even when another part of the input looks healthy.
|
|
55
|
-
*/
|
|
56
|
-
export declare function evaluateBrokerUpgradePreflight(input: BrokerUpgradePreflightInput): PreflightDecision;
|
|
57
|
-
/**
|
|
58
|
-
* The 4552 path is entered only for a numeric DSM error and a non-empty,
|
|
59
|
-
* fully identified running baseline inventory.
|
|
60
|
-
*/
|
|
61
|
-
export declare function evaluate4552Branch(input: Evaluate4552BranchInput): PreflightDecision;
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { comparePackageVersions } from "@synopackageland/package-source/index-manifest";
|
|
2
|
-
export const BROKER_UPGRADE_TARGET_HOST = "10.17.83.200";
|
|
3
|
-
/**
|
|
4
|
-
* Classify only already-parsed DSM evidence. Strings are deliberately never
|
|
5
|
-
* parsed or searched: a textual mention of 4552 is not a DSM error response.
|
|
6
|
-
*/
|
|
7
|
-
export function classifyDsmUpgradeResponse(raw) {
|
|
8
|
-
if (!isRecord(raw)) {
|
|
9
|
-
return "unknown";
|
|
10
|
-
}
|
|
11
|
-
if (isRecord(raw.error) && raw.error.code === 4552) {
|
|
12
|
-
return "error-4552";
|
|
13
|
-
}
|
|
14
|
-
const hasError = Object.prototype.hasOwnProperty.call(raw, "error") &&
|
|
15
|
-
raw.error !== null &&
|
|
16
|
-
raw.error !== undefined;
|
|
17
|
-
if (raw.success === true && !hasError) {
|
|
18
|
-
return "success";
|
|
19
|
-
}
|
|
20
|
-
if (isConsentDialogEvidence(raw)) {
|
|
21
|
-
return "consent";
|
|
22
|
-
}
|
|
23
|
-
return "unknown";
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Evaluate every local prerequisite without performing an upgrade or
|
|
27
|
-
* proposing a stop/start action. A missing or malformed prerequisite is a
|
|
28
|
-
* failure, even when another part of the input looks healthy.
|
|
29
|
-
*/
|
|
30
|
-
export function evaluateBrokerUpgradePreflight(input) {
|
|
31
|
-
const candidate = isRecord(input) ? input : {};
|
|
32
|
-
const codes = [];
|
|
33
|
-
const addCode = (code) => {
|
|
34
|
-
if (!codes.includes(code)) {
|
|
35
|
-
codes.push(code);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
if (candidate.targetHost !== BROKER_UPGRADE_TARGET_HOST) {
|
|
39
|
-
addCode("PREFLIGHT_WRONG_TARGET");
|
|
40
|
-
}
|
|
41
|
-
const broker = candidate.broker;
|
|
42
|
-
if (!isRecord(broker)) {
|
|
43
|
-
addCode("PREFLIGHT_BROKER_NOT_RUNNING");
|
|
44
|
-
addCode("PREFLIGHT_BROKER_VERSION_INVALID");
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
if (broker.running !== true || broker.status !== "running") {
|
|
48
|
-
addCode("PREFLIGHT_BROKER_NOT_RUNNING");
|
|
49
|
-
}
|
|
50
|
-
if (!isNonEmptyString(broker.version)) {
|
|
51
|
-
addCode("PREFLIGHT_BROKER_VERSION_INVALID");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const dependers = candidate.dependers;
|
|
55
|
-
if (!Array.isArray(dependers)) {
|
|
56
|
-
addCode("PREFLIGHT_DEPENDER_INVENTORY_INVALID");
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
for (const depender of dependers) {
|
|
60
|
-
if (!isRecord(depender)) {
|
|
61
|
-
addCode("PREFLIGHT_DEPENDER_INVENTORY_INVALID");
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (!isNonEmptyString(depender.packageIdentity) || !isNonEmptyString(depender.version)) {
|
|
65
|
-
addCode("PREFLIGHT_DEPENDER_INVENTORY_INVALID");
|
|
66
|
-
}
|
|
67
|
-
if (depender.running !== true) {
|
|
68
|
-
addCode("PREFLIGHT_DEPENDER_NOT_RUNNING");
|
|
69
|
-
}
|
|
70
|
-
if (depender.status !== "running") {
|
|
71
|
-
addCode("PREFLIGHT_DEPENDER_UNSAFE_STATUS");
|
|
72
|
-
}
|
|
73
|
-
if (depender.healthCheckOk !== true) {
|
|
74
|
-
addCode("PREFLIGHT_DEPENDER_HEALTHCHECK_FAILED");
|
|
75
|
-
}
|
|
76
|
-
if (depender.a23Classified !== true) {
|
|
77
|
-
addCode("PREFLIGHT_DEPENDER_A23_UNCLASSIFIED");
|
|
78
|
-
}
|
|
79
|
-
if (depender.dataSnapshotOk !== true) {
|
|
80
|
-
addCode("PREFLIGHT_DEPENDER_DATA_SNAPSHOT_MISSING");
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const previousSpk = candidate.previousSpk;
|
|
85
|
-
if (!isRecord(previousSpk) || previousSpk.available !== true) {
|
|
86
|
-
addCode("PREFLIGHT_PREVIOUS_SPK_UNAVAILABLE");
|
|
87
|
-
}
|
|
88
|
-
else if (!isSha256(previousSpk.sha256)) {
|
|
89
|
-
addCode("PREFLIGHT_PREVIOUS_SPK_DIGEST_INVALID");
|
|
90
|
-
}
|
|
91
|
-
if (candidate.canonicalizeGateSatisfied !== true) {
|
|
92
|
-
addCode("PREFLIGHT_CANONICALIZE_GATE_UNSATISFIED");
|
|
93
|
-
}
|
|
94
|
-
const catalogEntry = candidate.catalogEntry;
|
|
95
|
-
if (!isRecord(catalogEntry) || !isNonEmptyString(catalogEntry.version)) {
|
|
96
|
-
addCode("PREFLIGHT_CATALOG_VERSION_INVALID");
|
|
97
|
-
}
|
|
98
|
-
else if (!isRecord(broker) || !isNonEmptyString(broker.version)) {
|
|
99
|
-
// The broker version gate is already reported above; without both version
|
|
100
|
-
// strings there is no safe comparison to perform.
|
|
101
|
-
addCode("PREFLIGHT_VERSION_COMPARISON_INVALID");
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
const comparison = comparePackageVersions(catalogEntry.version, broker.version);
|
|
105
|
-
if (!Number.isFinite(comparison)) {
|
|
106
|
-
addCode("PREFLIGHT_VERSION_COMPARISON_INVALID");
|
|
107
|
-
}
|
|
108
|
-
else if (comparison <= 0) {
|
|
109
|
-
addCode("PREFLIGHT_CATALOG_VERSION_NOT_NEWER");
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return decisionFromCodes(codes);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The 4552 path is entered only for a numeric DSM error and a non-empty,
|
|
116
|
-
* fully identified running baseline inventory.
|
|
117
|
-
*/
|
|
118
|
-
export function evaluate4552Branch(input) {
|
|
119
|
-
const candidate = isRecord(input) ? input : {};
|
|
120
|
-
const codes = [];
|
|
121
|
-
if (classifyDsmUpgradeResponse(candidate.response) !== "error-4552") {
|
|
122
|
-
codes.push("PREFLIGHT_RESPONSE_NOT_4552");
|
|
123
|
-
}
|
|
124
|
-
const dependers = candidate.dependers;
|
|
125
|
-
if (!Array.isArray(dependers) ||
|
|
126
|
-
dependers.length === 0 ||
|
|
127
|
-
dependers.some((depender) => !isRunningBaseline(depender))) {
|
|
128
|
-
codes.push("PREFLIGHT_DEPENDER_INVENTORY_INCOMPLETE");
|
|
129
|
-
}
|
|
130
|
-
return decisionFromCodes(codes);
|
|
131
|
-
}
|
|
132
|
-
function decisionFromCodes(codes) {
|
|
133
|
-
return codes.length === 0 ? { ok: true } : { ok: false, codes };
|
|
134
|
-
}
|
|
135
|
-
function isRunningBaseline(value) {
|
|
136
|
-
return (isRecord(value) &&
|
|
137
|
-
isNonEmptyString(value.packageIdentity) &&
|
|
138
|
-
isNonEmptyString(value.version) &&
|
|
139
|
-
value.status === "running" &&
|
|
140
|
-
value.running === true);
|
|
141
|
-
}
|
|
142
|
-
function isConsentDialogEvidence(value) {
|
|
143
|
-
const dialog = value.consentDialog;
|
|
144
|
-
return (isRecord(dialog) &&
|
|
145
|
-
Array.isArray(dialog.dependers) &&
|
|
146
|
-
dialog.dependers.every((depender) => typeof depender === "string"));
|
|
147
|
-
}
|
|
148
|
-
function isRecord(value) {
|
|
149
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
150
|
-
}
|
|
151
|
-
function isNonEmptyString(value) {
|
|
152
|
-
return typeof value === "string" && value.length > 0;
|
|
153
|
-
}
|
|
154
|
-
function isSha256(value) {
|
|
155
|
-
return typeof value === "string" && /^[0-9a-fA-F]{64}$/.test(value);
|
|
156
|
-
}
|
package/dist/host/digests.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ProjectRoot } from "../discovery.js";
|
|
2
|
-
export declare function digestString(value: string): string;
|
|
3
|
-
export declare function digestDirectory(root: string): string;
|
|
4
|
-
export declare function digestProjectContract(project: ProjectRoot): string;
|
|
5
|
-
export declare function digestProjectBundle(project: ProjectRoot): string;
|
package/dist/host/digests.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
export function digestString(value) {
|
|
6
|
-
return createHash("sha256").update(value).digest("hex");
|
|
7
|
-
}
|
|
8
|
-
export function digestDirectory(root) {
|
|
9
|
-
const hash = createHash("sha256");
|
|
10
|
-
for (const relative of walkFiles(root)) {
|
|
11
|
-
hash.update(relative);
|
|
12
|
-
hash.update("\0");
|
|
13
|
-
hash.update(readFileSync(join(root, relative)));
|
|
14
|
-
hash.update("\0");
|
|
15
|
-
}
|
|
16
|
-
return hash.digest("hex");
|
|
17
|
-
}
|
|
18
|
-
export function digestProjectContract(project) {
|
|
19
|
-
return digestString(readFileSync(project.contractPath, "utf8"));
|
|
20
|
-
}
|
|
21
|
-
export function digestProjectBundle(project) {
|
|
22
|
-
const staging = mkdtempSync(join(tmpdir(), "syno-bundle-digest-"));
|
|
23
|
-
try {
|
|
24
|
-
const packageDir = join(staging, "package");
|
|
25
|
-
mkdirSync(packageDir, { recursive: true });
|
|
26
|
-
// Runtime members are whichever of the two exist; validate already refuses
|
|
27
|
-
// a project that has both or neither. The Broker computes the same set
|
|
28
|
-
// (packages/broker/src/digest.ts), so the two digests have to agree.
|
|
29
|
-
if (existsSync(project.composePath)) {
|
|
30
|
-
cpSync(project.composePath, join(packageDir, "compose.yaml"));
|
|
31
|
-
}
|
|
32
|
-
if (project.nativePath && existsSync(project.nativePath)) {
|
|
33
|
-
cpSync(project.nativePath, join(packageDir, "native.yaml"));
|
|
34
|
-
}
|
|
35
|
-
cpSync(project.contractPath, join(packageDir, "synology-app.yaml"));
|
|
36
|
-
const htmlDir = join(project.root, "html");
|
|
37
|
-
if (existsSync(htmlDir)) {
|
|
38
|
-
cpSync(htmlDir, join(packageDir, "html"), { recursive: true });
|
|
39
|
-
}
|
|
40
|
-
return digestDirectory(packageDir);
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
rmSync(staging, { recursive: true, force: true });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function walkFiles(root, prefix = "") {
|
|
47
|
-
const files = [];
|
|
48
|
-
for (const entry of readdirSync(root).sort(comparePosixPaths)) {
|
|
49
|
-
const relative = prefix ? `${prefix}/${entry}` : entry;
|
|
50
|
-
const absolute = join(root, entry);
|
|
51
|
-
const stat = statSync(absolute);
|
|
52
|
-
if (stat.isDirectory()) {
|
|
53
|
-
files.push(...walkFiles(absolute, relative));
|
|
54
|
-
}
|
|
55
|
-
else if (stat.isFile()) {
|
|
56
|
-
files.push(relative);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return files;
|
|
60
|
-
}
|
|
61
|
-
function comparePosixPaths(left, right) {
|
|
62
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
63
|
-
}
|
package/dist/host/fake-nas.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { SharePermissionRow } from "./share-permission.js";
|
|
2
|
-
import type { PortInfoEntry } from "./port-info.js";
|
|
3
|
-
import type { AttestationKind, HostInstallRecord, HostOidcCompatSettings, NasHost, PackageRoute } from "./types.js";
|
|
4
|
-
import type { DsmPortProfileInventory } from "./dsm-port-profile.js";
|
|
5
|
-
export type SharePermissionRowInput = {
|
|
6
|
-
name: string;
|
|
7
|
-
} & Partial<Omit<SharePermissionRow, "name">>;
|
|
8
|
-
export interface FakeNasHostOptions {
|
|
9
|
-
curated?: string[];
|
|
10
|
-
dsmOrigin?: string;
|
|
11
|
-
homesPath?: string;
|
|
12
|
-
installationId?: string;
|
|
13
|
-
shareNames?: string[];
|
|
14
|
-
shares?: Record<string, string>;
|
|
15
|
-
/**
|
|
16
|
-
* SYNO.Core.Share.Permission rows per Share, as partials -- every flag
|
|
17
|
-
* defaults to false, matching a row DSM grants nothing on. Omit the whole
|
|
18
|
-
* option to model a host that cannot answer the permission question.
|
|
19
|
-
*/
|
|
20
|
-
sharePermissions?: Record<string, {
|
|
21
|
-
users: SharePermissionRowInput[];
|
|
22
|
-
groups: SharePermissionRowInput[];
|
|
23
|
-
}>;
|
|
24
|
-
/** Group membership per DSM user, for share-permission resolution. */
|
|
25
|
-
userGroups?: Record<string, string[]>;
|
|
26
|
-
/** SYNO.Core.Service.PortInfo rows; omit to model a host without the capability. */
|
|
27
|
-
portInfo?: PortInfoEntry[];
|
|
28
|
-
/** Model a host whose PortInfo capability is present but the API failed. */
|
|
29
|
-
portInfoFailure?: boolean;
|
|
30
|
-
installedEnv?: Record<string, Record<string, string>>;
|
|
31
|
-
diagnostics?: {
|
|
32
|
-
dsmResidue?: import("./types.js").DsmResidueInventory;
|
|
33
|
-
packageRoute?: PackageRoute;
|
|
34
|
-
isPackageOnly?: boolean;
|
|
35
|
-
[key: string]: unknown;
|
|
36
|
-
};
|
|
37
|
-
/** Administrator-only DSM PortInfo inventory, when the fake should expose it. */
|
|
38
|
-
portProfileInventory?: DsmPortProfileInventory;
|
|
39
|
-
/** Omit to model an older Broker without the OIDC settings endpoint. */
|
|
40
|
-
oidcCompat?: HostOidcCompatSettings;
|
|
41
|
-
}
|
|
42
|
-
export declare function createFakeNasHost(options?: FakeNasHostOptions): NasHost & {
|
|
43
|
-
installs: HostInstallRecord[];
|
|
44
|
-
attestations: Set<string>;
|
|
45
|
-
attestationInfo(packageIdentity: string): {
|
|
46
|
-
attestationKind: AttestationKind;
|
|
47
|
-
} | undefined;
|
|
48
|
-
seedInstalled(packageIdentity: string): void;
|
|
49
|
-
};
|
package/dist/host/fake-nas.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { webStationAlias } from "../contract/web-launch.js";
|
|
2
|
-
function sharePermissionRow(input) {
|
|
3
|
-
return {
|
|
4
|
-
is_admin: false,
|
|
5
|
-
is_writable: false,
|
|
6
|
-
is_readonly: false,
|
|
7
|
-
is_deny: false,
|
|
8
|
-
is_custom: false,
|
|
9
|
-
...input,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function createFakeNasHost(options = {}) {
|
|
13
|
-
const dsmOrigin = options.dsmOrigin ?? "http://nas.example:5000";
|
|
14
|
-
const installationId = options.installationId ?? "fake-installation";
|
|
15
|
-
const curated = new Set(options.curated ?? []);
|
|
16
|
-
const installs = [];
|
|
17
|
-
const localAttestations = new Map();
|
|
18
|
-
const installed = new Set();
|
|
19
|
-
const openUrls = new Map();
|
|
20
|
-
const shares = { ...(options.shares ?? {}) };
|
|
21
|
-
const shareNames = options.shareNames
|
|
22
|
-
? [...options.shareNames]
|
|
23
|
-
: Object.keys(shares).length > 0
|
|
24
|
-
? Object.keys(shares)
|
|
25
|
-
: ["docker", "home", "photo"];
|
|
26
|
-
const installedEnv = Object.fromEntries(Object.entries(options.installedEnv ?? {}).map(([packageId, env]) => [packageId, { ...env }]));
|
|
27
|
-
const host = {
|
|
28
|
-
dsmOrigin,
|
|
29
|
-
installationId,
|
|
30
|
-
installs,
|
|
31
|
-
attestations: new Set(),
|
|
32
|
-
markCurated(packageIdentity) {
|
|
33
|
-
curated.add(packageIdentity);
|
|
34
|
-
localAttestations.set(packageIdentity, "app-package");
|
|
35
|
-
},
|
|
36
|
-
seedInstalled(packageIdentity) {
|
|
37
|
-
installed.add(packageIdentity);
|
|
38
|
-
},
|
|
39
|
-
async resolveSharePath(logicalName) {
|
|
40
|
-
return shares[logicalName];
|
|
41
|
-
},
|
|
42
|
-
async listShareNames() {
|
|
43
|
-
return [...shareNames];
|
|
44
|
-
},
|
|
45
|
-
...(options.sharePermissions
|
|
46
|
-
? {
|
|
47
|
-
async listSharePermissions(logicalName) {
|
|
48
|
-
const listing = options.sharePermissions?.[logicalName];
|
|
49
|
-
if (!listing) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
users: listing.users.map(sharePermissionRow),
|
|
54
|
-
groups: listing.groups.map(sharePermissionRow),
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
}
|
|
58
|
-
: {}),
|
|
59
|
-
...(options.userGroups
|
|
60
|
-
? {
|
|
61
|
-
async listUserGroups(userName) {
|
|
62
|
-
return options.userGroups?.[userName];
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
: {}),
|
|
66
|
-
...(options.portInfo !== undefined || options.portInfoFailure
|
|
67
|
-
? {
|
|
68
|
-
async listPortInfo() {
|
|
69
|
-
if (options.portInfoFailure) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
return options.portInfo?.map((entry) => ({
|
|
73
|
-
...entry,
|
|
74
|
-
dst_port: [...entry.dst_port],
|
|
75
|
-
...(entry.src_port === undefined
|
|
76
|
-
? {}
|
|
77
|
-
: { src_port: entry.src_port === null ? null : [...entry.src_port] }),
|
|
78
|
-
}));
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
: {}),
|
|
82
|
-
async resolveHomesPath() {
|
|
83
|
-
return options.homesPath;
|
|
84
|
-
},
|
|
85
|
-
async getInstalledProjectEnv(packageIdentity) {
|
|
86
|
-
const env = installedEnv[packageIdentity];
|
|
87
|
-
return env ? { ...env } : undefined;
|
|
88
|
-
},
|
|
89
|
-
attestationInfo(packageIdentity) {
|
|
90
|
-
const kind = localAttestations.get(packageIdentity) ?? (installed.has(packageIdentity) ? "local" : "none");
|
|
91
|
-
return kind === "none" ? undefined : { attestationKind: kind };
|
|
92
|
-
},
|
|
93
|
-
async requestAttestation(input) {
|
|
94
|
-
if (curated.has(input.packageIdentity) && !input.allowCuratedDowngrade) {
|
|
95
|
-
const error = new Error("Curated deploy refused");
|
|
96
|
-
error.code = "CURATED_DEPLOY_REFUSED";
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
if (curated.has(input.packageIdentity) && input.allowCuratedDowngrade) {
|
|
100
|
-
localAttestations.set(input.packageIdentity, "local");
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
localAttestations.set(input.packageIdentity, "local");
|
|
104
|
-
}
|
|
105
|
-
const digest = `${input.packageIdentity}:${input.bundleDigest}:${input.contractDigest}`;
|
|
106
|
-
host.attestations.add(input.packageIdentity);
|
|
107
|
-
return {
|
|
108
|
-
kind: "local",
|
|
109
|
-
attestationDigest: digest,
|
|
110
|
-
token: `fake-local-attestation.${input.packageIdentity}`,
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
async ensurePackageSource() { },
|
|
114
|
-
async installFromCatalog(input) {
|
|
115
|
-
installs.push({
|
|
116
|
-
packageId: input.packageId,
|
|
117
|
-
version: input.version,
|
|
118
|
-
source: "package-center",
|
|
119
|
-
extraValues: { ...(input.extraValues ?? {}) },
|
|
120
|
-
});
|
|
121
|
-
installed.add(input.packageId);
|
|
122
|
-
installedEnv[input.packageId] = {
|
|
123
|
-
...(installedEnv[input.packageId] ?? {}),
|
|
124
|
-
...(input.extraValues ?? {}),
|
|
125
|
-
};
|
|
126
|
-
openUrls.set(input.packageId, `${new URL(dsmOrigin).protocol}//${new URL(dsmOrigin).hostname}/${webStationAlias(input.packageId)}/`);
|
|
127
|
-
if (!localAttestations.has(input.packageId)) {
|
|
128
|
-
localAttestations.set(input.packageId, "local");
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
async installFromLocalSpk(input) {
|
|
132
|
-
installs.push({
|
|
133
|
-
packageId: input.packageId,
|
|
134
|
-
version: input.version,
|
|
135
|
-
source: "local-spk",
|
|
136
|
-
extraValues: { ...(input.extraValues ?? {}) },
|
|
137
|
-
});
|
|
138
|
-
installed.add(input.packageId);
|
|
139
|
-
installedEnv[input.packageId] = {
|
|
140
|
-
...(installedEnv[input.packageId] ?? {}),
|
|
141
|
-
...(input.extraValues ?? {}),
|
|
142
|
-
};
|
|
143
|
-
openUrls.set(input.packageId, `${new URL(dsmOrigin).protocol}//${new URL(dsmOrigin).hostname}/${webStationAlias(input.packageId)}/`);
|
|
144
|
-
if (!localAttestations.has(input.packageId)) {
|
|
145
|
-
localAttestations.set(input.packageId, "local");
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
async getInstalledPackageVersion(packageIdentity) {
|
|
149
|
-
const latest = [...installs].reverse().find((entry) => entry.packageId === packageIdentity);
|
|
150
|
-
return latest?.version;
|
|
151
|
-
},
|
|
152
|
-
async getAttestationInfo(packageIdentity) {
|
|
153
|
-
return {
|
|
154
|
-
packageIdentity,
|
|
155
|
-
attestationKind: localAttestations.get(packageIdentity) ?? (installed.has(packageIdentity) ? "local" : "none"),
|
|
156
|
-
developmentInstance: packageIdentity.endsWith(".dev"),
|
|
157
|
-
openUrl: openUrls.get(packageIdentity),
|
|
158
|
-
readiness: installed.has(packageIdentity) ? "RUNNING" : "NOT_INSTALLED",
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
async isPackageInstalled(packageIdentity) {
|
|
162
|
-
return installed.has(packageIdentity);
|
|
163
|
-
},
|
|
164
|
-
async fetchContainerLogs(packageIdentity) {
|
|
165
|
-
if (!installed.has(packageIdentity)) {
|
|
166
|
-
return [];
|
|
167
|
-
}
|
|
168
|
-
return [`[${packageIdentity}] container ready`];
|
|
169
|
-
},
|
|
170
|
-
async getDsmDiagnostics() {
|
|
171
|
-
return options.diagnostics;
|
|
172
|
-
},
|
|
173
|
-
async getDsmPortProfileInventory() {
|
|
174
|
-
return options.portProfileInventory;
|
|
175
|
-
},
|
|
176
|
-
async getOidcCompatSettings() {
|
|
177
|
-
if (!options.oidcCompat) {
|
|
178
|
-
return undefined;
|
|
179
|
-
}
|
|
180
|
-
return {
|
|
181
|
-
enabled: options.oidcCompat.enabled,
|
|
182
|
-
origin: { ...options.oidcCompat.origin },
|
|
183
|
-
};
|
|
184
|
-
},
|
|
185
|
-
async smokeRequireLogin() {
|
|
186
|
-
return { ok: true, username: "admin" };
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
for (const packageId of curated) {
|
|
190
|
-
localAttestations.set(packageId, "app-package");
|
|
191
|
-
}
|
|
192
|
-
return host;
|
|
193
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
-
export function writeMockBrokerBootstrap(projectRoot, bootstrap) {
|
|
4
|
-
const path = resolve(projectRoot, ".synopkgland", "mock-broker.json");
|
|
5
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
6
|
-
writeFileSync(path, `${JSON.stringify(bootstrap, null, 2)}\n`, "utf8");
|
|
7
|
-
return path;
|
|
8
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createReadStream } from "node:fs";
|
|
2
|
-
export interface FileItem {
|
|
3
|
-
name: string;
|
|
4
|
-
type: "file" | "directory";
|
|
5
|
-
path: string;
|
|
6
|
-
size?: number;
|
|
7
|
-
}
|
|
8
|
-
export declare class FileStoreError extends Error {
|
|
9
|
-
readonly code: string;
|
|
10
|
-
readonly status: number;
|
|
11
|
-
constructor(code: string, status: number, message: string);
|
|
12
|
-
}
|
|
13
|
-
export interface MockFileStoreOptions {
|
|
14
|
-
filesRoot?: string;
|
|
15
|
-
recycleBinDisabled?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface DownloadResult {
|
|
18
|
-
buffer?: Buffer;
|
|
19
|
-
stream?: ReturnType<typeof createReadStream>;
|
|
20
|
-
size: number;
|
|
21
|
-
totalSize: number;
|
|
22
|
-
}
|
|
23
|
-
export declare class MockFileStore {
|
|
24
|
-
private readonly filesRoot?;
|
|
25
|
-
private readonly recycleBinDisabled;
|
|
26
|
-
private readonly treeRoot;
|
|
27
|
-
constructor(options?: MockFileStoreOptions);
|
|
28
|
-
list(rawPath: string): FileItem[];
|
|
29
|
-
stat(rawPath: string): FileItem;
|
|
30
|
-
download(rawPath: string, range?: {
|
|
31
|
-
start: number;
|
|
32
|
-
end?: number;
|
|
33
|
-
}): DownloadResult;
|
|
34
|
-
upload(rawPath: string, body: Buffer, overwrite?: boolean): void;
|
|
35
|
-
mkdir(rawPath: string): void;
|
|
36
|
-
rename(rawPath: string, rawTo: string, overwrite?: boolean): void;
|
|
37
|
-
move(rawPath: string, rawTo: string, overwrite?: boolean): void;
|
|
38
|
-
copy(rawPath: string, rawTo: string, overwrite?: boolean): void;
|
|
39
|
-
trash(rawPath: string): void;
|
|
40
|
-
private resolveListPath;
|
|
41
|
-
private resolveOperationPath;
|
|
42
|
-
private listMemory;
|
|
43
|
-
private statMemory;
|
|
44
|
-
private downloadMemory;
|
|
45
|
-
private uploadMemory;
|
|
46
|
-
private mkdirMemory;
|
|
47
|
-
private moveMemory;
|
|
48
|
-
private copyMemory;
|
|
49
|
-
private trashMemory;
|
|
50
|
-
private listMapped;
|
|
51
|
-
private statMapped;
|
|
52
|
-
private downloadMapped;
|
|
53
|
-
private uploadMapped;
|
|
54
|
-
private mkdirMapped;
|
|
55
|
-
private moveMapped;
|
|
56
|
-
private copyMapped;
|
|
57
|
-
private trashMapped;
|
|
58
|
-
}
|
|
59
|
-
/** @deprecated Use MockFileStore.list instead */
|
|
60
|
-
export declare function listFakeFiles(path: string, filesRoot?: string): FileItem[];
|