@nangohq/types 0.52.4 → 0.53.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.
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
  */
@@ -15,9 +15,12 @@ import type { DeletePublicConnection, GetConnection, GetConnections, GetConnecti
15
15
  import type { GetMeta } from './meta/api';
16
16
  import type { PatchFlowDisable, PatchFlowEnable, PatchFlowFrequency, PostPreBuiltDeploy, PutUpgradePreBuiltFlow } from './flow/http.api';
17
17
  import type { PostPublicWebhook } from './webhooks/http.api';
18
- import type { PostEnvironment } from './environment/api';
19
- 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;
20
- 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;
18
+ import type { PatchEnvironment, PostEnvironment } from './environment/api';
19
+ import type { PatchWebhook } from './environment/api/webhook';
20
+ import type { PostEnvironmentVariables } from './environment/variable/api';
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;
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;
21
24
  export type APIEndpoints = PrivateApiEndpoints | PublicApiEndpoints;
22
25
  /**
23
26
  * Automatically narrow endpoints type with Method + Path
@@ -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,5 +1,10 @@
1
- import type { Endpoint } from '../../api';
2
- import type { DBEnvironment } from '../db';
1
+ import type { Merge } from 'type-fest';
2
+ import type { ApiTimestamps, Endpoint } from '../../api';
3
+ import type { DBEnvironment, DBExternalWebhook } from '../db';
4
+ export type ApiEnvironment = Omit<Merge<DBEnvironment, {
5
+ callback_url: string;
6
+ } & ApiTimestamps>, 'secret_key_iv' | 'secret_key_tag' | 'secret_key_hashed' | 'pending_secret_key_iv' | 'pending_secret_key_tag' | 'pending_public_key'>;
7
+ export type ApiWebhooks = Omit<DBExternalWebhook, 'id' | 'environment_id' | 'created_at' | 'updated_at'>;
3
8
  export type PostEnvironment = Endpoint<{
4
9
  Method: 'POST';
5
10
  Path: '/api/v1/environments';
@@ -10,3 +15,21 @@ export type PostEnvironment = Endpoint<{
10
15
  data: Pick<DBEnvironment, 'id' | 'name'>;
11
16
  };
12
17
  }>;
18
+ export type PatchEnvironment = Endpoint<{
19
+ Method: 'PATCH';
20
+ Path: '/api/v1/environments';
21
+ Body: {
22
+ callback_url?: string | undefined;
23
+ hmac_key?: string | undefined;
24
+ hmac_enabled?: boolean | undefined;
25
+ slack_notifications?: boolean | undefined;
26
+ otlp_endpoint?: string | undefined;
27
+ otlp_headers?: {
28
+ name: string;
29
+ value: string;
30
+ }[] | undefined;
31
+ };
32
+ Success: {
33
+ data: ApiEnvironment;
34
+ };
35
+ }>;
@@ -1,46 +1,19 @@
1
1
  import type { Endpoint } from '../../api.js';
2
- export interface WebhookSettings {
3
- alwaysSendWebhook: boolean;
4
- sendAuthWebhook: boolean;
5
- sendRefreshFailedWebhook: boolean;
6
- sendSyncFailedWebhook: boolean;
7
- }
8
- export type UpdateWebhookSettings = Endpoint<{
2
+ export type PatchWebhook = Endpoint<{
9
3
  Method: 'PATCH';
10
4
  Querystring: {
11
5
  env: string;
12
6
  };
13
- Path: '/api/v1/environment/webhook/settings';
14
- Body: WebhookSettings;
15
- Success: WebhookSettings;
16
- }>;
17
- export type UpdatePrimaryUrl = Endpoint<{
18
- Method: 'PATCH';
19
- Querystring: {
20
- env: string;
21
- };
22
- Path: '/api/v1/environment/webhook/url/primary-url';
23
- Body: {
24
- url: string;
25
- };
26
- Success: {
27
- data: {
28
- url: string;
29
- };
30
- };
31
- }>;
32
- export type UpdateSecondaryUrl = Endpoint<{
33
- Method: 'PATCH';
34
- Querystring: {
35
- env: string;
36
- };
37
- Path: '/api/v1/environment/webhook/secondary-url';
7
+ Path: '/api/v1/environments/webhook';
38
8
  Body: {
39
- url: string;
9
+ primary_url?: string | undefined;
10
+ secondary_url?: string | undefined;
11
+ on_sync_completion_always?: boolean | undefined;
12
+ on_auth_creation?: boolean | undefined;
13
+ on_auth_refresh_error?: boolean | undefined;
14
+ on_sync_error?: boolean | undefined;
40
15
  };
41
16
  Success: {
42
- data: {
43
- url: string;
44
- };
17
+ success: boolean;
45
18
  };
46
19
  }>;
@@ -1,11 +1,11 @@
1
1
  import type { Timestamps } from '../db';
2
2
  export interface DBEnvironmentVariable extends Timestamps {
3
- id?: number;
3
+ id: number;
4
4
  name: string;
5
5
  value: string;
6
6
  environment_id: number;
7
- value_iv?: string | null;
8
- value_tag?: string | null;
7
+ value_iv: string | null;
8
+ value_tag: string | null;
9
9
  }
10
10
  export interface DBEnvironment extends Timestamps {
11
11
  id: number;
@@ -18,7 +18,13 @@ export interface DBEnvironment extends Timestamps {
18
18
  secret_key_tag?: string | null;
19
19
  secret_key_hashed?: string | null;
20
20
  callback_url: string | null;
21
+ /**
22
+ * @deprecated
23
+ */
21
24
  webhook_url: string | null;
25
+ /**
26
+ * @deprecated
27
+ */
22
28
  webhook_url_secondary: string | null;
23
29
  websockets_path: string | null;
24
30
  hmac_enabled: boolean;
@@ -33,17 +39,17 @@ export interface DBEnvironment extends Timestamps {
33
39
  pending_secret_key_tag?: string | null;
34
40
  pending_public_key?: string | null;
35
41
  slack_notifications: boolean;
36
- webhook_receive_url?: string;
42
+ webhook_receive_url: string | null;
37
43
  otlp_settings: {
38
44
  endpoint: string;
39
45
  headers: Record<string, string>;
40
46
  } | null;
41
47
  }
42
- export interface ExternalWebhook extends Timestamps {
48
+ export interface DBExternalWebhook extends Timestamps {
43
49
  id: number;
44
50
  environment_id: number;
45
- primary_url: string;
46
- secondary_url: string;
51
+ primary_url: string | null;
52
+ secondary_url: string | null;
47
53
  on_sync_completion_always: boolean;
48
54
  on_auth_creation: boolean;
49
55
  on_auth_refresh_error: boolean;
@@ -0,0 +1,16 @@
1
+ import type { Endpoint } from '../../api';
2
+ import type { DBEnvironmentVariable } from '../db';
3
+ export type ApiEnvironmentVariable = Pick<DBEnvironmentVariable, 'name' | 'value'>;
4
+ export type PostEnvironmentVariables = Endpoint<{
5
+ Method: 'POST';
6
+ Path: '/api/v1/environments/variables';
7
+ Body: {
8
+ variables: {
9
+ name: string;
10
+ value: string;
11
+ }[];
12
+ };
13
+ Success: {
14
+ success: boolean;
15
+ };
16
+ }>;
@@ -1,10 +1,10 @@
1
1
  import type { Endpoint, ApiError } from '../api.js';
2
- import type { CommitHash, Deployment } from './index.js';
2
+ import type { Deployment } from './index.js';
3
3
  export type PostRollout = Endpoint<{
4
4
  Method: 'POST';
5
5
  Path: '/fleet/:fleetId/rollout';
6
6
  Body: {
7
- commitHash: CommitHash;
7
+ image: string;
8
8
  };
9
9
  Params: {
10
10
  fleetId: string;
@@ -1,9 +1,6 @@
1
- export type CommitHash = string & {
2
- readonly length: 40;
3
- };
4
1
  export interface Deployment {
5
2
  readonly id: number;
6
- readonly commitId: CommitHash;
3
+ readonly image: string;
7
4
  readonly createdAt: Date;
8
5
  readonly supersededAt: Date | null;
9
6
  }
package/dist/index.d.ts CHANGED
@@ -48,6 +48,7 @@ export type * from './environment/api/index.js';
48
48
  export type * from './environment/api/webhook.js';
49
49
  export type * from './environment/api/otlp.js';
50
50
  export type * from './environment/variable/index.js';
51
+ export type * from './environment/variable/api.js';
51
52
  export type * from './webhooks/api.js';
52
53
  export type * from './webhooks/http.api.js';
53
54
  export type * from './flow/http.api.js';
@@ -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;
@@ -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,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,11 +8,11 @@ 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
  } | {
@@ -18,3 +20,25 @@ export type MergingStrategy = {
18
20
  cursor?: string;
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.4",
3
+ "version": "0.53.0",
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/**/*"