@selvajs/local-provider 0.11.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/LICENSE +21 -0
- package/README.md +123 -0
- package/dist/auth/LocalAuthProvider.d.ts +28 -0
- package/dist/auth/LocalAuthProvider.d.ts.map +1 -0
- package/dist/auth/LocalAuthProvider.js +142 -0
- package/dist/auth/LocalAuthProvider.js.map +1 -0
- package/dist/auth/__tests__/conformance.test.d.ts +2 -0
- package/dist/auth/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/auth/__tests__/conformance.test.js +36 -0
- package/dist/auth/__tests__/conformance.test.js.map +1 -0
- package/dist/auth/hmac.d.ts +18 -0
- package/dist/auth/hmac.d.ts.map +1 -0
- package/dist/auth/hmac.js +41 -0
- package/dist/auth/hmac.js.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +4 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/users.d.ts +38 -0
- package/dist/auth/users.d.ts.map +1 -0
- package/dist/auth/users.js +100 -0
- package/dist/auth/users.js.map +1 -0
- package/dist/compute/FilesystemComputeProvider.d.ts +16 -0
- package/dist/compute/FilesystemComputeProvider.d.ts.map +1 -0
- package/dist/compute/FilesystemComputeProvider.js +51 -0
- package/dist/compute/FilesystemComputeProvider.js.map +1 -0
- package/dist/compute/SingleComputeServerProvider.d.ts +15 -0
- package/dist/compute/SingleComputeServerProvider.d.ts.map +1 -0
- package/dist/compute/SingleComputeServerProvider.js +26 -0
- package/dist/compute/SingleComputeServerProvider.js.map +1 -0
- package/dist/compute/types.d.ts +30 -0
- package/dist/compute/types.d.ts.map +1 -0
- package/dist/compute/types.js +2 -0
- package/dist/compute/types.js.map +1 -0
- package/dist/computeServer/FilesystemComputeServerStore.d.ts +14 -0
- package/dist/computeServer/FilesystemComputeServerStore.d.ts.map +1 -0
- package/dist/computeServer/FilesystemComputeServerStore.js +35 -0
- package/dist/computeServer/FilesystemComputeServerStore.js.map +1 -0
- package/dist/computeServer/LocalComputeServerProvider.d.ts +18 -0
- package/dist/computeServer/LocalComputeServerProvider.d.ts.map +1 -0
- package/dist/computeServer/LocalComputeServerProvider.js +29 -0
- package/dist/computeServer/LocalComputeServerProvider.js.map +1 -0
- package/dist/computeServer/__tests__/conformance.test.d.ts +2 -0
- package/dist/computeServer/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/computeServer/__tests__/conformance.test.js +20 -0
- package/dist/computeServer/__tests__/conformance.test.js.map +1 -0
- package/dist/computeServer/index.d.ts +2 -0
- package/dist/computeServer/index.d.ts.map +1 -0
- package/dist/computeServer/index.js +2 -0
- package/dist/computeServer/index.js.map +1 -0
- package/dist/data/LocalComputeServerStore.d.ts +72 -0
- package/dist/data/LocalComputeServerStore.d.ts.map +1 -0
- package/dist/data/LocalComputeServerStore.js +207 -0
- package/dist/data/LocalComputeServerStore.js.map +1 -0
- package/dist/data/LocalDataProvider.d.ts +47 -0
- package/dist/data/LocalDataProvider.d.ts.map +1 -0
- package/dist/data/LocalDataProvider.js +118 -0
- package/dist/data/LocalDataProvider.js.map +1 -0
- package/dist/data/LocalDefinitionMetaProvider.d.ts +22 -0
- package/dist/data/LocalDefinitionMetaProvider.d.ts.map +1 -0
- package/dist/data/LocalDefinitionMetaProvider.js +131 -0
- package/dist/data/LocalDefinitionMetaProvider.js.map +1 -0
- package/dist/data/LocalDefinitionStore.d.ts +33 -0
- package/dist/data/LocalDefinitionStore.d.ts.map +1 -0
- package/dist/data/LocalDefinitionStore.js +274 -0
- package/dist/data/LocalDefinitionStore.js.map +1 -0
- package/dist/data/LocalInviteStore.d.ts +23 -0
- package/dist/data/LocalInviteStore.d.ts.map +1 -0
- package/dist/data/LocalInviteStore.js +98 -0
- package/dist/data/LocalInviteStore.js.map +1 -0
- package/dist/data/LocalOrgStore.d.ts +67 -0
- package/dist/data/LocalOrgStore.d.ts.map +1 -0
- package/dist/data/LocalOrgStore.js +255 -0
- package/dist/data/LocalOrgStore.js.map +1 -0
- package/dist/data/LocalPlatformProjectGrantStore.d.ts +14 -0
- package/dist/data/LocalPlatformProjectGrantStore.d.ts.map +1 -0
- package/dist/data/LocalPlatformProjectGrantStore.js +62 -0
- package/dist/data/LocalPlatformProjectGrantStore.js.map +1 -0
- package/dist/data/LocalProjectStore.d.ts +30 -0
- package/dist/data/LocalProjectStore.d.ts.map +1 -0
- package/dist/data/LocalProjectStore.js +171 -0
- package/dist/data/LocalProjectStore.js.map +1 -0
- package/dist/data/LocalShareLinkStore.d.ts +39 -0
- package/dist/data/LocalShareLinkStore.d.ts.map +1 -0
- package/dist/data/LocalShareLinkStore.js +108 -0
- package/dist/data/LocalShareLinkStore.js.map +1 -0
- package/dist/data/__tests__/LocalDefinitionMetaProvider.test.d.ts +2 -0
- package/dist/data/__tests__/LocalDefinitionMetaProvider.test.d.ts.map +1 -0
- package/dist/data/__tests__/LocalDefinitionMetaProvider.test.js +21 -0
- package/dist/data/__tests__/LocalDefinitionMetaProvider.test.js.map +1 -0
- package/dist/data/__tests__/cascade.test.d.ts +2 -0
- package/dist/data/__tests__/cascade.test.d.ts.map +1 -0
- package/dist/data/__tests__/cascade.test.js +265 -0
- package/dist/data/__tests__/cascade.test.js.map +1 -0
- package/dist/data/__tests__/compute-server-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/compute-server-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/compute-server-conformance.test.js +21 -0
- package/dist/data/__tests__/compute-server-conformance.test.js.map +1 -0
- package/dist/data/__tests__/compute-server-encryption.test.d.ts +2 -0
- package/dist/data/__tests__/compute-server-encryption.test.d.ts.map +1 -0
- package/dist/data/__tests__/compute-server-encryption.test.js +131 -0
- package/dist/data/__tests__/compute-server-encryption.test.js.map +1 -0
- package/dist/data/__tests__/definition-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/definition-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/definition-conformance.test.js +20 -0
- package/dist/data/__tests__/definition-conformance.test.js.map +1 -0
- package/dist/data/__tests__/event-sink-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/event-sink-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/event-sink-conformance.test.js +24 -0
- package/dist/data/__tests__/event-sink-conformance.test.js.map +1 -0
- package/dist/data/__tests__/invite-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/invite-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/invite-conformance.test.js +21 -0
- package/dist/data/__tests__/invite-conformance.test.js.map +1 -0
- package/dist/data/__tests__/org-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/org-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/org-conformance.test.js +36 -0
- package/dist/data/__tests__/org-conformance.test.js.map +1 -0
- package/dist/data/__tests__/platform-project-grant-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/platform-project-grant-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/platform-project-grant-conformance.test.js +20 -0
- package/dist/data/__tests__/platform-project-grant-conformance.test.js.map +1 -0
- package/dist/data/__tests__/project-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/project-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/project-conformance.test.js +53 -0
- package/dist/data/__tests__/project-conformance.test.js.map +1 -0
- package/dist/data/__tests__/rules.test.d.ts +2 -0
- package/dist/data/__tests__/rules.test.d.ts.map +1 -0
- package/dist/data/__tests__/rules.test.js +484 -0
- package/dist/data/__tests__/rules.test.js.map +1 -0
- package/dist/data/__tests__/share-link-conformance.test.d.ts +2 -0
- package/dist/data/__tests__/share-link-conformance.test.d.ts.map +1 -0
- package/dist/data/__tests__/share-link-conformance.test.js +20 -0
- package/dist/data/__tests__/share-link-conformance.test.js.map +1 -0
- package/dist/data/fsJson.d.ts +12 -0
- package/dist/data/fsJson.d.ts.map +1 -0
- package/dist/data/fsJson.js +29 -0
- package/dist/data/fsJson.js.map +1 -0
- package/dist/data/index.d.ts +13 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +9 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/pagination.d.ts +15 -0
- package/dist/data/pagination.d.ts.map +1 -0
- package/dist/data/pagination.js +36 -0
- package/dist/data/pagination.js.map +1 -0
- package/dist/data/secretCrypto.d.ts +23 -0
- package/dist/data/secretCrypto.d.ts.map +1 -0
- package/dist/data/secretCrypto.js +64 -0
- package/dist/data/secretCrypto.js.map +1 -0
- package/dist/data/userData.d.ts +40 -0
- package/dist/data/userData.d.ts.map +1 -0
- package/dist/data/userData.js +84 -0
- package/dist/data/userData.js.map +1 -0
- package/dist/definitions/LocalDefinitionMetaProvider.d.ts +27 -0
- package/dist/definitions/LocalDefinitionMetaProvider.d.ts.map +1 -0
- package/dist/definitions/LocalDefinitionMetaProvider.js +188 -0
- package/dist/definitions/LocalDefinitionMetaProvider.js.map +1 -0
- package/dist/definitions/__tests__/conformance.test.d.ts +2 -0
- package/dist/definitions/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/definitions/__tests__/conformance.test.js +20 -0
- package/dist/definitions/__tests__/conformance.test.js.map +1 -0
- package/dist/definitions/index.d.ts +2 -0
- package/dist/definitions/index.d.ts.map +1 -0
- package/dist/definitions/index.js +2 -0
- package/dist/definitions/index.js.map +1 -0
- package/dist/definitions/providers/filesystem-files.d.ts +24 -0
- package/dist/definitions/providers/filesystem-files.d.ts.map +1 -0
- package/dist/definitions/providers/filesystem-files.js +170 -0
- package/dist/definitions/providers/filesystem-files.js.map +1 -0
- package/dist/definitions/providers/filesystem-meta.d.ts +17 -0
- package/dist/definitions/providers/filesystem-meta.d.ts.map +1 -0
- package/dist/definitions/providers/filesystem-meta.js +216 -0
- package/dist/definitions/providers/filesystem-meta.js.map +1 -0
- package/dist/fsJson.d.ts +12 -0
- package/dist/fsJson.d.ts.map +1 -0
- package/dist/fsJson.js +29 -0
- package/dist/fsJson.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/invites/LocalInviteProvider.d.ts +24 -0
- package/dist/invites/LocalInviteProvider.d.ts.map +1 -0
- package/dist/invites/LocalInviteProvider.js +89 -0
- package/dist/invites/LocalInviteProvider.js.map +1 -0
- package/dist/invites/__tests__/conformance.test.d.ts +2 -0
- package/dist/invites/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/invites/__tests__/conformance.test.js +21 -0
- package/dist/invites/__tests__/conformance.test.js.map +1 -0
- package/dist/organizations/LocalOrganizationProvider.d.ts +41 -0
- package/dist/organizations/LocalOrganizationProvider.d.ts.map +1 -0
- package/dist/organizations/LocalOrganizationProvider.js +198 -0
- package/dist/organizations/LocalOrganizationProvider.js.map +1 -0
- package/dist/organizations/__tests__/conformance.test.d.ts +2 -0
- package/dist/organizations/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/organizations/__tests__/conformance.test.js +20 -0
- package/dist/organizations/__tests__/conformance.test.js.map +1 -0
- package/dist/organizations/index.d.ts +2 -0
- package/dist/organizations/index.d.ts.map +1 -0
- package/dist/organizations/index.js +2 -0
- package/dist/organizations/index.js.map +1 -0
- package/dist/pagination.d.ts +15 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +36 -0
- package/dist/pagination.js.map +1 -0
- package/dist/permissions/LocalPlatformPermissionStore.d.ts +39 -0
- package/dist/permissions/LocalPlatformPermissionStore.d.ts.map +1 -0
- package/dist/permissions/LocalPlatformPermissionStore.js +117 -0
- package/dist/permissions/LocalPlatformPermissionStore.js.map +1 -0
- package/dist/permissions/__tests__/conformance.test.d.ts +2 -0
- package/dist/permissions/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/permissions/__tests__/conformance.test.js +37 -0
- package/dist/permissions/__tests__/conformance.test.js.map +1 -0
- package/dist/permissions/index.d.ts +2 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +2 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/projects/LocalProjectProvider.d.ts +21 -0
- package/dist/projects/LocalProjectProvider.d.ts.map +1 -0
- package/dist/projects/LocalProjectProvider.js +125 -0
- package/dist/projects/LocalProjectProvider.js.map +1 -0
- package/dist/projects/__tests__/conformance.test.d.ts +2 -0
- package/dist/projects/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/projects/__tests__/conformance.test.js +44 -0
- package/dist/projects/__tests__/conformance.test.js.map +1 -0
- package/dist/projects/index.d.ts +2 -0
- package/dist/projects/index.d.ts.map +1 -0
- package/dist/projects/index.js +2 -0
- package/dist/projects/index.js.map +1 -0
- package/dist/storage/LocalStorageProvider.d.ts +27 -0
- package/dist/storage/LocalStorageProvider.d.ts.map +1 -0
- package/dist/storage/LocalStorageProvider.js +74 -0
- package/dist/storage/LocalStorageProvider.js.map +1 -0
- package/dist/storage/__tests__/conformance.test.d.ts +2 -0
- package/dist/storage/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/storage/__tests__/conformance.test.js +20 -0
- package/dist/storage/__tests__/conformance.test.js.map +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/userProfile/LocalUserProfileProvider.d.ts +25 -0
- package/dist/userProfile/LocalUserProfileProvider.d.ts.map +1 -0
- package/dist/userProfile/LocalUserProfileProvider.js +110 -0
- package/dist/userProfile/LocalUserProfileProvider.js.map +1 -0
- package/dist/userProfile/__tests__/conformance.test.d.ts +2 -0
- package/dist/userProfile/__tests__/conformance.test.d.ts.map +1 -0
- package/dist/userProfile/__tests__/conformance.test.js +40 -0
- package/dist/userProfile/__tests__/conformance.test.js.map +1 -0
- package/dist/userProfile/index.d.ts +2 -0
- package/dist/userProfile/index.d.ts.map +1 -0
- package/dist/userProfile/index.js +2 -0
- package/dist/userProfile/index.js.map +1 -0
- package/package.json +70 -0
- package/src/README.md +37 -0
- package/src/auth/LocalAuthProvider.ts +165 -0
- package/src/auth/__tests__/conformance.test.ts +40 -0
- package/src/auth/hmac.ts +53 -0
- package/src/auth/index.ts +5 -0
- package/src/auth/users.ts +151 -0
- package/src/data/LocalComputeServerStore.ts +290 -0
- package/src/data/LocalDataProvider.ts +148 -0
- package/src/data/LocalDefinitionStore.ts +369 -0
- package/src/data/LocalInviteStore.ts +117 -0
- package/src/data/LocalOrgStore.ts +356 -0
- package/src/data/LocalPlatformProjectGrantStore.ts +85 -0
- package/src/data/LocalProjectStore.ts +274 -0
- package/src/data/LocalShareLinkStore.ts +138 -0
- package/src/data/__tests__/cascade.test.ts +300 -0
- package/src/data/__tests__/compute-server-conformance.test.ts +26 -0
- package/src/data/__tests__/compute-server-encryption.test.ts +185 -0
- package/src/data/__tests__/definition-conformance.test.ts +23 -0
- package/src/data/__tests__/event-sink-conformance.test.ts +28 -0
- package/src/data/__tests__/invite-conformance.test.ts +24 -0
- package/src/data/__tests__/org-conformance.test.ts +43 -0
- package/src/data/__tests__/platform-project-grant-conformance.test.ts +24 -0
- package/src/data/__tests__/project-conformance.test.ts +64 -0
- package/src/data/__tests__/rules.test.ts +682 -0
- package/src/data/__tests__/share-link-conformance.test.ts +23 -0
- package/src/data/fsJson.ts +28 -0
- package/src/data/index.ts +16 -0
- package/src/data/pagination.ts +48 -0
- package/src/data/secretCrypto.ts +69 -0
- package/src/data/userData.ts +134 -0
- package/src/index.ts +42 -0
- package/src/permissions/LocalPlatformPermissionStore.ts +129 -0
- package/src/permissions/__tests__/conformance.test.ts +40 -0
- package/src/permissions/index.ts +1 -0
- package/src/storage/LocalStorageProvider.ts +78 -0
- package/src/storage/__tests__/conformance.test.ts +23 -0
- package/src/storage/index.ts +1 -0
- package/src/userProfile/LocalUserProfileProvider.ts +135 -0
- package/src/userProfile/__tests__/conformance.test.ts +43 -0
- package/src/userProfile/index.ts +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IComputeServerProvider, ComputeServerConfig, ComputeConfig, SolveRequest } from '@selva/platform/compute';
|
|
2
|
+
/**
|
|
3
|
+
* Compute provider that reads/writes compute.config.json.
|
|
4
|
+
* The file is re-read on every getConfig/getServer call — changes take effect
|
|
5
|
+
* immediately without restarting the server.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FilesystemComputeProvider implements IComputeServerProvider {
|
|
8
|
+
private readonly configFilePath;
|
|
9
|
+
constructor(configFilePath: string);
|
|
10
|
+
getConfig(): Promise<ComputeConfig>;
|
|
11
|
+
saveConfig(config: ComputeConfig): Promise<void>;
|
|
12
|
+
getDefaultServer(): Promise<ComputeServerConfig | undefined>;
|
|
13
|
+
getServerById(id: string): Promise<ComputeServerConfig | undefined>;
|
|
14
|
+
getServer(_request?: SolveRequest): Promise<ComputeServerConfig>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=FilesystemComputeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilesystemComputeProvider.d.ts","sourceRoot":"","sources":["../../src/compute/FilesystemComputeProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,MAAM;IAE7C,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAYnC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAS5D,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAKnE,SAAS,CAAC,QAAQ,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAUtE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
/**
|
|
3
|
+
* Compute provider that reads/writes compute.config.json.
|
|
4
|
+
* The file is re-read on every getConfig/getServer call — changes take effect
|
|
5
|
+
* immediately without restarting the server.
|
|
6
|
+
*/
|
|
7
|
+
export class FilesystemComputeProvider {
|
|
8
|
+
configFilePath;
|
|
9
|
+
constructor(configFilePath) {
|
|
10
|
+
this.configFilePath = configFilePath;
|
|
11
|
+
}
|
|
12
|
+
async getConfig() {
|
|
13
|
+
try {
|
|
14
|
+
const raw = await fs.readFile(this.configFilePath, 'utf-8');
|
|
15
|
+
return JSON.parse(raw);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
if (err.code === 'ENOENT') {
|
|
19
|
+
return { servers: [] };
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`Failed to read compute.config.json at "${this.configFilePath}": ${err}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async saveConfig(config) {
|
|
25
|
+
const tmp = `${this.configFilePath}.tmp`;
|
|
26
|
+
await fs.writeFile(tmp, JSON.stringify(config, null, '\t'), 'utf-8');
|
|
27
|
+
await fs.rename(tmp, this.configFilePath);
|
|
28
|
+
}
|
|
29
|
+
async getDefaultServer() {
|
|
30
|
+
const config = await this.getConfig();
|
|
31
|
+
if (config.defaultServerId) {
|
|
32
|
+
const found = config.servers.find((s) => s.id === config.defaultServerId);
|
|
33
|
+
if (found)
|
|
34
|
+
return found;
|
|
35
|
+
}
|
|
36
|
+
return config.servers[0];
|
|
37
|
+
}
|
|
38
|
+
async getServerById(id) {
|
|
39
|
+
const config = await this.getConfig();
|
|
40
|
+
return config.servers.find((s) => s.id === id);
|
|
41
|
+
}
|
|
42
|
+
async getServer(_request) {
|
|
43
|
+
const server = await this.getDefaultServer();
|
|
44
|
+
if (!server) {
|
|
45
|
+
throw new Error(`No compute servers configured in "${this.configFilePath}". ` +
|
|
46
|
+
`Add at least one entry to the "servers" array.`);
|
|
47
|
+
}
|
|
48
|
+
return server;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=FilesystemComputeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilesystemComputeProvider.js","sourceRoot":"","sources":["../../src/compute/FilesystemComputeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQvC;;;;GAIG;AACH,MAAM,OAAO,yBAAyB;IACR;IAA7B,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEvD,KAAK,CAAC,SAAS;QACd,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB,CAAC;QACzC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YACxB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAC,cAAc,MAAM,GAAG,EAAE,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAqB;QACrC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,cAAc,MAAM,CAAC;QACzC,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QACrE,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,gBAAgB;QACrB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,eAAe,CAAC,CAAC;YAC1E,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAuB;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACd,qCAAqC,IAAI,CAAC,cAAc,KAAK;gBAC5D,gDAAgD,CACjD,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;CACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IComputeServerProvider, ComputeServerConfig, ComputeConfig, SolveRequest } from '@selva/platform/compute';
|
|
2
|
+
/**
|
|
3
|
+
* Default compute provider: always routes to the same server.
|
|
4
|
+
* Configured by passing a ComputeServerConfig at construction time.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SingleComputeServerProvider implements IComputeServerProvider {
|
|
7
|
+
private readonly server;
|
|
8
|
+
constructor(server: ComputeServerConfig);
|
|
9
|
+
getServer(_request?: SolveRequest): Promise<ComputeServerConfig>;
|
|
10
|
+
getDefaultServer(): Promise<ComputeServerConfig>;
|
|
11
|
+
getServerById(id: string): Promise<ComputeServerConfig | undefined>;
|
|
12
|
+
getConfig(): Promise<ComputeConfig>;
|
|
13
|
+
saveConfig(_config: ComputeConfig): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=SingleComputeServerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleComputeServerProvider.d.ts","sourceRoot":"","sources":["../../src/compute/SingleComputeServerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,qBAAa,2BAA4B,YAAW,sBAAsB;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,mBAAmB;IAElD,SAAS,CAAC,QAAQ,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIhE,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAIhD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAInE,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAInC,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default compute provider: always routes to the same server.
|
|
3
|
+
* Configured by passing a ComputeServerConfig at construction time.
|
|
4
|
+
*/
|
|
5
|
+
export class SingleComputeServerProvider {
|
|
6
|
+
server;
|
|
7
|
+
constructor(server) {
|
|
8
|
+
this.server = server;
|
|
9
|
+
}
|
|
10
|
+
async getServer(_request) {
|
|
11
|
+
return this.server;
|
|
12
|
+
}
|
|
13
|
+
async getDefaultServer() {
|
|
14
|
+
return this.server;
|
|
15
|
+
}
|
|
16
|
+
async getServerById(id) {
|
|
17
|
+
return this.server.id === id ? this.server : undefined;
|
|
18
|
+
}
|
|
19
|
+
async getConfig() {
|
|
20
|
+
return { servers: [this.server], defaultServerId: this.server.id };
|
|
21
|
+
}
|
|
22
|
+
async saveConfig(_config) {
|
|
23
|
+
throw new Error('SingleComputeServerProvider does not support saveConfig — use FilesystemComputeProvider or another mutable provider.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=SingleComputeServerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleComputeServerProvider.js","sourceRoot":"","sources":["../../src/compute/SingleComputeServerProvider.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IACV;IAA7B,YAA6B,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAE5D,KAAK,CAAC,SAAS,CAAC,QAAuB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,SAAS;QACd,OAAO,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAsB;QACtC,MAAM,IAAI,KAAK,CAAC,sHAAsH,CAAC,CAAC;IACzI,CAAC;CACD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of compute.config.json stored in the definitions directory.
|
|
3
|
+
*
|
|
4
|
+
* Set COMPUTE_PROVIDER=filesystem to use this file instead of
|
|
5
|
+
* the COMPUTE_SERVER_URL environment variable.
|
|
6
|
+
*
|
|
7
|
+
* Example compute.config.json:
|
|
8
|
+
* {
|
|
9
|
+
* "servers": [
|
|
10
|
+
* { "label": "local", "serverUrl": "http://localhost:5000", "timeoutMs": 30000 }
|
|
11
|
+
* ],
|
|
12
|
+
* "defaultServer": "local"
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export interface ComputeServerEntry {
|
|
16
|
+
/** Unique human-readable key. Referenced by defaultServer. */
|
|
17
|
+
label: string;
|
|
18
|
+
serverUrl: string;
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
/** Request timeout in ms. Default: 30000 */
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
/** Retries on transient failure. Default: 0 */
|
|
23
|
+
retryCount?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ComputeConfig {
|
|
26
|
+
servers: ComputeServerEntry[];
|
|
27
|
+
/** Label of the server to use when no routing rule matches. Falls back to servers[0]. */
|
|
28
|
+
defaultServer?: string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compute/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,kBAAkB;IAClC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,yFAAyF;IACzF,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/compute/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IComputeServerStore, ComputeConfig } from '@selva/platform';
|
|
2
|
+
/**
|
|
3
|
+
* Reads/writes compute.config.json.
|
|
4
|
+
* The file is re-read on every getConfig() call — changes take effect
|
|
5
|
+
* immediately without restarting the server.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FilesystemComputeServerStore implements IComputeServerStore {
|
|
8
|
+
private readonly configFilePath;
|
|
9
|
+
static fromEnv(env: Record<string, string | undefined>): FilesystemComputeServerStore;
|
|
10
|
+
constructor(configFilePath: string);
|
|
11
|
+
getConfig(): Promise<ComputeConfig>;
|
|
12
|
+
saveConfig(config: ComputeConfig): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=FilesystemComputeServerStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilesystemComputeServerStore.d.ts","sourceRoot":"","sources":["../../src/computeServer/FilesystemComputeServerStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E;;;;GAIG;AACH,qBAAa,4BAA6B,YAAW,mBAAmB;IAM3D,OAAO,CAAC,QAAQ,CAAC,cAAc;IAL3C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,4BAA4B;gBAKxD,cAAc,EAAE,MAAM;IAE7C,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAUnC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAKtD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Reads/writes compute.config.json.
|
|
5
|
+
* The file is re-read on every getConfig() call — changes take effect
|
|
6
|
+
* immediately without restarting the server.
|
|
7
|
+
*/
|
|
8
|
+
export class FilesystemComputeServerStore {
|
|
9
|
+
configFilePath;
|
|
10
|
+
static fromEnv(env) {
|
|
11
|
+
if (!env.DATA_PATH)
|
|
12
|
+
throw new Error('Missing required env var: DATA_PATH');
|
|
13
|
+
return new FilesystemComputeServerStore(path.join(env.DATA_PATH, 'compute.config.json'));
|
|
14
|
+
}
|
|
15
|
+
constructor(configFilePath) {
|
|
16
|
+
this.configFilePath = configFilePath;
|
|
17
|
+
}
|
|
18
|
+
async getConfig() {
|
|
19
|
+
try {
|
|
20
|
+
const raw = await fs.readFile(this.configFilePath, 'utf-8');
|
|
21
|
+
return JSON.parse(raw);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
if (err.code === 'ENOENT')
|
|
25
|
+
return { servers: [] };
|
|
26
|
+
throw new Error(`Failed to read compute.config.json at "${this.configFilePath}": ${err}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async saveConfig(config) {
|
|
30
|
+
const tmp = `${this.configFilePath}.tmp`;
|
|
31
|
+
await fs.writeFile(tmp, JSON.stringify(config, null, '\t'), 'utf-8');
|
|
32
|
+
await fs.rename(tmp, this.configFilePath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=FilesystemComputeServerStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilesystemComputeServerStore.js","sourceRoot":"","sources":["../../src/computeServer/FilesystemComputeServerStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC;;;;GAIG;AACH,MAAM,OAAO,4BAA4B;IAMX;IAL7B,MAAM,CAAC,OAAO,CAAC,GAAuC;QACrD,IAAI,CAAC,GAAG,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC3E,OAAO,IAAI,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEvD,KAAK,CAAC,SAAS;QACd,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB,CAAC;QACzC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAC7E,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAC,cAAc,MAAM,GAAG,EAAE,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAqB;QACrC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,cAAc,MAAM,CAAC;QACzC,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QACrE,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IComputeServerStore, ComputeConfig, RequestContext } from '@selva/platform';
|
|
2
|
+
/**
|
|
3
|
+
* Reads/writes compute.config.json.
|
|
4
|
+
* The file is re-read on every getConfig() call — changes take effect
|
|
5
|
+
* immediately without restarting the server.
|
|
6
|
+
*
|
|
7
|
+
* `ctx` is part of the contract but unused locally — there is no tenant
|
|
8
|
+
* scope to enforce against the filesystem. A multi-tenant adapter would
|
|
9
|
+
* authorize writes here.
|
|
10
|
+
*/
|
|
11
|
+
export declare class LocalComputeServerProvider implements IComputeServerStore {
|
|
12
|
+
private readonly configFilePath;
|
|
13
|
+
static fromEnv(env: Record<string, string | undefined>): LocalComputeServerProvider;
|
|
14
|
+
constructor(configFilePath: string);
|
|
15
|
+
getConfig(_ctx: RequestContext): Promise<ComputeConfig>;
|
|
16
|
+
saveConfig(_ctx: RequestContext, config: ComputeConfig): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=LocalComputeServerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalComputeServerProvider.d.ts","sourceRoot":"","sources":["../../src/computeServer/LocalComputeServerProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG1F;;;;;;;;GAQG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAMzD,OAAO,CAAC,QAAQ,CAAC,cAAc;IAL3C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,0BAA0B;gBAKtD,cAAc,EAAE,MAAM;IAE7C,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAIvD,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { readJsonFile, writeJsonFile } from '../fsJson.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads/writes compute.config.json.
|
|
5
|
+
* The file is re-read on every getConfig() call — changes take effect
|
|
6
|
+
* immediately without restarting the server.
|
|
7
|
+
*
|
|
8
|
+
* `ctx` is part of the contract but unused locally — there is no tenant
|
|
9
|
+
* scope to enforce against the filesystem. A multi-tenant adapter would
|
|
10
|
+
* authorize writes here.
|
|
11
|
+
*/
|
|
12
|
+
export class LocalComputeServerProvider {
|
|
13
|
+
configFilePath;
|
|
14
|
+
static fromEnv(env) {
|
|
15
|
+
if (!env.DATA_PATH)
|
|
16
|
+
throw new Error('Missing required env var: DATA_PATH');
|
|
17
|
+
return new LocalComputeServerProvider(path.join(env.DATA_PATH, 'compute.config.json'));
|
|
18
|
+
}
|
|
19
|
+
constructor(configFilePath) {
|
|
20
|
+
this.configFilePath = configFilePath;
|
|
21
|
+
}
|
|
22
|
+
async getConfig(_ctx) {
|
|
23
|
+
return readJsonFile(this.configFilePath, { servers: [] });
|
|
24
|
+
}
|
|
25
|
+
async saveConfig(_ctx, config) {
|
|
26
|
+
await writeJsonFile(this.configFilePath, config);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=LocalComputeServerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalComputeServerProvider.js","sourceRoot":"","sources":["../../src/computeServer/LocalComputeServerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,OAAO,0BAA0B;IAMT;IAL7B,MAAM,CAAC,OAAO,CAAC,GAAuC;QACrD,IAAI,CAAC,GAAG,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC3E,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEvD,KAAK,CAAC,SAAS,CAAC,IAAoB;QACnC,OAAO,YAAY,CAAgB,IAAI,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAoB,EAAE,MAAqB;QAC3D,MAAM,aAAa,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.test.d.ts","sourceRoot":"","sources":["../../../src/computeServer/__tests__/conformance.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import * as os from 'node:os';
|
|
5
|
+
import { runComputeServerStoreConformance } from '@selva/platform/testing';
|
|
6
|
+
import { LocalComputeServerProvider } from '../LocalComputeServerProvider.js';
|
|
7
|
+
describe('LocalComputeServerProvider', () => {
|
|
8
|
+
let tempDir;
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'selva-compute-'));
|
|
11
|
+
});
|
|
12
|
+
afterEach(async () => {
|
|
13
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
14
|
+
});
|
|
15
|
+
runComputeServerStoreConformance({
|
|
16
|
+
name: 'LocalComputeServerProvider',
|
|
17
|
+
createStore: () => new LocalComputeServerProvider(path.join(tempDir, 'compute.config.json'))
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=conformance.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.test.js","sourceRoot":"","sources":["../../../src/computeServer/__tests__/conformance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAE9E,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC3C,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QACrB,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,gCAAgC,CAAC;QAChC,IAAI,EAAE,4BAA4B;QAClC,WAAW,EAAE,GAAG,EAAE,CACjB,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;KAC1E,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/computeServer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/computeServer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type IComputeServerStore, type ComputeConfig, type ComputeServerConfig, type RequestContext } from '@selvajs/platform';
|
|
2
|
+
/**
|
|
3
|
+
* Result of {@link LocalComputeServerStore.verifySecrets}. One entry per
|
|
4
|
+
* server whose `apiKey` couldn't be loaded:
|
|
5
|
+
* - `plaintext_on_disk` — the field exists but isn't an `enc:v1:` envelope.
|
|
6
|
+
* Either a hand-edit or a migration regression. Security-relevant.
|
|
7
|
+
* - `key_mismatch` — envelope is valid but GCM auth tag verification
|
|
8
|
+
* fails under the current `SELVA_AT_REST_KEY`. The key was rotated or the
|
|
9
|
+
* data came from another deployment.
|
|
10
|
+
*/
|
|
11
|
+
export type SecretVerificationFailureReason = 'key_mismatch' | 'plaintext_on_disk';
|
|
12
|
+
export interface SecretVerificationFailure {
|
|
13
|
+
serverId: string;
|
|
14
|
+
serverLabel: string;
|
|
15
|
+
reason: SecretVerificationFailureReason;
|
|
16
|
+
/** Underlying error message for `key_mismatch`. Absent for plaintext. */
|
|
17
|
+
cause?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SecretVerificationReport {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
failures: SecretVerificationFailure[];
|
|
22
|
+
/** True if at least one row holds an unencrypted apiKey on disk. */
|
|
23
|
+
plaintextFound: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Reads/writes compute.config.json. The file is re-read on every read call
|
|
27
|
+
* so changes take effect without a restart.
|
|
28
|
+
*
|
|
29
|
+
* Mutation methods are scope-targeted (`savePlatformServers`,
|
|
30
|
+
* `saveOrgServers`, `setOrgDefault`) — each preserves rows in the other
|
|
31
|
+
* scopes untouched.
|
|
32
|
+
*/
|
|
33
|
+
export declare class LocalComputeServerStore implements IComputeServerStore {
|
|
34
|
+
private readonly configFilePath;
|
|
35
|
+
private readonly secretKey;
|
|
36
|
+
static fromEnv(env: Record<string, string | undefined>): LocalComputeServerStore;
|
|
37
|
+
constructor(configFilePath: string, secretKey: Buffer);
|
|
38
|
+
private readAll;
|
|
39
|
+
/**
|
|
40
|
+
* Per-row tolerant decrypt. A row whose ciphertext can't be authenticated
|
|
41
|
+
* under the current `SELVA_AT_REST_KEY` is returned with `apiKey: undefined`
|
|
42
|
+
* and a warning logged once. The page that loaded the config keeps
|
|
43
|
+
* rendering; solves against that server will fail later when Rhino.Compute
|
|
44
|
+
* rejects the missing key.
|
|
45
|
+
*
|
|
46
|
+
* Boot-time `verifySecrets()` is the strict counterpart — call that from
|
|
47
|
+
* the app entrypoint to refuse to start when this state is detected.
|
|
48
|
+
*
|
|
49
|
+
* Plaintext-on-disk is still hard-fail. That state is never produced by
|
|
50
|
+
* the store itself (every write goes through `encryptApiKeys`), so seeing
|
|
51
|
+
* it means someone hand-edited the file with a real secret in plaintext —
|
|
52
|
+
* which is a security issue we should surface loudly, not paper over.
|
|
53
|
+
*/
|
|
54
|
+
private decryptApiKeys;
|
|
55
|
+
/**
|
|
56
|
+
* Boot-time integrity check. Reads every server row and attempts to
|
|
57
|
+
* decrypt each encrypted `apiKey`. Returns a structured report — does NOT
|
|
58
|
+
* throw. The caller decides what to do (refuse boot, log + degrade, etc.).
|
|
59
|
+
*
|
|
60
|
+
* Use this from app startup (`hooks.server.ts`) so a key mismatch fails
|
|
61
|
+
* loudly at deploy time instead of as a blank page when a user first hits
|
|
62
|
+
* a route that loads compute config.
|
|
63
|
+
*/
|
|
64
|
+
verifySecrets(): Promise<SecretVerificationReport>;
|
|
65
|
+
private encryptApiKeys;
|
|
66
|
+
getConfig(_ctx: RequestContext): Promise<ComputeConfig>;
|
|
67
|
+
savePlatformServers(_ctx: RequestContext, servers: ComputeServerConfig[], defaultServerId: string | undefined): Promise<void>;
|
|
68
|
+
saveOrgServers(_ctx: RequestContext, orgId: string, servers: ComputeServerConfig[], defaultServerId?: string | null): Promise<void>;
|
|
69
|
+
setOrgDefault(_ctx: RequestContext, orgId: string, serverId: string | null): Promise<void>;
|
|
70
|
+
deleteByOrg(_ctx: RequestContext, orgId: string): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=LocalComputeServerStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalComputeServerStore.d.ts","sourceRoot":"","sources":["../../src/data/LocalComputeServerStore.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,KAAK,cAAc,EACnB,MAAM,mBAAmB,CAAC;AAyB3B;;;;;;;;GAQG;AACH,MAAM,MAAM,+BAA+B,GAAG,cAAc,GAAG,mBAAmB,CAAC;AAEnF,MAAM,WAAW,yBAAyB;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,+BAA+B,CAAC;IACxC,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACxC,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,oEAAoE;IACpE,cAAc,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,qBAAa,uBAAwB,YAAW,mBAAmB;IAgBjE,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAhB3B,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,uBAAuB;gBAe9D,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM;YAGrB,OAAO;IASrB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,cAAc;IAyBtB;;;;;;;;OAQG;IACG,aAAa,IAAI,OAAO,CAAC,wBAAwB,CAAC;IA+BxD,OAAO,CAAC,cAAc;IAQhB,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IASvD,mBAAmB,CACxB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,eAAe,EAAE,MAAM,GAAG,SAAS,GACjC,OAAO,CAAC,IAAI,CAAC;IAYV,cAAc,CACnB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,mBAAmB,EAAE,EAC9B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAC7B,OAAO,CAAC,IAAI,CAAC;IA6BV,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1F,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAkCrE"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { isOrgServer, isPlatformServer } from '@selvajs/platform';
|
|
3
|
+
import { readJsonFile, writeJsonFile } from './fsJson.js';
|
|
4
|
+
import { decodeSecretKey, decryptSecret, encryptSecret, isEncryptedSecret } from './secretCrypto.js';
|
|
5
|
+
const EMPTY = { servers: [], orgDefaults: {} };
|
|
6
|
+
/**
|
|
7
|
+
* Reads/writes compute.config.json. The file is re-read on every read call
|
|
8
|
+
* so changes take effect without a restart.
|
|
9
|
+
*
|
|
10
|
+
* Mutation methods are scope-targeted (`savePlatformServers`,
|
|
11
|
+
* `saveOrgServers`, `setOrgDefault`) — each preserves rows in the other
|
|
12
|
+
* scopes untouched.
|
|
13
|
+
*/
|
|
14
|
+
export class LocalComputeServerStore {
|
|
15
|
+
configFilePath;
|
|
16
|
+
secretKey;
|
|
17
|
+
static fromEnv(env) {
|
|
18
|
+
if (!env.DATA_PATH)
|
|
19
|
+
throw new Error('Missing required env var: DATA_PATH');
|
|
20
|
+
if (!env.SELVA_AT_REST_KEY) {
|
|
21
|
+
throw new Error('Missing required env var: SELVA_AT_REST_KEY (32-byte hex or base64). ' +
|
|
22
|
+
"Generate one with: node -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"");
|
|
23
|
+
}
|
|
24
|
+
return new LocalComputeServerStore(path.join(env.DATA_PATH, 'compute.config.json'), decodeSecretKey(env.SELVA_AT_REST_KEY));
|
|
25
|
+
}
|
|
26
|
+
constructor(configFilePath, secretKey) {
|
|
27
|
+
this.configFilePath = configFilePath;
|
|
28
|
+
this.secretKey = secretKey;
|
|
29
|
+
}
|
|
30
|
+
async readAll() {
|
|
31
|
+
const raw = await readJsonFile(this.configFilePath, EMPTY);
|
|
32
|
+
return {
|
|
33
|
+
servers: raw.servers ?? [],
|
|
34
|
+
defaultServerId: raw.defaultServerId,
|
|
35
|
+
orgDefaults: raw.orgDefaults ?? {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Per-row tolerant decrypt. A row whose ciphertext can't be authenticated
|
|
40
|
+
* under the current `SELVA_AT_REST_KEY` is returned with `apiKey: undefined`
|
|
41
|
+
* and a warning logged once. The page that loaded the config keeps
|
|
42
|
+
* rendering; solves against that server will fail later when Rhino.Compute
|
|
43
|
+
* rejects the missing key.
|
|
44
|
+
*
|
|
45
|
+
* Boot-time `verifySecrets()` is the strict counterpart — call that from
|
|
46
|
+
* the app entrypoint to refuse to start when this state is detected.
|
|
47
|
+
*
|
|
48
|
+
* Plaintext-on-disk is still hard-fail. That state is never produced by
|
|
49
|
+
* the store itself (every write goes through `encryptApiKeys`), so seeing
|
|
50
|
+
* it means someone hand-edited the file with a real secret in plaintext —
|
|
51
|
+
* which is a security issue we should surface loudly, not paper over.
|
|
52
|
+
*/
|
|
53
|
+
decryptApiKeys(servers) {
|
|
54
|
+
return servers.map((s) => {
|
|
55
|
+
if (!s.apiKey)
|
|
56
|
+
return s;
|
|
57
|
+
if (!isEncryptedSecret(s.apiKey)) {
|
|
58
|
+
throw new Error(`compute.config.json contains an unencrypted apiKey for server "${s.label}" (${s.id}). ` +
|
|
59
|
+
'Re-enter the key via /admin/compute so it is stored encrypted.');
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return { ...s, apiKey: decryptSecret(s.apiKey, this.secretKey) };
|
|
63
|
+
}
|
|
64
|
+
catch (cause) {
|
|
65
|
+
console.warn(`[selva] Could not decrypt apiKey for compute server "${s.label}" (${s.id}). ` +
|
|
66
|
+
'The stored ciphertext does not match the current SELVA_AT_REST_KEY. ' +
|
|
67
|
+
'This server will be returned without an apiKey; solves against it will fail. ' +
|
|
68
|
+
'Re-enter the key via /admin/compute, or restore the original SELVA_AT_REST_KEY. ' +
|
|
69
|
+
'See docs/Troubleshooting.md.', cause);
|
|
70
|
+
return { ...s, apiKey: undefined };
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Boot-time integrity check. Reads every server row and attempts to
|
|
76
|
+
* decrypt each encrypted `apiKey`. Returns a structured report — does NOT
|
|
77
|
+
* throw. The caller decides what to do (refuse boot, log + degrade, etc.).
|
|
78
|
+
*
|
|
79
|
+
* Use this from app startup (`hooks.server.ts`) so a key mismatch fails
|
|
80
|
+
* loudly at deploy time instead of as a blank page when a user first hits
|
|
81
|
+
* a route that loads compute config.
|
|
82
|
+
*/
|
|
83
|
+
async verifySecrets() {
|
|
84
|
+
const all = await this.readAll();
|
|
85
|
+
const failures = [];
|
|
86
|
+
let plaintextFound = false;
|
|
87
|
+
for (const s of all.servers) {
|
|
88
|
+
if (!s.apiKey)
|
|
89
|
+
continue;
|
|
90
|
+
if (!isEncryptedSecret(s.apiKey)) {
|
|
91
|
+
plaintextFound = true;
|
|
92
|
+
failures.push({
|
|
93
|
+
serverId: s.id,
|
|
94
|
+
serverLabel: s.label,
|
|
95
|
+
reason: 'plaintext_on_disk'
|
|
96
|
+
});
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
decryptSecret(s.apiKey, this.secretKey);
|
|
101
|
+
}
|
|
102
|
+
catch (cause) {
|
|
103
|
+
failures.push({
|
|
104
|
+
serverId: s.id,
|
|
105
|
+
serverLabel: s.label,
|
|
106
|
+
reason: 'key_mismatch',
|
|
107
|
+
cause: cause instanceof Error ? cause.message : String(cause)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { ok: failures.length === 0, failures, plaintextFound };
|
|
112
|
+
}
|
|
113
|
+
encryptApiKeys(servers) {
|
|
114
|
+
return servers.map((s) => {
|
|
115
|
+
if (!s.apiKey)
|
|
116
|
+
return s;
|
|
117
|
+
if (isEncryptedSecret(s.apiKey))
|
|
118
|
+
return s;
|
|
119
|
+
return { ...s, apiKey: encryptSecret(s.apiKey, this.secretKey) };
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
async getConfig(_ctx) {
|
|
123
|
+
const all = await this.readAll();
|
|
124
|
+
return {
|
|
125
|
+
servers: this.decryptApiKeys(all.servers),
|
|
126
|
+
defaultServerId: all.defaultServerId,
|
|
127
|
+
orgDefaults: all.orgDefaults
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
async savePlatformServers(_ctx, servers, defaultServerId) {
|
|
131
|
+
const all = await this.readAll();
|
|
132
|
+
const orgRows = all.servers.filter(isOrgServer);
|
|
133
|
+
const platformRows = this.encryptApiKeys(servers.filter(isPlatformServer));
|
|
134
|
+
await writeJsonFile(this.configFilePath, {
|
|
135
|
+
servers: [...platformRows, ...orgRows],
|
|
136
|
+
defaultServerId,
|
|
137
|
+
orgDefaults: all.orgDefaults
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async saveOrgServers(_ctx, orgId, servers, defaultServerId) {
|
|
141
|
+
const all = await this.readAll();
|
|
142
|
+
const platformRows = all.servers.filter(isPlatformServer);
|
|
143
|
+
const otherOrgRows = all.servers.filter((s) => isOrgServer(s) && s.ownerOrgId !== orgId);
|
|
144
|
+
const thisOrgRows = this.encryptApiKeys(servers
|
|
145
|
+
.filter((_s) => true)
|
|
146
|
+
.map((s) => isOrgServer(s)
|
|
147
|
+
? { ...s, ownerOrgId: orgId }
|
|
148
|
+
: // Coerce — caller passed something with the wrong/missing scope.
|
|
149
|
+
{ ...s, scope: 'org', ownerOrgId: orgId }));
|
|
150
|
+
const orgDefaults = { ...(all.orgDefaults ?? {}) };
|
|
151
|
+
if (defaultServerId === null) {
|
|
152
|
+
delete orgDefaults[orgId];
|
|
153
|
+
}
|
|
154
|
+
else if (typeof defaultServerId === 'string') {
|
|
155
|
+
orgDefaults[orgId] = defaultServerId;
|
|
156
|
+
}
|
|
157
|
+
await writeJsonFile(this.configFilePath, {
|
|
158
|
+
servers: [...platformRows, ...otherOrgRows, ...thisOrgRows],
|
|
159
|
+
defaultServerId: all.defaultServerId,
|
|
160
|
+
orgDefaults
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
async setOrgDefault(_ctx, orgId, serverId) {
|
|
164
|
+
const all = await this.readAll();
|
|
165
|
+
const orgDefaults = { ...(all.orgDefaults ?? {}) };
|
|
166
|
+
if (serverId === null) {
|
|
167
|
+
delete orgDefaults[orgId];
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
orgDefaults[orgId] = serverId;
|
|
171
|
+
}
|
|
172
|
+
await writeJsonFile(this.configFilePath, { ...all, orgDefaults });
|
|
173
|
+
}
|
|
174
|
+
async deleteByOrg(_ctx, orgId) {
|
|
175
|
+
const all = await this.readAll();
|
|
176
|
+
// Drop org-private rows owned by this org.
|
|
177
|
+
const remaining = all.servers.filter((s) => !(isOrgServer(s) && s.ownerOrgId === orgId));
|
|
178
|
+
// Strip this org from any platform server's `sharedWith` allowlist.
|
|
179
|
+
const cleaned = remaining.map((s) => {
|
|
180
|
+
if (!isPlatformServer(s))
|
|
181
|
+
return s;
|
|
182
|
+
if (s.sharedWith === 'all')
|
|
183
|
+
return s;
|
|
184
|
+
if (!s.sharedWith.includes(orgId))
|
|
185
|
+
return s;
|
|
186
|
+
const next = {
|
|
187
|
+
...s,
|
|
188
|
+
sharedWith: s.sharedWith.filter((id) => id !== orgId)
|
|
189
|
+
};
|
|
190
|
+
return next;
|
|
191
|
+
});
|
|
192
|
+
const orgDefaults = { ...(all.orgDefaults ?? {}) };
|
|
193
|
+
const hadDefault = orgId in orgDefaults;
|
|
194
|
+
delete orgDefaults[orgId];
|
|
195
|
+
const changed = cleaned.length !== all.servers.length ||
|
|
196
|
+
hadDefault ||
|
|
197
|
+
cleaned.some((c, i) => c !== all.servers[i]);
|
|
198
|
+
if (!changed)
|
|
199
|
+
return;
|
|
200
|
+
await writeJsonFile(this.configFilePath, {
|
|
201
|
+
servers: cleaned,
|
|
202
|
+
defaultServerId: all.defaultServerId,
|
|
203
|
+
orgDefaults
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=LocalComputeServerStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalComputeServerStore.js","sourceRoot":"","sources":["../../src/data/LocalComputeServerStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACN,WAAW,EACX,gBAAgB,EAMhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACN,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,MAAM,mBAAmB,CAAC;AAgB3B,MAAM,KAAK,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AA4B5D;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAuB;IAgBjB;IACA;IAhBlB,MAAM,CAAC,OAAO,CAAC,GAAuC;QACrD,IAAI,CAAC,GAAG,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CA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