@sasjs/core 4.4.1 → 4.4.5
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 +4 -5
- package/base/mf_getapploc.sas +7 -2
- package/base/mp_streamfile.sas +32 -15
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ Macros used for interfacing with SAS Viya.
|
|
|
81
81
|
|
|
82
82
|
Wait - this is a macro library - what is LUA doing here? Well, it is a little known fact that you CAN run LUA within a SAS Macro. It has to be written to a text file with a `.lua` extension, from where you can `%include` it. So, without using the `proc lua` wrapper.
|
|
83
83
|
|
|
84
|
-
To contribute, simply write your freeform LUA in the LUA folder. Then run the `build.py`, which will convert
|
|
84
|
+
To contribute, simply write your freeform LUA in the LUA folder. Then run the `build.py`, which will convert all files with a ".lua" extension into a macro wrapper with an `ml_` prefix (embedding the necessary data step put statements). You can then use your module in any program by running:
|
|
85
85
|
|
|
86
86
|
```sas
|
|
87
87
|
/* compile the lua module */
|
|
@@ -95,8 +95,7 @@ endsubmit;
|
|
|
95
95
|
run;
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
-
|
|
99
|
-
- Prefixes: _mmw_,_mmu_,_mmx_
|
|
98
|
+
- Prefixes: _ml_
|
|
100
99
|
|
|
101
100
|
## Installation
|
|
102
101
|
|
|
@@ -129,11 +128,11 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
|
|
129
128
|
- _mf_ for macro functions (can be used in open code).
|
|
130
129
|
- _ml_ for macros that are used to compile LUA modules
|
|
131
130
|
- _mm_ for metadata macros (interface with the metadata server).
|
|
132
|
-
- _mmx_ for macros that use metadata and are XCMD enabled
|
|
131
|
+
- _mmx_ for macros that use metadata and are XCMD enabled (working on both windows and unix)
|
|
133
132
|
- _mp_ for macro procedures (which generate sas code)
|
|
134
133
|
- _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
|
135
134
|
- _mv_ for macro procedures that will only work in Viya
|
|
136
|
-
- _mx_ for macros that are XCMD enabled
|
|
135
|
+
- _mx_ for macros that are XCMD enabled (working on both windows and unix)
|
|
137
136
|
- follow verb-noun convention
|
|
138
137
|
- unix style line endings (lf)
|
|
139
138
|
- individual lines should be no more than 80 characters long
|
package/base/mf_getapploc.sas
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
@li /data
|
|
16
16
|
@li /jobs
|
|
17
17
|
@li /services
|
|
18
|
+
@li /tests
|
|
18
19
|
@li /tests/jobs
|
|
19
20
|
@li /tests/services
|
|
20
21
|
@li /tests/macros
|
|
@@ -46,9 +47,13 @@
|
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* First check we are not in the tests/macros folder (which has no subfolders)
|
|
50
|
+
* or specifically in the testsetup or testteardown services
|
|
49
51
|
*/
|
|
50
|
-
%if %index(&pgm,/tests/macros/)
|
|
51
|
-
|
|
52
|
+
%if %index(&pgm,/tests/macros/)
|
|
53
|
+
or %index(&pgm,/tests/testsetup)
|
|
54
|
+
or %index(&pgm,/tests/testteardown)
|
|
55
|
+
%then %do;
|
|
56
|
+
%let root=%substr(&pgm,1,%index(&pgm,/tests)-1);
|
|
52
57
|
&root
|
|
53
58
|
%return;
|
|
54
59
|
%end;
|
package/base/mp_streamfile.sas
CHANGED
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
@param [in] contenttype= (TEXTS) Either TEXT, ZIP, CSV, EXCEL
|
|
16
16
|
@param [in] inloc= /path/to/file.ext to be sent
|
|
17
17
|
@param [in] inref= fileref of file to be sent (if provided, overrides `inloc`)
|
|
18
|
+
@param [in] iftrue= (1=1) Provide a condition under which to execute.
|
|
18
19
|
@param [out] outname= the name of the file, as downloaded by the browser
|
|
20
|
+
@param [out] outref= (_webout) The destination where the file should be
|
|
21
|
+
streamed.
|
|
19
22
|
|
|
20
23
|
<h4> SAS Macros </h4>
|
|
21
24
|
@li mf_getplatform.sas
|
|
@@ -29,13 +32,17 @@
|
|
|
29
32
|
contenttype=TEXT
|
|
30
33
|
,inloc=
|
|
31
34
|
,inref=0
|
|
35
|
+
,iftrue=%str(1=1)
|
|
32
36
|
,outname=
|
|
37
|
+
,outref=_webout
|
|
33
38
|
)/*/STORE SOURCE*/;
|
|
34
39
|
|
|
40
|
+
%if not(%eval(%unquote(&iftrue))) %then %return;
|
|
41
|
+
|
|
35
42
|
%let contentype=%upcase(&contenttype);
|
|
43
|
+
%let outref=%upcase(&outref);
|
|
36
44
|
%local platform; %let platform=%mf_getplatform();
|
|
37
45
|
|
|
38
|
-
|
|
39
46
|
/**
|
|
40
47
|
* check engine type to avoid the below err message:
|
|
41
48
|
* > Function is only valid for filerefs using the CACHE access method.
|
|
@@ -43,7 +50,7 @@
|
|
|
43
50
|
%local streamweb;
|
|
44
51
|
%let streamweb=0;
|
|
45
52
|
data _null_;
|
|
46
|
-
set sashelp.vextfl(where=(upcase(fileref)="
|
|
53
|
+
set sashelp.vextfl(where=(upcase(fileref)="&outref"));
|
|
47
54
|
if xengine='STREAM' then call symputx('streamweb',1,'l');
|
|
48
55
|
run;
|
|
49
56
|
|
|
@@ -55,7 +62,7 @@ run;
|
|
|
55
62
|
run;
|
|
56
63
|
%end;
|
|
57
64
|
%else %if &platform=SASVIYA %then %do;
|
|
58
|
-
filename
|
|
65
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
59
66
|
contenttype='application/csv'
|
|
60
67
|
contentdisp="attachment; filename=&outname";
|
|
61
68
|
%end;
|
|
@@ -69,14 +76,25 @@ run;
|
|
|
69
76
|
run;
|
|
70
77
|
%end;
|
|
71
78
|
%else %if &platform=SASVIYA %then %do;
|
|
72
|
-
filename
|
|
79
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
|
73
80
|
contenttype='application/vnd.ms-excel'
|
|
74
81
|
contentdisp="attachment; filename=&outname";
|
|
75
82
|
%end;
|
|
76
83
|
%end;
|
|
84
|
+
%else %if &contentype=GIF or &contentype=JPEG or &contentype=PNG %then %do;
|
|
85
|
+
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
86
|
+
data _null_;
|
|
87
|
+
rc=stpsrv_header('Content-type',"image/%lowcase(&contenttype)");
|
|
88
|
+
run;
|
|
89
|
+
%end;
|
|
90
|
+
%else %if &platform=SASVIYA %then %do;
|
|
91
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
92
|
+
contenttype="image/%lowcase(&contenttype)";
|
|
93
|
+
%end;
|
|
94
|
+
%end;
|
|
77
95
|
%else %if &contentype=HTML %then %do;
|
|
78
96
|
%if &platform=SASVIYA %then %do;
|
|
79
|
-
filename
|
|
97
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
|
80
98
|
contenttype="text/html";
|
|
81
99
|
%end;
|
|
82
100
|
%end;
|
|
@@ -88,15 +106,11 @@ run;
|
|
|
88
106
|
run;
|
|
89
107
|
%end;
|
|
90
108
|
%else %if &platform=SASVIYA %then %do;
|
|
91
|
-
filename
|
|
109
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
92
110
|
contenttype='application/text'
|
|
93
111
|
contentdisp="attachment; filename=&outname";
|
|
94
112
|
%end;
|
|
95
113
|
%end;
|
|
96
|
-
%else %do;
|
|
97
|
-
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
|
98
|
-
%return;
|
|
99
|
-
%end;
|
|
100
114
|
%else %if &contentype=WOFF or &contentype=WOFF2 or &contentype=TTF %then %do;
|
|
101
115
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
102
116
|
data _null_;
|
|
@@ -104,7 +118,7 @@ run;
|
|
|
104
118
|
run;
|
|
105
119
|
%end;
|
|
106
120
|
%else %if &platform=SASVIYA %then %do;
|
|
107
|
-
filename
|
|
121
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
108
122
|
contenttype="font/%lowcase(&contenttype)";
|
|
109
123
|
%end;
|
|
110
124
|
%end;
|
|
@@ -117,7 +131,7 @@ run;
|
|
|
117
131
|
run;
|
|
118
132
|
%end;
|
|
119
133
|
%else %if &platform=SASVIYA %then %do;
|
|
120
|
-
filename
|
|
134
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
|
121
135
|
contenttype=
|
|
122
136
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
123
137
|
contentdisp="attachment; filename=&outname";
|
|
@@ -131,17 +145,20 @@ run;
|
|
|
131
145
|
run;
|
|
132
146
|
%end;
|
|
133
147
|
%else %if &platform=SASVIYA %then %do;
|
|
134
|
-
filename
|
|
148
|
+
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
|
135
149
|
contenttype='application/zip'
|
|
136
150
|
contentdisp="attachment; filename=&outname";
|
|
137
151
|
%end;
|
|
138
152
|
%end;
|
|
153
|
+
%else %do;
|
|
154
|
+
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
|
155
|
+
%end;
|
|
139
156
|
|
|
140
157
|
%if &inref ne 0 %then %do;
|
|
141
|
-
%mp_binarycopy(inref=&inref,outref
|
|
158
|
+
%mp_binarycopy(inref=&inref,outref=&outref)
|
|
142
159
|
%end;
|
|
143
160
|
%else %do;
|
|
144
|
-
%mp_binarycopy(inloc="&inloc",outref
|
|
161
|
+
%mp_binarycopy(inloc="&inloc",outref=&outref)
|
|
145
162
|
%end;
|
|
146
163
|
|
|
147
164
|
%mend mp_streamfile;
|
package/package.json
CHANGED