@nangohq/types 0.71.0 → 0.71.2

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,15 @@
1
+ import type { DBEnvironment } from '../environment/db.js';
2
+ import type { DBPlan } from '../plans/db.js';
3
+ import type { DBTeam } from '../team/db.js';
4
+ /**
5
+ * The context persist resolves when authenticating a request with an internal
6
+ * secret key. Deliberately minimal: it holds only the fields persist actually
7
+ * reads, fetched by a purpose-built query on the auth hot path — the Pick types
8
+ * make unfetched fields impossible to reference. Adding a field here requires
9
+ * extending the query in accountService.getPersistAuthContext.
10
+ */
11
+ export interface PersistAuthContext {
12
+ account: Pick<DBTeam, 'id'>;
13
+ environment: Pick<DBEnvironment, 'id' | 'name'>;
14
+ plan: Pick<DBPlan, 'id' | 'name' | 'records_store'> | null;
15
+ }
@@ -6,8 +6,8 @@ import type { PostPublicApiKeyAuthorization, PostPublicAppStoreAuthorization, Po
6
6
  import type { PostCliTelemetry } from './cli/api.js';
7
7
  import type { GetPublicClientMetadata } from './clientMetadata/http.api.js';
8
8
  import type { DeleteConnectSession, GetConnectSession, PostConnectSessions, PostInternalConnectSessions, PostPublicConnectSessionsReconnect, PostPublicConnectTelemetry } from './connect/api.js';
9
- import type { DeletePublicConnection, GetConnection, GetConnections, GetConnectionsCount, GetPublicConnection, GetPublicConnections, PatchConnection, PatchPublicConnection, PostConnectionRefresh, PostPublicConnection } from './connection/api/get.js';
10
- import type { SetMetadata, UpdateMetadata } from './connection/api/metadata.js';
9
+ import type { DeleteConnection, DeletePublicConnection, GetConnection, GetConnections, GetConnectionsCount, GetPublicConnection, GetPublicConnections, PatchConnection, PatchPublicConnection, PostConnectionRefresh, PostPublicConnection } from './connection/api/get.js';
10
+ import type { PostConnectionMetadata, SetMetadata, UpdateMetadata } from './connection/api/metadata.js';
11
11
  import type { GetConnectUISettings, PutConnectUISettings } from './connectUISettings/api.js';
12
12
  import type { PostDeploy, PostDeployConfirmation, PostDeployInternal } from './deploy/api.js';
13
13
  import type { CreateApiKey, DeleteApiKey, DeleteEnvironment, GetEnvironment, GetEnvironments, ListApiKeys, PatchApiKey, PatchEnvironment, PostEnvironment } from './environment/api/index.js';
@@ -20,6 +20,7 @@ import type { DeleteIntegration, DeletePublicIntegration, GetFunctionCode, GetIn
20
20
  import type { DeleteInvite, GetInvite, PostInvite } from './invitations/api.js';
21
21
  import type { GetOperation, PostInsights, SearchFilters, SearchMessages, SearchOperations } from './logs/api.js';
22
22
  import type { GetMeta } from './meta/api.js';
23
+ import type { DeleteMFA, GetMFAStatus, PostMFAActivation, PostMFAEnrollment, PostMFARecoveryCodes } from './mfa/api.js';
23
24
  import type { GetPlainHmac } from './plain/api.js';
24
25
  import type { GetBillingUsage, GetBillingUsageTopDimensionValues, PostPlanChange, PostPlanExtendTrial, PutBillingInvoicingDetails } from './plans/http.api.js';
25
26
  import type { GetProvider, GetProviders, GetPublicProvider, GetPublicProviders } from './providers/api.js';
@@ -31,8 +32,8 @@ import type { GetPublicSyncStatus, PostPublicSyncPause, PostPublicSyncStart, Pos
31
32
  import type { DeleteTeamUser, GetTeam, PatchTeamUser, PutTeam } from './team/api.js';
32
33
  import type { GetUser, PatchUser, PutUserPassword } from './user/api.js';
33
34
  import type { PostPublicWebhook } from './webhooks/http.api.js';
34
- export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | PostPublicTrigger | PostPublicTbaAuthorization | PostPublicJwtAuthorization | PostPublicUnauthenticatedAuthorization | PostPublicApiKeyAuthorization | PostPublicBasicAuthorization | PostPublicAppStoreAuthorization | GetPublicProviders | GetPublicProvider | GetPublicListIntegrations | GetPublicIntegration | DeletePublicIntegration | PostConnectSessions | PostPublicConnectSessionsReconnect | GetPublicConnections | GetPublicConnection | GetConnectSession | DeleteConnectSession | PostDeployInternal | PostPublicBillAuthorization | DeletePublicConnection | 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 | GetPublicFunctionCode | GetPublicIntegrationFunctions | GetPublicIntegrationFunction | DeletePublicIntegrationFunction | GetPublicProviderTemplates | AllPublicProxy;
35
- export type PrivateApiEndpoints = 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 | GetConnectionRecordModels | GetConnectionRecords | GetInvite | GetMeta | GetEmailByExpiredToken | GetEmailByUuid | GetManagedCallback | GetManagedEmailVerification | PatchFlowDisable | PatchFlowEnable | PatchFlowFrequency | PutUpgradePreBuiltFlow | PostConnectionRefresh | PatchConnection | 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 | GetPlainHmac;
35
+ export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | PostPublicTrigger | PostPublicTbaAuthorization | PostPublicJwtAuthorization | PostPublicUnauthenticatedAuthorization | PostPublicApiKeyAuthorization | PostPublicBasicAuthorization | PostPublicAppStoreAuthorization | 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 | GetPublicFunctionCode | GetPublicIntegrationFunctions | GetPublicIntegrationFunction | DeletePublicIntegrationFunction | GetPublicProviderTemplates | AllPublicProxy;
36
+ export type PrivateApiEndpoints = 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 | 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 | DeleteMFA | GetPlainHmac;
36
37
  export type APIEndpoints = PrivateApiEndpoints | PublicApiEndpoints;
37
38
  /**
38
39
  * Automatically narrow endpoints type with Method + Path
@@ -1,4 +1,5 @@
1
1
  import type { DBConnection } from '../connection/db.js';
2
+ import type { ReplaceInObjectDeep } from '../utils.js';
2
3
  export interface AuthModes {
3
4
  OAuth1: 'OAUTH1';
4
5
  OAuth2: 'OAUTH2';
@@ -171,3 +172,4 @@ export interface AuthorizationTokenResponse extends Omit<OAuth2Credentials, 'typ
171
172
  export type TestableCredentials = ApiKeyCredentials | BasicApiCredentials | TbaCredentials | JwtCredentials | SignatureCredentials;
172
173
  export type RefreshableCredentials = OAuth2Credentials | AppCredentials | AppStoreCredentials | OAuth2ClientCredentials | JwtCredentials | TwoStepCredentials | BillCredentials | SignatureCredentials | AwsSigV4Credentials;
173
174
  export type AllAuthCredentials = OAuth1Credentials | OAuth2Credentials | OAuth2ClientCredentials | BasicApiCredentials | ApiKeyCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | CustomCredentials | TbaCredentials | JwtCredentials | BillCredentials | TwoStepCredentials | CombinedOauth2AppCredentials | SignatureCredentials | InstallPluginCredentials | AwsSigV4Credentials;
175
+ export type ApiPublicAllAuthCredentials = ReplaceInObjectDeep<AllAuthCredentials, Date, string>;
@@ -94,19 +94,12 @@ export interface GetBillingUsageOpts {
94
94
  group_by?: 'environmentId' | 'environmentName' | 'integrationId' | 'type' | 'functionName' | 'model';
95
95
  };
96
96
  /**
97
- * Dev-only escape hatch: pins the request to Orb for parity checks.
98
- * Honoured only when `FLAG_ALLOW_OVERRIDE_GETUSAGE_SERVICE` is enabled;
99
- * ignored everywhere else. Default is ClickHouse.
100
- */
101
- source?: 'clickhouse' | 'orb';
102
- /**
103
- * Per-metric dimension breakdown spec. Honoured only on the CH path
97
+ * Per-metric dimension breakdown spec, applied to CH-backed metrics
104
98
  * (records / connections via `getDailySumAndBatches`, counters via
105
- * `getDailyCounter`); the Orb client ignores it. Each metric's
106
- * `BillingUsageMetric` gains a `breakdown` array of up to `top + 1`
107
- * series (top-N dimension values + a single 'rest' aggregating the
108
- * long tail). Top defaults to 10 and is clamped server-side to
109
- * the CH cap.
99
+ * `getDailyCounter`). Each metric's `BillingUsageMetric` gains a
100
+ * `breakdown` array of up to `top + 1` series (top-N dimension
101
+ * values + a single 'rest' aggregating the long tail). Top defaults
102
+ * to 10 and is clamped server-side to the CH cap.
110
103
  */
111
104
  breakdown?: {
112
105
  [M in UsageMetric]?: BreakdownDimensions[M] | undefined;
@@ -114,8 +107,7 @@ export interface GetBillingUsageOpts {
114
107
  top?: number;
115
108
  /**
116
109
  * Subset of metrics to populate in the response. When set, only those
117
- * metrics are fanned out (CH path) and returned. Omitted → all 7.
118
- * Ignored on the Orb path.
110
+ * metrics are fanned out and returned. Omitted → all 7.
119
111
  */
120
112
  metrics?: UsageMetric[];
121
113
  /**
@@ -123,8 +115,7 @@ export interface GetBillingUsageOpts {
123
115
  * where the given dimension equals the given value. Composes with
124
116
  * `breakdown[<metric>]` on the same metric when the dimensions differ
125
117
  * (drill-in: filter to one value, re-break-down by another); controllers
126
- * reject only the same-dimension pairing. CH path only; the Orb client
127
- * ignores it.
118
+ * reject only the same-dimension pairing.
128
119
  */
129
120
  filter?: {
130
121
  [M in UsageMetric]?: {
@@ -132,6 +123,12 @@ export interface GetBillingUsageOpts {
132
123
  value: string;
133
124
  } | undefined;
134
125
  };
126
+ /**
127
+ * AVG metrics (connections, records) are returned as the point-in-time daily count instead of
128
+ * the billing running-average. Used by the Free caps view, where the cap is a concurrent
129
+ * maximum. CH path only. Default false (billing running-average).
130
+ */
131
+ avgPerDay?: boolean;
135
132
  }
136
133
  export interface BillingUsageMetric {
137
134
  externalId: string;
@@ -9,7 +9,6 @@ export interface ConnectSessionInput {
9
9
  connection_config?: {
10
10
  [key: string]: unknown;
11
11
  oauth_scopes_override?: string | undefined;
12
- webhook_url?: string | undefined;
13
12
  } | undefined;
14
13
  }> | undefined;
15
14
  end_user: EndUserInput;
@@ -21,6 +20,8 @@ export interface ConnectSessionInput {
21
20
  overrides?: Record<string, {
22
21
  docs_connect?: string | undefined;
23
22
  }> | undefined;
23
+ /** Session-level override of the environment's webhook URLs, applied to the connection created by this session. */
24
+ webhook_url_override?: string | undefined;
24
25
  }
25
26
  export interface EndUserInput {
26
27
  id: string;
@@ -62,6 +63,7 @@ export type PostPublicConnectSessionsReconnect = Endpoint<{
62
63
  end_user?: ConnectSessionInput['end_user'] | undefined;
63
64
  organization?: ConnectSessionInput['organization'];
64
65
  overrides?: ConnectSessionInput['overrides'];
66
+ webhook_url_override?: ConnectSessionInput['webhook_url_override'];
65
67
  tags?: ConnectSessionInput['tags'];
66
68
  };
67
69
  Success: {
@@ -88,7 +90,7 @@ export type PostInternalConnectSessions = Endpoint<{
88
90
  Method: 'POST';
89
91
  Path: '/api/v1/connect/sessions';
90
92
  Success: PostConnectSessions['Success'];
91
- Body: Pick<ConnectSessionInput, 'allowed_integrations' | 'end_user' | 'organization' | 'integrations_config_defaults' | 'overrides'>;
93
+ Body: Pick<ConnectSessionInput, 'allowed_integrations' | 'end_user' | 'organization' | 'integrations_config_defaults' | 'overrides' | 'webhook_url_override'>;
92
94
  }>;
93
95
  export type PostPublicConnectTelemetry = Endpoint<{
94
96
  Method: 'POST';
@@ -10,6 +10,8 @@ export interface ConnectSession {
10
10
  readonly allowedIntegrations: string[] | null;
11
11
  readonly integrationsConfigDefaults: Record<string, ConnectSessionIntegrationConfigDefaults> | null;
12
12
  readonly overrides: Record<string, ConnectSessionOverrides> | null;
13
+ /** Session-level override of the environment's webhook URLs, applied to the connection created by this session. */
14
+ readonly webhookUrlOverride: string | null;
13
15
  readonly endUser: InternalEndUser | null;
14
16
  readonly tags: Tags;
15
17
  readonly createdAt: Date;
@@ -1,5 +1,5 @@
1
1
  import type { ApiError, ApiTimestamps, Endpoint } from '../../api.js';
2
- import type { AllAuthCredentials, ApiKeyCredentials, BasicApiCredentials, OAuth1Credentials, OAuth2ClientCredentials, OAuth2Credentials, TbaCredentials } from '../../auth/api.js';
2
+ import type { ApiKeyCredentials, ApiPublicAllAuthCredentials, BasicApiCredentials, OAuth1Credentials, OAuth2ClientCredentials, OAuth2Credentials, TbaCredentials } from '../../auth/api.js';
3
3
  import type { EndUserInput } from '../../connect/api.js';
4
4
  import type { Tags } from '../../db.js';
5
5
  import type { ApiEndUser } from '../../endUser/index.js';
@@ -83,6 +83,7 @@ export type PostPublicConnection = Endpoint<{
83
83
  provider_config_key: string;
84
84
  metadata?: Record<string, unknown> | undefined;
85
85
  connection_config?: ConnectionConfig | undefined;
86
+ webhook_url_override?: string | undefined;
86
87
  credentials: Omit<OAuth2Credentials, 'raw'> | Omit<OAuth2ClientCredentials, 'raw'> | Omit<OAuth1Credentials, 'raw'> | Omit<ApiKeyCredentials, 'raw'> | Omit<BasicApiCredentials, 'raw'> | Omit<TbaCredentials, 'raw'> | {
87
88
  type: 'APP';
88
89
  app_id: string;
@@ -121,7 +122,7 @@ export type GetConnection = Endpoint<{
121
122
  };
122
123
  };
123
124
  }>;
124
- export type ApiPublicConnectionFull = Pick<DBConnection, 'id' | 'connection_id' | 'connection_config'> & {
125
+ export type ApiPublicConnectionFull = Pick<DBConnection, 'id' | 'connection_id' | 'connection_config' | 'webhook_url_override'> & {
125
126
  provider_config_key: string;
126
127
  created_at: string;
127
128
  updated_at: string;
@@ -134,7 +135,7 @@ export type ApiPublicConnectionFull = Pick<DBConnection, 'id' | 'connection_id'
134
135
  }[];
135
136
  end_user: ApiEndUser | null;
136
137
  tags: Tags;
137
- credentials: AllAuthCredentials;
138
+ credentials: ApiPublicAllAuthCredentials;
138
139
  };
139
140
  export type GetPublicConnection = Endpoint<{
140
141
  Method: 'GET';
@@ -163,7 +164,7 @@ export type PatchPublicConnection = Endpoint<{
163
164
  Body: {
164
165
  end_user?: EndUserInput | undefined;
165
166
  tags?: Tags | undefined;
166
- webhook_url?: string | undefined;
167
+ webhook_url_override?: string | undefined;
167
168
  };
168
169
  Success: {
169
170
  success: boolean;
@@ -183,7 +184,7 @@ export type PatchConnection = Endpoint<{
183
184
  Body: {
184
185
  end_user?: EndUserInput | undefined;
185
186
  tags?: Tags | undefined;
186
- webhook_url?: string | undefined;
187
+ webhook_url_override?: string | undefined;
187
188
  };
188
189
  Success: {
189
190
  success: boolean;
@@ -20,4 +20,22 @@ export type UpdateMetadata = Endpoint<{
20
20
  Error: MetadataError;
21
21
  Success: MetadataBody;
22
22
  }>;
23
+ export type PostConnectionMetadata = Endpoint<{
24
+ Method: 'POST';
25
+ Path: '/api/v1/connections/:connectionId/metadata';
26
+ Params: {
27
+ connectionId: string;
28
+ };
29
+ Querystring: {
30
+ env: string;
31
+ provider_config_key: string;
32
+ };
33
+ Body: {
34
+ metadata: Metadata;
35
+ };
36
+ Success: {
37
+ success: boolean;
38
+ };
39
+ Error: ApiError<'unknown_provider_config' | 'not_found' | 'invalid_body'>;
40
+ }>;
23
41
  export {};
@@ -11,7 +11,6 @@ export interface ConnectionConfig {
11
11
  oauth_scopes_override?: string[] | undefined;
12
12
  oauth_scopes?: string | undefined;
13
13
  authorization_params?: Record<string, string> | undefined;
14
- webhook_url?: string | undefined;
15
14
  }
16
15
  export interface DBConnection extends TimestampsAndDeletedCorrect {
17
16
  id: number;
@@ -24,6 +23,11 @@ export interface DBConnection extends TimestampsAndDeletedCorrect {
24
23
  provider_config_key: string;
25
24
  connection_id: string;
26
25
  connection_config: ConnectionConfig;
26
+ /**
27
+ * Backend-set override of the environment's webhook URLs for this connection. Distinct from `connection_config`,
28
+ * which holds end-user-supplied, provider-declared inputs (see providers.yaml). Only sourced from the connect session.
29
+ */
30
+ webhook_url_override: string | null;
27
31
  environment_id: number;
28
32
  metadata: Metadata | null;
29
33
  credentials: {
@@ -56,7 +60,7 @@ export interface FailedConnectionError {
56
60
  description: string;
57
61
  }
58
62
  export interface RecentlyFailedConnection {
59
- connection: DBConnection | Pick<DBConnection, 'connection_id' | 'provider_config_key' | 'connection_config'>;
63
+ connection: DBConnection | (Pick<DBConnection, 'connection_id' | 'provider_config_key'> & Partial<Pick<DBConnection, 'webhook_url_override'>>);
60
64
  auth_mode: AuthModeType;
61
65
  error?: FailedConnectionError;
62
66
  operation: AuthOperationType;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export type * from './keystore/index.js';
11
11
  export type * from './action/api.js';
12
12
  export type * from './admin/http.api.js';
13
13
  export type * from './account/api.js';
14
+ export type * from './account/context.js';
14
15
  export type * from './user/api.js';
15
16
  export type * from './user/db.js';
16
17
  export type * from './plain/api.js';
@@ -90,6 +91,8 @@ export type * from './jobs/api.js';
90
91
  export type * from './checkpoint/types.js';
91
92
  export type * from './checkpoint/db.js';
92
93
  export type * from './mcp/api.js';
94
+ export type * from './mfa/api.js';
95
+ export type * from './mfa/db.js';
93
96
  export type * from './functions/api.js';
94
97
  export type * from './functions/capabilities.js';
95
98
  export type * from './functions/domain.js';
@@ -11,6 +11,7 @@ export type ApiPublicIntegration = Merge<Pick<IntegrationConfig, 'created_at' |
11
11
  export interface ApiPublicIntegrationInclude {
12
12
  webhook_url?: string | null;
13
13
  credentials_label?: Record<string, string> | undefined;
14
+ preconfigured_credentials?: string[] | undefined;
14
15
  credentials?: {
15
16
  type: AuthModes['OAuth2'] | AuthModes['OAuth1'] | AuthModes['TBA'];
16
17
  client_id: string | null;
@@ -14,7 +14,6 @@ export type GetMeta = Endpoint<{
14
14
  baseUrl: string;
15
15
  debugMode: boolean;
16
16
  gettingStartedClosed: boolean;
17
- billingUsageSource: 'clickhouse' | 'orb';
18
17
  };
19
18
  };
20
19
  }>;
@@ -0,0 +1,60 @@
1
+ import type { ApiError, Endpoint } from '../api.js';
2
+ type MFAError = ApiError<'invalid_mfa_code'> | ApiError<'mfa_already_enabled'> | ApiError<'mfa_enrollment_not_found'> | ApiError<'mfa_not_enabled'>;
3
+ export type GetMFAStatus = Endpoint<{
4
+ Method: 'GET';
5
+ Path: '/api/v1/account/mfa';
6
+ Success: {
7
+ data: {
8
+ enabled: boolean;
9
+ };
10
+ };
11
+ }>;
12
+ export type PostMFAEnrollment = Endpoint<{
13
+ Method: 'POST';
14
+ Path: '/api/v1/account/mfa/enroll';
15
+ Error: ApiError<'mfa_already_enabled'>;
16
+ Success: {
17
+ data: {
18
+ otpauthUri: string;
19
+ };
20
+ };
21
+ }>;
22
+ export type PostMFAActivation = Endpoint<{
23
+ Method: 'POST';
24
+ Path: '/api/v1/account/mfa/activate';
25
+ Body: {
26
+ code: string;
27
+ };
28
+ Error: ApiError<'invalid_mfa_code'> | ApiError<'mfa_enrollment_not_found'>;
29
+ Success: {
30
+ data: {
31
+ recoveryCodes: string[];
32
+ };
33
+ };
34
+ }>;
35
+ export type PostMFARecoveryCodes = Endpoint<{
36
+ Method: 'POST';
37
+ Path: '/api/v1/account/mfa/recovery-codes';
38
+ Body: {
39
+ code: string;
40
+ };
41
+ Error: ApiError<'invalid_mfa_code'> | ApiError<'mfa_not_enabled'>;
42
+ Success: {
43
+ data: {
44
+ recoveryCodes: string[];
45
+ };
46
+ };
47
+ }>;
48
+ export type DeleteMFA = Endpoint<{
49
+ Method: 'DELETE';
50
+ Path: '/api/v1/account/mfa';
51
+ Body: {
52
+ code: string;
53
+ };
54
+ Error: ApiError<'invalid_mfa_code'> | ApiError<'mfa_not_enabled'>;
55
+ Success: {
56
+ success: true;
57
+ };
58
+ }>;
59
+ export type MFAEndpointError = MFAError;
60
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { Timestamps } from '../db.js';
2
+ export type MFAFactorType = 'totp';
3
+ export interface DBMFAFactor extends Timestamps {
4
+ id: string;
5
+ user_id: number;
6
+ type: MFAFactorType;
7
+ encrypted_secret: string;
8
+ iv: string;
9
+ auth_tag: string;
10
+ enabled_at: Date | null;
11
+ last_accepted_counter: string | null;
12
+ }
13
+ export interface DBMFARecoveryCode {
14
+ id: string;
15
+ user_id: number;
16
+ code_hash: string;
17
+ created_at: Date;
18
+ consumed_at: Date | null;
19
+ }
@@ -9,6 +9,7 @@ export interface DBOAuthSession extends Timestamps {
9
9
  authMode: AuthModeType;
10
10
  connect_session_id: number | null;
11
11
  connection_config: Record<string, string>;
12
+ webhook_url_override: string | null;
12
13
  environment_id: number;
13
14
  web_socket_client_id: string | undefined;
14
15
  activity_log_id: string;
@@ -24,6 +25,7 @@ export interface OAuthSession {
24
25
  authMode: AuthModeType;
25
26
  connectSessionId: number | null;
26
27
  connectionConfig: Record<string, string>;
28
+ webhookUrlOverride: string | null;
27
29
  environmentId: number;
28
30
  webSocketClientId: string | undefined;
29
31
  activityLogId: string;
@@ -89,7 +89,7 @@ export interface DBPlan extends Timestamps {
89
89
  * Change the applied rate limit for the public API
90
90
  * @default "m"
91
91
  */
92
- api_rate_limit_size: 's' | 'm' | 'l' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl';
92
+ api_rate_limit_size: 's' | 'm' | 'l' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' | '8xl' | '9xl' | '10xl' | '11xl' | '12xl';
93
93
  /**
94
94
  * Enable or disable machine auto idling
95
95
  * @default true
@@ -103,6 +103,7 @@ export type GetBillingUsage = Endpoint<{
103
103
  } | undefined;
104
104
  top?: string | undefined;
105
105
  filter?: Partial<Record<UsageMetric, string | undefined>> | undefined;
106
+ avgPerDay?: boolean | undefined;
106
107
  };
107
108
  Success: {
108
109
  data: {
@@ -41,6 +41,9 @@ export interface SimplifiedJSONSchema {
41
41
  equals: string;
42
42
  };
43
43
  }
44
+ export type ProxyBodyValue = string | {
45
+ [key: string]: ProxyBodyValue;
46
+ };
44
47
  export interface BaseProvider {
45
48
  display_name: string;
46
49
  auth_mode: AuthModeType;
@@ -50,7 +53,7 @@ export interface BaseProvider {
50
53
  headers?: Record<string, string>;
51
54
  connection_config?: Record<string, string>;
52
55
  query?: Record<string, string>;
53
- body?: Record<string, string>;
56
+ body?: Record<string, ProxyBodyValue>;
54
57
  retry?: RetryHeaderConfig;
55
58
  decompress?: boolean;
56
59
  forward_headers_on_redirect?: boolean;
@@ -81,6 +84,7 @@ export interface BaseProvider {
81
84
  authorization_code_param_in_webhook?: string;
82
85
  docs: string;
83
86
  docs_connect?: string;
87
+ setup_guide_url?: string;
84
88
  token_expiration_buffer?: number;
85
89
  webhook_routing_script?: string;
86
90
  webhook_user_defined_secret?: boolean;
@@ -1,3 +1,4 @@
1
+ import type { AllAuthCredentials } from '../auth/api.js';
1
2
  import type { DBConnectionDecrypted } from '../connection/db.js';
2
3
  import type { DBIntegrationDecrypted } from '../integration/db.js';
3
4
  import type { HTTP_METHOD } from '../nangoYaml/index.js';
@@ -48,7 +49,9 @@ export interface UserProvidedProxyConfiguration extends BaseProxyConfiguration {
48
49
  method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'get' | 'post' | 'patch' | 'put' | 'delete';
49
50
  paginate?: Partial<CursorPagination> | Partial<LinkPagination> | Partial<OffsetPagination>;
50
51
  }
51
- export type ConnectionForProxy = Pick<DBConnectionDecrypted, 'connection_id' | 'connection_config' | 'credentials' | 'metadata'>;
52
+ export type ConnectionForProxy = Pick<DBConnectionDecrypted, 'connection_id' | 'connection_config' | 'metadata'> & {
53
+ credentials: AllAuthCredentials;
54
+ };
52
55
  export type IntegrationConfigForProxy = Pick<DBIntegrationDecrypted, 'oauth_client_id' | 'oauth_client_secret' | 'custom'>;
53
56
  export interface ApplicationConstructedProxyConfiguration extends BaseProxyConfiguration {
54
57
  decompress: boolean;
package/dist/utils.d.ts CHANGED
@@ -21,4 +21,7 @@ export type Jsonable = string | number | boolean | null | undefined | readonly J
21
21
  export type ReplaceInObject<T, From, To> = {
22
22
  [K in keyof T]: T[K] extends infer U ? (U extends From ? Exclude<U, From> | To : U) : never;
23
23
  };
24
+ export type ReplaceInObjectDeep<T, From, To> = T extends From ? To : T extends object ? ReplaceInObject<{
25
+ [K in keyof T]: ReplaceInObjectDeep<T[K], From, To>;
26
+ }, From, To> : T;
24
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.71.0",
3
+ "version": "0.71.2",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",