@sasjs/api 0.45.0 → 0.47.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.
@@ -209,6 +209,28 @@ exports.VIYA_CORPUS = [
209
209
  expected: 200,
210
210
  shape: undefined
211
211
  },
212
+ {
213
+ route: 'GET /compute/sessions/{}/variables/{}',
214
+ step: 'compute/execute-script',
215
+ queries: [],
216
+ statuses: [200],
217
+ expected: 200,
218
+ shape: {
219
+ links: [
220
+ {
221
+ href: 'string',
222
+ method: 'string',
223
+ rel: 'string',
224
+ type: 'string',
225
+ uri: 'string'
226
+ }
227
+ ],
228
+ name: 'string',
229
+ scope: 'string',
230
+ value: 'string',
231
+ version: 'number'
232
+ }
233
+ },
212
234
  {
213
235
  route: 'POST /files/files',
214
236
  step: 'files/create',
@@ -617,6 +639,264 @@ exports.VIYA_CORPUS = [
617
639
  version: 'number'
618
640
  }
619
641
  },
642
+ {
643
+ route: 'POST /jobDefinitions/definitions',
644
+ step: 'jobs/definition',
645
+ queries: ['parentFolderUri'],
646
+ statuses: [201],
647
+ expected: 201,
648
+ shape: {
649
+ code: 'string',
650
+ createdBy: 'string',
651
+ creationTimeStamp: 'string',
652
+ id: 'string',
653
+ links: [
654
+ {
655
+ href: 'string',
656
+ method: 'string',
657
+ rel: 'string',
658
+ type: 'string',
659
+ uri: 'string'
660
+ }
661
+ ],
662
+ modifiedBy: 'string',
663
+ modifiedTimeStamp: 'string',
664
+ name: 'string',
665
+ parameters: [
666
+ {
667
+ defaultValue: 'string',
668
+ name: 'string',
669
+ required: 'boolean',
670
+ type: 'string',
671
+ version: 'number'
672
+ }
673
+ ],
674
+ type: 'string',
675
+ version: 'number'
676
+ }
677
+ },
678
+ {
679
+ route: 'GET /jobDefinitions/definitions/{}',
680
+ step: 'jobs/execute',
681
+ queries: [],
682
+ statuses: [200],
683
+ expected: 200,
684
+ shape: {
685
+ code: 'string',
686
+ createdBy: 'string',
687
+ creationTimeStamp: 'string',
688
+ id: 'string',
689
+ links: [
690
+ {
691
+ href: 'string',
692
+ method: 'string',
693
+ rel: 'string',
694
+ type: 'string',
695
+ uri: 'string'
696
+ }
697
+ ],
698
+ modifiedBy: 'string',
699
+ modifiedTimeStamp: 'string',
700
+ name: 'string',
701
+ parameters: [
702
+ {
703
+ defaultValue: 'string',
704
+ name: 'string',
705
+ required: 'boolean',
706
+ type: 'string',
707
+ version: 'number'
708
+ }
709
+ ],
710
+ type: 'string',
711
+ version: 'number'
712
+ }
713
+ },
714
+ {
715
+ route: 'POST /jobExecution/jobs',
716
+ step: 'jobs/execute',
717
+ queries: ['_action'],
718
+ statuses: [201],
719
+ expected: 201,
720
+ shape: {
721
+ createdBy: 'string',
722
+ creationTimeStamp: 'string',
723
+ elapsedTime: 'number',
724
+ heartbeatInterval: 'number',
725
+ heartbeatTimeStamp: 'string',
726
+ id: 'string',
727
+ jobRequest: {
728
+ arguments: {
729
+ _DEBUG: 'string',
730
+ _OMITJSONLISTING: 'string',
731
+ _OMITJSONLOG: 'string',
732
+ _OMITTEXTLISTING: 'string',
733
+ _OMITTEXTLOG: 'string',
734
+ _addjesbeginendmacros: 'string',
735
+ _contextName: 'string',
736
+ _omitSessionResults: 'string',
737
+ _program: 'string',
738
+ _webin_file_count: 'string'
739
+ },
740
+ createdByApplication: 'string',
741
+ description: 'string',
742
+ jobDefinition: {
743
+ code: 'string',
744
+ createdBy: 'string',
745
+ creationTimeStamp: 'string',
746
+ id: 'string',
747
+ links: ['object'],
748
+ modifiedBy: 'string',
749
+ modifiedTimeStamp: 'string',
750
+ name: 'string',
751
+ parameters: ['object'],
752
+ type: 'string',
753
+ version: 'number'
754
+ },
755
+ name: 'string',
756
+ properties: 'array',
757
+ version: 'number'
758
+ },
759
+ links: [
760
+ {
761
+ href: 'string',
762
+ method: 'string',
763
+ rel: 'string',
764
+ type: 'string',
765
+ uri: 'string'
766
+ }
767
+ ],
768
+ modifiedBy: 'string',
769
+ modifiedTimeStamp: 'string',
770
+ results: {},
771
+ state: 'string',
772
+ submittedByApplication: 'string',
773
+ version: 'number'
774
+ }
775
+ },
776
+ {
777
+ route: 'GET /jobExecution/jobs/{}',
778
+ step: 'jobs/execute',
779
+ queries: [],
780
+ statuses: [200],
781
+ expected: 200,
782
+ shape: {
783
+ createdBy: 'string',
784
+ creationTimeStamp: 'string',
785
+ elapsedTime: 'number',
786
+ endTimeStamp: 'string',
787
+ heartbeatInterval: 'number',
788
+ heartbeatTimeStamp: 'string',
789
+ id: 'string',
790
+ jobRequest: {
791
+ arguments: {
792
+ _DEBUG: 'string',
793
+ _OMITJSONLISTING: 'string',
794
+ _OMITJSONLOG: 'string',
795
+ _OMITTEXTLISTING: 'string',
796
+ _OMITTEXTLOG: 'string',
797
+ _addjesbeginendmacros: 'string',
798
+ _contextName: 'string',
799
+ _omitSessionResults: 'string',
800
+ _program: 'string',
801
+ _webin_file_count: 'string'
802
+ },
803
+ createdByApplication: 'string',
804
+ description: 'string',
805
+ jobDefinition: {
806
+ code: 'string',
807
+ createdBy: 'string',
808
+ creationTimeStamp: 'string',
809
+ id: 'string',
810
+ links: ['object'],
811
+ modifiedBy: 'string',
812
+ modifiedTimeStamp: 'string',
813
+ name: 'string',
814
+ parameters: ['object'],
815
+ type: 'string',
816
+ version: 'number'
817
+ },
818
+ name: 'string',
819
+ properties: 'array',
820
+ version: 'number'
821
+ },
822
+ links: [
823
+ {
824
+ href: 'string',
825
+ method: 'string',
826
+ rel: 'string',
827
+ type: 'string',
828
+ uri: 'string'
829
+ }
830
+ ],
831
+ logLocation: 'string',
832
+ modifiedBy: 'string',
833
+ modifiedTimeStamp: 'string',
834
+ results: {
835
+ COMPUTE_CONTEXT: 'string',
836
+ COMPUTE_JOB: 'string',
837
+ COMPUTE_SESSION: 'string',
838
+ '{}.log': 'string',
839
+ '{}.log.txt': 'string'
840
+ },
841
+ state: 'string',
842
+ submittedByApplication: 'string',
843
+ version: 'number'
844
+ }
845
+ },
846
+ {
847
+ route: 'GET /jobExecution/jobs/{}/state',
848
+ step: 'jobs/execute',
849
+ queries: ['_action', 'wait'],
850
+ statuses: [200],
851
+ expected: 200,
852
+ shape: undefined
853
+ },
854
+ {
855
+ route: 'GET /launcher/contexts',
856
+ step: 'compute/launcher-contexts',
857
+ queries: ['limit'],
858
+ statuses: [200],
859
+ expected: 200,
860
+ shape: {
861
+ accept: 'string',
862
+ count: 'number',
863
+ items: [
864
+ {
865
+ createdBy: 'string',
866
+ creationTimeStamp: 'string',
867
+ description: 'string',
868
+ id: 'string',
869
+ links: [
870
+ {
871
+ href: 'string',
872
+ method: 'string',
873
+ rel: 'string',
874
+ type: 'string',
875
+ uri: 'string'
876
+ }
877
+ ],
878
+ modifiedBy: 'string',
879
+ modifiedTimeStamp: 'string',
880
+ name: 'string',
881
+ type: 'string',
882
+ version: 'number'
883
+ }
884
+ ],
885
+ limit: 'number',
886
+ links: [
887
+ {
888
+ href: 'string',
889
+ method: 'string',
890
+ rel: 'string',
891
+ type: 'string',
892
+ uri: 'string'
893
+ }
894
+ ],
895
+ name: 'string',
896
+ start: 'number',
897
+ version: 'number'
898
+ }
899
+ },
620
900
  {
621
901
  route: 'POST /SASLogon/oauth/token',
622
902
  step: 'auth/token-refresh',
@@ -642,6 +922,44 @@ exports.VIYA_CORPUS = [
642
922
  queries: ['limit'],
643
923
  statuses: [200],
644
924
  expected: 200,
645
- shape: undefined
925
+ shape: {
926
+ accept: 'string',
927
+ count: 'number',
928
+ items: [
929
+ {
930
+ description: 'string',
931
+ iconUri: 'string',
932
+ label: 'string',
933
+ links: [
934
+ {
935
+ href: 'string',
936
+ method: 'string',
937
+ rel: 'string',
938
+ type: 'string',
939
+ uri: 'string'
940
+ }
941
+ ],
942
+ mediaType: 'string',
943
+ name: 'string',
944
+ resourceUri: 'string',
945
+ tags: ['string'],
946
+ version: 'number'
947
+ }
948
+ ],
949
+ limit: 'number',
950
+ links: [
951
+ {
952
+ href: 'string',
953
+ itemType: 'string',
954
+ method: 'string',
955
+ rel: 'string',
956
+ type: 'string',
957
+ uri: 'string'
958
+ }
959
+ ],
960
+ name: 'string',
961
+ start: 'number',
962
+ version: 'number'
963
+ }
646
964
  }
647
965
  ];
@@ -70,20 +70,20 @@ const contextNameFrom = (filter) => {
70
70
  return match?.[1] ?? match?.[2] ?? exports.DEFAULT_CONTEXT_NAME;
71
71
  };
72
72
  exports.contextNameFrom = contextNameFrom;
73
- const contextBody = (name) => ({
73
+ const contextBody = (name, caller) => ({
74
74
  id: exports.EMULATED_CONTEXT_ID,
75
75
  name,
76
- createdBy: ids_js_1.EMULATED_USER.id,
76
+ createdBy: caller,
77
77
  version: 2,
78
78
  links: linksFor(`/compute/contexts/${exports.EMULATED_CONTEXT_ID}`, 'application/vnd.sas.compute.context')
79
79
  });
80
- const sessionBody = (services, session, autoExecLines) => {
80
+ const sessionBody = (services, session, autoExecLines, caller) => {
81
81
  const { id } = session;
82
82
  const uri = `/compute/sessions/${id}`;
83
83
  return {
84
84
  id,
85
85
  applicationName: 'emulated',
86
- owner: ids_js_1.EMULATED_USER.id,
86
+ owner: caller,
87
87
  serverId: (0, ids_js_1.idFor)((0, seed_js_1.normaliseServerUrl)(services.viya?.serverUrl) || 'emulated', 'server'),
88
88
  state: 'idle',
89
89
  attributes: {
@@ -169,7 +169,9 @@ exports.COMPUTE_HANDLERS = {
169
169
  limit,
170
170
  count: 1,
171
171
  version: 2,
172
- items: [contextBody((0, exports.contextNameFrom)(request.query?.filter))],
172
+ items: [
173
+ contextBody((0, exports.contextNameFrom)(request.query?.filter), (0, ids_js_1.callerId)(request.subject))
174
+ ],
173
175
  links: linksFor('/compute/contexts', 'application/vnd.sas.compute.context', true)
174
176
  }
175
177
  };
@@ -181,7 +183,7 @@ exports.COMPUTE_HANDLERS = {
181
183
  const session = estateOf(services).create();
182
184
  return {
183
185
  status: 201,
184
- body: sessionBody(services, session, body.environment?.autoExecLines ?? [])
186
+ body: sessionBody(services, session, body.environment?.autoExecLines ?? [], (0, ids_js_1.callerId)(request.subject))
185
187
  };
186
188
  },
187
189
  'GET /compute/sessions/{}/state': async ({ services, params }) => {
@@ -26,7 +26,7 @@ const contentTypeOf = (name) => {
26
26
  * client reads rather than placeholders: the three `content.*` flags say what can
27
27
  * be done with the file, and `typeRegistrant` says who registered the type.
28
28
  */
29
- const fileBody = (file) => {
29
+ const fileBody = (file, caller) => {
30
30
  const id = (0, ids_js_1.idFor)(file.path, 'file');
31
31
  const uri = `/files/files/${id}`;
32
32
  const contentType = contentTypeOf(file.name);
@@ -41,8 +41,8 @@ const fileBody = (file) => {
41
41
  fileVersion: 1,
42
42
  version: 2,
43
43
  typeDefName: 'file',
44
- createdBy: ids_js_1.EMULATED_USER.id,
45
- modifiedBy: ids_js_1.EMULATED_USER.id,
44
+ createdBy: caller,
45
+ modifiedBy: caller,
46
46
  creationTimeStamp: ids_js_1.EMULATED_NOW,
47
47
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
48
48
  quarantine: false,
@@ -54,7 +54,7 @@ const fileBody = (file) => {
54
54
  'content.openInBrowser': 'true',
55
55
  'content.preview': 'false',
56
56
  sasIconKey: 'file',
57
- typeRegistrant: ids_js_1.EMULATED_USER.id
57
+ typeRegistrant: caller
58
58
  },
59
59
  links: [
60
60
  {
@@ -150,12 +150,18 @@ exports.FILE_HANDLERS = {
150
150
  const parent = await parentOf(drive, request.query?.parentFolderUri);
151
151
  const path = `${parent}/${upload.name}`.replace(/\/{2,}/g, '/');
152
152
  await drive.save(path, upload.contents);
153
- return { status: 201, body: fileBody(await bodyOf(drive, path)) };
153
+ return {
154
+ status: 201,
155
+ body: fileBody(await bodyOf(drive, path), (0, ids_js_1.callerId)(request.subject))
156
+ };
154
157
  },
155
- 'GET /files/files/{}': async ({ services, params }) => {
158
+ 'GET /files/files/{}': async ({ services, params, request }) => {
156
159
  const drive = (0, ports_js_1.requireDrive)(services);
157
160
  const path = await pathForFileId(drive, params.id);
158
- return { status: 200, body: fileBody(await bodyOf(drive, path)) };
161
+ return {
162
+ status: 200,
163
+ body: fileBody(await bodyOf(drive, path), (0, ids_js_1.callerId)(request.subject))
164
+ };
159
165
  },
160
166
  'PATCH /files/files/{}': async ({ services, params, request }) => {
161
167
  const drive = (0, ports_js_1.requireDrive)(services);
@@ -165,7 +171,10 @@ exports.FILE_HANDLERS = {
165
171
  const target = `${path.split('/').slice(0, -1).join('/')}/${name}`.replace(/\/{2,}/g, '/');
166
172
  if (target !== path)
167
173
  await drive.rename(path, target);
168
- return { status: 200, body: fileBody(await bodyOf(drive, target)) };
174
+ return {
175
+ status: 200,
176
+ body: fileBody(await bodyOf(drive, target), (0, ids_js_1.callerId)(request.subject))
177
+ };
169
178
  },
170
179
  'GET /files/files/{}/content': async ({ services, params }) => {
171
180
  const drive = (0, ports_js_1.requireDrive)(services);
@@ -198,6 +207,9 @@ exports.FILE_HANDLERS = {
198
207
  if (contents === undefined || contents === null)
199
208
  throw new types_js_1.ApiError(400, 'File content is required.');
200
209
  await drive.update(path, contents);
201
- return { status: 200, body: fileBody(await bodyOf(drive, path)) };
210
+ return {
211
+ status: 200,
212
+ body: fileBody(await bodyOf(drive, path), (0, ids_js_1.callerId)(request.subject))
213
+ };
202
214
  }
203
215
  };
@@ -8,11 +8,23 @@
8
8
  * would be a cycle.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.normalisePath = exports.idFor = exports.EMULATED_USER = exports.EMULATED_NOW = void 0;
11
+ exports.normalisePath = exports.idFor = exports.callerId = exports.EMULATED_USER = exports.EMULATED_NOW = void 0;
12
12
  /** The emulated clock: a fixed instant, so a body is reproducible. */
13
13
  exports.EMULATED_NOW = '2026-01-01T00:00:00.000Z';
14
14
  /** The caller the emulated estate reports when a host does not name one. */
15
15
  exports.EMULATED_USER = { id: 'emulated-user', name: 'Emulated User' };
16
+ /**
17
+ * The id the emulated estate reports as the caller.
18
+ *
19
+ * A host that resolved the caller before dispatching - the server's signed-in
20
+ * account - passes it as `subject`; a host with no identity (the browser worker)
21
+ * passes none, and the fallback names itself, so the answer says on its face that
22
+ * no account was resolved. Bodies that carry `createdBy`, `modifiedBy` or `owner`
23
+ * use this, so an application that reads its own name back is told the account it
24
+ * signed in with.
25
+ */
26
+ const callerId = (subject) => subject?.userId ?? exports.EMULATED_USER.id;
27
+ exports.callerId = callerId;
16
28
  /**
17
29
  * A uuid shape from a string, deterministically.
18
30
  *
@@ -23,6 +23,15 @@ const declared_js_1 = require("./declared.js");
23
23
  * a second answer to the same question.
24
24
  */
25
25
  const NEEDS_AUTH = 'The token endpoint is answered by the host that mounts the emulator, which owns the token port.';
26
+ /**
27
+ * The job family is a capture without a handler.
28
+ *
29
+ * The deploy-and-run path is recorded - a service pack deploy creates a job
30
+ * definition and submits it - and this package answers the compute and content
31
+ * families, not that one. Saying so is the difference between a client learning
32
+ * what is missing and a client learning nothing.
33
+ */
34
+ const NEEDS_JOBS = 'The emulator answers the compute and content families; the job definitions a deploy creates and the executions a run submits are not modelled yet.';
26
35
  exports.VIYA_OVERLAY = {
27
36
  // answered here
28
37
  'POST /folders/folders': { implemented: true },
@@ -48,6 +57,32 @@ exports.VIYA_OVERLAY = {
48
57
  'PATCH /files/files/{}': { implemented: true },
49
58
  'GET /files/files/{}/content': { implemented: true },
50
59
  'PUT /files/files/{}/content': { implemented: true },
60
+ // declined: the job family needs a job service
61
+ //
62
+ // A capture describes what the estate answers on the deploy-and-run path, and
63
+ // the emulator does not answer that path yet: a client that deploys a service
64
+ // pack against an emulated estate stops here, with a reason rather than a 404.
65
+ 'POST /jobDefinitions/definitions': {
66
+ implemented: false,
67
+ reason: NEEDS_JOBS
68
+ },
69
+ 'GET /jobDefinitions/definitions/{}': {
70
+ implemented: false,
71
+ reason: NEEDS_JOBS
72
+ },
73
+ 'POST /jobExecution/jobs': { implemented: false, reason: NEEDS_JOBS },
74
+ 'GET /jobExecution/jobs/{}': { implemented: false, reason: NEEDS_JOBS },
75
+ 'GET /jobExecution/jobs/{}/state': { implemented: false, reason: NEEDS_JOBS },
76
+ // declined: contexts come from the seed, not from the launcher
77
+ 'GET /launcher/contexts': {
78
+ implemented: false,
79
+ reason: 'The emulator answers compute contexts from its seed; the launcher list a client falls back to is not modelled, and nothing on the emulated path asks for it.'
80
+ },
81
+ // declined: session variables are not modelled
82
+ 'GET /compute/sessions/{}/variables/{}': {
83
+ implemented: false,
84
+ reason: 'The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run.'
85
+ },
51
86
  // declined: the host owns the token port
52
87
  'POST /SASLogon/oauth/token': { implemented: false, reason: NEEDS_AUTH },
53
88
  // declared, not captured: the webout an application's service returns
@@ -26,7 +26,7 @@ const linksFor = (uri, collection = false) => {
26
26
  // itemType its capture recorded
27
27
  return collection ? [members, self] : [self, members];
28
28
  };
29
- const folderBody = async (drive, path) => {
29
+ const folderBody = async (drive, path, caller) => {
30
30
  const listing = await drive.list(path);
31
31
  const id = (0, ids_js_1.idFor)(path);
32
32
  const name = path.split('/').filter(Boolean).pop() ?? '';
@@ -37,8 +37,8 @@ const folderBody = async (drive, path) => {
37
37
  description: '',
38
38
  type: 'folder',
39
39
  version: 1,
40
- createdBy: ids_js_1.EMULATED_USER.id,
41
- modifiedBy: ids_js_1.EMULATED_USER.id,
40
+ createdBy: caller,
41
+ modifiedBy: caller,
42
42
  creationTimeStamp: ids_js_1.EMULATED_NOW,
43
43
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
44
44
  memberCount: listing.files.length + listing.folders.length,
@@ -46,7 +46,7 @@ const folderBody = async (drive, path) => {
46
46
  links: linksFor(`/folders/folders/${id}`)
47
47
  };
48
48
  };
49
- const recycleBin = () => {
49
+ const recycleBin = (caller) => {
50
50
  const path = '@myRecycleBin';
51
51
  const id = (0, ids_js_1.idFor)(path);
52
52
  return {
@@ -55,8 +55,8 @@ const recycleBin = () => {
55
55
  description: 'Recycle Bin',
56
56
  type: 'trashFolder',
57
57
  version: 1,
58
- createdBy: ids_js_1.EMULATED_USER.id,
59
- modifiedBy: ids_js_1.EMULATED_USER.id,
58
+ createdBy: caller,
59
+ modifiedBy: caller,
60
60
  creationTimeStamp: ids_js_1.EMULATED_NOW,
61
61
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
62
62
  memberCount: 0,
@@ -103,9 +103,9 @@ const pathForId = async (drive, id) => {
103
103
  /** The handlers, keyed by the operation id the table states. */
104
104
  exports.VIYA_HANDLERS = {
105
105
  'GET /identities/users/@currentUser': async ({ services, request }) => {
106
- const subject = request.subject ??
107
- (await services.identity?.authenticate(request.token));
108
- const id = subject?.userId ?? ids_js_1.EMULATED_USER.id;
106
+ // the host's resolved caller wins; a token is the second way to name one
107
+ const subject = request.subject ?? (await services.identity?.authenticate(request.token));
108
+ const id = (0, ids_js_1.callerId)(subject);
109
109
  return {
110
110
  status: 200,
111
111
  body: {
@@ -144,20 +144,20 @@ exports.VIYA_HANDLERS = {
144
144
  }),
145
145
  'GET /folders/folders/@item': async ({ services, request }) => ({
146
146
  status: 200,
147
- body: await folderBody((0, ports_js_1.requireDrive)(services), pathFromQuery(request))
147
+ body: await folderBody((0, ports_js_1.requireDrive)(services), pathFromQuery(request), (0, ids_js_1.callerId)(request.subject))
148
148
  }),
149
- 'GET /folders/folders/@myRecycleBin': async () => ({
149
+ 'GET /folders/folders/@myRecycleBin': async ({ request }) => ({
150
150
  status: 200,
151
- body: recycleBin()
151
+ body: recycleBin((0, ids_js_1.callerId)(request.subject))
152
152
  }),
153
- 'GET /folders/folders/{}': async ({ services, params }) => {
153
+ 'GET /folders/folders/{}': async ({ services, params, request }) => {
154
154
  // the bin is addressed by id too, and it is not in the drive's tree
155
155
  if (params.id === (0, ids_js_1.idFor)('@myRecycleBin'))
156
- return { status: 200, body: recycleBin() };
156
+ return { status: 200, body: recycleBin((0, ids_js_1.callerId)(request.subject)) };
157
157
  const drive = (0, ports_js_1.requireDrive)(services);
158
158
  return {
159
159
  status: 200,
160
- body: await folderBody(drive, await pathForId(drive, params.id))
160
+ body: await folderBody(drive, await pathForId(drive, params.id), (0, ids_js_1.callerId)(request.subject))
161
161
  };
162
162
  },
163
163
  'GET /folders/folders/{}/members': async ({ services, params, request }) => {
@@ -183,6 +183,7 @@ exports.VIYA_HANDLERS = {
183
183
  };
184
184
  const path = await pathForId(drive, params.id);
185
185
  const listing = await drive.list(path);
186
+ const caller = (0, ids_js_1.callerId)(request.subject);
186
187
  /**
187
188
  * A member's `uri` is the resource, not its path.
188
189
  *
@@ -198,8 +199,8 @@ exports.VIYA_HANDLERS = {
198
199
  name,
199
200
  type: 'folder',
200
201
  version: 1,
201
- createdBy: ids_js_1.EMULATED_USER.id,
202
- modifiedBy: ids_js_1.EMULATED_USER.id,
202
+ createdBy: caller,
203
+ modifiedBy: caller,
203
204
  creationTimeStamp: ids_js_1.EMULATED_NOW,
204
205
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
205
206
  parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(path)}`,
@@ -212,8 +213,8 @@ exports.VIYA_HANDLERS = {
212
213
  type: 'file',
213
214
  version: 1,
214
215
  contentType: 'text/plain',
215
- createdBy: ids_js_1.EMULATED_USER.id,
216
- modifiedBy: ids_js_1.EMULATED_USER.id,
216
+ createdBy: caller,
217
+ modifiedBy: caller,
217
218
  creationTimeStamp: ids_js_1.EMULATED_NOW,
218
219
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
219
220
  parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(path)}`,
@@ -252,7 +253,10 @@ exports.VIYA_HANDLERS = {
252
253
  : '/';
253
254
  const path = (0, ids_js_1.normalisePath)(`${parent}/${body.name}`);
254
255
  await drive.mkdir(path);
255
- return { status: 201, body: await folderBody(drive, path) };
256
+ return {
257
+ status: 201,
258
+ body: await folderBody(drive, path, (0, ids_js_1.callerId)(request.subject))
259
+ };
256
260
  },
257
261
  'PATCH /folders/folders/{}': async ({ services, request, params }) => {
258
262
  const drive = (0, ports_js_1.requireDrive)(services);
@@ -264,7 +268,7 @@ exports.VIYA_HANDLERS = {
264
268
  // shape the capture recorded for this verb. Both spellings arrive: the bin's
265
269
  // id, and the alias the emulator itself answers with
266
270
  if (isRecycleBin(body.parentFolderUri)) {
267
- const removed = await folderBody(drive, path);
271
+ const removed = await folderBody(drive, path, (0, ids_js_1.callerId)(request.subject));
268
272
  await drive.rmdir(path);
269
273
  // the answer describes the folder that was moved, not the drive root -
270
274
  // a client reads the id and parent from it
@@ -285,7 +289,10 @@ exports.VIYA_HANDLERS = {
285
289
  const target = (0, ids_js_1.normalisePath)(`${parent}/${name}`);
286
290
  if (target !== path)
287
291
  await drive.rename(path, target);
288
- return { status: 200, body: await folderBody(drive, target) };
292
+ return {
293
+ status: 200,
294
+ body: await folderBody(drive, target, (0, ids_js_1.callerId)(request.subject))
295
+ };
289
296
  },
290
297
  ...compute_js_1.COMPUTE_HANDLERS,
291
298
  ...files_js_1.FILE_HANDLERS