@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.
Files changed (155) hide show
  1. package/base/lib/Effects.d.ts +4 -22
  2. package/base/lib/actions/index.d.ts +5 -5
  3. package/base/lib/actions/index.js.map +1 -1
  4. package/base/lib/actions/input/builder/inputSpec.d.ts +10 -25
  5. package/base/lib/actions/input/builder/inputSpec.js +0 -17
  6. package/base/lib/actions/input/builder/inputSpec.js.map +1 -1
  7. package/base/lib/actions/input/builder/list.d.ts +8 -23
  8. package/base/lib/actions/input/builder/list.js +0 -17
  9. package/base/lib/actions/input/builder/list.js.map +1 -1
  10. package/base/lib/actions/input/builder/value.d.ts +318 -53
  11. package/base/lib/actions/input/builder/value.js +280 -17
  12. package/base/lib/actions/input/builder/value.js.map +1 -1
  13. package/base/lib/actions/input/builder/variants.d.ts +8 -23
  14. package/base/lib/actions/input/builder/variants.js +0 -17
  15. package/base/lib/actions/input/builder/variants.js.map +1 -1
  16. package/base/lib/actions/input/inputSpecConstants.d.ts +6 -6
  17. package/base/lib/actions/input/inputSpecConstants.js.map +1 -1
  18. package/base/lib/actions/setupActions.d.ts +10 -11
  19. package/base/lib/actions/setupActions.js +24 -11
  20. package/base/lib/actions/setupActions.js.map +1 -1
  21. package/base/lib/dependencies/setupDependencies.d.ts +1 -3
  22. package/base/lib/dependencies/setupDependencies.js +3 -12
  23. package/base/lib/dependencies/setupDependencies.js.map +1 -1
  24. package/base/lib/index.d.ts +1 -0
  25. package/base/lib/index.js +2 -1
  26. package/base/lib/index.js.map +1 -1
  27. package/base/lib/inits/index.d.ts +2 -0
  28. package/base/lib/inits/index.js +19 -0
  29. package/base/lib/inits/index.js.map +1 -0
  30. package/base/lib/inits/setupInit.d.ts +11 -0
  31. package/base/lib/inits/setupInit.js +69 -0
  32. package/base/lib/inits/setupInit.js.map +1 -0
  33. package/base/lib/inits/setupUninit.d.ts +7 -0
  34. package/base/lib/inits/setupUninit.js +14 -0
  35. package/base/lib/inits/setupUninit.js.map +1 -0
  36. package/base/lib/interfaces/setupInterfaces.d.ts +2 -4
  37. package/base/lib/interfaces/setupInterfaces.js +8 -19
  38. package/base/lib/interfaces/setupInterfaces.js.map +1 -1
  39. package/base/lib/osBindings/AddCategoryParams.d.ts +0 -2
  40. package/base/lib/osBindings/AddPackageToCategoryParams.d.ts +5 -0
  41. package/base/lib/osBindings/AddPackageToCategoryParams.js +3 -0
  42. package/base/lib/osBindings/AddPackageToCategoryParams.js.map +1 -0
  43. package/base/lib/osBindings/Category.d.ts +0 -2
  44. package/base/lib/osBindings/Category.js +1 -0
  45. package/base/lib/osBindings/Category.js.map +1 -1
  46. package/base/lib/osBindings/FileType.d.ts +1 -0
  47. package/base/lib/osBindings/{UnsetPublicParams.js → FileType.js} +1 -1
  48. package/base/lib/osBindings/FileType.js.map +1 -0
  49. package/base/lib/osBindings/GetOsVersionParams.d.ts +4 -3
  50. package/base/lib/osBindings/GetPackageParams.d.ts +1 -1
  51. package/base/lib/osBindings/MainStatus.d.ts +0 -2
  52. package/base/lib/osBindings/MountTarget.d.ts +2 -0
  53. package/base/lib/osBindings/PackageDataEntry.d.ts +1 -2
  54. package/base/lib/osBindings/RemoveAdminParams.d.ts +4 -0
  55. package/base/lib/osBindings/RemoveAdminParams.js +3 -0
  56. package/base/lib/osBindings/RemoveAdminParams.js.map +1 -0
  57. package/base/lib/osBindings/RemoveAssetParams.d.ts +4 -0
  58. package/base/lib/osBindings/{NetworkInterfaceSetPublicParams.js → RemoveAssetParams.js} +1 -1
  59. package/base/lib/osBindings/RemoveAssetParams.js.map +1 -0
  60. package/base/lib/osBindings/RemovePackageFromCategoryParams.d.ts +5 -0
  61. package/base/lib/osBindings/RemovePackageFromCategoryParams.js +3 -0
  62. package/base/lib/osBindings/RemovePackageFromCategoryParams.js.map +1 -0
  63. package/base/lib/osBindings/RemovePackageParams.d.ts +6 -0
  64. package/base/lib/osBindings/RemovePackageParams.js +3 -0
  65. package/base/lib/osBindings/RemovePackageParams.js.map +1 -0
  66. package/base/lib/osBindings/index.d.ts +6 -3
  67. package/base/lib/types.d.ts +20 -33
  68. package/base/lib/types.js +8 -0
  69. package/base/lib/types.js.map +1 -1
  70. package/base/lib/util/GetSystemSmtp.js +7 -2
  71. package/base/lib/util/GetSystemSmtp.js.map +1 -1
  72. package/base/lib/util/getServiceInterface.d.ts +10 -0
  73. package/base/lib/util/getServiceInterface.js +41 -1
  74. package/base/lib/util/getServiceInterface.js.map +1 -1
  75. package/base/lib/util/getServiceInterfaces.js +6 -1
  76. package/base/lib/util/getServiceInterfaces.js.map +1 -1
  77. package/base/lib/util/index.d.ts +0 -1
  78. package/base/lib/util/index.js +1 -3
  79. package/base/lib/util/index.js.map +1 -1
  80. package/package/lib/StartSdk.d.ts +106 -546
  81. package/package/lib/StartSdk.js +81 -410
  82. package/package/lib/StartSdk.js.map +1 -1
  83. package/package/lib/backup/Backups.d.ts +15 -3
  84. package/package/lib/backup/Backups.js +47 -5
  85. package/package/lib/backup/Backups.js.map +1 -1
  86. package/package/lib/backup/setupBackups.d.ts +5 -2
  87. package/package/lib/backup/setupBackups.js +7 -5
  88. package/package/lib/backup/setupBackups.js.map +1 -1
  89. package/package/lib/health/HealthCheck.js +1 -1
  90. package/package/lib/health/HealthCheck.js.map +1 -1
  91. package/package/lib/health/checkFns/runHealthScript.d.ts +2 -1
  92. package/package/lib/health/checkFns/runHealthScript.js +1 -1
  93. package/package/lib/health/checkFns/runHealthScript.js.map +1 -1
  94. package/package/lib/index.d.ts +0 -3
  95. package/package/lib/index.js +1 -8
  96. package/package/lib/index.js.map +1 -1
  97. package/package/lib/inits/index.d.ts +2 -3
  98. package/package/lib/inits/index.js +16 -3
  99. package/package/lib/inits/index.js.map +1 -1
  100. package/package/lib/inits/setupInit.d.ts +7 -13
  101. package/package/lib/inits/setupInit.js +22 -48
  102. package/package/lib/inits/setupInit.js.map +1 -1
  103. package/package/lib/inits/setupInstall.d.ts +10 -10
  104. package/package/lib/inits/setupInstall.js.map +1 -1
  105. package/package/lib/inits/setupUninit.d.ts +7 -0
  106. package/package/lib/inits/setupUninit.js +14 -0
  107. package/package/lib/inits/setupUninit.js.map +1 -0
  108. package/package/lib/inits/setupUninstall.d.ts +5 -5
  109. package/package/lib/inits/setupUninstall.js.map +1 -1
  110. package/package/lib/mainFn/CommandController.d.ts +4 -13
  111. package/package/lib/mainFn/CommandController.js +28 -49
  112. package/package/lib/mainFn/CommandController.js.map +1 -1
  113. package/package/lib/mainFn/Daemon.d.ts +13 -14
  114. package/package/lib/mainFn/Daemon.js +44 -12
  115. package/package/lib/mainFn/Daemon.js.map +1 -1
  116. package/package/lib/mainFn/Daemons.d.ts +34 -33
  117. package/package/lib/mainFn/Daemons.js +30 -10
  118. package/package/lib/mainFn/Daemons.js.map +1 -1
  119. package/package/lib/mainFn/HealthDaemon.d.ts +6 -6
  120. package/package/lib/mainFn/HealthDaemon.js +30 -14
  121. package/package/lib/mainFn/HealthDaemon.js.map +1 -1
  122. package/package/lib/mainFn/Mounts.d.ts +38 -43
  123. package/package/lib/mainFn/Mounts.js +19 -48
  124. package/package/lib/mainFn/Mounts.js.map +1 -1
  125. package/package/lib/mainFn/Oneshot.d.ts +21 -0
  126. package/package/lib/mainFn/Oneshot.js +31 -0
  127. package/package/lib/mainFn/Oneshot.js.map +1 -0
  128. package/package/lib/mainFn/index.d.ts +1 -1
  129. package/package/lib/store/getStore.js +7 -2
  130. package/package/lib/store/getStore.js.map +1 -1
  131. package/package/lib/test/inputSpecBuilder.test.js +0 -8
  132. package/package/lib/test/inputSpecBuilder.test.js.map +1 -1
  133. package/package/lib/test/output.d.ts +2 -38
  134. package/package/lib/test/output.sdk.d.ts +239 -887
  135. package/package/lib/test/output.sdk.js +0 -1
  136. package/package/lib/test/output.sdk.js.map +1 -1
  137. package/package/lib/util/Drop.d.ts +1 -0
  138. package/package/lib/util/Drop.js +17 -4
  139. package/package/lib/util/Drop.js.map +1 -1
  140. package/package/lib/util/GetSslCertificate.js +7 -2
  141. package/package/lib/util/GetSslCertificate.js.map +1 -1
  142. package/package/lib/util/SubContainer.d.ts +160 -44
  143. package/package/lib/util/SubContainer.js +215 -99
  144. package/package/lib/util/SubContainer.js.map +1 -1
  145. package/package/lib/util/fileHelper.d.ts +41 -15
  146. package/package/lib/util/fileHelper.js +72 -27
  147. package/package/lib/util/fileHelper.js.map +1 -1
  148. package/package/lib/version/VersionGraph.d.ts +20 -5
  149. package/package/lib/version/VersionGraph.js +85 -18
  150. package/package/lib/version/VersionGraph.js.map +1 -1
  151. package/package.json +10 -11
  152. package/base/lib/osBindings/NetworkInterfaceSetPublicParams.d.ts +0 -4
  153. package/base/lib/osBindings/NetworkInterfaceSetPublicParams.js.map +0 -1
  154. package/base/lib/osBindings/UnsetPublicParams.d.ts +0 -3
  155. package/base/lib/osBindings/UnsetPublicParams.js.map +0 -1
@@ -1,53 +1,49 @@
1
1
  import { Value } from "../../base/lib/actions/input/builder/value";
2
- import { InputSpec, LazyBuild } from "../../base/lib/actions/input/builder/inputSpec";
3
- import { DefaultString, ListValueSpecText, Pattern, RandomString, ValueSpecDatetime, ValueSpecText } from "../../base/lib/actions/input/inputSpecTypes";
2
+ import { InputSpec } from "../../base/lib/actions/input/builder/inputSpec";
4
3
  import { Variants } from "../../base/lib/actions/input/builder/variants";
5
4
  import { Action, Actions } from "../../base/lib/actions/setupActions";
6
5
  import { SyncOptions, ServiceInterfaceId, PackageId, ServiceInterfaceType, Effects } from "../../base/lib/types";
7
6
  import * as patterns from "../../base/lib/util/patterns";
8
7
  import { BackupSync, Backups } from "./backup/Backups";
9
- import { Daemons } from "./mainFn/Daemons";
8
+ import { Daemon, Daemons } from "./mainFn/Daemons";
10
9
  import { HealthCheck } from "./health/HealthCheck";
11
10
  import { checkPortListening } from "./health/checkFns/checkPortListening";
12
11
  import { List } from "../../base/lib/actions/input/builder/list";
13
- import { InstallFn, PostInstall, PreInstall } from "./inits/setupInstall";
14
12
  import { SetupBackupsParams } from "./backup/setupBackups";
15
- import { UninstallFn } from "./inits/setupUninstall";
16
13
  import { changeOnFirstSuccess, cooldownTrigger } from "./trigger";
17
- import { UpdateServiceInterfaces } from "../../base/lib/interfaces/setupInterfaces";
18
14
  import { MultiHost, Scheme } from "../../base/lib/interfaces/Host";
19
15
  import { ServiceInterfaceBuilder } from "../../base/lib/interfaces/ServiceInterfaceBuilder";
20
16
  import { GetSystemSmtp } from "./util";
21
17
  import { nullIfEmpty } from "./util";
22
- import { CommandOptions, MountOptions, SubContainer } from "./util/SubContainer";
18
+ import { CommandOptions, SubContainer, SubContainerOwned } from "./util/SubContainer";
23
19
  import { Mounts } from "./mainFn/Mounts";
24
20
  import * as T from "../../base/lib/types";
25
- import { ExposedStorePaths } from "./store/setupExposeStore";
26
- import { PathBuilder } from "../../base/lib/util/PathBuilder";
27
21
  import { CheckDependencies } from "../../base/lib/dependencies/dependencies";
28
22
  import { GetSslCertificate } from "./util";
29
- import { VersionGraph } from "./version";
23
+ import { getDataVersion, setDataVersion } from "./version";
30
24
  import { MaybeFn } from "../../base/lib/actions/setupActions";
31
25
  import { GetInput } from "../../base/lib/actions/setupActions";
32
26
  import { Run } from "../../base/lib/actions/setupActions";
33
27
  import * as actions from "../../base/lib/actions";
34
- export declare const OSVersion: "0.4.0-alpha.0";
28
+ import { setupInit, setupUninit, setupPostInstall, setupPostUpdate, setupPostInstallOrUpdate } from "../../base/lib/inits";
29
+ export declare const OSVersion: "0.4.0-alpha.3";
35
30
  type AnyNeverCond<T extends any[], Then, Else> = T extends [] ? Else : T extends [never, ...Array<any>] ? Then : T extends [any, ...infer U] ? AnyNeverCond<U, Then, Else> : never;
36
- export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
31
+ export declare class StartSdk<Manifest extends T.SDKManifest> {
37
32
  readonly manifest: Manifest;
38
33
  private constructor();
39
- static of(): StartSdk<never, never>;
40
- withManifest<Manifest extends T.SDKManifest = never>(manifest: Manifest): StartSdk<Manifest, Store>;
41
- withStore<Store extends Record<string, any>>(): StartSdk<Manifest, Store>;
42
- build(isReady: AnyNeverCond<[Manifest, Store], "Build not ready", true>): {
34
+ static of(): StartSdk<never>;
35
+ withManifest<Manifest extends T.SDKManifest = never>(manifest: Manifest): StartSdk<Manifest>;
36
+ build(isReady: AnyNeverCond<[Manifest], "Build not ready", true>): {
37
+ setDataVersion: typeof setDataVersion;
38
+ getDataVersion: typeof getDataVersion;
43
39
  action: {
44
40
  run: <Input extends Record<string, unknown>>(options: {
45
41
  effects: T.Effects;
46
42
  actionId: T.ActionId;
47
43
  input?: actions.RunActionInput<Input>;
48
44
  }) => Promise<T.ActionResult | null>;
49
- request: <T extends Action<T.ActionId, any, any>>(effects: T.Effects, packageId: T.PackageId, action: T, severity: T.ActionSeverity, options?: actions.ActionRequestOptions<T>) => Promise<null>;
50
- requestOwn: <T extends Action<T.ActionId, Store, any>>(effects: T.Effects, action: T, severity: T.ActionSeverity, options?: actions.ActionRequestOptions<T>) => Promise<null>;
45
+ request: <T extends Action<T.ActionId, any>>(effects: T.Effects, packageId: T.PackageId, action: T, severity: T.ActionSeverity, options?: actions.ActionRequestOptions<T>) => Promise<null>;
46
+ requestOwn: <T extends Action<T.ActionId, any>>(effects: T.Effects, action: T, severity: T.ActionSeverity, options?: actions.ActionRequestOptions<T>) => Promise<null>;
51
47
  clearRequest: (effects: T.Effects, ...replayIds: string[]) => Promise<null>;
52
48
  };
53
49
  checkDependencies: <DependencyId extends keyof Manifest["dependencies"] & PackageId = keyof Manifest["dependencies"] & PackageId>(effects: Effects, packageIds?: DependencyId[]) => Promise<CheckDependencies<DependencyId>>;
@@ -68,25 +64,11 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
68
64
  watch: () => AsyncGenerator<string, void, unknown>;
69
65
  onChange: (callback: (value: string | null, error?: Error) => void | Promise<void>) => void;
70
66
  };
71
- store: {
72
- get: <E extends Effects, StoreValue = unknown>(effects: E, packageId: string, path: PathBuilder<Store, StoreValue>) => import("./store/getStore").GetStore<Store, StoreValue>;
73
- getOwn: <E extends Effects, StoreValue = unknown>(effects: E, path: PathBuilder<Store, StoreValue>) => import("./store/getStore").GetStore<Store, StoreValue>;
74
- setOwn: <E extends Effects, Path extends PathBuilder<Store, unknown>>(effects: E, path: Path, value: Path extends PathBuilder<Store, infer Value> ? Value : never) => Promise<null>;
75
- };
76
67
  MultiHost: {
77
68
  of: (effects: Effects, id: string) => MultiHost;
78
69
  };
79
70
  nullIfEmpty: typeof nullIfEmpty;
80
71
  useEntrypoint: (overrideCmd?: string[]) => T.UseEntrypoint;
81
- runCommand: <A extends string>(effects: Effects, image: {
82
- imageId: keyof Manifest["images"] & T.ImageId;
83
- sharedRun?: boolean;
84
- }, command: T.CommandType, options: CommandOptions & {
85
- mounts: Mounts<Manifest>;
86
- }, name?: string) => Promise<{
87
- stdout: string | Buffer;
88
- stderr: string | Buffer;
89
- }>;
90
72
  /**
91
73
  * @description Use this class to create an Action. By convention, each Action should receive its own file.
92
74
  *
@@ -149,7 +131,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
149
131
  )
150
132
  * ```
151
133
  */
152
- withInput: <Id extends T.ActionId, InputSpecType extends Record<string, any> | InputSpec<any, any> | InputSpec<any, never>>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, "hasInput">>, inputSpec: InputSpecType, getInput: GetInput<InputSpecType>, run: Run<InputSpecType>) => Action<Id, unknown, InputSpecType>;
134
+ withInput: <Id extends T.ActionId, InputSpecType extends Record<string, any> | InputSpec<any>>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, "hasInput">>, inputSpec: InputSpecType, getInput: GetInput<InputSpecType>, run: Run<InputSpecType>) => Action<Id, InputSpecType>;
153
135
  /**
154
136
  * @description Use this function to create an action that does not accept form input
155
137
  * @param id - a unique ID for this action
@@ -159,6 +141,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
159
141
  * In this example, we create an action that returns a secret phrase for the user to see.
160
142
  *
161
143
  * ```
144
+ import { store } from '../file-models/store.json'
162
145
  import { sdk } from '../sdk'
163
146
 
164
147
  export const showSecretPhrase = sdk.Action.withoutInput(
@@ -183,9 +166,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
183
166
  'Below is your secret phrase. Use it to gain access to extraordinary places',
184
167
  result: {
185
168
  type: 'single',
186
- value: await sdk.store
187
- .getOwn(effects, sdk.StorePath.secretPhrase)
188
- .const(),
169
+ value: (await store.read.once())?.secretPhrase,
189
170
  copyable: true,
190
171
  qr: true,
191
172
  masked: true,
@@ -194,19 +175,19 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
194
175
  )
195
176
  * ```
196
177
  */
197
- withoutInput: <Id extends T.ActionId>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, "hasInput">>, run: Run<{}>) => Action<Id, unknown, {}>;
178
+ withoutInput: <Id extends T.ActionId>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, "hasInput">>, run: Run<{}>) => Action<Id, {}>;
198
179
  };
199
180
  inputSpecConstants: {
200
- smtpInputSpec: Value<import("../../base/lib/actions/input/builder/variants").UnionRes<never, {
181
+ smtpInputSpec: Value<import("../../base/lib/actions/input/builder/variants").UnionRes<{
201
182
  disabled: {
202
183
  name: string;
203
- spec: InputSpec<{}, Store_1>;
184
+ spec: InputSpec<{}>;
204
185
  };
205
186
  system: {
206
187
  name: string;
207
188
  spec: InputSpec<{
208
189
  customFrom: string | null;
209
- }, Store_1>;
190
+ }>;
210
191
  };
211
192
  custom: {
212
193
  name: string;
@@ -216,9 +197,9 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
216
197
  from: string;
217
198
  login: string;
218
199
  password: string | null | undefined;
219
- }, never>;
200
+ }>;
220
201
  };
221
- }, "disabled" | "system" | "custom">, never>;
202
+ }, "disabled" | "system" | "custom">>;
222
203
  };
223
204
  /**
224
205
  * @description Use this function to create a service interface.
@@ -277,7 +258,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
277
258
  successMessage?: string | undefined;
278
259
  errorMessage?: string | undefined;
279
260
  }) => Promise<import("./health/checkFns").HealthCheckResult>;
280
- runHealthScript: (runCommand: string[], subcontainer: SubContainer, { timeout, errorMessage, message, }?: {
261
+ runHealthScript: <Manifest_1 extends T.SDKManifest>(runCommand: string[], subcontainer: SubContainer<Manifest_1>, { timeout, errorMessage, message, }?: {
281
262
  timeout?: number | undefined;
282
263
  errorMessage?: string | undefined;
283
264
  message?: ((res: string) => string) | undefined;
@@ -299,8 +280,8 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
299
280
  * ```
300
281
  */
301
282
  Actions: {
302
- new (actions: {}): Actions<Store, {}>;
303
- of<Store_2>(): Actions<Store_2, {}>;
283
+ new (actions: {}): Actions<{}>;
284
+ of(): Actions<{}>;
304
285
  };
305
286
  /**
306
287
  * @description Use this function to determine which volumes are backed up when a user creates a backup, including advanced options.
@@ -329,16 +310,16 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
329
310
  */
330
311
  setupBackups: (options: SetupBackupsParams<Manifest>) => {
331
312
  createBackup: T.ExpectedExports.createBackup;
332
- restoreBackup: T.ExpectedExports.restoreBackup;
313
+ restoreInit: import("../../base/lib/inits").InitScript;
333
314
  };
334
315
  /**
335
316
  * @description Use this function to set dependency information.
336
317
  * @example
337
- * In this example, we create a perpetual dependency on Hello World >=1.0.0:0, where Hello World must be running and passing its "primary" health check.
318
+ * 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.
338
319
  *
339
320
  * ```
340
321
  export const setDependencies = sdk.setupDependencies(
341
- async ({ effects, input }) => {
322
+ async ({ effects }) => {
342
323
  return {
343
324
  'hello-world': {
344
325
  kind: 'running',
@@ -349,76 +330,63 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
349
330
  },
350
331
  )
351
332
  * ```
352
- * @example
353
- * In this example, we create a conditional dependency on Hello World based on a hypothetical "needsWorld" boolean in our Store.
354
- * Using .const() ensures that if the "needsWorld" boolean changes, setupDependencies will re-run.
355
- *
356
- * ```
357
- export const setDependencies = sdk.setupDependencies(
358
- async ({ effects }) => {
359
- if (sdk.store.getOwn(sdk.StorePath.needsWorld).const()) {
360
- return {
361
- 'hello-world': {
362
- kind: 'running',
363
- versionRange: '>=1.0.0',
364
- healthChecks: ['primary'],
365
- },
366
- }
367
- }
368
- return {}
369
- },
370
- )
371
- * ```
372
333
  */
373
334
  setupDependencies: (fn: (options: {
374
335
  effects: T.Effects;
375
- }) => Promise<T.CurrentDependenciesResult<Manifest>>) => (options: {
376
- effects: T.Effects;
377
- }) => Promise<null>;
378
- setupInit: (versions: VersionGraph<string>, preInstall: PreInstall<Manifest, Store>, postInstall: PostInstall<Manifest, Store>, uninstall: import("./inits/setupUninstall").Uninstall<Manifest, Store>, setServiceInterfaces: UpdateServiceInterfaces<any>, setDependencies: (options: {
379
- effects: T.Effects;
380
- }) => Promise<null | void | undefined>, actions: Actions<Store, any>, initStore: Store, exposedStore: ExposedStorePaths) => {
381
- packageInit: T.ExpectedExports.packageInit;
382
- packageUninit: T.ExpectedExports.packageUninit;
383
- containerInit: T.ExpectedExports.containerInit;
384
- };
336
+ }) => Promise<T.CurrentDependenciesResult<Manifest>>) => (effects: T.Effects) => Promise<null>;
337
+ /**
338
+ * @description Use this function to create an InitScript that runs only when the service is freshly installed
339
+ */
340
+ setupPostInstall: typeof setupPostInstall;
385
341
  /**
386
- * @description Use this function to execute arbitrary logic *once*, on initial install *before* interfaces, actions, and dependencies are updated.
342
+ * @description Use this function to create an InitScript that runs only when the service is updated
343
+ */
344
+ setupPostUpdate: typeof setupPostUpdate;
345
+ /**
346
+ * @description Use this function to create an InitScript that runs only when the service is installed or updated
347
+ */
348
+ setupPostInstallOrUpdate: typeof setupPostInstallOrUpdate;
349
+ /**
350
+ * @description Use this function to setup what happens when the service initializes.
351
+ *
352
+ * This happens when the server boots, or a service is installed, updated, or restored
353
+ *
354
+ * Not every init script does something on every initialization. For example, versions only does something on install or update
355
+ *
356
+ * These scripts are run in the order they are supplied
387
357
  * @example
388
- * In the this example, we initialize a config file
389
358
  *
390
359
  * ```
391
- const preInstall = sdk.setupPreInstall(async ({ effects }) => {
392
- await configFile.write(effects, { name: 'World' })
393
- })
360
+ export const init = sdk.setupInit(
361
+ backups,
362
+ versions,
363
+ setDependencies,
364
+ setInterfaces,
365
+ actions,
366
+ postInstall,
367
+ )
394
368
  * ```
395
369
  */
396
- setupPreInstall: (fn: InstallFn<Manifest, Store>) => PreInstall<Manifest, Store>;
370
+ setupInit: typeof setupInit;
397
371
  /**
398
- * @description Use this function to execute arbitrary logic *once*, on initial install *after* interfaces, actions, and dependencies are updated.
372
+ * @description Use this function to setup what happens when the service uninitializes.
373
+ *
374
+ * This happens when the server shuts down, or a service is uninstalled or updated
375
+ *
376
+ * Not every uninit script does something on every uninitialization. For example, versions only does something on uninstall or update
377
+ *
378
+ * These scripts are run in the order they are supplied
399
379
  * @example
400
- * In the this example, we bootstrap our Store with a random, 16-char admin password.
401
380
  *
402
381
  * ```
403
- const postInstall = sdk.setupPostInstall(async ({ effects }) => {
404
- await sdk.store.setOwn(
405
- effects,
406
- sdk.StorePath.adminPassword,
407
- utils.getDefaultString({
408
- charset: 'a-z,A-Z,1-9,!,@,$,%,&,',
409
- len: 16,
410
- }),
411
- )
412
- })
382
+ export const uninit = sdk.setupUninit(
383
+ versions,
384
+ )
413
385
  * ```
414
386
  */
415
- setupPostInstall: (fn: InstallFn<Manifest, Store>) => PostInstall<Manifest, Store>;
387
+ setupUninit: typeof setupUninit;
416
388
  /**
417
389
  * @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.
418
- *
419
- * "input" will be of type `Input` for inputSpec save. It will be `null` for install and update.
420
- *
421
- * To learn about creating multi-hosts and interfaces, check out the {@link https://docs.start9.com/packaging-guide/learn/interfaces documentation}.
422
390
  * @param inputSpec - The inputSpec spec of this service as exported from /inputSpec/spec.
423
391
  * @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.
424
392
  * @example
@@ -426,8 +394,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
426
394
  *
427
395
  * ```
428
396
  export const setInterfaces = sdk.setupInterfaces(
429
- inputSpecSpec,
430
- async ({ effects, input }) => {
397
+ async ({ effects }) => {
431
398
  // ** UI multi-host **
432
399
  const uiMulti = sdk.MultiHost.of(effects, 'ui-multi')
433
400
  const uiMultiOrigin = await uiMulti.bindPort(80, {
@@ -491,10 +458,6 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
491
458
  effects: Effects;
492
459
  started(onTerm: () => PromiseLike<void>): PromiseLike<null>;
493
460
  }) => Promise<Daemons<Manifest, any>>) => T.ExpectedExports.main;
494
- /**
495
- * Use this function to execute arbitrary logic *once*, on uninstall only. Most services will not use this.
496
- */
497
- setupUninstall: (fn: UninstallFn<Manifest, Store>) => import("./inits/setupUninstall").Uninstall<Manifest, Store>;
498
461
  trigger: {
499
462
  defaultTrigger: import("./trigger").Trigger;
500
463
  cooldownTrigger: typeof cooldownTrigger;
@@ -505,7 +468,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
505
468
  }) => import("./trigger").Trigger;
506
469
  };
507
470
  Mounts: {
508
- of(): Mounts<Manifest>;
471
+ of(): Mounts<Manifest, never>;
509
472
  };
510
473
  Backups: {
511
474
  volumes: (...volumeNames: Array<Manifest["volumes"][number] & string>) => Backups<Manifest>;
@@ -540,447 +503,51 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
540
503
  })
541
504
  * ```
542
505
  */
543
- of: <Spec extends Record<string, Value<any, Store> | Value<any, never>>>(spec: Spec) => InputSpec<{ [K in keyof Spec]: Spec[K] extends Value<infer T, never> | Value<infer T, Store> ? T : never; }, Store>;
506
+ of: <Spec extends Record<string, Value<any>>>(spec: Spec) => InputSpec<{ [K in keyof Spec]: Spec[K] extends Value<infer T> ? T : never; }>;
507
+ };
508
+ Daemon: {
509
+ readonly of: (effects: T.Effects, subcontainer: SubContainer<Manifest, Effects>, command: T.CommandType, options: {
510
+ runAsInit?: boolean;
511
+ env?: {
512
+ [variable: string]: string;
513
+ } | undefined;
514
+ cwd?: string | undefined;
515
+ user?: string | undefined;
516
+ onStdout?: ((chunk: Buffer | string | any) => void) | undefined;
517
+ onStderr?: ((chunk: Buffer | string | any) => void) | undefined;
518
+ sigtermTimeout?: number;
519
+ }) => Promise<Daemon<Manifest>>;
544
520
  };
545
521
  Daemons: {
546
522
  of(effects: Effects, started: (onTerm: () => PromiseLike<void>) => PromiseLike<null>, healthChecks: HealthCheck[]): Daemons<Manifest, never>;
547
523
  };
548
524
  SubContainer: {
525
+ /**
526
+ * @description Create a new SubContainer
527
+ * @param effects
528
+ * @param image - what container image to use
529
+ * @param mounts - what to mount to the subcontainer
530
+ * @param name - a name to use to refer to the subcontainer for debugging purposes
531
+ */
549
532
  of(effects: Effects, image: {
550
533
  imageId: T.ImageId & keyof Manifest["images"];
551
534
  sharedRun?: boolean;
552
- }, name: string): Promise<SubContainer>;
553
- with<T>(effects: T.Effects, image: {
554
- imageId: T.ImageId & keyof Manifest["images"];
555
- sharedRun?: boolean;
556
- }, mounts: {
557
- options: MountOptions;
558
- mountpoint: string;
559
- }[], name: string, fn: (subContainer: SubContainer) => Promise<T>): Promise<T>;
560
- };
561
- List: {
562
- /**
563
- * @description Create a list of text inputs.
564
- * @param a - attributes of the list itself.
565
- * @param aSpec - attributes describing each member of the list.
566
- */
567
- text: typeof List.text;
568
- /**
569
- * @description Create a list of objects.
570
- * @param a - attributes of the list itself.
571
- * @param aSpec - attributes describing each member of the list.
572
- */
573
- obj: <Type extends Record<string, any>>(a: Parameters<typeof List.obj<Type, Store>>[0], aSpec: Parameters<typeof List.obj<Type, Store>>[1]) => List<Type[], Store>;
574
- /**
575
- * @description Create a list of dynamic text inputs.
576
- * @param a - attributes of the list itself.
577
- * @param aSpec - attributes describing each member of the list.
578
- */
579
- dynamicText: (getA: LazyBuild<Store, {
580
- name: string;
581
- description?: string | null;
582
- warning?: string | null;
583
- default?: string[];
584
- minLength?: number | null;
585
- maxLength?: number | null;
586
- disabled?: false | string;
587
- generate?: null | RandomString;
588
- spec: {
589
- masked?: boolean;
590
- placeholder?: string | null;
591
- minLength?: number | null;
592
- maxLength?: number | null;
593
- patterns?: Pattern[];
594
- inputmode?: ListValueSpecText["inputmode"];
595
- };
596
- }>) => List<string[], Store>;
597
- };
598
- StorePath: PathBuilder<Store, Store>;
599
- Value: {
600
- /**
601
- * @description Displays a boolean toggle to enable/disable
602
- * @example
603
- * ```
604
- toggleExample: Value.toggle({
605
- // required
606
- name: 'Toggle Example',
607
- default: true,
608
-
609
- // optional
610
- description: null,
611
- warning: null,
612
- immutable: false,
613
- }),
614
- * ```
615
- */
616
- toggle: typeof Value.toggle;
617
- /**
618
- * @description Displays a text input field
619
- * @example
620
- * ```
621
- textExample: Value.text({
622
- // required
623
- name: 'Text Example',
624
- required: false,
625
- default: null,
626
-
627
- // optional
628
- description: null,
629
- placeholder: null,
630
- warning: null,
631
- generate: null,
632
- inputmode: 'text',
633
- masked: false,
634
- minLength: null,
635
- maxLength: null,
636
- patterns: [],
637
- immutable: false,
638
- }),
639
- * ```
640
- */
641
- text: typeof Value.text;
642
- /**
643
- * @description Displays a large textarea field for long form entry.
644
- * @example
645
- * ```
646
- textareaExample: Value.textarea({
647
- // required
648
- name: 'Textarea Example',
649
- required: false,
650
- default: null,
651
-
652
- // optional
653
- description: null,
654
- placeholder: null,
655
- warning: null,
656
- minLength: null,
657
- maxLength: null,
658
- immutable: false,
659
- }),
660
- * ```
661
- */
662
- textarea: typeof Value.textarea;
663
- /**
664
- * @description Displays a number input field
665
- * @example
666
- * ```
667
- numberExample: Value.number({
668
- // required
669
- name: 'Number Example',
670
- required: false,
671
- default: null,
672
- integer: true,
673
-
674
- // optional
675
- description: null,
676
- placeholder: null,
677
- warning: null,
678
- min: null,
679
- max: null,
680
- immutable: false,
681
- step: null,
682
- units: null,
683
- }),
684
- * ```
685
- */
686
- number: typeof Value.number;
687
- /**
688
- * @description Displays a browser-native color selector.
689
- * @example
690
- * ```
691
- colorExample: Value.color({
692
- // required
693
- name: 'Color Example',
694
- required: false,
695
- default: null,
696
-
697
- // optional
698
- description: null,
699
- warning: null,
700
- immutable: false,
701
- }),
702
- * ```
703
- */
704
- color: typeof Value.color;
705
- /**
706
- * @description Displays a browser-native date/time selector.
707
- * @example
708
- * ```
709
- datetimeExample: Value.datetime({
710
- // required
711
- name: 'Datetime Example',
712
- required: false,
713
- default: null,
714
-
715
- // optional
716
- description: null,
717
- warning: null,
718
- immutable: false,
719
- inputmode: 'datetime-local',
720
- min: null,
721
- max: null,
722
- }),
723
- * ```
724
- */
725
- datetime: typeof Value.datetime;
726
- /**
727
- * @description Displays a select modal with radio buttons, allowing for a single selection.
728
- * @example
729
- * ```
730
- selectExample: Value.select({
731
- // required
732
- name: 'Select Example',
733
- default: 'radio1',
734
- values: {
735
- radio1: 'Radio 1',
736
- radio2: 'Radio 2',
737
- },
738
-
739
- // optional
740
- description: null,
741
- warning: null,
742
- immutable: false,
743
- disabled: false,
744
- }),
745
- * ```
746
- */
747
- select: typeof Value.select;
535
+ }, mounts: Mounts<Manifest> | null, name: string): Promise<SubContainerOwned<Manifest, Effects>>;
748
536
  /**
749
- * @description Displays a select modal with checkboxes, allowing for multiple selections.
750
- * @example
751
- * ```
752
- multiselectExample: Value.multiselect({
753
- // required
754
- name: 'Multiselect Example',
755
- values: {
756
- option1: 'Option 1',
757
- option2: 'Option 2',
758
- },
759
- default: [],
760
-
761
- // optional
762
- description: null,
763
- warning: null,
764
- immutable: false,
765
- disabled: false,
766
- minlength: null,
767
- maxLength: null,
768
- }),
769
- * ```
537
+ * @description Run a function with a temporary SubContainer
538
+ * @param effects
539
+ * @param image - what container image to use
540
+ * @param mounts - what to mount to the subcontainer
541
+ * @param name - a name to use to refer to the ephemeral subcontainer for debugging purposes
770
542
  */
771
- multiselect: typeof Value.multiselect;
772
- /**
773
- * @description Display a collapsable grouping of additional fields, a "sub form". The second value is the inputSpec spec for the sub form.
774
- * @example
775
- * ```
776
- objectExample: Value.object(
777
- {
778
- // required
779
- name: 'Object Example',
780
-
781
- // optional
782
- description: null,
783
- warning: null,
784
- },
785
- InputSpec.of({}),
786
- ),
787
- * ```
788
- */
789
- object: typeof Value.object;
790
- /**
791
- * @description Displays a dropdown, allowing for a single selection. Depending on the selection, a different object ("sub form") is presented.
792
- * @example
793
- * ```
794
- unionExample: Value.union(
795
- {
796
- // required
797
- name: 'Union Example',
798
- default: 'option1',
799
-
800
- // optional
801
- description: null,
802
- warning: null,
803
- disabled: false,
804
- immutable: false,
805
- },
806
- Variants.of({
807
- option1: {
808
- name: 'Option 1',
809
- spec: InputSpec.of({}),
810
- },
811
- option2: {
812
- name: 'Option 2',
813
- spec: InputSpec.of({}),
814
- },
815
- }),
816
- ),
817
- * ```
818
- */
819
- union: typeof Value.union;
820
- /**
821
- * @description Presents an interface to add/remove/edit items in a list.
822
- * @example
823
- * In this example, we create a list of text inputs.
824
- *
825
- * ```
826
- listExampleText: Value.list(
827
- List.text(
828
- {
829
- // required
830
- name: 'Text List',
831
-
832
- // optional
833
- description: null,
834
- warning: null,
835
- default: [],
836
- minLength: null,
837
- maxLength: null,
838
- },
839
- {
840
- // required
841
- patterns: [],
842
-
843
- // optional
844
- placeholder: null,
845
- generate: null,
846
- inputmode: 'url',
847
- masked: false,
848
- minLength: null,
849
- maxLength: null,
850
- },
851
- ),
852
- ),
853
- * ```
854
- * @example
855
- * In this example, we create a list of objects.
856
- *
857
- * ```
858
- listExampleObject: Value.list(
859
- List.obj(
860
- {
861
- // required
862
- name: 'Object List',
863
-
864
- // optional
865
- description: null,
866
- warning: null,
867
- default: [],
868
- minLength: null,
869
- maxLength: null,
870
- },
871
- {
872
- // required
873
- spec: InputSpec.of({}),
874
-
875
- // optional
876
- displayAs: null,
877
- uniqueBy: null,
878
- },
879
- ),
880
- ),
881
- * ```
882
- */
883
- list: typeof Value.list;
884
- hidden: typeof Value.hidden;
885
- dynamicToggle: (a: LazyBuild<Store, {
886
- name: string;
887
- description?: string | null;
888
- warning?: string | null;
889
- default: boolean;
890
- disabled?: false | string;
891
- }>) => Value<boolean, Store>;
892
- dynamicText: (getA: LazyBuild<Store, {
893
- name: string;
894
- description?: string | null;
895
- warning?: string | null;
896
- default: DefaultString | null;
897
- required: boolean;
898
- masked?: boolean;
899
- placeholder?: string | null;
900
- minLength?: number | null;
901
- maxLength?: number | null;
902
- patterns?: Pattern[];
903
- inputmode?: ValueSpecText["inputmode"];
904
- disabled?: string | false;
905
- generate?: null | RandomString;
906
- }>) => Value<string | null, Store>;
907
- dynamicTextarea: (getA: LazyBuild<Store, {
908
- name: string;
909
- description?: string | null;
910
- warning?: string | null;
911
- default: string | null;
912
- required: boolean;
913
- minLength?: number | null;
914
- maxLength?: number | null;
915
- placeholder?: string | null;
916
- disabled?: false | string;
917
- }>) => Value<string | null, Store>;
918
- dynamicNumber: (getA: LazyBuild<Store, {
919
- name: string;
920
- description?: string | null;
921
- warning?: string | null;
922
- default: number | null;
923
- required: boolean;
924
- min?: number | null;
925
- max?: number | null;
926
- step?: number | null;
927
- integer: boolean;
928
- units?: string | null;
929
- placeholder?: string | null;
930
- disabled?: false | string;
931
- }>) => Value<number | null, Store>;
932
- dynamicColor: (getA: LazyBuild<Store, {
933
- name: string;
934
- description?: string | null;
935
- warning?: string | null;
936
- default: string | null;
937
- required: boolean;
938
- disabled?: false | string;
939
- }>) => Value<string | null, Store>;
940
- dynamicDatetime: (getA: LazyBuild<Store, {
941
- name: string;
942
- description?: string | null;
943
- warning?: string | null;
944
- default: string | null;
945
- required: boolean;
946
- inputmode?: ValueSpecDatetime["inputmode"];
947
- min?: string | null;
948
- max?: string | null;
949
- disabled?: false | string;
950
- }>) => Value<string | null, Store>;
951
- dynamicSelect: (getA: LazyBuild<Store, {
952
- name: string;
953
- description?: string | null;
954
- warning?: string | null;
955
- default: string;
956
- values: Record<string, string>;
957
- disabled?: false | string | string[];
958
- }>) => Value<string, Store>;
959
- dynamicMultiselect: (getA: LazyBuild<Store, {
960
- name: string;
961
- description?: string | null;
962
- warning?: string | null;
963
- default: string[];
964
- values: Record<string, string>;
965
- minLength?: number | null;
966
- maxLength?: number | null;
967
- disabled?: false | string | string[];
968
- }>) => Value<string[], Store>;
969
- filteredUnion: <VariantValues extends { [K in string]: {
970
- name: string;
971
- spec: InputSpec<any, Store> | InputSpec<any, never>;
972
- }; }>(getDisabledFn: Parameters<typeof Value.filteredUnion<VariantValues, Store>>[0], a: Parameters<typeof Value.filteredUnion<VariantValues, Store>>[1], aVariants: Parameters<typeof Value.filteredUnion<VariantValues, Store>>[2]) => Value<import("../../base/lib/actions/input/builder/variants").UnionRes<Store, VariantValues, keyof VariantValues & string> | import("../../base/lib/actions/input/builder/variants").UnionRes<never, VariantValues, keyof VariantValues & string>, Store>;
973
- dynamicUnion: <VariantValues extends { [K in string]: {
974
- name: string;
975
- spec: InputSpec<any, Store> | InputSpec<any, never>;
976
- }; }>(getA: Parameters<typeof Value.dynamicUnion<VariantValues, Store>>[0], aVariants: Parameters<typeof Value.dynamicUnion<VariantValues, Store>>[1]) => Value<import("../../base/lib/actions/input/builder/variants").UnionRes<Store, VariantValues, keyof VariantValues & string> | import("../../base/lib/actions/input/builder/variants").UnionRes<never, VariantValues, keyof VariantValues & string>, Store>;
977
- };
978
- Variants: {
979
- of: <VariantValues extends { [K in string]: {
980
- name: string;
981
- spec: InputSpec<any, Store>;
982
- }; }>(a: VariantValues) => Variants<VariantValues, Store>;
543
+ withTemp<T>(effects: T.Effects, image: {
544
+ imageId: T.ImageId & keyof Manifest["images"];
545
+ sharedRun?: boolean;
546
+ }, mounts: Mounts<Manifest> | null, name: string, fn: (subContainer: SubContainer<Manifest>) => Promise<T>): Promise<T>;
983
547
  };
548
+ List: typeof List;
549
+ Value: typeof Value;
550
+ Variants: typeof Variants;
984
551
  restart: (effects: Effects) => Promise<null>;
985
552
  shutdown: (effects: Effects) => Promise<null>;
986
553
  getStatus: (effects: Effects, options: {
@@ -1001,9 +568,6 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
1001
568
  };
1002
569
  }) => Promise<string>;
1003
570
  getInstalledPackages: (effects: Effects) => Promise<string[]>;
1004
- exposeForDependents: (effects: Effects, options: {
1005
- paths: string[];
1006
- }) => Promise<null>;
1007
571
  getServicePortForward: (effects: Effects, options: {
1008
572
  packageId?: PackageId;
1009
573
  hostId: T.HostId;
@@ -1020,10 +584,6 @@ export declare class StartSdk<Manifest extends T.SDKManifest, Store> {
1020
584
  hostnames: string[];
1021
585
  algorithm?: "ecdsa" | "ed25519";
1022
586
  }) => Promise<string>;
1023
- setDataVersion: (effects: Effects, options: {
1024
- version: string;
1025
- }) => Promise<null>;
1026
- getDataVersion: (effects: Effects) => Promise<string | null>;
1027
587
  manifest: Manifest;
1028
588
  };
1029
589
  }
@@ -1031,7 +591,7 @@ export declare function runCommand<Manifest extends T.SDKManifest>(effects: Effe
1031
591
  imageId: keyof Manifest["images"] & T.ImageId;
1032
592
  sharedRun?: boolean;
1033
593
  }, command: T.CommandType, options: CommandOptions & {
1034
- mounts: Mounts<Manifest>;
594
+ mounts: Mounts<Manifest> | null;
1035
595
  }, name?: string): Promise<{
1036
596
  stdout: string | Buffer;
1037
597
  stderr: string | Buffer;