@openfn/language-mssql 3.1.0 → 3.1.1

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/ast.json CHANGED
@@ -663,6 +663,14 @@
663
663
  "name": "Function"
664
664
  },
665
665
  "name": "func"
666
+ },
667
+ {
668
+ "title": "returns",
669
+ "description": null,
670
+ "type": {
671
+ "type": "NameExpression",
672
+ "name": "Operation"
673
+ }
666
674
  }
667
675
  ]
668
676
  },
@@ -698,6 +706,14 @@
698
706
  "name": "String"
699
707
  },
700
708
  "name": "path"
709
+ },
710
+ {
711
+ "title": "returns",
712
+ "description": null,
713
+ "type": {
714
+ "type": "NameExpression",
715
+ "name": "Operation"
716
+ }
701
717
  }
702
718
  ]
703
719
  },
@@ -776,6 +792,14 @@
776
792
  "name": "String"
777
793
  },
778
794
  "name": "path"
795
+ },
796
+ {
797
+ "title": "returns",
798
+ "description": null,
799
+ "type": {
800
+ "type": "NameExpression",
801
+ "name": "Operation"
802
+ }
779
803
  }
780
804
  ]
781
805
  },
@@ -811,6 +835,14 @@
811
835
  "name": "String"
812
836
  },
813
837
  "name": "path"
838
+ },
839
+ {
840
+ "title": "returns",
841
+ "description": null,
842
+ "type": {
843
+ "type": "NameExpression",
844
+ "name": "Operation"
845
+ }
814
846
  }
815
847
  ]
816
848
  },
@@ -856,6 +888,14 @@
856
888
  "name": "Operation"
857
889
  },
858
890
  "name": "operation"
891
+ },
892
+ {
893
+ "title": "returns",
894
+ "description": null,
895
+ "type": {
896
+ "type": "NameExpression",
897
+ "name": "Operation"
898
+ }
859
899
  }
860
900
  ]
861
901
  },
@@ -944,6 +984,14 @@
944
984
  "name": "Value"
945
985
  },
946
986
  "name": "value"
987
+ },
988
+ {
989
+ "title": "returns",
990
+ "description": null,
991
+ "type": {
992
+ "type": "NameExpression",
993
+ "name": "Field"
994
+ }
947
995
  }
948
996
  ]
949
997
  },
package/dist/index.cjs CHANGED
@@ -19,8 +19,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/index.js
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
- Adaptor: () => Adaptor_exports,
23
- default: () => src_default
22
+ alterState: () => import_language_common2.alterState,
23
+ combine: () => import_language_common2.combine,
24
+ dataPath: () => import_language_common2.dataPath,
25
+ dataValue: () => import_language_common2.dataValue,
26
+ dateFns: () => import_language_common2.dateFns,
27
+ default: () => src_default,
28
+ describeTable: () => describeTable,
29
+ each: () => import_language_common2.each,
30
+ execute: () => execute,
31
+ field: () => import_language_common2.field,
32
+ fields: () => import_language_common2.fields,
33
+ findValue: () => findValue,
34
+ fn: () => import_language_common2.fn,
35
+ http: () => import_language_common2.http,
36
+ insert: () => insert,
37
+ insertMany: () => insertMany,
38
+ insertTable: () => insertTable,
39
+ lastReferenceValue: () => import_language_common2.lastReferenceValue,
40
+ merge: () => import_language_common2.merge,
41
+ modifyTable: () => modifyTable,
42
+ sourceValue: () => import_language_common2.sourceValue,
43
+ sql: () => sql,
44
+ upsert: () => upsert,
45
+ upsertIf: () => upsertIf,
46
+ upsertMany: () => upsertMany
24
47
  });
25
48
  module.exports = __toCommonJS(src_exports);
26
49
 
@@ -517,5 +540,28 @@ function modifyTable(tableName, columns, options) {
517
540
  var src_default = Adaptor_exports;
518
541
  // Annotate the CommonJS export names for ESM import in node:
519
542
  0 && (module.exports = {
520
- Adaptor
543
+ alterState,
544
+ combine,
545
+ dataPath,
546
+ dataValue,
547
+ dateFns,
548
+ describeTable,
549
+ each,
550
+ execute,
551
+ field,
552
+ fields,
553
+ findValue,
554
+ fn,
555
+ http,
556
+ insert,
557
+ insertMany,
558
+ insertTable,
559
+ lastReferenceValue,
560
+ merge,
561
+ modifyTable,
562
+ sourceValue,
563
+ sql,
564
+ upsert,
565
+ upsertIf,
566
+ upsertMany
521
567
  });
package/dist/index.js CHANGED
@@ -513,6 +513,29 @@ function modifyTable(tableName, columns, options) {
513
513
  // src/index.js
514
514
  var src_default = Adaptor_exports;
515
515
  export {
516
- Adaptor_exports as Adaptor,
517
- src_default as default
516
+ alterState,
517
+ combine,
518
+ dataPath,
519
+ dataValue,
520
+ dateFns,
521
+ src_default as default,
522
+ describeTable,
523
+ each,
524
+ execute,
525
+ field,
526
+ fields,
527
+ findValue,
528
+ fn,
529
+ http,
530
+ insert,
531
+ insertMany,
532
+ insertTable,
533
+ lastReferenceValue,
534
+ merge,
535
+ modifyTable,
536
+ sourceValue,
537
+ sql,
538
+ upsert,
539
+ upsertIf,
540
+ upsertMany
518
541
  };
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@openfn/language-mssql",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "A Microsoft SQL language pack for OpenFn",
5
- "main": "dist/index.cjs",
5
+ "exports": {
6
+ "import": "./dist/index.js",
7
+ "require": "./dist/index.cjs"
8
+ },
6
9
  "homepage": "https://docs.openfn.org",
7
10
  "repository": {
8
11
  "type": "git",
@@ -17,29 +20,28 @@
17
20
  "configuration-schema.json"
18
21
  ],
19
22
  "dependencies": {
20
- "@openfn/language-common": "1.6.2",
23
+ "@openfn/language-common": "1.7.4",
21
24
  "request": "2.88.0",
22
25
  "tedious": "15.1.0"
23
26
  },
24
27
  "devDependencies": {
28
+ "@openfn/buildtools": "^1.0.2",
25
29
  "@openfn/simple-ast": "0.4.1",
26
- "assertion-error": "1.1.0",
27
- "chai": "3.5.0",
28
- "deep-eql": "0.1.3",
30
+ "assertion-error": "2.0.0",
31
+ "chai": "4.3.6",
32
+ "deep-eql": "4.1.1",
33
+ "esno": "^0.16.3",
29
34
  "mocha": "10.1.0",
30
- "sinon": "1.17.7",
31
- "superagent-mock": "4.0.0",
32
- "esno": "0.16.3",
33
- "rimraf": "3.0.2",
34
- "@openfn/buildtools": "^1.0.0"
35
+ "rimraf": "3.0.2"
35
36
  },
36
37
  "type": "module",
37
38
  "types": "types/index.d.ts",
39
+ "main": "dist/index.cjs",
38
40
  "scripts": {
39
41
  "build": "pnpm clean && build-adaptor mssql",
40
42
  "test": "mocha --experimental-specifier-resolution=node --no-warnings",
41
43
  "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
42
- "clean": "rm -rf dist types docs",
44
+ "clean": "rimraf dist types docs",
43
45
  "pack": "pnpm pack --pack-destination ../../dist"
44
46
  }
45
47
  }
@@ -0,0 +1,349 @@
1
+ /**
2
+ * Execute a sequence of operations.
3
+ * Wraps `language-common/execute`, and prepends initial state for mssql.
4
+ * @example
5
+ * execute(
6
+ * create('foo'),
7
+ * delete('bar')
8
+ * )(state)
9
+ * @constructor
10
+ * @param {Operations} operations - Operations to be performed.
11
+ * @returns {Operation}
12
+ */
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
+ /**
30
+ * Execute an SQL statement
31
+ * @public
32
+ * @example
33
+ * sql({ query, options })
34
+ * @constructor
35
+ * @param {object} params - Payload data for the message
36
+ * @returns {Operation}
37
+ */
38
+ 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
+ /**
52
+ * Fetch a uuid key given a condition
53
+ * @public
54
+ * @example
55
+ * findValue({
56
+ * uuid: 'id',
57
+ * relation: 'users',
58
+ * where: { first_name: 'Mama%', last_name: 'Cisse'},
59
+ * operator: { first_name: 'like', last_name: '='}
60
+ * })
61
+ * @constructor
62
+ * @param {object} filter - A filter object with the lookup table, a uuid and the condition
63
+ * @returns {Operation}
64
+ */
65
+ 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
+ /**
84
+ * Insert a record
85
+ * @public
86
+ * @example
87
+ * insert(table, record, {setNull: ["'undefined'", "''"], logValues: false})
88
+ * @constructor
89
+ * @param {string} table - The target table
90
+ * @param {object} record - Payload data for the record as a JS object
91
+ * @param {object} options - Optional options argument
92
+ * @returns {Operation}
93
+ */
94
+ 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
+ /**
110
+ * Insert many records, using the keys of the first as the column template
111
+ * @public
112
+ * @example
113
+ * insertMany(table, records, { setNull: false, writeSql: true, logValues: false })
114
+ * @constructor
115
+ * @param {string} table - The target table
116
+ * @param {function} records - A function that takes state and returns an array of records
117
+ * @param {object} options - Optional options argument
118
+ * @returns {Operation}
119
+ */
120
+ 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
+ /**
136
+ * Insert or update a record using SQL MERGE
137
+ * @public
138
+ * @example
139
+ * upsert(table, uuid, record, { setNull: "'undefined'", logValues: false})
140
+ * upsert(table, [uuid1, uuid2], record, { setNull: "'undefined'", logValues: false})
141
+ * @constructor
142
+ * @param {string} table - The target table
143
+ * @param {string} uuid - The uuid column to determine a matching/existing record
144
+ * @param {object} record - Payload data for the record as a JS object
145
+ * @param {object} options - Optional options argument
146
+ * @returns {Operation}
147
+ */
148
+ 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
+ /**
166
+ * Insert or update a record based on a logical condition using ON CONFLICT UPDATE
167
+ * @public
168
+ * @example
169
+ * upsertIf(
170
+ * dataValue('name'),
171
+ * 'users', // the DB table
172
+ * 'uuid', // a DB column with a unique constraint
173
+ * { name: 'Elodie', id: 7 },
174
+ * { writeSql:true, execute: true, logValues: false }
175
+ * )
176
+ * @constructor
177
+ * @param {string} logical - a data to check existing value for.
178
+ * @param {string} table - The target table
179
+ * @param {string} uuid - The uuid column to determine a matching/existing record
180
+ * @param {object} record - Payload data for the record as a JS object or function
181
+ * @param {object} options - Optional options argument
182
+ * @returns {Operation}
183
+ */
184
+ 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
+ /**
208
+ * Insert or update multiple records using ON CONFLICT UPDATE and excluded
209
+ * @public
210
+ * @example
211
+ * upsertMany(
212
+ * 'users', 'email', records, { logValues: false }
213
+ * )
214
+ * upsertMany(
215
+ * 'users', ['email', 'phone'], records, { logValues: false }
216
+ * )
217
+ * @constructor
218
+ * @param {string} table - The target table
219
+ * @param {string} uuid - The uuid column to determine a matching/existing record
220
+ * @param {function} records - A function that takes state and returns an array of records
221
+ * @param {object} options - Optional options argument
222
+ * @returns {Operation}
223
+ */
224
+ 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
+ /**
246
+ * List the columns of a table in a database.
247
+ * @public
248
+ * @example
249
+ * describeTable('clinic_visits')
250
+ * @constructor
251
+ * @param {string} tableName - The name of the table to describe
252
+ * @param {object} options - Optional options argument
253
+ * @returns {Operation}
254
+ */
255
+ 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
+ /**
270
+ * Create a table in database when given an array of columns and a table_name.
271
+ * @public
272
+ * @example
273
+ * insertTable('table_name', state => state.data.map(
274
+ * column => ({
275
+ * name: column.name,
276
+ * type: column.type,
277
+ * required: true, // optional
278
+ * unique: false, // optional - to be set to true for unique constraint
279
+ * })
280
+ * ));
281
+ * @constructor
282
+ * @param {string} tableName - The name of the table to create
283
+ * @param {array} columns - An array of form columns
284
+ * @param {object} options - Optional options argument
285
+ * @returns {Operation}
286
+ */
287
+ 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
+ /**
310
+ * Alter an existing table in the database.
311
+ * @public
312
+ * @example
313
+ * modifyTable('table_name', state => state.data.map(
314
+ * newColumn => ({
315
+ * name: newColumn.name,
316
+ * type: newColumn.type,
317
+ * required: true, // optional
318
+ * unique: false, // optional - to be set to true for unique constraint
319
+ * })
320
+ * ));
321
+ * @constructor
322
+ * @param {string} tableName - The name of the table to alter
323
+ * @param {array} columns - An array of form columns
324
+ * @param {object} options - Optional options argument
325
+ * @returns {Operation}
326
+ */
327
+ 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
+ export { alterState, combine, dataPath, dataValue, dateFns, each, field, fields, fn, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
package/types/index.d.ts CHANGED
@@ -1,388 +1,3 @@
1
- /**
2
- * Execute a sequence of operations.
3
- * Wraps `language-common/execute`, and prepends initial state for mssql.
4
- * @example
5
- * execute(
6
- * create('foo'),
7
- * delete('bar')
8
- * )(state)
9
- * @constructor
10
- * @param {Operations} operations - Operations to be performed.
11
- * @returns {Operation}
12
- */
13
- declare function execute(...operations: Operations): Operation;
14
- declare 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
- /**
30
- * Execute an SQL statement
31
- * @public
32
- * @example
33
- * sql({ query, options })
34
- * @constructor
35
- * @param {object} params - Payload data for the message
36
- * @returns {Operation}
37
- */
38
- declare function sql(params: object): Operation;
39
- declare 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
- /**
52
- * Fetch a uuid key given a condition
53
- * @public
54
- * @example
55
- * findValue({
56
- * uuid: 'id',
57
- * relation: 'users',
58
- * where: { first_name: 'Mama%', last_name: 'Cisse'},
59
- * operator: { first_name: 'like', last_name: '='}
60
- * })
61
- * @constructor
62
- * @param {object} filter - A filter object with the lookup table, a uuid and the condition
63
- * @returns {Operation}
64
- */
65
- declare function findValue(filter: object): Operation;
66
- declare 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
- /**
84
- * Insert a record
85
- * @public
86
- * @example
87
- * insert(table, record, {setNull: ["'undefined'", "''"], logValues: false})
88
- * @constructor
89
- * @param {string} table - The target table
90
- * @param {object} record - Payload data for the record as a JS object
91
- * @param {object} options - Optional options argument
92
- * @returns {Operation}
93
- */
94
- declare function insert(table: string, record: object, options: object): Operation;
95
- declare 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
- /**
110
- * Insert many records, using the keys of the first as the column template
111
- * @public
112
- * @example
113
- * insertMany(table, records, { setNull: false, writeSql: true, logValues: false })
114
- * @constructor
115
- * @param {string} table - The target table
116
- * @param {function} records - A function that takes state and returns an array of records
117
- * @param {object} options - Optional options argument
118
- * @returns {Operation}
119
- */
120
- declare function insertMany(table: string, records: Function, options: object): Operation;
121
- declare 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
- /**
136
- * Insert or update a record using SQL MERGE
137
- * @public
138
- * @example
139
- * upsert(table, uuid, record, { setNull: "'undefined'", logValues: false})
140
- * upsert(table, [uuid1, uuid2], record, { setNull: "'undefined'", logValues: false})
141
- * @constructor
142
- * @param {string} table - The target table
143
- * @param {string} uuid - The uuid column to determine a matching/existing record
144
- * @param {object} record - Payload data for the record as a JS object
145
- * @param {object} options - Optional options argument
146
- * @returns {Operation}
147
- */
148
- declare function upsert(table: string, uuid: string, record: object, options: object): Operation;
149
- declare 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
- /**
166
- * Insert or update a record based on a logical condition using ON CONFLICT UPDATE
167
- * @public
168
- * @example
169
- * upsertIf(
170
- * dataValue('name'),
171
- * 'users', // the DB table
172
- * 'uuid', // a DB column with a unique constraint
173
- * { name: 'Elodie', id: 7 },
174
- * { writeSql:true, execute: true, logValues: false }
175
- * )
176
- * @constructor
177
- * @param {string} logical - a data to check existing value for.
178
- * @param {string} table - The target table
179
- * @param {string} uuid - The uuid column to determine a matching/existing record
180
- * @param {object} record - Payload data for the record as a JS object or function
181
- * @param {object} options - Optional options argument
182
- * @returns {Operation}
183
- */
184
- declare function upsertIf(logical: string, table: string, uuid: string, record: object, options: object): Operation;
185
- declare 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
- /**
208
- * Insert or update multiple records using ON CONFLICT UPDATE and excluded
209
- * @public
210
- * @example
211
- * upsertMany(
212
- * 'users', 'email', records, { logValues: false }
213
- * )
214
- * upsertMany(
215
- * 'users', ['email', 'phone'], records, { logValues: false }
216
- * )
217
- * @constructor
218
- * @param {string} table - The target table
219
- * @param {string} uuid - The uuid column to determine a matching/existing record
220
- * @param {function} records - A function that takes state and returns an array of records
221
- * @param {object} options - Optional options argument
222
- * @returns {Operation}
223
- */
224
- declare function upsertMany(table: string, uuid: string, records: Function, options: object): Operation;
225
- declare 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
- /**
246
- * List the columns of a table in a database.
247
- * @public
248
- * @example
249
- * describeTable('clinic_visits')
250
- * @constructor
251
- * @param {string} tableName - The name of the table to describe
252
- * @param {object} options - Optional options argument
253
- * @returns {Operation}
254
- */
255
- declare function describeTable(tableName: string, options: object): Operation;
256
- declare 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
- /**
270
- * Create a table in database when given an array of columns and a table_name.
271
- * @public
272
- * @example
273
- * insertTable('table_name', state => state.data.map(
274
- * column => ({
275
- * name: column.name,
276
- * type: column.type,
277
- * required: true, // optional
278
- * unique: false, // optional - to be set to true for unique constraint
279
- * })
280
- * ));
281
- * @constructor
282
- * @param {string} tableName - The name of the table to create
283
- * @param {array} columns - An array of form columns
284
- * @param {object} options - Optional options argument
285
- * @returns {Operation}
286
- */
287
- declare function insertTable(tableName: string, columns: any[], options: object): Operation;
288
- declare 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
- /**
310
- * Alter an existing table in the database.
311
- * @public
312
- * @example
313
- * modifyTable('table_name', state => state.data.map(
314
- * newColumn => ({
315
- * name: newColumn.name,
316
- * type: newColumn.type,
317
- * required: true, // optional
318
- * unique: false, // optional - to be set to true for unique constraint
319
- * })
320
- * ));
321
- * @constructor
322
- * @param {string} tableName - The name of the table to alter
323
- * @param {array} columns - An array of form columns
324
- * @param {object} options - Optional options argument
325
- * @returns {Operation}
326
- */
327
- declare function modifyTable(tableName: string, columns: any[], options: object): Operation;
328
- declare 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
-
350
- type Adaptor_execute = execute;
351
- declare const Adaptor_execute: typeof execute;
352
- type Adaptor_sql = sql;
353
- declare const Adaptor_sql: typeof sql;
354
- type Adaptor_findValue = findValue;
355
- declare const Adaptor_findValue: typeof findValue;
356
- type Adaptor_insert = insert;
357
- declare const Adaptor_insert: typeof insert;
358
- type Adaptor_insertMany = insertMany;
359
- declare const Adaptor_insertMany: typeof insertMany;
360
- type Adaptor_upsert = upsert;
361
- declare const Adaptor_upsert: typeof upsert;
362
- type Adaptor_upsertIf = upsertIf;
363
- declare const Adaptor_upsertIf: typeof upsertIf;
364
- type Adaptor_upsertMany = upsertMany;
365
- declare const Adaptor_upsertMany: typeof upsertMany;
366
- type Adaptor_describeTable = describeTable;
367
- declare const Adaptor_describeTable: typeof describeTable;
368
- type Adaptor_insertTable = insertTable;
369
- declare const Adaptor_insertTable: typeof insertTable;
370
- type Adaptor_modifyTable = modifyTable;
371
- declare const Adaptor_modifyTable: typeof modifyTable;
372
- declare namespace Adaptor {
373
- export {
374
- Adaptor_execute as execute,
375
- Adaptor_sql as sql,
376
- Adaptor_findValue as findValue,
377
- Adaptor_insert as insert,
378
- Adaptor_insertMany as insertMany,
379
- Adaptor_upsert as upsert,
380
- Adaptor_upsertIf as upsertIf,
381
- Adaptor_upsertMany as upsertMany,
382
- Adaptor_describeTable as describeTable,
383
- Adaptor_insertTable as insertTable,
384
- Adaptor_modifyTable as modifyTable,
385
- };
386
- }
387
-
388
- export { Adaptor, Adaptor as default };
1
+ export default Adaptor;
2
+ export * from "./Adaptor";
3
+ import * as Adaptor from "./Adaptor";