@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.
- package/build/browser.js +845 -68
- package/build/cjs/corpus/viya/operations.js +319 -1
- package/build/cjs/viya/compute.js +8 -6
- package/build/cjs/viya/files.js +21 -9
- package/build/cjs/viya/ids.js +13 -1
- package/build/cjs/viya/overlay.js +35 -0
- package/build/cjs/viya/service.js +29 -22
- package/build/cjs/viya/surface.js +7 -0
- package/build/cjs/viya/table.js +422 -9
- package/build/cjs/viya/unrecorded.js +0 -22
- package/build/esm/corpus/viya/operations.d.ts.map +1 -1
- package/build/esm/corpus/viya/operations.js +319 -1
- package/build/esm/viya/compute.d.ts +2 -1
- package/build/esm/viya/compute.d.ts.map +1 -1
- package/build/esm/viya/compute.js +9 -7
- package/build/esm/viya/files.d.ts +6 -1
- package/build/esm/viya/files.d.ts.map +1 -1
- package/build/esm/viya/files.js +22 -10
- package/build/esm/viya/ids.d.ts +12 -0
- package/build/esm/viya/ids.d.ts.map +1 -1
- package/build/esm/viya/ids.js +11 -0
- package/build/esm/viya/overlay.d.ts.map +1 -1
- package/build/esm/viya/overlay.js +35 -0
- package/build/esm/viya/service.d.ts +9 -1
- package/build/esm/viya/service.d.ts.map +1 -1
- package/build/esm/viya/service.js +30 -23
- package/build/esm/viya/surface.d.ts +11 -0
- package/build/esm/viya/surface.d.ts.map +1 -1
- package/build/esm/viya/surface.js +7 -0
- package/build/esm/viya/table.d.ts.map +1 -1
- package/build/esm/viya/table.js +422 -9
- package/build/esm/viya/unrecorded.d.ts.map +1 -1
- package/build/esm/viya/unrecorded.js +0 -22
- package/package.json +1 -1
|
@@ -206,6 +206,28 @@ export const VIYA_CORPUS = [
|
|
|
206
206
|
expected: 200,
|
|
207
207
|
shape: undefined
|
|
208
208
|
},
|
|
209
|
+
{
|
|
210
|
+
route: 'GET /compute/sessions/{}/variables/{}',
|
|
211
|
+
step: 'compute/execute-script',
|
|
212
|
+
queries: [],
|
|
213
|
+
statuses: [200],
|
|
214
|
+
expected: 200,
|
|
215
|
+
shape: {
|
|
216
|
+
links: [
|
|
217
|
+
{
|
|
218
|
+
href: 'string',
|
|
219
|
+
method: 'string',
|
|
220
|
+
rel: 'string',
|
|
221
|
+
type: 'string',
|
|
222
|
+
uri: 'string'
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
name: 'string',
|
|
226
|
+
scope: 'string',
|
|
227
|
+
value: 'string',
|
|
228
|
+
version: 'number'
|
|
229
|
+
}
|
|
230
|
+
},
|
|
209
231
|
{
|
|
210
232
|
route: 'POST /files/files',
|
|
211
233
|
step: 'files/create',
|
|
@@ -614,6 +636,264 @@ export const VIYA_CORPUS = [
|
|
|
614
636
|
version: 'number'
|
|
615
637
|
}
|
|
616
638
|
},
|
|
639
|
+
{
|
|
640
|
+
route: 'POST /jobDefinitions/definitions',
|
|
641
|
+
step: 'jobs/definition',
|
|
642
|
+
queries: ['parentFolderUri'],
|
|
643
|
+
statuses: [201],
|
|
644
|
+
expected: 201,
|
|
645
|
+
shape: {
|
|
646
|
+
code: 'string',
|
|
647
|
+
createdBy: 'string',
|
|
648
|
+
creationTimeStamp: 'string',
|
|
649
|
+
id: 'string',
|
|
650
|
+
links: [
|
|
651
|
+
{
|
|
652
|
+
href: 'string',
|
|
653
|
+
method: 'string',
|
|
654
|
+
rel: 'string',
|
|
655
|
+
type: 'string',
|
|
656
|
+
uri: 'string'
|
|
657
|
+
}
|
|
658
|
+
],
|
|
659
|
+
modifiedBy: 'string',
|
|
660
|
+
modifiedTimeStamp: 'string',
|
|
661
|
+
name: 'string',
|
|
662
|
+
parameters: [
|
|
663
|
+
{
|
|
664
|
+
defaultValue: 'string',
|
|
665
|
+
name: 'string',
|
|
666
|
+
required: 'boolean',
|
|
667
|
+
type: 'string',
|
|
668
|
+
version: 'number'
|
|
669
|
+
}
|
|
670
|
+
],
|
|
671
|
+
type: 'string',
|
|
672
|
+
version: 'number'
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
route: 'GET /jobDefinitions/definitions/{}',
|
|
677
|
+
step: 'jobs/execute',
|
|
678
|
+
queries: [],
|
|
679
|
+
statuses: [200],
|
|
680
|
+
expected: 200,
|
|
681
|
+
shape: {
|
|
682
|
+
code: 'string',
|
|
683
|
+
createdBy: 'string',
|
|
684
|
+
creationTimeStamp: 'string',
|
|
685
|
+
id: 'string',
|
|
686
|
+
links: [
|
|
687
|
+
{
|
|
688
|
+
href: 'string',
|
|
689
|
+
method: 'string',
|
|
690
|
+
rel: 'string',
|
|
691
|
+
type: 'string',
|
|
692
|
+
uri: 'string'
|
|
693
|
+
}
|
|
694
|
+
],
|
|
695
|
+
modifiedBy: 'string',
|
|
696
|
+
modifiedTimeStamp: 'string',
|
|
697
|
+
name: 'string',
|
|
698
|
+
parameters: [
|
|
699
|
+
{
|
|
700
|
+
defaultValue: 'string',
|
|
701
|
+
name: 'string',
|
|
702
|
+
required: 'boolean',
|
|
703
|
+
type: 'string',
|
|
704
|
+
version: 'number'
|
|
705
|
+
}
|
|
706
|
+
],
|
|
707
|
+
type: 'string',
|
|
708
|
+
version: 'number'
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
route: 'POST /jobExecution/jobs',
|
|
713
|
+
step: 'jobs/execute',
|
|
714
|
+
queries: ['_action'],
|
|
715
|
+
statuses: [201],
|
|
716
|
+
expected: 201,
|
|
717
|
+
shape: {
|
|
718
|
+
createdBy: 'string',
|
|
719
|
+
creationTimeStamp: 'string',
|
|
720
|
+
elapsedTime: 'number',
|
|
721
|
+
heartbeatInterval: 'number',
|
|
722
|
+
heartbeatTimeStamp: 'string',
|
|
723
|
+
id: 'string',
|
|
724
|
+
jobRequest: {
|
|
725
|
+
arguments: {
|
|
726
|
+
_DEBUG: 'string',
|
|
727
|
+
_OMITJSONLISTING: 'string',
|
|
728
|
+
_OMITJSONLOG: 'string',
|
|
729
|
+
_OMITTEXTLISTING: 'string',
|
|
730
|
+
_OMITTEXTLOG: 'string',
|
|
731
|
+
_addjesbeginendmacros: 'string',
|
|
732
|
+
_contextName: 'string',
|
|
733
|
+
_omitSessionResults: 'string',
|
|
734
|
+
_program: 'string',
|
|
735
|
+
_webin_file_count: 'string'
|
|
736
|
+
},
|
|
737
|
+
createdByApplication: 'string',
|
|
738
|
+
description: 'string',
|
|
739
|
+
jobDefinition: {
|
|
740
|
+
code: 'string',
|
|
741
|
+
createdBy: 'string',
|
|
742
|
+
creationTimeStamp: 'string',
|
|
743
|
+
id: 'string',
|
|
744
|
+
links: ['object'],
|
|
745
|
+
modifiedBy: 'string',
|
|
746
|
+
modifiedTimeStamp: 'string',
|
|
747
|
+
name: 'string',
|
|
748
|
+
parameters: ['object'],
|
|
749
|
+
type: 'string',
|
|
750
|
+
version: 'number'
|
|
751
|
+
},
|
|
752
|
+
name: 'string',
|
|
753
|
+
properties: 'array',
|
|
754
|
+
version: 'number'
|
|
755
|
+
},
|
|
756
|
+
links: [
|
|
757
|
+
{
|
|
758
|
+
href: 'string',
|
|
759
|
+
method: 'string',
|
|
760
|
+
rel: 'string',
|
|
761
|
+
type: 'string',
|
|
762
|
+
uri: 'string'
|
|
763
|
+
}
|
|
764
|
+
],
|
|
765
|
+
modifiedBy: 'string',
|
|
766
|
+
modifiedTimeStamp: 'string',
|
|
767
|
+
results: {},
|
|
768
|
+
state: 'string',
|
|
769
|
+
submittedByApplication: 'string',
|
|
770
|
+
version: 'number'
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
route: 'GET /jobExecution/jobs/{}',
|
|
775
|
+
step: 'jobs/execute',
|
|
776
|
+
queries: [],
|
|
777
|
+
statuses: [200],
|
|
778
|
+
expected: 200,
|
|
779
|
+
shape: {
|
|
780
|
+
createdBy: 'string',
|
|
781
|
+
creationTimeStamp: 'string',
|
|
782
|
+
elapsedTime: 'number',
|
|
783
|
+
endTimeStamp: 'string',
|
|
784
|
+
heartbeatInterval: 'number',
|
|
785
|
+
heartbeatTimeStamp: 'string',
|
|
786
|
+
id: 'string',
|
|
787
|
+
jobRequest: {
|
|
788
|
+
arguments: {
|
|
789
|
+
_DEBUG: 'string',
|
|
790
|
+
_OMITJSONLISTING: 'string',
|
|
791
|
+
_OMITJSONLOG: 'string',
|
|
792
|
+
_OMITTEXTLISTING: 'string',
|
|
793
|
+
_OMITTEXTLOG: 'string',
|
|
794
|
+
_addjesbeginendmacros: 'string',
|
|
795
|
+
_contextName: 'string',
|
|
796
|
+
_omitSessionResults: 'string',
|
|
797
|
+
_program: 'string',
|
|
798
|
+
_webin_file_count: 'string'
|
|
799
|
+
},
|
|
800
|
+
createdByApplication: 'string',
|
|
801
|
+
description: 'string',
|
|
802
|
+
jobDefinition: {
|
|
803
|
+
code: 'string',
|
|
804
|
+
createdBy: 'string',
|
|
805
|
+
creationTimeStamp: 'string',
|
|
806
|
+
id: 'string',
|
|
807
|
+
links: ['object'],
|
|
808
|
+
modifiedBy: 'string',
|
|
809
|
+
modifiedTimeStamp: 'string',
|
|
810
|
+
name: 'string',
|
|
811
|
+
parameters: ['object'],
|
|
812
|
+
type: 'string',
|
|
813
|
+
version: 'number'
|
|
814
|
+
},
|
|
815
|
+
name: 'string',
|
|
816
|
+
properties: 'array',
|
|
817
|
+
version: 'number'
|
|
818
|
+
},
|
|
819
|
+
links: [
|
|
820
|
+
{
|
|
821
|
+
href: 'string',
|
|
822
|
+
method: 'string',
|
|
823
|
+
rel: 'string',
|
|
824
|
+
type: 'string',
|
|
825
|
+
uri: 'string'
|
|
826
|
+
}
|
|
827
|
+
],
|
|
828
|
+
logLocation: 'string',
|
|
829
|
+
modifiedBy: 'string',
|
|
830
|
+
modifiedTimeStamp: 'string',
|
|
831
|
+
results: {
|
|
832
|
+
COMPUTE_CONTEXT: 'string',
|
|
833
|
+
COMPUTE_JOB: 'string',
|
|
834
|
+
COMPUTE_SESSION: 'string',
|
|
835
|
+
'{}.log': 'string',
|
|
836
|
+
'{}.log.txt': 'string'
|
|
837
|
+
},
|
|
838
|
+
state: 'string',
|
|
839
|
+
submittedByApplication: 'string',
|
|
840
|
+
version: 'number'
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
route: 'GET /jobExecution/jobs/{}/state',
|
|
845
|
+
step: 'jobs/execute',
|
|
846
|
+
queries: ['_action', 'wait'],
|
|
847
|
+
statuses: [200],
|
|
848
|
+
expected: 200,
|
|
849
|
+
shape: undefined
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
route: 'GET /launcher/contexts',
|
|
853
|
+
step: 'compute/launcher-contexts',
|
|
854
|
+
queries: ['limit'],
|
|
855
|
+
statuses: [200],
|
|
856
|
+
expected: 200,
|
|
857
|
+
shape: {
|
|
858
|
+
accept: 'string',
|
|
859
|
+
count: 'number',
|
|
860
|
+
items: [
|
|
861
|
+
{
|
|
862
|
+
createdBy: 'string',
|
|
863
|
+
creationTimeStamp: 'string',
|
|
864
|
+
description: 'string',
|
|
865
|
+
id: 'string',
|
|
866
|
+
links: [
|
|
867
|
+
{
|
|
868
|
+
href: 'string',
|
|
869
|
+
method: 'string',
|
|
870
|
+
rel: 'string',
|
|
871
|
+
type: 'string',
|
|
872
|
+
uri: 'string'
|
|
873
|
+
}
|
|
874
|
+
],
|
|
875
|
+
modifiedBy: 'string',
|
|
876
|
+
modifiedTimeStamp: 'string',
|
|
877
|
+
name: 'string',
|
|
878
|
+
type: 'string',
|
|
879
|
+
version: 'number'
|
|
880
|
+
}
|
|
881
|
+
],
|
|
882
|
+
limit: 'number',
|
|
883
|
+
links: [
|
|
884
|
+
{
|
|
885
|
+
href: 'string',
|
|
886
|
+
method: 'string',
|
|
887
|
+
rel: 'string',
|
|
888
|
+
type: 'string',
|
|
889
|
+
uri: 'string'
|
|
890
|
+
}
|
|
891
|
+
],
|
|
892
|
+
name: 'string',
|
|
893
|
+
start: 'number',
|
|
894
|
+
version: 'number'
|
|
895
|
+
}
|
|
896
|
+
},
|
|
617
897
|
{
|
|
618
898
|
route: 'POST /SASLogon/oauth/token',
|
|
619
899
|
step: 'auth/token-refresh',
|
|
@@ -639,6 +919,44 @@ export const VIYA_CORPUS = [
|
|
|
639
919
|
queries: ['limit'],
|
|
640
920
|
statuses: [200],
|
|
641
921
|
expected: 200,
|
|
642
|
-
shape:
|
|
922
|
+
shape: {
|
|
923
|
+
accept: 'string',
|
|
924
|
+
count: 'number',
|
|
925
|
+
items: [
|
|
926
|
+
{
|
|
927
|
+
description: 'string',
|
|
928
|
+
iconUri: 'string',
|
|
929
|
+
label: 'string',
|
|
930
|
+
links: [
|
|
931
|
+
{
|
|
932
|
+
href: 'string',
|
|
933
|
+
method: 'string',
|
|
934
|
+
rel: 'string',
|
|
935
|
+
type: 'string',
|
|
936
|
+
uri: 'string'
|
|
937
|
+
}
|
|
938
|
+
],
|
|
939
|
+
mediaType: 'string',
|
|
940
|
+
name: 'string',
|
|
941
|
+
resourceUri: 'string',
|
|
942
|
+
tags: ['string'],
|
|
943
|
+
version: 'number'
|
|
944
|
+
}
|
|
945
|
+
],
|
|
946
|
+
limit: 'number',
|
|
947
|
+
links: [
|
|
948
|
+
{
|
|
949
|
+
href: 'string',
|
|
950
|
+
itemType: 'string',
|
|
951
|
+
method: 'string',
|
|
952
|
+
rel: 'string',
|
|
953
|
+
type: 'string',
|
|
954
|
+
uri: 'string'
|
|
955
|
+
}
|
|
956
|
+
],
|
|
957
|
+
name: 'string',
|
|
958
|
+
start: 'number',
|
|
959
|
+
version: 'number'
|
|
960
|
+
}
|
|
643
961
|
}
|
|
644
962
|
];
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* name, so a session can be created for the id the list returned.
|
|
14
14
|
*/
|
|
15
15
|
import type { ApiResponse, Services } from '../host/dispatch.js';
|
|
16
|
+
import type { Subject } from '../identity/types.js';
|
|
16
17
|
/**
|
|
17
18
|
* The name the emulator answers when a client asks for no particular context.
|
|
18
19
|
*
|
|
@@ -41,7 +42,7 @@ export declare const COMPUTE_HANDLERS: Record<string, (context: {
|
|
|
41
42
|
query?: Record<string, string | undefined>;
|
|
42
43
|
body?: unknown;
|
|
43
44
|
token?: string;
|
|
44
|
-
subject?:
|
|
45
|
+
subject?: Subject;
|
|
45
46
|
};
|
|
46
47
|
params: Record<string, string>;
|
|
47
48
|
}) => Promise<ApiResponse>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../src/viya/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../src/viya/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAOnD;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sCAAsC,CAAA;AAEvE,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,QAAuC,CAAA;AA+CvE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,GAAG,SAAS,KAAG,MAM5D,CAAA;AAgHD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN,CAAC,OAAO,EAAE;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,KAAK,OAAO,CAAC,WAAW,CAAC,CAyM3B,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { ApiError } from '../types.js';
|
|
|
2
2
|
import { normaliseServerUrl } from './seed.js';
|
|
3
3
|
import { seedOf } from './seed.js';
|
|
4
4
|
import { estateFor } from './sessions.js';
|
|
5
|
-
import {
|
|
5
|
+
import { idFor, callerId } from './ids.js';
|
|
6
6
|
/**
|
|
7
7
|
* The name the emulator answers when a client asks for no particular context.
|
|
8
8
|
*
|
|
@@ -66,20 +66,20 @@ export const contextNameFrom = (filter) => {
|
|
|
66
66
|
const match = /name\s*,\s*'([^']*)'|name\s*,\s*"([^"]*)"/i.exec(filter);
|
|
67
67
|
return match?.[1] ?? match?.[2] ?? DEFAULT_CONTEXT_NAME;
|
|
68
68
|
};
|
|
69
|
-
const contextBody = (name) => ({
|
|
69
|
+
const contextBody = (name, caller) => ({
|
|
70
70
|
id: EMULATED_CONTEXT_ID,
|
|
71
71
|
name,
|
|
72
|
-
createdBy:
|
|
72
|
+
createdBy: caller,
|
|
73
73
|
version: 2,
|
|
74
74
|
links: linksFor(`/compute/contexts/${EMULATED_CONTEXT_ID}`, 'application/vnd.sas.compute.context')
|
|
75
75
|
});
|
|
76
|
-
const sessionBody = (services, session, autoExecLines) => {
|
|
76
|
+
const sessionBody = (services, session, autoExecLines, caller) => {
|
|
77
77
|
const { id } = session;
|
|
78
78
|
const uri = `/compute/sessions/${id}`;
|
|
79
79
|
return {
|
|
80
80
|
id,
|
|
81
81
|
applicationName: 'emulated',
|
|
82
|
-
owner:
|
|
82
|
+
owner: caller,
|
|
83
83
|
serverId: idFor(normaliseServerUrl(services.viya?.serverUrl) || 'emulated', 'server'),
|
|
84
84
|
state: 'idle',
|
|
85
85
|
attributes: {
|
|
@@ -165,7 +165,9 @@ export const COMPUTE_HANDLERS = {
|
|
|
165
165
|
limit,
|
|
166
166
|
count: 1,
|
|
167
167
|
version: 2,
|
|
168
|
-
items: [
|
|
168
|
+
items: [
|
|
169
|
+
contextBody(contextNameFrom(request.query?.filter), callerId(request.subject))
|
|
170
|
+
],
|
|
169
171
|
links: linksFor('/compute/contexts', 'application/vnd.sas.compute.context', true)
|
|
170
172
|
}
|
|
171
173
|
};
|
|
@@ -177,7 +179,7 @@ export const COMPUTE_HANDLERS = {
|
|
|
177
179
|
const session = estateOf(services).create();
|
|
178
180
|
return {
|
|
179
181
|
status: 201,
|
|
180
|
-
body: sessionBody(services, session, body.environment?.autoExecLines ?? [])
|
|
182
|
+
body: sessionBody(services, session, body.environment?.autoExecLines ?? [], callerId(request.subject))
|
|
181
183
|
};
|
|
182
184
|
},
|
|
183
185
|
'GET /compute/sessions/{}/state': async ({ services, params }) => {
|
|
@@ -8,8 +8,13 @@
|
|
|
8
8
|
*
|
|
9
9
|
* A file id is derived from its path, like a folder id: a client stores the id an
|
|
10
10
|
* upload answered and asks for it later, so the id cannot move between runs.
|
|
11
|
+
*
|
|
12
|
+
* `createdBy`, `modifiedBy` and `properties.typeRegistrant` name the asking
|
|
13
|
+
* caller, not the account that uploaded the bytes - the drive stores contents,
|
|
14
|
+
* not authorship. See `service.ts` for why that is the honest answer here.
|
|
11
15
|
*/
|
|
12
16
|
import type { ApiResponse, Services } from '../host/dispatch.js';
|
|
17
|
+
import type { Subject } from '../identity/types.js';
|
|
13
18
|
/** What an upload answers about itself, whichever operation asked. */
|
|
14
19
|
export interface EmulatedFile {
|
|
15
20
|
name: string;
|
|
@@ -27,7 +32,7 @@ export declare const FILE_HANDLERS: Record<string, (context: {
|
|
|
27
32
|
contents: string | Uint8Array;
|
|
28
33
|
};
|
|
29
34
|
token?: string;
|
|
30
|
-
subject?:
|
|
35
|
+
subject?: Subject;
|
|
31
36
|
};
|
|
32
37
|
params: Record<string, string>;
|
|
33
38
|
}) => Promise<ApiResponse>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/viya/files.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/viya/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAOnD,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AA4KD,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,MAAM,EACN,CAAC,OAAO,EAAE;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;QAC9B,IAAI,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;SAAE,CAAA;QACtD,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,KAAK,OAAO,CAAC,WAAW,CAAC,CA6F3B,CAAA"}
|
package/build/esm/viya/files.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiError } from '../types.js';
|
|
2
2
|
import { requireDrive } from './ports.js';
|
|
3
|
-
import { EMULATED_NOW,
|
|
3
|
+
import { EMULATED_NOW, idFor, callerId } from './ids.js';
|
|
4
4
|
const contentTypeOf = (name) => {
|
|
5
5
|
if (/\.sas$/i.test(name))
|
|
6
6
|
return 'text/plain';
|
|
@@ -23,7 +23,7 @@ const contentTypeOf = (name) => {
|
|
|
23
23
|
* client reads rather than placeholders: the three `content.*` flags say what can
|
|
24
24
|
* be done with the file, and `typeRegistrant` says who registered the type.
|
|
25
25
|
*/
|
|
26
|
-
const fileBody = (file) => {
|
|
26
|
+
const fileBody = (file, caller) => {
|
|
27
27
|
const id = idFor(file.path, 'file');
|
|
28
28
|
const uri = `/files/files/${id}`;
|
|
29
29
|
const contentType = contentTypeOf(file.name);
|
|
@@ -38,8 +38,8 @@ const fileBody = (file) => {
|
|
|
38
38
|
fileVersion: 1,
|
|
39
39
|
version: 2,
|
|
40
40
|
typeDefName: 'file',
|
|
41
|
-
createdBy:
|
|
42
|
-
modifiedBy:
|
|
41
|
+
createdBy: caller,
|
|
42
|
+
modifiedBy: caller,
|
|
43
43
|
creationTimeStamp: EMULATED_NOW,
|
|
44
44
|
modifiedTimeStamp: EMULATED_NOW,
|
|
45
45
|
quarantine: false,
|
|
@@ -51,7 +51,7 @@ const fileBody = (file) => {
|
|
|
51
51
|
'content.openInBrowser': 'true',
|
|
52
52
|
'content.preview': 'false',
|
|
53
53
|
sasIconKey: 'file',
|
|
54
|
-
typeRegistrant:
|
|
54
|
+
typeRegistrant: caller
|
|
55
55
|
},
|
|
56
56
|
links: [
|
|
57
57
|
{
|
|
@@ -147,12 +147,18 @@ export const FILE_HANDLERS = {
|
|
|
147
147
|
const parent = await parentOf(drive, request.query?.parentFolderUri);
|
|
148
148
|
const path = `${parent}/${upload.name}`.replace(/\/{2,}/g, '/');
|
|
149
149
|
await drive.save(path, upload.contents);
|
|
150
|
-
return {
|
|
150
|
+
return {
|
|
151
|
+
status: 201,
|
|
152
|
+
body: fileBody(await bodyOf(drive, path), callerId(request.subject))
|
|
153
|
+
};
|
|
151
154
|
},
|
|
152
|
-
'GET /files/files/{}': async ({ services, params }) => {
|
|
155
|
+
'GET /files/files/{}': async ({ services, params, request }) => {
|
|
153
156
|
const drive = requireDrive(services);
|
|
154
157
|
const path = await pathForFileId(drive, params.id);
|
|
155
|
-
return {
|
|
158
|
+
return {
|
|
159
|
+
status: 200,
|
|
160
|
+
body: fileBody(await bodyOf(drive, path), callerId(request.subject))
|
|
161
|
+
};
|
|
156
162
|
},
|
|
157
163
|
'PATCH /files/files/{}': async ({ services, params, request }) => {
|
|
158
164
|
const drive = requireDrive(services);
|
|
@@ -162,7 +168,10 @@ export const FILE_HANDLERS = {
|
|
|
162
168
|
const target = `${path.split('/').slice(0, -1).join('/')}/${name}`.replace(/\/{2,}/g, '/');
|
|
163
169
|
if (target !== path)
|
|
164
170
|
await drive.rename(path, target);
|
|
165
|
-
return {
|
|
171
|
+
return {
|
|
172
|
+
status: 200,
|
|
173
|
+
body: fileBody(await bodyOf(drive, target), callerId(request.subject))
|
|
174
|
+
};
|
|
166
175
|
},
|
|
167
176
|
'GET /files/files/{}/content': async ({ services, params }) => {
|
|
168
177
|
const drive = requireDrive(services);
|
|
@@ -195,6 +204,9 @@ export const FILE_HANDLERS = {
|
|
|
195
204
|
if (contents === undefined || contents === null)
|
|
196
205
|
throw new ApiError(400, 'File content is required.');
|
|
197
206
|
await drive.update(path, contents);
|
|
198
|
-
return {
|
|
207
|
+
return {
|
|
208
|
+
status: 200,
|
|
209
|
+
body: fileBody(await bodyOf(drive, path), callerId(request.subject))
|
|
210
|
+
};
|
|
199
211
|
}
|
|
200
212
|
};
|
package/build/esm/viya/ids.d.ts
CHANGED
|
@@ -13,6 +13,18 @@ export declare const EMULATED_USER: {
|
|
|
13
13
|
id: string;
|
|
14
14
|
name: string;
|
|
15
15
|
};
|
|
16
|
+
import type { Subject } from '../identity/types.js';
|
|
17
|
+
/**
|
|
18
|
+
* The id the emulated estate reports as the caller.
|
|
19
|
+
*
|
|
20
|
+
* A host that resolved the caller before dispatching - the server's signed-in
|
|
21
|
+
* account - passes it as `subject`; a host with no identity (the browser worker)
|
|
22
|
+
* passes none, and the fallback names itself, so the answer says on its face that
|
|
23
|
+
* no account was resolved. Bodies that carry `createdBy`, `modifiedBy` or `owner`
|
|
24
|
+
* use this, so an application that reads its own name back is told the account it
|
|
25
|
+
* signed in with.
|
|
26
|
+
*/
|
|
27
|
+
export declare const callerId: (subject?: Subject) => string;
|
|
16
28
|
/**
|
|
17
29
|
* A uuid shape from a string, deterministically.
|
|
18
30
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/viya/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sEAAsE;AACtE,eAAO,MAAM,YAAY,6BAA6B,CAAA;AAEtD,4EAA4E;AAC5E,eAAO,MAAM,aAAa;;;CAAiD,CAAA;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,aAAe,KAAG,MAyBrD,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAI5C,CAAA"}
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/viya/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sEAAsE;AACtE,eAAO,MAAM,YAAY,6BAA6B,CAAA;AAEtD,4EAA4E;AAC5E,eAAO,MAAM,aAAa;;;CAAiD,CAAA;AAE3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAU,OAAO,KAAG,MACR,CAAA;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,aAAe,KAAG,MAyBrD,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAI5C,CAAA"}
|
package/build/esm/viya/ids.js
CHANGED
|
@@ -10,6 +10,17 @@
|
|
|
10
10
|
export const EMULATED_NOW = '2026-01-01T00:00:00.000Z';
|
|
11
11
|
/** The caller the emulated estate reports when a host does not name one. */
|
|
12
12
|
export const EMULATED_USER = { id: 'emulated-user', name: 'Emulated User' };
|
|
13
|
+
/**
|
|
14
|
+
* The id the emulated estate reports as the caller.
|
|
15
|
+
*
|
|
16
|
+
* A host that resolved the caller before dispatching - the server's signed-in
|
|
17
|
+
* account - passes it as `subject`; a host with no identity (the browser worker)
|
|
18
|
+
* passes none, and the fallback names itself, so the answer says on its face that
|
|
19
|
+
* no account was resolved. Bodies that carry `createdBy`, `modifiedBy` or `owner`
|
|
20
|
+
* use this, so an application that reads its own name back is told the account it
|
|
21
|
+
* signed in with.
|
|
22
|
+
*/
|
|
23
|
+
export const callerId = (subject) => subject?.userId ?? EMULATED_USER.id;
|
|
13
24
|
/**
|
|
14
25
|
* A uuid shape from a string, deterministically.
|
|
15
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/viya/overlay.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAA;IACpB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/viya/overlay.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAA;IACpB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAuBD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAgEzD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACzC,aAAY,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAmB,KAClD,IAcF,CAAA"}
|
|
@@ -20,6 +20,15 @@ import { VIYA_OPERATIONS } from './declared.js';
|
|
|
20
20
|
* a second answer to the same question.
|
|
21
21
|
*/
|
|
22
22
|
const NEEDS_AUTH = 'The token endpoint is answered by the host that mounts the emulator, which owns the token port.';
|
|
23
|
+
/**
|
|
24
|
+
* The job family is a capture without a handler.
|
|
25
|
+
*
|
|
26
|
+
* The deploy-and-run path is recorded - a service pack deploy creates a job
|
|
27
|
+
* definition and submits it - and this package answers the compute and content
|
|
28
|
+
* families, not that one. Saying so is the difference between a client learning
|
|
29
|
+
* what is missing and a client learning nothing.
|
|
30
|
+
*/
|
|
31
|
+
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.';
|
|
23
32
|
export const VIYA_OVERLAY = {
|
|
24
33
|
// answered here
|
|
25
34
|
'POST /folders/folders': { implemented: true },
|
|
@@ -45,6 +54,32 @@ export const VIYA_OVERLAY = {
|
|
|
45
54
|
'PATCH /files/files/{}': { implemented: true },
|
|
46
55
|
'GET /files/files/{}/content': { implemented: true },
|
|
47
56
|
'PUT /files/files/{}/content': { implemented: true },
|
|
57
|
+
// declined: the job family needs a job service
|
|
58
|
+
//
|
|
59
|
+
// A capture describes what the estate answers on the deploy-and-run path, and
|
|
60
|
+
// the emulator does not answer that path yet: a client that deploys a service
|
|
61
|
+
// pack against an emulated estate stops here, with a reason rather than a 404.
|
|
62
|
+
'POST /jobDefinitions/definitions': {
|
|
63
|
+
implemented: false,
|
|
64
|
+
reason: NEEDS_JOBS
|
|
65
|
+
},
|
|
66
|
+
'GET /jobDefinitions/definitions/{}': {
|
|
67
|
+
implemented: false,
|
|
68
|
+
reason: NEEDS_JOBS
|
|
69
|
+
},
|
|
70
|
+
'POST /jobExecution/jobs': { implemented: false, reason: NEEDS_JOBS },
|
|
71
|
+
'GET /jobExecution/jobs/{}': { implemented: false, reason: NEEDS_JOBS },
|
|
72
|
+
'GET /jobExecution/jobs/{}/state': { implemented: false, reason: NEEDS_JOBS },
|
|
73
|
+
// declined: contexts come from the seed, not from the launcher
|
|
74
|
+
'GET /launcher/contexts': {
|
|
75
|
+
implemented: false,
|
|
76
|
+
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.'
|
|
77
|
+
},
|
|
78
|
+
// declined: session variables are not modelled
|
|
79
|
+
'GET /compute/sessions/{}/variables/{}': {
|
|
80
|
+
implemented: false,
|
|
81
|
+
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.'
|
|
82
|
+
},
|
|
48
83
|
// declined: the host owns the token port
|
|
49
84
|
'POST /SASLogon/oauth/token': { implemented: false, reason: NEEDS_AUTH },
|
|
50
85
|
// declared, not captured: the webout an application's service returns
|
|
@@ -12,8 +12,16 @@
|
|
|
12
12
|
* the same id on every host and every run. That is the seed rule applied to the
|
|
13
13
|
* one thing the emulator cannot invent per request: a client stores a folder id
|
|
14
14
|
* and asks for it later.
|
|
15
|
+
*
|
|
16
|
+
* Authorship is the ASKING caller, not the object's creator. The drive stores
|
|
17
|
+
* paths and contents, not who wrote them, so `createdBy`, `modifiedBy` and a
|
|
18
|
+
* session's `owner` name whoever made the request - a second caller reading the
|
|
19
|
+
* same folder is told it created it. Persisting the creator would mean the drive
|
|
20
|
+
* carrying an owner, which is a wider change than an emulator should force; the
|
|
21
|
+
* bodies say the one thing they can say honestly, which is who is asking.
|
|
15
22
|
*/
|
|
16
23
|
import type { ApiResponse, Services } from '../host/dispatch.js';
|
|
24
|
+
import type { Subject } from '../identity/types.js';
|
|
17
25
|
/** The handlers, keyed by the operation id the table states. */
|
|
18
26
|
export declare const VIYA_HANDLERS: Record<string, (context: {
|
|
19
27
|
services: Services;
|
|
@@ -21,7 +29,7 @@ export declare const VIYA_HANDLERS: Record<string, (context: {
|
|
|
21
29
|
query?: Record<string, string | undefined>;
|
|
22
30
|
body?: unknown;
|
|
23
31
|
token?: string;
|
|
24
|
-
subject?:
|
|
32
|
+
subject?: Subject;
|
|
25
33
|
};
|
|
26
34
|
params: Record<string, string>;
|
|
27
35
|
}) => Promise<ApiResponse>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/viya/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/viya/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AA6InD,gEAAgE;AAChE,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,MAAM,EACN,CAAC,OAAO,EAAE;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,KAAK,OAAO,CAAC,WAAW,CAAC,CAwP3B,CAAA"}
|