oak-domain 1.1.13 → 1.1.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.
@@ -1,16 +1,12 @@
1
- import { String, Datetime, PrimaryKey } from "../../types/DataType";
1
+ import { String } from "../../types/DataType";
2
2
  import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
3
  import { OneOf } from "../../types/Polyfill";
4
4
  import * as SubQuery from "../_SubQuery";
5
- import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
5
+ import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
6
6
  import { Action, ParticularAction, IState } from "./Action";
7
7
  import * as ModiEntity from "../ModiEntity/Schema";
8
8
  import * as OperEntity from "../OperEntity/Schema";
9
- export declare type OpSchema = {
10
- id: PrimaryKey;
11
- $$createAt$$: Datetime;
12
- $$updateAt$$: Datetime;
13
- $$deleteAt$$?: Datetime | null;
9
+ export declare type OpSchema = EntityShape & {
14
10
  targetEntity: String<32>;
15
11
  entity: String<32>;
16
12
  entityId: String<64>;
@@ -21,11 +17,7 @@ export declare type OpSchema = {
21
17
  iState?: IState | null;
22
18
  };
23
19
  export declare type OpAttr = keyof OpSchema;
24
- export declare type Schema = {
25
- id: PrimaryKey;
26
- $$createAt$$: Datetime;
27
- $$updateAt$$: Datetime;
28
- $$deleteAt$$?: Datetime | null;
20
+ export declare type Schema = EntityShape & {
29
21
  targetEntity: String<32>;
30
22
  entity: String<32>;
31
23
  entityId: String<64>;
@@ -42,6 +34,7 @@ export declare type Schema = {
42
34
  declare type AttrFilter = {
43
35
  id: Q_StringValue | SubQuery.ModiIdSubQuery;
44
36
  $$createAt$$: Q_DateValue;
37
+ $$seq$$: Q_StringValue;
45
38
  $$updateAt$$: Q_DateValue;
46
39
  targetEntity: Q_StringValue;
47
40
  entity: Q_StringValue;
@@ -59,6 +52,7 @@ export declare type Projection = {
59
52
  id: 1;
60
53
  $$createAt$$?: 1;
61
54
  $$updateAt$$?: 1;
55
+ $$seq$$?: 1;
62
56
  targetEntity?: 1;
63
57
  entity?: 1;
64
58
  entityId?: 1;
@@ -80,6 +74,7 @@ export declare type ExportProjection = {
80
74
  id?: string;
81
75
  $$createAt$$?: string;
82
76
  $$updateAt$$?: string;
77
+ $$seq$$?: string;
83
78
  targetEntity?: string;
84
79
  entity?: string;
85
80
  entityId?: string;
@@ -102,6 +97,8 @@ export declare type SortAttr = {
102
97
  id: 1;
103
98
  } | {
104
99
  $$createAt$$: 1;
100
+ } | {
101
+ $$seq$$: 1;
105
102
  } | {
106
103
  $$updateAt$$: 1;
107
104
  } | {
@@ -1,26 +1,18 @@
1
- import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
1
+ import { String, ForeignKey } from "../../types/DataType";
2
2
  import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
3
  import { OneOf } from "../../types/Polyfill";
4
4
  import * as SubQuery from "../_SubQuery";
5
- import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
5
+ import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
6
6
  import { AppendOnlyAction } from "../../actions/action";
7
7
  import * as Modi from "../Modi/Schema";
8
8
  import * as User from "../User/Schema";
9
- export declare type OpSchema = {
10
- id: PrimaryKey;
11
- $$createAt$$: Datetime;
12
- $$updateAt$$: Datetime;
13
- $$deleteAt$$?: Datetime | null;
9
+ export declare type OpSchema = EntityShape & {
14
10
  modiId: ForeignKey<"modi">;
15
11
  entity: "user" | string;
16
12
  entityId: String<64>;
17
13
  };
18
14
  export declare type OpAttr = keyof OpSchema;
19
- export declare type Schema = {
20
- id: PrimaryKey;
21
- $$createAt$$: Datetime;
22
- $$updateAt$$: Datetime;
23
- $$deleteAt$$?: Datetime | null;
15
+ export declare type Schema = EntityShape & {
24
16
  modiId: ForeignKey<"modi">;
25
17
  entity: "user" | string;
26
18
  entityId: String<64>;
@@ -32,6 +24,7 @@ export declare type Schema = {
32
24
  declare type AttrFilter<E> = {
33
25
  id: Q_StringValue | SubQuery.ModiEntityIdSubQuery;
34
26
  $$createAt$$: Q_DateValue;
27
+ $$seq$$: Q_StringValue;
35
28
  $$updateAt$$: Q_DateValue;
36
29
  modiId: Q_StringValue | SubQuery.ModiIdSubQuery;
37
30
  modi: Modi.Filter;
@@ -46,6 +39,7 @@ export declare type Projection = {
46
39
  id: 1;
47
40
  $$createAt$$?: 1;
48
41
  $$updateAt$$?: 1;
42
+ $$seq$$?: 1;
49
43
  modiId?: 1;
50
44
  modi?: Modi.Projection;
51
45
  entity?: 1;
@@ -58,6 +52,7 @@ export declare type ExportProjection = {
58
52
  id?: string;
59
53
  $$createAt$$?: string;
60
54
  $$updateAt$$?: string;
55
+ $$seq$$?: string;
61
56
  modiId?: string;
62
57
  modi?: Modi.ExportProjection;
63
58
  entity?: string;
@@ -77,6 +72,8 @@ export declare type SortAttr = {
77
72
  id: 1;
78
73
  } | {
79
74
  $$createAt$$: 1;
75
+ } | {
76
+ $$seq$$: 1;
80
77
  } | {
81
78
  $$updateAt$$: 1;
82
79
  } | {
@@ -1,16 +1,12 @@
1
- import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
1
+ import { String, ForeignKey } from "../../types/DataType";
2
2
  import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
3
  import { OneOf } from "../../types/Polyfill";
4
4
  import * as SubQuery from "../_SubQuery";
5
- import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
5
+ import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
6
6
  import { AppendOnlyAction } from "../../actions/action";
7
7
  import * as User from "../User/Schema";
8
8
  import * as OperEntity from "../OperEntity/Schema";
9
- export declare type OpSchema = {
10
- id: PrimaryKey;
11
- $$createAt$$: Datetime;
12
- $$updateAt$$: Datetime;
13
- $$deleteAt$$?: Datetime | null;
9
+ export declare type OpSchema = EntityShape & {
14
10
  action: String<16>;
15
11
  data: Object;
16
12
  filter?: Object | null;
@@ -18,11 +14,7 @@ export declare type OpSchema = {
18
14
  operatorId?: ForeignKey<"user"> | null;
19
15
  };
20
16
  export declare type OpAttr = keyof OpSchema;
21
- export declare type Schema = {
22
- id: PrimaryKey;
23
- $$createAt$$: Datetime;
24
- $$updateAt$$: Datetime;
25
- $$deleteAt$$?: Datetime | null;
17
+ export declare type Schema = EntityShape & {
26
18
  action: String<16>;
27
19
  data: Object;
28
20
  filter?: Object | null;
@@ -36,6 +28,7 @@ export declare type Schema = {
36
28
  declare type AttrFilter = {
37
29
  id: Q_StringValue | SubQuery.OperIdSubQuery;
38
30
  $$createAt$$: Q_DateValue;
31
+ $$seq$$: Q_StringValue;
39
32
  $$updateAt$$: Q_DateValue;
40
33
  action: Q_StringValue;
41
34
  data: Object;
@@ -51,6 +44,7 @@ export declare type Projection = {
51
44
  id: 1;
52
45
  $$createAt$$?: 1;
53
46
  $$updateAt$$?: 1;
47
+ $$seq$$?: 1;
54
48
  action?: 1;
55
49
  data?: 1;
56
50
  filter?: 1;
@@ -67,6 +61,7 @@ export declare type ExportProjection = {
67
61
  id?: string;
68
62
  $$createAt$$?: string;
69
63
  $$updateAt$$?: string;
64
+ $$seq$$?: string;
70
65
  action?: string;
71
66
  data?: string;
72
67
  filter?: string;
@@ -87,6 +82,8 @@ export declare type SortAttr = {
87
82
  id: 1;
88
83
  } | {
89
84
  $$createAt$$: 1;
85
+ } | {
86
+ $$seq$$: 1;
90
87
  } | {
91
88
  $$updateAt$$: 1;
92
89
  } | {
@@ -1,27 +1,19 @@
1
- import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
1
+ import { String, ForeignKey } from "../../types/DataType";
2
2
  import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
3
  import { OneOf } from "../../types/Polyfill";
4
4
  import * as SubQuery from "../_SubQuery";
5
- import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
5
+ import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
6
6
  import { AppendOnlyAction } from "../../actions/action";
7
7
  import * as Oper from "../Oper/Schema";
8
8
  import * as Modi from "../Modi/Schema";
9
9
  import * as User from "../User/Schema";
10
- export declare type OpSchema = {
11
- id: PrimaryKey;
12
- $$createAt$$: Datetime;
13
- $$updateAt$$: Datetime;
14
- $$deleteAt$$?: Datetime | null;
10
+ export declare type OpSchema = EntityShape & {
15
11
  operId: ForeignKey<"oper">;
16
12
  entity: "modi" | "user" | string;
17
13
  entityId: String<64>;
18
14
  };
19
15
  export declare type OpAttr = keyof OpSchema;
20
- export declare type Schema = {
21
- id: PrimaryKey;
22
- $$createAt$$: Datetime;
23
- $$updateAt$$: Datetime;
24
- $$deleteAt$$?: Datetime | null;
16
+ export declare type Schema = EntityShape & {
25
17
  operId: ForeignKey<"oper">;
26
18
  entity: "modi" | "user" | string;
27
19
  entityId: String<64>;
@@ -34,6 +26,7 @@ export declare type Schema = {
34
26
  declare type AttrFilter<E> = {
35
27
  id: Q_StringValue | SubQuery.OperEntityIdSubQuery;
36
28
  $$createAt$$: Q_DateValue;
29
+ $$seq$$: Q_StringValue;
37
30
  $$updateAt$$: Q_DateValue;
38
31
  operId: Q_StringValue | SubQuery.OperIdSubQuery;
39
32
  oper: Oper.Filter;
@@ -49,6 +42,7 @@ export declare type Projection = {
49
42
  id: 1;
50
43
  $$createAt$$?: 1;
51
44
  $$updateAt$$?: 1;
45
+ $$seq$$?: 1;
52
46
  operId?: 1;
53
47
  oper?: Oper.Projection;
54
48
  entity?: 1;
@@ -62,6 +56,7 @@ export declare type ExportProjection = {
62
56
  id?: string;
63
57
  $$createAt$$?: string;
64
58
  $$updateAt$$?: string;
59
+ $$seq$$?: string;
65
60
  operId?: string;
66
61
  oper?: Oper.ExportProjection;
67
62
  entity?: string;
@@ -85,6 +80,8 @@ export declare type SortAttr = {
85
80
  id: 1;
86
81
  } | {
87
82
  $$createAt$$: 1;
83
+ } | {
84
+ $$seq$$: 1;
88
85
  } | {
89
86
  $$updateAt$$: 1;
90
87
  } | {
@@ -1,27 +1,19 @@
1
- import { String, Text, Datetime, PrimaryKey } from "../../types/DataType";
1
+ import { String, Text } from "../../types/DataType";
2
2
  import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
3
  import { OneOf } from "../../types/Polyfill";
4
4
  import * as SubQuery from "../_SubQuery";
5
- import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
5
+ import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
6
6
  import { GenericAction, RelationAction } from "../../actions/action";
7
7
  import * as Oper from "../Oper/Schema";
8
8
  import * as OperEntity from "../OperEntity/Schema";
9
9
  import * as ModiEntity from "../ModiEntity/Schema";
10
- export declare type OpSchema = {
11
- id: PrimaryKey;
12
- $$createAt$$: Datetime;
13
- $$updateAt$$: Datetime;
14
- $$deleteAt$$?: Datetime | null;
10
+ export declare type OpSchema = EntityShape & {
15
11
  name?: String<16> | null;
16
12
  nickname?: String<64> | null;
17
13
  password?: Text | null;
18
14
  };
19
15
  export declare type OpAttr = keyof OpSchema;
20
- export declare type Schema = {
21
- id: PrimaryKey;
22
- $$createAt$$: Datetime;
23
- $$updateAt$$: Datetime;
24
- $$deleteAt$$?: Datetime | null;
16
+ export declare type Schema = EntityShape & {
25
17
  name?: String<16> | null;
26
18
  nickname?: String<64> | null;
27
19
  password?: Text | null;
@@ -34,6 +26,7 @@ export declare type Schema = {
34
26
  declare type AttrFilter = {
35
27
  id: Q_StringValue | SubQuery.UserIdSubQuery;
36
28
  $$createAt$$: Q_DateValue;
29
+ $$seq$$: Q_StringValue;
37
30
  $$updateAt$$: Q_DateValue;
38
31
  name: Q_StringValue;
39
32
  nickname: Q_StringValue;
@@ -46,6 +39,7 @@ export declare type Projection = {
46
39
  id: 1;
47
40
  $$createAt$$?: 1;
48
41
  $$updateAt$$?: 1;
42
+ $$seq$$?: 1;
49
43
  name?: 1;
50
44
  nickname?: 1;
51
45
  password?: 1;
@@ -65,6 +59,7 @@ export declare type ExportProjection = {
65
59
  id?: string;
66
60
  $$createAt$$?: string;
67
61
  $$updateAt$$?: string;
62
+ $$seq$$?: string;
68
63
  name?: string;
69
64
  nickname?: string;
70
65
  password?: string;
@@ -85,6 +80,8 @@ export declare type SortAttr = {
85
80
  id: 1;
86
81
  } | {
87
82
  $$createAt$$: 1;
83
+ } | {
84
+ $$seq$$: 1;
88
85
  } | {
89
86
  $$updateAt$$: 1;
90
87
  } | {
@@ -850,19 +850,7 @@ function analyzeEntity(filename, path, program, relativePath) {
850
850
  function constructSchema(statements, entity) {
851
851
  var e_1, _a, e_2, _b;
852
852
  var schemaAttrs = Schema[entity].schemaAttrs;
853
- var members = [
854
- // id: String<64>
855
- factory.createPropertySignature(undefined, factory.createIdentifier('id'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('PrimaryKey'))),
856
- // $$createAt$$: Datetime
857
- factory.createPropertySignature(undefined, factory.createIdentifier('$$createAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Datetime'))),
858
- // $$updateAt$$: Datetime
859
- factory.createPropertySignature(undefined, factory.createIdentifier('$$updateAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Datetime'))),
860
- // $$updateAt$$: Datetime
861
- factory.createPropertySignature(undefined, factory.createIdentifier('$$deleteAt$$'), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createUnionTypeNode([
862
- factory.createTypeReferenceNode(factory.createIdentifier('Datetime')),
863
- factory.createLiteralTypeNode(factory.createNull())
864
- ]))
865
- ];
853
+ var members = [];
866
854
  var members2 = [];
867
855
  var _c = ManyToOne, _d = entity, manyToOneSet = _c[_d];
868
856
  var _e = OneToMany, _f = entity, oneToManySet = _e[_f];
@@ -997,10 +985,14 @@ function constructSchema(statements, entity) {
997
985
  }
998
986
  statements.push(factory.createTypeAliasDeclaration(undefined, [
999
987
  factory.createModifier(ts.SyntaxKind.ExportKeyword)
1000
- ], factory.createIdentifier('OpSchema'), undefined, factory.createTypeLiteralNode(members)), factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("OpAttr"), undefined, factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeReferenceNode(factory.createIdentifier("OpSchema"), undefined))));
988
+ ], factory.createIdentifier('OpSchema'), undefined, factory.createIntersectionTypeNode([
989
+ factory.createTypeReferenceNode('EntityShape'),
990
+ factory.createTypeLiteralNode(members)
991
+ ])), factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("OpAttr"), undefined, factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeReferenceNode(factory.createIdentifier("OpSchema"), undefined))));
1001
992
  statements.push(factory.createTypeAliasDeclaration(undefined, [
1002
993
  factory.createModifier(ts.SyntaxKind.ExportKeyword)
1003
994
  ], factory.createIdentifier('Schema'), undefined, factory.createIntersectionTypeNode([
995
+ factory.createTypeReferenceNode('EntityShape'),
1004
996
  factory.createTypeLiteralNode(members.concat(members2)),
1005
997
  factory.createMappedTypeNode(undefined, factory.createTypeParameterDeclaration(undefined, factory.createIdentifier("A"), factory.createTypeReferenceNode(factory.createIdentifier("ExpressionKey"), undefined), undefined), undefined, factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), undefined)
1006
998
  ])));
@@ -1022,6 +1014,8 @@ function constructFilter(statements, entity) {
1022
1014
  ])),
1023
1015
  // $$createAt$$: Q_DateValue
1024
1016
  factory.createPropertySignature(undefined, factory.createIdentifier('$$createAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue'))),
1017
+ // $$seq$$: Q_StringValue
1018
+ factory.createPropertySignature(undefined, factory.createIdentifier('$$seq$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_StringValue'))),
1025
1019
  // $$updateAt$$: Q_DateValue
1026
1020
  factory.createPropertySignature(undefined, factory.createIdentifier('$$updateAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue')))
1027
1021
  ];
@@ -1176,6 +1170,7 @@ function constructProjection(statements, entity) {
1176
1170
  ['id', true],
1177
1171
  ['$$createAt$$', false],
1178
1172
  ['$$updateAt$$', false],
1173
+ ['$$seq$$', false],
1179
1174
  ];
1180
1175
  var foreignKeyProperties = (_a = {},
1181
1176
  _a[entity] = [''],
@@ -1501,6 +1496,8 @@ function constructSorter(statements, entity) {
1501
1496
  factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("id"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
1502
1497
  // $$createAt$$: 1
1503
1498
  factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$createAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
1499
+ // $$seq$$: 1
1500
+ factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$seq$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
1504
1501
  // $$updateAt$$: 1
1505
1502
  factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$updateAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
1506
1503
  ];
@@ -2549,7 +2546,8 @@ var initialStatements = function () { return [
2549
2546
  factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormCreateData")),
2550
2547
  factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormUpdateData")),
2551
2548
  factory.createImportSpecifier(false, factory.createIdentifier("Operation"), factory.createIdentifier("OakOperation")),
2552
- factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction"))
2549
+ factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction")),
2550
+ factory.createImportSpecifier(false, undefined, factory.createIdentifier("EntityShape")),
2553
2551
  ])), factory.createStringLiteral("".concat((0, env_1.TYPE_PATH_IN_OAK_DOMAIN)(), "Entity")), undefined)
2554
2552
  ]; };
2555
2553
  function outputSubQuery(outputDir, printer) {
@@ -35,6 +35,9 @@ var CascadeStore = /** @class */ (function (_super) {
35
35
  _a[id] = (0, lodash_1.cloneDeep)(row),
36
36
  _a));
37
37
  }
38
+ else {
39
+ Object.assign(entityBranch_1[id], row);
40
+ }
38
41
  });
39
42
  return;
40
43
  }
@@ -667,7 +670,7 @@ var CascadeStore = /** @class */ (function (_super) {
667
670
  modiAttr = this.getSchema()[entity].toModi;
668
671
  option2 = Object.assign({}, option);
669
672
  opData = {};
670
- if (modiAttr && action !== 'remove') {
673
+ if (modiAttr && action !== 'remove' && !option.dontCreateModi) {
671
674
  // create/update具有modi对象的对象,对其子对象的update行为全部是create modi对象(缓存动作)
672
675
  // delete此对象,所有的modi子对象应该通过触发器作废,这个通过系统的trigger来搞
673
676
  (0, assert_1.default)(!option2.modiParentId && !option2.modiParentEntity);
@@ -1074,7 +1077,7 @@ var CascadeStore = /** @class */ (function (_super) {
1074
1077
  */
1075
1078
  CascadeStore.prototype.doUpdateSingleRow = function (entity, operation, context, option) {
1076
1079
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1077
- var data, action, operId, filter, now, _a, modiCreate, addTimestamp_1, result_1, createInner, multipleCreate, data_2, data_2_1, d, createSingleOper, e_4_1, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, createOper, updateAttrCount, result_2;
1080
+ var data, action, operId, filter, now, _a, modiCreate, addTimestamp_1, result_1, createInner, multipleCreate, data_2, data_2_1, d, createSingleOper, e_4_1, operatorId, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, createOper, updateAttrCount, result_2;
1078
1081
  var e_4, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1079
1082
  var _this = this;
1080
1083
  return tslib_1.__generator(this, function (_o) {
@@ -1257,6 +1260,10 @@ var CascadeStore = /** @class */ (function (_super) {
1257
1260
  if (!(!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity))) return [3 /*break*/, 22];
1258
1261
  // 按照框架要求生成Oper和OperEntity这两个内置的对象
1259
1262
  (0, assert_1.default)(operId);
1263
+ return [4 /*yield*/, context.getCurrentUserId(true)];
1264
+ case 16:
1265
+ operatorId = _o.sent();
1266
+ if (!operatorId) return [3 /*break*/, 22];
1260
1267
  _e = {
1261
1268
  id: 'dummy',
1262
1269
  action: 'create'
@@ -1264,11 +1271,9 @@ var CascadeStore = /** @class */ (function (_super) {
1264
1271
  _f = {
1265
1272
  id: operId,
1266
1273
  action: action,
1267
- data: data
1274
+ data: data,
1275
+ operatorId: operatorId
1268
1276
  };
1269
- return [4 /*yield*/, context.getCurrentUserId()];
1270
- case 16:
1271
- _f.operatorId = _o.sent();
1272
1277
  if (!(data instanceof Array)) return [3 /*break*/, 18];
1273
1278
  _g = {
1274
1279
  id: 'dummy',
@@ -28,5 +28,5 @@ export declare abstract class UniversalContext<ED extends EntityDict> implements
28
28
  rollback(): Promise<void>;
29
29
  getCurrentTxnId(): string | undefined;
30
30
  abstract toString(): Promise<string>;
31
- abstract getCurrentUserId(): Promise<string | undefined>;
31
+ abstract getCurrentUserId(allowUnloggedIn?: boolean): Promise<string | undefined>;
32
32
  }
@@ -23,7 +23,7 @@ function getFullProjection(entity, schema) {
23
23
  exports.getFullProjection = getFullProjection;
24
24
  function checkFilterContains(entity, schema, contained, context, filter) {
25
25
  return tslib_1.__awaiter(this, void 0, void 0, function () {
26
- var rowStore, filter2, result, data_1;
26
+ var rowStore, filter2, projection, result, data_1;
27
27
  var _a;
28
28
  return tslib_1.__generator(this, function (_b) {
29
29
  switch (_b.label) {
@@ -39,8 +39,9 @@ function checkFilterContains(entity, schema, contained, context, filter) {
39
39
  filter2 = (0, filter_1.combineFilters)([filter, {
40
40
  $not: contained,
41
41
  }]);
42
+ projection = process.env.OAK_PLATFORM === 'server' ? getFullProjection(entity, schema) : { id: 1 };
42
43
  return [4 /*yield*/, rowStore.select(entity, {
43
- data: getFullProjection(entity, schema),
44
+ data: projection,
44
45
  filter: filter2,
45
46
  indexFrom: 0,
46
47
  count: 10,
@@ -150,7 +150,7 @@ function getRelevantIds(filter) {
150
150
  }
151
151
  // 因为要准确判定id,如果有其它的过滤条件,可能会使实际处理的行数少于id指向的行数,只能返回空数组
152
152
  var attrs = Object.keys(filter);
153
- if ((0, lodash_1.union)(attrs, ['id', '$and', '$or']).length > 3) {
153
+ if ((0, lodash_1.intersection)(attrs, ['id', '$and', '$or']).length > 3) {
154
154
  return [];
155
155
  }
156
156
  if (filter === null || filter === void 0 ? void 0 : filter.$and) {
@@ -199,6 +199,7 @@ function reinforceSelection(schema, entity, selection) {
199
199
  entity: 1,
200
200
  entityId: 1,
201
201
  action: 1,
202
+ iState: 1,
202
203
  data: 1,
203
204
  filter: 1,
204
205
  },
@@ -11,6 +11,6 @@ export interface Context<ED extends EntityDict> {
11
11
  toString(): Promise<string>;
12
12
  getScene(): string | undefined;
13
13
  setScene(scene?: string): void;
14
- getCurrentUserId(): Promise<string | undefined>;
14
+ getCurrentUserId(allowUnloggedIn?: boolean): Promise<string | undefined>;
15
15
  getHeader(key: string): string | string[] | undefined;
16
16
  }
@@ -11,6 +11,7 @@ export declare type Datetime = number | Date;
11
11
  export declare type Boolean = boolean;
12
12
  export declare type PrimaryKey = string;
13
13
  export declare type ForeignKey<E extends string> = string;
14
+ export declare type Sequence = string;
14
15
  export { Geo, SingleGeo } from './Geo';
15
16
  export declare type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
16
17
  export declare const types: string[];
@@ -1,10 +1,11 @@
1
1
  import { GenericAction } from '../actions/action';
2
2
  import { ExpressionKey, ExprOp, MakeFilter, NodeId } from './Demand';
3
3
  import { OneOf, OptionalKeys } from './Polyfill';
4
+ import { PrimaryKey, Sequence } from './DataType';
4
5
  export declare type TriggerDataAttribute = '$$triggerData$$';
5
6
  export declare type TriggerTimestampAttribute = '$$triggerTimestamp$$';
6
7
  declare type PrimaryKeyAttribute = 'id';
7
- export declare type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute;
8
+ export declare type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute | '$$seq$$';
8
9
  export declare const initinctiveAttributes: string[];
9
10
  export declare type Filter<A extends string, F extends Object | undefined = undefined> = {
10
11
  filter?: A extends 'create' ? undefined : F;
@@ -23,6 +24,7 @@ export declare type OperateOption = {
23
24
  blockTrigger?: true;
24
25
  dontCollect?: boolean;
25
26
  dontCreateOper?: boolean;
27
+ dontCreateModi?: boolean;
26
28
  allowExists?: boolean;
27
29
  modiParentId?: string;
28
30
  modiParentEntity?: string;
@@ -35,14 +37,15 @@ export declare type FormCreateData<SH extends GeneralEntityShape> = Omit<SH, Ins
35
37
  id: string;
36
38
  };
37
39
  export declare type Operation<A extends GenericAction | string, DATA extends Object, FILTER extends Object | undefined = undefined, SORTER extends Object | undefined = undefined> = {
38
- id: string;
40
+ id?: string;
39
41
  action: A;
40
42
  data: DATA;
41
43
  sorter?: SORTER;
42
44
  } & Filter<A, FILTER>;
43
- export declare type Selection<DATA extends Object, FILTER extends Object | undefined = undefined, SORT extends Object | undefined = undefined> = Omit<Operation<'select', DATA, FILTER, SORT>, 'id'>;
45
+ export declare type Selection<DATA extends Object, FILTER extends Object | undefined = undefined, SORT extends Object | undefined = undefined> = Operation<'select', DATA, FILTER, SORT>;
44
46
  export interface EntityShape {
45
- id: string;
47
+ id: PrimaryKey;
48
+ $$seq$$: Sequence;
46
49
  $$createAt$$: number | Date;
47
50
  $$updateAt$$: number | Date;
48
51
  $$deleteAt$$?: number | Date | null;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initinctiveAttributes = void 0;
4
- exports.initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$'];
4
+ exports.initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$', '$$seq$$'];
5
5
  ;
6
6
  ;
7
7
  ;
@@ -38,7 +38,9 @@ export declare class OakRowInconsistencyException<ED extends EntityDict> extends
38
38
  */
39
39
  export declare class OakInputIllegalException extends OakUserException {
40
40
  private attributes;
41
- constructor(attributes: string[], message?: string);
41
+ private entity;
42
+ constructor(entity: string, attributes: string[], message?: string);
43
+ getEntity(): string;
42
44
  getAttributes(): string[];
43
45
  addAttributesPrefix(prefix: string): void;
44
46
  toString(): string;
@@ -71,6 +73,9 @@ export declare class OakCongruentRowExists<ED extends EntityDict, T extends keyo
71
73
  getEntity(): T;
72
74
  toString(): string;
73
75
  }
76
+ export declare class OakDeadlock extends OakUserException {
77
+ constructor(message?: string | undefined);
78
+ }
74
79
  export declare function makeException(data: {
75
80
  name: string;
76
81
  message?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeException = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakDataException = exports.OakException = void 0;
3
+ exports.makeException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakDataException = exports.OakException = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var OakException = /** @class */ (function (_super) {
6
6
  tslib_1.__extends(OakException, _super);
@@ -109,11 +109,15 @@ exports.OakRowInconsistencyException = OakRowInconsistencyException;
109
109
  */
110
110
  var OakInputIllegalException = /** @class */ (function (_super) {
111
111
  tslib_1.__extends(OakInputIllegalException, _super);
112
- function OakInputIllegalException(attributes, message) {
112
+ function OakInputIllegalException(entity, attributes, message) {
113
113
  var _this = _super.call(this, message) || this;
114
+ _this.entity = entity;
114
115
  _this.attributes = attributes;
115
116
  return _this;
116
117
  }
118
+ OakInputIllegalException.prototype.getEntity = function () {
119
+ return this.entity;
120
+ };
117
121
  OakInputIllegalException.prototype.getAttributes = function () {
118
122
  return this.attributes;
119
123
  };
@@ -122,6 +126,7 @@ var OakInputIllegalException = /** @class */ (function (_super) {
122
126
  };
123
127
  OakInputIllegalException.prototype.toString = function () {
124
128
  return JSON.stringify({
129
+ entity: this.entity,
125
130
  name: this.constructor.name,
126
131
  message: this.message,
127
132
  attributes: this.attributes,
@@ -195,6 +200,15 @@ var OakCongruentRowExists = /** @class */ (function (_super) {
195
200
  return OakCongruentRowExists;
196
201
  }(OakUserException));
197
202
  exports.OakCongruentRowExists = OakCongruentRowExists;
203
+ var OakDeadlock = /** @class */ (function (_super) {
204
+ tslib_1.__extends(OakDeadlock, _super);
205
+ function OakDeadlock(message) {
206
+ return _super.call(this, message || '发现死锁') || this;
207
+ }
208
+ return OakDeadlock;
209
+ }(OakUserException));
210
+ exports.OakDeadlock = OakDeadlock;
211
+ ;
198
212
  function makeException(data) {
199
213
  var name = data.name;
200
214
  switch (name) {
@@ -211,7 +225,7 @@ function makeException(data) {
211
225
  return new OakRowInconsistencyException(data.data, data.message);
212
226
  }
213
227
  case OakInputIllegalException.name: {
214
- return new OakInputIllegalException(data.attributes, data.message);
228
+ return new OakInputIllegalException(data.entity, data.attributes, data.message);
215
229
  }
216
230
  case OakUserUnpermittedException.name: {
217
231
  return new OakUserUnpermittedException(data.message);
@@ -228,6 +242,9 @@ function makeException(data) {
228
242
  case OakRowUnexistedException.name: {
229
243
  return new OakRowUnexistedException(data.rows);
230
244
  }
245
+ case OakDeadlock.name: {
246
+ return new OakDeadlock(data.message);
247
+ }
231
248
  default:
232
249
  return;
233
250
  }
@@ -25,6 +25,7 @@ export interface Attribute {
25
25
  default?: string | number | boolean;
26
26
  notNull?: boolean;
27
27
  unique?: boolean;
28
+ sequenceStart?: number;
28
29
  }
29
30
  export declare type Attributes<SH extends EntityShape> = Omit<{
30
31
  [attrName in keyof SH]: Attribute;
@@ -18,7 +18,7 @@ export declare type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" |
18
18
  /**
19
19
  * All other regular column types.
20
20
  */
21
- export declare type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree" | "object" | "array" | "function";
21
+ export declare type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree" | "object" | "array" | "function" | "sequence";
22
22
  /**
23
23
  * Any column type column can be.
24
24
  */
@@ -18,6 +18,6 @@ export declare const isPhone: ValidatorFunction;
18
18
  export declare const isNumber: ValidatorFunction;
19
19
  export declare const isMoney: ValidatorMoneyFunction;
20
20
  export declare const isVehicleNumber: ValidatorFunction;
21
- export declare function checkAttributesNotNull<T extends Record<string, any>>(data: T, attributes: Array<keyof T>, allowEmpty?: true): void;
22
- export declare function checkAttributesScope<T extends Record<string, any>>(data: T, attributes: Array<keyof T>): void;
21
+ export declare function checkAttributesNotNull<T extends Record<string, any>>(entity: string, data: T, attributes: Array<keyof T>, allowEmpty?: true): void;
22
+ export declare function checkAttributesScope<T extends Record<string, any>>(entity: string, data: T, attributes: Array<keyof T>): void;
23
23
  export {};
@@ -99,7 +99,7 @@ var isVehicleNumber = function (str) {
99
99
  return reg.test(str);
100
100
  };
101
101
  exports.isVehicleNumber = isVehicleNumber;
102
- function checkAttributesNotNull(data, attributes, allowEmpty) {
102
+ function checkAttributesNotNull(entity, data, attributes, allowEmpty) {
103
103
  var attrs = attributes.filter(function (attr) {
104
104
  if (data[attr] === null || data[attr] === '') {
105
105
  return true;
@@ -109,15 +109,15 @@ function checkAttributesNotNull(data, attributes, allowEmpty) {
109
109
  }
110
110
  });
111
111
  if (attrs.length > 0) {
112
- throw new types_1.OakInputIllegalException(attrs, '属性不能为空');
112
+ throw new types_1.OakInputIllegalException(entity, attrs, '属性不能为空');
113
113
  }
114
114
  }
115
115
  exports.checkAttributesNotNull = checkAttributesNotNull;
116
116
  ;
117
- function checkAttributesScope(data, attributes) {
117
+ function checkAttributesScope(entity, data, attributes) {
118
118
  var attrs = attributes.filter(function (attr) { return !data.hasOwnProperty(attr); });
119
119
  if (attrs.length > 0) {
120
- throw new types_1.OakInputIllegalException(attrs, '多余的属性');
120
+ throw new types_1.OakInputIllegalException(entity, attrs, '多余的属性');
121
121
  }
122
122
  }
123
123
  exports.checkAttributesScope = checkAttributesScope;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },