cloudcommerce 0.0.61 → 0.0.64

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 (65) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/action.yml +1 -0
  4. package/package.json +1 -1
  5. package/packages/api/lib/api.d.ts +8 -8
  6. package/packages/api/lib/types/applications.d.ts +2 -2
  7. package/packages/api/package.json +1 -1
  8. package/packages/api/src/types/applications.d.ts +2 -2
  9. package/packages/apps/correios/CHANGELOG.md +1 -0
  10. package/packages/apps/correios/README.md +1 -0
  11. package/packages/apps/correios/lib/correios.d.ts +2 -0
  12. package/packages/apps/correios/lib/correios.js +6 -0
  13. package/packages/apps/correios/lib/correios.js.map +1 -0
  14. package/packages/apps/correios/lib/index.d.ts +1 -0
  15. package/packages/apps/correios/lib/index.js +2 -0
  16. package/packages/apps/correios/lib/index.js.map +1 -0
  17. package/packages/apps/correios/lib-mjs/calculate-correios.mjs +470 -0
  18. package/packages/apps/correios/lib-mjs/correios-ws.mjs +154 -0
  19. package/packages/apps/correios/package.json +29 -0
  20. package/packages/apps/correios/src/correios.ts +7 -0
  21. package/packages/apps/correios/src/index.ts +1 -0
  22. package/packages/apps/correios/tsconfig.json +6 -0
  23. package/packages/apps/discounts/lib/index.js +1 -1
  24. package/packages/apps/discounts/package.json +3 -7
  25. package/packages/apps/tiny-erp/lib/event-to-tiny.js +0 -2
  26. package/packages/apps/tiny-erp/lib/event-to-tiny.js.map +1 -1
  27. package/packages/apps/tiny-erp/lib/index.js +1 -1
  28. package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +4 -6
  29. package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js.map +1 -1
  30. package/packages/apps/tiny-erp/lib/tiny-erp.js +6 -5
  31. package/packages/apps/tiny-erp/lib/tiny-erp.js.map +1 -1
  32. package/packages/apps/tiny-erp/package.json +1 -1
  33. package/packages/apps/tiny-erp/src/event-to-tiny.ts +0 -2
  34. package/packages/apps/tiny-erp/src/integration/import-order-from-tiny.ts +4 -6
  35. package/packages/apps/tiny-erp/src/tiny-erp.ts +9 -7
  36. package/packages/cli/package.json +1 -1
  37. package/packages/events/lib/firebase.js.map +1 -1
  38. package/packages/events/package.json +1 -1
  39. package/packages/events/src/firebase.ts +0 -1
  40. package/packages/firebase/lib/config.d.ts +3 -0
  41. package/packages/firebase/lib/config.js +3 -0
  42. package/packages/firebase/lib/config.js.map +1 -1
  43. package/packages/firebase/lib/index.js.map +1 -1
  44. package/packages/firebase/lib/init.js.map +1 -1
  45. package/packages/firebase/package.json +1 -1
  46. package/packages/firebase/src/config.ts +3 -0
  47. package/packages/firebase/src/index.ts +0 -1
  48. package/packages/firebase/src/init.ts +0 -1
  49. package/packages/modules/lib/firebase/call-app-module.js +28 -13
  50. package/packages/modules/lib/firebase/call-app-module.js.map +1 -1
  51. package/packages/modules/lib/firebase.js.map +1 -1
  52. package/packages/modules/package.json +2 -1
  53. package/packages/modules/src/firebase/call-app-module.ts +29 -14
  54. package/packages/modules/src/firebase.ts +0 -1
  55. package/packages/passport/package.json +1 -1
  56. package/packages/ssr/lib/firebase.js.map +1 -1
  57. package/packages/ssr/package.json +1 -1
  58. package/packages/ssr/src/firebase.ts +0 -1
  59. package/packages/storefront/package.json +1 -1
  60. package/packages/types/package.json +1 -1
  61. package/packages/apps/_app.config.js +0 -80
  62. package/packages/apps/discounts/lib/discounts.config.d.ts +0 -14
  63. package/packages/apps/discounts/lib/discounts.config.js +0 -19
  64. package/packages/apps/discounts/lib/discounts.config.js.map +0 -1
  65. package/packages/apps/discounts/src/discounts.config.ts +0 -25
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,kCAAkC,CAAC;AAC1C,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAClE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,kCAAkC,CAAC;AAC1C,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAClE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/modules",
3
3
  "type": "module",
4
- "version": "0.0.61",
4
+ "version": "0.0.64",
5
5
  "description": "E-Com Plus Cloud Commerce modules API",
6
6
  "main": "lib/index.cjs",
7
7
  "exports": {
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@cloudcommerce/api": "workspace:*",
28
+ "@cloudcommerce/app-correios": "workspace:*",
28
29
  "@cloudcommerce/app-discounts": "workspace:*",
29
30
  "@cloudcommerce/firebase": "workspace:*",
30
31
  "ajv": "^8.11.0",
@@ -20,7 +20,16 @@ export default async (
20
20
  }
21
21
  const { storeId, apps } = config.get();
22
22
 
23
- const debug = (response: AxiosResponse) => {
23
+ const checkErrorResponse = (logHead: string, resData: any) => {
24
+ if (typeof resData === 'object' && resData !== null) {
25
+ const { error, message } = resData;
26
+ if (typeof error === 'string' && error.length && typeof message === 'string') {
27
+ logger.warn(logHead, JSON.stringify({ error, message }));
28
+ }
29
+ }
30
+ };
31
+
32
+ const debugAndBlacklist = (response: AxiosResponse) => {
24
33
  const status = response ? response.status : 0;
25
34
  if (!blacklist[url]) {
26
35
  blacklist[url] = 1;
@@ -34,16 +43,11 @@ export default async (
34
43
  delete blacklist[url];
35
44
  }
36
45
  }, !status ? 180000 : 6000);
37
-
38
- logger.info(`${url} : ${status}`);
46
+ const logHead = `${url} : ${status}`;
39
47
  if (status >= 400 && status < 500) {
40
- const { data: resData } = response;
41
- if (typeof resData === 'object' && resData !== null) {
42
- const { error, message } = resData;
43
- if (typeof error === 'string' && error.length && typeof message === 'string') {
44
- logger.warn(JSON.stringify({ error, message }));
45
- }
46
- }
48
+ checkErrorResponse(logHead, response.data);
49
+ } else {
50
+ logger.info(logHead);
47
51
  }
48
52
  };
49
53
 
@@ -56,6 +60,13 @@ export default async (
56
60
  .then(({ applyDiscount }) => applyDiscount(_data));
57
61
  };
58
62
  }
63
+ } else if (modName === 'calculate_shipping') {
64
+ if (appId === apps.correios.appId) {
65
+ internalModuleFn = async (_data: AppModuleBody = data) => {
66
+ return import('@cloudcommerce/app-correios')
67
+ .then(({ calculateShipping }) => calculateShipping(_data));
68
+ };
69
+ }
59
70
  }
60
71
  if (internalModuleFn) {
61
72
  /*
@@ -71,10 +82,14 @@ export default async (
71
82
  */
72
83
  const middleware = global[`app${appId}_${modName}_middleware`];
73
84
  try {
85
+ let appResponse: any;
74
86
  if (typeof middleware === 'function') {
75
- return await middleware(data, internalModuleFn);
87
+ appResponse = await middleware(data, internalModuleFn);
88
+ } else {
89
+ appResponse = await internalModuleFn(data);
76
90
  }
77
- return await internalModuleFn(data);
91
+ checkErrorResponse(`${appId}_${modName}`, appResponse);
92
+ return appResponse;
78
93
  } catch (err) {
79
94
  logger.error(err);
80
95
  let message = 'Failed to execute module function';
@@ -102,12 +117,12 @@ export default async (
102
117
  timeout: isBigTimeout ? 30000 : 10000,
103
118
  })
104
119
  .then((response) => {
105
- debug(response);
120
+ debugAndBlacklist(response);
106
121
  return response.data;
107
122
  })
108
123
  .catch((err) => {
109
124
  const { response } = err;
110
- debug(response);
125
+ debugAndBlacklist(response);
111
126
  if (err.message || err.code) {
112
127
  let msg = `Axios error ${err.code}: ${err.message}`;
113
128
  if (data) {
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
-
3
2
  import '@cloudcommerce/firebase/lib/init';
4
3
  // eslint-disable-next-line import/no-unresolved
5
4
  import { onRequest } from 'firebase-functions/v2/https';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/passport",
3
3
  "type": "module",
4
- "version": "0.0.61",
4
+ "version": "0.0.64",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,kCAAkC,CAAC;AAC1C,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC1D,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,kCAAkC,CAAC;AAC1C,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC1D,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "0.0.61",
4
+ "version": "0.0.64",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
-
3
2
  import '@cloudcommerce/firebase/lib/init';
4
3
  // eslint-disable-next-line import/no-unresolved
5
4
  import { onRequest } from 'firebase-functions/v2/https';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "0.0.61",
4
+ "version": "0.0.64",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "main": "src/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "0.0.61",
4
+ "version": "0.0.64",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {
@@ -1,80 +0,0 @@
1
- /* eslint-disable comma-dangle, no-multi-spaces, key-spacing, max-len */
2
-
3
- /**
4
- * Edit base E-Com Plus Application object here.
5
- * Ref.: https://developers.e-com.plus/docs/api/#/store/applications/
6
- */
7
-
8
- export default () => {
9
- return {
10
- app_id: 9000,
11
- title: 'My Awesome E-Com Plus App',
12
- slug: 'my-awesome-app',
13
- type: 'external',
14
- state: 'active',
15
-
16
- /**
17
- * Uncomment modules above to work with E-Com Plus Mods API on Storefront.
18
- * Ref.: https://developers.e-com.plus/modules-api/
19
- */
20
- modules: {
21
- /**
22
- * Triggered to calculate shipping options, must return values and deadlines.
23
- * Start editing `routes/ecom/modules/calculate-shipping.js`
24
- */
25
- // calculate_shipping: { enabled: true },
26
-
27
- /**
28
- * Triggered to validate and apply discount value, must return discount and conditions.
29
- * Start editing `routes/ecom/modules/apply-discount.js`
30
- */
31
- // apply_discount: { enabled: true },
32
-
33
- /**
34
- * Triggered when listing payments, must return available payment methods.
35
- * Start editing `routes/ecom/modules/list-payments.js`
36
- */
37
- // list_payments: { enabled: true },
38
-
39
- /**
40
- * Triggered when order is being closed, must create payment transaction and return info.
41
- * Start editing `routes/ecom/modules/create-transaction.js`
42
- */
43
- // create_transaction: { enabled: true },
44
- },
45
-
46
- admin_settings: {
47
- /**
48
- * JSON schema based fields to be configured by merchant and saved to app `data` / `hidden_data`, such as:
49
-
50
- webhook_uri: {
51
- schema: {
52
- type: 'string',
53
- maxLength: 255,
54
- format: 'uri',
55
- title: 'Notifications URI',
56
- description: 'Unique notifications URI available on your Custom App dashboard'
57
- },
58
- hide: true
59
- },
60
- token: {
61
- schema: {
62
- type: 'string',
63
- maxLength: 50,
64
- title: 'App token'
65
- },
66
- hide: true
67
- },
68
- opt_in: {
69
- schema: {
70
- type: 'boolean',
71
- default: false,
72
- title: 'Some config option'
73
- },
74
- hide: false
75
- },
76
-
77
- */
78
- },
79
- };
80
- };
@@ -1,14 +0,0 @@
1
- declare const _default: () => {
2
- app_id: number;
3
- title: string;
4
- slug: string;
5
- type: string;
6
- state: string;
7
- modules: {
8
- apply_discount: {
9
- enabled: boolean;
10
- };
11
- };
12
- admin_settings: {};
13
- };
14
- export default _default;
@@ -1,19 +0,0 @@
1
- import config from '@cloudcommerce/firebase/lib/config';
2
-
3
- export default () => {
4
- const { lang, apps: { discounts: { appId } } } = config.get();
5
- return {
6
- app_id: appId,
7
- title: lang.startsWith('en') ? 'Campaigns and discounts' : 'Campanhas e descontos',
8
- slug: 'discounts',
9
- type: 'external',
10
- state: 'active',
11
- modules: {
12
- apply_discount: {
13
- enabled: true,
14
- },
15
- },
16
- admin_settings: {},
17
- };
18
- };
19
- // # sourceMappingURL=discounts.config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discounts.config.js","sourceRoot":"","sources":["../src/discounts.config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,eAAe,GAAG,EAAE;IAClB,MAAM,EACJ,IAAI,EACJ,IAAI,EAAE,EACJ,SAAS,EAAE,EAAE,KAAK,EAAE,GACrB,GACF,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;IAEjB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,uBAAuB;QAClF,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE;YACP,cAAc,EAAE;gBACd,OAAO,EAAE,IAAI;aACd;SACF;QACD,cAAc,EAAE,EACf;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,25 +0,0 @@
1
- import config from '@cloudcommerce/firebase/lib/config';
2
-
3
- export default () => {
4
- const {
5
- lang,
6
- apps: {
7
- discounts: { appId },
8
- },
9
- } = config.get();
10
-
11
- return {
12
- app_id: appId,
13
- title: lang.startsWith('en') ? 'Campaigns and discounts' : 'Campanhas e descontos',
14
- slug: 'discounts',
15
- type: 'external',
16
- state: 'active',
17
- modules: {
18
- apply_discount: {
19
- enabled: true,
20
- },
21
- },
22
- admin_settings: {
23
- },
24
- };
25
- };