@openfn/language-mssql 4.0.0 → 4.0.2
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 +1 -1
- package/ast.json +10 -20
- package/configuration-schema.json +16 -4
- package/dist/index.cjs +60705 -33
- package/dist/index.js +60719 -30
- package/package.json +1 -1
- package/types/Adaptor.d.ts +11 -196
package/package.json
CHANGED
package/types/Adaptor.d.ts
CHANGED
|
@@ -6,48 +6,21 @@
|
|
|
6
6
|
* create('foo'),
|
|
7
7
|
* delete('bar')
|
|
8
8
|
* )(state)
|
|
9
|
-
* @
|
|
9
|
+
* @function
|
|
10
10
|
* @param {Operations} operations - Operations to be performed.
|
|
11
11
|
* @returns {Operation}
|
|
12
12
|
*/
|
|
13
13
|
export function execute(...operations: Operations): Operation;
|
|
14
|
-
export class execute {
|
|
15
|
-
/**
|
|
16
|
-
* Execute a sequence of operations.
|
|
17
|
-
* Wraps `language-common/execute`, and prepends initial state for mssql.
|
|
18
|
-
* @example
|
|
19
|
-
* execute(
|
|
20
|
-
* create('foo'),
|
|
21
|
-
* delete('bar')
|
|
22
|
-
* )(state)
|
|
23
|
-
* @constructor
|
|
24
|
-
* @param {Operations} operations - Operations to be performed.
|
|
25
|
-
* @returns {Operation}
|
|
26
|
-
*/
|
|
27
|
-
constructor(...operations: Operations);
|
|
28
|
-
}
|
|
29
14
|
/**
|
|
30
15
|
* Execute an SQL statement
|
|
31
16
|
* @public
|
|
32
17
|
* @example
|
|
33
18
|
* sql({ query, options })
|
|
34
|
-
* @
|
|
19
|
+
* @function
|
|
35
20
|
* @param {object} params - Payload data for the message
|
|
36
21
|
* @returns {Operation}
|
|
37
22
|
*/
|
|
38
23
|
export function sql(params: object): Operation;
|
|
39
|
-
export class sql {
|
|
40
|
-
/**
|
|
41
|
-
* Execute an SQL statement
|
|
42
|
-
* @public
|
|
43
|
-
* @example
|
|
44
|
-
* sql({ query, options })
|
|
45
|
-
* @constructor
|
|
46
|
-
* @param {object} params - Payload data for the message
|
|
47
|
-
* @returns {Operation}
|
|
48
|
-
*/
|
|
49
|
-
constructor(params: object);
|
|
50
|
-
}
|
|
51
24
|
/**
|
|
52
25
|
* Fetch a uuid key given a condition
|
|
53
26
|
* @public
|
|
@@ -58,87 +31,42 @@ export class sql {
|
|
|
58
31
|
* where: { first_name: 'Mama%', last_name: 'Cisse'},
|
|
59
32
|
* operator: { first_name: 'like', last_name: '='}
|
|
60
33
|
* })
|
|
61
|
-
* @
|
|
34
|
+
* @function
|
|
62
35
|
* @param {object} filter - A filter object with the lookup table, a uuid and the condition
|
|
63
36
|
* @returns {Operation}
|
|
64
37
|
*/
|
|
65
38
|
export function findValue(filter: object): Operation;
|
|
66
|
-
export class findValue {
|
|
67
|
-
/**
|
|
68
|
-
* Fetch a uuid key given a condition
|
|
69
|
-
* @public
|
|
70
|
-
* @example
|
|
71
|
-
* findValue({
|
|
72
|
-
* uuid: 'id',
|
|
73
|
-
* relation: 'users',
|
|
74
|
-
* where: { first_name: 'Mama%', last_name: 'Cisse'},
|
|
75
|
-
* operator: { first_name: 'like', last_name: '='}
|
|
76
|
-
* })
|
|
77
|
-
* @constructor
|
|
78
|
-
* @param {object} filter - A filter object with the lookup table, a uuid and the condition
|
|
79
|
-
* @returns {Operation}
|
|
80
|
-
*/
|
|
81
|
-
constructor(filter: object);
|
|
82
|
-
}
|
|
83
39
|
/**
|
|
84
40
|
* Insert a record
|
|
85
41
|
* @public
|
|
86
42
|
* @example
|
|
87
43
|
* insert(table, record, {setNull: ["'undefined'", "''"], logValues: false})
|
|
88
|
-
* @
|
|
44
|
+
* @function
|
|
89
45
|
* @param {string} table - The target table
|
|
90
46
|
* @param {object} record - Payload data for the record as a JS object
|
|
91
47
|
* @param {object} options - Optional options argument
|
|
92
48
|
* @returns {Operation}
|
|
93
49
|
*/
|
|
94
50
|
export function insert(table: string, record: object, options: object): Operation;
|
|
95
|
-
export class insert {
|
|
96
|
-
/**
|
|
97
|
-
* Insert a record
|
|
98
|
-
* @public
|
|
99
|
-
* @example
|
|
100
|
-
* insert(table, record, {setNull: ["'undefined'", "''"], logValues: false})
|
|
101
|
-
* @constructor
|
|
102
|
-
* @param {string} table - The target table
|
|
103
|
-
* @param {object} record - Payload data for the record as a JS object
|
|
104
|
-
* @param {object} options - Optional options argument
|
|
105
|
-
* @returns {Operation}
|
|
106
|
-
*/
|
|
107
|
-
constructor(table: string, record: object, options: object);
|
|
108
|
-
}
|
|
109
51
|
/**
|
|
110
52
|
* Insert many records, using the keys of the first as the column template
|
|
111
53
|
* @public
|
|
112
54
|
* @example
|
|
113
55
|
* insertMany(table, records, { setNull: false, writeSql: true, logValues: false })
|
|
114
|
-
* @
|
|
56
|
+
* @function
|
|
115
57
|
* @param {string} table - The target table
|
|
116
58
|
* @param {function} records - A function that takes state and returns an array of records
|
|
117
59
|
* @param {object} options - Optional options argument
|
|
118
60
|
* @returns {Operation}
|
|
119
61
|
*/
|
|
120
62
|
export function insertMany(table: string, records: Function, options: object): Operation;
|
|
121
|
-
export class insertMany {
|
|
122
|
-
/**
|
|
123
|
-
* Insert many records, using the keys of the first as the column template
|
|
124
|
-
* @public
|
|
125
|
-
* @example
|
|
126
|
-
* insertMany(table, records, { setNull: false, writeSql: true, logValues: false })
|
|
127
|
-
* @constructor
|
|
128
|
-
* @param {string} table - The target table
|
|
129
|
-
* @param {function} records - A function that takes state and returns an array of records
|
|
130
|
-
* @param {object} options - Optional options argument
|
|
131
|
-
* @returns {Operation}
|
|
132
|
-
*/
|
|
133
|
-
constructor(table: string, records: Function, options: object);
|
|
134
|
-
}
|
|
135
63
|
/**
|
|
136
64
|
* Insert or update a record using SQL MERGE
|
|
137
65
|
* @public
|
|
138
66
|
* @example
|
|
139
67
|
* upsert(table, uuid, record, { setNull: "'undefined'", logValues: false})
|
|
140
68
|
* upsert(table, [uuid1, uuid2], record, { setNull: "'undefined'", logValues: false})
|
|
141
|
-
* @
|
|
69
|
+
* @function
|
|
142
70
|
* @param {string} table - The target table
|
|
143
71
|
* @param {string} uuid - The uuid column to determine a matching/existing record
|
|
144
72
|
* @param {object} record - Payload data for the record as a JS object
|
|
@@ -146,22 +74,6 @@ export class insertMany {
|
|
|
146
74
|
* @returns {Operation}
|
|
147
75
|
*/
|
|
148
76
|
export function upsert(table: string, uuid: string, record: object, options: object): Operation;
|
|
149
|
-
export class upsert {
|
|
150
|
-
/**
|
|
151
|
-
* Insert or update a record using SQL MERGE
|
|
152
|
-
* @public
|
|
153
|
-
* @example
|
|
154
|
-
* upsert(table, uuid, record, { setNull: "'undefined'", logValues: false})
|
|
155
|
-
* upsert(table, [uuid1, uuid2], record, { setNull: "'undefined'", logValues: false})
|
|
156
|
-
* @constructor
|
|
157
|
-
* @param {string} table - The target table
|
|
158
|
-
* @param {string} uuid - The uuid column to determine a matching/existing record
|
|
159
|
-
* @param {object} record - Payload data for the record as a JS object
|
|
160
|
-
* @param {object} options - Optional options argument
|
|
161
|
-
* @returns {Operation}
|
|
162
|
-
*/
|
|
163
|
-
constructor(table: string, uuid: string, record: object, options: object);
|
|
164
|
-
}
|
|
165
77
|
/**
|
|
166
78
|
* Insert or update a record based on a logical condition using ON CONFLICT UPDATE
|
|
167
79
|
* @public
|
|
@@ -173,7 +85,7 @@ export class upsert {
|
|
|
173
85
|
* { name: 'Elodie', id: 7 },
|
|
174
86
|
* { writeSql:true, execute: true, logValues: false }
|
|
175
87
|
* )
|
|
176
|
-
* @
|
|
88
|
+
* @function
|
|
177
89
|
* @param {string} logical - a data to check existing value for.
|
|
178
90
|
* @param {string} table - The target table
|
|
179
91
|
* @param {string} uuid - The uuid column to determine a matching/existing record
|
|
@@ -182,28 +94,6 @@ export class upsert {
|
|
|
182
94
|
* @returns {Operation}
|
|
183
95
|
*/
|
|
184
96
|
export function upsertIf(logical: string, table: string, uuid: string, record: object, options: object): Operation;
|
|
185
|
-
export class upsertIf {
|
|
186
|
-
/**
|
|
187
|
-
* Insert or update a record based on a logical condition using ON CONFLICT UPDATE
|
|
188
|
-
* @public
|
|
189
|
-
* @example
|
|
190
|
-
* upsertIf(
|
|
191
|
-
* dataValue('name'),
|
|
192
|
-
* 'users', // the DB table
|
|
193
|
-
* 'uuid', // a DB column with a unique constraint
|
|
194
|
-
* { name: 'Elodie', id: 7 },
|
|
195
|
-
* { writeSql:true, execute: true, logValues: false }
|
|
196
|
-
* )
|
|
197
|
-
* @constructor
|
|
198
|
-
* @param {string} logical - a data to check existing value for.
|
|
199
|
-
* @param {string} table - The target table
|
|
200
|
-
* @param {string} uuid - The uuid column to determine a matching/existing record
|
|
201
|
-
* @param {object} record - Payload data for the record as a JS object or function
|
|
202
|
-
* @param {object} options - Optional options argument
|
|
203
|
-
* @returns {Operation}
|
|
204
|
-
*/
|
|
205
|
-
constructor(logical: string, table: string, uuid: string, record: object, options: object);
|
|
206
|
-
}
|
|
207
97
|
/**
|
|
208
98
|
* Insert or update multiple records using ON CONFLICT UPDATE and excluded
|
|
209
99
|
* @public
|
|
@@ -214,7 +104,7 @@ export class upsertIf {
|
|
|
214
104
|
* upsertMany(
|
|
215
105
|
* 'users', ['email', 'phone'], records, { logValues: false }
|
|
216
106
|
* )
|
|
217
|
-
* @
|
|
107
|
+
* @function
|
|
218
108
|
* @param {string} table - The target table
|
|
219
109
|
* @param {string} uuid - The uuid column to determine a matching/existing record
|
|
220
110
|
* @param {function} records - A function that takes state and returns an array of records
|
|
@@ -222,50 +112,17 @@ export class upsertIf {
|
|
|
222
112
|
* @returns {Operation}
|
|
223
113
|
*/
|
|
224
114
|
export function upsertMany(table: string, uuid: string, records: Function, options: object): Operation;
|
|
225
|
-
export class upsertMany {
|
|
226
|
-
/**
|
|
227
|
-
* Insert or update multiple records using ON CONFLICT UPDATE and excluded
|
|
228
|
-
* @public
|
|
229
|
-
* @example
|
|
230
|
-
* upsertMany(
|
|
231
|
-
* 'users', 'email', records, { logValues: false }
|
|
232
|
-
* )
|
|
233
|
-
* upsertMany(
|
|
234
|
-
* 'users', ['email', 'phone'], records, { logValues: false }
|
|
235
|
-
* )
|
|
236
|
-
* @constructor
|
|
237
|
-
* @param {string} table - The target table
|
|
238
|
-
* @param {string} uuid - The uuid column to determine a matching/existing record
|
|
239
|
-
* @param {function} records - A function that takes state and returns an array of records
|
|
240
|
-
* @param {object} options - Optional options argument
|
|
241
|
-
* @returns {Operation}
|
|
242
|
-
*/
|
|
243
|
-
constructor(table: string, uuid: string, records: Function, options: object);
|
|
244
|
-
}
|
|
245
115
|
/**
|
|
246
116
|
* List the columns of a table in a database.
|
|
247
117
|
* @public
|
|
248
118
|
* @example
|
|
249
119
|
* describeTable('clinic_visits')
|
|
250
|
-
* @
|
|
120
|
+
* @function
|
|
251
121
|
* @param {string} tableName - The name of the table to describe
|
|
252
122
|
* @param {object} options - Optional options argument
|
|
253
123
|
* @returns {Operation}
|
|
254
124
|
*/
|
|
255
125
|
export function describeTable(tableName: string, options: object): Operation;
|
|
256
|
-
export class describeTable {
|
|
257
|
-
/**
|
|
258
|
-
* List the columns of a table in a database.
|
|
259
|
-
* @public
|
|
260
|
-
* @example
|
|
261
|
-
* describeTable('clinic_visits')
|
|
262
|
-
* @constructor
|
|
263
|
-
* @param {string} tableName - The name of the table to describe
|
|
264
|
-
* @param {object} options - Optional options argument
|
|
265
|
-
* @returns {Operation}
|
|
266
|
-
*/
|
|
267
|
-
constructor(tableName: string, options: object);
|
|
268
|
-
}
|
|
269
126
|
/**
|
|
270
127
|
* Create a table in database when given an array of columns and a table_name.
|
|
271
128
|
* @public
|
|
@@ -278,34 +135,13 @@ export class describeTable {
|
|
|
278
135
|
* unique: false, // optional - to be set to true for unique constraint
|
|
279
136
|
* })
|
|
280
137
|
* ));
|
|
281
|
-
* @
|
|
138
|
+
* @function
|
|
282
139
|
* @param {string} tableName - The name of the table to create
|
|
283
140
|
* @param {array} columns - An array of form columns
|
|
284
141
|
* @param {object} options - Optional options argument
|
|
285
142
|
* @returns {Operation}
|
|
286
143
|
*/
|
|
287
144
|
export function insertTable(tableName: string, columns: any[], options: object): Operation;
|
|
288
|
-
export class insertTable {
|
|
289
|
-
/**
|
|
290
|
-
* Create a table in database when given an array of columns and a table_name.
|
|
291
|
-
* @public
|
|
292
|
-
* @example
|
|
293
|
-
* insertTable('table_name', state => state.data.map(
|
|
294
|
-
* column => ({
|
|
295
|
-
* name: column.name,
|
|
296
|
-
* type: column.type,
|
|
297
|
-
* required: true, // optional
|
|
298
|
-
* unique: false, // optional - to be set to true for unique constraint
|
|
299
|
-
* })
|
|
300
|
-
* ));
|
|
301
|
-
* @constructor
|
|
302
|
-
* @param {string} tableName - The name of the table to create
|
|
303
|
-
* @param {array} columns - An array of form columns
|
|
304
|
-
* @param {object} options - Optional options argument
|
|
305
|
-
* @returns {Operation}
|
|
306
|
-
*/
|
|
307
|
-
constructor(tableName: string, columns: any[], options: object);
|
|
308
|
-
}
|
|
309
145
|
/**
|
|
310
146
|
* Alter an existing table in the database.
|
|
311
147
|
* @public
|
|
@@ -318,32 +154,11 @@ export class insertTable {
|
|
|
318
154
|
* unique: false, // optional - to be set to true for unique constraint
|
|
319
155
|
* })
|
|
320
156
|
* ));
|
|
321
|
-
* @
|
|
157
|
+
* @function
|
|
322
158
|
* @param {string} tableName - The name of the table to alter
|
|
323
159
|
* @param {array} columns - An array of form columns
|
|
324
160
|
* @param {object} options - Optional options argument
|
|
325
161
|
* @returns {Operation}
|
|
326
162
|
*/
|
|
327
163
|
export function modifyTable(tableName: string, columns: any[], options: object): Operation;
|
|
328
|
-
export class modifyTable {
|
|
329
|
-
/**
|
|
330
|
-
* Alter an existing table in the database.
|
|
331
|
-
* @public
|
|
332
|
-
* @example
|
|
333
|
-
* modifyTable('table_name', state => state.data.map(
|
|
334
|
-
* newColumn => ({
|
|
335
|
-
* name: newColumn.name,
|
|
336
|
-
* type: newColumn.type,
|
|
337
|
-
* required: true, // optional
|
|
338
|
-
* unique: false, // optional - to be set to true for unique constraint
|
|
339
|
-
* })
|
|
340
|
-
* ));
|
|
341
|
-
* @constructor
|
|
342
|
-
* @param {string} tableName - The name of the table to alter
|
|
343
|
-
* @param {array} columns - An array of form columns
|
|
344
|
-
* @param {object} options - Optional options argument
|
|
345
|
-
* @returns {Operation}
|
|
346
|
-
*/
|
|
347
|
-
constructor(tableName: string, columns: any[], options: object);
|
|
348
|
-
}
|
|
349
164
|
export { alterState, combine, dataPath, dataValue, dateFns, each, field, fields, fn, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
|