@sasjs/adapter 4.12.1 → 4.13.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.
@@ -0,0 +1,7 @@
1
+ export declare class Tables {
2
+ _tables: {
3
+ [macroName: string]: Record<string, any>;
4
+ };
5
+ constructor(table: Record<string, any>, macroName: string);
6
+ add(table: Record<string, any> | null, macroName: string): void;
7
+ }
@@ -0,0 +1,4 @@
1
+ export declare class ArgumentError extends Error {
2
+ message: string;
3
+ constructor(message: string);
4
+ }
@@ -1,3 +1,4 @@
1
+ export * from './ArgumentError';
1
2
  export * from './AuthorizeError';
2
3
  export * from './CertificateError';
3
4
  export * from './ComputeJobExecutionError';
@@ -15,3 +15,4 @@ export * from './PollOptions';
15
15
  export * from './WriteStream';
16
16
  export * from './ExecuteScript';
17
17
  export * from './errors';
18
+ export * from './Tables';
package/package.json CHANGED
@@ -82,9 +82,9 @@
82
82
  "@sasjs/utils": "3.5.2",
83
83
  "axios": "1.8.2",
84
84
  "axios-cookiejar-support": "5.0.5",
85
- "form-data": "4.0.0",
85
+ "form-data": "4.0.4",
86
86
  "https": "1.0.0",
87
87
  "tough-cookie": "4.1.3"
88
88
  },
89
- "version": "4.12.1"
89
+ "version": "4.13.0"
90
90
  }
package/src/SASjs.ts CHANGED
@@ -9,7 +9,8 @@ import {
9
9
  ErrorResponse,
10
10
  LoginOptions,
11
11
  LoginResult,
12
- ExecutionQuery
12
+ ExecutionQuery,
13
+ Tables
13
14
  } from './types'
14
15
  import { SASViyaApiClient } from './SASViyaApiClient'
15
16
  import { SAS9ApiClient } from './SAS9ApiClient'
@@ -1240,4 +1241,15 @@ export default class SASjs {
1240
1241
  public setVerboseMode = (verboseMode: VerboseMode) => {
1241
1242
  this.requestClient?.setVerboseMode(verboseMode)
1242
1243
  }
1244
+
1245
+ /**
1246
+ * Create a tables class containing one or more tables to be sent to
1247
+ * SAS.
1248
+ * @param table - initial table data
1249
+ * @param macroName - macro name
1250
+ * @returns Tables class
1251
+ */
1252
+ Tables(table: Record<string, any>, macroName: string) {
1253
+ return new Tables(table, macroName)
1254
+ }
1243
1255
  }
@@ -0,0 +1,29 @@
1
+ import { ArgumentError } from './errors'
2
+
3
+ export class Tables {
4
+ _tables: { [macroName: string]: Record<string, any> }
5
+
6
+ constructor(table: Record<string, any>, macroName: string) {
7
+ this._tables = {}
8
+
9
+ this.add(table, macroName)
10
+ }
11
+
12
+ add(table: Record<string, any> | null, macroName: string) {
13
+ if (table && macroName) {
14
+ if (!(table instanceof Array)) {
15
+ throw new ArgumentError('First argument must be array')
16
+ }
17
+ if (typeof macroName !== 'string') {
18
+ throw new ArgumentError('Second argument must be string')
19
+ }
20
+ if (!isNaN(Number(macroName[macroName.length - 1]))) {
21
+ throw new ArgumentError('Macro name cannot have number at the end')
22
+ }
23
+ } else {
24
+ throw new ArgumentError('Missing arguments')
25
+ }
26
+
27
+ this._tables[macroName] = table
28
+ }
29
+ }
@@ -0,0 +1,7 @@
1
+ export class ArgumentError extends Error {
2
+ constructor(public message: string) {
3
+ super(message)
4
+ this.name = 'ArgumentError'
5
+ Object.setPrototypeOf(this, ArgumentError.prototype)
6
+ }
7
+ }
@@ -1,3 +1,4 @@
1
+ export * from './ArgumentError'
1
2
  export * from './AuthorizeError'
2
3
  export * from './CertificateError'
3
4
  export * from './ComputeJobExecutionError'
@@ -15,3 +15,4 @@ export * from './PollOptions'
15
15
  export * from './WriteStream'
16
16
  export * from './ExecuteScript'
17
17
  export * from './errors'
18
+ export * from './Tables'
@@ -0,0 +1,7 @@
1
+ export declare class Tables {
2
+ _tables: {
3
+ [macroName: string]: Record<string, any>;
4
+ };
5
+ constructor(table: Record<string, any>, macroName: string);
6
+ add(table: Record<string, any> | null, macroName: string): void;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare class ArgumentError extends Error {
2
+ message: string;
3
+ constructor(message: string);
4
+ }
@@ -1,3 +1,4 @@
1
+ export * from './ArgumentError';
1
2
  export * from './AuthorizeError';
2
3
  export * from './CertificateError';
3
4
  export * from './ComputeJobExecutionError';
package/types/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export * from './PollOptions';
15
15
  export * from './WriteStream';
16
16
  export * from './ExecuteScript';
17
17
  export * from './errors';
18
+ export * from './Tables';