@quatrain/cloudwrapper-supabase 1.1.12 → 1.1.13
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.
|
@@ -15,7 +15,7 @@ export declare class SupabaseCloudWrapper extends AbstractCloudWrapper {
|
|
|
15
15
|
protected _realtimeClient: RealtimeChannel | undefined;
|
|
16
16
|
protected _isInitialized: boolean;
|
|
17
17
|
constructor(params: SupabaseParams);
|
|
18
|
-
databaseTrigger(trigger: DatabaseTriggerType): {
|
|
18
|
+
databaseTrigger(trigger: DatabaseTriggerType): void | {
|
|
19
19
|
event: any;
|
|
20
20
|
schema: string;
|
|
21
21
|
table: string;
|
|
@@ -57,16 +57,22 @@ class SupabaseCloudWrapper extends cloudwrapper_1.AbstractCloudWrapper {
|
|
|
57
57
|
if (typeof trigger.script !== 'function') {
|
|
58
58
|
throw new Error(`Passed script value is not a function`);
|
|
59
59
|
}
|
|
60
|
+
if (Array.isArray(trigger.event)) {
|
|
61
|
+
const params = trigger.event.forEach((event) => {
|
|
62
|
+
return this.databaseTrigger(Object.assign(Object.assign({}, trigger), { event, name: `${trigger.name}-${event}` }));
|
|
63
|
+
});
|
|
64
|
+
return params;
|
|
65
|
+
}
|
|
60
66
|
try {
|
|
61
67
|
const params = {
|
|
62
68
|
event: Reflect.get(exports.eventMap, trigger.event),
|
|
63
69
|
schema: 'public',
|
|
64
70
|
table: trigger.model,
|
|
65
71
|
};
|
|
72
|
+
cloudwrapper_1.CloudWrapper.info(`Set up DB trigger ${trigger.name} for ${trigger.event} event on table ${params.table}`);
|
|
66
73
|
(_a = this._supabaseClient) === null || _a === void 0 ? void 0 : _a.channel(trigger.name).on('postgres_changes', params, (_b) => __awaiter(this, void 0, void 0, function* () {
|
|
67
74
|
var { old: before, new: after } = _b, context = __rest(_b, ["old", "new"]);
|
|
68
|
-
|
|
69
|
-
cloudwrapper_1.CloudWrapper.info(`Triggering function on event`);
|
|
75
|
+
cloudwrapper_1.CloudWrapper.info(`Triggering function on event ${trigger.name}`);
|
|
70
76
|
try {
|
|
71
77
|
return yield trigger.script({ before, after, context });
|
|
72
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/cloudwrapper-supabase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Cloud Wrapper adapter for Supabase",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@quatrain/backend": "^1.1.12",
|
|
18
|
-
"@quatrain/cloudwrapper": "^1.1.
|
|
18
|
+
"@quatrain/cloudwrapper": "^1.1.12",
|
|
19
19
|
"@quatrain/core": "^1.1.14",
|
|
20
20
|
"@supabase/supabase-js": "^2.47.15"
|
|
21
21
|
},
|