@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.
package/.editorconfig CHANGED
@@ -1,12 +1,12 @@
1
- root = true
2
-
3
- [*]
4
- end_of_line = lf
5
- charset = utf-8
6
- trim_trailing_whitespace = true
7
- insert_final_newline = false
8
- indent_style = space
9
- indent_size = 2
10
-
11
- [*.{diff,md}]
12
- trim_trailing_whitespace = false
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ charset = utf-8
6
+ trim_trailing_whitespace = true
7
+ insert_final_newline = false
8
+ indent_style = space
9
+ indent_size = 2
10
+
11
+ [*.{diff,md}]
12
+ trim_trailing_whitespace = false
@@ -1,10 +1,10 @@
1
- { "eslint.validate": [
2
- "javascript",
3
- "javascriptreact",
4
- "typescript",
5
- "typescriptreact"
6
- ],
7
- "editor.codeActionsOnSave": {
8
- "source.fixAll.eslint": true,
9
- },
1
+ { "eslint.validate": [
2
+ "javascript",
3
+ "javascriptreact",
4
+ "typescript",
5
+ "typescriptreact"
6
+ ],
7
+ "editor.codeActionsOnSave": {
8
+ "source.fixAll.eslint": true,
9
+ },
10
10
  }
@@ -1,20 +1,20 @@
1
- image: node:16.18.0
2
-
3
- pipelines:
4
- default:
5
- - step:
6
- caches:
7
- - node
8
- script:
9
- - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
10
- - npm install
11
- - npm run build:dev
12
- branches:
13
- master:
14
- - step:
15
- deployment: prod
16
- caches:
17
- - node
18
- script:
19
- - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
20
- - npm run push
1
+ image: node:16.18.0
2
+
3
+ pipelines:
4
+ default:
5
+ - step:
6
+ caches:
7
+ - node
8
+ script:
9
+ - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
10
+ - npm install
11
+ - npm run build:dev
12
+ branches:
13
+ master:
14
+ - step:
15
+ deployment: prod
16
+ caches:
17
+ - node
18
+ script:
19
+ - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
20
+ - npm run push
package/build.js CHANGED
@@ -1,22 +1,22 @@
1
- // @ts-nocheck
2
- // @ts-ignore
3
- /* eslint-disable */
4
-
5
- const { build } = require('esbuild')
6
- const { dependencies } = require('./package.json')
7
- const { Generator } = require('npm-dts')
8
-
9
- new Generator({
10
- entry: 'src/index.ts',
11
- output: 'dist/index.d.ts',
12
- }).generate()
13
-
14
- build({
15
- entryPoints: ['./src/index.ts'],
16
- outdir: 'dist',
17
- bundle: true,
18
- format: 'esm',
19
- platform: 'node',
20
- sourcemap: 'linked',
21
- external: [...Object.keys(dependencies), 'aws-sdk', "@faker-js/faker"]
1
+ // @ts-nocheck
2
+ // @ts-ignore
3
+ /* eslint-disable */
4
+
5
+ const { build } = require('esbuild')
6
+ const { dependencies } = require('./package.json')
7
+ const { Generator } = require('npm-dts')
8
+
9
+ new Generator({
10
+ entry: 'src/index.ts',
11
+ output: 'dist/index.d.ts',
12
+ }).generate()
13
+
14
+ build({
15
+ entryPoints: ['./src/index.ts'],
16
+ outdir: 'dist',
17
+ bundle: true,
18
+ format: 'esm',
19
+ platform: 'node',
20
+ sourcemap: 'linked',
21
+ external: [...Object.keys(dependencies), 'aws-sdk', "@faker-js/faker"]
22
22
  })
package/dist/index.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- declare module '@adtrackify/at-service-common/__tests__/helpers/subscription-helper.spec' {
2
- export {};
3
-
4
- }
5
1
  declare module '@adtrackify/at-service-common/clients/generic/dynamodb-client' {
6
2
  import AWS from 'aws-sdk';
7
3
  export class DynamoDbClient {
@@ -419,6 +415,11 @@ declare module '@adtrackify/at-service-common/clients/third-party/shopify-client
419
415
  data: any;
420
416
  status: any;
421
417
  }>;
418
+ static cancelAppSubscription: (shop: string, accessToken: string, chargeId: string) => Promise<{
419
+ headers: any;
420
+ data: any;
421
+ status: any;
422
+ }>;
422
423
  static listAppSubscriptions: (shop: string, accessToken: string) => Promise<{
423
424
  headers: any;
424
425
  data: any;
@@ -517,6 +518,7 @@ declare module '@adtrackify/at-service-common/helpers/subscription-helper' {
517
518
  items: SubscriptionPlan[];
518
519
  };
519
520
  export const getPlanDetails: (planId: number, stage: string) => SubscriptionPlan;
521
+ export const getPlanByStripePriceId: (stripePriceId: string, stage: string) => SubscriptionPlan;
520
522
 
521
523
  }
522
524
  declare module '@adtrackify/at-service-common/index' {
@@ -686,6 +688,10 @@ declare module '@adtrackify/at-service-common/types/internal-events/event-detail
686
688
  declare module '@adtrackify/at-service-common/types/internal-events/index' {
687
689
  export * from '@adtrackify/at-service-common/types/internal-events/event-detail-types';
688
690
 
691
+ }
692
+ declare module '@adtrackify/at-service-common/__tests__/helpers/subscription-helper.spec' {
693
+ export {};
694
+
689
695
  }
690
696
  declare module '@adtrackify/at-service-common' {
691
697
  import main = require('@adtrackify/at-service-common/src/index');
package/dist/index.js CHANGED
@@ -704,6 +704,15 @@ __publicField(ShopifyClient, "createAppSubscription", async (shop, accessToken,
704
704
  }
705
705
  return res;
706
706
  });
707
+ __publicField(ShopifyClient, "cancelAppSubscription", async (shop, accessToken, chargeId) => {
708
+ const url = `https://${shop}/admin/api/${_ShopifyClient._shopify_api_version}/recurring_application_charges/${chargeId}.json`;
709
+ const client2 = axiosHttpService();
710
+ const res = await client2.delete(url, { headers: { "X-Shopify-Access-Token": accessToken } });
711
+ if (res.status !== 200) {
712
+ log8.error("Failed to cancel recurring App billing", { shop, accessToken, url });
713
+ }
714
+ return res;
715
+ });
707
716
  __publicField(ShopifyClient, "listAppSubscriptions", async (shop, accessToken) => {
708
717
  const url = `https://${shop}/admin/api/${_ShopifyClient._shopify_api_version}/recurring_application_charges.json`;
709
718
  const res = await _ShopifyClient.genericShopifyGet(url, accessToken);
@@ -1029,6 +1038,13 @@ var getPlanDetails = (planId, stage2) => {
1029
1038
  plan.stripePriceId = StripeBillingMap[stage2][plan.planName];
1030
1039
  return plan;
1031
1040
  };
1041
+ var getPlanByStripePriceId = (stripePriceId, stage2) => {
1042
+ const stripePriceIds = StripeBillingMap[stage2];
1043
+ const planName = Object.keys(stripePriceIds).find((key) => stripePriceIds[key] === stripePriceId);
1044
+ const plan = SubscriptionPlanSeedItems.items.filter((x) => x.planName === planName)[0];
1045
+ plan.stripePriceId = stripePriceId;
1046
+ return plan;
1047
+ };
1032
1048
 
1033
1049
  // src/types/internal-events/event-detail-types.ts
1034
1050
  var ADTRACKIFY_EVENT_TYPES = /* @__PURE__ */ ((ADTRACKIFY_EVENT_TYPES2) => {
@@ -1108,6 +1124,7 @@ export {
1108
1124
  getCurrentDate,
1109
1125
  getCurrentTimestamp,
1110
1126
  getDateFromTimestamp,
1127
+ getPlanByStripePriceId,
1111
1128
  getPlanDetails,
1112
1129
  isShopifyRequestValid,
1113
1130
  mapObjectToQueryString,