@sofiakb/fireblaze-ts 1.0.0-dev.9 → 2.0.0-dev.2

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 (52) hide show
  1. package/lib/commons/index.d.ts +1 -0
  2. package/lib/commons/index.js +14 -0
  3. package/lib/commons/index.js.map +1 -0
  4. package/lib/core/firebase-config.d.ts +7 -0
  5. package/lib/core/firebase-config.js +1 -1
  6. package/lib/core/firebase.d.ts +4 -4
  7. package/lib/core/firebase.js +9 -3
  8. package/lib/core/firebase.js.map +1 -1
  9. package/lib/core/firestore-repository.d.ts +324 -0
  10. package/lib/core/firestore-repository.js +660 -0
  11. package/lib/core/firestore-repository.js.map +1 -0
  12. package/lib/core/prepared-data.d.ts +27 -0
  13. package/lib/core/prepared-data.js +30 -0
  14. package/lib/core/prepared-data.js.map +1 -0
  15. package/lib/exceptions/empty-snapshot-exception.d.ts +3 -0
  16. package/lib/exceptions/empty-snapshot-exception.js +17 -0
  17. package/lib/exceptions/empty-snapshot-exception.js.map +1 -0
  18. package/lib/exceptions/no-document-found-exception.d.ts +11 -0
  19. package/lib/exceptions/no-document-found-exception.js +25 -0
  20. package/lib/exceptions/no-document-found-exception.js.map +1 -0
  21. package/lib/exceptions/no-firebase-instance-exception.js +3 -3
  22. package/lib/exceptions/no-firestore-instance-exception.d.ts +3 -0
  23. package/lib/exceptions/no-firestore-instance-exception.js +17 -0
  24. package/lib/exceptions/no-firestore-instance-exception.js.map +1 -0
  25. package/lib/exceptions/unique-constraint-exception.d.ts +11 -0
  26. package/lib/exceptions/unique-constraint-exception.js +25 -0
  27. package/lib/exceptions/unique-constraint-exception.js.map +1 -0
  28. package/lib/index.d.ts +4 -4
  29. package/lib/index.js +4 -4
  30. package/lib/index.js.map +1 -1
  31. package/lib/types/class-constructor.js +1 -1
  32. package/lib/types/nullable.d.ts +1 -1
  33. package/lib/types/nullable.js +1 -1
  34. package/lib/utils/date.d.ts +12 -1
  35. package/lib/utils/date.js +27 -14
  36. package/lib/utils/date.js.map +1 -1
  37. package/lib/utils/ignored-keys.d.ts +2 -0
  38. package/lib/utils/ignored-keys.js +12 -0
  39. package/lib/utils/ignored-keys.js.map +1 -0
  40. package/lib/utils/index.d.ts +0 -1
  41. package/lib/utils/index.js +4 -6
  42. package/lib/utils/index.js.map +1 -1
  43. package/lib/utils/paginated-data.d.ts +35 -0
  44. package/lib/utils/paginated-data.js +49 -0
  45. package/lib/utils/paginated-data.js.map +1 -0
  46. package/lib/utils/to-json.d.ts +1 -0
  47. package/lib/utils/to-json.js +35 -0
  48. package/lib/utils/to-json.js.map +1 -0
  49. package/package.json +26 -24
  50. package/lib/core/firebase-repository.d.ts +0 -60
  51. package/lib/core/firebase-repository.js +0 -316
  52. package/lib/core/firebase-repository.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ import { DocumentReference } from "firebase/firestore";
2
+ interface PreparedDataProperties {
3
+ documentReference: DocumentReference;
4
+ data: any;
5
+ }
6
+ /**
7
+ * @class PreparedData
8
+ */
9
+ export default class PreparedData {
10
+ documentReference: DocumentReference;
11
+ data: any;
12
+ /**
13
+ * @constructor PreparedData
14
+ *
15
+ * @param {PreparedDataProperties} properties
16
+ */
17
+ constructor(properties: PreparedDataProperties);
18
+ /**
19
+ * @method create
20
+ *
21
+ * @param {PreparedDataProperties} properties
22
+ *
23
+ * @return {PreparedData}
24
+ */
25
+ static create(properties: PreparedDataProperties): PreparedData;
26
+ }
27
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * @class PreparedData
5
+ */
6
+ class PreparedData {
7
+ documentReference;
8
+ data;
9
+ /**
10
+ * @constructor PreparedData
11
+ *
12
+ * @param {PreparedDataProperties} properties
13
+ */
14
+ constructor(properties) {
15
+ this.data = properties.data;
16
+ this.documentReference = properties.documentReference;
17
+ }
18
+ /**
19
+ * @method create
20
+ *
21
+ * @param {PreparedDataProperties} properties
22
+ *
23
+ * @return {PreparedData}
24
+ */
25
+ static create(properties) {
26
+ return new PreparedData(properties);
27
+ }
28
+ }
29
+ exports.default = PreparedData;
30
+ //# sourceMappingURL=prepared-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepared-data.js","sourceRoot":"","sources":["../../src/core/prepared-data.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAkCb;;GAEG;AACH,MAAqB,YAAY;IAChC,iBAAiB,CAAoB;IACrC,IAAI,CAAM;IAEV;;;;OAIG;IACH,YAAY,UAAkC;QAC7C,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,iBAAiB,CAAC;IACvD,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,UAAkC;QAC/C,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;CACD;AAxBD,+BAwBC"}
@@ -0,0 +1,3 @@
1
+ export default class EmptySnapshotException extends Error {
2
+ constructor(message?: string);
3
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * @sofiakb/fireblaze-ts
5
+ *
6
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
7
+ *
8
+ * Created by WebStorm on 21/09/2022 at 14:27
9
+ * File src/exceptions/empty-snapshot-exception
10
+ */
11
+ class EmptySnapshotException extends Error {
12
+ constructor(message = "Error: Snapshot query empty. (Method [get])") {
13
+ super(message);
14
+ }
15
+ }
16
+ exports.default = EmptySnapshotException;
17
+ //# sourceMappingURL=empty-snapshot-exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-snapshot-exception.js","sourceRoot":"","sources":["../../src/exceptions/empty-snapshot-exception.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;GAOG;AAEH,MAAqB,sBAAuB,SAAQ,KAAK;IACxD,YAAY,OAAO,GAAG,6CAA6C;QAClE,KAAK,CAAC,OAAO,CAAC,CAAC;IAChB,CAAC;CACD;AAJD,yCAIC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @class NoDocumentFoundException
3
+ */
4
+ export default class NoDocumentFoundException extends Error {
5
+ /**
6
+ * @constructor NoDocumentFound
7
+ *
8
+ * @param {string?} message
9
+ */
10
+ constructor(message?: string);
11
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * cloud-functions
5
+ *
6
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
7
+ *
8
+ * Created by WebStorm on 03/01/2023 at 13:41
9
+ * File functions/src/firebase/exceptions/no-document-found-exception
10
+ */
11
+ /**
12
+ * @class NoDocumentFoundException
13
+ */
14
+ class NoDocumentFoundException extends Error {
15
+ /**
16
+ * @constructor NoDocumentFound
17
+ *
18
+ * @param {string?} message
19
+ */
20
+ constructor(message = "No document found") {
21
+ super(message);
22
+ }
23
+ }
24
+ exports.default = NoDocumentFoundException;
25
+ //# sourceMappingURL=no-document-found-exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-document-found-exception.js","sourceRoot":"","sources":["../../src/exceptions/no-document-found-exception.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAqB,wBAAyB,SAAQ,KAAK;IAC1D;;;;OAIG;IACH,YAAY,OAAO,GAAG,mBAAmB;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChB,CAAC;CACD;AATD,2CASC"}
@@ -1,15 +1,15 @@
1
- 'use strict';
1
+ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /*
4
4
  * @sofiakb/fireblaze-ts
5
5
  *
6
- * (c) Sofiane Akbly <sofiane.akbly@digi-service.fr>
6
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
7
7
  *
8
8
  * Created by WebStorm on 21/09/2022 at 14:27
9
9
  * File src/exceptions/no-firebase-instance-exception
10
10
  */
11
11
  class NoFirebaseInstanceException extends Error {
12
- constructor(message = 'No firebase instance found') {
12
+ constructor(message = "No firebase instance found") {
13
13
  super(message);
14
14
  }
15
15
  }
@@ -0,0 +1,3 @@
1
+ export default class NoFirestoreInstanceException extends Error {
2
+ constructor(message?: string);
3
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * @sofiakb/fireblaze-ts
5
+ *
6
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
7
+ *
8
+ * Created by WebStorm on 21/09/2022 at 14:27
9
+ * File src/exceptions/no-firestore-instance-exception
10
+ */
11
+ class NoFirestoreInstanceException extends Error {
12
+ constructor(message = "No firestore instance found") {
13
+ super(message);
14
+ }
15
+ }
16
+ exports.default = NoFirestoreInstanceException;
17
+ //# sourceMappingURL=no-firestore-instance-exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-firestore-instance-exception.js","sourceRoot":"","sources":["../../src/exceptions/no-firestore-instance-exception.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;GAOG;AAEH,MAAqB,4BAA6B,SAAQ,KAAK;IAC9D,YAAY,OAAO,GAAG,6BAA6B;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;IAChB,CAAC;CACD;AAJD,+CAIC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @class UniqueConstraintException
3
+ */
4
+ export default class UniqueConstraintException extends Error {
5
+ /**
6
+ * @constructor UniqueConstraint
7
+ *
8
+ */
9
+ constructor();
10
+ static code: string;
11
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * cloud-functions
5
+ *
6
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
7
+ *
8
+ * Created by WebStorm on 03/01/2023 at 13:41
9
+ * File functions/src/firebase/exceptions/unique-constraint-exception
10
+ */
11
+ /**
12
+ * @class UniqueConstraintException
13
+ */
14
+ class UniqueConstraintException extends Error {
15
+ /**
16
+ * @constructor UniqueConstraint
17
+ *
18
+ */
19
+ constructor() {
20
+ super(UniqueConstraintException.code);
21
+ }
22
+ static code = "unique-constraint";
23
+ }
24
+ exports.default = UniqueConstraintException;
25
+ //# sourceMappingURL=unique-constraint-exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unique-constraint-exception.js","sourceRoot":"","sources":["../../src/exceptions/unique-constraint-exception.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAqB,yBAA0B,SAAQ,KAAK;IAC3D;;;OAGG;IACH;QACC,KAAK,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAC;;kBATd,yBAAyB"}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { default as Firebase } from './core/firebase';
2
- export { default as FirebaseConfig } from './core/firebase-config';
3
- export { default as FirebaseRepository } from './core/firebase-repository';
4
- export { default as NoFirebaseInstanceException } from './exceptions/no-firebase-instance-exception';
1
+ export { default as Firebase } from "./core/firebase";
2
+ export { default as FirebaseConfig } from "./core/firebase-config";
3
+ export { default as FirestoreRepository, FirestoreRepositoryAttributes } from "./core/firestore-repository";
4
+ export { default as NoFirebaseInstanceException } from "./exceptions/no-firebase-instance-exception";
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- 'use strict';
1
+ "use strict";
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NoFirebaseInstanceException = exports.FirebaseRepository = exports.Firebase = void 0;
6
+ exports.NoFirebaseInstanceException = exports.FirestoreRepository = exports.Firebase = void 0;
7
7
  /*
8
8
  * @sofiakb/fireblaze-ts
9
9
  *
@@ -14,8 +14,8 @@ exports.NoFirebaseInstanceException = exports.FirebaseRepository = exports.Fireb
14
14
  */
15
15
  var firebase_1 = require("./core/firebase");
16
16
  Object.defineProperty(exports, "Firebase", { enumerable: true, get: function () { return __importDefault(firebase_1).default; } });
17
- var firebase_repository_1 = require("./core/firebase-repository");
18
- Object.defineProperty(exports, "FirebaseRepository", { enumerable: true, get: function () { return __importDefault(firebase_repository_1).default; } });
17
+ var firestore_repository_1 = require("./core/firestore-repository");
18
+ Object.defineProperty(exports, "FirestoreRepository", { enumerable: true, get: function () { return __importDefault(firestore_repository_1).default; } });
19
19
  var no_firebase_instance_exception_1 = require("./exceptions/no-firebase-instance-exception");
20
20
  Object.defineProperty(exports, "NoFirebaseInstanceException", { enumerable: true, get: function () { return __importDefault(no_firebase_instance_exception_1).default; } });
21
21
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;;GAOG;AAEH,4CAAsD;AAA7C,qHAAA,OAAO,OAAY;AAE5B,kEAA2E;AAAlE,0IAAA,OAAO,OAAsB;AACtC,8FAAqG;AAA5F,8JAAA,OAAO,OAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;;GAOG;AAEH,4CAAsD;AAA7C,qHAAA,OAAO,OAAY;AAE5B,oEAA4G;AAAnG,4IAAA,OAAO,OAAuB;AACvC,8FAAqG;AAA5F,8JAAA,OAAO,OAA+B"}
@@ -1,3 +1,3 @@
1
- 'use strict';
1
+ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=class-constructor.js.map
@@ -1,2 +1,2 @@
1
- declare type Nullable<T> = T | null;
1
+ type Nullable<T> = T | null;
2
2
  export default Nullable;
@@ -1,3 +1,3 @@
1
- 'use strict';
1
+ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=nullable.js.map
@@ -1 +1,12 @@
1
- export declare const toMoment: (value: any) => any;
1
+ /**
2
+ * @class DateJs
3
+ */
4
+ export default class DateJs {
5
+ /**
6
+ * @method toMoment
7
+ * @param {any} value
8
+ *
9
+ * @return {any}
10
+ */
11
+ static toMoment(value: any): any;
12
+ }
package/lib/utils/date.js CHANGED
@@ -1,24 +1,37 @@
1
- 'use strict';
1
+ "use strict";
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.toMoment = void 0;
7
6
  /*
8
- * @sofiakb/fireblaze-ts
7
+ * cloud-functions
9
8
  *
10
- * (c) Sofiane Akbly <sofiane.akbly@digi-service.fr>
9
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
11
10
  *
12
- * Created by WebStorm on 21/09/2022 at 14:20
13
- * File src/utils/date
11
+ * Created by WebStorm on 31/12/2022 at 18:15
12
+ * File functions/src/date
14
13
  */
15
14
  const moment_1 = __importDefault(require("moment"));
16
- const toMoment = (value) => typeof value !== 'undefined' && value !== null
17
- ? value?.constructor?.name?.toLowerCase() === 'moment'
18
- ? value
19
- : value?.constructor?.name?.toLowerCase() === 'date'
20
- ? (0, moment_1.default)(value?.toLocaleDateString('fr') + ' ' + value?.toLocaleTimeString('fr'), 'DD/MM/YYYY HH:mm:ss')
21
- : moment_1.default.unix(value?._seconds ?? value?.seconds ?? null)
22
- : value;
23
- exports.toMoment = toMoment;
15
+ const commons_1 = require("../commons");
16
+ /**
17
+ * @class DateJs
18
+ */
19
+ class DateJs {
20
+ /**
21
+ * @method toMoment
22
+ * @param {any} value
23
+ *
24
+ * @return {any}
25
+ */
26
+ static toMoment(value) {
27
+ return (0, commons_1.defined)(value)
28
+ ? value?.constructor?.name?.toLowerCase() === "moment"
29
+ ? value
30
+ : value?.constructor?.name?.toLowerCase() === "date"
31
+ ? (0, moment_1.default)(value?.toLocaleDateString("fr") + " " + value?.toLocaleTimeString("fr"), "DD/MM/YYYY HH:mm:ss")
32
+ : moment_1.default.unix(value?._seconds ?? value?.seconds ?? null)
33
+ : value;
34
+ }
35
+ }
36
+ exports.default = DateJs;
24
37
  //# sourceMappingURL=date.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;;GAOG;AAEH,oDAA4B;AAErB,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE,CACtC,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI;IAC7C,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,QAAQ;QACrD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,MAAM;YACpD,CAAC,CAAC,IAAA,gBAAM,EAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,KAAK,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC;YACxG,CAAC,CAAC,gBAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,IAAI,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC;IACzD,CAAC,CAAC,KAAK,CAAC;AAPG,QAAA,QAAQ,YAOX"}
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb;;;;;;;GAOG;AAEH,oDAA4B;AAE5B,wCAAqC;AAErC;;GAEG;AACH,MAAqB,MAAM;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAU;QACzB,OAAO,IAAA,iBAAO,EAAC,KAAK,CAAC;YACpB,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,QAAQ;gBACrD,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,MAAM;oBACnD,CAAC,CAAC,IAAA,gBAAM,EACN,KAAK,EAAE,kBAAkB,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,KAAK,EAAE,kBAAkB,CAAC,IAAI,CAAC,EACvE,qBAAqB,CACrB;oBACF,CAAC,CAAC,gBAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,IAAI,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC;YAC1D,CAAC,CAAC,KAAK,CAAC;IACV,CAAC;CACD;AAnBD,yBAmBC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * @sofiakb_fireblaze-node-ts
5
+ *
6
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
7
+ *
8
+ * Created by WebStorm on 08/06/2023 at 14:21
9
+ * File src/utils/ignored-keys
10
+ */
11
+ exports.default = ["GeoPoint", "Moment", "string", "number"];
12
+ //# sourceMappingURL=ignored-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignored-keys.js","sourceRoot":"","sources":["../../src/utils/ignored-keys.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;GAOG;AAEH,kBAAe,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC"}
@@ -3,5 +3,4 @@ interface Base64Interface {
3
3
  decode(data: string): string;
4
4
  }
5
5
  export declare const base64: Base64Interface;
6
- export declare const toJSON: (object: any) => any;
7
6
  export {};
@@ -1,10 +1,8 @@
1
- 'use strict';
1
+ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toJSON = exports.base64 = void 0;
3
+ exports.base64 = void 0;
4
4
  exports.base64 = {
5
- encode: (data) => Buffer.from(data).toString('base64'),
6
- decode: (data) => Buffer.from(data, 'base64').toString('ascii'),
5
+ encode: (data) => Buffer.from(data).toString("base64"),
6
+ decode: (data) => Buffer.from(data, "base64").toString("ascii"),
7
7
  };
8
- const toJSON = (object) => JSON.parse(JSON.stringify({ ...object }));
9
- exports.toJSON = toJSON;
10
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAiBA,QAAA,MAAM,GAAoB;IACtC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC9D,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;CACvE,CAAC;AAEK,MAAM,MAAM,GAAG,CAAC,MAAW,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;AAApE,QAAA,MAAM,UAA8D"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAiBA,QAAA,MAAM,GAAoB;IACtC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC9D,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;CACvE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import Nullable from "@src/types/nullable";
2
+ interface PaginatedDataProperties {
3
+ page: number;
4
+ data: Nullable<any[]>;
5
+ limit: number;
6
+ count?: number;
7
+ }
8
+ /**
9
+ * @class PaginatedData
10
+ */
11
+ export default class PaginatedData {
12
+ page: number;
13
+ data: Nullable<any[]>;
14
+ first: number;
15
+ latest: number;
16
+ per: number;
17
+ prev: Nullable<number>;
18
+ next: Nullable<number>;
19
+ total: number;
20
+ /**
21
+ * @constructor PaginatedData
22
+ *
23
+ * @param {PaginatedDataProperties} properties
24
+ */
25
+ constructor({ data, page, limit, count }: PaginatedDataProperties);
26
+ /**
27
+ * @method create
28
+ *
29
+ * @param {PaginatedDataProperties} properties
30
+ *
31
+ * @return {PaginatedData}
32
+ */
33
+ static create(properties: PaginatedDataProperties): PaginatedData;
34
+ }
35
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * @class PaginatedData
5
+ */
6
+ class PaginatedData {
7
+ page;
8
+ data;
9
+ first;
10
+ latest;
11
+ per;
12
+ prev;
13
+ next;
14
+ total;
15
+ /**
16
+ * @constructor PaginatedData
17
+ *
18
+ * @param {PaginatedDataProperties} properties
19
+ */
20
+ constructor({ data, page, limit, count }) {
21
+ page = parseInt(page.toString());
22
+ if (page === 0)
23
+ page = 1;
24
+ // page = Math.max(page - 1, 0)
25
+ limit = parseInt(limit.toString());
26
+ const total = count ?? data?.length ?? 0;
27
+ const latest = Math.ceil(total / limit);
28
+ this.page = page;
29
+ this.data = data;
30
+ this.first = 0;
31
+ this.latest = latest;
32
+ this.per = limit;
33
+ this.prev = page <= 1 ? null : page - 1;
34
+ this.next = page >= latest ? null : page + 1;
35
+ this.total = total;
36
+ }
37
+ /**
38
+ * @method create
39
+ *
40
+ * @param {PaginatedDataProperties} properties
41
+ *
42
+ * @return {PaginatedData}
43
+ */
44
+ static create(properties) {
45
+ return new PaginatedData(properties);
46
+ }
47
+ }
48
+ exports.default = PaginatedData;
49
+ //# sourceMappingURL=paginated-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginated-data.js","sourceRoot":"","sources":["../../src/utils/paginated-data.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAoBb;;GAEG;AACH,MAAqB,aAAa;IACjC,IAAI,CAAS;IACb,IAAI,CAAkB;IACtB,KAAK,CAAS;IACd,MAAM,CAAS;IACf,GAAG,CAAS;IACZ,IAAI,CAAmB;IACvB,IAAI,CAAmB;IACvB,KAAK,CAAS;IAEd;;;;OAIG;IACH,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAA2B;QAChE,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjC,IAAI,IAAI,KAAK,CAAC;YAAE,IAAI,GAAG,CAAC,CAAC;QACzB,+BAA+B;QAE/B,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEnC,MAAM,KAAK,GAAG,KAAK,IAAI,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;QAExC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,UAAmC;QAChD,OAAO,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACD;AA7CD,gCA6CC"}
@@ -0,0 +1 @@
1
+ export declare const toJSON: (object: any) => any;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.toJSON = void 0;
7
+ /*
8
+ * cloud-functions
9
+ *
10
+ * (c) Sofiakb <contact.sofiakb@gmail.com>
11
+ *
12
+ * Created by WebStorm on 04/01/2023 at 11:43
13
+ * File functions/src/utils/to-json
14
+ */
15
+ const ignored_keys_1 = __importDefault(require("./ignored-keys"));
16
+ const toJSON = (object) => {
17
+ if (Array.isArray(object)) {
18
+ return object.map((item) => typeof item === "object" && !ignored_keys_1.default.includes(item?.constructor?.name) ? (0, exports.toJSON)(item) : item);
19
+ }
20
+ const keys = Object.keys(object);
21
+ const object2 = {};
22
+ keys.map((key) => {
23
+ if (typeof object[key] === "object" && !!object[key]) {
24
+ return (object2[key] = !ignored_keys_1.default.includes(object[key]?.constructor?.name)
25
+ ? (0, exports.toJSON)(object[key])
26
+ : object[key]);
27
+ }
28
+ else {
29
+ object2[key] = object[key];
30
+ }
31
+ });
32
+ return { ...JSON.parse(JSON.stringify({ ...object })), ...object2 };
33
+ };
34
+ exports.toJSON = toJSON;
35
+ //# sourceMappingURL=to-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-json.js","sourceRoot":"","sources":["../../src/utils/to-json.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;;GAOG;AAEH,kEAAyC;AAElC,MAAM,MAAM,GAAG,CAAC,MAAW,EAAO,EAAE;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC1B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC1B,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,sBAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAChG,CAAC;KACF;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,MAAM,OAAO,GAAQ,EAAE,CAAC;IAExB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAChB,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACrD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,sBAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC;gBAC3E,CAAC,CAAC,IAAA,cAAM,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;SAChB;aAAM;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;SAC3B;IACF,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;AACrE,CAAC,CAAC;AArBW,QAAA,MAAM,UAqBjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sofiakb/fireblaze-ts",
3
- "version": "1.0.0-dev.9",
3
+ "version": "2.0.0-dev.2",
4
4
  "description": "A typescript library for axios API calls.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -30,30 +30,32 @@
30
30
  },
31
31
  "homepage": "https://github.com/sofiakb/fireblaze-ts#readme",
32
32
  "devDependencies": {
33
- "@babel/core": "^7.19.1",
34
- "@babel/preset-env": "^7.19.1",
35
- "@babel/preset-typescript": "^7.18.6",
33
+ "@babel/core": "^7.23.9",
34
+ "@babel/preset-env": "^7.23.9",
35
+ "@babel/preset-typescript": "^7.23.3",
36
36
  "@sofiakb/local-storage": "1.0.0-alpha.3",
37
- "@types/jest": "^29.0.3",
38
- "@types/jquery": "^3.5.14",
39
- "@types/lodash": "^4.14.185",
40
- "@types/node": "^18.7.18",
41
- "@typescript-eslint/eslint-plugin": "^5.38.0",
42
- "@typescript-eslint/parser": "^5.38.0",
43
- "babel-jest": "^28.1.3",
37
+ "@types/jest": "^29.5.11",
38
+ "@types/jquery": "^3.5.29",
39
+ "@types/lodash": "^4.14.202",
40
+ "@types/node": "^20.11.7",
41
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
42
+ "@typescript-eslint/parser": "^6.19.1",
43
+ "babel-jest": "^29.7.0",
44
44
  "buffer": "^6.0.3",
45
- "eslint": "^8.22.0",
46
- "eslint-config-prettier": "^8.5.0",
47
- "eslint-plugin-prettier": "^4.2.1",
48
- "firebase": "^9.10.0",
49
- "jest": "^28.1.3",
50
- "jquery": "^3.6.1",
45
+ "eslint": "^8.56.0",
46
+ "eslint-config-google": "^0.14.0",
47
+ "eslint-config-prettier": "^9.1.0",
48
+ "eslint-plugin-import": "^2.29.1",
49
+ "eslint-plugin-prettier": "^5.1.3",
50
+ "firebase": "^10.7.2",
51
+ "jest": "^29.7.0",
52
+ "jquery": "^3.7.1",
51
53
  "lodash": "^4.17.21",
52
- "moment": "^2.29.4",
53
- "prettier": "^2.7.1",
54
- "ts-jest": "^28.0.8",
55
- "ts-node": "^10.9.1",
56
- "typescript": "^4.8.3"
54
+ "moment": "^2.30.1",
55
+ "prettier": "^3.2.4",
56
+ "ts-jest": "^29.1.2",
57
+ "ts-node": "^10.9.2",
58
+ "typescript": "5.0.4"
57
59
  },
58
60
  "files": [
59
61
  "lib/**/*"
@@ -61,8 +63,8 @@
61
63
  "peerDependencies": {
62
64
  "@sofiakb/local-storage": "1.0.0-alpha.3",
63
65
  "buffer": "^6.0.3",
64
- "firebase": "^9.10.0",
65
- "jquery": "^3.6.1",
66
+ "firebase": "^10.7.2",
67
+ "jquery": "^3.7.1",
66
68
  "moment": "^2.29.4"
67
69
  }
68
70
  }