@nangohq/types 0.58.6 → 0.59.0

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,13 @@
1
+ import type { Endpoint } from '../api';
2
+ export interface AsyncActionResponse {
3
+ id: string;
4
+ statusUrl: string;
5
+ }
6
+ export type GetAsyncActionResult = Endpoint<{
7
+ Method: 'GET';
8
+ Path: `/action/:id`;
9
+ Params: {
10
+ id: string;
11
+ };
12
+ Success: Record<string, any>;
13
+ }>;
@@ -1,4 +1,5 @@
1
1
  import type { GetEmailByExpiredToken, GetEmailByUuid, GetManagedCallback, PostForgotPassword, PostLogout, PostManagedSignup, PostSignin, PostSignup, PutResetPassword } from './account/api';
2
+ import type { GetAsyncActionResult } from './action/api';
2
3
  import type { EndpointMethod } from './api';
3
4
  import type { PostPublicApiKeyAuthorization, PostPublicAppStoreAuthorization, PostPublicBasicAuthorization, PostPublicBillAuthorization, PostPublicJwtAuthorization, PostPublicSignatureAuthorization, PostPublicTableauAuthorization, PostPublicTbaAuthorization, PostPublicTwoStepAuthorization, PostPublicUnauthenticatedAuthorization } from './auth/http.api';
4
5
  import type { DeleteConnectSession, GetConnectSession, PostConnectSessions, PostInternalConnectSessions, PostPublicConnectSessionsReconnect, PostPublicConnectTelemetry } from './connect/api';
@@ -9,7 +10,7 @@ import type { DeleteEnvironment, PatchEnvironment, PostEnvironment } from './env
9
10
  import type { PatchWebhook } from './environment/api/webhook';
10
11
  import type { PostEnvironmentVariables } from './environment/variable/api';
11
12
  import type { PatchFlowDisable, PatchFlowEnable, PatchFlowFrequency, PostPreBuiltDeploy, PutUpgradePreBuiltFlow } from './flow/http.api';
12
- import type { DeleteIntegration, DeletePublicIntegration, GetIntegration, GetIntegrationFlows, GetPublicIntegration, GetPublicListIntegrations, GetPublicListIntegrationsLegacy, PatchIntegration, PostIntegration } from './integration/api';
13
+ import type { DeleteIntegration, DeletePublicIntegration, GetIntegration, GetIntegrationFlows, GetPublicIntegration, GetPublicListIntegrations, GetPublicListIntegrationsLegacy, PatchIntegration, PatchPublicIntegration, PostIntegration, PostPublicIntegration } from './integration/api';
13
14
  import type { DeleteInvite, GetInvite, PostInvite } from './invitations/api';
14
15
  import type { GetOperation, PostInsights, SearchFilters, SearchMessages, SearchOperations } from './logs/api';
15
16
  import type { GetMeta } from './meta/api';
@@ -22,7 +23,7 @@ import type { PostPublicTrigger, PutPublicSyncConnectionFrequency } from './sync
22
23
  import type { DeleteTeamUser, GetTeam, PutTeam } from './team/api';
23
24
  import type { GetUser, PatchUser } from './user/api';
24
25
  import type { PostPublicWebhook } from './webhooks/http.api';
25
- export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | PostPublicTrigger | PostPublicTbaAuthorization | PostPublicTableauAuthorization | PostPublicJwtAuthorization | PostPublicUnauthenticatedAuthorization | PostPublicApiKeyAuthorization | PostPublicBasicAuthorization | PostPublicAppStoreAuthorization | GetPublicProviders | GetPublicProvider | GetPublicListIntegrationsLegacy | GetPublicListIntegrations | GetPublicIntegration | DeletePublicIntegration | PostConnectSessions | PostPublicConnectSessionsReconnect | GetPublicConnections | GetPublicConnection | GetConnectSession | DeleteConnectSession | PostDeployInternal | PostPublicBillAuthorization | DeletePublicConnection | PostPublicSignatureAuthorization | PostPublicTwoStepAuthorization | PostPublicWebhook | GetPublicRecords | GetPublicScriptsConfig | PostPublicConnectTelemetry | PutPublicSyncConnectionFrequency;
26
+ export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | PostPublicTrigger | PostPublicTbaAuthorization | PostPublicTableauAuthorization | PostPublicJwtAuthorization | PostPublicUnauthenticatedAuthorization | PostPublicApiKeyAuthorization | PostPublicBasicAuthorization | PostPublicAppStoreAuthorization | GetPublicProviders | GetPublicProvider | GetPublicListIntegrationsLegacy | GetPublicListIntegrations | GetPublicIntegration | DeletePublicIntegration | PostConnectSessions | PostPublicConnectSessionsReconnect | GetPublicConnections | GetPublicConnection | GetConnectSession | DeleteConnectSession | PostDeployInternal | PostPublicBillAuthorization | DeletePublicConnection | PostPublicSignatureAuthorization | PostPublicTwoStepAuthorization | PostPublicWebhook | GetPublicRecords | GetPublicScriptsConfig | PostPublicConnectTelemetry | PutPublicSyncConnectionFrequency | PostPublicIntegration | PatchPublicIntegration | GetAsyncActionResult;
26
27
  export type PrivateApiEndpoints = PostSignup | PostSignin | PostLogout | GetTeam | PutTeam | PostPlanExtendTrial | GetUser | PatchUser | PostInvite | DeleteInvite | DeleteTeamUser | PostInsights | PostForgotPassword | PutResetPassword | SearchOperations | GetOperation | SearchMessages | SearchFilters | PatchOnboarding | PostInternalConnectSessions | GetIntegrationFlows | DeleteIntegration | PatchIntegration | GetIntegration | PostIntegration | GetConnections | GetConnectionsCount | GetConnection | GetInvite | GetMeta | GetEmailByExpiredToken | GetEmailByUuid | GetManagedCallback | PatchFlowDisable | PatchFlowEnable | PatchFlowFrequency | PutUpgradePreBuiltFlow | PostConnectionRefresh | PostManagedSignup | PostPreBuiltDeploy | PostEnvironment | PatchEnvironment | DeleteEnvironment | PatchWebhook | PostEnvironmentVariables;
27
28
  export type APIEndpoints = PrivateApiEndpoints | PublicApiEndpoints;
28
29
  /**
@@ -0,0 +1,35 @@
1
+ import type { Result } from '../result';
2
+ export interface BillingClient {
3
+ ingest: (events: BillingIngestEvent[]) => Promise<void>;
4
+ getCustomer: (accountId: number) => Promise<Result<BillingCustomer>>;
5
+ getSubscription: (accountId: number) => Promise<Result<BillingSubscription | null>>;
6
+ getUsage: (subscriptionId: string, period?: 'previous') => Promise<Result<BillingUsageMetric[]>>;
7
+ }
8
+ export interface BillingCustomer {
9
+ id: string;
10
+ portalUrl: string | null;
11
+ }
12
+ export interface BillingSubscription {
13
+ id: string;
14
+ }
15
+ export interface BillingUsageMetric {
16
+ id: string;
17
+ name: string;
18
+ quantity: number;
19
+ }
20
+ export interface BillingIngestEvent {
21
+ type: 'monthly_active_records' | 'billable_connections' | 'billable_actions';
22
+ idempotencyKey: string;
23
+ accountId: number;
24
+ timestamp: Date;
25
+ properties: Record<string, string | number>;
26
+ }
27
+ export interface BillingMetric {
28
+ type: BillingIngestEvent['type'];
29
+ value: number;
30
+ properties: {
31
+ accountId: number;
32
+ timestamp?: Date | undefined;
33
+ idempotencyKey?: string | undefined;
34
+ };
35
+ }
@@ -12,6 +12,7 @@ export type PatchWebhook = Endpoint<{
12
12
  on_auth_creation?: boolean | undefined;
13
13
  on_auth_refresh_error?: boolean | undefined;
14
14
  on_sync_error?: boolean | undefined;
15
+ on_async_action_completion?: boolean | undefined;
15
16
  };
16
17
  Success: {
17
18
  success: boolean;
@@ -54,4 +54,5 @@ export interface DBExternalWebhook extends Timestamps {
54
54
  on_auth_creation: boolean;
55
55
  on_auth_refresh_error: boolean;
56
56
  on_sync_error: boolean;
57
+ on_async_action_completion: boolean;
57
58
  }
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export type * from './record/api.js';
7
7
  export type * from './logs/api.js';
8
8
  export type * from './logs/messages.js';
9
9
  export type * from './keystore/index.js';
10
+ export type * from './action/api.js';
10
11
  export type * from './account/api.js';
11
12
  export type * from './user/api.js';
12
13
  export type * from './user/db.js';
@@ -19,8 +20,10 @@ export type * from './syncConfigs/db.js';
19
20
  export type * from './syncConfigs/api.js';
20
21
  export type * from './team/api.js';
21
22
  export type * from './team/db.js';
23
+ export type * from './billing/types.js';
22
24
  export type * from './providers/api.js';
23
25
  export type * from './proxy/api.js';
26
+ export type * from './result.js';
24
27
  export type * from './scripts/on-events/db.js';
25
28
  export type * from './scripts/on-events/api.js';
26
29
  export type * from './scripts/syncs/api.js';
@@ -63,3 +66,4 @@ export type * from './fleet/api.js';
63
66
  export type * from './fleet/index.js';
64
67
  export type * from './persist/api.js';
65
68
  export type * from './jobs/api.js';
69
+ export type * from './mcp/api.js';
@@ -38,6 +38,19 @@ export type GetPublicListIntegrations = Endpoint<{
38
38
  data: ApiPublicIntegration[];
39
39
  };
40
40
  }>;
41
+ export type PostPublicIntegration = Endpoint<{
42
+ Method: 'POST';
43
+ Path: '/integrations';
44
+ Body: {
45
+ provider: string;
46
+ unique_key: string;
47
+ display_name?: string | undefined;
48
+ credentials?: ApiPublicIntegrationCredentials | undefined;
49
+ };
50
+ Success: {
51
+ data: ApiPublicIntegration;
52
+ };
53
+ }>;
41
54
  export type GetPublicIntegration = Endpoint<{
42
55
  Method: 'GET';
43
56
  Path: '/integrations/:uniqueKey';
@@ -51,7 +64,32 @@ export type GetPublicIntegration = Endpoint<{
51
64
  data: ApiPublicIntegration;
52
65
  };
53
66
  }>;
67
+ export type PatchPublicIntegration = Endpoint<{
68
+ Method: 'PATCH';
69
+ Path: '/integrations/:uniqueKey';
70
+ Params: {
71
+ uniqueKey: string;
72
+ };
73
+ Body: {
74
+ unique_key?: string | undefined;
75
+ display_name?: string | undefined;
76
+ credentials?: ApiPublicIntegrationCredentials | undefined;
77
+ };
78
+ Success: {
79
+ data: ApiPublicIntegration;
80
+ };
81
+ }>;
54
82
  export type DeletePublicIntegration = Endpoint<{
83
+ Method: 'DELETE';
84
+ Path: '/integrations/:uniqueKey';
85
+ Params: {
86
+ uniqueKey: string;
87
+ };
88
+ Success: {
89
+ success: true;
90
+ };
91
+ }>;
92
+ export type DeletePublicIntegrationDeprecated = Endpoint<{
55
93
  Method: 'DELETE';
56
94
  Path: '/config/:providerConfigKey';
57
95
  Params: {
@@ -182,3 +220,21 @@ export type GetIntegrationFlows = Endpoint<{
182
220
  };
183
221
  };
184
222
  }>;
223
+ export type ApiPublicIntegrationCredentials = {
224
+ type: Extract<AuthModeType, 'OAUTH1' | 'OAUTH2' | 'TBA'>;
225
+ client_id: string;
226
+ client_secret: string;
227
+ scopes?: string | undefined;
228
+ } | {
229
+ type: Extract<AuthModeType, 'APP'>;
230
+ app_id: string;
231
+ app_link: string;
232
+ private_key: string;
233
+ } | {
234
+ type: Extract<AuthModeType, 'CUSTOM'>;
235
+ client_id: string;
236
+ client_secret: string;
237
+ app_id: string;
238
+ app_link: string;
239
+ private_key: string;
240
+ };
@@ -1,6 +1,6 @@
1
1
  import type { TimestampsAndDeleted } from '../db.js';
2
2
  import type { NullablePartial } from '../utils.js';
3
- import type { SetOptional } from 'type-fest';
3
+ import type { SetOptional, Tagged } from 'type-fest';
4
4
  export interface IntegrationConfig extends TimestampsAndDeleted {
5
5
  id?: number | undefined;
6
6
  unique_key: string;
@@ -16,4 +16,5 @@ export interface IntegrationConfig extends TimestampsAndDeleted {
16
16
  missing_fields: string[];
17
17
  display_name: string | null;
18
18
  }
19
+ export type DBIntegrationCrypted = Tagged<IntegrationConfig, 'IntegrationCrypted'>;
19
20
  export type DBCreateIntegration = SetOptional<NullablePartial<Omit<IntegrationConfig, 'created_at' | 'updated_at'>>, 'missing_fields'>;
@@ -13,13 +13,14 @@ export type SearchOperations = Endpoint<{
13
13
  env: string;
14
14
  };
15
15
  Body: {
16
+ search?: string | undefined;
16
17
  limit?: number;
17
18
  states?: SearchOperationsState[];
18
19
  types?: SearchOperationsType[];
19
20
  integrations?: SearchOperationsIntegration[] | undefined;
20
21
  connections?: SearchOperationsConnection[] | undefined;
21
22
  syncs?: SearchOperationsSync[] | undefined;
22
- period?: SearchOperationsPeriod | undefined;
23
+ period?: SearchPeriod | undefined;
23
24
  cursor?: string | null | undefined;
24
25
  };
25
26
  Success: {
@@ -35,7 +36,7 @@ export type SearchOperationsType = 'all' | ConcatOperationListWithGroup;
35
36
  export type SearchOperationsIntegration = 'all' | string;
36
37
  export type SearchOperationsConnection = 'all' | string;
37
38
  export type SearchOperationsSync = 'all' | string;
38
- export interface SearchOperationsPeriod {
39
+ export interface SearchPeriod {
39
40
  from: string;
40
41
  to: string;
41
42
  }
@@ -66,6 +67,7 @@ export type SearchMessages = Endpoint<{
66
67
  search?: string | undefined;
67
68
  cursorBefore?: string | null | undefined;
68
69
  cursorAfter?: string | null | undefined;
70
+ period?: SearchPeriod | undefined;
69
71
  };
70
72
  Success: {
71
73
  data: MessageRow[];
@@ -0,0 +1,17 @@
1
+ import type { ApiError, Endpoint } from '../api.js';
2
+ export type PostMcp = Endpoint<{
3
+ Method: 'POST';
4
+ Path: '/mcp';
5
+ Body: Record<string, unknown>;
6
+ Headers: {
7
+ 'connection-id': string;
8
+ 'provider-config-key': string;
9
+ };
10
+ Success: Record<string, unknown>;
11
+ Error: ApiError<'missing_connection_id' | 'unknown_connection'>;
12
+ }>;
13
+ export type GetMcp = Endpoint<{
14
+ Method: 'GET';
15
+ Path: '/mcp';
16
+ Success: Record<string, unknown>;
17
+ }>;
@@ -1,3 +1,4 @@
1
+ import type { BillingCustomer, BillingUsageMetric } from '../billing/types';
1
2
  import type { ReplaceInObject } from '../utils';
2
3
  import type { DBPlan } from './db.js';
3
4
  import type { Endpoint } from '../api';
@@ -34,3 +35,17 @@ export type GetPlans = Endpoint<{
34
35
  data: PlanDefinition[];
35
36
  };
36
37
  }>;
38
+ export type GetUsage = Endpoint<{
39
+ Method: 'GET';
40
+ Path: '/api/v1/plans/usage';
41
+ Querystring: {
42
+ env: string;
43
+ };
44
+ Success: {
45
+ data: {
46
+ customer: BillingCustomer;
47
+ current: BillingUsageMetric[];
48
+ previous: BillingUsageMetric[];
49
+ };
50
+ };
51
+ }>;
@@ -84,7 +84,7 @@ export interface BaseProvider {
84
84
  body_format?: OAuthBodyFormatType;
85
85
  }
86
86
  export interface ProviderOAuth2 extends BaseProvider {
87
- auth_mode: 'OAUTH2' | 'CUSTOM';
87
+ auth_mode: 'OAUTH2';
88
88
  disable_pkce?: boolean;
89
89
  token_params?: {
90
90
  grant_type?: 'authorization_code' | 'client_credentials';
@@ -93,6 +93,7 @@ export interface ProviderOAuth2 extends BaseProvider {
93
93
  grant_type: 'refresh_token';
94
94
  };
95
95
  authorization_method?: OAuthAuthorizationMethodType;
96
+ alternate_access_token_response_path?: string;
96
97
  refresh_url?: string;
97
98
  expires_in_unit?: 'milliseconds';
98
99
  token_request_auth_method?: 'basic' | 'custom';
@@ -105,6 +106,13 @@ export interface ProviderOAuth1 extends BaseProvider {
105
106
  token_http_method?: 'GET' | 'PUT' | 'POST';
106
107
  signature_method: 'HMAC-SHA1' | 'RSA-SHA1' | 'PLAINTEXT';
107
108
  }
109
+ export interface ProviderCustom extends Omit<ProviderOAuth2, 'auth_mode'> {
110
+ auth_mode: 'CUSTOM';
111
+ token_url: {
112
+ OAUTH2: string;
113
+ APP: string;
114
+ };
115
+ }
108
116
  export interface ProviderJwt extends BaseProvider {
109
117
  auth_mode: 'JWT';
110
118
  signature: {
@@ -170,6 +178,6 @@ export interface ProviderSignature extends BaseProvider {
170
178
  export interface ProviderApiKey extends BaseProvider {
171
179
  auth_mode: 'API_KEY';
172
180
  }
173
- export type Provider = BaseProvider | ProviderOAuth1 | ProviderOAuth2 | ProviderJwt | ProviderTwoStep | ProviderSignature | ProviderApiKey | ProviderTableau | ProviderBill | ProviderGithubApp | ProviderAppleAppStore;
181
+ export type Provider = BaseProvider | ProviderOAuth1 | ProviderOAuth2 | ProviderJwt | ProviderTwoStep | ProviderSignature | ProviderApiKey | ProviderTableau | ProviderBill | ProviderGithubApp | ProviderAppleAppStore | ProviderCustom;
174
182
  export type RefreshableProvider = ProviderTwoStep | ProviderJwt | ProviderSignature | ProviderOAuth2;
175
183
  export type TestableProvider = ProviderApiKey;
@@ -0,0 +1,17 @@
1
+ export interface Left<T, E extends Error> {
2
+ error: E;
3
+ isErr(this: Result<T, E>): this is Left<T, E>;
4
+ isOk(this: Result<T, E>): this is Right<T, E>;
5
+ unwrap(): T;
6
+ map<U>(fn: (value: T) => U): Result<T, E>;
7
+ mapError<U extends Error>(fn: (error: E) => U): Result<T, U>;
8
+ }
9
+ export interface Right<T, E extends Error> {
10
+ value: T;
11
+ isErr(this: Result<T, E>): this is Left<T, E>;
12
+ isOk(this: Result<T, E>): this is Right<T, E>;
13
+ unwrap(): T;
14
+ map<U>(fn: (value: T) => U): Result<U, E>;
15
+ mapError<U extends Error>(fn: (error: E) => U): Result<T, U>;
16
+ }
17
+ export type Result<T, E extends Error = Error> = Left<T, E> | Right<T, E>;
@@ -1,7 +1,7 @@
1
- import type { JSONSchema7 } from 'json-schema';
2
1
  import type { TimestampsAndDeleted } from '../db';
3
2
  import type { LegacySyncModelSchema, NangoConfigMetadata } from '../deploy/incomingFlow';
4
3
  import type { NangoModel, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml';
4
+ import type { JSONSchema7 } from 'json-schema';
5
5
  export interface DBSyncConfig extends TimestampsAndDeleted {
6
6
  id: number;
7
7
  sync_name: string;
@@ -1,7 +1,8 @@
1
1
  import type { AuthOperationType, AuthModeType } from '../auth/api.js';
2
2
  import type { SyncResult } from '../scripts/syncs/api.js';
3
3
  import type { ErrorPayload } from '../api.js';
4
- export type WebhookTypes = 'sync' | 'auth' | 'forward';
4
+ import type { AsyncActionResponse } from '../action/api.js';
5
+ export type WebhookTypes = 'sync' | 'auth' | 'forward' | 'async_action';
5
6
  export interface NangoWebhookBase {
6
7
  from: string;
7
8
  type: WebhookTypes;
@@ -64,3 +65,9 @@ export interface NangoForwardWebhookBody extends NangoWebhookBase {
64
65
  providerConfigKey: string;
65
66
  payload: unknown;
66
67
  }
68
+ export interface NangoAsyncActionWebhookBody extends NangoWebhookBase {
69
+ type: 'async_action';
70
+ connectionId: string;
71
+ providerConfigKey: string;
72
+ payload: AsyncActionResponse;
73
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.58.6",
3
+ "version": "0.59.0",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",
@@ -12,9 +12,9 @@
12
12
  "directory": "packages/utils"
13
13
  },
14
14
  "dependencies": {
15
- "axios": "^1.8.4",
15
+ "axios": "1.9.0",
16
16
  "json-schema": "0.4.0",
17
- "type-fest": "4.32.0"
17
+ "type-fest": "4.40.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/json-schema": "7.0.15"