cloudcommerce 0.0.58 → 0.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 (146) hide show
  1. package/.eslintrc.cjs +2 -0
  2. package/CHANGELOG.md +51 -0
  3. package/action.yml +5 -1
  4. package/package.json +9 -8
  5. package/packages/api/lib/api.d.ts +5036 -0
  6. package/packages/api/lib/{index.js → api.js} +16 -10
  7. package/packages/api/lib/api.js.map +1 -0
  8. package/packages/api/lib/types.d.ts +1 -0
  9. package/packages/api/package.json +3 -3
  10. package/packages/api/src/{index.ts → api.ts} +21 -17
  11. package/packages/api/src/types.ts +1 -0
  12. package/packages/api/tests/index.test.ts +2 -2
  13. package/packages/apps/discounts/lib/discounts.js +1 -1
  14. package/packages/apps/discounts/lib/discounts.js.map +1 -1
  15. package/packages/apps/discounts/{lib-cjs/apply-discount.cjs → lib-mjs/apply-discount.mjs} +7 -9
  16. package/packages/apps/discounts/{lib-cjs/helpers.cjs → lib-mjs/helpers.mjs} +2 -2
  17. package/packages/apps/discounts/package.json +1 -1
  18. package/packages/apps/discounts/src/discounts.ts +1 -1
  19. package/packages/apps/tiny-erp/CHANGELOG.md +1 -0
  20. package/packages/apps/tiny-erp/README.md +1 -0
  21. package/packages/apps/tiny-erp/lib/event-to-tiny.js +117 -0
  22. package/packages/apps/tiny-erp/lib/event-to-tiny.js.map +1 -0
  23. package/packages/apps/tiny-erp/lib/index.js +2 -0
  24. package/packages/apps/tiny-erp/lib/index.js.map +1 -0
  25. package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js +79 -0
  26. package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js.map +1 -0
  27. package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js +81 -0
  28. package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js.map +1 -0
  29. package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js +58 -0
  30. package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js.map +1 -0
  31. package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js +7 -0
  32. package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js.map +1 -0
  33. package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +94 -0
  34. package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js.map +1 -0
  35. package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js +158 -0
  36. package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js.map +1 -0
  37. package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js +46 -0
  38. package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js.map +1 -0
  39. package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js +193 -0
  40. package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js.map +1 -0
  41. package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js +199 -0
  42. package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js.map +1 -0
  43. package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js +129 -0
  44. package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js.map +1 -0
  45. package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js +34 -0
  46. package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js.map +1 -0
  47. package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js +39 -0
  48. package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js.map +1 -0
  49. package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js +47 -0
  50. package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js.map +1 -0
  51. package/packages/apps/tiny-erp/lib/tiny-erp.js +17 -0
  52. package/packages/apps/tiny-erp/lib/tiny-erp.js.map +1 -0
  53. package/packages/apps/tiny-erp/lib/tiny-webhook.js +92 -0
  54. package/packages/apps/tiny-erp/lib/tiny-webhook.js.map +1 -0
  55. package/packages/apps/tiny-erp/package.json +34 -0
  56. package/packages/apps/tiny-erp/src/event-to-tiny.ts +136 -0
  57. package/packages/apps/tiny-erp/src/index.ts +1 -0
  58. package/packages/apps/tiny-erp/src/integration/after-tiny-queue.ts +80 -0
  59. package/packages/apps/tiny-erp/src/integration/export-order-to-tiny.ts +86 -0
  60. package/packages/apps/tiny-erp/src/integration/export-product-to-tiny.ts +60 -0
  61. package/packages/apps/tiny-erp/src/integration/helpers/format-tiny-date.ts +6 -0
  62. package/packages/apps/tiny-erp/src/integration/import-order-from-tiny.ts +104 -0
  63. package/packages/apps/tiny-erp/src/integration/import-product-from-tiny.ts +162 -0
  64. package/packages/apps/tiny-erp/src/integration/parsers/order-from-tiny.ts +49 -0
  65. package/packages/apps/tiny-erp/src/integration/parsers/order-to-tiny.ts +205 -0
  66. package/packages/apps/tiny-erp/src/integration/parsers/product-from-tiny.ts +215 -0
  67. package/packages/apps/tiny-erp/src/integration/parsers/product-to-tiny.ts +138 -0
  68. package/packages/apps/tiny-erp/src/integration/parsers/status-from-tiny.ts +35 -0
  69. package/packages/apps/tiny-erp/src/integration/parsers/status-to-tiny.ts +42 -0
  70. package/packages/apps/tiny-erp/src/integration/post-tiny-erp.ts +52 -0
  71. package/packages/apps/tiny-erp/src/tiny-erp.ts +23 -0
  72. package/packages/apps/tiny-erp/src/tiny-webhook.ts +100 -0
  73. package/packages/apps/tiny-erp/tsconfig.json +3 -0
  74. package/packages/cli/config/firebase.json +6 -3
  75. package/packages/cli/lib/index.js +23 -4
  76. package/packages/cli/lib/{config-gcloud.js → setup-gcloud.js} +2 -2
  77. package/packages/cli/lib/setup-gh.js +59 -0
  78. package/packages/cli/package.json +2 -1
  79. package/packages/cli/src/index.ts +30 -3
  80. package/packages/cli/src/{config-gcloud.ts → setup-gcloud.ts} +2 -2
  81. package/packages/cli/src/setup-gh.ts +83 -0
  82. package/packages/events/lib/firebase.js +2 -26
  83. package/packages/events/lib/firebase.js.map +1 -1
  84. package/packages/events/lib/index.js +1 -1
  85. package/packages/events/lib/index.js.map +1 -1
  86. package/packages/events/package.json +2 -1
  87. package/packages/events/src/firebase.ts +2 -28
  88. package/packages/events/src/index.ts +1 -1
  89. package/packages/firebase/lib/config.d.ts +2 -2
  90. package/packages/firebase/lib/config.js +8 -6
  91. package/packages/firebase/lib/config.js.map +1 -1
  92. package/packages/firebase/lib/const.d.ts +2 -0
  93. package/packages/firebase/lib/const.js +6 -0
  94. package/packages/firebase/lib/const.js.map +1 -0
  95. package/packages/firebase/lib/handlers/check-store-events.d.ts +1 -1
  96. package/packages/firebase/lib/handlers/check-store-events.js +86 -22
  97. package/packages/firebase/lib/handlers/check-store-events.js.map +1 -1
  98. package/packages/firebase/lib/helpers/pubsub.d.ts +9 -0
  99. package/packages/firebase/lib/helpers/pubsub.js +32 -0
  100. package/packages/firebase/lib/helpers/pubsub.js.map +1 -0
  101. package/packages/firebase/lib/helpers/update-app-data.d.ts +9 -0
  102. package/packages/firebase/lib/helpers/update-app-data.js +45 -0
  103. package/packages/firebase/lib/helpers/update-app-data.js.map +1 -0
  104. package/packages/firebase/lib/index.d.ts +1 -2
  105. package/packages/firebase/lib/index.js +1 -6
  106. package/packages/firebase/lib/index.js.map +1 -1
  107. package/packages/firebase/lib/init.d.ts +2 -0
  108. package/packages/firebase/lib/init.js +9 -0
  109. package/packages/firebase/lib/init.js.map +1 -0
  110. package/packages/firebase/package.json +6 -2
  111. package/packages/firebase/src/config.ts +10 -7
  112. package/packages/firebase/src/const.ts +5 -0
  113. package/packages/firebase/src/handlers/check-store-events.ts +100 -28
  114. package/packages/firebase/src/helpers/pubsub.ts +52 -0
  115. package/packages/firebase/src/helpers/update-app-data.ts +49 -0
  116. package/packages/firebase/src/index.ts +1 -7
  117. package/packages/firebase/src/init.ts +9 -0
  118. package/packages/modules/lib/firebase/handle-module.js +4 -5
  119. package/packages/modules/lib/firebase/handle-module.js.map +1 -1
  120. package/packages/modules/lib/firebase/serve-modules-api.js +2 -2
  121. package/packages/modules/lib/firebase/serve-modules-api.js.map +1 -1
  122. package/packages/modules/lib/firebase.js +2 -7
  123. package/packages/modules/lib/firebase.js.map +1 -1
  124. package/packages/modules/package.json +1 -1
  125. package/packages/modules/src/firebase/handle-module.ts +2 -5
  126. package/packages/modules/src/firebase/serve-modules-api.ts +2 -6
  127. package/packages/modules/src/firebase.ts +2 -7
  128. package/packages/passport/lib/firebase/handle-passport.js +12 -10
  129. package/packages/passport/lib/firebase/handle-passport.js.map +1 -1
  130. package/packages/passport/lib/firebase/serve-passport-api.js +2 -2
  131. package/packages/passport/lib/firebase/serve-passport-api.js.map +1 -1
  132. package/packages/passport/lib/firebase.js +2 -7
  133. package/packages/passport/lib/firebase.js.map +1 -1
  134. package/packages/passport/package.json +1 -1
  135. package/packages/passport/src/firebase/handle-passport.ts +10 -19
  136. package/packages/passport/src/firebase/serve-passport-api.ts +0 -2
  137. package/packages/passport/src/firebase.ts +1 -7
  138. package/packages/ssr/lib/firebase.js +1 -4
  139. package/packages/ssr/lib/firebase.js.map +1 -1
  140. package/packages/ssr/package.json +1 -1
  141. package/packages/ssr/src/firebase.ts +1 -4
  142. package/packages/storefront/package.json +5 -4
  143. package/packages/types/index.ts +18 -3
  144. package/packages/types/package.json +1 -1
  145. package/packages/api/lib/index.d.ts +0 -9974
  146. package/packages/api/lib/index.js.map +0 -1
package/.eslintrc.cjs CHANGED
@@ -22,6 +22,8 @@ module.exports = {
22
22
  '**/types/*.d.ts',
23
23
  ],
24
24
  rules: {
25
+ 'prefer-template': 'warn',
26
+ 'no-nested-ternary': 'warn',
25
27
  'no-await-in-loop': 'warn',
26
28
  'no-shadow': 'warn',
27
29
  'no-param-reassign': 'warn',
package/CHANGELOG.md CHANGED
@@ -2,6 +2,57 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.61](https://github.com/ecomplus/cloud-commerce/compare/v0.0.60...v0.0.61) (2022-08-31)
6
+
7
+
8
+ ### Features
9
+
10
+ * Add optional `tiny-erp-token` input to GH Action to improve Tiny webhooks performance ([0444f65](https://github.com/ecomplus/cloud-commerce/commit/0444f655b0a358979b14cee8ab85f0f018d08df3))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **tiny-erp:** Properly set and reuse `process.env.TINY_ERP_TOKEN` on webhooks ([4aee43a](https://github.com/ecomplus/cloud-commerce/commit/4aee43a3f067eb430c0c183eada27dca1b331fd3))
16
+
17
+ ### [0.0.60](https://github.com/ecomplus/cloud-commerce/compare/v0.0.59...v0.0.60) (2022-08-30)
18
+
19
+
20
+ ### Features
21
+
22
+ * **api:** Check auth from env vars `ECOM_AUTHENTICATION_ID` and `ECOM_API_KEY` ([0dce4e0](https://github.com/ecomplus/cloud-commerce/commit/0dce4e051e178d192e09130279071d6bd5c60e84))
23
+ * **events:** Get app data on events list (scheduled) and send on PubSub message [[#29](https://github.com/ecomplus/cloud-commerce/issues/29)] ([bcdeec1](https://github.com/ecomplus/cloud-commerce/commit/bcdeec173fc3b2ad747014d7e948c907b66f9030))
24
+ * **events:** Read API doc of respective event and send on Pub/Sub message [[#29](https://github.com/ecomplus/cloud-commerce/issues/29)] ([f8702e9](https://github.com/ecomplus/cloud-commerce/commit/f8702e9ac04c586420804da59afbe33c056be5f7))
25
+ * **firebase:** Create helpers to setup Pub/Sub on publish functions ([8e240c6](https://github.com/ecomplus/cloud-commerce/commit/8e240c6d9cb83ad2de4c2a980f9e8478ee32f842))
26
+ * Helper method to update app data on Store API and publish internal PubSub message [[#29](https://github.com/ecomplus/cloud-commerce/issues/29)] ([be7ab47](https://github.com/ecomplus/cloud-commerce/commit/be7ab47b8f5882a0a00da635dd9d2c034ee4ff6e))
27
+ * **tiny-erp:** Refactor Tiny ERP handlers from https://github.com/ecomplus/app-tiny-erp ([6530533](https://github.com/ecomplus/cloud-commerce/commit/6530533643dc055a4aad07e77dc1877aa75eaaf2))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **api:** Fix typedefs for authenticated methods (may use env vars) ([f4c51aa](https://github.com/ecomplus/cloud-commerce/commit/f4c51aa9bbcfd805cadfda106913c4b77e69ab28))
33
+ * **api:** Fix typedefs for authenticated methods with optional config ([c1938ae](https://github.com/ecomplus/cloud-commerce/commit/c1938aed2009f39165cd05c693dab949d3362d69))
34
+ * **deps:** Update all non-major dependencies ([#45](https://github.com/ecomplus/cloud-commerce/issues/45)) ([5fef410](https://github.com/ecomplus/cloud-commerce/commit/5fef410e87c8e8a30b728372b0745b623b4a00b9))
35
+ * **events:** Must read full `apiDoc` even on new document events ([b8cbac6](https://github.com/ecomplus/cloud-commerce/commit/b8cbac6258bd16ac867f23cd536817ffdb4ef807))
36
+ * **events:** Prevent handling multiple API events for same ID&topic at once ([f7e3ba3](https://github.com/ecomplus/cloud-commerce/commit/f7e3ba3177ec392b5d1103ca13a3b01046ad3f14))
37
+ * **events:** Remove generic `onNewOrder` function [[#29](https://github.com/ecomplus/cloud-commerce/issues/29)] ([3da6a26](https://github.com/ecomplus/cloud-commerce/commit/3da6a2649e3e92a561464a7d9ab68d7651be6344))
38
+ * **firebase:** Ensure fetch polyfill and Firebase app initialization before any function logic ([09f8ad2](https://github.com/ecomplus/cloud-commerce/commit/09f8ad21d4af03325f297485a0ceb6ecf3ec1126))
39
+
40
+ ### [0.0.59](https://github.com/ecomplus/cloud-commerce/compare/v0.0.58...v0.0.59) (2022-08-24)
41
+
42
+
43
+ ### Features
44
+
45
+ * **cli:** Use `GITHUB_TOKEN` env to auto set secrets on setup ([#43](https://github.com/ecomplus/cloud-commerce/issues/43)) ([8949070](https://github.com/ecomplus/cloud-commerce/commit/89490703cba52affdbb69c63d8b459cb609f5130))
46
+ * **events:** Start publishing PubSub messages for each topic/app/event [[#29](https://github.com/ecomplus/cloud-commerce/issues/29)] ([9575d25](https://github.com/ecomplus/cloud-commerce/commit/9575d25d4ca27fcc19acbd0118b0140f8b484316))
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **cli:** Do not create `GH_TOKEN` secret (set by default) ([8e50e37](https://github.com/ecomplus/cloud-commerce/commit/8e50e371477bdf67ec0cef380f2c6488d3d588a5))
52
+ * **deps:** Add `@google-cloud/pubsub` to core `@cloudcommerce/firebase` dependencies ([0b35b0e](https://github.com/ecomplus/cloud-commerce/commit/0b35b0edb560329a21869e8b6a75abaed9c4cd34))
53
+ * **events:** Save last run state and timestamp to Firestore ([7183a55](https://github.com/ecomplus/cloud-commerce/commit/7183a55694ca0e5cc6968be9ca4e965772937e2a))
54
+ * Set default GCloud region to `southamerica-east1` (São Paulo) ([212d04d](https://github.com/ecomplus/cloud-commerce/commit/212d04d72ace4cffe54489dae5b74c2dbfa4e0d0))
55
+
5
56
  ### [0.0.58](https://github.com/ecomplus/cloud-commerce/compare/v0.0.57...v0.0.58) (2022-08-23)
6
57
 
7
58
  ### [0.0.57](https://github.com/ecomplus/cloud-commerce/compare/v0.0.56...v0.0.57) (2022-08-23)
package/action.yml CHANGED
@@ -15,7 +15,9 @@ inputs:
15
15
  description: 'E-Com Plus store API key'
16
16
  required: true
17
17
  ecom-store-id:
18
- description: 'Store ID if defined in config.json'
18
+ description: 'Store ID if not defined in config.json'
19
+ tiny-erp-token:
20
+ description: 'App: Tiny ERP API token'
19
21
 
20
22
  outputs: {}
21
23
 
@@ -52,6 +54,7 @@ runs:
52
54
  ECOM_AUTHENTICATION_ID: ${{ inputs.ecom-authentication-id }}
53
55
  ECOM_API_KEY: ${{ inputs.ecom-api-key }}
54
56
  ECOM_STORE_ID: ${{ inputs.ecom-store-id }}
57
+ TINY_ERP_TOKEN: ${{ inputs.tiny-erp-token }}
55
58
  run: |
56
59
  export GAC_FILENAME=".gac-$RANDOM.json"
57
60
  echo $FIREBASE_SERVICE_ACCOUNT > $GAC_FILENAME
@@ -59,6 +62,7 @@ runs:
59
62
  ECOM_API_KEY=$ECOM_API_KEY
60
63
  ECOM_STORE_ID=$ECOM_STORE_ID
61
64
  GITHUB_TOKEN=$GITHUB_TOKEN
65
+ TINY_ERP_TOKEN=$TINY_ERP_TOKEN
62
66
  " > functions/.env
63
67
  GOOGLE_APPLICATION_CREDENTIALS=$GAC_FILENAME npm run deploy
64
68
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "0.0.58",
4
+ "version": "0.0.61",
5
5
  "description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",
6
6
  "main": "packages/api/lib/index.js",
7
7
  "author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
@@ -16,22 +16,23 @@
16
16
  }
17
17
  },
18
18
  "devDependencies": {
19
- "@commitlint/cli": "^17.0.3",
20
- "@commitlint/config-conventional": "^17.0.3",
19
+ "@commitlint/cli": "^17.1.1",
20
+ "@commitlint/config-conventional": "^17.1.0",
21
21
  "@commitlint/rules": "^17.0.0",
22
22
  "@types/node": "^18.0.5",
23
- "@typescript-eslint/eslint-plugin": "^5.33.1",
24
- "@typescript-eslint/parser": "^5.33.1",
23
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
24
+ "@typescript-eslint/parser": "^5.35.1",
25
25
  "esbuild": "^0.15.5",
26
- "eslint": "^8.22.0",
26
+ "eslint": "^8.23.0",
27
27
  "eslint-config-airbnb-base": "^15.0.0",
28
28
  "eslint-plugin-import": "^2.26.0",
29
- "eslint-plugin-vue": "^9.3.0",
29
+ "eslint-plugin-vue": "^9.4.0",
30
30
  "husky": "^8.0.1",
31
31
  "node-fetch": "^3.2.10",
32
32
  "standard-version": "^9.5.0",
33
+ "ts-node": "^10.9.1",
33
34
  "turbo": "^1.4.3",
34
- "typescript": "^4.7.4",
35
+ "typescript": "^4.8.2",
35
36
  "vite": "^3.0.9",
36
37
  "vitest": "^0.22.1",
37
38
  "zx": "^7.0.8"