@sasjs/core 7.1.12 → 7.1.14

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.
@@ -10,6 +10,12 @@
10
10
  **/
11
11
 
12
12
  %macro ml_gsubfile();
13
+ /* a narrow LRECL truncates the wide lines of the library as they
14
+ are written, so widen it for the write as well as the include */
15
+ %local optval;
16
+ %let optval=%sysfunc(getoption(lrecl));
17
+ options lrecl=1024;
18
+
13
19
  data _null_;
14
20
  file "%sysfunc(pathname(work))/ml_gsubfile.lua";
15
21
  put 'local fpath, outpath, file, fcontent ';
@@ -39,11 +45,6 @@ data _null_;
39
45
  put 'io.close(file) ';
40
46
  run;
41
47
 
42
- /* ensure big enough lrecl to avoid lua compilation issues */
43
- %local optval;
44
- %let optval=%sysfunc(getoption(lrecl));
45
- options lrecl=1024;
46
-
47
48
  /* execute the lua code by using a .lua extension */
48
49
  %inc "%sysfunc(pathname(work))/ml_gsubfile.lua" /source2;
49
50
 
package/lua/ml_json.sas CHANGED
@@ -11,6 +11,12 @@
11
11
  **/
12
12
 
13
13
  %macro ml_json();
14
+ /* a narrow LRECL truncates the wide lines of the library as they
15
+ are written, so widen it for the write as well as the include */
16
+ %local optval;
17
+ %let optval=%sysfunc(getoption(lrecl));
18
+ options lrecl=1024;
19
+
14
20
  data _null_;
15
21
  file "%sysfunc(pathname(work))/ml_json.lua";
16
22
  put '-- NOTE - THE COPYRIGHT BELOW IS IN RELATION TO THE JSON.LUA FILE ONLY ';
@@ -390,11 +396,6 @@ data _null_;
390
396
  put '-- JSON.LUA ENDS HERE ';
391
397
  run;
392
398
 
393
- /* ensure big enough lrecl to avoid lua compilation issues */
394
- %local optval;
395
- %let optval=%sysfunc(getoption(lrecl));
396
- options lrecl=1024;
397
-
398
399
  /* execute the lua code by using a .lua extension */
399
400
  %inc "%sysfunc(pathname(work))/ml_json.lua" /source2;
400
401
 
package/package.json CHANGED
@@ -54,5 +54,5 @@
54
54
  "devDependencies": {
55
55
  "@nogoo9/gitleaks": "8.30.1-post.2"
56
56
  },
57
- "version": "7.1.12"
57
+ "version": "7.1.14"
58
58
  }
@@ -6,6 +6,9 @@
6
6
 
7
7
  %mv_getfoldermembers(root=/Public, outds=work.mymembers)
8
8
 
9
+ A root with nothing to list - an empty folder, or an answer that carries no
10
+ members link - still yields &outds, with the documented columns and zero rows.
11
+
9
12
 
10
13
  @param [in] root= (/) The path for which to return the list of folders
11
14
  @param [out] outds= (work.mv_getfolders) The output dataset to create. Format:
@@ -83,9 +86,41 @@ options noquotelenmax;
83
86
  %end;
84
87
  run;
85
88
  libname &libref1 JSON fileref=&fname1;
86
- data &outds;
87
- set &libref1..items;
88
- run;
89
+ /* an empty collection produces no items dataset at all, so a straight SET
90
+ would fail with "File ...ITEMS.DATA does not exist" and leave syscc dirty */
91
+ %if %sysfunc(exist(&libref1..items))=1 %then %do;
92
+ data &outds;
93
+ /* the documented columns are declared on every path, so a caller reads
94
+ the same columns whether the collection is empty or full - an empty
95
+ collection's items dataset carries a narrower shape (no createdBy,
96
+ no timestamps) than a populated one. The declared lengths are at
97
+ least the engine's own, which are sized to the payload */
98
+ length ordinal_root 8 ordinal_items 8
99
+ creationTimeStamp $32 modifiedTimeStamp $32
100
+ createdBy $64 modifiedBy $64
101
+ id $36 uri $512 added $32 type $32
102
+ name $256 description $256;
103
+ /* initialise the declared columns - an empty collection's items
104
+ dataset carries none of the member columns, and referencing one that
105
+ the input does not supply raises "Variable x is uninitialized" */
106
+ call missing(of _all_);
107
+ set &libref1..items;
108
+ /* the engine emits one all-missing row for an empty collection */
109
+ if missing(name) and missing(uri) then delete;
110
+ run;
111
+ %end;
112
+ %else %do;
113
+ %put NOTE: &sysmacroname - no root folders found;
114
+ data &outds;
115
+ length ordinal_root 8 ordinal_items 8
116
+ creationTimeStamp $32 modifiedTimeStamp $32
117
+ createdBy $64 modifiedBy $64
118
+ id $36 uri $512 added $32 type $32
119
+ name $256 description $256;
120
+ call missing(of _all_);
121
+ stop;
122
+ run;
123
+ %end;
89
124
  %end;
90
125
  %else %do;
91
126
  /* first get parent folder id */
@@ -100,18 +135,35 @@ options noquotelenmax;
100
135
  /* now get the followon link to list members */
101
136
  %local href cnt;
102
137
  %let cnt=0;
103
- data _null_;
104
- length rel href $512;
105
- call missing(rel,href);
106
- set &libref1..links;
107
- if rel='members' then do;
108
- url=cats("'","&base_uri",href,"?limit=10000'");
109
- call symputx('href',url,'l');
110
- call symputx('cnt',1,'l');
111
- end;
112
- run;
138
+ /* a root that is not a folder (a member path, for instance) answers
139
+ without a links dataset, so a straight SET would leave syscc dirty */
140
+ %if %sysfunc(exist(&libref1..links))=1 %then %do;
141
+ data _null_;
142
+ length rel href $512;
143
+ call missing(rel,href);
144
+ set &libref1..links;
145
+ if rel='members' then do;
146
+ url=cats("'","&base_uri",href,"?limit=10000'");
147
+ call symputx('href',url,'l');
148
+ call symputx('cnt',1,'l');
149
+ end;
150
+ run;
151
+ %end;
113
152
  %if &cnt=0 %then %do;
114
153
  %put NOTE:;%put NOTE- No members found in &root!!;%put NOTE-;
154
+ /* the folder answered without a members link, so there is nothing to list -
155
+ the output dataset is still created, with the documented columns */
156
+ data &outds;
157
+ length ordinal_root 8 ordinal_items 8
158
+ creationTimeStamp $32 modifiedTimeStamp $32
159
+ createdBy $64 modifiedBy $64
160
+ id $36 uri $512 added $32 type $32
161
+ name $256 description $256;
162
+ call missing(of _all_);
163
+ stop;
164
+ run;
165
+ filename &fname1 clear;
166
+ libname &libref1 clear;
115
167
  %return;
116
168
  %end;
117
169
  %local fname2 libref2;
@@ -124,11 +176,36 @@ options noquotelenmax;
124
176
  %end;
125
177
  run;
126
178
  libname &libref2 JSON fileref=&fname2;
127
- data &outds;
128
- length id $36 name $128 uri $64 type $32 description $256;
129
- if _n_=1 then call missing (of _all_);
130
- set &libref2..items;
131
- run;
179
+ /* an emptied folder produces no items dataset at all, so a straight SET would
180
+ fail with "File ...ITEMS.DATA does not exist" and leave syscc dirty */
181
+ %if %sysfunc(exist(&libref2..items))=1 %then %do;
182
+ data &outds;
183
+ length ordinal_root 8 ordinal_items 8
184
+ creationTimeStamp $32 modifiedTimeStamp $32
185
+ createdBy $64 modifiedBy $64
186
+ id $36 uri $512 added $32 type $32
187
+ name $256 description $256;
188
+ /* initialise the declared columns - an empty collection's items
189
+ dataset carries none of the member columns, and referencing one that
190
+ the input does not supply raises "Variable x is uninitialized" */
191
+ call missing(of _all_);
192
+ set &libref2..items;
193
+ /* the engine emits one all-missing row for an empty collection */
194
+ if missing(name) and missing(uri) then delete;
195
+ run;
196
+ %end;
197
+ %else %do;
198
+ %put NOTE: &sysmacroname - &root is empty;
199
+ data &outds;
200
+ length ordinal_root 8 ordinal_items 8
201
+ creationTimeStamp $32 modifiedTimeStamp $32
202
+ createdBy $64 modifiedBy $64
203
+ id $36 uri $512 added $32 type $32
204
+ name $256 description $256;
205
+ call missing(of _all_);
206
+ stop;
207
+ run;
208
+ %end;
132
209
  filename &fname2 clear;
133
210
  libname &libref2 clear;
134
211
  %end;
@@ -20,8 +20,15 @@
20
20
  version num,
21
21
  id char(256),
22
22
  name char(256),
23
- providerId char(5),
24
- implicit num
23
+ providerId char(32),
24
+ implicit num,
25
+ type char(32)
26
+
27
+ `type` is the member type (user or group) and is declared on every path.
28
+ `implicit` is declared so a caller reading it does not fail with "Variable
29
+ implicit not found", but the identities API returns no such field, so the
30
+ column is present and always missing. A group with no members, and a group
31
+ id the server does not know, both return the columns above with zero rows.
25
32
 
26
33
  @param [in] group Group id for which to return group members
27
34
  @param [in] access_token_var= (ACCESS_TOKEN)
@@ -44,6 +51,7 @@
44
51
  @li mf_getplatform.sas
45
52
  @li mf_getuniquefileref.sas
46
53
  @li mf_getuniquelibref.sas
54
+ @li mf_existvar.sas
47
55
 
48
56
  **/
49
57
 
@@ -88,9 +96,13 @@ run;
88
96
  /*data _null_;infile &fname1;input;putlog _infile_;run;*/
89
97
  %if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
90
98
  %put NOTE: Group &group not found!!;
99
+ /* the same documented columns and zero rows as a group with no members -
100
+ call missing alone would output one all-missing observation */
91
101
  data &outds;
92
- length id name $256;
102
+ length ordinal_root 8 ordinal_items 8 version 8
103
+ id $256 name $256 providerId $32 implicit 8 type $32;
93
104
  call missing(of _all_);
105
+ stop;
94
106
  run;
95
107
  %end;
96
108
  %else %do;
@@ -100,15 +112,33 @@ run;
100
112
  )
101
113
  %let libref1=%mf_getuniquelibref();
102
114
  libname &libref1 JSON fileref=&fname1;
103
- /* id and name have to be declared, as a group with no members returns no
104
- such columns to rename. $256 is the longest active directory can hold for
105
- a display name or a SAM account name: the JSON engine sizes the columns to
106
- the longest value in the payload, so a shorter declaration truncates the
107
- name and fails the step with "Multiple lengths were specified for the
108
- variable ... by input data set(s)". */
115
+ /* a group with no members returns a collection whose items dataset carries no
116
+ member columns, so a straight SET would raise "Variable id is uninitialized"
117
+ and leave syscc dirty. Only copy when there is something to copy. The
118
+ documented columns are declared on both paths, so an empty group hands the
119
+ caller the same PDV as a populated one. The lengths are declared because
120
+ the JSON engine sizes its columns to the longest value in the payload:
121
+ $256 is the longest an active directory display name or SAM account name
122
+ can hold, and a shorter declaration lets the engine report "Multiple
123
+ lengths were specified" on a later member. */
124
+ %local itemsds hasvars;
125
+ %let itemsds=&libref1..items;
126
+ %let hasvars=0;
127
+ %if %sysfunc(exist(&itemsds))=1 %then %do;
128
+ %if %mf_existvar(&itemsds,id)>0 %then %let hasvars=1;
129
+ %end;
109
130
  data &outds;
110
- length id name $256;
111
- set &libref1..items;
131
+ length ordinal_root 8 ordinal_items 8 version 8
132
+ id $256 name $256 providerId $32 implicit 8 type $32;
133
+ call missing(of _all_);
134
+ %if &hasvars=1 %then %do;
135
+ set &itemsds;
136
+ /* the engine emits one all-missing row for an empty collection */
137
+ if missing(id) then delete;
138
+ %end;
139
+ %else %do;
140
+ stop;
141
+ %end;
112
142
  run;
113
143
  libname &libref1 clear;
114
144
  %end;
@@ -19,7 +19,12 @@
19
19
  @param [in] grant_type= (sas_services)
20
20
  Valid values are "password" or "authorization_code" (unquoted).
21
21
  @param [out] outds= (work.mv_getusergroups)
22
- The library.dataset to be created that contains the list of groups
22
+ The library.dataset to be created that contains the list of groups. Format:
23
+ |ordinal_root|ordinal_items|version|id|implicit|name|providerId|
24
+ |---|---|---|---|---|---|---|
25
+ |1|1|1|viyagroup18|0|SAS Viyagroup18|ldap|
26
+
27
+ A user the server does not know returns the columns above with zero rows.
23
28
 
24
29
 
25
30
  @version VIYA V.03.04
@@ -73,8 +78,19 @@ proc http method='GET' out=&fname1 &oauth_bearer
73
78
  "Accept"="application/json";
74
79
  run;
75
80
  /*data _null_;infile &fname1;input;putlog _infile_;run;*/
81
+ /* a 404 answers with a document that carries no items dataset, so the output
82
+ is written here instead, with the documented columns and zero rows, and the
83
+ JSON libref is never assigned */
76
84
  %if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
77
85
  %put NOTE: User &user not found!!;
86
+ data &outds;
87
+ length ordinal_root 8 ordinal_items 8 version 8
88
+ id $256 implicit 8 name $256 providerId $32;
89
+ call missing(of _all_);
90
+ stop;
91
+ run;
92
+ filename &fname1 clear;
93
+ %return;
78
94
  %end;
79
95
  %else %do;
80
96
  %mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200)
@@ -84,7 +100,12 @@ run;
84
100
  %end;
85
101
  libname &libref1 JSON fileref=&fname1;
86
102
 
103
+ /* the documented columns are declared on both paths, so a caller reads the
104
+ same columns whether the user has memberships or is unknown. The lengths
105
+ are at least the engine's own, which are sized to the payload */
87
106
  data &outds;
107
+ length ordinal_root 8 ordinal_items 8 version 8
108
+ id $256 implicit 8 name $256 providerId $32;
88
109
  set &libref1..items;
89
110
  run;
90
111