cloudcommerce 2.1.0 → 2.2.1
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/.github/workflows/test-apps.yml +2 -2
- package/.husky/commit-msg +0 -3
- package/.husky/pre-commit +0 -3
- package/CHANGELOG.md +24 -0
- package/README.md +3 -7
- package/action.yml +40 -16
- package/ecomplus-stores/barra-doce/.github/workflows/build-and-deploy.yml +3 -2
- package/ecomplus-stores/barra-doce/.husky/pre-commit +0 -3
- package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
- package/ecomplus-stores/barra-doce/functions/ssr/content/pages/brands.json +2 -1
- package/ecomplus-stores/barra-doce/functions/ssr/content/pages/categories.json +2 -1
- package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barra-doce/functions/ssr/src/assets/style.css +2 -2
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/PageTitle.vue +26 -17
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/ProductCard.vue +4 -5
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/ProductDetails.vue +1 -1
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/SearchShowcase.vue +2 -1
- package/ecomplus-stores/barra-doce/functions/ssr/src/pages/[...slug].astro +3 -3
- package/ecomplus-stores/barra-doce/functions/ssr/src/pages/blog/[page].astro +6 -5
- package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barra-doce/package.json +4 -6
- package/ecomplus-stores/tia-sonia/.github/workflows/build-and-deploy.yml +4 -2
- package/ecomplus-stores/tia-sonia/package.json +0 -2
- package/package.json +10 -10
- package/packages/api/package.json +1 -1
- package/packages/apps/affiliate-program/package.json +1 -1
- package/packages/apps/correios/package.json +2 -2
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +2 -2
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +1 -1
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/flash-courier/package.json +2 -2
- package/packages/apps/frenet/package.json +2 -2
- package/packages/apps/galaxpay/package.json +2 -2
- package/packages/apps/google-analytics/package.json +2 -2
- package/packages/apps/jadlog/package.json +2 -2
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/mandae/package.json +2 -2
- package/packages/apps/melhor-envio/package.json +2 -2
- package/packages/apps/mercadopago/package.json +2 -2
- package/packages/apps/pagarme/package.json +2 -2
- package/packages/apps/pagarme-v5/package.json +2 -2
- package/packages/apps/paghiper/package.json +2 -2
- package/packages/apps/pix/package.json +2 -2
- package/packages/apps/tiny-erp/package.json +2 -2
- package/packages/apps/webhooks/package.json +2 -2
- package/packages/cli/ci/bunny-config-base.sh +68 -12
- package/packages/cli/ci/bunny-prepare-ab.sh +35 -26
- package/packages/cli/ci/bunny-remove-ab.sh +54 -0
- package/packages/cli/ci/bunny-setup.sh +103 -0
- package/packages/cli/config/firebase.json +0 -13
- package/packages/cli/lib/cli.js +4 -12
- package/packages/cli/package.json +2 -2
- package/packages/cli/src/cli.ts +8 -12
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +2 -2
- package/packages/eslint/package.json +2 -2
- package/packages/events/package.json +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +2 -2
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +2 -2
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/lib/cron-ssr-save-views.js +76 -4
- package/packages/ssr/lib/lib/cron-ssr-save-views.js.map +1 -1
- package/packages/ssr/package.json +4 -4
- package/packages/ssr/src/lib/cron-ssr-save-views.ts +78 -4
- package/packages/storefront/client.d.ts +2 -0
- package/packages/storefront/dist/client/_astro/{AccountPage.9BlGHXT3.js → AccountPage.89hLh9p2.js} +1 -1
- package/packages/storefront/dist/client/_astro/{CartSidebar.55UgTcV0.js → CartSidebar.G25ZUnKP.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductDetails.ENLKdSz_.js → ProductDetails.ntFWLjla.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductShelf.lCBJky3e.js → ProductShelf.PPitdYxI.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductShelf.CNf5JDrU.js → ProductShelf.xSxmHkTe.js} +1 -1
- package/packages/storefront/dist/client/_astro/{SearchModal.4osqtafp.js → SearchModal.R55jFaBZ.js} +1 -1
- package/packages/storefront/dist/client/_astro/{SearchShowcase.hg6TWrz3.js → SearchShowcase.I1PPFu_n.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ShopHeader.xLMeJpqV.js → ShopHeader.OLf0l4Ot.js} +2 -2
- package/packages/storefront/dist/client/_astro/{_slug_.r344YGqG.css → _slug_.Hc-dqhcW.css} +1 -1
- package/packages/storefront/dist/client/_astro/customer-session.AcETMuhI.js +7 -0
- package/packages/storefront/dist/client/_astro/ecom-icon_12falx.png +0 -0
- package/packages/storefront/dist/client/_astro/ecom-icon_15pqnO.png +0 -0
- package/packages/storefront/dist/client/_astro/ecom-icon_t3guw.png +0 -0
- package/packages/storefront/dist/client/_astro/{firebase-app.cPMfoOsn.js → firebase-app.VduCDgof.js} +1 -1
- package/packages/storefront/dist/client/_astro/headphone_T2Jjc.avif +0 -0
- package/packages/storefront/dist/client/_astro/headphone_Z1CG18r.webp +0 -0
- package/packages/storefront/dist/client/_astro/{hoisted.J15ErMtK.js → hoisted.PxLuJZKI.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.KYhwGfsv.js → hoisted.WBjTfX6e.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.HGTzAuTI.js → hoisted.Wi6YpdWJ.js} +1 -1
- package/packages/storefront/dist/client/_astro/{index-dd468b12.D5s8VdAL.js → index-dd468b12.fl8bpn8l.js} +3 -3
- package/packages/storefront/dist/client/_astro/logo_1UBsBq.webp +0 -0
- package/packages/storefront/dist/client/_astro/logo_Z1K5PE9.png +0 -0
- package/packages/storefront/dist/client/_astro/logo_Z1KIIl1.avif +0 -0
- package/packages/storefront/dist/client/_astro/passion_LHbe9.webp +0 -0
- package/packages/storefront/dist/client/_astro/passion_Z23MeUb.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_1TtOHY.png +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_1f5opX.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_IUskt.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Uxfdf.png +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Z15uApA.png +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Z1Ap1Im.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_Z1JT1HB.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_ZY9mtN.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect8589_tMFW0.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_1TgQXS.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_2Nm1z.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_DIqwR.png +0 -0
- package/packages/storefront/dist/client/_astro/rect859_Z1IKDb2.png +0 -0
- package/packages/storefront/dist/client/_astro/rect859_Z29FI4V.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect859_Z2kFHGk.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect859_ZkpPFI.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect859_jXzBi.png +0 -0
- package/packages/storefront/dist/client/_astro/rect859_x1l16.webp +0 -0
- package/packages/storefront/dist/client/_astro/rect89_1TSfW7.avif +0 -0
- package/packages/storefront/dist/client/_astro/rect89_Z1re32x.webp +0 -0
- package/packages/storefront/dist/client/_astro/{shopping-cart.ZdSCrjS6.js → shopping-cart.dJsZkyuD.js} +1 -1
- package/packages/storefront/dist/client/_astro/use-analytics.uqK_2k_k.js +1 -0
- package/packages/storefront/dist/client/_astro/{use-product-card.-9TsgDDW.js → use-product-card.WRVLjenR.js} +1 -1
- package/packages/storefront/dist/client/~fallback.html +98 -0
- package/packages/storefront/dist/client/~index.html +128 -0
- package/packages/storefront/dist/server/chunks/{CartSidebar_7UWmGIF6.mjs → CartSidebar_yYIzwp_R.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{SearchModal_MNdcYMws.mjs → SearchModal_GvRUZ6ce.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{_.._h5R83hoK.mjs → _.._Lq3r7hpv.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{_page__lWVlZyRe.mjs → _page__LqbeNfr1.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{account_jmelxnlw.mjs → account_4n4rpirV.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/astro/{assets-service_xNulQtBO.mjs → assets-service_yXRChsFH.mjs} +11 -66
- package/packages/storefront/dist/server/chunks/{astro_tggR3S_9.mjs → astro_F4pl3toV.mjs} +1 -7
- package/packages/storefront/dist/server/chunks/{index_e3ytAL8v.mjs → index_SwXtE1IM.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{node_kUJIRL0c.mjs → node_Nzz44v5l.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{__wihn0dYD.mjs → __z8Igc_-f.mjs} +102 -298
- package/packages/storefront/dist/server/chunks/pages/{_page__Sb1eYhpz.mjs → _page__-V1Q-Ymk.mjs} +3 -17
- package/packages/storefront/dist/server/chunks/pages/account_frSUn7gD.mjs +22 -0
- package/packages/storefront/dist/server/chunks/pages/{index_mQXYNYRg.mjs → index_QqJiJpFy.mjs} +4 -15
- package/packages/storefront/dist/server/chunks/pages/node_FoDIj_f7.mjs +257 -0
- package/packages/storefront/dist/server/chunks/pages/~fallback_t0lNhRm9.mjs +33 -0
- package/packages/storefront/dist/server/chunks/~fallback_EWqi0UyU.mjs +6 -0
- package/packages/storefront/dist/server/entry.mjs +8 -8
- package/packages/storefront/dist/server/images.dist.csv +30 -0
- package/packages/storefront/dist/server/images.src.csv +11 -0
- package/packages/storefront/dist/server/manifest_ZHJUD8_m.mjs +196 -0
- package/packages/storefront/dist/server/renderers.mjs +1 -1
- package/packages/storefront/dist/server/static-builds.csv +71 -0
- package/packages/storefront/package.json +7 -7
- package/packages/storefront/src/lib/composables/use-search-showcase.ts +34 -8
- package/packages/storefront/src/lib/layouts/BaseHead.astro +1 -0
- package/packages/storefront/src/lib/state/search-engine.ts +7 -2
- package/packages/storefront/src/lib/state/use-analytics.ts +24 -6
- package/packages/test-base/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/ecomplus-stores/barra-doce/LICENSE.md +0 -230
- package/ecomplus-stores/tia-sonia/LICENSE.md +0 -230
- package/packages/storefront/dist/client/_astro/customer-session.hXdZh5Ii.js +0 -7
- package/packages/storefront/dist/client/_astro/use-analytics.tCrQbW8O.js +0 -1
- package/packages/storefront/dist/server/chunks/pages/account_-mULVQUB.mjs +0 -32
- package/packages/storefront/dist/server/chunks/pages/node_-qe5LuQh.mjs +0 -112
- package/packages/storefront/dist/server/chunks/pages/~fallback_ad_xyGHU.mjs +0 -58
- package/packages/storefront/dist/server/chunks/~fallback_EZqiEAFE.mjs +0 -6
- package/packages/storefront/dist/server/manifest_RrmXPEuL.mjs +0 -196
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
if [ -z "$BUNNYNET_API_KEY" ]; then
|
|
4
|
+
echo "BUNNYNET_API_KEY env var must be set"
|
|
5
|
+
exit 1
|
|
6
|
+
fi
|
|
7
|
+
if [ $# -eq 0 ]; then
|
|
8
|
+
echo "Provide the Firebase project ID as the first argument"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
project_id=$1
|
|
13
|
+
domain=$2
|
|
14
|
+
|
|
15
|
+
storage_list=$(curl --silent --request GET \
|
|
16
|
+
--url https://api.bunny.net/storagezone \
|
|
17
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
18
|
+
--header 'accept: application/json')
|
|
19
|
+
|
|
20
|
+
storage_prefix="storefront-isr-"
|
|
21
|
+
storage_id=$(echo $storage_list | jq --arg prefix "$storage_prefix" '.[] | select(.Name | startswith($prefix)) | .Id')
|
|
22
|
+
|
|
23
|
+
if [ -z "$storage_id" ]; then
|
|
24
|
+
rand_suffix=$(printf "%06d" $((RANDOM % 10000000)))
|
|
25
|
+
storage_name="${storage_prefix}${rand_suffix}"
|
|
26
|
+
|
|
27
|
+
printf "\n"
|
|
28
|
+
response=$(curl --silent --request POST \
|
|
29
|
+
--url https://api.bunny.net/storagezone \
|
|
30
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
31
|
+
--header 'accept: application/json' \
|
|
32
|
+
--header 'content-type: application/json' \
|
|
33
|
+
--data "
|
|
34
|
+
{
|
|
35
|
+
\"Name\": \"$storage_name\",
|
|
36
|
+
\"Region\": \"DE\",
|
|
37
|
+
\"ReplicationRegions\": [
|
|
38
|
+
\"NY\",
|
|
39
|
+
\"BR\"
|
|
40
|
+
],
|
|
41
|
+
\"ZoneTier\": 1
|
|
42
|
+
}
|
|
43
|
+
")
|
|
44
|
+
|
|
45
|
+
storage_id=$(echo "$response" | jq -r '.Id')
|
|
46
|
+
printf "\n\n> Created storage zone \"$storage_name\" ($storage_id)"
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
if [ -z "$storage_id" ]; then
|
|
50
|
+
echo "Could not create bunny.net storage zone"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
origin_url="https://$project_id.web.app"
|
|
55
|
+
|
|
56
|
+
get_pull_zone_id() {
|
|
57
|
+
pull_zone_list=$(curl --silent --request GET \
|
|
58
|
+
--url https://api.bunny.net/pullzone \
|
|
59
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
60
|
+
--header 'accept: application/json')
|
|
61
|
+
|
|
62
|
+
pull_zone_id=$(echo $pull_zone_list | jq --arg url "$origin_url" '.[] | select(.OriginUrl == $url) | .Id')
|
|
63
|
+
}
|
|
64
|
+
get_pull_zone_id
|
|
65
|
+
|
|
66
|
+
if [ -z "$pull_zone_id" ]; then
|
|
67
|
+
printf "\n"
|
|
68
|
+
response=$(curl --silent --request POST \
|
|
69
|
+
--url https://api.bunny.net/pullzone \
|
|
70
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
71
|
+
--header 'accept: application/json' \
|
|
72
|
+
--header 'content-type: application/json' \
|
|
73
|
+
--data "
|
|
74
|
+
{
|
|
75
|
+
\"OriginUrl\": \"$origin_url\",
|
|
76
|
+
\"EnableGeoZoneUS\": true,
|
|
77
|
+
\"EnableGeoZoneEU\": true,
|
|
78
|
+
\"EnableGeoZoneASIA\": false,
|
|
79
|
+
\"EnableGeoZoneSA\": true,
|
|
80
|
+
\"EnableGeoZoneAF\": false,
|
|
81
|
+
\"Name\": \"$project_id\",
|
|
82
|
+
\"PermaCacheStorageZoneId\": $storage_id,
|
|
83
|
+
\"CacheControlMaxAgeOverride\": 31919000,
|
|
84
|
+
\"EnableOriginShield\": false
|
|
85
|
+
}
|
|
86
|
+
")
|
|
87
|
+
|
|
88
|
+
get_pull_zone_id
|
|
89
|
+
printf "\n\n> Created pull zone \"$pull_zone_id\" with origin \"$origin_url\""
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
if [ -n "$domain" ]; then
|
|
93
|
+
printf "\n"
|
|
94
|
+
curl --silent --request POST \
|
|
95
|
+
--url https://api.bunny.net/pullzone/$pull_zone_id/addHostname \
|
|
96
|
+
--header "AccessKey: $BUNNYNET_API_KEY" \
|
|
97
|
+
--header 'content-type: application/json' \
|
|
98
|
+
--data "{\"Hostname\":\"$domain\"}"
|
|
99
|
+
printf "\n\n> Added hostname \"$domain\" to pull zone"
|
|
100
|
+
|
|
101
|
+
script_dir=$(dirname $0)
|
|
102
|
+
bash $script_dir/bunny-config-base.sh $domain
|
|
103
|
+
fi
|
|
@@ -88,19 +88,6 @@
|
|
|
88
88
|
}
|
|
89
89
|
],
|
|
90
90
|
"headers": [
|
|
91
|
-
{
|
|
92
|
-
"source": "/**",
|
|
93
|
-
"headers": [
|
|
94
|
-
{
|
|
95
|
-
"key": "Set-Cookie",
|
|
96
|
-
"value": "bid={{BUILD_ID}}"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"key": "Set-Cookie",
|
|
100
|
-
"value": "branch={{GIT_BRANCH}}"
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
91
|
{
|
|
105
92
|
"source": "/img/**",
|
|
106
93
|
"headers": [
|
package/packages/cli/lib/cli.js
CHANGED
|
@@ -10,14 +10,12 @@ import build, { prepareCodebases } from './build.js';
|
|
|
10
10
|
import { siginGcloudAndSetIAM, createServiceAccountKey } from './setup-gcloud.js';
|
|
11
11
|
import createGhSecrets from './setup-gh.js';
|
|
12
12
|
|
|
13
|
-
if (!process.env.FIREBASE_PROJECT_ID && !process.env.
|
|
13
|
+
if (!process.env.FIREBASE_PROJECT_ID && !process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
14
14
|
const pwd = process.cwd();
|
|
15
15
|
dotenv.config();
|
|
16
16
|
dotenv.config({ path: joinPath(pwd, 'functions/.env') });
|
|
17
17
|
}
|
|
18
|
-
const {
|
|
19
|
-
FIREBASE_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS, GITHUB_TOKEN, BUILD_ID, DEPLOY_RAND, GIT_BRANCH,
|
|
20
|
-
} = process.env;
|
|
18
|
+
const { FIREBASE_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS, GITHUB_TOKEN } = process.env;
|
|
21
19
|
// https://github.com/google/zx/issues/124
|
|
22
20
|
process.env.FORCE_COLOR = '3';
|
|
23
21
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
@@ -47,14 +45,8 @@ if (projectId) {
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
export default async () => {
|
|
50
|
-
const buildId = BUILD_ID || DEPLOY_RAND || `${Math.random()}`;
|
|
51
48
|
const baseConfigDir = joinPath(__dirname, '..', 'config');
|
|
52
49
|
await fs.copy(baseConfigDir, pwd);
|
|
53
|
-
const firebaseJsonPath = joinPath(pwd, 'firebase.json');
|
|
54
|
-
const firebaseJson = fs.readFileSync(firebaseJsonPath, 'utf8')
|
|
55
|
-
.replace('{{BUILD_ID}}', buildId)
|
|
56
|
-
.replace('{{GIT_BRANCH}}', GIT_BRANCH || '_');
|
|
57
|
-
fs.writeFileSync(firebaseJsonPath, firebaseJson);
|
|
58
50
|
const userConfigDir = joinPath(pwd, 'conf');
|
|
59
51
|
if (fs.existsSync(userConfigDir) && fs.lstatSync(userConfigDir).isDirectory()) {
|
|
60
52
|
await fs.copy(userConfigDir, pwd);
|
|
@@ -68,9 +60,9 @@ export default async () => {
|
|
|
68
60
|
}
|
|
69
61
|
if (userFirebaseConfig) {
|
|
70
62
|
const deepmerge = Deepmerge();
|
|
71
|
-
const baseFirebaseConfig = JSON.parse(
|
|
63
|
+
const baseFirebaseConfig = JSON.parse(fs.readFileSync(joinPath(baseConfigDir, 'firebase.json'), 'utf8'));
|
|
72
64
|
const mergedConfig = deepmerge(baseFirebaseConfig, userFirebaseConfig);
|
|
73
|
-
fs.writeFileSync(
|
|
65
|
+
fs.writeFileSync(joinPath(pwd, 'firebase.json'), JSON.stringify(mergedConfig, null, 2));
|
|
74
66
|
}
|
|
75
67
|
}
|
|
76
68
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce CLI tools",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cloudcommerce": "./bin/run.mjs"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@cloudcommerce/api": "workspace:*",
|
|
30
30
|
"@fastify/deepmerge": "^1.3.0",
|
|
31
|
-
"dotenv": "^16.
|
|
31
|
+
"dotenv": "^16.4.1",
|
|
32
32
|
"libsodium-wrappers": "^0.7.13",
|
|
33
33
|
"md5": "^2.3.0",
|
|
34
34
|
"typescript": "~5.2.2",
|
package/packages/cli/src/cli.ts
CHANGED
|
@@ -14,7 +14,7 @@ import build, { prepareCodebases } from './build';
|
|
|
14
14
|
import { siginGcloudAndSetIAM, createServiceAccountKey } from './setup-gcloud';
|
|
15
15
|
import createGhSecrets from './setup-gh';
|
|
16
16
|
|
|
17
|
-
if (!process.env.FIREBASE_PROJECT_ID && !process.env.
|
|
17
|
+
if (!process.env.FIREBASE_PROJECT_ID && !process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
18
18
|
const pwd = process.cwd();
|
|
19
19
|
dotenv.config();
|
|
20
20
|
dotenv.config({ path: joinPath(pwd, 'functions/.env') });
|
|
@@ -23,9 +23,6 @@ const {
|
|
|
23
23
|
FIREBASE_PROJECT_ID,
|
|
24
24
|
GOOGLE_APPLICATION_CREDENTIALS,
|
|
25
25
|
GITHUB_TOKEN,
|
|
26
|
-
BUILD_ID,
|
|
27
|
-
DEPLOY_RAND,
|
|
28
|
-
GIT_BRANCH,
|
|
29
26
|
} = process.env;
|
|
30
27
|
|
|
31
28
|
// https://github.com/google/zx/issues/124
|
|
@@ -62,14 +59,8 @@ if (projectId) {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
export default async () => {
|
|
65
|
-
const buildId = BUILD_ID || DEPLOY_RAND || `${Math.random()}`;
|
|
66
62
|
const baseConfigDir = joinPath(__dirname, '..', 'config');
|
|
67
63
|
await fs.copy(baseConfigDir, pwd);
|
|
68
|
-
const firebaseJsonPath = joinPath(pwd, 'firebase.json');
|
|
69
|
-
const firebaseJson = fs.readFileSync(firebaseJsonPath, 'utf8')
|
|
70
|
-
.replace('{{BUILD_ID}}', buildId)
|
|
71
|
-
.replace('{{GIT_BRANCH}}', GIT_BRANCH || '_');
|
|
72
|
-
fs.writeFileSync(firebaseJsonPath, firebaseJson);
|
|
73
64
|
const userConfigDir = joinPath(pwd, 'conf');
|
|
74
65
|
if (fs.existsSync(userConfigDir) && fs.lstatSync(userConfigDir).isDirectory()) {
|
|
75
66
|
await fs.copy(userConfigDir, pwd);
|
|
@@ -85,9 +76,14 @@ export default async () => {
|
|
|
85
76
|
}
|
|
86
77
|
if (userFirebaseConfig) {
|
|
87
78
|
const deepmerge = Deepmerge();
|
|
88
|
-
const baseFirebaseConfig = JSON.parse(
|
|
79
|
+
const baseFirebaseConfig = JSON.parse(
|
|
80
|
+
fs.readFileSync(joinPath(baseConfigDir, 'firebase.json'), 'utf8'),
|
|
81
|
+
);
|
|
89
82
|
const mergedConfig = deepmerge(baseFirebaseConfig, userFirebaseConfig);
|
|
90
|
-
fs.writeFileSync(
|
|
83
|
+
fs.writeFileSync(
|
|
84
|
+
joinPath(pwd, 'firebase.json'),
|
|
85
|
+
JSON.stringify(mergedConfig, null, 2),
|
|
86
|
+
);
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/emails",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce email sender",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@cloudcommerce/firebase": "workspace:*",
|
|
26
|
-
"axios": "^1.6.
|
|
26
|
+
"axios": "^1.6.7",
|
|
27
27
|
"ejs": "^3.1.9",
|
|
28
28
|
"nodemailer": "^6.9.8"
|
|
29
29
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/eslint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce ESLint config",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
26
26
|
"eslint-plugin-astro": "^0.31.3",
|
|
27
27
|
"eslint-plugin-import": "^2.29.1",
|
|
28
|
-
"eslint-plugin-tailwindcss": "3.14.
|
|
28
|
+
"eslint-plugin-tailwindcss": "3.14.1",
|
|
29
29
|
"eslint-plugin-vue": "^9.20.1"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce on Firebase",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@cloudcommerce/api": "workspace:*",
|
|
34
34
|
"@cloudcommerce/config": "workspace:*",
|
|
35
35
|
"@google-cloud/pubsub": "^4.1.1",
|
|
36
|
-
"dotenv": "^16.
|
|
36
|
+
"dotenv": "^16.4.1",
|
|
37
37
|
"firebase-admin": "^12.0.0",
|
|
38
38
|
"firebase-functions": "^4.6.0",
|
|
39
39
|
"source-map-support": "^0.5.21"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/modules",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce modules API",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
7
7
|
"exports": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
48
48
|
"ajv": "^8.12.0",
|
|
49
49
|
"ajv-formats": "^2.1.1",
|
|
50
|
-
"axios": "^1.6.
|
|
50
|
+
"axios": "^1.6.7",
|
|
51
51
|
"firebase-admin": "^12.0.0",
|
|
52
52
|
"firebase-functions": "^4.6.0",
|
|
53
53
|
"source-map-support": "^0.5.21"
|
|
@@ -29,7 +29,62 @@ const saveViews = async () => {
|
|
|
29
29
|
}
|
|
30
30
|
const { domain } = config.get().settingsContent;
|
|
31
31
|
if (domain && process.env.BUNNYNET_API_KEY) {
|
|
32
|
+
let bunnyStorageName = process.env.BUNNYNET_STORAGE_NAME;
|
|
33
|
+
let bunnyStoragePass = process.env.BUNNYNET_STORAGE_PASS;
|
|
34
|
+
let bunnyZoneName = process.env.BUNNYNET_ZONE_NAME;
|
|
35
|
+
let permaCacheZoneFolder = '';
|
|
36
|
+
const bunnyAxios = axios.create({
|
|
37
|
+
baseURL: 'https://api.bunny.net/',
|
|
38
|
+
headers: {
|
|
39
|
+
AccessKey: process.env.BUNNYNET_API_KEY,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
32
42
|
try {
|
|
43
|
+
if (!bunnyStorageName || !bunnyStoragePass) {
|
|
44
|
+
const { data } = await bunnyAxios.get('/storagezone');
|
|
45
|
+
for (let i = 0; i < data.length; i++) {
|
|
46
|
+
const bunnyStorage = data[i];
|
|
47
|
+
if (bunnyStorageName) {
|
|
48
|
+
if (bunnyStorage.Name === bunnyStorageName) {
|
|
49
|
+
bunnyStoragePass = bunnyStorage.Password;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (bunnyStorage.Name.startsWith('storefront-isr-')) {
|
|
55
|
+
bunnyStorageName = bunnyStorage.Name;
|
|
56
|
+
bunnyStoragePass = bunnyStorage.Password;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (bunnyStorageName && bunnyStoragePass) {
|
|
62
|
+
if (!bunnyZoneName) {
|
|
63
|
+
const { data } = await bunnyAxios.get('/pullzone');
|
|
64
|
+
for (let i = 0; i < data.length; i++) {
|
|
65
|
+
const pullZone = data[i];
|
|
66
|
+
if (pullZone.Hostnames.find(({ Value }) => Value === domain)) {
|
|
67
|
+
bunnyZoneName = pullZone.Name;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (bunnyZoneName) {
|
|
73
|
+
const { data } = await axios({
|
|
74
|
+
url: `https://storage.bunnycdn.com/${bunnyStorageName}/__bcdn_perma_cache__/`,
|
|
75
|
+
headers: {
|
|
76
|
+
AccessKey: bunnyStoragePass,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
for (let i = 0; i < data.length; i++) {
|
|
80
|
+
const { ObjectName } = data[i];
|
|
81
|
+
if (ObjectName.startsWith(`pullzone__${bunnyZoneName}__`)
|
|
82
|
+
&& (!permaCacheZoneFolder || permaCacheZoneFolder < ObjectName)) {
|
|
83
|
+
permaCacheZoneFolder = ObjectName;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
33
88
|
const pageViewsSnapshot = await db.collection('ssrPageViews')
|
|
34
89
|
.where('at', '>', new Date(Date.now() - 1000 * 60 * 20))
|
|
35
90
|
.get();
|
|
@@ -38,17 +93,34 @@ const saveViews = async () => {
|
|
|
38
93
|
const doc = pageViewsSnapshot.docs[i];
|
|
39
94
|
const { url } = doc.data();
|
|
40
95
|
if (url?.startsWith(`https://${domain}`) && !purgedUrls.includes(url)) {
|
|
41
|
-
await
|
|
96
|
+
await bunnyAxios('/purge', {
|
|
42
97
|
method: 'POST',
|
|
43
98
|
params: {
|
|
44
99
|
async: 'false',
|
|
45
100
|
url,
|
|
46
101
|
},
|
|
47
|
-
headers: {
|
|
48
|
-
AccessKey: process.env.BUNNYNET_API_KEY,
|
|
49
|
-
},
|
|
50
102
|
});
|
|
51
103
|
purgedUrls.push(url);
|
|
104
|
+
if (permaCacheZoneFolder) {
|
|
105
|
+
let pathname = url.replace(`https://${domain}`, '');
|
|
106
|
+
if (pathname.charAt(0) === '/') {
|
|
107
|
+
pathname = pathname.slice(1);
|
|
108
|
+
}
|
|
109
|
+
const paths = pathname.split('/');
|
|
110
|
+
const filename = paths.pop() || '';
|
|
111
|
+
let folderpath = paths.join('/');
|
|
112
|
+
if (folderpath) folderpath += '/';
|
|
113
|
+
// https://support.bunny.net/hc/en-us/articles/360017048720-Perma-Cache-Folder-Structure-Explained
|
|
114
|
+
const permaCachePath = `__bcdn_perma_cache__/${permaCacheZoneFolder}`
|
|
115
|
+
+ `/${folderpath}___${filename}___/___file___`;
|
|
116
|
+
await axios({
|
|
117
|
+
method: 'DELETE',
|
|
118
|
+
url: `https://storage.bunnycdn.com/${bunnyStorageName}/${permaCachePath}`,
|
|
119
|
+
headers: {
|
|
120
|
+
AccessKey: bunnyStoragePass,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
52
124
|
}
|
|
53
125
|
}
|
|
54
126
|
} catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron-ssr-save-views.js","sourceRoot":"","sources":["../../src/lib/cron-ssr-save-views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAEjF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAC3B,qCAAqC;IACrC,MAAM,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1B,MAAM,oBAAoB,GAAG,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I,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,gBAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/ssr",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce storefront SSR",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"build:workers": "npx tsc -p src/cloudflare --outDir cloudflare && npx eslint --ext .js cloudflare --fix"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@astrojs/node": "8.
|
|
29
|
+
"@astrojs/node": "8.1.0",
|
|
30
30
|
"@cloudcommerce/api": "workspace:*",
|
|
31
31
|
"@cloudcommerce/firebase": "workspace:*",
|
|
32
32
|
"@cloudcommerce/i18n": "workspace:*",
|
|
33
33
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
34
34
|
"@vueuse/core": "10.7.2",
|
|
35
|
-
"astro": "4.2.
|
|
35
|
+
"astro": "4.2.6",
|
|
36
36
|
"astro-capo": "^0.0.1",
|
|
37
|
-
"axios": "^1.6.
|
|
37
|
+
"axios": "^1.6.7",
|
|
38
38
|
"firebase-admin": "^12.0.0",
|
|
39
39
|
"firebase-functions": "^4.6.0",
|
|
40
40
|
"mitt": "^3.0.1",
|
|
@@ -29,7 +29,64 @@ const saveViews = async () => {
|
|
|
29
29
|
}
|
|
30
30
|
const { domain } = config.get().settingsContent;
|
|
31
31
|
if (domain && process.env.BUNNYNET_API_KEY) {
|
|
32
|
+
let bunnyStorageName = process.env.BUNNYNET_STORAGE_NAME;
|
|
33
|
+
let bunnyStoragePass = process.env.BUNNYNET_STORAGE_PASS;
|
|
34
|
+
let bunnyZoneName = process.env.BUNNYNET_ZONE_NAME;
|
|
35
|
+
let permaCacheZoneFolder = '';
|
|
36
|
+
const bunnyAxios = axios.create({
|
|
37
|
+
baseURL: 'https://api.bunny.net/',
|
|
38
|
+
headers: {
|
|
39
|
+
AccessKey: process.env.BUNNYNET_API_KEY,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
32
42
|
try {
|
|
43
|
+
if (!bunnyStorageName || !bunnyStoragePass) {
|
|
44
|
+
const { data } = await bunnyAxios.get('/storagezone');
|
|
45
|
+
for (let i = 0; i < data.length; i++) {
|
|
46
|
+
const bunnyStorage = data[i];
|
|
47
|
+
if (bunnyStorageName) {
|
|
48
|
+
if (bunnyStorage.Name === bunnyStorageName) {
|
|
49
|
+
bunnyStoragePass = bunnyStorage.Password;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (bunnyStorage.Name.startsWith('storefront-isr-')) {
|
|
55
|
+
bunnyStorageName = bunnyStorage.Name;
|
|
56
|
+
bunnyStoragePass = bunnyStorage.Password;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (bunnyStorageName && bunnyStoragePass) {
|
|
62
|
+
if (!bunnyZoneName) {
|
|
63
|
+
const { data } = await bunnyAxios.get('/pullzone');
|
|
64
|
+
for (let i = 0; i < data.length; i++) {
|
|
65
|
+
const pullZone = data[i];
|
|
66
|
+
if (pullZone.Hostnames.find(({ Value }) => Value === domain)) {
|
|
67
|
+
bunnyZoneName = pullZone.Name;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (bunnyZoneName) {
|
|
73
|
+
const { data } = await axios({
|
|
74
|
+
url: `https://storage.bunnycdn.com/${bunnyStorageName}/__bcdn_perma_cache__/`,
|
|
75
|
+
headers: {
|
|
76
|
+
AccessKey: bunnyStoragePass,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
for (let i = 0; i < data.length; i++) {
|
|
80
|
+
const { ObjectName } = data[i];
|
|
81
|
+
if (
|
|
82
|
+
ObjectName.startsWith(`pullzone__${bunnyZoneName}__`)
|
|
83
|
+
&& (!permaCacheZoneFolder || permaCacheZoneFolder < ObjectName)
|
|
84
|
+
) {
|
|
85
|
+
permaCacheZoneFolder = ObjectName;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
33
90
|
const pageViewsSnapshot = await db.collection('ssrPageViews')
|
|
34
91
|
.where('at', '>', new Date(Date.now() - 1000 * 60 * 20))
|
|
35
92
|
.get();
|
|
@@ -38,17 +95,34 @@ const saveViews = async () => {
|
|
|
38
95
|
const doc = pageViewsSnapshot.docs[i];
|
|
39
96
|
const { url } = doc.data() as { url: string };
|
|
40
97
|
if (url?.startsWith(`https://${domain}`) && !purgedUrls.includes(url)) {
|
|
41
|
-
await
|
|
98
|
+
await bunnyAxios('/purge', {
|
|
42
99
|
method: 'POST',
|
|
43
100
|
params: {
|
|
44
101
|
async: 'false',
|
|
45
102
|
url,
|
|
46
103
|
},
|
|
47
|
-
headers: {
|
|
48
|
-
AccessKey: process.env.BUNNYNET_API_KEY,
|
|
49
|
-
},
|
|
50
104
|
});
|
|
51
105
|
purgedUrls.push(url);
|
|
106
|
+
if (permaCacheZoneFolder) {
|
|
107
|
+
let pathname = url.replace(`https://${domain}`, '');
|
|
108
|
+
if (pathname.charAt(0) === '/') {
|
|
109
|
+
pathname = pathname.slice(1);
|
|
110
|
+
}
|
|
111
|
+
const paths = pathname.split('/');
|
|
112
|
+
const filename = paths.pop() || '';
|
|
113
|
+
let folderpath = paths.join('/');
|
|
114
|
+
if (folderpath) folderpath += '/';
|
|
115
|
+
// https://support.bunny.net/hc/en-us/articles/360017048720-Perma-Cache-Folder-Structure-Explained
|
|
116
|
+
const permaCachePath = `__bcdn_perma_cache__/${permaCacheZoneFolder}`
|
|
117
|
+
+ `/${folderpath}___${filename}___/___file___`;
|
|
118
|
+
await axios({
|
|
119
|
+
method: 'DELETE',
|
|
120
|
+
url: `https://storage.bunnycdn.com/${bunnyStorageName}/${permaCachePath}`,
|
|
121
|
+
headers: {
|
|
122
|
+
AccessKey: bunnyStoragePass,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
52
126
|
}
|
|
53
127
|
}
|
|
54
128
|
} catch (err: any) {
|
|
@@ -25,6 +25,8 @@ interface Window {
|
|
|
25
25
|
ECOM_CURRENCY: string;
|
|
26
26
|
ECOM_CURRENCY_SYMBOL: string;
|
|
27
27
|
ECOM_COUNTRY_CODE: string;
|
|
28
|
+
GIT_BRANCH: string;
|
|
29
|
+
AB_EXPERIMENT_ID?: string;
|
|
28
30
|
$storefront?: import('@@sf/$storefront').$Storefront & {
|
|
29
31
|
modulesInfoPreset?: Partial<typeof import('./src/lib/state/modules-info').default>,
|
|
30
32
|
};
|
package/packages/storefront/dist/client/_astro/{AccountPage.9BlGHXT3.js → AccountPage.89hLh9p2.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as P,a as A,v as M,w as k}from"./_plugin-vue_export-helper.SO-0jCqa.js";import{e as T,f as _,E as V,a as R,d as I}from"./customer-session.
|
|
1
|
+
import{_ as P,a as A,v as M,w as k}from"./_plugin-vue_export-helper.SO-0jCqa.js";import{e as T,f as _,E as V,a as R,d as I}from"./customer-session.AcETMuhI.js";import{u as j}from"./index.R7A-Pg5V.js";import{g as B,b as O,c as q}from"./index-dd468b12.fl8bpn8l.js";import{b as D}from"./index.q6KIyKlJ.js";import{a as f,w as h,d as C,c as z,M as F,N as l,O as c,Z as N,R as i,S as b,P as r,Q as S,W as x,T as E,U as L,V as U,a2 as W,a3 as Y,X as G,Y as K}from"./runtime-core.esm-bundler.XTSAdOlw.js";import"./sf-utils.Z4H-dRBJ.js";const Q=m=>{T();const s=m?.canUseUrlParams!==!1?j("history"):{},e=s.sign_up!==void 0&&s.sign_up!=="0",a=s.password!==void 0&&s.password!=="0",u=f(e),n=f(!e&&!a);h(u,p=>{p?(n.value=!0,s.sign_up="1"):s.sign_up="0"}),h(n,p=>{s.password=p?"0":"1"});const o=f(""),d=f(!1),g=D(async p=>{d.value=!0;const v=Date.now(),y=B();if(_.value){window.localStorage.setItem(V,_.value);try{if(n.value){const w=new URL(p||window.location.toString());w.searchParams.append("email",_.value),await O(y,_.value,{url:w.toString(),handleCodeInApp:!0})}else await q(y,_.value,o.value)}catch(w){console.warn(w.code),console.error(w)}setTimeout(()=>{d.value=!1},Math.min(2e3-(Date.now()-v),1))}},2e3);return{isLinkSignIn:n,isSignUp:u,email:_,password:o,isSubmitting:d,submitLogin:g}},X=C({__name:"LoginForm",props:{loginLinkActionUrl:{}},setup(m,{expose:t}){t();const{isLinkSignIn:s,isSignUp:e,email:a,password:u,isSubmitting:n,submitLogin:o}=Q(),d=f(!1),g=f(0),p=z(()=>g.value>9);h(n,()=>{!n.value&&s.value&&(d.value=!0,g.value+=1)}),h([a,e],()=>{d.value=!1}),h(p,()=>{s.value=!1});const v={isLinkSignIn:s,isSignUp:e,email:a,password:u,isSubmitting:n,submitLogin:o,isEmailSentMsg:d,countEmailsSent:g,isLinkSignInBlocked:p,get customerName(){return R}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),Z={class:"text-base-600 mb-4 text-2xl font-light"},$={key:0},H={key:1,class:"lowercase"},J={key:0,for:"login-form-email"},ee={class:"relative"},se=["disabled"],te={key:0,class:"text-success-800 absolute left-0 top-0 mt-4 font-medium"},ne=i("i",{class:"i-check mr-1"},null,-1);function ie(m,t,s,e,a,u){const n=F("Fade");return l(),c("form",{class:"text-base-800 w-full max-w-sm bg-white p-6 text-base md:p-8",onSubmit:t[4]||(t[4]=k(()=>e.submitLogin(s.loginLinkActionUrl),["prevent"]))},[N(m.$slots,"head"),i("p",Z,[b(r("Olá")+" "),e.customerName?(l(),c("span",$,r(e.customerName),1)):(l(),c("span",H,r("Visitante")))]),e.isLinkSignIn?(l(),c("label",J,r("Enviar link de acesso por e-mail"))):S("",!0),x(i("input",{id:"login-form-email",type:"email",placeholder:"email@mail.com","onUpdate:modelValue":t[0]||(t[0]=o=>e.email=o),class:"mb-0.5 mt-2 w-full",required:""},null,512),[[A,e.email]]),e.isLinkSignIn?S("",!0):x((l(),c("input",{key:1,type:"password",placeholder:"Senha","onUpdate:modelValue":t[1]||(t[1]=o=>e.password=o),class:"mb-0.5 mt-2 w-full lowercase",required:""},null,512)),[[A,e.password]]),i("div",ee,[i("div",{class:E(["transition-opacity",e.isEmailSentMsg&&"opacity-0 invisible"])},[x(i("a",{href:"?password",class:"text-base-500 ui-link text-right text-sm lowercase",onClick:t[2]||(t[2]=k(o=>e.isLinkSignIn=!e.isLinkSignIn,["prevent"]))},r(e.isLinkSignIn?"Entrar com senha":"Esqueci minha senha"),513),[[M,!e.isSignUp&&!e.isLinkSignInBlocked]]),i("button",{type:"submit",disabled:e.isSubmitting,class:E(["ui-btn-lg ui-btn-primary mb-2 mt-5 w-full",e.isSubmitting&&"opacity-50"])},r(e.isSignUp?"Cadastrar":"Acessar minha conta"),11,se)],2),L(n,{speed:"slow"},{default:U(()=>[e.isEmailSentMsg?(l(),c("p",te,[ne,b(" "+r("Te enviamos o e-mail, verifique sua caixa de entrada e spam se necessário."),1)])):S("",!0)]),_:1}),i("a",{href:"?sign_up",class:"ui-btn-lg ui-btn-contrast block w-full text-center",onClick:t[3]||(t[3]=k(o=>e.isSignUp=!e.isSignUp,["prevent"]))},r(e.isSignUp?"Acessar minha conta":"Criar uma conta"),1)])],32)}const ae=P(X,[["render",ie]]),oe=C({__name:"AccountPage",setup(m,{expose:t}){t();let s=null;{const{location:a}=window,u=new URLSearchParams(a.search).get("return_url");if(!u){const n=new URL(a.toString());n.pathname="/app/",n.hash=`#${a.pathname.replace("/app/","/")}`,s=n.toString()}h(I,()=>{I.value&&(a.href=u||s)},{immediate:!0})}const e={get loginLinkActionUrl(){return s},set loginLinkActionUrl(a){s=a},LoginForm:ae};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}}),re={class:"from-secondary-700 to-secondary-950 flex min-h-screen w-full flex-col justify-center bg-gradient-to-br"},le={class:"mx-auto p-4"},ce=i("section",{class:"ui-section text-center"},[i("a",{href:"/",class:"text-base-200 hover:text-white"},[i("i",{class:"i-arrow-right mr-1 rotate-180"}),b(" "+r("Ir para a loja"))])],-1),me={class:"overflow-hidden rounded-md shadow-md ring-4 ring-black/10"},ue={class:"mb-5 text-center"},de={href:"/",class:"inline-block"},pe={key:0,class:"ui-section px-0"},ge={class:"mx-auto flex max-w-sm flex-wrap items-center justify-evenly gap-4 px-3"};function _e(m,t,s,e,a,u){const n=F("ALink");return l(),c("article",re,[i("div",le,[ce,i("section",me,[L(e.LoginForm,W(Y({loginLinkActionUrl:e.loginLinkActionUrl})),{head:U(()=>[i("div",ue,[i("a",de,[N(m.$slots,"logo")])])]),_:3},16)]),m.$settings.serviceLinks?.length?(l(),c("nav",pe,[i("ul",ge,[(l(!0),c(G,null,K(m.$settings.serviceLinks,({title:o,href:d},g)=>(l(),c("li",{key:`s-${g}`},[L(n,{href:d,class:"text-base-200 ui-link hover:text-white"},{default:U(()=>[b(r(o),1)]),_:2},1032,["href"])]))),128))])])):S("",!0)])])}const xe=P(oe,[["render",_e]]);export{xe as default};
|