sasat 0.22.3 → 0.22.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/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { D as setConfig, a as getDbClient, b as unique, c as formatQuery, d as SasatError, j as assignDeep, m as Conditions, o as MySqlTransaction, s as DBClient, t as migrate, u as SqlString, v as nonNullable, y as pick } from "./migrate-Cbj2OVbY.mjs";
2
- import * as SqlString$1 from "sqlstring";
1
+ import { a as getDbClient, c as formatQuery, f as setConfig, i as SasatError, l as SqlString, n as pick, o as MySqlTransaction, r as unique, s as DBClient, t as nonNullable, v as assignDeep } from "./util-Dkw5bD7a.mjs";
3
2
  import { createConnection } from "mysql2/promise";
3
+ import * as SqlString$1 from "sqlstring";
4
4
  //#region src/db/connectors/mysql/client.ts
5
5
  var MysqlClient = class extends DBClient {
6
6
  async release() {}
@@ -208,65 +208,6 @@ var CompositeCondition = class CompositeCondition {
208
208
  }
209
209
  };
210
210
  //#endregion
211
- //#region src/migration/makeMutaion.ts
212
- const formatSubscription = (subscription) => {
213
- if (subscription === void 0 || subscription === false) return {
214
- enabled: false,
215
- subscriptionFilter: []
216
- };
217
- if (subscription === true) return {
218
- enabled: true,
219
- subscriptionFilter: []
220
- };
221
- return {
222
- enabled: subscription.enabled,
223
- subscriptionFilter: subscription.subscriptionFilter || []
224
- };
225
- };
226
- const formatOptions = (type, option) => ({
227
- type,
228
- noReFetch: option?.noRefetch || false,
229
- middlewares: option?.middlewares || [],
230
- contextFields: option?.contextFields || [],
231
- subscription: formatSubscription(option?.subscription)
232
- });
233
- const Mutations = {
234
- create: (options) => formatOptions("create", options),
235
- update: (options) => formatOptions("update", options),
236
- delete: (options) => formatOptions("delete", options)
237
- };
238
- //#endregion
239
- //#region src/migration/makeQuery.ts
240
- const single = (name, options) => ({
241
- type: "single",
242
- name,
243
- conditions: options?.conditions || [],
244
- middlewares: options?.middlewares || []
245
- });
246
- const listAll = (name, options) => ({
247
- type: "list-all",
248
- name,
249
- conditions: options?.conditions || [],
250
- middlewares: options?.middlewares || []
251
- });
252
- const paging = (name, options) => ({
253
- type: "list-paging",
254
- name,
255
- conditions: options?.conditions || [],
256
- middlewares: options?.middlewares || []
257
- });
258
- const primary = (middlewares = []) => ({
259
- type: "primary",
260
- conditions: [],
261
- middlewares
262
- });
263
- const Queries = {
264
- single,
265
- listAll,
266
- paging,
267
- primary
268
- };
269
- //#endregion
270
211
  //#region src/runtime/createTypeDef.ts
271
212
  const makeArgs = (args) => {
272
213
  if (!args || args.length === 0) return "";
@@ -860,4 +801,4 @@ const pagingOption = (option) => {
860
801
  };
861
802
  };
862
803
  //#endregion
863
- export { CompositeCondition, Conditions, Mutations, MysqlClient, QExpr, QExpr as qe, Queries, SasatDBDatasource, Sql, SqlString, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, formatQuery, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, migrate, pagingOption, pick, queryToSql, setConfig };
804
+ export { CompositeCondition, MysqlClient, QExpr, QExpr as qe, SasatDBDatasource, Sql, SqlString, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, formatQuery, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, queryToSql, setConfig };
@@ -0,0 +1,134 @@
1
+ //#region src/migration/makeCondition.ts
2
+ const parent = (field) => ({
3
+ kind: "parent",
4
+ field
5
+ });
6
+ const child = (field) => ({
7
+ kind: "child",
8
+ field
9
+ });
10
+ const contextOrError = (field, errorMessage) => ({
11
+ kind: "context",
12
+ field,
13
+ onNotDefined: {
14
+ action: "error",
15
+ message: errorMessage
16
+ }
17
+ });
18
+ const contextOrDefault = (field, defaultValue) => ({
19
+ kind: "context",
20
+ field,
21
+ onNotDefined: {
22
+ action: "defaultValue",
23
+ value: defaultValue
24
+ }
25
+ });
26
+ const fixed = (value) => ({
27
+ kind: "fixed",
28
+ value
29
+ });
30
+ const today = (thresholdHour, date) => ({
31
+ kind: "today",
32
+ type: date ? "date" : "datetime",
33
+ thresholdHour
34
+ });
35
+ const now = () => ({ kind: "now" });
36
+ const values = (begin, end) => ({
37
+ kind: "range",
38
+ begin,
39
+ end
40
+ });
41
+ const betweenToday = (thresholdHour) => ({
42
+ kind: "date-range",
43
+ range: "today",
44
+ thresholdHour
45
+ });
46
+ const custom = (conditionName, parentRequiredFields, childRequiredFields) => ({
47
+ kind: "custom",
48
+ conditionName,
49
+ parentRequiredFields,
50
+ childRequiredFields
51
+ });
52
+ const field = (column) => ({
53
+ kind: "field",
54
+ column
55
+ });
56
+ const arg = (name, type) => ({
57
+ kind: "arg",
58
+ name,
59
+ type
60
+ });
61
+ const betweenRel = (left, range) => ({
62
+ kind: "comparison",
63
+ left,
64
+ operator: "BETWEEN",
65
+ right: range
66
+ });
67
+ const betweenQuery = (left, begin, end) => ({
68
+ kind: "between",
69
+ operator: "BETWEEN",
70
+ left,
71
+ begin,
72
+ end
73
+ });
74
+ const comparisonRel = (left, operator, right) => ({
75
+ kind: "comparison",
76
+ left,
77
+ right,
78
+ operator
79
+ });
80
+ const inRel = (left, right) => ({
81
+ kind: "comparison",
82
+ left,
83
+ right,
84
+ operator: "IN"
85
+ });
86
+ const isNullRel = (value) => ({
87
+ kind: "isNull",
88
+ value,
89
+ not: false
90
+ });
91
+ const isNotNullRel = (value) => ({
92
+ kind: "isNull",
93
+ value,
94
+ not: true
95
+ });
96
+ const comparisonQuery = (left, operator, right) => ({
97
+ kind: "comparison",
98
+ left,
99
+ right,
100
+ operator
101
+ });
102
+ const Conditions = {
103
+ betweenRel,
104
+ betweenQuery,
105
+ custom,
106
+ rel: {
107
+ between: betweenRel,
108
+ comparison: comparisonRel,
109
+ in: inRel,
110
+ isNull: isNullRel,
111
+ isNotNull: isNotNullRel
112
+ },
113
+ query: {
114
+ between: betweenQuery,
115
+ comparison: comparisonQuery
116
+ },
117
+ value: {
118
+ parent,
119
+ child,
120
+ contextOrError,
121
+ contextOrDefault,
122
+ fixed,
123
+ today,
124
+ now,
125
+ field,
126
+ arg
127
+ },
128
+ range: {
129
+ values,
130
+ today: betweenToday
131
+ }
132
+ };
133
+ //#endregion
134
+ export { Conditions as t };
@@ -0,0 +1,139 @@
1
+ //#region src/migration/makeCondition.ts
2
+ const parent = (field) => ({
3
+ kind: "parent",
4
+ field
5
+ });
6
+ const child = (field) => ({
7
+ kind: "child",
8
+ field
9
+ });
10
+ const contextOrError = (field, errorMessage) => ({
11
+ kind: "context",
12
+ field,
13
+ onNotDefined: {
14
+ action: "error",
15
+ message: errorMessage
16
+ }
17
+ });
18
+ const contextOrDefault = (field, defaultValue) => ({
19
+ kind: "context",
20
+ field,
21
+ onNotDefined: {
22
+ action: "defaultValue",
23
+ value: defaultValue
24
+ }
25
+ });
26
+ const fixed = (value) => ({
27
+ kind: "fixed",
28
+ value
29
+ });
30
+ const today = (thresholdHour, date) => ({
31
+ kind: "today",
32
+ type: date ? "date" : "datetime",
33
+ thresholdHour
34
+ });
35
+ const now = () => ({ kind: "now" });
36
+ const values = (begin, end) => ({
37
+ kind: "range",
38
+ begin,
39
+ end
40
+ });
41
+ const betweenToday = (thresholdHour) => ({
42
+ kind: "date-range",
43
+ range: "today",
44
+ thresholdHour
45
+ });
46
+ const custom = (conditionName, parentRequiredFields, childRequiredFields) => ({
47
+ kind: "custom",
48
+ conditionName,
49
+ parentRequiredFields,
50
+ childRequiredFields
51
+ });
52
+ const field = (column) => ({
53
+ kind: "field",
54
+ column
55
+ });
56
+ const arg = (name, type) => ({
57
+ kind: "arg",
58
+ name,
59
+ type
60
+ });
61
+ const betweenRel = (left, range) => ({
62
+ kind: "comparison",
63
+ left,
64
+ operator: "BETWEEN",
65
+ right: range
66
+ });
67
+ const betweenQuery = (left, begin, end) => ({
68
+ kind: "between",
69
+ operator: "BETWEEN",
70
+ left,
71
+ begin,
72
+ end
73
+ });
74
+ const comparisonRel = (left, operator, right) => ({
75
+ kind: "comparison",
76
+ left,
77
+ right,
78
+ operator
79
+ });
80
+ const inRel = (left, right) => ({
81
+ kind: "comparison",
82
+ left,
83
+ right,
84
+ operator: "IN"
85
+ });
86
+ const isNullRel = (value) => ({
87
+ kind: "isNull",
88
+ value,
89
+ not: false
90
+ });
91
+ const isNotNullRel = (value) => ({
92
+ kind: "isNull",
93
+ value,
94
+ not: true
95
+ });
96
+ const comparisonQuery = (left, operator, right) => ({
97
+ kind: "comparison",
98
+ left,
99
+ right,
100
+ operator
101
+ });
102
+ const Conditions = {
103
+ betweenRel,
104
+ betweenQuery,
105
+ custom,
106
+ rel: {
107
+ between: betweenRel,
108
+ comparison: comparisonRel,
109
+ in: inRel,
110
+ isNull: isNullRel,
111
+ isNotNull: isNotNullRel
112
+ },
113
+ query: {
114
+ between: betweenQuery,
115
+ comparison: comparisonQuery
116
+ },
117
+ value: {
118
+ parent,
119
+ child,
120
+ contextOrError,
121
+ contextOrDefault,
122
+ fixed,
123
+ today,
124
+ now,
125
+ field,
126
+ arg
127
+ },
128
+ range: {
129
+ values,
130
+ today: betweenToday
131
+ }
132
+ };
133
+ //#endregion
134
+ Object.defineProperty(exports, "Conditions", {
135
+ enumerable: true,
136
+ get: function() {
137
+ return Conditions;
138
+ }
139
+ });