oak-domain 2.4.1 → 2.4.3

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.
Files changed (42) hide show
  1. package/lib/actions/action.d.ts +8 -8
  2. package/lib/actions/action.js +1 -1
  3. package/lib/actions/relation.d.ts +1 -1
  4. package/lib/base-app-domain/EntityDict.d.ts +1 -1
  5. package/lib/base-app-domain/Modi/Action.d.ts +4 -4
  6. package/lib/base-app-domain/Modi/Action.js +1 -1
  7. package/lib/base-app-domain/Modi/Schema.d.ts +27 -27
  8. package/lib/base-app-domain/ModiEntity/Schema.d.ts +29 -29
  9. package/lib/base-app-domain/Oper/Schema.d.ts +28 -28
  10. package/lib/base-app-domain/OperEntity/Schema.d.ts +31 -31
  11. package/lib/base-app-domain/User/Schema.d.ts +28 -28
  12. package/lib/base-app-domain/_SubQuery.d.ts +5 -5
  13. package/lib/compiler/schemalBuilder.js +29 -27
  14. package/lib/store/CascadeStore.js +20 -24
  15. package/lib/store/TriggerExecutor.d.ts +1 -1
  16. package/lib/store/actionDef.js +223 -25
  17. package/lib/store/checker.js +26 -26
  18. package/lib/store/selection.js +3 -0
  19. package/lib/types/Action.d.ts +5 -5
  20. package/lib/types/Auth.d.ts +9 -9
  21. package/lib/types/DataType.d.ts +14 -14
  22. package/lib/types/Demand.d.ts +23 -23
  23. package/lib/types/Endpoint.d.ts +1 -1
  24. package/lib/types/Entity.d.ts +54 -47
  25. package/lib/types/Exception.d.ts +10 -0
  26. package/lib/types/Exception.js +17 -1
  27. package/lib/types/Expression.d.ts +14 -14
  28. package/lib/types/Geo.d.ts +6 -6
  29. package/lib/types/Locale.d.ts +5 -5
  30. package/lib/types/Polyfill.d.ts +8 -8
  31. package/lib/types/Port.d.ts +2 -2
  32. package/lib/types/RowStore.d.ts +1 -1
  33. package/lib/types/Storage.d.ts +4 -4
  34. package/lib/types/Timer.d.ts +3 -3
  35. package/lib/types/Trigger.d.ts +5 -5
  36. package/lib/types/Watcher.d.ts +2 -2
  37. package/lib/types/schema/DataTypes.d.ts +7 -7
  38. package/lib/utils/concurrent.d.ts +1 -1
  39. package/lib/utils/uuid.d.ts +1 -1
  40. package/lib/utils/uuid.js +1 -1
  41. package/lib/utils/validator.d.ts +2 -2
  42. package/package.json +1 -1
@@ -1,11 +1,12 @@
1
+ import { ReadOnlyAction } from '../actions/action';
1
2
  import { PrimaryKey, Sequence } from './DataType';
2
- type TriggerDataAttributeType = '$$triggerData$$';
3
- type TriggerTimestampAttributeType = '$$triggerTimestamp$$';
4
- type PrimaryKeyAttributeType = 'id';
5
- type CreateAtAttributeType = '$$createAt$$';
6
- type UpdateAtAttributeType = '$$updateAt$$';
7
- type DeleteAtAttributeType = '$$deleteAt$$';
8
- type SeqAttributeType = '$$seq$$';
3
+ declare type TriggerDataAttributeType = '$$triggerData$$';
4
+ declare type TriggerTimestampAttributeType = '$$triggerTimestamp$$';
5
+ declare type PrimaryKeyAttributeType = 'id';
6
+ declare type CreateAtAttributeType = '$$createAt$$';
7
+ declare type UpdateAtAttributeType = '$$updateAt$$';
8
+ declare type DeleteAtAttributeType = '$$deleteAt$$';
9
+ declare type SeqAttributeType = '$$seq$$';
9
10
  export declare const TriggerDataAttribute = "$$triggerData$$";
10
11
  export declare const TriggerTimestampAttribute = "$$triggerTimestamp$$";
11
12
  export declare const PrimaryKeyAttribute = "id";
@@ -13,14 +14,14 @@ export declare const CreateAtAttribute = "$$createAt$$";
13
14
  export declare const UpdateAtAttribute = "$$updateAt$$";
14
15
  export declare const DeleteAtAttribute = "$$deleteAt$$";
15
16
  export declare const SeqAttribute = "$$seq$$";
16
- export type InstinctiveAttributes = PrimaryKeyAttributeType | CreateAtAttributeType | UpdateAtAttributeType | DeleteAtAttributeType | TriggerDataAttributeType | TriggerTimestampAttributeType | SeqAttributeType;
17
+ export declare type InstinctiveAttributes = PrimaryKeyAttributeType | CreateAtAttributeType | UpdateAtAttributeType | DeleteAtAttributeType | TriggerDataAttributeType | TriggerTimestampAttributeType | SeqAttributeType;
17
18
  export declare const initinctiveAttributes: string[];
18
- type FilterPart<A extends string, F extends Object | undefined> = {
19
+ declare type FilterPart<A extends string, F extends Object | undefined> = {
19
20
  filter?: A extends 'create' ? undefined : F;
20
21
  indexFrom?: A extends 'create' ? undefined : number;
21
22
  count?: A extends 'create' ? undefined : number;
22
23
  };
23
- export type SelectOption = {
24
+ export declare type SelectOption = {
24
25
  dontCollect?: boolean;
25
26
  blockTrigger?: true;
26
27
  obscure?: boolean;
@@ -28,7 +29,7 @@ export type SelectOption = {
28
29
  includedDeleted?: true;
29
30
  dummy?: 1;
30
31
  };
31
- export type OperateOption = {
32
+ export declare type OperateOption = {
32
33
  blockTrigger?: true;
33
34
  dontCollect?: boolean;
34
35
  dontCreateOper?: boolean;
@@ -38,13 +39,19 @@ export type OperateOption = {
38
39
  modiParentEntity?: string;
39
40
  dummy?: 1;
40
41
  };
41
- export type FormUpdateData<SH extends GeneralEntityShape> = Partial<{
42
+ export declare type FormUpdateData<SH extends GeneralEntityShape> = Partial<{
42
43
  [K in keyof Omit<SH, InstinctiveAttributes>]: SH[K] | null;
43
44
  }>;
44
- export type FormCreateData<SH extends GeneralEntityShape> = Partial<Omit<SH, InstinctiveAttributes>> & {
45
+ export declare type FormCreateData<SH extends GeneralEntityShape> = Partial<Omit<SH, InstinctiveAttributes>> & {
45
46
  id: string;
46
47
  };
47
- export type Operation<A extends string, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
48
+ export declare type Operation<A extends string, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
49
+ id: string;
50
+ action: A;
51
+ data: D;
52
+ sorter?: S;
53
+ } & FilterPart<A, F>;
54
+ export declare type Selection<A extends ReadOnlyAction, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
48
55
  id?: string;
49
56
  action: A;
50
57
  data: D;
@@ -60,14 +67,14 @@ export interface EntityShape {
60
67
  interface GeneralEntityShape extends EntityShape {
61
68
  [K: string]: any;
62
69
  }
63
- export type MakeAction<A extends string> = A;
70
+ export declare type MakeAction<A extends string> = A;
64
71
  export interface EntityDef {
65
72
  Schema: GeneralEntityShape;
66
73
  OpSchema: GeneralEntityShape;
67
74
  Action: string;
68
75
  ParticularAction?: string;
69
- Selection: Omit<Operation<'select', Projection, Filter, Sorter>, 'action'>;
70
- Aggregation: Omit<DeduceAggregation<Projection, Filter, Sorter>, 'action'>;
76
+ Selection: Omit<Selection<'select', Projection, Filter, Sorter>, 'action'>;
77
+ Aggregation: DeduceAggregation<Projection, Filter, Sorter>;
71
78
  Operation: CUDOperation;
72
79
  Create: CreateOperation;
73
80
  CreateSingle: CreateSingleOperation;
@@ -82,79 +89,79 @@ export interface EntityDict {
82
89
  export interface OtmSubProjection extends Omit<Operation<'select', any, any, any>, 'action'> {
83
90
  $entity: string;
84
91
  }
85
- export type AggregationOp = `#max-${number}` | `#min-${number}` | `#avg-${number}` | `#count-${number}` | `#sum-${number}`;
86
- export type DeduceAggregationData<P extends Projection> = {
92
+ export declare type AggregationOp = `#max-${number}` | `#min-${number}` | `#avg-${number}` | `#count-${number}` | `#sum-${number}`;
93
+ export declare type DeduceAggregationData<P extends Projection> = {
87
94
  [A in AggregationOp]?: P;
88
95
  } & {
89
96
  '#aggr'?: P;
90
97
  };
91
- export type AggregationResult<SH extends GeneralEntityShape> = Array<{
98
+ export declare type AggregationResult<SH extends GeneralEntityShape> = Array<{
92
99
  [A in AggregationOp]?: number | string;
93
100
  } & {
94
101
  '#data'?: Partial<SH>;
95
102
  }>;
96
- export type AttrFilter<SH extends GeneralEntityShape> = {
103
+ export declare type AttrFilter<SH extends GeneralEntityShape> = {
97
104
  [K in keyof SH]?: any;
98
105
  };
99
- type SortAttr = {
106
+ declare type SortAttr = {
100
107
  [K: string]: any;
101
108
  };
102
- type SorterItem = {
109
+ declare type SorterItem = {
103
110
  $attr: SortAttr;
104
111
  $direction?: "asc" | "desc";
105
112
  };
106
- type Sorter = Array<SorterItem>;
107
- type Filter = {
113
+ declare type Sorter = Array<SorterItem>;
114
+ declare type Filter = {
108
115
  [K: string]: any;
109
116
  };
110
- type Projection = {
117
+ declare type Projection = {
111
118
  [K: string]: any;
112
119
  };
113
- export type DeduceAggregation<P extends Projection, F extends Filter, S extends Sorter> = Omit<Operation<'aggregate', DeduceAggregationData<P>, F, S>, 'action'>;
114
- type CreateOperationData = {
120
+ export declare type DeduceAggregation<P extends Projection, F extends Filter, S extends Sorter> = Omit<Selection<'aggregate', DeduceAggregationData<P>, F, S>, 'action'>;
121
+ declare type CreateOperationData = {
115
122
  id: string;
116
123
  [K: string]: any;
117
124
  };
118
- type CreateSingleOperation = Operation<'create', CreateOperationData, undefined, undefined>;
119
- type CreateMultipleOperation = Operation<'create', Array<CreateOperationData>, undefined, undefined>;
120
- type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
121
- type UpdateOperationData = {
125
+ declare type CreateSingleOperation = Operation<'create', CreateOperationData, undefined, undefined>;
126
+ declare type CreateMultipleOperation = Operation<'create', Array<CreateOperationData>, undefined, undefined>;
127
+ declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
128
+ declare type UpdateOperationData = {
122
129
  id?: never;
123
130
  [k: string]: any;
124
131
  };
125
- export type UpdateOperation = Operation<string, UpdateOperationData, Filter, Sorter>;
126
- type RemoveOperationData = {
132
+ export declare type UpdateOperation = Operation<string, UpdateOperationData, Filter, Sorter>;
133
+ declare type RemoveOperationData = {
127
134
  [k: string]: any;
128
135
  };
129
- export type RemoveOperation = Operation<'remove', RemoveOperationData, Filter, Sorter>;
130
- export type CUDOperation = CreateOperation | UpdateOperation | RemoveOperation;
131
- export type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
136
+ export declare type RemoveOperation = Operation<'remove', RemoveOperationData, Filter, Sorter>;
137
+ export declare type CUDOperation = CreateOperation | UpdateOperation | RemoveOperation;
138
+ export declare type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
132
139
  a: 'c';
133
140
  e: T;
134
141
  d: ED[T]['OpSchema'] | ED[T]['OpSchema'][];
135
142
  };
136
- export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
143
+ export declare type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
137
144
  a: 'u';
138
145
  e: T;
139
146
  d: UpdateOperationData;
140
147
  f?: Filter;
141
148
  };
142
- export type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
149
+ export declare type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
143
150
  a: 'r';
144
151
  e: T;
145
152
  f?: Filter;
146
153
  };
147
- export type RelationHierarchy<R extends string> = {
154
+ export declare type RelationHierarchy<R extends string> = {
148
155
  [K in R]?: R[];
149
156
  };
150
- export type CascadeRelationItem = {
157
+ export declare type CascadeRelationItem = {
151
158
  cascadePath: string;
152
159
  relations?: string[];
153
160
  };
154
- export type CascadeRelationAuth<R extends string> = {
161
+ export declare type CascadeRelationAuth<R extends string> = {
155
162
  [K in R]?: CascadeRelationItem | (CascadeRelationItem | CascadeRelationItem[])[];
156
163
  };
157
- export type SelectOpResult<ED extends EntityDict> = {
164
+ export declare type SelectOpResult<ED extends EntityDict> = {
158
165
  a: 's';
159
166
  d: {
160
167
  [T in keyof ED]?: {
@@ -162,14 +169,14 @@ export type SelectOpResult<ED extends EntityDict> = {
162
169
  };
163
170
  };
164
171
  };
165
- export type OpRecord<ED extends EntityDict> = CreateOpResult<ED, keyof ED> | UpdateOpResult<ED, keyof ED> | RemoveOpResult<ED, keyof ED> | SelectOpResult<ED>;
166
- export type OperationResult<ED extends EntityDict> = {
172
+ export declare type OpRecord<ED extends EntityDict> = CreateOpResult<ED, keyof ED> | UpdateOpResult<ED, keyof ED> | RemoveOpResult<ED, keyof ED> | SelectOpResult<ED>;
173
+ export declare type OperationResult<ED extends EntityDict> = {
167
174
  [K in keyof ED]?: {
168
175
  [A in ED[K]['Action']]?: number;
169
176
  };
170
177
  };
171
- export type ActionType = 'readOnly' | 'appendOnly' | 'excludeUpdate' | 'excludeRemove' | 'crud';
172
- export type Configuration = {
178
+ export declare type ActionType = 'readOnly' | 'appendOnly' | 'excludeUpdate' | 'excludeRemove' | 'crud';
179
+ export declare type Configuration = {
173
180
  actionType?: ActionType;
174
181
  static?: boolean;
175
182
  };
@@ -5,6 +5,16 @@ export declare class OakException extends Error {
5
5
  }
6
6
  export declare class OakDataException extends OakException {
7
7
  }
8
+ export declare class OakUniqueViolationException extends OakException {
9
+ rows: Array<{
10
+ id?: string;
11
+ attrs: string[];
12
+ }>;
13
+ constructor(rows: Array<{
14
+ id?: string;
15
+ attrs: string[];
16
+ }>, message?: string);
17
+ }
8
18
  export declare class OakImportDataParseException extends OakException {
9
19
  line: number;
10
20
  header?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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.OakImportDataParseException = 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.OakImportDataParseException = exports.OakUniqueViolationException = 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);
@@ -36,6 +36,16 @@ var OakDataException = /** @class */ (function (_super) {
36
36
  return OakDataException;
37
37
  }(OakException));
38
38
  exports.OakDataException = OakDataException;
39
+ var OakUniqueViolationException = /** @class */ (function (_super) {
40
+ tslib_1.__extends(OakUniqueViolationException, _super);
41
+ function OakUniqueViolationException(rows, message) {
42
+ var _this = _super.call(this, message || '您更新的数据违反了唯一性约束') || this;
43
+ _this.rows = rows;
44
+ return _this;
45
+ }
46
+ return OakUniqueViolationException;
47
+ }(OakException));
48
+ exports.OakUniqueViolationException = OakUniqueViolationException;
39
49
  var OakImportDataParseException = /** @class */ (function (_super) {
40
50
  tslib_1.__extends(OakImportDataParseException, _super);
41
51
  // message必传,描述具体错误的数据内容
@@ -257,6 +267,12 @@ function makeException(data) {
257
267
  case 'OakDeadlock': {
258
268
  return new OakDeadlock(data.message);
259
269
  }
270
+ case 'OakDataException': {
271
+ return new OakDataException(data.message);
272
+ }
273
+ case 'OakUniqueViolationException': {
274
+ return new OakUniqueViolationException(data.rows, data.message);
275
+ }
260
276
  case 'OakImportDataParseException': {
261
277
  return new OakImportDataParseException(data.message, data.line, data.header);
262
278
  }
@@ -1,8 +1,8 @@
1
1
  import { RefAttr } from "./Demand";
2
2
  import { Geo } from "./Geo";
3
- export type RefOrExpression<A> = RefAttr<A> | Expression<A>;
4
- type MathType<A> = RefOrExpression<A> | number;
5
- type StringType<A> = RefOrExpression<A> | string;
3
+ export declare type RefOrExpression<A> = RefAttr<A> | Expression<A>;
4
+ declare type MathType<A> = RefOrExpression<A> | number;
5
+ declare type StringType<A> = RefOrExpression<A> | string;
6
6
  interface Add<A> {
7
7
  $add: (MathType<A>)[];
8
8
  }
@@ -30,8 +30,8 @@ interface Ceil<A> {
30
30
  interface Pow<A> {
31
31
  $pow: [MathType<A>, MathType<A>];
32
32
  }
33
- type MathExpression<A> = Add<A> | Subtract<A> | Multiply<A> | Divide<A> | Abs<A> | Round<A> | Floor<A> | Ceil<A> | Pow<A>;
34
- type CmpType<A> = RefOrExpression<A> | string | number;
33
+ declare type MathExpression<A> = Add<A> | Subtract<A> | Multiply<A> | Divide<A> | Abs<A> | Round<A> | Floor<A> | Ceil<A> | Pow<A>;
34
+ declare type CmpType<A> = RefOrExpression<A> | string | number;
35
35
  interface Gt<A> {
36
36
  $gt: [CmpType<A>, CmpType<A>];
37
37
  }
@@ -59,14 +59,14 @@ interface EndsWith<A> {
59
59
  interface Includes<A> {
60
60
  $includes: [RefOrExpression<A> | string, RefOrExpression<A> | string];
61
61
  }
62
- type CompareExpression<A> = Lt<A> | Gt<A> | Lte<A> | Gte<A> | Eq<A> | Ne<A> | StartsWith<A> | EndsWith<A> | Includes<A>;
62
+ declare type CompareExpression<A> = Lt<A> | Gt<A> | Lte<A> | Gte<A> | Eq<A> | Ne<A> | StartsWith<A> | EndsWith<A> | Includes<A>;
63
63
  interface BoolTrue<A> {
64
64
  $true: Expression<A>;
65
65
  }
66
66
  interface BoolFalse<A> {
67
67
  $false: Expression<A>;
68
68
  }
69
- type BoolExpression<A> = BoolTrue<A> | BoolFalse<A>;
69
+ declare type BoolExpression<A> = BoolTrue<A> | BoolFalse<A>;
70
70
  interface LogicAnd<A> {
71
71
  $and: Expression<A>[];
72
72
  }
@@ -76,7 +76,7 @@ interface LogicOr<A> {
76
76
  interface LogicNot<A> {
77
77
  $not: Expression<A>;
78
78
  }
79
- type LogicExpression<A> = LogicAnd<A> | LogicOr<A> | LogicNot<A>;
79
+ declare type LogicExpression<A> = LogicAnd<A> | LogicOr<A> | LogicNot<A>;
80
80
  interface DateYear<A> {
81
81
  $year: RefOrExpression<A> | Date | number;
82
82
  }
@@ -110,18 +110,18 @@ interface DateCeiling<A> {
110
110
  interface DateFloor<A> {
111
111
  $dateFloor: [RefOrExpression<A> | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's'];
112
112
  }
113
- type DateExpression<A> = DateYear<A> | DateMonth<A> | DateWeekday<A> | DateWeekOfYear<A> | DateDay<A> | DateDayOfYear<A> | DateDayOfMonth<A> | DateDayOfWeek<A> | DateDiff<A> | DateCeiling<A> | DateFloor<A>;
113
+ declare type DateExpression<A> = DateYear<A> | DateMonth<A> | DateWeekday<A> | DateWeekOfYear<A> | DateDay<A> | DateDayOfYear<A> | DateDayOfMonth<A> | DateDayOfWeek<A> | DateDiff<A> | DateCeiling<A> | DateFloor<A>;
114
114
  interface StringConcat<A> {
115
115
  $concat: StringType<A>[];
116
116
  }
117
- type StringExpression<A> = StringConcat<A>;
117
+ declare type StringExpression<A> = StringConcat<A>;
118
118
  interface GeoContains<A> {
119
119
  $contains: [RefOrExpression<A> | Geo, RefOrExpression<A> | Geo];
120
120
  }
121
121
  interface GeoDistance<A> {
122
122
  $distance: [RefOrExpression<A> | Geo, RefOrExpression<A> | Geo];
123
123
  }
124
- type GeoExpression<A> = GeoContains<A> | GeoDistance<A>;
124
+ declare type GeoExpression<A> = GeoContains<A> | GeoDistance<A>;
125
125
  interface AggrCountExpression<A> {
126
126
  $$count: RefOrExpression<A>;
127
127
  }
@@ -137,9 +137,9 @@ interface AggrMinExpression<A> {
137
137
  interface AggrAvgExpression<A> {
138
138
  $$avg: RefOrExpression<A>;
139
139
  }
140
- export type AggrExpression<A> = AggrAvgExpression<A> | AggrCountExpression<A> | AggrSumExpression<A> | AggrMaxExpression<A> | AggrMinExpression<A>;
141
- export type Expression<A> = GeoExpression<A> | DateExpression<A> | LogicExpression<A> | BoolExpression<A> | CompareExpression<A> | MathExpression<A> | StringExpression<A> | AggrExpression<A>;
142
- export type ExpressionConstant = Geo | number | Date | string | boolean;
140
+ export declare type AggrExpression<A> = AggrAvgExpression<A> | AggrCountExpression<A> | AggrSumExpression<A> | AggrMaxExpression<A> | AggrMinExpression<A>;
141
+ export declare type Expression<A> = GeoExpression<A> | DateExpression<A> | LogicExpression<A> | BoolExpression<A> | CompareExpression<A> | MathExpression<A> | StringExpression<A> | AggrExpression<A>;
142
+ export declare type ExpressionConstant = Geo | number | Date | string | boolean;
143
143
  export declare function isGeoExpression<A>(expression: any): expression is GeoExpression<A>;
144
144
  export declare function isDateExpression<A>(expression: any): expression is DateExpression<A>;
145
145
  export declare function isLogicExpression<A>(expression: any): expression is LogicExpression<A>;
@@ -1,8 +1,8 @@
1
- export type Point = [number, number];
2
- export type Path = Array<Point>;
3
- export type Polygon = Array<Path>;
4
- export type Circle = [Point, number];
5
- export type SingleGeo = {
1
+ export declare type Point = [number, number];
2
+ export declare type Path = Array<Point>;
3
+ export declare type Polygon = Array<Path>;
4
+ export declare type Circle = [Point, number];
5
+ export declare type SingleGeo = {
6
6
  type: 'point';
7
7
  coordinate: Point;
8
8
  } | {
@@ -15,4 +15,4 @@ export type SingleGeo = {
15
15
  type: 'circle';
16
16
  coordinate: Circle;
17
17
  };
18
- export type Geo = SingleGeo | SingleGeo[];
18
+ export declare type Geo = SingleGeo | SingleGeo[];
@@ -1,17 +1,17 @@
1
1
  import { EntityShape } from "./Entity";
2
- type Language = 'zh_CN' | 'en_US';
3
- type LocaleOfSchema<S extends Record<string, any>> = {
2
+ declare type Language = 'zh_CN' | 'en_US';
3
+ declare type LocaleOfSchema<S extends Record<string, any>> = {
4
4
  [A in keyof Required<Omit<S, keyof EntityShape>>]: string;
5
5
  };
6
- type LocaleOfStringEnum<A extends string> = {
6
+ declare type LocaleOfStringEnum<A extends string> = {
7
7
  [K in A]: string;
8
8
  };
9
- type LocaleOfValue<V extends Record<string, string>> = {
9
+ declare type LocaleOfValue<V extends Record<string, string>> = {
10
10
  [K in keyof V]: {
11
11
  [K2 in V[K]]: string;
12
12
  };
13
13
  };
14
- export type LocaleDef<Sc extends Record<string, any>, Ac extends string, R extends string, V extends Record<string, string>> = {
14
+ export declare type LocaleDef<Sc extends Record<string, any>, Ac extends string, R extends string, V extends Record<string, string>> = {
15
15
  [L in Language]?: {
16
16
  attr: LocaleOfSchema<Sc> & {
17
17
  [A in keyof V]: string;
@@ -1,23 +1,23 @@
1
- export type OmitInferKey<T, R> = {
1
+ export declare type OmitInferKey<T, R> = {
2
2
  [K in keyof T as T extends R ? never : K]: T[K];
3
3
  };
4
- export type OmitInferValue<T, R> = {
4
+ export declare type OmitInferValue<T, R> = {
5
5
  [K in keyof T as T extends R ? never : K]: T[K];
6
6
  };
7
- export type ValueOf<Obj> = Obj[keyof Obj];
8
- export type OneOnly<Obj, Key extends keyof Obj> = {
7
+ export declare type ValueOf<Obj> = Obj[keyof Obj];
8
+ export declare type OneOnly<Obj, Key extends keyof Obj> = {
9
9
  [key in Exclude<keyof Obj, Key>]?: undefined;
10
10
  } & Pick<Obj, Key>;
11
- export type OneOfByKey<Obj> = {
11
+ export declare type OneOfByKey<Obj> = {
12
12
  [key in keyof Obj]: OneOnly<Obj, key>;
13
13
  };
14
- export type OneOf<Obj> = ValueOf<OneOfByKey<Obj>>;
15
- type IsOptional<T, K extends keyof T> = {
14
+ export declare type OneOf<Obj> = ValueOf<OneOfByKey<Obj>>;
15
+ declare type IsOptional<T, K extends keyof T> = {
16
16
  [K1 in Exclude<keyof T, K>]: T[K1];
17
17
  } & {
18
18
  K?: T[K];
19
19
  } extends T ? K : never;
20
- export type OptionalKeys<T> = {
20
+ export declare type OptionalKeys<T> = {
21
21
  [K in keyof T]: IsOptional<T, K>;
22
22
  }[keyof T];
23
23
  export {};
@@ -1,6 +1,6 @@
1
1
  import { AsyncContext } from "../store/AsyncRowStore";
2
2
  import { EntityDict } from "./Entity";
3
- export type Exportation<ED extends EntityDict, T extends keyof ED, K extends string> = {
3
+ export declare type Exportation<ED extends EntityDict, T extends keyof ED, K extends string> = {
4
4
  name: string;
5
5
  id: string;
6
6
  entity: T;
@@ -8,7 +8,7 @@ export type Exportation<ED extends EntityDict, T extends keyof ED, K extends str
8
8
  headers: K[];
9
9
  fn: (data: ED[T]['Schema']) => Partial<Record<K, string | number | boolean | null>>;
10
10
  };
11
- export type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = {
11
+ export declare type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = {
12
12
  name: string;
13
13
  id: string;
14
14
  entity: T;
@@ -1,6 +1,6 @@
1
1
  import { OperationResult, EntityDict } from './Entity';
2
2
  import { StorageSchema } from './Storage';
3
- export type TxnOption = {
3
+ export declare type TxnOption = {
4
4
  isolationLevel: 'repeatable read' | 'serializable';
5
5
  };
6
6
  export declare abstract class RowStore<ED extends EntityDict> {
@@ -1,7 +1,7 @@
1
1
  import { ActionType } from '.';
2
2
  import { EntityDict, EntityShape, InstinctiveAttributes } from './Entity';
3
3
  import { DataType, DataTypeParams } from './schema/DataTypes';
4
- export type Ref = 'ref';
4
+ export declare type Ref = 'ref';
5
5
  export interface Column<SH extends EntityShape> {
6
6
  name: keyof SH | `${string}State`;
7
7
  size?: number;
@@ -27,12 +27,12 @@ export interface Attribute {
27
27
  unique?: boolean;
28
28
  sequenceStart?: number;
29
29
  }
30
- export type Attributes<SH extends EntityShape> = Omit<{
30
+ export declare type Attributes<SH extends EntityShape> = Omit<{
31
31
  [attrName in keyof SH]: Attribute;
32
32
  }, InstinctiveAttributes>;
33
33
  export interface EntityConfig {
34
34
  }
35
- export type UniqConstraint<SH extends EntityShape> = {
35
+ export declare type UniqConstraint<SH extends EntityShape> = {
36
36
  attributes: Array<keyof SH>;
37
37
  type?: string;
38
38
  };
@@ -51,6 +51,6 @@ export interface StorageDesc<SH extends EntityShape> {
51
51
  relation?: string[];
52
52
  view?: true;
53
53
  }
54
- export type StorageSchema<ED extends EntityDict> = {
54
+ export declare type StorageSchema<ED extends EntityDict> = {
55
55
  [K in keyof ED]: StorageDesc<ED[K]['OpSchema']>;
56
56
  };
@@ -1,11 +1,11 @@
1
1
  import { EntityDict } from './Entity';
2
2
  import { AsyncContext } from "../store/AsyncRowStore";
3
- type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (context: Cxt) => Promise<string>;
4
- export type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
3
+ declare type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (context: Cxt) => Promise<string>;
4
+ export declare type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
5
5
  name: string;
6
6
  fn: RoutineFn<ED, Cxt>;
7
7
  };
8
- export type Timer<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
8
+ export declare type Timer<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
9
9
  name: string;
10
10
  cron: string;
11
11
  fn: RoutineFn<ED, Cxt>;
@@ -24,7 +24,7 @@ export interface CreateTriggerCrossTxn<ED extends EntityDict, T extends keyof ED
24
24
  when: 'commit';
25
25
  strict?: 'takeEasy' | 'makeSure';
26
26
  }
27
- export type CreateTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = CreateTriggerInTxn<ED, T, Cxt> | CreateTriggerCrossTxn<ED, T, Cxt>;
27
+ export declare type CreateTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = CreateTriggerInTxn<ED, T, Cxt> | CreateTriggerCrossTxn<ED, T, Cxt>;
28
28
  /**
29
29
  * update trigger如果带有filter,说明只对存在限定条件的行起作用。此时系统在进行相应动作时,
30
30
  * 会判定当前动作的filter条件和trigger所定义的filter是否有交集(即有同时满足两个条件的行)
@@ -46,7 +46,7 @@ export interface UpdateTriggerCrossTxn<ED extends EntityDict, T extends keyof ED
46
46
  when: 'commit';
47
47
  strict?: 'takeEasy' | 'makeSure';
48
48
  }
49
- export type UpdateTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = UpdateTriggerInTxn<ED, T, Cxt> | UpdateTriggerCrossTxn<ED, T, Cxt>;
49
+ export declare type UpdateTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = UpdateTriggerInTxn<ED, T, Cxt> | UpdateTriggerCrossTxn<ED, T, Cxt>;
50
50
  /**
51
51
  * 同update trigger一样,remove trigger如果带有filter,说明只对存在限定条件的行起作用。此时系统在进行相应动作时,
52
52
  * 会判定当前动作的filter条件和trigger所定义的filter是否有交集(即有同时满足两个条件的行)
@@ -67,7 +67,7 @@ export interface RemoveTriggerCrossTxn<ED extends EntityDict, T extends keyof ED
67
67
  when: 'commit';
68
68
  strict?: 'takeEasy' | 'makeSure';
69
69
  }
70
- export type RemoveTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = RemoveTriggerInTxn<ED, T, Cxt> | RemoveTriggerCrossTxn<ED, T, Cxt>;
70
+ export declare type RemoveTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = RemoveTriggerInTxn<ED, T, Cxt> | RemoveTriggerCrossTxn<ED, T, Cxt>;
71
71
  export interface SelectTriggerBase<ED extends EntityDict, T extends keyof ED> extends TriggerBase<ED, T> {
72
72
  action: 'select';
73
73
  }
@@ -88,8 +88,8 @@ export interface SelectTriggerAfter<ED extends EntityDict, T extends keyof ED, C
88
88
  result: Partial<ED[T]['Schema']>[];
89
89
  }, context: Cxt, params?: SelectOption) => Promise<number> | number;
90
90
  }
91
- export type SelectTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = SelectTriggerBefore<ED, T, Cxt> | SelectTriggerAfter<ED, T, Cxt>;
92
- export type Trigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = CreateTrigger<ED, T, Cxt> | UpdateTrigger<ED, T, Cxt> | RemoveTrigger<ED, T, Cxt> | SelectTrigger<ED, T, Cxt>;
91
+ export declare type SelectTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = SelectTriggerBefore<ED, T, Cxt> | SelectTriggerAfter<ED, T, Cxt>;
92
+ export declare type Trigger<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = CreateTrigger<ED, T, Cxt> | UpdateTrigger<ED, T, Cxt> | RemoveTrigger<ED, T, Cxt> | SelectTrigger<ED, T, Cxt>;
93
93
  export interface TriggerEntityShape extends EntityShape {
94
94
  $$triggerData$$?: {
95
95
  name: string;
@@ -1,6 +1,6 @@
1
1
  import { AsyncContext } from "../store/AsyncRowStore";
2
2
  import { EntityDict, OperationResult } from "./Entity";
3
- type ActionData<ED extends EntityDict, T extends keyof ED> = ED[T]['Update']['data'] | ED[T]['Remove']['data'];
3
+ declare type ActionData<ED extends EntityDict, T extends keyof ED> = ED[T]['Update']['data'] | ED[T]['Remove']['data'];
4
4
  export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
5
5
  name: string;
6
6
  entity: T;
@@ -15,5 +15,5 @@ export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extend
15
15
  projection: ED[T]['Selection']['data'] | (() => Promise<ED[T]['Selection']['data']>);
16
16
  fn: (context: Cxt, data: Partial<ED[T]['Schema']>[]) => Promise<OperationResult<ED>>;
17
17
  }
18
- export type Watcher<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>> = BBWatcher<ED, T> | WBWatcher<ED, T, Cxt>;
18
+ export declare type Watcher<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>> = BBWatcher<ED, T> | WBWatcher<ED, T, Cxt>;
19
19
  export {};
@@ -1,28 +1,28 @@
1
1
  /**
2
2
  * Column types used for @PrimaryGeneratedColumn() decorator.
3
3
  */
4
- export type PrimaryGeneratedColumnType = "int" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "number";
4
+ export declare type PrimaryGeneratedColumnType = "int" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "number";
5
5
  /**
6
6
  * Column types where spatial properties are used.
7
7
  */
8
- export type SpatialColumnType = "geometry" | "geography" | "st_geometry" | "st_point";
8
+ export declare type SpatialColumnType = "geometry" | "geography" | "st_geometry" | "st_point";
9
9
  /**
10
10
  * Column types where precision and scale properties are used.
11
11
  */
12
- export type WithPrecisionColumnType = "float" | "double" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "real" | "double precision" | "number" | "datetime" | "datetime2" | "datetimeoffset" | "time" | "time with time zone" | "time without time zone" | "timestamp" | "timestamp without time zone" | "timestamp with time zone" | "timestamp with local time zone";
12
+ export declare type WithPrecisionColumnType = "float" | "double" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "real" | "double precision" | "number" | "datetime" | "datetime2" | "datetimeoffset" | "time" | "time with time zone" | "time without time zone" | "timestamp" | "timestamp without time zone" | "timestamp with time zone" | "timestamp with local time zone";
13
13
  /**
14
14
  * Column types where column length is used.
15
15
  */
16
- export type WithLengthColumnType = "character varying" | "varying character" | "char varying" | "nvarchar" | "national varchar" | "character" | "native character" | "varchar" | "char" | "nchar" | "national char" | "varchar2" | "nvarchar2" | "alphanum" | "shorttext" | "raw" | "binary" | "varbinary" | "string";
17
- export type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" | "int" | "bigint";
16
+ export declare type WithLengthColumnType = "character varying" | "varying character" | "char varying" | "nvarchar" | "national varchar" | "character" | "native character" | "varchar" | "char" | "nchar" | "national char" | "varchar2" | "nvarchar2" | "alphanum" | "shorttext" | "raw" | "binary" | "varbinary" | "string";
17
+ export declare type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" | "int" | "bigint";
18
18
  /**
19
19
  * All other regular column types.
20
20
  */
21
- export 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";
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
  */
25
- export type DataType = WithPrecisionColumnType | WithLengthColumnType | WithWidthColumnType | SpatialColumnType | SimpleColumnType;
25
+ export declare type DataType = WithPrecisionColumnType | WithLengthColumnType | WithWidthColumnType | SpatialColumnType | SimpleColumnType;
26
26
  export interface DataTypeParams {
27
27
  length?: number;
28
28
  width?: number;
@@ -1,4 +1,4 @@
1
- type Mode = 'S' | 'X';
1
+ declare type Mode = 'S' | 'X';
2
2
  /**
3
3
  * 模拟一个读写锁,用于同步。
4
4
  * 注意,千万不要发生自己等自己
@@ -3,7 +3,7 @@ export declare function sequentialUuid({ random }: {
3
3
  }): string;
4
4
  export declare function shrinkUuidTo32Bytes(uuid: string): string;
5
5
  export declare function expandUuidTo36Bytes(uuidShrinked: string): string;
6
- export type GenerateIdOption = {
6
+ export declare type GenerateIdOption = {
7
7
  shuffle?: boolean;
8
8
  };
9
9
  export declare function generateNewIdAsync(option?: GenerateIdOption): Promise<string>;
package/lib/utils/uuid.js CHANGED
@@ -105,7 +105,7 @@ function sequentialUuid(_a) {
105
105
  }
106
106
  exports.sequentialUuid = sequentialUuid;
107
107
  function shrinkUuidTo32Bytes(uuid) {
108
- return uuid.replaceAll('-', '');
108
+ return uuid.replace(/\-/g, '');
109
109
  }
110
110
  exports.shrinkUuidTo32Bytes = shrinkUuidTo32Bytes;
111
111
  function expandUuidTo36Bytes(uuidShrinked) {