@nangohq/types 0.40.5 → 0.40.7

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<'not_found'> | ApiError<'invalid_query_params', ValidationError[]> | ApiError<'invalid_body', ValidationError[]> | ApiError<'invalid_uri_params', ValidationError[]> | ApiError<'feature_disabled'> | ApiError<'missing_auth_header'> | ApiError<'generic_error_support', undefined, string>;
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<'missing_auth_header'> | ApiError<'generic_error_support', undefined, string> | ApiError<'server_error'>;
15
15
  export type EndpointMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
16
16
  /**
17
17
  * API Request/Response type
@@ -2,7 +2,8 @@ import type { EndpointMethod } from './api';
2
2
  import type { GetOperation, SearchFilters, SearchMessages, SearchOperations } from './logs/api';
3
3
  import type { GetOnboardingStatus } from './onboarding/api';
4
4
  import type { SetMetadata, UpdateMetadata } from './connection/api/metadata';
5
- export type APIEndpoints = SearchOperations | GetOperation | SearchMessages | SearchFilters | GetOnboardingStatus | SetMetadata | UpdateMetadata;
5
+ import type { PostDeploy, PostDeployConfirmation } from './deploy/api';
6
+ export type APIEndpoints = SearchOperations | GetOperation | SearchMessages | SearchFilters | GetOnboardingStatus | SetMetadata | UpdateMetadata | PostDeploy | PostDeployConfirmation;
6
7
  /**
7
8
  * Automatically narrow endpoints type with Method + Path
8
9
  */
@@ -9,6 +9,7 @@ export interface AuthModes {
9
9
  Custom: 'CUSTOM';
10
10
  App: 'APP';
11
11
  None: 'NONE';
12
+ TBA: 'TBA';
12
13
  }
13
14
  export type AuthModeType = AuthModes[keyof AuthModes];
14
15
  export interface AuthOperation {
@@ -94,6 +95,13 @@ export interface CredentialsRefresh<T = unknown> {
94
95
  connectionId: string;
95
96
  promise: Promise<T>;
96
97
  }
98
+ export interface TbaCredentials {
99
+ type: AuthModes['TBA'];
100
+ token: string;
101
+ secret: string;
102
+ oauth_client_id: string;
103
+ oauth_client_secret: string;
104
+ }
97
105
  export type UnauthCredentials = Record<string, never>;
98
106
  export type RefreshTokenResponse = AuthorizationTokenResponse;
99
107
  export interface AuthorizationTokenResponse extends Omit<OAuth2Credentials, 'type' | 'raw'> {
@@ -0,0 +1,19 @@
1
+ import type { ApiError, Endpoint } from '../api';
2
+ import type { ConnectionConfig } from '../connection/db';
3
+ export type TbaAuthorization = Endpoint<{
4
+ Method: 'POST';
5
+ Body: {
6
+ token_id: string;
7
+ token_secret: string;
8
+ };
9
+ QueryParams: {
10
+ connectionId: string;
11
+ connectionConfig: ConnectionConfig;
12
+ };
13
+ Params: {
14
+ providerConfigKey: string;
15
+ };
16
+ Path: '/auth/tba';
17
+ Error: ApiError<'invalid_body'> | ApiError<'invalid_query_params'> | ApiError<'unknown_provider_config'> | ApiError<'invalid_auth_mode'> | ApiError<'missing_token_url'> | ApiError<'no_data_returned_from_token_request'> | ApiError<'missing_connection_config_param'>;
18
+ Success: never;
19
+ }>;
@@ -1,5 +1,5 @@
1
1
  import type { TimestampsAndDeleted } from '../db.js';
2
- import type { AuthCredentials, ApiKeyCredentials, BasicApiCredentials, AppCredentials, AppStoreCredentials, UnauthCredentials, CustomCredentials, AuthModeType, AuthOperationType } from '../auth/api.js';
2
+ import type { AuthCredentials, ApiKeyCredentials, BasicApiCredentials, AppCredentials, AppStoreCredentials, UnauthCredentials, CustomCredentials, TbaCredentials, AuthModeType, AuthOperationType } from '../auth/api.js';
3
3
  import type { Environment } from '../environment/db.js';
4
4
  import type { Account } from '../account/db.js';
5
5
  export type Metadata = Record<string, unknown>;
@@ -20,7 +20,7 @@ export interface StoredConnection extends BaseConnection {
20
20
  credentials: Record<string, any>;
21
21
  }
22
22
  export interface Connection extends BaseConnection {
23
- credentials: AuthCredentials | ApiKeyCredentials | BasicApiCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | CustomCredentials;
23
+ credentials: AuthCredentials | ApiKeyCredentials | BasicApiCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | CustomCredentials | TbaCredentials;
24
24
  }
25
25
  export type RecentlyCreatedConnection = Pick<StoredConnection, 'id' | 'connection_id' | 'provider_config_key'> & {
26
26
  auth_mode: AuthModeType;
@@ -0,0 +1,50 @@
1
+ import type { JSONSchema7 } from 'json-schema';
2
+ import type { Endpoint } from '../api.js';
3
+ import type { IncomingFlowConfig, PostConnectionScriptByProvider } from './incomingFlow.js';
4
+ export type PostDeployConfirmation = Endpoint<{
5
+ Method: 'POST';
6
+ Path: '/sync/deploy/confirmation';
7
+ Body: {
8
+ flowConfigs: IncomingFlowConfig[];
9
+ postConnectionScriptsByProvider: PostConnectionScriptByProvider[];
10
+ reconcile: boolean;
11
+ debug: boolean;
12
+ singleDeployMode?: boolean;
13
+ jsonSchema?: JSONSchema7 | undefined;
14
+ };
15
+ Success: SyncAndActionDifferences;
16
+ }>;
17
+ export type PostDeploy = Endpoint<{
18
+ Method: 'POST';
19
+ Path: '/sync/deploy';
20
+ Body: {
21
+ flowConfigs: IncomingFlowConfig[];
22
+ postConnectionScriptsByProvider: PostConnectionScriptByProvider[];
23
+ nangoYamlBody: string;
24
+ reconcile: boolean;
25
+ debug: boolean;
26
+ singleDeployMode?: boolean;
27
+ jsonSchema?: JSONSchema7 | undefined;
28
+ };
29
+ Success: any[];
30
+ }>;
31
+ export interface SlimSync {
32
+ id?: number;
33
+ name: string;
34
+ auto_start: boolean;
35
+ sync_id?: string | null;
36
+ providerConfigKey: string;
37
+ connections?: number;
38
+ enabled?: boolean;
39
+ }
40
+ export interface SlimAction {
41
+ id?: number;
42
+ providerConfigKey: string;
43
+ name: string;
44
+ }
45
+ export interface SyncAndActionDifferences {
46
+ newSyncs: SlimSync[];
47
+ deletedSyncs: SlimSync[];
48
+ newActions: SlimAction[];
49
+ deletedActions: SlimAction[];
50
+ }
@@ -0,0 +1,55 @@
1
+ import type { NangoModel, NangoSyncEndpoint, ScriptTypeLiteral, SyncTypeLiteral } from '../nangoYaml';
2
+ export interface IncomingScriptFiles {
3
+ js: string;
4
+ ts: string;
5
+ }
6
+ export interface IncomingPostConnectionScript {
7
+ name: string;
8
+ fileBody: IncomingScriptFiles;
9
+ }
10
+ export interface PostConnectionScriptByProvider {
11
+ providerConfigKey: string;
12
+ scripts: IncomingPostConnectionScript[];
13
+ }
14
+ export interface NangoConfigMetadata {
15
+ scopes?: string[] | undefined;
16
+ description?: string | undefined;
17
+ }
18
+ export interface LegacySyncModelSchema {
19
+ name: string;
20
+ fields: {
21
+ name: string;
22
+ type: string;
23
+ }[];
24
+ }
25
+ interface InternalIncomingPreBuiltFlowConfig {
26
+ type: ScriptTypeLiteral;
27
+ models: string[];
28
+ runs: string;
29
+ auto_start?: boolean;
30
+ attributes?: object | undefined;
31
+ metadata?: NangoConfigMetadata | undefined;
32
+ model_schema: string | NangoModel[];
33
+ input?: string | LegacySyncModelSchema | undefined;
34
+ endpoints?: NangoSyncEndpoint[] | undefined;
35
+ }
36
+ export interface IncomingPreBuiltFlowConfig extends InternalIncomingPreBuiltFlowConfig {
37
+ provider: string;
38
+ is_public: boolean;
39
+ public_route?: string;
40
+ name: string;
41
+ syncName?: string;
42
+ nango_config_id?: number;
43
+ providerConfigKey?: string;
44
+ fileBody?: IncomingScriptFiles;
45
+ }
46
+ export interface IncomingFlowConfig extends InternalIncomingPreBuiltFlowConfig {
47
+ syncName: string;
48
+ providerConfigKey: string;
49
+ fileBody: IncomingScriptFiles;
50
+ version?: string | undefined;
51
+ track_deletes?: boolean;
52
+ sync_type?: SyncTypeLiteral | undefined;
53
+ webhookSubscriptions?: string[] | undefined;
54
+ }
55
+ export {};
package/dist/index.d.ts CHANGED
@@ -13,7 +13,6 @@ export type * from './connection/api/metadata.js';
13
13
  export type * from './connection/db.js';
14
14
  export type * from './proxy/api.js';
15
15
  export type * from './environment/db.js';
16
- export type * from './scripts/post-connection/api.js';
17
16
  export type * from './scripts/post-connection/db.js';
18
17
  export type * from './scripts/syncs/api.js';
19
18
  export type * from './notification/active-logs/db.js';
@@ -22,8 +21,11 @@ export type * from './integration/db.js';
22
21
  export type * from './integration/template.js';
23
22
  export type * from './auth/api.js';
24
23
  export type * from './auth/db.js';
24
+ export type * from './auth/http.api.js';
25
+ export type * from './deploy/api.js';
26
+ export type * from './deploy/incomingFlow.js';
25
27
  export type * from './nangoYaml/index.js';
26
- export type * from './utils.js';
27
28
  export type * from './environment/db.js';
28
29
  export type * from './environment/api/webhook.js';
29
30
  export type * from './webhooks/api.js';
31
+ export type * from './utils.js';
@@ -31,6 +31,7 @@ export interface Template {
31
31
  };
32
32
  };
33
33
  authorization_url?: string;
34
+ access_token_url?: string;
34
35
  authorization_params?: Record<string, string>;
35
36
  scope_separator?: string;
36
37
  default_scopes?: string[];
@@ -1,11 +1,13 @@
1
1
  export type HTTP_VERB = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
2
2
  export type SyncTypeLiteral = 'incremental' | 'full';
3
+ export type ScriptFileType = 'actions' | 'syncs' | 'post-connection-scripts';
4
+ export type ScriptTypeLiteral = 'action' | 'sync';
3
5
  export interface NangoYamlV1 {
4
6
  integrations: Record<string, Record<string, NangoYamlV1Integration>>;
5
7
  models: NangoYamlModel;
6
8
  }
7
9
  export interface NangoYamlV1Integration {
8
- type?: 'action' | 'sync';
10
+ type?: ScriptTypeLiteral;
9
11
  returns?: string | string[];
10
12
  description?: string;
11
13
  runs?: string;
@@ -89,18 +91,18 @@ export type LayoutMode = 'root' | 'nested';
89
91
  export interface NangoModel {
90
92
  name: string;
91
93
  fields: NangoModelField[];
92
- isAnon?: boolean;
94
+ isAnon?: boolean | undefined;
93
95
  }
94
96
  export interface NangoModelField {
95
97
  name: string;
96
- value: string | number | boolean | null | undefined | NangoModelField[];
97
- dynamic?: boolean;
98
- tsType?: boolean;
99
- model?: boolean;
100
- array?: boolean;
101
- union?: boolean;
102
- optional?: boolean;
98
+ value: string | number | boolean | null | NangoModelField[];
99
+ dynamic?: boolean | undefined;
100
+ tsType?: boolean | undefined;
101
+ model?: boolean | undefined;
102
+ array?: boolean | undefined;
103
+ union?: boolean | undefined;
104
+ optional?: boolean | undefined;
103
105
  }
104
106
  export type NangoSyncEndpoint = {
105
- [key in HTTP_VERB]?: string;
107
+ [key in HTTP_VERB]?: string | undefined;
106
108
  };
@@ -4,9 +4,8 @@ export interface ActiveLog extends Timestamps {
4
4
  type: string;
5
5
  action: string;
6
6
  connection_id: number;
7
- activity_log_id: number;
8
7
  log_id: string;
9
8
  active: boolean;
10
9
  sync_id: string | null;
11
10
  }
12
- export type ActiveLogIds = Pick<ActiveLog, 'activity_log_id' | 'log_id'>;
11
+ export type ActiveLogIds = Pick<ActiveLog, 'log_id'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.40.5",
3
+ "version": "0.40.7",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",
@@ -12,7 +12,9 @@
12
12
  "directory": "packages/utils"
13
13
  },
14
14
  "devDependencies": {
15
+ "@types/json-schema": "7.0.15",
15
16
  "axios": "^1.3.4",
17
+ "json-schema": "0.4.0",
16
18
  "type-fest": "4.14.0"
17
19
  },
18
20
  "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY",
@@ -1,11 +0,0 @@
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
- }