@vroskus/library-datahandler 1.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.
package/dist/index.js ADDED
@@ -0,0 +1,528 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
26
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
27
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
28
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ var _DatabaseService_instances, _DatabaseService_getModel, _DatabaseService_getModelInstance, _DatabaseService_mapQueryAssociations, _DatabaseService_prepareQueryParams, _DatabaseService_associate;
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ const sequelize_1 = require("sequelize");
36
+ const lodash_1 = __importDefault(require("lodash"));
37
+ const pluralize_1 = __importDefault(require("pluralize"));
38
+ const library_error_1 = require("@vroskus/library-error");
39
+ const helpers_1 = __importDefault(require("./helpers"));
40
+ __exportStar(require("./types"), exports);
41
+ class DatabaseService {
42
+ constructor({ database, dialect, host, logging, password, port, storage, username, }, modelShapes) {
43
+ _DatabaseService_instances.add(this);
44
+ const dbConfig = {
45
+ database,
46
+ define: {
47
+ charset: 'utf8',
48
+ dialectOptions: {
49
+ collate: 'utf8_general_ci',
50
+ },
51
+ timestamps: true,
52
+ },
53
+ dialect: dialect || 'mysql',
54
+ dialectOptions: {},
55
+ host,
56
+ logging,
57
+ password,
58
+ port: Number(port),
59
+ storage,
60
+ username,
61
+ };
62
+ const stack = new sequelize_1.Sequelize(dbConfig.database, dbConfig.username, dbConfig.password, dbConfig);
63
+ const models = lodash_1.default.mapValues(modelShapes, (f) => f(sequelize_1.Sequelize, stack, helpers_1.default));
64
+ Object.keys(models).forEach((modelName) => {
65
+ if (models[modelName].associate) {
66
+ models[modelName].associate(models);
67
+ }
68
+ if (models[modelName].hooks) {
69
+ models[modelName].hooks(models);
70
+ }
71
+ });
72
+ this.models = models;
73
+ this.helpers = helpers_1.default;
74
+ this.stack = stack;
75
+ this.Op = sequelize_1.Op;
76
+ }
77
+ setupTestEnvironment() {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ yield this.stack.sync({
80
+ force: true,
81
+ });
82
+ });
83
+ }
84
+ getOne({ modelName, params, }) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
87
+ modelName,
88
+ });
89
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
90
+ params,
91
+ });
92
+ const modelInstances = yield model.findAll(request);
93
+ if (modelInstances.length > 1) {
94
+ throw new library_error_1.CustomError('Multiple records found', library_error_1.baseErrorKey.multipleRecordsFoundError, {
95
+ data: {
96
+ amount: modelInstances.length,
97
+ modelName,
98
+ request,
99
+ },
100
+ });
101
+ }
102
+ return lodash_1.default.head(modelInstances) || null;
103
+ });
104
+ }
105
+ getFirst({ modelName, params, }) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
108
+ modelName,
109
+ });
110
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
111
+ params,
112
+ });
113
+ const modelInstances = yield model.findAll(request);
114
+ return lodash_1.default.first(modelInstances) || null;
115
+ });
116
+ }
117
+ getLast({ modelName, params, }) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
120
+ modelName,
121
+ });
122
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
123
+ params,
124
+ });
125
+ const modelInstances = yield model.findAll(request);
126
+ return lodash_1.default.last(modelInstances) || null;
127
+ });
128
+ }
129
+ getMany({ modelName, params, }) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
132
+ modelName,
133
+ });
134
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
135
+ params,
136
+ });
137
+ return model.findAll(request);
138
+ });
139
+ }
140
+ createOne({ modelName, params, }) {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
143
+ modelName,
144
+ });
145
+ const attributes = lodash_1.default.clone(params);
146
+ return model.create(attributes);
147
+ });
148
+ }
149
+ createBundle({ include, modelName, params, }) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
152
+ modelName,
153
+ });
154
+ const attributes = lodash_1.default.clone(params);
155
+ return model.create(attributes, {
156
+ include,
157
+ });
158
+ });
159
+ }
160
+ createMany({ modelName, params, }) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
163
+ modelName,
164
+ });
165
+ const attributes = lodash_1.default.clone(params);
166
+ return model.bulkCreate(attributes);
167
+ });
168
+ }
169
+ upsertOne({ modelName, params, where, }) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ const attributes = lodash_1.default.omit(params, ['id', 'createdAt', 'updatedAt']);
172
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
173
+ modelName,
174
+ });
175
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
176
+ params: {
177
+ where,
178
+ },
179
+ });
180
+ const modelInstances = yield model.findAll(request);
181
+ if (modelInstances.length > 1) {
182
+ throw new library_error_1.CustomError('Multiple records found', library_error_1.baseErrorKey.multipleRecordsFoundError, {
183
+ data: {
184
+ amount: modelInstances.length,
185
+ modelName,
186
+ request,
187
+ },
188
+ });
189
+ }
190
+ if (modelInstances.length === 0) {
191
+ return model.create(attributes);
192
+ }
193
+ if (typeof modelInstances[0].update === 'function') {
194
+ return modelInstances[0].update(attributes);
195
+ }
196
+ return modelInstances[0];
197
+ });
198
+ }
199
+ updateOne({ modelName, params, }) {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ const { id, } = params;
202
+ const modelInstance = yield __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModelInstance).call(this, {
203
+ id,
204
+ modelName,
205
+ });
206
+ const attributes = lodash_1.default.omit(params, ['id', 'createdAt', 'updatedAt']);
207
+ if (typeof modelInstance.update === 'function') {
208
+ yield modelInstance.update(attributes);
209
+ }
210
+ return modelInstance;
211
+ });
212
+ }
213
+ toggleOne({ modelName, where, }) {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const attributes = lodash_1.default.omit(where, ['id', 'createdAt', 'updatedAt']);
216
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
217
+ modelName,
218
+ });
219
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
220
+ params: {
221
+ where,
222
+ },
223
+ });
224
+ let modelInstance = yield model.findOne(request);
225
+ if (modelInstance !== null) {
226
+ yield modelInstance.destroy();
227
+ }
228
+ else {
229
+ modelInstance = yield model.create(attributes);
230
+ }
231
+ return modelInstance;
232
+ });
233
+ }
234
+ deleteOne({ modelName, params, }) {
235
+ return __awaiter(this, void 0, void 0, function* () {
236
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
237
+ modelName,
238
+ });
239
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
240
+ params,
241
+ });
242
+ const modelInstances = yield model.findAll(request);
243
+ if (modelInstances.length > 1) {
244
+ throw new library_error_1.CustomError('Multiple records found', library_error_1.baseErrorKey.multipleRecordsFoundError, {
245
+ data: {
246
+ amount: modelInstances.length,
247
+ modelName,
248
+ request,
249
+ },
250
+ });
251
+ }
252
+ if (modelInstances.length === 0) {
253
+ throw new library_error_1.CustomError('Record was not found', library_error_1.baseErrorKey.entityNotFoundError, {
254
+ data: {
255
+ modelName,
256
+ request,
257
+ },
258
+ });
259
+ }
260
+ yield modelInstances[0].destroy();
261
+ return modelInstances[0];
262
+ });
263
+ }
264
+ deleteMany({ modelName, params, }) {
265
+ return __awaiter(this, void 0, void 0, function* () {
266
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
267
+ modelName,
268
+ });
269
+ const request = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_prepareQueryParams).call(this, {
270
+ params,
271
+ });
272
+ const modelInstances = yield model.findAll(request);
273
+ for (let index = 0; index < modelInstances.length; index += 1) {
274
+ if (modelInstances[index].destroy) {
275
+ yield modelInstances[index].destroy();
276
+ }
277
+ }
278
+ return modelInstances;
279
+ });
280
+ }
281
+ sync({ modelName, params: { associationModelId, associationModelName, items, }, }) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ const actions = [];
284
+ const where = {
285
+ [`${String(associationModelName)}Id`]: associationModelId,
286
+ };
287
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
288
+ modelName,
289
+ });
290
+ __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
291
+ modelName: associationModelName,
292
+ });
293
+ const presentItems = yield model.findAll({
294
+ where,
295
+ });
296
+ const presentItemIds = lodash_1.default.map(presentItems, 'id');
297
+ const updatedItemIds = lodash_1.default.map(lodash_1.default.filter(items, (item) => item.id), 'id');
298
+ const deletedItemIds = lodash_1.default.without(presentItemIds, ...updatedItemIds);
299
+ const createdItemIds = [];
300
+ const syncedItems = [];
301
+ items.forEach((item) => {
302
+ const request = {
303
+ modelName,
304
+ params: Object.assign(Object.assign({}, item), where),
305
+ where: {
306
+ id: item.id || null,
307
+ },
308
+ };
309
+ const action = (() => __awaiter(this, void 0, void 0, function* () {
310
+ const upsertedItem = yield this.upsertOne(request);
311
+ if (!item.id) {
312
+ createdItemIds.push(upsertedItem.id);
313
+ }
314
+ syncedItems.push(upsertedItem);
315
+ }))();
316
+ actions.push(action);
317
+ });
318
+ deletedItemIds.forEach((id) => {
319
+ const request = {
320
+ modelName,
321
+ params: {
322
+ where: Object.assign({ id }, where),
323
+ },
324
+ };
325
+ const action = this.deleteOne(request);
326
+ actions.push(action);
327
+ });
328
+ yield Promise.all(actions);
329
+ return {
330
+ createdItemIds,
331
+ deletedItemIds,
332
+ syncedItems,
333
+ updatedItemIds,
334
+ };
335
+ });
336
+ }
337
+ addAssociation({ modelName, params, }) {
338
+ return __awaiter(this, void 0, void 0, function* () {
339
+ const { associationModelId, associationModelName, id, pivot, } = params;
340
+ const result = yield __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_associate).call(this, {
341
+ action: 'add',
342
+ associationModelId,
343
+ associationModelName,
344
+ id,
345
+ modelName,
346
+ pivot,
347
+ });
348
+ if (!result || (result && result.length !== 1)) {
349
+ throw new library_error_1.CustomError('Already associatied records', library_error_1.baseErrorKey.alreadyAssociatedRecordsError, {
350
+ data: {
351
+ model1: modelName,
352
+ model1id: id,
353
+ model2: associationModelName,
354
+ model2id: associationModelId,
355
+ },
356
+ });
357
+ }
358
+ return result[0];
359
+ });
360
+ }
361
+ removeAssociation({ modelName, params, }) {
362
+ return __awaiter(this, void 0, void 0, function* () {
363
+ const { associationModelId, associationModelName, id, } = params;
364
+ const result = yield __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_associate).call(this, {
365
+ action: 'remove',
366
+ associationModelId,
367
+ associationModelName,
368
+ id,
369
+ modelName,
370
+ });
371
+ if (!result || (result && result !== 1)) {
372
+ throw new library_error_1.CustomError('Not associatied records', library_error_1.baseErrorKey.notAssociatedRecordsError, {
373
+ data: {
374
+ model1: modelName,
375
+ model1id: id,
376
+ model2: associationModelName,
377
+ model2id: associationModelId,
378
+ },
379
+ });
380
+ }
381
+ return true;
382
+ });
383
+ }
384
+ syncAssociations({ modelName, params: { associationModelIds, associationModelName, id, }, }) {
385
+ return __awaiter(this, void 0, void 0, function* () {
386
+ const actions = [];
387
+ const pluralAssociationModelName = pluralize_1.default.plural(associationModelName);
388
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
389
+ modelName,
390
+ });
391
+ const modelInstance = yield model.findOne({
392
+ include: [pluralAssociationModelName],
393
+ where: {
394
+ id,
395
+ },
396
+ });
397
+ const presentAssociationModelIds = lodash_1.default.map(lodash_1.default.get(modelInstance, pluralAssociationModelName, []), 'id');
398
+ const addAssociationModelIds = lodash_1.default.without(associationModelIds, ...presentAssociationModelIds);
399
+ addAssociationModelIds.forEach((associationModelId) => {
400
+ const addAssociationRequest = {
401
+ modelName,
402
+ params: {
403
+ associationModelId,
404
+ associationModelName,
405
+ id,
406
+ },
407
+ };
408
+ const action = this.addAssociation(addAssociationRequest);
409
+ actions.push(action);
410
+ });
411
+ const removeAssociationModelIds = lodash_1.default.without(presentAssociationModelIds, ...associationModelIds);
412
+ removeAssociationModelIds.forEach((associationModelId) => {
413
+ const addAssociationRequest = {
414
+ modelName,
415
+ params: {
416
+ associationModelId,
417
+ associationModelName,
418
+ id,
419
+ },
420
+ };
421
+ const action = this.removeAssociation(addAssociationRequest);
422
+ actions.push(action);
423
+ });
424
+ yield Promise.all(actions);
425
+ return {
426
+ addedAssociationModelIds: addAssociationModelIds,
427
+ removedAssociationModelIds: removeAssociationModelIds,
428
+ };
429
+ });
430
+ }
431
+ }
432
+ _DatabaseService_instances = new WeakSet(), _DatabaseService_getModel = function _DatabaseService_getModel({ modelName, }) {
433
+ if (!lodash_1.default.has(this.models, modelName)) {
434
+ throw new library_error_1.CustomError('Invalid model name', library_error_1.baseErrorKey.invalidModelNameError, {
435
+ data: {
436
+ modelName,
437
+ },
438
+ });
439
+ }
440
+ return lodash_1.default.get(this.models, modelName);
441
+ }, _DatabaseService_getModelInstance = function _DatabaseService_getModelInstance({ id, modelName, }) {
442
+ return __awaiter(this, void 0, void 0, function* () {
443
+ const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
444
+ modelName,
445
+ });
446
+ const modelInstance = yield model.findByPk(id);
447
+ if (modelInstance === null) {
448
+ throw new library_error_1.CustomError('Record was not found', library_error_1.baseErrorKey.entityNotFoundError, {
449
+ data: {
450
+ id,
451
+ modelName,
452
+ },
453
+ });
454
+ }
455
+ return modelInstance;
456
+ });
457
+ }, _DatabaseService_mapQueryAssociations = function _DatabaseService_mapQueryAssociations({ include: includeInput, where: whereInput, }) {
458
+ let where = lodash_1.default.clone(whereInput);
459
+ const include = lodash_1.default.clone(includeInput);
460
+ lodash_1.default.forOwn(where, (value, key) => {
461
+ if (key.includes('.')) {
462
+ const associationName = key.substr(0, key.indexOf('.'));
463
+ const param = key.substr(key.indexOf('.') + 1);
464
+ const model = this.models[pluralize_1.default.singular(associationName)];
465
+ if (model) {
466
+ include.push(Object.assign({ as: associationName, model }, __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_mapQueryAssociations).call(this, {
467
+ include: [],
468
+ where: {
469
+ [param]: value,
470
+ },
471
+ })));
472
+ }
473
+ else {
474
+ include.push(associationName);
475
+ }
476
+ where = lodash_1.default.omit(where, [key]);
477
+ }
478
+ });
479
+ return {
480
+ include,
481
+ where,
482
+ };
483
+ }, _DatabaseService_prepareQueryParams = function _DatabaseService_prepareQueryParams({ params, }) {
484
+ const preparedParams = {
485
+ attributes: params.attributes,
486
+ include: params.include,
487
+ where: undefined,
488
+ };
489
+ if (params.where) {
490
+ const { include, where, } = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_mapQueryAssociations).call(this, {
491
+ include: lodash_1.default.get(preparedParams, 'include', []),
492
+ where: params.where,
493
+ });
494
+ preparedParams.where = where;
495
+ preparedParams.include = include;
496
+ }
497
+ return preparedParams;
498
+ }, _DatabaseService_associate = function _DatabaseService_associate({ action, associationModelId, associationModelName, id, modelName, pivot, }) {
499
+ return __awaiter(this, void 0, void 0, function* () {
500
+ const actionMethod = `${action}${String(associationModelName)}`;
501
+ const modelInstance = yield __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModelInstance).call(this, {
502
+ id,
503
+ modelName,
504
+ });
505
+ const associationModel = yield __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModelInstance).call(this, {
506
+ id: associationModelId,
507
+ modelName: associationModelName,
508
+ });
509
+ const pivotData = pivot ? {
510
+ through: pivot,
511
+ } : {};
512
+ if (typeof modelInstance[actionMethod] !== 'function') {
513
+ throw new library_error_1.CustomError('Association action method not found', library_error_1.baseErrorKey.associationActionMethodNotFoundError, {
514
+ data: {
515
+ action,
516
+ associationModelId,
517
+ associationModelName,
518
+ id,
519
+ modelName,
520
+ pivot,
521
+ },
522
+ });
523
+ }
524
+ return modelInstance[actionMethod](associationModel, pivotData);
525
+ });
526
+ };
527
+ exports.default = DatabaseService;
528
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAGmB;AACnB,oDAAuB;AACvB,0DAAkC;AAClC,0DAGgC;AAChC,wDAAgC;AAchC,0CAAwB;AAExB,MAAM,eAAe;IAcnB,YAAY,EACV,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,QAAQ,GACN,EAAE,WAAyB;;QAC7B,MAAM,QAAQ,GAAG;YACf,QAAQ;YACR,MAAM,EAAE;gBACN,OAAO,EAAE,MAAM;gBACf,cAAc,EAAE;oBACd,OAAO,EAAE,iBAAiB;iBAC3B;gBACD,UAAU,EAAE,IAAI;aACjB;YACD,OAAO,EAAE,OAAO,IAAI,OAAO;YAC3B,cAAc,EAAE,EACf;YACD,IAAI;YACJ,OAAO;YACP,QAAQ;YACR,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;YAClB,OAAO;YACP,QAAQ;SACT,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,qBAAS,CACzB,QAAQ,CAAC,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I,EAAmB;YACpD,EAAE,EAAE,kBAAkB;YACtB,SAAS,EAAE,oBAAoB;SAChC,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC;YACxB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC,CAAC,EACH,CAAC;QAEF,IAAI,OAAO,aAAa,CAAC,YAAY,CAAC,KAAK,UAAU,EAAE;YACrD,MAAM,IAAI,2BAAW,CACnB,qCAAqC,EACrC,4BAAY,CAAC,oCAAoC,EACjD;gBACE,IAAI,EAAE;oBACJ,MAAM;oBACN,kBAAkB;oBAClB,oBAAoB;oBACpB,EAAE;oBACF,SAAS;oBACT,KAAK;iBACN;aACF,CACF,CAAC;SACH;QAED,OAAO,aAAa,CAAC,YAAY,CAAC,CAChC,gBAAgB,EAChB,SAAS,CACV,CAAC;IACJ,CAAC;;AAwnBH,kBAAe,eAAe,CAAC"}
@@ -0,0 +1,25 @@
1
+ export type $Config = {
2
+ database: string;
3
+ dialect?: 'sqlite' | 'mysql';
4
+ host: string;
5
+ logging?: boolean;
6
+ password: string;
7
+ port: string;
8
+ storage?: string;
9
+ username: string;
10
+ };
11
+ export type $Where<MCC extends Record<MN, any>, MN extends keyof MCC> = MCC[MN]['ModelQueryParams'] & {
12
+ [key: string]: string | Record<string, any> | void;
13
+ };
14
+ type $IncludeInside<MCC extends Record<MN, any>, MCS extends Record<MN, any>, MN extends keyof MCC> = MN | {
15
+ model: MCS[MN];
16
+ as?: string;
17
+ where: $Where<MCC, MN>;
18
+ };
19
+ export type $Include<MCC extends Record<MN, any>, MCS extends Record<MN, any>, MN extends keyof MCC> = Array<$IncludeInside<MCC, MCS, MN> | string>;
20
+ export type $QueryParams<MCC extends Record<MN, any>, MCS extends Record<MN, any>, MN extends keyof MCC> = {
21
+ where?: $Where<MCC, MN>;
22
+ attributes?: Array<string>;
23
+ include?: $Include<MCC, MCS, any>;
24
+ };
25
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@vroskus/library-datahandler",
3
+ "version": "1.0.1",
4
+ "description": "Data Handler",
5
+ "author": "Vilius Roškus <vilius@regattas.eu>",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/vroskus/library-datahandler.git"
10
+ },
11
+ "main": "dist/index.js",
12
+ "scripts": {
13
+ "postinstall": "npm run build",
14
+ "build": "tsc",
15
+ "test": "npm run test:eslint && npm run test:e2e",
16
+ "test:eslint": "eslint src --fix",
17
+ "test:e2e": "echo 'No tests'"
18
+ },
19
+ "dependencies": {
20
+ "@types/lodash": "4.14.192",
21
+ "@types/sequelize": "4.28.14",
22
+ "@vroskus/library-error": "1.0.2",
23
+ "lodash": "4.17.21",
24
+ "mysql2": "3.1.2",
25
+ "pg-hstore": "2.3.4",
26
+ "pluralize": "8.0.0",
27
+ "sequelize": "6.29.0",
28
+ "uuid": "9.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/jest": "29.5.0",
32
+ "@types/node": "18.15.11",
33
+ "@typescript-eslint/eslint-plugin": "5.53.0",
34
+ "@typescript-eslint/parser": "5.53.0",
35
+ "eslint": "8.34.0",
36
+ "eslint-config-airbnb-base": "15.0.0",
37
+ "eslint-config-airbnb-typescript": "17.0.0",
38
+ "eslint-plugin-import": "2.27.5",
39
+ "eslint-plugin-import-newlines": "1.3.1",
40
+ "eslint-plugin-react": "7.32.2",
41
+ "eslint-plugin-sort": "2.4.0",
42
+ "npm-check": "6.0.1",
43
+ "sqlite3": "5.1.4",
44
+ "typescript": "4.9.5"
45
+ }
46
+ }
package/src/helpers.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type $Helpers = Record<string, never>;
2
+
3
+ const helpers: $Helpers = {
4
+ };
5
+
6
+ export default helpers;