@sasjs/core 5.7.2 → 5.7.3

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/README.md CHANGED
@@ -209,7 +209,7 @@ When contributing to this library, it is therefore important to ensure that all
209
209
  - Mandatory parameters should be positional, all optional parameters should be keyword (var=) style.
210
210
  - All dataset references must be 2 level (eg `work.blah`, not `blah`). This is to avoid contention when options [DATASTMTCHK](https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279064.htm)=ALLKEYWORDS is in effect, or the [USER](https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/n18m1vkqmeo4esn1moikt23zhp8s.htm) library is active.
211
211
  - Avoid naming collisions! All macro variables should be local scope. Use system generated work tables where possible - eg `data ; set sashelp.class; run; data &output; set &syslast; run;`
212
- - Where global macro variables are absolutely necessary, they should make use of `&sasjs_prefix` - see mp_init.sas
212
+ - Where global macro variables are absolutely necessary, they must use the hard-coded `_SASJS_` prefix and be declared in mp_init.sas - see mp_init.sas
213
213
  - The use of `quit;` for `proc sql` is essential, to avoid `WARNING: You cannot disconnect or terminate session XXXX until the procedure completes.` when terminating CAS sessions in Viya.
214
214
  - Use [sasjs lint](https://github.com/sasjs/lint)!
215
215
 
@@ -220,15 +220,10 @@ When contributing to this library, it is therefore important to ensure that all
220
220
 
221
221
  ## Breaking Changes
222
222
 
223
- We are currently on major release v5. The following breaking changes were applied as part of the v5 release:
223
+ We are currently on major release v6. The following breaking changes were applied as part of the v6 release:
224
224
 
225
- * mcf_xxx macros - the `insert_cmplib` option was removed (the option is now checked automatically with value inserted only if needed)
226
- * mcf_xxx macros - the `wrap=` option now defaults to YES for convenience. Set this option explicitly to avoid issues.
227
- * mf_getuniquelibref.sas - the deprecated maxtries parameter was removed (no longer needed)
228
- * mp_abort.sas - the redundant type= parameter was removed.
229
- * mp_coretable.sas - removed, and replaced by the standalone macros in the `ddl` folder
230
- * mp_getddl.sas - renamed to mp_ds2ddl.sas (consistent with other ds2xxx macros). The default for SHOWLOG is now YES instead of NO.
231
- * mp_testservice.sas - renamed to mx_execute.sas (as it doesn't actually test anything, and the mp_ suite should not reference mx_ macros)
225
+ * all macros - the session macro variables were renamed to the `_SASJS_` prefix, matching the names sasjs/server sets in its pre-programs. `SASJSWORK` is now `_SASJS_WORK`, `SASJS_INIT_NUM` is `_SASJS_INIT_NUM`, `SASJS_INIT_DTTM` is `_SASJS_INIT_DTTM`, `SASJSPROCESSMODE` is `_SASJS_PROCESSMODE` and `SASJS_FUNCTIONS` is `_SASJS_FUNCTIONS`. Code that built paths, tests or ignore lists from the old names must read the new ones - core no longer creates the old names and no alias variables are declared. The one name that still answers to its old form is the initialisation marker described in the next point, which is honoured rather than created.
226
+ * mp_init.sas - the `prefix=` parameter was removed, and the prefix is hard-coded as `_SASJS_`. Call `%mp_init()` with no arguments. The "do not initialise" marker is renamed with everything else: set `_SASJS_INIT` (formerly `SASJS_PREFIX`) in the autoexec, to any value, to suppress initialisation. `SASJS_PREFIX` still suppresses initialisation if it is already set, so an existing autoexec keeps working unchanged; core no longer sets it.
232
227
 
233
228
  ## Star Gazing
234
229
 
@@ -3,11 +3,11 @@
3
3
  @brief Deletes a physical file, if it exists
4
4
  @details Usage:
5
5
 
6
- %mf_writefile(&sasjswork/myfile.txt,l1=some content)
6
+ %mf_writefile(&_sasjs_work/myfile.txt,l1=some content)
7
7
 
8
- %mf_deletefile(&sasjswork/myfile.txt)
8
+ %mf_deletefile(&_sasjs_work/myfile.txt)
9
9
 
10
- %mf_deletefile(&sasjswork/myfile.txt)
10
+ %mf_deletefile(&_sasjs_work/myfile.txt)
11
11
 
12
12
 
13
13
  @param [in] file Full path to the target file
@@ -26,8 +26,8 @@
26
26
  )/*/STORE SOURCE*/;
27
27
  %local a b c;
28
28
  %if &switch.NONE=NONE %then %do;
29
- %if %symexist(sasjsprocessmode) %then %do;
30
- %if &sasjsprocessmode=Stored Program %then %do;
29
+ %if %symexist(_sasjs_processmode) %then %do;
30
+ %if &_sasjs_processmode=Stored Program %then %do;
31
31
  SASJS
32
32
  %return;
33
33
  %end;
@@ -9,9 +9,9 @@
9
9
 
10
10
  Usage:
11
11
 
12
- %mf_writefile(&sasjswork/myfile.txt,l1=some content,l2=more content)
12
+ %mf_writefile(&_sasjs_work/myfile.txt,l1=some content,l2=more content)
13
13
 
14
- %put %mf_readfile(&sasjswork/myfile.txt);
14
+ %put %mf_readfile(&_sasjs_work/myfile.txt);
15
15
 
16
16
 
17
17
  @param [in] fpath Full path to file to be read
@@ -10,9 +10,9 @@
10
10
 
11
11
  Usage:
12
12
 
13
- %mf_writefile(&sasjswork/myfile.txt,l1=some content,l2=more content)
13
+ %mf_writefile(&_sasjs_work/myfile.txt,l1=some content,l2=more content)
14
14
  data _null_;
15
- infile "&sasjswork/myfile.txt";
15
+ infile "&_sasjs_work/myfile.txt";
16
16
  input;
17
17
  list;
18
18
  run;
package/base/mp_abort.sas CHANGED
@@ -66,7 +66,6 @@
66
66
  , mode=REGULAR
67
67
  )/*/STORE SOURCE*/;
68
68
 
69
- %global sysprocessmode sysprocessname _sasjs_webout_headers sasjsprocessmode;
70
69
  %local fref fid i;
71
70
 
72
71
  %if not(%eval(%unquote(&iftrue))) %then %return;
@@ -171,18 +170,24 @@ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
171
170
  name="_webout.json" lrecl=999999 mod;
172
171
  %end;
173
172
  %end;
174
- %else %if %sysfunc(filename(fref,&_sasjs_webout_headers))=0 %then %do;
175
- options nobomfile;
176
- /* set up http header for SASjs Server */
177
- %let fid=%sysfunc(fopen(&fref,A));
178
- %if &fid=0 %then %do;
179
- %put %str(ERR)OR: %sysfunc(sysmsg());
180
- %return;
173
+ %else %if %symexist(_sasjs_webout_headers) %then %do;
174
+ /* the header location is declared by mp_init, not here - a %global on the
175
+ abort path adds it to the caller's scope mid-session, which is the scope
176
+ leak mp_assertscope reports as Add:(_SASJS_WEBOUT_HEADERS). Guarded
177
+ because a session that never ran mp_init has no value to read. */
178
+ %if %sysfunc(filename(fref,&_sasjs_webout_headers))=0 %then %do;
179
+ options nobomfile;
180
+ /* set up http header for SASjs Server */
181
+ %let fid=%sysfunc(fopen(&fref,A));
182
+ %if &fid=0 %then %do;
183
+ %put %str(ERR)OR: %sysfunc(sysmsg());
184
+ %return;
185
+ %end;
186
+ %let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
187
+ %let rc=%sysfunc(fwrite(&fid));
188
+ %let rc=%sysfunc(fclose(&fid));
189
+ %let rc=%sysfunc(filename(&fref));
181
190
  %end;
182
- %let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
183
- %let rc=%sysfunc(fwrite(&fid));
184
- %let rc=%sysfunc(fclose(&fid));
185
- %let rc=%sysfunc(filename(&fref));
186
191
  %end;
187
192
 
188
193
  /* send response in SASjs JSON format */
@@ -204,7 +209,7 @@ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
204
209
  msg=cats('"',msg,'"');
205
210
  if symexist('_debug') then debug=quote(trim(symget('_debug')));
206
211
  else debug='""';
207
- if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
212
+ if symget('_sasjs_processmode')='Stored Program' then mode='SASJS';
208
213
  if mode ne 'SASJS' then put '>>weboutBEGIN<<';
209
214
  put '{"SYSDATE" : "' "&SYSDATE" '"';
210
215
  put ',"SYSTIME" : "' "&SYSTIME" '"';
@@ -14,12 +14,12 @@
14
14
  The following variables are NOT tested (as they are known, global variables
15
15
  used in SASjs):
16
16
 
17
- @li &sasjs_prefix._FUNCTIONS
17
+ @li _SASJS_FUNCTIONS
18
18
 
19
19
  Global variables are initialised in mp_init.sas - which will also trigger
20
20
  "strict mode" in your SAS session. Whilst this is a default in SASjs
21
21
  produced apps, if you prefer not to use this mode, simply instantiate the
22
- following variable to prevent the macro from running: `SASJS_PREFIX`
22
+ following variable to prevent the macro from running: `_SASJS_INIT`
23
23
 
24
24
  Example usage:
25
25
 
@@ -76,12 +76,12 @@
76
76
  /**
77
77
  * this sets up the global vars, it will also enter STRICT mode. If this
78
78
  * behaviour is not desired, simply initiate the following global macro
79
- * variable to prevent the macro from running: SASJS_PREFIX
79
+ * variable to prevent the macro from running: _SASJS_INIT
80
80
  */
81
81
  %mp_init()
82
82
 
83
83
  %local ds test_result test_comments del add mod ilist;
84
- %let ilist=%upcase(&sasjs_prefix._FUNCTIONS SYS_PROCHTTP_STATUS_CODE
84
+ %let ilist=%upcase(&_SASJS_FUNCTIONS SYS_PROCHTTP_STATUS_CODE
85
85
  SYS_PROCHTTP_STATUS_CODE SYS_PROCHTTP_STATUS_PHRASE &ignorelist);
86
86
 
87
87
  /* get current variables */
@@ -95,8 +95,9 @@ data &outds;
95
95
  /*length GROUP_LOGIC SUBGROUP_LOGIC $3 SUBGROUP_ID 8 VARIABLE_NM $32
96
96
  OPERATOR_NM $10 RAW_VALUE $4000;*/
97
97
  set &inds end=last;
98
- length reason_cd $4032 vtype vtype2 $1 vnum dsid 8 tmp $4000 re_temporal 8;
99
- drop tmp re_temporal;
98
+ length reason_cd $4032 vtype vtype2 $1 vnum dsid 8 tmp $4000 re_temporal 8
99
+ vref $64;
100
+ drop tmp re_temporal vref;
100
101
  retain re_temporal;
101
102
  /* SAS temporal literals - date, datetime and time */
102
103
  if _n_=1 then re_temporal=prxparse("/^'[^']*'(dt|d|t)$/i");
@@ -171,6 +172,48 @@ data &outds;
171
172
  output;
172
173
  end;
173
174
 
175
+ /* CONTAINS is a character-only operator - the engine rejects a numeric
176
+ operand, so catch the pairing here rather than letting the generated
177
+ clause fail validation with no reference to the offending variable */
178
+ if vtype='N' & OPERATOR_NM='CONTAINS' then do;
179
+ vref=cats("&targetds",'.',VARIABLE_NM);
180
+ REASON_CD=catx(' ','CONTAINS is only valid for character variables -'
181
+ ,vref,'is numeric');
182
+ putlog REASON_CD= OPERATOR_NM=;
183
+ call symputx('reason_cd',reason_cd,'l');
184
+ call symputx('nobs',_n_,'l');
185
+ output;
186
+ return;
187
+ end;
188
+
189
+ /* the operand must be a string literal or a character variable - the
190
+ engine rejects an unquoted numeric value even where the column is
191
+ character, eg 'name contains 12' */
192
+ if vtype='C' & OPERATOR_NM='CONTAINS'
193
+ & subpad(strip(raw_value),1,1) not in ('"',"'")
194
+ then do;
195
+ vref=cats("&targetds",'.',VARIABLE_NM);
196
+ /* a bare value can only be a variable reference if it is a valid name */
197
+ vnum=0;
198
+ if prxmatch('/^[a-z_][a-z0-9_]*$/i',strip(raw_value))>0 then do;
199
+ vnum=varnum(dsid,strip(raw_value));
200
+ end;
201
+ if vnum>=1 then do;
202
+ /* the name is a variable of this table - the type must be character */
203
+ vtype2=vartype(dsid,vnum);
204
+ if vtype2='C' then return;
205
+ REASON_CD=catx(' ',"Compared Type ("!!vtype2!!") is not (C) -"
206
+ ,vref,'CONTAINS',cats(raw_value));
207
+ end;
208
+ else REASON_CD=catx(' ','CONTAINS requires a quoted value or a character'
209
+ ,'variable -',vref,'CONTAINS',cats(raw_value));
210
+ putlog REASON_CD= OPERATOR_NM=;
211
+ call symputx('reason_cd',reason_cd,'l');
212
+ call symputx('nobs',_n_,'l');
213
+ output;
214
+ return;
215
+ end;
216
+
174
217
  /* special missing logic */
175
218
  if vtype='N' & OPERATOR_NM in ('=','>','<','<=','>=','NE','GE','LE') then do;
176
219
  if cats(upcase(raw_value)) in (
package/base/mp_init.sas CHANGED
@@ -19,39 +19,44 @@
19
19
  variable - feel free to [raise an issue](
20
20
  https://github.com/sasjs/core/issues/new)!
21
21
 
22
- All global variables are prefixed with "SASJS" (unless modified with the
23
- prefix parameter).
24
-
25
- @param [in] prefix= (SASJS) The prefix to apply to the global macro variables
22
+ All the system variables this macro creates use the hard-coded `_SASJS_`
23
+ prefix - the same namespace sasjs/server uses in the pre-program it
24
+ generates for each session (`_SASJS_WEBOUT_HEADERS`, `_SASJS_TOKENFILE`,
25
+ `_SASJS_USERNAME` ...). There is no configurable prefix.
26
26
 
27
+ Setting `_SASJS_INIT` before this macro runs skips it, which is how an
28
+ autoexec opts out - a second pass would re-apply the options below.
27
29
 
28
30
  @version 9.2
29
31
  @author Allan Bowe
30
32
 
31
33
  **/
32
34
 
33
- %macro mp_init(prefix=SASJS
35
+ %macro mp_init(
34
36
  )/*/STORE SOURCE*/;
35
37
 
36
- %if %symexist(SASJS_PREFIX) %then %return; /* only run once */
38
+ /* only run once. The guard is the marker: an autoexec that sets it is the
39
+ documented way to skip this macro, and a second pass would re-apply the
40
+ options below mid-session. SASJS_PREFIX is the name an existing autoexec
41
+ would set, so it suppresses initialisation too. */
42
+ %if %symexist(_SASJS_INIT) or %symexist(SASJS_PREFIX) %then %return;
37
43
 
38
44
  %global
39
- SASJS_PREFIX /* the ONLY hard-coded global macro variable in SASjs */
40
- &prefix.PROCESSMODE &prefix._STPSRV_HEADER_LOC /* SASjs server specific vars*/
41
- &prefix._FUNCTIONS /* used in mcf_init() to track core function compilation */
42
- &prefix._INIT_NUM /* initialisation time as numeric */
43
- &prefix._INIT_DTTM /* initialisation time in E8601DT26.6 format */
44
- &prefix.WORK /* avoid typing %sysfunc(pathname(work)) every time */
45
- &prefix.PROCESSMODE
46
- &prefix._STPSRV_HEADER_LOC
45
+ _SASJS_INIT /* set to any value by this macro: "already initialised" */
46
+ _SASJS_PROCESSMODE /* process mode, as the server's pre-program names it */
47
+ _SASJS_WEBOUT_HEADERS /* the server's webout header file location */
48
+ _SASJS_FUNCTIONS /* used in mcf_init() to track core function compilation */
49
+ _SASJS_INIT_NUM /* initialisation time as numeric */
50
+ _SASJS_INIT_DTTM /* initialisation time in E8601DT26.6 format */
51
+ _SASJS_WORK /* avoid typing %sysfunc(pathname(work)) every time */
47
52
  ;
48
- %let sasjs_prefix=&prefix;
53
+ %let _sasjs_init=1;
49
54
 
50
55
  data _null_;
51
56
  dttm=datetime();
52
- call symputx("&sasjs_prefix._init_num",dttm,'g');
53
- call symputx("&sasjs_prefix._init_dttm",put(dttm,E8601DT26.6),'g');
54
- call symputx("&sasjs_prefix.work",pathname('WORK'),'g');
57
+ call symputx('_SASJS_INIT_NUM',dttm,'g');
58
+ call symputx('_SASJS_INIT_DTTM',put(dttm,E8601DT26.6),'g');
59
+ call symputx('_SASJS_WORK',pathname('WORK'),'g');
55
60
  run;
56
61
 
57
62
  options
package/fcmp/mcf_init.sas CHANGED
@@ -23,21 +23,16 @@
23
23
  %macro mcf_init(func
24
24
  )/*/STORE SOURCE*/;
25
25
 
26
- %if not (%symexist(SASJS_PREFIX)) %then %do;
27
- %global SASJS_PREFIX;
28
- %let SASJS_PREFIX=SASJS;
29
- %end;
30
-
31
26
  %let func=%upcase(&func);
32
27
 
33
28
  /* the / character is just a seperator */
34
- %global &sasjs_prefix._FUNCTIONS;
35
- %if %index(&&&sasjs_prefix._FUNCTIONS,&func/)>0 %then %do;
29
+ %global _SASJS_FUNCTIONS;
30
+ %if %index(&_SASJS_FUNCTIONS,&func/)>0 %then %do;
36
31
  1
37
32
  %return;
38
33
  %end;
39
34
  %else %do;
40
- %let &sasjs_prefix._FUNCTIONS=&&&sasjs_prefix._FUNCTIONS &func/;
35
+ %let _SASJS_FUNCTIONS=&_SASJS_FUNCTIONS &func/;
41
36
  0
42
37
  %end;
43
38
 
package/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "@nogoo9/gitleaks": "8.30.1-post.2"
45
45
  },
46
- "version": "5.7.2"
46
+ "version": "5.7.3"
47
47
  }