@sasjs/api 0.33.0 → 0.35.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.
Files changed (37) hide show
  1. package/build/browser.js +1962 -50
  2. package/build/cjs/corpus/viya/operations.js +647 -0
  3. package/build/cjs/index.js +60 -40
  4. package/build/cjs/viya/dispatch.js +141 -0
  5. package/build/cjs/viya/overlay.js +104 -0
  6. package/build/cjs/viya/service.js +317 -0
  7. package/build/cjs/viya/surface.js +1 -49
  8. package/build/cjs/viya/table.js +805 -0
  9. package/build/cjs/viya/unrecorded.js +58 -0
  10. package/build/cjs/viya/version.js +43 -0
  11. package/build/esm/corpus/viya/operations.d.ts +28 -0
  12. package/build/esm/corpus/viya/operations.d.ts.map +1 -0
  13. package/build/esm/corpus/viya/operations.js +644 -0
  14. package/build/esm/index.d.ts +12 -0
  15. package/build/esm/index.d.ts.map +1 -1
  16. package/build/esm/index.js +7 -0
  17. package/build/esm/viya/dispatch.d.ts +35 -0
  18. package/build/esm/viya/dispatch.d.ts.map +1 -0
  19. package/build/esm/viya/dispatch.js +136 -0
  20. package/build/esm/viya/overlay.d.ts +25 -0
  21. package/build/esm/viya/overlay.d.ts.map +1 -0
  22. package/build/esm/viya/overlay.js +100 -0
  23. package/build/esm/viya/service.d.ts +44 -0
  24. package/build/esm/viya/service.d.ts.map +1 -0
  25. package/build/esm/viya/service.js +313 -0
  26. package/build/esm/viya/surface.d.ts.map +1 -1
  27. package/build/esm/viya/surface.js +1 -49
  28. package/build/esm/viya/table.d.ts +39 -0
  29. package/build/esm/viya/table.d.ts.map +1 -0
  30. package/build/esm/viya/table.js +802 -0
  31. package/build/esm/viya/unrecorded.d.ts +24 -0
  32. package/build/esm/viya/unrecorded.d.ts.map +1 -0
  33. package/build/esm/viya/unrecorded.js +55 -0
  34. package/build/esm/viya/version.d.ts +37 -0
  35. package/build/esm/viya/version.d.ts.map +1 -0
  36. package/build/esm/viya/version.js +39 -0
  37. package/package.json +3 -1
package/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.33.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.35.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;
@@ -46,6 +46,8 @@ var SASjsApi = (() => {
46
46
  DIRECTORY_CORPUS: () => DIRECTORY_CORPUS,
47
47
  DOCUMENTED_RUN_TIMES: () => DOCUMENTED_RUN_TIMES,
48
48
  DRIVE_CORPUS: () => DRIVE_CORPUS,
49
+ EMULATED_HEADER: () => EMULATED_HEADER,
50
+ EMULATED_HEADER_VALUE: () => EMULATED_HEADER_VALUE,
49
51
  HANDLED_ROUTES: () => HANDLED_ROUTES,
50
52
  HOME_CORPUS: () => HOME_CORPUS,
51
53
  IDENTITY_CORPUS: () => IDENTITY_CORPUS,
@@ -70,6 +72,13 @@ var SASjsApi = (() => {
70
72
  SURFACE_ADAPTER_VERSION: () => SURFACE_ADAPTER_VERSION,
71
73
  TAG_CAPABILITIES: () => TAG_CAPABILITIES,
72
74
  TOP_LEVEL_ROUTES: () => TOP_LEVEL_ROUTES,
75
+ UNRECORDED: () => UNRECORDED,
76
+ VIYA_CAPTURED_AT: () => VIYA_CAPTURED_AT,
77
+ VIYA_CORPUS: () => VIYA_CORPUS,
78
+ VIYA_HANDLERS: () => VIYA_HANDLERS,
79
+ VIYA_OVERLAY: () => VIYA_OVERLAY,
80
+ VIYA_TABLE: () => VIYA_TABLE,
81
+ VIYA_TARGET_VERSION: () => VIYA_TARGET_VERSION,
73
82
  appSummary: () => appSummary,
74
83
  basename: () => basename,
75
84
  cacheControlFor: () => cacheControlFor,
@@ -95,8 +104,11 @@ var SASjsApi = (() => {
95
104
  deployTree: () => deployTree,
96
105
  dirname: () => dirname,
97
106
  dispatch: () => dispatch,
107
+ dispatchViya: () => dispatchViya,
108
+ emulatedHeaders: () => emulatedHeaders,
98
109
  escapeHtml: () => escapeHtml,
99
110
  findRoute: () => findRoute,
111
+ findViyaOperation: () => findViyaOperation,
100
112
  hasBlockedExtension: () => hasBlockedExtension,
101
113
  isApiError: () => isApiError,
102
114
  isAppId: () => isAppId,
@@ -3209,35 +3221,11 @@ var SASjsApi = (() => {
3209
3221
  var SURFACE_ADAPTER_VERSION = "6.0.2";
3210
3222
  var SURFACE = [
3211
3223
  // sas9
3212
- {
3213
- path: "/Public/example/deleteThis",
3214
- family: "sas9",
3215
- decision: "declined",
3216
- reason: "a path in a doc example or a default config value, not a call"
3217
- },
3218
- {
3219
- path: "/Public/example/myFolder",
3220
- family: "sas9",
3221
- decision: "declined",
3222
- reason: "a path in a doc example or a default config value, not a call"
3223
- },
3224
- {
3225
- path: "/Public/newDestination",
3226
- family: "sas9",
3227
- decision: "declined",
3228
- reason: "a path in a doc example or a default config value, not a call"
3229
- },
3230
- {
3231
- path: "/Public/newDestination/myFolder",
3232
- family: "sas9",
3233
- decision: "declined",
3234
- reason: "a path in a doc example or a default config value, not a call"
3235
- },
3236
3224
  {
3237
3225
  path: "/Public/seedapp",
3238
3226
  family: "sas9",
3239
3227
  decision: "declined",
3240
- reason: "a path in a doc example or a default config value, not a call"
3228
+ reason: "a default config value the client falls back to, not a call"
3241
3229
  },
3242
3230
  {
3243
3231
  path: "/SASJobExecution",
@@ -3252,12 +3240,6 @@ var SASjsApi = (() => {
3252
3240
  decision: "in",
3253
3241
  reason: "the auth flow the client speaks, and the reason the emulated paths cannot be renamed"
3254
3242
  },
3255
- {
3256
- path: "/SASLogon/home",
3257
- family: "viya-auth",
3258
- decision: "in",
3259
- reason: "the auth flow the client speaks, and the reason the emulated paths cannot be renamed"
3260
- },
3261
3243
  {
3262
3244
  path: "/SASLogon/login",
3263
3245
  family: "viya-auth",
@@ -3320,12 +3302,6 @@ var SASjsApi = (() => {
3320
3302
  decision: "declined",
3321
3303
  reason: "the SASjs API surface, answered by the server's own registered routes, not by a Viya-shaped one"
3322
3304
  },
3323
- {
3324
- path: "/SASjsApi/{}",
3325
- family: "sasjs-api",
3326
- decision: "declined",
3327
- reason: "the SASjs API surface, answered by the server's own registered routes, not by a Viya-shaped one"
3328
- },
3329
3305
  // sas9
3330
3306
  {
3331
3307
  path: "/User Folders/{}/My Folder/sasjs/runner",
@@ -3334,18 +3310,6 @@ var SASjsApi = (() => {
3334
3310
  reason: "SAS 9 and SASjs surfaces: the emulator answers Viya, and the same client reaches these on an EBI deployment"
3335
3311
  },
3336
3312
  // sasjs-api
3337
- {
3338
- path: "/api",
3339
- family: "sasjs-api",
3340
- decision: "declined",
3341
- reason: "the SASjs API surface, answered by the server's own registered routes, not by a Viya-shaped one"
3342
- },
3343
- {
3344
- path: "/api/stp/execute",
3345
- family: "sasjs-api",
3346
- decision: "declined",
3347
- reason: "the SASjs API surface, answered by the server's own registered routes, not by a Viya-shaped one"
3348
- },
3349
3313
  {
3350
3314
  path: "/auth/refresh",
3351
3315
  family: "sasjs-api",
@@ -3564,6 +3528,1954 @@ var SASjsApi = (() => {
3564
3528
  }
3565
3529
  ];
3566
3530
 
3531
+ // src/viya/table.ts
3532
+ var VIYA_TABLE = [
3533
+ {
3534
+ id: "GET /compute/contexts",
3535
+ method: "GET",
3536
+ path: "/compute/contexts",
3537
+ steps: [
3538
+ "compute/context-by-name",
3539
+ "compute/contexts",
3540
+ "compute/execute-script",
3541
+ "compute/session-create"
3542
+ ],
3543
+ statuses: [200],
3544
+ queries: ["filter", "limit"],
3545
+ request: {
3546
+ queries: ["filter", "limit"],
3547
+ body: void 0
3548
+ },
3549
+ shape: {
3550
+ accept: "string",
3551
+ count: "number",
3552
+ items: [
3553
+ {
3554
+ createdBy: "string",
3555
+ id: "string",
3556
+ links: [
3557
+ {
3558
+ href: "string",
3559
+ method: "string",
3560
+ rel: "string",
3561
+ type: "string",
3562
+ uri: "string"
3563
+ }
3564
+ ],
3565
+ name: "string",
3566
+ version: "number"
3567
+ }
3568
+ ],
3569
+ limit: "number",
3570
+ links: [
3571
+ {
3572
+ href: "string",
3573
+ itemType: "string",
3574
+ method: "string",
3575
+ rel: "string",
3576
+ type: "string",
3577
+ uri: "string"
3578
+ }
3579
+ ],
3580
+ name: "string",
3581
+ start: "number",
3582
+ version: "number"
3583
+ }
3584
+ },
3585
+ {
3586
+ id: "POST /compute/contexts/{}/sessions",
3587
+ method: "POST",
3588
+ path: "/compute/contexts/{}/sessions",
3589
+ steps: ["compute/execute-script", "compute/session-create"],
3590
+ statuses: [201],
3591
+ queries: [],
3592
+ request: {
3593
+ queries: [],
3594
+ body: {}
3595
+ },
3596
+ shape: {
3597
+ applicationName: "string",
3598
+ attributes: {
3599
+ homeDirectory: "string",
3600
+ sessionInactiveTimeout: "number"
3601
+ },
3602
+ creationTimeStamp: "string",
3603
+ environment: {
3604
+ autoExecLines: ["string"]
3605
+ },
3606
+ id: "string",
3607
+ links: [
3608
+ {
3609
+ href: "string",
3610
+ method: "string",
3611
+ rel: "string",
3612
+ type: "string",
3613
+ uri: "string"
3614
+ }
3615
+ ],
3616
+ owner: "string",
3617
+ serverId: "string",
3618
+ serviceAPIVersion: "number",
3619
+ sessionConditionCode: "number",
3620
+ state: "string",
3621
+ stateElapsedTime: "number",
3622
+ version: "number"
3623
+ }
3624
+ },
3625
+ {
3626
+ id: "DELETE /compute/sessions/{}",
3627
+ method: "DELETE",
3628
+ path: "/compute/sessions/{}",
3629
+ steps: ["compute/session-delete"],
3630
+ statuses: [204],
3631
+ queries: [],
3632
+ request: {
3633
+ queries: [],
3634
+ body: void 0
3635
+ },
3636
+ shape: void 0
3637
+ },
3638
+ {
3639
+ id: "POST /compute/sessions/{}/jobs",
3640
+ method: "POST",
3641
+ path: "/compute/sessions/{}/jobs",
3642
+ steps: ["compute/execute-script"],
3643
+ statuses: [201],
3644
+ queries: [],
3645
+ request: {
3646
+ queries: [],
3647
+ body: {
3648
+ code: "string",
3649
+ description: "string",
3650
+ name: "string",
3651
+ variables: {
3652
+ SYS_JES_JOB_URI: "string",
3653
+ _DEBUG: "number",
3654
+ _program: "string"
3655
+ },
3656
+ version: "number"
3657
+ }
3658
+ },
3659
+ shape: {
3660
+ creationTimeStamp: "string",
3661
+ id: "string",
3662
+ links: [
3663
+ {
3664
+ href: "string",
3665
+ method: "string",
3666
+ rel: "string",
3667
+ type: "string",
3668
+ uri: "string"
3669
+ }
3670
+ ],
3671
+ sessionId: "string",
3672
+ state: "string",
3673
+ stateElapsedTime: "number",
3674
+ version: "number"
3675
+ }
3676
+ },
3677
+ {
3678
+ id: "GET /compute/sessions/{}/jobs/{}",
3679
+ method: "GET",
3680
+ path: "/compute/sessions/{}/jobs/{}",
3681
+ steps: ["compute/execute-script"],
3682
+ statuses: [200],
3683
+ queries: [],
3684
+ request: {
3685
+ queries: [],
3686
+ body: void 0
3687
+ },
3688
+ shape: {
3689
+ completedTimeStamp: "string",
3690
+ creationTimeStamp: "string",
3691
+ id: "string",
3692
+ jobConditionCode: "number",
3693
+ links: [
3694
+ {
3695
+ href: "string",
3696
+ method: "string",
3697
+ rel: "string",
3698
+ type: "string",
3699
+ uri: "string"
3700
+ }
3701
+ ],
3702
+ listingStatistics: {
3703
+ lineCount: "number",
3704
+ modifiedTimeStamp: "string"
3705
+ },
3706
+ logStatistics: {
3707
+ lineCount: "number",
3708
+ modifiedTimeStamp: "string"
3709
+ },
3710
+ sessionId: "string",
3711
+ state: "string",
3712
+ stateElapsedTime: "number",
3713
+ statistics: {
3714
+ systemCpuTime: "number",
3715
+ userCpuTime: "number"
3716
+ },
3717
+ version: "number"
3718
+ }
3719
+ },
3720
+ {
3721
+ id: "GET /compute/sessions/{}/jobs/{}/log/content",
3722
+ method: "GET",
3723
+ path: "/compute/sessions/{}/jobs/{}/log/content",
3724
+ steps: ["compute/execute-script"],
3725
+ statuses: [200],
3726
+ queries: ["limit", "start"],
3727
+ request: {
3728
+ queries: ["limit", "start"],
3729
+ body: void 0
3730
+ },
3731
+ shape: {
3732
+ accept: "string",
3733
+ count: "number",
3734
+ items: [
3735
+ {
3736
+ line: "string",
3737
+ type: "string",
3738
+ version: "number"
3739
+ }
3740
+ ],
3741
+ limit: "number",
3742
+ links: [
3743
+ {
3744
+ href: "string",
3745
+ itemType: "string",
3746
+ method: "string",
3747
+ rel: "string",
3748
+ type: "string",
3749
+ uri: "string"
3750
+ }
3751
+ ],
3752
+ name: "string",
3753
+ start: "number",
3754
+ version: "number"
3755
+ }
3756
+ },
3757
+ {
3758
+ id: "GET /compute/sessions/{}/jobs/{}/state",
3759
+ method: "GET",
3760
+ path: "/compute/sessions/{}/jobs/{}/state",
3761
+ steps: ["compute/execute-script"],
3762
+ statuses: [200],
3763
+ queries: ["_action", "wait"],
3764
+ request: {
3765
+ queries: ["_action", "wait"],
3766
+ body: void 0
3767
+ },
3768
+ shape: void 0
3769
+ },
3770
+ {
3771
+ id: "GET /compute/sessions/{}/state",
3772
+ method: "GET",
3773
+ path: "/compute/sessions/{}/state",
3774
+ steps: ["compute/execute-script", "compute/session-state"],
3775
+ statuses: [200],
3776
+ queries: ["wait"],
3777
+ request: {
3778
+ queries: ["wait"],
3779
+ body: void 0
3780
+ },
3781
+ shape: void 0
3782
+ },
3783
+ {
3784
+ id: "POST /files/files",
3785
+ method: "POST",
3786
+ path: "/files/files",
3787
+ steps: ["files/create"],
3788
+ statuses: [201],
3789
+ queries: ["parentFolderUri", "typeDefName"],
3790
+ request: {
3791
+ queries: ["parentFolderUri", "typeDefName"],
3792
+ body: {
3793
+ multipart: ["file"]
3794
+ }
3795
+ },
3796
+ shape: {
3797
+ contentDisposition: "string",
3798
+ contentType: "string",
3799
+ createdBy: "string",
3800
+ creationTimeStamp: "string",
3801
+ encoding: "string",
3802
+ fileStatus: "string",
3803
+ fileVersion: "number",
3804
+ id: "string",
3805
+ links: [
3806
+ {
3807
+ href: "string",
3808
+ method: "string",
3809
+ rel: "string",
3810
+ type: "string",
3811
+ uri: "string"
3812
+ }
3813
+ ],
3814
+ modifiedBy: "string",
3815
+ modifiedTimeStamp: "string",
3816
+ name: "string",
3817
+ properties: {},
3818
+ quarantine: "boolean",
3819
+ searchable: "boolean",
3820
+ size: "number",
3821
+ typeDefName: "string",
3822
+ urlDetected: "boolean",
3823
+ version: "number",
3824
+ virusDetected: "boolean"
3825
+ }
3826
+ },
3827
+ {
3828
+ id: "GET /files/files/{}",
3829
+ method: "GET",
3830
+ path: "/files/files/{}",
3831
+ steps: ["files/replace"],
3832
+ statuses: [200],
3833
+ queries: [],
3834
+ request: {
3835
+ queries: [],
3836
+ body: void 0
3837
+ },
3838
+ shape: {
3839
+ contentDisposition: "string",
3840
+ contentType: "string",
3841
+ createdBy: "string",
3842
+ creationTimeStamp: "string",
3843
+ encoding: "string",
3844
+ fileStatus: "string",
3845
+ fileVersion: "number",
3846
+ id: "string",
3847
+ links: [
3848
+ {
3849
+ href: "string",
3850
+ method: "string",
3851
+ rel: "string",
3852
+ type: "string",
3853
+ uri: "string"
3854
+ }
3855
+ ],
3856
+ modifiedBy: "string",
3857
+ modifiedTimeStamp: "string",
3858
+ name: "string",
3859
+ properties: {
3860
+ "content.download": "string",
3861
+ "content.openInBrowser": "string",
3862
+ "content.preview": "string",
3863
+ sasIconKey: "string",
3864
+ typeRegistrant: "string"
3865
+ },
3866
+ quarantine: "boolean",
3867
+ searchable: "boolean",
3868
+ size: "number",
3869
+ typeDefName: "string",
3870
+ urlDetected: "boolean",
3871
+ version: "number",
3872
+ virusDetected: "boolean"
3873
+ }
3874
+ },
3875
+ {
3876
+ id: "PATCH /files/files/{}",
3877
+ method: "PATCH",
3878
+ path: "/files/files/{}",
3879
+ steps: ["files/create"],
3880
+ statuses: [200],
3881
+ queries: [],
3882
+ request: {
3883
+ queries: [],
3884
+ body: {
3885
+ name: "string",
3886
+ properties: {
3887
+ "content.download": "string",
3888
+ "content.openInBrowser": "string",
3889
+ "content.preview": "string",
3890
+ sasIconKey: "string",
3891
+ typeRegistrant: "string"
3892
+ }
3893
+ }
3894
+ },
3895
+ shape: {
3896
+ contentDisposition: "string",
3897
+ contentType: "string",
3898
+ createdBy: "string",
3899
+ creationTimeStamp: "string",
3900
+ encoding: "string",
3901
+ fileStatus: "string",
3902
+ fileVersion: "number",
3903
+ id: "string",
3904
+ links: [
3905
+ {
3906
+ href: "string",
3907
+ method: "string",
3908
+ rel: "string",
3909
+ type: "string",
3910
+ uri: "string"
3911
+ }
3912
+ ],
3913
+ modifiedBy: "string",
3914
+ modifiedTimeStamp: "string",
3915
+ name: "string",
3916
+ properties: {
3917
+ "content.download": "string",
3918
+ "content.openInBrowser": "string",
3919
+ "content.preview": "string",
3920
+ sasIconKey: "string",
3921
+ typeRegistrant: "string"
3922
+ },
3923
+ quarantine: "boolean",
3924
+ searchable: "boolean",
3925
+ size: "number",
3926
+ typeDefName: "string",
3927
+ urlDetected: "boolean",
3928
+ version: "number",
3929
+ virusDetected: "boolean"
3930
+ }
3931
+ },
3932
+ {
3933
+ id: "GET /files/files/{}/content",
3934
+ method: "GET",
3935
+ path: "/files/files/{}/content",
3936
+ steps: ["files/content"],
3937
+ statuses: [200],
3938
+ queries: [],
3939
+ request: {
3940
+ queries: [],
3941
+ body: void 0
3942
+ },
3943
+ shape: void 0
3944
+ },
3945
+ {
3946
+ id: "PUT /files/files/{}/content",
3947
+ method: "PUT",
3948
+ path: "/files/files/{}/content",
3949
+ steps: ["files/replace"],
3950
+ statuses: [200],
3951
+ queries: [],
3952
+ request: {
3953
+ queries: [],
3954
+ body: void 0
3955
+ },
3956
+ shape: {
3957
+ contentDisposition: "string",
3958
+ contentType: "string",
3959
+ createdBy: "string",
3960
+ creationTimeStamp: "string",
3961
+ encoding: "string",
3962
+ fileStatus: "string",
3963
+ fileVersion: "number",
3964
+ id: "string",
3965
+ links: [
3966
+ {
3967
+ href: "string",
3968
+ method: "string",
3969
+ rel: "string",
3970
+ type: "string",
3971
+ uri: "string"
3972
+ }
3973
+ ],
3974
+ modifiedBy: "string",
3975
+ modifiedTimeStamp: "string",
3976
+ name: "string",
3977
+ properties: {
3978
+ "content.download": "string",
3979
+ "content.openInBrowser": "string",
3980
+ "content.preview": "string",
3981
+ sasIconKey: "string",
3982
+ typeRegistrant: "string"
3983
+ },
3984
+ quarantine: "boolean",
3985
+ searchable: "boolean",
3986
+ size: "number",
3987
+ typeDefName: "string",
3988
+ urlDetected: "boolean",
3989
+ version: "number",
3990
+ virusDetected: "boolean"
3991
+ }
3992
+ },
3993
+ {
3994
+ id: "POST /folders/folders",
3995
+ method: "POST",
3996
+ path: "/folders/folders",
3997
+ steps: ["folders/create"],
3998
+ statuses: [201],
3999
+ queries: ["parentFolderUri"],
4000
+ request: {
4001
+ queries: ["parentFolderUri"],
4002
+ body: {
4003
+ name: "string",
4004
+ type: "string"
4005
+ }
4006
+ },
4007
+ shape: {
4008
+ createdBy: "string",
4009
+ creationTimeStamp: "string",
4010
+ id: "string",
4011
+ links: [
4012
+ {
4013
+ href: "string",
4014
+ method: "string",
4015
+ rel: "string",
4016
+ type: "string",
4017
+ uri: "string"
4018
+ }
4019
+ ],
4020
+ memberCount: "number",
4021
+ modifiedBy: "string",
4022
+ modifiedTimeStamp: "string",
4023
+ name: "string",
4024
+ parentFolderUri: "string",
4025
+ type: "string",
4026
+ version: "number"
4027
+ }
4028
+ },
4029
+ {
4030
+ id: "GET /folders/folders/{}",
4031
+ method: "GET",
4032
+ path: "/folders/folders/{}",
4033
+ steps: ["folders/delete"],
4034
+ statuses: [200],
4035
+ queries: [],
4036
+ request: {
4037
+ queries: [],
4038
+ body: void 0
4039
+ },
4040
+ shape: {
4041
+ createdBy: "string",
4042
+ creationTimeStamp: "string",
4043
+ description: "string",
4044
+ id: "string",
4045
+ links: [
4046
+ {
4047
+ href: "string",
4048
+ method: "string",
4049
+ rel: "string",
4050
+ type: "string",
4051
+ uri: "string"
4052
+ }
4053
+ ],
4054
+ memberCount: "number",
4055
+ modifiedBy: "string",
4056
+ modifiedTimeStamp: "string",
4057
+ name: "string",
4058
+ parentFolderUri: "string",
4059
+ properties: {
4060
+ allowMove: "string"
4061
+ },
4062
+ type: "string",
4063
+ version: "number"
4064
+ }
4065
+ },
4066
+ {
4067
+ id: "PATCH /folders/folders/{}",
4068
+ method: "PATCH",
4069
+ path: "/folders/folders/{}",
4070
+ steps: ["folders/delete"],
4071
+ statuses: [200],
4072
+ queries: [],
4073
+ request: {
4074
+ queries: [],
4075
+ body: {
4076
+ id: "string",
4077
+ name: "string",
4078
+ parentFolderUri: "string"
4079
+ }
4080
+ },
4081
+ shape: {
4082
+ createdBy: "string",
4083
+ creationTimeStamp: "string",
4084
+ id: "string",
4085
+ links: [
4086
+ {
4087
+ href: "string",
4088
+ method: "string",
4089
+ rel: "string",
4090
+ type: "string",
4091
+ uri: "string"
4092
+ }
4093
+ ],
4094
+ memberCount: "number",
4095
+ modifiedBy: "string",
4096
+ modifiedTimeStamp: "string",
4097
+ name: "string",
4098
+ parentFolderUri: "string",
4099
+ type: "string",
4100
+ version: "number"
4101
+ }
4102
+ },
4103
+ {
4104
+ id: "GET /folders/folders/{}/members",
4105
+ method: "GET",
4106
+ path: "/folders/folders/{}/members",
4107
+ steps: [
4108
+ "files/content",
4109
+ "files/replace",
4110
+ "folders/create",
4111
+ "folders/members"
4112
+ ],
4113
+ statuses: [200],
4114
+ queries: ["limit"],
4115
+ request: {
4116
+ queries: ["limit"],
4117
+ body: void 0
4118
+ },
4119
+ shape: {
4120
+ accept: "string",
4121
+ count: "number",
4122
+ items: [
4123
+ {
4124
+ added: "string",
4125
+ contentType: "string",
4126
+ createdBy: "string",
4127
+ creationTimeStamp: "string",
4128
+ id: "string",
4129
+ links: [
4130
+ {
4131
+ href: "string",
4132
+ method: "string",
4133
+ rel: "string",
4134
+ type: "string",
4135
+ uri: "string"
4136
+ }
4137
+ ],
4138
+ modifiedBy: "string",
4139
+ modifiedTimeStamp: "string",
4140
+ name: "string",
4141
+ parentFolderUri: "string",
4142
+ type: "string",
4143
+ uri: "string",
4144
+ version: "number"
4145
+ }
4146
+ ],
4147
+ limit: "number",
4148
+ links: [
4149
+ {
4150
+ href: "string",
4151
+ itemType: "string",
4152
+ method: "string",
4153
+ rel: "string",
4154
+ type: "string",
4155
+ uri: "string"
4156
+ }
4157
+ ],
4158
+ name: "string",
4159
+ start: "number",
4160
+ version: "number"
4161
+ }
4162
+ },
4163
+ {
4164
+ id: "GET /folders/folders/@item",
4165
+ method: "GET",
4166
+ path: "/folders/folders/@item",
4167
+ steps: [
4168
+ "files/content",
4169
+ "files/create",
4170
+ "files/replace",
4171
+ "folders/create",
4172
+ "folders/delete",
4173
+ "folders/item",
4174
+ "folders/members"
4175
+ ],
4176
+ statuses: [200, 401, 404],
4177
+ queries: ["path"],
4178
+ request: {
4179
+ queries: ["path"],
4180
+ body: void 0
4181
+ },
4182
+ shape: {
4183
+ createdBy: "string",
4184
+ creationTimeStamp: "string",
4185
+ description: "string",
4186
+ id: "string",
4187
+ links: [
4188
+ {
4189
+ href: "string",
4190
+ method: "string",
4191
+ rel: "string",
4192
+ type: "string",
4193
+ uri: "string"
4194
+ }
4195
+ ],
4196
+ memberCount: "number",
4197
+ modifiedBy: "string",
4198
+ modifiedTimeStamp: "string",
4199
+ name: "string",
4200
+ parentFolderUri: "string",
4201
+ type: "string",
4202
+ version: "number"
4203
+ }
4204
+ },
4205
+ {
4206
+ id: "GET /folders/folders/@myRecycleBin",
4207
+ method: "GET",
4208
+ path: "/folders/folders/@myRecycleBin",
4209
+ steps: ["folders/delete"],
4210
+ statuses: [200],
4211
+ queries: [],
4212
+ request: {
4213
+ queries: [],
4214
+ body: void 0
4215
+ },
4216
+ shape: {
4217
+ createdBy: "string",
4218
+ creationTimeStamp: "string",
4219
+ description: "string",
4220
+ id: "string",
4221
+ links: [
4222
+ {
4223
+ href: "string",
4224
+ method: "string",
4225
+ rel: "string",
4226
+ type: "string",
4227
+ uri: "string"
4228
+ }
4229
+ ],
4230
+ memberCount: "number",
4231
+ modifiedBy: "string",
4232
+ modifiedTimeStamp: "string",
4233
+ name: "string",
4234
+ parentFolderUri: "string",
4235
+ properties: {
4236
+ allowMove: "string"
4237
+ },
4238
+ type: "string",
4239
+ version: "number"
4240
+ }
4241
+ },
4242
+ {
4243
+ id: "GET /identities/users/@currentUser",
4244
+ method: "GET",
4245
+ path: "/identities/users/@currentUser",
4246
+ steps: ["identities/current-user"],
4247
+ statuses: [200],
4248
+ queries: [],
4249
+ request: {
4250
+ queries: [],
4251
+ body: void 0
4252
+ },
4253
+ shape: {
4254
+ addresses: [
4255
+ {
4256
+ locality: "string",
4257
+ type: "string"
4258
+ }
4259
+ ],
4260
+ emailAddresses: [
4261
+ {
4262
+ type: "string",
4263
+ value: "string"
4264
+ }
4265
+ ],
4266
+ id: "string",
4267
+ links: [
4268
+ {
4269
+ href: "string",
4270
+ method: "string",
4271
+ rel: "string",
4272
+ type: "string",
4273
+ uri: "string"
4274
+ }
4275
+ ],
4276
+ name: "string",
4277
+ providerId: "string",
4278
+ state: "string",
4279
+ version: "number"
4280
+ }
4281
+ },
4282
+ {
4283
+ id: "POST /SASLogon/oauth/token",
4284
+ method: "POST",
4285
+ path: "/SASLogon/oauth/token",
4286
+ steps: ["auth/token-refresh", "auth/token-refresh-refused"],
4287
+ statuses: [200, 401],
4288
+ queries: [],
4289
+ request: {
4290
+ queries: [],
4291
+ body: {
4292
+ multipart: ["grant_type", "refresh_token"]
4293
+ }
4294
+ },
4295
+ shape: {
4296
+ access_token: "string",
4297
+ expires_in: "number",
4298
+ id_token: "string",
4299
+ jti: "string",
4300
+ refresh_expires_in: "number",
4301
+ refresh_revocable: "boolean",
4302
+ refresh_token: "string",
4303
+ revocable: "boolean",
4304
+ scope: "string",
4305
+ token_type: "string"
4306
+ }
4307
+ },
4308
+ {
4309
+ id: "GET /types/types",
4310
+ method: "GET",
4311
+ path: "/types/types",
4312
+ steps: ["files/create"],
4313
+ statuses: [200],
4314
+ queries: ["limit"],
4315
+ request: {
4316
+ queries: ["limit"],
4317
+ body: void 0
4318
+ },
4319
+ shape: void 0
4320
+ }
4321
+ ];
4322
+
4323
+ // src/viya/unrecorded.ts
4324
+ var UNRECORDED = [
4325
+ // The recorder hands the adapter a token it obtained itself, so the calls that
4326
+ // obtain one never pass through the proxy. The capture tool records them as a
4327
+ // separate pass, which needs a client id and secret.
4328
+ {
4329
+ path: "/SASLogon",
4330
+ reason: "no capture: the pass authenticates outside the adapter, so the login root is never requested through the client"
4331
+ },
4332
+ {
4333
+ path: "/SASLogon/login",
4334
+ reason: "no capture: an interactive login; the pass presents a token instead of a form"
4335
+ },
4336
+ {
4337
+ path: "/SASLogon/login.do",
4338
+ reason: "no capture: an interactive login; the pass presents a token instead of a form"
4339
+ },
4340
+ {
4341
+ path: "/SASLogon/logout",
4342
+ reason: "no capture: the pass never signs out, because a capture run must leave the estate as it found it"
4343
+ },
4344
+ {
4345
+ path: "/SASLogon/logout.do",
4346
+ reason: "no capture: the pass never signs out, because a capture run must leave the estate as it found it"
4347
+ },
4348
+ {
4349
+ path: "/SASLogon/oauth/authorize",
4350
+ reason: "no capture: the authorisation-code step needs a browser; the pass uses the password grant"
4351
+ },
4352
+ // Compute operations the scripted passes do not reach.
4353
+ {
4354
+ path: "/compute/sessions/{}/filerefs/_webout/content",
4355
+ reason: "no capture: the adapter reads the webout fileref only when a run expects one (`expectWebout`); the execute pass submits a `%put` and reads the log"
4356
+ },
4357
+ {
4358
+ path: "/compute/sessions/{}/variables/{}",
4359
+ reason: "no capture: the adapter reads a session variable only to report a submitted job's pid (`printPid`), which the pass does not set"
4360
+ },
4361
+ {
4362
+ path: "/launcher/contexts",
4363
+ reason: "no capture: the fallback list, asked for only when the compute context list fails; a healthy estate never reaches it"
4364
+ },
4365
+ // The job path needs something deployed to run.
4366
+ {
4367
+ path: "/jobDefinitions/definitions",
4368
+ reason: "no capture: needs a job definition on the estate. The next pass deploys a service pack under its own app folder and reads the definition back"
4369
+ },
4370
+ {
4371
+ path: "/jobExecution/jobs",
4372
+ reason: "no capture: needs a deployed service to submit. The next pass deploys a service pack under its own app folder"
4373
+ },
4374
+ {
4375
+ path: "/jobExecution/jobs/{}",
4376
+ reason: "no capture: follows a submission, so it arrives with the same pass as POST /jobExecution/jobs"
4377
+ }
4378
+ ];
4379
+
4380
+ // src/viya/version.ts
4381
+ var VIYA_TARGET_VERSION = "V.04.00M0P100526";
4382
+ var VIYA_CAPTURED_AT = "2026-11-12";
4383
+ var EMULATED_HEADER = "x-sasjs-emulated";
4384
+ var EMULATED_HEADER_VALUE = `viya@${VIYA_TARGET_VERSION}`;
4385
+ var emulatedHeaders = () => ({
4386
+ [EMULATED_HEADER]: EMULATED_HEADER_VALUE,
4387
+ "Access-Control-Expose-Headers": EMULATED_HEADER
4388
+ });
4389
+
4390
+ // src/viya/overlay.ts
4391
+ var NEEDS_RUNTIME = "The emulated estate answers folders, identities and types today. This operation needs the session or file port, which the host mounting the emulator has not supplied.";
4392
+ var NEEDS_AUTH = "The token endpoint is answered by the host that mounts the emulator, which owns the token port.";
4393
+ var VIYA_OVERLAY = {
4394
+ // answered here
4395
+ "POST /folders/folders": { implemented: true },
4396
+ "GET /folders/folders/{}": { implemented: true },
4397
+ "PATCH /folders/folders/{}": { implemented: true },
4398
+ "GET /folders/folders/{}/members": { implemented: true },
4399
+ "GET /folders/folders/@item": { implemented: true },
4400
+ "GET /folders/folders/@myRecycleBin": { implemented: true },
4401
+ "GET /identities/users/@currentUser": { implemented: true },
4402
+ "GET /types/types": { implemented: true },
4403
+ // declined: the session and file ports
4404
+ "GET /compute/contexts": { implemented: false, reason: NEEDS_RUNTIME },
4405
+ "POST /compute/contexts/{}/sessions": {
4406
+ implemented: false,
4407
+ reason: NEEDS_RUNTIME
4408
+ },
4409
+ "DELETE /compute/sessions/{}": { implemented: false, reason: NEEDS_RUNTIME },
4410
+ "POST /compute/sessions/{}/jobs": {
4411
+ implemented: false,
4412
+ reason: NEEDS_RUNTIME
4413
+ },
4414
+ "GET /compute/sessions/{}/jobs/{}": {
4415
+ implemented: false,
4416
+ reason: NEEDS_RUNTIME
4417
+ },
4418
+ "GET /compute/sessions/{}/jobs/{}/log/content": {
4419
+ implemented: false,
4420
+ reason: NEEDS_RUNTIME
4421
+ },
4422
+ "GET /compute/sessions/{}/jobs/{}/state": {
4423
+ implemented: false,
4424
+ reason: NEEDS_RUNTIME
4425
+ },
4426
+ "GET /compute/sessions/{}/state": {
4427
+ implemented: false,
4428
+ reason: NEEDS_RUNTIME
4429
+ },
4430
+ "POST /files/files": { implemented: false, reason: NEEDS_RUNTIME },
4431
+ "GET /files/files/{}": { implemented: false, reason: NEEDS_RUNTIME },
4432
+ "PATCH /files/files/{}": { implemented: false, reason: NEEDS_RUNTIME },
4433
+ "GET /files/files/{}/content": { implemented: false, reason: NEEDS_RUNTIME },
4434
+ "PUT /files/files/{}/content": { implemented: false, reason: NEEDS_RUNTIME },
4435
+ // declined: the host owns the token port
4436
+ "POST /SASLogon/oauth/token": { implemented: false, reason: NEEDS_AUTH }
4437
+ };
4438
+ var assertOverlayEntries = (overlay, operations = VIYA_TABLE) => {
4439
+ const known2 = new Set(operations.map((operation) => operation.id));
4440
+ for (const id of Object.keys(overlay))
4441
+ if (!known2.has(id))
4442
+ throw new Error(
4443
+ `src/viya/overlay.ts names an operation the table does not have: ${id}. The table is generated from a capture, so an entry for an operation nobody observed is a claim about a call no client makes.`
4444
+ );
4445
+ for (const operation of operations)
4446
+ if (!(operation.id in overlay))
4447
+ throw new Error(
4448
+ `src/viya/overlay.ts has no decision for ${operation.id}. Every captured operation states whether this package implements it and, when it does not, the reason it does not: add \`{ implemented: false, reason: '...' }\` until a handler exists.`
4449
+ );
4450
+ };
4451
+ assertOverlayEntries(VIYA_OVERLAY);
4452
+
4453
+ // src/viya/service.ts
4454
+ var EMULATED_NOW = "2026-01-01T00:00:00.000Z";
4455
+ var EMULATED_USER = { id: "emulated-user", name: "Emulated User" };
4456
+ var idFor = (path, kind = "folder") => {
4457
+ const hash = (input, seed) => {
4458
+ let value = seed;
4459
+ for (let index = 0; index < input.length; index++) {
4460
+ value ^= input.charCodeAt(index);
4461
+ value = Math.imul(value, 16777619) >>> 0;
4462
+ }
4463
+ return value.toString(16).padStart(8, "0");
4464
+ };
4465
+ const raw = hash(`${kind}:${path}`, 2166136261) + hash(`${kind}:${path}`, 2246822519) + hash(`${kind}:${path}`, 3266489917) + hash(`${kind}:${path}`, 668265263);
4466
+ const hex = raw.slice(0, 32);
4467
+ return [
4468
+ hex.slice(0, 8),
4469
+ hex.slice(8, 12),
4470
+ `4${hex.slice(13, 16)}`,
4471
+ `a${hex.slice(17, 20)}`,
4472
+ hex.slice(20, 32)
4473
+ ].join("-");
4474
+ };
4475
+ var linksFor = (uri, collection = false) => {
4476
+ const self = {
4477
+ href: uri,
4478
+ uri,
4479
+ rel: "self",
4480
+ method: "GET",
4481
+ type: "application/vnd.sas.folder"
4482
+ };
4483
+ const members = {
4484
+ href: `${uri}/members`,
4485
+ uri: `${uri}/members`,
4486
+ rel: "members",
4487
+ method: "GET",
4488
+ type: "application/vnd.sas.collection",
4489
+ itemType: "folder"
4490
+ };
4491
+ return collection ? [members, self] : [self, members];
4492
+ };
4493
+ var folderBody = async (drive, path) => {
4494
+ const listing = await drive.list(path);
4495
+ const id = idFor(path);
4496
+ const name = path.split("/").filter(Boolean).pop() ?? "";
4497
+ const parent = path.split("/").slice(0, -1).join("/") || "/";
4498
+ return {
4499
+ id,
4500
+ name,
4501
+ description: "",
4502
+ type: "folder",
4503
+ version: 1,
4504
+ createdBy: EMULATED_USER.id,
4505
+ modifiedBy: EMULATED_USER.id,
4506
+ creationTimeStamp: EMULATED_NOW,
4507
+ modifiedTimeStamp: EMULATED_NOW,
4508
+ memberCount: listing.files.length + listing.folders.length,
4509
+ parentFolderUri: `/folders/folders/${idFor(parent)}`,
4510
+ links: linksFor(`/folders/folders/${id}`)
4511
+ };
4512
+ };
4513
+ var recycleBin = () => {
4514
+ const path = "@myRecycleBin";
4515
+ const id = idFor(path);
4516
+ return {
4517
+ id,
4518
+ name: "Recycle Bin",
4519
+ description: "Recycle Bin",
4520
+ type: "trashFolder",
4521
+ version: 1,
4522
+ createdBy: EMULATED_USER.id,
4523
+ modifiedBy: EMULATED_USER.id,
4524
+ creationTimeStamp: EMULATED_NOW,
4525
+ modifiedTimeStamp: EMULATED_NOW,
4526
+ memberCount: 0,
4527
+ parentFolderUri: "",
4528
+ properties: { allowMove: "false" },
4529
+ links: linksFor(`/folders/folders/${id}`)
4530
+ };
4531
+ };
4532
+ var requireDrive = (services) => {
4533
+ if (!services.drive)
4534
+ throw new ApiError(
4535
+ 501,
4536
+ "This host has no drive, so it cannot answer a folder operation."
4537
+ );
4538
+ return services.drive;
4539
+ };
4540
+ var pathFromQuery = (request) => {
4541
+ const path = request.query?.path;
4542
+ if (!path) throw new ApiError(400, "The path parameter is required.");
4543
+ return path;
4544
+ };
4545
+ var RECYCLE_BIN_ALIAS = "/folders/folders/@myRecycleBin";
4546
+ var isRecycleBin = (uri) => !!uri && (uri === RECYCLE_BIN_ALIAS || uri.endsWith(`/${idFor("@myRecycleBin")}`));
4547
+ var pathForId = async (drive, id) => {
4548
+ const walk2 = (node) => {
4549
+ if (node.isFolder && idFor(node.relativePath) === id)
4550
+ return node.relativePath;
4551
+ for (const child of node.children) {
4552
+ const hit = walk2(child);
4553
+ if (hit) return hit;
4554
+ }
4555
+ return void 0;
4556
+ };
4557
+ const { tree } = await drive.tree("/");
4558
+ const path = walk2(tree);
4559
+ if (!path)
4560
+ throw new ApiError(
4561
+ 404,
4562
+ `No folder matches the id ${id}. Ids are derived from paths, so an id that names no folder is one no folder ever had.`
4563
+ );
4564
+ return path;
4565
+ };
4566
+ var VIYA_HANDLERS = {
4567
+ "GET /identities/users/@currentUser": async ({ services, request }) => {
4568
+ const subject = request.subject ?? await services.identity?.authenticate(request.token);
4569
+ const id = subject?.userId ?? EMULATED_USER.id;
4570
+ return {
4571
+ status: 200,
4572
+ body: {
4573
+ id,
4574
+ name: subject?.userId ?? EMULATED_USER.name,
4575
+ providerId: "sas",
4576
+ state: "active",
4577
+ version: 1,
4578
+ addresses: [],
4579
+ emailAddresses: [],
4580
+ links: [
4581
+ {
4582
+ href: `/identities/users/${id}`,
4583
+ uri: `/identities/users/${id}`,
4584
+ rel: "self",
4585
+ method: "GET",
4586
+ type: "application/vnd.sas.identity.user"
4587
+ }
4588
+ ]
4589
+ }
4590
+ };
4591
+ },
4592
+ "GET /types/types": async () => ({
4593
+ status: 200,
4594
+ body: {
4595
+ count: 1,
4596
+ items: [
4597
+ {
4598
+ name: "file",
4599
+ type: "typeDef",
4600
+ version: 1,
4601
+ links: [{ href: "/types/types/file", rel: "self", method: "GET" }]
4602
+ }
4603
+ ]
4604
+ }
4605
+ }),
4606
+ "GET /folders/folders/@item": async ({ services, request }) => ({
4607
+ status: 200,
4608
+ body: await folderBody(requireDrive(services), pathFromQuery(request))
4609
+ }),
4610
+ "GET /folders/folders/@myRecycleBin": async () => ({
4611
+ status: 200,
4612
+ body: recycleBin()
4613
+ }),
4614
+ "GET /folders/folders/{}": async ({ services, params }) => {
4615
+ if (params.id === idFor("@myRecycleBin"))
4616
+ return { status: 200, body: recycleBin() };
4617
+ const drive = requireDrive(services);
4618
+ return {
4619
+ status: 200,
4620
+ body: await folderBody(drive, await pathForId(drive, params.id))
4621
+ };
4622
+ },
4623
+ "GET /folders/folders/{}/members": async ({ services, params, request }) => {
4624
+ const drive = requireDrive(services);
4625
+ const limit = Number(request.query?.limit ?? 0) || 0;
4626
+ if (params.id === idFor("@myRecycleBin"))
4627
+ return {
4628
+ status: 200,
4629
+ body: {
4630
+ accept: "application/json",
4631
+ name: "members",
4632
+ start: 0,
4633
+ // the query value is echoed as the sibling branch echoes it: a caller
4634
+ // that asked for five and is told zero cannot tell what happened
4635
+ limit,
4636
+ count: 0,
4637
+ version: 2,
4638
+ items: [],
4639
+ links: linksFor(`/folders/folders/${idFor("@myRecycleBin")}`, true)
4640
+ }
4641
+ };
4642
+ const path = await pathForId(drive, params.id);
4643
+ const listing = await drive.list(path);
4644
+ const items = [
4645
+ ...listing.folders.map((name) => ({
4646
+ id: idFor(`${path}/${name}`.replace(/\/{2,}/g, "/")),
4647
+ name,
4648
+ type: "folder",
4649
+ version: 1,
4650
+ createdBy: EMULATED_USER.id,
4651
+ modifiedBy: EMULATED_USER.id,
4652
+ creationTimeStamp: EMULATED_NOW,
4653
+ modifiedTimeStamp: EMULATED_NOW,
4654
+ parentFolderUri: `/folders/folders/${idFor(path)}`,
4655
+ uri: `${path}/${name}`.replace(/\/{2,}/g, "/"),
4656
+ links: linksFor(
4657
+ `/folders/folders/${idFor(`${path}/${name}`.replace(/\/{2,}/g, "/"))}`
4658
+ )
4659
+ })),
4660
+ ...listing.files.map((name) => ({
4661
+ id: idFor(`${path}/${name}`.replace(/\/{2,}/g, "/"), "file"),
4662
+ name,
4663
+ type: "file",
4664
+ version: 1,
4665
+ contentType: "text/plain",
4666
+ createdBy: EMULATED_USER.id,
4667
+ modifiedBy: EMULATED_USER.id,
4668
+ creationTimeStamp: EMULATED_NOW,
4669
+ modifiedTimeStamp: EMULATED_NOW,
4670
+ parentFolderUri: `/folders/folders/${idFor(path)}`,
4671
+ added: EMULATED_NOW,
4672
+ uri: `${path}/${name}`.replace(/\/{2,}/g, "/"),
4673
+ links: linksFor(
4674
+ `/files/files/${idFor(`${path}/${name}`.replace(/\/{2,}/g, "/"), "file")}`
4675
+ )
4676
+ }))
4677
+ ];
4678
+ const page = limit > 0 ? items.slice(0, limit) : items;
4679
+ return {
4680
+ status: 200,
4681
+ body: {
4682
+ accept: "application/json",
4683
+ name: "members",
4684
+ start: 0,
4685
+ limit: limit || page.length,
4686
+ count: page.length,
4687
+ version: 2,
4688
+ items: page,
4689
+ links: linksFor(`/folders/folders/${idFor(path)}`, true)
4690
+ }
4691
+ };
4692
+ },
4693
+ "POST /folders/folders": async ({ services, request }) => {
4694
+ const drive = requireDrive(services);
4695
+ const body = request.body ?? {};
4696
+ if (!body.name) throw new ApiError(400, "A folder name is required.");
4697
+ const parentUri = request.query?.parentFolderUri ?? body.parentFolderUri;
4698
+ const parent = parentUri ? await pathForId(drive, String(parentUri).split("/").pop()) : "/";
4699
+ const path = `${parent}/${body.name}`.replace(/\/{2,}/g, "/");
4700
+ await drive.mkdir(path);
4701
+ return { status: 201, body: await folderBody(drive, path) };
4702
+ },
4703
+ "PATCH /folders/folders/{}": async ({ services, request, params }) => {
4704
+ const drive = requireDrive(services);
4705
+ if (params.id === idFor("@myRecycleBin"))
4706
+ throw new ApiError(400, "The recycle bin cannot be moved or renamed.");
4707
+ const path = await pathForId(drive, params.id);
4708
+ const body = request.body ?? {};
4709
+ if (isRecycleBin(body.parentFolderUri)) {
4710
+ const removed = await folderBody(drive, path);
4711
+ await drive.rmdir(path);
4712
+ return {
4713
+ status: 200,
4714
+ body: { ...removed, parentFolderUri: String(body.parentFolderUri) }
4715
+ };
4716
+ }
4717
+ const name = body.name ?? path.split("/").pop();
4718
+ const parent = body.parentFolderUri === void 0 ? path.split("/").slice(0, -1).join("/") || "/" : body.parentFolderUri === "" ? "/" : await pathForId(
4719
+ drive,
4720
+ body.parentFolderUri.split("/").pop()
4721
+ );
4722
+ const target = `${parent}/${name}`.replace(/\/{2,}/g, "/");
4723
+ if (target !== path) await drive.rename(path, target);
4724
+ return { status: 200, body: await folderBody(drive, target) };
4725
+ }
4726
+ };
4727
+
4728
+ // src/viya/dispatch.ts
4729
+ var escape2 = (segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4730
+ var compiled2 = VIYA_TABLE.filter(
4731
+ (operation) => operation.path.includes("{}")
4732
+ ).map((operation) => ({
4733
+ operation,
4734
+ pattern: new RegExp(
4735
+ "^" + operation.path.split("/").map((segment) => segment === "{}" ? "([^/]+)" : escape2(segment)).join("/") + "$",
4736
+ // the static segments ignore case, as the hosts do
4737
+ "i"
4738
+ )
4739
+ }));
4740
+ var exact2 = /* @__PURE__ */ new Map();
4741
+ for (const operation of VIYA_TABLE)
4742
+ if (!operation.path.includes("{}"))
4743
+ exact2.set(`${operation.method} ${operation.path}`.toLowerCase(), operation);
4744
+ var findViyaOperation = (method, path) => {
4745
+ const verb = method.toUpperCase();
4746
+ const clean = path.split("?")[0].replace(/\/+$/, "") || "/";
4747
+ const staticHit = exact2.get(`${verb} ${clean}`.toLowerCase());
4748
+ if (staticHit) return { operation: staticHit, segments: [] };
4749
+ for (const candidate of compiled2) {
4750
+ if (candidate.operation.method !== verb) continue;
4751
+ const match = candidate.pattern.exec(clean);
4752
+ if (match)
4753
+ return {
4754
+ operation: candidate.operation,
4755
+ segments: match.slice(1).map((segment) => {
4756
+ try {
4757
+ return decodeURIComponent(segment);
4758
+ } catch {
4759
+ return segment;
4760
+ }
4761
+ })
4762
+ };
4763
+ }
4764
+ return void 0;
4765
+ };
4766
+ var dispatchViya = async (services, method, path, request = {}) => {
4767
+ const headers = emulatedHeaders();
4768
+ const found = findViyaOperation(method, path);
4769
+ if (!found)
4770
+ return {
4771
+ status: 404,
4772
+ headers,
4773
+ body: {
4774
+ version: 2,
4775
+ httpStatusCode: 404,
4776
+ errorCode: 404,
4777
+ message: `No operation is emulated at ${method.toUpperCase()} ${path}. The emulated estate answers the client's call surface and nothing else.`
4778
+ }
4779
+ };
4780
+ const entry = VIYA_OVERLAY[found.operation.id];
4781
+ if (!entry)
4782
+ return {
4783
+ status: 501,
4784
+ headers,
4785
+ body: { message: `${found.operation.id} has no decision in the overlay.` }
4786
+ };
4787
+ if (!entry.implemented)
4788
+ return {
4789
+ status: 501,
4790
+ headers,
4791
+ body: {
4792
+ message: `${found.operation.id} is not emulated. ${entry.reason ?? ""}`.trim()
4793
+ }
4794
+ };
4795
+ const handler = VIYA_HANDLERS[found.operation.id];
4796
+ if (!handler)
4797
+ return {
4798
+ status: 501,
4799
+ headers,
4800
+ body: {
4801
+ message: `${found.operation.id} is marked implemented, but no handler answers it.`
4802
+ }
4803
+ };
4804
+ try {
4805
+ const answer = await handler({
4806
+ services,
4807
+ request,
4808
+ params: {
4809
+ id: found.segments[0],
4810
+ segments: found.segments
4811
+ }
4812
+ });
4813
+ return {
4814
+ ...answer,
4815
+ // the emulated headers are spread LAST: they are the invariant this module
4816
+ // exists to guarantee, so a handler cannot overwrite the stamp even by
4817
+ // returning headers of its own
4818
+ headers: { ...answer.headers, ...headers }
4819
+ };
4820
+ } catch (error) {
4821
+ if (isApiError(error))
4822
+ return {
4823
+ status: error.status,
4824
+ headers,
4825
+ body: error.body ?? {
4826
+ version: 2,
4827
+ httpStatusCode: error.status,
4828
+ errorCode: error.status,
4829
+ message: error.message
4830
+ }
4831
+ };
4832
+ return {
4833
+ status: 500,
4834
+ headers,
4835
+ body: {
4836
+ version: 2,
4837
+ httpStatusCode: 500,
4838
+ errorCode: 500,
4839
+ message: String(error?.message ?? error)
4840
+ }
4841
+ };
4842
+ }
4843
+ };
4844
+
4845
+ // src/corpus/viya/operations.ts
4846
+ var VIYA_CORPUS = [
4847
+ {
4848
+ route: "GET /compute/contexts",
4849
+ step: "compute/context-by-name",
4850
+ queries: ["filter", "limit"],
4851
+ statuses: [200],
4852
+ expected: 200,
4853
+ shape: {
4854
+ accept: "string",
4855
+ count: "number",
4856
+ items: [
4857
+ {
4858
+ createdBy: "string",
4859
+ id: "string",
4860
+ links: [
4861
+ {
4862
+ href: "string",
4863
+ method: "string",
4864
+ rel: "string",
4865
+ type: "string",
4866
+ uri: "string"
4867
+ }
4868
+ ],
4869
+ name: "string",
4870
+ version: "number"
4871
+ }
4872
+ ],
4873
+ limit: "number",
4874
+ links: [
4875
+ {
4876
+ href: "string",
4877
+ itemType: "string",
4878
+ method: "string",
4879
+ rel: "string",
4880
+ type: "string",
4881
+ uri: "string"
4882
+ }
4883
+ ],
4884
+ name: "string",
4885
+ start: "number",
4886
+ version: "number"
4887
+ }
4888
+ },
4889
+ {
4890
+ route: "POST /compute/contexts/{}/sessions",
4891
+ step: "compute/execute-script",
4892
+ queries: [],
4893
+ statuses: [201],
4894
+ expected: 201,
4895
+ shape: {
4896
+ applicationName: "string",
4897
+ attributes: {
4898
+ homeDirectory: "string",
4899
+ sessionInactiveTimeout: "number"
4900
+ },
4901
+ creationTimeStamp: "string",
4902
+ environment: {
4903
+ autoExecLines: ["string"]
4904
+ },
4905
+ id: "string",
4906
+ links: [
4907
+ {
4908
+ href: "string",
4909
+ method: "string",
4910
+ rel: "string",
4911
+ type: "string",
4912
+ uri: "string"
4913
+ }
4914
+ ],
4915
+ owner: "string",
4916
+ serverId: "string",
4917
+ serviceAPIVersion: "number",
4918
+ sessionConditionCode: "number",
4919
+ state: "string",
4920
+ stateElapsedTime: "number",
4921
+ version: "number"
4922
+ }
4923
+ },
4924
+ {
4925
+ route: "DELETE /compute/sessions/{}",
4926
+ step: "compute/session-delete",
4927
+ queries: [],
4928
+ statuses: [204],
4929
+ expected: 204,
4930
+ shape: void 0
4931
+ },
4932
+ {
4933
+ route: "POST /compute/sessions/{}/jobs",
4934
+ step: "compute/execute-script",
4935
+ queries: [],
4936
+ statuses: [201],
4937
+ expected: 201,
4938
+ shape: {
4939
+ creationTimeStamp: "string",
4940
+ id: "string",
4941
+ links: [
4942
+ {
4943
+ href: "string",
4944
+ method: "string",
4945
+ rel: "string",
4946
+ type: "string",
4947
+ uri: "string"
4948
+ }
4949
+ ],
4950
+ sessionId: "string",
4951
+ state: "string",
4952
+ stateElapsedTime: "number",
4953
+ version: "number"
4954
+ }
4955
+ },
4956
+ {
4957
+ route: "GET /compute/sessions/{}/jobs/{}",
4958
+ step: "compute/execute-script",
4959
+ queries: [],
4960
+ statuses: [200],
4961
+ expected: 200,
4962
+ shape: {
4963
+ completedTimeStamp: "string",
4964
+ creationTimeStamp: "string",
4965
+ id: "string",
4966
+ jobConditionCode: "number",
4967
+ links: [
4968
+ {
4969
+ href: "string",
4970
+ method: "string",
4971
+ rel: "string",
4972
+ type: "string",
4973
+ uri: "string"
4974
+ }
4975
+ ],
4976
+ listingStatistics: {
4977
+ lineCount: "number",
4978
+ modifiedTimeStamp: "string"
4979
+ },
4980
+ logStatistics: {
4981
+ lineCount: "number",
4982
+ modifiedTimeStamp: "string"
4983
+ },
4984
+ sessionId: "string",
4985
+ state: "string",
4986
+ stateElapsedTime: "number",
4987
+ statistics: {
4988
+ systemCpuTime: "number",
4989
+ userCpuTime: "number"
4990
+ },
4991
+ version: "number"
4992
+ }
4993
+ },
4994
+ {
4995
+ route: "GET /compute/sessions/{}/jobs/{}/log/content",
4996
+ step: "compute/execute-script",
4997
+ queries: ["limit", "start"],
4998
+ statuses: [200],
4999
+ expected: 200,
5000
+ shape: {
5001
+ accept: "string",
5002
+ count: "number",
5003
+ items: [
5004
+ {
5005
+ line: "string",
5006
+ type: "string",
5007
+ version: "number"
5008
+ }
5009
+ ],
5010
+ limit: "number",
5011
+ links: [
5012
+ {
5013
+ href: "string",
5014
+ itemType: "string",
5015
+ method: "string",
5016
+ rel: "string",
5017
+ type: "string",
5018
+ uri: "string"
5019
+ }
5020
+ ],
5021
+ name: "string",
5022
+ start: "number",
5023
+ version: "number"
5024
+ }
5025
+ },
5026
+ {
5027
+ route: "GET /compute/sessions/{}/jobs/{}/state",
5028
+ step: "compute/execute-script",
5029
+ queries: ["_action", "wait"],
5030
+ statuses: [200],
5031
+ expected: 200,
5032
+ shape: void 0
5033
+ },
5034
+ {
5035
+ route: "GET /compute/sessions/{}/state",
5036
+ step: "compute/execute-script",
5037
+ queries: ["wait"],
5038
+ statuses: [200],
5039
+ expected: 200,
5040
+ shape: void 0
5041
+ },
5042
+ {
5043
+ route: "POST /files/files",
5044
+ step: "files/create",
5045
+ queries: ["parentFolderUri", "typeDefName"],
5046
+ statuses: [201],
5047
+ expected: 201,
5048
+ shape: {
5049
+ contentDisposition: "string",
5050
+ contentType: "string",
5051
+ createdBy: "string",
5052
+ creationTimeStamp: "string",
5053
+ encoding: "string",
5054
+ fileStatus: "string",
5055
+ fileVersion: "number",
5056
+ id: "string",
5057
+ links: [
5058
+ {
5059
+ href: "string",
5060
+ method: "string",
5061
+ rel: "string",
5062
+ type: "string",
5063
+ uri: "string"
5064
+ }
5065
+ ],
5066
+ modifiedBy: "string",
5067
+ modifiedTimeStamp: "string",
5068
+ name: "string",
5069
+ properties: {},
5070
+ quarantine: "boolean",
5071
+ searchable: "boolean",
5072
+ size: "number",
5073
+ typeDefName: "string",
5074
+ urlDetected: "boolean",
5075
+ version: "number",
5076
+ virusDetected: "boolean"
5077
+ }
5078
+ },
5079
+ {
5080
+ route: "GET /files/files/{}",
5081
+ step: "files/replace",
5082
+ queries: [],
5083
+ statuses: [200],
5084
+ expected: 200,
5085
+ shape: {
5086
+ contentDisposition: "string",
5087
+ contentType: "string",
5088
+ createdBy: "string",
5089
+ creationTimeStamp: "string",
5090
+ encoding: "string",
5091
+ fileStatus: "string",
5092
+ fileVersion: "number",
5093
+ id: "string",
5094
+ links: [
5095
+ {
5096
+ href: "string",
5097
+ method: "string",
5098
+ rel: "string",
5099
+ type: "string",
5100
+ uri: "string"
5101
+ }
5102
+ ],
5103
+ modifiedBy: "string",
5104
+ modifiedTimeStamp: "string",
5105
+ name: "string",
5106
+ properties: {
5107
+ "content.download": "string",
5108
+ "content.openInBrowser": "string",
5109
+ "content.preview": "string",
5110
+ sasIconKey: "string",
5111
+ typeRegistrant: "string"
5112
+ },
5113
+ quarantine: "boolean",
5114
+ searchable: "boolean",
5115
+ size: "number",
5116
+ typeDefName: "string",
5117
+ urlDetected: "boolean",
5118
+ version: "number",
5119
+ virusDetected: "boolean"
5120
+ }
5121
+ },
5122
+ {
5123
+ route: "PATCH /files/files/{}",
5124
+ step: "files/create",
5125
+ queries: [],
5126
+ statuses: [200],
5127
+ expected: 200,
5128
+ shape: {
5129
+ contentDisposition: "string",
5130
+ contentType: "string",
5131
+ createdBy: "string",
5132
+ creationTimeStamp: "string",
5133
+ encoding: "string",
5134
+ fileStatus: "string",
5135
+ fileVersion: "number",
5136
+ id: "string",
5137
+ links: [
5138
+ {
5139
+ href: "string",
5140
+ method: "string",
5141
+ rel: "string",
5142
+ type: "string",
5143
+ uri: "string"
5144
+ }
5145
+ ],
5146
+ modifiedBy: "string",
5147
+ modifiedTimeStamp: "string",
5148
+ name: "string",
5149
+ properties: {
5150
+ "content.download": "string",
5151
+ "content.openInBrowser": "string",
5152
+ "content.preview": "string",
5153
+ sasIconKey: "string",
5154
+ typeRegistrant: "string"
5155
+ },
5156
+ quarantine: "boolean",
5157
+ searchable: "boolean",
5158
+ size: "number",
5159
+ typeDefName: "string",
5160
+ urlDetected: "boolean",
5161
+ version: "number",
5162
+ virusDetected: "boolean"
5163
+ }
5164
+ },
5165
+ {
5166
+ route: "GET /files/files/{}/content",
5167
+ step: "files/content",
5168
+ queries: [],
5169
+ statuses: [200],
5170
+ expected: 200,
5171
+ shape: void 0
5172
+ },
5173
+ {
5174
+ route: "PUT /files/files/{}/content",
5175
+ step: "files/replace",
5176
+ queries: [],
5177
+ statuses: [200],
5178
+ expected: 200,
5179
+ shape: {
5180
+ contentDisposition: "string",
5181
+ contentType: "string",
5182
+ createdBy: "string",
5183
+ creationTimeStamp: "string",
5184
+ encoding: "string",
5185
+ fileStatus: "string",
5186
+ fileVersion: "number",
5187
+ id: "string",
5188
+ links: [
5189
+ {
5190
+ href: "string",
5191
+ method: "string",
5192
+ rel: "string",
5193
+ type: "string",
5194
+ uri: "string"
5195
+ }
5196
+ ],
5197
+ modifiedBy: "string",
5198
+ modifiedTimeStamp: "string",
5199
+ name: "string",
5200
+ properties: {
5201
+ "content.download": "string",
5202
+ "content.openInBrowser": "string",
5203
+ "content.preview": "string",
5204
+ sasIconKey: "string",
5205
+ typeRegistrant: "string"
5206
+ },
5207
+ quarantine: "boolean",
5208
+ searchable: "boolean",
5209
+ size: "number",
5210
+ typeDefName: "string",
5211
+ urlDetected: "boolean",
5212
+ version: "number",
5213
+ virusDetected: "boolean"
5214
+ }
5215
+ },
5216
+ {
5217
+ route: "POST /folders/folders",
5218
+ step: "folders/create",
5219
+ queries: ["parentFolderUri"],
5220
+ statuses: [201],
5221
+ expected: 201,
5222
+ shape: {
5223
+ createdBy: "string",
5224
+ creationTimeStamp: "string",
5225
+ id: "string",
5226
+ links: [
5227
+ {
5228
+ href: "string",
5229
+ method: "string",
5230
+ rel: "string",
5231
+ type: "string",
5232
+ uri: "string"
5233
+ }
5234
+ ],
5235
+ memberCount: "number",
5236
+ modifiedBy: "string",
5237
+ modifiedTimeStamp: "string",
5238
+ name: "string",
5239
+ parentFolderUri: "string",
5240
+ type: "string",
5241
+ version: "number"
5242
+ }
5243
+ },
5244
+ {
5245
+ route: "GET /folders/folders/{}",
5246
+ step: "folders/delete",
5247
+ queries: [],
5248
+ statuses: [200],
5249
+ expected: 200,
5250
+ shape: {
5251
+ createdBy: "string",
5252
+ creationTimeStamp: "string",
5253
+ description: "string",
5254
+ id: "string",
5255
+ links: [
5256
+ {
5257
+ href: "string",
5258
+ method: "string",
5259
+ rel: "string",
5260
+ type: "string",
5261
+ uri: "string"
5262
+ }
5263
+ ],
5264
+ memberCount: "number",
5265
+ modifiedBy: "string",
5266
+ modifiedTimeStamp: "string",
5267
+ name: "string",
5268
+ parentFolderUri: "string",
5269
+ properties: {
5270
+ allowMove: "string"
5271
+ },
5272
+ type: "string",
5273
+ version: "number"
5274
+ }
5275
+ },
5276
+ {
5277
+ route: "PATCH /folders/folders/{}",
5278
+ step: "folders/delete",
5279
+ queries: [],
5280
+ statuses: [200],
5281
+ expected: 200,
5282
+ shape: {
5283
+ createdBy: "string",
5284
+ creationTimeStamp: "string",
5285
+ id: "string",
5286
+ links: [
5287
+ {
5288
+ href: "string",
5289
+ method: "string",
5290
+ rel: "string",
5291
+ type: "string",
5292
+ uri: "string"
5293
+ }
5294
+ ],
5295
+ memberCount: "number",
5296
+ modifiedBy: "string",
5297
+ modifiedTimeStamp: "string",
5298
+ name: "string",
5299
+ parentFolderUri: "string",
5300
+ type: "string",
5301
+ version: "number"
5302
+ }
5303
+ },
5304
+ {
5305
+ route: "GET /folders/folders/{}/members",
5306
+ step: "files/content",
5307
+ queries: ["limit"],
5308
+ statuses: [200],
5309
+ expected: 200,
5310
+ shape: {
5311
+ accept: "string",
5312
+ count: "number",
5313
+ items: [
5314
+ {
5315
+ added: "string",
5316
+ contentType: "string",
5317
+ createdBy: "string",
5318
+ creationTimeStamp: "string",
5319
+ id: "string",
5320
+ links: [
5321
+ {
5322
+ href: "string",
5323
+ method: "string",
5324
+ rel: "string",
5325
+ type: "string",
5326
+ uri: "string"
5327
+ }
5328
+ ],
5329
+ modifiedBy: "string",
5330
+ modifiedTimeStamp: "string",
5331
+ name: "string",
5332
+ parentFolderUri: "string",
5333
+ type: "string",
5334
+ uri: "string",
5335
+ version: "number"
5336
+ }
5337
+ ],
5338
+ limit: "number",
5339
+ links: [
5340
+ {
5341
+ href: "string",
5342
+ itemType: "string",
5343
+ method: "string",
5344
+ rel: "string",
5345
+ type: "string",
5346
+ uri: "string"
5347
+ }
5348
+ ],
5349
+ name: "string",
5350
+ start: "number",
5351
+ version: "number"
5352
+ }
5353
+ },
5354
+ {
5355
+ route: "GET /folders/folders/@item",
5356
+ step: "files/content",
5357
+ queries: ["path"],
5358
+ statuses: [200, 401, 404],
5359
+ expected: 200,
5360
+ shape: {
5361
+ createdBy: "string",
5362
+ creationTimeStamp: "string",
5363
+ description: "string",
5364
+ id: "string",
5365
+ links: [
5366
+ {
5367
+ href: "string",
5368
+ method: "string",
5369
+ rel: "string",
5370
+ type: "string",
5371
+ uri: "string"
5372
+ }
5373
+ ],
5374
+ memberCount: "number",
5375
+ modifiedBy: "string",
5376
+ modifiedTimeStamp: "string",
5377
+ name: "string",
5378
+ parentFolderUri: "string",
5379
+ type: "string",
5380
+ version: "number"
5381
+ }
5382
+ },
5383
+ {
5384
+ route: "GET /folders/folders/@myRecycleBin",
5385
+ step: "folders/delete",
5386
+ queries: [],
5387
+ statuses: [200],
5388
+ expected: 200,
5389
+ shape: {
5390
+ createdBy: "string",
5391
+ creationTimeStamp: "string",
5392
+ description: "string",
5393
+ id: "string",
5394
+ links: [
5395
+ {
5396
+ href: "string",
5397
+ method: "string",
5398
+ rel: "string",
5399
+ type: "string",
5400
+ uri: "string"
5401
+ }
5402
+ ],
5403
+ memberCount: "number",
5404
+ modifiedBy: "string",
5405
+ modifiedTimeStamp: "string",
5406
+ name: "string",
5407
+ parentFolderUri: "string",
5408
+ properties: {
5409
+ allowMove: "string"
5410
+ },
5411
+ type: "string",
5412
+ version: "number"
5413
+ }
5414
+ },
5415
+ {
5416
+ route: "GET /identities/users/@currentUser",
5417
+ step: "identities/current-user",
5418
+ queries: [],
5419
+ statuses: [200],
5420
+ expected: 200,
5421
+ shape: {
5422
+ addresses: [
5423
+ {
5424
+ locality: "string",
5425
+ type: "string"
5426
+ }
5427
+ ],
5428
+ emailAddresses: [
5429
+ {
5430
+ type: "string",
5431
+ value: "string"
5432
+ }
5433
+ ],
5434
+ id: "string",
5435
+ links: [
5436
+ {
5437
+ href: "string",
5438
+ method: "string",
5439
+ rel: "string",
5440
+ type: "string",
5441
+ uri: "string"
5442
+ }
5443
+ ],
5444
+ name: "string",
5445
+ providerId: "string",
5446
+ state: "string",
5447
+ version: "number"
5448
+ }
5449
+ },
5450
+ {
5451
+ route: "POST /SASLogon/oauth/token",
5452
+ step: "auth/token-refresh",
5453
+ queries: [],
5454
+ statuses: [200, 401],
5455
+ expected: 200,
5456
+ shape: {
5457
+ access_token: "string",
5458
+ expires_in: "number",
5459
+ id_token: "string",
5460
+ jti: "string",
5461
+ refresh_expires_in: "number",
5462
+ refresh_revocable: "boolean",
5463
+ refresh_token: "string",
5464
+ revocable: "boolean",
5465
+ scope: "string",
5466
+ token_type: "string"
5467
+ }
5468
+ },
5469
+ {
5470
+ route: "GET /types/types",
5471
+ step: "files/create",
5472
+ queries: ["limit"],
5473
+ statuses: [200],
5474
+ expected: 200,
5475
+ shape: void 0
5476
+ }
5477
+ ];
5478
+
3567
5479
  // src/appstream/identity.ts
3568
5480
  var normaliseAppLoc = (appLoc) => {
3569
5481
  if (typeof appLoc !== "string" || appLoc === "")