@start9labs/start-sdk 0.4.0-beta.20 → 0.4.0-beta.22

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 (85) hide show
  1. package/base/lib/Effects.d.ts +1 -1
  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/value.d.ts +0 -11
  5. package/base/lib/actions/input/builder/value.js +0 -11
  6. package/base/lib/actions/input/builder/value.js.map +1 -1
  7. package/base/lib/actions/input/inputSpecConstants.js +8 -6
  8. package/base/lib/actions/input/inputSpecConstants.js.map +1 -1
  9. package/base/lib/actions/setupActions.d.ts +9 -5
  10. package/base/lib/actions/setupActions.js +18 -4
  11. package/base/lib/actions/setupActions.js.map +1 -1
  12. package/base/lib/dependencies/setupDependencies.d.ts +1 -3
  13. package/base/lib/dependencies/setupDependencies.js +3 -10
  14. package/base/lib/dependencies/setupDependencies.js.map +1 -1
  15. package/base/lib/index.d.ts +1 -0
  16. package/base/lib/index.js +2 -1
  17. package/base/lib/index.js.map +1 -1
  18. package/base/lib/inits/index.d.ts +2 -0
  19. package/base/lib/inits/index.js +19 -0
  20. package/base/lib/inits/index.js.map +1 -0
  21. package/base/lib/inits/setupInit.d.ts +12 -0
  22. package/base/lib/inits/setupInit.js +79 -0
  23. package/base/lib/inits/setupInit.js.map +1 -0
  24. package/base/lib/inits/setupUninit.d.ts +7 -0
  25. package/base/lib/inits/setupUninit.js +14 -0
  26. package/base/lib/inits/setupUninit.js.map +1 -0
  27. package/base/lib/interfaces/Origin.d.ts +2 -2
  28. package/base/lib/interfaces/Origin.js +3 -3
  29. package/base/lib/interfaces/Origin.js.map +1 -1
  30. package/base/lib/interfaces/ServiceInterfaceBuilder.d.ts +2 -2
  31. package/base/lib/interfaces/setupInterfaces.d.ts +2 -4
  32. package/base/lib/interfaces/setupInterfaces.js +8 -17
  33. package/base/lib/interfaces/setupInterfaces.js.map +1 -1
  34. package/base/lib/osBindings/MainStatus.d.ts +0 -2
  35. package/base/lib/osBindings/PackageDataEntry.d.ts +1 -2
  36. package/base/lib/types.d.ts +9 -26
  37. package/base/lib/types.js +5 -0
  38. package/base/lib/types.js.map +1 -1
  39. package/package/lib/StartSdk.d.ts +60 -48
  40. package/package/lib/StartSdk.js +56 -33
  41. package/package/lib/StartSdk.js.map +1 -1
  42. package/package/lib/backup/Backups.d.ts +4 -2
  43. package/package/lib/backup/Backups.js +8 -3
  44. package/package/lib/backup/Backups.js.map +1 -1
  45. package/package/lib/backup/setupBackups.d.ts +5 -2
  46. package/package/lib/backup/setupBackups.js +6 -4
  47. package/package/lib/backup/setupBackups.js.map +1 -1
  48. package/package/lib/index.d.ts +0 -1
  49. package/package/lib/index.js +1 -4
  50. package/package/lib/index.js.map +1 -1
  51. package/package/lib/inits/index.d.ts +2 -3
  52. package/package/lib/inits/index.js +16 -3
  53. package/package/lib/inits/index.js.map +1 -1
  54. package/package/lib/inits/setupInit.d.ts +7 -12
  55. package/package/lib/inits/setupInit.js +22 -43
  56. package/package/lib/inits/setupInit.js.map +1 -1
  57. package/package/lib/inits/setupUninit.d.ts +7 -0
  58. package/package/lib/inits/setupUninit.js +14 -0
  59. package/package/lib/inits/setupUninit.js.map +1 -0
  60. package/package/lib/mainFn/CommandController.d.ts +3 -6
  61. package/package/lib/mainFn/CommandController.js +7 -13
  62. package/package/lib/mainFn/CommandController.js.map +1 -1
  63. package/package/lib/mainFn/Daemon.d.ts +6 -3
  64. package/package/lib/mainFn/Daemon.js +14 -7
  65. package/package/lib/mainFn/Daemon.js.map +1 -1
  66. package/package/lib/mainFn/Daemons.d.ts +3 -2
  67. package/package/lib/mainFn/Daemons.js.map +1 -1
  68. package/package/lib/mainFn/HealthDaemon.js +8 -11
  69. package/package/lib/mainFn/HealthDaemon.js.map +1 -1
  70. package/package/lib/mainFn/Oneshot.js +4 -2
  71. package/package/lib/mainFn/Oneshot.js.map +1 -1
  72. package/package/lib/test/host.test.js +1 -1
  73. package/package/lib/test/host.test.js.map +1 -1
  74. package/package/lib/test/inputSpecBuilder.test.js +3 -2
  75. package/package/lib/test/inputSpecBuilder.test.js.map +1 -1
  76. package/package/lib/test/output.js +297 -386
  77. package/package/lib/test/output.js.map +1 -1
  78. package/package/lib/test/output.sdk.d.ts +55 -392
  79. package/package/lib/util/SubContainer.d.ts +99 -33
  80. package/package/lib/util/SubContainer.js +89 -24
  81. package/package/lib/util/SubContainer.js.map +1 -1
  82. package/package/lib/version/VersionGraph.d.ts +26 -5
  83. package/package/lib/version/VersionGraph.js +88 -22
  84. package/package/lib/version/VersionGraph.js.map +1 -1
  85. package/package.json +1 -1
@@ -1,37 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupServiceInterfaces = exports.NO_INTERFACE_CHANGES = void 0;
4
- const util_1 = require("../util");
5
4
  exports.NO_INTERFACE_CHANGES = {};
6
5
  const setupServiceInterfaces = (fn) => {
7
- const cell = {
8
- updater: (async (options) => []),
9
- };
10
- cell.updater = (async (options) => {
11
- const childEffects = options.effects.child("setupInterfaces");
12
- childEffects.constRetry = (0, util_1.once)(() => {
13
- cell.updater({ effects: options.effects });
14
- });
6
+ return (async (effects) => {
15
7
  const bindings = [];
16
8
  const interfaces = [];
17
- const res = await fn({
9
+ await fn({
18
10
  effects: {
19
- ...childEffects,
11
+ ...effects,
20
12
  bind: (params) => {
21
13
  bindings.push({ id: params.id, internalPort: params.internalPort });
22
- return childEffects.bind(params);
14
+ return effects.bind(params);
23
15
  },
24
16
  exportServiceInterface: (params) => {
25
17
  interfaces.push(params.id);
26
- return childEffects.exportServiceInterface(params);
18
+ return effects.exportServiceInterface(params);
27
19
  },
28
20
  },
29
21
  });
30
- await options.effects.clearBindings({ except: bindings });
31
- await options.effects.clearServiceInterfaces({ except: interfaces });
32
- return res;
22
+ await effects.clearBindings({ except: bindings });
23
+ await effects.clearServiceInterfaces({ except: interfaces });
24
+ return null;
33
25
  });
34
- return cell.updater;
35
26
  };
36
27
  exports.setupServiceInterfaces = setupServiceInterfaces;
37
28
  //# sourceMappingURL=setupInterfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupInterfaces.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/setupInterfaces.ts"],"names":[],"mappings":";;;AACA,kCAA8B;AAkBjB,QAAA,oBAAoB,GAAG,EAAoC,CAAA;AACjE,MAAM,sBAAsB,GAA2B,CAG5D,EAAgC,EAChC,EAAE;IACF,MAAM,IAAI,GAAG;QACX,OAAO,EAAE,CAAC,KAAK,EAAE,OAA+B,EAAE,EAAE,CAClD,EAAmB,CAAoC;KAC1D,CAAA;IACD,IAAI,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,OAA+B,EAAE,EAAE;QACxD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAC7D,YAAY,CAAC,UAAU,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;QACF,MAAM,QAAQ,GAAe,EAAE,CAAA;QAC/B,MAAM,UAAU,GAA2B,EAAE,CAAA;QAC7C,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;YACnB,OAAO,EAAE;gBACP,GAAG,YAAY;gBACf,IAAI,EAAE,CAAC,MAAoB,EAAE,EAAE;oBAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CAAA;oBACnE,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBAClC,CAAC;gBACD,sBAAsB,EAAE,CAAC,MAAsC,EAAE,EAAE;oBACjE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBAC1B,OAAO,YAAY,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;gBACpD,CAAC;aACF;SACF,CAAC,CAAA;QACF,MAAM,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QACzD,MAAM,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QACpE,OAAO,GAAG,CAAA;IACZ,CAAC,CAAoC,CAAA;IACrC,OAAO,IAAI,CAAC,OAAO,CAAA;AACrB,CAAC,CAAA;AAlCY,QAAA,sBAAsB,0BAkClC"}
1
+ {"version":3,"file":"setupInterfaces.js","sourceRoot":"","sources":["../../../../base/lib/interfaces/setupInterfaces.ts"],"names":[],"mappings":";;;AAgBa,QAAA,oBAAoB,GAAG,EAAoC,CAAA;AACjE,MAAM,sBAAsB,GAA2B,CAG5D,EAAgC,EAChC,EAAE;IACF,OAAO,CAAC,KAAK,EAAE,OAAkB,EAAE,EAAE;QACnC,MAAM,QAAQ,GAAe,EAAE,CAAA;QAC/B,MAAM,UAAU,GAA2B,EAAE,CAAA;QAC7C,MAAM,EAAE,CAAC;YACP,OAAO,EAAE;gBACP,GAAG,OAAO;gBACV,IAAI,EAAE,CAAC,MAAoB,EAAE,EAAE;oBAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CAAA;oBACnE,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBAC7B,CAAC;gBACD,sBAAsB,EAAE,CAAC,MAAsC,EAAE,EAAE;oBACjE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBAC1B,OAAO,OAAO,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;gBAC/C,CAAC;aACF;SACF,CAAC,CAAA;QACF,MAAM,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QACjD,MAAM,OAAO,CAAC,sBAAsB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QAC5D,OAAO,IAAI,CAAA;IACb,CAAC,CAA4B,CAAA;AAC/B,CAAC,CAAA;AAzBY,QAAA,sBAAsB,0BAyBlC"}
@@ -10,8 +10,6 @@ export type MainStatus = {
10
10
  main: "stopped";
11
11
  } | {
12
12
  main: "restarting";
13
- } | {
14
- main: "restoring";
15
13
  } | {
16
14
  main: "stopping";
17
15
  } | {
@@ -8,10 +8,9 @@ import type { MainStatus } from "./MainStatus";
8
8
  import type { PackageState } from "./PackageState";
9
9
  import type { ServiceInterface } from "./ServiceInterface";
10
10
  import type { ServiceInterfaceId } from "./ServiceInterfaceId";
11
- import type { Version } from "./Version";
12
11
  export type PackageDataEntry = {
13
12
  stateInfo: PackageState;
14
- dataVersion: Version | null;
13
+ dataVersion: string | null;
15
14
  status: MainStatus;
16
15
  registry: string | null;
17
16
  developerKey: string;
@@ -3,6 +3,7 @@ import { DependencyRequirement, NamedHealthCheckResult, Manifest, ServiceInterfa
3
3
  import { StringObject, ToKebab } from "./util";
4
4
  import { Action, Actions } from "./actions/setupActions";
5
5
  import { Effects } from "./Effects";
6
+ import { ExtendedVersion, VersionRange } from "./exver";
6
7
  export { Effects };
7
8
  export * from "./osBindings";
8
9
  export { SDKManifest } from "./types/ManifestTypes";
@@ -27,10 +28,6 @@ export declare namespace ExpectedExports {
27
28
  type createBackup = (options: {
28
29
  effects: Effects;
29
30
  }) => Promise<unknown>;
30
- /** For restoring service data that was previously backed up using the startOS UI create backup flow. Backup restores are also triggered via the startOS UI, or doing a system restore flow during setup. */
31
- type restoreBackup = (options: {
32
- effects: Effects;
33
- }) => Promise<unknown>;
34
31
  /**
35
32
  * This is the entrypoint for the main container. Used to start up something like the service that the
36
33
  * package represents, like running a bitcoind in a bitcoind-wrapper.
@@ -39,45 +36,29 @@ export declare namespace ExpectedExports {
39
36
  effects: Effects;
40
37
  started(onTerm: () => PromiseLike<void>): PromiseLike<null>;
41
38
  }) => Promise<DaemonBuildable>;
42
- /**
43
- * After a shutdown, if we wanted to do any operations to clean up things, like
44
- * set the action as unavailable or something.
45
- */
46
- type afterShutdown = (options: {
47
- effects: Effects;
48
- }) => Promise<unknown>;
49
39
  /**
50
40
  * Every time a service launches (both on startup, and on install) this function is called before packageInit
51
41
  * Can be used to register callbacks
52
42
  */
53
- type containerInit = (options: {
54
- effects: Effects;
55
- }) => Promise<unknown>;
56
- /**
57
- * Every time a package completes an install, this function is called before the main.
58
- * Can be used to do migration like things.
59
- */
60
- type packageInit = (options: {
43
+ type init = (options: {
61
44
  effects: Effects;
45
+ kind: "install" | "update" | "restore" | null;
62
46
  }) => Promise<unknown>;
63
47
  /** This will be ran during any time a package is uninstalled, for example during a update
64
48
  * this will be called.
65
49
  */
66
- type packageUninit = (options: {
50
+ type uninit = (options: {
67
51
  effects: Effects;
68
- nextVersion: null | string;
52
+ target: ExtendedVersion | VersionRange | null;
69
53
  }) => Promise<unknown>;
70
54
  type manifest = Manifest;
71
55
  type actions = Actions<Record<ActionId, Action<ActionId, any>>>;
72
56
  }
73
57
  export type ABI = {
74
58
  createBackup: ExpectedExports.createBackup;
75
- restoreBackup: ExpectedExports.restoreBackup;
76
59
  main: ExpectedExports.main;
77
- afterShutdown: ExpectedExports.afterShutdown;
78
- containerInit: ExpectedExports.containerInit;
79
- packageInit: ExpectedExports.packageInit;
80
- packageUninit: ExpectedExports.packageUninit;
60
+ init: ExpectedExports.init;
61
+ uninit: ExpectedExports.uninit;
81
62
  manifest: ExpectedExports.manifest;
82
63
  actions: ExpectedExports.actions;
83
64
  };
@@ -102,8 +83,10 @@ export type SmtpValue = {
102
83
  };
103
84
  export declare class UseEntrypoint {
104
85
  readonly overridCmd?: string[] | undefined;
86
+ readonly USE_ENTRYPOINT = "USE_ENTRYPOINT";
105
87
  constructor(overridCmd?: string[] | undefined);
106
88
  }
89
+ export declare function isUseEntrypoint(command: CommandType): command is UseEntrypoint;
107
90
  export type CommandType = string | [string, ...string[]] | UseEntrypoint;
108
91
  export type DaemonReturned = {
109
92
  wait(): Promise<unknown>;
package/base/lib/types.js CHANGED
@@ -37,6 +37,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.UseEntrypoint = exports.ExpectedExports = exports.NO_TIMEOUT = exports.SIGKILL = exports.SIGTERM = exports.inputSpecTypes = void 0;
40
+ exports.isUseEntrypoint = isUseEntrypoint;
40
41
  exports.writable = writable;
41
42
  exports.readonly = readonly;
42
43
  exports.inputSpecTypes = __importStar(require("./actions/input/inputSpecTypes"));
@@ -51,9 +52,13 @@ var ExpectedExports;
51
52
  class UseEntrypoint {
52
53
  constructor(overridCmd) {
53
54
  this.overridCmd = overridCmd;
55
+ this.USE_ENTRYPOINT = "USE_ENTRYPOINT";
54
56
  }
55
57
  }
56
58
  exports.UseEntrypoint = UseEntrypoint;
59
+ function isUseEntrypoint(command) {
60
+ return typeof command === "object" && "ENTRYPOINT" in command;
61
+ }
57
62
  function writable(value) {
58
63
  return value;
59
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../base/lib/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6MA,4BAEC;AAMD,4BAEC;AAvND,iFAAgE;AAahE,+CAA4B;AAgBf,QAAA,OAAO,GAAY,SAAS,CAAA;AAC5B,QAAA,OAAO,GAAY,SAAS,CAAA;AAC5B,QAAA,UAAU,GAAG,CAAC,CAAC,CAAA;AAI5B,IAAiB,eAAe,CAmD/B;AAnDD,WAAiB,eAAe;IAC9B,OAAO,EAAE,CAAC,CAAA;AAkDZ,CAAC,EAnDgB,eAAe,+BAAf,eAAe,QAmD/B;AAkCD,MAAa,aAAa;IACxB,YAAqB,UAAqB;QAArB,eAAU,GAAV,UAAU,CAAW;IAAG,CAAC;CAC/C;AAFD,sCAEC;AAmFD,SAAgB,QAAQ,CAAI,KAAQ;IAClC,OAAO,KAAK,CAAA;AACd,CAAC;AAMD,SAAgB,QAAQ,CAAI,KAAQ;IAClC,OAAO,KAAK,CAAA;AACd,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../base/lib/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,0CAIC;AAmFD,4BAEC;AAMD,4BAEC;AA1MD,iFAAgE;AAchE,+CAA4B;AAgBf,QAAA,OAAO,GAAY,SAAS,CAAA;AAC5B,QAAA,OAAO,GAAY,SAAS,CAAA;AAC5B,QAAA,UAAU,GAAG,CAAC,CAAC,CAAA;AAI5B,IAAiB,eAAe,CAkC/B;AAlCD,WAAiB,eAAe;IAC9B,OAAO,EAAE,CAAC,CAAA;AAiCZ,CAAC,EAlCgB,eAAe,+BAAf,eAAe,QAkC/B;AA+BD,MAAa,aAAa;IAExB,YAAqB,UAAqB;QAArB,eAAU,GAAV,UAAU,CAAW;QADjC,mBAAc,GAAG,gBAAgB,CAAA;IACG,CAAC;CAC/C;AAHD,sCAGC;AACD,SAAgB,eAAe,CAC7B,OAAoB;IAEpB,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,YAAY,IAAI,OAAO,CAAA;AAC/D,CAAC;AAmFD,SAAgB,QAAQ,CAAI,KAAQ;IAClC,OAAO,KAAK,CAAA;AACd,CAAC;AAMD,SAAgB,QAAQ,CAAI,KAAQ;IAClC,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Value } from "../../base/lib/actions/input/builder/value";
2
2
  import { InputSpec } from "../../base/lib/actions/input/builder/inputSpec";
3
3
  import { Variants } from "../../base/lib/actions/input/builder/variants";
4
- import { Action, Actions } from "../../base/lib/actions/setupActions";
4
+ import { Action, ActionInfo, Actions } from "../../base/lib/actions/setupActions";
5
5
  import { SyncOptions, ServiceInterfaceId, PackageId, ServiceInterfaceType, Effects } from "../../base/lib/types";
6
6
  import * as patterns from "../../base/lib/util/patterns";
7
7
  import { BackupSync, Backups } from "./backup/Backups";
@@ -9,26 +9,24 @@ import { Daemon, Daemons } from "./mainFn/Daemons";
9
9
  import { HealthCheck } from "./health/HealthCheck";
10
10
  import { checkPortListening } from "./health/checkFns/checkPortListening";
11
11
  import { List } from "../../base/lib/actions/input/builder/list";
12
- import { InstallFn, PostInstall, PreInstall } from "./inits/setupInstall";
13
12
  import { SetupBackupsParams } from "./backup/setupBackups";
14
- import { UninstallFn } from "./inits/setupUninstall";
15
13
  import { changeOnFirstSuccess, cooldownTrigger } from "./trigger";
16
- import { UpdateServiceInterfaces } from "../../base/lib/interfaces/setupInterfaces";
17
14
  import { MultiHost, Scheme } from "../../base/lib/interfaces/Host";
18
15
  import { ServiceInterfaceBuilder } from "../../base/lib/interfaces/ServiceInterfaceBuilder";
19
16
  import { GetSystemSmtp } from "./util";
20
17
  import { nullIfEmpty } from "./util";
21
- import { CommandOptions, SubContainer } from "./util/SubContainer";
18
+ import { CommandOptions, SubContainer, SubContainerOwned } from "./util/SubContainer";
22
19
  import { Mounts } from "./mainFn/Mounts";
23
20
  import * as T from "../../base/lib/types";
24
21
  import { CheckDependencies } from "../../base/lib/dependencies/dependencies";
25
22
  import { GetSslCertificate } from "./util";
26
- import { VersionGraph } from "./version";
23
+ import { getDataVersion, setDataVersion } from "./version";
27
24
  import { MaybeFn } from "../../base/lib/actions/setupActions";
28
25
  import { GetInput } from "../../base/lib/actions/setupActions";
29
26
  import { Run } from "../../base/lib/actions/setupActions";
30
27
  import * as actions from "../../base/lib/actions";
31
- export declare const OSVersion: "0.4.0-alpha.1";
28
+ import { setupInit, setupUninit, setupOnInstall, setupOnUpdate, setupOnInstallOrUpdate, setupOnInit } from "../../base/lib/inits";
29
+ export declare const OSVersion: "0.4.0-alpha.3";
32
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;
33
31
  export declare class StartSdk<Manifest extends T.SDKManifest> {
34
32
  readonly manifest: Manifest;
@@ -36,14 +34,16 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
36
34
  static of(): StartSdk<never>;
37
35
  withManifest<Manifest extends T.SDKManifest = never>(manifest: Manifest): StartSdk<Manifest>;
38
36
  build(isReady: AnyNeverCond<[Manifest], "Build not ready", true>): {
37
+ setDataVersion: typeof setDataVersion;
38
+ getDataVersion: typeof getDataVersion;
39
39
  action: {
40
40
  run: <Input extends Record<string, unknown>>(options: {
41
41
  effects: T.Effects;
42
42
  actionId: T.ActionId;
43
43
  input?: actions.RunActionInput<Input>;
44
44
  }) => Promise<T.ActionResult | 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>;
45
+ request: <T extends ActionInfo<T.ActionId, any>>(effects: T.Effects, packageId: T.PackageId, action: T, severity: T.ActionSeverity, options?: actions.ActionRequestOptions<T>) => Promise<null>;
46
+ requestOwn: <T extends ActionInfo<T.ActionId, any>>(effects: T.Effects, action: T, severity: T.ActionSeverity, options?: actions.ActionRequestOptions<T>) => Promise<null>;
47
47
  clearRequest: (effects: T.Effects, ...replayIds: string[]) => Promise<null>;
48
48
  };
49
49
  checkDependencies: <DependencyId extends keyof Manifest["dependencies"] & PackageId = keyof Manifest["dependencies"] & PackageId>(effects: Effects, packageIds?: DependencyId[]) => Promise<CheckDependencies<DependencyId>>;
@@ -218,7 +218,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
218
218
  schemeOverride: null,
219
219
  username: null,
220
220
  path: '',
221
- search: {},
221
+ query: {},
222
222
  })
223
223
  * ```
224
224
  */
@@ -236,7 +236,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
236
236
  /** (optional) appends the provided path to all URLs. */
237
237
  path: string;
238
238
  /** (optional) appends the provided query params to all URLs. */
239
- search: Record<string, string>;
239
+ query: Record<string, string>;
240
240
  /** (optional) overrides the protocol prefix provided by the bind function.
241
241
  *
242
242
  * @example `ftp://`
@@ -310,7 +310,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
310
310
  */
311
311
  setupBackups: (options: SetupBackupsParams<Manifest>) => {
312
312
  createBackup: T.ExpectedExports.createBackup;
313
- restoreBackup: T.ExpectedExports.restoreBackup;
313
+ restoreInit: import("../../base/lib/inits").InitScript;
314
314
  };
315
315
  /**
316
316
  * @description Use this function to set dependency information.
@@ -333,42 +333,62 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
333
333
  */
334
334
  setupDependencies: (fn: (options: {
335
335
  effects: T.Effects;
336
- }) => Promise<T.CurrentDependenciesResult<Manifest>>) => (options: {
337
- effects: T.Effects;
338
- }) => Promise<null>;
339
- setupInit: (versions: VersionGraph<string>, preInstall: PreInstall<Manifest>, postInstall: PostInstall<Manifest>, uninstall: import("./inits/setupUninstall").Uninstall<Manifest>, setServiceInterfaces: UpdateServiceInterfaces<any>, setDependencies: (options: {
340
- effects: T.Effects;
341
- }) => Promise<null | void | undefined>, actions: Actions<any>) => {
342
- packageInit: T.ExpectedExports.packageInit;
343
- packageUninit: T.ExpectedExports.packageUninit;
344
- containerInit: T.ExpectedExports.containerInit;
345
- };
336
+ }) => Promise<T.CurrentDependenciesResult<Manifest>>) => (effects: T.Effects) => Promise<null>;
346
337
  /**
347
- * @description Use this function to execute arbitrary logic *once*, on initial install *before* interfaces, actions, and dependencies are updated.
338
+ * @description Use this function to create an InitScript that runs every time the service initializes
339
+ */
340
+ setupOnInit: typeof setupOnInit;
341
+ /**
342
+ * @description Use this function to create an InitScript that runs only when the service is freshly installed
343
+ */
344
+ setupOnInstall: typeof setupOnInstall;
345
+ /**
346
+ * @description Use this function to create an InitScript that runs only when the service is updated
347
+ */
348
+ setupOnUpdate: typeof setupOnUpdate;
349
+ /**
350
+ * @description Use this function to create an InitScript that runs only when the service is installed or updated
351
+ */
352
+ setupOnInstallOrUpdate: typeof setupOnInstallOrUpdate;
353
+ /**
354
+ * @description Use this function to setup what happens when the service initializes.
355
+ *
356
+ * This happens when the server boots, or a service is installed, updated, or restored
357
+ *
358
+ * Not every init script does something on every initialization. For example, versions only does something on install or update
359
+ *
360
+ * These scripts are run in the order they are supplied
348
361
  * @example
349
- * In the this example, we initialize a config file
350
362
  *
351
363
  * ```
352
- const preInstall = sdk.setupPreInstall(async ({ effects }) => {
353
- await configFile.write(effects, { name: 'World' })
354
- })
364
+ export const init = sdk.setupInit(
365
+ restoreInit,
366
+ versions,
367
+ setDependencies,
368
+ setInterfaces,
369
+ actions,
370
+ postInstall,
371
+ )
355
372
  * ```
356
373
  */
357
- setupPreInstall: (fn: InstallFn<Manifest>) => PreInstall<Manifest>;
374
+ setupInit: typeof setupInit;
358
375
  /**
359
- * @description Use this function to execute arbitrary logic *once*, on initial install *after* interfaces, actions, and dependencies are updated.
376
+ * @description Use this function to setup what happens when the service uninitializes.
377
+ *
378
+ * This happens when the server shuts down, or a service is uninstalled or updated
379
+ *
380
+ * Not every uninit script does something on every uninitialization. For example, versions only does something on uninstall or update
381
+ *
382
+ * These scripts are run in the order they are supplied
360
383
  * @example
361
- * In the this example, we create a task for the user to perform.
362
384
  *
363
385
  * ```
364
- const postInstall = sdk.setupPostInstall(async ({ effects }) => {
365
- await sdk.action.requestOwn(effects, showSecretPhrase, 'important', {
366
- reason: 'Check out your secret phrase!',
367
- })
368
- })
386
+ export const uninit = sdk.setupUninit(
387
+ versions,
388
+ )
369
389
  * ```
370
390
  */
371
- setupPostInstall: (fn: InstallFn<Manifest>) => PostInstall<Manifest>;
391
+ setupUninit: typeof setupUninit;
372
392
  /**
373
393
  * @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.
374
394
  * @param inputSpec - The inputSpec spec of this service as exported from /inputSpec/spec.
@@ -394,7 +414,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
394
414
  schemeOverride: null,
395
415
  username: null,
396
416
  path: '',
397
- search: {},
417
+ query: {},
398
418
  })
399
419
  // Admin UI
400
420
  const adminUi = sdk.createInterface(effects, {
@@ -406,7 +426,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
406
426
  schemeOverride: null,
407
427
  username: null,
408
428
  path: '/admin',
409
- search: {},
429
+ query: {},
410
430
  })
411
431
  // UI receipt
412
432
  const uiReceipt = await uiMultiOrigin.export([primaryUi, adminUi])
@@ -426,7 +446,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
426
446
  schemeOverride: null,
427
447
  username: null,
428
448
  path: '',
429
- search: {},
449
+ query: {},
430
450
  })
431
451
  // API receipt
432
452
  const apiReceipt = await apiMultiOrigin.export([api])
@@ -442,10 +462,6 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
442
462
  effects: Effects;
443
463
  started(onTerm: () => PromiseLike<void>): PromiseLike<null>;
444
464
  }) => Promise<Daemons<Manifest, any>>) => T.ExpectedExports.main;
445
- /**
446
- * Use this function to execute arbitrary logic *once*, on uninstall only. Most services will not use this.
447
- */
448
- setupUninstall: (fn: UninstallFn<Manifest>) => import("./inits/setupUninstall").Uninstall<Manifest>;
449
465
  trigger: {
450
466
  defaultTrigger: import("./trigger").Trigger;
451
467
  cooldownTrigger: typeof cooldownTrigger;
@@ -520,7 +536,7 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
520
536
  of(effects: Effects, image: {
521
537
  imageId: T.ImageId & keyof Manifest["images"];
522
538
  sharedRun?: boolean;
523
- }, mounts: Mounts<Manifest> | null, name: string): Promise<SubContainer<T.SDKManifest, Effects>>;
539
+ }, mounts: Mounts<Manifest> | null, name: string): Promise<SubContainerOwned<Manifest, Effects>>;
524
540
  /**
525
541
  * @description Run a function with a temporary SubContainer
526
542
  * @param effects
@@ -572,10 +588,6 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
572
588
  hostnames: string[];
573
589
  algorithm?: "ecdsa" | "ed25519";
574
590
  }) => Promise<string>;
575
- setDataVersion: (effects: Effects, options: {
576
- version: string;
577
- }) => Promise<null>;
578
- getDataVersion: (effects: Effects) => Promise<string | null>;
579
591
  manifest: Manifest;
580
592
  };
581
593
  }
@@ -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");
@@ -68,10 +66,11 @@ const T = __importStar(require("../../base/lib/types"));
68
66
  const exver_1 = require("../../base/lib/exver");
69
67
  const dependencies_1 = require("../../base/lib/dependencies/dependencies");
70
68
  const util_5 = require("./util");
69
+ const version_1 = require("./version");
71
70
  const actions = __importStar(require("../../base/lib/actions"));
72
- const setupInit_1 = require("./inits/setupInit");
73
71
  const fs = __importStar(require("node:fs/promises"));
74
- exports.OSVersion = (0, exver_1.testTypeVersion)("0.4.0-alpha.1");
72
+ const inits_1 = require("../../base/lib/inits");
73
+ exports.OSVersion = (0, exver_1.testTypeVersion)("0.4.0-alpha.3");
75
74
  class StartSdk {
76
75
  constructor(manifest) {
77
76
  this.manifest = manifest;
@@ -93,8 +92,6 @@ class StartSdk {
93
92
  clearBindings: (effects, ...args) => effects.clearBindings(...args),
94
93
  getOsIp: (effects, ...args) => effects.getOsIp(...args),
95
94
  getSslKey: (effects, ...args) => effects.getSslKey(...args),
96
- setDataVersion: (effects, ...args) => effects.setDataVersion(...args),
97
- getDataVersion: (effects, ...args) => effects.getDataVersion(...args),
98
95
  shutdown: (effects, ...args) => effects.shutdown(...args),
99
96
  getDependencies: (effects, ...args) => effects.getDependencies(...args),
100
97
  getStatus: (effects, ...args) => effects.getStatus(...args),
@@ -102,6 +99,8 @@ class StartSdk {
102
99
  return {
103
100
  manifest: this.manifest,
104
101
  ...startSdkEffectWrapper,
102
+ setDataVersion: version_1.setDataVersion,
103
+ getDataVersion: version_1.getDataVersion,
105
104
  action: {
106
105
  run: actions.runAction,
107
106
  request: (effects, packageId, action, severity, options) => actions.requestAction({
@@ -301,7 +300,7 @@ class StartSdk {
301
300
  schemeOverride: null,
302
301
  username: null,
303
302
  path: '',
304
- search: {},
303
+ query: {},
305
304
  })
306
305
  * ```
307
306
  */
@@ -376,33 +375,61 @@ class StartSdk {
376
375
  * ```
377
376
  */
378
377
  setupDependencies: (setupDependencies_1.setupDependencies),
379
- setupInit: (setupInit_1.setupInit),
380
378
  /**
381
- * @description Use this function to execute arbitrary logic *once*, on initial install *before* interfaces, actions, and dependencies are updated.
379
+ * @description Use this function to create an InitScript that runs every time the service initializes
380
+ */
381
+ setupOnInit: inits_1.setupOnInit,
382
+ /**
383
+ * @description Use this function to create an InitScript that runs only when the service is freshly installed
384
+ */
385
+ setupOnInstall: inits_1.setupOnInstall,
386
+ /**
387
+ * @description Use this function to create an InitScript that runs only when the service is updated
388
+ */
389
+ setupOnUpdate: inits_1.setupOnUpdate,
390
+ /**
391
+ * @description Use this function to create an InitScript that runs only when the service is installed or updated
392
+ */
393
+ setupOnInstallOrUpdate: inits_1.setupOnInstallOrUpdate,
394
+ /**
395
+ * @description Use this function to setup what happens when the service initializes.
396
+ *
397
+ * This happens when the server boots, or a service is installed, updated, or restored
398
+ *
399
+ * Not every init script does something on every initialization. For example, versions only does something on install or update
400
+ *
401
+ * These scripts are run in the order they are supplied
382
402
  * @example
383
- * In the this example, we initialize a config file
384
403
  *
385
404
  * ```
386
- const preInstall = sdk.setupPreInstall(async ({ effects }) => {
387
- await configFile.write(effects, { name: 'World' })
388
- })
405
+ export const init = sdk.setupInit(
406
+ restoreInit,
407
+ versions,
408
+ setDependencies,
409
+ setInterfaces,
410
+ actions,
411
+ postInstall,
412
+ )
389
413
  * ```
390
414
  */
391
- setupPreInstall: (fn) => setupInstall_1.PreInstall.of(fn),
415
+ setupInit: inits_1.setupInit,
392
416
  /**
393
- * @description Use this function to execute arbitrary logic *once*, on initial install *after* interfaces, actions, and dependencies are updated.
417
+ * @description Use this function to setup what happens when the service uninitializes.
418
+ *
419
+ * This happens when the server shuts down, or a service is uninstalled or updated
420
+ *
421
+ * Not every uninit script does something on every uninitialization. For example, versions only does something on uninstall or update
422
+ *
423
+ * These scripts are run in the order they are supplied
394
424
  * @example
395
- * In the this example, we create a task for the user to perform.
396
425
  *
397
426
  * ```
398
- const postInstall = sdk.setupPostInstall(async ({ effects }) => {
399
- await sdk.action.requestOwn(effects, showSecretPhrase, 'important', {
400
- reason: 'Check out your secret phrase!',
401
- })
402
- })
427
+ export const uninit = sdk.setupUninit(
428
+ versions,
429
+ )
403
430
  * ```
404
431
  */
405
- setupPostInstall: (fn) => setupInstall_1.PostInstall.of(fn),
432
+ setupUninit: inits_1.setupUninit,
406
433
  /**
407
434
  * @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.
408
435
  * @param inputSpec - The inputSpec spec of this service as exported from /inputSpec/spec.
@@ -428,7 +455,7 @@ class StartSdk {
428
455
  schemeOverride: null,
429
456
  username: null,
430
457
  path: '',
431
- search: {},
458
+ query: {},
432
459
  })
433
460
  // Admin UI
434
461
  const adminUi = sdk.createInterface(effects, {
@@ -440,7 +467,7 @@ class StartSdk {
440
467
  schemeOverride: null,
441
468
  username: null,
442
469
  path: '/admin',
443
- search: {},
470
+ query: {},
444
471
  })
445
472
  // UI receipt
446
473
  const uiReceipt = await uiMultiOrigin.export([primaryUi, adminUi])
@@ -460,7 +487,7 @@ class StartSdk {
460
487
  schemeOverride: null,
461
488
  username: null,
462
489
  path: '',
463
- search: {},
490
+ query: {},
464
491
  })
465
492
  // API receipt
466
493
  const apiReceipt = await apiMultiOrigin.export([api])
@@ -473,10 +500,6 @@ class StartSdk {
473
500
  */
474
501
  setupInterfaces: setupInterfaces_1.setupServiceInterfaces,
475
502
  setupMain: (fn) => (0, mainFn_1.setupMain)(fn),
476
- /**
477
- * Use this function to execute arbitrary logic *once*, on uninstall only. Most services will not use this.
478
- */
479
- setupUninstall: (fn) => (0, setupUninstall_1.setupUninstall)(fn),
480
503
  trigger: {
481
504
  defaultTrigger: defaultTrigger_1.defaultTrigger,
482
505
  cooldownTrigger: trigger_1.cooldownTrigger,
@@ -542,7 +565,7 @@ class StartSdk {
542
565
  * @param name - a name to use to refer to the subcontainer for debugging purposes
543
566
  */
544
567
  of(effects, image, mounts, name) {
545
- return SubContainer_1.SubContainer.of(effects, image, mounts, name);
568
+ return SubContainer_1.SubContainerOwned.of(effects, image, mounts, name);
546
569
  },
547
570
  /**
548
571
  * @description Run a function with a temporary SubContainer
@@ -552,7 +575,7 @@ class StartSdk {
552
575
  * @param name - a name to use to refer to the ephemeral subcontainer for debugging purposes
553
576
  */
554
577
  withTemp(effects, image, mounts, name, fn) {
555
- return SubContainer_1.SubContainer.withTemp(effects, image, mounts, name, fn);
578
+ return SubContainer_1.SubContainerOwned.withTemp(effects, image, mounts, name, fn);
556
579
  },
557
580
  },
558
581
  List: list_1.List,
@@ -564,7 +587,7 @@ class StartSdk {
564
587
  exports.StartSdk = StartSdk;
565
588
  async function runCommand(effects, image, command, options, name) {
566
589
  let commands;
567
- if (command instanceof T.UseEntrypoint) {
590
+ if (T.isUseEntrypoint(command)) {
568
591
  const imageMeta = await fs
569
592
  .readFile(`/media/startos/images/${image.imageId}.json`, {
570
593
  encoding: "utf8",
@@ -576,7 +599,7 @@ async function runCommand(effects, image, command, options, name) {
576
599
  }
577
600
  else
578
601
  commands = (0, util_4.splitCommand)(command);
579
- return SubContainer_1.SubContainer.withTemp(effects, image, options.mounts, name ||
602
+ return SubContainer_1.SubContainerOwned.withTemp(effects, image, options.mounts, name ||
580
603
  commands
581
604
  .map((c) => {
582
605
  if (c.includes(" ")) {