@start9labs/start-sdk 0.4.0-beta.3 → 0.4.0-beta.30

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 (206) hide show
  1. package/base/lib/Effects.d.ts +8 -34
  2. package/base/lib/actions/index.d.ts +13 -13
  3. package/base/lib/actions/index.js +4 -4
  4. package/base/lib/actions/index.js.map +1 -1
  5. package/base/lib/actions/input/builder/inputSpec.d.ts +10 -25
  6. package/base/lib/actions/input/builder/inputSpec.js +0 -17
  7. package/base/lib/actions/input/builder/inputSpec.js.map +1 -1
  8. package/base/lib/actions/input/builder/list.d.ts +8 -23
  9. package/base/lib/actions/input/builder/list.js +0 -17
  10. package/base/lib/actions/input/builder/list.js.map +1 -1
  11. package/base/lib/actions/input/builder/value.d.ts +315 -61
  12. package/base/lib/actions/input/builder/value.js +280 -28
  13. package/base/lib/actions/input/builder/value.js.map +1 -1
  14. package/base/lib/actions/input/builder/variants.d.ts +8 -23
  15. package/base/lib/actions/input/builder/variants.js +0 -17
  16. package/base/lib/actions/input/builder/variants.js.map +1 -1
  17. package/base/lib/actions/input/inputSpecConstants.d.ts +6 -6
  18. package/base/lib/actions/input/inputSpecConstants.js +8 -6
  19. package/base/lib/actions/input/inputSpecConstants.js.map +1 -1
  20. package/base/lib/actions/setupActions.d.ts +15 -11
  21. package/base/lib/actions/setupActions.js +25 -11
  22. package/base/lib/actions/setupActions.js.map +1 -1
  23. package/base/lib/dependencies/dependencies.d.ts +2 -2
  24. package/base/lib/dependencies/dependencies.js +23 -15
  25. package/base/lib/dependencies/dependencies.js.map +1 -1
  26. package/base/lib/dependencies/setupDependencies.d.ts +1 -3
  27. package/base/lib/dependencies/setupDependencies.js +3 -12
  28. package/base/lib/dependencies/setupDependencies.js.map +1 -1
  29. package/base/lib/index.d.ts +1 -0
  30. package/base/lib/index.js +2 -1
  31. package/base/lib/index.js.map +1 -1
  32. package/base/lib/inits/index.d.ts +2 -0
  33. package/base/lib/inits/index.js +19 -0
  34. package/base/lib/inits/index.js.map +1 -0
  35. package/base/lib/inits/setupInit.d.ts +9 -0
  36. package/base/lib/inits/setupInit.js +40 -0
  37. package/base/lib/inits/setupInit.js.map +1 -0
  38. package/base/lib/inits/setupUninit.d.ts +25 -0
  39. package/base/lib/inits/setupUninit.js +24 -0
  40. package/base/lib/inits/setupUninit.js.map +1 -0
  41. package/base/lib/interfaces/Host.js +18 -6
  42. package/base/lib/interfaces/Host.js.map +1 -1
  43. package/base/lib/interfaces/Origin.d.ts +2 -2
  44. package/base/lib/interfaces/Origin.js +3 -3
  45. package/base/lib/interfaces/Origin.js.map +1 -1
  46. package/base/lib/interfaces/ServiceInterfaceBuilder.d.ts +2 -2
  47. package/base/lib/interfaces/setupInterfaces.d.ts +2 -4
  48. package/base/lib/interfaces/setupInterfaces.js +8 -19
  49. package/base/lib/interfaces/setupInterfaces.js.map +1 -1
  50. package/base/lib/osBindings/AddCategoryParams.d.ts +0 -2
  51. package/base/lib/osBindings/AddPackageToCategoryParams.d.ts +5 -0
  52. package/base/lib/osBindings/AddPackageToCategoryParams.js +3 -0
  53. package/base/lib/osBindings/AddPackageToCategoryParams.js.map +1 -0
  54. package/base/lib/osBindings/AttachParams.d.ts +1 -0
  55. package/base/lib/osBindings/Category.d.ts +0 -2
  56. package/base/lib/osBindings/Category.js +1 -0
  57. package/base/lib/osBindings/Category.js.map +1 -1
  58. package/base/lib/osBindings/CheckDependenciesResult.d.ts +3 -3
  59. package/base/lib/osBindings/ClearTasksParams.d.ts +5 -0
  60. package/base/lib/osBindings/{UnsetPublicParams.js → ClearTasksParams.js} +1 -1
  61. package/base/lib/osBindings/ClearTasksParams.js.map +1 -0
  62. package/base/lib/osBindings/CreateTaskParams.d.ts +15 -0
  63. package/base/lib/osBindings/CreateTaskParams.js +3 -0
  64. package/base/lib/osBindings/CreateTaskParams.js.map +1 -0
  65. package/base/lib/osBindings/FileType.d.ts +1 -0
  66. package/base/lib/osBindings/{NetworkInterfaceSetPublicParams.js → FileType.js} +1 -1
  67. package/base/lib/osBindings/FileType.js.map +1 -0
  68. package/base/lib/osBindings/GetOsVersionParams.d.ts +3 -3
  69. package/base/lib/osBindings/GetPackageParams.d.ts +1 -1
  70. package/base/lib/osBindings/MainStatus.d.ts +0 -2
  71. package/base/lib/osBindings/Manifest.d.ts +1 -0
  72. package/base/lib/osBindings/MountTarget.d.ts +2 -0
  73. package/base/lib/osBindings/PackageDataEntry.d.ts +4 -5
  74. package/base/lib/osBindings/RemoveAdminParams.d.ts +4 -0
  75. package/base/lib/osBindings/RemoveAdminParams.js +3 -0
  76. package/base/lib/osBindings/RemoveAdminParams.js.map +1 -0
  77. package/base/lib/osBindings/RemoveAssetParams.d.ts +4 -0
  78. package/base/lib/osBindings/RemoveAssetParams.js +4 -0
  79. package/base/lib/osBindings/RemoveAssetParams.js.map +1 -0
  80. package/base/lib/osBindings/RemovePackageFromCategoryParams.d.ts +5 -0
  81. package/base/lib/osBindings/RemovePackageFromCategoryParams.js +3 -0
  82. package/base/lib/osBindings/RemovePackageFromCategoryParams.js.map +1 -0
  83. package/base/lib/osBindings/RemovePackageParams.d.ts +6 -0
  84. package/base/lib/osBindings/RemovePackageParams.js +3 -0
  85. package/base/lib/osBindings/RemovePackageParams.js.map +1 -0
  86. package/base/lib/osBindings/ServerInfo.d.ts +1 -0
  87. package/base/lib/osBindings/SetupExecuteParams.d.ts +1 -0
  88. package/base/lib/osBindings/Task.d.ts +13 -0
  89. package/base/lib/osBindings/Task.js +3 -0
  90. package/base/lib/osBindings/Task.js.map +1 -0
  91. package/base/lib/osBindings/TaskCondition.d.ts +1 -0
  92. package/base/lib/osBindings/TaskCondition.js +4 -0
  93. package/base/lib/osBindings/TaskCondition.js.map +1 -0
  94. package/base/lib/osBindings/TaskEntry.d.ts +5 -0
  95. package/base/lib/osBindings/TaskEntry.js +3 -0
  96. package/base/lib/osBindings/TaskEntry.js.map +1 -0
  97. package/base/lib/osBindings/TaskInput.d.ts +4 -0
  98. package/base/lib/osBindings/TaskInput.js +4 -0
  99. package/base/lib/osBindings/TaskInput.js.map +1 -0
  100. package/base/lib/osBindings/TaskSeverity.d.ts +1 -0
  101. package/base/lib/osBindings/TaskSeverity.js +4 -0
  102. package/base/lib/osBindings/TaskSeverity.js.map +1 -0
  103. package/base/lib/osBindings/TaskTrigger.d.ts +5 -0
  104. package/base/lib/osBindings/TaskTrigger.js +3 -0
  105. package/base/lib/osBindings/TaskTrigger.js.map +1 -0
  106. package/base/lib/osBindings/index.d.ts +14 -11
  107. package/base/lib/s9pk/index.js +5 -7
  108. package/base/lib/s9pk/index.js.map +1 -1
  109. package/base/lib/types.d.ts +22 -33
  110. package/base/lib/types.js +13 -0
  111. package/base/lib/types.js.map +1 -1
  112. package/base/lib/util/GetSystemSmtp.d.ts +4 -0
  113. package/base/lib/util/GetSystemSmtp.js +32 -2
  114. package/base/lib/util/GetSystemSmtp.js.map +1 -1
  115. package/base/lib/util/getServiceInterface.d.ts +14 -0
  116. package/base/lib/util/getServiceInterface.js +70 -1
  117. package/base/lib/util/getServiceInterface.js.map +1 -1
  118. package/base/lib/util/getServiceInterfaces.d.ts +4 -0
  119. package/base/lib/util/getServiceInterfaces.js +34 -1
  120. package/base/lib/util/getServiceInterfaces.js.map +1 -1
  121. package/base/lib/util/index.d.ts +0 -1
  122. package/base/lib/util/index.js +1 -3
  123. package/base/lib/util/index.js.map +1 -1
  124. package/package/lib/StartSdk.d.ts +108 -570
  125. package/package/lib/StartSdk.js +112 -428
  126. package/package/lib/StartSdk.js.map +1 -1
  127. package/package/lib/backup/Backups.d.ts +15 -3
  128. package/package/lib/backup/Backups.js +44 -28
  129. package/package/lib/backup/Backups.js.map +1 -1
  130. package/package/lib/backup/setupBackups.d.ts +5 -2
  131. package/package/lib/backup/setupBackups.js +7 -5
  132. package/package/lib/backup/setupBackups.js.map +1 -1
  133. package/package/lib/health/HealthCheck.d.ts +0 -1
  134. package/package/lib/health/HealthCheck.js +1 -7
  135. package/package/lib/health/HealthCheck.js.map +1 -1
  136. package/package/lib/health/checkFns/runHealthScript.d.ts +2 -1
  137. package/package/lib/health/checkFns/runHealthScript.js +1 -1
  138. package/package/lib/health/checkFns/runHealthScript.js.map +1 -1
  139. package/package/lib/index.d.ts +0 -3
  140. package/package/lib/index.js +1 -8
  141. package/package/lib/index.js.map +1 -1
  142. package/package/lib/inits/index.d.ts +2 -3
  143. package/package/lib/inits/index.js +16 -3
  144. package/package/lib/inits/index.js.map +1 -1
  145. package/package/lib/inits/setupInit.d.ts +7 -13
  146. package/package/lib/inits/setupInit.js +22 -48
  147. package/package/lib/inits/setupInit.js.map +1 -1
  148. package/package/lib/inits/setupInstall.d.ts +10 -10
  149. package/package/lib/inits/setupInstall.js.map +1 -1
  150. package/package/lib/inits/setupUninit.d.ts +7 -0
  151. package/package/lib/inits/setupUninit.js +14 -0
  152. package/package/lib/inits/setupUninit.js.map +1 -0
  153. package/package/lib/inits/setupUninstall.d.ts +5 -5
  154. package/package/lib/inits/setupUninstall.js.map +1 -1
  155. package/package/lib/mainFn/CommandController.d.ts +6 -24
  156. package/package/lib/mainFn/CommandController.js +72 -48
  157. package/package/lib/mainFn/CommandController.js.map +1 -1
  158. package/package/lib/mainFn/Daemon.d.ts +15 -22
  159. package/package/lib/mainFn/Daemon.js +56 -13
  160. package/package/lib/mainFn/Daemon.js.map +1 -1
  161. package/package/lib/mainFn/Daemons.d.ts +72 -49
  162. package/package/lib/mainFn/Daemons.js +87 -23
  163. package/package/lib/mainFn/Daemons.js.map +1 -1
  164. package/package/lib/mainFn/HealthDaemon.d.ts +8 -7
  165. package/package/lib/mainFn/HealthDaemon.js +79 -38
  166. package/package/lib/mainFn/HealthDaemon.js.map +1 -1
  167. package/package/lib/mainFn/Mounts.d.ts +38 -43
  168. package/package/lib/mainFn/Mounts.js +19 -48
  169. package/package/lib/mainFn/Mounts.js.map +1 -1
  170. package/package/lib/mainFn/Oneshot.d.ts +12 -0
  171. package/package/lib/mainFn/Oneshot.js +23 -0
  172. package/package/lib/mainFn/Oneshot.js.map +1 -0
  173. package/package/lib/mainFn/index.d.ts +1 -1
  174. package/package/lib/manifest/setupManifest.js +2 -0
  175. package/package/lib/manifest/setupManifest.js.map +1 -1
  176. package/package/lib/store/getStore.js +7 -2
  177. package/package/lib/store/getStore.js.map +1 -1
  178. package/package/lib/test/host.test.js +1 -1
  179. package/package/lib/test/host.test.js.map +1 -1
  180. package/package/lib/test/inputSpecBuilder.test.js +3 -10
  181. package/package/lib/test/inputSpecBuilder.test.js.map +1 -1
  182. package/package/lib/test/output.d.ts +2 -38
  183. package/package/lib/test/output.sdk.d.ts +235 -901
  184. package/package/lib/test/output.sdk.js +0 -1
  185. package/package/lib/test/output.sdk.js.map +1 -1
  186. package/package/lib/util/Drop.d.ts +4 -2
  187. package/package/lib/util/Drop.js +32 -8
  188. package/package/lib/util/Drop.js.map +1 -1
  189. package/package/lib/util/GetSslCertificate.d.ts +4 -0
  190. package/package/lib/util/GetSslCertificate.js +34 -2
  191. package/package/lib/util/GetSslCertificate.js.map +1 -1
  192. package/package/lib/util/SubContainer.d.ts +164 -45
  193. package/package/lib/util/SubContainer.js +223 -100
  194. package/package/lib/util/SubContainer.js.map +1 -1
  195. package/package/lib/util/fileHelper.d.ts +46 -17
  196. package/package/lib/util/fileHelper.js +112 -41
  197. package/package/lib/util/fileHelper.js.map +1 -1
  198. package/package/lib/version/VersionGraph.d.ts +26 -5
  199. package/package/lib/version/VersionGraph.js +88 -22
  200. package/package/lib/version/VersionGraph.js.map +1 -1
  201. package/package/package.json +63 -0
  202. package/package.json +7 -8
  203. package/base/lib/osBindings/NetworkInterfaceSetPublicParams.d.ts +0 -4
  204. package/base/lib/osBindings/NetworkInterfaceSetPublicParams.js.map +0 -1
  205. package/base/lib/osBindings/UnsetPublicParams.d.ts +0 -3
  206. package/base/lib/osBindings/UnsetPublicParams.js.map +0 -1
@@ -43,13 +43,10 @@ const patterns = __importStar(require("../../base/lib/util/patterns"));
43
43
  const Backups_1 = require("./backup/Backups");
44
44
  const inputSpecConstants_1 = require("../../base/lib/actions/input/inputSpecConstants");
45
45
  const Daemons_1 = require("./mainFn/Daemons");
46
- const HealthCheck_1 = require("./health/HealthCheck");
47
46
  const checkPortListening_1 = require("./health/checkFns/checkPortListening");
48
47
  const checkFns_1 = require("./health/checkFns");
49
48
  const list_1 = require("../../base/lib/actions/input/builder/list");
50
- const setupInstall_1 = require("./inits/setupInstall");
51
49
  const setupBackups_1 = require("./backup/setupBackups");
52
- const setupUninstall_1 = require("./inits/setupUninstall");
53
50
  const mainFn_1 = require("./mainFn");
54
51
  const defaultTrigger_1 = require("./trigger/defaultTrigger");
55
52
  const trigger_1 = require("./trigger");
@@ -60,20 +57,19 @@ const ServiceInterfaceBuilder_1 = require("../../base/lib/interfaces/ServiceInte
60
57
  const util_1 = require("./util");
61
58
  const util_2 = require("./util");
62
59
  const util_3 = require("./util");
63
- const getStore_1 = require("./store/getStore");
64
60
  const SubContainer_1 = require("./util/SubContainer");
65
61
  const util_4 = require("./util");
66
62
  const Mounts_1 = require("./mainFn/Mounts");
67
63
  const setupDependencies_1 = require("../../base/lib/dependencies/setupDependencies");
68
64
  const T = __importStar(require("../../base/lib/types"));
69
65
  const exver_1 = require("../../base/lib/exver");
70
- const PathBuilder_1 = require("../../base/lib/util/PathBuilder");
71
66
  const dependencies_1 = require("../../base/lib/dependencies/dependencies");
72
67
  const util_5 = require("./util");
68
+ const version_1 = require("./version");
73
69
  const actions = __importStar(require("../../base/lib/actions"));
74
- const setupInit_1 = require("./inits/setupInit");
75
70
  const fs = __importStar(require("node:fs/promises"));
76
- exports.OSVersion = (0, exver_1.testTypeVersion)("0.4.0-alpha.0");
71
+ const inits_1 = require("../../base/lib/inits");
72
+ exports.OSVersion = (0, exver_1.testTypeVersion)("0.4.0-alpha.6");
77
73
  class StartSdk {
78
74
  constructor(manifest) {
79
75
  this.manifest = manifest;
@@ -84,9 +80,6 @@ class StartSdk {
84
80
  withManifest(manifest) {
85
81
  return new StartSdk(manifest);
86
82
  }
87
- withStore() {
88
- return new StartSdk(this.manifest);
89
- }
90
83
  build(isReady) {
91
84
  const startSdkEffectWrapper = {
92
85
  restart: (effects, ...args) => effects.restart(...args),
@@ -94,37 +87,37 @@ class StartSdk {
94
87
  checkDependencies: (effects, ...args) => effects.checkDependencies(...args),
95
88
  mount: (effects, ...args) => effects.mount(...args),
96
89
  getInstalledPackages: (effects, ...args) => effects.getInstalledPackages(...args),
97
- exposeForDependents: (effects, ...args) => effects.exposeForDependents(...args),
98
90
  getServicePortForward: (effects, ...args) => effects.getServicePortForward(...args),
99
91
  clearBindings: (effects, ...args) => effects.clearBindings(...args),
100
92
  getOsIp: (effects, ...args) => effects.getOsIp(...args),
101
93
  getSslKey: (effects, ...args) => effects.getSslKey(...args),
102
- setDataVersion: (effects, ...args) => effects.setDataVersion(...args),
103
- getDataVersion: (effects, ...args) => effects.getDataVersion(...args),
104
94
  shutdown: (effects, ...args) => effects.shutdown(...args),
105
95
  getDependencies: (effects, ...args) => effects.getDependencies(...args),
106
96
  getStatus: (effects, ...args) => effects.getStatus(...args),
97
+ setHealth: (effects, ...args) => effects.setHealth(...args),
107
98
  };
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
- request: (effects, packageId, action, severity, options) => actions.requestAction({
106
+ createTask: (effects, packageId, action, severity, options) => actions.createTask({
114
107
  effects,
115
108
  packageId,
116
109
  action,
117
110
  severity,
118
111
  options: options,
119
112
  }),
120
- requestOwn: (effects, action, severity, options) => actions.requestAction({
113
+ createOwnTask: (effects, action, severity, options) => actions.createTask({
121
114
  effects,
122
115
  packageId: this.manifest.id,
123
116
  action,
124
117
  severity,
125
118
  options: options,
126
119
  }),
127
- clearRequest: (effects, ...replayIds) => effects.action.clearRequests({ only: replayIds }),
120
+ clearTask: (effects, ...replayIds) => effects.action.clearTasks({ only: replayIds }),
128
121
  },
129
122
  checkDependencies: dependencies_1.checkDependencies,
130
123
  serviceInterface: {
@@ -137,10 +130,15 @@ class StartSdk {
137
130
  },
138
131
  getContainerIp: (effects, options = {}) => {
139
132
  async function* watch() {
140
- while (true) {
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;
@@ -169,30 +167,33 @@ class StartSdk {
169
167
  .catch((e) => callback(null, e))
170
168
  .catch((e) => console.error("callback function threw an error @ getContainerIp.onChange", e));
171
169
  },
170
+ waitFor: async (pred) => {
171
+ const resolveCell = { resolve: () => { } };
172
+ effects.onLeaveContext(() => {
173
+ resolveCell.resolve();
174
+ });
175
+ while (effects.isInContext) {
176
+ let callback = () => { };
177
+ const waitForNext = new Promise((resolve) => {
178
+ callback = resolve;
179
+ resolveCell.resolve = resolve;
180
+ });
181
+ const res = await effects.getContainerIp({ ...options, callback });
182
+ if (pred(res)) {
183
+ resolveCell.resolve();
184
+ return res;
185
+ }
186
+ await waitForNext;
187
+ }
188
+ return null;
189
+ },
172
190
  };
173
191
  },
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
192
  MultiHost: {
185
193
  of: (effects, id) => new Host_1.MultiHost({ id, effects }),
186
194
  },
187
195
  nullIfEmpty: util_2.nullIfEmpty,
188
196
  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
197
  /**
197
198
  * @description Use this class to create an Action. By convention, each Action should receive its own file.
198
199
  *
@@ -265,6 +266,7 @@ class StartSdk {
265
266
  * In this example, we create an action that returns a secret phrase for the user to see.
266
267
  *
267
268
  * ```
269
+ import { store } from '../file-models/store.json'
268
270
  import { sdk } from '../sdk'
269
271
 
270
272
  export const showSecretPhrase = sdk.Action.withoutInput(
@@ -289,9 +291,7 @@ class StartSdk {
289
291
  'Below is your secret phrase. Use it to gain access to extraordinary places',
290
292
  result: {
291
293
  type: 'single',
292
- value: await sdk.store
293
- .getOwn(effects, sdk.StorePath.secretPhrase)
294
- .const(),
294
+ value: (await store.read.once())?.secretPhrase,
295
295
  copyable: true,
296
296
  qr: true,
297
297
  masked: true,
@@ -320,14 +320,13 @@ class StartSdk {
320
320
  schemeOverride: null,
321
321
  username: null,
322
322
  path: '',
323
- search: {},
323
+ query: {},
324
324
  })
325
325
  * ```
326
326
  */
327
327
  createInterface: (effects, options) => new ServiceInterfaceBuilder_1.ServiceInterfaceBuilder({ ...options, effects }),
328
328
  getSystemSmtp: (effects) => new util_1.GetSystemSmtp(effects),
329
329
  getSslCerificate: (effects, hostnames, algorithm) => new util_5.GetSslCertificate(effects, hostnames, algorithm),
330
- HealthCheck: HealthCheck_1.HealthCheck,
331
330
  healthCheck: {
332
331
  checkPortListening: checkPortListening_1.checkPortListening,
333
332
  checkWebUrl: checkFns_1.checkWebUrl,
@@ -378,11 +377,11 @@ class StartSdk {
378
377
  /**
379
378
  * @description Use this function to set dependency information.
380
379
  * @example
381
- * 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.
380
+ * 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
381
  *
383
382
  * ```
384
383
  export const setDependencies = sdk.setupDependencies(
385
- async ({ effects, input }) => {
384
+ async ({ effects }) => {
386
385
  return {
387
386
  'hello-world': {
388
387
  kind: 'running',
@@ -393,66 +392,57 @@ class StartSdk {
393
392
  },
394
393
  )
395
394
  * ```
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
395
  */
417
396
  setupDependencies: (setupDependencies_1.setupDependencies),
418
- setupInit: (setupInit_1.setupInit),
419
397
  /**
420
- * @description Use this function to execute arbitrary logic *once*, on initial install *before* interfaces, actions, and dependencies are updated.
398
+ * @description Use this function to create an InitScript that runs every time the service initializes (install, update, restore, rebuild, and server bootup)
399
+ */
400
+ setupOnInit: inits_1.setupOnInit,
401
+ /**
402
+ * @description Use this function to create an UninitScript that runs every time the service uninitializes (update, uninstall, and server shutdown)
403
+ */
404
+ setupOnUninit: inits_1.setupOnUninit,
405
+ /**
406
+ * @description Use this function to setup what happens when the service initializes.
407
+ *
408
+ * This happens when the server boots, or a service is installed, updated, or restored
409
+ *
410
+ * Not every init script does something on every initialization. For example, versions only does something on install or update
411
+ *
412
+ * These scripts are run in the order they are supplied
421
413
  * @example
422
- * In the this example, we initialize a config file
423
414
  *
424
415
  * ```
425
- const preInstall = sdk.setupPreInstall(async ({ effects }) => {
426
- await configFile.write(effects, { name: 'World' })
427
- })
416
+ export const init = sdk.setupInit(
417
+ restoreInit,
418
+ versions,
419
+ setDependencies,
420
+ setInterfaces,
421
+ actions,
422
+ postInstall,
423
+ )
428
424
  * ```
429
425
  */
430
- setupPreInstall: (fn) => setupInstall_1.PreInstall.of(fn),
426
+ setupInit: inits_1.setupInit,
431
427
  /**
432
- * @description Use this function to execute arbitrary logic *once*, on initial install *after* interfaces, actions, and dependencies are updated.
428
+ * @description Use this function to setup what happens when the service uninitializes.
429
+ *
430
+ * This happens when the server shuts down, or a service is uninstalled or updated
431
+ *
432
+ * Not every uninit script does something on every uninitialization. For example, versions only does something on uninstall or update
433
+ *
434
+ * These scripts are run in the order they are supplied
433
435
  * @example
434
- * In the this example, we bootstrap our Store with a random, 16-char admin password.
435
436
  *
436
437
  * ```
437
- const postInstall = sdk.setupPostInstall(async ({ effects }) => {
438
- await sdk.store.setOwn(
439
- effects,
440
- sdk.StorePath.adminPassword,
441
- utils.getDefaultString({
442
- charset: 'a-z,A-Z,1-9,!,@,$,%,&,',
443
- len: 16,
444
- }),
445
- )
446
- })
438
+ export const uninit = sdk.setupUninit(
439
+ versions,
440
+ )
447
441
  * ```
448
442
  */
449
- setupPostInstall: (fn) => setupInstall_1.PostInstall.of(fn),
443
+ setupUninit: inits_1.setupUninit,
450
444
  /**
451
445
  * @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
446
  * @param inputSpec - The inputSpec spec of this service as exported from /inputSpec/spec.
457
447
  * @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
448
  * @example
@@ -460,8 +450,7 @@ class StartSdk {
460
450
  *
461
451
  * ```
462
452
  export const setInterfaces = sdk.setupInterfaces(
463
- inputSpecSpec,
464
- async ({ effects, input }) => {
453
+ async ({ effects }) => {
465
454
  // ** UI multi-host **
466
455
  const uiMulti = sdk.MultiHost.of(effects, 'ui-multi')
467
456
  const uiMultiOrigin = await uiMulti.bindPort(80, {
@@ -477,7 +466,7 @@ class StartSdk {
477
466
  schemeOverride: null,
478
467
  username: null,
479
468
  path: '',
480
- search: {},
469
+ query: {},
481
470
  })
482
471
  // Admin UI
483
472
  const adminUi = sdk.createInterface(effects, {
@@ -489,7 +478,7 @@ class StartSdk {
489
478
  schemeOverride: null,
490
479
  username: null,
491
480
  path: '/admin',
492
- search: {},
481
+ query: {},
493
482
  })
494
483
  // UI receipt
495
484
  const uiReceipt = await uiMultiOrigin.export([primaryUi, adminUi])
@@ -509,7 +498,7 @@ class StartSdk {
509
498
  schemeOverride: null,
510
499
  username: null,
511
500
  path: '',
512
- search: {},
501
+ query: {},
513
502
  })
514
503
  // API receipt
515
504
  const apiReceipt = await apiMultiOrigin.export([api])
@@ -522,10 +511,6 @@ class StartSdk {
522
511
  */
523
512
  setupInterfaces: setupInterfaces_1.setupServiceInterfaces,
524
513
  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
514
  trigger: {
530
515
  defaultTrigger: defaultTrigger_1.defaultTrigger,
531
516
  cooldownTrigger: trigger_1.cooldownTrigger,
@@ -533,14 +518,12 @@ class StartSdk {
533
518
  successFailure: successFailure_1.successFailure,
534
519
  },
535
520
  Mounts: {
536
- of() {
537
- return Mounts_1.Mounts.of();
538
- },
521
+ of: (Mounts_1.Mounts.of),
539
522
  },
540
523
  Backups: {
541
- volumes: (...volumeNames) => Backups_1.Backups.withVolumes(...volumeNames),
542
- addSets: (...options) => Backups_1.Backups.withSyncs(...options),
543
- withOptions: (options) => Backups_1.Backups.withOptions(options),
524
+ ofVolumes: (Backups_1.Backups.ofVolumes),
525
+ ofSyncs: (Backups_1.Backups.ofSyncs),
526
+ withOptions: (Backups_1.Backups.withOptions),
544
527
  },
545
528
  InputSpec: {
546
529
  /**
@@ -572,347 +555,48 @@ class StartSdk {
572
555
  */
573
556
  of: (spec) => inputSpec_1.InputSpec.of(spec),
574
557
  },
575
- Daemons: {
576
- of(effects, started, healthChecks) {
577
- return Daemons_1.Daemons.of({ effects, started, healthChecks });
558
+ Daemon: {
559
+ get of() {
560
+ return Daemons_1.Daemon.of();
578
561
  },
579
562
  },
580
- 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);
563
+ Daemons: {
564
+ of(effects, started) {
565
+ return Daemons_1.Daemons.of({ effects, started });
586
566
  },
587
567
  },
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,
568
+ SubContainer: {
800
569
  /**
801
- * @description Displays a dropdown, allowing for a single selection. Depending on the selection, a different object ("sub form") is presented.
802
- * @example
803
- * ```
804
- unionExample: Value.union(
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
- * ```
570
+ * @description Create a new SubContainer
571
+ * @param effects
572
+ * @param image - what container image to use
573
+ * @param mounts - what to mount to the subcontainer
574
+ * @param name - a name to use to refer to the subcontainer for debugging purposes
828
575
  */
829
- union: value_1.Value.union,
576
+ of(effects, image, mounts, name) {
577
+ return SubContainer_1.SubContainerOwned.of(effects, image, mounts, name);
578
+ },
830
579
  /**
831
- * @description Presents an interface to add/remove/edit items in a list.
832
- * @example
833
- * In this example, we create a list of text inputs.
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
- * ```
580
+ * @description Run a function with a temporary SubContainer
581
+ * @param effects
582
+ * @param image - what container image to use
583
+ * @param mounts - what to mount to the subcontainer
584
+ * @param name - a name to use to refer to the ephemeral subcontainer for debugging purposes
892
585
  */
893
- list: value_1.Value.list,
894
- hidden: value_1.Value.hidden,
895
- dynamicToggle: (value_1.Value.dynamicToggle),
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),
586
+ withTemp(effects, image, mounts, name, fn) {
587
+ return SubContainer_1.SubContainerOwned.withTemp(effects, image, mounts, name, fn);
588
+ },
908
589
  },
590
+ List: list_1.List,
591
+ Value: value_1.Value,
592
+ Variants: variants_1.Variants,
909
593
  };
910
594
  }
911
595
  }
912
596
  exports.StartSdk = StartSdk;
913
597
  async function runCommand(effects, image, command, options, name) {
914
598
  let commands;
915
- if (command instanceof T.UseEntrypoint) {
599
+ if (T.isUseEntrypoint(command)) {
916
600
  const imageMeta = await fs
917
601
  .readFile(`/media/startos/images/${image.imageId}.json`, {
918
602
  encoding: "utf8",
@@ -920,11 +604,11 @@ async function runCommand(effects, image, command, options, name) {
920
604
  .catch(() => "{}")
921
605
  .then(JSON.parse);
922
606
  commands = imageMeta.entrypoint ?? [];
923
- commands.concat(...(command.overridCmd ?? imageMeta.cmd ?? []));
607
+ commands = commands.concat(...(command.overridCmd ?? imageMeta.cmd ?? []));
924
608
  }
925
609
  else
926
610
  commands = (0, util_4.splitCommand)(command);
927
- return SubContainer_1.SubContainer.with(effects, image, options.mounts.build(), name ||
611
+ return SubContainer_1.SubContainerOwned.withTemp(effects, image, options.mounts, name ||
928
612
  commands
929
613
  .map((c) => {
930
614
  if (c.includes(" ")) {