@nangohq/types 0.56.1 → 0.56.3

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<'forbidden'> | 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'>;
14
+ export type ResDefaultErrors = ApiError<'invalid_content_type'> | ApiError<'not_found'> | ApiError<'conflict'> | ApiError<'forbidden'> | 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'> | ApiError<'request_too_large'>;
15
15
  export type EndpointMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
16
16
  /**
17
17
  * API Request/Response type
package/dist/index.d.ts CHANGED
@@ -60,3 +60,4 @@ export type * from './web/env.js';
60
60
  export type * from './fleet/api.js';
61
61
  export type * from './fleet/index.js';
62
62
  export type * from './persist/api.js';
63
+ export type * from './jobs/api.js';
@@ -0,0 +1,53 @@
1
+ import type { JsonValue } from 'type-fest';
2
+ import type { ApiError, Endpoint } from '../api';
3
+ import type { RunnerOutputError } from '../runner';
4
+ import type { NangoProps } from '../runner/sdk';
5
+ export type PostHeartbeat = Endpoint<{
6
+ Method: 'POST';
7
+ Path: '/tasks/:taskId/heartbeat';
8
+ Params: {
9
+ taskId: string;
10
+ };
11
+ Body: never;
12
+ Error: ApiError<'heartbeat_failed'>;
13
+ Success: never;
14
+ }>;
15
+ export type PutTask = Endpoint<{
16
+ Method: 'PUT';
17
+ Path: '/tasks/:taskId';
18
+ Params: {
19
+ taskId: string;
20
+ };
21
+ Body: {
22
+ nangoProps?: NangoProps | undefined;
23
+ error?: RunnerOutputError | undefined;
24
+ output?: JsonValue | undefined;
25
+ };
26
+ Error: ApiError<'put_task_failed'>;
27
+ Success: never;
28
+ }>;
29
+ export type PostRegister = Endpoint<{
30
+ Method: 'POST';
31
+ Path: '/runners/:nodeId/register';
32
+ Params: {
33
+ nodeId: number;
34
+ };
35
+ Body: {
36
+ url: string;
37
+ };
38
+ Error: ApiError<'register_failed'>;
39
+ Success: {
40
+ status: 'ok';
41
+ };
42
+ }>;
43
+ export type PostIdle = Endpoint<{
44
+ Method: 'POST';
45
+ Path: '/runners/:nodeId/idle';
46
+ Params: {
47
+ nodeId: number;
48
+ };
49
+ Error: ApiError<'idle_failed'>;
50
+ Success: {
51
+ status: 'ok';
52
+ };
53
+ }>;
@@ -1,6 +1,6 @@
1
1
  import type { Endpoint } from '../api';
2
2
  import type { PickFromUnion } from '../utils';
3
- import type { MessageRow, MessageState, OperationList, OperationRow } from './messages';
3
+ import type { MessageRow, OperationList, OperationRow, OperationState } from './messages';
4
4
  type Concat<T extends OperationList> = T extends {
5
5
  action: string;
6
6
  } ? `${T['type']}:${T['action']}` : never;
@@ -30,7 +30,7 @@ export type SearchOperations = Endpoint<{
30
30
  };
31
31
  };
32
32
  }>;
33
- export type SearchOperationsState = 'all' | MessageState;
33
+ export type SearchOperationsState = 'all' | OperationState;
34
34
  export type SearchOperationsType = 'all' | ConcatOperationListWithGroup;
35
35
  export type SearchOperationsIntegration = 'all' | string;
36
36
  export type SearchOperationsConnection = 'all' | string;
@@ -1,4 +1,4 @@
1
- import type { Merge, SetNonNullable } from 'type-fest';
1
+ import type { Merge } from 'type-fest';
2
2
  /**
3
3
  * Level of the log and operation
4
4
  */
@@ -13,15 +13,10 @@ export type MessageMeta = Record<any, any>;
13
13
  * - http: an HTTP request with request/response added to the log
14
14
  */
15
15
  export type MessageType = 'log' | 'http';
16
- /**
17
- * Error code attached to the message
18
- * Not used yet
19
- */
20
- export type MessageCode = 'success';
21
16
  /**
22
17
  * State of the Operation
23
18
  */
24
- export type MessageState = 'waiting' | 'running' | 'success' | 'failed' | 'timeout' | 'cancelled';
19
+ export type OperationState = 'waiting' | 'running' | 'success' | 'failed' | 'timeout' | 'cancelled';
25
20
  /**
26
21
  * Operations
27
22
  */
@@ -58,64 +53,83 @@ export interface OperationDeploy {
58
53
  action: 'prebuilt' | 'custom';
59
54
  }
60
55
  export type OperationList = OperationSync | OperationProxy | OperationAction | OperationWebhook | OperationOnEvents | OperationDeploy | OperationAuth | OperationAdmin;
56
+ export interface MessageError {
57
+ name: string;
58
+ message: string;
59
+ type?: string | undefined;
60
+ payload?: any;
61
+ }
62
+ export interface MessageHTTPRequest {
63
+ url: string;
64
+ method: string;
65
+ headers: Record<string, string>;
66
+ body?: unknown;
67
+ }
68
+ export interface MessageHTTPResponse {
69
+ code: number;
70
+ headers: Record<string, string>;
71
+ }
72
+ export interface MessageHTTPRetry {
73
+ attempt: number;
74
+ max: number;
75
+ waited: number;
76
+ }
61
77
  /**
62
78
  * Full schema
63
79
  */
64
80
  export interface MessageRow {
81
+ /**
82
+ * This ID is for debugging purpose, not for insertion
83
+ * It should never be used to index
84
+ */
65
85
  id: string;
66
86
  source: 'internal' | 'user';
67
87
  level: LogLevel;
68
88
  type: MessageType;
69
89
  message: string;
70
- title: string | null;
71
- state: MessageState;
72
- code: MessageCode | null;
73
- operation: null;
74
- accountId: number | null;
75
- accountName: string | null;
76
- environmentId: number | null;
77
- environmentName: string | null;
90
+ parentId: string;
91
+ error?: MessageError | undefined;
92
+ request?: MessageHTTPRequest | undefined;
93
+ response?: MessageHTTPResponse | undefined;
94
+ meta?: MessageMeta | null | undefined;
95
+ retry?: MessageHTTPRetry | undefined;
96
+ createdAt: string;
97
+ endedAt?: string | undefined;
98
+ }
99
+ export interface OperationRow {
100
+ id: string;
101
+ source: 'internal';
102
+ level: LogLevel;
103
+ type: 'operation';
104
+ message: string;
105
+ operation: OperationList;
106
+ state: OperationState;
107
+ accountId: number;
108
+ accountName: string;
109
+ environmentId?: number | undefined;
110
+ environmentName?: string | undefined;
78
111
  /**
79
112
  * Provider name, i.e: github
80
113
  */
81
- providerName: string | null;
114
+ providerName?: string | undefined;
82
115
  /**
83
116
  * Database ID of the config, i.e: 9
84
117
  */
85
- integrationId: number | null;
118
+ integrationId?: number | undefined;
86
119
  /**
87
120
  * Unique config name, i.e: github-demo
88
121
  */
89
- integrationName: string | null;
90
- connectionId: number | null;
91
- connectionName: string | null;
92
- syncConfigId: number | null;
93
- syncConfigName: string | null;
94
- jobId: string | null;
95
- userId: number | null;
96
- parentId: string | null;
97
- error: {
98
- name: string;
99
- message: string;
100
- type?: string | null;
101
- payload?: any;
102
- } | null;
103
- request: {
104
- url: string;
105
- method: string;
106
- headers: Record<string, string>;
107
- body?: unknown;
108
- } | null;
109
- response: {
110
- code: number;
111
- headers: Record<string, string>;
112
- } | null;
113
- meta: MessageMeta | null;
114
- retry?: {
115
- attempt: number;
116
- max: number;
117
- waited: number;
118
- } | undefined;
122
+ integrationName?: string | undefined;
123
+ connectionId?: number | undefined;
124
+ connectionName?: string | undefined;
125
+ syncConfigId?: number | undefined;
126
+ syncConfigName?: string | undefined;
127
+ jobId?: string | undefined;
128
+ userId?: number | undefined;
129
+ error?: MessageError | undefined;
130
+ request?: MessageHTTPRequest | undefined;
131
+ response?: MessageHTTPResponse | undefined;
132
+ meta?: MessageMeta | undefined;
119
133
  createdAt: string;
120
134
  updatedAt: string;
121
135
  startedAt: string | null;
@@ -123,14 +137,9 @@ export interface MessageRow {
123
137
  expiresAt: string | null;
124
138
  }
125
139
  /**
126
- * What is required to insert a Message
140
+ * What is required to insert an Operation
127
141
  */
128
- export type OperationRowInsert = Omit<Merge<Partial<MessageRow>, {
129
- operation: OperationList;
130
- }>, 'message'>;
131
- export type OperationRow = SetNonNullable<Omit<MessageRow, 'operation'>, 'id' | 'message' | 'source' | 'createdAt' | 'accountId' | 'accountName' | 'type' | 'level' | 'expiresAt' | 'state'> & {
132
- operation: OperationList;
133
- };
142
+ export type OperationRowInsert = Merge<Partial<OperationRow>, Pick<OperationRow, 'operation'>>;
134
143
  /**
135
144
  * What is required to insert a Message
136
145
  */
@@ -1,4 +1,20 @@
1
+ import type { ApiError, Endpoint } from '../api.js';
2
+ import type { MessageRowInsert } from '../logs/messages.js';
1
3
  import type { MergingStrategy, NangoRecord } from '../record/api.js';
4
+ interface LogBody {
5
+ activityLogId: string;
6
+ log: MessageRowInsert;
7
+ }
8
+ export type PostLog = Endpoint<{
9
+ Method: 'POST';
10
+ Path: '/environment/:environmentId/log';
11
+ Params: {
12
+ environmentId: number;
13
+ };
14
+ Body: LogBody;
15
+ Error: ApiError<'post_log_failed'>;
16
+ Success: never;
17
+ }>;
2
18
  export interface PostRecordsSuccess {
3
19
  nextMerging: MergingStrategy;
4
20
  }
@@ -15,3 +31,4 @@ export interface GetRecordsSuccess {
15
31
  records: NangoRecord[];
16
32
  nextCursor?: string;
17
33
  }
34
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nangohq/types",
3
- "version": "0.56.1",
3
+ "version": "0.56.3",
4
4
  "description": "Types used in Nango applications",
5
5
  "type": "module",
6
6
  "typings": "dist/index.d.ts",