@sasjs/cli 6.19.0 → 6.19.1

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.
@@ -1475,9 +1475,16 @@ const api = {
1475
1475
  // Called by the host with the persisted drive; skips seeding entirely.
1476
1476
  load: (files) => {
1477
1477
  started = true
1478
+ // The site's configuration and the webout() block are host files, not drive
1479
+ // contents, so a restore needs them exactly as a seed does: only the seed
1480
+ // used to load them, and every service written with webout() then failed
1481
+ // with "webout is not defined" for a visitor the drive had been restored
1482
+ // for. The drive itself is loaded synchronously, so callers that read it
1483
+ // straight away still can; the promise is what a worker awaits.
1484
+ const hostFiles = Promise.all([loadMockConfig(), loadWeboutPrelude()])
1478
1485
  const info = loadSnapshot(files)
1479
- ready = Promise.resolve(info)
1480
- if (resolveBoot) resolveBoot(info)
1486
+ ready = hostFiles.then(() => info)
1487
+ if (resolveBoot) resolveBoot(ready)
1481
1488
  return ready
1482
1489
  },
1483
1490
  seed: () => {
@@ -66,6 +66,19 @@ var jsonResponse = function (body) { return ({
66
66
  return [2 /*return*/, body];
67
67
  }); }); }
68
68
  }); };
69
+ /** The webout() block the build ships, with its sentinels still in place. */
70
+ var weboutPrelude = function () { return ({
71
+ sentinels: mockSite_1.WEBOUT_SENTINELS,
72
+ template: (0, utils_1.getWeboutPrelude)({
73
+ weboutPath: mockSite_1.WEBOUT_SENTINELS.weboutPath,
74
+ headersPath: mockSite_1.WEBOUT_SENTINELS.headersPath,
75
+ program: mockSite_1.WEBOUT_SENTINELS.program,
76
+ debug: mockSite_1.WEBOUT_SENTINELS.debug,
77
+ username: mockSite_1.WEBOUT_SENTINELS.username,
78
+ userId: mockSite_1.WEBOUT_SENTINELS.userId,
79
+ apiServerUrl: mockSite_1.WEBOUT_SENTINELS.apiServerUrl
80
+ })
81
+ }); };
69
82
  var seedDrive = function (runtime, files, prelude) { return __awaiter(void 0, void 0, void 0, function () {
70
83
  return __generator(this, function (_a) {
71
84
  switch (_a.label) {
@@ -151,18 +164,7 @@ describe('browser runtime', function () {
151
164
  // values runtime-core fills per run. Without it a service written with
152
165
  // webout() fails in a mock build with "webout is not defined", which is the
153
166
  // gap this closes.
154
- return [4 /*yield*/, seedDrive(runtime, {}, {
155
- sentinels: mockSite_1.WEBOUT_SENTINELS,
156
- template: (0, utils_1.getWeboutPrelude)({
157
- weboutPath: mockSite_1.WEBOUT_SENTINELS.weboutPath,
158
- headersPath: mockSite_1.WEBOUT_SENTINELS.headersPath,
159
- program: mockSite_1.WEBOUT_SENTINELS.program,
160
- debug: mockSite_1.WEBOUT_SENTINELS.debug,
161
- username: mockSite_1.WEBOUT_SENTINELS.username,
162
- userId: mockSite_1.WEBOUT_SENTINELS.userId,
163
- apiServerUrl: mockSite_1.WEBOUT_SENTINELS.apiServerUrl
164
- })
165
- })];
167
+ return [4 /*yield*/, seedDrive(runtime, {}, weboutPrelude())];
166
168
  case 1:
167
169
  // A mock build ships the same block the server generates, with sentinel
168
170
  // values runtime-core fills per run. Without it a service written with
@@ -189,6 +191,43 @@ describe('browser runtime', function () {
189
191
  }
190
192
  });
191
193
  }); });
194
+ it('restores a persisted drive with the host files, so webout() still runs', function () { return __awaiter(void 0, void 0, void 0, function () {
195
+ var runtime, result, byName;
196
+ var _a;
197
+ return __generator(this, function (_b) {
198
+ switch (_b.label) {
199
+ case 0:
200
+ runtime = loadRuntime();
201
+ global.fetch = jest.fn(function (url) { return __awaiter(void 0, void 0, void 0, function () {
202
+ return __generator(this, function (_a) {
203
+ if (url.includes('mock-config'))
204
+ return [2 /*return*/, jsonResponse({ appLoc: appLoc })];
205
+ if (url.includes('webout-prelude'))
206
+ return [2 /*return*/, jsonResponse(weboutPrelude())];
207
+ return [2 /*return*/, { ok: false, json: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
208
+ return [2 /*return*/, ({})];
209
+ }); }); } }];
210
+ });
211
+ }); });
212
+ return [4 /*yield*/, runtime.load((_a = {},
213
+ _a[drivePath('services/public/svc.js')] = "\nwebout('OPEN')\nwebout('OBJ', 'users', [{ name: 'ann' }])\nwebout('CLOSE')",
214
+ _a))
215
+ // the first failure on a restored drive was this one: the block is a host
216
+ // file, so webout() was not defined at all
217
+ ];
218
+ case 1:
219
+ _b.sent();
220
+ result = runtime.run({
221
+ program: "".concat(appLoc, "/services/public/svc.js")
222
+ });
223
+ expect(result.error).toBeNull();
224
+ expect(JSON.parse(result.webout).users).toEqual([{ name: 'ann' }]);
225
+ byName = runtime.run({ program: 'public/svc' });
226
+ expect(byName.error).toBeNull();
227
+ return [2 /*return*/];
228
+ }
229
+ });
230
+ }); });
192
231
  it('seeds the headers the way a JS session does, for a service that only assigns _webout', function () { return __awaiter(void 0, void 0, void 0, function () {
193
232
  var runtime, result;
194
233
  return __generator(this, function (_a) {
package/package.json CHANGED
@@ -125,5 +125,5 @@
125
125
  "ws": "8.21.0",
126
126
  "nanoid": "3.3.18"
127
127
  },
128
- "version": "6.19.0"
128
+ "version": "6.19.1"
129
129
  }