cloudcommerce 0.0.116 → 0.0.117
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 +2 -0
- package/ecomplus-stores/monocard/functions/core/package.json +1 -1
- package/ecomplus-stores/monocard/functions/events/package.json +2 -2
- package/ecomplus-stores/monocard/functions/modules/package.json +2 -2
- package/ecomplus-stores/monocard/functions/passport/package.json +2 -2
- package/ecomplus-stores/monocard/functions/ssr/package.json +6 -6
- package/ecomplus-stores/monocard/package.json +1 -1
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/tiny-erp/lib/event-to-tiny.js +115 -0
- package/packages/apps/tiny-erp/lib/event-to-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/index.js +2 -0
- package/packages/apps/tiny-erp/lib/index.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js +79 -0
- package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js +84 -0
- package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js +58 -0
- package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js +7 -0
- package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +92 -0
- package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js +158 -0
- package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js +46 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js +193 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js +199 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js +129 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js +34 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js +39 -0
- package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js.map +1 -0
- package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js +47 -0
- package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js.map +1 -0
- package/packages/apps/tiny-erp/lib/tiny-erp.js +18 -0
- package/packages/apps/tiny-erp/lib/tiny-erp.js.map +1 -0
- package/packages/apps/tiny-erp/lib/tiny-webhook.js +92 -0
- package/packages/apps/tiny-erp/lib/tiny-webhook.js.map +1 -0
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/firebase/lib/config.js +34 -38
- package/packages/firebase/lib/const.js +2 -3
- package/packages/firebase/lib/env.js +1 -2
- package/packages/firebase/lib/handlers/check-store-events.js +145 -146
- package/packages/firebase/lib/helpers/pubsub.js +18 -20
- package/packages/firebase/lib/helpers/update-app-data.js +38 -38
- package/packages/firebase/lib/index.js +7 -9
- package/packages/firebase/lib/init.js +1 -2
- package/packages/firebase/package.json +1 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/turbo.json +0 -1
|
@@ -5,126 +5,125 @@ import { PubSub } from '@google-cloud/pubsub';
|
|
|
5
5
|
import api from '@cloudcommerce/api';
|
|
6
6
|
import config from '../config.js';
|
|
7
7
|
import { EVENT_SKIP_FLAG, GET_PUBSUB_TOPIC } from '../const.js';
|
|
8
|
-
|
|
9
8
|
const parseEventName = (evName, baseApiEventsFilter) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
const [resource, actionName] = evName.split('-');
|
|
10
|
+
const params = { ...baseApiEventsFilter };
|
|
11
|
+
const bodySet = {};
|
|
12
|
+
if (actionName === 'new') {
|
|
13
|
+
params.action = 'create';
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
switch (resource) {
|
|
17
|
+
case 'orders':
|
|
18
|
+
switch (actionName) {
|
|
19
|
+
case 'paid':
|
|
20
|
+
bodySet['financial_status.current'] = 'paid';
|
|
21
|
+
break;
|
|
22
|
+
case 'readyForShipping':
|
|
23
|
+
bodySet['fulfillment_status.current'] = 'ready_for_shipping';
|
|
24
|
+
break;
|
|
25
|
+
case 'shipped':
|
|
26
|
+
case 'delivered':
|
|
27
|
+
bodySet['fulfillment_status.current'] = actionName;
|
|
28
|
+
break;
|
|
29
|
+
case 'cancelled':
|
|
30
|
+
bodySet.status = 'cancelled';
|
|
31
|
+
break;
|
|
32
|
+
default: // anyStatusSet
|
|
33
|
+
params.modified_fields = [
|
|
34
|
+
'financial_status',
|
|
35
|
+
'fulfillment_status',
|
|
36
|
+
'status',
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
case 'products':
|
|
41
|
+
params.modified_fields = actionName === 'priceSet'
|
|
42
|
+
? ['price', 'variations.price']
|
|
43
|
+
: ['quantity']; // quantitySet
|
|
44
|
+
break;
|
|
45
|
+
case 'carts':
|
|
46
|
+
params.modified_fields = ['customers']; // customerSet
|
|
47
|
+
break;
|
|
48
|
+
case 'applications':
|
|
49
|
+
params.modified_fields = ['data', 'hidden_data']; // dataSet
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
38
52
|
}
|
|
39
|
-
break;
|
|
40
|
-
case 'products':
|
|
41
|
-
params.modified_fields = actionName === 'priceSet'
|
|
42
|
-
? ['price', 'variations.price']
|
|
43
|
-
: ['quantity']; // quantitySet
|
|
44
|
-
break;
|
|
45
|
-
case 'carts':
|
|
46
|
-
params.modified_fields = ['customers']; // customerSet
|
|
47
|
-
break;
|
|
48
|
-
case 'applications':
|
|
49
|
-
params.modified_fields = ['data', 'hidden_data']; // dataSet
|
|
50
|
-
break;
|
|
51
|
-
default:
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return { resource, params };
|
|
54
|
+
Object.keys(bodySet).forEach((field) => {
|
|
55
|
+
params[`body.${field}`] = bodySet[field];
|
|
56
|
+
});
|
|
57
|
+
return { resource, params };
|
|
58
58
|
};
|
|
59
59
|
const pubSubClient = new PubSub();
|
|
60
60
|
const tryPubSubPublish = (topicName, messageObj, retries = 0) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
pubSubClient.topic(topicName).publishMessage(messageObj)
|
|
62
|
+
.catch((err) => {
|
|
63
|
+
// eslint-disable-next-line no-param-reassign
|
|
64
|
+
err.retries = retries;
|
|
65
|
+
logger.error(err);
|
|
66
|
+
if (retries <= 3) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
tryPubSubPublish(topicName, messageObj, retries + 1);
|
|
69
|
+
}, 1000 * (2 ** retries));
|
|
70
|
+
}
|
|
71
71
|
});
|
|
72
72
|
};
|
|
73
|
-
|
|
74
73
|
export default async () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const timestamp = Date.now();
|
|
75
|
+
const documentRef = getFirestore().doc('storeEvents/last');
|
|
76
|
+
const documentSnapshot = await documentRef.get();
|
|
77
|
+
const lastRunTimestamp = documentSnapshot.get('timestamp')
|
|
79
78
|
|| Date.now() - 1000 * 60 * 5;
|
|
80
|
-
|
|
79
|
+
const lastNonOrdersTimestamp = documentSnapshot.get('nonOrdersTimestamp')
|
|
81
80
|
|| 0;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
const activeApps = (await api.get('applications', {
|
|
96
|
-
params: {
|
|
97
|
-
state: 'active',
|
|
98
|
-
app_id: subscribersApps.map(({ appId }) => appId),
|
|
99
|
-
fields: '_id,app_id,data,hidden_data',
|
|
100
|
-
},
|
|
101
|
-
})).data.result;
|
|
102
|
-
const listenedEvents = [];
|
|
103
|
-
subscribersApps.forEach(({ appId, events }) => {
|
|
104
|
-
if (activeApps.find((app) => app.app_id === appId)) {
|
|
105
|
-
events.forEach((evName) => {
|
|
106
|
-
if (!listenedEvents.includes(evName)) {
|
|
107
|
-
listenedEvents.push(evName);
|
|
81
|
+
const baseApiEventsFilter = {
|
|
82
|
+
'flag!': EVENT_SKIP_FLAG,
|
|
83
|
+
'timestamp>': new Date(lastRunTimestamp - 1).toISOString(),
|
|
84
|
+
'timestamp<': new Date(timestamp).toISOString(),
|
|
85
|
+
};
|
|
86
|
+
const { apps } = config.get();
|
|
87
|
+
const subscribersApps = [];
|
|
88
|
+
Object.keys(apps).forEach((appName) => {
|
|
89
|
+
const appObj = apps[appName];
|
|
90
|
+
if (appObj.events && appObj.events.length) {
|
|
91
|
+
subscribersApps.push(appObj);
|
|
108
92
|
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
// Some resource events are not listened to every minute
|
|
113
|
-
const isOrdersOnly = Boolean(new Date().getMinutes() % 5);
|
|
114
|
-
listenedEvents.forEach(async (listenedEventName) => {
|
|
115
|
-
const { resource, params } = parseEventName(listenedEventName, baseApiEventsFilter);
|
|
116
|
-
if (resource !== 'orders') {
|
|
117
|
-
if (isOrdersOnly) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (lastNonOrdersTimestamp) {
|
|
121
|
-
params['timestamp>'] = new Date(lastNonOrdersTimestamp).toISOString();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
let { data: { result } } = await api.get(`events/${resource}`, {
|
|
125
|
-
params,
|
|
126
93
|
});
|
|
127
|
-
|
|
94
|
+
const activeApps = (await api.get('applications', {
|
|
95
|
+
params: {
|
|
96
|
+
state: 'active',
|
|
97
|
+
app_id: subscribersApps.map(({ appId }) => appId),
|
|
98
|
+
fields: '_id,app_id,data,hidden_data',
|
|
99
|
+
},
|
|
100
|
+
})).data.result;
|
|
101
|
+
const listenedEvents = [];
|
|
102
|
+
subscribersApps.forEach(({ appId, events }) => {
|
|
103
|
+
if (activeApps.find((app) => app.app_id === appId)) {
|
|
104
|
+
events.forEach((evName) => {
|
|
105
|
+
if (!listenedEvents.includes(evName)) {
|
|
106
|
+
listenedEvents.push(evName);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
// Some resource events are not listened to every minute
|
|
112
|
+
const isOrdersOnly = Boolean(new Date().getMinutes() % 5);
|
|
113
|
+
listenedEvents.forEach(async (listenedEventName) => {
|
|
114
|
+
const { resource, params } = parseEventName(listenedEventName, baseApiEventsFilter);
|
|
115
|
+
if (resource !== 'orders') {
|
|
116
|
+
if (isOrdersOnly) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (lastNonOrdersTimestamp) {
|
|
120
|
+
params['timestamp>'] = new Date(lastNonOrdersTimestamp).toISOString();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
let { data: { result } } = await api.get(`events/${resource}`, {
|
|
124
|
+
params,
|
|
125
|
+
});
|
|
126
|
+
/*
|
|
128
127
|
global.api_events_middleware = async (
|
|
129
128
|
resource: string,
|
|
130
129
|
result: EventsResult,
|
|
@@ -135,45 +134,45 @@ export default async () => {
|
|
|
135
134
|
return result;
|
|
136
135
|
};
|
|
137
136
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
const resourceIdsRead = [];
|
|
143
|
-
result.forEach(async (apiEvent) => {
|
|
144
|
-
const resourceId = apiEvent.resource_id;
|
|
145
|
-
if (resourceIdsRead.includes(resourceId)) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
resourceIdsRead.push(resourceId);
|
|
149
|
-
const apiDoc = resource !== 'applications'
|
|
150
|
-
? (await api.get(`${resource}/${resourceId}`)).data
|
|
151
|
-
: null;
|
|
152
|
-
activeApps.forEach((app) => {
|
|
153
|
-
const appConfig = subscribersApps.find(({ appId }) => appId === app.app_id);
|
|
154
|
-
if (appConfig?.events.includes(listenedEventName)) {
|
|
155
|
-
const topicName = GET_PUBSUB_TOPIC(app.app_id);
|
|
156
|
-
const json = {
|
|
157
|
-
evName: listenedEventName,
|
|
158
|
-
apiEvent,
|
|
159
|
-
apiDoc: apiDoc || app,
|
|
160
|
-
app,
|
|
161
|
-
};
|
|
162
|
-
const messageObj = {
|
|
163
|
-
messageId: `${resourceId}_${apiEvent.timestamp}`,
|
|
164
|
-
json,
|
|
165
|
-
};
|
|
166
|
-
tryPubSubPublish(topicName, messageObj);
|
|
137
|
+
const middleware = global.api_events_middleware;
|
|
138
|
+
if (typeof middleware === 'function') {
|
|
139
|
+
result = await middleware(resource, result);
|
|
167
140
|
}
|
|
168
|
-
|
|
141
|
+
const resourceIdsRead = [];
|
|
142
|
+
result.forEach(async (apiEvent) => {
|
|
143
|
+
const resourceId = apiEvent.resource_id;
|
|
144
|
+
if (resourceIdsRead.includes(resourceId)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
resourceIdsRead.push(resourceId);
|
|
148
|
+
const apiDoc = resource !== 'applications'
|
|
149
|
+
? (await api.get(`${resource}/${resourceId}`)).data
|
|
150
|
+
: null;
|
|
151
|
+
activeApps.forEach((app) => {
|
|
152
|
+
const appConfig = subscribersApps.find(({ appId }) => appId === app.app_id);
|
|
153
|
+
if (appConfig?.events.includes(listenedEventName)) {
|
|
154
|
+
const topicName = GET_PUBSUB_TOPIC(app.app_id);
|
|
155
|
+
const json = {
|
|
156
|
+
evName: listenedEventName,
|
|
157
|
+
apiEvent,
|
|
158
|
+
apiDoc: apiDoc || app,
|
|
159
|
+
app,
|
|
160
|
+
};
|
|
161
|
+
const messageObj = {
|
|
162
|
+
messageId: `${resourceId}_${apiEvent.timestamp}`,
|
|
163
|
+
json,
|
|
164
|
+
};
|
|
165
|
+
tryPubSubPublish(topicName, messageObj);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
logger.info(`> '${listenedEventName}' events: `, result);
|
|
170
|
+
});
|
|
171
|
+
return documentRef.set({
|
|
172
|
+
timestamp,
|
|
173
|
+
nonOrdersTimestamp: isOrdersOnly ? lastNonOrdersTimestamp : timestamp,
|
|
174
|
+
activeApps,
|
|
175
|
+
listenedEvents,
|
|
169
176
|
});
|
|
170
|
-
logger.info(`> '${listenedEventName}' events: `, result);
|
|
171
|
-
});
|
|
172
|
-
return documentRef.set({
|
|
173
|
-
timestamp,
|
|
174
|
-
nonOrdersTimestamp: isOrdersOnly ? lastNonOrdersTimestamp : timestamp,
|
|
175
|
-
activeApps,
|
|
176
|
-
listenedEvents,
|
|
177
|
-
});
|
|
178
177
|
};
|
|
179
|
-
|
|
178
|
+
//# sourceMappingURL=check-store-events.js.map
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import functions from 'firebase-functions';
|
|
2
2
|
import config from '../config.js';
|
|
3
3
|
import { GET_PUBSUB_TOPIC } from '../const.js';
|
|
4
|
-
|
|
5
4
|
const { logger } = functions;
|
|
6
5
|
/* eslint-enable no-unused-vars */
|
|
7
6
|
const createPubSubFunction = (pubSubTopic, fn, eventMaxAgeMs = 60000) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const { httpsFunctionOptions: { region } } = config.get();
|
|
8
|
+
return functions.region(region)
|
|
9
|
+
.runWith({ failurePolicy: true })
|
|
10
|
+
.pubsub.topic(pubSubTopic).onPublish((message, context) => {
|
|
11
|
+
const eventAgeMs = Date.now() - Date.parse(context.timestamp);
|
|
12
|
+
if (eventAgeMs > eventMaxAgeMs) {
|
|
13
|
+
logger.warn(`Dropping event ${context.eventId} with age[ms]: ${eventAgeMs}`);
|
|
14
|
+
}
|
|
15
|
+
fn(message.json, context, message);
|
|
17
16
|
});
|
|
18
17
|
};
|
|
19
18
|
const createAppEventsFunction = (appNameOrId, fn, eventMaxAgeMs = 60000) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
let appId;
|
|
20
|
+
if (typeof appNameOrId === 'string') {
|
|
21
|
+
appId = config.get().apps[appNameOrId].appId;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
appId = appNameOrId;
|
|
25
|
+
}
|
|
26
|
+
return createPubSubFunction(GET_PUBSUB_TOPIC(appId), fn, eventMaxAgeMs);
|
|
27
27
|
};
|
|
28
|
-
|
|
29
28
|
export default createPubSubFunction;
|
|
30
|
-
|
|
31
29
|
export { createPubSubFunction, createAppEventsFunction };
|
|
32
|
-
|
|
30
|
+
//# sourceMappingURL=pubsub.js.map
|
|
@@ -2,44 +2,44 @@ import { PubSub } from '@google-cloud/pubsub';
|
|
|
2
2
|
import logger from 'firebase-functions/lib/logger';
|
|
3
3
|
import api from '@cloudcommerce/api';
|
|
4
4
|
import { EVENT_SKIP_FLAG, GET_PUBSUB_TOPIC } from '../const.js';
|
|
5
|
-
|
|
6
5
|
export default async (application, data, { isHiddenData = false, canSendPubSub = true } = {}) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
6
|
+
const applicationId = typeof application === 'string'
|
|
7
|
+
? application : application._id;
|
|
8
|
+
const subresource = isHiddenData ? 'hidden_data' : 'data';
|
|
9
|
+
if (application && typeof application === 'object' && canSendPubSub) {
|
|
10
|
+
// eslint-disable-next-line no-param-reassign
|
|
11
|
+
application[subresource] = data;
|
|
12
|
+
const json = {
|
|
13
|
+
evName: 'applications-dataSet',
|
|
14
|
+
apiEvent: {
|
|
15
|
+
timestamp: new Date().toISOString(),
|
|
16
|
+
resource_id: applicationId,
|
|
17
|
+
action: 'update',
|
|
18
|
+
modified_fields: [subresource],
|
|
19
|
+
authentication_id: null,
|
|
20
|
+
},
|
|
21
|
+
apiDoc: application,
|
|
22
|
+
app: {
|
|
23
|
+
_id: applicationId,
|
|
24
|
+
app_id: application.app_id,
|
|
25
|
+
data: application.data,
|
|
26
|
+
hidden_data: application.hidden_data,
|
|
27
|
+
},
|
|
28
|
+
isInternal: true,
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
await new PubSub()
|
|
32
|
+
.topic(GET_PUBSUB_TOPIC(application.app_id))
|
|
33
|
+
.publishMessage({ json });
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
logger.error(err);
|
|
37
|
+
}
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
});
|
|
39
|
+
return api.patch(`applications/${applicationId}/${subresource}`, data, {
|
|
40
|
+
headers: {
|
|
41
|
+
'X-Event-Flag': EVENT_SKIP_FLAG,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
//# sourceMappingURL=update-app-data.js.map
|
|
@@ -3,18 +3,16 @@ import './init.js';
|
|
|
3
3
|
import functions from 'firebase-functions';
|
|
4
4
|
import config from './config.js';
|
|
5
5
|
import checkStoreEvents from './handlers/check-store-events.js';
|
|
6
|
-
|
|
7
6
|
const { httpsFunctionOptions: { region } } = config.get();
|
|
8
7
|
const functionBuilder = functions
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
.region(region)
|
|
9
|
+
.runWith({
|
|
11
10
|
timeoutSeconds: 300,
|
|
12
11
|
memory: '128MB',
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
});
|
|
15
13
|
export const cronStoreEvents = functionBuilder.pubsub
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
.schedule('* * * * *')
|
|
15
|
+
.onRun(() => {
|
|
18
16
|
return checkStoreEvents();
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -4,6 +4,5 @@ import '@cloudcommerce/api/fetch-polyfill';
|
|
|
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
|
-
|
|
8
7
|
initializeApp();
|
|
9
|
-
|
|
8
|
+
//# sourceMappingURL=init.js.map
|