@nangohq/types 0.39.32 → 0.40.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,10 @@
1
+ export interface Account {
2
+ id: number;
3
+ name: string;
4
+ secret_key: string;
5
+ host?: string | null;
6
+ websockets_path?: string;
7
+ uuid: string;
8
+ is_admin?: boolean;
9
+ is_capped?: boolean;
10
+ }
package/dist/api.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- export interface ApiError<TCode extends string, TErrors = undefined> {
1
+ export interface ApiError<TCode extends string, TErrors = undefined, P = unknown> {
2
2
  error: {
3
3
  code: TCode;
4
4
  message?: string | undefined;
5
5
  errors?: TErrors;
6
+ payload?: P;
6
7
  };
7
8
  }
8
9
  export interface ValidationError {
@@ -56,3 +57,7 @@ export interface Endpoint<T extends EndpointDefinition> {
56
57
  */
57
58
  Reply: ResDefaultErrors | (T['Error'] extends ApiError<any> ? T['Error'] | T['Success'] : T['Success']);
58
59
  }
60
+ export interface ErrorPayload {
61
+ type: string;
62
+ description: string;
63
+ }
@@ -0,0 +1,102 @@
1
+ import type { BaseConnection } from '../connection/db.js';
2
+ export interface AuthModes {
3
+ OAuth1: 'OAUTH1';
4
+ OAuth2: 'OAUTH2';
5
+ OAuth2CC: 'OAUTH2_CC';
6
+ Basic: 'BASIC';
7
+ ApiKey: 'API_KEY';
8
+ AppStore: 'APP_STORE';
9
+ Custom: 'CUSTOM';
10
+ App: 'APP';
11
+ None: 'NONE';
12
+ }
13
+ export type AuthModeType = AuthModes[keyof AuthModes];
14
+ export interface AuthOperation {
15
+ CREATION: 'creation';
16
+ OVERRIDE: 'override';
17
+ REFRESH: 'refresh';
18
+ UNKNOWN: 'unknown';
19
+ }
20
+ export type AuthOperationType = AuthOperation[keyof AuthOperation];
21
+ export interface OAuthAuthorizationMethod {
22
+ BODY: 'body';
23
+ HEADER: 'header';
24
+ }
25
+ export type OAuthAuthorizationMethodType = OAuthAuthorizationMethod[keyof OAuthAuthorizationMethod];
26
+ export type OAuthBodyFormatType = OAuthBodyFormat[keyof OAuthBodyFormat];
27
+ export interface OAuthBodyFormat {
28
+ FORM: 'form';
29
+ JSON: 'json';
30
+ }
31
+ export interface ConnectionUpsertResponse {
32
+ id: number;
33
+ operation: AuthOperation;
34
+ }
35
+ export interface OAuth1RequestTokenResult {
36
+ request_token: string;
37
+ request_token_secret: string;
38
+ parsed_query_string: any;
39
+ }
40
+ export interface CredentialsCommon<T = Record<string, any>> {
41
+ type: AuthModeType;
42
+ raw: T;
43
+ }
44
+ export interface BasicApiCredentials {
45
+ type?: AuthModes['Basic'];
46
+ username: string;
47
+ password: string;
48
+ }
49
+ export interface ApiKeyCredentials {
50
+ type?: AuthModes['ApiKey'];
51
+ apiKey: string;
52
+ }
53
+ export type AuthCredentials = OAuth2Credentials | OAuth1Credentials | OAuth2ClientCredentials;
54
+ export interface AppCredentials {
55
+ type?: AuthModes['App'];
56
+ access_token: string;
57
+ expires_at?: Date | undefined;
58
+ raw: Record<string, any>;
59
+ }
60
+ export interface AppStoreCredentials {
61
+ type?: AuthModes['AppStore'];
62
+ access_token: string;
63
+ expires_at?: Date | undefined;
64
+ raw: Record<string, any>;
65
+ private_key: string;
66
+ }
67
+ export interface OAuth2Credentials extends CredentialsCommon {
68
+ type: AuthModes['OAuth2'];
69
+ access_token: string;
70
+ refresh_token?: string;
71
+ expires_at?: Date | undefined;
72
+ config_override?: {
73
+ client_id?: string;
74
+ client_secret?: string;
75
+ };
76
+ }
77
+ export interface CustomCredentials extends CredentialsCommon {
78
+ type: AuthModes['Custom'];
79
+ }
80
+ export interface OAuth2ClientCredentials extends CredentialsCommon {
81
+ type: AuthModes['OAuth2CC'];
82
+ token: string;
83
+ expires_at?: Date | undefined;
84
+ client_id: string;
85
+ client_secret: string;
86
+ }
87
+ export interface OAuth1Credentials extends CredentialsCommon {
88
+ type: AuthModes['OAuth1'];
89
+ oauth_token: string;
90
+ oauth_token_secret: string;
91
+ }
92
+ export interface CredentialsRefresh<T = unknown> {
93
+ providerConfigKey: string;
94
+ connectionId: string;
95
+ promise: Promise<T>;
96
+ }
97
+ export type UnauthCredentials = Record<string, never>;
98
+ export type RefreshTokenResponse = AuthorizationTokenResponse;
99
+ export interface AuthorizationTokenResponse extends Omit<OAuth2Credentials, 'type' | 'raw'> {
100
+ expires_in?: number;
101
+ }
102
+ export type ImportedCredentials = (OAuth2Credentials & Partial<Pick<AuthorizationTokenResponse, 'expires_in'>> & Partial<Pick<BaseConnection, 'metadata' | 'connection_config'>>) | OAuth1Credentials;
@@ -0,0 +1,15 @@
1
+ import type { AuthModes } from './api.js';
2
+ export interface OAuthSession {
3
+ providerConfigKey: string;
4
+ provider: string;
5
+ connectionId: string;
6
+ callbackUrl: string;
7
+ authMode: AuthModes;
8
+ id: string;
9
+ connectionConfig: Record<string, string>;
10
+ environmentId: number;
11
+ webSocketClientId: string | undefined;
12
+ codeVerifier: string;
13
+ requestTokenSecret?: string;
14
+ activityLogId: string;
15
+ }
@@ -0,0 +1,21 @@
1
+ import type { ApiError, Endpoint } from '../../api.js';
2
+ import type { Connection } from '../db.js';
3
+ import type { ActiveLog } from '../../notification/active-logs/db.js';
4
+ export type GetConnection = Endpoint<{
5
+ Method: 'GET';
6
+ Params: {
7
+ connectionId: string;
8
+ };
9
+ Querystring: {
10
+ env: string;
11
+ provider_config_key: string;
12
+ force_refresh?: 'true' | 'false';
13
+ };
14
+ Path: '/api/v1/connection/:connectionId';
15
+ Error: ApiError<'unknown_connection'> | ApiError<'missing_provider_config'> | ApiError<'unknown_provider'> | ApiError<'missing_connection'> | ApiError<'unknown_provider_config'>;
16
+ Success: {
17
+ provider: string | null;
18
+ connection: Connection;
19
+ errorLog: ActiveLog | null;
20
+ };
21
+ }>;
@@ -1 +1,62 @@
1
+ import type { TimestampsAndDeleted } from '../db.js';
2
+ import type { AuthCredentials, ApiKeyCredentials, BasicApiCredentials, AppCredentials, AppStoreCredentials, UnauthCredentials, CustomCredentials, AuthModeType, AuthOperationType } from '../auth/api.js';
3
+ import type { Environment } from '../environment/db.js';
4
+ import type { Account } from '../account/db.js';
1
5
  export type Metadata = Record<string, unknown>;
6
+ export type ConnectionConfig = Record<string, any>;
7
+ export interface BaseConnection extends TimestampsAndDeleted {
8
+ id?: number;
9
+ config_id?: number;
10
+ provider_config_key: string;
11
+ connection_id: string;
12
+ connection_config: ConnectionConfig;
13
+ environment_id: number;
14
+ metadata?: Metadata | null;
15
+ credentials_iv?: string | null;
16
+ credentials_tag?: string | null;
17
+ last_fetched_at?: Date | null;
18
+ }
19
+ export interface StoredConnection extends BaseConnection {
20
+ credentials: Record<string, any>;
21
+ }
22
+ export interface Connection extends BaseConnection {
23
+ credentials: AuthCredentials | ApiKeyCredentials | BasicApiCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | CustomCredentials;
24
+ }
25
+ export type RecentlyCreatedConnection = Pick<StoredConnection, 'id' | 'connection_id' | 'provider_config_key'> & {
26
+ auth_mode: AuthModeType;
27
+ error?: string;
28
+ operation: AuthOperationType;
29
+ environment: Environment;
30
+ account: Account;
31
+ };
32
+ export interface ApiConnection {
33
+ id?: number;
34
+ connection_id: string;
35
+ provider_config_key: string;
36
+ config_id?: number;
37
+ environment_id: number;
38
+ connection_config: ConnectionConfig;
39
+ credentials_iv?: string | null;
40
+ credentials_tag?: string | null;
41
+ credentials: BasicApiCredentials | ApiKeyCredentials;
42
+ }
43
+ export interface NangoConnection {
44
+ id?: number;
45
+ connection_id: string;
46
+ provider_config_key: string;
47
+ environment_id: number;
48
+ connection_config?: ConnectionConfig;
49
+ /**
50
+ * @deprecated
51
+ */
52
+ account_id?: number;
53
+ }
54
+ export interface ConnectionList {
55
+ id: number;
56
+ connection_id: string;
57
+ provider_config_key: string;
58
+ provider: string;
59
+ created: string;
60
+ metadata?: Metadata | null;
61
+ error_log_id?: number | string | null;
62
+ }
@@ -7,3 +7,31 @@ export interface EnvironmentVariable extends Timestamps {
7
7
  value_iv?: string | null;
8
8
  value_tag?: string | null;
9
9
  }
10
+ export interface Environment extends Timestamps {
11
+ id: number;
12
+ uuid: string;
13
+ name: string;
14
+ account_id: number;
15
+ secret_key: string;
16
+ public_key: string;
17
+ secret_key_iv?: string | null;
18
+ secret_key_tag?: string | null;
19
+ secret_key_hashed?: string | null;
20
+ callback_url: string | null;
21
+ webhook_url: string | null;
22
+ webhook_url_secondary: string | null;
23
+ websockets_path: string | null;
24
+ hmac_enabled: boolean;
25
+ always_send_webhook: boolean;
26
+ send_auth_webhook: boolean;
27
+ hmac_key: string | null;
28
+ hmac_digest?: string | null;
29
+ secret_key_rotatable?: boolean;
30
+ public_key_rotatable?: boolean;
31
+ pending_secret_key?: string | null;
32
+ pending_secret_key_iv?: string | null;
33
+ pending_secret_key_tag?: string | null;
34
+ pending_public_key?: string | null;
35
+ slack_notifications: boolean;
36
+ webhook_receive_url?: string;
37
+ }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,17 @@ 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 './account/api.js';
10
+ export type * from './account/db.js';
10
11
  export type * from './user/api.js';
11
12
  export type * from './connection/api/metadata.js';
12
13
  export type * from './connection/db.js';
13
14
  export type * from './environment/db.js';
15
+ export type * from './scripts/post-connection/api.js';
16
+ export type * from './scripts/post-connection/db.js';
17
+ export type * from './scripts/syncs/api.js';
18
+ export type * from './notification/active-logs/db.js';
19
+ export type * from './connection/api/get.js';
20
+ export type * from './integration/db.js';
21
+ export type * from './integration/template.js';
22
+ export type * from './auth/api.js';
23
+ export type * from './auth/db.js';
@@ -0,0 +1,14 @@
1
+ import type { TimestampsAndDeleted } from '../db.js';
2
+ export interface IntegrationConfig extends TimestampsAndDeleted {
3
+ id?: number;
4
+ unique_key: string;
5
+ provider: string;
6
+ oauth_client_id: string;
7
+ oauth_client_secret: string;
8
+ oauth_scopes?: string;
9
+ environment_id: number;
10
+ oauth_client_secret_iv?: string | null;
11
+ oauth_client_secret_tag?: string | null;
12
+ app_link?: string | null;
13
+ custom?: Record<string, string>;
14
+ }
@@ -0,0 +1,71 @@
1
+ import type { RetryHeaderConfig, CursorPagination, LinkPagination, OffsetPagination } from '../proxy/api.js';
2
+ import type { AuthModeType, OAuthAuthorizationMethodType, OAuthBodyFormatType } from '../auth/api.js';
3
+ import type { EndpointMethod } from '../api.js';
4
+ export interface TokenUrlObject {
5
+ OAUTH1?: string;
6
+ OAUTH2?: string;
7
+ OAUTH2CC?: string;
8
+ BASIC?: string;
9
+ API_KEY?: string;
10
+ APP_STORE?: string;
11
+ CUSTOM?: string;
12
+ APP?: string;
13
+ NONE?: string;
14
+ }
15
+ export interface Template {
16
+ auth_mode: AuthModeType;
17
+ proxy?: {
18
+ base_url: string;
19
+ headers?: Record<string, string>;
20
+ query?: {
21
+ api_key: string;
22
+ };
23
+ retry?: RetryHeaderConfig;
24
+ decompress?: boolean;
25
+ paginate?: LinkPagination | CursorPagination | OffsetPagination;
26
+ verification?: {
27
+ method: EndpointMethod;
28
+ endpoint: string;
29
+ base_url_override?: string;
30
+ headers?: Record<string, string>;
31
+ };
32
+ };
33
+ authorization_url?: string;
34
+ authorization_params?: Record<string, string>;
35
+ scope_separator?: string;
36
+ default_scopes?: string[];
37
+ token_url?: string | TokenUrlObject;
38
+ token_params?: Record<string, string>;
39
+ authorization_url_replacements?: Record<string, string>;
40
+ redirect_uri_metadata?: string[];
41
+ token_response_metadata?: string[];
42
+ docs?: string;
43
+ token_expiration_buffer?: number;
44
+ webhook_routing_script?: string;
45
+ webhook_user_defined_secret?: boolean;
46
+ post_connection_script?: string;
47
+ categories?: string[];
48
+ connection_configuration?: string[];
49
+ }
50
+ export interface TemplateOAuth2 extends Template {
51
+ auth_mode: 'OAUTH2' | 'CUSTOM';
52
+ disable_pkce?: boolean;
53
+ token_params?: {
54
+ grant_type?: 'authorization_code' | 'client_credentials';
55
+ };
56
+ refresh_params?: {
57
+ grant_type: 'refresh_token';
58
+ };
59
+ authorization_method?: OAuthAuthorizationMethodType;
60
+ body_format?: OAuthBodyFormatType;
61
+ refresh_url?: string;
62
+ token_request_auth_method?: 'basic';
63
+ }
64
+ export interface TemplateOAuth1 extends Template {
65
+ auth_mode: 'OAUTH1';
66
+ request_url: string;
67
+ request_params?: Record<string, string>;
68
+ request_http_method?: 'GET' | 'PUT' | 'POST';
69
+ token_http_method?: 'GET' | 'PUT' | 'POST';
70
+ signature_method: 'HMAC-SHA1' | 'RSA-SHA1' | 'PLAINTEXT';
71
+ }
@@ -17,11 +17,13 @@ export type SearchOperations = Endpoint<{
17
17
  connections?: SearchOperationsConnection[] | undefined;
18
18
  syncs?: SearchOperationsSync[] | undefined;
19
19
  period?: SearchOperationsPeriod | undefined;
20
+ cursor?: string | null | undefined;
20
21
  };
21
22
  Success: {
22
23
  data: OperationRow[];
23
24
  pagination: {
24
25
  total: number;
26
+ cursor: string | null;
25
27
  };
26
28
  };
27
29
  }>;
@@ -59,11 +61,15 @@ export type SearchMessages = Endpoint<{
59
61
  limit?: number;
60
62
  states?: SearchOperationsState[];
61
63
  search?: string | undefined;
64
+ cursorBefore?: string | null | undefined;
65
+ cursorAfter?: string | null | undefined;
62
66
  };
63
67
  Success: {
64
68
  data: MessageRow[];
65
69
  pagination: {
66
70
  total: number;
71
+ cursorBefore: string | null;
72
+ cursorAfter: string | null;
67
73
  };
68
74
  };
69
75
  }>;
@@ -104,6 +104,7 @@ export type MessageRow = {
104
104
  updatedAt: string;
105
105
  startedAt: string | null;
106
106
  endedAt: string | null;
107
+ expiresAt: string | null;
107
108
  } & {
108
109
  operation: MessageOperation | null;
109
110
  };
@@ -0,0 +1,12 @@
1
+ import type { Timestamps } from '../../db.js';
2
+ export interface ActiveLog extends Timestamps {
3
+ id: number;
4
+ type: string;
5
+ action: string;
6
+ connection_id: number;
7
+ activity_log_id: number;
8
+ log_id: string;
9
+ active: boolean;
10
+ sync_id: string | null;
11
+ }
12
+ export type ActiveLogIds = Pick<ActiveLog, 'activity_log_id' | 'log_id'>;
@@ -0,0 +1,65 @@
1
+ import type { ParamsSerializerOptions } from 'axios';
2
+ import type { EndpointMethod } from '../api.js';
3
+ import type { BasicApiCredentials, ApiKeyCredentials, AppCredentials } from '../auth/api.js';
4
+ import type { Connection } from '../connection/db.js';
5
+ import type { Template as ProviderTemplate } from '../integration/template.js';
6
+ interface BaseProxyConfiguration {
7
+ providerConfigKey: string;
8
+ connectionId: string;
9
+ endpoint: string;
10
+ retries?: number;
11
+ data?: unknown;
12
+ headers?: Record<string, string>;
13
+ params?: string | Record<string, string | number>;
14
+ paramsSerializer?: ParamsSerializerOptions;
15
+ baseUrlOverride?: string;
16
+ responseType?: ResponseType;
17
+ retryHeader?: RetryHeaderConfig;
18
+ retryOn?: number[] | null;
19
+ }
20
+ export interface UserProvidedProxyConfiguration extends BaseProxyConfiguration {
21
+ decompress?: boolean | string;
22
+ method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'get' | 'post' | 'patch' | 'put' | 'delete';
23
+ paginate?: Partial<CursorPagination> | Partial<LinkPagination> | Partial<OffsetPagination>;
24
+ }
25
+ export interface ApplicationConstructedProxyConfiguration extends BaseProxyConfiguration {
26
+ decompress?: boolean;
27
+ method: EndpointMethod;
28
+ provider: string;
29
+ token: string | BasicApiCredentials | ApiKeyCredentials | AppCredentials;
30
+ template: ProviderTemplate;
31
+ connection: Connection;
32
+ }
33
+ export type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
34
+ export interface InternalProxyConfiguration {
35
+ provider: string;
36
+ connection: Connection;
37
+ existingActivityLogId?: number | null;
38
+ }
39
+ export interface RetryHeaderConfig {
40
+ at?: string;
41
+ after?: string;
42
+ }
43
+ export declare enum PaginationType {
44
+ CURSOR = "cursor",
45
+ LINK = "link",
46
+ OFFSET = "offset"
47
+ }
48
+ export interface Pagination {
49
+ type: string;
50
+ limit?: number;
51
+ response_path?: string;
52
+ limit_name_in_request: string;
53
+ }
54
+ export interface CursorPagination extends Pagination {
55
+ cursor_path_in_response: string;
56
+ cursor_name_in_request: string;
57
+ }
58
+ export interface LinkPagination extends Pagination {
59
+ link_rel_in_response_header?: string;
60
+ link_path_in_response_body?: string;
61
+ }
62
+ export interface OffsetPagination extends Pagination {
63
+ offset_name_in_request: string;
64
+ }
65
+ export {};
@@ -0,0 +1,11 @@
1
+ export interface IncomingPostConnectionScript {
2
+ name: string;
3
+ fileBody: {
4
+ js: string;
5
+ ts: string;
6
+ };
7
+ }
8
+ export interface PostConnectionScriptByProvider {
9
+ providerConfigKey: string;
10
+ scripts: IncomingPostConnectionScript[];
11
+ }
@@ -0,0 +1,9 @@
1
+ import type { Timestamps } from '../../db.js';
2
+ export interface PostConnectionScript extends Timestamps {
3
+ id: number;
4
+ config_id: number;
5
+ name: string;
6
+ file_location: string;
7
+ version: string;
8
+ active: boolean;
9
+ }
@@ -0,0 +1,6 @@
1
+ export interface SyncResult {
2
+ added: number;
3
+ updated: number;
4
+ deleted: number;
5
+ }
6
+ export type SyncType = 'INCREMENTAL' | 'INITIAL';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.39.32",
3
+ "version": "0.40.0",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",
@@ -11,6 +11,9 @@
11
11
  "url": "git+https://github.com/NangoHQ/nango.git",
12
12
  "directory": "packages/utils"
13
13
  },
14
+ "devDependencies": {
15
+ "axios": "^1.3.4"
16
+ },
14
17
  "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY",
15
18
  "files": [
16
19
  "dist/**/*"