@withnicer/sdk 0.0.0 → 1.0.0-beta.2
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/README.md +89 -4
- package/dist/_/codec.d.ts +93 -0
- package/dist/_/codec.js +298 -0
- package/dist/_/error.d.ts +27 -0
- package/dist/_/error.js +68 -0
- package/dist/_/hooks/envelope.d.ts +11 -0
- package/dist/_/hooks/envelope.js +15 -0
- package/dist/_/index.d.ts +3 -0
- package/dist/_/index.js +5 -0
- package/dist/_/transport.d.ts +146 -0
- package/dist/_/transport.js +220 -0
- package/dist/activity/client.d.ts +42 -0
- package/dist/activity/client.js +18 -0
- package/dist/activity/index.d.ts +5 -0
- package/dist/activity/index.js +4 -0
- package/dist/activity/models.d.ts +65 -0
- package/dist/activity/models.js +3 -0
- package/dist/client.d.ts +1680 -0
- package/dist/client.js +749 -0
- package/dist/crmSettings/client.d.ts +50 -0
- package/dist/crmSettings/client.js +25 -0
- package/dist/crmSettings/index.d.ts +5 -0
- package/dist/crmSettings/index.js +4 -0
- package/dist/crmSettings/models.d.ts +313 -0
- package/dist/crmSettings/models.js +3 -0
- package/dist/crmTrips/client.d.ts +100 -0
- package/dist/crmTrips/client.js +38 -0
- package/dist/crmTrips/index.d.ts +5 -0
- package/dist/crmTrips/index.js +4 -0
- package/dist/crmTrips/models.d.ts +193 -0
- package/dist/crmTrips/models.js +3 -0
- package/dist/crmTrips/travelers/client.d.ts +33 -0
- package/dist/crmTrips/travelers/client.js +18 -0
- package/dist/crmTrips/travelers/index.d.ts +5 -0
- package/dist/crmTrips/travelers/index.js +4 -0
- package/dist/crmTrips/travelers/models.d.ts +14 -0
- package/dist/crmTrips/travelers/models.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/me/client.d.ts +56 -0
- package/dist/me/client.js +25 -0
- package/dist/me/index.d.ts +5 -0
- package/dist/me/index.js +4 -0
- package/dist/me/models.d.ts +95 -0
- package/dist/me/models.js +3 -0
- package/dist/models.d.ts +8539 -0
- package/dist/models.js +4 -0
- package/dist/notes/client.d.ts +82 -0
- package/dist/notes/client.js +41 -0
- package/dist/notes/index.d.ts +5 -0
- package/dist/notes/index.js +4 -0
- package/dist/notes/models.d.ts +116 -0
- package/dist/notes/models.js +3 -0
- package/dist/options/index.d.ts +114 -0
- package/dist/options/index.js +115 -0
- package/dist/profileForms/client.d.ts +38 -0
- package/dist/profileForms/client.js +25 -0
- package/dist/profileForms/index.d.ts +5 -0
- package/dist/profileForms/index.js +4 -0
- package/dist/profileForms/models.d.ts +24 -0
- package/dist/profileForms/models.js +3 -0
- package/dist/taskTemplates/client.d.ts +36 -0
- package/dist/taskTemplates/client.js +18 -0
- package/dist/taskTemplates/index.d.ts +5 -0
- package/dist/taskTemplates/index.js +4 -0
- package/dist/taskTemplates/models.d.ts +15 -0
- package/dist/taskTemplates/models.js +3 -0
- package/dist/tasks/client.d.ts +105 -0
- package/dist/tasks/client.js +41 -0
- package/dist/tasks/index.d.ts +5 -0
- package/dist/tasks/index.js +4 -0
- package/dist/tasks/models.d.ts +59 -0
- package/dist/tasks/models.js +3 -0
- package/dist/travelers/client.d.ts +214 -0
- package/dist/travelers/client.js +76 -0
- package/dist/travelers/index.d.ts +5 -0
- package/dist/travelers/index.js +4 -0
- package/dist/travelers/models.d.ts +576 -0
- package/dist/travelers/models.js +3 -0
- package/package.json +35 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { type Codec } from './codec.js';
|
|
2
|
+
/**
|
|
3
|
+
* The options every client takes.
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseClientOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The API token, sent as `Authorization: Bearer <token>`.
|
|
8
|
+
*/
|
|
9
|
+
token: string;
|
|
10
|
+
/**
|
|
11
|
+
* The URL the paths of the API are relative to.
|
|
12
|
+
*/
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The fetch function to send requests with; the global one by default.
|
|
16
|
+
*/
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
/**
|
|
19
|
+
* Headers sent with every request.
|
|
20
|
+
*/
|
|
21
|
+
headers?: HeadersInit;
|
|
22
|
+
/**
|
|
23
|
+
* Query parameters sent with every request.
|
|
24
|
+
*/
|
|
25
|
+
query?: URLSearchParams;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The options of a call. Every member is optional.
|
|
29
|
+
*/
|
|
30
|
+
export interface RequestOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Aborts the request.
|
|
33
|
+
*/
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
/**
|
|
36
|
+
* Headers sent with the request, which replace those of the client.
|
|
37
|
+
*/
|
|
38
|
+
headers?: HeadersInit;
|
|
39
|
+
/**
|
|
40
|
+
* Query parameters appended after those of the client.
|
|
41
|
+
*/
|
|
42
|
+
query?: URLSearchParams;
|
|
43
|
+
/**
|
|
44
|
+
* Called with the response before its body is read.
|
|
45
|
+
*/
|
|
46
|
+
onResponse?: (response: Response) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* How a paginated operation moves from one page to the next. Each function
|
|
50
|
+
* reads the response of a page, and the value of `param` that picked it.
|
|
51
|
+
*/
|
|
52
|
+
export interface Pagination {
|
|
53
|
+
/**
|
|
54
|
+
* Returns the items of a page.
|
|
55
|
+
*/
|
|
56
|
+
items(response: unknown): readonly unknown[] | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The request field that picks the page.
|
|
59
|
+
*/
|
|
60
|
+
param: string;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the value of `param` for the next page.
|
|
63
|
+
*/
|
|
64
|
+
next(response: unknown, param: unknown): unknown;
|
|
65
|
+
/**
|
|
66
|
+
* Returns whether there is a next page.
|
|
67
|
+
*/
|
|
68
|
+
more(response: unknown, param: unknown): unknown;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* An operation of the API, as the generated clients describe it.
|
|
72
|
+
*/
|
|
73
|
+
export interface Operation {
|
|
74
|
+
/**
|
|
75
|
+
* The HTTP method.
|
|
76
|
+
*/
|
|
77
|
+
method: string;
|
|
78
|
+
/**
|
|
79
|
+
* The path of the URL, with each path parameter as `{field}`.
|
|
80
|
+
*/
|
|
81
|
+
route: string;
|
|
82
|
+
/**
|
|
83
|
+
* The path parameters that fall back to the client's options.
|
|
84
|
+
*/
|
|
85
|
+
variables?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* The wire names of the query parameters, by field.
|
|
88
|
+
*/
|
|
89
|
+
query?: {
|
|
90
|
+
readonly [field: string]: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The query parameters whose arrays are joined with commas.
|
|
94
|
+
*/
|
|
95
|
+
joined?: readonly string[];
|
|
96
|
+
/**
|
|
97
|
+
* Where the body is: the fields of the request that are not parameters
|
|
98
|
+
* ("flat"), or its `body` field ("nested"). No body when absent.
|
|
99
|
+
*/
|
|
100
|
+
body?: 'flat' | 'nested';
|
|
101
|
+
/**
|
|
102
|
+
* The media type of the body, when not application/json.
|
|
103
|
+
*/
|
|
104
|
+
contentType?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The codec of the body, when it has something to convert.
|
|
107
|
+
*/
|
|
108
|
+
request?: Codec;
|
|
109
|
+
/**
|
|
110
|
+
* The codec of the response body, null when it has nothing to convert,
|
|
111
|
+
* and absent when the operation has no response body.
|
|
112
|
+
*/
|
|
113
|
+
response?: Codec | null;
|
|
114
|
+
/**
|
|
115
|
+
* The declared error responses, by status, range such as "4XX", or
|
|
116
|
+
* "default": the codec of the body, true for a JSON body with nothing to
|
|
117
|
+
* convert, and false for a body that is not JSON.
|
|
118
|
+
*/
|
|
119
|
+
errors?: {
|
|
120
|
+
readonly [status: string]: Codec | boolean;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* How the operation pages.
|
|
124
|
+
*/
|
|
125
|
+
pagination?: Pagination;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sends the requests of the generated clients.
|
|
129
|
+
*/
|
|
130
|
+
export declare class Transport {
|
|
131
|
+
#private;
|
|
132
|
+
/**
|
|
133
|
+
* Checks the options of a client. `baseUrl` is used when the options have
|
|
134
|
+
* none.
|
|
135
|
+
*/
|
|
136
|
+
constructor(options: BaseClientOptions, baseUrl?: string);
|
|
137
|
+
/**
|
|
138
|
+
* Sends a request for operation and returns its decoded response.
|
|
139
|
+
*/
|
|
140
|
+
send<T>(operation: Operation, request: object | undefined, options: RequestOptions | undefined): Promise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Sends a request for a paginated operation. Awaiting the result gives
|
|
143
|
+
* the first page, and iterating it gives every item of every page.
|
|
144
|
+
*/
|
|
145
|
+
paginate<T, I>(operation: Operation, request: object | undefined, options: RequestOptions | undefined): Promise<T> & AsyncIterable<I>;
|
|
146
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Code generated by forge. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { isRecord, parse, set, toBase64 } from './codec.js';
|
|
4
|
+
import { ApiError, errorMessage } from './error.js';
|
|
5
|
+
import { unwrapEnvelope } from './hooks/envelope.js';
|
|
6
|
+
// The fields of each operation that are parameters rather than body.
|
|
7
|
+
const paramFields = new WeakMap();
|
|
8
|
+
function paramsOf(operation) {
|
|
9
|
+
let fields = paramFields.get(operation);
|
|
10
|
+
if (fields === undefined) {
|
|
11
|
+
fields = new Set(Object.keys(operation.query ?? {}));
|
|
12
|
+
for (const [, field] of operation.route.matchAll(/\{([^}]+)\}/g)) {
|
|
13
|
+
fields.add(field);
|
|
14
|
+
}
|
|
15
|
+
paramFields.set(operation, fields);
|
|
16
|
+
}
|
|
17
|
+
return fields;
|
|
18
|
+
}
|
|
19
|
+
function toParam(value) {
|
|
20
|
+
if (value instanceof Uint8Array) {
|
|
21
|
+
return toBase64(value);
|
|
22
|
+
}
|
|
23
|
+
if (isRecord(value)) {
|
|
24
|
+
return JSON.stringify(value);
|
|
25
|
+
}
|
|
26
|
+
return String(value);
|
|
27
|
+
}
|
|
28
|
+
function lookup(errors, status) {
|
|
29
|
+
if (errors === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
for (const key of [String(status), `${Math.floor(status / 100)}XX`]) {
|
|
33
|
+
if (Object.hasOwn(errors, key)) {
|
|
34
|
+
return errors[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return Object.hasOwn(errors, 'default') ? errors['default'] : undefined;
|
|
38
|
+
}
|
|
39
|
+
async function apiError(operation, response) {
|
|
40
|
+
const text = await response.text();
|
|
41
|
+
let body;
|
|
42
|
+
let json = false;
|
|
43
|
+
if (text !== '') {
|
|
44
|
+
try {
|
|
45
|
+
body = parse(text);
|
|
46
|
+
json = true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// The body is kept as text.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const declared = lookup(operation.errors, response.status);
|
|
53
|
+
let details = text === '' ? undefined : text;
|
|
54
|
+
if (json && declared !== undefined && declared !== false) {
|
|
55
|
+
details = declared === true ? body : declared.decode(body);
|
|
56
|
+
}
|
|
57
|
+
const message = (json ? errorMessage(body) : undefined) ?? `${response.status} ${response.statusText}`.trim();
|
|
58
|
+
return new ApiError(message, response, details);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sends the requests of the generated clients.
|
|
62
|
+
*/
|
|
63
|
+
export class Transport {
|
|
64
|
+
#options;
|
|
65
|
+
#baseUrl;
|
|
66
|
+
/**
|
|
67
|
+
* Checks the options of a client. `baseUrl` is used when the options have
|
|
68
|
+
* none.
|
|
69
|
+
*/
|
|
70
|
+
constructor(options, baseUrl) {
|
|
71
|
+
if (typeof options?.token !== 'string' || options.token === '') {
|
|
72
|
+
throw new TypeError('createClient: token is required');
|
|
73
|
+
}
|
|
74
|
+
const url = options.baseUrl ?? baseUrl;
|
|
75
|
+
if (url === undefined || url === '') {
|
|
76
|
+
throw new TypeError('createClient: baseUrl is required');
|
|
77
|
+
}
|
|
78
|
+
this.#options = options;
|
|
79
|
+
this.#baseUrl = url.replace(/\/+$/, '');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sends a request for operation and returns its decoded response.
|
|
83
|
+
*/
|
|
84
|
+
send(operation, request, options) {
|
|
85
|
+
return this.#send(operation, (request ?? {}), options);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sends a request for a paginated operation. Awaiting the result gives
|
|
89
|
+
* the first page, and iterating it gives every item of every page.
|
|
90
|
+
*/
|
|
91
|
+
paginate(operation, request, options) {
|
|
92
|
+
const fields = (request ?? {});
|
|
93
|
+
const first = this.#send(operation, fields, options);
|
|
94
|
+
return Object.assign(first, {
|
|
95
|
+
[Symbol.asyncIterator]: () => this.#items(operation, fields, options, first),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async *#items(operation, request, options, first) {
|
|
99
|
+
const pagination = operation.pagination;
|
|
100
|
+
let current = request;
|
|
101
|
+
let response = await first;
|
|
102
|
+
for (;;) {
|
|
103
|
+
yield* pagination.items(response) ?? [];
|
|
104
|
+
const param = current[pagination.param];
|
|
105
|
+
if (!pagination.more(response, param)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const next = pagination.next(response, param);
|
|
109
|
+
// A next page that is the one just fetched would loop forever.
|
|
110
|
+
if (next === undefined || next === null || next === param) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
current = { ...current, [pagination.param]: next };
|
|
114
|
+
response = await this.#send(operation, current, options);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async #send(operation, request, options) {
|
|
118
|
+
const url = this.#url(operation, request, options);
|
|
119
|
+
const headers = new Headers({ accept: 'application/json' });
|
|
120
|
+
headers.set('authorization', `Bearer ${this.#options.token}`);
|
|
121
|
+
const init = { method: operation.method, headers };
|
|
122
|
+
const body = this.#body(operation, request);
|
|
123
|
+
if (body !== undefined) {
|
|
124
|
+
headers.set('content-type', operation.contentType ?? 'application/json');
|
|
125
|
+
init.body = JSON.stringify(body);
|
|
126
|
+
}
|
|
127
|
+
new Headers(this.#options.headers).forEach((value, key) => {
|
|
128
|
+
headers.set(key, value);
|
|
129
|
+
});
|
|
130
|
+
new Headers(options?.headers).forEach((value, key) => {
|
|
131
|
+
headers.set(key, value);
|
|
132
|
+
});
|
|
133
|
+
if (options?.signal !== undefined) {
|
|
134
|
+
init.signal = options.signal;
|
|
135
|
+
}
|
|
136
|
+
const fetcher = this.#options.fetch ?? fetch;
|
|
137
|
+
const response = await fetcher(url, init);
|
|
138
|
+
options?.onResponse?.(response);
|
|
139
|
+
if (response.status < 200 || response.status > 299) {
|
|
140
|
+
throw await apiError(operation, response);
|
|
141
|
+
}
|
|
142
|
+
if (operation.response === undefined) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
const text = await response.text();
|
|
146
|
+
if (text === '') {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
let value;
|
|
150
|
+
try {
|
|
151
|
+
value = parse(text);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
throw new ApiError('the response body is not valid JSON', response, text, {
|
|
155
|
+
cause: e,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
value = unwrapEnvelope(response, value);
|
|
159
|
+
return operation.response === null ? value : operation.response.decode(value);
|
|
160
|
+
}
|
|
161
|
+
#url(operation, request, options) {
|
|
162
|
+
const client = this.#options;
|
|
163
|
+
const path = operation.route.replace(/\{([^}]+)\}/g, (_, field) => {
|
|
164
|
+
let value = request[field];
|
|
165
|
+
if (value === undefined && operation.variables?.includes(field)) {
|
|
166
|
+
value = client[field];
|
|
167
|
+
}
|
|
168
|
+
if (value === undefined || value === null || value === '') {
|
|
169
|
+
throw new TypeError(`${field} is required: set it in the request or the client options`);
|
|
170
|
+
}
|
|
171
|
+
return encodeURIComponent(toParam(value));
|
|
172
|
+
});
|
|
173
|
+
const url = new URL(this.#baseUrl + path);
|
|
174
|
+
const query = url.searchParams;
|
|
175
|
+
for (const [field, wire] of Object.entries(operation.query ?? {})) {
|
|
176
|
+
const value = request[field];
|
|
177
|
+
if (value === undefined || value === null) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (!Array.isArray(value)) {
|
|
181
|
+
query.append(wire, toParam(value));
|
|
182
|
+
}
|
|
183
|
+
else if (operation.joined?.includes(field)) {
|
|
184
|
+
query.append(wire, value.map(toParam).join(','));
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
for (const item of value) {
|
|
188
|
+
query.append(wire, toParam(item));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this.#options.query?.forEach((value, key) => {
|
|
193
|
+
query.append(key, value);
|
|
194
|
+
});
|
|
195
|
+
options?.query?.forEach((value, key) => {
|
|
196
|
+
query.append(key, value);
|
|
197
|
+
});
|
|
198
|
+
return url;
|
|
199
|
+
}
|
|
200
|
+
#body(operation, request) {
|
|
201
|
+
let body;
|
|
202
|
+
if (operation.body === 'nested') {
|
|
203
|
+
body = request['body'];
|
|
204
|
+
}
|
|
205
|
+
else if (operation.body === 'flat') {
|
|
206
|
+
const params = paramsOf(operation);
|
|
207
|
+
const fields = {};
|
|
208
|
+
for (const key of Object.keys(request)) {
|
|
209
|
+
if (!params.has(key)) {
|
|
210
|
+
set(fields, key, request[key]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
body = fields;
|
|
214
|
+
}
|
|
215
|
+
if (body === undefined || operation.request === undefined) {
|
|
216
|
+
return body;
|
|
217
|
+
}
|
|
218
|
+
return operation.request.encode(body);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type BaseClientOptions, type RequestOptions, Transport } from "../_/index.js";
|
|
2
|
+
import type { TravelerId } from "../models.js";
|
|
3
|
+
import type { ActivityList } from "./models.js";
|
|
4
|
+
export interface ClientOptions extends BaseClientOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The URL the paths of the API are relative to.
|
|
7
|
+
*/
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Client {
|
|
11
|
+
/**
|
|
12
|
+
* List a traveler's timeline
|
|
13
|
+
*
|
|
14
|
+
* Returns what happened to one traveler (travelerId), newest first: changes
|
|
15
|
+
* in the CRM, notes and tasks, trips, bookings, payments, invitations, emails
|
|
16
|
+
* and itineraries sent. Each entry has its type, a one-line summary and the
|
|
17
|
+
* ids it is about in data, never the values that changed. 50 a page unless
|
|
18
|
+
* limit says otherwise; send the answer's nextToken back to read the next
|
|
19
|
+
* page, until it is null. Errors: 400 ERROR_INVALID_QUERY for a missing
|
|
20
|
+
* travelerId, a limit out of range or a nextToken of another list; 404
|
|
21
|
+
* ERROR_ITEM_NOT_FOUND for a traveler the caller may not see.
|
|
22
|
+
*/
|
|
23
|
+
list(request: ListRequest, options?: RequestOptions): Promise<ListResponse>;
|
|
24
|
+
}
|
|
25
|
+
export declare function createClient(options: ClientOptions): Client;
|
|
26
|
+
export declare function bind(transport: Transport): Client;
|
|
27
|
+
export interface ListRequest {
|
|
28
|
+
/**
|
|
29
|
+
* How many entries a page holds, 1 to 100; 50 when left out.
|
|
30
|
+
*/
|
|
31
|
+
limit?: number;
|
|
32
|
+
/**
|
|
33
|
+
* The nextToken of the page before, to read the next one; left out for the
|
|
34
|
+
* first page.
|
|
35
|
+
*/
|
|
36
|
+
nextToken?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The traveler (TRV…) whose timeline to list.
|
|
39
|
+
*/
|
|
40
|
+
travelerId: TravelerId;
|
|
41
|
+
}
|
|
42
|
+
export type ListResponse = ActivityList;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Code generated by forge. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { Transport, } from "../_/index.js";
|
|
4
|
+
export function createClient(options) {
|
|
5
|
+
return bind(new Transport(options));
|
|
6
|
+
}
|
|
7
|
+
export function bind(transport) {
|
|
8
|
+
return {
|
|
9
|
+
list: (request, options) => transport.send(ListOperation, request, options),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const ListOperation = {
|
|
13
|
+
method: "GET",
|
|
14
|
+
route: "/crm/activity",
|
|
15
|
+
query: { limit: "limit", nextToken: "nextToken", travelerId: "travelerId" },
|
|
16
|
+
response: null,
|
|
17
|
+
errors: { "400": true, "401": true, "403": true },
|
|
18
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ApiError } from "../_/index.js";
|
|
2
|
+
export type { RequestOptions } from "../_/index.js";
|
|
3
|
+
export { createClient } from "./client.js";
|
|
4
|
+
export type { Client, ClientOptions, ListRequest, ListResponse, } from "./client.js";
|
|
5
|
+
export type { Activity, ActivityList, ActivityType, } from "./models.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { TravelerId } from "../models.js";
|
|
2
|
+
/**
|
|
3
|
+
* One entry of a traveler's timeline: an event of the CRM or of another domain,
|
|
4
|
+
* with ids and a readable summary.
|
|
5
|
+
*/
|
|
6
|
+
export interface Activity {
|
|
7
|
+
/**
|
|
8
|
+
* The event's id; the same entry is never recorded twice.
|
|
9
|
+
*/
|
|
10
|
+
activityId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The user id of who did it; null for the system and other domains'
|
|
13
|
+
* automations.
|
|
14
|
+
*/
|
|
15
|
+
actorUserId: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Ids, section names and counts the entry is about, as the event of its type
|
|
18
|
+
* gives them.
|
|
19
|
+
*/
|
|
20
|
+
data: {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* When it happened.
|
|
25
|
+
*/
|
|
26
|
+
occurredAt: string;
|
|
27
|
+
/**
|
|
28
|
+
* One readable line, e.g. "Hotel booked" or "Passport updated".
|
|
29
|
+
*/
|
|
30
|
+
summary: string;
|
|
31
|
+
/**
|
|
32
|
+
* The traveler whose timeline holds the entry.
|
|
33
|
+
*/
|
|
34
|
+
travelerId: TravelerId | null;
|
|
35
|
+
/**
|
|
36
|
+
* The trip (TT…) the entry is about, when it is about one.
|
|
37
|
+
*/
|
|
38
|
+
travelersTripId: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* The event the entry was written from.
|
|
41
|
+
*/
|
|
42
|
+
type: ActivityType;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One page of a traveler's timeline, newest first, and the token of the next
|
|
46
|
+
* page.
|
|
47
|
+
*/
|
|
48
|
+
export interface ActivityList {
|
|
49
|
+
/**
|
|
50
|
+
* The items of this page.
|
|
51
|
+
*/
|
|
52
|
+
items: Activity[];
|
|
53
|
+
/**
|
|
54
|
+
* Send it back as nextToken to read the next page; null on the last page.
|
|
55
|
+
*/
|
|
56
|
+
nextToken: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The event a timeline entry was written from: a trip created or joined
|
|
60
|
+
* (app.TravelersTrip.*), a proposal sent or approved (app.TripItinerary.*), an
|
|
61
|
+
* order, a booking confirmation or a payment (commerce.*), a change in the CRM
|
|
62
|
+
* (crm.*), or an email the agency sent the traveler
|
|
63
|
+
* (notifications.traveler-email-sent.v1).
|
|
64
|
+
*/
|
|
65
|
+
export type ActivityType = "app.TravelersTrip.created" | "app.TravelersTrip.user.added" | "app.TripItinerary.Send" | "app.TripItinerary.approved" | "commerce.order-confirmation-requested.v1" | "commerce.order-projection-changed.v1" | "commerce.payment-receipt-requested.v1" | "crm.note-changed.v1" | "crm.task-changed.v1" | "crm.traveler-advisors-changed.v1" | "crm.traveler-created.v1" | "crm.traveler-documents-changed.v1" | "crm.traveler-invitation-requested.v1" | "crm.traveler-linked.v1" | "crm.traveler-unlinked.v1" | "crm.traveler-updated.v1" | "crm.travelers-merged.v1" | "crm.trip-updated.v1" | "notifications.traveler-email-sent.v1";
|