@adtrackify/at-service-common 1.0.72 → 1.0.74

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,39 +1,39 @@
1
- import { createHmac } from 'crypto';
2
- import * as log from 'lambda-log';
3
- import { HttpError } from '../libs';
4
- import { mapObjectToQueryString } from '../libs/url';
5
- export interface ShopifyRequestValidationParameters {
6
- code: string,
7
- hmac?: string,
8
- shop: string,
9
- state: string,
10
- timestamp: string;
11
- }
12
-
13
- export const isShopifyRequestValid = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string): boolean => {
14
- // remove hmac if it exists
15
- // map input to query string
16
- // generate hash using api secret key and validate it matches hmac
17
- delete validationParams.hmac;
18
- const hmacString = mapObjectToQueryString(validationParams);
19
-
20
-
21
- const generatedHash = createHmac('sha256', shopifyAppApiSecret)
22
- .update(hmacString)
23
- .digest('hex');
24
-
25
- return generatedHash === validationHmac;
26
- };
27
-
28
- export const validateShopifyRequest = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => {
29
- log.info('Validating shopify request is authentic', { validationParams });
30
- const isValid = isShopifyRequestValid(validationParams, validationHmac as string, shopifyAppApiSecret);
31
- if (!isValid) {
32
- const message = 'Failed: Shopify Request hmac validation';
33
- log.error(message);
34
- throw HttpError.badRequest(message);
35
- }
36
- log.info('Sucess: Shopify Request hmac validation');
37
- return true;
38
- }
39
-
1
+ import { createHmac } from 'crypto';
2
+ import * as log from 'lambda-log';
3
+ import { HttpError } from '../libs';
4
+ import { mapObjectToQueryString } from '../libs/url';
5
+ export interface ShopifyRequestValidationParameters {
6
+ code: string,
7
+ hmac?: string,
8
+ shop: string,
9
+ state: string,
10
+ timestamp: string;
11
+ }
12
+
13
+ export const isShopifyRequestValid = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string): boolean => {
14
+ // remove hmac if it exists
15
+ // map input to query string
16
+ // generate hash using api secret key and validate it matches hmac
17
+ delete validationParams.hmac;
18
+ const hmacString = mapObjectToQueryString(validationParams);
19
+
20
+
21
+ const generatedHash = createHmac('sha256', shopifyAppApiSecret)
22
+ .update(hmacString)
23
+ .digest('hex');
24
+
25
+ return generatedHash === validationHmac;
26
+ };
27
+
28
+ export const validateShopifyRequest = (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => {
29
+ log.info('Validating shopify request is authentic', { validationParams });
30
+ const isValid = isShopifyRequestValid(validationParams, validationHmac as string, shopifyAppApiSecret);
31
+ if (!isValid) {
32
+ const message = 'Failed: Shopify Request hmac validation';
33
+ log.error(message);
34
+ throw HttpError.badRequest(message);
35
+ }
36
+ log.info('Sucess: Shopify Request hmac validation');
37
+ return true;
38
+ }
39
+
@@ -1,225 +1,235 @@
1
- import { SubscriptionPlan, PLAN_BILLING_FREQUENCY } from '@adtrackify/at-tracking-event-types';
2
-
3
- export const StripeBillingMap: any = {
4
- dev: {
5
- 'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
6
- 'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
7
- 'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
8
- 'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
9
- 'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
10
- 'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
11
- 'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
12
- },
13
- qa: {
14
- 'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
15
- 'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
16
- 'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
17
- 'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
18
- 'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
19
- 'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
20
- 'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
21
- },
22
- prod: {
23
- 'free': 'price_1KAFsIK7krGh4037RsaAYMEl',
24
- 'starter_monthly': 'price_1KAFsMK7krGh4037Lz3P0ksU',
25
- 'starter_yearly': 'price_1KAFsMK7krGh4037Dj1WmSi8',
26
- 'scale_monthly': 'price_1KAFrxK7krGh4037zWCdaTly',
27
- 'scale_yearly': 'price_1KAFrxK7krGh40375fhymyWP',
28
- 'growth_monthly': 'price_1KAFs7K7krGh4037JChjz5Cr',
29
- 'growth_yearly': 'price_1KAFs7K7krGh4037rZElg12s'
30
- }
31
- };
32
- export const SubscriptionPlanSeedItems: {
33
- items: SubscriptionPlan[];
34
- } = {
35
- items: [ {
36
- id: 1,
37
- planName: 'free',
38
- displayName: 'Free',
39
- sku: 'ADT-001',
40
- description: 'Free Plan - Monthly',
41
- price: '0',
42
- displayPrice: '$0',
43
- billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
44
- trialLengthDays: 30,
45
- trialRequiresCreditCard: false,
46
- planDesc: [
47
- 'Fixes IOS14.5 tracking',
48
- 'Multi Pixel Support',
49
- 'Enhanced Tracking / Attribution',
50
- 'Unlimited Facebook Conversion API',
51
- 'Unlimited Integrations',
52
- 'Easy no code setup',
53
- '1,000 tracking events/mo'
54
- ],
55
- unitPriceText: 'try now - free forever',
56
- isHighlighted: false,
57
- isBanner: false
58
- },
59
- // STARTER PLANS
60
- {
61
- id: 2,
62
- planName: 'starter_monthly',
63
- displayName: 'Starter',
64
- sku: 'ADT-002',
65
- description: 'Starter Plan - Monthly',
66
- price: '9.99',
67
- displayPrice: '$9.99',
68
- billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
69
- trialLengthDays: 30,
70
- trialRequiresCreditCard: false,
71
- planDesc: [
72
- '30-day Risk Free Trial',
73
- 'Fixes IOS14.5 tracking',
74
- 'Multi Pixel Support',
75
- 'Enhanced Tracking / Attribution',
76
- 'Unlimited Facebook Conversion API',
77
- 'Unlimited Integrations',
78
- 'Easy no code setup',
79
- '2,500 tracking events/mo'
80
- ],
81
- unitPriceText: '',
82
- isHighlighted: false,
83
- isBanner: false,
84
- }, {
85
- id: 3,
86
- planName: 'starter_yearly',
87
- displayName: 'Starter',
88
- sku: 'ADT-003',
89
- description: 'Starter Plan - Yearly',
90
- price: '96.00',
91
- displayPrice: '$8',
92
- billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
93
- trialLengthDays: 30,
94
- trialRequiresCreditCard: false,
95
- planDesc: [
96
- '30-day Risk Free Trial',
97
- 'Fixes IOS14.5 tracking',
98
- 'Multi Pixel Support',
99
- 'Enhanced Tracking / Attribution',
100
- 'Unlimited Facebook Conversion API',
101
- 'Unlimited Integrations',
102
- 'Easy no code setup',
103
- '2,500 tracking events/mo'
104
- ],
105
- unitPriceText: 'billed yearly ($96) - 20% savings',
106
- isHighlighted: false,
107
- isBanner: false
108
- },
109
- // SCALE PLANS
110
- {
111
- id: 4,
112
- planName: 'scale_monthly',
113
- displayName: 'Scale',
114
- sku: 'ADT-004',
115
- description: 'Scale Plan - Monthly',
116
- price: '59.99',
117
- displayPrice: '$59.99',
118
- billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
119
- trialLengthDays: 30,
120
- trialRequiresCreditCard: false,
121
- planDesc: [
122
- '30-day Risk Free Trial',
123
- 'Fixes IOS14.5 tracking',
124
- 'Multi Pixel Support',
125
- 'Enhanced Tracking / Attribution',
126
- 'Unlimited Facebook Conversion API',
127
- 'Unlimited Integrations',
128
- 'Easy no code setup',
129
- '25,000 tracking events/mo'
130
- ],
131
- unitPriceText: 'billed yearly ($96) - 20% savings',
132
- isHighlighted: true,
133
- isBanner: true,
134
- bannerColor: 'blue',
135
- bannerText: 'MOST POPULAR'
136
- }, {
137
- id: 5,
138
- planName: 'scale_yearly',
139
- displayName: 'Scale',
140
- sku: 'ADT-005',
141
- description: 'Scale Plan - Yearly',
142
- price: '540.00',
143
- displayPrice: '$45',
144
- billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
145
- trialLengthDays: 30,
146
- trialRequiresCreditCard: false,
147
- planDesc: [
148
- '30-day Risk Free Trial',
149
- 'Fixes IOS14.5 tracking',
150
- 'Multi Pixel Support',
151
- 'Enhanced Tracking / Attribution',
152
- 'Unlimited Facebook Conversion API',
153
- 'Unlimited Integrations',
154
- 'Easy no code setup',
155
- '25,000 tracking events/mo'
156
- ],
157
- unitPriceText: 'billed yearly ($540) - 25% savings',
158
- isHighlighted: true,
159
- isBanner: true,
160
- bannerColor: 'blue',
161
- bannerText: 'MOST POPULAR'
162
- },
163
- // GROWTH PLANS
164
- {
165
- id: 6,
166
- planName: 'growth_monthly',
167
- displayName: 'Growth',
168
- sku: 'ADT-006',
169
- description: 'Growth Plan - Monthly',
170
- price: '159.99',
171
- displayPrice: '$159.99',
172
- billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
173
- trialLengthDays: 30,
174
- trialRequiresCreditCard: false,
175
- planDesc: [
176
- '30-day Risk Free Trial',
177
- 'Fixes IOS14.5 tracking',
178
- 'Multi Pixel Support',
179
- 'Enhanced Tracking / Attribution',
180
- 'Unlimited Facebook Conversion API',
181
- 'Unlimited Integrations',
182
- 'Easy no code setup',
183
- '100,000 tracking events/mo'
184
- ],
185
- unitPriceText: 'billed yearly ($540) - 25% savings',
186
- isHighlighted: false,
187
- isBanner: true,
188
- bannerColor: 'orange',
189
- bannerText: 'BEST VALUE'
190
- }, {
191
- id: 7,
192
- planName: 'growth_yearly',
193
- displayName: 'Growth',
194
- sku: 'ADT-007',
195
- description: 'Growth Plan - Yearly',
196
- price: '1344.00',
197
- displayPrice: '$112',
198
- billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
199
- trialLengthDays: 30,
200
- trialRequiresCreditCard: false,
201
- planDesc: [
202
- '30-day Risk Free Trial',
203
- 'Fixes IOS14.5 tracking',
204
- 'Multi Pixel Support',
205
- 'Enhanced Tracking / Attribution',
206
- 'Unlimited Facebook Conversion API',
207
- 'Unlimited Integrations',
208
- 'Easy no code setup',
209
- '100,000 tracking events/mo'
210
- ],
211
- unitPriceText: 'billed yearly ($1344) - 30% savings',
212
- isHighlighted: false,
213
- isBanner: true,
214
- bannerColor: 'orange',
215
- bannerText: 'BEST VALUE'
216
- },
217
- ]
218
- };
219
-
220
-
221
- export const getPlanDetails = (planId: number, stage: string) => {
222
- const plan = SubscriptionPlanSeedItems.items.filter(x => x.id === planId)[ 0 ] as any;
223
- plan.stripePriceId = StripeBillingMap[ stage ][ plan.planName ];
224
- return plan as SubscriptionPlan;
225
- };
1
+ import { SubscriptionPlan, PLAN_BILLING_FREQUENCY } from '@adtrackify/at-tracking-event-types';
2
+
3
+ export const StripeBillingMap: any = {
4
+ dev: {
5
+ 'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
6
+ 'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
7
+ 'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
8
+ 'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
9
+ 'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
10
+ 'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
11
+ 'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
12
+ },
13
+ qa: {
14
+ 'free': 'price_1JzjbKK7krGh4037ezNbGJEm',
15
+ 'starter_monthly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
16
+ 'starter_yearly': 'price_1JwzsGK7krGh4037Li0hPpsZ',
17
+ 'scale_monthly': 'price_1JzjcSK7krGh4037yh34LPk3',
18
+ 'scale_yearly': 'price_1JzjcSK7krGh4037QiBJYfnD',
19
+ 'growth_monthly': 'price_1Jzje1K7krGh4037KErHBp5N',
20
+ 'growth_yearly': 'price_1Jzje1K7krGh4037MhCUhTDh'
21
+ },
22
+ prod: {
23
+ 'free': 'price_1KAFsIK7krGh4037RsaAYMEl',
24
+ 'starter_monthly': 'price_1KAFsMK7krGh4037Lz3P0ksU',
25
+ 'starter_yearly': 'price_1KAFsMK7krGh4037Dj1WmSi8',
26
+ 'scale_monthly': 'price_1KAFrxK7krGh4037zWCdaTly',
27
+ 'scale_yearly': 'price_1KAFrxK7krGh40375fhymyWP',
28
+ 'growth_monthly': 'price_1KAFs7K7krGh4037JChjz5Cr',
29
+ 'growth_yearly': 'price_1KAFs7K7krGh4037rZElg12s'
30
+ }
31
+ };
32
+ export const SubscriptionPlanSeedItems: {
33
+ items: SubscriptionPlan[];
34
+ } = {
35
+ items: [ {
36
+ id: 1,
37
+ planName: 'free',
38
+ displayName: 'Free',
39
+ sku: 'ADT-001',
40
+ description: 'Free Plan - Monthly',
41
+ price: '0',
42
+ displayPrice: '$0',
43
+ billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
44
+ trialLengthDays: 30,
45
+ trialRequiresCreditCard: false,
46
+ planDesc: [
47
+ 'Fixes IOS14.5 tracking',
48
+ 'Multi Pixel Support',
49
+ 'Enhanced Tracking / Attribution',
50
+ 'Unlimited Facebook Conversion API',
51
+ 'Unlimited Integrations',
52
+ 'Easy no code setup',
53
+ '1,000 tracking events/mo'
54
+ ],
55
+ unitPriceText: 'try now - free forever',
56
+ isHighlighted: false,
57
+ isBanner: false
58
+ },
59
+ // STARTER PLANS
60
+ {
61
+ id: 2,
62
+ planName: 'starter_monthly',
63
+ displayName: 'Starter',
64
+ sku: 'ADT-002',
65
+ description: 'Starter Plan - Monthly',
66
+ price: '9.99',
67
+ displayPrice: '$9.99',
68
+ billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
69
+ trialLengthDays: 30,
70
+ trialRequiresCreditCard: false,
71
+ planDesc: [
72
+ '30-day Risk Free Trial',
73
+ 'Fixes IOS14.5 tracking',
74
+ 'Multi Pixel Support',
75
+ 'Enhanced Tracking / Attribution',
76
+ 'Unlimited Facebook Conversion API',
77
+ 'Unlimited Integrations',
78
+ 'Easy no code setup',
79
+ '2,500 tracking events/mo'
80
+ ],
81
+ unitPriceText: '',
82
+ isHighlighted: false,
83
+ isBanner: false,
84
+ }, {
85
+ id: 3,
86
+ planName: 'starter_yearly',
87
+ displayName: 'Starter',
88
+ sku: 'ADT-003',
89
+ description: 'Starter Plan - Yearly',
90
+ price: '96.00',
91
+ displayPrice: '$8',
92
+ billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
93
+ trialLengthDays: 30,
94
+ trialRequiresCreditCard: false,
95
+ planDesc: [
96
+ '30-day Risk Free Trial',
97
+ 'Fixes IOS14.5 tracking',
98
+ 'Multi Pixel Support',
99
+ 'Enhanced Tracking / Attribution',
100
+ 'Unlimited Facebook Conversion API',
101
+ 'Unlimited Integrations',
102
+ 'Easy no code setup',
103
+ '2,500 tracking events/mo'
104
+ ],
105
+ unitPriceText: 'billed yearly ($96) - 20% savings',
106
+ isHighlighted: false,
107
+ isBanner: false
108
+ },
109
+ // SCALE PLANS
110
+ {
111
+ id: 4,
112
+ planName: 'scale_monthly',
113
+ displayName: 'Scale',
114
+ sku: 'ADT-004',
115
+ description: 'Scale Plan - Monthly',
116
+ price: '59.99',
117
+ displayPrice: '$59.99',
118
+ billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
119
+ trialLengthDays: 30,
120
+ trialRequiresCreditCard: false,
121
+ planDesc: [
122
+ '30-day Risk Free Trial',
123
+ 'Fixes IOS14.5 tracking',
124
+ 'Multi Pixel Support',
125
+ 'Enhanced Tracking / Attribution',
126
+ 'Unlimited Facebook Conversion API',
127
+ 'Unlimited Integrations',
128
+ 'Easy no code setup',
129
+ '25,000 tracking events/mo'
130
+ ],
131
+ unitPriceText: 'billed yearly ($96) - 20% savings',
132
+ isHighlighted: true,
133
+ isBanner: true,
134
+ bannerColor: 'blue',
135
+ bannerText: 'MOST POPULAR'
136
+ }, {
137
+ id: 5,
138
+ planName: 'scale_yearly',
139
+ displayName: 'Scale',
140
+ sku: 'ADT-005',
141
+ description: 'Scale Plan - Yearly',
142
+ price: '540.00',
143
+ displayPrice: '$45',
144
+ billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
145
+ trialLengthDays: 30,
146
+ trialRequiresCreditCard: false,
147
+ planDesc: [
148
+ '30-day Risk Free Trial',
149
+ 'Fixes IOS14.5 tracking',
150
+ 'Multi Pixel Support',
151
+ 'Enhanced Tracking / Attribution',
152
+ 'Unlimited Facebook Conversion API',
153
+ 'Unlimited Integrations',
154
+ 'Easy no code setup',
155
+ '25,000 tracking events/mo'
156
+ ],
157
+ unitPriceText: 'billed yearly ($540) - 25% savings',
158
+ isHighlighted: true,
159
+ isBanner: true,
160
+ bannerColor: 'blue',
161
+ bannerText: 'MOST POPULAR'
162
+ },
163
+ // GROWTH PLANS
164
+ {
165
+ id: 6,
166
+ planName: 'growth_monthly',
167
+ displayName: 'Growth',
168
+ sku: 'ADT-006',
169
+ description: 'Growth Plan - Monthly',
170
+ price: '159.99',
171
+ displayPrice: '$159.99',
172
+ billingFrequency: PLAN_BILLING_FREQUENCY.MONTHLY,
173
+ trialLengthDays: 30,
174
+ trialRequiresCreditCard: false,
175
+ planDesc: [
176
+ '30-day Risk Free Trial',
177
+ 'Fixes IOS14.5 tracking',
178
+ 'Multi Pixel Support',
179
+ 'Enhanced Tracking / Attribution',
180
+ 'Unlimited Facebook Conversion API',
181
+ 'Unlimited Integrations',
182
+ 'Easy no code setup',
183
+ '100,000 tracking events/mo'
184
+ ],
185
+ unitPriceText: 'billed yearly ($540) - 25% savings',
186
+ isHighlighted: false,
187
+ isBanner: true,
188
+ bannerColor: 'orange',
189
+ bannerText: 'BEST VALUE'
190
+ }, {
191
+ id: 7,
192
+ planName: 'growth_yearly',
193
+ displayName: 'Growth',
194
+ sku: 'ADT-007',
195
+ description: 'Growth Plan - Yearly',
196
+ price: '1344.00',
197
+ displayPrice: '$112',
198
+ billingFrequency: PLAN_BILLING_FREQUENCY.YEARLY,
199
+ trialLengthDays: 30,
200
+ trialRequiresCreditCard: false,
201
+ planDesc: [
202
+ '30-day Risk Free Trial',
203
+ 'Fixes IOS14.5 tracking',
204
+ 'Multi Pixel Support',
205
+ 'Enhanced Tracking / Attribution',
206
+ 'Unlimited Facebook Conversion API',
207
+ 'Unlimited Integrations',
208
+ 'Easy no code setup',
209
+ '100,000 tracking events/mo'
210
+ ],
211
+ unitPriceText: 'billed yearly ($1344) - 30% savings',
212
+ isHighlighted: false,
213
+ isBanner: true,
214
+ bannerColor: 'orange',
215
+ bannerText: 'BEST VALUE'
216
+ },
217
+ ]
218
+ };
219
+
220
+
221
+ export const getPlanDetails = (planId: number, stage: string) => {
222
+ const plan = SubscriptionPlanSeedItems.items.filter(x => x.id === planId)[ 0 ] as any;
223
+ plan.stripePriceId = StripeBillingMap[ stage ][ plan.planName ];
224
+ return plan as SubscriptionPlan;
225
+ };
226
+
227
+ export const getPlanByStripePriceId = (stripePriceId: string, stage: string) => {
228
+ const stripePriceIds = StripeBillingMap[stage];
229
+ const planName = Object.keys(stripePriceIds).find(key => stripePriceIds[key] === stripePriceId);
230
+
231
+ const plan = SubscriptionPlanSeedItems.items.filter(x => x.planName === planName)[0] as any;
232
+ plan.stripePriceId = stripePriceId;
233
+
234
+ return plan as SubscriptionPlan;
235
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './clients';
2
- export * from './helpers';
3
- export * from './libs';
4
- export * from './types';
1
+ export * from './clients';
2
+ export * from './helpers';
3
+ export * from './libs';
4
+ export * from './types';
5
5
  export * from './services';
package/src/libs/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from '../helpers/shopify-helper';
2
- export * from './crypto';
3
- export * from './dates';
4
- export * from './http-error';
5
- export * from './http-status-codes';
6
- export * from './url';
7
-
1
+ export * from '../helpers/shopify-helper';
2
+ export * from './crypto';
3
+ export * from './dates';
4
+ export * from './http-error';
5
+ export * from './http-status-codes';
6
+ export * from './url';
7
+
package/src/libs/url.ts CHANGED
@@ -1,10 +1,10 @@
1
- // Record<string, string> is any object
2
- export const mapObjectToQueryString = (inputObj: any): string => {
3
- const qsp = Object.entries(inputObj).sort((a, b) => a[ 0 ] < b[ 0 ] ? -1 : 1);
4
- const urlParams = new URLSearchParams();
5
- qsp.map(p => {
6
- urlParams.append(p[ 0 ], p[ 1 ] as string);
7
- });
8
- const qs = urlParams.toString();
9
- return qs;
1
+ // Record<string, string> is any object
2
+ export const mapObjectToQueryString = (inputObj: any): string => {
3
+ const qsp = Object.entries(inputObj).sort((a, b) => a[ 0 ] < b[ 0 ] ? -1 : 1);
4
+ const urlParams = new URLSearchParams();
5
+ qsp.map(p => {
6
+ urlParams.append(p[ 0 ], p[ 1 ] as string);
7
+ });
8
+ const qs = urlParams.toString();
9
+ return qs;
10
10
  };