@nangohq/types 0.52.5 → 0.53.1

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
@@ -11,7 +11,7 @@ export interface ValidationError {
11
11
  message: string;
12
12
  path: (string | number)[];
13
13
  }
14
- export type ResDefaultErrors = ApiError<'invalid_content_type'> | ApiError<'not_found'> | ApiError<'conflict'> | 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'> | ApiError<'invalid_permissions'> | ApiError<'invalid_connect_session_token_format'>;
14
+ export type ResDefaultErrors = ApiError<'invalid_content_type'> | ApiError<'not_found'> | ApiError<'conflict'> | ApiError<'invalid_query_params', ValidationError[]> | ApiError<'invalid_headers', 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'> | ApiError<'invalid_permissions'> | ApiError<'invalid_connect_session_token_format'>;
15
15
  export type EndpointMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
16
16
  /**
17
17
  * API Request/Response type
@@ -21,6 +21,7 @@ export interface EndpointDefinition {
21
21
  Path: string;
22
22
  Params?: Record<string, any>;
23
23
  Body?: Record<string, any>;
24
+ Headers?: Record<string, any>;
24
25
  Querystring?: Record<string, any>;
25
26
  Error?: ApiError<any> | never;
26
27
  Success: Record<string, any> | never;
@@ -44,6 +45,10 @@ export interface Endpoint<T extends EndpointDefinition> {
44
45
  * Received body
45
46
  */
46
47
  Body: T['Body'] extends Record<string, any> ? T['Body'] : never;
48
+ /**
49
+ * Received headers
50
+ */
51
+ Headers: T['Headers'] extends Record<string, any> ? T['Headers'] : never;
47
52
  /**
48
53
  * Response body for success
49
54
  */
@@ -18,7 +18,8 @@ import type { PostPublicWebhook } from './webhooks/http.api';
18
18
  import type { PatchEnvironment, PostEnvironment } from './environment/api';
19
19
  import type { PatchWebhook } from './environment/api/webhook';
20
20
  import type { PostEnvironmentVariables } from './environment/variable/api';
21
- export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | 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;
21
+ import type { GetPublicRecords } from './record/api';
22
+ export type PublicApiEndpoints = SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation | 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;
22
23
  export type PrivateApiEndpoints = PostSignup | PostSignin | GetTeam | PutTeam | 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 | PatchWebhook | PostEnvironmentVariables;
23
24
  export type APIEndpoints = PrivateApiEndpoints | PublicApiEndpoints;
24
25
  /**
@@ -1,5 +1,5 @@
1
1
  import type { ApiError, ApiTimestamps, Endpoint } from '../../api.js';
2
- import type { DBConnection } from '../db.js';
2
+ import type { DBConnection, DBConnectionDecrypted } from '../db.js';
3
3
  import type { ActiveLog } from '../../notification/active-logs/db.js';
4
4
  import type { Merge } from 'type-fest';
5
5
  import type { ApiEndUser } from '../../endUser/index.js';
@@ -64,7 +64,7 @@ export type GetPublicConnections = Endpoint<{
64
64
  connections: ApiPublicConnection[];
65
65
  };
66
66
  }>;
67
- export type ApiConnectionFull = Merge<DBConnection, ApiTimestamps>;
67
+ export type ApiConnectionFull = Merge<DBConnectionDecrypted, ApiTimestamps>;
68
68
  export type GetConnection = Endpoint<{
69
69
  Method: 'GET';
70
70
  Params: {
@@ -88,7 +88,7 @@ export type GetConnection = Endpoint<{
88
88
  export type ApiPublicConnectionFull = Pick<DBConnection, 'id' | 'connection_id' | 'provider_config_key' | 'connection_config'> & {
89
89
  created_at: string;
90
90
  updated_at: string;
91
- last_fetched_at: string;
91
+ last_fetched_at: string | null;
92
92
  metadata: Record<string, unknown> | null;
93
93
  provider: string;
94
94
  errors: {
@@ -1,58 +1,53 @@
1
- import type { TimestampsAndDeleted } from '../db.js';
1
+ import type { TimestampsAndDeletedCorrect } from '../db.js';
2
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
5
  import type { Merge } from 'type-fest';
6
+ import type { EndUser } from '../endUser/index.js';
6
7
  export type Metadata = Record<string, unknown>;
7
8
  export type ConnectionConfig = Record<string, any>;
8
- export interface BaseConnection extends TimestampsAndDeleted {
9
- id?: number;
10
- config_id?: number;
9
+ export interface DBConnection extends TimestampsAndDeletedCorrect {
10
+ id: number;
11
+ config_id: number;
11
12
  end_user_id: number | null;
13
+ /**
14
+ * @deprecated
15
+ */
12
16
  provider_config_key: string;
13
17
  connection_id: string;
14
18
  connection_config: ConnectionConfig;
15
19
  environment_id: number;
16
- metadata?: Metadata | null;
17
- credentials_iv?: string | null;
18
- credentials_tag?: string | null;
19
- last_fetched_at?: Date | null;
20
- }
21
- export interface StoredConnection extends BaseConnection {
22
- credentials: Record<string, any>;
20
+ metadata: Metadata | null;
21
+ credentials: {
22
+ encrypted_credentials?: string;
23
+ };
24
+ credentials_iv: string | null;
25
+ credentials_tag: string | null;
26
+ last_fetched_at: Date | null;
23
27
  }
24
- export type DBConnection = Merge<BaseConnection, {
25
- id: number;
26
- config_id: number;
27
- credentials: Record<string, any>;
28
- }>;
29
- export interface Connection extends BaseConnection {
28
+ export type DBConnectionDecrypted = Merge<DBConnection, {
30
29
  credentials: AllAuthCredentials;
31
- }
32
- export type RecentlyCreatedConnection = Pick<StoredConnection, 'id' | 'connection_id' | 'provider_config_key'> & {
30
+ }>;
31
+ export interface RecentlyCreatedConnection {
32
+ connection: DBConnection;
33
33
  auth_mode: AuthModeType;
34
34
  error?: string;
35
35
  operation: AuthOperationType;
36
36
  environment: DBEnvironment;
37
37
  account: DBTeam;
38
- };
39
- export interface NangoConnection {
40
- id?: number;
41
- connection_id: string;
42
- provider_config_key: string;
43
- environment_id: number;
44
- connection_config?: ConnectionConfig;
45
- /**
46
- * @deprecated
47
- */
48
- account_id?: number;
38
+ endUser: EndUser | undefined;
49
39
  }
50
- export interface ConnectionList {
51
- id: number;
52
- connection_id: string;
53
- provider_config_key: string;
54
- provider: string;
55
- created: string;
56
- metadata?: Metadata | null;
57
- error_log_id?: number | string | null;
40
+ export interface FailedConnectionError {
41
+ type: string;
42
+ description: string;
43
+ }
44
+ export interface RecentlyFailedConnection {
45
+ connection: DBConnection | Pick<DBConnection, 'connection_id' | 'provider_config_key'>;
46
+ auth_mode: AuthModeType;
47
+ error?: FailedConnectionError;
48
+ operation: AuthOperationType;
49
+ environment: DBEnvironment;
50
+ account: DBTeam;
58
51
  }
52
+ export type ConnectionInternal = Pick<DBConnection, 'id' | 'connection_id' | 'provider_config_key' | 'environment_id' | 'connection_config'>;
53
+ export type ConnectionJobs = Pick<DBConnection, 'id' | 'connection_id' | 'provider_config_key' | 'environment_id'>;
package/dist/db.d.ts CHANGED
@@ -6,5 +6,11 @@ export interface Deleted {
6
6
  deleted_at?: Date | null;
7
7
  deleted?: boolean;
8
8
  }
9
+ export interface DeletedCorrect {
10
+ deleted_at: Date | null;
11
+ deleted: boolean;
12
+ }
9
13
  export interface TimestampsAndDeleted extends Timestamps, Deleted {
10
14
  }
15
+ export interface TimestampsAndDeletedCorrect extends Timestamps, DeletedCorrect {
16
+ }
@@ -28,7 +28,7 @@ export interface LegacySyncModelSchema {
28
28
  interface InternalIncomingPreBuiltFlowConfig {
29
29
  type: ScriptTypeLiteral;
30
30
  models: string[];
31
- runs: string;
31
+ runs: string | null;
32
32
  auto_start?: boolean;
33
33
  attributes?: object | undefined;
34
34
  metadata?: NangoConfigMetadata | undefined;
@@ -6,7 +6,7 @@ export interface SyncDeploymentResult {
6
6
  providerConfigKey: string;
7
7
  type: ScriptTypeLiteral;
8
8
  last_deployed?: Date;
9
- input?: string | LegacySyncModelSchema | undefined;
9
+ input?: string | LegacySyncModelSchema | undefined | null;
10
10
  models: string | string[];
11
11
  id?: number | undefined;
12
12
  /** @deprecated legacy **/
@@ -1,9 +1,5 @@
1
- export type CommitHash = string & {
2
- readonly length: 40;
3
- };
4
1
  export interface Deployment {
5
2
  readonly id: number;
6
- readonly commitId: CommitHash;
7
3
  readonly image: string;
8
4
  readonly createdAt: Date;
9
5
  readonly supersededAt: Date | null;
@@ -3,10 +3,9 @@ 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, AuthModes } from '../auth/api';
6
- import type { NangoModel, NangoSyncEndpointV2, ScriptTypeLiteral } from '../nangoYaml';
6
+ import type { NangoModel, NangoSyncEndpointV2, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml';
7
7
  import type { LegacySyncModelSchema, NangoConfigMetadata } from '../deploy/incomingFlow';
8
8
  import type { JSONSchema7 } from 'json-schema';
9
- import type { SyncType } from '../scripts/syncs/api';
10
9
  export type ApiPublicIntegration = Merge<Pick<IntegrationConfig, 'created_at' | 'updated_at' | 'unique_key' | 'provider'>, ApiTimestamps> & {
11
10
  logo: string;
12
11
  display_name: string;
@@ -177,7 +176,7 @@ export interface NangoSyncConfig {
177
176
  last_deployed?: string | null;
178
177
  id?: number;
179
178
  input?: NangoModel | LegacySyncModelSchema;
180
- sync_type?: SyncType;
179
+ sync_type?: SyncTypeLiteral;
181
180
  webhookSubscriptions?: string[];
182
181
  enabled?: boolean;
183
182
  json_schema: JSONSchema7 | null;
@@ -51,7 +51,7 @@ export interface OperationAdmin {
51
51
  }
52
52
  export interface OperationWebhook {
53
53
  type: 'webhook';
54
- action: 'incoming' | 'forward' | 'sync';
54
+ action: 'incoming' | 'forward' | 'sync' | 'connection_create' | 'connection_refresh';
55
55
  }
56
56
  export interface OperationDeploy {
57
57
  type: 'deploy';
@@ -109,7 +109,6 @@ export interface MessageRow {
109
109
  response: {
110
110
  code: number;
111
111
  headers: Record<string, string>;
112
- body?: unknown;
113
112
  } | null;
114
113
  meta: MessageMeta | null;
115
114
  createdAt: string;
@@ -1,6 +1,6 @@
1
1
  import type { OnEventType } from '../scripts/on-events/api';
2
2
  export type HTTP_METHOD = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
3
- export type SyncTypeLiteral = 'incremental' | 'full' | 'FULL' | 'INCREMENTAL';
3
+ export type SyncTypeLiteral = 'incremental' | 'full';
4
4
  export type ScriptFileType = 'actions' | 'syncs' | 'on-events' | 'post-connection-scripts';
5
5
  export type ScriptTypeLiteral = 'action' | 'sync' | 'on-event';
6
6
  export interface NangoYamlV1 {
@@ -1,4 +1,4 @@
1
- import type { MergingStrategy } from '../record/api.js';
1
+ import type { MergingStrategy, NangoRecord } from '../record/api.js';
2
2
  export interface PostRecordsSuccess {
3
3
  nextMerging: MergingStrategy;
4
4
  }
@@ -11,3 +11,7 @@ export interface DeleteRecordsSuccess {
11
11
  export interface GetCursorSuccess {
12
12
  cursor?: string;
13
13
  }
14
+ export interface GetRecordsSuccess {
15
+ records: NangoRecord[];
16
+ nextCursor?: string;
17
+ }
@@ -120,6 +120,12 @@ export interface ProviderTwoStep extends Omit<BaseProvider, 'body_format'> {
120
120
  token_expiration: string;
121
121
  token_expiration_strategy: 'expireAt' | 'expireIn';
122
122
  };
123
+ additional_steps?: {
124
+ body_format?: 'json' | 'form';
125
+ token_params?: Record<string, string>;
126
+ token_headers?: Record<string, string>;
127
+ token_url: string;
128
+ }[];
123
129
  token_expires_in_ms?: number;
124
130
  proxy_header_authorization?: string;
125
131
  body_format?: 'xml' | 'json' | 'form';
@@ -1,6 +1,6 @@
1
1
  import type { EndpointMethod } from '../api.js';
2
2
  import type { BasicApiCredentials, ApiKeyCredentials, AppCredentials } from '../auth/api.js';
3
- import type { Connection } from '../connection/db.js';
3
+ import type { DBConnectionDecrypted } from '../connection/db.js';
4
4
  import type { Provider } from '../providers/provider.js';
5
5
  export interface BaseProxyConfiguration {
6
6
  providerConfigKey: string;
@@ -26,12 +26,12 @@ export interface ApplicationConstructedProxyConfiguration extends BaseProxyConfi
26
26
  providerName: string;
27
27
  token: string | BasicApiCredentials | ApiKeyCredentials | AppCredentials;
28
28
  provider: Provider;
29
- connection: Connection;
29
+ connection: DBConnectionDecrypted;
30
30
  }
31
31
  export type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
32
32
  export interface InternalProxyConfiguration {
33
33
  providerName: string;
34
- connection: Connection;
34
+ connection: DBConnectionDecrypted;
35
35
  existingActivityLogId?: string | null | undefined;
36
36
  }
37
37
  export interface RetryHeaderConfig {
@@ -1,4 +1,6 @@
1
+ import type { ApiError, Endpoint } from '../api';
1
2
  export type RecordLastAction = 'ADDED' | 'UPDATED' | 'DELETED' | 'added' | 'updated' | 'deleted';
3
+ export type CombinedFilterAction = `${RecordLastAction},${RecordLastAction}`;
2
4
  export interface RecordMetadata {
3
5
  first_seen_at: string;
4
6
  last_modified_at: string;
@@ -6,15 +8,37 @@ export interface RecordMetadata {
6
8
  deleted_at: string | null;
7
9
  cursor: string;
8
10
  }
9
- export interface NangoRecord {
11
+ export type NangoRecord<T extends Record<string, any> = Record<string, any>> = {
10
12
  [key: string]: any;
11
13
  id: string | number;
12
14
  _nango_metadata: RecordMetadata;
13
- }
15
+ } & T;
14
16
  export type MergingStrategy = {
15
17
  strategy: 'override';
16
18
  } | {
17
19
  strategy: 'ignore_if_modified_after_cursor';
18
- cursor?: string;
20
+ cursor?: string | undefined;
19
21
  };
20
22
  export type CursorOffset = 'first' | 'last';
23
+ export type GetPublicRecords = Endpoint<{
24
+ Method: 'GET';
25
+ Path: `/records`;
26
+ Headers: {
27
+ 'connection-id': string;
28
+ 'provider-config-key': string;
29
+ };
30
+ Error: ApiError<'unknown_connection'>;
31
+ Querystring: {
32
+ model: string;
33
+ delta?: string | undefined;
34
+ modified_after?: string | undefined;
35
+ limit?: number | undefined;
36
+ filter?: RecordLastAction | CombinedFilterAction | undefined;
37
+ cursor?: string | undefined;
38
+ ids?: string[] | undefined;
39
+ };
40
+ Success: {
41
+ next_cursor: string | null;
42
+ records: NangoRecord[];
43
+ };
44
+ }>;
@@ -3,4 +3,4 @@ export interface SyncResult {
3
3
  updated: number;
4
4
  deleted: number;
5
5
  }
6
- export type SyncType = 'INCREMENTAL' | 'FULL' | 'WEBHOOK';
6
+ export type SyncOperationType = 'INCREMENTAL' | 'FULL' | 'WEBHOOK';
@@ -8,7 +8,7 @@ export interface DBSyncConfig extends TimestampsAndDeleted {
8
8
  nango_config_id: number;
9
9
  file_location: string;
10
10
  version: string;
11
- models: string[] | null;
11
+ models: string[];
12
12
  active: boolean;
13
13
  runs: string | null;
14
14
  model_schema: LegacySyncModelSchema[] | NangoModel[] | null;
@@ -26,3 +26,4 @@ export interface DBSyncConfig extends TimestampsAndDeleted {
26
26
  enabled: boolean;
27
27
  models_json_schema: JSONSchema7 | null;
28
28
  }
29
+ export type DBSyncConfigInsert = Omit<DBSyncConfig, 'id'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.52.5",
3
+ "version": "0.53.1",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",
@@ -11,12 +11,14 @@
11
11
  "url": "git+https://github.com/NangoHQ/nango.git",
12
12
  "directory": "packages/utils"
13
13
  },
14
- "devDependencies": {
15
- "@types/json-schema": "7.0.15",
14
+ "dependencies": {
16
15
  "axios": "^1.7.9",
17
16
  "json-schema": "0.4.0",
18
17
  "type-fest": "4.32.0"
19
18
  },
19
+ "devDependencies": {
20
+ "@types/json-schema": "7.0.15"
21
+ },
20
22
  "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY",
21
23
  "files": [
22
24
  "dist/**/*"