sasat 0.19.13 → 0.19.14
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/lib/cli/cli.js +2 -0
- package/lib/cli/commands/migrate.d.ts +6 -3
- package/lib/cli/commands/migrate.js +1 -1
- package/lib/db/getDbClient.d.ts +1 -1
- package/lib/db/sql/createTable/createTableParser.js +2 -2
- package/lib/generatorv2/codegen/ts/generateIDEncoder.js +2 -5
- package/lib/generatorv2/codegen/ts/generateMiddlewares.d.ts +2 -0
- package/lib/generatorv2/codegen/ts/generateMiddlewares.js +45 -0
- package/lib/generatorv2/codegen/ts/generateQueryResolver.js +15 -6
- package/lib/generatorv2/codegen/ts/generateUserDefinedCondition.js +2 -1
- package/lib/generatorv2/codegen/ts/mutation/makeMutationInputDecoder.js +5 -2
- package/lib/generatorv2/codegen/ts/tsFileNames.d.ts +1 -0
- package/lib/generatorv2/codegen/ts/tsFileNames.js +1 -0
- package/lib/generatorv2/codegen/tscodegen_v2.d.ts +1 -0
- package/lib/generatorv2/codegen/tscodegen_v2.js +4 -0
- package/lib/generatorv2/codegen_v2.d.ts +1 -0
- package/lib/generatorv2/codegen_v2.js +10 -0
- package/lib/generatorv2/nodes/entityNode.js +11 -5
- package/lib/generatorv2/nodes/mutationNode.d.ts +1 -0
- package/lib/generatorv2/parser/makeContextNodes.js +2 -2
- package/lib/generatorv2/parser/makeMutationNodes.js +27 -23
- package/lib/generatorv2/parser/makeSubscriptionNode.js +11 -19
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/migration/controller.d.ts +2 -1
- package/lib/migration/controller.js +6 -2
- package/lib/migration/creators/tableCreator.d.ts +5 -11
- package/lib/migration/creators/tableCreator.js +6 -16
- package/lib/migration/data/GQLOption.d.ts +14 -18
- package/lib/migration/data/GQLOption.js +2 -22
- package/lib/migration/exec/runMigration.d.ts +2 -1
- package/lib/migration/exec/runMigration.js +7 -1
- package/lib/migration/front/tableMigrator.d.ts +5 -9
- package/lib/migration/front/tableMigrator.js +14 -16
- package/lib/migration/makeMutaion.d.ts +16 -0
- package/lib/migration/makeMutaion.js +29 -0
- package/lib/migration/makeQuery.d.ts +13 -4
- package/lib/migration/makeQuery.js +12 -8
- package/lib/migration/serializable/table.d.ts +1 -5
- package/lib/migration/serializable/table.js +3 -35
- package/lib/runtime/resolverMiddleware.d.ts +1 -1
- package/package.json +10 -10
- package/lib/generatorv2/codegen/gql/generateTypeDefs.d.ts +0 -3
- package/lib/generatorv2/codegen/gql/generateTypeDefs.js +0 -114
- package/lib/generatorv2/codegen/gql/gqlString.d.ts +0 -16
- package/lib/generatorv2/codegen/gql/gqlString.js +0 -43
- package/lib/generatorv2/codegen/gql/typeDefinition.d.ts +0 -9
- package/lib/generatorv2/codegen/gql/typeDefinition.js +0 -13
- package/lib/generatorv2/codegen/ts/relationMap/makeCondition.d.ts +0 -2
- package/lib/generatorv2/codegen/ts/relationMap/makeCondition.js +0 -100
- package/lib/generatorv2/nodes/ConditionNode.d.ts +0 -56
- package/lib/generatorv2/nodes/ConditionNode.js +0 -1
- package/lib/generatorv2/parser/makeQueryNodes.d.ts +0 -0
- package/lib/generatorv2/parser/makeQueryNodes.js +0 -1
- package/lib/runtime/dsl/query/fieldToQuery.d.ts +0 -0
- package/lib/runtime/dsl/query/fieldToQuery.js +0 -1
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { tsg } from '../../../../tsg/index.js';
|
|
2
|
-
import { makeThrowExpressions } from './makeNoContexError.js';
|
|
3
|
-
import { nonNullableFilter } from '../../../../util/type.js';
|
|
4
|
-
const parentTableAlias = 'parentTableAlias';
|
|
5
|
-
const childTableAlias = 'childTableAlias';
|
|
6
|
-
const qExpr = tsg.identifier('QExpr').importFrom('sasat');
|
|
7
|
-
const makeConditionValueQExpr = (node, cv) => {
|
|
8
|
-
const arg = tsg.identifier('arg');
|
|
9
|
-
const context = arg.property('context?');
|
|
10
|
-
switch (cv.kind) {
|
|
11
|
-
case 'context': {
|
|
12
|
-
const value = context.property(cv.field);
|
|
13
|
-
if (cv.onNotDefined.action !== 'defaultValue') {
|
|
14
|
-
return qExpr.property('value').call(value);
|
|
15
|
-
}
|
|
16
|
-
return qExpr
|
|
17
|
-
.property('value')
|
|
18
|
-
.call(tsg.binary(context.property(cv.field), '||', typeof cv.onNotDefined.value === 'string'
|
|
19
|
-
? tsg.string(cv.onNotDefined.value)
|
|
20
|
-
: tsg.number(cv.onNotDefined.value)));
|
|
21
|
-
}
|
|
22
|
-
case 'parent': {
|
|
23
|
-
const columnName = node.fields.find(it => it.fieldName === cv.field)?.columnName ||
|
|
24
|
-
cv.field;
|
|
25
|
-
return qExpr
|
|
26
|
-
.property('field')
|
|
27
|
-
.call(arg.property(childTableAlias), tsg.string(columnName));
|
|
28
|
-
}
|
|
29
|
-
case 'child': {
|
|
30
|
-
const columnName = node.fields.find(it => it.fieldName === cv.field)?.columnName ||
|
|
31
|
-
cv.field;
|
|
32
|
-
return tsg.ternary(arg.property(parentTableAlias), qExpr
|
|
33
|
-
.property('field')
|
|
34
|
-
.call(arg.property(parentTableAlias), tsg.string(columnName)), qExpr
|
|
35
|
-
.property('value')
|
|
36
|
-
.call(arg.property('parent?').property(cv.field)));
|
|
37
|
-
}
|
|
38
|
-
case 'fixed': {
|
|
39
|
-
return qExpr
|
|
40
|
-
.property('value')
|
|
41
|
-
.call(typeof cv.value === 'string'
|
|
42
|
-
? tsg.string(cv.value)
|
|
43
|
-
: tsg.number(cv.value));
|
|
44
|
-
}
|
|
45
|
-
case 'today': {
|
|
46
|
-
return qExpr
|
|
47
|
-
.property('value')
|
|
48
|
-
.call(tsg.identifier('getTodayDateTimeString').importFrom('sasat').call());
|
|
49
|
-
}
|
|
50
|
-
case 'now': {
|
|
51
|
-
return qExpr.property('value').call(tsg
|
|
52
|
-
.identifier('dateString')
|
|
53
|
-
.importFrom('sasat')
|
|
54
|
-
.call(tsg.new(tsg.identifier('Date'))));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const makeRangeCondition = (entity, range) => {
|
|
59
|
-
if (range.kind === 'range') {
|
|
60
|
-
return [
|
|
61
|
-
makeConditionValueQExpr(entity, range.begin),
|
|
62
|
-
makeConditionValueQExpr(entity, range.end),
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
return [
|
|
66
|
-
tsg.spread(tsg
|
|
67
|
-
.identifier('getDayRangeQExpr')
|
|
68
|
-
.importFrom('sasat')
|
|
69
|
-
.call(tsg.new(tsg.identifier('Date')), range.thresholdHour
|
|
70
|
-
? tsg.number(range.thresholdHour)
|
|
71
|
-
: tsg.identifier('undefined'))),
|
|
72
|
-
];
|
|
73
|
-
};
|
|
74
|
-
const makeConditionExpr = (entity, condition) => {
|
|
75
|
-
if (condition.kind === 'custom') {
|
|
76
|
-
return tsg
|
|
77
|
-
.identifier(condition.conditionName)
|
|
78
|
-
.importFrom('../conditions')
|
|
79
|
-
.call(tsg.identifier('arg'));
|
|
80
|
-
}
|
|
81
|
-
if (condition.operator === 'BETWEEN') {
|
|
82
|
-
return qExpr
|
|
83
|
-
.property('conditions')
|
|
84
|
-
.property('between')
|
|
85
|
-
.call(makeConditionValueQExpr(entity, condition.left), ...makeRangeCondition(entity, condition.right));
|
|
86
|
-
}
|
|
87
|
-
return qExpr
|
|
88
|
-
.property('conditions')
|
|
89
|
-
.property('comparison')
|
|
90
|
-
.call(makeConditionValueQExpr(entity, condition.left), tsg.string(condition.operator), makeConditionValueQExpr(entity, condition.right));
|
|
91
|
-
};
|
|
92
|
-
export const makeCondition = (node, ref) => {
|
|
93
|
-
const arg = tsg.identifier('arg');
|
|
94
|
-
return tsg.propertyAssign('condition', tsg.arrowFunc([tsg.parameter(arg.toString())], tsg.typeRef('BooleanValueExpression').importFrom('sasat'), tsg.block(...ref.joinCondition
|
|
95
|
-
.flatMap(it => makeThrowExpressions(it))
|
|
96
|
-
.filter(nonNullableFilter), tsg.return(qExpr
|
|
97
|
-
.property('conditions')
|
|
98
|
-
.property('and')
|
|
99
|
-
.call(...ref.joinCondition.map(it => makeConditionExpr(node, it)))))));
|
|
100
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { ComparisonOperators } from '../../db/sql/expression/comparison.js';
|
|
2
|
-
export declare type ConditionValue = {
|
|
3
|
-
kind: 'parent' | 'child';
|
|
4
|
-
field: string;
|
|
5
|
-
} | ContextConditionValue | FixedConditionValue | TodayStartConditionValue | NowConditionValue;
|
|
6
|
-
declare type ContextConditionValue = {
|
|
7
|
-
kind: 'context';
|
|
8
|
-
field: string;
|
|
9
|
-
onNotDefined: OnNotDefinedAction;
|
|
10
|
-
};
|
|
11
|
-
declare type FixedConditionValue = {
|
|
12
|
-
kind: 'fixed';
|
|
13
|
-
value: string | number;
|
|
14
|
-
};
|
|
15
|
-
declare type TodayStartConditionValue = {
|
|
16
|
-
kind: 'today';
|
|
17
|
-
thresholdHour?: number;
|
|
18
|
-
};
|
|
19
|
-
declare type NowConditionValue = {
|
|
20
|
-
kind: 'now';
|
|
21
|
-
};
|
|
22
|
-
export declare type ContextConditionRangeValue = {
|
|
23
|
-
kind: 'range';
|
|
24
|
-
begin: ConditionValue;
|
|
25
|
-
end: ConditionValue;
|
|
26
|
-
} | DateRangeConditionValue;
|
|
27
|
-
declare type DateRangeConditionValue = {
|
|
28
|
-
kind: 'date-range';
|
|
29
|
-
range: 'today';
|
|
30
|
-
thresholdHour?: number;
|
|
31
|
-
};
|
|
32
|
-
declare type OnNotDefinedAction = {
|
|
33
|
-
action: 'error';
|
|
34
|
-
message: string;
|
|
35
|
-
} | {
|
|
36
|
-
action: 'defaultValue';
|
|
37
|
-
value: string | number;
|
|
38
|
-
};
|
|
39
|
-
export declare type ConditionNode = {
|
|
40
|
-
kind: 'comparison';
|
|
41
|
-
left: ConditionValue;
|
|
42
|
-
operator: ComparisonOperators;
|
|
43
|
-
right: ConditionValue;
|
|
44
|
-
} | {
|
|
45
|
-
kind: 'comparison';
|
|
46
|
-
left: ConditionValue;
|
|
47
|
-
operator: 'BETWEEN';
|
|
48
|
-
right: ContextConditionRangeValue;
|
|
49
|
-
} | CustomConditionNode;
|
|
50
|
-
export declare type CustomConditionNode = {
|
|
51
|
-
kind: 'custom';
|
|
52
|
-
conditionName: string;
|
|
53
|
-
parentRequiredFields?: string[];
|
|
54
|
-
childRequiredFields?: string[];
|
|
55
|
-
};
|
|
56
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|