my-q-format-response-aws-lambda 1.0.59 → 1.0.61

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 (3) hide show
  1. package/index.js +7 -6
  2. package/index.ts +20 -14
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -430,12 +430,13 @@ exports.normaliseMongoFilter = normaliseMongoFilter;
430
430
  * @param filter
431
431
  */
432
432
  const normaliseMongoPaginate = (filter) => {
433
- let res = {
434
- skip: 0,
435
- limit: 50,
436
- };
437
- res.skip = filter && filter.skip ? parseInt(filter.skip, 10) || 0 : 0;
438
- res.limit = filter && filter.limit ? parseInt(filter.limit, 10) || 50 : 50;
433
+ let res = {};
434
+ if (filter.hasOwnProperty('limit') && filter.hasOwnProperty('skip')) {
435
+ res = {
436
+ skip: filter.skip ? parseInt(filter.skip, 10) : 0,
437
+ limit: filter.limit ? parseInt(filter.limit, 10) : 50,
438
+ };
439
+ }
439
440
  return res;
440
441
  };
441
442
  exports.normaliseMongoPaginate = normaliseMongoPaginate;
package/index.ts CHANGED
@@ -600,10 +600,12 @@ export const normaliseMongoFilter = (
600
600
  return _filter
601
601
  }
602
602
 
603
- export interface TMongoPaginate {
604
- skip: number
605
- limit: number
606
- }
603
+ export type TMongoPaginate =
604
+ | {
605
+ skip: number
606
+ limit: number
607
+ }
608
+ | {}
607
609
 
608
610
  export type TFieldsGQL =
609
611
  | 'create'
@@ -629,13 +631,14 @@ export type TFieldsGQL =
629
631
  * @param filter
630
632
  */
631
633
  export const normaliseMongoPaginate = (filter: TMongoFilterNormalise): TMongoPaginate => {
632
- let res: TMongoPaginate = {
633
- skip: 0,
634
- limit: 50,
635
- }
634
+ let res: TMongoPaginate = {}
636
635
 
637
- res.skip = filter && filter.skip ? parseInt(filter.skip, 10) || 0 : 0
638
- res.limit = filter && filter.limit ? parseInt(filter.limit, 10) || 50 : 50
636
+ if (filter.hasOwnProperty('limit') && filter.hasOwnProperty('skip')) {
637
+ res = {
638
+ skip: filter.skip ? parseInt(filter.skip, 10) : 0,
639
+ limit: filter.limit ? parseInt(filter.limit, 10) : 50,
640
+ }
641
+ }
639
642
 
640
643
  return res
641
644
  }
@@ -733,6 +736,9 @@ export const parseMessageResponse = (message: string, separator: string = '__'):
733
736
  // ********************** ENTITY INPUT TYPES *************************************
734
737
  // **************************************************************************************
735
738
 
739
+ type TID = string
740
+ type TIDs = string[]
741
+
736
742
  // CREATE
737
743
  export interface TEntityInputCreate<M> {
738
744
  values: M
@@ -748,23 +754,23 @@ export interface TEntityInputGetList<F, S> {
748
754
 
749
755
  // ONE BY ID
750
756
  export interface TEntityInputOneByID {
751
- id: string
757
+ id: TID
752
758
  }
753
759
 
754
760
  // MANY BY IDs
755
761
  export interface TEntityInputManyByIDs {
756
- ids: string[]
762
+ ids: TIDs
757
763
  }
758
764
 
759
765
  // VALUES ONE BY ID
760
766
  export interface TEntityInputValuesOneByID<M> {
761
- id: string
767
+ id: TID
762
768
  values: M
763
769
  }
764
770
 
765
771
  // VALUES MANY BY IDs
766
772
  export interface TEntityInputValuesManyByIDs<M> {
767
- ids: string[]
773
+ ids: TIDs
768
774
  values: M
769
775
  }
770
776
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-q-format-response-aws-lambda",
3
- "version": "1.0.59",
3
+ "version": "1.0.61",
4
4
  "homepage": "https://github.com/zhukyuri/my-q-format-response-aws-lambda",
5
5
  "description": "my-q-format-response-aws-lambda",
6
6
  "main": "index.js",