@sasjs/adapter 6.0.2 → 6.1.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.
package/README.md CHANGED
@@ -291,7 +291,7 @@ Configuration on the client side involves passing an object on startup, which ca
291
291
  - `appLoc` - this is the folder (eg in metadata or SAS Drive) under which the SAS services are created.
292
292
  - `serverType` - either `SAS9`, `SASVIYA` or `SASJS`. The `SASJS` server type is for use with [sasjs/server](https://github.com/sasjs/server).
293
293
  - `serverUrl` - the location (including http protocol and port) of the SAS Server. Can be omitted, eg if serving directly from the SAS Web Server, or in streaming mode.
294
- - `pathSASJS` - Only relevant when the serverType is `SASJS`. The path the SASjs Server API is mounted at - `/SASjsApi` by default, or `/api` to use the short spelling that sasjs/server also serves. Every SASjs Server route is addressed under this mount, including the stored-program endpoint at `<mount>/stp/execute`, which is not configurable.
294
+ - `pathSASJS` - Only relevant when the serverType is `SASJS`. The path the SASjs Server API is mounted at - `/SASjsApi` by default, or `/api` to use the short spelling that sasjs/server also serves. Every SASjs Server route is addressed under this mount, including the stored-program endpoint at `<mount>/stp/execute`, which is not configurable. Read the mount back with `sasjs.getApiBasePath()`, which answers the normalised mount (`/api` for a configured `/api/`, the mount itself for a configured `/api/stp/execute`, and the default `/SASjsApi` for a Viya or SAS 9 project) - note that `sasjs.getSasjsConfig().pathSASJS` reads back as configured, or `/SASjsApi` when it was never set, so a defaulted mount and one configured as `/SASjsApi` look the same there and `getApiBasePath()` is the answer to what the mount is. A root mount is `/`, and a caller concatenating onto it should treat that as an empty prefix rather than the value verbatim, or the URL carries a doubled slash.
295
295
  - `debug` - if `true` then SAS Logs and extra debug information is returned.
296
296
  - `verbose` - optional, if `true` then a summary of every HTTP response is logged.
297
297
  - `loginMechanism` - either `Default` or `Redirected`. See [SAS Logon](#sas-logon) section.
@@ -249,6 +249,14 @@ export declare class SASViyaApiClient {
249
249
  * @param onTokensRefreshed - optional callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
250
250
  */
251
251
  executeJob(sasJob: string, contextName: string, debug: boolean, data?: any, authConfig?: AuthConfig, onTokensRefreshed?: OnTokensRefreshed): Promise<JobExecutionResult>;
252
+ /**
253
+ * The key `folderMap` stores a folder's members under.
254
+ *
255
+ * Normalised, so a caller's '//app' and its own '/app' are one key: the map is
256
+ * written by populateFolderMap and read by four other methods, and a path that
257
+ * needs normalising must not miss its own entry.
258
+ */
259
+ private folderMapKey;
252
260
  private populateFolderMap;
253
261
  private pollJobState;
254
262
  private uploadTables;
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.SASViyaApiClient = void 0;
16
16
  const utils_1 = require("./utils");
17
+ const joinFolderPath_1 = require("./utils/joinFolderPath");
17
18
  const form_data_1 = __importDefault(require("form-data"));
18
19
  const errors_1 = require("./types/errors");
19
20
  const SessionManager_1 = require("./SessionManager");
@@ -71,9 +72,7 @@ class SASViyaApiClient {
71
72
  */
72
73
  getJobsInFolder(folderPath) {
73
74
  return __awaiter(this, void 0, void 0, function* () {
74
- const path = (0, utils_1.isRelativePath)(folderPath)
75
- ? `${this.rootFolderName}/${folderPath}`
76
- : folderPath;
75
+ const path = this.folderMapKey(folderPath);
77
76
  if (this.folderMap.get(path)) {
78
77
  return this.folderMap.get(path);
79
78
  }
@@ -275,8 +274,11 @@ class SASViyaApiClient {
275
274
  */
276
275
  getFolder(folderPath, accessToken) {
277
276
  return __awaiter(this, void 0, void 0, function* () {
277
+ // one of the three places a path becomes a request, so the same normalisation
278
+ // applies here as in getFolderDetails - otherwise getFolder('//app') sends the
279
+ // string this class now refuses to send anywhere else
278
280
  return yield this.requestClient
279
- .get(`/folders/folders/@item?path=${folderPath}`, accessToken)
281
+ .get(`/folders/folders/@item?path=${(0, joinFolderPath_1.normaliseFolderPath)(folderPath)}`, accessToken)
280
282
  .then((res) => res.result);
281
283
  });
282
284
  }
@@ -405,10 +407,10 @@ class SASViyaApiClient {
405
407
  parentFolderUri = `/folders/folders/${parentFolder.id}`;
406
408
  }
407
409
  else if (isForced) {
408
- const folderPath = parentFolderPath + '/' + folderName;
410
+ const folderPath = (0, joinFolderPath_1.joinFolderPath)(parentFolderPath, folderName);
409
411
  const folderUri = yield this.getFolderUri(folderPath, accessToken);
410
412
  if (folderUri) {
411
- yield this.deleteFolder(parentFolderPath + '/' + folderName, accessToken);
413
+ yield this.deleteFolder(folderPath, accessToken);
412
414
  }
413
415
  }
414
416
  }
@@ -431,8 +433,21 @@ class SASViyaApiClient {
431
433
  }
432
434
  throw err;
433
435
  });
434
- // update folder map with newly created folder.
435
- yield this.populateFolderMap(`${parentFolderPath}/${folderName}`, accessToken);
436
+ // The POST answered with the folder it created, so there is nothing to look up:
437
+ // a new folder has no members, and re-reading it by a path joined here by hand
438
+ // is how the doubled slash in adapter#974 reached the server.
439
+ //
440
+ // An empty member list is only ever written for a folder that has just been
441
+ // created, which is the one case where it is exact: a folder that already
442
+ // existed refuses the POST (409) unless `isForced` deleted it first, and a
443
+ // deleted folder takes its members with it. So this cannot drop members the
444
+ // server still has.
445
+ //
446
+ // A caller may have given a URI instead of a path, in which case there is no
447
+ // key to file it under - and the previous code filed it under "undefined/name".
448
+ if (parentFolderPath) {
449
+ this.folderMap.set(this.folderMapKey((0, joinFolderPath_1.joinFolderPath)(parentFolderPath, folderName)), []);
450
+ }
436
451
  return createFolderResponse;
437
452
  });
438
453
  }
@@ -573,7 +588,7 @@ class SASViyaApiClient {
573
588
  yield this.populateFolderMap(fullFolderPath, access_token).catch((err) => {
574
589
  throw (0, error_1.prefixMessage)(err, 'Error while populating folder map. ');
575
590
  });
576
- const jobFolder = this.folderMap.get(fullFolderPath);
591
+ const jobFolder = this.folderMap.get(this.folderMapKey(fullFolderPath));
577
592
  if (!jobFolder) {
578
593
  throw new Error(`The folder '${fullFolderPath}' was not found on '${this.serverUrl}'`);
579
594
  }
@@ -629,7 +644,7 @@ class SASViyaApiClient {
629
644
  ? `${this.rootFolderName}/${folderPath}`
630
645
  : folderPath;
631
646
  yield this.populateFolderMap(fullFolderPath, access_token);
632
- const jobFolder = this.folderMap.get(fullFolderPath);
647
+ const jobFolder = this.folderMap.get(this.folderMapKey(fullFolderPath));
633
648
  if (!jobFolder) {
634
649
  throw new Error(`The folder '${fullFolderPath}' was not found on '${this.serverUrl}'.`);
635
650
  }
@@ -703,11 +718,21 @@ class SASViyaApiClient {
703
718
  return executionResult;
704
719
  });
705
720
  }
721
+ /**
722
+ * The key `folderMap` stores a folder's members under.
723
+ *
724
+ * Normalised, so a caller's '//app' and its own '/app' are one key: the map is
725
+ * written by populateFolderMap and read by four other methods, and a path that
726
+ * needs normalising must not miss its own entry.
727
+ */
728
+ folderMapKey(folderPath) {
729
+ return (0, joinFolderPath_1.normaliseFolderPath)((0, utils_1.isRelativePath)(folderPath)
730
+ ? `${this.rootFolderName}/${folderPath}`
731
+ : folderPath);
732
+ }
706
733
  populateFolderMap(folderPath, accessToken) {
707
734
  return __awaiter(this, void 0, void 0, function* () {
708
- const path = (0, utils_1.isRelativePath)(folderPath)
709
- ? `${this.rootFolderName}/${folderPath}`
710
- : folderPath;
735
+ const path = this.folderMapKey(folderPath);
711
736
  if (this.folderMap.get(path)) {
712
737
  return;
713
738
  }
@@ -742,9 +767,12 @@ class SASViyaApiClient {
742
767
  }
743
768
  getFolderDetails(folderPath, accessToken) {
744
769
  return __awaiter(this, void 0, void 0, function* () {
745
- const url = (0, utils_1.isUri)(folderPath)
746
- ? folderPath
747
- : `/folders/folders/@item?path=${folderPath}`;
770
+ // every caller reaches the server through here, so the collapse happens at the
771
+ // point a path becomes a URL rather than at each place one is built
772
+ const normalisedPath = (0, joinFolderPath_1.normaliseFolderPath)(folderPath);
773
+ const url = (0, utils_1.isUri)(normalisedPath)
774
+ ? normalisedPath
775
+ : `/folders/folders/@item?path=${normalisedPath}`;
748
776
  const { result: folder } = yield this.requestClient
749
777
  .get(`${this.serverUrl}${url}`, accessToken)
750
778
  .catch((err) => {
package/SASjs.d.ts CHANGED
@@ -246,13 +246,30 @@ export default class SASjs {
246
246
  */
247
247
  setSASjsConfig(config: Partial<SASjsConfig>): Promise<void>;
248
248
  /**
249
- * The mount every SASjs Server route sits under, read from `pathSASJS`.
249
+ * The mount every SASjs Server route sits under, normalised.
250
250
  *
251
- * One knob: deploy, code execution, triggers, sessions, auth and the
252
- * stored-program endpoint all hang off this, so they cannot end up on
253
- * different mounts.
254
- */
255
- private getApiBasePath;
251
+ * This is the read side of `pathSASJS`, and the only place the value is
252
+ * interpreted: one leading slash, no trailing one (`/api/` and ` api/ ` are
253
+ * both `/api`), a value carrying the stored-program endpoint
254
+ * (`/api/stp/execute`) is read as the mount it names, and absent or empty
255
+ * means `/SASjsApi`. A root mount is `/` - a proxy that puts the API at the
256
+ * origin - and a caller concatenating onto it contributes `''` for that
257
+ * case rather than the value verbatim, because `${serverUrl}/` + `/stp/...`
258
+ * is a doubled slash and a different URL to a proxy.
259
+ *
260
+ * A Viya or SAS 9 project has no such mount: neither server type reads
261
+ * `pathSASJS`, so this answers the default `/SASjsApi` for them.
262
+ *
263
+ * Public so a consumer that composes a URL by hand - `<mount>/stp/execute`
264
+ * for a `?_program=` link, or a route it builds for the drive and info
265
+ * endpoints - asks the adapter instead of re-implementing the normalisation
266
+ * or deep-importing the `apiBasePath` module. Note that
267
+ * `getSasjsConfig().pathSASJS` is not this value: it reads back as configured,
268
+ * or `/SASjsApi` when it was never set (the constructor's default), so a
269
+ * caller cannot tell a defaulted value from one configured as `/SASjsApi`
270
+ * there - this accessor is the answer to what the mount is.
271
+ */
272
+ getApiBasePath(): string;
256
273
  /**
257
274
  * Sets the debug state. Turning this on will enable additional logging in the adapter.
258
275
  * @param value - boolean indicating debug state (on/off).
package/SASjs.js CHANGED
@@ -439,11 +439,28 @@ class SASjs {
439
439
  });
440
440
  }
441
441
  /**
442
- * The mount every SASjs Server route sits under, read from `pathSASJS`.
442
+ * The mount every SASjs Server route sits under, normalised.
443
443
  *
444
- * One knob: deploy, code execution, triggers, sessions, auth and the
445
- * stored-program endpoint all hang off this, so they cannot end up on
446
- * different mounts.
444
+ * This is the read side of `pathSASJS`, and the only place the value is
445
+ * interpreted: one leading slash, no trailing one (`/api/` and ` api/ ` are
446
+ * both `/api`), a value carrying the stored-program endpoint
447
+ * (`/api/stp/execute`) is read as the mount it names, and absent or empty
448
+ * means `/SASjsApi`. A root mount is `/` - a proxy that puts the API at the
449
+ * origin - and a caller concatenating onto it contributes `''` for that
450
+ * case rather than the value verbatim, because `${serverUrl}/` + `/stp/...`
451
+ * is a doubled slash and a different URL to a proxy.
452
+ *
453
+ * A Viya or SAS 9 project has no such mount: neither server type reads
454
+ * `pathSASJS`, so this answers the default `/SASjsApi` for them.
455
+ *
456
+ * Public so a consumer that composes a URL by hand - `<mount>/stp/execute`
457
+ * for a `?_program=` link, or a route it builds for the drive and info
458
+ * endpoints - asks the adapter instead of re-implementing the normalisation
459
+ * or deep-importing the `apiBasePath` module. Note that
460
+ * `getSasjsConfig().pathSASJS` is not this value: it reads back as configured,
461
+ * or `/SASjsApi` when it was never set (the constructor's default), so a
462
+ * caller cannot tell a defaulted value from one configured as `/SASjsApi`
463
+ * there - this accessor is the answer to what the mount is.
447
464
  */
448
465
  getApiBasePath() {
449
466
  // Only a SASjs Server project has this mount; a Viya or SAS 9 project never
@@ -2982,6 +2982,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2982
2982
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2983
2983
  exports.SASViyaApiClient = void 0;
2984
2984
  const utils_1 = __webpack_require__(9266);
2985
+ const joinFolderPath_1 = __webpack_require__(459);
2985
2986
  const form_data_1 = __importDefault(__webpack_require__(1894));
2986
2987
  const errors_1 = __webpack_require__(7388);
2987
2988
  const SessionManager_1 = __webpack_require__(8697);
@@ -3039,9 +3040,7 @@ class SASViyaApiClient {
3039
3040
  */
3040
3041
  getJobsInFolder(folderPath) {
3041
3042
  return __awaiter(this, void 0, void 0, function* () {
3042
- const path = (0, utils_1.isRelativePath)(folderPath)
3043
- ? `${this.rootFolderName}/${folderPath}`
3044
- : folderPath;
3043
+ const path = this.folderMapKey(folderPath);
3045
3044
  if (this.folderMap.get(path)) {
3046
3045
  return this.folderMap.get(path);
3047
3046
  }
@@ -3243,8 +3242,11 @@ class SASViyaApiClient {
3243
3242
  */
3244
3243
  getFolder(folderPath, accessToken) {
3245
3244
  return __awaiter(this, void 0, void 0, function* () {
3245
+ // one of the three places a path becomes a request, so the same normalisation
3246
+ // applies here as in getFolderDetails - otherwise getFolder('//app') sends the
3247
+ // string this class now refuses to send anywhere else
3246
3248
  return yield this.requestClient
3247
- .get(`/folders/folders/@item?path=${folderPath}`, accessToken)
3249
+ .get(`/folders/folders/@item?path=${(0, joinFolderPath_1.normaliseFolderPath)(folderPath)}`, accessToken)
3248
3250
  .then((res) => res.result);
3249
3251
  });
3250
3252
  }
@@ -3373,10 +3375,10 @@ class SASViyaApiClient {
3373
3375
  parentFolderUri = `/folders/folders/${parentFolder.id}`;
3374
3376
  }
3375
3377
  else if (isForced) {
3376
- const folderPath = parentFolderPath + '/' + folderName;
3378
+ const folderPath = (0, joinFolderPath_1.joinFolderPath)(parentFolderPath, folderName);
3377
3379
  const folderUri = yield this.getFolderUri(folderPath, accessToken);
3378
3380
  if (folderUri) {
3379
- yield this.deleteFolder(parentFolderPath + '/' + folderName, accessToken);
3381
+ yield this.deleteFolder(folderPath, accessToken);
3380
3382
  }
3381
3383
  }
3382
3384
  }
@@ -3399,8 +3401,21 @@ class SASViyaApiClient {
3399
3401
  }
3400
3402
  throw err;
3401
3403
  });
3402
- // update folder map with newly created folder.
3403
- yield this.populateFolderMap(`${parentFolderPath}/${folderName}`, accessToken);
3404
+ // The POST answered with the folder it created, so there is nothing to look up:
3405
+ // a new folder has no members, and re-reading it by a path joined here by hand
3406
+ // is how the doubled slash in adapter#974 reached the server.
3407
+ //
3408
+ // An empty member list is only ever written for a folder that has just been
3409
+ // created, which is the one case where it is exact: a folder that already
3410
+ // existed refuses the POST (409) unless `isForced` deleted it first, and a
3411
+ // deleted folder takes its members with it. So this cannot drop members the
3412
+ // server still has.
3413
+ //
3414
+ // A caller may have given a URI instead of a path, in which case there is no
3415
+ // key to file it under - and the previous code filed it under "undefined/name".
3416
+ if (parentFolderPath) {
3417
+ this.folderMap.set(this.folderMapKey((0, joinFolderPath_1.joinFolderPath)(parentFolderPath, folderName)), []);
3418
+ }
3404
3419
  return createFolderResponse;
3405
3420
  });
3406
3421
  }
@@ -3541,7 +3556,7 @@ class SASViyaApiClient {
3541
3556
  yield this.populateFolderMap(fullFolderPath, access_token).catch((err) => {
3542
3557
  throw (0, error_1.prefixMessage)(err, 'Error while populating folder map. ');
3543
3558
  });
3544
- const jobFolder = this.folderMap.get(fullFolderPath);
3559
+ const jobFolder = this.folderMap.get(this.folderMapKey(fullFolderPath));
3545
3560
  if (!jobFolder) {
3546
3561
  throw new Error(`The folder '${fullFolderPath}' was not found on '${this.serverUrl}'`);
3547
3562
  }
@@ -3597,7 +3612,7 @@ class SASViyaApiClient {
3597
3612
  ? `${this.rootFolderName}/${folderPath}`
3598
3613
  : folderPath;
3599
3614
  yield this.populateFolderMap(fullFolderPath, access_token);
3600
- const jobFolder = this.folderMap.get(fullFolderPath);
3615
+ const jobFolder = this.folderMap.get(this.folderMapKey(fullFolderPath));
3601
3616
  if (!jobFolder) {
3602
3617
  throw new Error(`The folder '${fullFolderPath}' was not found on '${this.serverUrl}'.`);
3603
3618
  }
@@ -3671,11 +3686,21 @@ class SASViyaApiClient {
3671
3686
  return executionResult;
3672
3687
  });
3673
3688
  }
3689
+ /**
3690
+ * The key `folderMap` stores a folder's members under.
3691
+ *
3692
+ * Normalised, so a caller's '//app' and its own '/app' are one key: the map is
3693
+ * written by populateFolderMap and read by four other methods, and a path that
3694
+ * needs normalising must not miss its own entry.
3695
+ */
3696
+ folderMapKey(folderPath) {
3697
+ return (0, joinFolderPath_1.normaliseFolderPath)((0, utils_1.isRelativePath)(folderPath)
3698
+ ? `${this.rootFolderName}/${folderPath}`
3699
+ : folderPath);
3700
+ }
3674
3701
  populateFolderMap(folderPath, accessToken) {
3675
3702
  return __awaiter(this, void 0, void 0, function* () {
3676
- const path = (0, utils_1.isRelativePath)(folderPath)
3677
- ? `${this.rootFolderName}/${folderPath}`
3678
- : folderPath;
3703
+ const path = this.folderMapKey(folderPath);
3679
3704
  if (this.folderMap.get(path)) {
3680
3705
  return;
3681
3706
  }
@@ -3710,9 +3735,12 @@ class SASViyaApiClient {
3710
3735
  }
3711
3736
  getFolderDetails(folderPath, accessToken) {
3712
3737
  return __awaiter(this, void 0, void 0, function* () {
3713
- const url = (0, utils_1.isUri)(folderPath)
3714
- ? folderPath
3715
- : `/folders/folders/@item?path=${folderPath}`;
3738
+ // every caller reaches the server through here, so the collapse happens at the
3739
+ // point a path becomes a URL rather than at each place one is built
3740
+ const normalisedPath = (0, joinFolderPath_1.normaliseFolderPath)(folderPath);
3741
+ const url = (0, utils_1.isUri)(normalisedPath)
3742
+ ? normalisedPath
3743
+ : `/folders/folders/@item?path=${normalisedPath}`;
3716
3744
  const { result: folder } = yield this.requestClient
3717
3745
  .get(`${this.serverUrl}${url}`, accessToken)
3718
3746
  .catch((err) => {
@@ -4333,11 +4361,28 @@ class SASjs {
4333
4361
  });
4334
4362
  }
4335
4363
  /**
4336
- * The mount every SASjs Server route sits under, read from `pathSASJS`.
4364
+ * The mount every SASjs Server route sits under, normalised.
4365
+ *
4366
+ * This is the read side of `pathSASJS`, and the only place the value is
4367
+ * interpreted: one leading slash, no trailing one (`/api/` and ` api/ ` are
4368
+ * both `/api`), a value carrying the stored-program endpoint
4369
+ * (`/api/stp/execute`) is read as the mount it names, and absent or empty
4370
+ * means `/SASjsApi`. A root mount is `/` - a proxy that puts the API at the
4371
+ * origin - and a caller concatenating onto it contributes `''` for that
4372
+ * case rather than the value verbatim, because `${serverUrl}/` + `/stp/...`
4373
+ * is a doubled slash and a different URL to a proxy.
4337
4374
  *
4338
- * One knob: deploy, code execution, triggers, sessions, auth and the
4339
- * stored-program endpoint all hang off this, so they cannot end up on
4340
- * different mounts.
4375
+ * A Viya or SAS 9 project has no such mount: neither server type reads
4376
+ * `pathSASJS`, so this answers the default `/SASjsApi` for them.
4377
+ *
4378
+ * Public so a consumer that composes a URL by hand - `<mount>/stp/execute`
4379
+ * for a `?_program=` link, or a route it builds for the drive and info
4380
+ * endpoints - asks the adapter instead of re-implementing the normalisation
4381
+ * or deep-importing the `apiBasePath` module. Note that
4382
+ * `getSasjsConfig().pathSASJS` is not this value: it reads back as configured,
4383
+ * or `/SASjsApi` when it was never set (the constructor's default), so a
4384
+ * caller cannot tell a defaulted value from one configured as `/SASjsApi`
4385
+ * there - this accessor is the answer to what the mount is.
4341
4386
  */
4342
4387
  getApiBasePath() {
4343
4388
  // Only a SASjs Server project has this mount; a Viya or SAS 9 project never
@@ -10499,6 +10544,52 @@ const isUrl = (str) => {
10499
10544
  exports.isUrl = isUrl;
10500
10545
 
10501
10546
 
10547
+ /***/ },
10548
+
10549
+ /***/ 459
10550
+ (__unused_webpack_module, exports) {
10551
+
10552
+ "use strict";
10553
+ var __webpack_unused_export__;
10554
+
10555
+ __webpack_unused_export__ = ({ value: true });
10556
+ exports.joinFolderPath = exports.normaliseFolderPath = void 0;
10557
+ /**
10558
+ * Collapse repeated slashes in a folder path.
10559
+ *
10560
+ * A Viya folder path is a sequence of names separated by single slashes, so a run
10561
+ * of slashes is always a caller's join going wrong. Two ways of getting one:
10562
+ *
10563
+ * - joining a parent path with a name, when the parent is the root: `'/' + '/app'`
10564
+ * is `'//app'` (adapter#974)
10565
+ * - a caller passing a path it built itself, with a trailing slash or a doubled
10566
+ * one in the middle: `'/Users/me/' + 'app'`
10567
+ *
10568
+ * Some deployments do not collapse the doubled slash when it arrives in `?path=`,
10569
+ * and answer 404 for a folder that exists, so the path a request carries has to be
10570
+ * the path the server knows. This is applied where a path is turned into a request,
10571
+ * not only where one is joined, so the invariant holds for every caller.
10572
+ */
10573
+ const normaliseFolderPath = (folderPath) => {
10574
+ const collapsed = folderPath.replace(/\/{2,}/g, '/');
10575
+ // a single trailing slash is the other way a caller's join goes wrong, and it is
10576
+ // not a run of slashes: '/app/' names the same folder as '/app', and asking the
10577
+ // server about the first is a 404 on a deployment that does not tidy it up
10578
+ return collapsed.length > 1 && collapsed.endsWith('/')
10579
+ ? collapsed.slice(0, -1)
10580
+ : collapsed;
10581
+ };
10582
+ exports.normaliseFolderPath = normaliseFolderPath;
10583
+ /**
10584
+ * Join a parent folder path and a folder name into one path.
10585
+ *
10586
+ * The result is normalised, so a create at the root reads back the same path it
10587
+ * wrote - which is the failure adapter#974 describes.
10588
+ */
10589
+ const joinFolderPath = (parentFolderPath, folderName) => (0, exports.normaliseFolderPath)(`${parentFolderPath}/${folderName}`);
10590
+ exports.joinFolderPath = joinFolderPath;
10591
+
10592
+
10502
10593
  /***/ },
10503
10594
 
10504
10595
  /***/ 2986
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://adapter.sasjs.io",
5
5
  "scripts": {
6
6
  "nodeVersionMessage": "echo \u001b[33m make sure you are running node lts version \u001b[0m",
7
- "build": "npm run nodeVersionMessage && npx rimraf build node && npx tsc -p tsconfig.build.json && node createNodeEntry.js && node release/bundle-check.mjs --source-only && webpack && node release/bundle-check.mjs",
7
+ "build": "npm run nodeVersionMessage && npx rimraf build node && npx tsc -p tsconfig.build.json && node createNodeEntry.js && node scripts/bundle-check.mjs --source-only && webpack && node scripts/bundle-check.mjs",
8
8
  "package:lib": "npm run build && cp ./package.json ./README.md ./LICENSE ./DISCLOSURE build/ && cd build && npm pack",
9
9
  "publish:lib": "npm run package:lib && cd build && npm stage publish",
10
10
  "lint:fix": "npx prettier --log-level silent --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --log-level silent --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --log-level silent --write \"cypress/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
@@ -14,7 +14,9 @@
14
14
  "publishInit": "cp -r ./build/* . && rm -rf ./build",
15
15
  "typedoc": "node createTSDocs",
16
16
  "cypress": "cypress open",
17
- "cy:run": "cypress run"
17
+ "cy:run": "cypress run",
18
+ "release": "sasjs-release",
19
+ "prepublishOnly": "node -e \"const v=require('./package.json').version; if (/^0\\.0\\.0/.test(v)) { console.error('refusing to publish ' + v + ': the version is stamped from the tag when publishing'); process.exit(1) }\""
18
20
  },
19
21
  "publishConfig": {
20
22
  "access": "public"
@@ -22,19 +24,6 @@
22
24
  "contentPolicy": {
23
25
  "class": "dual-use"
24
26
  },
25
- "release": {
26
- "plugins": [
27
- "@semantic-release/commit-analyzer",
28
- "@semantic-release/release-notes-generator",
29
- [
30
- "@semantic-release/exec",
31
- {
32
- "prepareCmd": "npm version ${nextRelease.version} --no-git-tag-version --allow-same-version"
33
- }
34
- ],
35
- "@semantic-release/github"
36
- ]
37
- },
38
27
  "keywords": [
39
28
  "sas",
40
29
  "viya",
@@ -48,6 +37,7 @@
48
37
  "license": "ISC",
49
38
  "devDependencies": {
50
39
  "@cypress/webpack-preprocessor": "8.0.0",
40
+ "@sasjs/release": "0.3.2",
51
41
  "@types/cors": "2.8.19",
52
42
  "@types/express": "5.0.6",
53
43
  "@types/jest": "30.0.0",
@@ -101,7 +91,6 @@
101
91
  "!**/test/**",
102
92
  "!**/__mocks__/**",
103
93
  "!src/**",
104
- "!release/**",
105
94
  "!node_modules/**"
106
95
  ],
107
96
  "dependencies": {
@@ -131,7 +120,7 @@
131
120
  "safer-buffer": "npm:@socketregistry/safer-buffer@1.0.10",
132
121
  "side-channel": "npm:@socketregistry/side-channel@1.0.10"
133
122
  },
134
- "version": "6.0.2",
123
+ "version": "6.1.1",
135
124
  "engines": {
136
125
  "node": ">=22"
137
126
  },
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Collapse repeated slashes in a folder path.
3
+ *
4
+ * A Viya folder path is a sequence of names separated by single slashes, so a run
5
+ * of slashes is always a caller's join going wrong. Two ways of getting one:
6
+ *
7
+ * - joining a parent path with a name, when the parent is the root: `'/' + '/app'`
8
+ * is `'//app'` (adapter#974)
9
+ * - a caller passing a path it built itself, with a trailing slash or a doubled
10
+ * one in the middle: `'/Users/me/' + 'app'`
11
+ *
12
+ * Some deployments do not collapse the doubled slash when it arrives in `?path=`,
13
+ * and answer 404 for a folder that exists, so the path a request carries has to be
14
+ * the path the server knows. This is applied where a path is turned into a request,
15
+ * not only where one is joined, so the invariant holds for every caller.
16
+ */
17
+ export declare const normaliseFolderPath: (folderPath: string) => string;
18
+ /**
19
+ * Join a parent folder path and a folder name into one path.
20
+ *
21
+ * The result is normalised, so a create at the root reads back the same path it
22
+ * wrote - which is the failure adapter#974 describes.
23
+ */
24
+ export declare const joinFolderPath: (parentFolderPath: string, folderName: string) => string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.joinFolderPath = exports.normaliseFolderPath = void 0;
4
+ /**
5
+ * Collapse repeated slashes in a folder path.
6
+ *
7
+ * A Viya folder path is a sequence of names separated by single slashes, so a run
8
+ * of slashes is always a caller's join going wrong. Two ways of getting one:
9
+ *
10
+ * - joining a parent path with a name, when the parent is the root: `'/' + '/app'`
11
+ * is `'//app'` (adapter#974)
12
+ * - a caller passing a path it built itself, with a trailing slash or a doubled
13
+ * one in the middle: `'/Users/me/' + 'app'`
14
+ *
15
+ * Some deployments do not collapse the doubled slash when it arrives in `?path=`,
16
+ * and answer 404 for a folder that exists, so the path a request carries has to be
17
+ * the path the server knows. This is applied where a path is turned into a request,
18
+ * not only where one is joined, so the invariant holds for every caller.
19
+ */
20
+ const normaliseFolderPath = (folderPath) => {
21
+ const collapsed = folderPath.replace(/\/{2,}/g, '/');
22
+ // a single trailing slash is the other way a caller's join goes wrong, and it is
23
+ // not a run of slashes: '/app/' names the same folder as '/app', and asking the
24
+ // server about the first is a 404 on a deployment that does not tidy it up
25
+ return collapsed.length > 1 && collapsed.endsWith('/')
26
+ ? collapsed.slice(0, -1)
27
+ : collapsed;
28
+ };
29
+ exports.normaliseFolderPath = normaliseFolderPath;
30
+ /**
31
+ * Join a parent folder path and a folder name into one path.
32
+ *
33
+ * The result is normalised, so a create at the root reads back the same path it
34
+ * wrote - which is the failure adapter#974 describes.
35
+ */
36
+ const joinFolderPath = (parentFolderPath, folderName) => (0, exports.normaliseFolderPath)(`${parentFolderPath}/${folderName}`);
37
+ exports.joinFolderPath = joinFolderPath;