@lambdaorm/base 3.0.1

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 (175) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +3 -0
  3. package/index.d.ts +8 -0
  4. package/index.js +25 -0
  5. package/index.js.map +1 -0
  6. package/jest-config.json +15 -0
  7. package/package.json +24 -0
  8. package/query/domain/data.d.ts +12 -0
  9. package/query/domain/data.js +63 -0
  10. package/query/domain/data.js.map +1 -0
  11. package/query/domain/index.d.ts +3 -0
  12. package/query/domain/index.js +20 -0
  13. package/query/domain/index.js.map +1 -0
  14. package/query/domain/query.d.ts +14 -0
  15. package/query/domain/query.js +3 -0
  16. package/query/domain/query.js.map +1 -0
  17. package/repository/application/index.d.ts +1 -0
  18. package/repository/application/index.js +18 -0
  19. package/repository/application/index.js.map +1 -0
  20. package/repository/application/repository.d.ts +35 -0
  21. package/repository/application/repository.js +3 -0
  22. package/repository/application/repository.js.map +1 -0
  23. package/repository/domain/actions.d.ts +11 -0
  24. package/repository/domain/actions.js +3 -0
  25. package/repository/domain/actions.js.map +1 -0
  26. package/repository/domain/index.d.ts +2 -0
  27. package/repository/domain/index.js +19 -0
  28. package/repository/domain/index.js.map +1 -0
  29. package/repository/domain/queryable.d.ts +320 -0
  30. package/repository/domain/queryable.js +226 -0
  31. package/repository/domain/queryable.js.map +1 -0
  32. package/schema/application/facade.d.ts +28 -0
  33. package/schema/application/facade.js +59 -0
  34. package/schema/application/facade.js.map +1 -0
  35. package/schema/application/index.d.ts +21 -0
  36. package/schema/application/index.js +38 -0
  37. package/schema/application/index.js.map +1 -0
  38. package/schema/application/services/config/dataSourceConfigService.d.ts +8 -0
  39. package/schema/application/services/config/dataSourceConfigService.js +38 -0
  40. package/schema/application/services/config/dataSourceConfigService.js.map +1 -0
  41. package/schema/application/services/config/domainConfigService.d.ts +7 -0
  42. package/schema/application/services/config/domainConfigService.js +13 -0
  43. package/schema/application/services/config/domainConfigService.js.map +1 -0
  44. package/schema/application/services/config/domainConfigServiceBase.d.ts +45 -0
  45. package/schema/application/services/config/domainConfigServiceBase.js +304 -0
  46. package/schema/application/services/config/domainConfigServiceBase.js.map +1 -0
  47. package/schema/application/services/config/mappingConfigService.d.ts +13 -0
  48. package/schema/application/services/config/mappingConfigService.js +32 -0
  49. package/schema/application/services/config/mappingConfigService.js.map +1 -0
  50. package/schema/application/services/config/mappingsConfigService.d.ts +10 -0
  51. package/schema/application/services/config/mappingsConfigService.js +43 -0
  52. package/schema/application/services/config/mappingsConfigService.js.map +1 -0
  53. package/schema/application/services/config/stageConfigService.d.ts +7 -0
  54. package/schema/application/services/config/stageConfigService.js +32 -0
  55. package/schema/application/services/config/stageConfigService.js.map +1 -0
  56. package/schema/application/services/config/viewConfigService.d.ts +12 -0
  57. package/schema/application/services/config/viewConfigService.js +36 -0
  58. package/schema/application/services/config/viewConfigService.js.map +1 -0
  59. package/schema/application/services/config/viewsConfigService.d.ts +9 -0
  60. package/schema/application/services/config/viewsConfigService.js +43 -0
  61. package/schema/application/services/config/viewsConfigService.js.map +1 -0
  62. package/schema/application/services/createEntitiesService.d.ts +10 -0
  63. package/schema/application/services/createEntitiesService.js +168 -0
  64. package/schema/application/services/createEntitiesService.js.map +1 -0
  65. package/schema/application/services/interpretSchemaDataService.d.ts +12 -0
  66. package/schema/application/services/interpretSchemaDataService.js +142 -0
  67. package/schema/application/services/interpretSchemaDataService.js.map +1 -0
  68. package/schema/application/services/routeService.d.ts +10 -0
  69. package/schema/application/services/routeService.js +35 -0
  70. package/schema/application/services/routeService.js.map +1 -0
  71. package/schema/application/services/schemaExtender.d.ts +37 -0
  72. package/schema/application/services/schemaExtender.js +472 -0
  73. package/schema/application/services/schemaExtender.js.map +1 -0
  74. package/schema/application/services/schemaService.d.ts +9 -0
  75. package/schema/application/services/schemaService.js +78 -0
  76. package/schema/application/services/schemaService.js.map +1 -0
  77. package/schema/application/state.d.ts +54 -0
  78. package/schema/application/state.js +176 -0
  79. package/schema/application/state.js.map +1 -0
  80. package/schema/application/useCases/clear.d.ts +9 -0
  81. package/schema/application/useCases/clear.js +149 -0
  82. package/schema/application/useCases/clear.js.map +1 -0
  83. package/schema/application/useCases/complete.d.ts +0 -0
  84. package/schema/application/useCases/complete.js +61 -0
  85. package/schema/application/useCases/complete.js.map +1 -0
  86. package/schema/application/useCases/create.d.ts +7 -0
  87. package/schema/application/useCases/create.js +21 -0
  88. package/schema/application/useCases/create.js.map +1 -0
  89. package/schema/application/useCases/getSchemaData.d.ts +8 -0
  90. package/schema/application/useCases/getSchemaData.js +16 -0
  91. package/schema/application/useCases/getSchemaData.js.map +1 -0
  92. package/schema/application/useCases/initialize.d.ts +8 -0
  93. package/schema/application/useCases/initialize.js +131 -0
  94. package/schema/application/useCases/initialize.js.map +1 -0
  95. package/schema/application/useCases/load.d.ts +17 -0
  96. package/schema/application/useCases/load.js +68 -0
  97. package/schema/application/useCases/load.js.map +1 -0
  98. package/schema/application/useCases/match.d.ts +21 -0
  99. package/schema/application/useCases/match.js +297 -0
  100. package/schema/application/useCases/match.js.map +1 -0
  101. package/schema/application/useCases/update.d.ts +9 -0
  102. package/schema/application/useCases/update.js +115 -0
  103. package/schema/application/useCases/update.js.map +1 -0
  104. package/schema/domain/dialect.d.ts +10 -0
  105. package/schema/domain/dialect.js +15 -0
  106. package/schema/domain/dialect.js.map +1 -0
  107. package/schema/domain/errors.d.ts +3 -0
  108. package/schema/domain/errors.js +11 -0
  109. package/schema/domain/errors.js.map +1 -0
  110. package/schema/domain/index.d.ts +6 -0
  111. package/schema/domain/index.js +23 -0
  112. package/schema/domain/index.js.map +1 -0
  113. package/schema/domain/ports/fileSchemaService.d.ts +5 -0
  114. package/schema/domain/ports/fileSchemaService.js +3 -0
  115. package/schema/domain/ports/fileSchemaService.js.map +1 -0
  116. package/schema/domain/schema.d.ts +207 -0
  117. package/schema/domain/schema.js +12 -0
  118. package/schema/domain/schema.js.map +1 -0
  119. package/schema/domain/sentence.d.ts +68 -0
  120. package/schema/domain/sentence.js +65 -0
  121. package/schema/domain/sentence.js.map +1 -0
  122. package/schema/domain/services.d.ts +20 -0
  123. package/schema/domain/services.js +3 -0
  124. package/schema/domain/services.js.map +1 -0
  125. package/schema/infrastructure/facadeBuilder.d.ts +9 -0
  126. package/schema/infrastructure/facadeBuilder.js +30 -0
  127. package/schema/infrastructure/facadeBuilder.js.map +1 -0
  128. package/schema/infrastructure/fileSchemaService.d.ts +11 -0
  129. package/schema/infrastructure/fileSchemaService.js +69 -0
  130. package/schema/infrastructure/fileSchemaService.js.map +1 -0
  131. package/schema/infrastructure/index.d.ts +3 -0
  132. package/schema/infrastructure/index.js +20 -0
  133. package/schema/infrastructure/index.js.map +1 -0
  134. package/schema/infrastructure/schemaFileHelper.d.ts +7 -0
  135. package/schema/infrastructure/schemaFileHelper.js +81 -0
  136. package/schema/infrastructure/schemaFileHelper.js.map +1 -0
  137. package/schema/infrastructure/schemaHelper.d.ts +23 -0
  138. package/schema/infrastructure/schemaHelper.js +132 -0
  139. package/schema/infrastructure/schemaHelper.js.map +1 -0
  140. package/schema/infrastructure/stateBuilder.d.ts +10 -0
  141. package/schema/infrastructure/stateBuilder.js +24 -0
  142. package/schema/infrastructure/stateBuilder.js.map +1 -0
  143. package/sentence/domain/index.d.ts +3 -0
  144. package/sentence/domain/index.js +20 -0
  145. package/sentence/domain/index.js.map +1 -0
  146. package/sentence/domain/metadata.d.ts +37 -0
  147. package/sentence/domain/metadata.js +3 -0
  148. package/sentence/domain/metadata.js.map +1 -0
  149. package/sentence/domain/sentence.d.ts +68 -0
  150. package/sentence/domain/sentence.js +128 -0
  151. package/sentence/domain/sentence.js.map +1 -0
  152. package/sentence/domain/services.d.ts +13 -0
  153. package/sentence/domain/services.js +3 -0
  154. package/sentence/domain/services.js.map +1 -0
  155. package/shared/domain/error.d.ts +9 -0
  156. package/shared/domain/error.js +25 -0
  157. package/shared/domain/error.js.map +1 -0
  158. package/shared/domain/ports/logger.d.ts +9 -0
  159. package/shared/domain/ports/logger.js +39 -0
  160. package/shared/domain/ports/logger.js.map +1 -0
  161. package/shared/index.d.ts +5 -0
  162. package/shared/index.js +22 -0
  163. package/shared/index.js.map +1 -0
  164. package/shared/infrastructure/consoleLogger.d.ts +6 -0
  165. package/shared/infrastructure/consoleLogger.js +41 -0
  166. package/shared/infrastructure/consoleLogger.js.map +1 -0
  167. package/shared/infrastructure/helper.d.ts +40 -0
  168. package/shared/infrastructure/helper.js +224 -0
  169. package/shared/infrastructure/helper.js.map +1 -0
  170. package/shared/infrastructure/loggerBuilder.d.ts +4 -0
  171. package/shared/infrastructure/loggerBuilder.js +15 -0
  172. package/shared/infrastructure/loggerBuilder.js.map +1 -0
  173. package/shared/infrastructure/winstonLogger.d.ts +7 -0
  174. package/shared/infrastructure/winstonLogger.js +57 -0
  175. package/shared/infrastructure/winstonLogger.js.map +1 -0
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./sentence"), exports);
18
+ __exportStar(require("./errors"), exports);
19
+ __exportStar(require("./schema"), exports);
20
+ __exportStar(require("./dialect"), exports);
21
+ __exportStar(require("./ports/fileSchemaService"), exports);
22
+ __exportStar(require("./services"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/schema/domain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,2CAAwB;AACxB,2CAAwB;AACxB,4CAAyB;AACzB,4DAAyC;AACzC,6CAA0B"}
@@ -0,0 +1,5 @@
1
+ import { Schema, SchemaInfo } from '..';
2
+ export interface IFileSchemaService {
3
+ read(source: string): Promise<SchemaInfo | null>;
4
+ write(schema: Schema, fullPath: string): Promise<void>;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=fileSchemaService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSchemaService.js","sourceRoot":"","sources":["../../../../../src/lib/schema/domain/ports/fileSchemaService.ts"],"names":[],"mappings":""}
@@ -0,0 +1,207 @@
1
+ import { SentenceCategory } from './sentence';
2
+ import { Dialect } from './dialect';
3
+ export declare const DIALECT_DEFAULT = Dialect.MySQL;
4
+ export declare enum RelationType {
5
+ oneToMany = "oneToMany",
6
+ manyToOne = "manyToOne",
7
+ oneToOne = "oneToOne"
8
+ }
9
+ export interface EnumValue {
10
+ name: string;
11
+ value: any;
12
+ }
13
+ export interface Enum {
14
+ name: string;
15
+ extends?: string;
16
+ abstract?: boolean;
17
+ values: EnumValue[];
18
+ }
19
+ export interface Constraint {
20
+ message: string;
21
+ condition: string;
22
+ }
23
+ export interface Property {
24
+ name: string;
25
+ type?: string;
26
+ length?: number;
27
+ required?: boolean;
28
+ primaryKey?: boolean;
29
+ autoIncrement?: boolean;
30
+ view?: boolean;
31
+ readExp?: string;
32
+ writeExp?: string;
33
+ default?: string;
34
+ readValue?: string;
35
+ writeValue?: string;
36
+ enum?: string;
37
+ key?: string;
38
+ }
39
+ export interface Relation {
40
+ name: string;
41
+ type: RelationType;
42
+ composite?: boolean;
43
+ from: string;
44
+ entity: string;
45
+ to: string;
46
+ weak?: boolean;
47
+ target?: string;
48
+ }
49
+ export interface Dependent {
50
+ entity: string;
51
+ relation: Relation;
52
+ }
53
+ export interface Index {
54
+ name: string;
55
+ fields: string[];
56
+ }
57
+ export interface Entity {
58
+ name: string;
59
+ properties?: Property[];
60
+ extends?: string;
61
+ abstract?: boolean;
62
+ singular?: string;
63
+ view?: boolean;
64
+ primaryKey?: string[];
65
+ uniqueKey?: string[];
66
+ relations?: Relation[];
67
+ required?: string[];
68
+ indexes?: Index[];
69
+ dependents?: Dependent[];
70
+ constraints?: Constraint[];
71
+ hadReadExps?: boolean;
72
+ hadWriteExps?: boolean;
73
+ hadReadValues?: boolean;
74
+ hadWriteValues?: boolean;
75
+ hadDefaults?: boolean;
76
+ hadViewReadExp?: boolean;
77
+ composite?: boolean;
78
+ intermediate?: boolean;
79
+ }
80
+ export interface RelationInfo {
81
+ previousRelation: string;
82
+ previousEntity: Entity;
83
+ entity: Entity;
84
+ relation: Relation;
85
+ }
86
+ export interface PropertyMapping extends Property {
87
+ mapping: string;
88
+ readMappingExp?: string;
89
+ dbType?: string;
90
+ }
91
+ export interface EntityMapping extends Entity {
92
+ mapping?: string;
93
+ sequence?: string;
94
+ properties?: PropertyMapping[];
95
+ filter?: string;
96
+ hadKeys?: boolean;
97
+ hadReadMappingExp?: boolean;
98
+ }
99
+ export interface FormatMapping extends Entity {
100
+ dateTime?: string;
101
+ date?: string;
102
+ time?: string;
103
+ }
104
+ export interface Mapping {
105
+ extends?: string;
106
+ mapping?: string;
107
+ name: string;
108
+ entities?: EntityMapping[];
109
+ format?: FormatMapping;
110
+ }
111
+ export interface PropertyView {
112
+ name: string;
113
+ readExp?: string;
114
+ exclude?: boolean;
115
+ }
116
+ export interface EntityView {
117
+ name: string;
118
+ exclude?: boolean;
119
+ properties: PropertyView[];
120
+ }
121
+ export interface View {
122
+ name: string;
123
+ entities: EntityView[];
124
+ }
125
+ export interface Source {
126
+ name: string;
127
+ dialect: Dialect;
128
+ mapping: string;
129
+ connection: any;
130
+ }
131
+ export interface SourceRule {
132
+ name: string;
133
+ condition?: string;
134
+ }
135
+ export interface Stage {
136
+ name: string;
137
+ sources: SourceRule[];
138
+ }
139
+ export interface ListenerConfig {
140
+ name: string;
141
+ on: SentenceCategory[];
142
+ condition?: string;
143
+ before?: string;
144
+ after?: string;
145
+ error?: string;
146
+ }
147
+ export interface TaskConfig {
148
+ name: string;
149
+ condition?: string;
150
+ expression: string;
151
+ }
152
+ export interface AppPathsConfig {
153
+ src?: string;
154
+ state?: string;
155
+ domain?: string;
156
+ }
157
+ export interface DomainSchema {
158
+ version: string;
159
+ entities: Entity[];
160
+ enums?: Enum[];
161
+ }
162
+ export interface ServerConfig {
163
+ url: string;
164
+ }
165
+ export interface InfrastructureSchema {
166
+ paths?: AppPathsConfig;
167
+ mappings?: Mapping[];
168
+ views?: View[];
169
+ sources?: Source[];
170
+ stages?: Stage[];
171
+ server?: ServerConfig;
172
+ }
173
+ export interface ApplicationSchema {
174
+ start?: TaskConfig[];
175
+ listeners?: ListenerConfig[];
176
+ end?: TaskConfig[];
177
+ }
178
+ export interface Schema {
179
+ version: string;
180
+ domain: DomainSchema;
181
+ infrastructure?: InfrastructureSchema;
182
+ application?: ApplicationSchema;
183
+ }
184
+ export interface SchemaInfo {
185
+ schema: Schema;
186
+ path?: string;
187
+ }
188
+ export interface ModelConfig {
189
+ mappings: Mapping[];
190
+ }
191
+ export interface MappingConfig {
192
+ mapping: any;
193
+ pending: any[];
194
+ inconsistency: any[];
195
+ }
196
+ export interface Behavior {
197
+ alias?: string;
198
+ property: string;
199
+ expression: string;
200
+ }
201
+ export interface SchemaEntityData {
202
+ entity: string;
203
+ rows: any[];
204
+ }
205
+ export interface SchemaData {
206
+ entities: SchemaEntityData[];
207
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelationType = exports.DIALECT_DEFAULT = void 0;
4
+ const dialect_1 = require("./dialect");
5
+ exports.DIALECT_DEFAULT = dialect_1.Dialect.MySQL;
6
+ var RelationType;
7
+ (function (RelationType) {
8
+ RelationType["oneToMany"] = "oneToMany";
9
+ RelationType["manyToOne"] = "manyToOne";
10
+ RelationType["oneToOne"] = "oneToOne";
11
+ })(RelationType || (exports.RelationType = RelationType = {}));
12
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/lib/schema/domain/schema.ts"],"names":[],"mappings":";;;AACA,uCAAmC;AACtB,QAAA,eAAe,GAAG,iBAAO,CAAC,KAAK,CAAA;AAE5C,IAAY,YAIX;AAJD,WAAY,YAAY;IACvB,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;AACtB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB"}
@@ -0,0 +1,68 @@
1
+ export declare enum SentenceCategory {
2
+ undefined = "undefined",
3
+ select = "select",
4
+ insert = "insert",
5
+ upsert = "upsert",
6
+ update = "update",
7
+ delete = "delete",
8
+ truncate = "truncate",
9
+ create = "create",
10
+ add = "add",
11
+ alter = "alter",
12
+ drop = "drop"
13
+ }
14
+ export declare enum SentenceType {
15
+ dql = "dql",// SELECT statements
16
+ dml = "dml",// INSERT, UPDATE, DELETE statements
17
+ ddl = "ddl",// CREATE, ALTER, DROP statements
18
+ metadata = "metadata"
19
+ }
20
+ export declare enum SentenceAction {
21
+ undefined = "undefined",
22
+ select = "select",
23
+ insert = "insert",
24
+ insertConditional = "insertConditional",
25
+ bulkInsert = "bulkInsert",
26
+ bulkDelete = "bulkDelete",
27
+ update = "update",
28
+ upsert = "upsert",
29
+ delete = "delete",
30
+ merge = "merge",
31
+ bulkMerge = "bulkMerge",
32
+ truncateEntity = "truncateEntity",
33
+ createEntity = "createEntity",
34
+ createSequence = "createSequence",
35
+ createFk = "createFk",
36
+ createIndex = "createIndex",
37
+ alterProperty = "alterProperty",
38
+ addProperty = "addProperty",
39
+ addPk = "addPk",
40
+ addUk = "addUk",
41
+ addFk = "addFk",
42
+ dropSequence = "dropSequence",
43
+ dropEntity = "dropEntity",
44
+ dropProperty = "dropProperty",
45
+ dropPk = "dropPk",
46
+ dropUk = "dropUk",
47
+ dropFk = "dropFk",
48
+ dropIndex = "dropIndex",
49
+ objects = "objects",
50
+ tables = "tables",
51
+ views = "views",
52
+ sequences = "sequences",
53
+ indexes = "indexes",
54
+ primaryKeys = "primaryKeys",
55
+ uniqueKeys = "uniqueKeys",
56
+ foreignKeys = "foreignKeys",
57
+ partitions = "partitions"
58
+ }
59
+ export interface SentenceInfo {
60
+ entity: string;
61
+ action: SentenceAction;
62
+ category: SentenceCategory;
63
+ type: SentenceType;
64
+ read: boolean;
65
+ write: boolean;
66
+ ddl: boolean;
67
+ dml: boolean;
68
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SentenceAction = exports.SentenceType = exports.SentenceCategory = void 0;
4
+ var SentenceCategory;
5
+ (function (SentenceCategory) {
6
+ SentenceCategory["undefined"] = "undefined";
7
+ SentenceCategory["select"] = "select";
8
+ SentenceCategory["insert"] = "insert";
9
+ SentenceCategory["upsert"] = "upsert";
10
+ SentenceCategory["update"] = "update";
11
+ SentenceCategory["delete"] = "delete";
12
+ SentenceCategory["truncate"] = "truncate";
13
+ SentenceCategory["create"] = "create";
14
+ SentenceCategory["add"] = "add";
15
+ SentenceCategory["alter"] = "alter";
16
+ SentenceCategory["drop"] = "drop";
17
+ })(SentenceCategory || (exports.SentenceCategory = SentenceCategory = {}));
18
+ var SentenceType;
19
+ (function (SentenceType) {
20
+ SentenceType["dql"] = "dql";
21
+ SentenceType["dml"] = "dml";
22
+ SentenceType["ddl"] = "ddl";
23
+ SentenceType["metadata"] = "metadata"; // Metadata statements
24
+ })(SentenceType || (exports.SentenceType = SentenceType = {}));
25
+ var SentenceAction;
26
+ (function (SentenceAction) {
27
+ SentenceAction["undefined"] = "undefined";
28
+ SentenceAction["select"] = "select";
29
+ SentenceAction["insert"] = "insert";
30
+ SentenceAction["insertConditional"] = "insertConditional";
31
+ SentenceAction["bulkInsert"] = "bulkInsert";
32
+ SentenceAction["bulkDelete"] = "bulkDelete";
33
+ SentenceAction["update"] = "update";
34
+ SentenceAction["upsert"] = "upsert";
35
+ SentenceAction["delete"] = "delete";
36
+ SentenceAction["merge"] = "merge";
37
+ SentenceAction["bulkMerge"] = "bulkMerge";
38
+ SentenceAction["truncateEntity"] = "truncateEntity";
39
+ SentenceAction["createEntity"] = "createEntity";
40
+ SentenceAction["createSequence"] = "createSequence";
41
+ SentenceAction["createFk"] = "createFk";
42
+ SentenceAction["createIndex"] = "createIndex";
43
+ SentenceAction["alterProperty"] = "alterProperty";
44
+ SentenceAction["addProperty"] = "addProperty";
45
+ SentenceAction["addPk"] = "addPk";
46
+ SentenceAction["addUk"] = "addUk";
47
+ SentenceAction["addFk"] = "addFk";
48
+ SentenceAction["dropSequence"] = "dropSequence";
49
+ SentenceAction["dropEntity"] = "dropEntity";
50
+ SentenceAction["dropProperty"] = "dropProperty";
51
+ SentenceAction["dropPk"] = "dropPk";
52
+ SentenceAction["dropUk"] = "dropUk";
53
+ SentenceAction["dropFk"] = "dropFk";
54
+ SentenceAction["dropIndex"] = "dropIndex";
55
+ SentenceAction["objects"] = "objects";
56
+ SentenceAction["tables"] = "tables";
57
+ SentenceAction["views"] = "views";
58
+ SentenceAction["sequences"] = "sequences";
59
+ SentenceAction["indexes"] = "indexes";
60
+ SentenceAction["primaryKeys"] = "primaryKeys";
61
+ SentenceAction["uniqueKeys"] = "uniqueKeys";
62
+ SentenceAction["foreignKeys"] = "foreignKeys";
63
+ SentenceAction["partitions"] = "partitions";
64
+ })(SentenceAction || (exports.SentenceAction = SentenceAction = {}));
65
+ //# sourceMappingURL=sentence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentence.js","sourceRoot":"","sources":["../../../../src/lib/schema/domain/sentence.ts"],"names":[],"mappings":";;;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,6CAA2B,CAAA;IAC3B,2CAAyB,CAAA;AAC1B,CAAC,EAtCW,cAAc,8BAAd,cAAc,QAsCzB"}
@@ -0,0 +1,20 @@
1
+ import { SourceRule } from './schema';
2
+ import { Dialect } from './dialect';
3
+ import { SentenceInfo } from './sentence';
4
+ export interface IRouteService {
5
+ eval(source: SourceRule, info: SentenceInfo): boolean;
6
+ getSource(info: SentenceInfo, stage?: string): string;
7
+ }
8
+ export interface MatchOptions {
9
+ removeEntities?: boolean;
10
+ removeProperties?: boolean;
11
+ removeRelations?: boolean;
12
+ }
13
+ export interface InitializeSchemaArgs {
14
+ workspace: string;
15
+ url?: string;
16
+ source?: string;
17
+ dialect?: Dialect;
18
+ connection?: string;
19
+ dataPath?: string;
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["../../../../src/lib/schema/domain/services.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { Expressions } from '3xpr';
2
+ import { SchemaFacade } from '../application';
3
+ import { OrmBaseH3lp } from '../../shared';
4
+ export declare class SchemaFacadeBuilder {
5
+ private readonly exp;
6
+ private readonly helper;
7
+ constructor(exp: Expressions, helper: OrmBaseH3lp);
8
+ build(): SchemaFacade;
9
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaFacadeBuilder = void 0;
4
+ const application_1 = require("../application");
5
+ const schemaService_1 = require("../application/services/schemaService");
6
+ const interpretSchemaDataService_1 = require("../application/services/interpretSchemaDataService");
7
+ const fileSchemaService_1 = require("./fileSchemaService");
8
+ const schemaFileHelper_1 = require("./schemaFileHelper");
9
+ class SchemaFacadeBuilder {
10
+ // eslint-disable-next-line no-useless-constructor
11
+ constructor(exp, helper) {
12
+ this.exp = exp;
13
+ this.helper = helper;
14
+ }
15
+ build() {
16
+ const schemaService = new schemaService_1.SchemaService();
17
+ const createEntitiesService = new application_1.CreateEntitiesService(this.helper.schema);
18
+ const interpretSchemaDataService = new interpretSchemaDataService_1.InterpretSchemaDataService(this.helper.schema);
19
+ const extender = new application_1.SchemaExtender(this.exp, this.helper);
20
+ const createSchema = new application_1.CreateSchema(schemaService);
21
+ const initializeSchema = new application_1.InitializeSchema(schemaService);
22
+ const updateSchema = new application_1.UpdateSchema(createEntitiesService);
23
+ const matchSchema = new application_1.MatchSchema(schemaService, this.helper.schema);
24
+ const getSchemaData = new application_1.GetSchemaSchema(interpretSchemaDataService);
25
+ const fileSchemaService = new fileSchemaService_1.FileSchemaService(new schemaFileHelper_1.SchemaFileHelper(this.helper), this.helper);
26
+ return new application_1.SchemaFacade(schemaService, getSchemaData, extender, createSchema, initializeSchema, updateSchema, matchSchema, fileSchemaService);
27
+ }
28
+ }
29
+ exports.SchemaFacadeBuilder = SchemaFacadeBuilder;
30
+ //# sourceMappingURL=facadeBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facadeBuilder.js","sourceRoot":"","sources":["../../../../src/lib/schema/infrastructure/facadeBuilder.ts"],"names":[],"mappings":";;;AACA,gDAAgK;AAChK,yEAAqE;AACrE,mGAA+F;AAE/F,2DAAuD;AACvD,yDAAqD;AACrD,MAAa,mBAAmB;IAC/B,kDAAkD;IAClD,YACkB,GAAgB,EAChB,MAAmB;QADnB,QAAG,GAAH,GAAG,CAAa;QAChB,WAAM,GAAN,MAAM,CAAa;IAClC,CAAC;IAEG,KAAK;QACX,MAAM,aAAa,GAAG,IAAI,6BAAa,EAAE,CAAA;QACzC,MAAM,qBAAqB,GAAG,IAAI,mCAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAC3E,MAAM,0BAA0B,GAAG,IAAI,uDAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACrF,MAAM,QAAQ,GAAG,IAAI,4BAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAC1D,MAAM,YAAY,GAAG,IAAI,0BAAY,CAAC,aAAa,CAAC,CAAA;QACpD,MAAM,gBAAgB,GAAG,IAAI,8BAAgB,CAAC,aAAa,CAAC,CAAA;QAC5D,MAAM,YAAY,GAAG,IAAI,0BAAY,CAAC,qBAAqB,CAAC,CAAA;QAC5D,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACtE,MAAM,aAAa,GAAG,IAAI,6BAAe,CAAC,0BAA0B,CAAC,CAAA;QACrE,MAAM,iBAAiB,GAAG,IAAI,qCAAiB,CAAC,IAAI,mCAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/F,OAAO,IAAI,0BAAY,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAA;IAC9I,CAAC;CACD;AApBD,kDAoBC"}
@@ -0,0 +1,11 @@
1
+ import { Schema, SchemaInfo, IFileSchemaService } from '../domain';
2
+ import { H3lp } from 'h3lp';
3
+ import { SchemaFileHelper } from './schemaFileHelper';
4
+ export declare class FileSchemaService implements IFileSchemaService {
5
+ private schemaFileHelper;
6
+ private helper;
7
+ constructor(schemaFileHelper: SchemaFileHelper, helper: H3lp);
8
+ read(source: string): Promise<SchemaInfo | null>;
9
+ write(schema: Schema, fullPath: string): Promise<void>;
10
+ private readConfig;
11
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FileSchemaService = void 0;
16
+ const domain_1 = require("../domain");
17
+ const path_1 = __importDefault(require("path"));
18
+ const yaml = require('js-yaml');
19
+ class FileSchemaService {
20
+ // eslint-disable-next-line no-useless-constructor
21
+ constructor(schemaFileHelper, helper) {
22
+ this.schemaFileHelper = schemaFileHelper;
23
+ this.helper = helper;
24
+ }
25
+ read(source) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const configPath = yield this.schemaFileHelper.getConfigPath(source);
28
+ if (!configPath) {
29
+ return null;
30
+ }
31
+ const content = yield this.readConfig(configPath);
32
+ if (content === undefined || content === null) {
33
+ throw new domain_1.SchemaError(`Schema file: ${configPath} empty`);
34
+ }
35
+ else if (path_1.default.extname(configPath) === '.yaml' || path_1.default.extname(configPath) === '.yml') {
36
+ return { schema: yaml.load(content), path: configPath };
37
+ }
38
+ else if (path_1.default.extname(configPath) === '.json') {
39
+ return { schema: JSON.parse(content), path: configPath };
40
+ }
41
+ else {
42
+ throw new domain_1.SchemaError(`Schema file: ${configPath} not supported`);
43
+ }
44
+ });
45
+ }
46
+ write(schema, fullPath) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ if (path_1.default.extname(fullPath) === '.yaml' || path_1.default.extname(fullPath) === '.yml') {
49
+ yield this.helper.fs.write(fullPath, yaml.dump(schema));
50
+ }
51
+ else if (path_1.default.extname(fullPath) === '.json') {
52
+ yield this.helper.fs.write(fullPath, JSON.stringify(schema, null, 2));
53
+ }
54
+ else {
55
+ throw new domain_1.SchemaError(`Schema file: ${fullPath} not supported`);
56
+ }
57
+ });
58
+ }
59
+ readConfig(path) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ if (path.startsWith('http')) {
62
+ return yield this.helper.http.get(path);
63
+ }
64
+ return yield this.helper.fs.read(path);
65
+ });
66
+ }
67
+ }
68
+ exports.FileSchemaService = FileSchemaService;
69
+ //# sourceMappingURL=fileSchemaService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSchemaService.js","sourceRoot":"","sources":["../../../../src/lib/schema/infrastructure/fileSchemaService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAA+E;AAC/E,gDAAuB;AAGvB,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAE/B,MAAa,iBAAiB;IAC7B,kDAAkD;IAClD,YACS,gBAAkC,EAClC,MAAY;QADZ,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,WAAM,GAAN,MAAM,CAAM;IAClB,CAAC;IAES,IAAI,CAAE,MAAa;;YAC/B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;YACpE,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAA;YACZ,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;YACjD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBAC/C,MAAM,IAAI,oBAAW,CAAC,gBAAgB,UAAU,QAAQ,CAAC,CAAA;YAC1D,CAAC;iBAAM,IAAI,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,OAAO,IAAI,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,MAAM,EAAE,CAAC;gBACxF,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,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A;QACvC,CAAC;KAAA;CACD;AAxCD,8CAwCC"}
@@ -0,0 +1,3 @@
1
+ export * from './facadeBuilder';
2
+ export * from './stateBuilder';
3
+ export * from './schemaHelper';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./facadeBuilder"), exports);
18
+ __exportStar(require("./stateBuilder"), exports);
19
+ __exportStar(require("./schemaHelper"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/schema/infrastructure/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,iDAA8B;AAC9B,iDAA8B"}
@@ -0,0 +1,7 @@
1
+ import { OrmBaseH3lp } from '../../shared';
2
+ export declare class SchemaFileHelper {
3
+ private readonly helper;
4
+ constructor(helper: OrmBaseH3lp);
5
+ getConfigPath(source?: string): Promise<string | undefined>;
6
+ getConfigFileName(workspace: string): Promise<string | undefined>;
7
+ }