@xbg.solutions/utils-firebase-event-bridge 1.0.0
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/lib/adapters/auth-adapter.d.ts +32 -0
- package/lib/adapters/auth-adapter.d.ts.map +1 -0
- package/lib/adapters/auth-adapter.js +78 -0
- package/lib/adapters/auth-adapter.js.map +1 -0
- package/lib/adapters/firestore-adapter.d.ts +33 -0
- package/lib/adapters/firestore-adapter.d.ts.map +1 -0
- package/lib/adapters/firestore-adapter.js +118 -0
- package/lib/adapters/firestore-adapter.js.map +1 -0
- package/lib/adapters/storage-adapter.d.ts +21 -0
- package/lib/adapters/storage-adapter.d.ts.map +1 -0
- package/lib/adapters/storage-adapter.js +71 -0
- package/lib/adapters/storage-adapter.js.map +1 -0
- package/lib/bridge.d.ts +36 -0
- package/lib/bridge.d.ts.map +1 -0
- package/lib/bridge.js +117 -0
- package/lib/bridge.js.map +1 -0
- package/lib/config-types.d.ts +56 -0
- package/lib/config-types.d.ts.map +1 -0
- package/lib/config-types.js +4 -0
- package/lib/config-types.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/normalizer.d.ts +56 -0
- package/lib/normalizer.d.ts.map +1 -0
- package/lib/normalizer.js +111 -0
- package/lib/normalizer.js.map +1 -0
- package/lib/trigger-factory.d.ts +21 -0
- package/lib/trigger-factory.d.ts.map +1 -0
- package/lib/trigger-factory.js +84 -0
- package/lib/trigger-factory.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Logger } from '@xbg/utils-logger';
|
|
2
|
+
import { AuthOperation } from '../config-types';
|
|
3
|
+
import { NormalizedFirebaseEvent } from '../normalizer';
|
|
4
|
+
export declare class AuthAdapter {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly eventHandler;
|
|
7
|
+
constructor(logger: Logger, eventHandler: (event: NormalizedFirebaseEvent) => void);
|
|
8
|
+
/**
|
|
9
|
+
* Create Auth trigger for a specific operation
|
|
10
|
+
*
|
|
11
|
+
* Note: Firebase Functions v2 uses blocking functions (beforeUserCreated)
|
|
12
|
+
* rather than event functions. For true event-based triggers, we need to
|
|
13
|
+
* use Firestore triggers on the users collection instead.
|
|
14
|
+
*/
|
|
15
|
+
createTrigger(operation: AuthOperation): any;
|
|
16
|
+
/**
|
|
17
|
+
* Create trigger for user creation
|
|
18
|
+
* Uses Firestore trigger on users collection as workaround
|
|
19
|
+
* since Firebase Auth doesn't provide direct onCreate events in v2
|
|
20
|
+
*/
|
|
21
|
+
private createOnUserCreated;
|
|
22
|
+
/**
|
|
23
|
+
* Create trigger for user deletion
|
|
24
|
+
* Uses Firestore trigger on users collection
|
|
25
|
+
*/
|
|
26
|
+
private createOnUserDeleted;
|
|
27
|
+
/**
|
|
28
|
+
* Generate trigger function name
|
|
29
|
+
*/
|
|
30
|
+
static generateTriggerName(operation: string): string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=auth-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/auth-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAsB,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE5E,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI;IAGzE;;;;;;OAMG;IACH,aAAa,CAAC,SAAS,EAAE,aAAa,GAAG,GAAG;IAS5C;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IA6B3B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA6B3B;;OAEG;IACH,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAItD"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utilities/firebase-event-bridge/adapters/auth-adapter.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthAdapter = void 0;
|
|
5
|
+
const normalizer_1 = require("../normalizer");
|
|
6
|
+
class AuthAdapter {
|
|
7
|
+
constructor(logger, eventHandler) {
|
|
8
|
+
this.logger = logger;
|
|
9
|
+
this.eventHandler = eventHandler;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create Auth trigger for a specific operation
|
|
13
|
+
*
|
|
14
|
+
* Note: Firebase Functions v2 uses blocking functions (beforeUserCreated)
|
|
15
|
+
* rather than event functions. For true event-based triggers, we need to
|
|
16
|
+
* use Firestore triggers on the users collection instead.
|
|
17
|
+
*/
|
|
18
|
+
createTrigger(operation) {
|
|
19
|
+
switch (operation) {
|
|
20
|
+
case 'create':
|
|
21
|
+
return this.createOnUserCreated();
|
|
22
|
+
case 'delete':
|
|
23
|
+
return this.createOnUserDeleted();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create trigger for user creation
|
|
28
|
+
* Uses Firestore trigger on users collection as workaround
|
|
29
|
+
* since Firebase Auth doesn't provide direct onCreate events in v2
|
|
30
|
+
*/
|
|
31
|
+
createOnUserCreated() {
|
|
32
|
+
// Import here to avoid circular dependency
|
|
33
|
+
const { onDocumentCreated } = require('firebase-functions/v2/firestore');
|
|
34
|
+
return onDocumentCreated({ document: 'users/{userId}', database: 'identity' }, async (event) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const userId = event.params.userId;
|
|
37
|
+
const userData = (_a = event.data) === null || _a === void 0 ? void 0 : _a.data();
|
|
38
|
+
// ✅ Safe logging - only userId
|
|
39
|
+
this.logger.debug('Auth user created (via Firestore)', {
|
|
40
|
+
userId,
|
|
41
|
+
operation: 'create'
|
|
42
|
+
// ❌ NEVER LOG: userData
|
|
43
|
+
});
|
|
44
|
+
const normalizedEvent = (0, normalizer_1.normalizeAuthEvent)('created', userId, userData, this.logger);
|
|
45
|
+
this.eventHandler(normalizedEvent);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create trigger for user deletion
|
|
50
|
+
* Uses Firestore trigger on users collection
|
|
51
|
+
*/
|
|
52
|
+
createOnUserDeleted() {
|
|
53
|
+
// Import here to avoid circular dependency
|
|
54
|
+
const { onDocumentDeleted } = require('firebase-functions/v2/firestore');
|
|
55
|
+
return onDocumentDeleted({ document: 'users/{userId}', database: 'identity' }, async (event) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const userId = event.params.userId;
|
|
58
|
+
const userData = (_a = event.data) === null || _a === void 0 ? void 0 : _a.data();
|
|
59
|
+
// ✅ Safe logging - only userId
|
|
60
|
+
this.logger.debug('Auth user deleted (via Firestore)', {
|
|
61
|
+
userId,
|
|
62
|
+
operation: 'delete'
|
|
63
|
+
// ❌ NEVER LOG: userData
|
|
64
|
+
});
|
|
65
|
+
const normalizedEvent = (0, normalizer_1.normalizeAuthEvent)('deleted', userId, userData, this.logger);
|
|
66
|
+
this.eventHandler(normalizedEvent);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generate trigger function name
|
|
71
|
+
*/
|
|
72
|
+
static generateTriggerName(operation) {
|
|
73
|
+
const operationName = operation.charAt(0).toUpperCase() + operation.slice(1);
|
|
74
|
+
return `authUser${operationName}`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.AuthAdapter = AuthAdapter;
|
|
78
|
+
//# sourceMappingURL=auth-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-adapter.js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CAAC,iCAAiC,CAAC,CAAC;QAEzE,OAAO,iBAAiB,CACtB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,EACpD,KAAK,EAAE,KAAU,EAAE,EAAE;;YACnB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;YACnC,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,IAAI,0CAAE,IAAI,EAAE,CAAC;YAEpC,+BAA+B;YAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE;gBACrD,MAAM;gBACN,SAAS,EAAE,QAAQ;gBACnB,wBAAwB;aACzB,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,IAAA,+BAAkB,EACxC,SAAS,EACT,MAAM,EACN,QAAQ,EACR,IAAI,CAAC,MAAM,CACZ,CAAC;YAEF,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,mBAAmB,CAAC,SAAiB;QAC1C,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,WAAW,aAAa,EAAE,CAAC;IACpC,CAAC;CACF;AAhGD,kCAgGC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Logger } from '@xbg/utils-logger';
|
|
2
|
+
import { DatabaseName, FirestoreCollectionConfig, FirestoreOperation } from '../config-types';
|
|
3
|
+
import { NormalizedFirebaseEvent } from '../normalizer';
|
|
4
|
+
export declare class FirestoreAdapter {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly eventHandler;
|
|
7
|
+
constructor(logger: Logger, eventHandler: (event: NormalizedFirebaseEvent) => void);
|
|
8
|
+
/**
|
|
9
|
+
* Create Firestore trigger for a specific operation
|
|
10
|
+
*/
|
|
11
|
+
createTrigger(databaseName: DatabaseName, config: FirestoreCollectionConfig, operation: FirestoreOperation): any;
|
|
12
|
+
/**
|
|
13
|
+
* Map DatabaseName to Firebase database identifier
|
|
14
|
+
*/
|
|
15
|
+
private getDatabaseIdentifier;
|
|
16
|
+
/**
|
|
17
|
+
* Create onCreate trigger
|
|
18
|
+
*/
|
|
19
|
+
private createOnCreate;
|
|
20
|
+
/**
|
|
21
|
+
* Create onUpdate trigger
|
|
22
|
+
*/
|
|
23
|
+
private createOnUpdate;
|
|
24
|
+
/**
|
|
25
|
+
* Create onDelete trigger
|
|
26
|
+
*/
|
|
27
|
+
private createOnDelete;
|
|
28
|
+
/**
|
|
29
|
+
* Generate trigger function name
|
|
30
|
+
*/
|
|
31
|
+
static generateTriggerName(databaseName: string, collectionPath: string, operation: string, eventNameOverride?: string): string;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=firestore-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/firestore-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAkD,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExG,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI;IAGzE;;OAEG;IACH,aAAa,CACX,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,yBAAyB,EACjC,SAAS,EAAE,kBAAkB,GAC5B,GAAG;IAcN;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAQ7B;;OAEG;IACH,OAAO,CAAC,cAAc;IAqCtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAuCtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAqCtB;;OAEG;IACH,MAAM,CAAC,mBAAmB,CACxB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM;CAqBV"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utilities/firebase-event-bridge/adapters/firestore-adapter.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FirestoreAdapter = void 0;
|
|
5
|
+
const firestore_1 = require("firebase-functions/v2/firestore");
|
|
6
|
+
const normalizer_1 = require("../normalizer");
|
|
7
|
+
class FirestoreAdapter {
|
|
8
|
+
constructor(logger, eventHandler) {
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
this.eventHandler = eventHandler;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create Firestore trigger for a specific operation
|
|
14
|
+
*/
|
|
15
|
+
createTrigger(databaseName, config, operation) {
|
|
16
|
+
const documentPath = `${config.path}/{id}`;
|
|
17
|
+
const database = this.getDatabaseIdentifier(databaseName);
|
|
18
|
+
switch (operation) {
|
|
19
|
+
case 'create':
|
|
20
|
+
return this.createOnCreate(databaseName, database, documentPath, config);
|
|
21
|
+
case 'update':
|
|
22
|
+
return this.createOnUpdate(databaseName, database, documentPath, config);
|
|
23
|
+
case 'delete':
|
|
24
|
+
return this.createOnDelete(databaseName, database, documentPath, config);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Map DatabaseName to Firebase database identifier
|
|
29
|
+
*/
|
|
30
|
+
getDatabaseIdentifier(databaseName) {
|
|
31
|
+
const mapping = {
|
|
32
|
+
main: process.env.MAIN_DATABASE_ID || '(default)',
|
|
33
|
+
analytics: process.env.ANALYTICS_DATABASE_ID || 'analytics',
|
|
34
|
+
};
|
|
35
|
+
return mapping[databaseName] || databaseName;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create onCreate trigger
|
|
39
|
+
*/
|
|
40
|
+
createOnCreate(databaseName, database, documentPath, config) {
|
|
41
|
+
return (0, firestore_1.onDocumentCreated)({ document: documentPath, database }, async (event) => {
|
|
42
|
+
var _a;
|
|
43
|
+
const documentId = event.params.id;
|
|
44
|
+
const data = config.includeData ? (_a = event.data) === null || _a === void 0 ? void 0 : _a.data() : undefined;
|
|
45
|
+
// Safe logging - only metadata
|
|
46
|
+
this.logger.debug('Firestore onCreate triggered', {
|
|
47
|
+
databaseName,
|
|
48
|
+
collection: config.path,
|
|
49
|
+
documentId,
|
|
50
|
+
operation: 'create'
|
|
51
|
+
});
|
|
52
|
+
const collectionName = (0, normalizer_1.extractCollectionName)(config.path);
|
|
53
|
+
const normalizedEvent = (0, normalizer_1.normalizeFirestoreEvent)('created', event.document, documentId, databaseName, collectionName, data, this.logger, config.eventNameOverride);
|
|
54
|
+
this.eventHandler(normalizedEvent);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create onUpdate trigger
|
|
59
|
+
*/
|
|
60
|
+
createOnUpdate(databaseName, database, documentPath, config) {
|
|
61
|
+
return (0, firestore_1.onDocumentUpdated)({ document: documentPath, database }, async (event) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const documentId = event.params.id;
|
|
64
|
+
const before = config.includeData ? (_a = event.data) === null || _a === void 0 ? void 0 : _a.before.data() : undefined;
|
|
65
|
+
const after = config.includeData ? (_b = event.data) === null || _b === void 0 ? void 0 : _b.after.data() : undefined;
|
|
66
|
+
// Safe logging - only metadata
|
|
67
|
+
this.logger.debug('Firestore onUpdate triggered', {
|
|
68
|
+
databaseName,
|
|
69
|
+
collection: config.path,
|
|
70
|
+
documentId,
|
|
71
|
+
operation: 'update'
|
|
72
|
+
});
|
|
73
|
+
const collectionName = (0, normalizer_1.extractCollectionName)(config.path);
|
|
74
|
+
const normalizedEvent = (0, normalizer_1.normalizeFirestoreEvent)('updated', event.document, documentId, databaseName, collectionName, after, this.logger, config.eventNameOverride, config.includeData ? { before, after } : undefined);
|
|
75
|
+
this.eventHandler(normalizedEvent);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create onDelete trigger
|
|
80
|
+
*/
|
|
81
|
+
createOnDelete(databaseName, database, documentPath, config) {
|
|
82
|
+
return (0, firestore_1.onDocumentDeleted)({ document: documentPath, database }, async (event) => {
|
|
83
|
+
var _a;
|
|
84
|
+
const documentId = event.params.id;
|
|
85
|
+
const data = config.includeData ? (_a = event.data) === null || _a === void 0 ? void 0 : _a.data() : undefined;
|
|
86
|
+
// Safe logging - only metadata
|
|
87
|
+
this.logger.debug('Firestore onDelete triggered', {
|
|
88
|
+
databaseName,
|
|
89
|
+
collection: config.path,
|
|
90
|
+
documentId,
|
|
91
|
+
operation: 'delete'
|
|
92
|
+
});
|
|
93
|
+
const collectionName = (0, normalizer_1.extractCollectionName)(config.path);
|
|
94
|
+
const normalizedEvent = (0, normalizer_1.normalizeFirestoreEvent)('deleted', event.document, documentId, databaseName, collectionName, data, this.logger, config.eventNameOverride);
|
|
95
|
+
this.eventHandler(normalizedEvent);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Generate trigger function name
|
|
100
|
+
*/
|
|
101
|
+
static generateTriggerName(databaseName, collectionPath, operation, eventNameOverride) {
|
|
102
|
+
// Use database name as prefix
|
|
103
|
+
const dbPrefix = databaseName;
|
|
104
|
+
// Use override if provided, otherwise extract from path
|
|
105
|
+
const collection = eventNameOverride || (0, normalizer_1.extractCollectionName)(collectionPath);
|
|
106
|
+
// Convert to camelCase and capitalize first letter
|
|
107
|
+
const collectionName = collection
|
|
108
|
+
.split('_')
|
|
109
|
+
.map((part, index) => index === 0
|
|
110
|
+
? part.charAt(0).toUpperCase() + part.slice(1)
|
|
111
|
+
: part.charAt(0).toUpperCase() + part.slice(1))
|
|
112
|
+
.join('');
|
|
113
|
+
const operationName = operation.charAt(0).toUpperCase() + operation.slice(1);
|
|
114
|
+
return `${dbPrefix}${collectionName}${operationName}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.FirestoreAdapter = FirestoreAdapter;
|
|
118
|
+
//# sourceMappingURL=firestore-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore-adapter.js","sourceRoot":"","sources":["../../src/adapters/firestore-adapter.ts"],"names":[],"mappings":";AAAA,oEAAoE;;;AAEpE,+DAA0G;AAG1G,8CAAwG;AAExG,MAAa,gBAAgB;IAC3B,YACmB,MAAc,EACd,YAAsD;QADtD,WAAM,GAAN,MAAM,CAAQ;QACd,iBAAY,GAAZ,YAAY,CAA0C;IACtE,CAAC;IAEJ;;OAEG;IACH,aAAa,CACX,YAA0B,EAC1B,MAAiC,EACjC,SAA6B;QAE7B,MAAM,YAAY,GAAG,GAAG,MAAM,CAAC,IAAI,OAAO,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;QAE1D,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YAC3E,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YAC3E,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,YAA0B;QACtD,MAAM,OAAO,GAA2B;Y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C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CACjD;aACA,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE7E,OAAO,GAAG,QAAQ,GAAG,cAAc,GAAG,aAAa,EAAE,CAAC;IACxD,CAAC;CACF;AA7LD,4CA6LC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Logger } from '@xbg/utils-logger';
|
|
2
|
+
import { StorageConfig } from '../config-types';
|
|
3
|
+
import { NormalizedFirebaseEvent } from '../normalizer';
|
|
4
|
+
export declare class StorageAdapter {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly eventHandler;
|
|
7
|
+
constructor(logger: Logger, eventHandler: (event: NormalizedFirebaseEvent) => void);
|
|
8
|
+
/**
|
|
9
|
+
* Create Storage trigger
|
|
10
|
+
*/
|
|
11
|
+
createTrigger(config: StorageConfig): any;
|
|
12
|
+
/**
|
|
13
|
+
* Check if file path matches any configured pattern
|
|
14
|
+
*/
|
|
15
|
+
private matchesPathPattern;
|
|
16
|
+
/**
|
|
17
|
+
* Generate trigger function name
|
|
18
|
+
*/
|
|
19
|
+
static generateTriggerName(): string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=storage-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/storage-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAyB,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE/E,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI;IAGzE;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,GAAG;IA0CzC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACH,MAAM,CAAC,mBAAmB,IAAI,MAAM;CAGrC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utilities/firebase-event-bridge/adapters/storage-adapter.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.StorageAdapter = void 0;
|
|
5
|
+
const storage_1 = require("firebase-functions/v2/storage");
|
|
6
|
+
const normalizer_1 = require("../normalizer");
|
|
7
|
+
class StorageAdapter {
|
|
8
|
+
constructor(logger, eventHandler) {
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
this.eventHandler = eventHandler;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create Storage trigger
|
|
14
|
+
*/
|
|
15
|
+
createTrigger(config) {
|
|
16
|
+
return (0, storage_1.onObjectFinalized)(async (event) => {
|
|
17
|
+
const filePath = event.data.name;
|
|
18
|
+
// Check if file matches configured path patterns
|
|
19
|
+
if (!this.matchesPathPattern(filePath, config.pathPatterns)) {
|
|
20
|
+
this.logger.debug('Storage event skipped - path not matched', {
|
|
21
|
+
filePath,
|
|
22
|
+
patterns: config.pathPatterns
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const metadata = config.includeMetadata ? {
|
|
27
|
+
name: event.data.name,
|
|
28
|
+
bucket: event.data.bucket,
|
|
29
|
+
contentType: event.data.contentType,
|
|
30
|
+
size: event.data.size,
|
|
31
|
+
timeCreated: event.data.timeCreated,
|
|
32
|
+
updated: event.data.updated,
|
|
33
|
+
metadata: event.data.metadata,
|
|
34
|
+
md5Hash: event.data.md5Hash
|
|
35
|
+
} : undefined;
|
|
36
|
+
// ✅ Safe logging - only file path
|
|
37
|
+
this.logger.debug('Storage onFinalized triggered', {
|
|
38
|
+
filePath,
|
|
39
|
+
contentType: event.data.contentType,
|
|
40
|
+
size: event.data.size
|
|
41
|
+
// ❌ NEVER LOG: metadata content (may contain user-uploaded info)
|
|
42
|
+
});
|
|
43
|
+
const normalizedEvent = (0, normalizer_1.normalizeStorageEvent)(filePath, metadata, this.logger);
|
|
44
|
+
this.eventHandler(normalizedEvent);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if file path matches any configured pattern
|
|
49
|
+
*/
|
|
50
|
+
matchesPathPattern(filePath, patterns) {
|
|
51
|
+
return patterns.some(pattern => {
|
|
52
|
+
// Convert glob pattern to regex
|
|
53
|
+
// 'items/**' -> '^items/.*$'
|
|
54
|
+
// 'profiles/*' -> '^profiles/[^/]+$'
|
|
55
|
+
const regexPattern = pattern
|
|
56
|
+
.replace(/\*\*/g, '.*')
|
|
57
|
+
.replace(/\*/g, '[^/]+')
|
|
58
|
+
.replace(/\//g, '\\/');
|
|
59
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
60
|
+
return regex.test(filePath);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Generate trigger function name
|
|
65
|
+
*/
|
|
66
|
+
static generateTriggerName() {
|
|
67
|
+
return 'storageObjectFinalized';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.StorageAdapter = StorageAdapter;
|
|
71
|
+
//# sourceMappingURL=storage-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-adapter.js","sourceRoot":"","sources":["../../src/adapters/storage-adapter.ts"],"names":[],"mappings":";AAAA,kEAAkE;;;AAElE,2DAAkE;AAGlE,8CAA+E;AAE/E,MA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AAiE;aAClE,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,IAAA,kCAAqB,EAC3C,QAAQ,EACR,QAAQ,EACR,IAAI,CAAC,MAAM,CACZ,CAAC;YAEF,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,QAAgB,EAAE,QAAkB;QAC7D,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YAC7B,gCAAgC;YAChC,6BAA6B;YAC7B,qCAAqC;YACrC,MAAM,YAAY,GAAG,OAAO;iBACzB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;iBACtB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;iBACvB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAEzB,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC;YAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,mBAAmB;QACxB,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AA3ED,wCA2EC"}
|
package/lib/bridge.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FirebaseEventBridgeConfig } from './config-types';
|
|
2
|
+
import { NormalizedFirebaseEvent } from './normalizer';
|
|
3
|
+
/**
|
|
4
|
+
* Type for the event mapping function provided at app startup.
|
|
5
|
+
* Maps a Firebase event name + normalized event to a domain event + payload,
|
|
6
|
+
* or returns null/undefined if no mapping exists.
|
|
7
|
+
*/
|
|
8
|
+
export type MapFirebaseEventToDomainFn = (eventName: string, event: NormalizedFirebaseEvent) => {
|
|
9
|
+
domainEvent: string;
|
|
10
|
+
domainPayload: any;
|
|
11
|
+
} | null | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialize the Firebase Event Bridge with the event mapping function.
|
|
14
|
+
* Must be called at app startup before generating triggers.
|
|
15
|
+
*/
|
|
16
|
+
export declare function initializeFirebaseEventBridge(mapFn: MapFirebaseEventToDomainFn): void;
|
|
17
|
+
export declare class FirebaseEventBridge {
|
|
18
|
+
private readonly logger;
|
|
19
|
+
private readonly config;
|
|
20
|
+
private readonly triggerFactory;
|
|
21
|
+
constructor(config: FirebaseEventBridgeConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Generate all Firebase trigger functions based on config
|
|
24
|
+
*/
|
|
25
|
+
generateTriggers(): Record<string, any>;
|
|
26
|
+
/**
|
|
27
|
+
* Central event handler - publishes to event bus with error handling
|
|
28
|
+
*
|
|
29
|
+
* Maps Firebase-specific events to platform-agnostic domain events.
|
|
30
|
+
* This ensures subscribers remain unaware of the event source.
|
|
31
|
+
*
|
|
32
|
+
* ⚠️ LOGGING SAFETY: Never logs event payload (raw data)
|
|
33
|
+
*/
|
|
34
|
+
private handleEvent;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,uBAAuB,KAC3B;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,GAAG,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAKpE;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,0BAA0B,GAAG,IAAI,CAErF;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;IACnD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;gBAEpC,MAAM,EAAE,yBAAyB;IAW7C;;OAEG;IACH,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAqCvC;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CA2DpB"}
|
package/lib/bridge.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utilities/firebase-event-bridge/bridge.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FirebaseEventBridge = void 0;
|
|
5
|
+
exports.initializeFirebaseEventBridge = initializeFirebaseEventBridge;
|
|
6
|
+
const utils_logger_1 = require("@xbg/utils-logger");
|
|
7
|
+
const trigger_factory_1 = require("./trigger-factory");
|
|
8
|
+
// Event mapping function is provided via initializeFirebaseEventBridge() at app startup
|
|
9
|
+
let mapFirebaseEventToDomain = null;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the Firebase Event Bridge with the event mapping function.
|
|
12
|
+
* Must be called at app startup before generating triggers.
|
|
13
|
+
*/
|
|
14
|
+
function initializeFirebaseEventBridge(mapFn) {
|
|
15
|
+
mapFirebaseEventToDomain = mapFn;
|
|
16
|
+
}
|
|
17
|
+
class FirebaseEventBridge {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.logger = new utils_logger_1.Logger('firebase-event-bridge', {
|
|
21
|
+
component: 'firebase-event-bridge'
|
|
22
|
+
});
|
|
23
|
+
this.triggerFactory = new trigger_factory_1.TriggerFactory(this.logger, this.handleEvent.bind(this));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate all Firebase trigger functions based on config
|
|
27
|
+
*/
|
|
28
|
+
generateTriggers() {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
|
+
const triggers = {};
|
|
31
|
+
// Generate Firestore triggers
|
|
32
|
+
if ((_a = this.config.firestore) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
33
|
+
const firestoreTriggers = this.triggerFactory.generateFirestoreTriggers(this.config.firestore);
|
|
34
|
+
Object.assign(triggers, firestoreTriggers);
|
|
35
|
+
}
|
|
36
|
+
// Generate Auth triggers
|
|
37
|
+
if ((_b = this.config.auth) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
38
|
+
const authTriggers = this.triggerFactory.generateAuthTriggers(this.config.auth);
|
|
39
|
+
Object.assign(triggers, authTriggers);
|
|
40
|
+
}
|
|
41
|
+
// Generate Storage triggers
|
|
42
|
+
if ((_c = this.config.storage) === null || _c === void 0 ? void 0 : _c.enabled) {
|
|
43
|
+
const storageTriggers = this.triggerFactory.generateStorageTriggers(this.config.storage);
|
|
44
|
+
Object.assign(triggers, storageTriggers);
|
|
45
|
+
}
|
|
46
|
+
this.logger.info('Firebase Event Bridge initialized', {
|
|
47
|
+
totalTriggers: Object.keys(triggers).length,
|
|
48
|
+
firestoreEnabled: ((_d = this.config.firestore) === null || _d === void 0 ? void 0 : _d.enabled) || false,
|
|
49
|
+
authEnabled: ((_e = this.config.auth) === null || _e === void 0 ? void 0 : _e.enabled) || false,
|
|
50
|
+
storageEnabled: ((_f = this.config.storage) === null || _f === void 0 ? void 0 : _f.enabled) || false
|
|
51
|
+
});
|
|
52
|
+
return triggers;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Central event handler - publishes to event bus with error handling
|
|
56
|
+
*
|
|
57
|
+
* Maps Firebase-specific events to platform-agnostic domain events.
|
|
58
|
+
* This ensures subscribers remain unaware of the event source.
|
|
59
|
+
*
|
|
60
|
+
* ⚠️ LOGGING SAFETY: Never logs event payload (raw data)
|
|
61
|
+
*/
|
|
62
|
+
handleEvent(event) {
|
|
63
|
+
try {
|
|
64
|
+
// ✅ Safe logging - only event metadata
|
|
65
|
+
this.logger.debug('Firebase event received', {
|
|
66
|
+
firebaseEventName: event.eventName,
|
|
67
|
+
eventId: event.eventId,
|
|
68
|
+
source: event.source,
|
|
69
|
+
documentId: event.normalized.documentId,
|
|
70
|
+
userId: event.normalized.userId,
|
|
71
|
+
filePath: event.normalized.filePath
|
|
72
|
+
// ❌ NEVER LOG: event.raw, event.changes
|
|
73
|
+
});
|
|
74
|
+
// Map Firebase event to domain event
|
|
75
|
+
if (!mapFirebaseEventToDomain) {
|
|
76
|
+
this.logger.warn('Firebase Event Bridge not initialized. Call initializeFirebaseEventBridge() first.');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const mapping = mapFirebaseEventToDomain(event.eventName, event);
|
|
80
|
+
if (!mapping) {
|
|
81
|
+
this.logger.warn('No domain event mapping found for Firebase event', {
|
|
82
|
+
firebaseEventName: event.eventName,
|
|
83
|
+
eventId: event.eventId
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const { domainEvent, domainPayload } = mapping;
|
|
88
|
+
// ✅ Safe logging - mapping result
|
|
89
|
+
this.logger.debug('Firebase event mapped to domain event', {
|
|
90
|
+
firebaseEventName: event.eventName,
|
|
91
|
+
domainEvent,
|
|
92
|
+
eventId: event.eventId
|
|
93
|
+
});
|
|
94
|
+
// Publish domain event to internal event bus
|
|
95
|
+
this.config.eventBus.publish(domainEvent, domainPayload);
|
|
96
|
+
// ✅ Safe logging - only metadata
|
|
97
|
+
this.logger.debug('Domain event published to bus', {
|
|
98
|
+
domainEvent,
|
|
99
|
+
firebaseEventName: event.eventName,
|
|
100
|
+
listenerCount: this.config.eventBus.listenerCount(domainEvent)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// Swallow error and emit error event
|
|
105
|
+
this.logger.error('Failed to handle Firebase event', error, {
|
|
106
|
+
eventName: event.eventName,
|
|
107
|
+
eventId: event.eventId,
|
|
108
|
+
source: event.source
|
|
109
|
+
// ❌ NEVER LOG: event payload, error with full context
|
|
110
|
+
});
|
|
111
|
+
// Note: Not emitting error event as EventType doesn't have system errors
|
|
112
|
+
// Could be added if needed
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.FirebaseEventBridge = FirebaseEventBridge;
|
|
117
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";AAAA,gDAAgD;;;AAyBhD,sEAEC;AAzBD,oDAA2C;AAG3C,uDAAmD;AAanD,wFAAwF;AACxF,IAAI,wBAAwB,GAAsC,IAAI,CAAC;AAEvE;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,KAAiC;IAC7E,wBAAwB,GAAG,KAAK,CAAC;AACnC,CAAC;AAED,MAAa,mBAAmB;IAK9B,YAAY,MAAiC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAM,CAAC,uBAAuB,EAAE;YAChD,SAAS,EAAE,uBAAuB;SACnC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,IAAI,gCAAc,CACtC,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAC5B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,gBAAgB;;QACd,MAAM,QAAQ,GAAwB,EAAE,CAAC;QAEzC,8BAA8B;QAC9B,IAAI,MAAA,IAAI,CAAC,MAAM,CAAC,SAAS,0CAAE,OAAO,EAAE,CAAC;YACnC,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,yBAAyB,CACrE,IAAI,CAAC,MAAM,CAAC,SAAS,CACtB,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAC7C,CAAC;QAED,yBAAyB;QACzB,IAAI,MAAA,IAAI,CAAC,MAAM,CAAC,IAAI,0CAAE,OAA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,EAAE,KAAK,CAAC,SAAS;gBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,sDAAsD;aACvD,CAAC,CAAC;YAEH,yEAAyE;YACzE,2BAA2B;QAC7B,CAAC;IACH,CAAC;CACF;AA3HD,kDA2HC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { eventBus } from '@xbg/utils-events';
|
|
2
|
+
/**
|
|
3
|
+
* DatabaseName is defined locally since this is a standalone package.
|
|
4
|
+
* At app startup, pass the appropriate database name strings.
|
|
5
|
+
*/
|
|
6
|
+
export type DatabaseName = string;
|
|
7
|
+
/**
|
|
8
|
+
* Main configuration for Firebase Event Bridge
|
|
9
|
+
*/
|
|
10
|
+
export interface FirebaseEventBridgeConfig {
|
|
11
|
+
eventBus: typeof eventBus;
|
|
12
|
+
firestore?: FirestoreConfig;
|
|
13
|
+
auth?: AuthConfig;
|
|
14
|
+
storage?: StorageConfig;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Firestore trigger configuration
|
|
18
|
+
*/
|
|
19
|
+
export interface FirestoreConfig {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
databases: FirestoreDatabaseConfig[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for a single Firestore database
|
|
25
|
+
*/
|
|
26
|
+
export interface FirestoreDatabaseConfig {
|
|
27
|
+
databaseName: DatabaseName;
|
|
28
|
+
collections: FirestoreCollectionConfig[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for a single collection
|
|
32
|
+
*/
|
|
33
|
+
export interface FirestoreCollectionConfig {
|
|
34
|
+
path: string;
|
|
35
|
+
operations: FirestoreOperation[];
|
|
36
|
+
includeData: boolean;
|
|
37
|
+
eventNameOverride?: string;
|
|
38
|
+
}
|
|
39
|
+
export type FirestoreOperation = 'create' | 'update' | 'delete';
|
|
40
|
+
/**
|
|
41
|
+
* Auth trigger configuration
|
|
42
|
+
*/
|
|
43
|
+
export interface AuthConfig {
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
operations: AuthOperation[];
|
|
46
|
+
}
|
|
47
|
+
export type AuthOperation = 'create' | 'delete';
|
|
48
|
+
/**
|
|
49
|
+
* Storage trigger configuration
|
|
50
|
+
*/
|
|
51
|
+
export interface StorageConfig {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
pathPatterns: string[];
|
|
54
|
+
includeMetadata: boolean;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=config-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,OAAO,QAAQ,CAAC;IAC1B,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,uBAAuB,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,yBAAyB,EAAE,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.js","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":";AAAA,sDAAsD"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FirebaseEventBridge, initializeFirebaseEventBridge } from './bridge';
|
|
2
|
+
export type { MapFirebaseEventToDomainFn } from './bridge';
|
|
3
|
+
export type { FirebaseEventBridgeConfig, FirestoreConfig, FirestoreDatabaseConfig, FirestoreCollectionConfig, FirestoreOperation, AuthConfig, AuthOperation, StorageConfig } from './config-types';
|
|
4
|
+
export type { NormalizedFirebaseEvent } from './normalizer';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAC9E,YAAY,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAC3D,YAAY,EACV,yBAAyB,EACzB,eAAe,EACf,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utilities/firebase-event-bridge/index.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.initializeFirebaseEventBridge = exports.FirebaseEventBridge = void 0;
|
|
5
|
+
var bridge_1 = require("./bridge");
|
|
6
|
+
Object.defineProperty(exports, "FirebaseEventBridge", { enumerable: true, get: function () { return bridge_1.FirebaseEventBridge; } });
|
|
7
|
+
Object.defineProperty(exports, "initializeFirebaseEventBridge", { enumerable: true, get: function () { return bridge_1.initializeFirebaseEventBridge; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+CAA+C;;;AAE/C,mCAA8E;AAArE,6GAAA,mBAAmB,OAAA;AAAE,uHAAA,6BAA6B,OAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Logger } from '@xbg/utils-logger';
|
|
2
|
+
import { BaseEventPayload } from '@xbg/utils-events';
|
|
3
|
+
/**
|
|
4
|
+
* Normalized event structure for internal event bus
|
|
5
|
+
* Extends BaseEventPayload for type compatibility with event bus
|
|
6
|
+
*/
|
|
7
|
+
export interface NormalizedFirebaseEvent extends BaseEventPayload {
|
|
8
|
+
eventId: string;
|
|
9
|
+
eventName: string;
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
source: 'firestore' | 'auth' | 'storage';
|
|
12
|
+
normalized: {
|
|
13
|
+
databaseName?: string;
|
|
14
|
+
documentId?: string;
|
|
15
|
+
documentPath?: string;
|
|
16
|
+
collection?: string;
|
|
17
|
+
userId?: string;
|
|
18
|
+
filePath?: string;
|
|
19
|
+
operation?: string;
|
|
20
|
+
};
|
|
21
|
+
raw: any;
|
|
22
|
+
changes?: {
|
|
23
|
+
before: any;
|
|
24
|
+
after: any;
|
|
25
|
+
};
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Normalize Firestore event to standard format
|
|
30
|
+
*
|
|
31
|
+
* ⚠️ LOGGING SAFETY: Only logs metadata, never document data
|
|
32
|
+
*/
|
|
33
|
+
export declare function normalizeFirestoreEvent(operation: string, documentPath: string, documentId: string, databaseName: string, collectionName: string, data: any, logger: Logger, eventNameOverride?: string, changes?: {
|
|
34
|
+
before: any;
|
|
35
|
+
after: any;
|
|
36
|
+
}): NormalizedFirebaseEvent;
|
|
37
|
+
/**
|
|
38
|
+
* Normalize Auth event to standard format
|
|
39
|
+
*
|
|
40
|
+
* ⚠️ LOGGING SAFETY: Only logs metadata, never user data
|
|
41
|
+
*/
|
|
42
|
+
export declare function normalizeAuthEvent(operation: string, userId: string, userData: any, logger: Logger): NormalizedFirebaseEvent;
|
|
43
|
+
/**
|
|
44
|
+
* Normalize Storage event to standard format
|
|
45
|
+
*
|
|
46
|
+
* ⚠️ LOGGING SAFETY: Only logs file path, never metadata content
|
|
47
|
+
*/
|
|
48
|
+
export declare function normalizeStorageEvent(filePath: string, metadata: any, logger: Logger): NormalizedFirebaseEvent;
|
|
49
|
+
/**
|
|
50
|
+
* Extract collection name from document path
|
|
51
|
+
* Examples:
|
|
52
|
+
* 'users/{userUID}' -> 'users'
|
|
53
|
+
* 'items/{itemUID}/images/{imageUID}' -> 'images'
|
|
54
|
+
*/
|
|
55
|
+
export declare function extractCollectionName(path: string): string;
|
|
56
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../src/normalizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAE/D,OAAO,EAAE,MAAM,CAAC;IAChB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B,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS1D"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utilities/firebase-event-bridge/normalizer.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.normalizeFirestoreEvent = normalizeFirestoreEvent;
|
|
5
|
+
exports.normalizeAuthEvent = normalizeAuthEvent;
|
|
6
|
+
exports.normalizeStorageEvent = normalizeStorageEvent;
|
|
7
|
+
exports.extractCollectionName = extractCollectionName;
|
|
8
|
+
/**
|
|
9
|
+
* Normalize Firestore event to standard format
|
|
10
|
+
*
|
|
11
|
+
* ⚠️ LOGGING SAFETY: Only logs metadata, never document data
|
|
12
|
+
*/
|
|
13
|
+
function normalizeFirestoreEvent(operation, documentPath, documentId, databaseName, collectionName, data, logger, eventNameOverride, changes) {
|
|
14
|
+
const collection = eventNameOverride || collectionName;
|
|
15
|
+
const eventName = `firestore.${collection}.${operation}`;
|
|
16
|
+
// ✅ Safe logging - only metadata
|
|
17
|
+
logger.debug('Normalizing Firestore event', {
|
|
18
|
+
eventName,
|
|
19
|
+
documentId,
|
|
20
|
+
databaseName,
|
|
21
|
+
collection: collectionName,
|
|
22
|
+
operation,
|
|
23
|
+
hasChanges: !!changes,
|
|
24
|
+
hasEventNameOverride: !!eventNameOverride
|
|
25
|
+
// ❌ NEVER LOG: data, changes, raw document content
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
eventId: `${eventName}-${documentId}-${Date.now()}`,
|
|
29
|
+
eventName,
|
|
30
|
+
timestamp: new Date(),
|
|
31
|
+
source: 'firestore',
|
|
32
|
+
normalized: {
|
|
33
|
+
databaseName,
|
|
34
|
+
documentId,
|
|
35
|
+
documentPath,
|
|
36
|
+
collection: collectionName,
|
|
37
|
+
operation
|
|
38
|
+
},
|
|
39
|
+
raw: data, // Not logged, just passed through to event bus
|
|
40
|
+
changes // Not logged, just passed through to event bus
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize Auth event to standard format
|
|
45
|
+
*
|
|
46
|
+
* ⚠️ LOGGING SAFETY: Only logs metadata, never user data
|
|
47
|
+
*/
|
|
48
|
+
function normalizeAuthEvent(operation, userId, userData, logger) {
|
|
49
|
+
const eventName = `auth.user.${operation}`;
|
|
50
|
+
// ✅ Safe logging - only metadata
|
|
51
|
+
logger.debug('Normalizing Auth event', {
|
|
52
|
+
eventName,
|
|
53
|
+
userId,
|
|
54
|
+
operation
|
|
55
|
+
// ❌ NEVER LOG: userData, email, phone, etc.
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
eventId: `${eventName}-${userId}-${Date.now()}`,
|
|
59
|
+
eventName,
|
|
60
|
+
timestamp: new Date(),
|
|
61
|
+
source: 'auth',
|
|
62
|
+
normalized: {
|
|
63
|
+
userId,
|
|
64
|
+
operation
|
|
65
|
+
},
|
|
66
|
+
raw: userData // Not logged, just passed through
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Normalize Storage event to standard format
|
|
71
|
+
*
|
|
72
|
+
* ⚠️ LOGGING SAFETY: Only logs file path, never metadata content
|
|
73
|
+
*/
|
|
74
|
+
function normalizeStorageEvent(filePath, metadata, logger) {
|
|
75
|
+
const eventName = 'storage.object.finalized';
|
|
76
|
+
// ✅ Safe logging - only file path
|
|
77
|
+
logger.debug('Normalizing Storage event', {
|
|
78
|
+
eventName,
|
|
79
|
+
filePath,
|
|
80
|
+
hasMetadata: !!metadata
|
|
81
|
+
// ❌ NEVER LOG: metadata content (may contain user info)
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
eventId: `${eventName}-${Date.now()}`,
|
|
85
|
+
eventName,
|
|
86
|
+
timestamp: new Date(),
|
|
87
|
+
source: 'storage',
|
|
88
|
+
normalized: {
|
|
89
|
+
filePath,
|
|
90
|
+
operation: 'upload'
|
|
91
|
+
},
|
|
92
|
+
raw: metadata // Not logged, just passed through
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Extract collection name from document path
|
|
97
|
+
* Examples:
|
|
98
|
+
* 'users/{userUID}' -> 'users'
|
|
99
|
+
* 'items/{itemUID}/images/{imageUID}' -> 'images'
|
|
100
|
+
*/
|
|
101
|
+
function extractCollectionName(path) {
|
|
102
|
+
const parts = path.split('/');
|
|
103
|
+
// Get last non-parameter part
|
|
104
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
105
|
+
if (!parts[i].startsWith('{')) {
|
|
106
|
+
return parts[i];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return parts[0];
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=normalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizer.js","sourceRoot":"","sources":["../src/normalizer.ts"],"names":[],"mappings":";AAAA,oDAAoD;;AA+CpD,0DAyCC;AAOD,gDA2BC;AAOD,sDA0BC;AAQD,sDASC;AAlID;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,SAAiB,EACjB,YAAoB,EACpB,UAAkB,EAClB,YAAoB,EACpB,cAAsB,EACtB,IAAS,EACT,MAAc,EACd,iBAA0B,EAC1B,OAAqC;IAErC,MAAM,UAAU,GAAG,iBAAiB,IAAI,cAAc,CAAC;IACvD,MAAM,SAAS,GAAG,aAAa,UAAU,IAAI,SAAS,EAAE,CAAC;IAEzD,iCAAiC;IACjC,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE;QAC1C,SAAS;QACT,UAAU;QACV,YAAY;QACZ,UAAU,EAAE,cAAc;QAC1B,SAAS;QACT,UAAU,EAAE,CAAC,CAAC,OAAO;QACrB,oBAAoB,EAAE,CAAC,CAAC,iBAAiB;QACzC,mDAAmD;KACpD,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,GAAG,SAAS,IAAI,UAAU,IAAI,IAAI,CAAC,G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Q;YACR,SAAS,EAAE,QAAQ;SACpB;QACD,GAAG,EAAE,QAAQ,CAAE,kCAAkC;KAClD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,IAAY;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,8BAA8B;IAC9B,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Logger } from '@xbg/utils-logger';
|
|
2
|
+
import { FirestoreConfig, AuthConfig, StorageConfig } from './config-types';
|
|
3
|
+
import { NormalizedFirebaseEvent } from './normalizer';
|
|
4
|
+
export declare class TriggerFactory {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly eventHandler;
|
|
7
|
+
constructor(logger: Logger, eventHandler: (event: NormalizedFirebaseEvent) => void);
|
|
8
|
+
/**
|
|
9
|
+
* Generate all Firestore triggers based on config
|
|
10
|
+
*/
|
|
11
|
+
generateFirestoreTriggers(config: FirestoreConfig): Record<string, any>;
|
|
12
|
+
/**
|
|
13
|
+
* Generate all Auth triggers based on config
|
|
14
|
+
*/
|
|
15
|
+
generateAuthTriggers(config: AuthConfig): Record<string, any>;
|
|
16
|
+
/**
|
|
17
|
+
* Generate Storage trigger based on config
|
|
18
|
+
*/
|
|
19
|
+
generateStorageTriggers(config: StorageConfig): Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=trigger-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-factory.d.ts","sourceRoot":"","sources":["../src/trigger-factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI;IAGzE;;OAEG;IACH,yBAAyB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAyCvE;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAwB7D;;OAEG;IACH,uBAAuB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAsBpE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utilities/firebase-event-bridge/trigger-factory.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TriggerFactory = void 0;
|
|
5
|
+
const firestore_adapter_1 = require("./adapters/firestore-adapter");
|
|
6
|
+
const auth_adapter_1 = require("./adapters/auth-adapter");
|
|
7
|
+
const storage_adapter_1 = require("./adapters/storage-adapter");
|
|
8
|
+
class TriggerFactory {
|
|
9
|
+
constructor(logger, eventHandler) {
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
this.eventHandler = eventHandler;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate all Firestore triggers based on config
|
|
15
|
+
*/
|
|
16
|
+
generateFirestoreTriggers(config) {
|
|
17
|
+
const triggers = {};
|
|
18
|
+
const adapter = new firestore_adapter_1.FirestoreAdapter(this.logger, this.eventHandler);
|
|
19
|
+
for (const dbConfig of config.databases) {
|
|
20
|
+
for (const collectionConfig of dbConfig.collections) {
|
|
21
|
+
for (const operation of collectionConfig.operations) {
|
|
22
|
+
const trigger = adapter.createTrigger(dbConfig.databaseName, collectionConfig, operation);
|
|
23
|
+
const triggerName = firestore_adapter_1.FirestoreAdapter.generateTriggerName(dbConfig.databaseName, collectionConfig.path, operation, collectionConfig.eventNameOverride);
|
|
24
|
+
triggers[triggerName] = trigger;
|
|
25
|
+
// ✅ Safe logging - only trigger metadata
|
|
26
|
+
this.logger.debug('Firestore trigger generated', {
|
|
27
|
+
triggerName,
|
|
28
|
+
databaseName: dbConfig.databaseName,
|
|
29
|
+
collection: collectionConfig.path,
|
|
30
|
+
operation
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
this.logger.info('Firestore triggers generated', {
|
|
36
|
+
count: Object.keys(triggers).length,
|
|
37
|
+
databaseCount: config.databases.length
|
|
38
|
+
});
|
|
39
|
+
return triggers;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generate all Auth triggers based on config
|
|
43
|
+
*/
|
|
44
|
+
generateAuthTriggers(config) {
|
|
45
|
+
const triggers = {};
|
|
46
|
+
const adapter = new auth_adapter_1.AuthAdapter(this.logger, this.eventHandler);
|
|
47
|
+
for (const operation of config.operations) {
|
|
48
|
+
const trigger = adapter.createTrigger(operation);
|
|
49
|
+
const triggerName = auth_adapter_1.AuthAdapter.generateTriggerName(operation);
|
|
50
|
+
triggers[triggerName] = trigger;
|
|
51
|
+
// ✅ Safe logging - only trigger metadata
|
|
52
|
+
this.logger.debug('Auth trigger generated', {
|
|
53
|
+
triggerName,
|
|
54
|
+
operation
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
this.logger.info('Auth triggers generated', {
|
|
58
|
+
count: Object.keys(triggers).length
|
|
59
|
+
});
|
|
60
|
+
return triggers;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate Storage trigger based on config
|
|
64
|
+
*/
|
|
65
|
+
generateStorageTriggers(config) {
|
|
66
|
+
const triggers = {};
|
|
67
|
+
const adapter = new storage_adapter_1.StorageAdapter(this.logger, this.eventHandler);
|
|
68
|
+
const trigger = adapter.createTrigger(config);
|
|
69
|
+
const triggerName = storage_adapter_1.StorageAdapter.generateTriggerName();
|
|
70
|
+
triggers[triggerName] = trigger;
|
|
71
|
+
// ✅ Safe logging - only trigger metadata
|
|
72
|
+
this.logger.debug('Storage trigger generated', {
|
|
73
|
+
triggerName,
|
|
74
|
+
pathPatterns: config.pathPatterns
|
|
75
|
+
});
|
|
76
|
+
this.logger.info('Storage triggers generated', {
|
|
77
|
+
count: 1,
|
|
78
|
+
pathPatterns: config.pathPatterns
|
|
79
|
+
});
|
|
80
|
+
return triggers;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.TriggerFactory = TriggerFactory;
|
|
84
|
+
//# sourceMappingURL=trigger-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-factory.js","sourceRoot":"","sources":["../src/trigger-factory.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oEAAgE;AAChE,0DAAsD;AACtD,gEAA4D;AAG5D,MAAa,cAAc;IACzB,YACmB,MAAc,EACd,YAAsD;QADtD,WAAM,GAAN,MAAM,CAAQ;QACd,iBAAY,GAAZ,YAAY,CAA0C;IACtE,CAAC;IAEJ;;OAEG;IACH,yBAAyB,CAAC,MAAuB;QAC/C,MAAM,QAAQ,GAAwB,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,IAAI,oCAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAErE,KAAK,MAAM,QAAQ,IAAI,MAAM,CA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+
"description": "Firebase triggers to event normalization",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"build:watch": "tsc --watch",
|
|
13
|
+
"clean": "rm -rf lib",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@xbg/utils-events": "^1.0.0",
|
|
18
|
+
"@xbg/utils-logger": "^1.0.0",
|
|
19
|
+
"firebase-admin": "^12.0.0",
|
|
20
|
+
"firebase-functions": "^4.6.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^20.11.0",
|
|
24
|
+
"typescript": "^5.3.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "22"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|