@lorikeetai/node-sdk 0.1.0-alpha.1
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 +18 -0
- package/LICENSE +201 -0
- package/README.md +288 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +242 -0
- package/core.d.ts.map +1 -0
- package/core.js +903 -0
- package/core.js.map +1 -0
- package/core.mjs +871 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +53 -0
- package/error.d.ts.map +1 -0
- package/error.js +143 -0
- package/error.js.map +1 -0
- package/error.mjs +127 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +128 -0
- package/index.d.ts +128 -0
- package/index.d.ts.map +1 -0
- package/index.js +146 -0
- package/index.js.map +1 -0
- package/index.mjs +118 -0
- package/index.mjs.map +1 -0
- package/internal/qs/formats.d.ts +6 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +11 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +8 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +280 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +276 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.ts +14 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +229 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/package.json +103 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +11 -0
- package/resource.js.map +1 -0
- package/resource.mjs +7 -0
- package/resource.mjs.map +1 -0
- package/resources/conversation.d.ts +45 -0
- package/resources/conversation.d.ts.map +1 -0
- package/resources/conversation.js +23 -0
- package/resources/conversation.js.map +1 -0
- package/resources/conversation.mjs +19 -0
- package/resources/conversation.mjs.map +1 -0
- package/resources/index.d.ts +3 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +9 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -0
- package/resources/ingest.d.ts +58 -0
- package/resources/ingest.d.ts.map +1 -0
- package/resources/ingest.js +38 -0
- package/resources/ingest.js.map +1 -0
- package/resources/ingest.mjs +34 -0
- package/resources/ingest.mjs.map +1 -0
- package/resources/pets.d.ts +157 -0
- package/resources/pets.d.ts.map +1 -0
- package/resources/pets.js +75 -0
- package/resources/pets.js.map +1 -0
- package/resources/pets.mjs +71 -0
- package/resources/pets.mjs.map +1 -0
- package/resources/shared.d.ts +12 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +4 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +3 -0
- package/resources/shared.mjs.map +1 -0
- package/resources/store/index.d.ts +3 -0
- package/resources/store/index.d.ts.map +1 -0
- package/resources/store/index.js +9 -0
- package/resources/store/index.js.map +1 -0
- package/resources/store/index.mjs +4 -0
- package/resources/store/index.mjs.map +1 -0
- package/resources/store/order.d.ts +16 -0
- package/resources/store/order.d.ts.map +1 -0
- package/resources/store/order.js +26 -0
- package/resources/store/order.js.map +1 -0
- package/resources/store/order.mjs +22 -0
- package/resources/store/order.mjs.map +1 -0
- package/resources/store/store.d.ts +35 -0
- package/resources/store/store.d.ts.map +1 -0
- package/resources/store/store.js +53 -0
- package/resources/store/store.js.map +1 -0
- package/resources/store/store.mjs +26 -0
- package/resources/store/store.mjs.map +1 -0
- package/resources/user.d.ts +96 -0
- package/resources/user.d.ts.map +1 -0
- package/resources/user.js +65 -0
- package/resources/user.js.map +1 -0
- package/resources/user.mjs +61 -0
- package/resources/user.mjs.map +1 -0
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1196 -0
- package/src/error.ts +146 -0
- package/src/index.ts +243 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +9 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +388 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +11 -0
- package/src/resources/conversation.ts +62 -0
- package/src/resources/index.ts +15 -0
- package/src/resources/ingest.ts +92 -0
- package/src/resources/pets.ts +276 -0
- package/src/resources/shared.ts +18 -0
- package/src/resources/store/index.ts +4 -0
- package/src/resources/store/order.ts +26 -0
- package/src/resources/store/store.ts +59 -0
- package/src/resources/user.ts +185 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +255 -0
- package/src/version.ts +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +171 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +158 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { RFC1738 } from './formats';
|
|
2
|
+
import type { DefaultEncoder, Format } from './types';
|
|
3
|
+
|
|
4
|
+
const has = Object.prototype.hasOwnProperty;
|
|
5
|
+
const is_array = Array.isArray;
|
|
6
|
+
|
|
7
|
+
const hex_table = (() => {
|
|
8
|
+
const array = [];
|
|
9
|
+
for (let i = 0; i < 256; ++i) {
|
|
10
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return array;
|
|
14
|
+
})();
|
|
15
|
+
|
|
16
|
+
function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
|
|
17
|
+
while (queue.length > 1) {
|
|
18
|
+
const item = queue.pop();
|
|
19
|
+
if (!item) continue;
|
|
20
|
+
|
|
21
|
+
const obj = item.obj[item.prop];
|
|
22
|
+
|
|
23
|
+
if (is_array(obj)) {
|
|
24
|
+
const compacted: unknown[] = [];
|
|
25
|
+
|
|
26
|
+
for (let j = 0; j < obj.length; ++j) {
|
|
27
|
+
if (typeof obj[j] !== 'undefined') {
|
|
28
|
+
compacted.push(obj[j]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
item.obj[item.prop] = compacted;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function array_to_object(source: any[], options: { plainObjects: boolean }) {
|
|
39
|
+
const obj = options && options.plainObjects ? Object.create(null) : {};
|
|
40
|
+
for (let i = 0; i < source.length; ++i) {
|
|
41
|
+
if (typeof source[i] !== 'undefined') {
|
|
42
|
+
obj[i] = source[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function merge(
|
|
50
|
+
target: any,
|
|
51
|
+
source: any,
|
|
52
|
+
options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
|
|
53
|
+
) {
|
|
54
|
+
if (!source) {
|
|
55
|
+
return target;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (typeof source !== 'object') {
|
|
59
|
+
if (is_array(target)) {
|
|
60
|
+
target.push(source);
|
|
61
|
+
} else if (target && typeof target === 'object') {
|
|
62
|
+
if (
|
|
63
|
+
(options && (options.plainObjects || options.allowPrototypes)) ||
|
|
64
|
+
!has.call(Object.prototype, source)
|
|
65
|
+
) {
|
|
66
|
+
target[source] = true;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
return [target, source];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!target || typeof target !== 'object') {
|
|
76
|
+
return [target].concat(source);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let mergeTarget = target;
|
|
80
|
+
if (is_array(target) && !is_array(source)) {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
mergeTarget = array_to_object(target, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (is_array(target) && is_array(source)) {
|
|
86
|
+
source.forEach(function (item, i) {
|
|
87
|
+
if (has.call(target, i)) {
|
|
88
|
+
const targetItem = target[i];
|
|
89
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
90
|
+
target[i] = merge(targetItem, item, options);
|
|
91
|
+
} else {
|
|
92
|
+
target.push(item);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
target[i] = item;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
102
|
+
const value = source[key];
|
|
103
|
+
|
|
104
|
+
if (has.call(acc, key)) {
|
|
105
|
+
acc[key] = merge(acc[key], value, options);
|
|
106
|
+
} else {
|
|
107
|
+
acc[key] = value;
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
}, mergeTarget);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function assign_single_source(target: any, source: any) {
|
|
114
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
115
|
+
acc[key] = source[key];
|
|
116
|
+
return acc;
|
|
117
|
+
}, target);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function decode(str: string, _: any, charset: string) {
|
|
121
|
+
const strWithoutPlus = str.replace(/\+/g, ' ');
|
|
122
|
+
if (charset === 'iso-8859-1') {
|
|
123
|
+
// unescape never throws, no try...catch needed:
|
|
124
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
125
|
+
}
|
|
126
|
+
// utf-8
|
|
127
|
+
try {
|
|
128
|
+
return decodeURIComponent(strWithoutPlus);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return strWithoutPlus;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const limit = 1024;
|
|
135
|
+
|
|
136
|
+
export const encode: (
|
|
137
|
+
str: any,
|
|
138
|
+
defaultEncoder: DefaultEncoder,
|
|
139
|
+
charset: string,
|
|
140
|
+
type: 'key' | 'value',
|
|
141
|
+
format: Format,
|
|
142
|
+
) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
|
|
143
|
+
// This code was originally written by Brian White for the io.js core querystring library.
|
|
144
|
+
// It has been adapted here for stricter adherence to RFC 3986
|
|
145
|
+
if (str.length === 0) {
|
|
146
|
+
return str;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let string = str;
|
|
150
|
+
if (typeof str === 'symbol') {
|
|
151
|
+
string = Symbol.prototype.toString.call(str);
|
|
152
|
+
} else if (typeof str !== 'string') {
|
|
153
|
+
string = String(str);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (charset === 'iso-8859-1') {
|
|
157
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
158
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let out = '';
|
|
163
|
+
for (let j = 0; j < string.length; j += limit) {
|
|
164
|
+
const segment = string.length >= limit ? string.slice(j, j + limit) : string;
|
|
165
|
+
const arr = [];
|
|
166
|
+
|
|
167
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
168
|
+
let c = segment.charCodeAt(i);
|
|
169
|
+
if (
|
|
170
|
+
c === 0x2d || // -
|
|
171
|
+
c === 0x2e || // .
|
|
172
|
+
c === 0x5f || // _
|
|
173
|
+
c === 0x7e || // ~
|
|
174
|
+
(c >= 0x30 && c <= 0x39) || // 0-9
|
|
175
|
+
(c >= 0x41 && c <= 0x5a) || // a-z
|
|
176
|
+
(c >= 0x61 && c <= 0x7a) || // A-Z
|
|
177
|
+
(format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
|
|
178
|
+
) {
|
|
179
|
+
arr[arr.length] = segment.charAt(i);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (c < 0x80) {
|
|
184
|
+
arr[arr.length] = hex_table[c];
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (c < 0x800) {
|
|
189
|
+
arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (c < 0xd800 || c >= 0xe000) {
|
|
194
|
+
arr[arr.length] =
|
|
195
|
+
hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
i += 1;
|
|
200
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
201
|
+
|
|
202
|
+
arr[arr.length] =
|
|
203
|
+
hex_table[0xf0 | (c >> 18)]! +
|
|
204
|
+
hex_table[0x80 | ((c >> 12) & 0x3f)] +
|
|
205
|
+
hex_table[0x80 | ((c >> 6) & 0x3f)] +
|
|
206
|
+
hex_table[0x80 | (c & 0x3f)];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
out += arr.join('');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return out;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export function compact(value: any) {
|
|
216
|
+
const queue = [{ obj: { o: value }, prop: 'o' }];
|
|
217
|
+
const refs = [];
|
|
218
|
+
|
|
219
|
+
for (let i = 0; i < queue.length; ++i) {
|
|
220
|
+
const item = queue[i];
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
const obj = item.obj[item.prop];
|
|
223
|
+
|
|
224
|
+
const keys = Object.keys(obj);
|
|
225
|
+
for (let j = 0; j < keys.length; ++j) {
|
|
226
|
+
const key = keys[j]!;
|
|
227
|
+
const val = obj[key];
|
|
228
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
229
|
+
queue.push({ obj: obj, prop: key });
|
|
230
|
+
refs.push(val);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
compact_queue(queue);
|
|
236
|
+
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function is_regexp(obj: any) {
|
|
241
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function is_buffer(obj: any) {
|
|
245
|
+
if (!obj || typeof obj !== 'object') {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function combine(a: any, b: any) {
|
|
253
|
+
return [].concat(a, b);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function maybe_map<T>(val: T[], fn: (v: T) => T) {
|
|
257
|
+
if (is_array(val)) {
|
|
258
|
+
const mapped = [];
|
|
259
|
+
for (let i = 0; i < val.length; i += 1) {
|
|
260
|
+
mapped.push(fn(val[i]!));
|
|
261
|
+
}
|
|
262
|
+
return mapped;
|
|
263
|
+
}
|
|
264
|
+
return fn(val);
|
|
265
|
+
}
|
package/src/lib/.keep
ADDED
package/src/resource.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import type { Lorikeet } from './index';
|
|
4
|
+
|
|
5
|
+
export class APIResource {
|
|
6
|
+
protected _client: Lorikeet;
|
|
7
|
+
|
|
8
|
+
constructor(client: Lorikeet) {
|
|
9
|
+
this._client = client;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as ConversationAPI from './conversation';
|
|
6
|
+
|
|
7
|
+
export class Conversation extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Adds a message to an existing conversation using the conversation ID.
|
|
10
|
+
*/
|
|
11
|
+
message(
|
|
12
|
+
conversationId: string,
|
|
13
|
+
body: ConversationMessageParams,
|
|
14
|
+
options?: Core.RequestOptions,
|
|
15
|
+
): Core.APIPromise<ConversationMessageResponse> {
|
|
16
|
+
return this._client.post(`/conversation/${conversationId}/message`, { body, ...options });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generates a new conversation ID.
|
|
21
|
+
*/
|
|
22
|
+
start(options?: Core.RequestOptions): Core.APIPromise<ConversationStartResponse> {
|
|
23
|
+
return this._client.post('/conversation/start', options);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ConversationMessageResponse {
|
|
28
|
+
/**
|
|
29
|
+
* The ID of the conversation the message was added to.
|
|
30
|
+
*/
|
|
31
|
+
conversationId?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The content of the message.
|
|
35
|
+
*/
|
|
36
|
+
message?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The unique identifier of the added message.
|
|
40
|
+
*/
|
|
41
|
+
messageId?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ConversationStartResponse {
|
|
45
|
+
/**
|
|
46
|
+
* The unique identifier of the created conversation.
|
|
47
|
+
*/
|
|
48
|
+
conversationId?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ConversationMessageParams {
|
|
52
|
+
/**
|
|
53
|
+
* The message text to add to the conversation.
|
|
54
|
+
*/
|
|
55
|
+
message?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export namespace Conversation {
|
|
59
|
+
export import ConversationMessageResponse = ConversationAPI.ConversationMessageResponse;
|
|
60
|
+
export import ConversationStartResponse = ConversationAPI.ConversationStartResponse;
|
|
61
|
+
export import ConversationMessageParams = ConversationAPI.ConversationMessageParams;
|
|
62
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
ConversationMessageResponse,
|
|
5
|
+
ConversationStartResponse,
|
|
6
|
+
ConversationMessageParams,
|
|
7
|
+
Conversation,
|
|
8
|
+
} from './conversation';
|
|
9
|
+
export {
|
|
10
|
+
IngestValidateResponse,
|
|
11
|
+
IngestReturnWebhookParams,
|
|
12
|
+
IngestTokenParams,
|
|
13
|
+
IngestValidateParams,
|
|
14
|
+
Ingest,
|
|
15
|
+
} from './ingest';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as IngestAPI from './ingest';
|
|
6
|
+
|
|
7
|
+
export class Ingest extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* The URL to post a return webhook request to. This URL will be generated by
|
|
10
|
+
* Lorikeet and sent as a payload to your webhook.
|
|
11
|
+
*/
|
|
12
|
+
returnWebhook(
|
|
13
|
+
toolId: string,
|
|
14
|
+
ticketId: string,
|
|
15
|
+
body: IngestReturnWebhookParams,
|
|
16
|
+
options?: Core.RequestOptions,
|
|
17
|
+
): Core.APIPromise<void> {
|
|
18
|
+
return this._client.post(`/ingest/${toolId}/${ticketId}`, {
|
|
19
|
+
body,
|
|
20
|
+
...options,
|
|
21
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a signed JWT that can be associated with a user account.
|
|
27
|
+
*/
|
|
28
|
+
token(body: IngestTokenParams, options?: Core.RequestOptions): Core.APIPromise<void> {
|
|
29
|
+
return this._client.post('/ingest/token', {
|
|
30
|
+
body,
|
|
31
|
+
...options,
|
|
32
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Validate your webhook is configured correctly.
|
|
38
|
+
*/
|
|
39
|
+
validate(
|
|
40
|
+
body: IngestValidateParams,
|
|
41
|
+
options?: Core.RequestOptions,
|
|
42
|
+
): Core.APIPromise<IngestValidateResponse> {
|
|
43
|
+
return this._client.post('/ingest/validate', { body, ...options });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface IngestValidateResponse {
|
|
48
|
+
code?: 200;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The return data for the tool request.
|
|
52
|
+
*/
|
|
53
|
+
data?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IngestReturnWebhookParams {
|
|
57
|
+
/**
|
|
58
|
+
* The return data for the tool request.
|
|
59
|
+
*/
|
|
60
|
+
data: unknown;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface IngestTokenParams {
|
|
64
|
+
/**
|
|
65
|
+
* The email of the user.
|
|
66
|
+
*/
|
|
67
|
+
email: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The first name of the user.
|
|
71
|
+
*/
|
|
72
|
+
firstName: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The last name of the user.
|
|
76
|
+
*/
|
|
77
|
+
lastName: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface IngestValidateParams {
|
|
81
|
+
/**
|
|
82
|
+
* The return data for the tool request.
|
|
83
|
+
*/
|
|
84
|
+
data: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export namespace Ingest {
|
|
88
|
+
export import IngestValidateResponse = IngestAPI.IngestValidateResponse;
|
|
89
|
+
export import IngestReturnWebhookParams = IngestAPI.IngestReturnWebhookParams;
|
|
90
|
+
export import IngestTokenParams = IngestAPI.IngestTokenParams;
|
|
91
|
+
export import IngestValidateParams = IngestAPI.IngestValidateParams;
|
|
92
|
+
}
|