@nangohq/types 0.42.20 → 0.42.22

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.
package/dist/api.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export interface ApiError<TCode extends string, TErrors = any, P = unknown> {
1
+ export interface ApiError<TCode extends string, TErrors = any, TPayload = unknown> {
2
2
  error: {
3
3
  code: TCode;
4
4
  message?: string | undefined;
5
5
  errors?: TErrors;
6
- payload?: P;
6
+ payload?: TPayload;
7
7
  };
8
8
  }
9
9
  export interface ValidationError {
@@ -11,7 +11,7 @@ export interface ValidationError {
11
11
  message: string;
12
12
  path: (string | number)[];
13
13
  }
14
- export type ResDefaultErrors = ApiError<'not_found'> | ApiError<'invalid_query_params', ValidationError[]> | ApiError<'invalid_body', ValidationError[]> | ApiError<'invalid_uri_params', ValidationError[]> | ApiError<'feature_disabled'> | ApiError<'generic_error_support', undefined, string> | ApiError<'server_error'> | ApiError<'resource_capped'> | ApiError<'missing_auth_header'> | ApiError<'malformed_auth_header'> | ApiError<'unknown_account'> | ApiError<'unknown_connect_session_token'>;
14
+ export type ResDefaultErrors = ApiError<'not_found'> | ApiError<'invalid_query_params', ValidationError[]> | ApiError<'invalid_body', ValidationError[]> | ApiError<'invalid_uri_params', ValidationError[]> | ApiError<'feature_disabled'> | ApiError<'generic_error_support', undefined, string> | ApiError<'server_error'> | ApiError<'resource_capped'> | ApiError<'missing_auth_header'> | ApiError<'malformed_auth_header'> | ApiError<'unknown_account'> | ApiError<'unknown_connect_session_token'> | ApiError<'invalid_cli_version'>;
15
15
  export type EndpointMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
16
16
  /**
17
17
  * API Request/Response type
@@ -12,6 +12,7 @@ export interface AuthModes {
12
12
  Tableau: 'TABLEAU';
13
13
  Jwt: 'JWT';
14
14
  Bill: 'BILL';
15
+ TwoStep: 'TWO_STEP';
15
16
  }
16
17
  export type AuthModeType = AuthModes[keyof AuthModes];
17
18
  export interface AuthOperation {
@@ -135,9 +136,15 @@ export interface JwtCredentials {
135
136
  token?: string;
136
137
  expires_at?: Date | undefined;
137
138
  }
139
+ export interface TwoStepCredentials extends CredentialsCommon {
140
+ type: AuthModes['TwoStep'];
141
+ [key: string]: any;
142
+ token?: string;
143
+ expires_at?: Date | undefined;
144
+ }
138
145
  export type UnauthCredentials = Record<string, never>;
139
146
  export type RefreshTokenResponse = AuthorizationTokenResponse;
140
147
  export interface AuthorizationTokenResponse extends Omit<OAuth2Credentials, 'type' | 'raw'> {
141
148
  expires_in?: number;
142
149
  }
143
- export type AllAuthCredentials = OAuth1Credentials | OAuth2Credentials | OAuth2ClientCredentials | BasicApiCredentials | ApiKeyCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | CustomCredentials | TbaCredentials | TableauCredentials | JwtCredentials | BillCredentials;
150
+ export type AllAuthCredentials = OAuth1Credentials | OAuth2Credentials | OAuth2ClientCredentials | BasicApiCredentials | ApiKeyCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | CustomCredentials | TbaCredentials | TableauCredentials | JwtCredentials | BillCredentials | TwoStepCredentials;
@@ -108,3 +108,21 @@ export type PostPublicBillAuthorization = Endpoint<{
108
108
  connectionId: string;
109
109
  };
110
110
  }>;
111
+ export type PostPublicTwoStepAuthorization = Endpoint<{
112
+ Method: 'POST';
113
+ Body: Record<string, any>;
114
+ Querystring: {
115
+ connection_id?: string | undefined;
116
+ params?: Record<string, any> | undefined;
117
+ hmac?: string | undefined;
118
+ };
119
+ Params: {
120
+ providerConfigKey: string;
121
+ };
122
+ Path: '/auth/two-step';
123
+ Error: ApiError<'invalid_body'> | ApiError<'invalid_query_params'> | ApiError<'unknown_provider_config'> | ApiError<'unknown_provider_template'> | ApiError<'invalid_auth_mode'> | ApiError<'invalid_credentials'>;
124
+ Success: {
125
+ providerConfigKey: string;
126
+ connectionId: string;
127
+ };
128
+ }>;
@@ -41,4 +41,5 @@ export type PostInternalConnectSessions = Endpoint<{
41
41
  Method: 'POST';
42
42
  Path: '/api/v1/connect/sessions';
43
43
  Success: PostConnectSessions['Success'];
44
+ Body: Pick<ConnectSessionPayload, 'allowed_integrations'>;
44
45
  }>;
@@ -1,6 +1,64 @@
1
- import type { ApiError, Endpoint } from '../../api.js';
2
- import type { Connection } from '../db.js';
1
+ import type { ApiError, ApiTimestamps, Endpoint } from '../../api.js';
2
+ import type { DBConnection } from '../db.js';
3
3
  import type { ActiveLog } from '../../notification/active-logs/db.js';
4
+ import type { Merge } from 'type-fest';
5
+ import type { ApiEndUser } from '../../endUser/index.js';
6
+ export type ApiConnectionSimple = Pick<Merge<DBConnection, ApiTimestamps>, 'id' | 'connection_id' | 'provider_config_key' | 'created_at' | 'updated_at'> & {
7
+ provider: string;
8
+ errors: [{
9
+ type: string;
10
+ log_id: string;
11
+ }];
12
+ endUser: ApiEndUser | null;
13
+ };
14
+ export type GetConnections = Endpoint<{
15
+ Method: 'GET';
16
+ Querystring: {
17
+ env: string;
18
+ integrationIds?: string[] | undefined;
19
+ search?: string | undefined;
20
+ withError?: boolean | undefined;
21
+ page?: number | undefined;
22
+ };
23
+ Path: '/api/v1/connections';
24
+ Success: {
25
+ data: ApiConnectionSimple[];
26
+ };
27
+ }>;
28
+ export type GetConnectionsCount = Endpoint<{
29
+ Method: 'GET';
30
+ Querystring: {
31
+ env: string;
32
+ };
33
+ Path: '/api/v1/connections/count';
34
+ Success: {
35
+ data: {
36
+ total: number;
37
+ withAuthError: number;
38
+ };
39
+ };
40
+ }>;
41
+ export type ApiPublicConnection = Pick<DBConnection, 'id' | 'connection_id' | 'provider_config_key'> & {
42
+ created: string;
43
+ metadata: Record<string, unknown> | null;
44
+ provider: string;
45
+ errors: [{
46
+ type: string;
47
+ log_id: string;
48
+ }];
49
+ };
50
+ export type GetPublicConnections = Endpoint<{
51
+ Method: 'GET';
52
+ Querystring: {
53
+ connectionId?: string | undefined;
54
+ search?: string | undefined;
55
+ };
56
+ Path: '/connection';
57
+ Success: {
58
+ connections: ApiPublicConnection[];
59
+ };
60
+ }>;
61
+ export type ApiConnectionFull = Merge<DBConnection, ApiTimestamps>;
4
62
  export type GetConnection = Endpoint<{
5
63
  Method: 'GET';
6
64
  Params: {
@@ -9,14 +67,33 @@ export type GetConnection = Endpoint<{
9
67
  Querystring: {
10
68
  env: string;
11
69
  provider_config_key: string;
12
- force_refresh?: 'true' | 'false';
13
70
  };
14
71
  Path: '/api/v1/connections/:connectionId';
15
- Error: ApiError<'unknown_connection'> | ApiError<'missing_provider_config'> | ApiError<'unknown_provider'> | ApiError<'missing_connection'> | ApiError<'unknown_provider_config'>;
72
+ Error: ApiError<'unknown_provider_config'>;
73
+ Success: {
74
+ data: {
75
+ provider: string | null;
76
+ connection: ApiConnectionFull;
77
+ endUser: ApiEndUser | null;
78
+ errorLog: ActiveLog | null;
79
+ };
80
+ };
81
+ }>;
82
+ export type PostConnectionRefresh = Endpoint<{
83
+ Method: 'POST';
84
+ Params: {
85
+ connectionId: string;
86
+ };
87
+ Querystring: {
88
+ env: string;
89
+ provider_config_key: string;
90
+ };
91
+ Path: '/api/v1/connections/:connectionId/refresh';
92
+ Error: ApiError<'unknown_provider_config'> | ApiError<'failed_to_refresh', any, ActiveLog | null>;
16
93
  Success: {
17
- provider: string | null;
18
- connection: Connection;
19
- errorLog: ActiveLog | null;
94
+ data: {
95
+ success: boolean;
96
+ };
20
97
  };
21
98
  }>;
22
99
  export type DeletePublicConnection = Endpoint<{
@@ -1,7 +1,8 @@
1
1
  import type { TimestampsAndDeleted } from '../db.js';
2
- import type { ApiKeyCredentials, BasicApiCredentials, AuthModeType, AuthOperationType, AllAuthCredentials } from '../auth/api.js';
2
+ import type { AuthModeType, AuthOperationType, AllAuthCredentials } from '../auth/api.js';
3
3
  import type { DBEnvironment } from '../environment/db.js';
4
4
  import type { DBTeam } from '../team/db.js';
5
+ import type { Merge } from 'type-fest';
5
6
  export type Metadata = Record<string, unknown>;
6
7
  export type ConnectionConfig = Record<string, any>;
7
8
  export interface BaseConnection extends TimestampsAndDeleted {
@@ -20,6 +21,11 @@ export interface BaseConnection extends TimestampsAndDeleted {
20
21
  export interface StoredConnection extends BaseConnection {
21
22
  credentials: Record<string, any>;
22
23
  }
24
+ export type DBConnection = Merge<BaseConnection, {
25
+ id: number;
26
+ config_id: number;
27
+ credentials: Record<string, any>;
28
+ }>;
23
29
  export interface Connection extends BaseConnection {
24
30
  credentials: AllAuthCredentials;
25
31
  }
@@ -30,17 +36,6 @@ export type RecentlyCreatedConnection = Pick<StoredConnection, 'id' | 'connectio
30
36
  environment: DBEnvironment;
31
37
  account: DBTeam;
32
38
  };
33
- export interface ApiConnection {
34
- id?: number;
35
- connection_id: string;
36
- provider_config_key: string;
37
- config_id?: number;
38
- environment_id: number;
39
- connection_config: ConnectionConfig;
40
- credentials_iv?: string | null;
41
- credentials_tag?: string | null;
42
- credentials: BasicApiCredentials | ApiKeyCredentials;
43
- }
44
39
  export interface NangoConnection {
45
40
  id?: number;
46
41
  connection_id: string;
@@ -1,4 +1,5 @@
1
- import type { NangoModel, NangoSyncEndpoint, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml';
1
+ import type { Merge } from 'type-fest';
2
+ import type { NangoModel, NangoSyncEndpointOld, NangoSyncEndpointV2, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml';
2
3
  export interface IncomingScriptFiles {
3
4
  js: string;
4
5
  ts: string;
@@ -31,7 +32,7 @@ interface InternalIncomingPreBuiltFlowConfig {
31
32
  metadata?: NangoConfigMetadata | undefined;
32
33
  model_schema: string | NangoModel[];
33
34
  input?: string | LegacySyncModelSchema | undefined;
34
- endpoints?: NangoSyncEndpoint[] | undefined;
35
+ endpoints?: (NangoSyncEndpointV2 | NangoSyncEndpointOld)[] | undefined;
35
36
  track_deletes: boolean;
36
37
  providerConfigKey: string;
37
38
  }
@@ -43,6 +44,7 @@ export interface IncomingPreBuiltFlowConfig extends InternalIncomingPreBuiltFlow
43
44
  syncName?: string;
44
45
  nango_config_id?: number;
45
46
  fileBody?: IncomingScriptFiles;
47
+ endpoints: NangoSyncEndpointV2[];
46
48
  }
47
49
  export interface IncomingFlowConfig extends InternalIncomingPreBuiltFlowConfig {
48
50
  syncName: string;
@@ -51,4 +53,7 @@ export interface IncomingFlowConfig extends InternalIncomingPreBuiltFlowConfig {
51
53
  sync_type?: SyncTypeLiteral | undefined;
52
54
  webhookSubscriptions?: string[] | undefined;
53
55
  }
56
+ export type CleanedIncomingFlowConfig = Merge<IncomingFlowConfig, {
57
+ endpoints: NangoSyncEndpointV2[];
58
+ }>;
54
59
  export {};
@@ -12,3 +12,25 @@ export interface EndUser {
12
12
  readonly createdAt: Date;
13
13
  readonly updatedAt: Date | null;
14
14
  }
15
+ export interface DBEndUser {
16
+ readonly id: number;
17
+ readonly end_user_id: string;
18
+ readonly account_id: number;
19
+ readonly environment_id: number;
20
+ readonly email: string;
21
+ readonly display_name: string | null;
22
+ readonly organization_id: string | null;
23
+ readonly organization_display_name: string | null;
24
+ readonly created_at: Date;
25
+ readonly updated_at: Date | null;
26
+ }
27
+ export type DBInsertEndUser = Omit<DBEndUser, 'id' | 'created_at' | 'updated_at'>;
28
+ export interface ApiEndUser {
29
+ id: string;
30
+ displayName: string | null;
31
+ email: string;
32
+ organization: {
33
+ id: string;
34
+ displayName: string | null;
35
+ } | null;
36
+ }
@@ -0,0 +1,15 @@
1
+ import type { ApiError, Endpoint } from '../../api.js';
2
+ export interface OtlpSettings {
3
+ endpoint: string;
4
+ headers: Record<string, string>;
5
+ }
6
+ export type UpdateOtlpSettings = Endpoint<{
7
+ Method: 'POST';
8
+ Querystring: {
9
+ env: string;
10
+ };
11
+ Path: '/api/v1/environment/otlp/settings';
12
+ Body: OtlpSettings;
13
+ Success: OtlpSettings;
14
+ Error: ApiError<'forbidden'>;
15
+ }>;
@@ -34,6 +34,10 @@ export interface DBEnvironment extends Timestamps {
34
34
  pending_public_key?: string | null;
35
35
  slack_notifications: boolean;
36
36
  webhook_receive_url?: string;
37
+ otlp_settings: {
38
+ endpoint: string;
39
+ headers: Record<string, string>;
40
+ } | null;
37
41
  }
38
42
  export interface ExternalWebhook extends Timestamps {
39
43
  id: number;
package/dist/index.d.ts CHANGED
@@ -41,6 +41,7 @@ export type * from './endUser/index.js';
41
41
  export type * from './nangoYaml/index.js';
42
42
  export type * from './environment/db.js';
43
43
  export type * from './environment/api/webhook.js';
44
+ export type * from './environment/api/otlp.js';
44
45
  export type * from './webhooks/api.js';
45
46
  export type * from './flow/http.api.js';
46
47
  export type * from './utils.js';
@@ -3,7 +3,7 @@ import type { ApiTimestamps, Endpoint } from '../api';
3
3
  import type { IntegrationConfig } from './db';
4
4
  import type { Provider } from '../providers/provider';
5
5
  import type { AuthModeType } from '../auth/api';
6
- import type { NangoModel, NangoSyncEndpoint, ScriptTypeLiteral } from '../nangoYaml';
6
+ import type { NangoModel, NangoSyncEndpointV2, ScriptTypeLiteral } from '../nangoYaml';
7
7
  import type { LegacySyncModelSchema, NangoConfigMetadata } from '../deploy/incomingFlow';
8
8
  import type { JSONSchema7 } from 'json-schema';
9
9
  import type { SyncType } from '../scripts/syncs/api';
@@ -137,7 +137,7 @@ export interface NangoSyncConfig {
137
137
  track_deletes?: boolean;
138
138
  returns: string[] | string;
139
139
  models: any[];
140
- endpoints: NangoSyncEndpoint[];
140
+ endpoints: NangoSyncEndpointV2[];
141
141
  is_public?: boolean | null;
142
142
  pre_built?: boolean | null;
143
143
  version?: string | null;
@@ -1,4 +1,4 @@
1
- export type HTTP_VERB = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
1
+ export type HTTP_METHOD = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
2
2
  export type SyncTypeLiteral = 'incremental' | 'full';
3
3
  export type ScriptFileType = 'actions' | 'syncs' | 'post-connection-scripts';
4
4
  export type ScriptTypeLiteral = 'action' | 'sync';
@@ -26,7 +26,7 @@ export interface NangoYamlV2Integration {
26
26
  'post-connection-scripts'?: string[];
27
27
  }
28
28
  export interface NangoYamlV2IntegrationSync {
29
- endpoint: string | string[];
29
+ endpoint: string | string[] | NangoSyncEndpointV2 | NangoSyncEndpointV2[];
30
30
  output: string | string[];
31
31
  description?: string;
32
32
  sync_type?: SyncTypeLiteral;
@@ -68,7 +68,7 @@ export interface NangoYamlParsedIntegration {
68
68
  export interface ParsedNangoSync {
69
69
  name: string;
70
70
  type: 'sync';
71
- endpoints: NangoSyncEndpoint[];
71
+ endpoints: NangoSyncEndpointV2[];
72
72
  description: string;
73
73
  sync_type: SyncTypeLiteral;
74
74
  track_deletes: boolean;
@@ -87,7 +87,7 @@ export interface ParsedNangoAction {
87
87
  description: string;
88
88
  input: string | null;
89
89
  output: string[] | null;
90
- endpoint: NangoSyncEndpoint | null;
90
+ endpoint: NangoSyncEndpointV2 | null;
91
91
  scopes: string[];
92
92
  usedModels: string[];
93
93
  version: string;
@@ -108,6 +108,10 @@ export interface NangoModelField {
108
108
  union?: boolean | undefined;
109
109
  optional?: boolean | undefined;
110
110
  }
111
- export type NangoSyncEndpoint = {
112
- [key in HTTP_VERB]?: string | undefined;
111
+ export type NangoSyncEndpointOld = {
112
+ [key in HTTP_METHOD]?: string | undefined;
113
113
  };
114
+ export interface NangoSyncEndpointV2 {
115
+ method: HTTP_METHOD;
116
+ path: string;
117
+ }
@@ -24,6 +24,7 @@ export interface SimplifiedJSONSchema {
24
24
  description: string;
25
25
  example?: string;
26
26
  pattern?: string;
27
+ optional?: boolean;
27
28
  format?: string;
28
29
  order: number;
29
30
  default_value?: string;
@@ -37,6 +38,7 @@ export interface BaseProvider {
37
38
  proxy?: {
38
39
  base_url: string;
39
40
  headers?: Record<string, string>;
41
+ connection_base_url?: string;
40
42
  query?: {
41
43
  api_key: string;
42
44
  };
@@ -73,6 +75,7 @@ export interface BaseProvider {
73
75
  connection_config?: Record<string, SimplifiedJSONSchema>;
74
76
  credentials?: Record<string, SimplifiedJSONSchema>;
75
77
  authorization_url_fragment?: string;
78
+ body_format?: OAuthBodyFormatType;
76
79
  }
77
80
  export interface ProviderOAuth2 extends BaseProvider {
78
81
  auth_mode: 'OAUTH2' | 'CUSTOM';
@@ -84,7 +87,6 @@ export interface ProviderOAuth2 extends BaseProvider {
84
87
  grant_type: 'refresh_token';
85
88
  };
86
89
  authorization_method?: OAuthAuthorizationMethodType;
87
- body_format?: OAuthBodyFormatType;
88
90
  refresh_url?: string;
89
91
  expires_in_unit?: 'milliseconds';
90
92
  token_request_auth_method?: 'basic' | 'custom';
@@ -108,4 +110,14 @@ export interface ProviderJwt extends BaseProvider {
108
110
  };
109
111
  };
110
112
  }
111
- export type Provider = BaseProvider | ProviderOAuth1 | ProviderOAuth2 | ProviderJwt;
113
+ export interface ProviderTwoStep extends BaseProvider {
114
+ token_headers?: Record<string, string>;
115
+ token_response: {
116
+ token: string;
117
+ token_expiration: string;
118
+ token_expiration_strategy: 'expireAt' | 'expireIn';
119
+ };
120
+ token_expires_in_ms?: number;
121
+ proxy_header_authorization?: string;
122
+ }
123
+ export type Provider = BaseProvider | ProviderOAuth1 | ProviderOAuth2 | ProviderJwt | ProviderTwoStep;
@@ -3,4 +3,4 @@ export interface SyncResult {
3
3
  updated: number;
4
4
  deleted: number;
5
5
  }
6
- export type SyncType = 'INCREMENTAL' | 'FULL';
6
+ export type SyncType = 'INCREMENTAL' | 'FULL' | 'WEBHOOK';
package/dist/web/env.d.ts CHANGED
@@ -5,6 +5,7 @@ export interface WindowEnv {
5
5
  publicSentryKey: string;
6
6
  publicPosthogKey: string;
7
7
  publicPosthogPost: string;
8
+ publicLogoDevKey: string;
8
9
  isCloud: boolean;
9
10
  features: {
10
11
  logs: boolean;
@@ -12,6 +13,5 @@ export interface WindowEnv {
12
13
  auth: boolean;
13
14
  managedAuth: boolean;
14
15
  interactiveDemo: boolean;
15
- connectUI: boolean;
16
16
  };
17
17
  }
@@ -13,7 +13,7 @@ export interface NangoSyncWebhookBodyBase extends NangoWebhookBase {
13
13
  providerConfigKey: string;
14
14
  syncName: string;
15
15
  model: string;
16
- syncType: 'INCREMENTAL' | 'INITIAL';
16
+ syncType: 'INCREMENTAL' | 'INITIAL' | 'WEBHOOK';
17
17
  }
18
18
  export interface NangoSyncWebhookBodySuccess extends NangoSyncWebhookBodyBase {
19
19
  success: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.42.20",
3
+ "version": "0.42.22",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "@types/json-schema": "7.0.15",
16
16
  "axios": "^1.7.4",
17
17
  "json-schema": "0.4.0",
18
- "type-fest": "4.25.0"
18
+ "type-fest": "4.26.1"
19
19
  },
20
20
  "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY",
21
21
  "files": [