@start9labs/start-sdk 0.4.0-beta.2 → 0.4.0-beta.21
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/base/lib/Effects.d.ts +4 -22
- package/base/lib/actions/index.d.ts +5 -5
- package/base/lib/actions/index.js.map +1 -1
- package/base/lib/actions/input/builder/inputSpec.d.ts +10 -25
- package/base/lib/actions/input/builder/inputSpec.js +0 -17
- package/base/lib/actions/input/builder/inputSpec.js.map +1 -1
- package/base/lib/actions/input/builder/list.d.ts +8 -23
- package/base/lib/actions/input/builder/list.js +0 -17
- package/base/lib/actions/input/builder/list.js.map +1 -1
- package/base/lib/actions/input/builder/value.d.ts +318 -53
- package/base/lib/actions/input/builder/value.js +280 -17
- package/base/lib/actions/input/builder/value.js.map +1 -1
- package/base/lib/actions/input/builder/variants.d.ts +8 -23
- package/base/lib/actions/input/builder/variants.js +0 -17
- package/base/lib/actions/input/builder/variants.js.map +1 -1
- package/base/lib/actions/input/inputSpecConstants.d.ts +6 -6
- package/base/lib/actions/input/inputSpecConstants.js.map +1 -1
- package/base/lib/actions/setupActions.d.ts +10 -11
- package/base/lib/actions/setupActions.js +24 -11
- package/base/lib/actions/setupActions.js.map +1 -1
- package/base/lib/dependencies/setupDependencies.d.ts +1 -3
- package/base/lib/dependencies/setupDependencies.js +3 -12
- package/base/lib/dependencies/setupDependencies.js.map +1 -1
- package/base/lib/index.d.ts +1 -0
- package/base/lib/index.js +2 -1
- package/base/lib/index.js.map +1 -1
- package/base/lib/inits/index.d.ts +2 -0
- package/base/lib/inits/index.js +19 -0
- package/base/lib/inits/index.js.map +1 -0
- package/base/lib/inits/setupInit.d.ts +11 -0
- package/base/lib/inits/setupInit.js +69 -0
- package/base/lib/inits/setupInit.js.map +1 -0
- package/base/lib/inits/setupUninit.d.ts +7 -0
- package/base/lib/inits/setupUninit.js +14 -0
- package/base/lib/inits/setupUninit.js.map +1 -0
- package/base/lib/interfaces/setupInterfaces.d.ts +2 -4
- package/base/lib/interfaces/setupInterfaces.js +8 -19
- package/base/lib/interfaces/setupInterfaces.js.map +1 -1
- package/base/lib/osBindings/AddCategoryParams.d.ts +0 -2
- package/base/lib/osBindings/AddPackageToCategoryParams.d.ts +5 -0
- package/base/lib/osBindings/AddPackageToCategoryParams.js +3 -0
- package/base/lib/osBindings/AddPackageToCategoryParams.js.map +1 -0
- package/base/lib/osBindings/Category.d.ts +0 -2
- package/base/lib/osBindings/Category.js +1 -0
- package/base/lib/osBindings/Category.js.map +1 -1
- package/base/lib/osBindings/FileType.d.ts +1 -0
- package/base/lib/osBindings/{UnsetPublicParams.js → FileType.js} +1 -1
- package/base/lib/osBindings/FileType.js.map +1 -0
- package/base/lib/osBindings/GetOsVersionParams.d.ts +4 -3
- package/base/lib/osBindings/GetPackageParams.d.ts +1 -1
- package/base/lib/osBindings/MainStatus.d.ts +0 -2
- package/base/lib/osBindings/MountTarget.d.ts +2 -0
- package/base/lib/osBindings/PackageDataEntry.d.ts +1 -2
- package/base/lib/osBindings/RemoveAdminParams.d.ts +4 -0
- package/base/lib/osBindings/RemoveAdminParams.js +3 -0
- package/base/lib/osBindings/RemoveAdminParams.js.map +1 -0
- package/base/lib/osBindings/RemoveAssetParams.d.ts +4 -0
- package/base/lib/osBindings/{NetworkInterfaceSetPublicParams.js → RemoveAssetParams.js} +1 -1
- package/base/lib/osBindings/RemoveAssetParams.js.map +1 -0
- package/base/lib/osBindings/RemovePackageFromCategoryParams.d.ts +5 -0
- package/base/lib/osBindings/RemovePackageFromCategoryParams.js +3 -0
- package/base/lib/osBindings/RemovePackageFromCategoryParams.js.map +1 -0
- package/base/lib/osBindings/RemovePackageParams.d.ts +6 -0
- package/base/lib/osBindings/RemovePackageParams.js +3 -0
- package/base/lib/osBindings/RemovePackageParams.js.map +1 -0
- package/base/lib/osBindings/index.d.ts +6 -3
- package/base/lib/types.d.ts +20 -33
- package/base/lib/types.js +8 -0
- package/base/lib/types.js.map +1 -1
- package/base/lib/util/GetSystemSmtp.js +7 -2
- package/base/lib/util/GetSystemSmtp.js.map +1 -1
- package/base/lib/util/getServiceInterface.d.ts +10 -0
- package/base/lib/util/getServiceInterface.js +41 -1
- package/base/lib/util/getServiceInterface.js.map +1 -1
- package/base/lib/util/getServiceInterfaces.js +6 -1
- package/base/lib/util/getServiceInterfaces.js.map +1 -1
- package/base/lib/util/index.d.ts +0 -1
- package/base/lib/util/index.js +1 -3
- package/base/lib/util/index.js.map +1 -1
- package/package/lib/StartSdk.d.ts +106 -546
- package/package/lib/StartSdk.js +81 -410
- package/package/lib/StartSdk.js.map +1 -1
- package/package/lib/backup/Backups.d.ts +15 -3
- package/package/lib/backup/Backups.js +47 -5
- package/package/lib/backup/Backups.js.map +1 -1
- package/package/lib/backup/setupBackups.d.ts +5 -2
- package/package/lib/backup/setupBackups.js +7 -5
- package/package/lib/backup/setupBackups.js.map +1 -1
- package/package/lib/health/HealthCheck.js +1 -1
- package/package/lib/health/HealthCheck.js.map +1 -1
- package/package/lib/health/checkFns/runHealthScript.d.ts +2 -1
- package/package/lib/health/checkFns/runHealthScript.js +1 -1
- package/package/lib/health/checkFns/runHealthScript.js.map +1 -1
- package/package/lib/index.d.ts +0 -3
- package/package/lib/index.js +1 -8
- package/package/lib/index.js.map +1 -1
- package/package/lib/inits/index.d.ts +2 -3
- package/package/lib/inits/index.js +16 -3
- package/package/lib/inits/index.js.map +1 -1
- package/package/lib/inits/setupInit.d.ts +7 -13
- package/package/lib/inits/setupInit.js +22 -48
- package/package/lib/inits/setupInit.js.map +1 -1
- package/package/lib/inits/setupInstall.d.ts +10 -10
- package/package/lib/inits/setupInstall.js.map +1 -1
- package/package/lib/inits/setupUninit.d.ts +7 -0
- package/package/lib/inits/setupUninit.js +14 -0
- package/package/lib/inits/setupUninit.js.map +1 -0
- package/package/lib/inits/setupUninstall.d.ts +5 -5
- package/package/lib/inits/setupUninstall.js.map +1 -1
- package/package/lib/mainFn/CommandController.d.ts +4 -13
- package/package/lib/mainFn/CommandController.js +28 -49
- package/package/lib/mainFn/CommandController.js.map +1 -1
- package/package/lib/mainFn/Daemon.d.ts +13 -14
- package/package/lib/mainFn/Daemon.js +44 -12
- package/package/lib/mainFn/Daemon.js.map +1 -1
- package/package/lib/mainFn/Daemons.d.ts +34 -33
- package/package/lib/mainFn/Daemons.js +30 -10
- package/package/lib/mainFn/Daemons.js.map +1 -1
- package/package/lib/mainFn/HealthDaemon.d.ts +6 -6
- package/package/lib/mainFn/HealthDaemon.js +30 -14
- package/package/lib/mainFn/HealthDaemon.js.map +1 -1
- package/package/lib/mainFn/Mounts.d.ts +38 -43
- package/package/lib/mainFn/Mounts.js +19 -48
- package/package/lib/mainFn/Mounts.js.map +1 -1
- package/package/lib/mainFn/Oneshot.d.ts +21 -0
- package/package/lib/mainFn/Oneshot.js +31 -0
- package/package/lib/mainFn/Oneshot.js.map +1 -0
- package/package/lib/mainFn/index.d.ts +1 -1
- package/package/lib/store/getStore.js +7 -2
- package/package/lib/store/getStore.js.map +1 -1
- package/package/lib/test/inputSpecBuilder.test.js +0 -8
- package/package/lib/test/inputSpecBuilder.test.js.map +1 -1
- package/package/lib/test/output.d.ts +2 -38
- package/package/lib/test/output.sdk.d.ts +239 -887
- package/package/lib/test/output.sdk.js +0 -1
- package/package/lib/test/output.sdk.js.map +1 -1
- package/package/lib/util/Drop.d.ts +1 -0
- package/package/lib/util/Drop.js +17 -4
- package/package/lib/util/Drop.js.map +1 -1
- package/package/lib/util/GetSslCertificate.js +7 -2
- package/package/lib/util/GetSslCertificate.js.map +1 -1
- package/package/lib/util/SubContainer.d.ts +160 -44
- package/package/lib/util/SubContainer.js +215 -99
- package/package/lib/util/SubContainer.js.map +1 -1
- package/package/lib/util/fileHelper.d.ts +41 -15
- package/package/lib/util/fileHelper.js +72 -27
- package/package/lib/util/fileHelper.js.map +1 -1
- package/package/lib/version/VersionGraph.d.ts +20 -5
- package/package/lib/version/VersionGraph.js +85 -18
- package/package/lib/version/VersionGraph.js.map +1 -1
- package/package.json +10 -11
- package/base/lib/osBindings/NetworkInterfaceSetPublicParams.d.ts +0 -4
- package/base/lib/osBindings/NetworkInterfaceSetPublicParams.js.map +0 -1
- package/base/lib/osBindings/UnsetPublicParams.d.ts +0 -3
- package/base/lib/osBindings/UnsetPublicParams.js.map +0 -1
package/package/lib/StartSdk.js
CHANGED
|
@@ -47,9 +47,7 @@ const HealthCheck_1 = require("./health/HealthCheck");
|
|
|
47
47
|
const checkPortListening_1 = require("./health/checkFns/checkPortListening");
|
|
48
48
|
const checkFns_1 = require("./health/checkFns");
|
|
49
49
|
const list_1 = require("../../base/lib/actions/input/builder/list");
|
|
50
|
-
const setupInstall_1 = require("./inits/setupInstall");
|
|
51
50
|
const setupBackups_1 = require("./backup/setupBackups");
|
|
52
|
-
const setupUninstall_1 = require("./inits/setupUninstall");
|
|
53
51
|
const mainFn_1 = require("./mainFn");
|
|
54
52
|
const defaultTrigger_1 = require("./trigger/defaultTrigger");
|
|
55
53
|
const trigger_1 = require("./trigger");
|
|
@@ -60,20 +58,19 @@ const ServiceInterfaceBuilder_1 = require("../../base/lib/interfaces/ServiceInte
|
|
|
60
58
|
const util_1 = require("./util");
|
|
61
59
|
const util_2 = require("./util");
|
|
62
60
|
const util_3 = require("./util");
|
|
63
|
-
const getStore_1 = require("./store/getStore");
|
|
64
61
|
const SubContainer_1 = require("./util/SubContainer");
|
|
65
62
|
const util_4 = require("./util");
|
|
66
63
|
const Mounts_1 = require("./mainFn/Mounts");
|
|
67
64
|
const setupDependencies_1 = require("../../base/lib/dependencies/setupDependencies");
|
|
68
65
|
const T = __importStar(require("../../base/lib/types"));
|
|
69
66
|
const exver_1 = require("../../base/lib/exver");
|
|
70
|
-
const PathBuilder_1 = require("../../base/lib/util/PathBuilder");
|
|
71
67
|
const dependencies_1 = require("../../base/lib/dependencies/dependencies");
|
|
72
68
|
const util_5 = require("./util");
|
|
69
|
+
const version_1 = require("./version");
|
|
73
70
|
const actions = __importStar(require("../../base/lib/actions"));
|
|
74
|
-
const setupInit_1 = require("./inits/setupInit");
|
|
75
71
|
const fs = __importStar(require("node:fs/promises"));
|
|
76
|
-
|
|
72
|
+
const inits_1 = require("../../base/lib/inits");
|
|
73
|
+
exports.OSVersion = (0, exver_1.testTypeVersion)("0.4.0-alpha.3");
|
|
77
74
|
class StartSdk {
|
|
78
75
|
constructor(manifest) {
|
|
79
76
|
this.manifest = manifest;
|
|
@@ -84,9 +81,6 @@ class StartSdk {
|
|
|
84
81
|
withManifest(manifest) {
|
|
85
82
|
return new StartSdk(manifest);
|
|
86
83
|
}
|
|
87
|
-
withStore() {
|
|
88
|
-
return new StartSdk(this.manifest);
|
|
89
|
-
}
|
|
90
84
|
build(isReady) {
|
|
91
85
|
const startSdkEffectWrapper = {
|
|
92
86
|
restart: (effects, ...args) => effects.restart(...args),
|
|
@@ -94,13 +88,10 @@ class StartSdk {
|
|
|
94
88
|
checkDependencies: (effects, ...args) => effects.checkDependencies(...args),
|
|
95
89
|
mount: (effects, ...args) => effects.mount(...args),
|
|
96
90
|
getInstalledPackages: (effects, ...args) => effects.getInstalledPackages(...args),
|
|
97
|
-
exposeForDependents: (effects, ...args) => effects.exposeForDependents(...args),
|
|
98
91
|
getServicePortForward: (effects, ...args) => effects.getServicePortForward(...args),
|
|
99
92
|
clearBindings: (effects, ...args) => effects.clearBindings(...args),
|
|
100
93
|
getOsIp: (effects, ...args) => effects.getOsIp(...args),
|
|
101
94
|
getSslKey: (effects, ...args) => effects.getSslKey(...args),
|
|
102
|
-
setDataVersion: (effects, ...args) => effects.setDataVersion(...args),
|
|
103
|
-
getDataVersion: (effects, ...args) => effects.getDataVersion(...args),
|
|
104
95
|
shutdown: (effects, ...args) => effects.shutdown(...args),
|
|
105
96
|
getDependencies: (effects, ...args) => effects.getDependencies(...args),
|
|
106
97
|
getStatus: (effects, ...args) => effects.getStatus(...args),
|
|
@@ -108,6 +99,8 @@ class StartSdk {
|
|
|
108
99
|
return {
|
|
109
100
|
manifest: this.manifest,
|
|
110
101
|
...startSdkEffectWrapper,
|
|
102
|
+
setDataVersion: version_1.setDataVersion,
|
|
103
|
+
getDataVersion: version_1.getDataVersion,
|
|
111
104
|
action: {
|
|
112
105
|
run: actions.runAction,
|
|
113
106
|
request: (effects, packageId, action, severity, options) => actions.requestAction({
|
|
@@ -137,10 +130,15 @@ class StartSdk {
|
|
|
137
130
|
},
|
|
138
131
|
getContainerIp: (effects, options = {}) => {
|
|
139
132
|
async function* watch() {
|
|
140
|
-
|
|
133
|
+
const resolveCell = { resolve: () => { } };
|
|
134
|
+
effects.onLeaveContext(() => {
|
|
135
|
+
resolveCell.resolve();
|
|
136
|
+
});
|
|
137
|
+
while (effects.isInContext) {
|
|
141
138
|
let callback = () => { };
|
|
142
139
|
const waitForNext = new Promise((resolve) => {
|
|
143
140
|
callback = resolve;
|
|
141
|
+
resolveCell.resolve = resolve;
|
|
144
142
|
});
|
|
145
143
|
yield await effects.getContainerIp({ ...options, callback });
|
|
146
144
|
await waitForNext;
|
|
@@ -171,28 +169,11 @@ class StartSdk {
|
|
|
171
169
|
},
|
|
172
170
|
};
|
|
173
171
|
},
|
|
174
|
-
store: {
|
|
175
|
-
get: (effects, packageId, path) => (0, getStore_1.getStore)(effects, path, {
|
|
176
|
-
packageId,
|
|
177
|
-
}),
|
|
178
|
-
getOwn: (effects, path) => (0, getStore_1.getStore)(effects, path),
|
|
179
|
-
setOwn: (effects, path, value) => effects.store.set({
|
|
180
|
-
value,
|
|
181
|
-
path: (0, PathBuilder_1.extractJsonPath)(path),
|
|
182
|
-
}),
|
|
183
|
-
},
|
|
184
172
|
MultiHost: {
|
|
185
173
|
of: (effects, id) => new Host_1.MultiHost({ id, effects }),
|
|
186
174
|
},
|
|
187
175
|
nullIfEmpty: util_2.nullIfEmpty,
|
|
188
176
|
useEntrypoint: (overrideCmd) => new T.UseEntrypoint(overrideCmd),
|
|
189
|
-
runCommand: async (effects, image, command, options,
|
|
190
|
-
/**
|
|
191
|
-
* A name to use to refer to the ephemeral subcontainer for debugging purposes
|
|
192
|
-
*/
|
|
193
|
-
name) => {
|
|
194
|
-
return runCommand(effects, image, command, options, name);
|
|
195
|
-
},
|
|
196
177
|
/**
|
|
197
178
|
* @description Use this class to create an Action. By convention, each Action should receive its own file.
|
|
198
179
|
*
|
|
@@ -265,6 +246,7 @@ class StartSdk {
|
|
|
265
246
|
* In this example, we create an action that returns a secret phrase for the user to see.
|
|
266
247
|
*
|
|
267
248
|
* ```
|
|
249
|
+
import { store } from '../file-models/store.json'
|
|
268
250
|
import { sdk } from '../sdk'
|
|
269
251
|
|
|
270
252
|
export const showSecretPhrase = sdk.Action.withoutInput(
|
|
@@ -289,9 +271,7 @@ class StartSdk {
|
|
|
289
271
|
'Below is your secret phrase. Use it to gain access to extraordinary places',
|
|
290
272
|
result: {
|
|
291
273
|
type: 'single',
|
|
292
|
-
value: await
|
|
293
|
-
.getOwn(effects, sdk.StorePath.secretPhrase)
|
|
294
|
-
.const(),
|
|
274
|
+
value: (await store.read.once())?.secretPhrase,
|
|
295
275
|
copyable: true,
|
|
296
276
|
qr: true,
|
|
297
277
|
masked: true,
|
|
@@ -378,11 +358,11 @@ class StartSdk {
|
|
|
378
358
|
/**
|
|
379
359
|
* @description Use this function to set dependency information.
|
|
380
360
|
* @example
|
|
381
|
-
* In this example, we create a
|
|
361
|
+
* In this example, we create a dependency on Hello World >=1.0.0:0, where Hello World must be running and passing its "primary" health check.
|
|
382
362
|
*
|
|
383
363
|
* ```
|
|
384
364
|
export const setDependencies = sdk.setupDependencies(
|
|
385
|
-
async ({ effects
|
|
365
|
+
async ({ effects }) => {
|
|
386
366
|
return {
|
|
387
367
|
'hello-world': {
|
|
388
368
|
kind: 'running',
|
|
@@ -393,66 +373,61 @@ class StartSdk {
|
|
|
393
373
|
},
|
|
394
374
|
)
|
|
395
375
|
* ```
|
|
396
|
-
* @example
|
|
397
|
-
* In this example, we create a conditional dependency on Hello World based on a hypothetical "needsWorld" boolean in our Store.
|
|
398
|
-
* Using .const() ensures that if the "needsWorld" boolean changes, setupDependencies will re-run.
|
|
399
|
-
*
|
|
400
|
-
* ```
|
|
401
|
-
export const setDependencies = sdk.setupDependencies(
|
|
402
|
-
async ({ effects }) => {
|
|
403
|
-
if (sdk.store.getOwn(sdk.StorePath.needsWorld).const()) {
|
|
404
|
-
return {
|
|
405
|
-
'hello-world': {
|
|
406
|
-
kind: 'running',
|
|
407
|
-
versionRange: '>=1.0.0',
|
|
408
|
-
healthChecks: ['primary'],
|
|
409
|
-
},
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return {}
|
|
413
|
-
},
|
|
414
|
-
)
|
|
415
|
-
* ```
|
|
416
376
|
*/
|
|
417
377
|
setupDependencies: (setupDependencies_1.setupDependencies),
|
|
418
|
-
setupInit: (setupInit_1.setupInit),
|
|
419
378
|
/**
|
|
420
|
-
* @description Use this function to
|
|
379
|
+
* @description Use this function to create an InitScript that runs only when the service is freshly installed
|
|
380
|
+
*/
|
|
381
|
+
setupPostInstall: inits_1.setupPostInstall,
|
|
382
|
+
/**
|
|
383
|
+
* @description Use this function to create an InitScript that runs only when the service is updated
|
|
384
|
+
*/
|
|
385
|
+
setupPostUpdate: inits_1.setupPostUpdate,
|
|
386
|
+
/**
|
|
387
|
+
* @description Use this function to create an InitScript that runs only when the service is installed or updated
|
|
388
|
+
*/
|
|
389
|
+
setupPostInstallOrUpdate: inits_1.setupPostInstallOrUpdate,
|
|
390
|
+
/**
|
|
391
|
+
* @description Use this function to setup what happens when the service initializes.
|
|
392
|
+
*
|
|
393
|
+
* This happens when the server boots, or a service is installed, updated, or restored
|
|
394
|
+
*
|
|
395
|
+
* Not every init script does something on every initialization. For example, versions only does something on install or update
|
|
396
|
+
*
|
|
397
|
+
* These scripts are run in the order they are supplied
|
|
421
398
|
* @example
|
|
422
|
-
* In the this example, we initialize a config file
|
|
423
399
|
*
|
|
424
400
|
* ```
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
401
|
+
export const init = sdk.setupInit(
|
|
402
|
+
backups,
|
|
403
|
+
versions,
|
|
404
|
+
setDependencies,
|
|
405
|
+
setInterfaces,
|
|
406
|
+
actions,
|
|
407
|
+
postInstall,
|
|
408
|
+
)
|
|
428
409
|
* ```
|
|
429
410
|
*/
|
|
430
|
-
|
|
411
|
+
setupInit: inits_1.setupInit,
|
|
431
412
|
/**
|
|
432
|
-
* @description Use this function to
|
|
413
|
+
* @description Use this function to setup what happens when the service uninitializes.
|
|
414
|
+
*
|
|
415
|
+
* This happens when the server shuts down, or a service is uninstalled or updated
|
|
416
|
+
*
|
|
417
|
+
* Not every uninit script does something on every uninitialization. For example, versions only does something on uninstall or update
|
|
418
|
+
*
|
|
419
|
+
* These scripts are run in the order they are supplied
|
|
433
420
|
* @example
|
|
434
|
-
* In the this example, we bootstrap our Store with a random, 16-char admin password.
|
|
435
421
|
*
|
|
436
422
|
* ```
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
sdk.StorePath.adminPassword,
|
|
441
|
-
utils.getDefaultString({
|
|
442
|
-
charset: 'a-z,A-Z,1-9,!,@,$,%,&,',
|
|
443
|
-
len: 16,
|
|
444
|
-
}),
|
|
445
|
-
)
|
|
446
|
-
})
|
|
423
|
+
export const uninit = sdk.setupUninit(
|
|
424
|
+
versions,
|
|
425
|
+
)
|
|
447
426
|
* ```
|
|
448
427
|
*/
|
|
449
|
-
|
|
428
|
+
setupUninit: inits_1.setupUninit,
|
|
450
429
|
/**
|
|
451
430
|
* @description Use this function to determine how this service will be hosted and served. The function executes on service install, service update, and inputSpec save.
|
|
452
|
-
*
|
|
453
|
-
* "input" will be of type `Input` for inputSpec save. It will be `null` for install and update.
|
|
454
|
-
*
|
|
455
|
-
* To learn about creating multi-hosts and interfaces, check out the {@link https://docs.start9.com/packaging-guide/learn/interfaces documentation}.
|
|
456
431
|
* @param inputSpec - The inputSpec spec of this service as exported from /inputSpec/spec.
|
|
457
432
|
* @param fn - an async function that returns an array of interface receipts. The function always has access to `effects`; it has access to `input` only after inputSpec save, otherwise `input` will be null.
|
|
458
433
|
* @example
|
|
@@ -460,8 +435,7 @@ class StartSdk {
|
|
|
460
435
|
*
|
|
461
436
|
* ```
|
|
462
437
|
export const setInterfaces = sdk.setupInterfaces(
|
|
463
|
-
|
|
464
|
-
async ({ effects, input }) => {
|
|
438
|
+
async ({ effects }) => {
|
|
465
439
|
// ** UI multi-host **
|
|
466
440
|
const uiMulti = sdk.MultiHost.of(effects, 'ui-multi')
|
|
467
441
|
const uiMultiOrigin = await uiMulti.bindPort(80, {
|
|
@@ -522,10 +496,6 @@ class StartSdk {
|
|
|
522
496
|
*/
|
|
523
497
|
setupInterfaces: setupInterfaces_1.setupServiceInterfaces,
|
|
524
498
|
setupMain: (fn) => (0, mainFn_1.setupMain)(fn),
|
|
525
|
-
/**
|
|
526
|
-
* Use this function to execute arbitrary logic *once*, on uninstall only. Most services will not use this.
|
|
527
|
-
*/
|
|
528
|
-
setupUninstall: (fn) => (0, setupUninstall_1.setupUninstall)(fn),
|
|
529
499
|
trigger: {
|
|
530
500
|
defaultTrigger: defaultTrigger_1.defaultTrigger,
|
|
531
501
|
cooldownTrigger: trigger_1.cooldownTrigger,
|
|
@@ -572,340 +542,41 @@ class StartSdk {
|
|
|
572
542
|
*/
|
|
573
543
|
of: (spec) => inputSpec_1.InputSpec.of(spec),
|
|
574
544
|
},
|
|
545
|
+
Daemon: {
|
|
546
|
+
get of() {
|
|
547
|
+
return Daemons_1.Daemon.of();
|
|
548
|
+
},
|
|
549
|
+
},
|
|
575
550
|
Daemons: {
|
|
576
551
|
of(effects, started, healthChecks) {
|
|
577
552
|
return Daemons_1.Daemons.of({ effects, started, healthChecks });
|
|
578
553
|
},
|
|
579
554
|
},
|
|
580
555
|
SubContainer: {
|
|
581
|
-
of(effects, image, name) {
|
|
582
|
-
return SubContainer_1.SubContainer.of(effects, image, name);
|
|
583
|
-
},
|
|
584
|
-
with(effects, image, mounts, name, fn) {
|
|
585
|
-
return SubContainer_1.SubContainer.with(effects, image, mounts, name, fn);
|
|
586
|
-
},
|
|
587
|
-
},
|
|
588
|
-
List: {
|
|
589
|
-
/**
|
|
590
|
-
* @description Create a list of text inputs.
|
|
591
|
-
* @param a - attributes of the list itself.
|
|
592
|
-
* @param aSpec - attributes describing each member of the list.
|
|
593
|
-
*/
|
|
594
|
-
text: list_1.List.text,
|
|
595
|
-
/**
|
|
596
|
-
* @description Create a list of objects.
|
|
597
|
-
* @param a - attributes of the list itself.
|
|
598
|
-
* @param aSpec - attributes describing each member of the list.
|
|
599
|
-
*/
|
|
600
|
-
obj: (a, aSpec) => list_1.List.obj(a, aSpec),
|
|
601
|
-
/**
|
|
602
|
-
* @description Create a list of dynamic text inputs.
|
|
603
|
-
* @param a - attributes of the list itself.
|
|
604
|
-
* @param aSpec - attributes describing each member of the list.
|
|
605
|
-
*/
|
|
606
|
-
dynamicText: (list_1.List.dynamicText),
|
|
607
|
-
},
|
|
608
|
-
StorePath: (0, PathBuilder_1.pathBuilder)(),
|
|
609
|
-
Value: {
|
|
610
|
-
/**
|
|
611
|
-
* @description Displays a boolean toggle to enable/disable
|
|
612
|
-
* @example
|
|
613
|
-
* ```
|
|
614
|
-
toggleExample: Value.toggle({
|
|
615
|
-
// required
|
|
616
|
-
name: 'Toggle Example',
|
|
617
|
-
default: true,
|
|
618
|
-
|
|
619
|
-
// optional
|
|
620
|
-
description: null,
|
|
621
|
-
warning: null,
|
|
622
|
-
immutable: false,
|
|
623
|
-
}),
|
|
624
|
-
* ```
|
|
625
|
-
*/
|
|
626
|
-
toggle: value_1.Value.toggle,
|
|
627
|
-
/**
|
|
628
|
-
* @description Displays a text input field
|
|
629
|
-
* @example
|
|
630
|
-
* ```
|
|
631
|
-
textExample: Value.text({
|
|
632
|
-
// required
|
|
633
|
-
name: 'Text Example',
|
|
634
|
-
required: false,
|
|
635
|
-
default: null,
|
|
636
|
-
|
|
637
|
-
// optional
|
|
638
|
-
description: null,
|
|
639
|
-
placeholder: null,
|
|
640
|
-
warning: null,
|
|
641
|
-
generate: null,
|
|
642
|
-
inputmode: 'text',
|
|
643
|
-
masked: false,
|
|
644
|
-
minLength: null,
|
|
645
|
-
maxLength: null,
|
|
646
|
-
patterns: [],
|
|
647
|
-
immutable: false,
|
|
648
|
-
}),
|
|
649
|
-
* ```
|
|
650
|
-
*/
|
|
651
|
-
text: value_1.Value.text,
|
|
652
|
-
/**
|
|
653
|
-
* @description Displays a large textarea field for long form entry.
|
|
654
|
-
* @example
|
|
655
|
-
* ```
|
|
656
|
-
textareaExample: Value.textarea({
|
|
657
|
-
// required
|
|
658
|
-
name: 'Textarea Example',
|
|
659
|
-
required: false,
|
|
660
|
-
default: null,
|
|
661
|
-
|
|
662
|
-
// optional
|
|
663
|
-
description: null,
|
|
664
|
-
placeholder: null,
|
|
665
|
-
warning: null,
|
|
666
|
-
minLength: null,
|
|
667
|
-
maxLength: null,
|
|
668
|
-
immutable: false,
|
|
669
|
-
}),
|
|
670
|
-
* ```
|
|
671
|
-
*/
|
|
672
|
-
textarea: value_1.Value.textarea,
|
|
673
|
-
/**
|
|
674
|
-
* @description Displays a number input field
|
|
675
|
-
* @example
|
|
676
|
-
* ```
|
|
677
|
-
numberExample: Value.number({
|
|
678
|
-
// required
|
|
679
|
-
name: 'Number Example',
|
|
680
|
-
required: false,
|
|
681
|
-
default: null,
|
|
682
|
-
integer: true,
|
|
683
|
-
|
|
684
|
-
// optional
|
|
685
|
-
description: null,
|
|
686
|
-
placeholder: null,
|
|
687
|
-
warning: null,
|
|
688
|
-
min: null,
|
|
689
|
-
max: null,
|
|
690
|
-
immutable: false,
|
|
691
|
-
step: null,
|
|
692
|
-
units: null,
|
|
693
|
-
}),
|
|
694
|
-
* ```
|
|
695
|
-
*/
|
|
696
|
-
number: value_1.Value.number,
|
|
697
|
-
/**
|
|
698
|
-
* @description Displays a browser-native color selector.
|
|
699
|
-
* @example
|
|
700
|
-
* ```
|
|
701
|
-
colorExample: Value.color({
|
|
702
|
-
// required
|
|
703
|
-
name: 'Color Example',
|
|
704
|
-
required: false,
|
|
705
|
-
default: null,
|
|
706
|
-
|
|
707
|
-
// optional
|
|
708
|
-
description: null,
|
|
709
|
-
warning: null,
|
|
710
|
-
immutable: false,
|
|
711
|
-
}),
|
|
712
|
-
* ```
|
|
713
|
-
*/
|
|
714
|
-
color: value_1.Value.color,
|
|
715
|
-
/**
|
|
716
|
-
* @description Displays a browser-native date/time selector.
|
|
717
|
-
* @example
|
|
718
|
-
* ```
|
|
719
|
-
datetimeExample: Value.datetime({
|
|
720
|
-
// required
|
|
721
|
-
name: 'Datetime Example',
|
|
722
|
-
required: false,
|
|
723
|
-
default: null,
|
|
724
|
-
|
|
725
|
-
// optional
|
|
726
|
-
description: null,
|
|
727
|
-
warning: null,
|
|
728
|
-
immutable: false,
|
|
729
|
-
inputmode: 'datetime-local',
|
|
730
|
-
min: null,
|
|
731
|
-
max: null,
|
|
732
|
-
}),
|
|
733
|
-
* ```
|
|
734
|
-
*/
|
|
735
|
-
datetime: value_1.Value.datetime,
|
|
736
|
-
/**
|
|
737
|
-
* @description Displays a select modal with radio buttons, allowing for a single selection.
|
|
738
|
-
* @example
|
|
739
|
-
* ```
|
|
740
|
-
selectExample: Value.select({
|
|
741
|
-
// required
|
|
742
|
-
name: 'Select Example',
|
|
743
|
-
default: 'radio1',
|
|
744
|
-
values: {
|
|
745
|
-
radio1: 'Radio 1',
|
|
746
|
-
radio2: 'Radio 2',
|
|
747
|
-
},
|
|
748
|
-
|
|
749
|
-
// optional
|
|
750
|
-
description: null,
|
|
751
|
-
warning: null,
|
|
752
|
-
immutable: false,
|
|
753
|
-
disabled: false,
|
|
754
|
-
}),
|
|
755
|
-
* ```
|
|
756
|
-
*/
|
|
757
|
-
select: value_1.Value.select,
|
|
758
|
-
/**
|
|
759
|
-
* @description Displays a select modal with checkboxes, allowing for multiple selections.
|
|
760
|
-
* @example
|
|
761
|
-
* ```
|
|
762
|
-
multiselectExample: Value.multiselect({
|
|
763
|
-
// required
|
|
764
|
-
name: 'Multiselect Example',
|
|
765
|
-
values: {
|
|
766
|
-
option1: 'Option 1',
|
|
767
|
-
option2: 'Option 2',
|
|
768
|
-
},
|
|
769
|
-
default: [],
|
|
770
|
-
|
|
771
|
-
// optional
|
|
772
|
-
description: null,
|
|
773
|
-
warning: null,
|
|
774
|
-
immutable: false,
|
|
775
|
-
disabled: false,
|
|
776
|
-
minlength: null,
|
|
777
|
-
maxLength: null,
|
|
778
|
-
}),
|
|
779
|
-
* ```
|
|
780
|
-
*/
|
|
781
|
-
multiselect: value_1.Value.multiselect,
|
|
782
|
-
/**
|
|
783
|
-
* @description Display a collapsable grouping of additional fields, a "sub form". The second value is the inputSpec spec for the sub form.
|
|
784
|
-
* @example
|
|
785
|
-
* ```
|
|
786
|
-
objectExample: Value.object(
|
|
787
|
-
{
|
|
788
|
-
// required
|
|
789
|
-
name: 'Object Example',
|
|
790
|
-
|
|
791
|
-
// optional
|
|
792
|
-
description: null,
|
|
793
|
-
warning: null,
|
|
794
|
-
},
|
|
795
|
-
InputSpec.of({}),
|
|
796
|
-
),
|
|
797
|
-
* ```
|
|
798
|
-
*/
|
|
799
|
-
object: value_1.Value.object,
|
|
800
556
|
/**
|
|
801
|
-
* @description
|
|
802
|
-
* @
|
|
803
|
-
*
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
// required
|
|
807
|
-
name: 'Union Example',
|
|
808
|
-
default: 'option1',
|
|
809
|
-
|
|
810
|
-
// optional
|
|
811
|
-
description: null,
|
|
812
|
-
warning: null,
|
|
813
|
-
disabled: false,
|
|
814
|
-
immutable: false,
|
|
815
|
-
},
|
|
816
|
-
Variants.of({
|
|
817
|
-
option1: {
|
|
818
|
-
name: 'Option 1',
|
|
819
|
-
spec: InputSpec.of({}),
|
|
820
|
-
},
|
|
821
|
-
option2: {
|
|
822
|
-
name: 'Option 2',
|
|
823
|
-
spec: InputSpec.of({}),
|
|
824
|
-
},
|
|
825
|
-
}),
|
|
826
|
-
),
|
|
827
|
-
* ```
|
|
557
|
+
* @description Create a new SubContainer
|
|
558
|
+
* @param effects
|
|
559
|
+
* @param image - what container image to use
|
|
560
|
+
* @param mounts - what to mount to the subcontainer
|
|
561
|
+
* @param name - a name to use to refer to the subcontainer for debugging purposes
|
|
828
562
|
*/
|
|
829
|
-
|
|
563
|
+
of(effects, image, mounts, name) {
|
|
564
|
+
return SubContainer_1.SubContainerOwned.of(effects, image, mounts, name);
|
|
565
|
+
},
|
|
830
566
|
/**
|
|
831
|
-
* @description
|
|
832
|
-
* @
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
listExampleText: Value.list(
|
|
837
|
-
List.text(
|
|
838
|
-
{
|
|
839
|
-
// required
|
|
840
|
-
name: 'Text List',
|
|
841
|
-
|
|
842
|
-
// optional
|
|
843
|
-
description: null,
|
|
844
|
-
warning: null,
|
|
845
|
-
default: [],
|
|
846
|
-
minLength: null,
|
|
847
|
-
maxLength: null,
|
|
848
|
-
},
|
|
849
|
-
{
|
|
850
|
-
// required
|
|
851
|
-
patterns: [],
|
|
852
|
-
|
|
853
|
-
// optional
|
|
854
|
-
placeholder: null,
|
|
855
|
-
generate: null,
|
|
856
|
-
inputmode: 'url',
|
|
857
|
-
masked: false,
|
|
858
|
-
minLength: null,
|
|
859
|
-
maxLength: null,
|
|
860
|
-
},
|
|
861
|
-
),
|
|
862
|
-
),
|
|
863
|
-
* ```
|
|
864
|
-
* @example
|
|
865
|
-
* In this example, we create a list of objects.
|
|
866
|
-
*
|
|
867
|
-
* ```
|
|
868
|
-
listExampleObject: Value.list(
|
|
869
|
-
List.obj(
|
|
870
|
-
{
|
|
871
|
-
// required
|
|
872
|
-
name: 'Object List',
|
|
873
|
-
|
|
874
|
-
// optional
|
|
875
|
-
description: null,
|
|
876
|
-
warning: null,
|
|
877
|
-
default: [],
|
|
878
|
-
minLength: null,
|
|
879
|
-
maxLength: null,
|
|
880
|
-
},
|
|
881
|
-
{
|
|
882
|
-
// required
|
|
883
|
-
spec: InputSpec.of({}),
|
|
884
|
-
|
|
885
|
-
// optional
|
|
886
|
-
displayAs: null,
|
|
887
|
-
uniqueBy: null,
|
|
888
|
-
},
|
|
889
|
-
),
|
|
890
|
-
),
|
|
891
|
-
* ```
|
|
567
|
+
* @description Run a function with a temporary SubContainer
|
|
568
|
+
* @param effects
|
|
569
|
+
* @param image - what container image to use
|
|
570
|
+
* @param mounts - what to mount to the subcontainer
|
|
571
|
+
* @param name - a name to use to refer to the ephemeral subcontainer for debugging purposes
|
|
892
572
|
*/
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
dynamicText: (value_1.Value.dynamicText),
|
|
897
|
-
dynamicTextarea: (value_1.Value.dynamicTextarea),
|
|
898
|
-
dynamicNumber: (value_1.Value.dynamicNumber),
|
|
899
|
-
dynamicColor: (value_1.Value.dynamicColor),
|
|
900
|
-
dynamicDatetime: (value_1.Value.dynamicDatetime),
|
|
901
|
-
dynamicSelect: (value_1.Value.dynamicSelect),
|
|
902
|
-
dynamicMultiselect: (value_1.Value.dynamicMultiselect),
|
|
903
|
-
filteredUnion: (getDisabledFn, a, aVariants) => value_1.Value.filteredUnion(getDisabledFn, a, aVariants),
|
|
904
|
-
dynamicUnion: (getA, aVariants) => value_1.Value.dynamicUnion(getA, aVariants),
|
|
905
|
-
},
|
|
906
|
-
Variants: {
|
|
907
|
-
of: (a) => variants_1.Variants.of(a),
|
|
573
|
+
withTemp(effects, image, mounts, name, fn) {
|
|
574
|
+
return SubContainer_1.SubContainerOwned.withTemp(effects, image, mounts, name, fn);
|
|
575
|
+
},
|
|
908
576
|
},
|
|
577
|
+
List: list_1.List,
|
|
578
|
+
Value: value_1.Value,
|
|
579
|
+
Variants: variants_1.Variants,
|
|
909
580
|
};
|
|
910
581
|
}
|
|
911
582
|
}
|
|
@@ -920,11 +591,11 @@ async function runCommand(effects, image, command, options, name) {
|
|
|
920
591
|
.catch(() => "{}")
|
|
921
592
|
.then(JSON.parse);
|
|
922
593
|
commands = imageMeta.entrypoint ?? [];
|
|
923
|
-
commands.concat(...(command.overridCmd ?? imageMeta.cmd ?? []));
|
|
594
|
+
commands = commands.concat(...(command.overridCmd ?? imageMeta.cmd ?? []));
|
|
924
595
|
}
|
|
925
596
|
else
|
|
926
597
|
commands = (0, util_4.splitCommand)(command);
|
|
927
|
-
return SubContainer_1.
|
|
598
|
+
return SubContainer_1.SubContainerOwned.withTemp(effects, image, options.mounts, name ||
|
|
928
599
|
commands
|
|
929
600
|
.map((c) => {
|
|
930
601
|
if (c.includes(" ")) {
|