sasat 0.22.4 → 0.22.6
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/cli/index.cjs +16 -15
- package/dist/cli/index.mjs +2 -1
- package/dist/comparison-BpTtc1iD.d.mts +42 -0
- package/dist/comparison-CIb9xu5T.d.cts +42 -0
- package/dist/dbClient-2mFJTQw7.d.mts +35 -0
- package/dist/dbClient-Bnk1JKBU.d.cts +35 -0
- package/dist/index.cjs +33 -95
- package/dist/index.d.cts +5 -739
- package/dist/index.d.mts +6 -740
- package/dist/index.mjs +5 -63
- package/dist/makeCondition-3MdYUm5k.mjs +134 -0
- package/dist/makeCondition-DKSyAkri.cjs +139 -0
- package/dist/{migrate-BRNxkHCx.cjs → migrate-BDE07ocG.cjs} +3013 -3511
- package/dist/{migrate-Cbj2OVbY.mjs → migrate-DnqBdQ6r.mjs} +3019 -3385
- package/dist/migration/index.cjs +64 -0
- package/dist/migration/index.d.cts +657 -0
- package/dist/migration/index.d.mts +657 -0
- package/dist/migration/index.mjs +61 -0
- package/dist/testing/index.cjs +3 -0
- package/dist/testing/index.d.cts +12 -0
- package/dist/testing/index.d.mts +12 -0
- package/dist/testing/index.mjs +2 -0
- package/dist/util-C5Jevn5B.cjs +377 -0
- package/dist/util-Dkw5bD7a.mjs +239 -0
- package/package.json +9 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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() {}
|
|
@@ -110,6 +110,7 @@ const Sql = {
|
|
|
110
110
|
case 8: return Sql.in(expr);
|
|
111
111
|
case 6: return Sql.isNull(expr);
|
|
112
112
|
case 14: return Sql.exists(expr);
|
|
113
|
+
case 15: return expr.expr;
|
|
113
114
|
}
|
|
114
115
|
},
|
|
115
116
|
exists: (expr) => {
|
|
@@ -208,65 +209,6 @@ var CompositeCondition = class CompositeCondition {
|
|
|
208
209
|
}
|
|
209
210
|
};
|
|
210
211
|
//#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
212
|
//#region src/runtime/createTypeDef.ts
|
|
271
213
|
const makeArgs = (args) => {
|
|
272
214
|
if (!args || args.length === 0) return "";
|
|
@@ -683,7 +625,7 @@ const createQuery = (baseTableName, fields, options, tableInfo, relationMap, con
|
|
|
683
625
|
parentTableAlias: tableAlias,
|
|
684
626
|
childTableAlias: table.tableAlias || "t" + current,
|
|
685
627
|
context
|
|
686
|
-
}), table.joinOn), "LEFT");
|
|
628
|
+
}), table.joinOn), table.joinType ?? "LEFT");
|
|
687
629
|
}).filter(nonNullable), tableAlias);
|
|
688
630
|
};
|
|
689
631
|
return {
|
|
@@ -860,4 +802,4 @@ const pagingOption = (option) => {
|
|
|
860
802
|
};
|
|
861
803
|
};
|
|
862
804
|
//#endregion
|
|
863
|
-
export { CompositeCondition,
|
|
805
|
+
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
|
+
});
|