@lorikeetai/node-sdk 0.1.0 → 0.2.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 +22 -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.ts.map +1 -1
- package/index.js.map +1 -1
- 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.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/index.d.ts.map +1 -1
- package/resources/index.js.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/resources/token.d.ts.map +1 -1
- package/resources/token.js.map +1 -1
- package/resources/token.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 +69 -69
- package/src/lib/generate-signature.ts +3 -3
- package/src/resource.ts +3 -3
- package/src/resources/conversation/chat.ts +19 -19
- 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/index.ts +4 -4
- package/src/resources/ingest.ts +7 -7
- package/src/resources/token.ts +9 -9
- 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/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,32 @@
|
|
|
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 { Customer, CustomerCreateParams, CustomerCreateResponse } from './resources/customer'
|
|
9
|
-
import { Ingest, IngestTestParams } from './resources/ingest'
|
|
10
|
-
import { Token, TokenCreateParams, TokenCreateResponse } from './resources/token'
|
|
11
|
-
import { Conversation } from './resources/conversation/conversation'
|
|
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 { Customer, CustomerCreateParams, CustomerCreateResponse } from './resources/customer';
|
|
9
|
+
import { Ingest, IngestTestParams } from './resources/ingest';
|
|
10
|
+
import { Token, TokenCreateParams, TokenCreateResponse } from './resources/token';
|
|
11
|
+
import { Conversation } from './resources/conversation/conversation';
|
|
12
12
|
|
|
13
13
|
export interface ClientOptions {
|
|
14
14
|
/**
|
|
15
15
|
* client identifier authentication associated with the account.
|
|
16
16
|
*/
|
|
17
|
-
clientId?: string | undefined
|
|
17
|
+
clientId?: string | undefined;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Secret key pulled from the Lorikeet App
|
|
21
21
|
*/
|
|
22
|
-
clientSecret?: string | undefined
|
|
22
|
+
clientSecret?: string | undefined;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
26
26
|
*
|
|
27
27
|
* Defaults to process.env['LORIKEET_BASE_URL'].
|
|
28
28
|
*/
|
|
29
|
-
baseURL?: string | null | undefined
|
|
29
|
+
baseURL?: string | null | undefined;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
@@ -35,7 +35,7 @@ export interface ClientOptions {
|
|
|
35
35
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
36
36
|
* much longer than this timeout before the promise succeeds or fails.
|
|
37
37
|
*/
|
|
38
|
-
timeout?: number
|
|
38
|
+
timeout?: number;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* An HTTP agent used to manage HTTP(S) connections.
|
|
@@ -43,7 +43,7 @@ export interface ClientOptions {
|
|
|
43
43
|
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
44
44
|
* otherwise no agent is used.
|
|
45
45
|
*/
|
|
46
|
-
httpAgent?: Agent
|
|
46
|
+
httpAgent?: Agent;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Specify a custom `fetch` function implementation.
|
|
@@ -51,7 +51,7 @@ export interface ClientOptions {
|
|
|
51
51
|
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
52
52
|
* defined globally.
|
|
53
53
|
*/
|
|
54
|
-
fetch?: Core.Fetch | undefined
|
|
54
|
+
fetch?: Core.Fetch | undefined;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* The maximum number of times that the client will retry a request in case of a
|
|
@@ -59,7 +59,7 @@ export interface ClientOptions {
|
|
|
59
59
|
*
|
|
60
60
|
* @default 2
|
|
61
61
|
*/
|
|
62
|
-
maxRetries?: number
|
|
62
|
+
maxRetries?: number;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Default headers to include with every request to the API.
|
|
@@ -67,7 +67,7 @@ export interface ClientOptions {
|
|
|
67
67
|
* These can be removed in individual requests by explicitly setting the
|
|
68
68
|
* header to `undefined` or `null` in request options.
|
|
69
69
|
*/
|
|
70
|
-
defaultHeaders?: Core.Headers
|
|
70
|
+
defaultHeaders?: Core.Headers;
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Default query parameters to include with every request to the API.
|
|
@@ -75,17 +75,17 @@ export interface ClientOptions {
|
|
|
75
75
|
* These can be removed in individual requests by explicitly setting the
|
|
76
76
|
* param to `undefined` in request options.
|
|
77
77
|
*/
|
|
78
|
-
defaultQuery?: Core.DefaultQuery
|
|
78
|
+
defaultQuery?: Core.DefaultQuery;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* API Client for interfacing with the Lorikeet API.
|
|
83
83
|
*/
|
|
84
84
|
export class Lorikeet extends Core.APIClient {
|
|
85
|
-
clientId: string
|
|
86
|
-
clientSecret: string
|
|
85
|
+
clientId: string;
|
|
86
|
+
clientSecret: string;
|
|
87
87
|
|
|
88
|
-
private _options: ClientOptions
|
|
88
|
+
private _options: ClientOptions;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* API Client for interfacing with the Lorikeet API.
|
|
@@ -109,12 +109,12 @@ export class Lorikeet extends Core.APIClient {
|
|
|
109
109
|
if (clientId === undefined) {
|
|
110
110
|
throw new Errors.LorikeetError(
|
|
111
111
|
"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
|
-
)
|
|
112
|
+
);
|
|
113
113
|
}
|
|
114
114
|
if (clientSecret === undefined) {
|
|
115
115
|
throw new Errors.LorikeetError(
|
|
116
116
|
"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
|
-
)
|
|
117
|
+
);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
const options: ClientOptions = {
|
|
@@ -122,7 +122,7 @@ export class Lorikeet extends Core.APIClient {
|
|
|
122
122
|
clientSecret,
|
|
123
123
|
...opts,
|
|
124
124
|
baseURL: baseURL || `https://api.lorikeetcx.ai`,
|
|
125
|
-
}
|
|
125
|
+
};
|
|
126
126
|
|
|
127
127
|
super({
|
|
128
128
|
baseURL: options.baseURL!,
|
|
@@ -130,28 +130,28 @@ export class Lorikeet extends Core.APIClient {
|
|
|
130
130
|
httpAgent: options.httpAgent,
|
|
131
131
|
maxRetries: options.maxRetries,
|
|
132
132
|
fetch: options.fetch,
|
|
133
|
-
})
|
|
133
|
+
});
|
|
134
134
|
|
|
135
|
-
this._options = options
|
|
135
|
+
this._options = options;
|
|
136
136
|
|
|
137
|
-
this.clientId = clientId
|
|
138
|
-
this.clientSecret = clientSecret
|
|
137
|
+
this.clientId = clientId;
|
|
138
|
+
this.clientSecret = clientSecret;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
conversation: API.Conversation = new API.Conversation(this)
|
|
142
|
-
token: API.Token = new API.Token(this)
|
|
143
|
-
customer: API.Customer = new API.Customer(this)
|
|
144
|
-
ingest: API.Ingest = new API.Ingest(this)
|
|
141
|
+
conversation: API.Conversation = new API.Conversation(this);
|
|
142
|
+
token: API.Token = new API.Token(this);
|
|
143
|
+
customer: API.Customer = new API.Customer(this);
|
|
144
|
+
ingest: API.Ingest = new API.Ingest(this);
|
|
145
145
|
|
|
146
146
|
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
147
|
-
return this._options.defaultQuery
|
|
147
|
+
return this._options.defaultQuery;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
151
151
|
return {
|
|
152
152
|
...super.defaultHeaders(opts),
|
|
153
153
|
...this._options.defaultHeaders,
|
|
154
|
-
}
|
|
154
|
+
};
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
@@ -163,34 +163,34 @@ export class Lorikeet extends Core.APIClient {
|
|
|
163
163
|
: JSON.stringify(opts.body, null, 2)
|
|
164
164
|
: '',
|
|
165
165
|
this.clientSecret,
|
|
166
|
-
)
|
|
166
|
+
);
|
|
167
167
|
return {
|
|
168
168
|
// backwards compatibility
|
|
169
169
|
'x-optech-webhook-signature': signature,
|
|
170
170
|
'x-lorikeet-signature': signature,
|
|
171
171
|
authorization: `Bearer ${this.clientId}`,
|
|
172
|
-
}
|
|
172
|
+
};
|
|
173
173
|
}
|
|
174
174
|
|
|
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
|
|
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;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
export {
|
|
@@ -207,35 +207,35 @@ export {
|
|
|
207
207
|
InternalServerError,
|
|
208
208
|
PermissionDeniedError,
|
|
209
209
|
UnprocessableEntityError,
|
|
210
|
-
} from './error'
|
|
210
|
+
} from './error';
|
|
211
211
|
|
|
212
|
-
export import toFile = Uploads.toFile
|
|
213
|
-
export import fileFromPath = Uploads.fileFromPath
|
|
214
|
-
import { generateSignature } from './lib/generate-signature'
|
|
212
|
+
export import toFile = Uploads.toFile;
|
|
213
|
+
export import fileFromPath = Uploads.fileFromPath;
|
|
214
|
+
import { generateSignature } from './lib/generate-signature';
|
|
215
215
|
|
|
216
|
-
Lorikeet.Conversation = Conversation
|
|
217
|
-
Lorikeet.Token = Token
|
|
218
|
-
Lorikeet.Customer = Customer
|
|
219
|
-
Lorikeet.Ingest = Ingest
|
|
216
|
+
Lorikeet.Conversation = Conversation;
|
|
217
|
+
Lorikeet.Token = Token;
|
|
218
|
+
Lorikeet.Customer = Customer;
|
|
219
|
+
Lorikeet.Ingest = Ingest;
|
|
220
220
|
|
|
221
221
|
export declare namespace Lorikeet {
|
|
222
|
-
export type RequestOptions = Core.RequestOptions
|
|
222
|
+
export type RequestOptions = Core.RequestOptions;
|
|
223
223
|
|
|
224
|
-
export { Conversation as Conversation }
|
|
224
|
+
export { Conversation as Conversation };
|
|
225
225
|
|
|
226
226
|
export {
|
|
227
227
|
Token as Token,
|
|
228
228
|
type TokenCreateResponse as TokenCreateResponse,
|
|
229
229
|
type TokenCreateParams as TokenCreateParams,
|
|
230
|
-
}
|
|
230
|
+
};
|
|
231
231
|
|
|
232
232
|
export {
|
|
233
233
|
Customer as Customer,
|
|
234
234
|
type CustomerCreateResponse as CustomerCreateResponse,
|
|
235
235
|
type CustomerCreateParams as CustomerCreateParams,
|
|
236
|
-
}
|
|
236
|
+
};
|
|
237
237
|
|
|
238
|
-
export { Ingest as Ingest, type IngestTestParams as IngestTestParams }
|
|
238
|
+
export { Ingest as Ingest, type IngestTestParams as IngestTestParams };
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
export default Lorikeet
|
|
241
|
+
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,79 @@ 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
32
|
* The message to be sent back to the user. If empty, the message is still being
|
|
33
33
|
* processed.
|
|
34
34
|
*/
|
|
35
|
-
message: string
|
|
35
|
+
message: string;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface ChatGetResponse {
|
|
39
39
|
/**
|
|
40
40
|
* The ID of the conversation
|
|
41
41
|
*/
|
|
42
|
-
conversationId: unknown
|
|
42
|
+
conversationId: unknown;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* The timestamp of when the message was created in our system.
|
|
46
46
|
*/
|
|
47
|
-
createdAt: string
|
|
47
|
+
createdAt: string;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* The message to be sent back to the user. If empty, the message is still being
|
|
51
51
|
* processed.
|
|
52
52
|
*/
|
|
53
|
-
message: string
|
|
53
|
+
message: string;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export interface ChatStartResponse {
|
|
57
57
|
/**
|
|
58
58
|
* The ID of the conversation
|
|
59
59
|
*/
|
|
60
|
-
conversationId: unknown
|
|
60
|
+
conversationId: unknown;
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* The timestamp of the when the conversation was created in our system.
|
|
64
64
|
*/
|
|
65
|
-
createdAt: string
|
|
65
|
+
createdAt: string;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface ChatGenerateParams {
|
|
69
69
|
/**
|
|
70
70
|
* The ID of the conversation
|
|
71
71
|
*/
|
|
72
|
-
conversationId: unknown
|
|
72
|
+
conversationId: unknown;
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* The message to be sent to the user. This endpoint supports markdown.
|
|
76
76
|
*/
|
|
77
|
-
message: string
|
|
77
|
+
message: string;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export interface ChatGetParams {
|
|
81
81
|
/**
|
|
82
82
|
* The ID of the conversation you need to poll.
|
|
83
83
|
*/
|
|
84
|
-
conversationId: string
|
|
84
|
+
conversationId: string;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export interface ChatStartParams {
|
|
88
88
|
/**
|
|
89
89
|
* The ID of the customer. If omitted, a new customer will be created.
|
|
90
90
|
*/
|
|
91
|
-
customerId: unknown
|
|
91
|
+
customerId: unknown;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* The timestamp of the when the conversation was created in our system.
|
|
95
95
|
*/
|
|
96
|
-
subject?: string
|
|
96
|
+
subject?: string;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export declare namespace Chat {
|
|
@@ -104,5 +104,5 @@ export declare namespace Chat {
|
|
|
104
104
|
type ChatGenerateParams as ChatGenerateParams,
|
|
105
105
|
type ChatGetParams as ChatGetParams,
|
|
106
106
|
type ChatStartParams as ChatStartParams,
|
|
107
|
-
}
|
|
107
|
+
};
|
|
108
108
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
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 ChatAPI from './chat'
|
|
3
|
+
import { APIResource } from '../../resource';
|
|
4
|
+
import * as ChatAPI from './chat';
|
|
5
5
|
import {
|
|
6
6
|
Chat,
|
|
7
7
|
ChatGenerateParams,
|
|
@@ -10,24 +10,24 @@ import {
|
|
|
10
10
|
ChatGetResponse,
|
|
11
11
|
ChatStartParams,
|
|
12
12
|
ChatStartResponse,
|
|
13
|
-
} from './chat'
|
|
14
|
-
import * as EmailAPI from './email'
|
|
15
|
-
import { Email, EmailStartParams, EmailStartResponse } from './email'
|
|
13
|
+
} from './chat';
|
|
14
|
+
import * as EmailAPI from './email';
|
|
15
|
+
import { Email, EmailStartParams, EmailStartResponse } from './email';
|
|
16
16
|
|
|
17
17
|
export class Conversation extends APIResource {
|
|
18
|
-
email: EmailAPI.Email = new EmailAPI.Email(this._client)
|
|
19
|
-
chat: ChatAPI.Chat = new ChatAPI.Chat(this._client)
|
|
18
|
+
email: EmailAPI.Email = new EmailAPI.Email(this._client);
|
|
19
|
+
chat: ChatAPI.Chat = new ChatAPI.Chat(this._client);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
Conversation.Email = Email
|
|
23
|
-
Conversation.Chat = Chat
|
|
22
|
+
Conversation.Email = Email;
|
|
23
|
+
Conversation.Chat = Chat;
|
|
24
24
|
|
|
25
25
|
export declare namespace Conversation {
|
|
26
26
|
export {
|
|
27
27
|
Email as Email,
|
|
28
28
|
type EmailStartResponse as EmailStartResponse,
|
|
29
29
|
type EmailStartParams as EmailStartParams,
|
|
30
|
-
}
|
|
30
|
+
};
|
|
31
31
|
|
|
32
32
|
export {
|
|
33
33
|
Chat as Chat,
|
|
@@ -37,5 +37,5 @@ export declare namespace Conversation {
|
|
|
37
37
|
type ChatGenerateParams as ChatGenerateParams,
|
|
38
38
|
type ChatGetParams as ChatGetParams,
|
|
39
39
|
type ChatStartParams as ChatStartParams,
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
}
|