cloudcommerce 0.0.71 → 0.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/.eslintrc.cjs +1 -0
- package/CHANGELOG.md +38 -0
- package/package.json +9 -9
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/frenet/CHANGELOG.md +1 -0
- package/packages/apps/frenet/README.md +1 -0
- package/packages/apps/frenet/lib/frenet.d.ts +2 -0
- package/packages/apps/frenet/lib/frenet.js +6 -0
- package/packages/apps/frenet/lib/frenet.js.map +1 -0
- package/packages/apps/frenet/lib/index.d.ts +1 -0
- package/packages/apps/{tiny-erp → frenet}/lib/index.js +1 -1
- package/packages/apps/{tiny-erp → frenet}/lib/index.js.map +1 -1
- package/packages/apps/frenet/lib-mjs/calculate-frenet.mjs +152 -0
- package/packages/apps/frenet/package.json +28 -0
- package/packages/apps/frenet/src/frenet.ts +7 -0
- package/packages/apps/frenet/src/index.ts +1 -0
- package/packages/apps/frenet/tsconfig.json +6 -0
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/cli/config/firebase.json +47 -0
- package/packages/cli/package.json +1 -1
- package/packages/config/lib/config.js +9 -8
- package/packages/config/lib/config.js.map +1 -1
- package/packages/config/package.json +1 -1
- package/packages/config/src/config.ts +11 -10
- package/packages/events/package.json +1 -1
- package/packages/firebase/lib/config.d.ts +3 -0
- package/packages/firebase/lib/config.js +3 -0
- package/packages/firebase/lib/config.js.map +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/firebase/src/config.ts +3 -0
- package/packages/modules/package.json +3 -1
- package/packages/modules/schemas/@checkout.cjs +28 -28
- package/packages/modules/schemas/apply_discount.cjs +2 -2
- package/packages/modules/schemas/calculate_shipping.cjs +4 -4
- package/packages/modules/schemas/create_transaction.cjs +30 -30
- package/packages/modules/schemas/list_payments.cjs +6 -6
- package/packages/modules/src/firebase/ajv.ts +2 -1
- package/packages/modules/src/firebase/call-app-module.ts +5 -0
- package/packages/modules/src/firebase/handle-module.ts +5 -1
- package/packages/modules/src/firebase/serve-modules-api.ts +5 -3
- package/packages/passport/lib/firebase/handle-passport.js +96 -92
- package/packages/passport/lib/firebase/serve-passport-api.js +35 -34
- package/packages/passport/lib/firebase.js +5 -7
- package/packages/passport/lib/index.js +2 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/firebase/serve-storefront.js +37 -55
- package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
- package/packages/ssr/lib/firebase.js +2 -4
- package/packages/ssr/lib/index.js +1 -2
- package/packages/ssr/package.json +1 -1
- package/packages/ssr/src/firebase/serve-storefront.ts +13 -36
- package/packages/storefront/astro.config.mjs +2 -0
- package/packages/storefront/dist/client/LoginModal.d6b935cf.js +1 -0
- package/packages/storefront/dist/client/assets/{_...98510c96.css → _...27b7eb4d.css} +1 -1
- package/packages/storefront/dist/client/assets/_...b3f65c5c.css +1 -0
- package/packages/storefront/dist/client/assets/fallback-index.90217cf0.css +1 -0
- package/packages/storefront/dist/client/assets/{404.530428e5.css → fallback.9cd2ed3f.css} +1 -1
- package/packages/storefront/dist/client/assets/{index.53a3a3e0.css → index.c5a9ea80.css} +1 -1
- package/packages/storefront/dist/client/chunks/index.esm.69f70489.js +1726 -0
- package/packages/storefront/dist/client/chunks/index.esm2017.1194d1a1.js +457 -0
- package/packages/storefront/dist/client/chunks/runtime-core.esm-bundler.a7337834.js +1 -0
- package/packages/storefront/dist/client/client.80b904f3.js +1 -0
- package/packages/storefront/dist/client/hoisted.24787260.js +376 -0
- package/packages/storefront/dist/server/entry.mjs +672 -144
- package/packages/storefront/package.json +13 -11
- package/packages/storefront/src/assets/firebaseui.css +648 -0
- package/packages/storefront/src/env.d.ts +1 -0
- package/packages/storefront/src/{components → lib/components}/Card.astro +0 -0
- package/packages/storefront/src/lib/components/LoginModal.vue +89 -0
- package/packages/storefront/src/lib/layouts/Layout.astro +84 -0
- package/packages/storefront/src/lib/layouts/meta/Head.astro +7 -0
- package/packages/storefront/src/lib/layouts/meta/Json.astro +34 -0
- package/packages/storefront/src/lib/ssr-context.ts +131 -0
- package/packages/storefront/src/lib/views/[...slug].astro +77 -0
- package/packages/storefront/src/lib/views/app/index.astro +0 -0
- package/packages/storefront/src/{pages/404.astro → lib/views/fallback.astro} +6 -1
- package/packages/storefront/src/lib/views/index.astro +87 -0
- package/packages/storefront/src/pages/[...slug].astro +12 -76
- package/packages/storefront/src/pages/fallback.astro +13 -0
- package/packages/storefront/src/pages/index.astro +15 -79
- package/packages/storefront/storefront.config.mjs +23 -6
- package/packages/storefront/tsconfig.json +4 -1
- package/packages/types/package.json +1 -1
- package/packages/apps/tiny-erp/lib/event-to-tiny.js +0 -115
- package/packages/apps/tiny-erp/lib/event-to-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js +0 -79
- package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js +0 -84
- package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js +0 -58
- package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js +0 -7
- package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +0 -92
- package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js +0 -158
- package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js +0 -46
- package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js +0 -193
- package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js +0 -199
- package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js +0 -129
- package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js +0 -34
- package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js +0 -39
- package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js.map +0 -1
- package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js +0 -47
- package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js.map +0 -1
- package/packages/apps/tiny-erp/lib/tiny-erp.js +0 -18
- package/packages/apps/tiny-erp/lib/tiny-erp.js.map +0 -1
- package/packages/apps/tiny-erp/lib/tiny-webhook.js +0 -92
- package/packages/apps/tiny-erp/lib/tiny-webhook.js.map +0 -1
- package/packages/modules/lib/firebase/ajv.js +0 -33
- package/packages/modules/lib/firebase/ajv.js.map +0 -1
- package/packages/modules/lib/firebase/call-app-module.js +0 -130
- package/packages/modules/lib/firebase/call-app-module.js.map +0 -1
- package/packages/modules/lib/firebase/checkout.js +0 -1
- package/packages/modules/lib/firebase/checkout.js.map +0 -1
- package/packages/modules/lib/firebase/handle-module.js +0 -165
- package/packages/modules/lib/firebase/handle-module.js.map +0 -1
- package/packages/modules/lib/firebase/proxy-apps.js +0 -1
- package/packages/modules/lib/firebase/proxy-apps.js.map +0 -1
- package/packages/modules/lib/firebase/serve-modules-api.js +0 -57
- package/packages/modules/lib/firebase/serve-modules-api.js.map +0 -1
- package/packages/modules/lib/firebase.js +0 -13
- package/packages/modules/lib/firebase.js.map +0 -1
- package/packages/modules/lib/index.js +0 -25
- package/packages/modules/lib/index.js.map +0 -1
- package/packages/storefront/dist/client/assets/404-_...d4aa8aff.css +0 -1
- package/packages/storefront/dist/client/assets/404-index.d9230d24.css +0 -1
- package/packages/storefront/dist/client/client.6d48c590.js +0 -1
- package/packages/storefront/src/layouts/Layout.astro +0 -63
- package/packages/storefront/src/types.ts +0 -18
package/.eslintrc.cjs
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
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.74](https://github.com/ecomplus/cloud-commerce/compare/v0.0.73...v0.0.74) (2022-09-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **cli:** Update default `firbase.json` config with cache headers ([d9e3e99](https://github.com/ecomplus/cloud-commerce/commit/d9e3e995e26ce75c8d19748313fa31d0982629e5))
|
|
11
|
+
* **storefront:** Initialize Firebase app with Analytics ([2a5fe36](https://github.com/ecomplus/cloud-commerce/commit/2a5fe36dea7d3c1b0bfeeb66dc4866e5c6c13cd0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **modules:** Fix schemas to draft-07 and properly call module handler ([#48](https://github.com/ecomplus/cloud-commerce/issues/48)) ([bd1fd5b](https://github.com/ecomplus/cloud-commerce/commit/bd1fd5b8e3f1b4c7f35ad66570f542738d388ac6))
|
|
17
|
+
|
|
18
|
+
### [0.0.73](https://github.com/ecomplus/cloud-commerce/compare/v0.0.72...v0.0.73) (2022-09-10)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **ssr:** Fix fallback and errors and skip cache/redirect handled by Astro SSR ([abe19ae](https://github.com/ecomplus/cloud-commerce/commit/abe19ae585698c7621aa3bc6cf26bbf8f816824a))
|
|
24
|
+
* **storefront:** Must prefetch defined API endpoints also for non-slug pages (home) ([c55f201](https://github.com/ecomplus/cloud-commerce/commit/c55f201c76b96c19c334c460df35baa5715ac5b1))
|
|
25
|
+
* **storefront:** Send `X-SSR-Error` with error message only ([7fafde1](https://github.com/ecomplus/cloud-commerce/commit/7fafde110ee9b6d9139b2ad0f7959826c1b08e74))
|
|
26
|
+
|
|
27
|
+
### [0.0.72](https://github.com/ecomplus/cloud-commerce/compare/v0.0.71...v0.0.72) (2022-09-09)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* **frenet:** Setup Frenet app from https://github.com/ecomplus/app-frenet ([#47](https://github.com/ecomplus/cloud-commerce/issues/47)) ([465a8c8](https://github.com/ecomplus/cloud-commerce/commit/465a8c8232a2cfb1e46b2c0b176a0b3ec04e213c))
|
|
33
|
+
* **storefront:** Setup `loadPageContext` function and pages base SSR :tada: ([a7127be](https://github.com/ecomplus/cloud-commerce/commit/a7127be516eb87a7ac3f6221b717d9708f174d8a))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **config:** Check env and defaults on `get()` ([f466f3b](https://github.com/ecomplus/cloud-commerce/commit/f466f3be32edeefbb85a71699d884e629041c0cf))
|
|
39
|
+
* Remove `content` symlink to prevent clone error ([f35bd83](https://github.com/ecomplus/cloud-commerce/commit/f35bd835f3089d655dfee2b629dd1cda82ae3986))
|
|
40
|
+
* **ssr:** Fix handling SSR fallback for 5xx error ([fa280ea](https://github.com/ecomplus/cloud-commerce/commit/fa280ea5947946cb2820f8ca4a5c81ced20e25cc))
|
|
41
|
+
* **storefront:** Update `cms` function to consider folder collection if filename with / ([2d90a0a](https://github.com/ecomplus/cloud-commerce/commit/2d90a0a359e0cec617269c96274df289988d06d6))
|
|
42
|
+
|
|
5
43
|
### [0.0.71](https://github.com/ecomplus/cloud-commerce/compare/v0.0.70...v0.0.71) (2022-09-08)
|
|
6
44
|
|
|
7
45
|
### [0.0.70](https://github.com/ecomplus/cloud-commerce/compare/v0.0.69...v0.0.70) (2022-09-07)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcommerce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.74",
|
|
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>",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"@commitlint/cli": "^17.1.2",
|
|
20
20
|
"@commitlint/config-conventional": "^17.1.0",
|
|
21
21
|
"@commitlint/rules": "^17.0.0",
|
|
22
|
-
"@types/node": "^18.
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
24
|
-
"@typescript-eslint/parser": "^5.
|
|
22
|
+
"@types/node": "^18.7.17",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
24
|
+
"@typescript-eslint/parser": "^5.37.0",
|
|
25
25
|
"esbuild": "^0.15.7",
|
|
26
|
-
"eslint": "^8.23.
|
|
26
|
+
"eslint": "^8.23.1",
|
|
27
27
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
28
28
|
"eslint-plugin-import": "^2.26.0",
|
|
29
29
|
"eslint-plugin-vue": "^9.4.0",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"node-fetch": "^3.2.10",
|
|
32
32
|
"standard-version": "^9.5.0",
|
|
33
33
|
"ts-node": "^10.9.1",
|
|
34
|
-
"turbo": "^1.4.
|
|
35
|
-
"typescript": "^4.8.
|
|
34
|
+
"turbo": "^1.4.6",
|
|
35
|
+
"typescript": "^4.8.3",
|
|
36
36
|
"vite": "^3.1.0",
|
|
37
|
-
"vitest": "^0.23.
|
|
37
|
+
"vitest": "^0.23.2",
|
|
38
38
|
"zx": "^7.0.8"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"postinstall": "husky install",
|
|
41
|
+
"postinstall": "husky install && pnpm run -r prepare-monorepo",
|
|
42
42
|
"new-pkg": "bash scripts/new-package.sh",
|
|
43
43
|
"build": "turbo run build",
|
|
44
44
|
"test": "turbo run test",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Please refer to GitHub [repository releases](https://github.com/ecomplus/cloud-commerce/releases) or monorepo unified [CHANGELOG.md](https://github.com/ecomplus/cloud-commerce/blob/main/CHANGELOG.md).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# `@cloudcommerce/app-frenet`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frenet.js","sourceRoot":"","sources":["../src/frenet.ts"],"names":[],"mappings":"AAEA,OAAO,uBAAuB,MAAM,iCAAiC,CAAC;AAEtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAsB,EAAE,EAAE;IAChE,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './frenet';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './frenet.js';
|
|
2
2
|
// # sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
const getDimension = (side, item) => {
|
|
4
|
+
if (item.dimensions && item.dimensions[side]) {
|
|
5
|
+
const { value, unit } = item.dimensions[side];
|
|
6
|
+
switch (unit) {
|
|
7
|
+
case 'm':
|
|
8
|
+
return value * 100;
|
|
9
|
+
case 'dm':
|
|
10
|
+
return value * 10;
|
|
11
|
+
case 'cm':
|
|
12
|
+
return value;
|
|
13
|
+
default:
|
|
14
|
+
return 10;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return 10;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default async ({ params, application }) => {
|
|
21
|
+
const config = {
|
|
22
|
+
...application.data,
|
|
23
|
+
...application.hidden_data,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (!config.frenet_access_token) {
|
|
27
|
+
return {
|
|
28
|
+
error: 'FRENET_ERR',
|
|
29
|
+
message: 'Frenet token is unset on app hidden data (calculate unavailable) for this store',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// https://apx-mods.e-com.plus/api/v1/calculate_shipping/response_schema.json?store_id=100
|
|
34
|
+
const { items, subtotal, to } = params;
|
|
35
|
+
const response = {
|
|
36
|
+
shipping_services: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (config.free_shipping_from_value) {
|
|
40
|
+
response.free_shipping_from_value = config.free_shipping_from_value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!items || !subtotal || !to || !config.from) {
|
|
44
|
+
// parameters required to perform the request
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// calculate
|
|
49
|
+
let took = Date.now();
|
|
50
|
+
const getSchemaFrenet = () => new Promise((resolve, reject) => {
|
|
51
|
+
try {
|
|
52
|
+
const schema = {
|
|
53
|
+
SellerCEP: config.from.zip.replace('-', ''),
|
|
54
|
+
RecipientCEP: to.zip.replace('-', ''),
|
|
55
|
+
ShipmentInvoiceValue: subtotal,
|
|
56
|
+
ShippingItemArray: [],
|
|
57
|
+
};
|
|
58
|
+
items.forEach((item) => {
|
|
59
|
+
const { weight, quantity } = item;
|
|
60
|
+
const calculeWeight = () => {
|
|
61
|
+
if (weight) {
|
|
62
|
+
return (weight.unit && weight.unit === 'g') ? (weight.value / 1000) : weight.value;
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
};
|
|
66
|
+
schema.ShippingItemArray.push({
|
|
67
|
+
Weight: calculeWeight(),
|
|
68
|
+
Length: getDimension('length', item),
|
|
69
|
+
Height: getDimension('height', item),
|
|
70
|
+
Width: getDimension('width', item),
|
|
71
|
+
Quantity: quantity,
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
resolve({ schema });
|
|
75
|
+
} catch (error) {
|
|
76
|
+
const err = new Error('Error with the body sent by the module');
|
|
77
|
+
err.name = 'ParseFrenetSchemaError';
|
|
78
|
+
err.error = error;
|
|
79
|
+
reject(err);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const { schema } = await getSchemaFrenet();
|
|
85
|
+
const { data } = await axios({
|
|
86
|
+
url: 'http://api.frenet.com.br/shipping/quote',
|
|
87
|
+
method: 'post',
|
|
88
|
+
headers: {
|
|
89
|
+
'Content-Type': 'application/json',
|
|
90
|
+
token: config.frenet_access_token,
|
|
91
|
+
},
|
|
92
|
+
data: schema,
|
|
93
|
+
});
|
|
94
|
+
if (data && !data.ShippingSevicesArray) {
|
|
95
|
+
return {
|
|
96
|
+
error: 'SHIPPING_QUOTE_REQUEST_ERR',
|
|
97
|
+
message: 'ShippingSevicesArray property not found, try Later',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
took = Date.now() - took;
|
|
101
|
+
const { ShippingSevicesArray } = data;
|
|
102
|
+
|
|
103
|
+
if (ShippingSevicesArray && Array.isArray(ShippingSevicesArray)
|
|
104
|
+
&& ShippingSevicesArray.length) {
|
|
105
|
+
if (ShippingSevicesArray[0].Error && ShippingSevicesArray[0].Msg) {
|
|
106
|
+
return {
|
|
107
|
+
error: 'CALCULATE_REQUEST_ERR',
|
|
108
|
+
message: ShippingSevicesArray[0].Msg,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const services = ShippingSevicesArray
|
|
114
|
+
.filter((service) => !service.Error)
|
|
115
|
+
.map((service) => {
|
|
116
|
+
return {
|
|
117
|
+
label: service.ServiceDescription,
|
|
118
|
+
carrier: service.Carrier,
|
|
119
|
+
service_name: service.ServiceDescription,
|
|
120
|
+
service_code: `FR${service.ServiceCode}`,
|
|
121
|
+
shipping_line: {
|
|
122
|
+
from: config.from,
|
|
123
|
+
to,
|
|
124
|
+
delivery_time: {
|
|
125
|
+
days: parseInt(service.DeliveryTime || service.OriginalDeliveryTime, 10) || 14,
|
|
126
|
+
working_days: true,
|
|
127
|
+
},
|
|
128
|
+
price: parseFloat(service.OriginalShippingPrice || service.ShippingPrice) || 0,
|
|
129
|
+
total_price: parseFloat(service.ShippingPrice || service.OriginalShippingPrice) || 0,
|
|
130
|
+
custom_fields: [
|
|
131
|
+
{
|
|
132
|
+
field: 'by_frenet',
|
|
133
|
+
value: 'true',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
field: 'frenet:took',
|
|
137
|
+
value: String(took),
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
response.shipping_services = services;
|
|
145
|
+
return response;
|
|
146
|
+
} catch (err) {
|
|
147
|
+
return {
|
|
148
|
+
error: 'FRENET_ERR',
|
|
149
|
+
message: err.message,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloudcommerce/app-frenet",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.74",
|
|
5
|
+
"description": "E-Com Plus Cloud Commerce app for Frenet shipping calculation",
|
|
6
|
+
"main": "lib/frenet.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ecomplus/cloud-commerce.git",
|
|
10
|
+
"directory": "packages/apps/frenet"
|
|
11
|
+
},
|
|
12
|
+
"author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
|
|
13
|
+
"license": "Apache 2.0 with Commons Clause",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ecomplus/cloud-commerce/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/packages/apps/frenet#readme",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "sh ../../../scripts/build-lib.sh"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@cloudcommerce/api": "workspace:*",
|
|
23
|
+
"axios": "^0.27.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@cloudcommerce/types": "workspace:*"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
3
|
+
import handleCalculateShipping from '../lib-mjs/calculate-frenet.mjs';
|
|
4
|
+
|
|
5
|
+
export const calculateShipping = async (modBody: AppModuleBody) => {
|
|
6
|
+
return handleCalculateShipping(modBody);
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './frenet';
|
|
@@ -54,6 +54,53 @@
|
|
|
54
54
|
"region": "southamerica-east1"
|
|
55
55
|
}
|
|
56
56
|
],
|
|
57
|
+
"headers": [
|
|
58
|
+
{
|
|
59
|
+
"source": "/api/**",
|
|
60
|
+
"headers": [
|
|
61
|
+
{
|
|
62
|
+
"key": "Cache-Control",
|
|
63
|
+
"value": "private, max-age=30, must-revalidate"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"source": "/img/**",
|
|
69
|
+
"headers": [
|
|
70
|
+
{
|
|
71
|
+
"key": "Cache-Control",
|
|
72
|
+
"value": "public, max-age=300, s-maxage=60, must-revalidate"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"source": "/assets/**",
|
|
78
|
+
"headers": [
|
|
79
|
+
{
|
|
80
|
+
"key": "Cache-Control",
|
|
81
|
+
"value": "public, max-age=86400, s-maxage=600"
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"source": "/app/**",
|
|
87
|
+
"headers": [
|
|
88
|
+
{
|
|
89
|
+
"key": "Cache-Control",
|
|
90
|
+
"value": "public, max-age=600, stale-while-revalidate=900"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"source": "**/*.?????*.@(js|css|webp|avif)",
|
|
96
|
+
"headers": [
|
|
97
|
+
{
|
|
98
|
+
"key": "Cache-Control",
|
|
99
|
+
"value": "public, max-age=31536000, immutable"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
],
|
|
57
104
|
"cleanUrls": true
|
|
58
105
|
},
|
|
59
106
|
"storage": {
|
|
@@ -9,19 +9,20 @@ const _env = import.meta.env
|
|
|
9
9
|
|| globalThis;
|
|
10
10
|
const deepmerge = Deepmerge();
|
|
11
11
|
const self = globalThis.__cloudCommerce || {
|
|
12
|
-
config: {
|
|
13
|
-
lang: _env.ECOM_LANG || DEFAULT_LANG,
|
|
14
|
-
currency: _env.ECOM_CURRENCY || DEFAULT_CURRENCY,
|
|
15
|
-
currencySymbol: _env.ECOM_CURRENCY_SYMBOL || DEFAULT_CURRENCY_SYMBOL,
|
|
16
|
-
countryCode: _env.ECOM_COUNTRY_CODE || DEFAULT_COUNTRY_CODE,
|
|
17
|
-
storeId: Number(_env.ECOM_STORE_ID),
|
|
18
|
-
},
|
|
12
|
+
config: {},
|
|
19
13
|
};
|
|
20
14
|
globalThis.__cloudCommerce = self;
|
|
21
15
|
|
|
22
16
|
export default {
|
|
23
17
|
get() {
|
|
24
|
-
return
|
|
18
|
+
return {
|
|
19
|
+
lang: _env.ECOM_LANG || DEFAULT_LANG,
|
|
20
|
+
currency: _env.ECOM_CURRENCY || DEFAULT_CURRENCY,
|
|
21
|
+
currencySymbol: _env.ECOM_CURRENCY_SYMBOL || DEFAULT_CURRENCY_SYMBOL,
|
|
22
|
+
countryCode: _env.ECOM_COUNTRY_CODE || DEFAULT_COUNTRY_CODE,
|
|
23
|
+
storeId: Number(_env.ECOM_STORE_ID),
|
|
24
|
+
...self.config,
|
|
25
|
+
};
|
|
25
26
|
},
|
|
26
27
|
set(config) {
|
|
27
28
|
self.config = deepmerge(self.config, config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAUpB,aAAa;AACb,MAAM,IAAI,GAAwB,MAAM,CAAC,IAAI,CAAC,GAAG;OAC5C,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,EAAE,GAAG,CAAC;OAC7C,UAAU,CAAC;AAEhB,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAE9B,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAUpB,aAAa;AACb,MAAM,IAAI,GAAwB,MAAM,CAAC,IAAI,CAAC,GAAG;OAC5C,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,EAAE,GAAG,CAAC;OAC7C,UAAU,CAAC;AAEhB,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAE9B,MAAM,IAAI,GAAG,UAAU,CAAC,eAAe,IAAI;IACzC,MAAM,EAAE,EAAE;CACX,CAAC;AACF,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC;AAElC,eAAe;IACb,GAAG;QACD,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,SAAS,IAAI,YAAY;YACpC,QAAQ,EAAE,IAAI,CAAC,aAAa,IAAI,gBAAgB;YAChD,cAAc,EAAE,IAAI,CAAC,oBAAoB,IAAI,uBAAuB;YACpE,WAAW,EAAE,IAAI,CAAC,iBAAiB,IAAI,oBAAoB;YAC3D,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;YACnC,GAAG,IAAI,CAAC,MAAM;SACf,CAAC;IACJ,CAAC;IACD,GAAG,CAAC,MAAM;QACR,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC;SACrC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -21,20 +21,21 @@ const _env: Record<string, any> = import.meta.env
|
|
|
21
21
|
|
|
22
22
|
const deepmerge = Deepmerge();
|
|
23
23
|
|
|
24
|
-
const self
|
|
25
|
-
config: {
|
|
26
|
-
lang: _env.ECOM_LANG || DEFAULT_LANG,
|
|
27
|
-
currency: _env.ECOM_CURRENCY || DEFAULT_CURRENCY,
|
|
28
|
-
currencySymbol: _env.ECOM_CURRENCY_SYMBOL || DEFAULT_CURRENCY_SYMBOL,
|
|
29
|
-
countryCode: _env.ECOM_COUNTRY_CODE || DEFAULT_COUNTRY_CODE,
|
|
30
|
-
storeId: Number(_env.ECOM_STORE_ID),
|
|
31
|
-
},
|
|
24
|
+
const self = globalThis.__cloudCommerce || {
|
|
25
|
+
config: {},
|
|
32
26
|
};
|
|
33
27
|
globalThis.__cloudCommerce = self;
|
|
34
28
|
|
|
35
29
|
export default {
|
|
36
|
-
get() {
|
|
37
|
-
return
|
|
30
|
+
get(): BaseConfig {
|
|
31
|
+
return {
|
|
32
|
+
lang: _env.ECOM_LANG || DEFAULT_LANG,
|
|
33
|
+
currency: _env.ECOM_CURRENCY || DEFAULT_CURRENCY,
|
|
34
|
+
currencySymbol: _env.ECOM_CURRENCY_SYMBOL || DEFAULT_CURRENCY_SYMBOL,
|
|
35
|
+
countryCode: _env.ECOM_COUNTRY_CODE || DEFAULT_COUNTRY_CODE,
|
|
36
|
+
storeId: Number(_env.ECOM_STORE_ID),
|
|
37
|
+
...self.config,
|
|
38
|
+
};
|
|
38
39
|
},
|
|
39
40
|
set(config) {
|
|
40
41
|
self.config = deepmerge(self.config, config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,MAAsB,MAAM,uBAAuB,CAAC;AAE3D,MAAM,aAAa,GAAmB;IACpC,qBAAqB;IACrB,cAAc;IACd,mBAAmB;IACnB,sBAAsB;CACvB,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,8BAA8B;IACrC,oBAAoB,EAAE;QACpB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,oBAAoB;KAC1D;IACD,IAAI,EAAE;QACJ,SAAS,EAAE;YACT,KAAK,EAAE,IAAI;SACZ;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,IAAI;SACZ;QACD,cAAc,EAAE;YACd,KAAK,EAAE,IAAI;SACZ;QACD,OAAO,EAAE;YACP,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,aAAa;SACtB;KACF;CACF,CAAC;AACF,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAExB,eAAe,MAId,CAAC"}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,MAAsB,MAAM,uBAAuB,CAAC;AAE3D,MAAM,aAAa,GAAmB;IACpC,qBAAqB;IACrB,cAAc;IACd,mBAAmB;IACnB,sBAAsB;CACvB,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,8BAA8B;IACrC,oBAAoB,EAAE;QACpB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,oBAAoB;KAC1D;IACD,IAAI,EAAE;QACJ,SAAS,EAAE;YACT,KAAK,EAAE,IAAI;SACZ;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,IAAI;SACZ;QACD,cAAc,EAAE;YACd,KAAK,EAAE,IAAI;SACZ;QACD,MAAM,EAAE;YACN,KAAK,EAAE,IAAI;SACZ;QACD,OAAO,EAAE;YACP,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,aAAa;SACtB;KACF;CACF,CAAC;AACF,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAExB,eAAe,MAId,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/modules",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.74",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce modules API",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
7
7
|
"exports": {
|
|
@@ -28,8 +28,10 @@
|
|
|
28
28
|
"@cloudcommerce/app-correios": "workspace:*",
|
|
29
29
|
"@cloudcommerce/app-custom-shipping": "workspace:*",
|
|
30
30
|
"@cloudcommerce/app-discounts": "workspace:*",
|
|
31
|
+
"@cloudcommerce/app-frenet": "workspace:*",
|
|
31
32
|
"@cloudcommerce/firebase": "workspace:*",
|
|
32
33
|
"ajv": "^8.11.0",
|
|
34
|
+
"ajv-formats": "^2.1.1",
|
|
33
35
|
"axios": "^0.27.2",
|
|
34
36
|
"firebase-admin": "^11.0.1",
|
|
35
37
|
"firebase-functions": "^3.23.0",
|