cloudcommerce 0.0.71 → 0.0.72

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 (69) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/CHANGELOG.md +16 -0
  3. package/package.json +2 -2
  4. package/packages/api/package.json +1 -1
  5. package/packages/apps/correios/package.json +1 -1
  6. package/packages/apps/custom-shipping/package.json +1 -1
  7. package/packages/apps/discounts/package.json +1 -1
  8. package/packages/apps/frenet/CHANGELOG.md +1 -0
  9. package/packages/apps/frenet/README.md +1 -0
  10. package/packages/apps/frenet/lib/frenet.d.ts +2 -0
  11. package/packages/apps/frenet/lib/frenet.js +6 -0
  12. package/packages/apps/frenet/lib/frenet.js.map +1 -0
  13. package/packages/apps/frenet/lib/index.d.ts +1 -0
  14. package/packages/apps/frenet/lib/index.js +2 -0
  15. package/packages/apps/frenet/lib/index.js.map +1 -0
  16. package/packages/apps/frenet/lib-mjs/calculate-frenet.mjs +152 -0
  17. package/packages/apps/frenet/package.json +28 -0
  18. package/packages/apps/frenet/src/frenet.ts +7 -0
  19. package/packages/apps/frenet/src/index.ts +1 -0
  20. package/packages/apps/frenet/tsconfig.json +6 -0
  21. package/packages/apps/tiny-erp/package.json +1 -1
  22. package/packages/cli/package.json +1 -1
  23. package/packages/config/lib/config.js +9 -8
  24. package/packages/config/lib/config.js.map +1 -1
  25. package/packages/config/package.json +1 -1
  26. package/packages/config/src/config.ts +11 -10
  27. package/packages/events/package.json +1 -1
  28. package/packages/firebase/lib/config.d.ts +3 -0
  29. package/packages/firebase/lib/config.js +3 -0
  30. package/packages/firebase/lib/config.js.map +1 -1
  31. package/packages/firebase/package.json +1 -1
  32. package/packages/firebase/src/config.ts +3 -0
  33. package/packages/modules/lib/firebase/call-app-module.js +5 -0
  34. package/packages/modules/lib/firebase/call-app-module.js.map +1 -1
  35. package/packages/modules/package.json +2 -1
  36. package/packages/modules/src/firebase/call-app-module.ts +5 -0
  37. package/packages/passport/package.json +1 -1
  38. package/packages/ssr/lib/firebase/serve-storefront.js +6 -5
  39. package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
  40. package/packages/ssr/package.json +1 -1
  41. package/packages/ssr/src/firebase/serve-storefront.ts +6 -5
  42. package/packages/storefront/dist/client/assets/{404-_...d4aa8aff.css → 404-500-_...d4aa8aff.css} +0 -0
  43. package/packages/storefront/dist/client/assets/{404-index.d9230d24.css → 404-500-index.d9230d24.css} +0 -0
  44. package/packages/storefront/dist/client/assets/{index.53a3a3e0.css → 404.b3ead908.css} +1 -1
  45. package/packages/storefront/dist/client/assets/{404.530428e5.css → 500.d5d7700b.css} +1 -1
  46. package/packages/storefront/dist/client/assets/{_...98510c96.css → _...c08e0a75.css} +1 -1
  47. package/packages/storefront/dist/client/assets/index.9745690c.css +1 -0
  48. package/packages/storefront/dist/server/entry.mjs +398 -115
  49. package/packages/storefront/package.json +3 -3
  50. package/packages/storefront/src/env.d.ts +1 -0
  51. package/packages/storefront/src/{components → lib/components}/Card.astro +0 -0
  52. package/packages/storefront/src/lib/components/LoginModal.vue +56 -0
  53. package/packages/storefront/src/{layouts → lib/layouts}/Layout.astro +8 -11
  54. package/packages/storefront/src/lib/layouts/meta/Head.astro +7 -0
  55. package/packages/storefront/src/lib/layouts/meta/Json.astro +34 -0
  56. package/packages/storefront/src/lib/ssr-context.ts +107 -0
  57. package/packages/storefront/src/lib/views/404.astro +79 -0
  58. package/packages/storefront/src/lib/views/500.astro +79 -0
  59. package/packages/storefront/src/lib/views/[...slug].astro +77 -0
  60. package/packages/storefront/src/lib/views/app/index.astro +0 -0
  61. package/packages/storefront/src/lib/views/index.astro +87 -0
  62. package/packages/storefront/src/pages/404.astro +10 -71
  63. package/packages/storefront/src/pages/500.astro +13 -0
  64. package/packages/storefront/src/pages/[...slug].astro +7 -76
  65. package/packages/storefront/src/pages/index.astro +10 -79
  66. package/packages/storefront/storefront.config.mjs +23 -6
  67. package/packages/storefront/tsconfig.json +4 -1
  68. package/packages/types/package.json +1 -1
  69. package/packages/storefront/src/types.ts +0 -18
@@ -0,0 +1,13 @@
1
+ ---
2
+ import View500 from '../lib/views/500.astro';
3
+ import loadPageContext, { PageContext } from '../lib/ssr-context';
4
+
5
+ let pageContext: PageContext;
6
+ try {
7
+ pageContext = await loadPageContext(Astro);
8
+ } catch (err) {
9
+ return err.astroResponse;
10
+ }
11
+ ---
12
+
13
+ <View500 pageContext={pageContext} />
@@ -1,82 +1,13 @@
1
1
  ---
2
- import api from '@cloudcommerce/api';
3
- import '../../storefront.config.mjs';
4
- import Layout from '../layouts/Layout.astro';
2
+ import ViewWildcard from '../lib/views/[...slug].astro';
3
+ import loadPageContext, { PageContext } from '../lib/ssr-context';
5
4
 
6
- const { slug } = Astro.params as { slug: string };
7
- let resource: string;
8
- let doc: Record<string, any>;
5
+ let pageContext: PageContext;
9
6
  try {
10
- const { data } = await api.get(`slugs/${slug}`, { fetch });
11
- resource = data.resource;
12
- doc = data.doc;
13
- } catch {
14
- return Astro.redirect(`/404?url=${encodeURIComponent(`/${slug}`)}`);
7
+ pageContext = await loadPageContext(Astro);
8
+ } catch (err) {
9
+ return err.astroResponse;
15
10
  }
16
11
  ---
17
12
 
18
- <Layout title={doc.name}>
19
- <main>
20
- <h1>Hello <span class="text-gradient">{doc.name}</span></h1>
21
- <hr>
22
- <div class="mt-3">
23
- <mark>{doc._id}</mark> from <i>{resource}</i>
24
- <p>{Math.random()}</p>
25
- <em>Lorem ipsum dolor sit amet</em>
26
- </div>
27
- </main>
28
- </Layout>
29
-
30
- <style>
31
- :root {
32
- --astro-gradient: linear-gradient(0deg,#4F39FA, #DA62C4);
33
- }
34
-
35
- h1 {
36
- margin: 2rem 0;
37
- }
38
-
39
- main {
40
- margin: auto;
41
- padding: 1em;
42
- max-width: 60ch;
43
- }
44
-
45
- .text-gradient {
46
- font-weight: 900;
47
- background-image: var(--astro-gradient);
48
- -webkit-background-clip: text;
49
- -webkit-text-fill-color: transparent;
50
- background-size: 100% 200%;
51
- background-position-y: 100%;
52
- border-radius: 0.4rem;
53
- animation: pulse 4s ease-in-out infinite;
54
- }
55
-
56
- @keyframes pulse {
57
- 0%, 100% { background-position-y: 0%; }
58
- 50% { background-position-y: 80%; }
59
- }
60
-
61
- .instructions {
62
- line-height: 1.6;
63
- margin: 1rem 0;
64
- background: #4F39FA;
65
- padding: 1.0rem;
66
- border-radius: 0.4rem;
67
- color: var(--color-bg);
68
- }
69
-
70
- .instructions code {
71
- font-size: 0.875em;
72
- border: 0.1em solid var(--color-border);
73
- border-radius: 4px;
74
- padding: 0.15em 0.25em;
75
- }
76
- .link-card-grid {
77
- display: grid;
78
- grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
79
- gap: 1rem;
80
- padding: 0;
81
- }
82
- </style>
13
+ <ViewWildcard pageContext={pageContext} />
@@ -1,82 +1,13 @@
1
1
  ---
2
- import api from '@cloudcommerce/api';
3
- import Layout from '../layouts/Layout.astro';
4
- import Card from '../components/Card.astro';
5
-
6
- const products = (await api.get('products')).data.result;
2
+ import ViewHome from '../lib/views/index.astro';
3
+ import loadPageContext, { PageContext } from '../lib/ssr-context';
4
+
5
+ let pageContext: PageContext;
6
+ try {
7
+ pageContext = await loadPageContext(Astro);
8
+ } catch (err) {
9
+ return err.astroResponse;
10
+ }
7
11
  ---
8
12
 
9
- <Layout title="Welcome to Astro.">
10
- <main>
11
- <h1>Welcome to <span class="text-gradient">Astro</span></h1>
12
- <p class="instructions">
13
- Check out the <code>src/pages</code> directory to get started.<br/>
14
- <strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
15
- </p>
16
- <ul role="list" class="link-card-grid">
17
- <Card href="https://docs.astro.build/" title="Documentation" body="Learn how Astro works and explore the official API docs." />
18
- <Card href="https://astro.build/integrations/" title="Integrations" body="Supercharge your project with new frameworks and libraries." />
19
- <Card href="https://astro.build/themes/" title="Themes" body="Explore a galaxy of community-built starter themes." />
20
- <Card href="https://astro.build/chat/" title="Chat" body="Come say hi to our amazing Discord community. ❤️" />
21
- </ul>
22
- <ul role="list" class="mt-3 fs-20">
23
- {products.map((product) => <li>
24
- <a href={`/${product.slug}`}>{product.sku}</a>
25
- </li>)}
26
- </ul>
27
- </main>
28
- </Layout>
29
-
30
- <style>
31
- :root {
32
- --astro-gradient: linear-gradient(0deg,#4F39FA, #DA62C4);
33
- }
34
-
35
- h1 {
36
- margin: 2rem 0;
37
- }
38
-
39
- main {
40
- margin: auto;
41
- padding: 1em;
42
- max-width: 60ch;
43
- }
44
-
45
- .text-gradient {
46
- font-weight: 900;
47
- background-image: var(--astro-gradient);
48
- -webkit-background-clip: text;
49
- -webkit-text-fill-color: transparent;
50
- background-size: 100% 200%;
51
- background-position-y: 100%;
52
- border-radius: 0.4rem;
53
- animation: pulse 4s ease-in-out infinite;
54
- }
55
-
56
- @keyframes pulse {
57
- 0%, 100% { background-position-y: 0%; }
58
- 50% { background-position-y: 80%; }
59
- }
60
-
61
- .instructions {
62
- line-height: 1.6;
63
- margin: 1rem 0;
64
- background: #4F39FA;
65
- padding: 1.0rem;
66
- border-radius: 0.4rem;
67
- color: var(--color-bg);
68
- }
69
-
70
- .instructions code {
71
- font-size: 0.875em;
72
- border: 0.1em solid var(--color-border);
73
- border-radius: 4px;
74
- padding: 0.15em 0.25em;
75
- }
76
- .link-card-grid {
77
- display: grid;
78
- grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
79
- gap: 1rem;
80
- padding: 0;
81
- }
82
- </style>
13
+ <ViewHome pageContext={pageContext} />
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { readFileSync } from 'fs';
2
+ import fs from 'fs';
3
3
  import { resolve as resolvePath } from 'path';
4
4
  import config from '@cloudcommerce/config';
5
5
 
@@ -9,8 +9,6 @@ export default () => {
9
9
  VITE_ECOM_STORE_ID,
10
10
  } = import.meta.env || process.env;
11
11
 
12
- const { storeId, lang } = config.get();
13
-
14
12
  let baseDir;
15
13
  if (STOREFRONT_BASE_DIR) {
16
14
  const currentDir = fileURLToPath(new URL('.', import.meta.url));
@@ -23,9 +21,24 @@ export default () => {
23
21
  config.set({ storeId: Number(VITE_ECOM_STORE_ID) });
24
22
  }
25
23
 
26
- const settings = JSON.parse(
27
- readFileSync(resolvePath(dirContent, 'settings.json'), 'utf8'),
28
- );
24
+ const {
25
+ storeId,
26
+ lang,
27
+ countryCode,
28
+ currency,
29
+ currencySymbol,
30
+ } = config.get();
31
+
32
+ const cms = (filename) => {
33
+ if (filename.endsWith('/')) {
34
+ const dirColl = resolvePath(dirContent, filename);
35
+ return fs.readdirSync(dirColl).map((_filename) => _filename.replace('.json', ''));
36
+ }
37
+ const filepath = resolvePath(dirContent, `${filename}.json`);
38
+ return JSON.parse(fs.readFileSync(filepath, 'utf8'));
39
+ };
40
+
41
+ const settings = cms('settings');
29
42
  const { domain } = settings;
30
43
  const primaryColor = settings.primary_color || '#20c997';
31
44
  const secondaryColor = settings.secondary_color || '#343a40';
@@ -33,9 +46,13 @@ export default () => {
33
46
  return {
34
47
  storeId,
35
48
  lang,
49
+ countryCode,
50
+ currency,
51
+ currencySymbol,
36
52
  domain,
37
53
  primaryColor,
38
54
  secondaryColor,
39
55
  settings,
56
+ cms,
40
57
  };
41
58
  };
@@ -1,3 +1,6 @@
1
1
  {
2
- "extends": "astro/tsconfigs/base"
2
+ "extends": "astro/tsconfigs/base",
3
+ "compilerOptions": {
4
+ "jsx": "preserve"
5
+ }
3
6
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "0.0.71",
4
+ "version": "0.0.72",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {
@@ -1,18 +0,0 @@
1
- import type { BaseConfig } from '@cloudcommerce/config';
2
- import settings from '../content/settings.json';
3
-
4
- type CmsSettings = typeof settings;
5
-
6
- type StorefrontConfig = {
7
- storeId: BaseConfig['storeId'],
8
- lang: BaseConfig['lang'],
9
- domain: CmsSettings['domain'],
10
- primaryColor: CmsSettings['primary_color'],
11
- secondaryColor: CmsSettings['secondary_color'],
12
- settings: CmsSettings,
13
- };
14
-
15
- export type {
16
- StorefrontConfig,
17
- CmsSettings,
18
- };