cloudcommerce 0.0.42 → 0.0.45
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 +42 -0
- package/action.yml +8 -6
- package/package.json +1 -1
- package/packages/api/lib/index.d.ts +9 -3
- package/packages/api/lib/index.js +12 -2
- package/packages/api/lib/index.js.map +1 -1
- package/packages/api/lib/types.d.ts +12 -2
- package/packages/api/package.json +1 -1
- package/packages/api/src/index.ts +28 -5
- package/packages/api/src/types.ts +13 -1
- package/packages/apps/discounts/lib/index.d.ts +3 -0
- package/packages/apps/discounts/lib/index.js +3 -1
- package/packages/apps/discounts/lib/index.js.map +1 -1
- package/packages/apps/discounts/package.json +3 -3
- package/packages/apps/discounts/src/index.ts +1 -1
- package/packages/apps/discounts/tsconfig.json +4 -1
- package/packages/cli/lib/build.js +5 -2
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/build.ts +8 -5
- package/packages/events/CHANGELOG.md +1 -0
- package/packages/events/README.md +1 -0
- package/packages/events/package.json +36 -0
- package/packages/events/src/firebase.ts +31 -0
- package/packages/events/src/index.ts +1 -0
- package/packages/events/tsconfig.json +3 -0
- package/packages/firebase/lib/config.d.ts +5 -0
- package/packages/firebase/lib/config.js +27 -18
- package/packages/firebase/lib/config.js.map +1 -1
- package/packages/firebase/lib/defaults.js +4 -1
- package/packages/firebase/lib/env.js +17 -17
- package/packages/firebase/lib/handlers/check-store-events.js +24 -23
- package/packages/firebase/lib/index.d.ts +1 -1
- package/packages/firebase/lib/index.js +6 -3
- package/packages/firebase/lib/index.js.map +1 -1
- package/packages/firebase/lib/types.js +1 -1
- package/packages/firebase/package.json +3 -2
- package/packages/firebase/src/config.ts +5 -0
- package/packages/firebase/src/index.ts +2 -1
- package/packages/modules/lib/firebase/ajv.js +33 -0
- package/packages/modules/lib/firebase/ajv.js.map +1 -0
- package/packages/modules/lib/firebase/call-app-module.js +76 -0
- package/packages/modules/lib/firebase/call-app-module.js.map +1 -0
- package/packages/modules/lib/firebase/checkout.js +1 -0
- package/packages/modules/lib/firebase/checkout.js.map +1 -0
- package/packages/modules/lib/firebase/handle-module.js +161 -0
- package/packages/modules/lib/firebase/handle-module.js.map +1 -0
- package/packages/modules/lib/firebase/proxy-apps.js +1 -0
- package/packages/modules/lib/firebase/proxy-apps.js.map +1 -0
- package/packages/modules/lib/firebase/serve-modules-api.js +57 -0
- package/packages/modules/lib/firebase/serve-modules-api.js.map +1 -0
- package/packages/modules/lib/firebase.js +11 -3
- package/packages/modules/lib/firebase.js.map +1 -1
- package/packages/modules/lib/index.js +11 -7
- package/packages/modules/lib/index.js.map +1 -1
- package/packages/modules/package.json +5 -1
- package/packages/modules/src/firebase/ajv.ts +38 -0
- package/packages/modules/src/firebase/call-app-module.ts +86 -0
- package/packages/modules/src/firebase/{.gitkeep → checkout.ts} +0 -0
- package/packages/modules/src/firebase/handle-module.ts +197 -0
- package/packages/modules/src/firebase/proxy-apps.ts +0 -0
- package/packages/modules/src/firebase/serve-modules-api.ts +66 -0
- package/packages/modules/src/firebase.ts +11 -3
- package/packages/modules/src/index.ts +11 -8
- package/packages/passport/lib/firebase.js +2 -1
- package/packages/passport/lib/firebase.js.map +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/passport/src/firebase.ts +2 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/package.json +1 -1
- package/packages/types/index.ts +10 -4
- package/packages/types/package.json +1 -1
- package/pnpm-lock.yaml +79 -13
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AppModuleName } from '@cloudcommerce/types';
|
|
2
|
+
import { logger } from 'firebase-functions';
|
|
3
|
+
import axios, { AxiosResponse } from 'axios';
|
|
4
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
5
|
+
|
|
6
|
+
// Blacklist urls to prevent consecultive errors
|
|
7
|
+
const blacklist = {};
|
|
8
|
+
|
|
9
|
+
export default async (
|
|
10
|
+
appId: number,
|
|
11
|
+
modName: AppModuleName,
|
|
12
|
+
url: string,
|
|
13
|
+
data: any,
|
|
14
|
+
isBigTimeout: boolean,
|
|
15
|
+
) => {
|
|
16
|
+
if (blacklist[url] > 2) {
|
|
17
|
+
logger.log(`> Skipping blacklisted ${url}`);
|
|
18
|
+
const err = new Error('Blacklited endpoint URL');
|
|
19
|
+
return Promise.reject(err);
|
|
20
|
+
}
|
|
21
|
+
const { storeId, apps } = config.get();
|
|
22
|
+
|
|
23
|
+
const debug = (response: AxiosResponse) => {
|
|
24
|
+
const status = response ? response.status : 0;
|
|
25
|
+
if (!blacklist[url]) {
|
|
26
|
+
blacklist[url] = 1;
|
|
27
|
+
} else {
|
|
28
|
+
blacklist[url] += 1;
|
|
29
|
+
}
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
if (blacklist[url] > 1) {
|
|
32
|
+
blacklist[url] -= 1;
|
|
33
|
+
} else {
|
|
34
|
+
delete blacklist[url];
|
|
35
|
+
}
|
|
36
|
+
}, !status ? 180000 : 6000);
|
|
37
|
+
|
|
38
|
+
logger.info(`${url} : ${status}`);
|
|
39
|
+
if (status >= 400 && status < 500) {
|
|
40
|
+
const { data: resData } = response;
|
|
41
|
+
if (typeof resData === 'object' && resData !== null) {
|
|
42
|
+
const { error, message } = resData;
|
|
43
|
+
if (typeof error === 'string' && error.length && typeof message === 'string') {
|
|
44
|
+
logger.warn(JSON.stringify({ error, message }));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (modName === 'apply_discount') {
|
|
51
|
+
if (appId === apps.discounts.appId) {
|
|
52
|
+
return import('@cloudcommerce/app-discounts')
|
|
53
|
+
.then(({ applyDiscount }) => applyDiscount());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return axios({
|
|
58
|
+
method: 'POST',
|
|
59
|
+
maxRedirects: 2,
|
|
60
|
+
responseType: 'json',
|
|
61
|
+
maxContentLength: 1000000, // 1MB
|
|
62
|
+
url,
|
|
63
|
+
data,
|
|
64
|
+
headers: {
|
|
65
|
+
'X-Store-ID': storeId.toString(),
|
|
66
|
+
},
|
|
67
|
+
// Wait 10s by default and 30s in specific cases
|
|
68
|
+
timeout: isBigTimeout ? 30000 : 10000,
|
|
69
|
+
})
|
|
70
|
+
.then((response) => {
|
|
71
|
+
debug(response);
|
|
72
|
+
return response.data;
|
|
73
|
+
})
|
|
74
|
+
.catch((err) => {
|
|
75
|
+
const { response } = err;
|
|
76
|
+
debug(response);
|
|
77
|
+
if (err.message || err.code) {
|
|
78
|
+
let msg = `Axios error ${err.code}: ${err.message}`;
|
|
79
|
+
if (data) {
|
|
80
|
+
msg += `\n\n${JSON.stringify(data)}`;
|
|
81
|
+
}
|
|
82
|
+
logger.warn(msg);
|
|
83
|
+
}
|
|
84
|
+
throw err;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { Request, Response } from 'firebase-functions';
|
|
2
|
+
import type { Applications, AppModuleName } from '@cloudcommerce/types';
|
|
3
|
+
import { logger } from 'firebase-functions';
|
|
4
|
+
import Ajv, { ValidateFunction } from 'ajv';
|
|
5
|
+
import api, { ApiError, ApiConfig } from '@cloudcommerce/api';
|
|
6
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
7
|
+
import {
|
|
8
|
+
ajv,
|
|
9
|
+
ajvOptions,
|
|
10
|
+
parseAjvErrors,
|
|
11
|
+
sendRequestError,
|
|
12
|
+
} from './ajv';
|
|
13
|
+
import callAppModule from './call-app-module';
|
|
14
|
+
|
|
15
|
+
const ajvAppsResponse = new Ajv({ ...ajvOptions, allErrors: true });
|
|
16
|
+
|
|
17
|
+
// Cache apps list and no params modules results
|
|
18
|
+
const appsCache = {};
|
|
19
|
+
const resultsCache = {};
|
|
20
|
+
|
|
21
|
+
async function runModule(
|
|
22
|
+
apiAuth: { authenticationId: string, apiKey: string },
|
|
23
|
+
params: { [key: string]: any },
|
|
24
|
+
res: Response,
|
|
25
|
+
modName: string,
|
|
26
|
+
validate: ValidateFunction,
|
|
27
|
+
responseValidate: ValidateFunction,
|
|
28
|
+
appId?: any,
|
|
29
|
+
) {
|
|
30
|
+
const respond = (result: any[]) => res.send({
|
|
31
|
+
result,
|
|
32
|
+
meta: params,
|
|
33
|
+
});
|
|
34
|
+
const { storeId } = config.get();
|
|
35
|
+
const isEmptyParams = (!params || !Object.keys(params).length);
|
|
36
|
+
if (!validate(params)) {
|
|
37
|
+
return sendRequestError(res, modName, validate.errors);
|
|
38
|
+
}
|
|
39
|
+
let canCache = true;
|
|
40
|
+
const cacheKey = `${storeId}:${modName}`;
|
|
41
|
+
const listAppsParams: ApiConfig['params'] = {
|
|
42
|
+
state: 'active',
|
|
43
|
+
[`modules.${modName}.enabled`]: true,
|
|
44
|
+
fields: `_id,app_id,version,data,hidden_data,modules.${modName}`,
|
|
45
|
+
};
|
|
46
|
+
if (
|
|
47
|
+
appId
|
|
48
|
+
&& (typeof appId === 'number' || (typeof appId === 'string' && /^\d+$/.test(appId)))
|
|
49
|
+
) {
|
|
50
|
+
canCache = false;
|
|
51
|
+
listAppsParams.app_id = appId;
|
|
52
|
+
listAppsParams.limit = 1;
|
|
53
|
+
}
|
|
54
|
+
let canCacheResults = false;
|
|
55
|
+
if (canCache && isEmptyParams) {
|
|
56
|
+
if (resultsCache[cacheKey]) {
|
|
57
|
+
return respond(resultsCache[cacheKey]);
|
|
58
|
+
}
|
|
59
|
+
canCacheResults = true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let appsList: Applications[];
|
|
63
|
+
if (canCache && appsCache[cacheKey]) {
|
|
64
|
+
appsList = appsCache[cacheKey];
|
|
65
|
+
} else {
|
|
66
|
+
try {
|
|
67
|
+
const { data } = await api.get('applications', {
|
|
68
|
+
...apiAuth,
|
|
69
|
+
params: listAppsParams,
|
|
70
|
+
});
|
|
71
|
+
appsList = data.result;
|
|
72
|
+
} catch (err: any) {
|
|
73
|
+
logger.error(err);
|
|
74
|
+
const error = err as ApiError;
|
|
75
|
+
return res.status(500).send({
|
|
76
|
+
status: 500,
|
|
77
|
+
error_code: 'MOD801',
|
|
78
|
+
message: `Store API returned status ${error.statusCode} trying to list apps`,
|
|
79
|
+
more_info: error.data?.user_message?.en_us,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (Array.isArray(appsList)) {
|
|
85
|
+
if (!appsList.length) {
|
|
86
|
+
return respond([]);
|
|
87
|
+
}
|
|
88
|
+
if (canCache && !appsCache[cacheKey]) {
|
|
89
|
+
appsCache[cacheKey] = appsList;
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
appsCache[cacheKey] = null;
|
|
92
|
+
delete appsCache[cacheKey];
|
|
93
|
+
}, appsList.length ? 60000 : 3000);
|
|
94
|
+
}
|
|
95
|
+
const moduleReqs: Promise<any>[] = [];
|
|
96
|
+
for (let i = 0; i < appsList.length; i++) {
|
|
97
|
+
const application = appsList[i] as Applications & { modules: { [key: string]: any } };
|
|
98
|
+
if (!application.hidden_data) {
|
|
99
|
+
application.hidden_data = {};
|
|
100
|
+
}
|
|
101
|
+
if (!application.data) {
|
|
102
|
+
application.data = {};
|
|
103
|
+
}
|
|
104
|
+
const appModuleUrl = application.modules[modName].endpoint as string;
|
|
105
|
+
// Handle request with big timeout if proxying one app (by ID) only
|
|
106
|
+
const isBigTimeout = !!(appId);
|
|
107
|
+
const appModuleBody = {
|
|
108
|
+
module: modName,
|
|
109
|
+
params,
|
|
110
|
+
application,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const reqStartTime = Date.now();
|
|
114
|
+
moduleReqs.push(new Promise((resolve) => {
|
|
115
|
+
let response: any;
|
|
116
|
+
let isError = false;
|
|
117
|
+
let errorMessage: string | null = null;
|
|
118
|
+
callAppModule(
|
|
119
|
+
appId,
|
|
120
|
+
modName as AppModuleName,
|
|
121
|
+
appModuleUrl,
|
|
122
|
+
appModuleBody,
|
|
123
|
+
isBigTimeout,
|
|
124
|
+
)
|
|
125
|
+
.then((appResponse) => {
|
|
126
|
+
response = appResponse;
|
|
127
|
+
})
|
|
128
|
+
.catch((err: any) => {
|
|
129
|
+
response = null;
|
|
130
|
+
isError = true;
|
|
131
|
+
errorMessage = err.message;
|
|
132
|
+
})
|
|
133
|
+
.finally(() => {
|
|
134
|
+
const result = {
|
|
135
|
+
_id: application._id,
|
|
136
|
+
app_id: application.app_id,
|
|
137
|
+
took: Date.now() - reqStartTime,
|
|
138
|
+
version: application.version,
|
|
139
|
+
validated: false,
|
|
140
|
+
response_errors: null,
|
|
141
|
+
error: isError,
|
|
142
|
+
error_message: errorMessage,
|
|
143
|
+
response,
|
|
144
|
+
};
|
|
145
|
+
if (typeof response === 'object' && response !== null) {
|
|
146
|
+
result.validated = responseValidate(response);
|
|
147
|
+
if (!result.validated) {
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
result.response_errors = parseAjvErrors(
|
|
150
|
+
responseValidate.errors,
|
|
151
|
+
ajvAppsResponse,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
resolve(result);
|
|
156
|
+
});
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return Promise.all(moduleReqs).then((results) => {
|
|
161
|
+
if (!results.find(({ response }) => response)) {
|
|
162
|
+
res.status(409);
|
|
163
|
+
canCacheResults = false;
|
|
164
|
+
}
|
|
165
|
+
if (canCacheResults && !resultsCache[cacheKey]) {
|
|
166
|
+
resultsCache[cacheKey] = results;
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
resultsCache[cacheKey] = null;
|
|
169
|
+
delete resultsCache[cacheKey];
|
|
170
|
+
}, 60000);
|
|
171
|
+
}
|
|
172
|
+
return respond(results);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
// Shoud never happen
|
|
176
|
+
return res.sendStatus(501);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default (
|
|
180
|
+
modName: string,
|
|
181
|
+
schema: { [key: string]: any },
|
|
182
|
+
responseSchema: { [key: string]: any },
|
|
183
|
+
req: Request,
|
|
184
|
+
res: Response,
|
|
185
|
+
apiAuth: { authenticationId: string, apiKey: string },
|
|
186
|
+
) => {
|
|
187
|
+
const validate = ajv.compile(schema);
|
|
188
|
+
const responseValidate = ajvAppsResponse.compile(responseSchema);
|
|
189
|
+
return {
|
|
190
|
+
GET() {
|
|
191
|
+
runModule(apiAuth, req.query, res, modName, validate, responseValidate);
|
|
192
|
+
},
|
|
193
|
+
POST() {
|
|
194
|
+
runModule(apiAuth, req.body, res, modName, validate, responseValidate, req.query.app_id);
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Request, Response } from 'firebase-functions';
|
|
2
|
+
import { schemas } from '../index';
|
|
3
|
+
import handleModule from './handle-module';
|
|
4
|
+
|
|
5
|
+
export default (
|
|
6
|
+
req: Request,
|
|
7
|
+
res: Response,
|
|
8
|
+
apiAuth: { authenticationId: string, apiKey: string },
|
|
9
|
+
) => {
|
|
10
|
+
const { method } = req;
|
|
11
|
+
if (method !== 'POST' && method !== 'GET') {
|
|
12
|
+
return res.sendStatus(405);
|
|
13
|
+
}
|
|
14
|
+
if (
|
|
15
|
+
method === 'POST'
|
|
16
|
+
&& (!req.body || typeof req.body !== 'object' || Array.isArray(req.body))
|
|
17
|
+
) {
|
|
18
|
+
return res.sendStatus(400);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let { url } = req;
|
|
22
|
+
if (url.endsWith('.json')) {
|
|
23
|
+
url = url.slice(0, -5);
|
|
24
|
+
}
|
|
25
|
+
const modName = url.split('/')[1];
|
|
26
|
+
const sendSchema = (isResponseSchema = false) => {
|
|
27
|
+
return res.status(200)
|
|
28
|
+
.setHeader('Cache-Control', 'public, max-age=3600')
|
|
29
|
+
.send(schemas[modName][isResponseSchema ? 'response' : 'params']);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (modName === '@checkout') {
|
|
33
|
+
if (url === '/@checkout') {
|
|
34
|
+
return res.status(200).send({
|
|
35
|
+
status: 200,
|
|
36
|
+
message: 'CHECKOUT',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (url === '/@checkout/schema') {
|
|
40
|
+
return sendSchema();
|
|
41
|
+
}
|
|
42
|
+
return res.sendStatus(404);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (schemas[modName]) {
|
|
46
|
+
const { params: schema, response: responseSchema } = schemas[modName];
|
|
47
|
+
if (!schema.$schema) {
|
|
48
|
+
schema.$schema = 'http://json-schema.org/draft-06/schema#';
|
|
49
|
+
schema.title = `Module \`${modName}\`: Params model`;
|
|
50
|
+
}
|
|
51
|
+
if (!responseSchema.$schema) {
|
|
52
|
+
responseSchema.$schema = 'http://json-schema.org/draft-06/schema#';
|
|
53
|
+
responseSchema.title = `Module \`${modName}\`: App response model`;
|
|
54
|
+
}
|
|
55
|
+
if (url === `/${modName}/schema`) {
|
|
56
|
+
return sendSchema();
|
|
57
|
+
}
|
|
58
|
+
if (url === `/${modName}/response_schema`) {
|
|
59
|
+
return sendSchema(true);
|
|
60
|
+
}
|
|
61
|
+
if (url === `/${modName}`) {
|
|
62
|
+
return handleModule(modName, schema, responseSchema, req, res, apiAuth);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return res.sendStatus(404);
|
|
66
|
+
};
|
|
@@ -6,11 +6,19 @@ import { initializeApp } from 'firebase-admin/app';
|
|
|
6
6
|
// eslint-disable-next-line import/no-unresolved
|
|
7
7
|
import { onRequest } from 'firebase-functions/v2/https';
|
|
8
8
|
import config from '@cloudcommerce/firebase/lib/config';
|
|
9
|
+
import getEnv from '@cloudcommerce/firebase/lib/env';
|
|
10
|
+
import serveModulesApi from './firebase/serve-modules-api';
|
|
9
11
|
|
|
10
12
|
initializeApp();
|
|
11
|
-
const
|
|
13
|
+
const { httpsFunctionOptions } = config.get();
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
// eslint-disable-next-line camelcase
|
|
16
|
+
export const modules_api = onRequest(httpsFunctionOptions, (req, res) => {
|
|
17
|
+
const { authenticationId, apiKey } = getEnv();
|
|
18
|
+
// Hide API key for security
|
|
14
19
|
process.env.ECOM_API_KEY = '***';
|
|
15
|
-
|
|
20
|
+
serveModulesApi(req, res, {
|
|
21
|
+
authenticationId,
|
|
22
|
+
apiKey,
|
|
23
|
+
});
|
|
16
24
|
});
|
|
@@ -4,18 +4,21 @@ import * as listPayments from '../schemas/list_payments.cjs';
|
|
|
4
4
|
import * as createTransaction from '../schemas/create_transaction.cjs';
|
|
5
5
|
import * as checkout from '../schemas/@checkout.cjs';
|
|
6
6
|
|
|
7
|
+
const schemas = {
|
|
8
|
+
calculate_shipping: calculateShipping,
|
|
9
|
+
apply_discount: applyDiscount,
|
|
10
|
+
list_payments: listPayments,
|
|
11
|
+
create_transaction: createTransaction,
|
|
12
|
+
'@checkout': checkout,
|
|
13
|
+
};
|
|
14
|
+
|
|
7
15
|
export default {
|
|
8
16
|
calculateShipping,
|
|
9
17
|
applyDiscount,
|
|
10
18
|
listPayments,
|
|
11
19
|
createTransaction,
|
|
12
20
|
checkout,
|
|
13
|
-
|
|
14
|
-
schemas: {
|
|
15
|
-
calculate_shipping: calculateShipping,
|
|
16
|
-
apply_discount: applyDiscount,
|
|
17
|
-
list_payments: listPayments,
|
|
18
|
-
create_transaction: createTransaction,
|
|
19
|
-
'@checkout': checkout,
|
|
20
|
-
},
|
|
21
|
+
schemas,
|
|
21
22
|
};
|
|
23
|
+
|
|
24
|
+
export { schemas };
|
|
@@ -9,7 +9,8 @@ import config from '@cloudcommerce/firebase/lib/config';
|
|
|
9
9
|
initializeApp();
|
|
10
10
|
const options = config.get().httpsFunctionOptions;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// eslint-disable-next-line camelcase
|
|
13
|
+
export const passport_api = onRequest(options, (request, response) => {
|
|
13
14
|
process.env.ECOM_API_KEY = '***';
|
|
14
15
|
response.send('Hello passport!');
|
|
15
16
|
});
|
|
@@ -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,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IACnE,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"}
|
|
@@ -10,7 +10,8 @@ import config from '@cloudcommerce/firebase/lib/config';
|
|
|
10
10
|
initializeApp();
|
|
11
11
|
const options = config.get().httpsFunctionOptions;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// eslint-disable-next-line camelcase
|
|
14
|
+
export const passport_api = onRequest(options, (request, response) => {
|
|
14
15
|
process.env.ECOM_API_KEY = '***';
|
|
15
16
|
response.send('Hello passport!');
|
|
16
17
|
});
|
package/packages/types/index.ts
CHANGED
|
@@ -26,16 +26,21 @@ import type { CreateTransactionResponse } from './modules/create_transaction:res
|
|
|
26
26
|
import type { CheckoutBody } from './modules/@checkout:params';
|
|
27
27
|
|
|
28
28
|
type AppEventsTopic = 'orders-new'
|
|
29
|
-
| 'orders-
|
|
29
|
+
| 'orders-anyStatusSet'
|
|
30
30
|
| 'orders-paid'
|
|
31
31
|
| 'orders-readyForShipping'
|
|
32
32
|
| 'orders-delivered'
|
|
33
33
|
| 'orders-cancelled'
|
|
34
34
|
| 'products-new'
|
|
35
|
-
| 'products-
|
|
36
|
-
| 'products-
|
|
35
|
+
| 'products-quantitySet'
|
|
36
|
+
| 'products-priceSet'
|
|
37
37
|
| 'carts-new'
|
|
38
|
-
| 'carts-
|
|
38
|
+
| 'carts-customerSet';
|
|
39
|
+
|
|
40
|
+
type AppModuleName = 'apply_discount'
|
|
41
|
+
| 'calculate_shipping'
|
|
42
|
+
| 'list_payments'
|
|
43
|
+
| 'create_transaction';
|
|
39
44
|
|
|
40
45
|
export type {
|
|
41
46
|
Products,
|
|
@@ -54,6 +59,7 @@ export type {
|
|
|
54
59
|
ResourceListResult,
|
|
55
60
|
EventsResult,
|
|
56
61
|
AppEventsTopic,
|
|
62
|
+
AppModuleName,
|
|
57
63
|
ApplyDiscountParams,
|
|
58
64
|
ApplyDiscountResponse,
|
|
59
65
|
CalculateShippingParams,
|