corsair 0.1.9 → 0.1.11
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/constants.d.ts +2 -2
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/plugins/discord/client.d.ts +10 -0
- package/dist/plugins/discord/client.d.ts.map +1 -0
- package/dist/plugins/discord/client.js +42 -0
- package/dist/plugins/discord/endpoints/channels.d.ts +3 -0
- package/dist/plugins/discord/endpoints/channels.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/channels.js +19 -0
- package/dist/plugins/discord/endpoints/guilds.d.ts +4 -0
- package/dist/plugins/discord/endpoints/guilds.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/guilds.js +25 -0
- package/dist/plugins/discord/endpoints/index.d.ts +9 -0
- package/dist/plugins/discord/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/index.js +8 -0
- package/dist/plugins/discord/endpoints/members.d.ts +4 -0
- package/dist/plugins/discord/endpoints/members.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/members.js +55 -0
- package/dist/plugins/discord/endpoints/messages.d.ts +8 -0
- package/dist/plugins/discord/endpoints/messages.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/messages.js +97 -0
- package/dist/plugins/discord/endpoints/reactions.d.ts +5 -0
- package/dist/plugins/discord/endpoints/reactions.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/reactions.js +23 -0
- package/dist/plugins/discord/endpoints/threads.d.ts +4 -0
- package/dist/plugins/discord/endpoints/threads.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/threads.js +37 -0
- package/dist/plugins/discord/endpoints/types.d.ts +266 -0
- package/dist/plugins/discord/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/discord/endpoints/types.js +2 -0
- package/dist/plugins/discord/error-handlers.d.ts +77 -0
- package/dist/plugins/discord/error-handlers.d.ts.map +1 -0
- package/dist/plugins/discord/error-handlers.js +134 -0
- package/dist/plugins/discord/index.d.ts +109 -0
- package/dist/plugins/discord/index.d.ts.map +1 -0
- package/dist/plugins/discord/index.js +117 -0
- package/dist/plugins/discord/schema/database.d.ts +148 -0
- package/dist/plugins/discord/schema/database.d.ts.map +1 -0
- package/dist/plugins/discord/schema/database.js +51 -0
- package/dist/plugins/discord/schema/index.d.ts +148 -0
- package/dist/plugins/discord/schema/index.d.ts.map +1 -0
- package/dist/plugins/discord/schema/index.js +10 -0
- package/dist/plugins/discord/webhooks/index.d.ts +24 -0
- package/dist/plugins/discord/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/discord/webhooks/index.js +8 -0
- package/dist/plugins/discord/webhooks/interactions.d.ts +6 -0
- package/dist/plugins/discord/webhooks/interactions.d.ts.map +1 -0
- package/dist/plugins/discord/webhooks/interactions.js +108 -0
- package/dist/plugins/discord/webhooks/types.d.ts +119 -0
- package/dist/plugins/discord/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/discord/webhooks/types.js +98 -0
- package/dist/plugins/github/endpoints/index.d.ts +572 -572
- package/dist/plugins/github/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/github/endpoints/types.d.ts +1903 -1322
- package/dist/plugins/github/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/github/endpoints/types.js +249 -0
- package/dist/plugins/github/index.d.ts +46 -392
- package/dist/plugins/github/index.d.ts.map +1 -1
- package/dist/plugins/github/schema/database.d.ts +117 -117
- package/dist/plugins/github/schema/index.d.ts +117 -117
- package/dist/plugins/gmail/client.d.ts.map +1 -1
- package/dist/plugins/gmail/client.js +2 -7
- package/dist/plugins/gmail/endpoints/index.d.ts +73 -73
- package/dist/plugins/gmail/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/gmail/endpoints/types.d.ts +686 -183
- package/dist/plugins/gmail/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/gmail/endpoints/types.js +213 -1
- package/dist/plugins/gmail/index.d.ts +61 -324
- package/dist/plugins/gmail/index.d.ts.map +1 -1
- package/dist/plugins/gmail/index.js +19 -7
- package/dist/plugins/gmail/schema/database.d.ts +4 -4
- package/dist/plugins/gmail/schema/index.d.ts +4 -4
- package/dist/plugins/gmail/webhooks/index.d.ts +2 -10
- package/dist/plugins/gmail/webhooks/index.d.ts.map +1 -1
- package/dist/plugins/gmail/webhooks/index.js +2 -4
- package/dist/plugins/gmail/webhooks/messages.d.ts +1 -3
- package/dist/plugins/gmail/webhooks/messages.d.ts.map +1 -1
- package/dist/plugins/gmail/webhooks/messages.js +229 -338
- package/dist/plugins/gmail/webhooks/types.d.ts +6 -8
- package/dist/plugins/gmail/webhooks/types.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/client.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/client.js +2 -7
- package/dist/plugins/googlecalendar/endpoints/events.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/endpoints/events.js +1 -14
- package/dist/plugins/googlecalendar/endpoints/index.d.ts +38 -38
- package/dist/plugins/googlecalendar/endpoints/types.d.ts +268 -103
- package/dist/plugins/googlecalendar/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/endpoints/types.js +66 -0
- package/dist/plugins/googlecalendar/index.d.ts +22 -131
- package/dist/plugins/googlecalendar/index.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/index.js +19 -8
- package/dist/plugins/googlecalendar/schema/database.d.ts +24 -24
- package/dist/plugins/googlecalendar/schema/index.d.ts +24 -24
- package/dist/plugins/googlecalendar/setup.d.ts +9 -0
- package/dist/plugins/googlecalendar/setup.d.ts.map +1 -0
- package/dist/plugins/googlecalendar/setup.js +280 -0
- package/dist/plugins/googlecalendar/webhooks/events.d.ts +1 -5
- package/dist/plugins/googlecalendar/webhooks/events.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/webhooks/events.js +95 -269
- package/dist/plugins/googlecalendar/webhooks/index.d.ts +2 -18
- package/dist/plugins/googlecalendar/webhooks/index.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/webhooks/index.js +2 -6
- package/dist/plugins/googlecalendar/webhooks/types.d.ts +7 -26
- package/dist/plugins/googlecalendar/webhooks/types.d.ts.map +1 -1
- package/dist/plugins/googlecalendar/webhooks/types.js +3 -18
- package/dist/plugins/googledrive/client.d.ts.map +1 -1
- package/dist/plugins/googledrive/client.js +2 -7
- package/dist/plugins/googledrive/endpoints/files.d.ts.map +1 -1
- package/dist/plugins/googledrive/endpoints/files.js +5 -40
- package/dist/plugins/googledrive/endpoints/index.d.ts +120 -120
- package/dist/plugins/googledrive/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/googledrive/endpoints/types.d.ts +610 -78
- package/dist/plugins/googledrive/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/googledrive/endpoints/types.js +229 -1
- package/dist/plugins/googledrive/index.d.ts +52 -378
- package/dist/plugins/googledrive/index.d.ts.map +1 -1
- package/dist/plugins/googledrive/index.js +19 -5
- package/dist/plugins/googledrive/schema/database.d.ts +24 -18
- package/dist/plugins/googledrive/schema/database.d.ts.map +1 -1
- package/dist/plugins/googledrive/schema/database.js +2 -0
- package/dist/plugins/googledrive/schema/index.d.ts +24 -18
- package/dist/plugins/googledrive/schema/index.d.ts.map +1 -1
- package/dist/plugins/googledrive/webhooks/changes.d.ts +1 -2
- package/dist/plugins/googledrive/webhooks/changes.d.ts.map +1 -1
- package/dist/plugins/googledrive/webhooks/changes.js +212 -170
- package/dist/plugins/googledrive/webhooks/index.d.ts +2 -6
- package/dist/plugins/googledrive/webhooks/index.d.ts.map +1 -1
- package/dist/plugins/googledrive/webhooks/index.js +2 -3
- package/dist/plugins/googledrive/webhooks/types.d.ts +27 -19
- package/dist/plugins/googledrive/webhooks/types.d.ts.map +1 -1
- package/dist/plugins/googlesheets/client.d.ts.map +1 -1
- package/dist/plugins/googlesheets/client.js +2 -7
- package/dist/plugins/googlesheets/endpoints/index.d.ts +30 -30
- package/dist/plugins/googlesheets/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/googlesheets/endpoints/sheets.d.ts.map +1 -1
- package/dist/plugins/googlesheets/endpoints/sheets.js +157 -0
- package/dist/plugins/googlesheets/endpoints/types.d.ts +179 -0
- package/dist/plugins/googlesheets/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/googlesheets/endpoints/types.js +86 -0
- package/dist/plugins/googlesheets/index.d.ts +30 -138
- package/dist/plugins/googlesheets/index.d.ts.map +1 -1
- package/dist/plugins/googlesheets/index.js +8 -8
- package/dist/plugins/googlesheets/schema/database.d.ts +6 -6
- package/dist/plugins/googlesheets/schema/index.d.ts +6 -6
- package/dist/plugins/googlesheets/webhooks/index.d.ts +2 -10
- package/dist/plugins/googlesheets/webhooks/index.d.ts.map +1 -1
- package/dist/plugins/googlesheets/webhooks/index.js +2 -4
- package/dist/plugins/googlesheets/webhooks/rows.d.ts +1 -3
- package/dist/plugins/googlesheets/webhooks/rows.d.ts.map +1 -1
- package/dist/plugins/googlesheets/webhooks/rows.js +7 -92
- package/dist/plugins/googlesheets/webhooks/types.d.ts +11 -30
- package/dist/plugins/googlesheets/webhooks/types.d.ts.map +1 -1
- package/dist/plugins/googlesheets/webhooks/types.js +1 -2
- package/dist/plugins/hubspot/endpoints/index.d.ts +1398 -177
- package/dist/plugins/hubspot/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/hubspot/endpoints/types.d.ts +4633 -195
- package/dist/plugins/hubspot/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/hubspot/endpoints/types.js +302 -5
- package/dist/plugins/hubspot/index.d.ts +75 -447
- package/dist/plugins/hubspot/index.d.ts.map +1 -1
- package/dist/plugins/hubspot/schema/database.d.ts +6 -6
- package/dist/plugins/hubspot/schema/index.d.ts +6 -6
- package/dist/plugins/hubspot/webhooks/index.d.ts +12 -12
- package/dist/plugins/hubspot/webhooks/types.d.ts +2 -1
- package/dist/plugins/hubspot/webhooks/types.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +4 -1
- package/dist/plugins/linear/endpoints/comments.d.ts.map +1 -1
- package/dist/plugins/linear/endpoints/index.d.ts +237 -237
- package/dist/plugins/linear/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/linear/endpoints/projects.d.ts.map +1 -1
- package/dist/plugins/linear/endpoints/types.d.ts +1102 -759
- package/dist/plugins/linear/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/linear/endpoints/types.js +135 -7
- package/dist/plugins/linear/index.d.ts +57 -237
- package/dist/plugins/linear/index.d.ts.map +1 -1
- package/dist/plugins/linear/schema/database.d.ts +16 -16
- package/dist/plugins/linear/schema/index.d.ts +16 -16
- package/dist/plugins/linear/webhooks/index.d.ts +9 -9
- package/dist/plugins/linear/webhooks/types.d.ts +1 -0
- package/dist/plugins/linear/webhooks/types.d.ts.map +1 -1
- package/dist/plugins/posthog/endpoints/index.d.ts +12 -12
- package/dist/plugins/posthog/endpoints/types.d.ts +82 -0
- package/dist/plugins/posthog/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/posthog/endpoints/types.js +36 -0
- package/dist/plugins/posthog/index.d.ts +14 -62
- package/dist/plugins/posthog/index.d.ts.map +1 -1
- package/dist/plugins/posthog/schema/database.d.ts +2 -2
- package/dist/plugins/posthog/schema/index.d.ts +2 -2
- package/dist/plugins/resend/endpoints/index.d.ts +18 -18
- package/dist/plugins/resend/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/resend/endpoints/types.d.ts +135 -0
- package/dist/plugins/resend/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/resend/endpoints/types.js +62 -0
- package/dist/plugins/resend/index.d.ts +20 -92
- package/dist/plugins/resend/index.d.ts.map +1 -1
- package/dist/plugins/slack/endpoints/index.d.ts +227 -233
- package/dist/plugins/slack/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/slack/endpoints/types.d.ts +943 -476
- package/dist/plugins/slack/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/slack/endpoints/types.js +323 -0
- package/dist/plugins/slack/index.d.ts +89 -551
- package/dist/plugins/slack/index.d.ts.map +1 -1
- package/dist/plugins/slack/schema/database.d.ts +50 -50
- package/dist/plugins/slack/schema/index.d.ts +50 -50
- package/dist/plugins/tavily/client.d.ts +14 -0
- package/dist/plugins/tavily/client.d.ts.map +1 -0
- package/dist/plugins/tavily/client.js +47 -0
- package/dist/plugins/tavily/endpoints/index.d.ts +45 -0
- package/dist/plugins/tavily/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/tavily/endpoints/index.js +5 -0
- package/dist/plugins/tavily/endpoints/search.d.ts +3 -0
- package/dist/plugins/tavily/endpoints/search.d.ts.map +1 -0
- package/dist/plugins/tavily/endpoints/search.js +11 -0
- package/dist/plugins/tavily/endpoints/types.d.ts +226 -0
- package/dist/plugins/tavily/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/tavily/endpoints/types.js +98 -0
- package/dist/plugins/tavily/error-handlers.d.ts +77 -0
- package/dist/plugins/tavily/error-handlers.d.ts.map +1 -0
- package/dist/plugins/tavily/error-handlers.js +134 -0
- package/dist/plugins/tavily/index.d.ts +116 -0
- package/dist/plugins/tavily/index.d.ts.map +1 -0
- package/dist/plugins/tavily/index.js +158 -0
- package/dist/plugins/tavily/schema/database.d.ts +1 -0
- package/dist/plugins/tavily/schema/database.d.ts.map +1 -0
- package/dist/plugins/tavily/schema/database.js +10 -0
- package/dist/plugins/tavily/schema/index.d.ts +5 -0
- package/dist/plugins/tavily/schema/index.d.ts.map +1 -0
- package/dist/plugins/tavily/schema/index.js +14 -0
- package/dist/templates/plugin/generate.js +30 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/index.js +29 -1
- package/package.json +11 -1
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 ["discord", "github", "gmail", "googlecalendar", "googledrive", "googlesheets", "hubspot", "linear", "posthog", "resend", "slack"];
|
|
3
|
-
export type AllProviders = 'discord' | 'github' | 'gmail' | 'googlecalendar' | 'googledrive' | 'googlesheets' | 'hubspot' | 'linear' | 'posthog' | 'resend' | 'slack' | (string & {});
|
|
2
|
+
export declare const BaseProviders: readonly ["discord", "github", "gmail", "googlecalendar", "googledrive", "googlesheets", "hubspot", "linear", "posthog", "resend", "slack", "tavily"];
|
|
3
|
+
export type AllProviders = 'discord' | 'github' | 'gmail' | 'googlecalendar' | 'googledrive' | 'googlesheets' | 'hubspot' | 'linear' | 'posthog' | 'resend' | 'slack' | 'tavily' | (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,uJAahB,CAAC;AAEX,MAAM,MAAM,YAAY,GACrB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,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
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { createCorsair } from './core';
|
|
2
2
|
export { processWebhook } from './webhooks';
|
|
3
|
+
export { discord } from './plugins/discord';
|
|
3
4
|
export { github } from './plugins/github';
|
|
4
5
|
export { gmail } from './plugins/gmail';
|
|
5
6
|
export { googlecalendar } from './plugins/googlecalendar';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { createCorsair } from './core';
|
|
3
3
|
export { processWebhook } from './webhooks';
|
|
4
4
|
// plugin function exports
|
|
5
|
+
export { discord } from './plugins/discord';
|
|
5
6
|
export { github } from './plugins/github';
|
|
6
7
|
export { gmail } from './plugins/gmail';
|
|
7
8
|
export { googlecalendar } from './plugins/googlecalendar';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class DiscordAPIError extends Error {
|
|
2
|
+
readonly code?: string | undefined;
|
|
3
|
+
constructor(message: string, code?: string | undefined);
|
|
4
|
+
}
|
|
5
|
+
export declare function makeDiscordRequest<T>(endpoint: string, botToken: string, options?: {
|
|
6
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
7
|
+
body?: Record<string, unknown>;
|
|
8
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
9
|
+
}): Promise<T>;
|
|
10
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../plugins/discord/client.ts"],"names":[],"mappings":"AAIA,qBAAa,eAAgB,SAAQ,KAAK;aAGxB,IAAI,CAAC,EAAE,MAAM;gBAD7B,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA;CAK9B;AAID,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IACR,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CACzD,GACJ,OAAO,CAAC,CAAC,CAAC,CAkCZ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { request } from '../../async-core/request';
|
|
2
|
+
export class DiscordAPIError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(message, code) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = 'DiscordAPIError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const DISCORD_API_BASE = 'https://discord.com/api/v10';
|
|
11
|
+
export async function makeDiscordRequest(endpoint, botToken, options = {}) {
|
|
12
|
+
const { method = 'GET', body, query } = options;
|
|
13
|
+
const config = {
|
|
14
|
+
BASE: DISCORD_API_BASE,
|
|
15
|
+
VERSION: '1.0.0',
|
|
16
|
+
WITH_CREDENTIALS: false,
|
|
17
|
+
CREDENTIALS: 'omit',
|
|
18
|
+
HEADERS: {
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
Authorization: `Bot ${botToken}`,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const requestOptions = {
|
|
24
|
+
method,
|
|
25
|
+
url: endpoint,
|
|
26
|
+
body: method === 'POST' || method === 'PUT' || method === 'PATCH'
|
|
27
|
+
? body
|
|
28
|
+
: undefined,
|
|
29
|
+
mediaType: 'application/json; charset=utf-8',
|
|
30
|
+
query: method === 'GET' ? query : undefined,
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
const response = await request(config, requestOptions);
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof Error) {
|
|
38
|
+
throw new DiscordAPIError(error.message);
|
|
39
|
+
}
|
|
40
|
+
throw new DiscordAPIError('Unknown error');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../../../plugins/discord/endpoints/channels.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAI3C,eAAO,MAAM,IAAI,EAAE,gBAAgB,CAAC,cAAc,CAwBjD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { logEventFromContext } from '../../utils/events';
|
|
2
|
+
import { makeDiscordRequest } from '../client';
|
|
3
|
+
export const list = async (ctx, input) => {
|
|
4
|
+
const result = await makeDiscordRequest(`guilds/${input.guild_id}/channels`, ctx.key);
|
|
5
|
+
if (ctx.db.channels) {
|
|
6
|
+
try {
|
|
7
|
+
for (const channel of result) {
|
|
8
|
+
await ctx.db.channels.upsertByEntityId(channel.id, {
|
|
9
|
+
...channel,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.warn('Failed to save channels to database:', error);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
await logEventFromContext(ctx, 'discord.channels.list', { guild_id: input.guild_id }, 'completed');
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guilds.d.ts","sourceRoot":"","sources":["../../../../plugins/discord/endpoints/guilds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAI3C,eAAO,MAAM,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAS/C,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,WAAW,CA4B7C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { logEventFromContext } from '../../utils/events';
|
|
2
|
+
import { makeDiscordRequest } from '../client';
|
|
3
|
+
export const list = async (ctx, input) => {
|
|
4
|
+
const result = await makeDiscordRequest('users/@me/guilds', ctx.key, { query: input });
|
|
5
|
+
await logEventFromContext(ctx, 'discord.guilds.list', {}, 'completed');
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
export const get = async (ctx, input) => {
|
|
9
|
+
const { guild_id, ...query } = input;
|
|
10
|
+
const result = await makeDiscordRequest(`guilds/${guild_id}`, ctx.key, { query });
|
|
11
|
+
if (ctx.db.guilds) {
|
|
12
|
+
try {
|
|
13
|
+
await ctx.db.guilds.upsertByEntityId(result.id, {
|
|
14
|
+
...result,
|
|
15
|
+
approximate_member_count: result.approximate_member_count,
|
|
16
|
+
approximate_presence_count: result.approximate_presence_count,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.warn('Failed to save guild to database:', error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
await logEventFromContext(ctx, 'discord.guilds.get', { guild_id }, 'completed');
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Channels from './channels';
|
|
2
|
+
import * as Guilds from './guilds';
|
|
3
|
+
import * as Members from './members';
|
|
4
|
+
import * as Messages from './messages';
|
|
5
|
+
import * as Reactions from './reactions';
|
|
6
|
+
import * as Threads from './threads';
|
|
7
|
+
export { Channels, Guilds, Members, Messages, Reactions, Threads };
|
|
8
|
+
export * from './types';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugins/discord/endpoints/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACnE,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Channels from './channels';
|
|
2
|
+
import * as Guilds from './guilds';
|
|
3
|
+
import * as Members from './members';
|
|
4
|
+
import * as Messages from './messages';
|
|
5
|
+
import * as Reactions from './reactions';
|
|
6
|
+
import * as Threads from './threads';
|
|
7
|
+
export { Channels, Guilds, Members, Messages, Reactions, Threads };
|
|
8
|
+
export * from './types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../../../../plugins/discord/endpoints/members.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAI3C,eAAO,MAAM,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAqChD,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,YAAY,CAiC9C,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { logEventFromContext } from '../../utils/events';
|
|
2
|
+
import { makeDiscordRequest } from '../client';
|
|
3
|
+
export const list = async (ctx, input) => {
|
|
4
|
+
const { guild_id, ...query } = input;
|
|
5
|
+
const result = await makeDiscordRequest(`guilds/${guild_id}/members`, ctx.key, { query });
|
|
6
|
+
if (ctx.db.members) {
|
|
7
|
+
try {
|
|
8
|
+
for (const member of result) {
|
|
9
|
+
const userId = member.user?.id;
|
|
10
|
+
if (userId) {
|
|
11
|
+
await ctx.db.members.upsertByEntityId(userId, {
|
|
12
|
+
id: userId,
|
|
13
|
+
guild_id,
|
|
14
|
+
nick: member.nick,
|
|
15
|
+
roles: member.roles,
|
|
16
|
+
joined_at: member.joined_at,
|
|
17
|
+
premium_since: member.premium_since,
|
|
18
|
+
deaf: member.deaf,
|
|
19
|
+
mute: member.mute,
|
|
20
|
+
pending: member.pending,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.warn('Failed to save members to database:', error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
await logEventFromContext(ctx, 'discord.members.list', { guild_id }, 'completed');
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
export const get = async (ctx, input) => {
|
|
33
|
+
const { guild_id, user_id } = input;
|
|
34
|
+
const result = await makeDiscordRequest(`guilds/${guild_id}/members/${user_id}`, ctx.key);
|
|
35
|
+
if (ctx.db.members) {
|
|
36
|
+
try {
|
|
37
|
+
await ctx.db.members.upsertByEntityId(user_id, {
|
|
38
|
+
id: user_id,
|
|
39
|
+
guild_id,
|
|
40
|
+
nick: result.nick,
|
|
41
|
+
roles: result.roles,
|
|
42
|
+
joined_at: result.joined_at,
|
|
43
|
+
premium_since: result.premium_since,
|
|
44
|
+
deaf: result.deaf,
|
|
45
|
+
mute: result.mute,
|
|
46
|
+
pending: result.pending,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.warn('Failed to save member to database:', error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
await logEventFromContext(ctx, 'discord.members.get', { guild_id, user_id }, 'completed');
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DiscordEndpoints } from '..';
|
|
2
|
+
export declare const send: DiscordEndpoints['messagesSend'];
|
|
3
|
+
export declare const reply: DiscordEndpoints['messagesReply'];
|
|
4
|
+
export declare const get: DiscordEndpoints['messagesGet'];
|
|
5
|
+
export declare const list: DiscordEndpoints['messagesList'];
|
|
6
|
+
export declare const edit: DiscordEndpoints['messagesEdit'];
|
|
7
|
+
export declare const del: DiscordEndpoints['messagesDelete'];
|
|
8
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../plugins/discord/endpoints/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAI3C,eAAO,MAAM,IAAI,EAAE,gBAAgB,CAAC,cAAc,CA2BjD,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,gBAAgB,CAAC,eAAe,CAsCnD,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,aAAa,CAY/C,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,gBAAgB,CAAC,cAAc,CAcjD,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,gBAAgB,CAAC,cAAc,CA8BjD,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,gBAAgB,CAsBlD,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { logEventFromContext } from '../../utils/events';
|
|
2
|
+
import { makeDiscordRequest } from '../client';
|
|
3
|
+
export const send = async (ctx, input) => {
|
|
4
|
+
const { channel_id, ...body } = input;
|
|
5
|
+
const result = await makeDiscordRequest(`channels/${channel_id}/messages`, ctx.key, { method: 'POST', body });
|
|
6
|
+
if (ctx.db.messages) {
|
|
7
|
+
try {
|
|
8
|
+
await ctx.db.messages.upsertByEntityId(result.id, {
|
|
9
|
+
...result,
|
|
10
|
+
channel_id: result.channel_id,
|
|
11
|
+
authorId: result.author.id,
|
|
12
|
+
createdAt: new Date(result.timestamp),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.warn('Failed to save message to database:', error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
await logEventFromContext(ctx, 'discord.messages.send', { channel_id, ...body }, 'completed');
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
export const reply = async (ctx, input) => {
|
|
23
|
+
const { channel_id, message_id, fail_if_not_exists = true, ...rest } = input;
|
|
24
|
+
const result = await makeDiscordRequest(`channels/${channel_id}/messages`, ctx.key, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: {
|
|
27
|
+
...rest,
|
|
28
|
+
message_reference: {
|
|
29
|
+
type: 0,
|
|
30
|
+
message_id,
|
|
31
|
+
channel_id,
|
|
32
|
+
fail_if_not_exists,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
if (ctx.db.messages) {
|
|
37
|
+
try {
|
|
38
|
+
await ctx.db.messages.upsertByEntityId(result.id, {
|
|
39
|
+
...result,
|
|
40
|
+
channel_id: result.channel_id,
|
|
41
|
+
authorId: result.author.id,
|
|
42
|
+
createdAt: new Date(result.timestamp),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.warn('Failed to save reply to database:', error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await logEventFromContext(ctx, 'discord.messages.reply', { channel_id, message_id }, 'completed');
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
export const get = async (ctx, input) => {
|
|
53
|
+
const result = await makeDiscordRequest(`channels/${input.channel_id}/messages/${input.message_id}`, ctx.key);
|
|
54
|
+
await logEventFromContext(ctx, 'discord.messages.get', { ...input }, 'completed');
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
export const list = async (ctx, input) => {
|
|
58
|
+
const { channel_id, ...query } = input;
|
|
59
|
+
const result = await makeDiscordRequest(`channels/${channel_id}/messages`, ctx.key, { query });
|
|
60
|
+
await logEventFromContext(ctx, 'discord.messages.list', { channel_id }, 'completed');
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
export const edit = async (ctx, input) => {
|
|
64
|
+
const { channel_id, message_id, ...body } = input;
|
|
65
|
+
const result = await makeDiscordRequest(`channels/${channel_id}/messages/${message_id}`, ctx.key, {
|
|
66
|
+
method: 'PATCH',
|
|
67
|
+
body,
|
|
68
|
+
});
|
|
69
|
+
if (ctx.db.messages) {
|
|
70
|
+
try {
|
|
71
|
+
await ctx.db.messages.upsertByEntityId(result.id, {
|
|
72
|
+
...result,
|
|
73
|
+
channel_id: result.channel_id,
|
|
74
|
+
authorId: result.author.id,
|
|
75
|
+
createdAt: new Date(result.timestamp),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.warn('Failed to update message in database:', error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
await logEventFromContext(ctx, 'discord.messages.edit', { channel_id, message_id }, 'completed');
|
|
83
|
+
return result;
|
|
84
|
+
};
|
|
85
|
+
export const del = async (ctx, input) => {
|
|
86
|
+
await makeDiscordRequest(`channels/${input.channel_id}/messages/${input.message_id}`, ctx.key, { method: 'DELETE' });
|
|
87
|
+
if (ctx.db.messages) {
|
|
88
|
+
try {
|
|
89
|
+
await ctx.db.messages.deleteByEntityId(input.message_id);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.warn('Failed to delete message from database:', error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
await logEventFromContext(ctx, 'discord.messages.delete', { ...input }, 'completed');
|
|
96
|
+
return { success: true };
|
|
97
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DiscordEndpoints } from '..';
|
|
2
|
+
export declare const add: DiscordEndpoints['reactionsAdd'];
|
|
3
|
+
export declare const remove: DiscordEndpoints['reactionsRemove'];
|
|
4
|
+
export declare const list: DiscordEndpoints['reactionsList'];
|
|
5
|
+
//# sourceMappingURL=reactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactions.d.ts","sourceRoot":"","sources":["../../../../plugins/discord/endpoints/reactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAI3C,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,cAAc,CAiBhD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,iBAAiB,CAoBtD,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,gBAAgB,CAAC,eAAe,CAmBlD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { logEventFromContext } from '../../utils/events';
|
|
2
|
+
import { makeDiscordRequest } from '../client';
|
|
3
|
+
export const add = async (ctx, input) => {
|
|
4
|
+
const { channel_id, message_id, emoji } = input;
|
|
5
|
+
const encodedEmoji = encodeURIComponent(emoji);
|
|
6
|
+
await makeDiscordRequest(`channels/${channel_id}/messages/${message_id}/reactions/${encodedEmoji}/@me`, ctx.key, { method: 'PUT' });
|
|
7
|
+
await logEventFromContext(ctx, 'discord.reactions.add', { channel_id, message_id, emoji }, 'completed');
|
|
8
|
+
return { success: true };
|
|
9
|
+
};
|
|
10
|
+
export const remove = async (ctx, input) => {
|
|
11
|
+
const { channel_id, message_id, emoji } = input;
|
|
12
|
+
const encodedEmoji = encodeURIComponent(emoji);
|
|
13
|
+
await makeDiscordRequest(`channels/${channel_id}/messages/${message_id}/reactions/${encodedEmoji}/@me`, ctx.key, { method: 'DELETE' });
|
|
14
|
+
await logEventFromContext(ctx, 'discord.reactions.remove', { channel_id, message_id, emoji }, 'completed');
|
|
15
|
+
return { success: true };
|
|
16
|
+
};
|
|
17
|
+
export const list = async (ctx, input) => {
|
|
18
|
+
const { channel_id, message_id, emoji, ...query } = input;
|
|
19
|
+
const encodedEmoji = encodeURIComponent(emoji);
|
|
20
|
+
const result = await makeDiscordRequest(`channels/${channel_id}/messages/${message_id}/reactions/${encodedEmoji}`, ctx.key, { query });
|
|
21
|
+
await logEventFromContext(ctx, 'discord.reactions.list', { channel_id, message_id, emoji }, 'completed');
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../../plugins/discord/endpoints/threads.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAI3C,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,eAAe,CAwBpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,0BAA0B,CA4BzE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { logEventFromContext } from '../../utils/events';
|
|
2
|
+
import { makeDiscordRequest } from '../client';
|
|
3
|
+
export const create = async (ctx, input) => {
|
|
4
|
+
const { channel_id, ...body } = input;
|
|
5
|
+
const result = await makeDiscordRequest(`channels/${channel_id}/threads`, ctx.key, { method: 'POST', body });
|
|
6
|
+
if (ctx.db.channels) {
|
|
7
|
+
try {
|
|
8
|
+
await ctx.db.channels.upsertByEntityId(result.id, {
|
|
9
|
+
...result,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.warn('Failed to save thread to database:', error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
await logEventFromContext(ctx, 'discord.threads.create', { channel_id, name: input.name }, 'completed');
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
export const createFromMessage = async (ctx, input) => {
|
|
20
|
+
const { channel_id, message_id, ...body } = input;
|
|
21
|
+
const result = await makeDiscordRequest(`channels/${channel_id}/messages/${message_id}/threads`, ctx.key, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
body,
|
|
24
|
+
});
|
|
25
|
+
if (ctx.db.channels) {
|
|
26
|
+
try {
|
|
27
|
+
await ctx.db.channels.upsertByEntityId(result.id, {
|
|
28
|
+
...result,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.warn('Failed to save thread to database:', error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
await logEventFromContext(ctx, 'discord.threads.createFromMessage', { channel_id, message_id, name: input.name }, 'completed');
|
|
36
|
+
return result;
|
|
37
|
+
};
|