@lorikeetai/node-sdk 0.1.0-alpha.2 → 0.1.0-alpha.6
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 +50 -0
- package/README.md +26 -21
- 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 +1 -2
- 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 +1 -2
- 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 +2 -2
- 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 +1 -2
- 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 +2 -4
- package/core.d.ts.map +1 -1
- package/core.js +7 -6
- package/core.js.map +1 -1
- package/core.mjs +2 -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 +1 -6
- package/index.d.ts +1 -6
- package/index.d.ts.map +1 -1
- package/index.js +4 -14
- package/index.js.map +1 -1
- package/index.mjs +3 -13
- package/index.mjs.map +1 -1
- package/internal/qs/formats.d.ts.map +1 -1
- package/internal/qs/formats.js.map +1 -1
- package/internal/qs/formats.mjs.map +1 -1
- package/internal/qs/index.d.ts.map +1 -1
- package/internal/qs/index.js.map +1 -1
- package/internal/qs/index.mjs.map +1 -1
- package/internal/qs/stringify.d.ts.map +1 -1
- package/internal/qs/stringify.js +1 -2
- package/internal/qs/stringify.js.map +1 -1
- package/internal/qs/stringify.mjs.map +1 -1
- package/internal/qs/types.d.ts.map +1 -1
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/qs/utils.js +9 -9
- package/internal/qs/utils.js.map +1 -1
- package/internal/qs/utils.mjs.map +1 -1
- package/lib/generate-signature.d.ts +5 -0
- package/lib/generate-signature.d.ts.map +1 -0
- package/lib/generate-signature.js +19 -0
- package/lib/generate-signature.js.map +1 -0
- package/lib/generate-signature.mjs +13 -0
- package/lib/generate-signature.mjs.map +1 -0
- package/package.json +15 -13
- 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 +60 -30
- package/resources/conversation/chat.d.ts.map +1 -1
- package/resources/conversation/chat.js +6 -15
- package/resources/conversation/chat.js.map +1 -1
- package/resources/conversation/chat.mjs +5 -14
- package/resources/conversation/chat.mjs.map +1 -1
- package/resources/conversation/conversation.d.ts +3 -1
- package/resources/conversation/conversation.d.ts.map +1 -1
- package/resources/conversation/conversation.js +1 -1
- package/resources/conversation/conversation.js.map +1 -1
- package/resources/conversation/conversation.mjs.map +1 -1
- package/resources/conversation/index.d.ts +1 -1
- package/resources/conversation/index.d.ts.map +1 -1
- package/resources/conversation/index.js +3 -3
- package/resources/conversation/index.js.map +1 -1
- package/resources/conversation/index.mjs +1 -1
- package/resources/conversation/index.mjs.map +1 -1
- package/resources/conversation.d.ts.map +1 -1
- package/resources/conversation.js.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/ingest.d.ts +1 -34
- package/resources/ingest.d.ts.map +1 -1
- package/resources/ingest.js +2 -15
- package/resources/ingest.js.map +1 -1
- package/resources/ingest.mjs +2 -15
- package/resources/ingest.mjs.map +1 -1
- package/resources/token.d.ts +1 -5
- package/resources/token.d.ts.map +1 -1
- package/resources/token.js +2 -7
- package/resources/token.js.map +1 -1
- package/resources/token.mjs +1 -6
- package/resources/token.mjs.map +1 -1
- package/shims/node.d.ts +0 -4
- package/shims/node.d.ts.map +1 -1
- package/shims/node.js +0 -25
- package/shims/node.js.map +1 -1
- package/shims/node.mjs +0 -1
- package/shims/node.mjs.map +1 -1
- package/shims/web.d.ts.map +1 -1
- package/shims/web.js +0 -25
- package/shims/web.js.map +1 -1
- package/shims/web.mjs +0 -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 +373 -373
- package/src/error.ts +37 -37
- package/src/index.ts +60 -78
- package/src/internal/qs/formats.ts +5 -5
- package/src/internal/qs/index.ts +5 -5
- package/src/internal/qs/stringify.ts +98 -98
- package/src/internal/qs/types.ts +52 -52
- package/src/internal/qs/utils.ts +87 -87
- package/src/lib/generate-signature.ts +13 -0
- package/src/resource.ts +3 -3
- package/src/resources/conversation/chat.ts +79 -48
- package/src/resources/conversation/conversation.ts +10 -8
- package/src/resources/conversation/index.ts +10 -2
- package/src/resources/conversation.ts +1 -1
- package/src/resources/index.ts +3 -3
- package/src/resources/ingest.ts +5 -55
- package/src/resources/token.ts +10 -15
- package/src/shims/node.ts +24 -24
- package/src/shims/web.ts +24 -24
- package/src/uploads.ts +75 -74
- package/src/version.ts +1 -1
- package/uploads.d.ts +2 -2
- package/uploads.d.ts.map +1 -1
- package/uploads.js +3 -4
- package/uploads.js.map +1 -1
- package/uploads.mjs +1 -2
- 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/pets.d.ts +0 -157
- package/resources/pets.d.ts.map +0 -1
- package/resources/pets.js +0 -75
- package/resources/pets.js.map +0 -1
- package/resources/pets.mjs +0 -71
- package/resources/pets.mjs.map +0 -1
- package/resources/shared.d.ts +0 -12
- package/resources/shared.d.ts.map +0 -1
- package/resources/shared.js +0 -4
- package/resources/shared.js.map +0 -1
- package/resources/shared.mjs +0 -3
- package/resources/shared.mjs.map +0 -1
- package/resources/store/index.d.ts +0 -3
- package/resources/store/index.d.ts.map +0 -1
- package/resources/store/index.js +0 -9
- package/resources/store/index.js.map +0 -1
- package/resources/store/index.mjs +0 -4
- package/resources/store/index.mjs.map +0 -1
- package/resources/store/order.d.ts +0 -16
- package/resources/store/order.d.ts.map +0 -1
- package/resources/store/order.js +0 -26
- package/resources/store/order.js.map +0 -1
- package/resources/store/order.mjs +0 -22
- package/resources/store/order.mjs.map +0 -1
- package/resources/store/store.d.ts +0 -35
- package/resources/store/store.d.ts.map +0 -1
- package/resources/store/store.js +0 -53
- package/resources/store/store.js.map +0 -1
- package/resources/store/store.mjs +0 -26
- package/resources/store/store.mjs.map +0 -1
- package/resources/user.d.ts +0 -96
- package/resources/user.d.ts.map +0 -1
- package/resources/user.js +0 -65
- package/resources/user.js.map +0 -1
- package/resources/user.mjs +0 -61
- package/resources/user.mjs.map +0 -1
- package/src/resources/pets.ts +0 -276
- package/src/resources/shared.ts +0 -18
- package/src/resources/store/index.ts +0 -4
- package/src/resources/store/order.ts +0 -26
- package/src/resources/store/store.ts +0 -59
- package/src/resources/user.ts +0 -185
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
|
) {
|
|
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,28 +1,29 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import * as Errors from './error'
|
|
4
|
-
import * as Uploads from './uploads'
|
|
5
|
-
import { type Agent } from './_shims/index'
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
3
|
+
import * as Errors from './error'
|
|
4
|
+
import * as Uploads from './uploads'
|
|
5
|
+
import { type Agent } from './_shims/index'
|
|
6
|
+
import * as qs from './internal/qs'
|
|
7
|
+
import * as Core from './core'
|
|
8
|
+
import * as API from './resources/index'
|
|
8
9
|
|
|
9
10
|
export interface ClientOptions {
|
|
10
11
|
/**
|
|
11
12
|
* client identifier authentication associated with the account.
|
|
12
13
|
*/
|
|
13
|
-
clientId?: string | undefined
|
|
14
|
+
clientId?: string | undefined
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Secret key pulled from the Lorikeet App
|
|
17
18
|
*/
|
|
18
|
-
clientSecret?: string | undefined
|
|
19
|
+
clientSecret?: string | undefined
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
22
23
|
*
|
|
23
24
|
* Defaults to process.env['LORIKEET_BASE_URL'].
|
|
24
25
|
*/
|
|
25
|
-
baseURL?: string | null | undefined
|
|
26
|
+
baseURL?: string | null | undefined
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
@@ -31,7 +32,7 @@ export interface ClientOptions {
|
|
|
31
32
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
32
33
|
* much longer than this timeout before the promise succeeds or fails.
|
|
33
34
|
*/
|
|
34
|
-
timeout?: number
|
|
35
|
+
timeout?: number
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* An HTTP agent used to manage HTTP(S) connections.
|
|
@@ -39,7 +40,7 @@ export interface ClientOptions {
|
|
|
39
40
|
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
40
41
|
* otherwise no agent is used.
|
|
41
42
|
*/
|
|
42
|
-
httpAgent?: Agent
|
|
43
|
+
httpAgent?: Agent
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* Specify a custom `fetch` function implementation.
|
|
@@ -47,7 +48,7 @@ export interface ClientOptions {
|
|
|
47
48
|
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
48
49
|
* defined globally.
|
|
49
50
|
*/
|
|
50
|
-
fetch?: Core.Fetch | undefined
|
|
51
|
+
fetch?: Core.Fetch | undefined
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
54
|
* The maximum number of times that the client will retry a request in case of a
|
|
@@ -55,7 +56,7 @@ export interface ClientOptions {
|
|
|
55
56
|
*
|
|
56
57
|
* @default 2
|
|
57
58
|
*/
|
|
58
|
-
maxRetries?: number
|
|
59
|
+
maxRetries?: number
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* Default headers to include with every request to the API.
|
|
@@ -63,7 +64,7 @@ export interface ClientOptions {
|
|
|
63
64
|
* These can be removed in individual requests by explicitly setting the
|
|
64
65
|
* header to `undefined` or `null` in request options.
|
|
65
66
|
*/
|
|
66
|
-
defaultHeaders?: Core.Headers
|
|
67
|
+
defaultHeaders?: Core.Headers
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
70
|
* Default query parameters to include with every request to the API.
|
|
@@ -71,17 +72,17 @@ export interface ClientOptions {
|
|
|
71
72
|
* These can be removed in individual requests by explicitly setting the
|
|
72
73
|
* param to `undefined` in request options.
|
|
73
74
|
*/
|
|
74
|
-
defaultQuery?: Core.DefaultQuery
|
|
75
|
+
defaultQuery?: Core.DefaultQuery
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/**
|
|
78
79
|
* API Client for interfacing with the Lorikeet API.
|
|
79
80
|
*/
|
|
80
81
|
export class Lorikeet extends Core.APIClient {
|
|
81
|
-
clientId: string
|
|
82
|
-
clientSecret: string
|
|
82
|
+
clientId: string
|
|
83
|
+
clientSecret: string
|
|
83
84
|
|
|
84
|
-
private _options: ClientOptions
|
|
85
|
+
private _options: ClientOptions
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
88
|
* API Client for interfacing with the Lorikeet API.
|
|
@@ -105,12 +106,12 @@ export class Lorikeet extends Core.APIClient {
|
|
|
105
106
|
if (clientId === undefined) {
|
|
106
107
|
throw new Errors.LorikeetError(
|
|
107
108
|
"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' }).",
|
|
108
|
-
)
|
|
109
|
+
)
|
|
109
110
|
}
|
|
110
111
|
if (clientSecret === undefined) {
|
|
111
112
|
throw new Errors.LorikeetError(
|
|
112
113
|
"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' }).",
|
|
113
|
-
)
|
|
114
|
+
)
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
const options: ClientOptions = {
|
|
@@ -118,7 +119,7 @@ export class Lorikeet extends Core.APIClient {
|
|
|
118
119
|
clientSecret,
|
|
119
120
|
...opts,
|
|
120
121
|
baseURL: baseURL || `http://api.lorikeetcx.ai`,
|
|
121
|
-
}
|
|
122
|
+
}
|
|
122
123
|
|
|
123
124
|
super({
|
|
124
125
|
baseURL: options.baseURL!,
|
|
@@ -126,71 +127,56 @@ export class Lorikeet extends Core.APIClient {
|
|
|
126
127
|
httpAgent: options.httpAgent,
|
|
127
128
|
maxRetries: options.maxRetries,
|
|
128
129
|
fetch: options.fetch,
|
|
129
|
-
})
|
|
130
|
+
})
|
|
130
131
|
|
|
131
|
-
this._options = options
|
|
132
|
+
this._options = options
|
|
132
133
|
|
|
133
|
-
this.clientId = clientId
|
|
134
|
-
this.clientSecret = clientSecret
|
|
134
|
+
this.clientId = clientId
|
|
135
|
+
this.clientSecret = clientSecret
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
conversation: API.Conversation = new API.Conversation(this)
|
|
138
|
-
token: API.Token = new API.Token(this)
|
|
139
|
-
ingest: API.Ingest = new API.Ingest(this)
|
|
138
|
+
conversation: API.Conversation = new API.Conversation(this)
|
|
139
|
+
token: API.Token = new API.Token(this)
|
|
140
|
+
ingest: API.Ingest = new API.Ingest(this)
|
|
140
141
|
|
|
141
142
|
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
142
|
-
return this._options.defaultQuery
|
|
143
|
+
return this._options.defaultQuery
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
146
147
|
return {
|
|
147
148
|
...super.defaultHeaders(opts),
|
|
148
149
|
...this._options.defaultHeaders,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
153
|
-
const lorikeetClientIdAuth = this.lorikeetClientIdAuth(opts);
|
|
154
|
-
const lorikeetSignatureAuthV1Auth = this.lorikeetSignatureAuthV1Auth(opts);
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
lorikeetClientIdAuth != null &&
|
|
158
|
-
!Core.isEmptyObj(lorikeetClientIdAuth) &&
|
|
159
|
-
lorikeetSignatureAuthV1Auth != null &&
|
|
160
|
-
!Core.isEmptyObj(lorikeetSignatureAuthV1Auth)
|
|
161
|
-
) {
|
|
162
|
-
return { ...lorikeetClientIdAuth, ...lorikeetSignatureAuthV1Auth };
|
|
163
150
|
}
|
|
164
|
-
return {};
|
|
165
151
|
}
|
|
166
152
|
|
|
167
|
-
protected
|
|
168
|
-
return { Authorization: `Bearer ${this.clientId}` }
|
|
153
|
+
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
154
|
+
return { Authorization: `Bearer ${this.clientId}` }
|
|
169
155
|
}
|
|
170
156
|
|
|
171
|
-
protected
|
|
172
|
-
return { '
|
|
157
|
+
protected override stringifyQuery(query: Record<string, unknown>): string {
|
|
158
|
+
return qs.stringify(query, { arrayFormat: 'comma' })
|
|
173
159
|
}
|
|
174
160
|
|
|
175
|
-
static Lorikeet = this
|
|
176
|
-
static DEFAULT_TIMEOUT = 60000
|
|
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
|
|
161
|
+
static Lorikeet = this
|
|
162
|
+
static DEFAULT_TIMEOUT = 60000 // 1 minute
|
|
163
|
+
|
|
164
|
+
static LorikeetError = Errors.LorikeetError
|
|
165
|
+
static APIError = Errors.APIError
|
|
166
|
+
static APIConnectionError = Errors.APIConnectionError
|
|
167
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError
|
|
168
|
+
static APIUserAbortError = Errors.APIUserAbortError
|
|
169
|
+
static NotFoundError = Errors.NotFoundError
|
|
170
|
+
static ConflictError = Errors.ConflictError
|
|
171
|
+
static RateLimitError = Errors.RateLimitError
|
|
172
|
+
static BadRequestError = Errors.BadRequestError
|
|
173
|
+
static AuthenticationError = Errors.AuthenticationError
|
|
174
|
+
static InternalServerError = Errors.InternalServerError
|
|
175
|
+
static PermissionDeniedError = Errors.PermissionDeniedError
|
|
176
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError
|
|
177
|
+
|
|
178
|
+
static toFile = Uploads.toFile
|
|
179
|
+
static fileFromPath = Uploads.fileFromPath
|
|
194
180
|
}
|
|
195
181
|
|
|
196
182
|
export const {
|
|
@@ -207,23 +193,19 @@ export const {
|
|
|
207
193
|
InternalServerError,
|
|
208
194
|
PermissionDeniedError,
|
|
209
195
|
UnprocessableEntityError,
|
|
210
|
-
} = Errors
|
|
196
|
+
} = Errors
|
|
211
197
|
|
|
212
|
-
export import toFile = Uploads.toFile
|
|
213
|
-
export import fileFromPath = Uploads.fileFromPath
|
|
198
|
+
export import toFile = Uploads.toFile
|
|
199
|
+
export import fileFromPath = Uploads.fileFromPath
|
|
214
200
|
|
|
215
201
|
export namespace Lorikeet {
|
|
216
|
-
export import RequestOptions = Core.RequestOptions
|
|
202
|
+
export import RequestOptions = Core.RequestOptions
|
|
217
203
|
|
|
218
|
-
export import Conversation = API.Conversation
|
|
204
|
+
export import Conversation = API.Conversation
|
|
219
205
|
|
|
220
|
-
export import Token = API.Token
|
|
221
|
-
export import TokenCreateParams = API.TokenCreateParams;
|
|
206
|
+
export import Token = API.Token
|
|
222
207
|
|
|
223
|
-
export import Ingest = API.Ingest
|
|
224
|
-
export import IngestValidateResponse = API.IngestValidateResponse;
|
|
225
|
-
export import IngestValidateParams = API.IngestValidateParams;
|
|
226
|
-
export import IngestWebhooksParams = API.IngestWebhooksParams;
|
|
208
|
+
export import Ingest = API.Ingest
|
|
227
209
|
}
|
|
228
210
|
|
|
229
|
-
export default Lorikeet
|
|
211
|
+
export default Lorikeet
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Format } from './types'
|
|
1
|
+
import type { Format } from './types'
|
|
2
2
|
|
|
3
|
-
export const default_format: Format = 'RFC3986'
|
|
3
|
+
export const default_format: Format = 'RFC3986'
|
|
4
4
|
export const formatters: Record<Format, (str: PropertyKey) => string> = {
|
|
5
5
|
RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
|
|
6
6
|
RFC3986: (v: PropertyKey) => String(v),
|
|
7
|
-
}
|
|
8
|
-
export const RFC1738 = 'RFC1738'
|
|
9
|
-
export const RFC3986 = 'RFC3986'
|
|
7
|
+
}
|
|
8
|
+
export const RFC1738 = 'RFC1738'
|
|
9
|
+
export const RFC3986 = 'RFC3986'
|
package/src/internal/qs/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { default_format, formatters, RFC1738, RFC3986 } from './formats'
|
|
1
|
+
import { default_format, formatters, RFC1738, RFC3986 } from './formats'
|
|
2
2
|
|
|
3
3
|
const formats = {
|
|
4
4
|
formatters,
|
|
5
5
|
RFC1738,
|
|
6
6
|
RFC3986,
|
|
7
7
|
default: default_format,
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
export { stringify } from './stringify'
|
|
11
|
-
export { formats }
|
|
10
|
+
export { stringify } from './stringify'
|
|
11
|
+
export { formats }
|
|
12
12
|
|
|
13
|
-
export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types'
|
|
13
|
+
export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types'
|