@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/.eslintrc ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "parserOptions": {
5
+ "requireConfigFile": false,
6
+ "project": ["tsconfig.json"]
7
+ },
8
+ "extends": [
9
+ "airbnb-base",
10
+ "airbnb-typescript",
11
+ "plugin:import/recommended",
12
+ "plugin:@typescript-eslint/eslint-recommended",
13
+ "plugin:@typescript-eslint/recommended",
14
+ "plugin:sort/recommended"
15
+ ],
16
+ "plugins": [
17
+ "@typescript-eslint",
18
+ "import",
19
+ "import-newlines",
20
+ "react",
21
+ "sort"
22
+ ],
23
+ "rules": {
24
+ "complexity": ["error", 5],
25
+ "@typescript-eslint/ban-ts-comment": [1],
26
+ "@typescript-eslint/no-unused-vars": [2],
27
+ "curly": ["error", "all"],
28
+ "import/no-cycle": [0],
29
+ "no-await-in-loop": 0,
30
+ "no-console": "error",
31
+ "no-duplicate-imports": [0],
32
+ "no-loss-of-precision": [0],
33
+ "no-restricted-syntax": 0,
34
+ "no-unreachable-loop": [0],
35
+ "no-useless-backreference": [0],
36
+ "no-unused-private-class-members": [2],
37
+ "padding-line-between-statements": ["error", {
38
+ "blankLine": "always",
39
+ "prev": ["const", "let"],
40
+ "next": "*"
41
+ }, {
42
+ "blankLine": "any",
43
+ "prev": ["const", "let"],
44
+ "next": ["const", "let"]
45
+ }, {
46
+ "blankLine": "always",
47
+ "prev": ["if", "function", "for"],
48
+ "next": "*"
49
+ }, {
50
+ "blankLine": "always",
51
+ "prev": "*",
52
+ "next": "return"
53
+ }],
54
+ "object-curly-newline": ["error", {
55
+ "ObjectExpression": "always",
56
+ "ObjectPattern": "always",
57
+ "ImportDeclaration": "always",
58
+ "ExportDeclaration": "always"
59
+ }],
60
+ "function-call-argument-newline": ["error", "always"],
61
+ "object-property-newline": ["error", {
62
+ "allowMultiplePropertiesPerLine": false
63
+ }],
64
+ "import-newlines/enforce": ["error", {
65
+ "items": 1,
66
+ "forceSingleLine": false
67
+ }],
68
+ "sort/imports": [0],
69
+ "sort/exports": [0]
70
+ },
71
+ "env": {
72
+ "node": true,
73
+ "jest": true,
74
+ "es6": true
75
+ }
76
+ }
@@ -0,0 +1,3 @@
1
+ export type $Helpers = Record<string, never>;
2
+ declare const helpers: $Helpers;
3
+ export default helpers;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const helpers = {};
4
+ exports.default = helpers;
5
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;AAEA,MAAM,OAAO,GAAa,EACzB,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { Sequelize } from 'sequelize';
2
+ import type { $Config, $Include, $QueryParams, $Where } from './types';
3
+ import type { $Helpers } from './helpers';
4
+ export * from './types';
5
+ declare class DatabaseService<C extends $Config, MC extends {
6
+ Config: any;
7
+ Models: any;
8
+ Classes: any;
9
+ Shapes: any;
10
+ }> {
11
+ #private;
12
+ models: MC['Classes'];
13
+ helpers: $Helpers;
14
+ stack: Sequelize;
15
+ Op: object;
16
+ constructor({ database, dialect, host, logging, password, port, storage, username, }: C, modelShapes: MC['Shapes']);
17
+ setupTestEnvironment(): Promise<void>;
18
+ getOne<MN extends keyof MC['Config']>({ modelName, params, }: {
19
+ modelName: MN;
20
+ params: $QueryParams<MC['Config'], MC['Classes'], MN>;
21
+ }): Promise<MC['Models'][MN] | null>;
22
+ getFirst<MN extends keyof MC['Config']>({ modelName, params, }: {
23
+ modelName: MN;
24
+ params: $QueryParams<MC['Config'], MC['Classes'], MN>;
25
+ }): Promise<MC['Models'][MN] | null>;
26
+ getLast<MN extends keyof MC['Config']>({ modelName, params, }: {
27
+ modelName: MN;
28
+ params: $QueryParams<MC['Config'], MC['Classes'], MN>;
29
+ }): Promise<MC['Models'][MN] | null>;
30
+ getMany<MN extends keyof MC['Config']>({ modelName, params, }: {
31
+ modelName: MN;
32
+ params: $QueryParams<MC['Config'], MC['Classes'], MN>;
33
+ }): Promise<Array<MC['Models'][MN]>>;
34
+ createOne<MN extends keyof MC['Config']>({ modelName, params, }: {
35
+ modelName: MN;
36
+ params: MC['Config'][MN]['ModelCreateParams'];
37
+ }): Promise<MC['Models'][MN]>;
38
+ createBundle<MN extends keyof MC['Config']>({ include, modelName, params, }: {
39
+ modelName: MN;
40
+ params: MC['Config'][MN]['ModelCreateParams'];
41
+ include: $Include<MC['Config'], MC['Classes'], MN>;
42
+ }): Promise<MC['Models'][MN]>;
43
+ createMany<MN extends keyof MC['Config']>({ modelName, params, }: {
44
+ modelName: MN;
45
+ params: Array<MC['Config'][MN]['ModelCreateParams']>;
46
+ }): Promise<Array<MC['Models'][MN]>>;
47
+ upsertOne<MN extends keyof MC['Config']>({ modelName, params, where, }: {
48
+ modelName: MN;
49
+ params: MC['Config'][MN]['ModelUpsertParams'] | MC['Models'][MN];
50
+ where: $Where<MC['Config'], MN>;
51
+ }): Promise<MC['Models'][MN]>;
52
+ updateOne<MN extends keyof MC['Config']>({ modelName, params, }: {
53
+ modelName: MN;
54
+ params: MC['Config'][MN]['ModelUpdateParams'] | MC['Models'][MN];
55
+ }): Promise<MC['Models'][MN]>;
56
+ toggleOne<MN extends keyof MC['Config']>({ modelName, where, }: {
57
+ modelName: MN;
58
+ where: $Where<MC['Config'], MN>;
59
+ }): Promise<MC['Models'][MN]>;
60
+ deleteOne<MN extends keyof MC['Config']>({ modelName, params, }: {
61
+ modelName: MN;
62
+ params: $QueryParams<MC['Config'], MC['Classes'], MN>;
63
+ }): Promise<MC['Models'][MN]>;
64
+ deleteMany<MN extends keyof MC['Config']>({ modelName, params, }: {
65
+ modelName: MN;
66
+ params: $QueryParams<MC['Config'], MC['Classes'], MN>;
67
+ }): Promise<Array<MC['Models'][MN]>>;
68
+ sync<MN extends keyof MC['Config'], AM extends keyof MC['Config']>({ modelName, params: { associationModelId, associationModelName, items, }, }: {
69
+ modelName: MN;
70
+ params: {
71
+ items: Array<MC['Config'][MN]['ModelUpsertParams']>;
72
+ associationModelName: AM;
73
+ associationModelId: string;
74
+ };
75
+ }): Promise<{
76
+ createdItemIds: Array<string>;
77
+ deletedItemIds: Array<string>;
78
+ syncedItems: Array<MC['Models'][MN]>;
79
+ updatedItemIds: Array<string>;
80
+ }>;
81
+ addAssociation<MN extends keyof MC['Config'], AM extends keyof MC['Config']>({ modelName, params, }: {
82
+ modelName: MN;
83
+ params: {
84
+ id: string;
85
+ associationModelName: AM;
86
+ associationModelId: string;
87
+ pivot?: object;
88
+ };
89
+ }): Promise<MC['Models'][MN]>;
90
+ removeAssociation<MN extends keyof MC['Config'], AM extends keyof MC['Config']>({ modelName, params, }: {
91
+ modelName: MN;
92
+ params: {
93
+ id: string;
94
+ associationModelName: AM;
95
+ associationModelId: string;
96
+ pivot?: object;
97
+ };
98
+ }): Promise<boolean>;
99
+ syncAssociations<MN extends keyof MC['Config'], AM extends keyof MC['Config']>({ modelName, params: { associationModelIds, associationModelName, id, }, }: {
100
+ modelName: MN;
101
+ params: {
102
+ id: string;
103
+ associationModelName: AM;
104
+ associationModelIds: Array<string>;
105
+ };
106
+ }): Promise<{
107
+ addedAssociationModelIds: Array<string>;
108
+ removedAssociationModelIds: Array<string>;
109
+ }>;
110
+ }
111
+ export default DatabaseService;