@nangohq/types 0.39.23 → 0.39.25
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 +15 -3
- package/dist/api.endpoints.d.ts +18 -0
- package/dist/index.d.ts +4 -0
- package/dist/logs/api.d.ts +19 -0
- package/dist/logs/messages.d.ts +113 -0
- package/dist/onboarding/api.d.ts +4 -2
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
export interface ApiError<TCode extends string> {
|
|
1
|
+
export interface ApiError<TCode extends string, TErrors = undefined> {
|
|
2
2
|
error: {
|
|
3
3
|
code: TCode;
|
|
4
4
|
message?: string | undefined;
|
|
5
|
+
errors?: TErrors;
|
|
5
6
|
};
|
|
6
7
|
}
|
|
8
|
+
export interface ValidationError {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
path: (string | number)[];
|
|
12
|
+
}
|
|
13
|
+
export type ResDefaultErrors = ApiError<'not_found'> | ApiError<'invalid_query_params', ValidationError[]> | ApiError<'invalid_body', ValidationError[]> | ApiError<'feature_disabled'>;
|
|
14
|
+
export type EndpointMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
7
15
|
/**
|
|
8
16
|
* API Request/Response type
|
|
9
17
|
*/
|
|
10
18
|
export interface Endpoint<T extends {
|
|
19
|
+
Method: EndpointMethod;
|
|
20
|
+
Path: string;
|
|
11
21
|
Params?: Record<string, any>;
|
|
12
22
|
Body?: Record<string, any>;
|
|
13
23
|
Querystring?: Record<string, any>;
|
|
14
24
|
Error?: ApiError<any> | never;
|
|
15
25
|
Success: Record<string, any> | never;
|
|
16
26
|
}> {
|
|
27
|
+
Method: T['Method'];
|
|
28
|
+
Path: T['Path'];
|
|
17
29
|
/**
|
|
18
30
|
* URL params
|
|
19
31
|
*/
|
|
@@ -37,9 +49,9 @@ export interface Endpoint<T extends {
|
|
|
37
49
|
/**
|
|
38
50
|
* Response body for any error
|
|
39
51
|
*/
|
|
40
|
-
Errors: T['Error'];
|
|
52
|
+
Errors: ResDefaultErrors | T['Error'];
|
|
41
53
|
/**
|
|
42
54
|
* Response body (success + error)
|
|
43
55
|
*/
|
|
44
|
-
Reply: T['Error'] extends ApiError<any> ? T['Error'] | T['Success'] : T['Success'];
|
|
56
|
+
Reply: ResDefaultErrors | (T['Error'] extends ApiError<any> ? T['Error'] | T['Success'] : T['Success']);
|
|
45
57
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EndpointMethod } from './api';
|
|
2
|
+
import type { SearchLogs } from './logs/api';
|
|
3
|
+
import type { GetOnboardingStatus } from './onboarding/api';
|
|
4
|
+
export type APIEndpoints = SearchLogs | GetOnboardingStatus;
|
|
5
|
+
/**
|
|
6
|
+
* Automatically narrow endpoints type with Method + Path
|
|
7
|
+
*/
|
|
8
|
+
export type APIEndpointsPicker<TMethod extends EndpointMethod, TPath extends APIEndpoints['Path']> = Extract<APIEndpoints, {
|
|
9
|
+
Method: TMethod;
|
|
10
|
+
Path: TPath;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Automatically narrow endpoints type with Path
|
|
14
|
+
* Useful to get allowed methods
|
|
15
|
+
*/
|
|
16
|
+
export type APIEndpointsPickerWithPath<TPath extends APIEndpoints['Path']> = Extract<APIEndpoints, {
|
|
17
|
+
Path: TPath;
|
|
18
|
+
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export type * from './db.js';
|
|
2
|
+
export type * from './api.js';
|
|
3
|
+
export type * from './api.endpoints.js';
|
|
2
4
|
export type * from './onboarding/db.js';
|
|
3
5
|
export type * from './onboarding/api.js';
|
|
4
6
|
export type * from './record/api.js';
|
|
7
|
+
export type * from './logs/api.js';
|
|
8
|
+
export type * from './logs/messages.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ApiError, Endpoint } from '../api';
|
|
2
|
+
import type { OperationRow } from './messages';
|
|
3
|
+
export type SearchLogs = Endpoint<{
|
|
4
|
+
Method: 'POST';
|
|
5
|
+
Path: '/api/v1/logs/search';
|
|
6
|
+
Querystring: {
|
|
7
|
+
env: string;
|
|
8
|
+
};
|
|
9
|
+
Body: {
|
|
10
|
+
limit?: number;
|
|
11
|
+
};
|
|
12
|
+
Error: ApiError<'invalid_query_params'>;
|
|
13
|
+
Success: {
|
|
14
|
+
data: OperationRow[];
|
|
15
|
+
pagination: {
|
|
16
|
+
total: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Level of the log and operation
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
5
|
+
/**
|
|
6
|
+
* Free form JSON (not indexed)
|
|
7
|
+
*/
|
|
8
|
+
export type MessageMeta = Record<any, any>;
|
|
9
|
+
/**
|
|
10
|
+
* Kind of messages
|
|
11
|
+
* - log: classic string message
|
|
12
|
+
* - http: an HTTP request with request/response added to the log
|
|
13
|
+
*/
|
|
14
|
+
export type MessageType = 'log' | 'http';
|
|
15
|
+
/**
|
|
16
|
+
* Error code attached to the message
|
|
17
|
+
* Not used yet
|
|
18
|
+
*/
|
|
19
|
+
export type MessageCode = 'success';
|
|
20
|
+
/**
|
|
21
|
+
* State of the Operation
|
|
22
|
+
*/
|
|
23
|
+
export type MessageState = 'waiting' | 'running' | 'success' | 'failed' | 'timeout' | 'cancelled';
|
|
24
|
+
/**
|
|
25
|
+
* Operations
|
|
26
|
+
*/
|
|
27
|
+
export interface MessageOpSync {
|
|
28
|
+
type: 'sync';
|
|
29
|
+
action: 'pause' | 'unpause' | 'run' | 'run_full' | 'cancel' | 'init';
|
|
30
|
+
}
|
|
31
|
+
export interface MessageOpProxy {
|
|
32
|
+
type: 'proxy';
|
|
33
|
+
}
|
|
34
|
+
export interface MessageOpAction {
|
|
35
|
+
type: 'action';
|
|
36
|
+
}
|
|
37
|
+
export interface MessageOpAuth {
|
|
38
|
+
type: 'auth';
|
|
39
|
+
}
|
|
40
|
+
export interface MessageOpToken {
|
|
41
|
+
type: 'token';
|
|
42
|
+
}
|
|
43
|
+
export interface MessageOpAdmin {
|
|
44
|
+
type: 'admin';
|
|
45
|
+
action: 'impersonation';
|
|
46
|
+
}
|
|
47
|
+
export interface MessageOpWebhook {
|
|
48
|
+
type: 'webhook';
|
|
49
|
+
action: 'incoming' | 'outgoing';
|
|
50
|
+
}
|
|
51
|
+
export interface MessageOpDeploy {
|
|
52
|
+
type: 'deploy';
|
|
53
|
+
action: 'prebuilt' | 'custom';
|
|
54
|
+
}
|
|
55
|
+
export type MessageOperation = MessageOpSync | MessageOpProxy | MessageOpAction | MessageOpWebhook | MessageOpDeploy | MessageOpAuth | MessageOpAdmin | MessageOpToken;
|
|
56
|
+
/**
|
|
57
|
+
* Full schema
|
|
58
|
+
*/
|
|
59
|
+
export type MessageRow = {
|
|
60
|
+
id: string;
|
|
61
|
+
source: 'internal' | 'user';
|
|
62
|
+
level: LogLevel;
|
|
63
|
+
type: MessageType;
|
|
64
|
+
message: string;
|
|
65
|
+
title: string | null;
|
|
66
|
+
state: MessageState;
|
|
67
|
+
code: MessageCode | null;
|
|
68
|
+
accountId: number | null;
|
|
69
|
+
accountName: string | null;
|
|
70
|
+
environmentId: number | null;
|
|
71
|
+
environmentName: string | null;
|
|
72
|
+
configId: number | null;
|
|
73
|
+
configName: string | null;
|
|
74
|
+
connectionId: number | null;
|
|
75
|
+
connectionName: string | null;
|
|
76
|
+
syncId: string | null;
|
|
77
|
+
syncName: string | null;
|
|
78
|
+
jobId: string | null;
|
|
79
|
+
userId: number | null;
|
|
80
|
+
parentId: string | null;
|
|
81
|
+
error: {
|
|
82
|
+
name: string;
|
|
83
|
+
message: string;
|
|
84
|
+
} | null;
|
|
85
|
+
request: {
|
|
86
|
+
url: string;
|
|
87
|
+
method: string;
|
|
88
|
+
headers: Record<string, string>;
|
|
89
|
+
} | null;
|
|
90
|
+
response: {
|
|
91
|
+
code: number;
|
|
92
|
+
headers: Record<string, string>;
|
|
93
|
+
} | null;
|
|
94
|
+
meta: MessageMeta | null;
|
|
95
|
+
createdAt: string;
|
|
96
|
+
updatedAt: string;
|
|
97
|
+
startedAt: string | null;
|
|
98
|
+
endedAt: string | null;
|
|
99
|
+
} & {
|
|
100
|
+
operation: MessageOperation | null;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* What is required to insert a Message
|
|
104
|
+
*/
|
|
105
|
+
export type OperationRequired = 'operation' | 'message';
|
|
106
|
+
export type OperationRowInsert = Pick<MessageRow, OperationRequired> & Partial<Omit<MessageRow, OperationRequired>>;
|
|
107
|
+
export type OperationRow = Pick<MessageRow, OperationRequired> & Omit<MessageRow, OperationRequired>;
|
|
108
|
+
/**
|
|
109
|
+
* What is required to insert a Message
|
|
110
|
+
*/
|
|
111
|
+
export type MessageRowInsert = Pick<MessageRow, 'type' | 'message'> & Partial<Omit<MessageRow, 'type' | 'message'>> & {
|
|
112
|
+
id?: string | undefined;
|
|
113
|
+
};
|
package/dist/onboarding/api.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ApiError, Endpoint } from '../api';
|
|
2
2
|
import type { NangoRecord } from '../record/api';
|
|
3
3
|
export type GetOnboardingStatus = Endpoint<{
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Method: 'GET';
|
|
5
|
+
Path: '/api/v1/onboarding';
|
|
6
|
+
Querystring: {
|
|
7
|
+
env: string;
|
|
6
8
|
};
|
|
7
9
|
Error: ApiError<'onboarding_dev_only'> | ApiError<'no_onboarding'> | ApiError<'failed_to_get_records'> | ApiError<'invalid_query_params'>;
|
|
8
10
|
Success: {
|