cloudcommerce 0.0.72 → 0.0.73

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 (32) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +1 -1
  3. package/packages/api/package.json +1 -1
  4. package/packages/apps/correios/package.json +1 -1
  5. package/packages/apps/custom-shipping/package.json +1 -1
  6. package/packages/apps/discounts/package.json +1 -1
  7. package/packages/apps/frenet/package.json +1 -1
  8. package/packages/apps/tiny-erp/package.json +1 -1
  9. package/packages/cli/package.json +1 -1
  10. package/packages/config/package.json +1 -1
  11. package/packages/events/package.json +1 -1
  12. package/packages/firebase/package.json +1 -1
  13. package/packages/modules/package.json +1 -1
  14. package/packages/passport/package.json +1 -1
  15. package/packages/ssr/lib/firebase/serve-storefront.js +13 -32
  16. package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
  17. package/packages/ssr/package.json +1 -1
  18. package/packages/ssr/src/firebase/serve-storefront.ts +13 -37
  19. package/packages/storefront/dist/client/assets/{404-500-_...d4aa8aff.css → _...d4aa8aff.css} +0 -0
  20. package/packages/storefront/dist/client/assets/{404-500-index.d9230d24.css → fallback-index.d9230d24.css} +0 -0
  21. package/packages/storefront/dist/client/assets/{404.b3ead908.css → fallback.9745a8aa.css} +1 -1
  22. package/packages/storefront/dist/server/entry.mjs +146 -174
  23. package/packages/storefront/package.json +1 -1
  24. package/packages/storefront/src/lib/ssr-context.ts +54 -30
  25. package/packages/storefront/src/lib/views/{404.astro → fallback.astro} +1 -1
  26. package/packages/storefront/src/pages/[...slug].astro +7 -2
  27. package/packages/storefront/src/pages/{404.astro → fallback.astro} +2 -2
  28. package/packages/storefront/src/pages/index.astro +7 -2
  29. package/packages/types/package.json +1 -1
  30. package/packages/storefront/dist/client/assets/500.d5d7700b.css +0 -1
  31. package/packages/storefront/src/lib/views/500.astro +0 -79
  32. package/packages/storefront/src/pages/500.astro +0 -13
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
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.73](https://github.com/ecomplus/cloud-commerce/compare/v0.0.72...v0.0.73) (2022-09-10)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **ssr:** Fix fallback and errors and skip cache/redirect handled by Astro SSR ([abe19ae](https://github.com/ecomplus/cloud-commerce/commit/abe19ae585698c7621aa3bc6cf26bbf8f816824a))
11
+ * **storefront:** Must prefetch defined API endpoints also for non-slug pages (home) ([c55f201](https://github.com/ecomplus/cloud-commerce/commit/c55f201c76b96c19c334c460df35baa5715ac5b1))
12
+ * **storefront:** Send `X-SSR-Error` with error message only ([7fafde1](https://github.com/ecomplus/cloud-commerce/commit/7fafde110ee9b6d9139b2ad0f7959826c1b08e74))
13
+
5
14
  ### [0.0.72](https://github.com/ecomplus/cloud-commerce/compare/v0.0.71...v0.0.72) (2022-09-09)
6
15
 
7
16
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
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>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/api.js",
7
7
  "types": "lib/api.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-correios",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce app for Correios shipping calculation",
6
6
  "main": "lib/correios.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-custom-shipping",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce app for custom shipping methods",
6
6
  "main": "lib/custom-shipping.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-discounts",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce app for complex discount rules",
6
6
  "main": "lib/discounts.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-frenet",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce app for Frenet shipping calculation",
6
6
  "main": "lib/frenet.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-tiny-erp",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce app for Tiny ERP",
6
6
  "main": "lib/tiny-erp.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/cli",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce CLI tools",
6
6
  "bin": {
7
7
  "cloudcommerce": "./bin/run.mjs"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/config",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce base config",
6
6
  "main": "lib/config.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/events",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce app events",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/firebase",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce on Firebase",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/modules",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce modules API",
6
6
  "main": "lib/index.cjs",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/passport",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,10 +1,9 @@
1
1
  import { join as joinPath } from 'path';
2
2
  import { readFile } from 'fs/promises';
3
3
 
4
- const { STOREFRONT_BASE_DIR, STOREFRONT_LONG_CACHE } = process.env;
4
+ const { STOREFRONT_BASE_DIR } = process.env;
5
5
  const baseDir = STOREFRONT_BASE_DIR || process.cwd();
6
6
  const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
7
- const isLongCache = String(STOREFRONT_LONG_CACHE).toLowerCase() === 'true';
8
7
 
9
8
  export default (req, res) => {
10
9
  const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
@@ -14,32 +13,16 @@ export default (req, res) => {
14
13
  .set('Cache-Control', (typeof global.cache_control === 'function' && global.cache_control(status))
15
14
  || defaultCache);
16
15
  };
17
- const redirect = (toUrl, status = 302) => {
18
- let sMaxAge = status === 301 ? 360 : 12;
19
- if (isLongCache) {
20
- sMaxAge *= 10;
21
- }
22
- let cacheControl = `public, max-age=30, s-maxage=${sMaxAge}`;
23
- if (status === 302) {
24
- cacheControl += ', proxy-revalidate';
25
- }
26
- setStatusAndCache(status, cacheControl)
27
- .set('Location', toUrl).end();
28
- };
29
- const fallback = (status = 404) => {
30
- const is404 = status === 404;
31
- if (is404 && url.slice(-1) === '/') {
32
- redirect(url.slice(0, -1));
33
- } else if (url !== `/${status}` && (/\/[^/.]+$/.test(url) || /\.x?html$/.test(url))) {
34
- setStatusAndCache(status, `public, max-age=${(isLongCache ? 120 : 30)}`)
16
+ const fallback = (err, status = 500) => {
17
+ if (url !== '/fallback' && (/\/[^/.]+$/.test(url) || /\.x?html$/.test(url))) {
18
+ setStatusAndCache(status, 'public, max-age=120')
35
19
  .send('<html><head>'
36
- + `<meta http-equiv="refresh" content="0; url=/${status}?url=${encodeURIComponent(url)}"/>`
37
- + '</head><body></body></html>');
20
+ + '<meta http-equiv="refresh" content="0; '
21
+ + `url=/fallback?status=${status}&url=${encodeURIComponent(url)}"/>`
22
+ + `</head><body>${err.toString()}</body></html>`);
38
23
  } else {
39
- setStatusAndCache(status, isLongCache && is404
40
- ? 'public, max-age=60, s-maxage=86400'
41
- : 'public, max-age=60, s-maxage=300')
42
- .end();
24
+ setStatusAndCache(status, 'public, max-age=120, s-maxage=600')
25
+ .send(err.toString());
43
26
  }
44
27
  };
45
28
  /*
@@ -49,19 +32,17 @@ export default (req, res) => {
49
32
  */
50
33
  global.ssr_handler(req, res, async (err) => {
51
34
  if (err) {
52
- res.set('X-SSR-Error', err.stack);
53
- fallback(500);
35
+ res.set('X-SSR-Error', err.message);
36
+ fallback(err);
54
37
  return;
55
38
  }
56
39
  const local = new URL(`.${url}`, clientRoot);
57
40
  try {
58
41
  const data = await readFile(local);
59
- setStatusAndCache(200, isLongCache
60
- ? 'public, max-age=60, s-maxage=604800'
61
- : 'public, max-age=60, s-maxage=600, stale-while-revalidate=2592000')
42
+ setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
62
43
  .send(data);
63
44
  } catch {
64
- fallback();
45
+ fallback(err, 404);
65
46
  }
66
47
  });
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AI;YACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;YACnC,iBAAiB,CAAC,GAAG,EAAE,kCAAkC,CAAC;iBACvD,IAAI,CAAC,IAAI,CAAC,CAAC;SACf;QAAC,MAAM;YACN,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SACpB;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.73",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -2,14 +2,9 @@ import type { Request, Response } from 'firebase-functions';
2
2
  import { join as joinPath } from 'path';
3
3
  import { readFile } from 'fs/promises';
4
4
 
5
- const {
6
- STOREFRONT_BASE_DIR,
7
- STOREFRONT_LONG_CACHE,
8
- } = process.env;
9
-
5
+ const { STOREFRONT_BASE_DIR } = process.env;
10
6
  const baseDir = STOREFRONT_BASE_DIR || process.cwd();
11
7
  const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
12
- const isLongCache = String(STOREFRONT_LONG_CACHE).toLowerCase() === 'true';
13
8
 
14
9
  export default (req: Request, res: Response) => {
15
10
  const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
@@ -24,33 +19,16 @@ export default (req: Request, res: Response) => {
24
19
  );
25
20
  };
26
21
 
27
- const redirect = (toUrl: string, status = 302) => {
28
- let sMaxAge = status === 301 ? 360 : 12;
29
- if (isLongCache) {
30
- sMaxAge *= 10;
31
- }
32
- let cacheControl = `public, max-age=30, s-maxage=${sMaxAge}`;
33
- if (status === 302) {
34
- cacheControl += ', proxy-revalidate';
35
- }
36
- setStatusAndCache(status, cacheControl)
37
- .set('Location', toUrl).end();
38
- };
39
-
40
- const fallback = (status = 404) => {
41
- const is404 = status === 404;
42
- if (is404 && url.slice(-1) === '/') {
43
- redirect(url.slice(0, -1));
44
- } else if (url !== `/${status}` && (/\/[^/.]+$/.test(url) || /\.x?html$/.test(url))) {
45
- setStatusAndCache(status, `public, max-age=${(isLongCache ? 120 : 30)}`)
22
+ const fallback = (err: any, status = 500) => {
23
+ if (url !== '/fallback' && (/\/[^/.]+$/.test(url) || /\.x?html$/.test(url))) {
24
+ setStatusAndCache(status, 'public, max-age=120')
46
25
  .send('<html><head>'
47
- + `<meta http-equiv="refresh" content="0; url=/${status}?url=${encodeURIComponent(url)}"/>`
48
- + '</head><body></body></html>');
26
+ + '<meta http-equiv="refresh" content="0; '
27
+ + `url=/fallback?status=${status}&url=${encodeURIComponent(url)}"/>`
28
+ + `</head><body>${err.toString()}</body></html>`);
49
29
  } else {
50
- setStatusAndCache(status, isLongCache && is404
51
- ? 'public, max-age=60, s-maxage=86400'
52
- : 'public, max-age=60, s-maxage=300')
53
- .end();
30
+ setStatusAndCache(status, 'public, max-age=120, s-maxage=600')
31
+ .send(err.toString());
54
32
  }
55
33
  };
56
34
 
@@ -61,19 +39,17 @@ export default (req: Request, res: Response) => {
61
39
  */
62
40
  global.ssr_handler(req, res, async (err: any) => {
63
41
  if (err) {
64
- res.set('X-SSR-Error', err.stack);
65
- fallback(500);
42
+ res.set('X-SSR-Error', err.message);
43
+ fallback(err);
66
44
  return;
67
45
  }
68
46
  const local = new URL(`.${url}`, clientRoot);
69
47
  try {
70
48
  const data = await readFile(local);
71
- setStatusAndCache(200, isLongCache
72
- ? 'public, max-age=60, s-maxage=604800'
73
- : 'public, max-age=60, s-maxage=600, stale-while-revalidate=2592000')
49
+ setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
74
50
  .send(data);
75
51
  } catch {
76
- fallback();
52
+ fallback(err, 404);
77
53
  }
78
54
  });
79
55
  };
@@ -1 +1 @@
1
- :root{--astro-gradient: linear-gradient(0deg,#4F39FA, #DA62C4)}h1:where(.astro-DJT3DWAO){margin:2rem 0}main:where(.astro-DJT3DWAO){margin:auto;padding:1em;max-width:60ch}.text-gradient:where(.astro-DJT3DWAO){font-weight:900;background-image:var(--astro-gradient);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-size:100% 200%;background-position-y:100%;border-radius:.4rem;animation:pulse 4s ease-in-out infinite}@keyframes pulse{0%,to{background-position-y:0%}50%{background-position-y:80%}}.instructions:where(.astro-DJT3DWAO){line-height:1.6;margin:1rem 0;background:#4F39FA;padding:1rem;border-radius:.4rem;color:var(--color-bg)}.instructions:where(.astro-DJT3DWAO) code:where(.astro-DJT3DWAO){font-size:.875em;border:.1em solid var(--color-border);border-radius:4px;padding:.15em .25em}.link-card-grid:where(.astro-DJT3DWAO){display:grid;grid-template-columns:repeat(auto-fit,minmax(24ch,1fr));gap:1rem;padding:0}
1
+ :root{--astro-gradient: linear-gradient(0deg,#4F39FA, #DA62C4)}h1:where(.astro-HIITKN5F){margin:2rem 0}main:where(.astro-HIITKN5F){margin:auto;padding:1em;max-width:60ch}.text-gradient:where(.astro-HIITKN5F){font-weight:900;background-image:var(--astro-gradient);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-size:100% 200%;background-position-y:100%;border-radius:.4rem;animation:pulse 4s ease-in-out infinite}@keyframes pulse{0%,to{background-position-y:0%}50%{background-position-y:80%}}.instructions:where(.astro-HIITKN5F){line-height:1.6;margin:1rem 0;background:#4F39FA;padding:1rem;border-radius:.4rem;color:var(--color-bg)}.instructions:where(.astro-HIITKN5F) code:where(.astro-HIITKN5F){font-size:.875em;border:.1em solid var(--color-border);border-radius:4px;padding:.15em .25em}.link-card-grid:where(.astro-HIITKN5F){display:grid;grid-template-columns:repeat(auto-fit,minmax(24ch,1fr));gap:1rem;padding:0}