corsair 0.0.2 → 0.1.1
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/LICENSE +191 -0
- package/dist/adapters/drizzle/index.d.ts +2 -0
- package/dist/adapters/drizzle/index.d.ts.map +1 -0
- package/dist/adapters/drizzle/index.js +1 -0
- package/dist/adapters/drizzle/postgres.d.ts +34 -0
- package/dist/adapters/drizzle/postgres.d.ts.map +1 -0
- package/dist/adapters/drizzle/postgres.js +193 -0
- package/dist/adapters/index.d.ts +6 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +5 -0
- package/dist/adapters/kysely/index.d.ts +2 -0
- package/dist/adapters/kysely/index.d.ts.map +1 -0
- package/dist/adapters/kysely/index.js +1 -0
- package/dist/adapters/kysely/postgres.d.ts +19 -0
- package/dist/adapters/kysely/postgres.d.ts.map +1 -0
- package/dist/adapters/kysely/postgres.js +138 -0
- package/dist/adapters/prisma/index.d.ts +2 -0
- package/dist/adapters/prisma/index.d.ts.map +1 -0
- package/dist/adapters/prisma/index.js +1 -0
- package/dist/adapters/prisma/postgres.d.ts +17 -0
- package/dist/adapters/prisma/postgres.d.ts.map +1 -0
- package/dist/adapters/prisma/postgres.js +176 -0
- package/dist/adapters/tenant.d.ts +13 -0
- package/dist/adapters/tenant.d.ts.map +1 -0
- package/dist/adapters/tenant.js +95 -0
- package/dist/adapters/types.d.ts +162 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +1 -0
- package/dist/async-core/ApiError.d.ts +21 -0
- package/dist/async-core/ApiError.d.ts.map +1 -0
- package/dist/async-core/ApiError.js +27 -0
- package/dist/async-core/ApiRequestOptions.d.ts +14 -0
- package/dist/async-core/ApiRequestOptions.d.ts.map +1 -0
- package/dist/async-core/ApiRequestOptions.js +1 -0
- package/dist/async-core/ApiResult.d.ts +8 -0
- package/dist/async-core/ApiResult.d.ts.map +1 -0
- package/dist/async-core/ApiResult.js +1 -0
- package/dist/async-core/CancelablePromise.d.ts +21 -0
- package/dist/async-core/CancelablePromise.d.ts.map +1 -0
- package/dist/async-core/CancelablePromise.js +95 -0
- package/dist/async-core/OpenAPI.d.ts +16 -0
- package/dist/async-core/OpenAPI.d.ts.map +1 -0
- package/dist/async-core/OpenAPI.js +1 -0
- package/dist/async-core/rate-limit.d.ts +25 -0
- package/dist/async-core/rate-limit.d.ts.map +1 -0
- package/dist/async-core/rate-limit.js +79 -0
- package/dist/async-core/request.d.ts +9 -0
- package/dist/async-core/request.d.ts.map +1 -0
- package/dist/async-core/request.js +313 -0
- package/dist/async-core/webhook-handler.d.ts +15 -0
- package/dist/async-core/webhook-handler.d.ts.map +1 -0
- package/dist/async-core/webhook-handler.js +40 -0
- package/dist/async-core/webhook-utils.d.ts +4 -0
- package/dist/async-core/webhook-utils.d.ts.map +1 -0
- package/dist/async-core/webhook-utils.js +57 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +9 -0
- package/dist/core/auth/encryption.d.ts +71 -0
- package/dist/core/auth/encryption.d.ts.map +1 -0
- package/dist/core/auth/encryption.js +177 -0
- package/dist/core/auth/errors/index.d.ts +2 -0
- package/dist/core/auth/errors/index.d.ts.map +1 -0
- package/dist/core/auth/errors/index.js +1 -0
- package/dist/core/auth/errors/missing-config.d.ts +10 -0
- package/dist/core/auth/errors/missing-config.d.ts.map +1 -0
- package/dist/core/auth/errors/missing-config.js +25 -0
- package/dist/core/auth/index.d.ts +6 -0
- package/dist/core/auth/index.d.ts.map +1 -0
- package/dist/core/auth/index.js +8 -0
- package/dist/core/auth/key-manager.d.ts +43 -0
- package/dist/core/auth/key-manager.d.ts.map +1 -0
- package/dist/core/auth/key-manager.js +204 -0
- package/dist/core/auth/methods/api-key.d.ts +4 -0
- package/dist/core/auth/methods/api-key.d.ts.map +1 -0
- package/dist/core/auth/methods/api-key.js +102 -0
- package/dist/core/auth/methods/bot-token.d.ts +4 -0
- package/dist/core/auth/methods/bot-token.d.ts.map +1 -0
- package/dist/core/auth/methods/bot-token.js +102 -0
- package/dist/core/auth/methods/index.d.ts +4 -0
- package/dist/core/auth/methods/index.d.ts.map +1 -0
- package/dist/core/auth/methods/index.js +3 -0
- package/dist/core/auth/methods/oauth2.d.ts +4 -0
- package/dist/core/auth/methods/oauth2.d.ts.map +1 -0
- package/dist/core/auth/methods/oauth2.js +210 -0
- package/dist/core/auth/types.d.ts +211 -0
- package/dist/core/auth/types.d.ts.map +1 -0
- package/dist/core/auth/types.js +1 -0
- package/dist/core/client/index.d.ts +127 -0
- package/dist/core/client/index.d.ts.map +1 -0
- package/dist/core/client/index.js +376 -0
- package/dist/core/constants.d.ts +6 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +7 -0
- package/dist/core/endpoints/bind.d.ts +31 -0
- package/dist/core/endpoints/bind.d.ts.map +1 -0
- package/dist/core/endpoints/bind.js +117 -0
- package/dist/core/endpoints/index.d.ts +76 -0
- package/dist/core/endpoints/index.d.ts.map +1 -0
- package/dist/core/endpoints/index.js +1 -0
- package/dist/core/errors/handler.d.ts +11 -0
- package/dist/core/errors/handler.d.ts.map +1 -0
- package/dist/core/errors/handler.js +30 -0
- package/dist/core/errors/index.d.ts +30 -0
- package/dist/core/errors/index.d.ts.map +1 -0
- package/dist/core/errors/index.js +1 -0
- package/dist/core/index.d.ts +31 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +40 -0
- package/dist/core/plugins/index.d.ts +234 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +1 -0
- package/dist/core/utils.d.ts +29 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/utils.js +42 -0
- package/dist/core/webhooks/bind.d.ts +25 -0
- package/dist/core/webhooks/bind.d.ts.map +1 -0
- package/dist/core/webhooks/bind.js +65 -0
- package/dist/core/webhooks/index.d.ts +134 -0
- package/dist/core/webhooks/index.d.ts.map +1 -0
- package/dist/core/webhooks/index.js +1 -0
- package/dist/db/index.d.ts +106 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +52 -0
- package/dist/db/orm.d.ts +320 -0
- package/dist/db/orm.d.ts.map +1 -0
- package/dist/db/orm.js +707 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/plugins/gmail/client.d.ts +16 -0
- package/dist/plugins/gmail/client.d.ts.map +1 -0
- package/dist/plugins/gmail/client.js +81 -0
- package/dist/plugins/gmail/endpoints/drafts.d.ts +8 -0
- package/dist/plugins/gmail/endpoints/drafts.d.ts.map +1 -0
- package/dist/plugins/gmail/endpoints/drafts.js +117 -0
- package/dist/plugins/gmail/endpoints/index.d.ts +163 -0
- package/dist/plugins/gmail/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/gmail/endpoints/index.js +38 -0
- package/dist/plugins/gmail/endpoints/labels.d.ts +7 -0
- package/dist/plugins/gmail/endpoints/labels.d.ts.map +1 -0
- package/dist/plugins/gmail/endpoints/labels.js +126 -0
- package/dist/plugins/gmail/endpoints/messages.d.ts +10 -0
- package/dist/plugins/gmail/endpoints/messages.d.ts.map +1 -0
- package/dist/plugins/gmail/endpoints/messages.js +254 -0
- package/dist/plugins/gmail/endpoints/threads.d.ts +8 -0
- package/dist/plugins/gmail/endpoints/threads.d.ts.map +1 -0
- package/dist/plugins/gmail/endpoints/threads.js +109 -0
- package/dist/plugins/gmail/endpoints/types.d.ts +30 -0
- package/dist/plugins/gmail/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/gmail/endpoints/types.js +1 -0
- package/dist/plugins/gmail/index.d.ts +361 -0
- package/dist/plugins/gmail/index.d.ts.map +1 -0
- package/dist/plugins/gmail/index.js +90 -0
- package/dist/plugins/gmail/schema/database.d.ts +115 -0
- package/dist/plugins/gmail/schema/database.d.ts.map +1 -0
- package/dist/plugins/gmail/schema/database.js +59 -0
- package/dist/plugins/gmail/schema/index.d.ts +115 -0
- package/dist/plugins/gmail/schema/index.d.ts.map +1 -0
- package/dist/plugins/gmail/schema/index.js +10 -0
- package/dist/plugins/gmail/types.d.ts +119 -0
- package/dist/plugins/gmail/types.d.ts.map +1 -0
- package/dist/plugins/gmail/types.js +1 -0
- package/dist/plugins/gmail/webhooks/index.d.ts +52 -0
- package/dist/plugins/gmail/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/gmail/webhooks/index.js +7 -0
- package/dist/plugins/gmail/webhooks/messages.d.ts +52 -0
- package/dist/plugins/gmail/webhooks/messages.d.ts.map +1 -0
- package/dist/plugins/gmail/webhooks/messages.js +505 -0
- package/dist/plugins/gmail/webhooks/types.d.ts +65 -0
- package/dist/plugins/gmail/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/gmail/webhooks/types.js +1 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/linear/client.d.ts +32 -0
- package/dist/plugins/linear/client.d.ts.map +1 -0
- package/dist/plugins/linear/client.js +117 -0
- package/dist/plugins/linear/endpoints/comments.d.ts +6 -0
- package/dist/plugins/linear/endpoints/comments.d.ts.map +1 -0
- package/dist/plugins/linear/endpoints/comments.js +196 -0
- package/dist/plugins/linear/endpoints/index.d.ts +116 -0
- package/dist/plugins/linear/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/linear/endpoints/index.js +29 -0
- package/dist/plugins/linear/endpoints/issues.d.ts +7 -0
- package/dist/plugins/linear/endpoints/issues.d.ts.map +1 -0
- package/dist/plugins/linear/endpoints/issues.js +447 -0
- package/dist/plugins/linear/endpoints/projects.d.ts +7 -0
- package/dist/plugins/linear/endpoints/projects.d.ts.map +1 -0
- package/dist/plugins/linear/endpoints/projects.js +277 -0
- package/dist/plugins/linear/endpoints/teams.d.ts +4 -0
- package/dist/plugins/linear/endpoints/teams.d.ts.map +1 -0
- package/dist/plugins/linear/endpoints/teams.js +95 -0
- package/dist/plugins/linear/endpoints/types.d.ts +295 -0
- package/dist/plugins/linear/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/linear/endpoints/types.js +1 -0
- package/dist/plugins/linear/error-handlers.d.ts +46 -0
- package/dist/plugins/linear/error-handlers.d.ts.map +1 -0
- package/dist/plugins/linear/error-handlers.js +140 -0
- package/dist/plugins/linear/index.d.ts +283 -0
- package/dist/plugins/linear/index.d.ts.map +1 -0
- package/dist/plugins/linear/index.js +81 -0
- package/dist/plugins/linear/schema/database.d.ts +234 -0
- package/dist/plugins/linear/schema/database.d.ts.map +1 -0
- package/dist/plugins/linear/schema/database.js +86 -0
- package/dist/plugins/linear/schema/index.d.ts +233 -0
- package/dist/plugins/linear/schema/index.d.ts.map +1 -0
- package/dist/plugins/linear/schema/index.js +11 -0
- package/dist/plugins/linear/webhooks/comments.d.ts +5 -0
- package/dist/plugins/linear/webhooks/comments.d.ts.map +1 -0
- package/dist/plugins/linear/webhooks/comments.js +103 -0
- package/dist/plugins/linear/webhooks/index.d.ts +44 -0
- package/dist/plugins/linear/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/linear/webhooks/index.js +19 -0
- package/dist/plugins/linear/webhooks/issues.d.ts +5 -0
- package/dist/plugins/linear/webhooks/issues.d.ts.map +1 -0
- package/dist/plugins/linear/webhooks/issues.js +115 -0
- package/dist/plugins/linear/webhooks/projects.d.ts +5 -0
- package/dist/plugins/linear/webhooks/projects.d.ts.map +1 -0
- package/dist/plugins/linear/webhooks/projects.js +108 -0
- package/dist/plugins/linear/webhooks/types.d.ts +180 -0
- package/dist/plugins/linear/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/linear/webhooks/types.js +16 -0
- package/dist/plugins/posthog/client.d.ts +36 -0
- package/dist/plugins/posthog/client.d.ts.map +1 -0
- package/dist/plugins/posthog/client.js +122 -0
- package/dist/plugins/posthog/endpoints/events.d.ts +7 -0
- package/dist/plugins/posthog/endpoints/events.d.ts.map +1 -0
- package/dist/plugins/posthog/endpoints/events.js +123 -0
- package/dist/plugins/posthog/endpoints/index.d.ts +33 -0
- package/dist/plugins/posthog/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/posthog/endpoints/index.js +9 -0
- package/dist/plugins/posthog/endpoints/types.d.ts +28 -0
- package/dist/plugins/posthog/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/posthog/endpoints/types.js +1 -0
- package/dist/plugins/posthog/index.d.ts +103 -0
- package/dist/plugins/posthog/index.d.ts.map +1 -0
- package/dist/plugins/posthog/index.js +51 -0
- package/dist/plugins/posthog/schema/database.d.ts +28 -0
- package/dist/plugins/posthog/schema/database.d.ts.map +1 -0
- package/dist/plugins/posthog/schema/database.js +10 -0
- package/dist/plugins/posthog/schema/index.d.ts +31 -0
- package/dist/plugins/posthog/schema/index.d.ts.map +1 -0
- package/dist/plugins/posthog/schema/index.js +7 -0
- package/dist/plugins/posthog/webhooks/events.d.ts +3 -0
- package/dist/plugins/posthog/webhooks/events.d.ts.map +1 -0
- package/dist/plugins/posthog/webhooks/events.js +33 -0
- package/dist/plugins/posthog/webhooks/index.d.ts +8 -0
- package/dist/plugins/posthog/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/posthog/webhooks/index.js +5 -0
- package/dist/plugins/posthog/webhooks/types.d.ts +31 -0
- package/dist/plugins/posthog/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/posthog/webhooks/types.js +12 -0
- package/dist/plugins/resend/client.d.ts +35 -0
- package/dist/plugins/resend/client.d.ts.map +1 -0
- package/dist/plugins/resend/client.js +101 -0
- package/dist/plugins/resend/endpoints/domains.d.ts +7 -0
- package/dist/plugins/resend/endpoints/domains.d.ts.map +1 -0
- package/dist/plugins/resend/endpoints/domains.js +115 -0
- package/dist/plugins/resend/endpoints/emails.d.ts +5 -0
- package/dist/plugins/resend/endpoints/emails.d.ts.map +1 -0
- package/dist/plugins/resend/endpoints/emails.js +96 -0
- package/dist/plugins/resend/endpoints/index.d.ts +50 -0
- package/dist/plugins/resend/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/resend/endpoints/index.js +15 -0
- package/dist/plugins/resend/endpoints/types.d.ts +51 -0
- package/dist/plugins/resend/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/resend/endpoints/types.js +1 -0
- package/dist/plugins/resend/index.d.ts +155 -0
- package/dist/plugins/resend/index.d.ts.map +1 -0
- package/dist/plugins/resend/index.js +67 -0
- package/dist/plugins/resend/schema/database.d.ts +42 -0
- package/dist/plugins/resend/schema/database.d.ts.map +1 -0
- package/dist/plugins/resend/schema/database.js +15 -0
- package/dist/plugins/resend/schema/index.d.ts +44 -0
- package/dist/plugins/resend/schema/index.d.ts.map +1 -0
- package/dist/plugins/resend/schema/index.js +8 -0
- package/dist/plugins/resend/webhooks/domains.d.ts +4 -0
- package/dist/plugins/resend/webhooks/domains.d.ts.map +1 -0
- package/dist/plugins/resend/webhooks/domains.js +57 -0
- package/dist/plugins/resend/webhooks/emails.d.ts +10 -0
- package/dist/plugins/resend/webhooks/emails.d.ts.map +1 -0
- package/dist/plugins/resend/webhooks/emails.js +138 -0
- package/dist/plugins/resend/webhooks/index.d.ts +46 -0
- package/dist/plugins/resend/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/resend/webhooks/index.js +17 -0
- package/dist/plugins/resend/webhooks/types.d.ts +158 -0
- package/dist/plugins/resend/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/resend/webhooks/types.js +9 -0
- package/dist/plugins/slack/client.d.ts +50 -0
- package/dist/plugins/slack/client.d.ts.map +1 -0
- package/dist/plugins/slack/client.js +127 -0
- package/dist/plugins/slack/endpoints/channels.d.ts +20 -0
- package/dist/plugins/slack/endpoints/channels.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/channels.js +418 -0
- package/dist/plugins/slack/endpoints/files.d.ts +5 -0
- package/dist/plugins/slack/endpoints/files.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/files.js +90 -0
- package/dist/plugins/slack/endpoints/index.d.ts +353 -0
- package/dist/plugins/slack/endpoints/index.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/index.js +64 -0
- package/dist/plugins/slack/endpoints/messages.d.ts +7 -0
- package/dist/plugins/slack/endpoints/messages.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/messages.js +143 -0
- package/dist/plugins/slack/endpoints/reactions.d.ts +8 -0
- package/dist/plugins/slack/endpoints/reactions.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/reactions.js +69 -0
- package/dist/plugins/slack/endpoints/stars.d.ts +5 -0
- package/dist/plugins/slack/endpoints/stars.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/stars.js +42 -0
- package/dist/plugins/slack/endpoints/types.d.ts +692 -0
- package/dist/plugins/slack/endpoints/types.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/types.js +1 -0
- package/dist/plugins/slack/endpoints/user-groups.d.ts +7 -0
- package/dist/plugins/slack/endpoints/user-groups.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/user-groups.js +138 -0
- package/dist/plugins/slack/endpoints/users.d.ts +7 -0
- package/dist/plugins/slack/endpoints/users.d.ts.map +1 -0
- package/dist/plugins/slack/endpoints/users.js +110 -0
- package/dist/plugins/slack/error-handlers.d.ts +40 -0
- package/dist/plugins/slack/error-handlers.d.ts.map +1 -0
- package/dist/plugins/slack/error-handlers.js +103 -0
- package/dist/plugins/slack/index.d.ts +628 -0
- package/dist/plugins/slack/index.d.ts.map +1 -0
- package/dist/plugins/slack/index.js +131 -0
- package/dist/plugins/slack/schema/database.d.ts +346 -0
- package/dist/plugins/slack/schema/database.d.ts.map +1 -0
- package/dist/plugins/slack/schema/database.js +108 -0
- package/dist/plugins/slack/schema/index.d.ts +345 -0
- package/dist/plugins/slack/schema/index.d.ts.map +1 -0
- package/dist/plugins/slack/schema/index.js +11 -0
- package/dist/plugins/slack/webhooks/channels.d.ts +3 -0
- package/dist/plugins/slack/webhooks/channels.d.ts.map +1 -0
- package/dist/plugins/slack/webhooks/channels.js +44 -0
- package/dist/plugins/slack/webhooks/files.d.ts +5 -0
- package/dist/plugins/slack/webhooks/files.d.ts.map +1 -0
- package/dist/plugins/slack/webhooks/files.js +100 -0
- package/dist/plugins/slack/webhooks/index.d.ts +45 -0
- package/dist/plugins/slack/webhooks/index.d.ts.map +1 -0
- package/dist/plugins/slack/webhooks/index.js +25 -0
- package/dist/plugins/slack/webhooks/messages.d.ts +3 -0
- package/dist/plugins/slack/webhooks/messages.d.ts.map +1 -0
- package/dist/plugins/slack/webhooks/messages.js +40 -0
- package/dist/plugins/slack/webhooks/reactions.d.ts +3 -0
- package/dist/plugins/slack/webhooks/reactions.d.ts.map +1 -0
- package/dist/plugins/slack/webhooks/reactions.js +10 -0
- package/dist/plugins/slack/webhooks/types.d.ts +661 -0
- package/dist/plugins/slack/webhooks/types.d.ts.map +1 -0
- package/dist/plugins/slack/webhooks/types.js +22 -0
- package/dist/plugins/slack/webhooks/users.d.ts +4 -0
- package/dist/plugins/slack/webhooks/users.d.ts.map +1 -0
- package/dist/plugins/slack/webhooks/users.js +69 -0
- package/dist/plugins/utils/events.d.ts +31 -0
- package/dist/plugins/utils/events.d.ts.map +1 -0
- package/dist/plugins/utils/events.js +54 -0
- package/dist/tests/drizzle-adapter.test.d.ts +2 -0
- package/dist/tests/drizzle-adapter.test.d.ts.map +1 -0
- package/dist/tests/drizzle-adapter.test.js +534 -0
- package/dist/tests/error-handlers.test.d.ts +2 -0
- package/dist/tests/error-handlers.test.d.ts.map +1 -0
- package/dist/tests/error-handlers.test.js +454 -0
- package/dist/tests/hooks.test.d.ts +2 -0
- package/dist/tests/hooks.test.d.ts.map +1 -0
- package/dist/tests/hooks.test.js +357 -0
- package/dist/tests/multi-tenancy.test.d.ts +2 -0
- package/dist/tests/multi-tenancy.test.d.ts.map +1 -0
- package/dist/tests/multi-tenancy.test.js +277 -0
- package/dist/tests/setup-db.d.ts +7 -0
- package/dist/tests/setup-db.d.ts.map +1 -0
- package/dist/tests/setup-db.js +141 -0
- package/dist/tests/slack-rate-limit-integration.test.d.ts +2 -0
- package/dist/tests/slack-rate-limit-integration.test.d.ts.map +1 -0
- package/dist/tests/slack-rate-limit-integration.test.js +416 -0
- package/dist/tsup.config.d.ts +3 -0
- package/dist/tsup.config.d.ts.map +1 -0
- package/dist/tsup.config.js +26 -0
- package/dist/webhooks/index.d.ts +108 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +195 -0
- package/package.json +141 -20
- package/.npmignore +0 -8
- package/README.md +0 -1
- package/index.js +0 -3
- package/lib/apigateway.js +0 -292
- package/lib/corsair.js +0 -236
- package/lib/deploy.js +0 -74
- package/lib/iam.js +0 -26
- package/lib/lambda.js +0 -104
- package/lib/platforms/awslambda.js +0 -46
- package/lib/platforms/http.js +0 -26
- package/lib/platforms/index.js +0 -29
- package/lib/request-templates.js +0 -47
- package/lib/response-templates.js +0 -22
- package/lib/statuses.json +0 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(which shall not include Communications that are clearly marked or
|
|
39
|
+
otherwise designated in writing by the copyright owner as "Not a Work").
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution".
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright (c) 2026 Corsair
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../adapters/drizzle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,oBAAoB,EACzB,cAAc,GACd,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { drizzleAdapter, } from './postgres';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CorsairDbAdapter } from '../types';
|
|
2
|
+
export type DrizzleAdapterConfig = {
|
|
3
|
+
/**
|
|
4
|
+
* Corsair currently supports Postgres only.
|
|
5
|
+
*/
|
|
6
|
+
provider: 'pg';
|
|
7
|
+
/**
|
|
8
|
+
* Optional Drizzle schema object. If omitted, we try `db._.fullSchema`.
|
|
9
|
+
*/
|
|
10
|
+
schema?: Record<string, unknown> | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* If your table objects are keyed differently in the schema.
|
|
13
|
+
*/
|
|
14
|
+
tableNames?: {
|
|
15
|
+
integrations?: string | undefined;
|
|
16
|
+
accounts?: string | undefined;
|
|
17
|
+
entities?: string | undefined;
|
|
18
|
+
events?: string | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
adapterId?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `drizzleAdapter(db, { provider: "pg" })`.
|
|
24
|
+
*
|
|
25
|
+
* Corsair currently supports Postgres only.
|
|
26
|
+
*
|
|
27
|
+
* Note on typing:
|
|
28
|
+
* - Drizzle's column/table types are schema-generic. Corsair does not own the user's schema types,
|
|
29
|
+
* so we accept `unknown` and do runtime validation.
|
|
30
|
+
* - We cast the schema columns into Drizzle expression helpers (`eq`, `inArray`, `ilike`) because
|
|
31
|
+
* those helpers require Drizzle's column types, which we cannot represent without the user's generics.
|
|
32
|
+
*/
|
|
33
|
+
export declare function drizzleAdapter(db: unknown, config: DrizzleAdapterConfig): CorsairDbAdapter;
|
|
34
|
+
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../adapters/drizzle/postgres.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,gBAAgB,EAMhB,MAAM,UAAU,CAAC;AAyClB,MAAM,MAAM,oBAAoB,GAAG;IAClC;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C;;OAEG;IACH,UAAU,CAAC,EACR;QACA,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B,GACD,SAAS,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAgIF;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC7B,EAAE,EAAE,OAAO,EACX,MAAM,EAAE,oBAAoB,GAC1B,gBAAgB,CAiIlB"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { and, asc, count, desc, eq, ilike, inArray } from 'drizzle-orm';
|
|
2
|
+
function normalizeOperator(op) {
|
|
3
|
+
return op ?? '=';
|
|
4
|
+
}
|
|
5
|
+
function toArray(value) {
|
|
6
|
+
return Array.isArray(value) ? value : [value];
|
|
7
|
+
}
|
|
8
|
+
function getColumn(table, field) {
|
|
9
|
+
const col = table[field];
|
|
10
|
+
if (!col) {
|
|
11
|
+
throw new Error(`Drizzle adapter: column "${field}" was not found on the provided table.`);
|
|
12
|
+
}
|
|
13
|
+
return col;
|
|
14
|
+
}
|
|
15
|
+
function buildWhereExpr(tableObj, where) {
|
|
16
|
+
if (!where?.length)
|
|
17
|
+
return undefined;
|
|
18
|
+
const parts = [];
|
|
19
|
+
for (const w of where) {
|
|
20
|
+
const operator = normalizeOperator(w.operator);
|
|
21
|
+
const col = getColumn(tableObj, w.field);
|
|
22
|
+
if (operator === 'in') {
|
|
23
|
+
parts.push(inArray(col, toArray(w.value)));
|
|
24
|
+
}
|
|
25
|
+
else if (operator === 'like') {
|
|
26
|
+
// Postgres-only: use ILIKE for case-insensitive search.
|
|
27
|
+
parts.push(ilike(col, String(w.value)));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
parts.push(eq(col, w.value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return parts.length === 1 ? parts[0] : and(...parts);
|
|
34
|
+
}
|
|
35
|
+
function buildSelect(tableObj, select) {
|
|
36
|
+
if (!select?.length)
|
|
37
|
+
return undefined;
|
|
38
|
+
const projection = {};
|
|
39
|
+
for (const field of select) {
|
|
40
|
+
projection[field] = getColumn(tableObj, field);
|
|
41
|
+
}
|
|
42
|
+
return projection;
|
|
43
|
+
}
|
|
44
|
+
function applySort(q, tableObj, sortBy) {
|
|
45
|
+
if (!sortBy)
|
|
46
|
+
return q;
|
|
47
|
+
const col = getColumn(tableObj, sortBy.field);
|
|
48
|
+
return q.orderBy(sortBy.direction === 'asc' ? asc(col) : desc(col));
|
|
49
|
+
}
|
|
50
|
+
function asDrizzleDBLike(db) {
|
|
51
|
+
// We intentionally use structural typing to accept any Drizzle db instance.
|
|
52
|
+
// Runtime failures will be clearer than over-constraining types we don't own.
|
|
53
|
+
return db;
|
|
54
|
+
}
|
|
55
|
+
function getSchema(db, config) {
|
|
56
|
+
const schema = config.schema ?? db._?.fullSchema;
|
|
57
|
+
if (!schema) {
|
|
58
|
+
throw new Error('Drizzle adapter failed to initialize. Schema not found. Provide `schema` or use a Drizzle db that exposes `db._.fullSchema`.');
|
|
59
|
+
}
|
|
60
|
+
return schema;
|
|
61
|
+
}
|
|
62
|
+
function getTableFromSchema(schema, key) {
|
|
63
|
+
const table = schema[key];
|
|
64
|
+
if (!table || typeof table !== 'object') {
|
|
65
|
+
throw new Error(`Drizzle adapter failed to initialize. Table "${key}" was not found in schema.`);
|
|
66
|
+
}
|
|
67
|
+
return table;
|
|
68
|
+
}
|
|
69
|
+
function getCorsairTable(schema, table, tableNames) {
|
|
70
|
+
switch (table) {
|
|
71
|
+
case 'corsair_integrations':
|
|
72
|
+
return getTableFromSchema(schema, tableNames?.integrations ?? 'corsair_integrations');
|
|
73
|
+
case 'corsair_accounts':
|
|
74
|
+
return getTableFromSchema(schema, tableNames?.accounts ?? 'corsair_accounts');
|
|
75
|
+
case 'corsair_entities':
|
|
76
|
+
return getTableFromSchema(schema, tableNames?.entities ?? 'corsair_entities');
|
|
77
|
+
case 'corsair_events':
|
|
78
|
+
return getTableFromSchema(schema, tableNames?.events ?? 'corsair_events');
|
|
79
|
+
default:
|
|
80
|
+
// Allow custom tables by looking them up directly in the schema
|
|
81
|
+
return getTableFromSchema(schema, table);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* `drizzleAdapter(db, { provider: "pg" })`.
|
|
86
|
+
*
|
|
87
|
+
* Corsair currently supports Postgres only.
|
|
88
|
+
*
|
|
89
|
+
* Note on typing:
|
|
90
|
+
* - Drizzle's column/table types are schema-generic. Corsair does not own the user's schema types,
|
|
91
|
+
* so we accept `unknown` and do runtime validation.
|
|
92
|
+
* - We cast the schema columns into Drizzle expression helpers (`eq`, `inArray`, `ilike`) because
|
|
93
|
+
* those helpers require Drizzle's column types, which we cannot represent without the user's generics.
|
|
94
|
+
*/
|
|
95
|
+
export function drizzleAdapter(db, config) {
|
|
96
|
+
if (config.provider !== 'pg') {
|
|
97
|
+
throw new Error(`Corsair Drizzle adapter only supports provider "pg" (got "${String(config.provider)}").`);
|
|
98
|
+
}
|
|
99
|
+
const drizzle = asDrizzleDBLike(db);
|
|
100
|
+
const schema = getSchema(drizzle, config);
|
|
101
|
+
const adapterId = config.adapterId ?? 'drizzle';
|
|
102
|
+
return {
|
|
103
|
+
id: adapterId,
|
|
104
|
+
async findOne(args) {
|
|
105
|
+
const tableObj = getCorsairTable(schema, args.table, config.tableNames);
|
|
106
|
+
const whereExpr = buildWhereExpr(tableObj, args.where);
|
|
107
|
+
const projection = buildSelect(tableObj, args.select);
|
|
108
|
+
const q = projection
|
|
109
|
+
? drizzle.select(projection).from(tableObj)
|
|
110
|
+
: drizzle.select().from(tableObj);
|
|
111
|
+
const res = whereExpr
|
|
112
|
+
? await q.where(whereExpr).limit(1)
|
|
113
|
+
: await q.limit(1);
|
|
114
|
+
return (res?.[0] ?? null);
|
|
115
|
+
},
|
|
116
|
+
async findMany(args) {
|
|
117
|
+
const tableObj = getCorsairTable(schema, args.table, config.tableNames);
|
|
118
|
+
const whereExpr = buildWhereExpr(tableObj, args.where);
|
|
119
|
+
const projection = buildSelect(tableObj, args.select);
|
|
120
|
+
let q = projection
|
|
121
|
+
? drizzle.select(projection).from(tableObj)
|
|
122
|
+
: drizzle.select().from(tableObj);
|
|
123
|
+
if (whereExpr)
|
|
124
|
+
q = q.where(whereExpr);
|
|
125
|
+
q = applySort(q, tableObj, args.sortBy);
|
|
126
|
+
if (typeof args.limit === 'number')
|
|
127
|
+
q = q.limit(args.limit);
|
|
128
|
+
if (typeof args.offset === 'number')
|
|
129
|
+
q = q.offset(args.offset);
|
|
130
|
+
return (await q);
|
|
131
|
+
},
|
|
132
|
+
async insert(args) {
|
|
133
|
+
const tableObj = getCorsairTable(schema, args.table, config.tableNames);
|
|
134
|
+
const projection = buildSelect(tableObj, args.select);
|
|
135
|
+
const q = drizzle.insert(tableObj).values(args.data);
|
|
136
|
+
const rows = projection
|
|
137
|
+
? await q.returning(projection)
|
|
138
|
+
: await q.returning();
|
|
139
|
+
return (rows?.[0] ?? args.data);
|
|
140
|
+
},
|
|
141
|
+
async update(args) {
|
|
142
|
+
const tableObj = getCorsairTable(schema, args.table, config.tableNames);
|
|
143
|
+
const whereExpr = buildWhereExpr(tableObj, args.where);
|
|
144
|
+
if (!whereExpr) {
|
|
145
|
+
throw new Error('Drizzle adapter: update requires a non-empty where clause.');
|
|
146
|
+
}
|
|
147
|
+
const projection = buildSelect(tableObj, args.select);
|
|
148
|
+
const q = drizzle.update(tableObj).set(args.data).where(whereExpr);
|
|
149
|
+
const rows = projection
|
|
150
|
+
? await q.returning(projection)
|
|
151
|
+
: await q.returning();
|
|
152
|
+
return (rows?.[0] ?? null);
|
|
153
|
+
},
|
|
154
|
+
async deleteMany(args) {
|
|
155
|
+
const tableObj = getCorsairTable(schema, args.table, config.tableNames);
|
|
156
|
+
const whereExpr = buildWhereExpr(tableObj, args.where);
|
|
157
|
+
if (!whereExpr)
|
|
158
|
+
return 0;
|
|
159
|
+
// Postgres-only: use returning to count deletes deterministically.
|
|
160
|
+
const rows = await drizzle
|
|
161
|
+
.delete(tableObj)
|
|
162
|
+
.where(whereExpr)
|
|
163
|
+
.returning({
|
|
164
|
+
id: getColumn(tableObj, 'id'),
|
|
165
|
+
});
|
|
166
|
+
return rows.length;
|
|
167
|
+
},
|
|
168
|
+
async count(args) {
|
|
169
|
+
const tableObj = getCorsairTable(schema, args.table, config.tableNames);
|
|
170
|
+
const whereExpr = buildWhereExpr(tableObj, args.where);
|
|
171
|
+
const q = drizzle.select({ count: count() }).from(tableObj);
|
|
172
|
+
const rows = whereExpr ? await q.where(whereExpr) : await q;
|
|
173
|
+
const c = rows?.[0]?.count;
|
|
174
|
+
if (typeof c === 'number')
|
|
175
|
+
return c;
|
|
176
|
+
if (typeof c === 'bigint')
|
|
177
|
+
return Number(c);
|
|
178
|
+
return Number.parseInt(String(c ?? 0), 10);
|
|
179
|
+
},
|
|
180
|
+
async transaction(fn) {
|
|
181
|
+
if (!drizzle.transaction)
|
|
182
|
+
return fn(this);
|
|
183
|
+
return drizzle.transaction(async (tx) => {
|
|
184
|
+
// Keep the exact same config/schema; only swap the db instance.
|
|
185
|
+
const trxAdapter = drizzleAdapter(tx, {
|
|
186
|
+
...config,
|
|
187
|
+
adapterId: adapterId + ':trx',
|
|
188
|
+
});
|
|
189
|
+
return fn(trxAdapter);
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAE1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../adapters/kysely/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,aAAa,EACb,qBAAqB,GACrB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { kyselyAdapter, kyselyPostgresAdapter, } from './postgres';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import type { CorsairDbAdapter } from '../types';
|
|
3
|
+
export type KyselyPostgresAdapterConfig = {
|
|
4
|
+
adapterId?: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
export type KyselyAdapterConfig = KyselyPostgresAdapterConfig & {
|
|
7
|
+
/**
|
|
8
|
+
* Corsair currently supports Postgres only.
|
|
9
|
+
*/
|
|
10
|
+
provider: 'pg';
|
|
11
|
+
};
|
|
12
|
+
export declare function kyselyPostgresAdapter(db: Kysely<any>, config?: KyselyPostgresAdapterConfig): CorsairDbAdapter;
|
|
13
|
+
/**
|
|
14
|
+
* `kyselyAdapter(db, { provider: "pg" })`.
|
|
15
|
+
*
|
|
16
|
+
* Corsair currently supports Postgres only.
|
|
17
|
+
*/
|
|
18
|
+
export declare function kyselyAdapter(db: Kysely<any>, config: KyselyAdapterConfig): CorsairDbAdapter;
|
|
19
|
+
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../adapters/kysely/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EACX,gBAAgB,EAKhB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,2BAA2B,GAAG;IACzC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,2BAA2B,GAAG;IAC/D;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;CACf,CAAC;AA2CF,wBAAgB,qBAAqB,CACpC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EACf,MAAM,GAAE,2BAAgC,GACtC,gBAAgB,CA+HlB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EACf,MAAM,EAAE,mBAAmB,GACzB,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
function normalizeOperator(op) {
|
|
2
|
+
return op ?? '=';
|
|
3
|
+
}
|
|
4
|
+
function toArray(value) {
|
|
5
|
+
return Array.isArray(value) ? value : [value];
|
|
6
|
+
}
|
|
7
|
+
function applyWhere(q, where) {
|
|
8
|
+
if (!where?.length)
|
|
9
|
+
return q;
|
|
10
|
+
let next = q;
|
|
11
|
+
for (const w of where) {
|
|
12
|
+
const operator = normalizeOperator(w.operator);
|
|
13
|
+
if (operator === 'in') {
|
|
14
|
+
next = next.where(w.field, 'in', toArray(w.value));
|
|
15
|
+
}
|
|
16
|
+
else if (operator === 'like') {
|
|
17
|
+
next = next.where(w.field, 'like', w.value);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
next = next.where(w.field, '=', w.value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return next;
|
|
24
|
+
}
|
|
25
|
+
function applySort(q, sortBy) {
|
|
26
|
+
if (!sortBy)
|
|
27
|
+
return q;
|
|
28
|
+
return q.orderBy(sortBy.field, sortBy.direction);
|
|
29
|
+
}
|
|
30
|
+
function selectArgs(select) {
|
|
31
|
+
return select?.length ? select : undefined;
|
|
32
|
+
}
|
|
33
|
+
export function kyselyPostgresAdapter(db, config = {}) {
|
|
34
|
+
const adapterId = config.adapterId ?? 'kysely-postgres';
|
|
35
|
+
const findOneImpl = async (args) => {
|
|
36
|
+
let q = db.selectFrom(args.table);
|
|
37
|
+
const cols = selectArgs(args.select);
|
|
38
|
+
q = cols ? q.select(cols) : q.selectAll();
|
|
39
|
+
q = applyWhere(q, args.where);
|
|
40
|
+
return (await q.executeTakeFirst());
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
id: adapterId,
|
|
44
|
+
async findOne(args) {
|
|
45
|
+
return findOneImpl(args);
|
|
46
|
+
},
|
|
47
|
+
async findMany(args) {
|
|
48
|
+
let q = db.selectFrom(args.table);
|
|
49
|
+
const cols = selectArgs(args.select);
|
|
50
|
+
q = cols ? q.select(cols) : q.selectAll();
|
|
51
|
+
q = applyWhere(q, args.where);
|
|
52
|
+
q = applySort(q, args.sortBy);
|
|
53
|
+
if (typeof args.limit === 'number')
|
|
54
|
+
q = q.limit(args.limit);
|
|
55
|
+
if (typeof args.offset === 'number')
|
|
56
|
+
q = q.offset(args.offset);
|
|
57
|
+
return (await q.execute());
|
|
58
|
+
},
|
|
59
|
+
async insert(args) {
|
|
60
|
+
try {
|
|
61
|
+
// Postgres supports RETURNING.
|
|
62
|
+
const cols = selectArgs(args.select);
|
|
63
|
+
let q = db
|
|
64
|
+
.insertInto(args.table)
|
|
65
|
+
.values(args.data);
|
|
66
|
+
q = cols ? q.returning(cols) : q.returningAll();
|
|
67
|
+
const row = await q.executeTakeFirst();
|
|
68
|
+
return (row ?? args.data);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
await db.insertInto(args.table).values(args.data).execute();
|
|
72
|
+
return args.data;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
async update(args) {
|
|
76
|
+
try {
|
|
77
|
+
const cols = selectArgs(args.select);
|
|
78
|
+
let q = db.updateTable(args.table).set(args.data);
|
|
79
|
+
q = applyWhere(q, args.where);
|
|
80
|
+
q = cols ? q.returning(cols) : q.returningAll();
|
|
81
|
+
const row = await q.executeTakeFirst();
|
|
82
|
+
return (row ?? null);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
await applyWhere(db.updateTable(args.table).set(args.data), args.where).execute();
|
|
86
|
+
// Best-effort: fetch one updated row.
|
|
87
|
+
return await findOneImpl({
|
|
88
|
+
table: args.table,
|
|
89
|
+
where: args.where,
|
|
90
|
+
select: args.select,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
async deleteMany(args) {
|
|
95
|
+
const res = await applyWhere(db.deleteFrom(args.table), args.where).executeTakeFirst();
|
|
96
|
+
return Number(res?.numDeletedRows ?? 0);
|
|
97
|
+
},
|
|
98
|
+
async count(args) {
|
|
99
|
+
let q = db
|
|
100
|
+
.selectFrom(args.table)
|
|
101
|
+
.select((eb) => eb.fn.countAll().as('count'));
|
|
102
|
+
q = applyWhere(q, args.where);
|
|
103
|
+
const row = await q.executeTakeFirst();
|
|
104
|
+
const countVal = row?.count;
|
|
105
|
+
if (typeof countVal === 'number')
|
|
106
|
+
return countVal;
|
|
107
|
+
if (typeof countVal === 'bigint')
|
|
108
|
+
return Number(countVal);
|
|
109
|
+
return Number.parseInt(String(countVal ?? 0), 10);
|
|
110
|
+
},
|
|
111
|
+
async transaction(fn) {
|
|
112
|
+
// Kysely supports transactions via `db.transaction().execute(...)`.
|
|
113
|
+
// If a user passes a Kysely instance without transaction support, fall back to non-transactional execution.
|
|
114
|
+
const txFactory = db?.transaction?.bind(db);
|
|
115
|
+
if (!txFactory)
|
|
116
|
+
return fn(this);
|
|
117
|
+
return txFactory().execute(async (trx) => {
|
|
118
|
+
const trxAdapter = kyselyPostgresAdapter(trx, {
|
|
119
|
+
adapterId: adapterId + ':trx',
|
|
120
|
+
});
|
|
121
|
+
return fn(trxAdapter);
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* `kyselyAdapter(db, { provider: "pg" })`.
|
|
128
|
+
*
|
|
129
|
+
* Corsair currently supports Postgres only.
|
|
130
|
+
*/
|
|
131
|
+
export function kyselyAdapter(db, config) {
|
|
132
|
+
if (config.provider !== 'pg') {
|
|
133
|
+
throw new Error(`Corsair Kysely adapter only supports provider "pg" (got "${String(config.provider)}").`);
|
|
134
|
+
}
|
|
135
|
+
// Strip provider before passing through.
|
|
136
|
+
const { provider: _provider, ...rest } = config;
|
|
137
|
+
return kyselyPostgresAdapter(db, rest);
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../adapters/prisma/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,2BAA2B,EAChC,qBAAqB,GACrB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { prismaPostgresAdapter, } from './postgres';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CorsairDbAdapter } from '../types';
|
|
2
|
+
export type PrismaPostgresAdapterConfig = {
|
|
3
|
+
adapterId?: string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Prisma delegate keys on the Prisma client (e.g. `prisma.corsairEntity`).
|
|
6
|
+
*
|
|
7
|
+
* Since Prisma model names are user-defined, these are configurable.
|
|
8
|
+
*/
|
|
9
|
+
models?: {
|
|
10
|
+
corsair_integrations?: string | undefined;
|
|
11
|
+
corsair_accounts?: string | undefined;
|
|
12
|
+
corsair_entities?: string | undefined;
|
|
13
|
+
corsair_events?: string | undefined;
|
|
14
|
+
} | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare function prismaPostgresAdapter(prisma: any, config?: PrismaPostgresAdapterConfig): CorsairDbAdapter;
|
|
17
|
+
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../adapters/prisma/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAKhB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,2BAA2B,GAAG;IACzC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;;;OAIG;IACH,MAAM,CAAC,EACJ;QACA,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1C,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACnC,GACD,SAAS,CAAC;CACb,CAAC;AA6GF,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,GAAG,EACX,MAAM,GAAE,2BAAgC,GACtC,gBAAgB,CAyHlB"}
|