@flowerforce/flowerbase 1.7.5-beta.1 → 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.
@@ -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,kBAoExB,CAAA"}
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];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.7.5-beta.1",
3
+ "version": "1.7.5-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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