@nangohq/types 0.71.4 → 0.71.5

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.
Files changed (40) hide show
  1. package/dist/account/api.d.ts +48 -2
  2. package/dist/action/api.d.ts +4 -0
  3. package/dist/admin/http.api.d.ts +1 -1
  4. package/dist/agent/api.d.ts +88 -0
  5. package/dist/agent/connections.d.ts +44 -0
  6. package/dist/agent/mcp.api.d.ts +28 -0
  7. package/dist/agent/session.d.ts +20 -0
  8. package/dist/agent/toolset.d.ts +43 -0
  9. package/dist/api-keys/scopes.d.ts +9 -4
  10. package/dist/api.endpoints.d.ts +9 -7
  11. package/dist/audit-trail/api.d.ts +19 -7
  12. package/dist/audit-trail/event.d.ts +20 -3
  13. package/dist/auth/http.api.d.ts +11 -40
  14. package/dist/authz/types.d.ts +1 -1
  15. package/dist/billing/types.d.ts +46 -0
  16. package/dist/connection/api/get.d.ts +1 -1
  17. package/dist/connection/api/metadata.d.ts +8 -2
  18. package/dist/environment/api/index.d.ts +86 -0
  19. package/dist/function/trigger.d.ts +61 -0
  20. package/dist/functions/api.d.ts +35 -0
  21. package/dist/index.d.ts +8 -2
  22. package/dist/keystore/index.d.ts +10 -2
  23. package/dist/logs/messages.d.ts +23 -2
  24. package/dist/mfa/api.d.ts +2 -7
  25. package/dist/mfa/credential.d.ts +7 -0
  26. package/dist/mfa/db.d.ts +1 -0
  27. package/dist/persist/api.d.ts +1 -1
  28. package/dist/plans/db.d.ts +20 -0
  29. package/dist/plans/http.api.d.ts +109 -0
  30. package/dist/pubsub/events.d.ts +2 -2
  31. package/dist/runner/sdk.d.ts +1 -1
  32. package/dist/sharedCredentials/api.d.ts +2 -0
  33. package/dist/sharedCredentials/db.d.ts +1 -0
  34. package/dist/sharedCredentials/dto.d.ts +1 -1
  35. package/dist/stripe/http.api.d.ts +3 -0
  36. package/dist/sync/api.d.ts +1 -1
  37. package/dist/usage/index.d.ts +1 -1
  38. package/dist/user/api.d.ts +5 -1
  39. package/dist/web/env.d.ts +3 -0
  40. package/package.json +1 -1
@@ -1,6 +1,51 @@
1
+ import type { AccountApiKeyScope } from '../api-keys/scopes.js';
1
2
  import type { ApiEndpoint, ApiError } from '../api.js';
2
3
  import type { AuditPolicy } from '../audit-trail/event.js';
4
+ import type { MFACredential } from '../mfa/credential.js';
3
5
  import type { ApiUser } from '../user/api.js';
6
+ export interface AccountApiKey {
7
+ id: number;
8
+ display_name: string;
9
+ scopes: AccountApiKeyScope[];
10
+ secret: string;
11
+ last_used_at: string | null;
12
+ created_at: string;
13
+ }
14
+ export type ListAccountApiKeys = ApiEndpoint<{
15
+ Audit: {
16
+ kind: 'no-audit';
17
+ reason: 'non-auditable';
18
+ };
19
+ Method: 'GET';
20
+ Path: '/api/v1/account/api-keys';
21
+ Success: {
22
+ data: AccountApiKey[];
23
+ };
24
+ }>;
25
+ export type CreateAccountApiKey = ApiEndpoint<{
26
+ Audit: AuditPolicy<'api_key', 'created', 'account'>;
27
+ Method: 'POST';
28
+ Path: '/api/v1/account/api-keys';
29
+ Body: {
30
+ display_name: string;
31
+ };
32
+ Success: {
33
+ data: Omit<AccountApiKey, 'last_used_at'>;
34
+ };
35
+ Error: ApiError<'conflict' | 'resource_capped'>;
36
+ }>;
37
+ export type DeleteAccountApiKey = ApiEndpoint<{
38
+ Audit: AuditPolicy<'api_key', 'deleted', 'account'>;
39
+ Method: 'DELETE';
40
+ Path: '/api/v1/account/api-keys/:keyId';
41
+ Params: {
42
+ keyId: number;
43
+ };
44
+ Success: {
45
+ success: true;
46
+ };
47
+ Error: ApiError<'not_found'>;
48
+ }>;
4
49
  export type PostSignup = ApiEndpoint<{
5
50
  Audit: AuditPolicy<'app_auth', 'signup', 'account'>;
6
51
  Method: 'POST';
@@ -12,7 +57,7 @@ export type PostSignup = ApiEndpoint<{
12
57
  token?: string | undefined;
13
58
  foundUs?: string | undefined;
14
59
  };
15
- Error: ApiError<'email_already_verified'> | ApiError<'error_creating_user'> | ApiError<'user_already_exists'> | ApiError<'error_creating_account'> | ApiError<'invalid_invite_token'> | ApiError<'email_not_verified'>;
60
+ Error: ApiError<'email_already_verified'> | ApiError<'error_creating_user'> | ApiError<'user_already_exists'> | ApiError<'error_creating_account'> | ApiError<'not_found'> | ApiError<'email_not_verified'>;
16
61
  Success: {
17
62
  data: {
18
63
  uuid: string;
@@ -144,8 +189,9 @@ export type PutResetPassword = ApiEndpoint<{
144
189
  Body: {
145
190
  token: string;
146
191
  password: string;
192
+ mfa?: MFACredential | undefined;
147
193
  };
148
- Error: ApiError<'user_not_found'> | ApiError<'invalid_token'>;
194
+ Error: ApiError<'user_not_found'> | ApiError<'invalid_token'> | ApiError<'invalid_mfa_code'> | ApiError<'mfa_code_required'>;
149
195
  Success: {
150
196
  success: true;
151
197
  };
@@ -1,4 +1,8 @@
1
1
  import type { ApiEndpoint } from '../api.js';
2
+ export interface AsyncFunctionResponse {
3
+ id: string;
4
+ statusUrl: string;
5
+ }
2
6
  export interface AsyncActionResponse {
3
7
  id: string;
4
8
  statusUrl: string;
@@ -14,7 +14,7 @@ export type PostImpersonate = ApiEndpoint<{
14
14
  loginReason: string;
15
15
  code?: string | undefined;
16
16
  };
17
- Error: ApiError<'invalid_mfa_code'> | ApiError<'mfa_not_enabled'>;
17
+ Error: ApiError<'invalid_mfa_code'> | ApiError<'mfa_code_required'> | ApiError<'mfa_not_enabled'>;
18
18
  Success: {
19
19
  success: true;
20
20
  };
@@ -0,0 +1,88 @@
1
+ import type { ApiEndpoint, ApiError } from '../api.js';
2
+ import type { Tags } from '../db.js';
3
+ import type { AgentSessionUnknownPinnedConnectionsPayload } from './connections.js';
4
+ import type { AgentSessionToolsNotInToolsetPayload, AgentSessionUnknownIntegrationsPayload, AgentSessionUnknownToolsPayload, AgentSessionUnsupportedFunctionTypesPayload } from './toolset.js';
5
+ export interface AgentSessionToolListInput {
6
+ tools: string[];
7
+ }
8
+ export type AgentSessionIntegrationPolicyInput = '*' | {
9
+ allow?: AgentSessionToolListInput | '*' | undefined;
10
+ deny?: AgentSessionToolListInput | undefined;
11
+ };
12
+ export interface PostAgentSessionsBody {
13
+ tenant: {
14
+ connections: {
15
+ any?: {
16
+ tags: Tags;
17
+ }[] | undefined;
18
+ pinned?: {
19
+ integration_id: string;
20
+ connection_id: string;
21
+ }[] | undefined;
22
+ };
23
+ };
24
+ toolset?: '*' | Record<string, AgentSessionIntegrationPolicyInput> | undefined;
25
+ pinned_tools?: Record<string, string[]> | undefined;
26
+ meta_tools?: Record<string, boolean> | undefined;
27
+ expires_in?: string | undefined;
28
+ }
29
+ export interface AgentSessionToolsetSummary {
30
+ connected: boolean;
31
+ tools_pinned: number;
32
+ tools_searchable: number;
33
+ }
34
+ export interface AgentSessionMetaToolsSummary {
35
+ nango_tool_search: boolean;
36
+ nango_execute: boolean;
37
+ }
38
+ export interface AgentSessionUnknownMetaToolsPayload {
39
+ meta_tools: string[];
40
+ }
41
+ /**
42
+ * Creating a session does not require the connections read scope, so a returned candidate names the
43
+ * connection and nothing else. The tags that made it a candidate are on the session created
44
+ * operation, which is where an ambiguity gets debugged.
45
+ */
46
+ export interface AgentSessionReturnedCandidate {
47
+ connection_id: string;
48
+ }
49
+ export interface AgentSessionAmbiguousConnectionsReply {
50
+ integrations: Record<string, {
51
+ match_count: number;
52
+ candidates: AgentSessionReturnedCandidate[];
53
+ }>;
54
+ }
55
+ export interface AgentSessionPinnedConnectionNotMatchedReply {
56
+ pinned: {
57
+ integration_id: string;
58
+ connection_id: string;
59
+ candidates: AgentSessionReturnedCandidate[];
60
+ }[];
61
+ }
62
+ export type AgentSessionCreationErrorCode = 'ambiguous_connections' | 'unknown_pinned_connection' | 'pinned_connection_not_matched' | 'unknown_integration' | 'unknown_tool' | 'unsupported_function_type' | 'tool_not_in_toolset' | 'unknown_meta_tool';
63
+ /**
64
+ * The payload is not correlated to the code by the compiler on purpose. AgentSessionCreationError
65
+ * carries it as a plain record, so a discriminated union here would only be a cast at the caller.
66
+ */
67
+ export type AgentSessionCreationErrorPayload = AgentSessionAmbiguousConnectionsReply | AgentSessionUnknownPinnedConnectionsPayload | AgentSessionPinnedConnectionNotMatchedReply | AgentSessionUnknownIntegrationsPayload | AgentSessionUnknownToolsPayload | AgentSessionUnsupportedFunctionTypesPayload | AgentSessionToolsNotInToolsetPayload | AgentSessionUnknownMetaToolsPayload;
68
+ export type PostAgentSessionsCreationError = ApiError<AgentSessionCreationErrorCode, undefined, AgentSessionCreationErrorPayload>;
69
+ export type PostAgentSessions = ApiEndpoint<{
70
+ Audit: {
71
+ kind: 'no-audit';
72
+ reason: 'TODO: audit coverage pending';
73
+ };
74
+ Method: 'POST';
75
+ Path: '/sessions';
76
+ Body: PostAgentSessionsBody;
77
+ Error: PostAgentSessionsCreationError;
78
+ Success: {
79
+ data: {
80
+ session_id: string;
81
+ session_token: string;
82
+ mcp_url: string;
83
+ expires_at: string;
84
+ toolset: Record<string, AgentSessionToolsetSummary>;
85
+ meta_tools: AgentSessionMetaToolsSummary;
86
+ };
87
+ };
88
+ }>;
@@ -0,0 +1,44 @@
1
+ import type { Tags } from '../db.js';
2
+ export interface AgentSessionConnectionSelector {
3
+ readonly tags: Tags;
4
+ }
5
+ export interface AgentSessionPinnedConnection {
6
+ readonly integrationId: string;
7
+ readonly connectionId: string;
8
+ }
9
+ export interface AgentSessionTenantConnections {
10
+ readonly any: AgentSessionConnectionSelector[];
11
+ readonly pinned: AgentSessionPinnedConnection[];
12
+ }
13
+ export interface AgentSessionResolvedConnection {
14
+ readonly integrationId: string;
15
+ readonly provider: string;
16
+ readonly connectionId: string;
17
+ readonly internalConnectionId: number;
18
+ readonly configId: number;
19
+ }
20
+ export type AgentSessionResolvedConnections = Record<string, AgentSessionResolvedConnection>;
21
+ export type AgentSessionConnectionResolutionErrorCode = 'ambiguous_connections' | 'pinned_connection_not_matched' | 'unknown_pinned_connection';
22
+ export interface AgentSessionConnectionCandidateReport {
23
+ readonly connection_id: string;
24
+ readonly tags: Tags;
25
+ }
26
+ export interface AgentSessionAmbiguousConnectionsPayload {
27
+ readonly integrations: Record<string, {
28
+ readonly match_count: number;
29
+ readonly candidates: AgentSessionConnectionCandidateReport[];
30
+ }>;
31
+ }
32
+ export interface AgentSessionUnknownPinnedConnectionsPayload {
33
+ readonly pinned: {
34
+ readonly integration_id: string;
35
+ readonly connection_id: string;
36
+ }[];
37
+ }
38
+ export interface AgentSessionPinnedConnectionNotMatchedPayload {
39
+ readonly pinned: {
40
+ readonly integration_id: string;
41
+ readonly connection_id: string;
42
+ readonly candidates: AgentSessionConnectionCandidateReport[];
43
+ }[];
44
+ }
@@ -0,0 +1,28 @@
1
+ import type { ApiEndpoint, ApiError } from '../api.js';
2
+ export type AgentSessionMcpErrorCode = 'session_not_found';
3
+ export type PostAgentSessionMcp = ApiEndpoint<{
4
+ Audit: {
5
+ kind: 'no-audit';
6
+ reason: 'TODO: audit coverage pending';
7
+ };
8
+ Method: 'POST';
9
+ Path: '/session/:sessionId/mcp';
10
+ Params: {
11
+ sessionId: string;
12
+ };
13
+ Body: Record<string, unknown>;
14
+ Success: Record<string, unknown>;
15
+ Error: ApiError<AgentSessionMcpErrorCode>;
16
+ }>;
17
+ export type GetAgentSessionMcp = ApiEndpoint<{
18
+ Audit: {
19
+ kind: 'no-audit';
20
+ reason: 'non-auditable';
21
+ };
22
+ Method: 'GET';
23
+ Path: '/session/:sessionId/mcp';
24
+ Params: {
25
+ sessionId: string;
26
+ };
27
+ Success: Record<string, unknown>;
28
+ }>;
@@ -0,0 +1,20 @@
1
+ import type { AgentSessionResolvedConnections } from './connections.js';
2
+ import type { AgentSessionCompiledToolset } from './toolset.js';
3
+ export interface AgentSessionMetaTools {
4
+ readonly nangoToolSearch: boolean;
5
+ readonly nangoExecute: boolean;
6
+ }
7
+ export type AgentSessionEndedReason = 'terminated' | 'expired';
8
+ export interface AgentSession {
9
+ readonly id: string;
10
+ readonly environmentId: number;
11
+ readonly accountId: number;
12
+ readonly resolvedConnections: AgentSessionResolvedConnections;
13
+ readonly compiledToolset: AgentSessionCompiledToolset;
14
+ readonly metaTools: AgentSessionMetaTools;
15
+ readonly expiresAt: Date;
16
+ readonly endedAt: Date | null;
17
+ readonly endedReason: AgentSessionEndedReason | null;
18
+ readonly createdAt: Date;
19
+ readonly updatedAt: Date;
20
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * `allow` absent means every tool on the integration. `allow` present makes the
3
+ * integration an allowlist. `deny` always subtracts from whatever `allow` gave.
4
+ */
5
+ export interface AgentSessionIntegrationPolicy {
6
+ readonly allow: '*' | readonly string[];
7
+ readonly deny: readonly string[];
8
+ }
9
+ export type AgentSessionToolsetPolicy = '*' | Readonly<Record<string, AgentSessionIntegrationPolicy>>;
10
+ export type AgentSessionPinnedTools = Readonly<Record<string, readonly string[]>>;
11
+ export interface AgentSessionCompiledTool {
12
+ readonly name: string;
13
+ readonly description: string;
14
+ }
15
+ export interface AgentSessionCompiledIntegration {
16
+ readonly provider: string;
17
+ readonly pinned: AgentSessionCompiledTool[];
18
+ readonly searchable: AgentSessionCompiledTool[];
19
+ }
20
+ export type AgentSessionCompiledToolset = Record<string, AgentSessionCompiledIntegration>;
21
+ export type AgentSessionToolsetCompilationErrorCode = 'unknown_integration' | 'unknown_tool' | 'unsupported_function_type' | 'tool_not_in_toolset';
22
+ export interface AgentSessionUnknownIntegrationsPayload {
23
+ readonly integrations: string[];
24
+ }
25
+ export interface AgentSessionUnknownToolsPayload {
26
+ readonly tools: {
27
+ readonly integration_id: string;
28
+ readonly tool: string;
29
+ }[];
30
+ }
31
+ export interface AgentSessionUnsupportedFunctionTypesPayload {
32
+ readonly tools: {
33
+ readonly integration_id: string;
34
+ readonly tool: string;
35
+ readonly type: string;
36
+ }[];
37
+ }
38
+ export interface AgentSessionToolsNotInToolsetPayload {
39
+ readonly pinned: {
40
+ readonly integration_id: string;
41
+ readonly tool: string;
42
+ }[];
43
+ }
@@ -1,5 +1,10 @@
1
- export declare const API_KEY_SCOPES: readonly ["environment:*", "environment:integrations:list", "environment:integrations:list_credentials", "environment:integrations:list_functions", "environment:integrations:read", "environment:integrations:read_credentials", "environment:integrations:create", "environment:integrations:update", "environment:integrations:delete", "environment:integrations:*", "environment:connections:list", "environment:connections:list_credentials", "environment:connections:read", "environment:connections:read_credentials", "environment:connections:create", "environment:connections:update", "environment:connections:delete", "environment:connections:*", "environment:connect_sessions:write", "environment:syncs:read", "environment:syncs:execute", "environment:syncs:update", "environment:syncs:variant:create", "environment:syncs:variant:delete", "environment:syncs:*", "environment:functions:list", "environment:functions:read", "environment:functions:delete", "environment:functions:compile", "environment:functions:dryrun", "environment:functions:*", "environment:deploy", "environment:records:read", "environment:records:write", "environment:records:*", "environment:logs:read", "environment:actions:execute", "environment:actions:*", "environment:proxy", "environment:variables:read", "environment:mcp"];
2
- export type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
3
- export declare const ACCOUNT_API_KEY_SCOPES: readonly ["account:*", "account:billing:read", "account:team:invite_member"];
4
- export type AccountApiKeyScope = (typeof ACCOUNT_API_KEY_SCOPES)[number];
1
+ /** Every wildcard in a namespace: `environment:*`, `environment:connections:*`, … */
2
+ export type WildcardsFor<Namespace extends string> = `${Namespace}:*` | `${Namespace}:${string}:*`;
3
+ export declare const API_KEY_SCOPES: readonly ["environment:integrations:list", "environment:integrations:list_credentials", "environment:integrations:list_functions", "environment:integrations:read", "environment:integrations:read_credentials", "environment:integrations:create", "environment:integrations:update", "environment:integrations:delete", "environment:connections:list", "environment:connections:list_credentials", "environment:connections:read", "environment:connections:read_credentials", "environment:connections:create", "environment:connections:update", "environment:connections:delete", "environment:connect_sessions:write", "environment:agent_sessions:write", "environment:syncs:read", "environment:syncs:execute", "environment:syncs:update", "environment:syncs:variant:create", "environment:syncs:variant:delete", "environment:functions:list", "environment:functions:read", "environment:functions:delete", "environment:functions:compile", "environment:functions:dryrun", "environment:functions:invocations", "environment:deploy", "environment:records:read", "environment:records:write", "environment:logs:read", "environment:actions:execute", "environment:proxy", "environment:variables:read", "environment:webhook_signing_key:rotate", "environment:mcp"];
4
+ export type ConcreteApiKeyScope = (typeof API_KEY_SCOPES)[number];
5
+ /** A scope, or a wildcard over scopes. Which wildcards resolve to something is checked at runtime. */
6
+ export type ApiKeyScope = ConcreteApiKeyScope | WildcardsFor<'environment'>;
7
+ export declare const ACCOUNT_API_KEY_SCOPES: readonly ["account:environments:create", "account:environments:delete", "account:environments:set_production", "account:environments:api_keys:create", "account:environments:api_keys:delete"];
8
+ export type ConcreteAccountApiKeyScope = (typeof ACCOUNT_API_KEY_SCOPES)[number];
9
+ export type AccountApiKeyScope = ConcreteAccountApiKeyScope | WildcardsFor<'account'>;
5
10
  export type CustomerKeyScope = ApiKeyScope | AccountApiKeyScope;
@@ -1,8 +1,10 @@
1
- import type { ConfirmEmail, GetEmailByExpiredToken, GetEmailByUuid, GetManagedCallback, GetManagedEmailVerification, GetOnboardingAccountDiscovery, PostForgotPassword, PostLogout, PostManagedEmailVerification, PostManagedSignup, PostOnboardingRequestInvite, PostSignin, PostSignup, PutResetPassword } from './account/api.js';
1
+ import type { ConfirmEmail, CreateAccountApiKey, DeleteAccountApiKey, GetEmailByExpiredToken, GetEmailByUuid, GetManagedCallback, GetManagedEmailVerification, GetOnboardingAccountDiscovery, ListAccountApiKeys, PostForgotPassword, PostLogout, PostManagedEmailVerification, PostManagedSignup, PostOnboardingRequestInvite, PostSignin, PostSignup, PutResetPassword } from './account/api.js';
2
2
  import type { GetAsyncActionResult, GetPublicV1, PostInternalTriggerFunction, PostPublicTriggerAction } from './action/api.js';
3
3
  import type { PostImpersonate } from './admin/http.api.js';
4
+ import type { PostAgentSessions } from './agent/api.js';
5
+ import type { GetAgentSessionMcp, PostAgentSessionMcp } from './agent/mcp.api.js';
4
6
  import type { EndpointMethod } from './api.js';
5
- import type { GetAuditTrail } from './audit-trail/api.js';
7
+ import type { GetAuditTrail, GetAuditTrailExport } from './audit-trail/api.js';
6
8
  import type { PostPublicApiKeyAuthorization, PostPublicAwsSigV4Authorization, PostPublicBasicAuthorization, PostPublicBillAuthorization, PostPublicJwtAuthorization, PostPublicOauthOutboundAuthorization, PostPublicSignatureAuthorization, PostPublicTbaAuthorization, PostPublicTwoStepAuthorization, PostPublicUnauthenticatedAuthorization } from './auth/http.api.js';
7
9
  import type { PostCliTelemetry } from './cli/api.js';
8
10
  import type { GetPublicClientMetadata } from './clientMetadata/http.api.js';
@@ -11,11 +13,11 @@ import type { DeleteConnection, DeletePublicConnection, GetConnection, GetConnec
11
13
  import type { PostConnectionMetadata, SetMetadata, UpdateMetadata } from './connection/api/metadata.js';
12
14
  import type { GetConnectUISettings, PutConnectUISettings } from './connectUISettings/api.js';
13
15
  import type { PostDeploy, PostDeployConfirmation, PostDeployInternal } from './deploy/api.js';
14
- import type { CreateApiKey, DeleteApiKey, DeleteEnvironment, GetEnvironment, GetEnvironments, ListApiKeys, PatchApiKey, PatchEnvironment, PostEnvironment } from './environment/api/index.js';
16
+ import type { CreateApiKey, DeleteApiKey, DeleteEnvironment, DeletePublicApiKey, DeletePublicEnvironment, GetEnvironment, GetEnvironments, ListApiKeys, PatchApiKey, PatchEnvironment, PostEnvironment, PostPublicApiKey, PostPublicEnvironment, PostPublicRotateWebhookSigningKey, PostRotateWebhookSigningKey } from './environment/api/index.js';
15
17
  import type { PatchWebhook } from './environment/api/webhook.js';
16
18
  import type { PostEnvironmentVariables } from './environment/variable/api.js';
17
19
  import type { PatchFlowDisable, PatchFlowEnable, PatchFlowFrequency, PostPreBuiltDeploy, PutUpgradePreBuiltFlow } from './flow/http.api.js';
18
- import type { DeleteIntegrationFunction, DeletePublicIntegrationFunction, GetFunctionDeployment, GetFunctionDryrun, GetIntegrationFunction, GetIntegrationFunctions, GetIntegrationTemplates, GetProviderTemplates, GetPublicIntegrationFunction, GetPublicIntegrationFunctions, GetPublicProviderTemplates, PostFunctionCompile, PostFunctionDeployment, PostFunctionDeploymentBundle, PostFunctionDeploymentBundlePreview, PostFunctionDeploymentResult, PostFunctionDryrun, PostFunctionDryrunResult } from './functions/api.js';
20
+ import type { DeleteIntegrationFunction, DeletePublicIntegrationFunction, GetFunctionDeployment, GetFunctionDryrun, GetFunctionInvocation, GetIntegrationFunction, GetIntegrationFunctions, GetIntegrationTemplates, GetProviderTemplates, GetPublicIntegrationFunction, GetPublicIntegrationFunctions, GetPublicProviderTemplates, PostFunctionCompile, PostFunctionDeployment, PostFunctionDeploymentBundle, PostFunctionDeploymentBundlePreview, PostFunctionDeploymentResult, PostFunctionDryrun, PostFunctionDryrunResult, PostFunctionInvocation } from './functions/api.js';
19
21
  import type { GetGettingStarted, PatchGettingStarted } from './gettingStarted/api.js';
20
22
  import type { DeleteIntegration, DeletePublicIntegration, GetFunctionCode, GetIntegration, GetIntegrationFlows, GetPublicFunctionCode, GetPublicIntegration, GetPublicListIntegrations, PatchIntegration, PatchPublicIntegration, PostIntegration, PostPublicIntegration, PostPublicQuickstartIntegration } from './integration/api.js';
21
23
  import type { DeleteInvite, GetInvite, PostInvite } from './invitations/api.js';
@@ -23,7 +25,7 @@ import type { GetOperation, PostInsights, SearchFilters, SearchMessages, SearchO
23
25
  import type { GetMeta } from './meta/api.js';
24
26
  import type { DeleteMFA, GetMFAStatus, PostMFAActivation, PostMFAEnrollment, PostMFALoginVerification, PostMFARecoveryCodes } from './mfa/api.js';
25
27
  import type { GetPlainHmac } from './plain/api.js';
26
- import type { GetBillingUsage, GetBillingUsageTopDimensionValues, PostPlanChange, PostPlanExtendTrial, PutBillingInvoicingDetails } from './plans/http.api.js';
28
+ import type { DeleteSpendAlert, GetBillingPeriodCosts, GetBillingUsage, GetBillingUsageTopDimensionValues, GetOverdueInvoices, GetSpendAlert, GetUpcomingInvoice, PostPlanChange, PostPlanExtendTrial, PutBillingInvoicingDetails, PutSpendAlert } from './plans/http.api.js';
27
29
  import type { GetProvider, GetProviders, GetPublicProvider, GetPublicProviders } from './providers/api.js';
28
30
  import type { AllPublicProxy } from './proxy/http.api.js';
29
31
  import type { GetConnectionRecordModels, GetConnectionRecords, GetPublicRecords, PatchPublicPruneRecords } from './record/api.js';
@@ -33,8 +35,8 @@ import type { GetPublicSyncStatus, PostPublicSyncPause, PostPublicSyncStart, Pos
33
35
  import type { DeleteTeamUser, GetTeam, PatchTeamUser, PutTeam } from './team/api.js';
34
36
  import type { GetUser, PatchUser, PutUserPassword } from './user/api.js';
35
37
  import type { PostPublicWebhook } from './webhooks/http.api.js';
36
- export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | PostPublicTrigger | PostPublicTbaAuthorization | PostPublicJwtAuthorization | PostPublicUnauthenticatedAuthorization | PostPublicApiKeyAuthorization | PostPublicBasicAuthorization | GetPublicProviders | GetPublicProvider | GetPublicListIntegrations | GetPublicIntegration | DeletePublicIntegration | PostConnectSessions | PostPublicConnectSessionsReconnect | GetPublicConnections | GetPublicConnection | GetConnectSession | DeleteConnectSession | PostDeployInternal | PostPublicBillAuthorization | DeletePublicConnection | DeleteConnection | PostPublicSignatureAuthorization | PostPublicTwoStepAuthorization | PostPublicWebhook | GetPublicClientMetadata | GetPublicRecords | PatchPublicPruneRecords | GetPublicScriptsConfig | PostPublicConnectTelemetry | PostCliTelemetry | PutPublicSyncConnectionFrequency | PostPublicIntegration | PostPublicQuickstartIntegration | PatchPublicIntegration | GetAsyncActionResult | PostPublicOauthOutboundAuthorization | PostPublicAwsSigV4Authorization | PostPublicConnection | PatchPublicConnection | PostPublicSyncStart | PostPublicSyncPause | GetPublicSyncStatus | GetPublicV1 | PostPublicTriggerAction | PostFunctionCompile | PostFunctionDryrun | GetFunctionDryrun | PostFunctionDryrunResult | PostFunctionDeployment | GetFunctionDeployment | PostFunctionDeploymentResult | PostFunctionDeploymentBundle | PostFunctionDeploymentBundlePreview | GetPublicFunctionCode | GetPublicIntegrationFunctions | GetPublicIntegrationFunction | DeletePublicIntegrationFunction | GetPublicProviderTemplates | AllPublicProxy;
37
- export type PrivateApiEndpoints = GetAuditTrail | ConfirmEmail | PostSignup | PostSignin | PostLogout | GetTeam | PutTeam | PostPlanExtendTrial | PostPlanChange | PutBillingInvoicingDetails | GetBillingUsage | GetBillingUsageTopDimensionValues | GetUser | PatchUser | PutUserPassword | PostInvite | DeleteInvite | DeleteTeamUser | PatchTeamUser | PostInsights | PostForgotPassword | PutResetPassword | SearchOperations | GetOperation | SearchMessages | SearchFilters | PostInternalConnectSessions | GetIntegrationFlows | GetIntegrationFunction | GetIntegrationFunctions | GetFunctionCode | DeleteIntegrationFunction | GetIntegrationTemplates | GetProviderTemplates | DeleteIntegration | PatchIntegration | GetIntegration | PostIntegration | GetConnections | GetConnectionsCount | GetConnection | PatchConnection | PostConnectionMetadata | GetConnectionRecordModels | GetConnectionRecords | GetInvite | GetMeta | GetEmailByExpiredToken | GetEmailByUuid | GetManagedCallback | GetManagedEmailVerification | GetOnboardingAccountDiscovery | PostOnboardingRequestInvite | PatchFlowDisable | PatchFlowEnable | PatchFlowFrequency | PutUpgradePreBuiltFlow | PostConnectionRefresh | PostManagedEmailVerification | PostManagedSignup | PostPreBuiltDeploy | PostEnvironment | PatchEnvironment | DeleteEnvironment | GetEnvironments | GetEnvironment | ListApiKeys | CreateApiKey | DeleteApiKey | PatchApiKey | PatchWebhook | PostEnvironmentVariables | PostImpersonate | GetSharedCredentialsProviders | GetSharedCredentialsProvider | PostSharedCredentialsProvider | PatchSharedCredentialsProvider | GetGettingStarted | PatchGettingStarted | GetConnectUISettings | PutConnectUISettings | GetProviders | GetProvider | PostInternalTriggerFunction | GetMFAStatus | PostMFAEnrollment | PostMFAActivation | PostMFARecoveryCodes | PostMFALoginVerification | DeleteMFA | GetPlainHmac;
38
+ export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | PostPublicTrigger | PostPublicTbaAuthorization | PostPublicJwtAuthorization | PostPublicUnauthenticatedAuthorization | PostPublicApiKeyAuthorization | PostPublicBasicAuthorization | GetPublicProviders | GetPublicProvider | GetPublicListIntegrations | GetPublicIntegration | DeletePublicIntegration | PostConnectSessions | PostAgentSessions | PostAgentSessionMcp | GetAgentSessionMcp | PostPublicConnectSessionsReconnect | GetPublicConnections | GetPublicConnection | GetConnectSession | DeleteConnectSession | PostDeployInternal | PostPublicBillAuthorization | DeletePublicConnection | DeleteConnection | PostPublicSignatureAuthorization | PostPublicTwoStepAuthorization | PostPublicWebhook | GetPublicClientMetadata | GetPublicRecords | PatchPublicPruneRecords | GetPublicScriptsConfig | PostPublicConnectTelemetry | PostCliTelemetry | PutPublicSyncConnectionFrequency | PostPublicIntegration | PostPublicQuickstartIntegration | PatchPublicIntegration | GetAsyncActionResult | PostPublicOauthOutboundAuthorization | PostPublicAwsSigV4Authorization | PostPublicConnection | PatchPublicConnection | PostPublicSyncStart | PostPublicSyncPause | GetPublicSyncStatus | GetPublicV1 | PostPublicTriggerAction | PostFunctionCompile | PostFunctionDryrun | GetFunctionDryrun | PostFunctionDryrunResult | PostFunctionDeployment | GetFunctionDeployment | PostFunctionDeploymentResult | PostFunctionInvocation | GetFunctionInvocation | PostFunctionDeploymentBundle | PostFunctionDeploymentBundlePreview | GetPublicFunctionCode | GetPublicIntegrationFunctions | GetPublicIntegrationFunction | DeletePublicIntegrationFunction | GetPublicProviderTemplates | PostPublicRotateWebhookSigningKey | AllPublicProxy | PostPublicEnvironment | DeletePublicEnvironment | PostPublicApiKey | DeletePublicApiKey;
39
+ export type PrivateApiEndpoints = GetAuditTrail | GetAuditTrailExport | ListAccountApiKeys | CreateAccountApiKey | DeleteAccountApiKey | ConfirmEmail | PostSignup | PostSignin | PostLogout | GetTeam | PutTeam | PostPlanExtendTrial | PostPlanChange | PutBillingInvoicingDetails | GetOverdueInvoices | GetBillingUsage | GetBillingUsageTopDimensionValues | GetUpcomingInvoice | GetBillingPeriodCosts | GetSpendAlert | PutSpendAlert | DeleteSpendAlert | GetUser | PatchUser | PutUserPassword | PostInvite | DeleteInvite | DeleteTeamUser | PatchTeamUser | PostInsights | PostForgotPassword | PutResetPassword | SearchOperations | GetOperation | SearchMessages | SearchFilters | PostInternalConnectSessions | GetIntegrationFlows | GetIntegrationFunction | GetIntegrationFunctions | GetFunctionCode | DeleteIntegrationFunction | GetIntegrationTemplates | GetProviderTemplates | DeleteIntegration | PatchIntegration | GetIntegration | PostIntegration | GetConnections | GetConnectionsCount | GetConnection | PatchConnection | PostConnectionMetadata | GetConnectionRecordModels | GetConnectionRecords | GetInvite | GetMeta | GetEmailByExpiredToken | GetEmailByUuid | GetManagedCallback | GetManagedEmailVerification | GetOnboardingAccountDiscovery | PostOnboardingRequestInvite | PatchFlowDisable | PatchFlowEnable | PatchFlowFrequency | PutUpgradePreBuiltFlow | PostConnectionRefresh | PostManagedEmailVerification | PostManagedSignup | PostPreBuiltDeploy | PostEnvironment | PatchEnvironment | DeleteEnvironment | GetEnvironments | GetEnvironment | PostRotateWebhookSigningKey | ListApiKeys | CreateApiKey | DeleteApiKey | PatchApiKey | PatchWebhook | PostEnvironmentVariables | PostImpersonate | GetSharedCredentialsProviders | GetSharedCredentialsProvider | PostSharedCredentialsProvider | PatchSharedCredentialsProvider | GetGettingStarted | PatchGettingStarted | GetConnectUISettings | PutConnectUISettings | GetProviders | GetProvider | PostInternalTriggerFunction | GetMFAStatus | PostMFAEnrollment | PostMFAActivation | PostMFARecoveryCodes | PostMFALoginVerification | DeleteMFA | GetPlainHmac;
38
40
  export type APIEndpoints = PrivateApiEndpoints | PublicApiEndpoints;
39
41
  /**
40
42
  * Automatically narrow endpoints type with Method + Path
@@ -1,5 +1,5 @@
1
- import type { ApiEndpoint } from '../api.js';
2
- import type { AuditAction, AuditActor, AuditContext, AuditOutcome, AuditResource, AuditTarget, AuditTrailVersion } from './event.js';
1
+ import type { ApiEndpoint, ApiError } from '../api.js';
2
+ import type { AuditAction, AuditActor, AuditContext, AuditOutcome, AuditPolicy, AuditResource, AuditTarget, AuditTrailVersion, AuditVia } from './event.js';
3
3
  export interface ApiAuditTrailEvent {
4
4
  id: string;
5
5
  version: AuditTrailVersion;
@@ -10,7 +10,7 @@ export interface ApiAuditTrailEvent {
10
10
  display: string;
11
11
  } | null;
12
12
  actor: AuditActor;
13
- via?: AuditActor[];
13
+ via?: AuditVia[];
14
14
  targets: AuditTarget[];
15
15
  context: AuditContext;
16
16
  outcome: AuditOutcome;
@@ -19,12 +19,10 @@ export interface ApiAuditTrailEvent {
19
19
  metadata?: Record<string, unknown>;
20
20
  }
21
21
  export type GetAuditTrail = ApiEndpoint<{
22
- Audit: {
23
- kind: 'no-audit';
24
- reason: 'non-auditable';
25
- };
22
+ Audit: AuditPolicy<'audit_trail', 'queried', 'account'>;
26
23
  Method: 'GET';
27
24
  Path: '/api/v1/audit-trail';
25
+ Error: ApiError<'feature_disabled'>;
28
26
  Querystring: {
29
27
  cursor?: string;
30
28
  from?: string;
@@ -39,3 +37,17 @@ export type GetAuditTrail = ApiEndpoint<{
39
37
  };
40
38
  };
41
39
  }>;
40
+ export type AuditExportMaxRows = 50_000;
41
+ export type GetAuditTrailExport = ApiEndpoint<{
42
+ Audit: AuditPolicy<'audit_trail', 'exported', 'account'>;
43
+ Method: 'GET';
44
+ Path: '/api/v1/audit-trail/export';
45
+ Error: ApiError<'feature_disabled'>;
46
+ Querystring: {
47
+ from?: string;
48
+ to?: string;
49
+ resources?: string;
50
+ actions?: string;
51
+ };
52
+ Success: never;
53
+ }>;
@@ -1,6 +1,7 @@
1
1
  export type AuditTrailVersion = '2026-07-16';
2
- export type AuditActorType = 'user' | 'api_key' | 'system' | 'anonymous';
2
+ export type AuditActorType = 'user' | 'api_key' | 'connect_session' | 'anonymous' | 'unknown';
3
3
  export type AuditOutcome = 'success' | 'failure' | 'denied';
4
+ export type AuditViaType = 'impersonation';
4
5
  export type AuditInterface = 'api' | 'mcp';
5
6
  interface AuditEventTable {
6
7
  connection: 'created' | 'updated' | 'metadata_updated' | 'refreshed' | 'deleted';
@@ -11,10 +12,11 @@ interface AuditEventTable {
11
12
  member: 'invited' | 'invite_accepted' | 'invite_declined' | 'invite_revoked' | 'role_changed' | 'removed';
12
13
  team: 'updated';
13
14
  user: 'updated';
14
- environment: 'created' | 'updated' | 'variables_changed' | 'webhook_urls_changed' | 'deleted';
15
+ environment: 'created' | 'updated' | 'variables_changed' | 'webhook_urls_changed' | 'webhook_signing_key_rotated' | 'deleted';
15
16
  app_auth: 'login' | 'logout' | 'signup' | 'password_changed' | 'password_reset';
16
17
  mfa: 'enrolled' | 'enabled' | 'disabled' | 'verified' | 'recovery_regenerated';
17
- billing: 'plan_changed' | 'trial_extended' | 'details_changed' | 'payment_method_added' | 'payment_method_removed';
18
+ billing: 'plan_changed' | 'trial_extended' | 'details_changed' | 'payment_method_added' | 'payment_method_removed' | 'spend_alert_changed' | 'spend_alert_removed';
19
+ audit_trail: 'exported' | 'queried';
18
20
  }
19
21
  export type AuditResource = keyof AuditEventTable;
20
22
  export type AuditActionOf<R extends AuditResource> = AuditEventTable[R];
@@ -29,6 +31,12 @@ export interface AuditActor {
29
31
  id: string;
30
32
  display?: string;
31
33
  }
34
+ export interface AuditVia {
35
+ type: AuditViaType;
36
+ id: string;
37
+ display?: string;
38
+ actorId?: string;
39
+ }
32
40
  export interface AuditTarget {
33
41
  type: AuditTargetType;
34
42
  id: string;
@@ -39,6 +47,15 @@ export interface AuditContext {
39
47
  ip?: string;
40
48
  userAgent?: string;
41
49
  }
50
+ export interface AuditAttribution {
51
+ kind: 'request';
52
+ actor: AuditActor;
53
+ context: AuditContext;
54
+ }
55
+ export interface NoAttribution {
56
+ kind: 'no-attribution';
57
+ reason: string;
58
+ }
42
59
  export interface AuditPolicy<R extends AuditResource = AuditResource, A extends AuditActionOf<R> = AuditActionOf<R>, S extends AuditScope = AuditScope> {
43
60
  kind: 'audit';
44
61
  resource: R;
@@ -1,4 +1,5 @@
1
1
  import type { ApiEndpoint, ApiError } from '../api.js';
2
+ import type { AuditPolicy } from '../audit-trail/event.js';
2
3
  export type ConnectionQueryString = {
3
4
  connection_id?: string | undefined;
4
5
  params?: Record<string, any> | undefined;
@@ -35,10 +36,7 @@ export interface WebSocketConnectionResponseSuccess {
35
36
  }
36
37
  type AuthErrors = ApiError<'invalid_body'> | ApiError<'invalid_query_params'> | ApiError<'unknown_provider_config'> | ApiError<'unknown_provider_template'> | ApiError<'invalid_auth_mode'> | ApiError<'invalid_credentials'> | ApiError<'integration_not_allowed'> | ApiError<'invalid_connection'> | ApiError<'connection_test_failed'> | ApiError<'connection_validation_failed'>;
37
38
  export type PostPublicApiKeyAuthorization = ApiEndpoint<{
38
- Audit: {
39
- kind: 'no-audit';
40
- reason: 'TODO: audit coverage pending';
41
- };
39
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
42
40
  Method: 'POST';
43
41
  Body: {
44
42
  apiKey: string;
@@ -52,10 +50,7 @@ export type PostPublicApiKeyAuthorization = ApiEndpoint<{
52
50
  Success: ConnectionResponseSuccess;
53
51
  }>;
54
52
  export type PostPublicBasicAuthorization = ApiEndpoint<{
55
- Audit: {
56
- kind: 'no-audit';
57
- reason: 'TODO: audit coverage pending';
58
- };
53
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
59
54
  Method: 'POST';
60
55
  Body: {
61
56
  username: string;
@@ -70,10 +65,7 @@ export type PostPublicBasicAuthorization = ApiEndpoint<{
70
65
  Success: ConnectionResponseSuccess;
71
66
  }>;
72
67
  export type PostPublicTbaAuthorization = ApiEndpoint<{
73
- Audit: {
74
- kind: 'no-audit';
75
- reason: 'TODO: audit coverage pending';
76
- };
68
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
77
69
  Method: 'POST';
78
70
  Body: {
79
71
  token_id: string;
@@ -91,10 +83,7 @@ export type PostPublicTbaAuthorization = ApiEndpoint<{
91
83
  Success: ConnectionResponseSuccess;
92
84
  }>;
93
85
  export type PostPublicJwtAuthorization = ApiEndpoint<{
94
- Audit: {
95
- kind: 'no-audit';
96
- reason: 'TODO: audit coverage pending';
97
- };
86
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
98
87
  Method: 'POST';
99
88
  Body: Record<string, any>;
100
89
  Querystring: ConnectionQueryString;
@@ -106,10 +95,7 @@ export type PostPublicJwtAuthorization = ApiEndpoint<{
106
95
  Success: ConnectionResponseSuccess;
107
96
  }>;
108
97
  export type PostPublicUnauthenticatedAuthorization = ApiEndpoint<{
109
- Audit: {
110
- kind: 'no-audit';
111
- reason: 'TODO: audit coverage pending';
112
- };
98
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
113
99
  Method: 'POST';
114
100
  Querystring: ConnectionQueryString;
115
101
  Params: {
@@ -120,10 +106,7 @@ export type PostPublicUnauthenticatedAuthorization = ApiEndpoint<{
120
106
  Success: ConnectionResponseSuccess;
121
107
  }>;
122
108
  export type PostPublicBillAuthorization = ApiEndpoint<{
123
- Audit: {
124
- kind: 'no-audit';
125
- reason: 'TODO: audit coverage pending';
126
- };
109
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
127
110
  Method: 'POST';
128
111
  Body: {
129
112
  username: string;
@@ -140,10 +123,7 @@ export type PostPublicBillAuthorization = ApiEndpoint<{
140
123
  Success: ConnectionResponseSuccess;
141
124
  }>;
142
125
  export type PostPublicTwoStepAuthorization = ApiEndpoint<{
143
- Audit: {
144
- kind: 'no-audit';
145
- reason: 'TODO: audit coverage pending';
146
- };
126
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
147
127
  Method: 'POST';
148
128
  Body: Record<string, any>;
149
129
  Querystring: ConnectionQueryString;
@@ -155,10 +135,7 @@ export type PostPublicTwoStepAuthorization = ApiEndpoint<{
155
135
  Success: ConnectionResponseSuccess;
156
136
  }>;
157
137
  export type PostPublicSignatureAuthorization = ApiEndpoint<{
158
- Audit: {
159
- kind: 'no-audit';
160
- reason: 'TODO: audit coverage pending';
161
- };
138
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
162
139
  Method: 'POST';
163
140
  Body: {
164
141
  username: string;
@@ -174,10 +151,7 @@ export type PostPublicSignatureAuthorization = ApiEndpoint<{
174
151
  }>;
175
152
  type AwsSigV4AuthErrors = AuthErrors | ApiError<'invalid_aws_sigv4_config'> | ApiError<'missing_aws_sigv4_service'> | ApiError<'missing_aws_sigv4_sts_endpoint'> | ApiError<'missing_aws_sigv4_builtin_credentials'> | ApiError<'missing_aws_sigv4_region'> | ApiError<'aws_sigv4_sts_request_failed'>;
176
153
  export type PostPublicAwsSigV4Authorization = ApiEndpoint<{
177
- Audit: {
178
- kind: 'no-audit';
179
- reason: 'TODO: audit coverage pending';
180
- };
154
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
181
155
  Method: 'POST';
182
156
  Body: {
183
157
  role_arn: string;
@@ -192,10 +166,7 @@ export type PostPublicAwsSigV4Authorization = ApiEndpoint<{
192
166
  Success: ConnectionResponseSuccess;
193
167
  }>;
194
168
  export type PostPublicOauthOutboundAuthorization = ApiEndpoint<{
195
- Audit: {
196
- kind: 'no-audit';
197
- reason: 'TODO: audit coverage pending';
198
- };
169
+ Audit: AuditPolicy<'connection', 'created', 'environment'>;
199
170
  Method: 'POST';
200
171
  Body: {
201
172
  username: string;
@@ -1,6 +1,6 @@
1
1
  import type { Role } from '../user/db.js';
2
2
  export type Action = 'create' | 'read' | 'update' | 'delete' | '*';
3
- export type Resource = 'team' | 'team_member' | 'invite' | 'connect_ui_settings' | 'billing' | 'plan' | 'environment' | 'environment_production_flag' | 'environment_key' | 'environment_variable' | 'webhook' | 'integration' | 'connection' | 'flow' | 'sync_command' | 'secret_key' | 'connection_credential' | 'log' | 'audit_trail' | '*';
3
+ export type Resource = 'team' | 'team_member' | 'invite' | 'connect_ui_settings' | 'billing' | 'plan' | 'environment' | 'environment_production_flag' | 'environment_key' | 'account_key' | 'environment_variable' | 'webhook' | 'integration' | 'connection' | 'flow' | 'sync_command' | 'secret_key' | 'connection_credential' | 'log' | 'audit_trail' | '*';
4
4
  export type Scope = 'production' | 'non-production' | 'global';
5
5
  export interface Permission {
6
6
  action: Action;