@sasjs/core 7.1.13 → 7.1.15

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/.sasjslint CHANGED
@@ -6,6 +6,7 @@
6
6
  "hasMacroParentheses": true,
7
7
  "lineEndings": "lf",
8
8
  "noGremlins": true,
9
+ "noMalformedMacroCalls": true,
9
10
  "noNestedMacros": true,
10
11
  "noSingleAsteriskComments": true,
11
12
  "noSpacesInFileNames": true,
@@ -21,11 +22,13 @@
21
22
  "indentationMultiple": "error",
22
23
  "lineEndings": "error",
23
24
  "lowerCaseFileNames": "error",
25
+ "lowerCaseMacroNames": "error",
24
26
  "maxLineLength": "error",
25
27
  "minMacroNameLength": "error",
26
28
  "noBannedStrings": "error",
27
29
  "noEncodedPasswords": "error",
28
30
  "noGremlins": "error",
31
+ "noMalformedMacroCalls": "error",
29
32
  "noNestedCommentsInHeader": "error",
30
33
  "noNestedMacros": "error",
31
34
  "noSingleAsteriskComments": "error",
package/README.md CHANGED
@@ -224,9 +224,9 @@ We are currently on major release v6. The following breaking changes were appli
224
224
 
225
225
  ### Cutting a release
226
226
 
227
- Releases are cut by `semantic-release` from the commit messages on `main`, so the squashed PR message is what decides the version:
227
+ Releases are cut by `@sasjs/release` from the commit messages on `main`, so the squashed PR message is what decides the version:
228
228
 
229
- * a breaking change needs a `BREAKING CHANGE:` footer in the commit body. The `!` after the type on its own did not bump the major on this pipeline - the v6 rename merged as `feat!:` and shipped as a patch release.
229
+ * a breaking change bumps the major when the subject carries `!` after the type (`feat!:`) or the body carries a `BREAKING CHANGE:` footer. The previous pipeline ignored `!` on its own - the v6 rename merged as `feat!:` and shipped as a patch - and this one does not.
230
230
  * no commit that reaches `main` may carry a skip marker (`[skip ci]` and friends), including one copied in by the squashed commit list. A skip marker suppresses every workflow for that push, the release job included, and nothing is published.
231
231
 
232
232
  ## Star Gazing
@@ -33,7 +33,7 @@
33
33
  @version 9.2
34
34
  **/
35
35
 
36
- %macro mf_getVarFormat(libds /* two level ds name */
36
+ %macro mf_getvarformat(libds /* two level ds name */
37
37
  , var /* variable name from which to return the format */
38
38
  , force=0
39
39
  )/*/STORE SOURCE*/;
@@ -70,4 +70,4 @@
70
70
  %let rc = %sysfunc(close(&dsid));
71
71
  /* Return variable format */
72
72
  &vformat
73
- %mend mf_getVarFormat;
73
+ %mend mf_getvarformat;
@@ -27,7 +27,7 @@
27
27
 
28
28
  **/
29
29
 
30
- %macro mf_getVarLen(libds /* two level ds name */
30
+ %macro mf_getvarlen(libds /* two level ds name */
31
31
  , var /* variable name from which to return the length */
32
32
  )/*/STORE SOURCE*/;
33
33
  %local dsid vnum vlen rc;
@@ -53,4 +53,4 @@
53
53
  %let rc = %sysfunc(close(&dsid));
54
54
  /* Return variable format */
55
55
  &vlen
56
- %mend mf_getVarLen;
56
+ %mend mf_getvarlen;
@@ -29,7 +29,7 @@ returns:
29
29
 
30
30
  **/
31
31
 
32
- %macro mf_getVarNum(libds /* two level ds name */
32
+ %macro mf_getvarnum(libds /* two level ds name */
33
33
  , var /* variable name from which to return the format */
34
34
  )/*/STORE SOURCE*/;
35
35
  %local dsid vnum rc;
@@ -55,4 +55,4 @@ returns:
55
55
  /* Return variable number */
56
56
  &vnum.
57
57
 
58
- %mend mf_getVarNum;
58
+ %mend mf_getvarnum;
@@ -97,7 +97,7 @@ create table _data_ as
97
97
  %local colconst; %let colconst=&syslast;
98
98
 
99
99
  %local constraints_used;
100
- %macro addConst();
100
+ %macro addconst();
101
101
  data _null_;
102
102
  length ctype $11 constraint_name_orig $256 constraints_used $5000;
103
103
  set &colconst(
@@ -129,7 +129,7 @@ create table _data_ as
129
129
  end;
130
130
  run;
131
131
  %put &=constraints_used;
132
- %mend addConst;
132
+ %mend addconst;
133
133
 
134
134
  data _null_;
135
135
  file &fref mod;
@@ -20,7 +20,7 @@
20
20
 
21
21
  **/
22
22
 
23
- %macro mm_getDirectories(
23
+ %macro mm_getdirectories(
24
24
  path=
25
25
  ,outds=work.mm_getDirectories
26
26
  ,mDebug=0
@@ -55,4 +55,4 @@ data &outds (keep=directoryuri name directoryname directorydesc );
55
55
  end;
56
56
  run;
57
57
 
58
- %mend mm_getDirectories;
58
+ %mend mm_getdirectories;
@@ -27,7 +27,7 @@
27
27
 
28
28
  **/
29
29
 
30
- %macro mm_getGroups(
30
+ %macro mm_getgroups(
31
31
  user=
32
32
  ,outds=work.mm_getGroups
33
33
  ,repo=foundation
@@ -93,4 +93,4 @@
93
93
  options metarepository=&oldrepo;
94
94
  %end;
95
95
 
96
- %mend mm_getGroups;
96
+ %mend mm_getgroups;
@@ -24,7 +24,7 @@
24
24
 
25
25
  **/
26
26
 
27
- %macro mm_getTree(
27
+ %macro mm_gettree(
28
28
  tree=
29
29
  ,inds=
30
30
  ,outds=work.mm_getTree
@@ -65,4 +65,4 @@ data &outds;
65
65
  if treeuri ne "" and treepath ne "" then output;
66
66
  stop;
67
67
  run;
68
- %mend mm_getTree;
68
+ %mend mm_gettree;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@sasjs/core",
3
3
  "description": "Production-quality MIT-licensed SAS macro library (mf_*, mp_*, mm* macros) for SAS 9 and Viya application development",
4
+ "version": "7.1.15",
4
5
  "license": "MIT",
5
6
  "keywords": [
6
7
  "SAS",
@@ -19,22 +20,6 @@
19
20
  "type": "git",
20
21
  "url": "git+https://github.com/sasjs/core.git"
21
22
  },
22
- "release": {
23
- "branches": [
24
- "main"
25
- ],
26
- "plugins": [
27
- "@semantic-release/commit-analyzer",
28
- "@semantic-release/release-notes-generator",
29
- [
30
- "@semantic-release/npm",
31
- {
32
- "npmPublish": false
33
- }
34
- ],
35
- "@semantic-release/github"
36
- ]
37
- },
38
23
  "publishConfig": {
39
24
  "access": "public"
40
25
  },
@@ -46,13 +31,15 @@
46
31
  "build": "npx @sasjs/cli cbd -t server",
47
32
  "docs": "npx @sasjs/cli doc -t docsonly && ./sasjs/utils/build.sh",
48
33
  "test": "npx @sasjs/cli test -t server",
49
- "lint": "npx @sasjs/cli lint"
34
+ "lint": "npx @sasjs/cli lint",
35
+ "release": "sasjs-release",
36
+ "prepublishOnly": "node -e \"const v=require('./package.json').version; if (/^0\\.0\\.0/.test(v)) { console.error('refusing to publish ' + v + ': the version is stamped from the tag when publishing'); process.exit(1) }\""
50
37
  },
51
38
  "maintainers": [
52
39
  "https://sasapps.io"
53
40
  ],
54
41
  "devDependencies": {
55
- "@nogoo9/gitleaks": "8.30.1-post.2"
56
- },
57
- "version": "7.1.13"
42
+ "@nogoo9/gitleaks": "8.30.1-post.2",
43
+ "@sasjs/release": "0.3.2"
44
+ }
58
45
  }
@@ -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
 
@@ -32,7 +32,7 @@
32
32
 
33
33
  **/
34
34
 
35
- %macro mv_getViyaFileExtParms(
35
+ %macro mv_getviyafileextparms(
36
36
  ext,
37
37
  typeDefNameVar=,
38
38
  propertiesVar=,
@@ -250,4 +250,4 @@
250
250
 
251
251
  %end;
252
252
 
253
- %mend mv_getViyaFileExtParms;
253
+ %mend mv_getviyafileextparms;