@flowerforce/flowerbase 1.7.5-beta.0 → 1.7.5-beta.2
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/dist/auth/providers/custom-function/controller.d.ts.map +1 -1
- package/dist/auth/providers/custom-function/controller.js +31 -6
- package/dist/features/triggers/index.d.ts.map +1 -1
- package/dist/features/triggers/index.js +2 -0
- package/dist/features/triggers/utils.d.ts.map +1 -1
- package/dist/features/triggers/utils.js +36 -28
- package/package.json +1 -1
- package/src/auth/providers/custom-function/controller.ts +35 -8
- package/src/features/triggers/__tests__/index.test.ts +75 -0
- package/src/features/triggers/index.ts +1 -0
- package/src/features/triggers/utils.ts +39 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/custom-function/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/custom-function/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAUzC;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,iBA2IlE"}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.customFunctionController = customFunctionController;
|
|
13
|
+
const mongodb_1 = require("mongodb");
|
|
13
14
|
const constants_1 = require("../../../constants");
|
|
14
15
|
const state_1 = require("../../../state");
|
|
15
16
|
const context_1 = require("../../../utils/context");
|
|
@@ -36,7 +37,10 @@ function customFunctionController(app) {
|
|
|
36
37
|
* @returns {Promise<Object>} A promise resolving with access and refresh tokens.
|
|
37
38
|
*/
|
|
38
39
|
app.post(utils_1.AUTH_ENDPOINTS.LOGIN, {
|
|
39
|
-
schema: schema_1.LOGIN_SCHEMA
|
|
40
|
+
schema: schema_1.LOGIN_SCHEMA,
|
|
41
|
+
errorHandler: (_error, _request, reply) => {
|
|
42
|
+
reply.code(500).send({ message: 'Internal Server Error' });
|
|
43
|
+
}
|
|
40
44
|
}, function (req, reply) {
|
|
41
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
46
|
var _a, _b;
|
|
@@ -75,10 +79,29 @@ function customFunctionController(app) {
|
|
|
75
79
|
reply.code(401).send({ message: 'Unauthorized' });
|
|
76
80
|
return;
|
|
77
81
|
}
|
|
78
|
-
const
|
|
82
|
+
const email = (authResult === null || authResult === void 0 ? void 0 : authResult.email) || authResult.id;
|
|
83
|
+
let authUser = yield db.collection(authCollection).findOne({ email });
|
|
79
84
|
if (!authUser) {
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
const authUserId = new mongodb_1.ObjectId();
|
|
86
|
+
yield db.collection(authCollection).insertOne({
|
|
87
|
+
_id: authUserId,
|
|
88
|
+
email,
|
|
89
|
+
status: 'confirmed',
|
|
90
|
+
createdAt: new Date(),
|
|
91
|
+
custom_data: {},
|
|
92
|
+
identities: [
|
|
93
|
+
{
|
|
94
|
+
id: authResult.id.toString(),
|
|
95
|
+
provider_id: authResult.id.toString(),
|
|
96
|
+
provider_type: 'custom-function',
|
|
97
|
+
provider_data: { email }
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
authUser = {
|
|
102
|
+
_id: authUserId,
|
|
103
|
+
email
|
|
104
|
+
};
|
|
82
105
|
}
|
|
83
106
|
const user = user_id_field && userCollection
|
|
84
107
|
? yield db
|
|
@@ -99,12 +122,14 @@ function customFunctionController(app) {
|
|
|
99
122
|
expiresAt: new Date(Date.now() + refreshTokenTtlMs),
|
|
100
123
|
revokedAt: null
|
|
101
124
|
});
|
|
102
|
-
|
|
103
|
-
|
|
125
|
+
const accessToken = this.createAccessToken(currentUserData);
|
|
126
|
+
const responsePayload = {
|
|
127
|
+
access_token: accessToken,
|
|
104
128
|
refresh_token: refreshToken,
|
|
105
129
|
device_id: '',
|
|
106
130
|
user_id: authUser._id.toString()
|
|
107
131
|
};
|
|
132
|
+
reply.code(200).send(responsePayload);
|
|
108
133
|
});
|
|
109
134
|
});
|
|
110
135
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,0CAIpC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,0CAIpC,sBAAsB,kBAqExB,CAAA"}
|
|
@@ -79,6 +79,8 @@ const activateTriggers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fa
|
|
|
79
79
|
_f = false;
|
|
80
80
|
const trigger = _d;
|
|
81
81
|
const { content } = trigger;
|
|
82
|
+
if (content.disabled)
|
|
83
|
+
continue;
|
|
82
84
|
const { type, config, event_processors } = content;
|
|
83
85
|
const functionName = event_processors.FUNCTION.config.function_name;
|
|
84
86
|
const triggerHandler = functionsList[functionName];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AA0E9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AA0E9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;AA0nBD,eAAO,MAAM,gBAAgB;kHAnmB1B,aAAa;iHA2gBb,aAAa;uHA1Zb,aAAa;CAsff,CAAA"}
|
|
@@ -252,6 +252,14 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
252
252
|
if (shouldIgnoreStreamError(error))
|
|
253
253
|
return;
|
|
254
254
|
console.error('Authentication trigger change stream error', error);
|
|
255
|
+
emitTriggerEvent({
|
|
256
|
+
status: 'error',
|
|
257
|
+
triggerName,
|
|
258
|
+
triggerType,
|
|
259
|
+
functionName,
|
|
260
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'CHANGE_STREAM' }),
|
|
261
|
+
error
|
|
262
|
+
});
|
|
255
263
|
});
|
|
256
264
|
changeStream.on('change', function (change) {
|
|
257
265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -321,13 +329,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
321
329
|
updateDescription
|
|
322
330
|
};
|
|
323
331
|
try {
|
|
324
|
-
emitTriggerEvent({
|
|
325
|
-
status: 'fired',
|
|
326
|
-
triggerName,
|
|
327
|
-
triggerType,
|
|
328
|
-
functionName,
|
|
329
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'LOGOUT' })
|
|
330
|
-
});
|
|
331
332
|
yield (0, context_1.GenerateContext)({
|
|
332
333
|
args: [Object.assign({ user: userData }, op)],
|
|
333
334
|
app,
|
|
@@ -339,6 +340,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
339
340
|
services,
|
|
340
341
|
runAsSystem: true
|
|
341
342
|
});
|
|
343
|
+
emitTriggerEvent({
|
|
344
|
+
status: 'fired',
|
|
345
|
+
triggerName,
|
|
346
|
+
triggerType,
|
|
347
|
+
functionName,
|
|
348
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'LOGOUT' })
|
|
349
|
+
});
|
|
342
350
|
}
|
|
343
351
|
catch (error) {
|
|
344
352
|
emitTriggerEvent({
|
|
@@ -373,13 +381,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
373
381
|
updateDescription
|
|
374
382
|
};
|
|
375
383
|
try {
|
|
376
|
-
emitTriggerEvent({
|
|
377
|
-
status: 'fired',
|
|
378
|
-
triggerName,
|
|
379
|
-
triggerType,
|
|
380
|
-
functionName,
|
|
381
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'DELETE' })
|
|
382
|
-
});
|
|
383
384
|
yield (0, context_1.GenerateContext)({
|
|
384
385
|
args: isAutoTrigger ? [userData] : [Object.assign({ user: userData }, op)],
|
|
385
386
|
app,
|
|
@@ -391,6 +392,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
391
392
|
services,
|
|
392
393
|
runAsSystem: true
|
|
393
394
|
});
|
|
395
|
+
emitTriggerEvent({
|
|
396
|
+
status: 'fired',
|
|
397
|
+
triggerName,
|
|
398
|
+
triggerType,
|
|
399
|
+
functionName,
|
|
400
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'DELETE' })
|
|
401
|
+
});
|
|
394
402
|
}
|
|
395
403
|
catch (error) {
|
|
396
404
|
emitTriggerEvent({
|
|
@@ -427,13 +435,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
427
435
|
updateDescription
|
|
428
436
|
};
|
|
429
437
|
try {
|
|
430
|
-
emitTriggerEvent({
|
|
431
|
-
status: 'fired',
|
|
432
|
-
triggerName,
|
|
433
|
-
triggerType,
|
|
434
|
-
functionName,
|
|
435
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'UPDATE' })
|
|
436
|
-
});
|
|
437
438
|
yield (0, context_1.GenerateContext)({
|
|
438
439
|
args: isAutoTrigger ? [userData] : [Object.assign({ user: userData }, op)],
|
|
439
440
|
app,
|
|
@@ -445,6 +446,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
445
446
|
services,
|
|
446
447
|
runAsSystem: true
|
|
447
448
|
});
|
|
449
|
+
emitTriggerEvent({
|
|
450
|
+
status: 'fired',
|
|
451
|
+
triggerName,
|
|
452
|
+
triggerType,
|
|
453
|
+
functionName,
|
|
454
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'UPDATE' })
|
|
455
|
+
});
|
|
448
456
|
}
|
|
449
457
|
catch (error) {
|
|
450
458
|
emitTriggerEvent({
|
|
@@ -518,13 +526,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
518
526
|
updateDescription
|
|
519
527
|
};
|
|
520
528
|
try {
|
|
521
|
-
emitTriggerEvent({
|
|
522
|
-
status: 'fired',
|
|
523
|
-
triggerName,
|
|
524
|
-
triggerType,
|
|
525
|
-
functionName,
|
|
526
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'CREATE' })
|
|
527
|
-
});
|
|
528
529
|
yield (0, context_1.GenerateContext)({
|
|
529
530
|
args: isAutoTrigger ? [userData] : [Object.assign({ user: userData }, op)],
|
|
530
531
|
app,
|
|
@@ -536,6 +537,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
536
537
|
services,
|
|
537
538
|
runAsSystem: true
|
|
538
539
|
});
|
|
540
|
+
emitTriggerEvent({
|
|
541
|
+
status: 'fired',
|
|
542
|
+
triggerName,
|
|
543
|
+
triggerType,
|
|
544
|
+
functionName,
|
|
545
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'CREATE' })
|
|
546
|
+
});
|
|
539
547
|
}
|
|
540
548
|
catch (error) {
|
|
541
549
|
emitTriggerEvent({
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FastifyInstance } from 'fastify'
|
|
2
|
+
import { ObjectId } from 'mongodb'
|
|
2
3
|
import { AUTH_CONFIG, DB_NAME, DEFAULT_CONFIG } from '../../../constants'
|
|
3
4
|
import { StateManager } from '../../../state'
|
|
4
5
|
import { GenerateContext } from '../../../utils/context'
|
|
@@ -30,7 +31,10 @@ export async function customFunctionController(app: FastifyInstance) {
|
|
|
30
31
|
app.post<LoginDto>(
|
|
31
32
|
AUTH_ENDPOINTS.LOGIN,
|
|
32
33
|
{
|
|
33
|
-
schema: LOGIN_SCHEMA
|
|
34
|
+
schema: LOGIN_SCHEMA,
|
|
35
|
+
errorHandler: (_error, _request, reply) => {
|
|
36
|
+
reply.code(500).send({ message: 'Internal Server Error' })
|
|
37
|
+
}
|
|
34
38
|
},
|
|
35
39
|
async function (req, reply) {
|
|
36
40
|
const customFunctionProvider = AUTH_CONFIG.authProviders?.['custom-function']
|
|
@@ -54,7 +58,7 @@ export async function customFunctionController(app: FastifyInstance) {
|
|
|
54
58
|
id
|
|
55
59
|
} = req
|
|
56
60
|
|
|
57
|
-
type CustomFunctionAuthResult = { id?: string }
|
|
61
|
+
type CustomFunctionAuthResult = { id?: string; email?: string }
|
|
58
62
|
const authResult = await GenerateContext({
|
|
59
63
|
args: [
|
|
60
64
|
req.body
|
|
@@ -77,16 +81,35 @@ export async function customFunctionController(app: FastifyInstance) {
|
|
|
77
81
|
}
|
|
78
82
|
}) as CustomFunctionAuthResult
|
|
79
83
|
|
|
80
|
-
|
|
81
84
|
if (!authResult.id) {
|
|
82
85
|
reply.code(401).send({ message: 'Unauthorized' })
|
|
83
86
|
return
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
const
|
|
89
|
+
const email = authResult?.email || authResult.id
|
|
90
|
+
let authUser = await db.collection(authCollection!).findOne({ email })
|
|
91
|
+
|
|
87
92
|
if (!authUser) {
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
const authUserId = new ObjectId()
|
|
94
|
+
await db.collection(authCollection!).insertOne({
|
|
95
|
+
_id: authUserId,
|
|
96
|
+
email,
|
|
97
|
+
status: 'confirmed',
|
|
98
|
+
createdAt: new Date(),
|
|
99
|
+
custom_data: {},
|
|
100
|
+
identities: [
|
|
101
|
+
{
|
|
102
|
+
id: authResult.id.toString(),
|
|
103
|
+
provider_id: authResult.id.toString(),
|
|
104
|
+
provider_type: 'custom-function',
|
|
105
|
+
provider_data: { email }
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
authUser = {
|
|
110
|
+
_id: authUserId,
|
|
111
|
+
email
|
|
112
|
+
}
|
|
90
113
|
}
|
|
91
114
|
|
|
92
115
|
const user =
|
|
@@ -107,6 +130,7 @@ export async function customFunctionController(app: FastifyInstance) {
|
|
|
107
130
|
...(user || {})
|
|
108
131
|
}
|
|
109
132
|
}
|
|
133
|
+
|
|
110
134
|
const refreshToken = this.createRefreshToken(currentUserData)
|
|
111
135
|
const refreshTokenHash = hashToken(refreshToken)
|
|
112
136
|
await db.collection(refreshTokensCollection).insertOne({
|
|
@@ -116,12 +140,15 @@ export async function customFunctionController(app: FastifyInstance) {
|
|
|
116
140
|
expiresAt: new Date(Date.now() + refreshTokenTtlMs),
|
|
117
141
|
revokedAt: null
|
|
118
142
|
})
|
|
119
|
-
|
|
120
|
-
|
|
143
|
+
const accessToken = this.createAccessToken(currentUserData)
|
|
144
|
+
|
|
145
|
+
const responsePayload = {
|
|
146
|
+
access_token: accessToken,
|
|
121
147
|
refresh_token: refreshToken,
|
|
122
148
|
device_id: '',
|
|
123
149
|
user_id: authUser._id.toString()
|
|
124
150
|
}
|
|
151
|
+
reply.code(200).send(responsePayload)
|
|
125
152
|
}
|
|
126
153
|
)
|
|
127
154
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { activateTriggers } from '../index'
|
|
2
|
+
import { TRIGGER_HANDLERS } from '../utils'
|
|
3
|
+
|
|
4
|
+
jest.mock('../../../constants', () => ({
|
|
5
|
+
AUTH_CONFIG: {},
|
|
6
|
+
DB_NAME: 'test-db'
|
|
7
|
+
}))
|
|
8
|
+
|
|
9
|
+
jest.mock('../utils', () => ({
|
|
10
|
+
TRIGGER_HANDLERS: {
|
|
11
|
+
SCHEDULED: jest.fn(async () => {}),
|
|
12
|
+
DATABASE: jest.fn(async () => {}),
|
|
13
|
+
AUTHENTICATION: jest.fn(async () => {})
|
|
14
|
+
}
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
describe('activateTriggers', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
jest.clearAllMocks()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('skips triggers marked as disabled', async () => {
|
|
23
|
+
const functionsList = {
|
|
24
|
+
runEnabled: jest.fn(),
|
|
25
|
+
runDisabled: jest.fn()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await activateTriggers({
|
|
29
|
+
fastify: {} as never,
|
|
30
|
+
functionsList,
|
|
31
|
+
triggersList: [
|
|
32
|
+
{
|
|
33
|
+
fileName: 'enabled-trigger.json',
|
|
34
|
+
content: {
|
|
35
|
+
name: 'enabled-trigger',
|
|
36
|
+
type: 'SCHEDULED',
|
|
37
|
+
disabled: false,
|
|
38
|
+
config: { schedule: '* * * * *' },
|
|
39
|
+
event_processors: {
|
|
40
|
+
FUNCTION: {
|
|
41
|
+
config: {
|
|
42
|
+
function_name: 'runEnabled'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
fileName: 'disabled-trigger.json',
|
|
50
|
+
content: {
|
|
51
|
+
name: 'disabled-trigger',
|
|
52
|
+
type: 'SCHEDULED',
|
|
53
|
+
disabled: true,
|
|
54
|
+
config: { schedule: '* * * * *' },
|
|
55
|
+
event_processors: {
|
|
56
|
+
FUNCTION: {
|
|
57
|
+
config: {
|
|
58
|
+
function_name: 'runDisabled'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
] as never
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
expect(TRIGGER_HANDLERS.SCHEDULED).toHaveBeenCalledTimes(1)
|
|
68
|
+
expect(TRIGGER_HANDLERS.SCHEDULED).toHaveBeenCalledWith(
|
|
69
|
+
expect.objectContaining({
|
|
70
|
+
functionName: 'runEnabled',
|
|
71
|
+
triggerName: 'enabled-trigger'
|
|
72
|
+
})
|
|
73
|
+
)
|
|
74
|
+
})
|
|
75
|
+
})
|
|
@@ -62,6 +62,7 @@ export const activateTriggers = async ({
|
|
|
62
62
|
|
|
63
63
|
for await (const trigger of triggersToActivate) {
|
|
64
64
|
const { content } = trigger
|
|
65
|
+
if (content.disabled) continue
|
|
65
66
|
const { type, config, event_processors } = content
|
|
66
67
|
|
|
67
68
|
const functionName: keyof Functions = event_processors.FUNCTION.config.function_name
|
|
@@ -277,6 +277,17 @@ const handleAuthenticationTrigger = async ({
|
|
|
277
277
|
changeStream.on('error', (error) => {
|
|
278
278
|
if (shouldIgnoreStreamError(error)) return
|
|
279
279
|
console.error('Authentication trigger change stream error', error)
|
|
280
|
+
emitTriggerEvent({
|
|
281
|
+
status: 'error',
|
|
282
|
+
triggerName,
|
|
283
|
+
triggerType,
|
|
284
|
+
functionName,
|
|
285
|
+
meta: {
|
|
286
|
+
...baseMeta,
|
|
287
|
+
event: 'CHANGE_STREAM'
|
|
288
|
+
},
|
|
289
|
+
error
|
|
290
|
+
})
|
|
280
291
|
})
|
|
281
292
|
changeStream.on('change', async function (change) {
|
|
282
293
|
const operationType = change['operationType' as keyof typeof change] as
|
|
@@ -365,13 +376,6 @@ const handleAuthenticationTrigger = async ({
|
|
|
365
376
|
updateDescription
|
|
366
377
|
}
|
|
367
378
|
try {
|
|
368
|
-
emitTriggerEvent({
|
|
369
|
-
status: 'fired',
|
|
370
|
-
triggerName,
|
|
371
|
-
triggerType,
|
|
372
|
-
functionName,
|
|
373
|
-
meta: { ...baseMeta, event: 'LOGOUT' }
|
|
374
|
-
})
|
|
375
379
|
await GenerateContext({
|
|
376
380
|
args: [{ user: userData, ...op }],
|
|
377
381
|
app,
|
|
@@ -383,6 +387,13 @@ const handleAuthenticationTrigger = async ({
|
|
|
383
387
|
services,
|
|
384
388
|
runAsSystem: true
|
|
385
389
|
})
|
|
390
|
+
emitTriggerEvent({
|
|
391
|
+
status: 'fired',
|
|
392
|
+
triggerName,
|
|
393
|
+
triggerType,
|
|
394
|
+
functionName,
|
|
395
|
+
meta: { ...baseMeta, event: 'LOGOUT' }
|
|
396
|
+
})
|
|
386
397
|
} catch (error) {
|
|
387
398
|
emitTriggerEvent({
|
|
388
399
|
status: 'error',
|
|
@@ -417,13 +428,6 @@ const handleAuthenticationTrigger = async ({
|
|
|
417
428
|
updateDescription
|
|
418
429
|
}
|
|
419
430
|
try {
|
|
420
|
-
emitTriggerEvent({
|
|
421
|
-
status: 'fired',
|
|
422
|
-
triggerName,
|
|
423
|
-
triggerType,
|
|
424
|
-
functionName,
|
|
425
|
-
meta: { ...baseMeta, event: 'DELETE' }
|
|
426
|
-
})
|
|
427
431
|
await GenerateContext({
|
|
428
432
|
args: isAutoTrigger ? [userData] : [{ user: userData, ...op }],
|
|
429
433
|
app,
|
|
@@ -435,6 +439,13 @@ const handleAuthenticationTrigger = async ({
|
|
|
435
439
|
services,
|
|
436
440
|
runAsSystem: true
|
|
437
441
|
})
|
|
442
|
+
emitTriggerEvent({
|
|
443
|
+
status: 'fired',
|
|
444
|
+
triggerName,
|
|
445
|
+
triggerType,
|
|
446
|
+
functionName,
|
|
447
|
+
meta: { ...baseMeta, event: 'DELETE' }
|
|
448
|
+
})
|
|
438
449
|
} catch (error) {
|
|
439
450
|
emitTriggerEvent({
|
|
440
451
|
status: 'error',
|
|
@@ -471,13 +482,6 @@ const handleAuthenticationTrigger = async ({
|
|
|
471
482
|
updateDescription
|
|
472
483
|
}
|
|
473
484
|
try {
|
|
474
|
-
emitTriggerEvent({
|
|
475
|
-
status: 'fired',
|
|
476
|
-
triggerName,
|
|
477
|
-
triggerType,
|
|
478
|
-
functionName,
|
|
479
|
-
meta: { ...baseMeta, event: 'UPDATE' }
|
|
480
|
-
})
|
|
481
485
|
await GenerateContext({
|
|
482
486
|
args: isAutoTrigger ? [userData] : [{ user: userData, ...op }],
|
|
483
487
|
app,
|
|
@@ -489,6 +493,13 @@ const handleAuthenticationTrigger = async ({
|
|
|
489
493
|
services,
|
|
490
494
|
runAsSystem: true
|
|
491
495
|
})
|
|
496
|
+
emitTriggerEvent({
|
|
497
|
+
status: 'fired',
|
|
498
|
+
triggerName,
|
|
499
|
+
triggerType,
|
|
500
|
+
functionName,
|
|
501
|
+
meta: { ...baseMeta, event: 'UPDATE' }
|
|
502
|
+
})
|
|
492
503
|
} catch (error) {
|
|
493
504
|
emitTriggerEvent({
|
|
494
505
|
status: 'error',
|
|
@@ -575,13 +586,6 @@ const handleAuthenticationTrigger = async ({
|
|
|
575
586
|
}
|
|
576
587
|
|
|
577
588
|
try {
|
|
578
|
-
emitTriggerEvent({
|
|
579
|
-
status: 'fired',
|
|
580
|
-
triggerName,
|
|
581
|
-
triggerType,
|
|
582
|
-
functionName,
|
|
583
|
-
meta: { ...baseMeta, event: 'CREATE' }
|
|
584
|
-
})
|
|
585
589
|
await GenerateContext({
|
|
586
590
|
args: isAutoTrigger ? [userData] : [{ user: userData, ...op }],
|
|
587
591
|
app,
|
|
@@ -593,6 +597,13 @@ const handleAuthenticationTrigger = async ({
|
|
|
593
597
|
services,
|
|
594
598
|
runAsSystem: true
|
|
595
599
|
})
|
|
600
|
+
emitTriggerEvent({
|
|
601
|
+
status: 'fired',
|
|
602
|
+
triggerName,
|
|
603
|
+
triggerType,
|
|
604
|
+
functionName,
|
|
605
|
+
meta: { ...baseMeta, event: 'CREATE' }
|
|
606
|
+
})
|
|
596
607
|
} catch (error) {
|
|
597
608
|
emitTriggerEvent({
|
|
598
609
|
status: 'error',
|