@qrvey/data-persistence 0.0.2-4-rev-1 → 0.0.2-4-rev-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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAiE;AAAxD,4HAAA,OAAO,OAAe;AAC/B,mDAAkD;AAAzC,wGAAA,UAAU,OAAA;AAGnB,qDAAgF;AAAvE,0GAAA,WAAW,OAAA;AAAE,8GAAA,eAAe,OAAA;AAAE,wGAAA,SAAS,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAiE;AAAxD,4HAAA,OAAO,OAAe;AAC/B,mDAAkD;AAAzC,wGAAA,UAAU,OAAA;AAWnB,qDAAgF;AAAvE,0GAAA,WAAW,OAAA;AAAE,8GAAA,eAAe,OAAA;AAAE,wGAAA,SAAS,OAAA"}
@@ -1,5 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../utils/constants");
4
- const VALID_SORT_DIRECTIONS = Object.values(constants_1.SORT_DIRECTIONS);
5
3
  //# sourceMappingURL=sortDirection.type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sortDirection.type.js","sourceRoot":"","sources":["../../../src/types/sortDirection.type.ts"],"names":[],"mappings":";;AAAA,kDAAqD;AAErD,MAAM,qBAAqB,GAAsB,MAAM,CAAC,MAAM,CAAC,2BAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"sortDirection.type.js","sourceRoot":"","sources":["../../../src/types/sortDirection.type.ts"],"names":[],"mappings":""}
@@ -1,11 +1,25 @@
1
1
  import { default as default2 } from "./services/crud.service";
2
2
  import { CrudSchema } from "./schemas/crudSchema";
3
- import { IFindOptions } from "./interfaces";
3
+ import {
4
+ IFindOptions,
5
+ ISorting,
6
+ ICrudService,
7
+ IFilter,
8
+ IFindPagination
9
+ } from "./interfaces";
10
+ import { SortDirection, AggregateFunction, FilterInput } from "./types";
4
11
  import { buildFilter, buildQueryIndex, buildSort } from "./helpers/crudHelpers";
5
12
  export {
13
+ AggregateFunction,
6
14
  CrudSchema,
7
15
  default2 as CrudService,
16
+ FilterInput,
17
+ ICrudService,
18
+ IFilter,
8
19
  IFindOptions,
20
+ IFindPagination,
21
+ ISorting,
22
+ SortDirection,
9
23
  buildFilter,
10
24
  buildQueryIndex,
11
25
  buildSort
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { default as CrudService } from './services/crud.service';\nexport { CrudSchema } from './schemas/crudSchema';\nexport { IFindOptions } from './interfaces';\n\nexport { buildFilter, buildQueryIndex, buildSort } from './helpers/crudHelpers';\n"],"mappings":"AAAA,SAAoB,WAAXA,gBAA8B;AACvC,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAE7B,SAAS,aAAa,iBAAiB,iBAAiB;","names":["default"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { default as CrudService } from './services/crud.service';\nexport { CrudSchema } from './schemas/crudSchema';\nexport {\n IFindOptions,\n ISorting,\n ICrudService,\n IFilter,\n IFindPagination,\n} from './interfaces';\n\nexport { SortDirection, AggregateFunction, FilterInput } from './types';\n\nexport { buildFilter, buildQueryIndex, buildSort } from './helpers/crudHelpers';\n"],"mappings":"AAAA,SAAoB,WAAXA,gBAA8B;AACvC,SAAS,kBAAkB;AAC3B;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,eAAe,mBAAmB,mBAAmB;AAE9D,SAAS,aAAa,iBAAiB,iBAAiB;","names":["default"]}
@@ -38,6 +38,21 @@ interface IFindResult<T> {
38
38
  count: number;
39
39
  }
40
40
 
41
+ interface IUpdateOptions {
42
+ replace?: boolean;
43
+ }
44
+
45
+ interface ICrudService<T> {
46
+ create(entity: T): Promise<T>;
47
+ findItem(options?: IFindOptions): Promise<T | null>;
48
+ find(options?: IFindOptions): Promise<IFindResult<T>>;
49
+ findAll(options?: IFindOptions): Promise<IFindResult<T>>;
50
+ findCount(options?: IFindOptions): Promise<number>;
51
+ update(filters: IFilter[] | ICompoundFilter, data: Partial<T>, options?: IUpdateOptions): Promise<any | null>;
52
+ remove(filters: IFilter[] | ICompoundFilter): Promise<void>;
53
+ runQuery(queryCommand: any): Promise<any>;
54
+ }
55
+
41
56
  declare enum SORT_DIRECTIONS {
42
57
  ASC = "ASC",
43
58
  DESC = "DESC"
@@ -50,8 +65,7 @@ declare enum AGGREGATE_FUNCTIONS {
50
65
  COUNT = "COUNT"
51
66
  }
52
67
 
53
- declare const VALID_SORT_DIRECTIONS: SORT_DIRECTIONS[];
54
- type SortDirection = (typeof VALID_SORT_DIRECTIONS)[number];
68
+ type SortDirection = keyof typeof SORT_DIRECTIONS;
55
69
 
56
70
  interface ITableName {
57
71
  name: string;
@@ -66,6 +80,8 @@ interface ITableColumns {
66
80
  };
67
81
  }
68
82
 
83
+ type FilterInput = string | IFilter[] | ICompoundFilter[] | ICompoundFilter;
84
+
69
85
  declare const VALID_FILTER_LOGIC_OPERATORS: FILTER_LOGIC_OPERATORS[];
70
86
  type FilterLogicOperator = (typeof VALID_FILTER_LOGIC_OPERATORS)[number];
71
87
 
@@ -121,4 +137,4 @@ declare function buildQueryIndex(indexName: string, columns: string[]): {
121
137
  };
122
138
  declare function buildSort(column: string, direction?: SortDirection): ISorting;
123
139
 
124
- export { CrudSchema, CrudService, IFindOptions, buildFilter, buildQueryIndex, buildSort };
140
+ export { AggregateFunction, CrudSchema, CrudService, FilterInput, ICrudService, IFilter, IFindOptions, IFindPagination, ISorting, SortDirection, buildFilter, buildQueryIndex, buildSort };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@qrvey/data-persistence",
3
3
  "types": "dist/types/index.d.ts",
4
4
  "main": "dist/cjs/index.js",
5
- "version": "0.0.2-4-rev-1",
5
+ "version": "0.0.2-4-rev-3",
6
6
  "license": "MIT",
7
7
  "exports": {
8
8
  ".": {
@@ -30,10 +30,24 @@
30
30
  "publish-package": "yarn prepare-publish && npm publish"
31
31
  },
32
32
  "peerDependencies": {
33
- "@aws-sdk/client-dynamodb": "^3.433.0",
34
- "@aws-sdk/lib-dynamodb": "^3.433.0",
35
- "pg": "^8.11.4",
36
- "pg-format": "^1.0.4"
33
+ "@aws-sdk/client-dynamodb": "3.x",
34
+ "@aws-sdk/lib-dynamodb": "3.x",
35
+ "pg": "8.11.4",
36
+ "pg-format": "1.0.4"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "@aws-sdk/client-dynamodb": {
40
+ "optional": true
41
+ },
42
+ "@aws-sdk/lib-dynamodb": {
43
+ "optional": true
44
+ },
45
+ "pg": {
46
+ "optional": true
47
+ },
48
+ "pg-format": {
49
+ "optional": true
50
+ }
37
51
  },
38
52
  "devDependencies": {
39
53
  "@types/jest": "^29.5.5",