cloudcommerce 0.0.44 → 0.0.47
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/CHANGELOG.md +30 -0
- package/action.yml +8 -6
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/discounts/lib/index.js +3 -0
- package/packages/apps/discounts/lib/index.js.map +1 -1
- package/packages/apps/discounts/package.json +6 -3
- package/packages/apps/discounts/src/index.ts +2 -0
- package/packages/cli/package.json +1 -1
- package/packages/events/firebase.js +1 -0
- package/packages/events/lib/firebase.js +31 -0
- package/packages/events/lib/firebase.js.map +1 -0
- package/packages/events/lib/index.js +2 -0
- package/packages/events/lib/index.js.map +1 -0
- package/packages/events/package.json +2 -2
- package/packages/events/src/firebase.ts +6 -3
- package/packages/firebase/lib/config.js +3 -0
- package/packages/firebase/lib/config.js.map +1 -1
- package/packages/firebase/lib/env.d.ts +5 -2
- package/packages/firebase/lib/env.js +12 -3
- package/packages/firebase/lib/env.js.map +1 -1
- package/packages/firebase/lib/handlers/auth-callback.d.ts +3 -0
- package/packages/firebase/lib/handlers/auth-callback.js +45 -0
- package/packages/firebase/lib/handlers/auth-callback.js.map +1 -0
- package/packages/firebase/lib/handlers/check-store-events.js +4 -7
- package/packages/firebase/lib/handlers/check-store-events.js.map +1 -1
- package/packages/firebase/lib/index.d.ts +3 -1
- package/packages/firebase/lib/index.js +18 -4
- package/packages/firebase/lib/index.js.map +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/firebase/src/config.ts +3 -0
- package/packages/firebase/src/env.ts +15 -4
- package/packages/firebase/src/handlers/auth-callback.ts +49 -0
- package/packages/firebase/src/handlers/check-store-events.ts +4 -7
- package/packages/firebase/src/index.ts +20 -4
- package/packages/modules/lib/firebase.js +3 -6
- package/packages/modules/lib/firebase.js.map +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/modules/src/firebase.ts +3 -6
- package/packages/passport/lib/firebase.js +1 -1
- package/packages/passport/lib/firebase.js.map +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/passport/src/firebase.ts +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/pnpm-lock.yaml +24 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
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.47](https://github.com/ecomplus/cloud-commerce/compare/v0.0.46...v0.0.47) (2022-08-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Setup app auth callback function to handle installation callback ([12d5780](https://github.com/ecomplus/cloud-commerce/commit/12d57808a8d742b4a29ac2ce3ea1ae3a5af836dc))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **events:** Add root `firebase.js` as complement to pkg named export ([178fd8c](https://github.com/ecomplus/cloud-commerce/commit/178fd8c128ed55b098a28abe70e6c5385043ec89))
|
|
16
|
+
* Set `ECOM_STORE_ID` env from `config.storeId` ([65e806e](https://github.com/ecomplus/cloud-commerce/commit/65e806ee2228392cfa3c9c6a58537e6248d1f862))
|
|
17
|
+
|
|
18
|
+
### [0.0.46](https://github.com/ecomplus/cloud-commerce/compare/v0.0.45...v0.0.46) (2022-08-05)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* Set Firebase Functions v2 names with one word at all ([23d5f17](https://github.com/ecomplus/cloud-commerce/commit/23d5f17bbeca0bccc14047c6a5fa4a92753ae9b8))
|
|
24
|
+
|
|
25
|
+
### [0.0.45](https://github.com/ecomplus/cloud-commerce/compare/v0.0.44...v0.0.45) (2022-08-05)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* GH Action must install dependencies of each functions codebase ([0e1212a](https://github.com/ecomplus/cloud-commerce/commit/0e1212a61c455de0e1b698e9086c1df2a6c24fd7))
|
|
31
|
+
* GH Action must install dependencies of each functions codebase ([7379f0e](https://github.com/ecomplus/cloud-commerce/commit/7379f0e01e9ce94a666735e12dd38a29f090d238))
|
|
32
|
+
* GH Action must install optional dependencies for functions deploy ([59b281e](https://github.com/ecomplus/cloud-commerce/commit/59b281e74346dbe360c2810eb9749304214df17c))
|
|
33
|
+
* Set Firebase Functions names with snake case ([2ec6a31](https://github.com/ecomplus/cloud-commerce/commit/2ec6a31a42cd7692f5b004d65dff6d2e0b3bad30))
|
|
34
|
+
|
|
5
35
|
### [0.0.44](https://github.com/ecomplus/cloud-commerce/compare/v0.0.43...v0.0.44) (2022-08-05)
|
|
6
36
|
|
|
7
37
|
|
package/action.yml
CHANGED
|
@@ -29,17 +29,19 @@ runs:
|
|
|
29
29
|
|
|
30
30
|
- if: github.event_name == 'push'
|
|
31
31
|
shell: bash
|
|
32
|
-
run: npm i --location=global firebase-tools
|
|
32
|
+
run: npm i --location=global firebase-tools@11
|
|
33
33
|
|
|
34
34
|
- shell: bash
|
|
35
|
-
run: npm ci --
|
|
35
|
+
run: npm ci --omit=dev
|
|
36
36
|
|
|
37
37
|
- shell: bash
|
|
38
38
|
working-directory: functions
|
|
39
|
-
run:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
run: |
|
|
40
|
+
for d in */ ; do
|
|
41
|
+
cd $d
|
|
42
|
+
npm ci --omit=dev
|
|
43
|
+
cd ..
|
|
44
|
+
done
|
|
43
45
|
|
|
44
46
|
- if: github.event_name == 'push'
|
|
45
47
|
name: Deploy to Firebase live
|
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.47",
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAqB,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-discounts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.47",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce app for complex discount rules",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -19,9 +19,12 @@
|
|
|
19
19
|
"build": "sh ../../../scripts/build-lib.sh"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@cloudcommerce/api": "workspace:*"
|
|
22
|
+
"@cloudcommerce/api": "workspace:*",
|
|
23
|
+
"firebase-admin": "^11.0.1",
|
|
24
|
+
"firebase-functions": "^3.22.0"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
|
-
"@cloudcommerce/types": "workspace:*"
|
|
27
|
+
"@cloudcommerce/types": "workspace:*",
|
|
28
|
+
"@firebase/app-types": "^0.7.0"
|
|
26
29
|
}
|
|
27
30
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/firebase.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import 'source-map-support/register.js';
|
|
3
|
+
// eslint-disable-next-line import/no-unresolved
|
|
4
|
+
import { initializeApp } from 'firebase-admin/app';
|
|
5
|
+
import functions from 'firebase-functions';
|
|
6
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
7
|
+
|
|
8
|
+
const { logger } = functions;
|
|
9
|
+
initializeApp();
|
|
10
|
+
const eventMaxAgeMs = 60000;
|
|
11
|
+
const newOrderTopic = 'orders-new';
|
|
12
|
+
const { httpsFunctionOptions: { region } } = config.get();
|
|
13
|
+
|
|
14
|
+
export const onNewOrder = functions.region(region)
|
|
15
|
+
.runWith({ failurePolicy: true })
|
|
16
|
+
.pubsub.topic(newOrderTopic).onPublish((message, context) => {
|
|
17
|
+
const eventAgeMs = Date.now() - Date.parse(context.timestamp);
|
|
18
|
+
if (eventAgeMs > eventMaxAgeMs) {
|
|
19
|
+
logger.warn(`Dropping event ${context.eventId} with age[ms]: ${eventAgeMs}`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// Hide API key for security
|
|
23
|
+
process.env.ECOM_API_KEY = '***';
|
|
24
|
+
const { json } = message;
|
|
25
|
+
logger.info({
|
|
26
|
+
topic: newOrderTopic,
|
|
27
|
+
eventId: context.eventId,
|
|
28
|
+
json,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
// # sourceMappingURL=firebase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAGjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;AAC7B,aAAa,EAAE,CAAC;AAEhB,MAAM,aAAa,GAAG,KAAK,CAAC;AAC5B,MAAM,aAAa,GAAmB,YAAY,CAAC;AACnD,MAAM,EAAE,oBAAoB,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;AAE1D,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;KAC/C,OAAO,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;KAChC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9D,IAAI,UAAU,GAAG,aAAa,EAAE;QAC9B,MAAM,CAAC,IAAI,CAAC,kBAAkB,OAAO,CAAC,OAAO,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAC7E,OAAO;KACR;IACD,4BAA4B;IAC5B,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,CAAC,IAAI,CAAC;QACV,KAAK,EAAE,aAAa;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI;KACL,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/events",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.47",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce app events",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/events#readme",
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build": "
|
|
23
|
+
"build": "sh ../../scripts/build-lib.sh"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@cloudcommerce/api": "workspace:*",
|
|
@@ -4,15 +4,18 @@ import type { AppEventsTopic } from '@cloudcommerce/types';
|
|
|
4
4
|
import 'source-map-support/register.js';
|
|
5
5
|
// eslint-disable-next-line import/no-unresolved
|
|
6
6
|
import { initializeApp } from 'firebase-admin/app';
|
|
7
|
-
|
|
8
|
-
import
|
|
7
|
+
import functions from 'firebase-functions';
|
|
8
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
9
9
|
|
|
10
|
+
const { logger } = functions;
|
|
10
11
|
initializeApp();
|
|
11
12
|
|
|
12
13
|
const eventMaxAgeMs = 60000;
|
|
13
14
|
const newOrderTopic: AppEventsTopic = 'orders-new';
|
|
15
|
+
const { httpsFunctionOptions: { region } } = config.get();
|
|
14
16
|
|
|
15
|
-
export const onNewOrder =
|
|
17
|
+
export const onNewOrder = functions.region(region)
|
|
18
|
+
.runWith({ failurePolicy: true })
|
|
16
19
|
.pubsub.topic(newOrderTopic).onPublish((message, context) => {
|
|
17
20
|
const eventAgeMs = Date.now() - Date.parse(context.timestamp);
|
|
18
21
|
if (eventAgeMs > eventMaxAgeMs) {
|
|
@@ -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;AAEpB,M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OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,uBAAuB;QAC3E,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,oBAAoB;QAClE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;QAC1C,oBAAoB,EAAE;YACpB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;SAChD;QACD,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,KAAK,EAAE,MAAM;aACd;SACF;KACF;CACF,CAAC;AAEF,eAAe;IACb,GAAG;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IACD,GAAG,CAAC,MAAM;QACR,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjD,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC;SAC5C;IACH,CAAC;CACF,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export default () => {
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
ECOM_STORE_ID, ECOM_AUTHENTICATION_ID, ECOM_API_KEY, GITHUB_TOKEN,
|
|
4
|
+
} = process.env;
|
|
5
|
+
const storeId = ECOM_STORE_ID && parseInt(ECOM_STORE_ID, 10);
|
|
6
|
+
if (!storeId) {
|
|
7
|
+
throw new Error('ECOM_STORE_ID is not set or not a number');
|
|
8
|
+
}
|
|
3
9
|
if (!ECOM_AUTHENTICATION_ID) {
|
|
4
10
|
throw new Error('ECOM_AUTHENTICATION_ID is not set');
|
|
5
11
|
}
|
|
@@ -10,8 +16,11 @@ export default () => {
|
|
|
10
16
|
const apiKey = ECOM_API_KEY;
|
|
11
17
|
const githubToken = GITHUB_TOKEN;
|
|
12
18
|
const env = {
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
storeId,
|
|
20
|
+
apiAuth: {
|
|
21
|
+
authenticationId,
|
|
22
|
+
apiKey,
|
|
23
|
+
},
|
|
15
24
|
githubToken,
|
|
16
25
|
};
|
|
17
26
|
return env;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AASA,eAAe,GAAG,EAAE;IAClB,MAAM,EACJ,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,YAAY,GACb,GAAG,OAAO,CAAC,GAAG,CAAC;IAChB,MAAM,OAAO,GAAG,aAAa,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IACD,IAAI,CAAC,sBAAsB,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IACD,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IACD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC;IAC5B,MAAM,WAAW,GAAG,YAAY,CAAC;IACjC,MAAM,GAAG,GAAQ;QACf,OAAO;QACP,OAAO,EAAE;YACP,gBAAgB;YAChB,MAAM;SACP;QACD,WAAW;KACZ,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-unresolved
|
|
2
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
3
|
+
import api from '@cloudcommerce/api';
|
|
4
|
+
import config from '../config.js';
|
|
5
|
+
|
|
6
|
+
export default async (req, res) => {
|
|
7
|
+
const { storeId, apps } = config.get();
|
|
8
|
+
const { body } = req;
|
|
9
|
+
if (Number(req.get('X-Store-ID')) === storeId
|
|
10
|
+
&& body && body.store_id === storeId) {
|
|
11
|
+
const { application, authentication } = body;
|
|
12
|
+
if (application && authentication) {
|
|
13
|
+
const matchApp = Object.keys(apps).find((slug) => {
|
|
14
|
+
return apps[slug].appId === application.app_id;
|
|
15
|
+
});
|
|
16
|
+
if (matchApp) {
|
|
17
|
+
const authenticationId = authentication.authentication_id;
|
|
18
|
+
const firestoreDoc = getFirestore().doc(`installedApps/${authenticationId}`);
|
|
19
|
+
const installedApp = await firestoreDoc.get();
|
|
20
|
+
if (installedApp.exists) {
|
|
21
|
+
res.sendStatus(200);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const appDataEndpoint = `applications/${application._id}/hidden_data`;
|
|
25
|
+
try {
|
|
26
|
+
await api.patch(appDataEndpoint, {
|
|
27
|
+
__installedAt: new Date().toISOString(),
|
|
28
|
+
}, {
|
|
29
|
+
authenticationId: authentication._id,
|
|
30
|
+
apiKey: authentication.api_key,
|
|
31
|
+
});
|
|
32
|
+
} catch (e) {
|
|
33
|
+
res.sendStatus(403);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// Received app authentication is valid
|
|
37
|
+
await firestoreDoc.set({ application, authentication });
|
|
38
|
+
res.sendStatus(201);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
res.sendStatus(400);
|
|
44
|
+
};
|
|
45
|
+
// # sourceMappingURL=auth-callback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-callback.js","sourceRoot":"","sources":["../../src/handlers/auth-callback.ts"],"names":[],"mappings":"AACA,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,GAAoB,MAAM,oBAAoB,CAAC;AACtD,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B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AAC,CAAC;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACV,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;oBACpB,OAAO;iBACR;gBAED,uCAAuC;gBACvC,MAAM,YAAY,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;gBACxD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;gBACpB,OAAO;aACR;SACF;KACF;IACD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-unresolved
|
|
2
2
|
import { getFirestore } from 'firebase-admin/firestore';
|
|
3
|
-
import
|
|
3
|
+
import logger from 'firebase-functions/lib/logger';
|
|
4
4
|
import api from '@cloudcommerce/api';
|
|
5
5
|
import getEnv from '../env.js';
|
|
6
6
|
|
|
7
7
|
export default async () => {
|
|
8
|
-
const {
|
|
8
|
+
const { apiAuth } = getEnv();
|
|
9
9
|
const eventsSubs = await getFirestore().collection('eventsSubs').get();
|
|
10
10
|
const listenedEvents = [];
|
|
11
11
|
eventsSubs.forEach((doc) => {
|
|
@@ -20,11 +20,8 @@ export default async () => {
|
|
|
20
20
|
'products',
|
|
21
21
|
'carts',
|
|
22
22
|
].forEach(async (resource) => {
|
|
23
|
-
const { data: { result } } = await api
|
|
24
|
-
|
|
25
|
-
apiKey,
|
|
26
|
-
endpoint: `events/${resource}`,
|
|
27
|
-
});
|
|
23
|
+
const { data: { result } } = await api
|
|
24
|
+
.get(`events/${resource}`, apiAuth);
|
|
28
25
|
logger.info(`${resource} events: `, result);
|
|
29
26
|
});
|
|
30
27
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-store-events.js","sourceRoot":"","sources":["../../src/handlers/check-store-events.ts"],"names":[],"mappings":"AACA,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,C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|
|
1
1
|
import 'source-map-support/register.js';
|
|
2
2
|
import '@cloudcommerce/api/fetch-polyfill.js';
|
|
3
|
-
|
|
3
|
+
import functions from 'firebase-functions';
|
|
4
|
+
export declare const cronStoreEvents: functions.CloudFunction<unknown>;
|
|
5
|
+
export declare const appAuthCallback: functions.HttpsFunction;
|
|
@@ -4,12 +4,26 @@ import '@cloudcommerce/api/fetch-polyfill.js';
|
|
|
4
4
|
// https://github.com/import-js/eslint-plugin-import/issues/1810
|
|
5
5
|
// eslint-disable-next-line import/no-unresolved
|
|
6
6
|
import { initializeApp } from 'firebase-admin/app';
|
|
7
|
-
import
|
|
7
|
+
import functions from 'firebase-functions';
|
|
8
|
+
import config from './config.js';
|
|
8
9
|
import checkStoreEvents from './handlers/check-store-events.js';
|
|
10
|
+
import handleAuthCallback from './handlers/auth-callback.js';
|
|
9
11
|
|
|
10
12
|
initializeApp();
|
|
13
|
+
const { httpsFunctionOptions: { region } } = config.get();
|
|
14
|
+
const functionBuilder = functions
|
|
15
|
+
.region(region)
|
|
16
|
+
.runWith({
|
|
17
|
+
timeoutSeconds: 300,
|
|
18
|
+
memory: '128MB',
|
|
19
|
+
});
|
|
11
20
|
|
|
12
|
-
export const cronStoreEvents = pubsub
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
export const cronStoreEvents = functionBuilder.pubsub
|
|
22
|
+
.schedule('* * * * *')
|
|
23
|
+
.onRun(() => {
|
|
24
|
+
return checkStoreEvents();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const appAuthCallback = functionBuilder.https
|
|
28
|
+
.onRequest(handleAuthCallback);
|
|
15
29
|
// # sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,OAAO,sCAAsC,CAAC;AAC9C,gEAAgE;AAChE,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,OAAO,sCAAsC,CAAC;AAC9C,gEAAgE;AAChE,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D,aAAa,EAAE,CAAC;AAEhB,MAAM,EAAE,oBAAoB,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;AAE1D,MAAM,eAAe,GAAG,SAAS;KAC9B,MAAM,CAAC,MAAM,CAAC;KACd,OAAO,CAAC;IACP,cAAc,EAAE,GAAG;IACnB,MAAM,EAAE,OAAO;CAChB,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,MAAM;KAClD,QAAQ,CAAC,WAAW,CAAC;KACrB,KAAK,CAAC,GAAG,EAAE;IACV,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,KAAK;KACjD,SAAS,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
type Env = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
storeId: number;
|
|
3
|
+
apiAuth: {
|
|
4
|
+
authenticationId: string;
|
|
5
|
+
apiKey: string;
|
|
6
|
+
},
|
|
4
7
|
githubToken?: string;
|
|
5
8
|
};
|
|
6
9
|
|
|
7
10
|
export default () => {
|
|
8
11
|
const {
|
|
12
|
+
ECOM_STORE_ID,
|
|
9
13
|
ECOM_AUTHENTICATION_ID,
|
|
10
14
|
ECOM_API_KEY,
|
|
11
15
|
GITHUB_TOKEN,
|
|
12
16
|
} = process.env;
|
|
17
|
+
const storeId = ECOM_STORE_ID && parseInt(ECOM_STORE_ID, 10);
|
|
18
|
+
if (!storeId) {
|
|
19
|
+
throw new Error('ECOM_STORE_ID is not set or not a number');
|
|
20
|
+
}
|
|
13
21
|
if (!ECOM_AUTHENTICATION_ID) {
|
|
14
22
|
throw new Error('ECOM_AUTHENTICATION_ID is not set');
|
|
15
23
|
}
|
|
@@ -20,8 +28,11 @@ export default () => {
|
|
|
20
28
|
const apiKey = ECOM_API_KEY;
|
|
21
29
|
const githubToken = GITHUB_TOKEN;
|
|
22
30
|
const env: Env = {
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
storeId,
|
|
32
|
+
apiAuth: {
|
|
33
|
+
authenticationId,
|
|
34
|
+
apiKey,
|
|
35
|
+
},
|
|
25
36
|
githubToken,
|
|
26
37
|
};
|
|
27
38
|
return env;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Request, Response } from 'firebase-functions';
|
|
2
|
+
// eslint-disable-next-line import/no-unresolved
|
|
3
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
4
|
+
import api, { ApiEndpoint } from '@cloudcommerce/api';
|
|
5
|
+
import config from '../config';
|
|
6
|
+
|
|
7
|
+
export default async (req: Request, res: Response) => {
|
|
8
|
+
const { storeId, apps } = config.get();
|
|
9
|
+
const { body } = req;
|
|
10
|
+
if (
|
|
11
|
+
Number(req.get('X-Store-ID')) === storeId
|
|
12
|
+
&& body && body.store_id === storeId
|
|
13
|
+
) {
|
|
14
|
+
const { application, authentication } = body;
|
|
15
|
+
if (application && authentication) {
|
|
16
|
+
const matchApp = Object.keys(apps).find((slug) => {
|
|
17
|
+
return apps[slug].appId === application.app_id;
|
|
18
|
+
});
|
|
19
|
+
if (matchApp) {
|
|
20
|
+
const authenticationId = authentication.authentication_id;
|
|
21
|
+
const firestoreDoc = getFirestore().doc(`installedApps/${authenticationId}`);
|
|
22
|
+
const installedApp = await firestoreDoc.get();
|
|
23
|
+
if (installedApp.exists) {
|
|
24
|
+
res.sendStatus(200);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const appDataEndpoint: ApiEndpoint = `applications/${application._id}/hidden_data`;
|
|
29
|
+
try {
|
|
30
|
+
await api.patch(appDataEndpoint, {
|
|
31
|
+
__installedAt: new Date().toISOString(),
|
|
32
|
+
}, {
|
|
33
|
+
authenticationId: authentication._id,
|
|
34
|
+
apiKey: authentication.api_key,
|
|
35
|
+
});
|
|
36
|
+
} catch (e) {
|
|
37
|
+
res.sendStatus(403);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Received app authentication is valid
|
|
42
|
+
await firestoreDoc.set({ application, authentication });
|
|
43
|
+
res.sendStatus(201);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
res.sendStatus(400);
|
|
49
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { EventSub } from '../types';
|
|
2
2
|
// eslint-disable-next-line import/no-unresolved
|
|
3
3
|
import { getFirestore } from 'firebase-admin/firestore';
|
|
4
|
-
import
|
|
4
|
+
import logger from 'firebase-functions/lib/logger';
|
|
5
5
|
import api from '@cloudcommerce/api';
|
|
6
6
|
import getEnv from '../env';
|
|
7
7
|
|
|
8
8
|
export default async () => {
|
|
9
|
-
const {
|
|
9
|
+
const { apiAuth } = getEnv();
|
|
10
10
|
const eventsSubs = await getFirestore().collection('eventsSubs').get();
|
|
11
11
|
const listenedEvents: EventSub['event'][] = [];
|
|
12
12
|
eventsSubs.forEach((doc) => {
|
|
@@ -21,11 +21,8 @@ export default async () => {
|
|
|
21
21
|
'products',
|
|
22
22
|
'carts',
|
|
23
23
|
].forEach(async (resource) => {
|
|
24
|
-
const { data: { result } } = await api
|
|
25
|
-
|
|
26
|
-
apiKey,
|
|
27
|
-
endpoint: `events/${resource as 'orders'}`,
|
|
28
|
-
});
|
|
24
|
+
const { data: { result } } = await api
|
|
25
|
+
.get(`events/${resource as 'orders'}`, apiAuth);
|
|
29
26
|
logger.info(`${resource} events: `, result);
|
|
30
27
|
});
|
|
31
28
|
return true;
|
|
@@ -5,11 +5,27 @@ import '@cloudcommerce/api/fetch-polyfill.js';
|
|
|
5
5
|
// https://github.com/import-js/eslint-plugin-import/issues/1810
|
|
6
6
|
// eslint-disable-next-line import/no-unresolved
|
|
7
7
|
import { initializeApp } from 'firebase-admin/app';
|
|
8
|
-
import
|
|
8
|
+
import functions from 'firebase-functions';
|
|
9
|
+
import config from './config';
|
|
9
10
|
import checkStoreEvents from './handlers/check-store-events';
|
|
11
|
+
import handleAuthCallback from './handlers/auth-callback';
|
|
10
12
|
|
|
11
13
|
initializeApp();
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const { httpsFunctionOptions: { region } } = config.get();
|
|
16
|
+
|
|
17
|
+
const functionBuilder = functions
|
|
18
|
+
.region(region)
|
|
19
|
+
.runWith({
|
|
20
|
+
timeoutSeconds: 300,
|
|
21
|
+
memory: '128MB',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const cronStoreEvents = functionBuilder.pubsub
|
|
25
|
+
.schedule('* * * * *')
|
|
26
|
+
.onRun(() => {
|
|
27
|
+
return checkStoreEvents();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const appAuthCallback = functionBuilder.https
|
|
31
|
+
.onRequest(handleAuthCallback);
|
|
@@ -11,13 +11,10 @@ import serveModulesApi from './firebase/serve-modules-api.js';
|
|
|
11
11
|
initializeApp();
|
|
12
12
|
const { httpsFunctionOptions } = config.get();
|
|
13
13
|
|
|
14
|
-
export const
|
|
15
|
-
const {
|
|
14
|
+
export const modules = onRequest(httpsFunctionOptions, (req, res) => {
|
|
15
|
+
const { apiAuth } = getEnv();
|
|
16
16
|
// Hide API key for security
|
|
17
17
|
process.env.ECOM_API_KEY = '***';
|
|
18
|
-
serveModulesApi(req, res,
|
|
19
|
-
authenticationId,
|
|
20
|
-
apiKey,
|
|
21
|
-
});
|
|
18
|
+
serveModulesApi(req, res, apiAuth);
|
|
22
19
|
});
|
|
23
20
|
// # sourceMappingURL=firebase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,MAAM,MAAM,iCAAiC,CAAC;AACrD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,aAAa,EAAE,CAAC;AAChB,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,MAAM,MAAM,iCAAiC,CAAC;AACrD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,aAAa,EAAE,CAAC;AAChB,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7B,4BAA4B;IAC5B,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
|
|
@@ -12,12 +12,9 @@ import serveModulesApi from './firebase/serve-modules-api';
|
|
|
12
12
|
initializeApp();
|
|
13
13
|
const { httpsFunctionOptions } = config.get();
|
|
14
14
|
|
|
15
|
-
export const
|
|
16
|
-
const {
|
|
15
|
+
export const modules = onRequest(httpsFunctionOptions, (req, res) => {
|
|
16
|
+
const { apiAuth } = getEnv();
|
|
17
17
|
// Hide API key for security
|
|
18
18
|
process.env.ECOM_API_KEY = '***';
|
|
19
|
-
serveModulesApi(req, res,
|
|
20
|
-
authenticationId,
|
|
21
|
-
apiKey,
|
|
22
|
-
});
|
|
19
|
+
serveModulesApi(req, res, apiAuth);
|
|
23
20
|
});
|
|
@@ -9,7 +9,7 @@ import config from '@cloudcommerce/firebase/lib/config';
|
|
|
9
9
|
initializeApp();
|
|
10
10
|
const options = config.get().httpsFunctionOptions;
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const passport = onRequest(options, (request, response) => {
|
|
13
13
|
process.env.ECOM_API_KEY = '***';
|
|
14
14
|
response.send('Hello passport!');
|
|
15
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,aAAa,EAAE,CAAC;AAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,aAAa,EAAE,CAAC;AAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC/D,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"}
|
|
@@ -10,7 +10,7 @@ import config from '@cloudcommerce/firebase/lib/config';
|
|
|
10
10
|
initializeApp();
|
|
11
11
|
const options = config.get().httpsFunctionOptions;
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const passport = onRequest(options, (request, response) => {
|
|
14
14
|
process.env.ECOM_API_KEY = '***';
|
|
15
15
|
response.send('Hello passport!');
|
|
16
16
|
});
|
package/pnpm-lock.yaml
CHANGED
|
@@ -60,10 +60,16 @@ importers:
|
|
|
60
60
|
specifiers:
|
|
61
61
|
'@cloudcommerce/api': workspace:*
|
|
62
62
|
'@cloudcommerce/types': workspace:*
|
|
63
|
+
'@firebase/app-types': ^0.7.0
|
|
64
|
+
firebase-admin: ^11.0.1
|
|
65
|
+
firebase-functions: ^3.22.0
|
|
63
66
|
dependencies:
|
|
64
67
|
'@cloudcommerce/api': link:../../api
|
|
68
|
+
firebase-admin: 11.0.1_@firebase+app-types@0.7.0
|
|
69
|
+
firebase-functions: 3.22.0_firebase-admin@11.0.1
|
|
65
70
|
devDependencies:
|
|
66
71
|
'@cloudcommerce/types': link:../../types
|
|
72
|
+
'@firebase/app-types': 0.7.0
|
|
67
73
|
|
|
68
74
|
packages/cli:
|
|
69
75
|
specifiers:
|
|
@@ -78,7 +84,7 @@ importers:
|
|
|
78
84
|
packages/events:
|
|
79
85
|
specifiers:
|
|
80
86
|
'@cloudcommerce/api': workspace:*
|
|
81
|
-
'@cloudcommerce/firebase': workspace
|
|
87
|
+
'@cloudcommerce/firebase': workspace:*
|
|
82
88
|
'@cloudcommerce/types': workspace:*
|
|
83
89
|
'@firebase/app-types': ^0.7.0
|
|
84
90
|
firebase-admin: ^11.0.1
|
|
@@ -118,7 +124,7 @@ importers:
|
|
|
118
124
|
packages/modules:
|
|
119
125
|
specifiers:
|
|
120
126
|
'@cloudcommerce/api': workspace:*
|
|
121
|
-
'@cloudcommerce/app-discounts': workspace
|
|
127
|
+
'@cloudcommerce/app-discounts': workspace:*
|
|
122
128
|
'@cloudcommerce/firebase': workspace:*
|
|
123
129
|
'@cloudcommerce/types': workspace:*
|
|
124
130
|
'@firebase/app-types': ^0.7.0
|
|
@@ -198,36 +204,44 @@ importers:
|
|
|
198
204
|
|
|
199
205
|
store:
|
|
200
206
|
specifiers:
|
|
201
|
-
'@cloudcommerce/cli': ^0.0.
|
|
207
|
+
'@cloudcommerce/cli': ^0.0.46
|
|
202
208
|
dependencies:
|
|
203
209
|
'@cloudcommerce/cli': link:../packages/cli
|
|
204
210
|
|
|
205
211
|
store/functions/core:
|
|
206
212
|
specifiers:
|
|
207
|
-
'@cloudcommerce/firebase': ^0.0.
|
|
213
|
+
'@cloudcommerce/firebase': ^0.0.46
|
|
214
|
+
dependencies:
|
|
215
|
+
'@cloudcommerce/firebase': link:../../../packages/firebase
|
|
216
|
+
|
|
217
|
+
store/functions/events:
|
|
218
|
+
specifiers:
|
|
219
|
+
'@cloudcommerce/events': ^0.0.46
|
|
220
|
+
'@cloudcommerce/firebase': ^0.0.46
|
|
208
221
|
dependencies:
|
|
222
|
+
'@cloudcommerce/events': link:../../../packages/events
|
|
209
223
|
'@cloudcommerce/firebase': link:../../../packages/firebase
|
|
210
224
|
|
|
211
225
|
store/functions/modules:
|
|
212
226
|
specifiers:
|
|
213
|
-
'@cloudcommerce/firebase': ^0.0.
|
|
214
|
-
'@cloudcommerce/modules': ^0.0.
|
|
227
|
+
'@cloudcommerce/firebase': ^0.0.46
|
|
228
|
+
'@cloudcommerce/modules': ^0.0.46
|
|
215
229
|
dependencies:
|
|
216
230
|
'@cloudcommerce/firebase': link:../../../packages/firebase
|
|
217
231
|
'@cloudcommerce/modules': link:../../../packages/modules
|
|
218
232
|
|
|
219
233
|
store/functions/passport:
|
|
220
234
|
specifiers:
|
|
221
|
-
'@cloudcommerce/firebase': ^0.0.
|
|
222
|
-
'@cloudcommerce/passport': ^0.0.
|
|
235
|
+
'@cloudcommerce/firebase': ^0.0.46
|
|
236
|
+
'@cloudcommerce/passport': ^0.0.46
|
|
223
237
|
dependencies:
|
|
224
238
|
'@cloudcommerce/firebase': link:../../../packages/firebase
|
|
225
239
|
'@cloudcommerce/passport': link:../../../packages/passport
|
|
226
240
|
|
|
227
241
|
store/functions/ssr:
|
|
228
242
|
specifiers:
|
|
229
|
-
'@cloudcommerce/firebase': ^0.0.
|
|
230
|
-
'@cloudcommerce/ssr': ^0.0.
|
|
243
|
+
'@cloudcommerce/firebase': ^0.0.46
|
|
244
|
+
'@cloudcommerce/ssr': ^0.0.46
|
|
231
245
|
dependencies:
|
|
232
246
|
'@cloudcommerce/firebase': link:../../../packages/firebase
|
|
233
247
|
'@cloudcommerce/ssr': link:../../../packages/ssr
|