@sasjs/api 0.40.2 → 0.41.0

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/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.40.2 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.41.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
2
2
  "use strict";
3
3
  var SASjsApi = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -41,6 +41,7 @@ var SASjsApi = (() => {
41
41
  DEFAULT_IDENTITY: () => DEFAULT_IDENTITY,
42
42
  DEFAULT_LOG_LINES: () => DEFAULT_LOG_LINES,
43
43
  DEFAULT_SESSIONS: () => DEFAULT_SESSIONS,
44
+ DEPLOYMENT_FILE_ERROR: () => DEPLOYMENT_FILE_ERROR,
44
45
  DEPLOY_CORPUS: () => DEPLOY_CORPUS,
45
46
  DEPLOY_LIMITS: () => DEPLOY_LIMITS,
46
47
  DEPLOY_PAYLOAD_BYTES: () => DEPLOY_PAYLOAD_BYTES,
@@ -64,6 +65,7 @@ var SASjsApi = (() => {
64
65
  MemorySessionRunner: () => MemorySessionRunner,
65
66
  NO_SUCH_APP: () => NO_SUCH_APP,
66
67
  NO_WEB_BUILD: () => NO_WEB_BUILD,
68
+ ONE_NAME_ONLY: () => ONE_NAME_ONLY,
67
69
  OVERLAY: () => OVERLAY,
68
70
  PROVIDER_MANAGED: () => PROVIDER_MANAGED,
69
71
  RECORD_CORPUS: () => RECORD_CORPUS,
@@ -84,6 +86,7 @@ var SASjsApi = (() => {
84
86
  VIYA_TARGET_VERSION: () => VIYA_TARGET_VERSION,
85
87
  appRootOf: () => appRootOf,
86
88
  appSummary: () => appSummary,
89
+ assertOneFileName: () => assertOneFileName,
87
90
  basename: () => basename,
88
91
  cacheControlFor: () => cacheControlFor,
89
92
  checkDeployTree: () => checkDeployTree,
@@ -94,6 +97,7 @@ var SASjsApi = (() => {
94
97
  createAppStreamService: () => createAppStreamService,
95
98
  createAppStreamWebService: () => createAppStreamWebService,
96
99
  createAuthConfigService: () => createAuthConfigService,
100
+ createDeploymentFileService: () => createDeploymentFileService,
97
101
  createDirectoryService: () => createDirectoryService,
98
102
  createDriveAppStreamStore: () => createDriveAppStreamStore,
99
103
  createDriveService: () => createDriveService,
@@ -515,142 +519,622 @@ var SASjsApi = (() => {
515
519
  };
516
520
  };
517
521
 
518
- // src/drive/memory-store.ts
519
- var MemoryDriveStore = class {
520
- constructor(seed = {}) {
521
- this.files = /* @__PURE__ */ new Map();
522
- this.folders = /* @__PURE__ */ new Set(["/"]);
523
- /**
524
- * When each entry was first written and last written, ISO strings.
525
- *
526
- * A Map has no clock of its own, so the store keeps one: a seeded drive is
527
- * created when the store is, and a write moves `modified` while `created`
528
- * stays. A host with real file metadata reports its own instead.
529
- */
530
- this.times = /* @__PURE__ */ new Map();
531
- for (const [path, contents] of Object.entries(seed)) {
532
- this.putSync(path, contents);
533
- }
534
- }
535
- /** Everything on the drive, for a snapshot or an assertion. */
536
- dump() {
537
- const out = {};
538
- for (const [path, contents] of this.files) out[path] = contents;
539
- return out;
540
- }
541
- putSync(path, contents) {
542
- this.mkdirpSync(dirname(path));
543
- this.files.set(
544
- path,
545
- typeof contents === "string" ? contents : contents.slice()
522
+ // src/appstream/identity.ts
523
+ var normaliseAppLoc = (appLoc) => {
524
+ if (typeof appLoc !== "string" || appLoc === "")
525
+ throw new Error(
526
+ `App location must be a non-empty string, got ${JSON.stringify(appLoc)}.`
546
527
  );
547
- const now = (/* @__PURE__ */ new Date()).toISOString();
548
- const existing = this.times.get(path);
549
- this.times.set(path, {
550
- created: existing?.created ?? now,
551
- modified: now
552
- });
553
- }
554
- mkdirpSync(path) {
555
- const parts = path.split("/").filter(Boolean);
556
- let acc = "";
557
- for (const part of parts) {
558
- acc += "/" + part;
559
- this.folders.add(acc);
560
- }
561
- }
562
- children(path) {
563
- const prefix = path === "/" ? "/" : path + "/";
564
- const files = [];
565
- const folders = [];
566
- for (const candidate of this.files.keys()) {
567
- if (!candidate.startsWith(prefix)) continue;
568
- const rest = candidate.slice(prefix.length);
569
- if (rest && !rest.includes("/")) files.push(rest);
570
- }
571
- for (const candidate of this.folders) {
572
- if (!candidate.startsWith(prefix)) continue;
573
- const rest = candidate.slice(prefix.length);
574
- if (rest && !rest.includes("/")) folders.push(rest);
575
- }
576
- return { files: files.sort(), folders: folders.sort() };
577
- }
578
- async read(path) {
579
- const contents = this.files.get(path);
580
- if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
581
- return contents;
582
- }
583
- async write(path, contents) {
584
- this.putSync(path, contents);
528
+ const normalised = normaliseDrivePath(appLoc);
529
+ if (normalised === null)
530
+ throw new ApiError(400, "appLoc cannot be outside drive.");
531
+ return normalised;
532
+ };
533
+ var newAppId = () => {
534
+ const webCrypto = globalThis.crypto;
535
+ if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
536
+ if (typeof webCrypto?.getRandomValues !== "function")
537
+ throw new Error("No cryptographic source of randomness is available.");
538
+ const bytes3 = new Uint8Array(16);
539
+ webCrypto.getRandomValues(bytes3);
540
+ bytes3[6] = bytes3[6] & 15 | 64;
541
+ bytes3[8] = bytes3[8] & 63 | 128;
542
+ const hex = Array.from(bytes3).map((byte) => byte.toString(16).padStart(2, "0")).join("");
543
+ return [
544
+ hex.slice(0, 8),
545
+ hex.slice(8, 12),
546
+ hex.slice(12, 16),
547
+ hex.slice(16, 20),
548
+ hex.slice(20)
549
+ ].join("-");
550
+ };
551
+ var APP_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
552
+ var isAppId = (value) => typeof value === "string" && APP_ID.test(value);
553
+
554
+ // src/appstream/service.ts
555
+ var APP_FOLDERS_ROOT = "apps";
556
+ var frontendFolderOf = (name) => `/${APP_FOLDERS_ROOT}/${name}`;
557
+ var appSummary = (entry) => ({
558
+ id: entry.id,
559
+ name: entry.name,
560
+ url: `/app/${entry.id}/`
561
+ });
562
+ var webFolderOf = (value) => {
563
+ if (typeof value !== "string" || value === "")
564
+ throw new ApiError(400, '"streamWebFolder" is required');
565
+ if (value === "." || value === ".." || /[\\/]/.test(value))
566
+ throw new ApiError(400, "streamWebFolder must be a single path segment.");
567
+ return value;
568
+ };
569
+ var defaultAppName = (appLoc) => {
570
+ const segment = appLoc.split("/").filter(Boolean).pop();
571
+ return segment ? segment : "app";
572
+ };
573
+ var sameAppLoc = (left, right) => {
574
+ try {
575
+ return normaliseAppLoc(left) === normaliseAppLoc(right);
576
+ } catch (_) {
577
+ return false;
585
578
  }
586
- async exists(path) {
587
- return this.files.has(path) || this.folders.has(path);
579
+ };
580
+ var appLocOf = (value) => {
581
+ try {
582
+ return normaliseAppLoc(value);
583
+ } catch (error) {
584
+ throw new ApiError(400, error.message);
588
585
  }
589
- async stat(path) {
590
- if (this.folders.has(path) && !this.files.has(path))
591
- return { directory: true, size: 0 };
592
- const contents = this.files.get(path);
593
- if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
594
- const times = this.times.get(path);
586
+ };
587
+ var hasStreamFolder = (tree, streamWebFolder) => {
588
+ const members = tree?.members;
589
+ if (!Array.isArray(members)) return false;
590
+ const isFolder = (member, name) => {
591
+ const entry = member;
592
+ return entry?.type === "folder" && entry?.name === name;
593
+ };
594
+ const services = members.find((member) => isFolder(member, "services"));
595
+ const children = services?.members;
596
+ return Array.isArray(children) && children.some((member) => isFolder(member, streamWebFolder));
597
+ };
598
+ var hasFrontendRoot = (tree) => {
599
+ const members = tree?.members;
600
+ if (!Array.isArray(members)) return false;
601
+ return members.some((member) => {
602
+ const entry = member;
603
+ return entry?.type === "file" && entry?.name === "index.html";
604
+ });
605
+ };
606
+ var checkPublishRequest = (request, tree, options = {}) => {
607
+ const logo = logoOf(request.logo);
608
+ const frameAncestors = frameAncestorsOf(request.frameAncestors);
609
+ const timing = request.publishedAt === void 0 ? {} : { publishedAt: request.publishedAt };
610
+ if (request.streamWebFolder !== void 0) {
611
+ if (request.appLoc === void 0)
612
+ throw new ApiError(
613
+ 400,
614
+ '"appLoc" is required when "streamWebFolder" is stated: the entry keeps its web assets at <appLoc>/services/<streamWebFolder>, so both halves are needed to say where they are.'
615
+ );
616
+ const appLoc2 = appLocOf(request.appLoc);
617
+ if (appLoc2 === "/")
618
+ throw new ApiError(400, "An app cannot be published at the drive root.");
619
+ const streamWebFolder = webFolderOf(request.streamWebFolder);
620
+ if (tree !== void 0 && !hasStreamFolder(tree, streamWebFolder))
621
+ throw new ApiError(
622
+ 400,
623
+ `The deployed tree has no "services/${streamWebFolder}" folder, so nothing would be published at ${appLoc2}. Deploy the web assets under services/${streamWebFolder}, or ${options.folderFromManifest ? "correct the folder sasjs.app.json names." : "omit streamWebFolder."}`
624
+ );
595
625
  return {
596
- directory: false,
597
- size: typeof contents === "string" ? contents.length : contents.length,
598
- ...times ? { modified: times.modified, created: times.created } : {}
626
+ appLoc: appLoc2,
627
+ streamWebFolder,
628
+ ...request.name === void 0 ? {} : { name: nameOf(request.name) },
629
+ ...logo === void 0 ? {} : { logo },
630
+ ...frameAncestors === void 0 ? {} : { frameAncestors },
631
+ ...timing
599
632
  };
600
633
  }
601
- async list(path) {
602
- return this.children(path);
603
- }
604
- async mkdirp(path) {
605
- this.mkdirpSync(path);
606
- }
607
- async remove(path) {
608
- if (this.files.delete(path)) return;
609
- const prefix = path === "/" ? "/" : path + "/";
610
- for (const candidate of [...this.files.keys()]) {
611
- if (candidate.startsWith(prefix)) this.files.delete(candidate);
612
- }
613
- for (const candidate of [...this.folders]) {
614
- if (candidate === path || candidate.startsWith(prefix))
615
- this.folders.delete(candidate);
616
- }
617
- }
618
- async move(from, to) {
619
- const contents = this.files.get(from);
620
- if (contents !== void 0) {
621
- const copy = typeof contents === "string" ? contents : contents.slice();
622
- this.files.delete(from);
623
- this.mkdirpSync(dirname(to));
624
- this.files.set(to, copy);
625
- return;
626
- }
627
- const prefix = from + "/";
628
- const moves = [];
629
- for (const [candidate, value] of this.files) {
630
- if (candidate.startsWith(prefix))
631
- moves.push([candidate, to + candidate.slice(from.length), value]);
632
- }
633
- for (const [source] of moves) this.files.delete(source);
634
- for (const [, destination, value] of moves) {
635
- this.mkdirpSync(dirname(destination));
636
- this.files.set(destination, value);
637
- }
638
- for (const candidate of [...this.folders]) {
639
- if (candidate === from || candidate.startsWith(prefix)) {
640
- this.folders.delete(candidate);
641
- this.folders.add(to + candidate.slice(from.length));
642
- }
643
- }
644
- this.mkdirpSync(to);
645
- }
634
+ if (request.name === void 0)
635
+ throw new ApiError(
636
+ 400,
637
+ '"name" is required: an app is published at apps/<name>, so the publish has to say what it is called.'
638
+ );
639
+ const name = nameOf(request.name);
640
+ const appLoc = request.appLoc === void 0 ? void 0 : appLocOf(request.appLoc);
641
+ if (appLoc === "/")
642
+ throw new ApiError(400, "An app cannot name the drive root as its backend.");
643
+ if (tree !== void 0 && !hasFrontendRoot(tree))
644
+ throw new ApiError(
645
+ 400,
646
+ `The deployed tree has no "index.html" at its root, so nothing would be published at apps/${name}. Publish the compiled web folder itself, not the folder that holds it.`
647
+ );
648
+ return {
649
+ name,
650
+ ...appLoc === void 0 ? {} : { appLoc },
651
+ ...logo === void 0 ? {} : { logo },
652
+ ...frameAncestors === void 0 ? {} : { frameAncestors },
653
+ ...timing
654
+ };
646
655
  };
647
-
648
- // src/routes/generated.ts
649
- var GENERATED_ROUTES = [
650
- {
651
- id: "GET /",
652
- method: "GET",
653
- path: "/",
656
+ var nameOf = (value) => {
657
+ if (typeof value !== "string" || value.trim() === "")
658
+ throw new ApiError(400, '"name" must be a non-empty string');
659
+ return urlSafeName(value.trim());
660
+ };
661
+ var NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._~-]*$/;
662
+ var NAME_MAX_LENGTH = 64;
663
+ var RESERVED_NAMES = ["apps.json", "index.html"];
664
+ var urlSafeName = (name) => {
665
+ if (name.length > NAME_MAX_LENGTH)
666
+ throw new ApiError(
667
+ 400,
668
+ `"name" must be at most ${NAME_MAX_LENGTH} characters, and "${name}" is ${name.length}.`
669
+ );
670
+ if (!NAME_PATTERN.test(name))
671
+ throw new ApiError(
672
+ 400,
673
+ `"name" must be usable as a URL segment - letters, digits, dot, dash, underscore or tilde, starting with a letter or digit - so "/app/${name}" can be opened. "${name}" is not, because it carries a character that has to be percent-encoded, or a space.`
674
+ );
675
+ if (RESERVED_NAMES.includes(name.toLowerCase()))
676
+ throw new ApiError(
677
+ 400,
678
+ `"name" cannot be "${name}": the App Stream answers /app/${name} itself, so an app with that name could never be opened by name.`
679
+ );
680
+ return name;
681
+ };
682
+ var logoOf = (value) => {
683
+ if (value === void 0) return void 0;
684
+ if (typeof value !== "string" || value === "")
685
+ throw new ApiError(400, '"logo" must be a non-empty string');
686
+ return value;
687
+ };
688
+ var frameAncestorsOf = (value) => {
689
+ if (value === void 0) return void 0;
690
+ const list = Array.isArray(value) ? value : [value];
691
+ if (list.length === 0 || list.some((source) => typeof source !== "string" || source === ""))
692
+ throw new ApiError(
693
+ 400,
694
+ '"frameAncestors" must be a string or a non-empty list of strings'
695
+ );
696
+ return [...list];
697
+ };
698
+ var createAppStreamService = (store) => {
699
+ let queue = Promise.resolve();
700
+ const mutate = (work) => {
701
+ const run = queue.then(work, work);
702
+ queue = run.catch(() => void 0);
703
+ return run;
704
+ };
705
+ const readable = (allow) => store.read().then(
706
+ (entries) => entries.filter((entry) => allow ? allow(entry) : true).map((entry) => ({ ...entry })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
707
+ );
708
+ return {
709
+ list: readable,
710
+ async get(id) {
711
+ const entry = (await store.read()).find(
712
+ (candidate) => candidate.id === id
713
+ );
714
+ if (!entry) throw new ApiError(404, "No app is published with that id.");
715
+ return { ...entry };
716
+ },
717
+ async forAppLoc(appLoc) {
718
+ let normalised;
719
+ try {
720
+ normalised = normaliseAppLoc(appLoc);
721
+ } catch (_) {
722
+ return void 0;
723
+ }
724
+ const entry = (await store.read()).find(
725
+ (candidate) => candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, normalised)
726
+ );
727
+ return entry ? { ...entry } : void 0;
728
+ },
729
+ publish(request) {
730
+ return mutate(async () => {
731
+ const checked = checkPublishRequest(request);
732
+ const entries = await store.read();
733
+ const legacy = checked.streamWebFolder !== void 0;
734
+ const sameTarget = (candidate) => legacy ? candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, checked.appLoc) : candidate.streamWebFolder === void 0 && candidate.name === checked.name;
735
+ const existing = entries.find(sameTarget);
736
+ const logo = checked.logo;
737
+ const frameAncestors = checked.frameAncestors;
738
+ const name = legacy ? checked.name ?? existing?.name ?? defaultAppName(checked.appLoc) : checked.name;
739
+ if (!legacy || checked.name !== void 0) {
740
+ const clash = entries.find(
741
+ (candidate) => candidate !== existing && candidate.name.toLowerCase() === name.toLowerCase()
742
+ );
743
+ if (clash)
744
+ throw new ApiError(
745
+ 409,
746
+ `The name "${name}" is already the address of the app at ${clash.appLoc ?? frontendFolderOf(clash.name)}. An app's name is how it opens (/app/${name}), and two apps holding one name would answer an ambiguous lookup with nothing, so publish this one under a different name.`
747
+ );
748
+ }
749
+ const entry = {
750
+ id: existing ? existing.id : newAppId(),
751
+ // the label is the one field a redeploy inherits: everything else is
752
+ // what this publish states
753
+ name,
754
+ ...checked.appLoc === void 0 ? {} : { appLoc: checked.appLoc },
755
+ ...checked.streamWebFolder === void 0 ? {} : { streamWebFolder: checked.streamWebFolder },
756
+ ...logo === void 0 ? {} : { logo },
757
+ ...frameAncestors === void 0 ? {} : { frameAncestors },
758
+ publishedAt: checked.publishedAt ?? (/* @__PURE__ */ new Date()).toISOString()
759
+ };
760
+ await store.write([
761
+ ...entries.filter((candidate) => !sameTarget(candidate)),
762
+ entry
763
+ ]);
764
+ return { ...entry };
765
+ });
766
+ },
767
+ unpublish(id) {
768
+ return mutate(async () => {
769
+ const entries = await store.read();
770
+ const index = entries.findIndex((entry) => entry.id === id);
771
+ if (index === -1)
772
+ throw new ApiError(404, "No app is published with that id.");
773
+ const [removed] = entries.splice(index, 1);
774
+ await store.write(entries);
775
+ return { ...removed };
776
+ });
777
+ }
778
+ };
779
+ };
780
+ var MemoryAppStreamStore = class {
781
+ constructor(entries = []) {
782
+ this.entries = entries.map((entry) => ({ ...entry }));
783
+ }
784
+ async read() {
785
+ return this.entries.map((entry) => ({ ...entry }));
786
+ }
787
+ async write(entries) {
788
+ this.entries = entries.map((entry) => ({ ...entry }));
789
+ }
790
+ };
791
+
792
+ // src/appstream/web.ts
793
+ var DEFAULT_APP_PATH = "/app";
794
+ var NO_SUCH_APP = "There's no App Stream available here.";
795
+ var ESCAPES = {
796
+ "&": "&amp;",
797
+ "<": "&lt;",
798
+ ">": "&gt;",
799
+ '"': "&quot;",
800
+ "'": "&#39;"
801
+ };
802
+ var escapeHtml = (value) => value.replace(/[&<>"']/g, (character) => ESCAPES[character]);
803
+ var CONTENT_TYPES = {
804
+ html: "text/html; charset=utf-8",
805
+ htm: "text/html; charset=utf-8",
806
+ js: "text/javascript; charset=utf-8",
807
+ mjs: "text/javascript; charset=utf-8",
808
+ css: "text/css; charset=utf-8",
809
+ json: "application/json; charset=utf-8",
810
+ map: "application/json; charset=utf-8",
811
+ txt: "text/plain; charset=utf-8",
812
+ svg: "image/svg+xml",
813
+ png: "image/png",
814
+ jpg: "image/jpeg",
815
+ jpeg: "image/jpeg",
816
+ gif: "image/gif",
817
+ webp: "image/webp",
818
+ ico: "image/x-icon",
819
+ woff: "font/woff",
820
+ woff2: "font/woff2",
821
+ ttf: "font/ttf",
822
+ otf: "font/otf",
823
+ wasm: "application/wasm",
824
+ pdf: "application/pdf",
825
+ zip: "application/zip"
826
+ };
827
+ var contentTypeFor = (filePath2) => {
828
+ const extension = filePath2.slice(filePath2.lastIndexOf(".") + 1).toLowerCase();
829
+ return CONTENT_TYPES[extension] ?? "application/octet-stream";
830
+ };
831
+ var cacheControlFor = (filePath2) => /\.[0-9a-f]{8,}\.[A-Za-z0-9]+$/.test(filePath2) ? "public, max-age=31536000, immutable" : "public, max-age=0, must-revalidate";
832
+ var html = (status, markup) => ({
833
+ status,
834
+ body: markup,
835
+ contentType: "text/html; charset=utf-8"
836
+ });
837
+ var json = (status, body) => ({
838
+ status,
839
+ body: JSON.stringify(body),
840
+ contentType: "application/json; charset=utf-8"
841
+ });
842
+ var noSuchApp = () => html(404, `<!doctype html><html><body>${NO_SUCH_APP}</body></html>`);
843
+ var methodNotAllowed = (allowed) => ({
844
+ status: 405,
845
+ body: JSON.stringify({ status: "failure", message: `${allowed} only.` }),
846
+ contentType: "application/json; charset=utf-8",
847
+ headers: { allow: allowed }
848
+ });
849
+ var decoded = (segment) => {
850
+ try {
851
+ return decodeURIComponent(segment);
852
+ } catch (_) {
853
+ return void 0;
854
+ }
855
+ };
856
+ var appRootOf = (entry) => entry.streamWebFolder !== void 0 && entry.appLoc !== void 0 ? `${entry.appLoc}/services/${entry.streamWebFolder}` : frontendFolderOf(entry.name);
857
+ var createAppStreamWebService = (appStream, drive, options = {}) => {
858
+ const base = (options.basePath ?? DEFAULT_APP_PATH).replace(/\/+$/, "");
859
+ const title = options.title ?? "SASjs App Stream";
860
+ const urlOf = (entry) => `${base}/${entry.id}/`;
861
+ const rowOf = (entry) => ({
862
+ id: entry.id,
863
+ name: entry.name,
864
+ appLoc: entry.appLoc ?? null,
865
+ logo: entry.logo === void 0 ? null : `${urlOf(entry)}${entry.logo}`,
866
+ url: urlOf(entry),
867
+ publishedAt: entry.publishedAt ?? null
868
+ });
869
+ const apps = async (allow) => {
870
+ const entries = await appStream.list(allow);
871
+ return { apps: entries.map(rowOf) };
872
+ };
873
+ const landing = async (allow) => {
874
+ const { apps: rows } = await apps(allow);
875
+ const tiles = rows.length ? `<ul class="apps">${rows.map(
876
+ (row) => `<li><a href="${escapeHtml(row.url)}">${escapeHtml(row.name)}</a><span class="loc">${escapeHtml(
877
+ row.appLoc ?? frontendFolderOf(row.name)
878
+ )}</span></li>`
879
+ ).join("")}</ul>` : '<p class="empty">No apps have been published yet.</p>';
880
+ return html(
881
+ 200,
882
+ [
883
+ '<!doctype html><html lang="en"><head><meta charset="utf-8">',
884
+ '<meta name="viewport" content="width=device-width,initial-scale=1">',
885
+ `<title>${escapeHtml(title)}</title>`,
886
+ "<style>",
887
+ "body{font-family:system-ui,sans-serif;margin:2rem;color:#1f2430}",
888
+ "h1{font-size:1.4rem}",
889
+ "ul.apps{list-style:none;padding:0;display:grid;gap:.75rem;max-width:40rem}",
890
+ "ul.apps li{display:flex;flex-direction:column;gap:.15rem;padding:.75rem 1rem;",
891
+ "border:1px solid #d8dee9;border-radius:.5rem}",
892
+ "ul.apps a{font-weight:600;text-decoration:none;color:#0b5cad}",
893
+ ".loc{font-size:.8rem;color:#5b6472;font-family:ui-monospace,monospace}",
894
+ ".empty{color:#5b6472}",
895
+ "</style></head><body>",
896
+ `<h1>${escapeHtml(title)}</h1>`,
897
+ tiles,
898
+ "</body></html>"
899
+ ].join("")
900
+ );
901
+ };
902
+ const resolve = async (segment, allow) => {
903
+ const entries = await appStream.list(allow);
904
+ const byId2 = entries.find((entry) => entry.id === segment);
905
+ if (byId2) return byId2;
906
+ const byName = entries.filter((entry) => entry.name === segment);
907
+ return byName.length === 1 ? byName[0] : void 0;
908
+ };
909
+ const asset = async (entry, segments) => {
910
+ const parts = segments.map(decoded);
911
+ if (parts.some((part) => part === void 0)) return noSuchApp();
912
+ const relative = parts.join("/") || "index.html";
913
+ try {
914
+ const file = await drive.read(`${appRootOf(entry)}/${relative}`);
915
+ return {
916
+ status: 200,
917
+ body: file.contents,
918
+ contentType: contentTypeFor(relative),
919
+ headers: { "cache-control": cacheControlFor(relative) }
920
+ };
921
+ } catch (error) {
922
+ if (error instanceof ApiError && (error.status === 404 || error.status === 400))
923
+ return noSuchApp();
924
+ throw error;
925
+ }
926
+ };
927
+ return {
928
+ apps,
929
+ landing,
930
+ async request({ method, path, allow }) {
931
+ const clean = (path.split(/[?#]/)[0] || "/").replace(/\/{2,}/g, "/");
932
+ const relative = base === "" ? clean : clean === base ? "/" : clean.startsWith(`${base}/`) ? clean.slice(base.length) : null;
933
+ if (relative === null) return noSuchApp();
934
+ if (relative === "" || relative === "/" || relative === "/index.html") {
935
+ if (method !== "GET") return methodNotAllowed("GET");
936
+ return landing(allow);
937
+ }
938
+ if (relative === "/apps.json") {
939
+ if (method !== "GET") return methodNotAllowed("GET");
940
+ return json(200, await apps(allow));
941
+ }
942
+ const segments = relative.split("/").filter(Boolean);
943
+ const key = decoded(segments[0]);
944
+ if (key === void 0) return noSuchApp();
945
+ if (method === "DELETE") {
946
+ const entry2 = await resolve(key, allow);
947
+ if (!entry2) return noSuchApp();
948
+ const removed = await appStream.unpublish(entry2.id);
949
+ return json(200, { status: "success", app: rowOf(removed) });
950
+ }
951
+ if (method !== "GET") return methodNotAllowed("GET, DELETE");
952
+ const entry = await resolve(key, allow);
953
+ if (!entry) return noSuchApp();
954
+ if (segments.length === 1 && !relative.endsWith("/"))
955
+ return { status: 301, location: urlOf(entry) };
956
+ return asset(entry, segments.slice(1));
957
+ }
958
+ };
959
+ };
960
+
961
+ // src/drive/deploymentFile.ts
962
+ var DEPLOYMENT_FILE_ERROR = "Parameter Error\nFile error";
963
+ var ONE_NAME_ONLY = 'Exactly one of "_filePath" and "_FILE" may be given.';
964
+ var assertOneFileName = (query) => {
965
+ if (query._filePath !== void 0 && query._FILE !== void 0)
966
+ throw new ApiError(400, ONE_NAME_ONLY);
967
+ };
968
+ var notFound = (error) => isApiError(error) && error.status === 404 || // a structural read, not `NodeJS.ErrnoException`: this module is in the
969
+ // browser build, which has no node types at all
970
+ error?.code === "ENOENT";
971
+ var notThere = () => ({
972
+ status: 202,
973
+ contentType: "text/plain; charset=utf-8",
974
+ body: DEPLOYMENT_FILE_ERROR
975
+ });
976
+ var createDeploymentFileService = (store) => ({
977
+ async read(input) {
978
+ const checked = checkFilePath(input);
979
+ if ("reason" in checked)
980
+ throw checked.reason === "extension" ? new ApiError(400, "Invalid file extension") : new ApiError(400, `Can't get file outside drive.`);
981
+ if (isRoot(checked.path))
982
+ throw new ApiError(400, `Can't get file outside drive.`);
983
+ const path = checked.path;
984
+ try {
985
+ if ((await store.stat(path)).directory) return notThere();
986
+ return {
987
+ status: 200,
988
+ contentType: contentTypeFor(path),
989
+ // lower case, matching the app stream's own answer (src/appstream/web.ts):
990
+ // the names are case-insensitive in HTTP but not in a plain object, and a
991
+ // host copying one into the other would lose a policy that mattered
992
+ headers: { "cache-control": cacheControlFor(path) },
993
+ body: await store.read(path)
994
+ };
995
+ } catch (error) {
996
+ if (notFound(error)) return notThere();
997
+ throw error;
998
+ }
999
+ }
1000
+ });
1001
+
1002
+ // src/drive/memory-store.ts
1003
+ var MemoryDriveStore = class {
1004
+ constructor(seed = {}) {
1005
+ this.files = /* @__PURE__ */ new Map();
1006
+ this.folders = /* @__PURE__ */ new Set(["/"]);
1007
+ /**
1008
+ * When each entry was first written and last written, ISO strings.
1009
+ *
1010
+ * A Map has no clock of its own, so the store keeps one: a seeded drive is
1011
+ * created when the store is, and a write moves `modified` while `created`
1012
+ * stays. A host with real file metadata reports its own instead.
1013
+ */
1014
+ this.times = /* @__PURE__ */ new Map();
1015
+ for (const [path, contents] of Object.entries(seed)) {
1016
+ this.putSync(path, contents);
1017
+ }
1018
+ }
1019
+ /** Everything on the drive, for a snapshot or an assertion. */
1020
+ dump() {
1021
+ const out = {};
1022
+ for (const [path, contents] of this.files) out[path] = contents;
1023
+ return out;
1024
+ }
1025
+ putSync(path, contents) {
1026
+ this.mkdirpSync(dirname(path));
1027
+ this.files.set(
1028
+ path,
1029
+ typeof contents === "string" ? contents : contents.slice()
1030
+ );
1031
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1032
+ const existing = this.times.get(path);
1033
+ this.times.set(path, {
1034
+ created: existing?.created ?? now,
1035
+ modified: now
1036
+ });
1037
+ }
1038
+ mkdirpSync(path) {
1039
+ const parts = path.split("/").filter(Boolean);
1040
+ let acc = "";
1041
+ for (const part of parts) {
1042
+ acc += "/" + part;
1043
+ this.folders.add(acc);
1044
+ }
1045
+ }
1046
+ children(path) {
1047
+ const prefix = path === "/" ? "/" : path + "/";
1048
+ const files = [];
1049
+ const folders = [];
1050
+ for (const candidate of this.files.keys()) {
1051
+ if (!candidate.startsWith(prefix)) continue;
1052
+ const rest = candidate.slice(prefix.length);
1053
+ if (rest && !rest.includes("/")) files.push(rest);
1054
+ }
1055
+ for (const candidate of this.folders) {
1056
+ if (!candidate.startsWith(prefix)) continue;
1057
+ const rest = candidate.slice(prefix.length);
1058
+ if (rest && !rest.includes("/")) folders.push(rest);
1059
+ }
1060
+ return { files: files.sort(), folders: folders.sort() };
1061
+ }
1062
+ async read(path) {
1063
+ const contents = this.files.get(path);
1064
+ if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
1065
+ return contents;
1066
+ }
1067
+ async write(path, contents) {
1068
+ this.putSync(path, contents);
1069
+ }
1070
+ async exists(path) {
1071
+ return this.files.has(path) || this.folders.has(path);
1072
+ }
1073
+ async stat(path) {
1074
+ if (this.folders.has(path) && !this.files.has(path))
1075
+ return { directory: true, size: 0 };
1076
+ const contents = this.files.get(path);
1077
+ if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
1078
+ const times = this.times.get(path);
1079
+ return {
1080
+ directory: false,
1081
+ size: typeof contents === "string" ? contents.length : contents.length,
1082
+ ...times ? { modified: times.modified, created: times.created } : {}
1083
+ };
1084
+ }
1085
+ async list(path) {
1086
+ return this.children(path);
1087
+ }
1088
+ async mkdirp(path) {
1089
+ this.mkdirpSync(path);
1090
+ }
1091
+ async remove(path) {
1092
+ if (this.files.delete(path)) return;
1093
+ const prefix = path === "/" ? "/" : path + "/";
1094
+ for (const candidate of [...this.files.keys()]) {
1095
+ if (candidate.startsWith(prefix)) this.files.delete(candidate);
1096
+ }
1097
+ for (const candidate of [...this.folders]) {
1098
+ if (candidate === path || candidate.startsWith(prefix))
1099
+ this.folders.delete(candidate);
1100
+ }
1101
+ }
1102
+ async move(from, to) {
1103
+ const contents = this.files.get(from);
1104
+ if (contents !== void 0) {
1105
+ const copy = typeof contents === "string" ? contents : contents.slice();
1106
+ this.files.delete(from);
1107
+ this.mkdirpSync(dirname(to));
1108
+ this.files.set(to, copy);
1109
+ return;
1110
+ }
1111
+ const prefix = from + "/";
1112
+ const moves = [];
1113
+ for (const [candidate, value] of this.files) {
1114
+ if (candidate.startsWith(prefix))
1115
+ moves.push([candidate, to + candidate.slice(from.length), value]);
1116
+ }
1117
+ for (const [source] of moves) this.files.delete(source);
1118
+ for (const [, destination, value] of moves) {
1119
+ this.mkdirpSync(dirname(destination));
1120
+ this.files.set(destination, value);
1121
+ }
1122
+ for (const candidate of [...this.folders]) {
1123
+ if (candidate === from || candidate.startsWith(prefix)) {
1124
+ this.folders.delete(candidate);
1125
+ this.folders.add(to + candidate.slice(from.length));
1126
+ }
1127
+ }
1128
+ this.mkdirpSync(to);
1129
+ }
1130
+ };
1131
+
1132
+ // src/routes/generated.ts
1133
+ var GENERATED_ROUTES = [
1134
+ {
1135
+ id: "GET /",
1136
+ method: "GET",
1137
+ path: "/",
654
1138
  tag: "Web",
655
1139
  summary: "Serve the web interface",
656
1140
  params: [],
@@ -1389,7 +1873,13 @@ var SASjsApi = (() => {
1389
1873
  {
1390
1874
  name: "_filePath",
1391
1875
  in: "query",
1392
- required: true,
1876
+ required: false,
1877
+ type: "string"
1878
+ },
1879
+ {
1880
+ name: "_FILE",
1881
+ in: "query",
1882
+ required: false,
1393
1883
  type: "string"
1394
1884
  }
1395
1885
  ],
@@ -1399,9 +1889,13 @@ var SASjsApi = (() => {
1399
1889
  status: 200,
1400
1890
  description: "The contents of the file"
1401
1891
  },
1892
+ {
1893
+ status: 202,
1894
+ description: "A streamed file is not there: Parameter Error / File error"
1895
+ },
1402
1896
  {
1403
1897
  status: 400,
1404
- description: "Can't get file outside drive"
1898
+ description: "A path outside the drive, a refused extension, or a request naming neither or both"
1405
1899
  },
1406
1900
  {
1407
1901
  status: 404,
@@ -2967,7 +3461,16 @@ var SASjsApi = (() => {
2967
3461
  },
2968
3462
  // Drive - the file and folder rules, and the three deploy routes
2969
3463
  // The body is the file itself, so there is nothing to annotate
2970
- "GET /SASjsApi/drive/file": { implemented: true },
3464
+ // The `_FILE=` read needs one capability the plain drive read does not: a
3465
+ // host that serves a streamed deployment must supply the typed read, and one
3466
+ // that does not answers 501 naming it - which is what a capability is for.
3467
+ // (No route documents 501; the answer a host gives for a capability it lacks
3468
+ // is outside the contract, and this field is where the package says it may
3469
+ // happen.)
3470
+ "GET /SASjsApi/drive/file": {
3471
+ implemented: true,
3472
+ capabilities: ["storage", "deploymentFile"]
3473
+ },
2971
3474
  "POST /SASjsApi/drive/file": {
2972
3475
  implemented: true,
2973
3476
  responses: { 200: success, 409: "File already exists." }
@@ -5375,196 +5878,49 @@ var SASjsApi = (() => {
5375
5878
  const answer = await handler({
5376
5879
  services,
5377
5880
  request,
5378
- params: {
5379
- id: found.segments[0],
5380
- segments: found.segments
5381
- }
5382
- });
5383
- return {
5384
- ...answer,
5385
- // the emulated headers are spread LAST: they are the invariant this module
5386
- // exists to guarantee, so a handler cannot overwrite the stamp even by
5387
- // returning headers of its own
5388
- headers: { ...answer.headers, ...headers }
5389
- };
5390
- } catch (error) {
5391
- if (isApiError(error))
5392
- return {
5393
- status: error.status,
5394
- headers,
5395
- body: error.body ?? {
5396
- version: 2,
5397
- httpStatusCode: error.status,
5398
- errorCode: error.status,
5399
- message: error.message
5400
- }
5401
- };
5402
- return {
5403
- status: 500,
5404
- headers,
5405
- body: {
5406
- version: 2,
5407
- httpStatusCode: 500,
5408
- errorCode: 500,
5409
- message: String(error?.message ?? error)
5410
- }
5411
- };
5412
- }
5413
- };
5414
-
5415
- // src/corpus/viya/operations.ts
5416
- var VIYA_CORPUS = [
5417
- {
5418
- route: "GET /compute/contexts",
5419
- step: "compute/context-by-name",
5420
- queries: ["filter", "limit"],
5421
- statuses: [200],
5422
- expected: 200,
5423
- shape: {
5424
- accept: "string",
5425
- count: "number",
5426
- items: [
5427
- {
5428
- createdBy: "string",
5429
- id: "string",
5430
- links: [
5431
- {
5432
- href: "string",
5433
- method: "string",
5434
- rel: "string",
5435
- type: "string",
5436
- uri: "string"
5437
- }
5438
- ],
5439
- name: "string",
5440
- version: "number"
5441
- }
5442
- ],
5443
- limit: "number",
5444
- links: [
5445
- {
5446
- href: "string",
5447
- itemType: "string",
5448
- method: "string",
5449
- rel: "string",
5450
- type: "string",
5451
- uri: "string"
5452
- }
5453
- ],
5454
- name: "string",
5455
- start: "number",
5456
- version: "number"
5457
- }
5458
- },
5459
- {
5460
- route: "POST /compute/contexts/{}/sessions",
5461
- step: "compute/execute-script",
5462
- queries: [],
5463
- statuses: [201],
5464
- expected: 201,
5465
- shape: {
5466
- applicationName: "string",
5467
- attributes: {
5468
- homeDirectory: "string",
5469
- sessionInactiveTimeout: "number"
5470
- },
5471
- creationTimeStamp: "string",
5472
- environment: {
5473
- autoExecLines: ["string"]
5474
- },
5475
- id: "string",
5476
- links: [
5477
- {
5478
- href: "string",
5479
- method: "string",
5480
- rel: "string",
5481
- type: "string",
5482
- uri: "string"
5483
- }
5484
- ],
5485
- owner: "string",
5486
- serverId: "string",
5487
- serviceAPIVersion: "number",
5488
- sessionConditionCode: "number",
5489
- state: "string",
5490
- stateElapsedTime: "number",
5491
- version: "number"
5492
- }
5493
- },
5494
- {
5495
- route: "DELETE /compute/sessions/{}",
5496
- step: "compute/session-delete",
5497
- queries: [],
5498
- statuses: [204],
5499
- expected: 204,
5500
- shape: void 0
5501
- },
5502
- {
5503
- route: "POST /compute/sessions/{}/jobs",
5504
- step: "compute/execute-script",
5505
- queries: [],
5506
- statuses: [201],
5507
- expected: 201,
5508
- shape: {
5509
- creationTimeStamp: "string",
5510
- id: "string",
5511
- links: [
5512
- {
5513
- href: "string",
5514
- method: "string",
5515
- rel: "string",
5516
- type: "string",
5517
- uri: "string"
5518
- }
5519
- ],
5520
- sessionId: "string",
5521
- state: "string",
5522
- stateElapsedTime: "number",
5523
- version: "number"
5524
- }
5525
- },
5526
- {
5527
- route: "GET /compute/sessions/{}/jobs/{}",
5528
- step: "compute/execute-script",
5529
- queries: [],
5530
- statuses: [200],
5531
- expected: 200,
5532
- shape: {
5533
- completedTimeStamp: "string",
5534
- creationTimeStamp: "string",
5535
- id: "string",
5536
- jobConditionCode: "number",
5537
- links: [
5538
- {
5539
- href: "string",
5540
- method: "string",
5541
- rel: "string",
5542
- type: "string",
5543
- uri: "string"
5881
+ params: {
5882
+ id: found.segments[0],
5883
+ segments: found.segments
5884
+ }
5885
+ });
5886
+ return {
5887
+ ...answer,
5888
+ // the emulated headers are spread LAST: they are the invariant this module
5889
+ // exists to guarantee, so a handler cannot overwrite the stamp even by
5890
+ // returning headers of its own
5891
+ headers: { ...answer.headers, ...headers }
5892
+ };
5893
+ } catch (error) {
5894
+ if (isApiError(error))
5895
+ return {
5896
+ status: error.status,
5897
+ headers,
5898
+ body: error.body ?? {
5899
+ version: 2,
5900
+ httpStatusCode: error.status,
5901
+ errorCode: error.status,
5902
+ message: error.message
5544
5903
  }
5545
- ],
5546
- listingStatistics: {
5547
- lineCount: "number",
5548
- modifiedTimeStamp: "string"
5549
- },
5550
- logStatistics: {
5551
- lineCount: "number",
5552
- modifiedTimeStamp: "string"
5553
- },
5554
- sessionId: "string",
5555
- state: "string",
5556
- stateElapsedTime: "number",
5557
- statistics: {
5558
- systemCpuTime: "number",
5559
- userCpuTime: "number"
5560
- },
5561
- version: "number"
5562
- }
5563
- },
5904
+ };
5905
+ return {
5906
+ status: 500,
5907
+ headers,
5908
+ body: {
5909
+ version: 2,
5910
+ httpStatusCode: 500,
5911
+ errorCode: 500,
5912
+ message: String(error?.message ?? error)
5913
+ }
5914
+ };
5915
+ }
5916
+ };
5917
+
5918
+ // src/corpus/viya/operations.ts
5919
+ var VIYA_CORPUS = [
5564
5920
  {
5565
- route: "GET /compute/sessions/{}/jobs/{}/log/content",
5566
- step: "compute/execute-script",
5567
- queries: ["limit", "start"],
5921
+ route: "GET /compute/contexts",
5922
+ step: "compute/context-by-name",
5923
+ queries: ["filter", "limit"],
5568
5924
  statuses: [200],
5569
5925
  expected: 200,
5570
5926
  shape: {
@@ -5572,8 +5928,18 @@ var SASjsApi = (() => {
5572
5928
  count: "number",
5573
5929
  items: [
5574
5930
  {
5575
- line: "string",
5576
- type: "string",
5931
+ createdBy: "string",
5932
+ id: "string",
5933
+ links: [
5934
+ {
5935
+ href: "string",
5936
+ method: "string",
5937
+ rel: "string",
5938
+ type: "string",
5939
+ uri: "string"
5940
+ }
5941
+ ],
5942
+ name: "string",
5577
5943
  version: "number"
5578
5944
  }
5579
5945
  ],
@@ -5587,211 +5953,28 @@ var SASjsApi = (() => {
5587
5953
  type: "string",
5588
5954
  uri: "string"
5589
5955
  }
5590
- ],
5591
- name: "string",
5592
- start: "number",
5593
- version: "number"
5594
- }
5595
- },
5596
- {
5597
- route: "GET /compute/sessions/{}/jobs/{}/state",
5598
- step: "compute/execute-script",
5599
- queries: ["_action", "wait"],
5600
- statuses: [200],
5601
- expected: 200,
5602
- shape: void 0
5603
- },
5604
- {
5605
- route: "GET /compute/sessions/{}/state",
5606
- step: "compute/execute-script",
5607
- queries: ["wait"],
5608
- statuses: [200],
5609
- expected: 200,
5610
- shape: void 0
5611
- },
5612
- {
5613
- route: "POST /files/files",
5614
- step: "files/create",
5615
- queries: ["parentFolderUri", "typeDefName"],
5616
- statuses: [201],
5617
- expected: 201,
5618
- shape: {
5619
- contentDisposition: "string",
5620
- contentType: "string",
5621
- createdBy: "string",
5622
- creationTimeStamp: "string",
5623
- encoding: "string",
5624
- fileStatus: "string",
5625
- fileVersion: "number",
5626
- id: "string",
5627
- links: [
5628
- {
5629
- href: "string",
5630
- method: "string",
5631
- rel: "string",
5632
- type: "string",
5633
- uri: "string"
5634
- }
5635
- ],
5636
- modifiedBy: "string",
5637
- modifiedTimeStamp: "string",
5638
- name: "string",
5639
- properties: {},
5640
- quarantine: "boolean",
5641
- searchable: "boolean",
5642
- size: "number",
5643
- typeDefName: "string",
5644
- urlDetected: "boolean",
5645
- version: "number",
5646
- virusDetected: "boolean"
5647
- }
5648
- },
5649
- {
5650
- route: "GET /files/files/{}",
5651
- step: "files/replace",
5652
- queries: [],
5653
- statuses: [200],
5654
- expected: 200,
5655
- shape: {
5656
- contentDisposition: "string",
5657
- contentType: "string",
5658
- createdBy: "string",
5659
- creationTimeStamp: "string",
5660
- encoding: "string",
5661
- fileStatus: "string",
5662
- fileVersion: "number",
5663
- id: "string",
5664
- links: [
5665
- {
5666
- href: "string",
5667
- method: "string",
5668
- rel: "string",
5669
- type: "string",
5670
- uri: "string"
5671
- }
5672
- ],
5673
- modifiedBy: "string",
5674
- modifiedTimeStamp: "string",
5675
- name: "string",
5676
- properties: {
5677
- "content.download": "string",
5678
- "content.openInBrowser": "string",
5679
- "content.preview": "string",
5680
- sasIconKey: "string",
5681
- typeRegistrant: "string"
5682
- },
5683
- quarantine: "boolean",
5684
- searchable: "boolean",
5685
- size: "number",
5686
- typeDefName: "string",
5687
- urlDetected: "boolean",
5688
- version: "number",
5689
- virusDetected: "boolean"
5690
- }
5691
- },
5692
- {
5693
- route: "PATCH /files/files/{}",
5694
- step: "files/create",
5695
- queries: [],
5696
- statuses: [200],
5697
- expected: 200,
5698
- shape: {
5699
- contentDisposition: "string",
5700
- contentType: "string",
5701
- createdBy: "string",
5702
- creationTimeStamp: "string",
5703
- encoding: "string",
5704
- fileStatus: "string",
5705
- fileVersion: "number",
5706
- id: "string",
5707
- links: [
5708
- {
5709
- href: "string",
5710
- method: "string",
5711
- rel: "string",
5712
- type: "string",
5713
- uri: "string"
5714
- }
5715
- ],
5716
- modifiedBy: "string",
5717
- modifiedTimeStamp: "string",
5718
- name: "string",
5719
- properties: {
5720
- "content.download": "string",
5721
- "content.openInBrowser": "string",
5722
- "content.preview": "string",
5723
- sasIconKey: "string",
5724
- typeRegistrant: "string"
5725
- },
5726
- quarantine: "boolean",
5727
- searchable: "boolean",
5728
- size: "number",
5729
- typeDefName: "string",
5730
- urlDetected: "boolean",
5731
- version: "number",
5732
- virusDetected: "boolean"
5733
- }
5734
- },
5735
- {
5736
- route: "GET /files/files/{}/content",
5737
- step: "files/content",
5738
- queries: [],
5739
- statuses: [200],
5740
- expected: 200,
5741
- shape: void 0
5742
- },
5743
- {
5744
- route: "PUT /files/files/{}/content",
5745
- step: "files/replace",
5746
- queries: [],
5747
- statuses: [200],
5748
- expected: 200,
5749
- shape: {
5750
- contentDisposition: "string",
5751
- contentType: "string",
5752
- createdBy: "string",
5753
- creationTimeStamp: "string",
5754
- encoding: "string",
5755
- fileStatus: "string",
5756
- fileVersion: "number",
5757
- id: "string",
5758
- links: [
5759
- {
5760
- href: "string",
5761
- method: "string",
5762
- rel: "string",
5763
- type: "string",
5764
- uri: "string"
5765
- }
5766
- ],
5767
- modifiedBy: "string",
5768
- modifiedTimeStamp: "string",
5956
+ ],
5769
5957
  name: "string",
5770
- properties: {
5771
- "content.download": "string",
5772
- "content.openInBrowser": "string",
5773
- "content.preview": "string",
5774
- sasIconKey: "string",
5775
- typeRegistrant: "string"
5776
- },
5777
- quarantine: "boolean",
5778
- searchable: "boolean",
5779
- size: "number",
5780
- typeDefName: "string",
5781
- urlDetected: "boolean",
5782
- version: "number",
5783
- virusDetected: "boolean"
5958
+ start: "number",
5959
+ version: "number"
5784
5960
  }
5785
5961
  },
5786
5962
  {
5787
- route: "POST /folders/folders",
5788
- step: "folders/create",
5789
- queries: ["parentFolderUri"],
5963
+ route: "POST /compute/contexts/{}/sessions",
5964
+ step: "compute/execute-script",
5965
+ queries: [],
5790
5966
  statuses: [201],
5791
5967
  expected: 201,
5792
5968
  shape: {
5793
- createdBy: "string",
5969
+ applicationName: "string",
5970
+ attributes: {
5971
+ homeDirectory: "string",
5972
+ sessionInactiveTimeout: "number"
5973
+ },
5794
5974
  creationTimeStamp: "string",
5975
+ environment: {
5976
+ autoExecLines: ["string"]
5977
+ },
5795
5978
  id: "string",
5796
5979
  links: [
5797
5980
  {
@@ -5802,25 +5985,31 @@ var SASjsApi = (() => {
5802
5985
  uri: "string"
5803
5986
  }
5804
5987
  ],
5805
- memberCount: "number",
5806
- modifiedBy: "string",
5807
- modifiedTimeStamp: "string",
5808
- name: "string",
5809
- parentFolderUri: "string",
5810
- type: "string",
5988
+ owner: "string",
5989
+ serverId: "string",
5990
+ serviceAPIVersion: "number",
5991
+ sessionConditionCode: "number",
5992
+ state: "string",
5993
+ stateElapsedTime: "number",
5811
5994
  version: "number"
5812
5995
  }
5813
5996
  },
5814
5997
  {
5815
- route: "GET /folders/folders/{}",
5816
- step: "folders/delete",
5998
+ route: "DELETE /compute/sessions/{}",
5999
+ step: "compute/session-delete",
5817
6000
  queries: [],
5818
- statuses: [200],
5819
- expected: 200,
6001
+ statuses: [204],
6002
+ expected: 204,
6003
+ shape: void 0
6004
+ },
6005
+ {
6006
+ route: "POST /compute/sessions/{}/jobs",
6007
+ step: "compute/execute-script",
6008
+ queries: [],
6009
+ statuses: [201],
6010
+ expected: 201,
5820
6011
  shape: {
5821
- createdBy: "string",
5822
6012
  creationTimeStamp: "string",
5823
- description: "string",
5824
6013
  id: "string",
5825
6014
  links: [
5826
6015
  {
@@ -5831,28 +6020,23 @@ var SASjsApi = (() => {
5831
6020
  uri: "string"
5832
6021
  }
5833
6022
  ],
5834
- memberCount: "number",
5835
- modifiedBy: "string",
5836
- modifiedTimeStamp: "string",
5837
- name: "string",
5838
- parentFolderUri: "string",
5839
- properties: {
5840
- allowMove: "string"
5841
- },
5842
- type: "string",
6023
+ sessionId: "string",
6024
+ state: "string",
6025
+ stateElapsedTime: "number",
5843
6026
  version: "number"
5844
6027
  }
5845
6028
  },
5846
6029
  {
5847
- route: "PATCH /folders/folders/{}",
5848
- step: "folders/delete",
6030
+ route: "GET /compute/sessions/{}/jobs/{}",
6031
+ step: "compute/execute-script",
5849
6032
  queries: [],
5850
6033
  statuses: [200],
5851
6034
  expected: 200,
5852
6035
  shape: {
5853
- createdBy: "string",
6036
+ completedTimeStamp: "string",
5854
6037
  creationTimeStamp: "string",
5855
6038
  id: "string",
6039
+ jobConditionCode: "number",
5856
6040
  links: [
5857
6041
  {
5858
6042
  href: "string",
@@ -5862,19 +6046,28 @@ var SASjsApi = (() => {
5862
6046
  uri: "string"
5863
6047
  }
5864
6048
  ],
5865
- memberCount: "number",
5866
- modifiedBy: "string",
5867
- modifiedTimeStamp: "string",
5868
- name: "string",
5869
- parentFolderUri: "string",
5870
- type: "string",
6049
+ listingStatistics: {
6050
+ lineCount: "number",
6051
+ modifiedTimeStamp: "string"
6052
+ },
6053
+ logStatistics: {
6054
+ lineCount: "number",
6055
+ modifiedTimeStamp: "string"
6056
+ },
6057
+ sessionId: "string",
6058
+ state: "string",
6059
+ stateElapsedTime: "number",
6060
+ statistics: {
6061
+ systemCpuTime: "number",
6062
+ userCpuTime: "number"
6063
+ },
5871
6064
  version: "number"
5872
6065
  }
5873
6066
  },
5874
6067
  {
5875
- route: "GET /folders/folders/{}/members",
5876
- step: "files/content",
5877
- queries: ["limit"],
6068
+ route: "GET /compute/sessions/{}/jobs/{}/log/content",
6069
+ step: "compute/execute-script",
6070
+ queries: ["limit", "start"],
5878
6071
  statuses: [200],
5879
6072
  expected: 200,
5880
6073
  shape: {
@@ -5882,26 +6075,8 @@ var SASjsApi = (() => {
5882
6075
  count: "number",
5883
6076
  items: [
5884
6077
  {
5885
- added: "string",
5886
- contentType: "string",
5887
- createdBy: "string",
5888
- creationTimeStamp: "string",
5889
- id: "string",
5890
- links: [
5891
- {
5892
- href: "string",
5893
- method: "string",
5894
- rel: "string",
5895
- type: "string",
5896
- uri: "string"
5897
- }
5898
- ],
5899
- modifiedBy: "string",
5900
- modifiedTimeStamp: "string",
5901
- name: "string",
5902
- parentFolderUri: "string",
6078
+ line: "string",
5903
6079
  type: "string",
5904
- uri: "string",
5905
6080
  version: "number"
5906
6081
  }
5907
6082
  ],
@@ -5922,15 +6097,35 @@ var SASjsApi = (() => {
5922
6097
  }
5923
6098
  },
5924
6099
  {
5925
- route: "GET /folders/folders/@item",
5926
- step: "files/content",
5927
- queries: ["path"],
5928
- statuses: [200, 401, 404],
6100
+ route: "GET /compute/sessions/{}/jobs/{}/state",
6101
+ step: "compute/execute-script",
6102
+ queries: ["_action", "wait"],
6103
+ statuses: [200],
6104
+ expected: 200,
6105
+ shape: void 0
6106
+ },
6107
+ {
6108
+ route: "GET /compute/sessions/{}/state",
6109
+ step: "compute/execute-script",
6110
+ queries: ["wait"],
6111
+ statuses: [200],
5929
6112
  expected: 200,
6113
+ shape: void 0
6114
+ },
6115
+ {
6116
+ route: "POST /files/files",
6117
+ step: "files/create",
6118
+ queries: ["parentFolderUri", "typeDefName"],
6119
+ statuses: [201],
6120
+ expected: 201,
5930
6121
  shape: {
6122
+ contentDisposition: "string",
6123
+ contentType: "string",
5931
6124
  createdBy: "string",
5932
6125
  creationTimeStamp: "string",
5933
- description: "string",
6126
+ encoding: "string",
6127
+ fileStatus: "string",
6128
+ fileVersion: "number",
5934
6129
  id: "string",
5935
6130
  links: [
5936
6131
  {
@@ -5941,25 +6136,33 @@ var SASjsApi = (() => {
5941
6136
  uri: "string"
5942
6137
  }
5943
6138
  ],
5944
- memberCount: "number",
5945
6139
  modifiedBy: "string",
5946
6140
  modifiedTimeStamp: "string",
5947
6141
  name: "string",
5948
- parentFolderUri: "string",
5949
- type: "string",
5950
- version: "number"
6142
+ properties: {},
6143
+ quarantine: "boolean",
6144
+ searchable: "boolean",
6145
+ size: "number",
6146
+ typeDefName: "string",
6147
+ urlDetected: "boolean",
6148
+ version: "number",
6149
+ virusDetected: "boolean"
5951
6150
  }
5952
6151
  },
5953
6152
  {
5954
- route: "GET /folders/folders/@myRecycleBin",
5955
- step: "folders/delete",
6153
+ route: "GET /files/files/{}",
6154
+ step: "files/replace",
5956
6155
  queries: [],
5957
6156
  statuses: [200],
5958
6157
  expected: 200,
5959
6158
  shape: {
6159
+ contentDisposition: "string",
6160
+ contentType: "string",
5960
6161
  createdBy: "string",
5961
6162
  creationTimeStamp: "string",
5962
- description: "string",
6163
+ encoding: "string",
6164
+ fileStatus: "string",
6165
+ fileVersion: "number",
5963
6166
  id: "string",
5964
6167
  links: [
5965
6168
  {
@@ -5970,37 +6173,39 @@ var SASjsApi = (() => {
5970
6173
  uri: "string"
5971
6174
  }
5972
6175
  ],
5973
- memberCount: "number",
5974
6176
  modifiedBy: "string",
5975
6177
  modifiedTimeStamp: "string",
5976
6178
  name: "string",
5977
- parentFolderUri: "string",
5978
6179
  properties: {
5979
- allowMove: "string"
6180
+ "content.download": "string",
6181
+ "content.openInBrowser": "string",
6182
+ "content.preview": "string",
6183
+ sasIconKey: "string",
6184
+ typeRegistrant: "string"
5980
6185
  },
5981
- type: "string",
5982
- version: "number"
6186
+ quarantine: "boolean",
6187
+ searchable: "boolean",
6188
+ size: "number",
6189
+ typeDefName: "string",
6190
+ urlDetected: "boolean",
6191
+ version: "number",
6192
+ virusDetected: "boolean"
5983
6193
  }
5984
6194
  },
5985
6195
  {
5986
- route: "GET /identities/users/@currentUser",
5987
- step: "identities/current-user",
6196
+ route: "PATCH /files/files/{}",
6197
+ step: "files/create",
5988
6198
  queries: [],
5989
6199
  statuses: [200],
5990
6200
  expected: 200,
5991
6201
  shape: {
5992
- addresses: [
5993
- {
5994
- locality: "string",
5995
- type: "string"
5996
- }
5997
- ],
5998
- emailAddresses: [
5999
- {
6000
- type: "string",
6001
- value: "string"
6002
- }
6003
- ],
6202
+ contentDisposition: "string",
6203
+ contentType: "string",
6204
+ createdBy: "string",
6205
+ creationTimeStamp: "string",
6206
+ encoding: "string",
6207
+ fileStatus: "string",
6208
+ fileVersion: "number",
6004
6209
  id: "string",
6005
6210
  links: [
6006
6211
  {
@@ -6011,479 +6216,338 @@ var SASjsApi = (() => {
6011
6216
  uri: "string"
6012
6217
  }
6013
6218
  ],
6219
+ modifiedBy: "string",
6220
+ modifiedTimeStamp: "string",
6014
6221
  name: "string",
6015
- providerId: "string",
6016
- state: "string",
6017
- version: "number"
6018
- }
6019
- },
6020
- {
6021
- route: "POST /SASLogon/oauth/token",
6022
- step: "auth/token-refresh",
6023
- queries: [],
6024
- statuses: [200, 401],
6025
- expected: 200,
6026
- shape: {
6027
- access_token: "string",
6028
- expires_in: "number",
6029
- id_token: "string",
6030
- jti: "string",
6031
- refresh_expires_in: "number",
6032
- refresh_revocable: "boolean",
6033
- refresh_token: "string",
6034
- revocable: "boolean",
6035
- scope: "string",
6036
- token_type: "string"
6222
+ properties: {
6223
+ "content.download": "string",
6224
+ "content.openInBrowser": "string",
6225
+ "content.preview": "string",
6226
+ sasIconKey: "string",
6227
+ typeRegistrant: "string"
6228
+ },
6229
+ quarantine: "boolean",
6230
+ searchable: "boolean",
6231
+ size: "number",
6232
+ typeDefName: "string",
6233
+ urlDetected: "boolean",
6234
+ version: "number",
6235
+ virusDetected: "boolean"
6037
6236
  }
6038
6237
  },
6039
6238
  {
6040
- route: "GET /types/types",
6041
- step: "files/create",
6042
- queries: ["limit"],
6239
+ route: "GET /files/files/{}/content",
6240
+ step: "files/content",
6241
+ queries: [],
6043
6242
  statuses: [200],
6044
6243
  expected: 200,
6045
6244
  shape: void 0
6046
- }
6047
- ];
6048
-
6049
- // src/appstream/identity.ts
6050
- var normaliseAppLoc = (appLoc) => {
6051
- if (typeof appLoc !== "string" || appLoc === "")
6052
- throw new Error(
6053
- `App location must be a non-empty string, got ${JSON.stringify(appLoc)}.`
6054
- );
6055
- const normalised = normaliseDrivePath(appLoc);
6056
- if (normalised === null)
6057
- throw new ApiError(400, "appLoc cannot be outside drive.");
6058
- return normalised;
6059
- };
6060
- var newAppId = () => {
6061
- const webCrypto = globalThis.crypto;
6062
- if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
6063
- if (typeof webCrypto?.getRandomValues !== "function")
6064
- throw new Error("No cryptographic source of randomness is available.");
6065
- const bytes3 = new Uint8Array(16);
6066
- webCrypto.getRandomValues(bytes3);
6067
- bytes3[6] = bytes3[6] & 15 | 64;
6068
- bytes3[8] = bytes3[8] & 63 | 128;
6069
- const hex = Array.from(bytes3).map((byte) => byte.toString(16).padStart(2, "0")).join("");
6070
- return [
6071
- hex.slice(0, 8),
6072
- hex.slice(8, 12),
6073
- hex.slice(12, 16),
6074
- hex.slice(16, 20),
6075
- hex.slice(20)
6076
- ].join("-");
6077
- };
6078
- var APP_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
6079
- var isAppId = (value) => typeof value === "string" && APP_ID.test(value);
6080
-
6081
- // src/appstream/service.ts
6082
- var APP_FOLDERS_ROOT = "apps";
6083
- var frontendFolderOf = (name) => `/${APP_FOLDERS_ROOT}/${name}`;
6084
- var appSummary = (entry) => ({
6085
- id: entry.id,
6086
- name: entry.name,
6087
- url: `/app/${entry.id}/`
6088
- });
6089
- var webFolderOf = (value) => {
6090
- if (typeof value !== "string" || value === "")
6091
- throw new ApiError(400, '"streamWebFolder" is required');
6092
- if (value === "." || value === ".." || /[\\/]/.test(value))
6093
- throw new ApiError(400, "streamWebFolder must be a single path segment.");
6094
- return value;
6095
- };
6096
- var defaultAppName = (appLoc) => {
6097
- const segment = appLoc.split("/").filter(Boolean).pop();
6098
- return segment ? segment : "app";
6099
- };
6100
- var sameAppLoc = (left, right) => {
6101
- try {
6102
- return normaliseAppLoc(left) === normaliseAppLoc(right);
6103
- } catch (_) {
6104
- return false;
6105
- }
6106
- };
6107
- var appLocOf = (value) => {
6108
- try {
6109
- return normaliseAppLoc(value);
6110
- } catch (error) {
6111
- throw new ApiError(400, error.message);
6112
- }
6113
- };
6114
- var hasStreamFolder = (tree, streamWebFolder) => {
6115
- const members = tree?.members;
6116
- if (!Array.isArray(members)) return false;
6117
- const isFolder = (member, name) => {
6118
- const entry = member;
6119
- return entry?.type === "folder" && entry?.name === name;
6120
- };
6121
- const services = members.find((member) => isFolder(member, "services"));
6122
- const children = services?.members;
6123
- return Array.isArray(children) && children.some((member) => isFolder(member, streamWebFolder));
6124
- };
6125
- var hasFrontendRoot = (tree) => {
6126
- const members = tree?.members;
6127
- if (!Array.isArray(members)) return false;
6128
- return members.some((member) => {
6129
- const entry = member;
6130
- return entry?.type === "file" && entry?.name === "index.html";
6131
- });
6132
- };
6133
- var checkPublishRequest = (request, tree, options = {}) => {
6134
- const logo = logoOf(request.logo);
6135
- const frameAncestors = frameAncestorsOf(request.frameAncestors);
6136
- const timing = request.publishedAt === void 0 ? {} : { publishedAt: request.publishedAt };
6137
- if (request.streamWebFolder !== void 0) {
6138
- if (request.appLoc === void 0)
6139
- throw new ApiError(
6140
- 400,
6141
- '"appLoc" is required when "streamWebFolder" is stated: the entry keeps its web assets at <appLoc>/services/<streamWebFolder>, so both halves are needed to say where they are.'
6142
- );
6143
- const appLoc2 = appLocOf(request.appLoc);
6144
- if (appLoc2 === "/")
6145
- throw new ApiError(400, "An app cannot be published at the drive root.");
6146
- const streamWebFolder = webFolderOf(request.streamWebFolder);
6147
- if (tree !== void 0 && !hasStreamFolder(tree, streamWebFolder))
6148
- throw new ApiError(
6149
- 400,
6150
- `The deployed tree has no "services/${streamWebFolder}" folder, so nothing would be published at ${appLoc2}. Deploy the web assets under services/${streamWebFolder}, or ${options.folderFromManifest ? "correct the folder sasjs.app.json names." : "omit streamWebFolder."}`
6151
- );
6152
- return {
6153
- appLoc: appLoc2,
6154
- streamWebFolder,
6155
- ...request.name === void 0 ? {} : { name: nameOf(request.name) },
6156
- ...logo === void 0 ? {} : { logo },
6157
- ...frameAncestors === void 0 ? {} : { frameAncestors },
6158
- ...timing
6159
- };
6160
- }
6161
- if (request.name === void 0)
6162
- throw new ApiError(
6163
- 400,
6164
- '"name" is required: an app is published at apps/<name>, so the publish has to say what it is called.'
6165
- );
6166
- const name = nameOf(request.name);
6167
- const appLoc = request.appLoc === void 0 ? void 0 : appLocOf(request.appLoc);
6168
- if (appLoc === "/")
6169
- throw new ApiError(400, "An app cannot name the drive root as its backend.");
6170
- if (tree !== void 0 && !hasFrontendRoot(tree))
6171
- throw new ApiError(
6172
- 400,
6173
- `The deployed tree has no "index.html" at its root, so nothing would be published at apps/${name}. Publish the compiled web folder itself, not the folder that holds it.`
6174
- );
6175
- return {
6176
- name,
6177
- ...appLoc === void 0 ? {} : { appLoc },
6178
- ...logo === void 0 ? {} : { logo },
6179
- ...frameAncestors === void 0 ? {} : { frameAncestors },
6180
- ...timing
6181
- };
6182
- };
6183
- var nameOf = (value) => {
6184
- if (typeof value !== "string" || value.trim() === "")
6185
- throw new ApiError(400, '"name" must be a non-empty string');
6186
- return urlSafeName(value.trim());
6187
- };
6188
- var NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._~-]*$/;
6189
- var NAME_MAX_LENGTH = 64;
6190
- var RESERVED_NAMES = ["apps.json", "index.html"];
6191
- var urlSafeName = (name) => {
6192
- if (name.length > NAME_MAX_LENGTH)
6193
- throw new ApiError(
6194
- 400,
6195
- `"name" must be at most ${NAME_MAX_LENGTH} characters, and "${name}" is ${name.length}.`
6196
- );
6197
- if (!NAME_PATTERN.test(name))
6198
- throw new ApiError(
6199
- 400,
6200
- `"name" must be usable as a URL segment - letters, digits, dot, dash, underscore or tilde, starting with a letter or digit - so "/app/${name}" can be opened. "${name}" is not, because it carries a character that has to be percent-encoded, or a space.`
6201
- );
6202
- if (RESERVED_NAMES.includes(name.toLowerCase()))
6203
- throw new ApiError(
6204
- 400,
6205
- `"name" cannot be "${name}": the App Stream answers /app/${name} itself, so an app with that name could never be opened by name.`
6206
- );
6207
- return name;
6208
- };
6209
- var logoOf = (value) => {
6210
- if (value === void 0) return void 0;
6211
- if (typeof value !== "string" || value === "")
6212
- throw new ApiError(400, '"logo" must be a non-empty string');
6213
- return value;
6214
- };
6215
- var frameAncestorsOf = (value) => {
6216
- if (value === void 0) return void 0;
6217
- const list = Array.isArray(value) ? value : [value];
6218
- if (list.length === 0 || list.some((source) => typeof source !== "string" || source === ""))
6219
- throw new ApiError(
6220
- 400,
6221
- '"frameAncestors" must be a string or a non-empty list of strings'
6222
- );
6223
- return [...list];
6224
- };
6225
- var createAppStreamService = (store) => {
6226
- let queue = Promise.resolve();
6227
- const mutate = (work) => {
6228
- const run = queue.then(work, work);
6229
- queue = run.catch(() => void 0);
6230
- return run;
6231
- };
6232
- const readable = (allow) => store.read().then(
6233
- (entries) => entries.filter((entry) => allow ? allow(entry) : true).map((entry) => ({ ...entry })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
6234
- );
6235
- return {
6236
- list: readable,
6237
- async get(id) {
6238
- const entry = (await store.read()).find(
6239
- (candidate) => candidate.id === id
6240
- );
6241
- if (!entry) throw new ApiError(404, "No app is published with that id.");
6242
- return { ...entry };
6243
- },
6244
- async forAppLoc(appLoc) {
6245
- let normalised;
6246
- try {
6247
- normalised = normaliseAppLoc(appLoc);
6248
- } catch (_) {
6249
- return void 0;
6250
- }
6251
- const entry = (await store.read()).find(
6252
- (candidate) => candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, normalised)
6253
- );
6254
- return entry ? { ...entry } : void 0;
6255
- },
6256
- publish(request) {
6257
- return mutate(async () => {
6258
- const checked = checkPublishRequest(request);
6259
- const entries = await store.read();
6260
- const legacy = checked.streamWebFolder !== void 0;
6261
- const sameTarget = (candidate) => legacy ? candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, checked.appLoc) : candidate.streamWebFolder === void 0 && candidate.name === checked.name;
6262
- const existing = entries.find(sameTarget);
6263
- const logo = checked.logo;
6264
- const frameAncestors = checked.frameAncestors;
6265
- const name = legacy ? checked.name ?? existing?.name ?? defaultAppName(checked.appLoc) : checked.name;
6266
- if (!legacy || checked.name !== void 0) {
6267
- const clash = entries.find(
6268
- (candidate) => candidate !== existing && candidate.name.toLowerCase() === name.toLowerCase()
6269
- );
6270
- if (clash)
6271
- throw new ApiError(
6272
- 409,
6273
- `The name "${name}" is already the address of the app at ${clash.appLoc ?? frontendFolderOf(clash.name)}. An app's name is how it opens (/app/${name}), and two apps holding one name would answer an ambiguous lookup with nothing, so publish this one under a different name.`
6274
- );
6245
+ },
6246
+ {
6247
+ route: "PUT /files/files/{}/content",
6248
+ step: "files/replace",
6249
+ queries: [],
6250
+ statuses: [200],
6251
+ expected: 200,
6252
+ shape: {
6253
+ contentDisposition: "string",
6254
+ contentType: "string",
6255
+ createdBy: "string",
6256
+ creationTimeStamp: "string",
6257
+ encoding: "string",
6258
+ fileStatus: "string",
6259
+ fileVersion: "number",
6260
+ id: "string",
6261
+ links: [
6262
+ {
6263
+ href: "string",
6264
+ method: "string",
6265
+ rel: "string",
6266
+ type: "string",
6267
+ uri: "string"
6275
6268
  }
6276
- const entry = {
6277
- id: existing ? existing.id : newAppId(),
6278
- // the label is the one field a redeploy inherits: everything else is
6279
- // what this publish states
6280
- name,
6281
- ...checked.appLoc === void 0 ? {} : { appLoc: checked.appLoc },
6282
- ...checked.streamWebFolder === void 0 ? {} : { streamWebFolder: checked.streamWebFolder },
6283
- ...logo === void 0 ? {} : { logo },
6284
- ...frameAncestors === void 0 ? {} : { frameAncestors },
6285
- publishedAt: checked.publishedAt ?? (/* @__PURE__ */ new Date()).toISOString()
6286
- };
6287
- await store.write([
6288
- ...entries.filter((candidate) => !sameTarget(candidate)),
6289
- entry
6290
- ]);
6291
- return { ...entry };
6292
- });
6293
- },
6294
- unpublish(id) {
6295
- return mutate(async () => {
6296
- const entries = await store.read();
6297
- const index = entries.findIndex((entry) => entry.id === id);
6298
- if (index === -1)
6299
- throw new ApiError(404, "No app is published with that id.");
6300
- const [removed] = entries.splice(index, 1);
6301
- await store.write(entries);
6302
- return { ...removed };
6303
- });
6269
+ ],
6270
+ modifiedBy: "string",
6271
+ modifiedTimeStamp: "string",
6272
+ name: "string",
6273
+ properties: {
6274
+ "content.download": "string",
6275
+ "content.openInBrowser": "string",
6276
+ "content.preview": "string",
6277
+ sasIconKey: "string",
6278
+ typeRegistrant: "string"
6279
+ },
6280
+ quarantine: "boolean",
6281
+ searchable: "boolean",
6282
+ size: "number",
6283
+ typeDefName: "string",
6284
+ urlDetected: "boolean",
6285
+ version: "number",
6286
+ virusDetected: "boolean"
6304
6287
  }
6305
- };
6306
- };
6307
- var MemoryAppStreamStore = class {
6308
- constructor(entries = []) {
6309
- this.entries = entries.map((entry) => ({ ...entry }));
6310
- }
6311
- async read() {
6312
- return this.entries.map((entry) => ({ ...entry }));
6313
- }
6314
- async write(entries) {
6315
- this.entries = entries.map((entry) => ({ ...entry }));
6316
- }
6317
- };
6318
-
6319
- // src/appstream/web.ts
6320
- var DEFAULT_APP_PATH = "/app";
6321
- var NO_SUCH_APP = "There's no App Stream available here.";
6322
- var ESCAPES = {
6323
- "&": "&amp;",
6324
- "<": "&lt;",
6325
- ">": "&gt;",
6326
- '"': "&quot;",
6327
- "'": "&#39;"
6328
- };
6329
- var escapeHtml = (value) => value.replace(/[&<>"']/g, (character) => ESCAPES[character]);
6330
- var CONTENT_TYPES = {
6331
- html: "text/html; charset=utf-8",
6332
- htm: "text/html; charset=utf-8",
6333
- js: "text/javascript; charset=utf-8",
6334
- mjs: "text/javascript; charset=utf-8",
6335
- css: "text/css; charset=utf-8",
6336
- json: "application/json; charset=utf-8",
6337
- map: "application/json; charset=utf-8",
6338
- txt: "text/plain; charset=utf-8",
6339
- svg: "image/svg+xml",
6340
- png: "image/png",
6341
- jpg: "image/jpeg",
6342
- jpeg: "image/jpeg",
6343
- gif: "image/gif",
6344
- webp: "image/webp",
6345
- ico: "image/x-icon",
6346
- woff: "font/woff",
6347
- woff2: "font/woff2",
6348
- ttf: "font/ttf",
6349
- otf: "font/otf",
6350
- wasm: "application/wasm",
6351
- pdf: "application/pdf",
6352
- zip: "application/zip"
6353
- };
6354
- var contentTypeFor = (filePath2) => {
6355
- const extension = filePath2.slice(filePath2.lastIndexOf(".") + 1).toLowerCase();
6356
- return CONTENT_TYPES[extension] ?? "application/octet-stream";
6357
- };
6358
- var cacheControlFor = (filePath2) => /\.[0-9a-f]{8,}\.[A-Za-z0-9]+$/.test(filePath2) ? "public, max-age=31536000, immutable" : "public, max-age=0, must-revalidate";
6359
- var html = (status, markup) => ({
6360
- status,
6361
- body: markup,
6362
- contentType: "text/html; charset=utf-8"
6363
- });
6364
- var json = (status, body) => ({
6365
- status,
6366
- body: JSON.stringify(body),
6367
- contentType: "application/json; charset=utf-8"
6368
- });
6369
- var noSuchApp = () => html(404, `<!doctype html><html><body>${NO_SUCH_APP}</body></html>`);
6370
- var methodNotAllowed = (allowed) => ({
6371
- status: 405,
6372
- body: JSON.stringify({ status: "failure", message: `${allowed} only.` }),
6373
- contentType: "application/json; charset=utf-8",
6374
- headers: { allow: allowed }
6375
- });
6376
- var decoded = (segment) => {
6377
- try {
6378
- return decodeURIComponent(segment);
6379
- } catch (_) {
6380
- return void 0;
6381
- }
6382
- };
6383
- var appRootOf = (entry) => entry.streamWebFolder !== void 0 && entry.appLoc !== void 0 ? `${entry.appLoc}/services/${entry.streamWebFolder}` : frontendFolderOf(entry.name);
6384
- var createAppStreamWebService = (appStream, drive, options = {}) => {
6385
- const base = (options.basePath ?? DEFAULT_APP_PATH).replace(/\/+$/, "");
6386
- const title = options.title ?? "SASjs App Stream";
6387
- const urlOf = (entry) => `${base}/${entry.id}/`;
6388
- const rowOf = (entry) => ({
6389
- id: entry.id,
6390
- name: entry.name,
6391
- appLoc: entry.appLoc ?? null,
6392
- logo: entry.logo === void 0 ? null : `${urlOf(entry)}${entry.logo}`,
6393
- url: urlOf(entry),
6394
- publishedAt: entry.publishedAt ?? null
6395
- });
6396
- const apps = async (allow) => {
6397
- const entries = await appStream.list(allow);
6398
- return { apps: entries.map(rowOf) };
6399
- };
6400
- const landing = async (allow) => {
6401
- const { apps: rows } = await apps(allow);
6402
- const tiles = rows.length ? `<ul class="apps">${rows.map(
6403
- (row) => `<li><a href="${escapeHtml(row.url)}">${escapeHtml(row.name)}</a><span class="loc">${escapeHtml(
6404
- row.appLoc ?? frontendFolderOf(row.name)
6405
- )}</span></li>`
6406
- ).join("")}</ul>` : '<p class="empty">No apps have been published yet.</p>';
6407
- return html(
6408
- 200,
6409
- [
6410
- '<!doctype html><html lang="en"><head><meta charset="utf-8">',
6411
- '<meta name="viewport" content="width=device-width,initial-scale=1">',
6412
- `<title>${escapeHtml(title)}</title>`,
6413
- "<style>",
6414
- "body{font-family:system-ui,sans-serif;margin:2rem;color:#1f2430}",
6415
- "h1{font-size:1.4rem}",
6416
- "ul.apps{list-style:none;padding:0;display:grid;gap:.75rem;max-width:40rem}",
6417
- "ul.apps li{display:flex;flex-direction:column;gap:.15rem;padding:.75rem 1rem;",
6418
- "border:1px solid #d8dee9;border-radius:.5rem}",
6419
- "ul.apps a{font-weight:600;text-decoration:none;color:#0b5cad}",
6420
- ".loc{font-size:.8rem;color:#5b6472;font-family:ui-monospace,monospace}",
6421
- ".empty{color:#5b6472}",
6422
- "</style></head><body>",
6423
- `<h1>${escapeHtml(title)}</h1>`,
6424
- tiles,
6425
- "</body></html>"
6426
- ].join("")
6427
- );
6428
- };
6429
- const resolve = async (segment, allow) => {
6430
- const entries = await appStream.list(allow);
6431
- const byId2 = entries.find((entry) => entry.id === segment);
6432
- if (byId2) return byId2;
6433
- const byName = entries.filter((entry) => entry.name === segment);
6434
- return byName.length === 1 ? byName[0] : void 0;
6435
- };
6436
- const asset = async (entry, segments) => {
6437
- const parts = segments.map(decoded);
6438
- if (parts.some((part) => part === void 0)) return noSuchApp();
6439
- const relative = parts.join("/") || "index.html";
6440
- try {
6441
- const file = await drive.read(`${appRootOf(entry)}/${relative}`);
6442
- return {
6443
- status: 200,
6444
- body: file.contents,
6445
- contentType: contentTypeFor(relative),
6446
- headers: { "cache-control": cacheControlFor(relative) }
6447
- };
6448
- } catch (error) {
6449
- if (error instanceof ApiError && (error.status === 404 || error.status === 400))
6450
- return noSuchApp();
6451
- throw error;
6288
+ },
6289
+ {
6290
+ route: "POST /folders/folders",
6291
+ step: "folders/create",
6292
+ queries: ["parentFolderUri"],
6293
+ statuses: [201],
6294
+ expected: 201,
6295
+ shape: {
6296
+ createdBy: "string",
6297
+ creationTimeStamp: "string",
6298
+ id: "string",
6299
+ links: [
6300
+ {
6301
+ href: "string",
6302
+ method: "string",
6303
+ rel: "string",
6304
+ type: "string",
6305
+ uri: "string"
6306
+ }
6307
+ ],
6308
+ memberCount: "number",
6309
+ modifiedBy: "string",
6310
+ modifiedTimeStamp: "string",
6311
+ name: "string",
6312
+ parentFolderUri: "string",
6313
+ type: "string",
6314
+ version: "number"
6315
+ }
6316
+ },
6317
+ {
6318
+ route: "GET /folders/folders/{}",
6319
+ step: "folders/delete",
6320
+ queries: [],
6321
+ statuses: [200],
6322
+ expected: 200,
6323
+ shape: {
6324
+ createdBy: "string",
6325
+ creationTimeStamp: "string",
6326
+ description: "string",
6327
+ id: "string",
6328
+ links: [
6329
+ {
6330
+ href: "string",
6331
+ method: "string",
6332
+ rel: "string",
6333
+ type: "string",
6334
+ uri: "string"
6335
+ }
6336
+ ],
6337
+ memberCount: "number",
6338
+ modifiedBy: "string",
6339
+ modifiedTimeStamp: "string",
6340
+ name: "string",
6341
+ parentFolderUri: "string",
6342
+ properties: {
6343
+ allowMove: "string"
6344
+ },
6345
+ type: "string",
6346
+ version: "number"
6452
6347
  }
6453
- };
6454
- return {
6455
- apps,
6456
- landing,
6457
- async request({ method, path, allow }) {
6458
- const clean = (path.split(/[?#]/)[0] || "/").replace(/\/{2,}/g, "/");
6459
- const relative = base === "" ? clean : clean === base ? "/" : clean.startsWith(`${base}/`) ? clean.slice(base.length) : null;
6460
- if (relative === null) return noSuchApp();
6461
- if (relative === "" || relative === "/" || relative === "/index.html") {
6462
- if (method !== "GET") return methodNotAllowed("GET");
6463
- return landing(allow);
6464
- }
6465
- if (relative === "/apps.json") {
6466
- if (method !== "GET") return methodNotAllowed("GET");
6467
- return json(200, await apps(allow));
6468
- }
6469
- const segments = relative.split("/").filter(Boolean);
6470
- const key = decoded(segments[0]);
6471
- if (key === void 0) return noSuchApp();
6472
- if (method === "DELETE") {
6473
- const entry2 = await resolve(key, allow);
6474
- if (!entry2) return noSuchApp();
6475
- const removed = await appStream.unpublish(entry2.id);
6476
- return json(200, { status: "success", app: rowOf(removed) });
6477
- }
6478
- if (method !== "GET") return methodNotAllowed("GET, DELETE");
6479
- const entry = await resolve(key, allow);
6480
- if (!entry) return noSuchApp();
6481
- if (segments.length === 1 && !relative.endsWith("/"))
6482
- return { status: 301, location: urlOf(entry) };
6483
- return asset(entry, segments.slice(1));
6348
+ },
6349
+ {
6350
+ route: "PATCH /folders/folders/{}",
6351
+ step: "folders/delete",
6352
+ queries: [],
6353
+ statuses: [200],
6354
+ expected: 200,
6355
+ shape: {
6356
+ createdBy: "string",
6357
+ creationTimeStamp: "string",
6358
+ id: "string",
6359
+ links: [
6360
+ {
6361
+ href: "string",
6362
+ method: "string",
6363
+ rel: "string",
6364
+ type: "string",
6365
+ uri: "string"
6366
+ }
6367
+ ],
6368
+ memberCount: "number",
6369
+ modifiedBy: "string",
6370
+ modifiedTimeStamp: "string",
6371
+ name: "string",
6372
+ parentFolderUri: "string",
6373
+ type: "string",
6374
+ version: "number"
6484
6375
  }
6485
- };
6486
- };
6376
+ },
6377
+ {
6378
+ route: "GET /folders/folders/{}/members",
6379
+ step: "files/content",
6380
+ queries: ["limit"],
6381
+ statuses: [200],
6382
+ expected: 200,
6383
+ shape: {
6384
+ accept: "string",
6385
+ count: "number",
6386
+ items: [
6387
+ {
6388
+ added: "string",
6389
+ contentType: "string",
6390
+ createdBy: "string",
6391
+ creationTimeStamp: "string",
6392
+ id: "string",
6393
+ links: [
6394
+ {
6395
+ href: "string",
6396
+ method: "string",
6397
+ rel: "string",
6398
+ type: "string",
6399
+ uri: "string"
6400
+ }
6401
+ ],
6402
+ modifiedBy: "string",
6403
+ modifiedTimeStamp: "string",
6404
+ name: "string",
6405
+ parentFolderUri: "string",
6406
+ type: "string",
6407
+ uri: "string",
6408
+ version: "number"
6409
+ }
6410
+ ],
6411
+ limit: "number",
6412
+ links: [
6413
+ {
6414
+ href: "string",
6415
+ itemType: "string",
6416
+ method: "string",
6417
+ rel: "string",
6418
+ type: "string",
6419
+ uri: "string"
6420
+ }
6421
+ ],
6422
+ name: "string",
6423
+ start: "number",
6424
+ version: "number"
6425
+ }
6426
+ },
6427
+ {
6428
+ route: "GET /folders/folders/@item",
6429
+ step: "files/content",
6430
+ queries: ["path"],
6431
+ statuses: [200, 401, 404],
6432
+ expected: 200,
6433
+ shape: {
6434
+ createdBy: "string",
6435
+ creationTimeStamp: "string",
6436
+ description: "string",
6437
+ id: "string",
6438
+ links: [
6439
+ {
6440
+ href: "string",
6441
+ method: "string",
6442
+ rel: "string",
6443
+ type: "string",
6444
+ uri: "string"
6445
+ }
6446
+ ],
6447
+ memberCount: "number",
6448
+ modifiedBy: "string",
6449
+ modifiedTimeStamp: "string",
6450
+ name: "string",
6451
+ parentFolderUri: "string",
6452
+ type: "string",
6453
+ version: "number"
6454
+ }
6455
+ },
6456
+ {
6457
+ route: "GET /folders/folders/@myRecycleBin",
6458
+ step: "folders/delete",
6459
+ queries: [],
6460
+ statuses: [200],
6461
+ expected: 200,
6462
+ shape: {
6463
+ createdBy: "string",
6464
+ creationTimeStamp: "string",
6465
+ description: "string",
6466
+ id: "string",
6467
+ links: [
6468
+ {
6469
+ href: "string",
6470
+ method: "string",
6471
+ rel: "string",
6472
+ type: "string",
6473
+ uri: "string"
6474
+ }
6475
+ ],
6476
+ memberCount: "number",
6477
+ modifiedBy: "string",
6478
+ modifiedTimeStamp: "string",
6479
+ name: "string",
6480
+ parentFolderUri: "string",
6481
+ properties: {
6482
+ allowMove: "string"
6483
+ },
6484
+ type: "string",
6485
+ version: "number"
6486
+ }
6487
+ },
6488
+ {
6489
+ route: "GET /identities/users/@currentUser",
6490
+ step: "identities/current-user",
6491
+ queries: [],
6492
+ statuses: [200],
6493
+ expected: 200,
6494
+ shape: {
6495
+ addresses: [
6496
+ {
6497
+ locality: "string",
6498
+ type: "string"
6499
+ }
6500
+ ],
6501
+ emailAddresses: [
6502
+ {
6503
+ type: "string",
6504
+ value: "string"
6505
+ }
6506
+ ],
6507
+ id: "string",
6508
+ links: [
6509
+ {
6510
+ href: "string",
6511
+ method: "string",
6512
+ rel: "string",
6513
+ type: "string",
6514
+ uri: "string"
6515
+ }
6516
+ ],
6517
+ name: "string",
6518
+ providerId: "string",
6519
+ state: "string",
6520
+ version: "number"
6521
+ }
6522
+ },
6523
+ {
6524
+ route: "POST /SASLogon/oauth/token",
6525
+ step: "auth/token-refresh",
6526
+ queries: [],
6527
+ statuses: [200, 401],
6528
+ expected: 200,
6529
+ shape: {
6530
+ access_token: "string",
6531
+ expires_in: "number",
6532
+ id_token: "string",
6533
+ jti: "string",
6534
+ refresh_expires_in: "number",
6535
+ refresh_revocable: "boolean",
6536
+ refresh_token: "string",
6537
+ revocable: "boolean",
6538
+ scope: "string",
6539
+ token_type: "string"
6540
+ }
6541
+ },
6542
+ {
6543
+ route: "GET /types/types",
6544
+ step: "files/create",
6545
+ queries: ["limit"],
6546
+ statuses: [200],
6547
+ expected: 200,
6548
+ shape: void 0
6549
+ }
6550
+ ];
6487
6551
 
6488
6552
  // src/appstream/bundle.ts
6489
6553
  var APP_MANIFEST = "sasjs.app.json";
@@ -6821,7 +6885,24 @@ var SASjsApi = (() => {
6821
6885
  return { status: 200, body: await services.directory.synchronise() };
6822
6886
  }
6823
6887
  case "GET /SASjsApi/drive/file": {
6824
- const file = await drive.read(String(query._filePath || ""));
6888
+ assertOneFileName(query);
6889
+ if (query._FILE !== void 0) {
6890
+ if (!services.deploymentFile)
6891
+ throw new ApiError(
6892
+ 501,
6893
+ `This host has no deployment-file service, so it cannot answer ${routeId}.`
6894
+ );
6895
+ const page = await services.deploymentFile.read(String(query._FILE));
6896
+ return {
6897
+ status: page.status,
6898
+ contents: page.body,
6899
+ contentType: page.contentType,
6900
+ headers: page.headers
6901
+ };
6902
+ }
6903
+ if (query._filePath === void 0)
6904
+ throw new ApiError(400, '"_filePath" is required');
6905
+ const file = await drive.read(String(query._filePath));
6825
6906
  return { status: 200, contents: file.contents };
6826
6907
  }
6827
6908
  case "POST /SASjsApi/drive/file":
@@ -9230,6 +9311,34 @@ var SASjsApi = (() => {
9230
9311
  request: { query: { _filePath: "/../escape.csv" } },
9231
9312
  expect: { status: 400, error: "Can't get file outside drive." }
9232
9313
  },
9314
+ {
9315
+ id: "read-file-names-both",
9316
+ route: "GET /SASjsApi/drive/file",
9317
+ description: "refuses a request that names the file twice, in two readings",
9318
+ seed: { "/data/keep.csv": "a" },
9319
+ request: {
9320
+ query: { _filePath: "/data/keep.csv", _FILE: "/data/keep.csv" }
9321
+ },
9322
+ expect: {
9323
+ status: 400,
9324
+ error: 'Exactly one of "_filePath" and "_FILE" may be given.'
9325
+ }
9326
+ },
9327
+ {
9328
+ id: "read-streamed-file",
9329
+ route: "GET /SASjsApi/drive/file",
9330
+ description: "reads a deployment file by the name a streamed page links to",
9331
+ seed: { "/Public/app/services/web/main.js": "console.log(1)" },
9332
+ request: { query: { _FILE: "/Public/app/services/web/main.js" } },
9333
+ expect: { status: 200, contents: "console.log(1)" }
9334
+ },
9335
+ {
9336
+ id: "read-streamed-file-missing",
9337
+ route: "GET /SASjsApi/drive/file",
9338
+ description: "answers a missing deployment file the way the estate does, not as a 404",
9339
+ request: { query: { _FILE: "/Public/app/services/web/gone.js" } },
9340
+ expect: { status: 202, contents: DEPLOYMENT_FILE_ERROR }
9341
+ },
9233
9342
  {
9234
9343
  id: "delete-file",
9235
9344
  route: "DELETE /SASjsApi/drive/file",
@@ -10252,7 +10361,7 @@ var SASjsApi = (() => {
10252
10361
 
10253
10362
  // src/session/service.ts
10254
10363
  var createSessionService = (directory, host) => {
10255
- const notFound2 = (id) => `Session with ID '${id}' was not found.`;
10364
+ const notFound3 = (id) => `Session with ID '${id}' was not found.`;
10256
10365
  const visible = async (caller, id) => {
10257
10366
  if (!caller) throw new ApiError(401, "Unauthorized");
10258
10367
  const reader = await directory.userById(
@@ -10260,10 +10369,10 @@ var SASjsApi = (() => {
10260
10369
  );
10261
10370
  if (!reader || !reader.isActive) throw new ApiError(401, "Unauthorized");
10262
10371
  const session = await host.session(id);
10263
- if (!session) throw new ApiError(404, notFound2(id));
10372
+ if (!session) throw new ApiError(404, notFound3(id));
10264
10373
  const owner = session.owner;
10265
10374
  if (owner !== reader.uid && owner !== reader.username && !reader.isAdmin)
10266
- throw new ApiError(404, notFound2(id));
10375
+ throw new ApiError(404, notFound3(id));
10267
10376
  return session;
10268
10377
  };
10269
10378
  return {
@@ -10274,19 +10383,19 @@ var SASjsApi = (() => {
10274
10383
  async state(caller, id) {
10275
10384
  await visible(caller, id);
10276
10385
  const state = await host.state(id);
10277
- if (!state) throw new ApiError(404, notFound2(id));
10386
+ if (!state) throw new ApiError(404, notFound3(id));
10278
10387
  return state;
10279
10388
  },
10280
10389
  async log(caller, id) {
10281
10390
  await visible(caller, id);
10282
10391
  const log = await host.log(id);
10283
- if (log === void 0) throw new ApiError(404, notFound2(id));
10392
+ if (log === void 0) throw new ApiError(404, notFound3(id));
10284
10393
  return log;
10285
10394
  },
10286
10395
  async output(caller, id) {
10287
10396
  await visible(caller, id);
10288
10397
  const output = await host.output(id);
10289
- if (output === void 0) throw new ApiError(404, notFound2(id));
10398
+ if (output === void 0) throw new ApiError(404, notFound3(id));
10290
10399
  return output;
10291
10400
  }
10292
10401
  };
@@ -10297,7 +10406,7 @@ var SASjsApi = (() => {
10297
10406
 
10298
10407
  // src/runtime/program.ts
10299
10408
  var programNotFound = (given2) => `The Program at (${given2}) does not exist.`;
10300
- var notThere = (given2) => new ApiError(400, programNotFound(given2));
10409
+ var notThere2 = (given2) => new ApiError(400, programNotFound(given2));
10301
10410
  var runTimeOfPath = (path) => {
10302
10411
  const file = path.split(/[\\/]/).pop() || "";
10303
10412
  const dot = file.lastIndexOf(".");
@@ -10306,7 +10415,7 @@ var SASjsApi = (() => {
10306
10415
  };
10307
10416
  var resolveProgram = async (given2, deps) => {
10308
10417
  const resolved = deps.resolve(given2);
10309
- if (resolved === null) throw notThere(given2);
10418
+ if (resolved === null) throw notThere2(given2);
10310
10419
  const extension = runTimeOfPath(resolved);
10311
10420
  if (extension !== void 0) {
10312
10421
  if (await deps.exists(resolved))
@@ -10317,7 +10426,7 @@ var SASjsApi = (() => {
10317
10426
  if (await deps.exists(candidate)) return { path: candidate, runTime };
10318
10427
  }
10319
10428
  }
10320
- throw notThere(given2);
10429
+ throw notThere2(given2);
10321
10430
  };
10322
10431
 
10323
10432
  // src/runtime/service.ts
@@ -10340,7 +10449,7 @@ var SASjsApi = (() => {
10340
10449
  pad(now.getSeconds())
10341
10450
  ].join("");
10342
10451
  var newSessionId = (now) => `${timestamp(now)}-${Math.round(Math.random() * 1e5)}-${now.getTime()}`;
10343
- var notThere2 = (programPath) => programNotFound(programPath);
10452
+ var notThere3 = (programPath) => programNotFound(programPath);
10344
10453
  var failedRun = (error) => {
10345
10454
  const message = "Job execution failed.";
10346
10455
  throw new ApiError(400, message, {
@@ -10374,7 +10483,7 @@ var SASjsApi = (() => {
10374
10483
  if (request.program === "")
10375
10484
  throw new ApiError(400, '"_program" is not allowed to be empty');
10376
10485
  const resolved = normaliseDrivePath(request.program);
10377
- if (resolved === null) return failedRun(notThere2(request.program));
10486
+ if (resolved === null) return failedRun(notThere3(request.program));
10378
10487
  return { path: resolved };
10379
10488
  };
10380
10489
  const runTimeForPath = (path, request) => (
@@ -10600,10 +10709,10 @@ var SASjsApi = (() => {
10600
10709
  fail: testCase.failingRun,
10601
10710
  outputs: testCase.runOutput ? { [programOf(testCase)]: testCase.runOutput } : void 0
10602
10711
  });
10712
+ const driveStore = testCase.unwritable ? new RefusingDriveStore(testCase.seed || {}) : new MemoryDriveStore(testCase.seed || {});
10603
10713
  return {
10604
- drive: createDriveService(
10605
- testCase.unwritable ? new RefusingDriveStore(testCase.seed || {}) : new MemoryDriveStore(testCase.seed || {})
10606
- ),
10714
+ drive: createDriveService(driveStore),
10715
+ deploymentFile: createDeploymentFileService(driveStore),
10607
10716
  info: createInfoService(BROWSER_INFO),
10608
10717
  home: createHomeService(async () => CORPUS_WEB_PAGE),
10609
10718
  authConfig: createAuthConfigService(CORPUS_AUTH_CONFIG),
@@ -10755,7 +10864,7 @@ var SASjsApi = (() => {
10755
10864
  // src/corpus/session.ts
10756
10865
  var ADMIN = { userId: "user-admin", clientId: "web_app" };
10757
10866
  var RESTRICTED = { userId: "user-restricted", clientId: "web_app" };
10758
- var notFound = (id) => `Session with ID '${id}' was not found.`;
10867
+ var notFound2 = (id) => `Session with ID '${id}' was not found.`;
10759
10868
  var UNAUTHORIZED = "Unauthorized";
10760
10869
  var SESSION_CORPUS = [
10761
10870
  // ---------------------------------------------------------------- summary
@@ -10807,14 +10916,14 @@ var SASjsApi = (() => {
10807
10916
  route: "GET /SASjsApi/session/{sessionId}",
10808
10917
  description: "answers 404 for another account's session, not 403",
10809
10918
  request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10810
- expect: { status: 404, error: notFound("sess-admin") }
10919
+ expect: { status: 404, error: notFound2("sess-admin") }
10811
10920
  },
10812
10921
  {
10813
10922
  id: "session-summary-unknown",
10814
10923
  route: "GET /SASjsApi/session/{sessionId}",
10815
10924
  description: "answers the same 404 for a session that does not exist",
10816
10925
  request: { subject: ADMIN, params: { sessionId: "sess-nope" } },
10817
- expect: { status: 404, error: notFound("sess-nope") }
10926
+ expect: { status: 404, error: notFound2("sess-nope") }
10818
10927
  },
10819
10928
  // -------------------------------------------------------------------- log
10820
10929
  {
@@ -10846,7 +10955,7 @@ var SASjsApi = (() => {
10846
10955
  route: "GET /SASjsApi/session/{sessionId}/log",
10847
10956
  description: "will not read another account's log",
10848
10957
  request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10849
- expect: { status: 404, error: notFound("sess-admin") }
10958
+ expect: { status: 404, error: notFound2("sess-admin") }
10850
10959
  },
10851
10960
  // ----------------------------------------------------------------- output
10852
10961
  {
@@ -10868,7 +10977,7 @@ var SASjsApi = (() => {
10868
10977
  route: "GET /SASjsApi/session/{sessionId}/output",
10869
10978
  description: "will not read another account's webout",
10870
10979
  request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10871
- expect: { status: 404, error: notFound("sess-admin") }
10980
+ expect: { status: 404, error: notFound2("sess-admin") }
10872
10981
  },
10873
10982
  // ------------------------------------------------------------------ state
10874
10983
  {
@@ -10892,7 +11001,7 @@ var SASjsApi = (() => {
10892
11001
  route: "GET /SASjsApi/session/{sessionId}/state",
10893
11002
  description: "will not report another account's session state",
10894
11003
  request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10895
- expect: { status: 404, error: notFound("sess-admin") }
11004
+ expect: { status: 404, error: notFound2("sess-admin") }
10896
11005
  }
10897
11006
  ];
10898
11007