@lorikeetai/node-sdk 0.1.0 → 0.3.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/CHANGELOG.md +31 -0
- package/README.md +11 -11
- package/_shims/MultipartBody.js.map +1 -1
- package/_shims/MultipartBody.mjs.map +1 -1
- package/_shims/auto/runtime-bun.d.ts.map +1 -1
- package/_shims/auto/runtime-bun.js.map +1 -1
- package/_shims/auto/runtime-node.d.ts.map +1 -1
- package/_shims/auto/runtime-node.js.map +1 -1
- package/_shims/auto/runtime.d.ts.map +1 -1
- package/_shims/auto/runtime.js.map +1 -1
- package/_shims/auto/types-node.d.ts.map +1 -1
- package/_shims/auto/types-node.js.map +1 -1
- package/_shims/auto/types.d.ts +52 -52
- package/_shims/bun-runtime.d.ts.map +1 -1
- package/_shims/bun-runtime.js.map +1 -1
- package/_shims/bun-runtime.mjs.map +1 -1
- package/_shims/index.d.ts +36 -36
- package/_shims/index.js +5 -5
- package/_shims/index.mjs +4 -4
- package/_shims/node-runtime.d.ts.map +1 -1
- package/_shims/node-runtime.js.map +1 -1
- package/_shims/node-runtime.mjs.map +1 -1
- package/_shims/node-types.d.ts +27 -27
- package/_shims/registry.d.ts.map +1 -1
- package/_shims/registry.js.map +1 -1
- package/_shims/registry.mjs.map +1 -1
- package/_shims/web-runtime.d.ts.map +1 -1
- package/_shims/web-runtime.js.map +1 -1
- package/_shims/web-runtime.mjs.map +1 -1
- package/_shims/web-types.d.ts +52 -52
- package/core.d.ts.map +1 -1
- package/core.js +0 -1
- package/core.js.map +1 -1
- package/core.mjs +0 -1
- package/core.mjs.map +1 -1
- package/error.d.ts.map +1 -1
- package/error.js.map +1 -1
- package/error.mjs.map +1 -1
- package/index.d.mts +2 -5
- package/index.d.ts +2 -5
- package/index.d.ts.map +1 -1
- package/index.js +0 -3
- package/index.js.map +1 -1
- package/index.mjs +1 -4
- package/index.mjs.map +1 -1
- package/lib/generate-signature.js.map +1 -1
- package/lib/generate-signature.mjs.map +1 -1
- package/package.json +1 -1
- package/resource.d.ts.map +1 -1
- package/resource.js.map +1 -1
- package/resource.mjs.map +1 -1
- package/resources/conversation/chat.d.ts +58 -6
- package/resources/conversation/chat.d.ts.map +1 -1
- package/resources/conversation/chat.js.map +1 -1
- package/resources/conversation/chat.mjs.map +1 -1
- package/resources/conversation/conversation.d.ts.map +1 -1
- package/resources/conversation/conversation.js.map +1 -1
- package/resources/conversation/conversation.mjs.map +1 -1
- package/resources/conversation/email.d.ts.map +1 -1
- package/resources/conversation/email.js.map +1 -1
- package/resources/conversation/email.mjs.map +1 -1
- package/resources/conversation/index.d.ts.map +1 -1
- package/resources/conversation/index.js.map +1 -1
- package/resources/customer.d.ts +21 -1
- package/resources/customer.d.ts.map +1 -1
- package/resources/customer.js +7 -0
- package/resources/customer.js.map +1 -1
- package/resources/customer.mjs +7 -0
- package/resources/customer.mjs.map +1 -1
- package/resources/index.d.ts +1 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +1 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -2
- package/resources/index.mjs.map +1 -1
- package/resources/ingest.d.ts.map +1 -1
- package/resources/ingest.js.map +1 -1
- package/resources/ingest.mjs.map +1 -1
- package/shims/node.d.ts.map +1 -1
- package/shims/node.js.map +1 -1
- package/shims/node.mjs.map +1 -1
- package/shims/web.d.ts.map +1 -1
- package/shims/web.js.map +1 -1
- package/shims/web.mjs.map +1 -1
- package/src/_shims/MultipartBody.ts +1 -1
- package/src/_shims/auto/runtime-bun.ts +1 -1
- package/src/_shims/auto/runtime-node.ts +1 -1
- package/src/_shims/auto/runtime.ts +1 -1
- package/src/_shims/auto/types-node.ts +1 -1
- package/src/_shims/auto/types.d.ts +52 -52
- package/src/_shims/bun-runtime.ts +6 -6
- package/src/_shims/index.d.ts +36 -36
- package/src/_shims/index.js +5 -5
- package/src/_shims/index.mjs +4 -4
- package/src/_shims/node-runtime.ts +32 -32
- package/src/_shims/node-types.d.ts +27 -27
- package/src/_shims/registry.ts +44 -44
- package/src/_shims/web-runtime.ts +16 -16
- package/src/_shims/web-types.d.ts +52 -52
- package/src/core.ts +372 -372
- package/src/error.ts +37 -37
- package/src/index.ts +73 -74
- package/src/lib/generate-signature.ts +3 -3
- package/src/resource.ts +3 -3
- package/src/resources/conversation/chat.ts +85 -23
- package/src/resources/conversation/conversation.ts +11 -11
- package/src/resources/conversation/email.ts +8 -8
- package/src/resources/conversation/index.ts +3 -3
- package/src/resources/customer.ts +34 -0
- package/src/resources/index.ts +9 -4
- package/src/resources/ingest.ts +7 -7
- package/src/shims/node.ts +24 -24
- package/src/shims/web.ts +24 -24
- package/src/uploads.ts +72 -72
- package/src/version.ts +1 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js.map +1 -1
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/token.d.ts +0 -28
- package/resources/token.d.ts.map +0 -1
- package/resources/token.js +0 -16
- package/resources/token.js.map +0 -1
- package/resources/token.mjs +0 -12
- package/resources/token.mjs.map +0 -1
- package/src/resources/token.ts +0 -42
package/src/error.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { castToError, Headers } from './core'
|
|
3
|
+
import { castToError, Headers } from './core';
|
|
4
4
|
|
|
5
5
|
export class LorikeetError extends Error {}
|
|
6
6
|
|
|
7
7
|
export class APIError extends LorikeetError {
|
|
8
|
-
readonly status: number | undefined
|
|
9
|
-
readonly headers: Headers | undefined
|
|
10
|
-
readonly error: Object | undefined
|
|
8
|
+
readonly status: number | undefined;
|
|
9
|
+
readonly headers: Headers | undefined;
|
|
10
|
+
readonly error: Object | undefined;
|
|
11
11
|
|
|
12
12
|
constructor(
|
|
13
13
|
status: number | undefined,
|
|
@@ -15,10 +15,10 @@ export class APIError extends LorikeetError {
|
|
|
15
15
|
message: string | undefined,
|
|
16
16
|
headers: Headers | undefined,
|
|
17
17
|
) {
|
|
18
|
-
super(`${APIError.makeMessage(status, error, message)}`)
|
|
19
|
-
this.status = status
|
|
20
|
-
this.headers = headers
|
|
21
|
-
this.error = error
|
|
18
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.headers = headers;
|
|
21
|
+
this.error = error;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
@@ -28,18 +28,18 @@ export class APIError extends LorikeetError {
|
|
|
28
28
|
error.message
|
|
29
29
|
: JSON.stringify(error.message)
|
|
30
30
|
: error ? JSON.stringify(error)
|
|
31
|
-
: message
|
|
31
|
+
: message;
|
|
32
32
|
|
|
33
33
|
if (status && msg) {
|
|
34
|
-
return `${status} ${msg}
|
|
34
|
+
return `${status} ${msg}`;
|
|
35
35
|
}
|
|
36
36
|
if (status) {
|
|
37
|
-
return `${status} status code (no body)
|
|
37
|
+
return `${status} status code (no body)`;
|
|
38
38
|
}
|
|
39
39
|
if (msg) {
|
|
40
|
-
return msg
|
|
40
|
+
return msg;
|
|
41
41
|
}
|
|
42
|
-
return '(no status code or body)'
|
|
42
|
+
return '(no status code or body)';
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
static generate(
|
|
@@ -49,98 +49,98 @@ export class APIError extends LorikeetError {
|
|
|
49
49
|
headers: Headers | undefined,
|
|
50
50
|
): APIError {
|
|
51
51
|
if (!status) {
|
|
52
|
-
return new APIConnectionError({ message, cause: castToError(errorResponse) })
|
|
52
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const error = errorResponse as Record<string, any
|
|
55
|
+
const error = errorResponse as Record<string, any>;
|
|
56
56
|
|
|
57
57
|
if (status === 400) {
|
|
58
|
-
return new BadRequestError(status, error, message, headers)
|
|
58
|
+
return new BadRequestError(status, error, message, headers);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (status === 401) {
|
|
62
|
-
return new AuthenticationError(status, error, message, headers)
|
|
62
|
+
return new AuthenticationError(status, error, message, headers);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (status === 403) {
|
|
66
|
-
return new PermissionDeniedError(status, error, message, headers)
|
|
66
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
if (status === 404) {
|
|
70
|
-
return new NotFoundError(status, error, message, headers)
|
|
70
|
+
return new NotFoundError(status, error, message, headers);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (status === 409) {
|
|
74
|
-
return new ConflictError(status, error, message, headers)
|
|
74
|
+
return new ConflictError(status, error, message, headers);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (status === 422) {
|
|
78
|
-
return new UnprocessableEntityError(status, error, message, headers)
|
|
78
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
if (status === 429) {
|
|
82
|
-
return new RateLimitError(status, error, message, headers)
|
|
82
|
+
return new RateLimitError(status, error, message, headers);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
if (status >= 500) {
|
|
86
|
-
return new InternalServerError(status, error, message, headers)
|
|
86
|
+
return new InternalServerError(status, error, message, headers);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
return new APIError(status, error, message, headers)
|
|
89
|
+
return new APIError(status, error, message, headers);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export class APIUserAbortError extends APIError {
|
|
94
|
-
override readonly status: undefined = undefined
|
|
94
|
+
override readonly status: undefined = undefined;
|
|
95
95
|
|
|
96
96
|
constructor({ message }: { message?: string } = {}) {
|
|
97
|
-
super(undefined, undefined, message || 'Request was aborted.', undefined)
|
|
97
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
export class APIConnectionError extends APIError {
|
|
102
|
-
override readonly status: undefined = undefined
|
|
102
|
+
override readonly status: undefined = undefined;
|
|
103
103
|
|
|
104
104
|
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
105
|
-
super(undefined, undefined, message || 'Connection error.', undefined)
|
|
105
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
106
106
|
// in some environments the 'cause' property is already declared
|
|
107
107
|
// @ts-ignore
|
|
108
|
-
if (cause) this.cause = cause
|
|
108
|
+
if (cause) this.cause = cause;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
113
113
|
constructor({ message }: { message?: string } = {}) {
|
|
114
|
-
super({ message: message ?? 'Request timed out.' })
|
|
114
|
+
super({ message: message ?? 'Request timed out.' });
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export class BadRequestError extends APIError {
|
|
119
|
-
override readonly status: 400 = 400
|
|
119
|
+
override readonly status: 400 = 400;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export class AuthenticationError extends APIError {
|
|
123
|
-
override readonly status: 401 = 401
|
|
123
|
+
override readonly status: 401 = 401;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export class PermissionDeniedError extends APIError {
|
|
127
|
-
override readonly status: 403 = 403
|
|
127
|
+
override readonly status: 403 = 403;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
export class NotFoundError extends APIError {
|
|
131
|
-
override readonly status: 404 = 404
|
|
131
|
+
override readonly status: 404 = 404;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
export class ConflictError extends APIError {
|
|
135
|
-
override readonly status: 409 = 409
|
|
135
|
+
override readonly status: 409 = 409;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
export class UnprocessableEntityError extends APIError {
|
|
139
|
-
override readonly status: 422 = 422
|
|
139
|
+
override readonly status: 422 = 422;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
export class RateLimitError extends APIError {
|
|
143
|
-
override readonly status: 429 = 429
|
|
143
|
+
override readonly status: 429 = 429;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
export class InternalServerError extends APIError {}
|
package/src/index.ts
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { type Agent } from './_shims/index'
|
|
4
|
-
import * as Core from './core'
|
|
5
|
-
import * as Errors from './error'
|
|
6
|
-
import * as Uploads from './uploads'
|
|
7
|
-
import * as API from './resources/index'
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { type Agent } from './_shims/index';
|
|
4
|
+
import * as Core from './core';
|
|
5
|
+
import * as Errors from './error';
|
|
6
|
+
import * as Uploads from './uploads';
|
|
7
|
+
import * as API from './resources/index';
|
|
8
|
+
import {
|
|
9
|
+
Customer,
|
|
10
|
+
CustomerCreateParams,
|
|
11
|
+
CustomerCreateResponse,
|
|
12
|
+
CustomerTokenParams,
|
|
13
|
+
CustomerTokenResponse,
|
|
14
|
+
} from './resources/customer';
|
|
15
|
+
import { Ingest, IngestTestParams } from './resources/ingest';
|
|
16
|
+
import { Conversation } from './resources/conversation/conversation';
|
|
12
17
|
|
|
13
18
|
export interface ClientOptions {
|
|
14
19
|
/**
|
|
15
20
|
* client identifier authentication associated with the account.
|
|
16
21
|
*/
|
|
17
|
-
clientId?: string | undefined
|
|
22
|
+
clientId?: string | undefined;
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* Secret key pulled from the Lorikeet App
|
|
21
26
|
*/
|
|
22
|
-
clientSecret?: string | undefined
|
|
27
|
+
clientSecret?: string | undefined;
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
30
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
26
31
|
*
|
|
27
32
|
* Defaults to process.env['LORIKEET_BASE_URL'].
|
|
28
33
|
*/
|
|
29
|
-
baseURL?: string | null | undefined
|
|
34
|
+
baseURL?: string | null | undefined;
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
37
|
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
@@ -35,7 +40,7 @@ export interface ClientOptions {
|
|
|
35
40
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
36
41
|
* much longer than this timeout before the promise succeeds or fails.
|
|
37
42
|
*/
|
|
38
|
-
timeout?: number
|
|
43
|
+
timeout?: number;
|
|
39
44
|
|
|
40
45
|
/**
|
|
41
46
|
* An HTTP agent used to manage HTTP(S) connections.
|
|
@@ -43,7 +48,7 @@ export interface ClientOptions {
|
|
|
43
48
|
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
44
49
|
* otherwise no agent is used.
|
|
45
50
|
*/
|
|
46
|
-
httpAgent?: Agent
|
|
51
|
+
httpAgent?: Agent;
|
|
47
52
|
|
|
48
53
|
/**
|
|
49
54
|
* Specify a custom `fetch` function implementation.
|
|
@@ -51,7 +56,7 @@ export interface ClientOptions {
|
|
|
51
56
|
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
52
57
|
* defined globally.
|
|
53
58
|
*/
|
|
54
|
-
fetch?: Core.Fetch | undefined
|
|
59
|
+
fetch?: Core.Fetch | undefined;
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
62
|
* The maximum number of times that the client will retry a request in case of a
|
|
@@ -59,7 +64,7 @@ export interface ClientOptions {
|
|
|
59
64
|
*
|
|
60
65
|
* @default 2
|
|
61
66
|
*/
|
|
62
|
-
maxRetries?: number
|
|
67
|
+
maxRetries?: number;
|
|
63
68
|
|
|
64
69
|
/**
|
|
65
70
|
* Default headers to include with every request to the API.
|
|
@@ -67,7 +72,7 @@ export interface ClientOptions {
|
|
|
67
72
|
* These can be removed in individual requests by explicitly setting the
|
|
68
73
|
* header to `undefined` or `null` in request options.
|
|
69
74
|
*/
|
|
70
|
-
defaultHeaders?: Core.Headers
|
|
75
|
+
defaultHeaders?: Core.Headers;
|
|
71
76
|
|
|
72
77
|
/**
|
|
73
78
|
* Default query parameters to include with every request to the API.
|
|
@@ -75,17 +80,17 @@ export interface ClientOptions {
|
|
|
75
80
|
* These can be removed in individual requests by explicitly setting the
|
|
76
81
|
* param to `undefined` in request options.
|
|
77
82
|
*/
|
|
78
|
-
defaultQuery?: Core.DefaultQuery
|
|
83
|
+
defaultQuery?: Core.DefaultQuery;
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
87
|
* API Client for interfacing with the Lorikeet API.
|
|
83
88
|
*/
|
|
84
89
|
export class Lorikeet extends Core.APIClient {
|
|
85
|
-
clientId: string
|
|
86
|
-
clientSecret: string
|
|
90
|
+
clientId: string;
|
|
91
|
+
clientSecret: string;
|
|
87
92
|
|
|
88
|
-
private _options: ClientOptions
|
|
93
|
+
private _options: ClientOptions;
|
|
89
94
|
|
|
90
95
|
/**
|
|
91
96
|
* API Client for interfacing with the Lorikeet API.
|
|
@@ -109,12 +114,12 @@ export class Lorikeet extends Core.APIClient {
|
|
|
109
114
|
if (clientId === undefined) {
|
|
110
115
|
throw new Errors.LorikeetError(
|
|
111
116
|
"The LORIKEET_CLIENT_ID environment variable is missing or empty; either provide it, or instantiate the Lorikeet client with an clientId option, like new Lorikeet({ clientId: 'My Client ID' }).",
|
|
112
|
-
)
|
|
117
|
+
);
|
|
113
118
|
}
|
|
114
119
|
if (clientSecret === undefined) {
|
|
115
120
|
throw new Errors.LorikeetError(
|
|
116
121
|
"The LORIKEET_CLIENT_SECRET environment variable is missing or empty; either provide it, or instantiate the Lorikeet client with an clientSecret option, like new Lorikeet({ clientSecret: 'My Client Secret' }).",
|
|
117
|
-
)
|
|
122
|
+
);
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
const options: ClientOptions = {
|
|
@@ -122,7 +127,7 @@ export class Lorikeet extends Core.APIClient {
|
|
|
122
127
|
clientSecret,
|
|
123
128
|
...opts,
|
|
124
129
|
baseURL: baseURL || `https://api.lorikeetcx.ai`,
|
|
125
|
-
}
|
|
130
|
+
};
|
|
126
131
|
|
|
127
132
|
super({
|
|
128
133
|
baseURL: options.baseURL!,
|
|
@@ -130,28 +135,27 @@ export class Lorikeet extends Core.APIClient {
|
|
|
130
135
|
httpAgent: options.httpAgent,
|
|
131
136
|
maxRetries: options.maxRetries,
|
|
132
137
|
fetch: options.fetch,
|
|
133
|
-
})
|
|
138
|
+
});
|
|
134
139
|
|
|
135
|
-
this._options = options
|
|
140
|
+
this._options = options;
|
|
136
141
|
|
|
137
|
-
this.clientId = clientId
|
|
138
|
-
this.clientSecret = clientSecret
|
|
142
|
+
this.clientId = clientId;
|
|
143
|
+
this.clientSecret = clientSecret;
|
|
139
144
|
}
|
|
140
145
|
|
|
141
|
-
conversation: API.Conversation = new API.Conversation(this)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
ingest: API.Ingest = new API.Ingest(this)
|
|
146
|
+
conversation: API.Conversation = new API.Conversation(this);
|
|
147
|
+
customer: API.Customer = new API.Customer(this);
|
|
148
|
+
ingest: API.Ingest = new API.Ingest(this);
|
|
145
149
|
|
|
146
150
|
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
147
|
-
return this._options.defaultQuery
|
|
151
|
+
return this._options.defaultQuery;
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
151
155
|
return {
|
|
152
156
|
...super.defaultHeaders(opts),
|
|
153
157
|
...this._options.defaultHeaders,
|
|
154
|
-
}
|
|
158
|
+
};
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
@@ -163,34 +167,34 @@ export class Lorikeet extends Core.APIClient {
|
|
|
163
167
|
: JSON.stringify(opts.body, null, 2)
|
|
164
168
|
: '',
|
|
165
169
|
this.clientSecret,
|
|
166
|
-
)
|
|
170
|
+
);
|
|
167
171
|
return {
|
|
168
172
|
// backwards compatibility
|
|
169
173
|
'x-optech-webhook-signature': signature,
|
|
170
174
|
'x-lorikeet-signature': signature,
|
|
171
175
|
authorization: `Bearer ${this.clientId}`,
|
|
172
|
-
}
|
|
176
|
+
};
|
|
173
177
|
}
|
|
174
178
|
|
|
175
|
-
static Lorikeet = this
|
|
176
|
-
static DEFAULT_TIMEOUT = 60000 // 1 minute
|
|
177
|
-
|
|
178
|
-
static LorikeetError = Errors.LorikeetError
|
|
179
|
-
static APIError = Errors.APIError
|
|
180
|
-
static APIConnectionError = Errors.APIConnectionError
|
|
181
|
-
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError
|
|
182
|
-
static APIUserAbortError = Errors.APIUserAbortError
|
|
183
|
-
static NotFoundError = Errors.NotFoundError
|
|
184
|
-
static ConflictError = Errors.ConflictError
|
|
185
|
-
static RateLimitError = Errors.RateLimitError
|
|
186
|
-
static BadRequestError = Errors.BadRequestError
|
|
187
|
-
static AuthenticationError = Errors.AuthenticationError
|
|
188
|
-
static InternalServerError = Errors.InternalServerError
|
|
189
|
-
static PermissionDeniedError = Errors.PermissionDeniedError
|
|
190
|
-
static UnprocessableEntityError = Errors.UnprocessableEntityError
|
|
191
|
-
|
|
192
|
-
static toFile = Uploads.toFile
|
|
193
|
-
static fileFromPath = Uploads.fileFromPath
|
|
179
|
+
static Lorikeet = this;
|
|
180
|
+
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
181
|
+
|
|
182
|
+
static LorikeetError = Errors.LorikeetError;
|
|
183
|
+
static APIError = Errors.APIError;
|
|
184
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
185
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
186
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
187
|
+
static NotFoundError = Errors.NotFoundError;
|
|
188
|
+
static ConflictError = Errors.ConflictError;
|
|
189
|
+
static RateLimitError = Errors.RateLimitError;
|
|
190
|
+
static BadRequestError = Errors.BadRequestError;
|
|
191
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
192
|
+
static InternalServerError = Errors.InternalServerError;
|
|
193
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
194
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
195
|
+
|
|
196
|
+
static toFile = Uploads.toFile;
|
|
197
|
+
static fileFromPath = Uploads.fileFromPath;
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
export {
|
|
@@ -207,35 +211,30 @@ export {
|
|
|
207
211
|
InternalServerError,
|
|
208
212
|
PermissionDeniedError,
|
|
209
213
|
UnprocessableEntityError,
|
|
210
|
-
} from './error'
|
|
214
|
+
} from './error';
|
|
211
215
|
|
|
212
|
-
export import toFile = Uploads.toFile
|
|
213
|
-
export import fileFromPath = Uploads.fileFromPath
|
|
214
|
-
import { generateSignature } from './lib/generate-signature'
|
|
216
|
+
export import toFile = Uploads.toFile;
|
|
217
|
+
export import fileFromPath = Uploads.fileFromPath;
|
|
218
|
+
import { generateSignature } from './lib/generate-signature';
|
|
215
219
|
|
|
216
|
-
Lorikeet.Conversation = Conversation
|
|
217
|
-
Lorikeet.
|
|
218
|
-
Lorikeet.
|
|
219
|
-
Lorikeet.Ingest = Ingest
|
|
220
|
+
Lorikeet.Conversation = Conversation;
|
|
221
|
+
Lorikeet.Customer = Customer;
|
|
222
|
+
Lorikeet.Ingest = Ingest;
|
|
220
223
|
|
|
221
224
|
export declare namespace Lorikeet {
|
|
222
|
-
export type RequestOptions = Core.RequestOptions
|
|
225
|
+
export type RequestOptions = Core.RequestOptions;
|
|
223
226
|
|
|
224
|
-
export { Conversation as Conversation }
|
|
225
|
-
|
|
226
|
-
export {
|
|
227
|
-
Token as Token,
|
|
228
|
-
type TokenCreateResponse as TokenCreateResponse,
|
|
229
|
-
type TokenCreateParams as TokenCreateParams,
|
|
230
|
-
}
|
|
227
|
+
export { Conversation as Conversation };
|
|
231
228
|
|
|
232
229
|
export {
|
|
233
230
|
Customer as Customer,
|
|
234
231
|
type CustomerCreateResponse as CustomerCreateResponse,
|
|
232
|
+
type CustomerTokenResponse as CustomerTokenResponse,
|
|
235
233
|
type CustomerCreateParams as CustomerCreateParams,
|
|
236
|
-
|
|
234
|
+
type CustomerTokenParams as CustomerTokenParams,
|
|
235
|
+
};
|
|
237
236
|
|
|
238
|
-
export { Ingest as Ingest, type IngestTestParams as IngestTestParams }
|
|
237
|
+
export { Ingest as Ingest, type IngestTestParams as IngestTestParams };
|
|
239
238
|
}
|
|
240
239
|
|
|
241
|
-
export default Lorikeet
|
|
240
|
+
export default Lorikeet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import crypto from 'crypto'
|
|
1
|
+
import crypto from 'crypto';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Generate a signature for a given payload using a secret key.
|
|
@@ -7,7 +7,7 @@ import crypto from 'crypto'
|
|
|
7
7
|
*/
|
|
8
8
|
export function generateSignature(payload: Buffer | string | undefined, secret: string) {
|
|
9
9
|
if (!payload) {
|
|
10
|
-
return crypto.createHmac('sha256', secret).digest('base64').replace(/\+/g, '-').replace(/\//g, '_')
|
|
10
|
+
return crypto.createHmac('sha256', secret).digest('base64').replace(/\+/g, '-').replace(/\//g, '_');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return crypto
|
|
@@ -15,5 +15,5 @@ export function generateSignature(payload: Buffer | string | undefined, secret:
|
|
|
15
15
|
.update(payload)
|
|
16
16
|
.digest('base64')
|
|
17
17
|
.replace(/\+/g, '-')
|
|
18
|
-
.replace(/\//g, '_')
|
|
18
|
+
.replace(/\//g, '_');
|
|
19
19
|
}
|
package/src/resource.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import type { Lorikeet } from './index'
|
|
3
|
+
import type { Lorikeet } from './index';
|
|
4
4
|
|
|
5
5
|
export class APIResource {
|
|
6
|
-
protected _client: Lorikeet
|
|
6
|
+
protected _client: Lorikeet;
|
|
7
7
|
|
|
8
8
|
constructor(client: Lorikeet) {
|
|
9
|
-
this._client = client
|
|
9
|
+
this._client = client;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../../resource'
|
|
4
|
-
import * as Core from '../../core'
|
|
3
|
+
import { APIResource } from '../../resource';
|
|
4
|
+
import * as Core from '../../core';
|
|
5
5
|
|
|
6
6
|
export class Chat extends APIResource {
|
|
7
7
|
generate(body: ChatGenerateParams, options?: Core.RequestOptions): Core.APIPromise<ChatGenerateResponse> {
|
|
8
|
-
return this._client.post('/v1/conversation/chat/message', { body, ...options })
|
|
8
|
+
return this._client.post('/v1/conversation/chat/message', { body, ...options });
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
get(query: ChatGetParams, options?: Core.RequestOptions): Core.APIPromise<ChatGetResponse> {
|
|
12
|
-
return this._client.get('/v1/conversation/chat/message', { query, ...options })
|
|
12
|
+
return this._client.get('/v1/conversation/chat/message', { query, ...options });
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
start(body: ChatStartParams, options?: Core.RequestOptions): Core.APIPromise<ChatStartResponse> {
|
|
16
|
-
return this._client.post('/v1/conversation/chat/create', { body, ...options })
|
|
16
|
+
return this._client.post('/v1/conversation/chat/create', { body, ...options });
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,79 +21,141 @@ export interface ChatGenerateResponse {
|
|
|
21
21
|
/**
|
|
22
22
|
* The ID of the conversation
|
|
23
23
|
*/
|
|
24
|
-
conversationId: unknown
|
|
24
|
+
conversationId: unknown;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* The timestamp of when the message was created in our system.
|
|
28
28
|
*/
|
|
29
|
-
createdAt: string
|
|
29
|
+
createdAt: string;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* The message
|
|
33
|
-
* processed.
|
|
32
|
+
* The created message. This endpoint supports markdown.
|
|
34
33
|
*/
|
|
35
|
-
message:
|
|
34
|
+
message: ChatGenerateResponse.Message;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The timestamp of when the ticket was last updated in our system.
|
|
38
|
+
*/
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export namespace ChatGenerateResponse {
|
|
43
|
+
/**
|
|
44
|
+
* The created message. This endpoint supports markdown.
|
|
45
|
+
*/
|
|
46
|
+
export interface Message {
|
|
47
|
+
/**
|
|
48
|
+
* The ID of the conversation message
|
|
49
|
+
*/
|
|
50
|
+
id: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The content of the message. Markdown on plain text.
|
|
54
|
+
*/
|
|
55
|
+
content: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The raw content of the message. Usually HTML.
|
|
59
|
+
*/
|
|
60
|
+
rawContent: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The type of the message
|
|
64
|
+
*/
|
|
65
|
+
type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
66
|
+
}
|
|
36
67
|
}
|
|
37
68
|
|
|
38
69
|
export interface ChatGetResponse {
|
|
39
70
|
/**
|
|
40
71
|
* The ID of the conversation
|
|
41
72
|
*/
|
|
42
|
-
conversationId: unknown
|
|
73
|
+
conversationId: unknown;
|
|
43
74
|
|
|
44
75
|
/**
|
|
45
76
|
* The timestamp of when the message was created in our system.
|
|
46
77
|
*/
|
|
47
|
-
createdAt: string
|
|
78
|
+
createdAt: string;
|
|
48
79
|
|
|
49
80
|
/**
|
|
50
|
-
* The message
|
|
51
|
-
* processed.
|
|
81
|
+
* The created message. This endpoint supports markdown.
|
|
52
82
|
*/
|
|
53
|
-
message:
|
|
83
|
+
message: ChatGetResponse.Message;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The timestamp of when the ticket was last updated in our system.
|
|
87
|
+
*/
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export namespace ChatGetResponse {
|
|
92
|
+
/**
|
|
93
|
+
* The created message. This endpoint supports markdown.
|
|
94
|
+
*/
|
|
95
|
+
export interface Message {
|
|
96
|
+
/**
|
|
97
|
+
* The ID of the conversation message
|
|
98
|
+
*/
|
|
99
|
+
id: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The content of the message. Markdown on plain text.
|
|
103
|
+
*/
|
|
104
|
+
content: string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The raw content of the message. Usually HTML.
|
|
108
|
+
*/
|
|
109
|
+
rawContent: string;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The type of the message
|
|
113
|
+
*/
|
|
114
|
+
type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
115
|
+
}
|
|
54
116
|
}
|
|
55
117
|
|
|
56
118
|
export interface ChatStartResponse {
|
|
57
119
|
/**
|
|
58
120
|
* The ID of the conversation
|
|
59
121
|
*/
|
|
60
|
-
conversationId: unknown
|
|
122
|
+
conversationId: unknown;
|
|
61
123
|
|
|
62
124
|
/**
|
|
63
125
|
* The timestamp of the when the conversation was created in our system.
|
|
64
126
|
*/
|
|
65
|
-
createdAt: string
|
|
127
|
+
createdAt: string;
|
|
66
128
|
}
|
|
67
129
|
|
|
68
130
|
export interface ChatGenerateParams {
|
|
69
131
|
/**
|
|
70
132
|
* The ID of the conversation
|
|
71
133
|
*/
|
|
72
|
-
conversationId: unknown
|
|
134
|
+
conversationId: unknown;
|
|
73
135
|
|
|
74
136
|
/**
|
|
75
137
|
* The message to be sent to the user. This endpoint supports markdown.
|
|
76
138
|
*/
|
|
77
|
-
message: string
|
|
139
|
+
message: string;
|
|
78
140
|
}
|
|
79
141
|
|
|
80
142
|
export interface ChatGetParams {
|
|
81
143
|
/**
|
|
82
144
|
* The ID of the conversation you need to poll.
|
|
83
145
|
*/
|
|
84
|
-
conversationId: string
|
|
146
|
+
conversationId: string;
|
|
85
147
|
}
|
|
86
148
|
|
|
87
149
|
export interface ChatStartParams {
|
|
88
150
|
/**
|
|
89
151
|
* The ID of the customer. If omitted, a new customer will be created.
|
|
90
152
|
*/
|
|
91
|
-
customerId: unknown
|
|
153
|
+
customerId: unknown;
|
|
92
154
|
|
|
93
155
|
/**
|
|
94
156
|
* The timestamp of the when the conversation was created in our system.
|
|
95
157
|
*/
|
|
96
|
-
subject?: string
|
|
158
|
+
subject?: string;
|
|
97
159
|
}
|
|
98
160
|
|
|
99
161
|
export declare namespace Chat {
|
|
@@ -104,5 +166,5 @@ export declare namespace Chat {
|
|
|
104
166
|
type ChatGenerateParams as ChatGenerateParams,
|
|
105
167
|
type ChatGetParams as ChatGetParams,
|
|
106
168
|
type ChatStartParams as ChatStartParams,
|
|
107
|
-
}
|
|
169
|
+
};
|
|
108
170
|
}
|