corsair 0.1.4 → 0.1.6
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/core/auth/key-manager.d.ts.map +1 -1
- package/dist/core/auth/key-manager.js +19 -3
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +4 -0
- package/dist/db/kysely/database.d.ts +7 -1
- package/dist/db/kysely/database.d.ts.map +1 -1
- package/dist/db/kysely/database.js +22 -8
- package/dist/db/kysely/sqlite.d.ts +22 -0
- package/dist/db/kysely/sqlite.d.ts.map +1 -0
- package/dist/db/kysely/sqlite.js +38 -0
- package/dist/plugins/gmail/api.test.js +1 -1
- package/dist/plugins/gmail/endpoints/drafts.d.ts.map +1 -1
- package/dist/plugins/gmail/endpoints/drafts.js +2 -2
- package/dist/plugins/gmail/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/gmail/endpoints/labels.js +2 -2
- package/dist/plugins/gmail/endpoints/messages.d.ts.map +1 -1
- package/dist/plugins/gmail/endpoints/messages.js +22 -13
- package/dist/plugins/gmail/endpoints/threads.d.ts.map +1 -1
- package/dist/plugins/gmail/endpoints/threads.js +11 -7
- package/dist/plugins/gmail/index.d.ts +4 -3
- package/dist/plugins/gmail/index.d.ts.map +1 -1
- package/dist/plugins/gmail/index.js +1 -1
- package/dist/plugins/gmail/integration.test.js +18 -12
- package/dist/plugins/gmail/schema/index.d.ts +57 -39
- package/dist/plugins/gmail/schema/index.d.ts.map +1 -1
- package/dist/plugins/gmail/schema/index.js +7 -0
- package/dist/plugins/gmail/webhooks/index.d.ts +3 -64
- package/dist/plugins/gmail/webhooks/index.d.ts.map +1 -1
- package/dist/plugins/gmail/webhooks/messages.d.ts +4 -76
- package/dist/plugins/gmail/webhooks/messages.d.ts.map +1 -1
- package/dist/plugins/gmail/webhooks/messages.js +4 -49
- package/dist/plugins/gmail/webhooks/types.d.ts +3 -0
- package/dist/plugins/gmail/webhooks/types.d.ts.map +1 -1
- package/dist/plugins/gmail/webhooks/types.js +19 -1
- package/dist/plugins/googlecalendar/api.test.d.ts +2 -0
- package/dist/plugins/googlecalendar/api.test.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/api.test.js +134 -0
- package/dist/plugins/googlecalendar/client.d.ts +16 -0
- package/dist/plugins/googlecalendar/client.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/client.js +81 -0
- package/dist/plugins/googlecalendar/endpoints/calendar.d.ts +3 -0
- package/dist/plugins/googlecalendar/endpoints/calendar.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/endpoints/calendar.js +17 -0
- package/dist/plugins/googlecalendar/endpoints/events.d.ts +7 -0
- package/dist/plugins/googlecalendar/endpoints/events.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/endpoints/events.js +136 -0
- package/dist/plugins/googlecalendar/endpoints/index.d.ts +62 -0
- package/dist/plugins/googlecalendar/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/endpoints/index.js +13 -0
- package/dist/plugins/googlecalendar/endpoints/types.d.ts +1525 -0
- package/dist/plugins/googlecalendar/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/endpoints/types.js +120 -0
- package/dist/plugins/googlecalendar/index.d.ts +159 -0
- package/dist/plugins/googlecalendar/index.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/index.js +67 -0
- package/dist/plugins/googlecalendar/integration.test.d.ts +2 -0
- package/dist/plugins/googlecalendar/integration.test.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/integration.test.js +149 -0
- package/dist/plugins/googlecalendar/schema/database.d.ts +333 -0
- package/dist/plugins/googlecalendar/schema/database.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/schema/database.js +78 -0
- package/dist/plugins/googlecalendar/schema/index.d.ts +335 -0
- package/dist/plugins/googlecalendar/schema/index.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/schema/index.js +8 -0
- package/dist/plugins/googlecalendar/types.d.ts +182 -0
- package/dist/plugins/googlecalendar/types.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/webhooks/events.d.ts +7 -0
- package/dist/plugins/googlecalendar/webhooks/events.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/webhooks/events.js +310 -0
- package/dist/plugins/googlecalendar/webhooks/index.d.ts +24 -0
- package/dist/plugins/googlecalendar/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/webhooks/index.js +9 -0
- package/dist/plugins/googlecalendar/webhooks/types.d.ts +71 -0
- package/dist/plugins/googlecalendar/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/webhooks/types.js +34 -0
- package/dist/plugins/googledrive/api.test.d.ts +2 -0
- package/dist/plugins/googledrive/api.test.d.ts.map +1 -0
- package/dist/plugins/googledrive/api.test.js +473 -0
- package/dist/plugins/googledrive/client.d.ts +16 -0
- package/dist/plugins/googledrive/client.d.ts.map +1 -0
- package/dist/plugins/googledrive/client.js +81 -0
- package/dist/plugins/googledrive/endpoints/files.d.ts +12 -0
- package/dist/plugins/googledrive/endpoints/files.d.ts.map +1 -0
- package/dist/plugins/googledrive/endpoints/files.js +245 -0
- package/dist/plugins/googledrive/endpoints/folders.d.ts +7 -0
- package/dist/plugins/googledrive/endpoints/folders.d.ts.map +1 -0
- package/dist/plugins/googledrive/endpoints/folders.js +130 -0
- package/dist/plugins/googledrive/endpoints/index.d.ts +193 -0
- package/dist/plugins/googledrive/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/googledrive/endpoints/index.js +34 -0
- package/dist/plugins/googledrive/endpoints/search.d.ts +3 -0
- package/dist/plugins/googledrive/endpoints/search.d.ts.map +1 -0
- package/dist/plugins/googledrive/endpoints/search.js +49 -0
- package/dist/plugins/googledrive/endpoints/sharedDrives.d.ts +7 -0
- package/dist/plugins/googledrive/endpoints/sharedDrives.d.ts.map +1 -0
- package/dist/plugins/googledrive/endpoints/sharedDrives.js +124 -0
- package/dist/plugins/googledrive/endpoints/types.d.ts +1895 -0
- package/dist/plugins/googledrive/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/googledrive/endpoints/types.js +102 -0
- package/dist/plugins/googledrive/index.d.ts +410 -0
- package/dist/plugins/googledrive/index.d.ts.map +1 -0
- package/dist/plugins/googledrive/index.js +83 -0
- package/dist/plugins/googledrive/integration.test.d.ts +2 -0
- package/dist/plugins/googledrive/integration.test.d.ts.map +1 -0
- package/dist/plugins/googledrive/integration.test.js +139 -0
- package/dist/plugins/googledrive/schema/database.d.ts +545 -0
- package/dist/plugins/googledrive/schema/database.d.ts.map +1 -0
- package/dist/plugins/googledrive/schema/database.js +121 -0
- package/dist/plugins/googledrive/schema/index.d.ts +546 -0
- package/dist/plugins/googledrive/schema/index.d.ts.map +1 -0
- package/dist/plugins/googledrive/schema/index.js +9 -0
- package/dist/plugins/googledrive/types.d.ts +288 -0
- package/dist/plugins/googledrive/types.d.ts.map +1 -0
- package/dist/plugins/googledrive/types.js +1 -0
- package/dist/plugins/googledrive/webhooks/changes.d.ts +4 -0
- package/dist/plugins/googledrive/webhooks/changes.d.ts.map +1 -0
- package/dist/plugins/googledrive/webhooks/changes.js +230 -0
- package/dist/plugins/googledrive/webhooks/index.d.ts +12 -0
- package/dist/plugins/googledrive/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/googledrive/webhooks/index.js +6 -0
- package/dist/plugins/googledrive/webhooks/types.d.ts +49 -0
- package/dist/plugins/googledrive/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/googledrive/webhooks/types.js +19 -0
- package/dist/plugins/googlesheets/api.test.d.ts +2 -0
- package/dist/plugins/googlesheets/api.test.d.ts.map +1 -0
- package/dist/plugins/googlesheets/api.test.js +344 -0
- package/dist/plugins/googlesheets/client.d.ts +16 -0
- package/dist/plugins/googlesheets/client.d.ts.map +1 -0
- package/dist/plugins/googlesheets/client.js +81 -0
- package/dist/plugins/googlesheets/endpoints/index.d.ts +68 -0
- package/dist/plugins/googlesheets/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/googlesheets/endpoints/index.js +17 -0
- package/dist/plugins/googlesheets/endpoints/sheets.d.ts +10 -0
- package/dist/plugins/googlesheets/endpoints/sheets.d.ts.map +1 -0
- package/dist/plugins/googlesheets/endpoints/sheets.js +167 -0
- package/dist/plugins/googlesheets/endpoints/spreadsheets.d.ts +4 -0
- package/dist/plugins/googlesheets/endpoints/spreadsheets.d.ts.map +1 -0
- package/dist/plugins/googlesheets/endpoints/spreadsheets.js +46 -0
- package/dist/plugins/googlesheets/endpoints/types.d.ts +409 -0
- package/dist/plugins/googlesheets/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/googlesheets/endpoints/types.js +56 -0
- package/dist/plugins/googlesheets/index.d.ts +166 -0
- package/dist/plugins/googlesheets/index.d.ts.map +1 -0
- package/dist/plugins/googlesheets/index.js +71 -0
- package/dist/plugins/googlesheets/integration.test.d.ts +2 -0
- package/dist/plugins/googlesheets/integration.test.d.ts.map +1 -0
- package/dist/plugins/googlesheets/integration.test.js +106 -0
- package/dist/plugins/googlesheets/schema/database.d.ts +62 -0
- package/dist/plugins/googlesheets/schema/database.d.ts.map +1 -0
- package/dist/plugins/googlesheets/schema/database.js +22 -0
- package/dist/plugins/googlesheets/schema/index.d.ts +63 -0
- package/dist/plugins/googlesheets/schema/index.d.ts.map +1 -0
- package/dist/plugins/googlesheets/schema/index.js +9 -0
- package/dist/plugins/googlesheets/types.d.ts +687 -0
- package/dist/plugins/googlesheets/types.d.ts.map +1 -0
- package/dist/plugins/googlesheets/types.js +1 -0
- package/dist/plugins/googlesheets/webhooks/index.d.ts +16 -0
- package/dist/plugins/googlesheets/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/googlesheets/webhooks/index.js +7 -0
- package/dist/plugins/googlesheets/webhooks/rows.d.ts +5 -0
- package/dist/plugins/googlesheets/webhooks/rows.d.ts.map +1 -0
- package/dist/plugins/googlesheets/webhooks/rows.js +134 -0
- package/dist/plugins/googlesheets/webhooks/types.d.ts +48 -0
- package/dist/plugins/googlesheets/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/googlesheets/webhooks/types.js +10 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/linear/api.test.js +1 -3
- package/dist/plugins/linear/endpoints/comments.js +8 -8
- package/dist/plugins/linear/endpoints/issues.d.ts.map +1 -1
- package/dist/plugins/linear/endpoints/issues.js +9 -7
- package/dist/plugins/linear/endpoints/projects.js +5 -5
- package/dist/plugins/linear/endpoints/teams.js +2 -2
- package/dist/plugins/linear/endpoints/types.d.ts +57 -1635
- package/dist/plugins/linear/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/linear/endpoints/types.js +2 -2
- package/dist/plugins/slack/integration.test.js +6 -10
- package/dist/tests/plugins-test-utils.d.ts +3 -3
- package/dist/tests/plugins-test-utils.d.ts.map +1 -1
- package/dist/tests/plugins-test-utils.js +7 -8
- package/dist/tests/setup-db.d.ts.map +1 -1
- package/dist/tests/setup-db.js +4 -2
- package/package.json +3 -34
- package/dist/adapters/drizzle/index.d.ts +0 -2
- package/dist/adapters/drizzle/index.d.ts.map +0 -1
- package/dist/adapters/drizzle/index.js +0 -1
- package/dist/adapters/drizzle/postgres.d.ts +0 -34
- package/dist/adapters/drizzle/postgres.d.ts.map +0 -1
- package/dist/adapters/drizzle/postgres.js +0 -228
- package/dist/adapters/index.d.ts +0 -9
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -5
- package/dist/adapters/kysely/index.d.ts +0 -2
- package/dist/adapters/kysely/index.d.ts.map +0 -1
- package/dist/adapters/kysely/index.js +0 -1
- package/dist/adapters/kysely/postgres.d.ts +0 -19
- package/dist/adapters/kysely/postgres.d.ts.map +0 -1
- package/dist/adapters/kysely/postgres.js +0 -138
- package/dist/adapters/prisma/index.d.ts +0 -2
- package/dist/adapters/prisma/index.d.ts.map +0 -1
- package/dist/adapters/prisma/index.js +0 -1
- package/dist/adapters/prisma/postgres.d.ts +0 -17
- package/dist/adapters/prisma/postgres.d.ts.map +0 -1
- package/dist/adapters/prisma/postgres.js +0 -176
- package/dist/adapters/tenant.d.ts +0 -13
- package/dist/adapters/tenant.d.ts.map +0 -1
- package/dist/adapters/tenant.js +0 -95
- package/dist/adapters/types.d.ts +0 -162
- package/dist/adapters/types.d.ts.map +0 -1
- /package/dist/{adapters → plugins/googlecalendar}/types.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-manager.d.ts","sourceRoot":"","sources":["../../../core/auth/key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,OAAO,KAAK,EAEX,oBAAoB,EAEpB,wBAAwB,EACxB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"key-manager.d.ts","sourceRoot":"","sources":["../../../core/auth/key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,OAAO,KAAK,EAEX,oBAAoB,EAEpB,wBAAwB,EACxB,MAAM,SAAS,CAAC;AAkBjB,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,SAAS,IAAI;IAC/D,QAAQ,EAAE,CAAC,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,SAAS,EAC9D,OAAO,EAAE,4BAA4B,CAAC,CAAC,CAAC,GACtC,wBAAwB,CAAC,CAAC,CAAC,CAwE7B;AAMD,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,SAAS,IAAI;IAC3D,QAAQ,EAAE,CAAC,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,SAAS,EAC1D,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAClC,oBAAoB,CAAC,CAAC,CAAC,CAuGzB;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC7C,QAAQ,EAAE,eAAe,EACzB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,CAAC,CAwBjB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,eAAe,EACzB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,CAAC,CAqCjB"}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { encryptDEK, generateDEK } from './encryption';
|
|
2
2
|
import { createApiKeyAccountKeyManager, createApiKeyIntegrationKeyManager, createBotTokenAccountKeyManager, createBotTokenIntegrationKeyManager, createOAuth2AccountKeyManager, createOAuth2IntegrationKeyManager, } from './methods';
|
|
3
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
// Integration Key Manager Factory
|
|
5
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
const parseConfig = (config) => {
|
|
7
|
+
if (!config)
|
|
8
|
+
return {};
|
|
9
|
+
if (typeof config === 'string') {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(config);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return config;
|
|
18
|
+
};
|
|
3
19
|
/**
|
|
4
20
|
* Creates an integration-level key manager for the given auth type.
|
|
5
21
|
* The returned manager has methods based on the auth type:
|
|
@@ -27,7 +43,7 @@ export function createIntegrationKeyManager(options) {
|
|
|
27
43
|
}
|
|
28
44
|
cachedIntegration = {
|
|
29
45
|
id: integration.id,
|
|
30
|
-
config: (integration.config
|
|
46
|
+
config: parseConfig(integration.config),
|
|
31
47
|
dek: integration.dek ?? null,
|
|
32
48
|
};
|
|
33
49
|
return cachedIntegration;
|
|
@@ -85,7 +101,7 @@ export function createAccountKeyManager(options) {
|
|
|
85
101
|
}
|
|
86
102
|
cachedIntegration = {
|
|
87
103
|
id: integration.id,
|
|
88
|
-
config: (integration.config
|
|
104
|
+
config: parseConfig(integration.config),
|
|
89
105
|
dek: integration.dek ?? null,
|
|
90
106
|
};
|
|
91
107
|
return cachedIntegration;
|
|
@@ -110,7 +126,7 @@ export function createAccountKeyManager(options) {
|
|
|
110
126
|
}
|
|
111
127
|
cachedAccount = {
|
|
112
128
|
id: account.id,
|
|
113
|
-
config: (account.config
|
|
129
|
+
config: parseConfig(account.config),
|
|
114
130
|
dek: account.dek ?? null,
|
|
115
131
|
};
|
|
116
132
|
return cachedAccount;
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type AllErrors = 'RATE_LIMIT_ERROR' | 'AUTH_ERROR' | 'PERMISSION_ERROR' | 'NETWORK_ERROR' | 'TIMEOUT_ERROR' | 'SERVER_ERROR' | 'VALIDATION_ERROR' | 'NOT_FOUND_ERROR' | 'BAD_REQUEST_ERROR' | 'PARSING_ERROR' | 'DEFAULT' | (string & {});
|
|
2
|
-
export declare const BaseProviders: readonly ["slack", "github", "linear", "hubspot", "gmail", "resend"];
|
|
3
|
-
export type AllProviders = 'slack' | 'github' | 'linear' | 'hubspot' | 'gmail' | 'resend' | (string & {});
|
|
2
|
+
export declare const BaseProviders: readonly ["slack", "github", "linear", "hubspot", "gmail", "resend", "posthog", "googlesheets", "googledrive", "googlecalendar"];
|
|
3
|
+
export type AllProviders = 'slack' | 'github' | 'linear' | 'hubspot' | 'gmail' | 'resend' | 'posthog' | 'googlesheets' | 'googledrive' | 'googlecalendar' | (string & {});
|
|
4
4
|
export type AuthTypes = 'oauth_2' | 'api_key' | 'bot_token';
|
|
5
5
|
export type PickAuth<T extends AuthTypes> = T;
|
|
6
6
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../core/constants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAClB,kBAAkB,GAClB,YAAY,GACZ,kBAAkB,GAClB,eAAe,GACf,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,GACnB,eAAe,GACf,SAAS,GACT,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEjB,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../core/constants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAClB,kBAAkB,GAClB,YAAY,GACZ,kBAAkB,GAClB,eAAe,GACf,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,GACnB,eAAe,GACf,SAAS,GACT,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEjB,eAAO,MAAM,aAAa,kIAWhB,CAAC;AAEX,MAAM,MAAM,YAAY,GACrB,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,OAAO,GACP,QAAQ,GACR,SAAS,GACT,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEjB,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAE5D,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,CAAC"}
|
package/dist/core/constants.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SqliteDialectConfig } from 'kysely';
|
|
1
2
|
import { Kysely } from 'kysely';
|
|
2
3
|
import type { Pool } from 'pg';
|
|
3
4
|
import type { CorsairAccount, CorsairEntity, CorsairEvent, CorsairIntegration } from '../index';
|
|
@@ -10,6 +11,11 @@ export type CorsairKyselyDatabase = {
|
|
|
10
11
|
export type CorsairDatabase = {
|
|
11
12
|
db: Kysely<CorsairKyselyDatabase>;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* better-sqlite3 Database instance.
|
|
16
|
+
* Uses Kysely's expected SqliteDatabase type from SqliteDialectConfig.
|
|
17
|
+
*/
|
|
18
|
+
export type BetterSqlite3Database = NonNullable<SqliteDialectConfig['database']>;
|
|
19
|
+
export type CorsairDatabaseInput = Pool | BetterSqlite3Database | Kysely<CorsairKyselyDatabase>;
|
|
14
20
|
export declare function createCorsairDatabase(input: CorsairDatabaseInput): CorsairDatabase;
|
|
15
21
|
//# sourceMappingURL=database.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../db/kysely/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../db/kysely/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,MAAM,EAAkC,MAAM,QAAQ,CAAC;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,qBAAqB,GAAG;IACnC,oBAAoB,EAAE,kBAAkB,CAAC;IACzC,gBAAgB,EAAE,cAAc,CAAC;IACjC,gBAAgB,EAAE,aAAa,CAAC;IAChC,cAAc,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAC9C,mBAAmB,CAAC,UAAU,CAAC,CAC/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC7B,IAAI,GACJ,qBAAqB,GACrB,MAAM,CAAC,qBAAqB,CAAC,CAAC;AA6BjC,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,oBAAoB,GACzB,eAAe,CAsBjB"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { Kysely, PostgresDialect } from 'kysely';
|
|
1
|
+
import { Kysely, PostgresDialect, SqliteDialect } from 'kysely';
|
|
2
2
|
function isPgPool(input) {
|
|
3
|
-
return typeof input.query === 'function'
|
|
3
|
+
return (typeof input.query === 'function' &&
|
|
4
|
+
typeof input.connect === 'function');
|
|
5
|
+
}
|
|
6
|
+
function isBetterSqlite3(input) {
|
|
7
|
+
const db = input;
|
|
8
|
+
return (typeof db.prepare === 'function' &&
|
|
9
|
+
typeof db.exec === 'function' &&
|
|
10
|
+
typeof db.close === 'function' &&
|
|
11
|
+
!('query' in input));
|
|
4
12
|
}
|
|
5
13
|
function isKysely(input) {
|
|
6
14
|
return (typeof input.selectFrom === 'function');
|
|
@@ -9,11 +17,17 @@ export function createCorsairDatabase(input) {
|
|
|
9
17
|
if (isKysely(input)) {
|
|
10
18
|
return { db: input };
|
|
11
19
|
}
|
|
12
|
-
if (
|
|
13
|
-
|
|
20
|
+
if (isBetterSqlite3(input)) {
|
|
21
|
+
const db = new Kysely({
|
|
22
|
+
dialect: new SqliteDialect({ database: input }),
|
|
23
|
+
});
|
|
24
|
+
return { db };
|
|
25
|
+
}
|
|
26
|
+
if (isPgPool(input)) {
|
|
27
|
+
const db = new Kysely({
|
|
28
|
+
dialect: new PostgresDialect({ pool: input }),
|
|
29
|
+
});
|
|
30
|
+
return { db };
|
|
14
31
|
}
|
|
15
|
-
|
|
16
|
-
dialect: new PostgresDialect({ pool: input }),
|
|
17
|
-
});
|
|
18
|
-
return { db };
|
|
32
|
+
throw new Error('Unsupported database input. Expected a pg Pool, better-sqlite3 Database, or a Kysely instance.');
|
|
19
33
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts a text field from the JSON `data` column in SQLite.
|
|
3
|
+
* Uses json_extract for JSON value extraction.
|
|
4
|
+
*/
|
|
5
|
+
export declare function jsonTextField<Data extends Record<string, unknown>>(key: Extract<keyof Data, string>): import("kysely").RawBuilder<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Extracts a number field from the JSON `data` column in SQLite.
|
|
8
|
+
* Casts the result to REAL for numeric operations.
|
|
9
|
+
*/
|
|
10
|
+
export declare function jsonNumberField<Data extends Record<string, unknown>>(key: Extract<keyof Data, string>): import("kysely").RawBuilder<number>;
|
|
11
|
+
/**
|
|
12
|
+
* Extracts a boolean field from the JSON `data` column in SQLite.
|
|
13
|
+
* SQLite stores booleans as 0/1 in JSON, so we extract and compare.
|
|
14
|
+
*/
|
|
15
|
+
export declare function jsonBooleanField<Data extends Record<string, unknown>>(key: Extract<keyof Data, string>): import("kysely").RawBuilder<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Extracts a timestamp/date field from the JSON `data` column in SQLite.
|
|
18
|
+
* SQLite stores dates as ISO8601 text strings; this extracts them as-is.
|
|
19
|
+
* Date comparisons will work correctly with ISO8601 formatted strings.
|
|
20
|
+
*/
|
|
21
|
+
export declare function jsonTimestampField<Data extends Record<string, unknown>>(key: Extract<keyof Data, string>): import("kysely").RawBuilder<Date>;
|
|
22
|
+
//# sourceMappingURL=sqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../../db/kysely/sqlite.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,GAAG,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,CAAC,uCAIhC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,GAAG,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,CAAC,uCAIhC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,GAAG,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,CAAC,wCAIhC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtE,GAAG,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,CAAC,qCAIhC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
function escapeJsonPath(path) {
|
|
3
|
+
// Escape single quotes and ensure path is safe for SQLite json_extract
|
|
4
|
+
return path.replace(/'/g, "''").replace(/\\/g, '\\\\');
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Extracts a text field from the JSON `data` column in SQLite.
|
|
8
|
+
* Uses json_extract for JSON value extraction.
|
|
9
|
+
*/
|
|
10
|
+
export function jsonTextField(key) {
|
|
11
|
+
const escapedPath = escapeJsonPath(key);
|
|
12
|
+
return sql `json_extract(data, '$.${sql.raw(escapedPath)}')`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Extracts a number field from the JSON `data` column in SQLite.
|
|
16
|
+
* Casts the result to REAL for numeric operations.
|
|
17
|
+
*/
|
|
18
|
+
export function jsonNumberField(key) {
|
|
19
|
+
const escapedPath = escapeJsonPath(key);
|
|
20
|
+
return sql `CAST(json_extract(data, '$.${sql.raw(escapedPath)}') AS REAL)`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Extracts a boolean field from the JSON `data` column in SQLite.
|
|
24
|
+
* SQLite stores booleans as 0/1 in JSON, so we extract and compare.
|
|
25
|
+
*/
|
|
26
|
+
export function jsonBooleanField(key) {
|
|
27
|
+
const escapedPath = escapeJsonPath(key);
|
|
28
|
+
return sql `json_extract(data, '$.${sql.raw(escapedPath)}')`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Extracts a timestamp/date field from the JSON `data` column in SQLite.
|
|
32
|
+
* SQLite stores dates as ISO8601 text strings; this extracts them as-is.
|
|
33
|
+
* Date comparisons will work correctly with ISO8601 formatted strings.
|
|
34
|
+
*/
|
|
35
|
+
export function jsonTimestampField(key) {
|
|
36
|
+
const escapedPath = escapeJsonPath(key);
|
|
37
|
+
return sql `json_extract(data, '$.${sql.raw(escapedPath)}')`;
|
|
38
|
+
}
|
|
@@ -2,7 +2,7 @@ import dotenv from 'dotenv';
|
|
|
2
2
|
import { makeGmailRequest } from './client';
|
|
3
3
|
import { GmailEndpointOutputSchemas } from './endpoints/types';
|
|
4
4
|
dotenv.config();
|
|
5
|
-
const TEST_TOKEN = process.env.
|
|
5
|
+
const TEST_TOKEN = process.env.GOOGLE_ACCESS_TOKEN;
|
|
6
6
|
const TEST_EMAIL = 'mukulydv15@gmail.com';
|
|
7
7
|
function createRawEmailMessage(to, from, subject, body) {
|
|
8
8
|
const email = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drafts.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/drafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"drafts.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/drafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2C,cAAc,EAAE,MAAM,IAAI,CAAC;AAIlF,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,YAAY,CAsC7C,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,cAAc,CAAC,WAAW,CA2B3C,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,cAAc,CAsBjD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,cAAc,CAsBjD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,cAAc,CA0BtD,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,YAAY,CAoB7C,CAAC"}
|
|
@@ -59,7 +59,7 @@ export const create = async (ctx, input) => {
|
|
|
59
59
|
});
|
|
60
60
|
if (result.id) {
|
|
61
61
|
const endpoints = ctx.endpoints;
|
|
62
|
-
await endpoints.
|
|
62
|
+
await endpoints.drafts.get({ id: result.id, userId: input.userId });
|
|
63
63
|
}
|
|
64
64
|
await logEventFromContext(ctx, 'gmail.drafts.create', { ...input }, 'completed');
|
|
65
65
|
return result;
|
|
@@ -71,7 +71,7 @@ export const update = async (ctx, input) => {
|
|
|
71
71
|
});
|
|
72
72
|
if (result.id) {
|
|
73
73
|
const endpoints = ctx.endpoints;
|
|
74
|
-
await endpoints.
|
|
74
|
+
await endpoints.drafts.get({ id: result.id, userId: input.userId });
|
|
75
75
|
}
|
|
76
76
|
await logEventFromContext(ctx, 'gmail.drafts.update', { ...input }, 'completed');
|
|
77
77
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS7B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS7B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;gBA2Bk1C,CAAC;iCAAmC,CAAC;+BAA0C,CAAC;iBAA4D,CAAC;yBAAkB,CAAC;+BAA8B,CAAC;;;;;;;;gBAA0I,CAAC;iCAAmC,CAAC;+BAA0C,CAAC;iBAA4D,CAAC;yBAAkB,CAAC;+BAA8B,CAAC;;;;;;;;CArBr3D,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;mBAmB+0E,CAAC;mBAAY,CAAC;wBAAuB,CAAC;;;;;;;;mBAA6I,CAAC;mBAAY,CAAC;wBAAuB,CAAC;;;;;;;;;;;;eAAwO,CAAC;oBAAsB,CAAC;;;CAZn0F,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAO5B,CAAC;AAEF,cAAc,SAAS,CAAC"}
|
|
@@ -56,7 +56,7 @@ export const create = async (ctx, input) => {
|
|
|
56
56
|
});
|
|
57
57
|
if (result.id) {
|
|
58
58
|
const endpoints = ctx.endpoints;
|
|
59
|
-
await endpoints.
|
|
59
|
+
await endpoints.labels.get({ id: result.id, userId: input.userId });
|
|
60
60
|
}
|
|
61
61
|
await logEventFromContext(ctx, 'gmail.labels.create', { ...input }, 'completed');
|
|
62
62
|
return result;
|
|
@@ -68,7 +68,7 @@ export const update = async (ctx, input) => {
|
|
|
68
68
|
});
|
|
69
69
|
if (result.id) {
|
|
70
70
|
const endpoints = ctx.endpoints;
|
|
71
|
-
await endpoints.
|
|
71
|
+
await endpoints.labels.get({ id: result.id, userId: input.userId });
|
|
72
72
|
}
|
|
73
73
|
await logEventFromContext(ctx, 'gmail.labels.update', { ...input }, 'completed');
|
|
74
74
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,IAAI,CAAC;AAiF9D,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,cAAc,CAuC/C,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,cAAc,CAAC,aAAa,CAwC7C,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,cAAc,CAyB/C,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,gBAAgB,CA0B1D,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,IAAI,CAAC;AAiF9D,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,cAAc,CAuC/C,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,cAAc,CAAC,aAAa,CAwC7C,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,cAAc,CAyB/C,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,gBAAgB,CA0B1D,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,gBAAgB,CAmCnD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,qBAAqB,CAmC7D,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,cAAc,CAAC,eAAe,CAqBjD,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAsBrD,CAAC"}
|
|
@@ -135,7 +135,7 @@ export const send = async (ctx, input) => {
|
|
|
135
135
|
});
|
|
136
136
|
if (result.id) {
|
|
137
137
|
const endpoints = ctx.endpoints;
|
|
138
|
-
await endpoints.
|
|
138
|
+
await endpoints.messages.get({ id: result.id, userId: input.userId });
|
|
139
139
|
}
|
|
140
140
|
await logEventFromContext(ctx, 'gmail.messages.send', { ...input }, 'completed');
|
|
141
141
|
return result;
|
|
@@ -155,28 +155,37 @@ export const deleteMessage = async (ctx, input) => {
|
|
|
155
155
|
await logEventFromContext(ctx, 'gmail.messages.delete', { ...input }, 'completed');
|
|
156
156
|
};
|
|
157
157
|
export const modify = async (ctx, input) => {
|
|
158
|
+
const body = {};
|
|
159
|
+
if (input.addLabelIds && input.addLabelIds.length > 0) {
|
|
160
|
+
body.addLabelIds = input.addLabelIds;
|
|
161
|
+
}
|
|
162
|
+
if (input.removeLabelIds && input.removeLabelIds.length > 0) {
|
|
163
|
+
body.removeLabelIds = input.removeLabelIds;
|
|
164
|
+
}
|
|
158
165
|
const result = await makeGmailRequest(`/users/${input.userId || 'me'}/messages/${input.id}/modify`, ctx.key, {
|
|
159
166
|
method: 'POST',
|
|
160
|
-
body
|
|
161
|
-
addLabelIds: input.addLabelIds,
|
|
162
|
-
removeLabelIds: input.removeLabelIds,
|
|
163
|
-
},
|
|
167
|
+
body,
|
|
164
168
|
});
|
|
165
169
|
if (result.id) {
|
|
166
170
|
const endpoints = ctx.endpoints;
|
|
167
|
-
await endpoints.
|
|
171
|
+
await endpoints.messages.get({ id: result.id, userId: input.userId });
|
|
168
172
|
}
|
|
169
173
|
await logEventFromContext(ctx, 'gmail.messages.modify', { ...input }, 'completed');
|
|
170
174
|
return result;
|
|
171
175
|
};
|
|
172
176
|
export const batchModify = async (ctx, input) => {
|
|
177
|
+
const body = {
|
|
178
|
+
ids: input.ids,
|
|
179
|
+
};
|
|
180
|
+
if (input.addLabelIds && input.addLabelIds.length > 0) {
|
|
181
|
+
body.addLabelIds = input.addLabelIds;
|
|
182
|
+
}
|
|
183
|
+
if (input.removeLabelIds && input.removeLabelIds.length > 0) {
|
|
184
|
+
body.removeLabelIds = input.removeLabelIds;
|
|
185
|
+
}
|
|
173
186
|
await makeGmailRequest(`/users/${input.userId || 'me'}/messages/batchModify`, ctx.key, {
|
|
174
187
|
method: 'POST',
|
|
175
|
-
body
|
|
176
|
-
ids: input.ids,
|
|
177
|
-
addLabelIds: input.addLabelIds,
|
|
178
|
-
removeLabelIds: input.removeLabelIds,
|
|
179
|
-
},
|
|
188
|
+
body,
|
|
180
189
|
});
|
|
181
190
|
await logEventFromContext(ctx, 'gmail.messages.batchModify', { ...input }, 'completed');
|
|
182
191
|
};
|
|
@@ -186,7 +195,7 @@ export const trash = async (ctx, input) => {
|
|
|
186
195
|
});
|
|
187
196
|
if (result.id) {
|
|
188
197
|
const endpoints = ctx.endpoints;
|
|
189
|
-
await endpoints.
|
|
198
|
+
await endpoints.messages.get({ id: result.id, userId: input.userId });
|
|
190
199
|
}
|
|
191
200
|
await logEventFromContext(ctx, 'gmail.messages.trash', { ...input }, 'completed');
|
|
192
201
|
return result;
|
|
@@ -197,7 +206,7 @@ export const untrash = async (ctx, input) => {
|
|
|
197
206
|
});
|
|
198
207
|
if (result.id) {
|
|
199
208
|
const endpoints = ctx.endpoints;
|
|
200
|
-
await endpoints.
|
|
209
|
+
await endpoints.messages.get({ id: result.id, userId: input.userId });
|
|
201
210
|
}
|
|
202
211
|
await logEventFromContext(ctx, 'gmail.messages.untrash', { ...input }, 'completed');
|
|
203
212
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/threads.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,IAAI,CAAC;AAI9D,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,aAAa,CAuC9C,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,cAAc,CAAC,YAAY,CAgC5C,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../../plugins/gmail/endpoints/threads.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,IAAI,CAAC;AAI9D,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,aAAa,CAuC9C,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,cAAc,CAAC,YAAY,CAgC5C,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,eAAe,CAmClD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,eAAe,CA0BxD,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,cAAc,CAAC,cAAc,CAqBhD,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAqBpD,CAAC"}
|
|
@@ -54,16 +54,20 @@ export const get = async (ctx, input) => {
|
|
|
54
54
|
return result;
|
|
55
55
|
};
|
|
56
56
|
export const modify = async (ctx, input) => {
|
|
57
|
+
const body = {};
|
|
58
|
+
if (input.addLabelIds && input.addLabelIds.length > 0) {
|
|
59
|
+
body.addLabelIds = input.addLabelIds;
|
|
60
|
+
}
|
|
61
|
+
if (input.removeLabelIds && input.removeLabelIds.length > 0) {
|
|
62
|
+
body.removeLabelIds = input.removeLabelIds;
|
|
63
|
+
}
|
|
57
64
|
const result = await makeGmailRequest(`/users/${input.userId || 'me'}/threads/${input.id}/modify`, ctx.key, {
|
|
58
65
|
method: 'POST',
|
|
59
|
-
body
|
|
60
|
-
addLabelIds: input.addLabelIds,
|
|
61
|
-
removeLabelIds: input.removeLabelIds,
|
|
62
|
-
},
|
|
66
|
+
body,
|
|
63
67
|
});
|
|
64
68
|
if (result.id) {
|
|
65
69
|
const endpoints = ctx.endpoints;
|
|
66
|
-
await endpoints.
|
|
70
|
+
await endpoints.threads.get({ id: result.id, userId: input.userId });
|
|
67
71
|
}
|
|
68
72
|
await logEventFromContext(ctx, 'gmail.threads.modify', { ...input }, 'completed');
|
|
69
73
|
return result;
|
|
@@ -88,7 +92,7 @@ export const trash = async (ctx, input) => {
|
|
|
88
92
|
});
|
|
89
93
|
if (result.id) {
|
|
90
94
|
const endpoints = ctx.endpoints;
|
|
91
|
-
await endpoints.
|
|
95
|
+
await endpoints.threads.get({ id: result.id, userId: input.userId });
|
|
92
96
|
}
|
|
93
97
|
await logEventFromContext(ctx, 'gmail.threads.trash', { ...input }, 'completed');
|
|
94
98
|
return result;
|
|
@@ -99,7 +103,7 @@ export const untrash = async (ctx, input) => {
|
|
|
99
103
|
});
|
|
100
104
|
if (result.id) {
|
|
101
105
|
const endpoints = ctx.endpoints;
|
|
102
|
-
await endpoints.
|
|
106
|
+
await endpoints.threads.get({ id: result.id, userId: input.userId });
|
|
103
107
|
}
|
|
104
108
|
await logEventFromContext(ctx, 'gmail.threads.untrash', { ...input }, 'completed');
|
|
105
109
|
return result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BindEndpoints, BindWebhooks, CorsairEndpoint, CorsairPlugin, CorsairPluginContext, CorsairWebhook, KeyBuilderContext } from '../../core';
|
|
2
2
|
import type { AuthTypes, PickAuth } from '../../core/constants';
|
|
3
3
|
import type { GmailEndpointOutputs } from './endpoints';
|
|
4
|
-
import { GmailSchema } from './schema';
|
|
4
|
+
import { GmailCredentials, GmailSchema } from './schema';
|
|
5
5
|
import type { GmailWebhookOutputs, GmailWebhookPayload, MessageDeletedEvent, MessageLabelChangedEvent, MessageReceivedEvent } from './webhooks';
|
|
6
6
|
export type GmailContext = CorsairPluginContext<typeof GmailSchema, GmailPluginOptions>;
|
|
7
7
|
type GmailEndpoint<K extends keyof GmailEndpointOutputs, Input> = CorsairEndpoint<GmailContext, Input, GmailEndpointOutputs[K]>;
|
|
@@ -163,14 +163,14 @@ export type GmailEndpoints = {
|
|
|
163
163
|
userId?: string;
|
|
164
164
|
}>;
|
|
165
165
|
};
|
|
166
|
-
export type GmailBoundEndpoints = BindEndpoints<
|
|
166
|
+
export type GmailBoundEndpoints = BindEndpoints<typeof gmailEndpointsNested>;
|
|
167
167
|
type GmailWebhook<K extends keyof GmailWebhookOutputs, TEvent> = CorsairWebhook<GmailContext, GmailWebhookPayload, GmailWebhookOutputs[K]>;
|
|
168
168
|
export type GmailWebhooks = {
|
|
169
169
|
messageReceived: GmailWebhook<'messageReceived', MessageReceivedEvent>;
|
|
170
170
|
messageDeleted: GmailWebhook<'messageDeleted', MessageDeletedEvent>;
|
|
171
171
|
messageLabelChanged: GmailWebhook<'messageLabelChanged', MessageLabelChangedEvent>;
|
|
172
172
|
};
|
|
173
|
-
export type GmailBoundWebhooks = BindWebhooks<
|
|
173
|
+
export type GmailBoundWebhooks = BindWebhooks<typeof gmailWebhooksNested>;
|
|
174
174
|
declare const gmailEndpointsNested: {
|
|
175
175
|
readonly messages: {
|
|
176
176
|
readonly list: GmailEndpoint<"messagesList", {
|
|
@@ -342,6 +342,7 @@ declare const gmailWebhooksNested: {
|
|
|
342
342
|
export type GmailPluginOptions = {
|
|
343
343
|
authType?: PickAuth<'oauth_2'>;
|
|
344
344
|
key?: string;
|
|
345
|
+
credentials?: GmailCredentials;
|
|
345
346
|
hooks?: InternalGmailPlugin['hooks'];
|
|
346
347
|
webhookHooks?: InternalGmailPlugin['webhookHooks'];
|
|
347
348
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugins/gmail/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAOxD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugins/gmail/index.ts"],"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WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,YAAY,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAE3E,QAAA,MAAM,eAAe,EAAE,SAAqB,CAAC;AAE7C,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,kBAAkB,IAAI,aAAa,CACxE,OAAO,EACP,OAAO,WAAW,EAClB,OAAO,oBAAoB,EAC3B,OAAO,mBAAmB,EAC1B,CAAC,EACD,OAAO,eAAe,CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;AAEtE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,kBAAkB,IAC3D,eAAe,CAAC,CAAC,CAAC,CAAC;AAEpB,wBAAgB,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,kBAAkB,EACvD,eAAe,GAAE,kBAAkB,GAAG,CAAgC,GACpE,mBAAmB,CAAC,CAAC,CAAC,CAqDxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getValidAccessToken } from './client';
|
|
2
2
|
import { DraftsEndpoints, LabelsEndpoints, MessagesEndpoints, ThreadsEndpoints, } from './endpoints';
|
|
3
|
-
import { GmailSchema } from './schema';
|
|
3
|
+
import { GmailCredentials, GmailSchema } from './schema';
|
|
4
4
|
import { MessageWebhooks } from './webhooks';
|
|
5
5
|
const gmailEndpointsNested = {
|
|
6
6
|
messages: {
|
|
@@ -3,11 +3,13 @@ import { createCorsairOrm } from '../../db/orm';
|
|
|
3
3
|
import { createIntegrationAndAccount } from '../../tests/plugins-test-utils';
|
|
4
4
|
import { createTestDatabase } from '../../tests/setup-db';
|
|
5
5
|
import { gmail } from './index';
|
|
6
|
+
import dotenv from 'dotenv';
|
|
7
|
+
dotenv.config();
|
|
6
8
|
async function createGmailClient() {
|
|
7
|
-
const clientId = process.env.
|
|
8
|
-
const clientSecret = process.env.
|
|
9
|
-
const accessToken = process.env.
|
|
10
|
-
const refreshToken = process.env.
|
|
9
|
+
const clientId = process.env.GOOGLE_CLIENT_ID;
|
|
10
|
+
const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
|
|
11
|
+
const accessToken = process.env.GOOGLE_ACCESS_TOKEN;
|
|
12
|
+
const refreshToken = process.env.GOOGLE_REFRESH_TOKEN;
|
|
11
13
|
if (!clientId || !clientSecret || !accessToken || !refreshToken) {
|
|
12
14
|
return null;
|
|
13
15
|
}
|
|
@@ -17,17 +19,17 @@ async function createGmailClient() {
|
|
|
17
19
|
plugins: [
|
|
18
20
|
gmail({
|
|
19
21
|
authType: 'oauth_2',
|
|
20
|
-
credentials: {
|
|
21
|
-
clientId,
|
|
22
|
-
clientSecret,
|
|
23
|
-
accessToken,
|
|
24
|
-
refreshToken,
|
|
25
|
-
},
|
|
26
22
|
}),
|
|
27
23
|
],
|
|
28
24
|
database: testDb.db,
|
|
29
25
|
kek: process.env.CORSAIR_KEK,
|
|
30
26
|
});
|
|
27
|
+
await corsair.keys.gmail.issueNewDEK();
|
|
28
|
+
await corsair.keys.gmail.setClientId(clientId);
|
|
29
|
+
await corsair.keys.gmail.setClientSecret(clientSecret);
|
|
30
|
+
await corsair.gmail.keys.issueNewDEK();
|
|
31
|
+
await corsair.gmail.keys.setAccessToken(accessToken);
|
|
32
|
+
await corsair.gmail.keys.setRefreshToken(refreshToken);
|
|
31
33
|
return { corsair, testDb };
|
|
32
34
|
}
|
|
33
35
|
describe('Gmail plugin integration', () => {
|
|
@@ -62,8 +64,12 @@ describe('Gmail plugin integration', () => {
|
|
|
62
64
|
await corsair.gmail.api.messages.modify({
|
|
63
65
|
userId: 'me',
|
|
64
66
|
id,
|
|
65
|
-
addLabelIds: [],
|
|
66
|
-
|
|
67
|
+
addLabelIds: ['STARRED'],
|
|
68
|
+
});
|
|
69
|
+
await corsair.gmail.api.messages.modify({
|
|
70
|
+
userId: 'me',
|
|
71
|
+
id,
|
|
72
|
+
removeLabelIds: ['STARRED'],
|
|
67
73
|
});
|
|
68
74
|
const modifyEvents = await orm.events.findMany({
|
|
69
75
|
where: { event_type: 'gmail.messages.modify' },
|