corsair 0.1.88 → 0.1.89

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.
@@ -0,0 +1 @@
1
+ var c=class extends Error{status;code;extra;constructor(o,i,t,r={}){super(t),this.name="CorsairClientError",this.status=o,this.code=i,this.extra=r}};function g(e){return e.endsWith("/")?e.slice(0,-1):e}async function m(e){let o={};try{o=await e.json()}catch{}let i=typeof o.error=="string"?o.error:"request_failed",t=typeof o.message=="string"?o.message:`Request failed (${e.status})`,{error:r,message:u,...n}=o;return new c(e.status,i,t,n)}function k(e){let o=g(e.baseURL),i=e.fetch??((...n)=>globalThis.fetch(...n));async function t(n,s){let a=s&&Object.keys(s).length?`?${new URLSearchParams(s).toString()}`:"",l=await i(`${o}${n}${a}`,{method:"GET"});if(!l.ok)throw await m(l);return await l.json()}async function r(n,s){let a=await i(`${o}${n}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw await m(a);return await a.json()}let u=encodeURIComponent;return{ok:()=>t("/ok"),tenants:{list:()=>t("/tenants"),create:n=>r("/tenants",n),get:n=>t(`/tenants/${u(n)}`)},plugins:{list:()=>t("/plugins"),get:n=>t(`/plugins/${u(n)}`)},connectionStatus:{get:n=>{let s={};return n?.tenantId&&(s.tenantId=n.tenantId),t("/connection-status",s)}},permissions:{get:n=>"id"in n?t(`/permissions/${u(n.id)}`):r("/permissions/lookup-by-token",{token:n.token})},connect:{createLink:n=>r("/connect/links",n),resolve:n=>t("/connect/resolve",{state:n}),oauthCallback:n=>r("/connect/oauth/callback",n)}}}export{c as a,k as b};
@@ -0,0 +1,76 @@
1
+ import { T as Tenant, C as CreateTenantInput, P as PluginInfo, a as ConnectionStatus, b as PermissionRecord, c as ConnectLink, d as CreateConnectLinkInput, O as OAuthCallbackResult, e as OAuthCallbackInput } from '../../types-BswoTGV5.js';
2
+ export { f as PermissionLookupInput } from '../../types-BswoTGV5.js';
3
+ import { C as CorsairClientOptions, a as CorsairManagementClient } from '../../types-DoUHxHNl.js';
4
+ import '../../index-ggMa1Rj6.js';
5
+ import 'zod';
6
+ import '../../constants-CE0V2QbI.js';
7
+
8
+ type AsyncState<T> = {
9
+ status: 'idle';
10
+ data: null;
11
+ error: null;
12
+ loading: false;
13
+ } | {
14
+ status: 'loading';
15
+ data: null;
16
+ error: null;
17
+ loading: true;
18
+ } | {
19
+ status: 'success';
20
+ data: T;
21
+ error: null;
22
+ loading: false;
23
+ } | {
24
+ status: 'error';
25
+ data: null;
26
+ error: Error;
27
+ loading: false;
28
+ };
29
+ type CorsairReactClientOptions = CorsairClientOptions;
30
+ declare function createCorsairReactClient(opts: CorsairReactClientOptions): {
31
+ client: CorsairManagementClient;
32
+ useTenants: () => AsyncState<Tenant[]> & {
33
+ refetch: () => void;
34
+ };
35
+ useTenant: (id: string) => AsyncState<Tenant> & {
36
+ refetch: () => void;
37
+ };
38
+ useCreateTenant: () => {
39
+ data: Tenant | null;
40
+ loading: boolean;
41
+ error: Error | null;
42
+ mutate: (input: CreateTenantInput) => Promise<Tenant>;
43
+ };
44
+ usePlugins: () => AsyncState<PluginInfo[]> & {
45
+ refetch: () => void;
46
+ };
47
+ usePlugin: (id: string) => AsyncState<PluginInfo> & {
48
+ refetch: () => void;
49
+ };
50
+ useConnectionStatus: (query?: {
51
+ tenantId?: string;
52
+ }) => AsyncState<ConnectionStatus> & {
53
+ refetch: () => void;
54
+ };
55
+ usePermission: (input: {
56
+ id: string;
57
+ } | {
58
+ token: string;
59
+ }) => AsyncState<PermissionRecord> & {
60
+ refetch: () => void;
61
+ };
62
+ useCreateConnectLink: () => {
63
+ data: ConnectLink | null;
64
+ loading: boolean;
65
+ error: Error | null;
66
+ mutate: (input: CreateConnectLinkInput) => Promise<ConnectLink>;
67
+ };
68
+ useOAuthCallback: () => {
69
+ data: OAuthCallbackResult | null;
70
+ loading: boolean;
71
+ error: Error | null;
72
+ mutate: (input: OAuthCallbackInput) => Promise<OAuthCallbackResult>;
73
+ };
74
+ };
75
+
76
+ export { type AsyncState, ConnectLink, ConnectionStatus, type CorsairReactClientOptions, CreateConnectLinkInput, CreateTenantInput, OAuthCallbackInput, OAuthCallbackResult, PermissionRecord, PluginInfo, Tenant, createCorsairReactClient };
@@ -0,0 +1 @@
1
+ import{b as C}from"../../chunk-XLNT2UI2.js";import{useCallback as d,useEffect as m,useReducer as y,useRef as T}from"react";function R(r,t){switch(t.type){case"FETCH":return{status:"loading",data:null,error:null,loading:!0};case"SUCCESS":return{status:"success",data:t.data,error:null,loading:!1};case"ERROR":return{status:"error",data:null,error:t.error,loading:!1};case"RESET":return{status:"idle",data:null,error:null,loading:!1}}}var f={status:"idle",data:null,error:null,loading:!1};function l(r,t){let[a,s]=y(R,f),i=T(r);i.current=r;let e=T(0),u=d(()=>{let c=++e.current;s({type:"FETCH"}),i.current().then(o=>{c===e.current&&s({type:"SUCCESS",data:o})}).catch(o=>{c===e.current&&s({type:"ERROR",error:o instanceof Error?o:new Error(String(o))})})},[]);return m(()=>(u(),()=>{e.current++}),t),{...a,refetch:u}}function p(r){let[t,a]=y(R,f),s=d(async i=>{a({type:"FETCH"});try{let e=await r(i);return a({type:"SUCCESS",data:e}),e}catch(e){let u=e instanceof Error?e:new Error(String(e));throw a({type:"ERROR",error:u}),u}},[]);return{data:t.data,loading:t.loading,error:t.error,mutate:s}}function I(r){let t=C(r);function a(){return l(()=>t.tenants.list(),[])}function s(n){return l(()=>t.tenants.get(n),[n])}function i(){return p(n=>t.tenants.create(n))}function e(){return l(()=>t.plugins.list(),[])}function u(n){return l(()=>t.plugins.get(n),[n])}function c(n){return l(()=>t.connectionStatus.get(n),[n?.tenantId])}function o(n){let A="id"in n?n.id:n.token;return l(()=>t.permissions.get(n),[A])}function g(){return p(n=>t.connect.createLink(n))}function S(){return p(n=>t.connect.oauthCallback(n))}return{client:t,useTenants:a,useTenant:s,useCreateTenant:i,usePlugins:e,usePlugin:u,useConnectionStatus:c,usePermission:o,useCreateConnectLink:g,useOAuthCallback:S}}export{I as createCorsairReactClient};
@@ -0,0 +1,73 @@
1
+ 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
+ declare const BaseProviders: readonly ["ahrefs", "airtable", "amplitude", "asana", "bitwarden", "bluesky", "box", "cal", "calendly", "cloudflare", "cursor", "discord", "dodopayments", "dropbox", "exa", "figma", "firecrawl", "fireflies", "github", "gitlab", "gmail", "googlecalendar", "googledrive", "googlesheets", "grafana", "hackernews", "hubspot", "intercom", "jira", "linear", "monday", "notion", "onedrive", "openweathermap", "oura", "outlook", "pagerduty", "posthog", "razorpay", "reddit", "resend", "sentry", "sharepoint", "slack", "spotify", "strava", "stripe", "tally", "tavily", "teams", "telegram", "todoist", "trello", "twilio", "twitter", "twitterapiio", "typeform", "vapi", "xquik", "youtube", "zendesk", "zohomail", "zoom"];
3
+ declare const ProviderDisplayNames: {
4
+ readonly ahrefs: "Ahrefs";
5
+ readonly airtable: "Airtable";
6
+ readonly amplitude: "Amplitude";
7
+ readonly asana: "Asana";
8
+ readonly bitwarden: "Bitwarden";
9
+ readonly bluesky: "Bluesky";
10
+ readonly box: "Box";
11
+ readonly cal: "Cal";
12
+ readonly calendly: "Calendly";
13
+ readonly cloudflare: "Cloudflare";
14
+ readonly cursor: "Cursor";
15
+ readonly discord: "Discord";
16
+ readonly dodopayments: "Dodo Payments";
17
+ readonly dropbox: "Dropbox";
18
+ readonly exa: "Exa";
19
+ readonly figma: "Figma";
20
+ readonly firecrawl: "Firecrawl";
21
+ readonly fireflies: "Fireflies";
22
+ readonly github: "GitHub";
23
+ readonly gitlab: "GitLab";
24
+ readonly gmail: "Gmail";
25
+ readonly googlecalendar: "Google Calendar";
26
+ readonly googledrive: "Google Drive";
27
+ readonly googlesheets: "Google Sheets";
28
+ readonly grafana: "Grafana";
29
+ readonly hackernews: "Hacker News";
30
+ readonly hubspot: "HubSpot";
31
+ readonly intercom: "Intercom";
32
+ readonly jira: "Jira";
33
+ readonly linear: "Linear";
34
+ readonly monday: "Monday";
35
+ readonly notion: "Notion";
36
+ readonly onedrive: "OneDrive";
37
+ readonly openweathermap: "OpenWeatherMap";
38
+ readonly oura: "Oura";
39
+ readonly outlook: "Outlook";
40
+ readonly pagerduty: "PagerDuty";
41
+ readonly posthog: "PostHog";
42
+ readonly razorpay: "Razorpay";
43
+ readonly reddit: "Reddit";
44
+ readonly resend: "Resend";
45
+ readonly sentry: "Sentry";
46
+ readonly sharepoint: "SharePoint";
47
+ readonly slack: "Slack";
48
+ readonly spotify: "Spotify";
49
+ readonly strava: "Strava";
50
+ readonly stripe: "Stripe";
51
+ readonly tally: "Tally";
52
+ readonly tavily: "Tavily";
53
+ readonly teams: "Teams";
54
+ readonly telegram: "Telegram";
55
+ readonly todoist: "Todoist";
56
+ readonly trello: "Trello";
57
+ readonly twilio: "Twilio";
58
+ readonly twitter: "Twitter";
59
+ readonly twitterapiio: "Twitter API IO";
60
+ readonly typeform: "Typeform";
61
+ readonly vapi: "Vapi";
62
+ readonly xquik: "XQuik";
63
+ readonly youtube: "YouTube";
64
+ readonly zendesk: "Zendesk";
65
+ readonly zohomail: "Zoho Mail";
66
+ readonly zoom: "Zoom";
67
+ };
68
+ declare function formatProviderDisplayName(plugin: string): string;
69
+ type AllProviders = 'ahrefs' | 'airtable' | 'amplitude' | 'asana' | 'bitwarden' | 'bluesky' | 'box' | 'cal' | 'calendly' | 'cloudflare' | 'cursor' | 'discord' | 'dodopayments' | 'dropbox' | 'exa' | 'figma' | 'firecrawl' | 'fireflies' | 'github' | 'gitlab' | 'gmail' | 'googlecalendar' | 'googledrive' | 'googlesheets' | 'grafana' | 'hackernews' | 'hubspot' | 'intercom' | 'jira' | 'linear' | 'monday' | 'notion' | 'onedrive' | 'openweathermap' | 'oura' | 'outlook' | 'pagerduty' | 'posthog' | 'razorpay' | 'reddit' | 'resend' | 'sentry' | 'sharepoint' | 'slack' | 'spotify' | 'strava' | 'stripe' | 'tally' | 'tavily' | 'teams' | 'telegram' | 'todoist' | 'trello' | 'twilio' | 'twitter' | 'twitterapiio' | 'typeform' | 'vapi' | 'xquik' | 'youtube' | 'zendesk' | 'zohomail' | 'zoom' | (string & {});
70
+ type AuthTypes = 'oauth_2' | 'api_key' | 'bot_token' | 'managed';
71
+ type PickAuth<T extends AuthTypes> = T;
72
+
73
+ export { type AuthTypes as A, BaseProviders as B, type PickAuth as P, type AllProviders as a, ProviderDisplayNames as b, type AllErrors as c, formatProviderDisplayName as f };
package/dist/core.d.ts CHANGED
@@ -1,14 +1,18 @@
1
- export { C as CORSAIR_INTERNAL, a as CorsairInternalConfig, c as createCorsair } from './index-BOgiPWN6.js';
1
+ export { C as CORSAIR_INTERNAL, a as CorsairInternalConfig, c as createCorsair } from './index-dta3YWl8.js';
2
2
  import { CorsairDatabase } from './db.js';
3
- import { A as AuthTypes, a as AccountKeyManagerFor, I as IntegrationKeyManagerFor } from './types-C2vFipdU.js';
4
- export { b as AccountFieldNames, f as AllProviders, e as BASE_AUTH_FIELDS, B as BaseAuthFieldConfig, c as BaseKeyManager, g as BaseProviders, k as Bivariant, d as IntegrationFieldNames, O as OAuth2IntegrationCredentials, h as PickAuth, P as PluginAuthConfig, j as ProviderDisplayNames, U as UnionToIntersection, i as formatProviderDisplayName } from './types-C2vFipdU.js';
5
- export { v as BeforeHookResult, B as BindEndpoints, N as BindWebhooks, h as BoundEndpointFn, i as BoundEndpointTree, Q as BoundWebhook, S as BoundWebhookTree, g as CorsairClient, j as CorsairContext, k as CorsairEndpoint, m as CorsairErrorHandler, c as CorsairIntegration, w as CorsairKeyBuilder, x as CorsairKeyBuilderBase, U as CorsairOAuthWebhookTenantLinkResolver, s as CorsairPermissionsNamespace, C as CorsairPlugin, y as CorsairPluginContext, e as CorsairSingleTenantClient, d as CorsairTenantWrapper, V as CorsairWebhook, X as CorsairWebhookHandler, Y as CorsairWebhookMatcher, Z as CorsairWebhookTenantMatcher, z as EndpointHooks, A as EndpointMetaEntry, E as EndpointPathsOf, D as EndpointRiskLevel, l as EndpointTree, t as EnforcePermissionOptions, u as EnforcePermissionResult, n as ErrorContext, o as ErrorHandler, p as ErrorHandlerAndMatchFunction, q as ErrorMatcher, K as KeyBuilderContext, O as OAuthConfig, P as PermissionMode, F as PermissionPolicy, G as PluginEndpointMeta, H as PluginPermissionsConfig, _ as RawWebhookRequest, I as RequiredPluginEndpointMeta, J as RequiredPluginEndpointSchemas, L as RequiredPluginWebhookSchemas, R as RetryStrategies, r as RetryStrategy, T as TokenResponse, M as WebhookHooks, $ as WebhookPathsOf, a0 as WebhookRequest, a1 as WebhookResponse, W as WebhookTenantMatch, a2 as WebhookTree, f as exchangeCodeForTokens } from './index-Cs2O9Pmx.js';
6
- export { A as AuthMissingError, D as DocSchemaFieldRow, a as DocSchemaShape, b as DocsApiEndpoint, c as DocsDbEntity, d as DocsDbFilterField, e as DocsWebhook, E as EndpointSchemaResult, I as IntrospectPluginForDocsResult, L as ListOperationsOptions, P as PluginDocsIntrospection, j as PluginWebhookMatchers, R as ResolveConnectLinkResult, W as WebhookPluginTenantMatch, k as asRecord, g as collectPluginWebhookMatchers, l as decodePubSubData, n as extractMicrosoftGraphValidationToken, o as firstString, f as formatDocSchemaShape, p as getHeader, i as introspectPluginForDocs, q as isMicrosoftGraphValidationHandshake, m as matchWebhookPlugin, h as matchWebhookPluginAndTenant, s as readBodyRecord, t as readQueryParam, r as resolveConnectLink, u as toExternalId } from './tenant-match-utils-CHQomRrU.js';
3
+ import { A as AccountKeyManagerFor, I as IntegrationKeyManagerFor } from './types-BY2SDx3_.js';
4
+ export { a as AccountFieldNames, d as BASE_AUTH_FIELDS, B as BaseAuthFieldConfig, b as BaseKeyManager, e as Bivariant, c as IntegrationFieldNames, O as OAuth2IntegrationCredentials, P as PluginAuthConfig, U as UnionToIntersection } from './types-BY2SDx3_.js';
5
+ export { v as BeforeHookResult, B as BindEndpoints, N as BindWebhooks, h as BoundEndpointFn, i as BoundEndpointTree, Q as BoundWebhook, S as BoundWebhookTree, g as CorsairClient, j as CorsairContext, k as CorsairEndpoint, m as CorsairErrorHandler, c as CorsairIntegration, w as CorsairKeyBuilder, x as CorsairKeyBuilderBase, U as CorsairOAuthWebhookTenantLinkResolver, s as CorsairPermissionsNamespace, C as CorsairPlugin, y as CorsairPluginContext, e as CorsairSingleTenantClient, d as CorsairTenantWrapper, V as CorsairWebhook, X as CorsairWebhookHandler, Y as CorsairWebhookMatcher, Z as CorsairWebhookTenantMatcher, z as EndpointHooks, A as EndpointMetaEntry, E as EndpointPathsOf, D as EndpointRiskLevel, l as EndpointTree, t as EnforcePermissionOptions, u as EnforcePermissionResult, n as ErrorContext, o as ErrorHandler, p as ErrorHandlerAndMatchFunction, q as ErrorMatcher, K as KeyBuilderContext, O as OAuthConfig, P as PermissionMode, F as PermissionPolicy, G as PluginEndpointMeta, H as PluginPermissionsConfig, _ as RawWebhookRequest, I as RequiredPluginEndpointMeta, J as RequiredPluginEndpointSchemas, L as RequiredPluginWebhookSchemas, R as RetryStrategies, r as RetryStrategy, T as TokenResponse, M as WebhookHooks, $ as WebhookPathsOf, a0 as WebhookRequest, a1 as WebhookResponse, W as WebhookTenantMatch, a2 as WebhookTree, f as exchangeCodeForTokens } from './index-x-RG0TdQ.js';
6
+ export { A as AuthMissingError, D as DocSchemaFieldRow, a as DocSchemaShape, b as DocsApiEndpoint, c as DocsDbEntity, d as DocsDbFilterField, e as DocsWebhook, E as EndpointSchemaResult, I as IntrospectPluginForDocsResult, L as ListOperationsOptions, P as PluginDocsIntrospection, j as PluginWebhookMatchers, R as ResolveConnectLinkResult, W as WebhookPluginTenantMatch, k as asRecord, g as collectPluginWebhookMatchers, l as decodePubSubData, n as extractMicrosoftGraphValidationToken, o as firstString, f as formatDocSchemaShape, p as getHeader, i as introspectPluginForDocs, q as isMicrosoftGraphValidationHandshake, m as matchWebhookPlugin, h as matchWebhookPluginAndTenant, s as readBodyRecord, t as readQueryParam, r as resolveConnectLink, u as toExternalId } from './tenant-match-utils-DhF58Vo8.js';
7
+ import { A as AuthTypes } from './constants-CE0V2QbI.js';
8
+ export { a as AllProviders, B as BaseProviders, P as PickAuth, b as ProviderDisplayNames, f as formatProviderDisplayName } from './constants-CE0V2QbI.js';
7
9
  import 'kysely';
10
+ import './index-ggMa1Rj6.js';
8
11
  import 'zod';
9
12
  import 'pg';
10
13
  import 'postgres';
11
14
  import './orm.js';
15
+ import './types-BswoTGV5.js';
12
16
 
13
17
  /**
14
18
  * Context interface with account ID resolver for logging events.
package/dist/db.d.ts CHANGED
@@ -1,151 +1,10 @@
1
1
  import { Kysely, SqliteDialectConfig } from 'kysely';
2
2
  export { sql } from 'kysely';
3
- import { z } from 'zod';
3
+ import { b as CorsairIntegration, C as CorsairAccount, c as CorsairEntity, d as CorsairEvent, a as CorsairPermission } from './index-ggMa1Rj6.js';
4
+ export { n as CorsairAccountInsert, t as CorsairAccountUpdate, f as CorsairAccountsSchema, g as CorsairEntitiesSchema, o as CorsairEntityInsert, u as CorsairEntityUpdate, p as CorsairEventInsert, v as CorsairEventUpdate, h as CorsairEventsSchema, m as CorsairIntegrationInsert, s as CorsairIntegrationUpdate, e as CorsairIntegrationsSchema, j as CorsairPermissionInsert, i as CorsairPermissionsSchema, q as CorsairTableInsert, k as CorsairTableName, l as CorsairTableRow, w as CorsairTableUpdate, r as TableInsertType, T as TableRowType, x as TableUpdateType } from './index-ggMa1Rj6.js';
4
5
  import { Pool } from 'pg';
5
6
  import { Sql } from 'postgres';
6
-
7
- declare const CorsairIntegrationsSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- created_at: z.ZodCoercedDate<unknown>;
10
- updated_at: z.ZodCoercedDate<unknown>;
11
- name: z.ZodString;
12
- config: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
13
- dek: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
- }, z.core.$strip>;
15
- type CorsairIntegration = z.infer<typeof CorsairIntegrationsSchema>;
16
- declare const CorsairAccountsSchema: z.ZodObject<{
17
- id: z.ZodString;
18
- created_at: z.ZodCoercedDate<unknown>;
19
- updated_at: z.ZodCoercedDate<unknown>;
20
- tenant_id: z.ZodString;
21
- integration_id: z.ZodString;
22
- config: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
23
- dek: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
- }, z.core.$strip>;
25
- type CorsairAccount = z.infer<typeof CorsairAccountsSchema>;
26
- declare const CorsairEntitiesSchema: z.ZodObject<{
27
- id: z.ZodString;
28
- created_at: z.ZodCoercedDate<unknown>;
29
- updated_at: z.ZodCoercedDate<unknown>;
30
- account_id: z.ZodString;
31
- entity_id: z.ZodString;
32
- entity_type: z.ZodString;
33
- version: z.ZodString;
34
- data: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
35
- }, z.core.$strip>;
36
- type CorsairEntity = z.infer<typeof CorsairEntitiesSchema>;
37
- declare const CorsairEventsSchema: z.ZodObject<{
38
- id: z.ZodString;
39
- created_at: z.ZodCoercedDate<unknown>;
40
- updated_at: z.ZodCoercedDate<unknown>;
41
- account_id: z.ZodString;
42
- event_type: z.ZodString;
43
- payload: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
44
- status: z.ZodOptional<z.ZodEnum<{
45
- pending: "pending";
46
- processing: "processing";
47
- completed: "completed";
48
- failed: "failed";
49
- }>>;
50
- }, z.core.$strip>;
51
- type CorsairEvent = z.infer<typeof CorsairEventsSchema>;
52
- declare const CorsairPermissionsSchema: z.ZodObject<{
53
- id: z.ZodString;
54
- created_at: z.ZodCoercedDate<unknown>;
55
- updated_at: z.ZodCoercedDate<unknown>;
56
- token: z.ZodString;
57
- plugin: z.ZodString;
58
- endpoint: z.ZodString;
59
- args: z.ZodString;
60
- tenant_id: z.ZodString;
61
- status: z.ZodDefault<z.ZodEnum<{
62
- pending: "pending";
63
- completed: "completed";
64
- failed: "failed";
65
- approved: "approved";
66
- executing: "executing";
67
- denied: "denied";
68
- expired: "expired";
69
- }>>;
70
- expires_at: z.ZodString;
71
- error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
- }, z.core.$strip>;
73
- type CorsairPermission = z.infer<typeof CorsairPermissionsSchema>;
74
- type CorsairPermissionInsert = {
75
- id?: string;
76
- created_at?: Date;
77
- updated_at?: Date;
78
- token: string;
79
- plugin: string;
80
- endpoint: string;
81
- args: string;
82
- tenant_id?: string;
83
- status?: 'pending' | 'approved' | 'executing' | 'completed' | 'denied' | 'expired' | 'failed';
84
- expires_at: string;
85
- error?: string | null;
86
- };
87
- type CorsairTableName = 'corsair_integrations' | 'corsair_accounts' | 'corsair_entities' | 'corsair_events' | 'corsair_permissions' | (string & {});
88
- type CorsairTableRow = {
89
- corsair_integrations: CorsairIntegration;
90
- corsair_accounts: CorsairAccount;
91
- corsair_entities: CorsairEntity;
92
- corsair_events: CorsairEvent;
93
- };
94
- type TableRowType<T extends CorsairTableName> = T extends keyof CorsairTableRow ? CorsairTableRow[T] : Record<string, unknown>;
95
- type CorsairIntegrationInsert = {
96
- id?: string;
97
- created_at?: Date;
98
- updated_at?: Date;
99
- name: string;
100
- config: Record<string, unknown>;
101
- dek?: string;
102
- };
103
- type CorsairAccountInsert = {
104
- id?: string;
105
- created_at?: Date;
106
- updated_at?: Date;
107
- tenant_id: string;
108
- integration_id: string;
109
- config: Record<string, unknown>;
110
- dek?: string;
111
- };
112
- type CorsairEntityInsert = {
113
- id?: string;
114
- created_at?: Date;
115
- updated_at?: Date;
116
- account_id: string;
117
- entity_id: string;
118
- entity_type: string;
119
- version: string;
120
- data: Record<string, unknown>;
121
- };
122
- type CorsairEventInsert = {
123
- id?: string;
124
- created_at?: Date;
125
- updated_at?: Date;
126
- account_id: string;
127
- event_type: string;
128
- payload: Record<string, unknown>;
129
- status?: 'pending' | 'processing' | 'completed' | 'failed';
130
- };
131
- type CorsairTableInsert = {
132
- corsair_integrations: CorsairIntegrationInsert;
133
- corsair_accounts: CorsairAccountInsert;
134
- corsair_entities: CorsairEntityInsert;
135
- corsair_events: CorsairEventInsert;
136
- };
137
- type TableInsertType<T extends CorsairTableName> = T extends keyof CorsairTableInsert ? CorsairTableInsert[T] : Record<string, unknown>;
138
- type CorsairIntegrationUpdate = Partial<Omit<CorsairIntegration, 'id' | 'created_at'>>;
139
- type CorsairAccountUpdate = Partial<Omit<CorsairAccount, 'id' | 'created_at'>>;
140
- type CorsairEntityUpdate = Partial<Omit<CorsairEntity, 'id' | 'created_at'>>;
141
- type CorsairEventUpdate = Partial<Omit<CorsairEvent, 'id' | 'created_at'>>;
142
- type CorsairTableUpdate = {
143
- corsair_integrations: CorsairIntegrationUpdate;
144
- corsair_accounts: CorsairAccountUpdate;
145
- corsair_entities: CorsairEntityUpdate;
146
- corsair_events: CorsairEventUpdate;
147
- };
148
- type TableUpdateType<T extends CorsairTableName> = T extends keyof CorsairTableUpdate ? CorsairTableUpdate[T] : Record<string, unknown>;
7
+ import 'zod';
149
8
 
150
9
  type CorsairKyselyDatabase = {
151
10
  corsair_integrations: CorsairIntegration;
@@ -165,4 +24,4 @@ type BetterSqlite3Database = NonNullable<SqliteDialectConfig['database']>;
165
24
  type CorsairDatabaseInput = Pool | BetterSqlite3Database | Sql | Kysely<CorsairKyselyDatabase>;
166
25
  declare function createCorsairDatabase(input: CorsairDatabaseInput): CorsairDatabase;
167
26
 
168
- export { type CorsairAccount, type CorsairAccountInsert, type CorsairAccountUpdate, CorsairAccountsSchema, type CorsairDatabase, type CorsairDatabaseInput, CorsairEntitiesSchema, type CorsairEntity, type CorsairEntityInsert, type CorsairEntityUpdate, type CorsairEvent, type CorsairEventInsert, type CorsairEventUpdate, CorsairEventsSchema, type CorsairIntegration, type CorsairIntegrationInsert, type CorsairIntegrationUpdate, CorsairIntegrationsSchema, type CorsairKyselyDatabase, type CorsairPermission, type CorsairPermissionInsert, CorsairPermissionsSchema, type CorsairTableInsert, type CorsairTableName, type CorsairTableRow, type CorsairTableUpdate, type TableInsertType, type TableRowType, type TableUpdateType, createCorsairDatabase };
27
+ export { CorsairAccount, type CorsairDatabase, type CorsairDatabaseInput, CorsairEntity, CorsairEvent, CorsairIntegration, type CorsairKyselyDatabase, CorsairPermission, createCorsairDatabase };
package/dist/hub.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { n as HubOAuthMode, o as HubConnectSessionResult, p as HubPermissionSessionResult, q as HubConnectSource, H as HubConfig, m as HubConfigInput, r as HubConnectSessionInput, a as AccountKeyManagerFor, s as HubPermissionSessionInput } from './types-C2vFipdU.js';
2
- export { D as DEFAULT_HUB_API_URL, i as formatProviderDisplayName } from './types-C2vFipdU.js';
1
+ export { f as formatProviderDisplayName } from './constants-CE0V2QbI.js';
2
+ import { g as HubOAuthMode, h as HubConnectSessionResult, i as HubPermissionSessionResult, j as HubConnectSource, H as HubConfig, f as HubConfigInput, k as HubConnectSessionInput, A as AccountKeyManagerFor, l as HubPermissionSessionInput } from './types-BY2SDx3_.js';
3
+ export { D as DEFAULT_HUB_API_URL } from './types-BY2SDx3_.js';
3
4
  import { e as TunnelType, c as ProcessCorsairRequest } from './index-LpuBJQ1m.js';
4
5
  export { f as BROWSER_DELIVERY_TTL_MS, g as BrowserDeliveryMode, B as BrowserDeliveryPayload, S as SIGNED_TUNNEL_REPLAY_WINDOW_MS, d as TunnelEnvelope } from './index-LpuBJQ1m.js';
5
6
  export { b as buildBrowserDeliveryRedirectUrl, s as signBrowserDeliveryToken, v as verifyBrowserDeliveryToken } from './browser-delivery-CvBUoA96.js';
@@ -1,6 +1,6 @@
1
1
  import { CorsairDatabase } from './db.js';
2
- import { H as HubConfig } from './types-C2vFipdU.js';
3
- import { C as CorsairPlugin, a as CorsairPermissionsOptions, b as CorsairManualConfig, c as CorsairIntegration, d as CorsairTenantWrapper, e as CorsairSingleTenantClient } from './index-Cs2O9Pmx.js';
2
+ import { H as HubConfig } from './types-BY2SDx3_.js';
3
+ import { C as CorsairPlugin, a as CorsairPermissionsOptions, b as CorsairManualConfig, c as CorsairIntegration, d as CorsairTenantWrapper, e as CorsairSingleTenantClient } from './index-x-RG0TdQ.js';
4
4
 
5
5
  declare const CORSAIR_INTERNAL: unique symbol;
6
6
  type CorsairInternalConfig = {
@@ -0,0 +1,146 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const CorsairIntegrationsSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ created_at: z.ZodCoercedDate<unknown>;
6
+ updated_at: z.ZodCoercedDate<unknown>;
7
+ name: z.ZodString;
8
+ config: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
9
+ dek: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ }, z.core.$strip>;
11
+ type CorsairIntegration = z.infer<typeof CorsairIntegrationsSchema>;
12
+ declare const CorsairAccountsSchema: z.ZodObject<{
13
+ id: z.ZodString;
14
+ created_at: z.ZodCoercedDate<unknown>;
15
+ updated_at: z.ZodCoercedDate<unknown>;
16
+ tenant_id: z.ZodString;
17
+ integration_id: z.ZodString;
18
+ config: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
19
+ dek: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ }, z.core.$strip>;
21
+ type CorsairAccount = z.infer<typeof CorsairAccountsSchema>;
22
+ declare const CorsairEntitiesSchema: z.ZodObject<{
23
+ id: z.ZodString;
24
+ created_at: z.ZodCoercedDate<unknown>;
25
+ updated_at: z.ZodCoercedDate<unknown>;
26
+ account_id: z.ZodString;
27
+ entity_id: z.ZodString;
28
+ entity_type: z.ZodString;
29
+ version: z.ZodString;
30
+ data: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
31
+ }, z.core.$strip>;
32
+ type CorsairEntity = z.infer<typeof CorsairEntitiesSchema>;
33
+ declare const CorsairEventsSchema: z.ZodObject<{
34
+ id: z.ZodString;
35
+ created_at: z.ZodCoercedDate<unknown>;
36
+ updated_at: z.ZodCoercedDate<unknown>;
37
+ account_id: z.ZodString;
38
+ event_type: z.ZodString;
39
+ payload: z.ZodPipe<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, z.ZodTransform<Record<string, unknown>, Record<string, unknown> | null>>;
40
+ status: z.ZodOptional<z.ZodEnum<{
41
+ pending: "pending";
42
+ processing: "processing";
43
+ completed: "completed";
44
+ failed: "failed";
45
+ }>>;
46
+ }, z.core.$strip>;
47
+ type CorsairEvent = z.infer<typeof CorsairEventsSchema>;
48
+ declare const CorsairPermissionsSchema: z.ZodObject<{
49
+ id: z.ZodString;
50
+ created_at: z.ZodCoercedDate<unknown>;
51
+ updated_at: z.ZodCoercedDate<unknown>;
52
+ token: z.ZodString;
53
+ plugin: z.ZodString;
54
+ endpoint: z.ZodString;
55
+ args: z.ZodString;
56
+ tenant_id: z.ZodString;
57
+ status: z.ZodDefault<z.ZodEnum<{
58
+ pending: "pending";
59
+ completed: "completed";
60
+ failed: "failed";
61
+ approved: "approved";
62
+ executing: "executing";
63
+ denied: "denied";
64
+ expired: "expired";
65
+ }>>;
66
+ expires_at: z.ZodString;
67
+ error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
+ }, z.core.$strip>;
69
+ type CorsairPermission = z.infer<typeof CorsairPermissionsSchema>;
70
+ type CorsairPermissionInsert = {
71
+ id?: string;
72
+ created_at?: Date;
73
+ updated_at?: Date;
74
+ token: string;
75
+ plugin: string;
76
+ endpoint: string;
77
+ args: string;
78
+ tenant_id?: string;
79
+ status?: 'pending' | 'approved' | 'executing' | 'completed' | 'denied' | 'expired' | 'failed';
80
+ expires_at: string;
81
+ error?: string | null;
82
+ };
83
+ type CorsairTableName = 'corsair_integrations' | 'corsair_accounts' | 'corsair_entities' | 'corsair_events' | 'corsair_permissions' | (string & {});
84
+ type CorsairTableRow = {
85
+ corsair_integrations: CorsairIntegration;
86
+ corsair_accounts: CorsairAccount;
87
+ corsair_entities: CorsairEntity;
88
+ corsair_events: CorsairEvent;
89
+ };
90
+ type TableRowType<T extends CorsairTableName> = T extends keyof CorsairTableRow ? CorsairTableRow[T] : Record<string, unknown>;
91
+ type CorsairIntegrationInsert = {
92
+ id?: string;
93
+ created_at?: Date;
94
+ updated_at?: Date;
95
+ name: string;
96
+ config: Record<string, unknown>;
97
+ dek?: string;
98
+ };
99
+ type CorsairAccountInsert = {
100
+ id?: string;
101
+ created_at?: Date;
102
+ updated_at?: Date;
103
+ tenant_id: string;
104
+ integration_id: string;
105
+ config: Record<string, unknown>;
106
+ dek?: string;
107
+ };
108
+ type CorsairEntityInsert = {
109
+ id?: string;
110
+ created_at?: Date;
111
+ updated_at?: Date;
112
+ account_id: string;
113
+ entity_id: string;
114
+ entity_type: string;
115
+ version: string;
116
+ data: Record<string, unknown>;
117
+ };
118
+ type CorsairEventInsert = {
119
+ id?: string;
120
+ created_at?: Date;
121
+ updated_at?: Date;
122
+ account_id: string;
123
+ event_type: string;
124
+ payload: Record<string, unknown>;
125
+ status?: 'pending' | 'processing' | 'completed' | 'failed';
126
+ };
127
+ type CorsairTableInsert = {
128
+ corsair_integrations: CorsairIntegrationInsert;
129
+ corsair_accounts: CorsairAccountInsert;
130
+ corsair_entities: CorsairEntityInsert;
131
+ corsair_events: CorsairEventInsert;
132
+ };
133
+ type TableInsertType<T extends CorsairTableName> = T extends keyof CorsairTableInsert ? CorsairTableInsert[T] : Record<string, unknown>;
134
+ type CorsairIntegrationUpdate = Partial<Omit<CorsairIntegration, 'id' | 'created_at'>>;
135
+ type CorsairAccountUpdate = Partial<Omit<CorsairAccount, 'id' | 'created_at'>>;
136
+ type CorsairEntityUpdate = Partial<Omit<CorsairEntity, 'id' | 'created_at'>>;
137
+ type CorsairEventUpdate = Partial<Omit<CorsairEvent, 'id' | 'created_at'>>;
138
+ type CorsairTableUpdate = {
139
+ corsair_integrations: CorsairIntegrationUpdate;
140
+ corsair_accounts: CorsairAccountUpdate;
141
+ corsair_entities: CorsairEntityUpdate;
142
+ corsair_events: CorsairEventUpdate;
143
+ };
144
+ type TableUpdateType<T extends CorsairTableName> = T extends keyof CorsairTableUpdate ? CorsairTableUpdate[T] : Record<string, unknown>;
145
+
146
+ export { type CorsairAccount as C, type TableRowType as T, type CorsairPermission as a, type CorsairIntegration as b, type CorsairEntity as c, type CorsairEvent as d, CorsairIntegrationsSchema as e, CorsairAccountsSchema as f, CorsairEntitiesSchema as g, CorsairEventsSchema as h, CorsairPermissionsSchema as i, type CorsairPermissionInsert as j, type CorsairTableName as k, type CorsairTableRow as l, type CorsairIntegrationInsert as m, type CorsairAccountInsert as n, type CorsairEntityInsert as o, type CorsairEventInsert as p, type CorsairTableInsert as q, type TableInsertType as r, type CorsairIntegrationUpdate as s, type CorsairAccountUpdate as t, type CorsairEntityUpdate as u, type CorsairEventUpdate as v, type CorsairTableUpdate as w, type TableUpdateType as x };
@@ -1,7 +1,10 @@
1
1
  import { ZodTypeAny } from 'zod';
2
- import { CorsairDatabase, CorsairPermission, CorsairDatabaseInput } from './db.js';
2
+ import { CorsairDatabase, CorsairDatabaseInput } from './db.js';
3
3
  import { CorsairPluginSchema, PluginEntityClients } from './orm.js';
4
- import { l as AllErrors, A as AuthTypes, a as AccountKeyManagerFor, P as PluginAuthConfig, I as IntegrationKeyManagerFor, f as AllProviders, H as HubConfig, m as HubConfigInput } from './types-C2vFipdU.js';
4
+ import { c as AllErrors, A as AuthTypes, a as AllProviders } from './constants-CE0V2QbI.js';
5
+ import { A as AccountKeyManagerFor, P as PluginAuthConfig, I as IntegrationKeyManagerFor, H as HubConfig, f as HubConfigInput } from './types-BY2SDx3_.js';
6
+ import { M as ManagementOk, T as Tenant, C as CreateTenantInput, P as PluginInfo, a as ConnectionStatus, f as PermissionLookupInput, b as PermissionRecord, d as CreateConnectLinkInput, c as ConnectLink, R as ResolvedConnectLink, e as OAuthCallbackInput, O as OAuthCallbackResult } from './types-BswoTGV5.js';
7
+ import { a as CorsairPermission } from './index-ggMa1Rj6.js';
5
8
 
6
9
  /**
7
10
  * Bivariance hack for function types to ensure proper type inference.
@@ -134,73 +137,6 @@ type CorsairErrorHandler = {
134
137
  [K in AllErrors]?: ErrorHandlerAndMatchFunction;
135
138
  };
136
139
 
137
- type Tenant = {
138
- id: string;
139
- accounts: Array<{
140
- integrationName: string;
141
- hasCredentials: boolean;
142
- }>;
143
- connectedPlugins: string[];
144
- };
145
- type CreateTenantInput = {
146
- id: string;
147
- };
148
- type PluginInfo = {
149
- id: string;
150
- authType: AuthTypes | null;
151
- configured: boolean;
152
- missingFields: string[];
153
- oauth: {
154
- providerName: string;
155
- scopes: string[];
156
- requiresRegisteredRedirect: boolean;
157
- } | null;
158
- };
159
- type PluginConnectionState = 'connected' | 'missing_credentials' | 'not_connected';
160
- type ConnectionStatus = Record<string, PluginConnectionState>;
161
- type ManagementOk = {
162
- ok: true;
163
- };
164
- type PermissionRecord = CorsairPermission & {
165
- /** Resolved review URL for pending/approved records. Null when not actionable or not configured. */
166
- approvalUrl: string | null;
167
- };
168
- type PermissionLookupInput = {
169
- id: string;
170
- } | {
171
- token: string;
172
- };
173
- type CreateConnectLinkInput = {
174
- /** Required in manual mode. Optional in hub mode (omit to connect all plugins). */
175
- plugin?: string;
176
- tenantId?: string;
177
- /** Hub mode only — BYO uses your OAuth app; managed uses Corsair's. */
178
- oauthMode?: 'byo' | 'managed';
179
- /** Hub mode only — inferred from deliveryUrl when omitted. */
180
- source?: 'client' | 'server';
181
- /** Hub mode only — override the provider display name. */
182
- providerName?: string;
183
- };
184
- type ConnectLink = {
185
- connectUrl: string;
186
- expiresAt?: string;
187
- };
188
- type ResolvedConnectLink = {
189
- plugin: string;
190
- tenantId: string;
191
- providerName: string;
192
- oauthUrl: string;
193
- state: string;
194
- };
195
- type OAuthCallbackInput = {
196
- code: string;
197
- state: string;
198
- };
199
- type OAuthCallbackResult = {
200
- plugin: string;
201
- tenantId: string;
202
- };
203
-
204
140
  type CorsairManageNamespace = {
205
141
  ok: () => ManagementOk;
206
142
  tenants: {
@@ -1190,4 +1126,4 @@ type CorsairDeprecatedApprovalConfig = {
1190
1126
  approval?: CorsairPermissionsOptions;
1191
1127
  };
1192
1128
 
1193
- export { type WebhookPathsOf as $, type EndpointMetaEntry as A, type BindEndpoints as B, type CorsairPlugin as C, type EndpointRiskLevel as D, type EndpointPathsOf as E, type PermissionPolicy as F, type PluginEndpointMeta as G, type PluginPermissionsConfig as H, type RequiredPluginEndpointMeta as I, type RequiredPluginEndpointSchemas as J, type KeyBuilderContext as K, type RequiredPluginWebhookSchemas as L, type WebhookHooks as M, type BindWebhooks as N, type OAuthConfig as O, type PermissionMode as P, type BoundWebhook as Q, type RetryStrategies as R, type BoundWebhookTree as S, type TokenResponse as T, type CorsairOAuthWebhookTenantLinkResolver as U, type CorsairWebhook as V, type WebhookTenantMatch as W, type CorsairWebhookHandler as X, type CorsairWebhookMatcher as Y, type CorsairWebhookTenantMatcher as Z, type RawWebhookRequest as _, type CorsairPermissionsOptions as a, type WebhookRequest as a0, type WebhookResponse as a1, type WebhookTree as a2, type ManagementOk as a3, type Tenant as a4, type CreateTenantInput as a5, type PluginInfo as a6, type ConnectionStatus as a7, type PermissionLookupInput as a8, type PermissionRecord as a9, type CreateConnectLinkInput as aa, type ConnectLink as ab, type ResolvedConnectLink as ac, type OAuthCallbackInput as ad, type OAuthCallbackResult as ae, type CorsairManageNamespace as af, type PluginConnectionState as ag, type CorsairManualConfig as b, type CorsairIntegration as c, type CorsairTenantWrapper as d, type CorsairSingleTenantClient as e, exchangeCodeForTokens as f, type CorsairClient as g, type BoundEndpointFn as h, type BoundEndpointTree as i, type CorsairContext as j, type CorsairEndpoint as k, type EndpointTree as l, type CorsairErrorHandler as m, type ErrorContext as n, type ErrorHandler as o, type ErrorHandlerAndMatchFunction as p, type ErrorMatcher as q, type RetryStrategy as r, type CorsairPermissionsNamespace as s, type EnforcePermissionOptions as t, type EnforcePermissionResult as u, type BeforeHookResult as v, type CorsairKeyBuilder as w, type CorsairKeyBuilderBase as x, type CorsairPluginContext as y, type EndpointHooks as z };
1129
+ export { type WebhookPathsOf as $, type EndpointMetaEntry as A, type BindEndpoints as B, type CorsairPlugin as C, type EndpointRiskLevel as D, type EndpointPathsOf as E, type PermissionPolicy as F, type PluginEndpointMeta as G, type PluginPermissionsConfig as H, type RequiredPluginEndpointMeta as I, type RequiredPluginEndpointSchemas as J, type KeyBuilderContext as K, type RequiredPluginWebhookSchemas as L, type WebhookHooks as M, type BindWebhooks as N, type OAuthConfig as O, type PermissionMode as P, type BoundWebhook as Q, type RetryStrategies as R, type BoundWebhookTree as S, type TokenResponse as T, type CorsairOAuthWebhookTenantLinkResolver as U, type CorsairWebhook as V, type WebhookTenantMatch as W, type CorsairWebhookHandler as X, type CorsairWebhookMatcher as Y, type CorsairWebhookTenantMatcher as Z, type RawWebhookRequest as _, type CorsairPermissionsOptions as a, type WebhookRequest as a0, type WebhookResponse as a1, type WebhookTree as a2, type CorsairManageNamespace as a3, type CorsairManualConfig as b, type CorsairIntegration as c, type CorsairTenantWrapper as d, type CorsairSingleTenantClient as e, exchangeCodeForTokens as f, type CorsairClient as g, type BoundEndpointFn as h, type BoundEndpointTree as i, type CorsairContext as j, type CorsairEndpoint as k, type EndpointTree as l, type CorsairErrorHandler as m, type ErrorContext as n, type ErrorHandler as o, type ErrorHandlerAndMatchFunction as p, type ErrorMatcher as q, type RetryStrategy as r, type CorsairPermissionsNamespace as s, type EnforcePermissionOptions as t, type EnforcePermissionResult as u, type BeforeHookResult as v, type CorsairKeyBuilder as w, type CorsairKeyBuilderBase as x, type CorsairPluginContext as y, type EndpointHooks as z };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,22 @@
1
- import { a3 as ManagementOk, a4 as Tenant, a5 as CreateTenantInput, a6 as PluginInfo, a7 as ConnectionStatus, a8 as PermissionLookupInput, a9 as PermissionRecord, aa as CreateConnectLinkInput, ab as ConnectLink, ac as ResolvedConnectLink, ad as OAuthCallbackInput, ae as OAuthCallbackResult, e as CorsairSingleTenantClient, C as CorsairPlugin, d as CorsairTenantWrapper, g as CorsairClient, s as CorsairPermissionsNamespace, S as BoundWebhookTree, _ as RawWebhookRequest, Z as CorsairWebhookTenantMatcher, a1 as WebhookResponse } from './index-Cs2O9Pmx.js';
2
- export { af as CorsairManageNamespace, b as CorsairManualConfig, a as CorsairPermissionsOptions, ag as PluginConnectionState } from './index-Cs2O9Pmx.js';
3
- export { c as createCorsair } from './index-BOgiPWN6.js';
4
- import { F as FormFieldSchema, L as ListOperationsOptions } from './tenant-match-utils-CHQomRrU.js';
5
- export { A as AuthMissingError, j as PluginWebhookMatchers, R as ResolveConnectLinkResult, W as WebhookPluginTenantMatch, k as asRecord, g as collectPluginWebhookMatchers, l as decodePubSubData, o as firstString, f as formatDocSchemaShape, p as getHeader, m as matchWebhookPlugin, h as matchWebhookPluginAndTenant, s as readBodyRecord, r as resolveConnectLink, u as toExternalId } from './tenant-match-utils-CHQomRrU.js';
1
+ import { C as CorsairClientOptions, a as CorsairManagementClient } from './types-DoUHxHNl.js';
2
+ export { b as CorsairClientError } from './types-DoUHxHNl.js';
3
+ export { c as createCorsair } from './index-dta3YWl8.js';
4
+ import { e as CorsairSingleTenantClient, C as CorsairPlugin, d as CorsairTenantWrapper, g as CorsairClient, s as CorsairPermissionsNamespace, S as BoundWebhookTree, _ as RawWebhookRequest, Z as CorsairWebhookTenantMatcher, a1 as WebhookResponse } from './index-x-RG0TdQ.js';
5
+ export { a3 as CorsairManageNamespace, b as CorsairManualConfig, a as CorsairPermissionsOptions } from './index-x-RG0TdQ.js';
6
+ import { F as FormFieldSchema, L as ListOperationsOptions } from './tenant-match-utils-DhF58Vo8.js';
7
+ export { A as AuthMissingError, j as PluginWebhookMatchers, R as ResolveConnectLinkResult, W as WebhookPluginTenantMatch, k as asRecord, g as collectPluginWebhookMatchers, l as decodePubSubData, o as firstString, f as formatDocSchemaShape, p as getHeader, m as matchWebhookPlugin, h as matchWebhookPluginAndTenant, s as readBodyRecord, r as resolveConnectLink, u as toExternalId } from './tenant-match-utils-DhF58Vo8.js';
6
8
  export { SetupCorsairOptions, setupCorsair } from './setup.js';
7
9
  export { O as OAuthCallbackTunnelPayload, P as ProcessCorsairOptions, c as ProcessCorsairRequest, T as TunnelAck, d as TunnelEnvelope, e as TunnelType, W as WebhookTunnelPayload, p as processCorsair } from './index-LpuBJQ1m.js';
8
- import { g as BaseProviders } from './types-C2vFipdU.js';
9
- export { R as ResolveAccountFromWebhookLinkInput, W as WebhookTenantLink, r as resolveAccountFromWebhookLink, a as resolveTenantFromWebhookLink, b as resolveTenantIdFromWebhookLink, s as setWebhookTenantLink } from './tenant-links-Cg8-Zu9C.js';
10
- import 'zod';
10
+ import { B as BaseProviders } from './constants-CE0V2QbI.js';
11
+ export { R as ResolveAccountFromWebhookLinkInput, W as WebhookTenantLink, r as resolveAccountFromWebhookLink, a as resolveTenantFromWebhookLink, b as resolveTenantIdFromWebhookLink, s as setWebhookTenantLink } from './tenant-links-B7k-eaef.js';
12
+ export { c as ConnectLink, a as ConnectionStatus, d as CreateConnectLinkInput, C as CreateTenantInput, M as ManagementOk, e as OAuthCallbackInput, O as OAuthCallbackResult, f as PermissionLookupInput, b as PermissionRecord, g as PluginConnectionState, P as PluginInfo, R as ResolvedConnectLink, T as Tenant } from './types-BswoTGV5.js';
11
13
  import './db.js';
12
14
  import 'kysely';
15
+ import './index-ggMa1Rj6.js';
16
+ import 'zod';
13
17
  import 'pg';
14
18
  import 'postgres';
19
+ import './types-BY2SDx3_.js';
15
20
  import './orm.js';
16
21
 
17
22
  type ManagementHandlerOptions = {
@@ -54,44 +59,6 @@ declare function toNextJsHandler(corsair: unknown, opts?: ManagementHandlerOptio
54
59
  OPTIONS: (req: Request) => Promise<Response>;
55
60
  };
56
61
 
57
- type CorsairClientOptions = {
58
- /** Origin + base path of the mounted handler, e.g. 'https://api.example.com/api/corsair'. */
59
- baseURL: string;
60
- /** Optional fetch override. Defaults to globalThis.fetch. */
61
- fetch?: typeof fetch;
62
- };
63
- type CorsairManagementClient = {
64
- ok: () => Promise<ManagementOk>;
65
- tenants: {
66
- list: () => Promise<Tenant[]>;
67
- create: (input: CreateTenantInput) => Promise<Tenant>;
68
- get: (id: string) => Promise<Tenant>;
69
- };
70
- plugins: {
71
- list: () => Promise<PluginInfo[]>;
72
- get: (id: string) => Promise<PluginInfo>;
73
- };
74
- connectionStatus: {
75
- get: (query?: {
76
- tenantId?: string;
77
- }) => Promise<ConnectionStatus>;
78
- };
79
- permissions: {
80
- get: (input: PermissionLookupInput) => Promise<PermissionRecord>;
81
- };
82
- connect: {
83
- createLink: (input: CreateConnectLinkInput) => Promise<ConnectLink>;
84
- resolve: (state: string) => Promise<ResolvedConnectLink>;
85
- oauthCallback: (input: OAuthCallbackInput) => Promise<OAuthCallbackResult>;
86
- };
87
- };
88
- declare class CorsairClientError extends Error {
89
- readonly status: number;
90
- readonly code: string;
91
- readonly extra: Record<string, unknown>;
92
- constructor(status: number, code: string, message: string, extra?: Record<string, unknown>);
93
- }
94
-
95
62
  declare function createCorsairClient(opts: CorsairClientOptions): CorsairManagementClient;
96
63
 
97
64
  type InspectCorsairPlugin = {
@@ -256,4 +223,4 @@ declare function processWebhook(corsair: CorsairInstance, headers: WebhookHeader
256
223
  [x: string]: string | string[] | undefined;
257
224
  }): Promise<WebhookFilterResult>;
258
225
 
259
- export { type AnyCorsairInstance, ConnectLink, ConnectionStatus, CorsairClientError, type CorsairClientOptions, type CorsairManagementClient, CreateConnectLinkInput, CreateTenantInput, type ExpressHandler, FormFieldSchema, type HonoHandler, ListOperationsOptions, type ManagementHandlerOptions, ManagementOk, OAuthCallbackInput, OAuthCallbackResult, type PermissionExecuteResult, PermissionLookupInput, PermissionRecord, PluginInfo, ResolvedConnectLink, Tenant, createCorsairClient, executePermission, getSchema, getStructuredSchema, listOperations, managementHandler, processWebhook, toExpressHandler, toHonoHandler, toNextJsHandler };
226
+ export { type AnyCorsairInstance, CorsairClientOptions, CorsairManagementClient, type ExpressHandler, FormFieldSchema, type HonoHandler, ListOperationsOptions, type ManagementHandlerOptions, type PermissionExecuteResult, createCorsairClient, executePermission, getSchema, getStructuredSchema, listOperations, managementHandler, processWebhook, toExpressHandler, toHonoHandler, toNextJsHandler };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import{$ as w,$a as W,A as P,B as x,C as b,D as I,M as R,Ma as T,Na as L,Oa as A,Pa as v,Qa as $,Ua as d,Va as g,Wa as C,Xa as f,Za as E,_a as M,ab as F,bb as _,cb as N,db as D,hb as H,ib as j,jb as k,ka as S,kb as J,ra as O}from"./chunk-LWFKRPBU.js";import"./chunk-NZS35HPL.js";import"./chunk-IGGCNGU2.js";import"./chunk-QAIKSQAD.js";var u=class extends Error{status;code;extra;constructor(r,o,e,a={}){super(e),this.name="CorsairClientError",this.status=r,this.code=o,this.extra=a}};function U(n){return n.endsWith("/")?n.slice(0,-1):n}async function y(n){let r={};try{r=await n.json()}catch{}let o=typeof r.error=="string"?r.error:"request_failed",e=typeof r.message=="string"?r.message:`Request failed (${n.status})`,{error:a,message:c,...t}=r;return new u(n.status,o,e,t)}function q(n){let r=U(n.baseURL),o=n.fetch??((...t)=>globalThis.fetch(...t));async function e(t,s){let i=s&&Object.keys(s).length?`?${new URLSearchParams(s).toString()}`:"",p=await o(`${r}${t}${i}`,{method:"GET"});if(!p.ok)throw await y(p);return await p.json()}async function a(t,s){let i=await o(`${r}${t}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!i.ok)throw await y(i);return await i.json()}let c=encodeURIComponent;return{ok:()=>e("/ok"),tenants:{list:()=>e("/tenants"),create:t=>a("/tenants",t),get:t=>e(`/tenants/${c(t)}`)},plugins:{list:()=>e("/plugins"),get:t=>e(`/plugins/${c(t)}`)},connectionStatus:{get:t=>{let s={};return t?.tenantId&&(s.tenantId=t.tenantId),e("/connection-status",s)}},permissions:{get:t=>"id"in t?e(`/permissions/${c(t.id)}`):a("/permissions/lookup-by-token",{token:t.token})},connect:{createLink:t=>a("/connect/links",t),resolve:t=>e("/connect/resolve",{state:t}),oauthCallback:t=>a("/connect/oauth/callback",t)}}}function l(n){let r=n[k];if(!r)throw new Error("listOperations / getSchema: invalid corsair instance. Pass the value returned by createCorsair() or corsair.withTenant().");return r.plugins}function B(n,r){let o=g(l(n),r);return typeof o=="string"?o:Array.isArray(o)?o.join(`
2
- `):Object.values(o).flat().join(`
3
- `)}function G(n,r){return C(l(n),r)}function Y(n,r){return d(l(n),r)}var z=Symbol.for("corsair:internal");function K(n,r){let o=n;for(let e of r){if(!o||typeof o!="object")return null;o=o[e]}return typeof o=="function"?o:null}function h(n){return n[z]?.database}async function Q(n,r){let o=new Date().toISOString(),e=await n.permissions.find_by_token(r);if(!e)return console.error("executePermission: no permission found for token."),{error:"executePermission: no permission found for token."};if(e.status!=="approved")return console.error(`executePermission: permission '${e.id}' is '${e.status}', expected 'approved'.`),{endpoint:e.endpoint,plugin:e.plugin,result:null,error:`executePermission: permission '${e.id}' is '${e.status}', expected 'approved'.`};if(e.expires_at<o){let i=h(n);return i&&await i.db.updateTable("corsair_permissions").set({status:"expired",updated_at:new Date}).where("id","=",e.id).execute(),console.error(`executePermission: permission '${e.id}' has expired.`),{error:`executePermission: permission '${e.id}' has expired.`,endpoint:e.endpoint,plugin:e.plugin,result:null}}let a=e.tenant_id??"default",t=(n.withTenant?n.withTenant(a):n)[e.plugin];if(!t?.api)return console.error(`executePermission: plugin '${e.plugin}' not found or has no API on this corsair instance.`),{error:`executePermission: plugin '${e.plugin}' not found or has no API on this corsair instance.`,plugin:e.plugin,endpoint:e.endpoint,result:null};let s=K(t.api,e.endpoint.split("."));if(!s)return console.error(`executePermission: endpoint '${e.endpoint}' not found in plugin '${e.plugin}'.`),{endpoint:e.endpoint,plugin:e.plugin,result:null,error:`executePermission: endpoint '${e.endpoint}' not found in plugin '${e.plugin}'.`};await n.permissions.set_executing(e.id);try{let i=typeof e.args=="string"?JSON.parse(e.args):e.args,p=await s(i);return await n.permissions.set_completed(e.id),{plugin:e.plugin,endpoint:e.endpoint,result:p}}catch(i){let p=i instanceof Error?i.message:String(i),m=h(n);return m&&await m.db.updateTable("corsair_permissions").set({status:"failed",error:p,updated_at:new Date}).where("id","=",e.id).execute(),{plugin:e.plugin,endpoint:e.endpoint,result:null,error:p}}}export{O as AuthMissingError,u as CorsairClientError,N as asRecord,W as collectPluginWebhookMatchers,J as createCorsair,q as createCorsairClient,j as decodePubSubData,Q as executePermission,H as firstString,f as formatDocSchemaShape,F as getHeader,G as getSchema,Y as getStructuredSchema,B as listOperations,L as managementHandler,E as matchWebhookPlugin,M as matchWebhookPluginAndTenant,S as processCorsair,w as processWebhook,D as readBodyRecord,x as resolveAccountFromWebhookLink,T as resolveConnectLink,I as resolveTenantFromWebhookLink,b as resolveTenantIdFromWebhookLink,P as setWebhookTenantLink,R as setupCorsair,A as toExpressHandler,_ as toExternalId,v as toHonoHandler,$ as toNextJsHandler};
1
+ import{a as N,b as j}from"./chunk-XLNT2UI2.js";import{$ as b,$a as F,A as y,B as h,C as k,D as x,M as P,Ma as I,Na as O,Oa as R,Pa as T,Qa as A,Ua as l,Va as c,Wa as d,Xa as m,Za as L,_a as W,ab as v,bb as E,cb as _,db as $,hb as M,ib as D,jb as g,ka as S,kb as H,ra as w}from"./chunk-LWFKRPBU.js";import"./chunk-NZS35HPL.js";import"./chunk-IGGCNGU2.js";import"./chunk-QAIKSQAD.js";function s(n){let t=n[g];if(!t)throw new Error("listOperations / getSchema: invalid corsair instance. Pass the value returned by createCorsair() or corsair.withTenant().");return t.plugins}function B(n,t){let r=c(s(n),t);return typeof r=="string"?r:Array.isArray(r)?r.join(`
2
+ `):Object.values(r).flat().join(`
3
+ `)}function J(n,t){return d(s(n),t)}function q(n,t){return l(s(n),t)}var Y=Symbol.for("corsair:internal");function z(n,t){let r=n;for(let e of t){if(!r||typeof r!="object")return null;r=r[e]}return typeof r=="function"?r:null}function C(n){return n[Y]?.database}async function G(n,t){let r=new Date().toISOString(),e=await n.permissions.find_by_token(t);if(!e)return console.error("executePermission: no permission found for token."),{error:"executePermission: no permission found for token."};if(e.status!=="approved")return console.error(`executePermission: permission '${e.id}' is '${e.status}', expected 'approved'.`),{endpoint:e.endpoint,plugin:e.plugin,result:null,error:`executePermission: permission '${e.id}' is '${e.status}', expected 'approved'.`};if(e.expires_at<r){let o=C(n);return o&&await o.db.updateTable("corsair_permissions").set({status:"expired",updated_at:new Date}).where("id","=",e.id).execute(),console.error(`executePermission: permission '${e.id}' has expired.`),{error:`executePermission: permission '${e.id}' has expired.`,endpoint:e.endpoint,plugin:e.plugin,result:null}}let f=e.tenant_id??"default",a=(n.withTenant?n.withTenant(f):n)[e.plugin];if(!a?.api)return console.error(`executePermission: plugin '${e.plugin}' not found or has no API on this corsair instance.`),{error:`executePermission: plugin '${e.plugin}' not found or has no API on this corsair instance.`,plugin:e.plugin,endpoint:e.endpoint,result:null};let p=z(a.api,e.endpoint.split("."));if(!p)return console.error(`executePermission: endpoint '${e.endpoint}' not found in plugin '${e.plugin}'.`),{endpoint:e.endpoint,plugin:e.plugin,result:null,error:`executePermission: endpoint '${e.endpoint}' not found in plugin '${e.plugin}'.`};await n.permissions.set_executing(e.id);try{let o=typeof e.args=="string"?JSON.parse(e.args):e.args,i=await p(o);return await n.permissions.set_completed(e.id),{plugin:e.plugin,endpoint:e.endpoint,result:i}}catch(o){let i=o instanceof Error?o.message:String(o),u=C(n);return u&&await u.db.updateTable("corsair_permissions").set({status:"failed",error:i,updated_at:new Date}).where("id","=",e.id).execute(),{plugin:e.plugin,endpoint:e.endpoint,result:null,error:i}}}export{w as AuthMissingError,N as CorsairClientError,_ as asRecord,F as collectPluginWebhookMatchers,H as createCorsair,j as createCorsairClient,D as decodePubSubData,G as executePermission,M as firstString,m as formatDocSchemaShape,v as getHeader,J as getSchema,q as getStructuredSchema,B as listOperations,O as managementHandler,L as matchWebhookPlugin,W as matchWebhookPluginAndTenant,S as processCorsair,b as processWebhook,$ as readBodyRecord,h as resolveAccountFromWebhookLink,I as resolveConnectLink,x as resolveTenantFromWebhookLink,k as resolveTenantIdFromWebhookLink,y as setWebhookTenantLink,P as setupCorsair,R as toExpressHandler,E as toExternalId,T as toHonoHandler,A as toNextJsHandler};
package/dist/oauth.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- import { O as OAuthConfig } from './index-Cs2O9Pmx.js';
1
+ import { O as OAuthConfig } from './index-x-RG0TdQ.js';
2
2
  import 'zod';
3
3
  import './db.js';
4
4
  import 'kysely';
5
+ import './index-ggMa1Rj6.js';
5
6
  import 'pg';
6
7
  import 'postgres';
7
8
  import './orm.js';
8
- import './types-C2vFipdU.js';
9
+ import './constants-CE0V2QbI.js';
10
+ import './types-BY2SDx3_.js';
11
+ import './types-BswoTGV5.js';
9
12
 
10
13
  type OAuthState = {
11
14
  plugin: string;
package/dist/orm.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { CorsairEntity, CorsairAccount, CorsairEvent, CorsairIntegration, CorsairDatabase } from './db.js';
2
- export { CorsairAccountsSchema, CorsairEntitiesSchema, CorsairEventsSchema, CorsairIntegrationsSchema } from './db.js';
1
+ import { c as CorsairEntity, C as CorsairAccount, d as CorsairEvent, b as CorsairIntegration } from './index-ggMa1Rj6.js';
2
+ export { f as CorsairAccountsSchema, g as CorsairEntitiesSchema, h as CorsairEventsSchema, e as CorsairIntegrationsSchema } from './index-ggMa1Rj6.js';
3
3
  import { ZodTypeAny, z } from 'zod';
4
+ import { CorsairDatabase } from './db.js';
4
5
  import 'kysely';
5
6
  import 'pg';
6
7
  import 'postgres';
package/dist/setup.d.ts CHANGED
@@ -1,12 +1,15 @@
1
- import { a as CorsairInternalConfig } from './index-BOgiPWN6.js';
1
+ import { a as CorsairInternalConfig } from './index-dta3YWl8.js';
2
2
  import { CorsairDatabase } from './db.js';
3
- import { C as CorsairPlugin, e as CorsairSingleTenantClient, d as CorsairTenantWrapper } from './index-Cs2O9Pmx.js';
4
- import './types-C2vFipdU.js';
3
+ import { C as CorsairPlugin, e as CorsairSingleTenantClient, d as CorsairTenantWrapper } from './index-x-RG0TdQ.js';
4
+ import './types-BY2SDx3_.js';
5
+ import './constants-CE0V2QbI.js';
5
6
  import 'kysely';
7
+ import './index-ggMa1Rj6.js';
6
8
  import 'zod';
7
9
  import 'pg';
8
10
  import 'postgres';
9
11
  import './orm.js';
12
+ import './types-BswoTGV5.js';
10
13
 
11
14
  /** Plugin id → credential field → value (from CLI `field=value` pairs). */
12
15
  type SetupCredentials = Record<string, Record<string, string>>;
@@ -1,6 +1,7 @@
1
- import { A as AuthTypes } from './types-C2vFipdU.js';
2
- import { W as WebhookTenantMatch } from './index-Cs2O9Pmx.js';
3
- import { CorsairDatabase, CorsairAccount } from './db.js';
1
+ import { A as AuthTypes } from './constants-CE0V2QbI.js';
2
+ import { W as WebhookTenantMatch } from './index-x-RG0TdQ.js';
3
+ import { C as CorsairAccount } from './index-ggMa1Rj6.js';
4
+ import { CorsairDatabase } from './db.js';
4
5
 
5
6
  type WebhookTenantLink = WebhookTenantMatch;
6
7
  declare function setWebhookTenantLink(options: {
@@ -1,5 +1,5 @@
1
- import { D as EndpointRiskLevel, C as CorsairPlugin, Y as CorsairWebhookMatcher, Z as CorsairWebhookTenantMatcher, _ as RawWebhookRequest, W as WebhookTenantMatch } from './index-Cs2O9Pmx.js';
2
- import { f as AllProviders } from './types-C2vFipdU.js';
1
+ import { D as EndpointRiskLevel, C as CorsairPlugin, Y as CorsairWebhookMatcher, Z as CorsairWebhookTenantMatcher, _ as RawWebhookRequest, W as WebhookTenantMatch } from './index-x-RG0TdQ.js';
2
+ import { a as AllProviders } from './constants-CE0V2QbI.js';
3
3
 
4
4
  /**
5
5
  * Error thrown when a plugin endpoint is called but the required auth credentials
package/dist/tests.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as kysely from 'kysely';
2
2
  import { Kysely } from 'kysely';
3
3
  import { CorsairKyselyDatabase, CorsairDatabase } from './db.js';
4
+ import './index-ggMa1Rj6.js';
4
5
  import 'zod';
5
6
  import 'pg';
6
7
  import 'postgres';
package/dist/tunnel.d.ts CHANGED
@@ -1,15 +1,18 @@
1
1
  import { B as BrowserDeliveryPayload } from './index-LpuBJQ1m.js';
2
2
  export { O as OAuthCallbackTunnelPayload, b as OAuthTokensTunnelPayload, P as ProcessCorsairOptions, c as ProcessCorsairRequest, T as TunnelAck, d as TunnelEnvelope, e as TunnelType, W as WebhookTunnelPayload, a as applyPermissionDecision, p as processCorsair } from './index-LpuBJQ1m.js';
3
- export { r as resolveAccountFromWebhookLink, a as resolveTenantFromWebhookLink, b as resolveTenantIdFromWebhookLink, s as setWebhookTenantLink } from './tenant-links-Cg8-Zu9C.js';
3
+ export { r as resolveAccountFromWebhookLink, a as resolveTenantFromWebhookLink, b as resolveTenantIdFromWebhookLink, s as setWebhookTenantLink } from './tenant-links-B7k-eaef.js';
4
4
  export { v as verifyBrowserDeliveryToken } from './browser-delivery-CvBUoA96.js';
5
- import './types-C2vFipdU.js';
6
- import './index-Cs2O9Pmx.js';
5
+ import './constants-CE0V2QbI.js';
6
+ import './index-x-RG0TdQ.js';
7
7
  import 'zod';
8
8
  import './db.js';
9
9
  import 'kysely';
10
+ import './index-ggMa1Rj6.js';
10
11
  import 'pg';
11
12
  import 'postgres';
12
13
  import './orm.js';
14
+ import './types-BY2SDx3_.js';
15
+ import './types-BswoTGV5.js';
13
16
 
14
17
  declare function isConnectStatusBrowserDelivery(payload: BrowserDeliveryPayload): boolean;
15
18
  declare function isAuthCredentialsBrowserDelivery(payload: BrowserDeliveryPayload): boolean;
@@ -1,74 +1,4 @@
1
- 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
- declare const BaseProviders: readonly ["ahrefs", "airtable", "amplitude", "asana", "bitwarden", "bluesky", "box", "cal", "calendly", "cloudflare", "cursor", "discord", "dodopayments", "dropbox", "exa", "figma", "firecrawl", "fireflies", "github", "gitlab", "gmail", "googlecalendar", "googledrive", "googlesheets", "grafana", "hackernews", "hubspot", "intercom", "jira", "linear", "monday", "notion", "onedrive", "openweathermap", "oura", "outlook", "pagerduty", "posthog", "razorpay", "reddit", "resend", "sentry", "sharepoint", "slack", "spotify", "strava", "stripe", "tally", "tavily", "teams", "telegram", "todoist", "trello", "twilio", "twitter", "twitterapiio", "typeform", "vapi", "xquik", "youtube", "zendesk", "zohomail", "zoom"];
3
- declare const ProviderDisplayNames: {
4
- readonly ahrefs: "Ahrefs";
5
- readonly airtable: "Airtable";
6
- readonly amplitude: "Amplitude";
7
- readonly asana: "Asana";
8
- readonly bitwarden: "Bitwarden";
9
- readonly bluesky: "Bluesky";
10
- readonly box: "Box";
11
- readonly cal: "Cal";
12
- readonly calendly: "Calendly";
13
- readonly cloudflare: "Cloudflare";
14
- readonly cursor: "Cursor";
15
- readonly discord: "Discord";
16
- readonly dodopayments: "Dodo Payments";
17
- readonly dropbox: "Dropbox";
18
- readonly exa: "Exa";
19
- readonly figma: "Figma";
20
- readonly firecrawl: "Firecrawl";
21
- readonly fireflies: "Fireflies";
22
- readonly github: "GitHub";
23
- readonly gitlab: "GitLab";
24
- readonly gmail: "Gmail";
25
- readonly googlecalendar: "Google Calendar";
26
- readonly googledrive: "Google Drive";
27
- readonly googlesheets: "Google Sheets";
28
- readonly grafana: "Grafana";
29
- readonly hackernews: "Hacker News";
30
- readonly hubspot: "HubSpot";
31
- readonly intercom: "Intercom";
32
- readonly jira: "Jira";
33
- readonly linear: "Linear";
34
- readonly monday: "Monday";
35
- readonly notion: "Notion";
36
- readonly onedrive: "OneDrive";
37
- readonly openweathermap: "OpenWeatherMap";
38
- readonly oura: "Oura";
39
- readonly outlook: "Outlook";
40
- readonly pagerduty: "PagerDuty";
41
- readonly posthog: "PostHog";
42
- readonly razorpay: "Razorpay";
43
- readonly reddit: "Reddit";
44
- readonly resend: "Resend";
45
- readonly sentry: "Sentry";
46
- readonly sharepoint: "SharePoint";
47
- readonly slack: "Slack";
48
- readonly spotify: "Spotify";
49
- readonly strava: "Strava";
50
- readonly stripe: "Stripe";
51
- readonly tally: "Tally";
52
- readonly tavily: "Tavily";
53
- readonly teams: "Teams";
54
- readonly telegram: "Telegram";
55
- readonly todoist: "Todoist";
56
- readonly trello: "Trello";
57
- readonly twilio: "Twilio";
58
- readonly twitter: "Twitter";
59
- readonly twitterapiio: "Twitter API IO";
60
- readonly typeform: "Typeform";
61
- readonly vapi: "Vapi";
62
- readonly xquik: "XQuik";
63
- readonly youtube: "YouTube";
64
- readonly zendesk: "Zendesk";
65
- readonly zohomail: "Zoho Mail";
66
- readonly zoom: "Zoom";
67
- };
68
- declare function formatProviderDisplayName(plugin: string): string;
69
- type AllProviders = 'ahrefs' | 'airtable' | 'amplitude' | 'asana' | 'bitwarden' | 'bluesky' | 'box' | 'cal' | 'calendly' | 'cloudflare' | 'cursor' | 'discord' | 'dodopayments' | 'dropbox' | 'exa' | 'figma' | 'firecrawl' | 'fireflies' | 'github' | 'gitlab' | 'gmail' | 'googlecalendar' | 'googledrive' | 'googlesheets' | 'grafana' | 'hackernews' | 'hubspot' | 'intercom' | 'jira' | 'linear' | 'monday' | 'notion' | 'onedrive' | 'openweathermap' | 'oura' | 'outlook' | 'pagerduty' | 'posthog' | 'razorpay' | 'reddit' | 'resend' | 'sentry' | 'sharepoint' | 'slack' | 'spotify' | 'strava' | 'stripe' | 'tally' | 'tavily' | 'teams' | 'telegram' | 'todoist' | 'trello' | 'twilio' | 'twitter' | 'twitterapiio' | 'typeform' | 'vapi' | 'xquik' | 'youtube' | 'zendesk' | 'zohomail' | 'zoom' | (string & {});
70
- type AuthTypes = 'oauth_2' | 'api_key' | 'bot_token' | 'managed';
71
- type PickAuth<T extends AuthTypes> = T;
1
+ import { A as AuthTypes } from './constants-CE0V2QbI.js';
72
2
 
73
3
  type HubConnectSource = 'client' | 'server';
74
4
  type HubOAuthMode = 'byo' | 'managed';
@@ -251,4 +181,4 @@ type AccountKeyManagerFor<T extends AuthTypes, Config extends PluginAuthConfig |
251
181
  get_integration_credentials: () => Promise<OAuth2IntegrationCredentials>;
252
182
  } : {});
253
183
 
254
- export { type AuthTypes as A, type BaseAuthFieldConfig as B, DEFAULT_HUB_API_URL as D, type HubConfig as H, type IntegrationKeyManagerFor as I, type OAuth2IntegrationCredentials as O, type PluginAuthConfig as P, type UnionToIntersection as U, type AccountKeyManagerFor as a, type AccountFieldNames as b, type BaseKeyManager as c, type IntegrationFieldNames as d, BASE_AUTH_FIELDS as e, type AllProviders as f, BaseProviders as g, type PickAuth as h, formatProviderDisplayName as i, ProviderDisplayNames as j, type Bivariant as k, type AllErrors as l, type HubConfigInput as m, type HubOAuthMode as n, type HubConnectSessionResult as o, type HubPermissionSessionResult as p, type HubConnectSource as q, type HubConnectSessionInput as r, type HubPermissionSessionInput as s };
184
+ export { type AccountKeyManagerFor as A, type BaseAuthFieldConfig as B, DEFAULT_HUB_API_URL as D, type HubConfig as H, type IntegrationKeyManagerFor as I, type OAuth2IntegrationCredentials as O, type PluginAuthConfig as P, type UnionToIntersection as U, type AccountFieldNames as a, type BaseKeyManager as b, type IntegrationFieldNames as c, BASE_AUTH_FIELDS as d, type Bivariant as e, type HubConfigInput as f, type HubOAuthMode as g, type HubConnectSessionResult as h, type HubPermissionSessionResult as i, type HubConnectSource as j, type HubConnectSessionInput as k, type HubPermissionSessionInput as l };
@@ -0,0 +1,71 @@
1
+ import { a as CorsairPermission } from './index-ggMa1Rj6.js';
2
+ import { A as AuthTypes } from './constants-CE0V2QbI.js';
3
+
4
+ type Tenant = {
5
+ id: string;
6
+ accounts: Array<{
7
+ integrationName: string;
8
+ hasCredentials: boolean;
9
+ }>;
10
+ connectedPlugins: string[];
11
+ };
12
+ type CreateTenantInput = {
13
+ id: string;
14
+ };
15
+ type PluginInfo = {
16
+ id: string;
17
+ authType: AuthTypes | null;
18
+ configured: boolean;
19
+ missingFields: string[];
20
+ oauth: {
21
+ providerName: string;
22
+ scopes: string[];
23
+ requiresRegisteredRedirect: boolean;
24
+ } | null;
25
+ };
26
+ type PluginConnectionState = 'connected' | 'missing_credentials' | 'not_connected';
27
+ type ConnectionStatus = Record<string, PluginConnectionState>;
28
+ type ManagementOk = {
29
+ ok: true;
30
+ };
31
+ type PermissionRecord = CorsairPermission & {
32
+ /** Resolved review URL for pending/approved records. Null when not actionable or not configured. */
33
+ approvalUrl: string | null;
34
+ };
35
+ type PermissionLookupInput = {
36
+ id: string;
37
+ } | {
38
+ token: string;
39
+ };
40
+ type CreateConnectLinkInput = {
41
+ /** Required in manual mode. Optional in hub mode (omit to connect all plugins). */
42
+ plugin?: string;
43
+ tenantId?: string;
44
+ /** Hub mode only — BYO uses your OAuth app; managed uses Corsair's. */
45
+ oauthMode?: 'byo' | 'managed';
46
+ /** Hub mode only — inferred from deliveryUrl when omitted. */
47
+ source?: 'client' | 'server';
48
+ /** Hub mode only — override the provider display name. */
49
+ providerName?: string;
50
+ };
51
+ type ConnectLink = {
52
+ connectUrl: string;
53
+ expiresAt?: string;
54
+ };
55
+ type ResolvedConnectLink = {
56
+ plugin: string;
57
+ tenantId: string;
58
+ providerName: string;
59
+ oauthUrl: string;
60
+ state: string;
61
+ };
62
+ type OAuthCallbackInput = {
63
+ code: string;
64
+ state: string;
65
+ };
66
+ type OAuthCallbackResult = {
67
+ plugin: string;
68
+ tenantId: string;
69
+ };
70
+
71
+ export type { CreateTenantInput as C, ManagementOk as M, OAuthCallbackResult as O, PluginInfo as P, ResolvedConnectLink as R, Tenant as T, ConnectionStatus as a, PermissionRecord as b, ConnectLink as c, CreateConnectLinkInput as d, OAuthCallbackInput as e, PermissionLookupInput as f, PluginConnectionState as g };
@@ -0,0 +1,41 @@
1
+ import { M as ManagementOk, T as Tenant, C as CreateTenantInput, P as PluginInfo, a as ConnectionStatus, f as PermissionLookupInput, b as PermissionRecord, d as CreateConnectLinkInput, c as ConnectLink, R as ResolvedConnectLink, e as OAuthCallbackInput, O as OAuthCallbackResult } from './types-BswoTGV5.js';
2
+
3
+ type CorsairClientOptions = {
4
+ /** Origin + base path of the mounted handler, e.g. 'https://api.example.com/api/corsair'. */
5
+ baseURL: string;
6
+ /** Optional fetch override. Defaults to globalThis.fetch. */
7
+ fetch?: typeof fetch;
8
+ };
9
+ type CorsairManagementClient = {
10
+ ok: () => Promise<ManagementOk>;
11
+ tenants: {
12
+ list: () => Promise<Tenant[]>;
13
+ create: (input: CreateTenantInput) => Promise<Tenant>;
14
+ get: (id: string) => Promise<Tenant>;
15
+ };
16
+ plugins: {
17
+ list: () => Promise<PluginInfo[]>;
18
+ get: (id: string) => Promise<PluginInfo>;
19
+ };
20
+ connectionStatus: {
21
+ get: (query?: {
22
+ tenantId?: string;
23
+ }) => Promise<ConnectionStatus>;
24
+ };
25
+ permissions: {
26
+ get: (input: PermissionLookupInput) => Promise<PermissionRecord>;
27
+ };
28
+ connect: {
29
+ createLink: (input: CreateConnectLinkInput) => Promise<ConnectLink>;
30
+ resolve: (state: string) => Promise<ResolvedConnectLink>;
31
+ oauthCallback: (input: OAuthCallbackInput) => Promise<OAuthCallbackResult>;
32
+ };
33
+ };
34
+ declare class CorsairClientError extends Error {
35
+ readonly status: number;
36
+ readonly code: string;
37
+ readonly extra: Record<string, unknown>;
38
+ constructor(status: number, code: string, message: string, extra?: Record<string, unknown>);
39
+ }
40
+
41
+ export { type CorsairClientOptions as C, type CorsairManagementClient as a, CorsairClientError as b };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsair",
3
- "version": "0.1.88",
3
+ "version": "0.1.89",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",