asv-hlps 1.4.55 → 1.4.57

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.
@@ -12,6 +12,7 @@ export default interface BillPayment {
12
12
  restAmount?: number;
13
13
  bill?: Bill;
14
14
  method?: BillPaymentMethod;
15
+ mode?: BillPaymentMethod;
15
16
  checkNumber?: string;
16
17
  checkDate?: string;
17
18
  bank?: Bank;
@@ -1,23 +1,13 @@
1
1
  import { SelectQueryBuilder } from "typeorm";
2
2
  import OpDate from "../shared/models/OpDate";
3
- import { IQueryPrms } from "./IQueryPrms";
4
- declare class QueryPrms {
5
- query: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, prms: IQueryPrms<T>, opts?: {
6
- qDate?: any;
7
- qMbrId?: string;
8
- qProductId?: string;
9
- qSaleId?: string;
10
- }) => void;
11
- opDate: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, opDate: OpDate, qDate?: string) => void;
12
- storeName: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, storeName: string) => void;
13
- cat: <T = any>(qb: SelectQueryBuilder<T>, prms: {
14
- cat: {
15
- id?: number;
16
- name?: string;
17
- code?: string;
18
- };
19
- }) => void;
20
- active: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, active: "true" | "false") => void;
3
+ export interface QueryPrms<T> {
4
+ id?: number;
5
+ sqb?: SelectQueryBuilder<T>;
6
+ opDate?: OpDate;
7
+ search?: string;
8
+ joker?: {
9
+ qId: string;
10
+ qProp: string | number | boolean;
11
+ };
12
+ only?: boolean;
21
13
  }
22
- declare const _default: QueryPrms;
23
- export default _default;
@@ -1,59 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("typeorm");
4
- const typeorm_2 = require("../npms/typeorm");
5
- class QueryPrms {
6
- constructor() {
7
- this.query = (qb, qStr, prms, opts) => {
8
- var _a, _b, _c;
9
- if (prms === null || prms === void 0 ? void 0 : prms.opDate) {
10
- (0, typeorm_2.tormDateParams)(qb, `${(opts === null || opts === void 0 ? void 0 : opts.qDate) || qStr + ".createdAt"}`, (_a = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _a === void 0 ? void 0 : _a.eDate, (_b = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _b === void 0 ? void 0 : _b.dates, (_c = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _c === void 0 ? void 0 : _c.datesBy);
11
- }
12
- if (prms === null || prms === void 0 ? void 0 : prms.joker) {
13
- qb.andWhere(`${prms.joker.qId} = :joker`, { joker: prms.joker["qProp"] });
14
- }
15
- if (prms === null || prms === void 0 ? void 0 : prms.search) {
16
- asyncSearch(qb, prms.search);
17
- }
18
- };
19
- this.opDate = (qb, qStr, opDate, qDate) => {
20
- if (opDate) {
21
- (0, typeorm_2.tormDateParams)(qb, `${qDate || qStr + ".createdAt"}`, opDate === null || opDate === void 0 ? void 0 : opDate.eDate, opDate === null || opDate === void 0 ? void 0 : opDate.dates, opDate === null || opDate === void 0 ? void 0 : opDate.datesBy);
22
- }
23
- };
24
- this.storeName = (qb, qStr, storeName) => {
25
- qb.andWhere(`${qStr}.store = :store`, { store: storeName });
26
- };
27
- this.cat = (qb, prms) => {
28
- var _a, _b, _c;
29
- if (prms === null || prms === void 0 ? void 0 : prms.cat) {
30
- if ((_a = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _a === void 0 ? void 0 : _a.code) {
31
- qb.andWhere("cat.code = :code", { code: prms.cat.code });
32
- }
33
- if ((_b = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _b === void 0 ? void 0 : _b.id) {
34
- qb.andWhere("cat.id = :id", { id: prms.cat.id });
35
- }
36
- if ((_c = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _c === void 0 ? void 0 : _c.name) {
37
- qb.andWhere("cat.name = :name", { id: prms.cat.name });
38
- }
39
- }
40
- };
41
- this.active = (qb, qStr, active) => {
42
- if (active) {
43
- if (active === "true") {
44
- qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: true });
45
- }
46
- if (active === "false") {
47
- qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: false });
48
- }
49
- }
50
- };
51
- }
52
- }
53
- const asyncSearch = (qb, search) => {
54
- qb.andWhere(new typeorm_1.Brackets((qb) => {
55
- qb.where("s.ref LIKE :ref", { ref: "%" + search + "%" });
56
- qb.orWhere("e.ref LIKE :entryRef", { entryRef: "%" + search + "%" });
57
- }));
58
- };
59
- exports.default = new QueryPrms();
@@ -1,13 +1,22 @@
1
1
  import { SelectQueryBuilder } from "typeorm";
2
2
  declare class HlpQuery {
3
3
  where: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
4
+ whereBool: <T = any>(qb: SelectQueryBuilder<T>, qKey: string, active: "true" | "false", qOn?: string) => void;
5
+ whereCat: <T = any>(qb: SelectQueryBuilder<T>, prms: {
6
+ cat: {
7
+ id?: number;
8
+ name?: string;
9
+ code?: string;
10
+ };
11
+ }) => void;
4
12
  whereIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
5
13
  whereNotIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
6
14
  opDate: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any) => void;
7
15
  join: <T = any>(qb: SelectQueryBuilder<T>, key: string, rStr: string, status?: "lj" | "ljs") => void;
8
16
  joker: <T = any>(qb: SelectQueryBuilder<T>, joker: {
9
- qId: string;
17
+ qKey: string;
10
18
  qProp: string | number;
19
+ qOn?: any;
11
20
  }) => void;
12
21
  }
13
22
  declare const _default: HlpQuery;
@@ -9,6 +9,31 @@ class HlpQuery {
9
9
  qb.andWhere(`${key} = :${qVar}`, { [qVar]: prm });
10
10
  }
11
11
  };
12
+ this.whereBool = (qb, qKey, active, qOn) => {
13
+ const qVar = !qOn ? qKey.substring(qKey.indexOf(".") + 1) : qOn;
14
+ if (active) {
15
+ if (active === "true") {
16
+ qb.andWhere(`${qKey} = :${qVar}`, { [qVar]: true });
17
+ }
18
+ if (active === "false") {
19
+ qb.andWhere(`${qKey} = :${qVar}`, { [qVar]: false });
20
+ }
21
+ }
22
+ };
23
+ this.whereCat = (qb, prms) => {
24
+ var _a, _b, _c;
25
+ if (prms === null || prms === void 0 ? void 0 : prms.cat) {
26
+ if ((_a = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _a === void 0 ? void 0 : _a.code) {
27
+ qb.andWhere("cat.code = :code", { code: prms.cat.code });
28
+ }
29
+ if ((_b = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _b === void 0 ? void 0 : _b.id) {
30
+ qb.andWhere("cat.id = :id", { id: prms.cat.id });
31
+ }
32
+ if ((_c = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _c === void 0 ? void 0 : _c.name) {
33
+ qb.andWhere("cat.name = :name", { id: prms.cat.name });
34
+ }
35
+ }
36
+ };
12
37
  this.whereIn = (qb, key, prm, qOn) => {
13
38
  const qVar = !qOn ? key.substring(key.indexOf(".") + 1) : qOn;
14
39
  if (prm) {
@@ -37,8 +62,9 @@ class HlpQuery {
37
62
  }
38
63
  };
39
64
  this.joker = (qb, joker) => {
65
+ const qVar = !(joker === null || joker === void 0 ? void 0 : joker.qOn) ? joker.qKey.substring(joker.qKey.indexOf(".") + 1) : joker === null || joker === void 0 ? void 0 : joker.qOn;
40
66
  if (joker) {
41
- qb.andWhere(`${joker.qId} = :joker`, { joker: joker["qProp"] });
67
+ qb.andWhere(`${joker.qKey} = :${qVar}`, { [qVar]: joker["qProp"] });
42
68
  }
43
69
  };
44
70
  }
@@ -1,3 +1,2 @@
1
- import QueryPrms from "./QueryPrms";
2
- export * from "./IQueryPrms";
1
+ import { QueryPrms } from "./QueryPrms";
3
2
  export { QueryPrms };
@@ -1,23 +1,2 @@
1
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 __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
2
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.QueryPrms = void 0;
21
- const QueryPrms_1 = __importDefault(require("./QueryPrms"));
22
- exports.QueryPrms = QueryPrms_1.default;
23
- __exportStar(require("./IQueryPrms"), exports);
package/lib/cjs/utils.js CHANGED
@@ -276,7 +276,7 @@ const removeBackSlashOccurences = (text, toChar) => {
276
276
  };
277
277
  exports.removeBackSlashOccurences = removeBackSlashOccurences;
278
278
  const removeAMPM = (ref) => {
279
- return ref.indexOf(" ") ? ref.substring(0, ref.indexOf(" ")).trim() : ref;
279
+ return (ref === null || ref === void 0 ? void 0 : ref.indexOf(" ")) ? ref.substring(0, ref.indexOf(" ")).trim() : ref;
280
280
  };
281
281
  exports.removeAMPM = removeAMPM;
282
282
  const refGenerator = (char = "c", regex = /\/+/gi, toChar = "") => {
@@ -12,6 +12,7 @@ export default interface BillPayment {
12
12
  restAmount?: number;
13
13
  bill?: Bill;
14
14
  method?: BillPaymentMethod;
15
+ mode?: BillPaymentMethod;
15
16
  checkNumber?: string;
16
17
  checkDate?: string;
17
18
  bank?: Bank;
@@ -1,23 +1,13 @@
1
1
  import { SelectQueryBuilder } from "typeorm";
2
2
  import OpDate from "../shared/models/OpDate";
3
- import { IQueryPrms } from "./IQueryPrms";
4
- declare class QueryPrms {
5
- query: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, prms: IQueryPrms<T>, opts?: {
6
- qDate?: any;
7
- qMbrId?: string;
8
- qProductId?: string;
9
- qSaleId?: string;
10
- }) => void;
11
- opDate: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, opDate: OpDate, qDate?: string) => void;
12
- storeName: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, storeName: string) => void;
13
- cat: <T = any>(qb: SelectQueryBuilder<T>, prms: {
14
- cat: {
15
- id?: number;
16
- name?: string;
17
- code?: string;
18
- };
19
- }) => void;
20
- active: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, active: "true" | "false") => void;
3
+ export interface QueryPrms<T> {
4
+ id?: number;
5
+ sqb?: SelectQueryBuilder<T>;
6
+ opDate?: OpDate;
7
+ search?: string;
8
+ joker?: {
9
+ qId: string;
10
+ qProp: string | number | boolean;
11
+ };
12
+ only?: boolean;
21
13
  }
22
- declare const _default: QueryPrms;
23
- export default _default;
@@ -1,57 +1 @@
1
- import { Brackets } from "typeorm";
2
- import { tormDateParams } from "../npms/typeorm";
3
- class QueryPrms {
4
- constructor() {
5
- this.query = (qb, qStr, prms, opts) => {
6
- var _a, _b, _c;
7
- if (prms === null || prms === void 0 ? void 0 : prms.opDate) {
8
- tormDateParams(qb, `${(opts === null || opts === void 0 ? void 0 : opts.qDate) || qStr + ".createdAt"}`, (_a = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _a === void 0 ? void 0 : _a.eDate, (_b = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _b === void 0 ? void 0 : _b.dates, (_c = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _c === void 0 ? void 0 : _c.datesBy);
9
- }
10
- if (prms === null || prms === void 0 ? void 0 : prms.joker) {
11
- qb.andWhere(`${prms.joker.qId} = :joker`, { joker: prms.joker["qProp"] });
12
- }
13
- if (prms === null || prms === void 0 ? void 0 : prms.search) {
14
- asyncSearch(qb, prms.search);
15
- }
16
- };
17
- this.opDate = (qb, qStr, opDate, qDate) => {
18
- if (opDate) {
19
- tormDateParams(qb, `${qDate || qStr + ".createdAt"}`, opDate === null || opDate === void 0 ? void 0 : opDate.eDate, opDate === null || opDate === void 0 ? void 0 : opDate.dates, opDate === null || opDate === void 0 ? void 0 : opDate.datesBy);
20
- }
21
- };
22
- this.storeName = (qb, qStr, storeName) => {
23
- qb.andWhere(`${qStr}.store = :store`, { store: storeName });
24
- };
25
- this.cat = (qb, prms) => {
26
- var _a, _b, _c;
27
- if (prms === null || prms === void 0 ? void 0 : prms.cat) {
28
- if ((_a = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _a === void 0 ? void 0 : _a.code) {
29
- qb.andWhere("cat.code = :code", { code: prms.cat.code });
30
- }
31
- if ((_b = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _b === void 0 ? void 0 : _b.id) {
32
- qb.andWhere("cat.id = :id", { id: prms.cat.id });
33
- }
34
- if ((_c = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _c === void 0 ? void 0 : _c.name) {
35
- qb.andWhere("cat.name = :name", { id: prms.cat.name });
36
- }
37
- }
38
- };
39
- this.active = (qb, qStr, active) => {
40
- if (active) {
41
- if (active === "true") {
42
- qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: true });
43
- }
44
- if (active === "false") {
45
- qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: false });
46
- }
47
- }
48
- };
49
- }
50
- }
51
- const asyncSearch = (qb, search) => {
52
- qb.andWhere(new Brackets((qb) => {
53
- qb.where("s.ref LIKE :ref", { ref: "%" + search + "%" });
54
- qb.orWhere("e.ref LIKE :entryRef", { entryRef: "%" + search + "%" });
55
- }));
56
- };
57
- export default new QueryPrms();
1
+ export {};
@@ -1,13 +1,22 @@
1
1
  import { SelectQueryBuilder } from "typeorm";
2
2
  declare class HlpQuery {
3
3
  where: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
4
+ whereBool: <T = any>(qb: SelectQueryBuilder<T>, qKey: string, active: "true" | "false", qOn?: string) => void;
5
+ whereCat: <T = any>(qb: SelectQueryBuilder<T>, prms: {
6
+ cat: {
7
+ id?: number;
8
+ name?: string;
9
+ code?: string;
10
+ };
11
+ }) => void;
4
12
  whereIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
5
13
  whereNotIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
6
14
  opDate: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any) => void;
7
15
  join: <T = any>(qb: SelectQueryBuilder<T>, key: string, rStr: string, status?: "lj" | "ljs") => void;
8
16
  joker: <T = any>(qb: SelectQueryBuilder<T>, joker: {
9
- qId: string;
17
+ qKey: string;
10
18
  qProp: string | number;
19
+ qOn?: any;
11
20
  }) => void;
12
21
  }
13
22
  declare const _default: HlpQuery;
@@ -7,6 +7,31 @@ class HlpQuery {
7
7
  qb.andWhere(`${key} = :${qVar}`, { [qVar]: prm });
8
8
  }
9
9
  };
10
+ this.whereBool = (qb, qKey, active, qOn) => {
11
+ const qVar = !qOn ? qKey.substring(qKey.indexOf(".") + 1) : qOn;
12
+ if (active) {
13
+ if (active === "true") {
14
+ qb.andWhere(`${qKey} = :${qVar}`, { [qVar]: true });
15
+ }
16
+ if (active === "false") {
17
+ qb.andWhere(`${qKey} = :${qVar}`, { [qVar]: false });
18
+ }
19
+ }
20
+ };
21
+ this.whereCat = (qb, prms) => {
22
+ var _a, _b, _c;
23
+ if (prms === null || prms === void 0 ? void 0 : prms.cat) {
24
+ if ((_a = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _a === void 0 ? void 0 : _a.code) {
25
+ qb.andWhere("cat.code = :code", { code: prms.cat.code });
26
+ }
27
+ if ((_b = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _b === void 0 ? void 0 : _b.id) {
28
+ qb.andWhere("cat.id = :id", { id: prms.cat.id });
29
+ }
30
+ if ((_c = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _c === void 0 ? void 0 : _c.name) {
31
+ qb.andWhere("cat.name = :name", { id: prms.cat.name });
32
+ }
33
+ }
34
+ };
10
35
  this.whereIn = (qb, key, prm, qOn) => {
11
36
  const qVar = !qOn ? key.substring(key.indexOf(".") + 1) : qOn;
12
37
  if (prm) {
@@ -35,8 +60,9 @@ class HlpQuery {
35
60
  }
36
61
  };
37
62
  this.joker = (qb, joker) => {
63
+ const qVar = !(joker === null || joker === void 0 ? void 0 : joker.qOn) ? joker.qKey.substring(joker.qKey.indexOf(".") + 1) : joker === null || joker === void 0 ? void 0 : joker.qOn;
38
64
  if (joker) {
39
- qb.andWhere(`${joker.qId} = :joker`, { joker: joker["qProp"] });
65
+ qb.andWhere(`${joker.qKey} = :${qVar}`, { [qVar]: joker["qProp"] });
40
66
  }
41
67
  };
42
68
  }
@@ -1,3 +1,2 @@
1
- import QueryPrms from "./QueryPrms";
2
- export * from "./IQueryPrms";
1
+ import { QueryPrms } from "./QueryPrms";
3
2
  export { QueryPrms };
@@ -1,3 +1 @@
1
- import QueryPrms from "./QueryPrms";
2
- export * from "./IQueryPrms";
3
- export { QueryPrms };
1
+ export {};
package/lib/esm/utils.js CHANGED
@@ -239,7 +239,7 @@ export const removeBackSlashOccurences = (text, toChar) => {
239
239
  return String(text).toLowerCase().replace(regex, toChar) || text;
240
240
  };
241
241
  export const removeAMPM = (ref) => {
242
- return ref.indexOf(" ") ? ref.substring(0, ref.indexOf(" ")).trim() : ref;
242
+ return (ref === null || ref === void 0 ? void 0 : ref.indexOf(" ")) ? ref.substring(0, ref.indexOf(" ")).trim() : ref;
243
243
  };
244
244
  export const refGenerator = (char = "c", regex = /\/+/gi, toChar = "") => {
245
245
  let date = new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.55",
3
+ "version": "1.4.57",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",