@memori.ai/memori-api-client 0.1.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/LICENSE +18 -0
- package/README.md +188 -0
- package/dist/apiFetcher.d.ts +13 -0
- package/dist/backend/asset.d.ts +44 -0
- package/dist/backend/integration.d.ts +55 -0
- package/dist/backend/invitation.d.ts +82 -0
- package/dist/backend/memori.d.ts +125 -0
- package/dist/backend/user.d.ts +109 -0
- package/dist/backend.d.ts +273 -0
- package/dist/constants.d.ts +2 -0
- package/dist/engine/correlationPairs.d.ts +20 -0
- package/dist/engine/dialog.d.ts +88 -0
- package/dist/engine/importExport.d.ts +34 -0
- package/dist/engine/intents.d.ts +65 -0
- package/dist/engine/localizationKeys.d.ts +50 -0
- package/dist/engine/media.d.ts +48 -0
- package/dist/engine/memori.d.ts +30 -0
- package/dist/engine/memories.d.ts +50 -0
- package/dist/engine/nlp.d.ts +25 -0
- package/dist/engine/people.d.ts +46 -0
- package/dist/engine/promptedQuestions.d.ts +37 -0
- package/dist/engine/search.d.ts +30 -0
- package/dist/engine/session.d.ts +28 -0
- package/dist/engine/stats.d.ts +25 -0
- package/dist/engine/unansweredQuestions.d.ts +22 -0
- package/dist/engine/webhooks.d.ts +21 -0
- package/dist/engine.d.ts +297 -0
- package/dist/helpers/asset.d.ts +20 -0
- package/dist/helpers/getApiUrl.d.ts +1 -0
- package/dist/index.d.ts +582 -0
- package/dist/index.js +8 -0
- package/dist/memori-api-client.cjs.development.js +3666 -0
- package/dist/memori-api-client.cjs.development.js.map +1 -0
- package/dist/memori-api-client.cjs.production.min.js +2 -0
- package/dist/memori-api-client.cjs.production.min.js.map +1 -0
- package/dist/memori-api-client.esm.js +3660 -0
- package/dist/memori-api-client.esm.js.map +1 -0
- package/dist/speech.d.ts +10 -0
- package/dist/types.d.ts +410 -0
- package/package.json +125 -0
- package/src/apiFetcher.ts +29 -0
- package/src/backend/asset.ts +86 -0
- package/src/backend/integration.ts +98 -0
- package/src/backend/invitation.ts +115 -0
- package/src/backend/memori.ts +223 -0
- package/src/backend/user.ts +186 -0
- package/src/backend.ts +20 -0
- package/src/constants.ts +21 -0
- package/src/engine/correlationPairs.ts +31 -0
- package/src/engine/dialog.ts +158 -0
- package/src/engine/importExport.ts +43 -0
- package/src/engine/intents.ts +116 -0
- package/src/engine/localizationKeys.ts +94 -0
- package/src/engine/media.ts +79 -0
- package/src/engine/memori.ts +51 -0
- package/src/engine/memories.ts +89 -0
- package/src/engine/nlp.ts +39 -0
- package/src/engine/people.ts +82 -0
- package/src/engine/promptedQuestions.ts +63 -0
- package/src/engine/search.ts +49 -0
- package/src/engine/session.ts +49 -0
- package/src/engine/stats.ts +44 -0
- package/src/engine/unansweredQuestions.ts +38 -0
- package/src/engine/webhooks.ts +32 -0
- package/src/engine.ts +51 -0
- package/src/helpers/asset.ts +52 -0
- package/src/helpers/getApiUrl.ts +6 -0
- package/src/index.ts +20 -0
- package/src/speech.ts +242 -0
- package/src/types.ts +440 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
export declare type Error = {
|
|
2
|
+
code: number;
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
export declare type ResponseSpec = {
|
|
6
|
+
requestID: string;
|
|
7
|
+
requestDateTime: string;
|
|
8
|
+
resultCode: number;
|
|
9
|
+
resultMessage: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type MemoriConfig = {
|
|
12
|
+
memoriConfigID: string;
|
|
13
|
+
useCase: string;
|
|
14
|
+
culture: string;
|
|
15
|
+
descriptions?: {
|
|
16
|
+
[lang: string]: string;
|
|
17
|
+
};
|
|
18
|
+
dialogExamples?: {
|
|
19
|
+
[lang: string]: string;
|
|
20
|
+
};
|
|
21
|
+
logoURL?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type Memori = {
|
|
24
|
+
memoriID: string;
|
|
25
|
+
name: string;
|
|
26
|
+
password?: string;
|
|
27
|
+
recoveryTokens?: string[];
|
|
28
|
+
newPassword?: string;
|
|
29
|
+
ownerUserID?: string;
|
|
30
|
+
ownerTenantName?: string;
|
|
31
|
+
memoriConfigurationID: string;
|
|
32
|
+
description: string;
|
|
33
|
+
engineMemoriID?: string;
|
|
34
|
+
isGiver?: boolean;
|
|
35
|
+
isReceiver?: boolean;
|
|
36
|
+
giverTag?: string;
|
|
37
|
+
giverPIN?: string;
|
|
38
|
+
privacyType: 'PUBLIC' | 'PRIVATE' | 'SECRET';
|
|
39
|
+
secretToken?: string;
|
|
40
|
+
minimumNumberOfRecoveryTokens?: number;
|
|
41
|
+
totalNumberOfRecoveryTokens?: number;
|
|
42
|
+
avatarURL?: string;
|
|
43
|
+
coverURL?: string;
|
|
44
|
+
needsPosition?: boolean;
|
|
45
|
+
voiceType: string;
|
|
46
|
+
culture?: string;
|
|
47
|
+
publishedInTheMetaverse?: boolean;
|
|
48
|
+
metaverseEnvironment?: string;
|
|
49
|
+
properties?: {
|
|
50
|
+
[key: string]: string;
|
|
51
|
+
};
|
|
52
|
+
creationTimestamp?: string;
|
|
53
|
+
lastChangeTimestamp?: string;
|
|
54
|
+
integrations?: Integration[];
|
|
55
|
+
sentInvitations?: Invitation[];
|
|
56
|
+
receivedInvitations?: Invitation[];
|
|
57
|
+
categories?: string[];
|
|
58
|
+
ownerUserName?: string;
|
|
59
|
+
};
|
|
60
|
+
export declare type Venue = {
|
|
61
|
+
placeName: string;
|
|
62
|
+
latitude: number;
|
|
63
|
+
longitude: number;
|
|
64
|
+
uncertainty?: number;
|
|
65
|
+
};
|
|
66
|
+
export declare type User = {
|
|
67
|
+
tenant?: string;
|
|
68
|
+
userID?: string;
|
|
69
|
+
userName?: string;
|
|
70
|
+
password?: string;
|
|
71
|
+
newPassword?: string;
|
|
72
|
+
eMail?: string;
|
|
73
|
+
admin?: boolean;
|
|
74
|
+
superAdmin?: boolean;
|
|
75
|
+
verificationCode?: string;
|
|
76
|
+
flowID?: string;
|
|
77
|
+
newsletterSubscribed?: boolean;
|
|
78
|
+
maxMemori?: number;
|
|
79
|
+
canCreateMemori?: boolean;
|
|
80
|
+
canAccessAPI?: boolean;
|
|
81
|
+
canEditIntegrations?: boolean;
|
|
82
|
+
canEditDynamicIntents?: boolean;
|
|
83
|
+
canEditMemoriChaining?: boolean;
|
|
84
|
+
maxFreeSessions?: number;
|
|
85
|
+
creationTimestamp?: string;
|
|
86
|
+
lastChangeTimestamp?: string;
|
|
87
|
+
};
|
|
88
|
+
export declare type IntegrationResource = {
|
|
89
|
+
name: string;
|
|
90
|
+
url: string;
|
|
91
|
+
};
|
|
92
|
+
export declare type IntegrationType = 'GOOGLE' | 'ALEXA' | 'LANDING_EXPERIENCE';
|
|
93
|
+
export declare type Integration = {
|
|
94
|
+
integrationID?: string;
|
|
95
|
+
memoriID?: string;
|
|
96
|
+
type: IntegrationType;
|
|
97
|
+
state?: 'NEW' | 'PROCESSING' | 'DONE' | 'REMOVED' | 'ERROR' | 'WAITING_MANUAL_ACTION' | 'DRAFT' | 'NOT_VALIDATED' | 'PUBLISHED';
|
|
98
|
+
publish?: boolean;
|
|
99
|
+
deviceEmails?: string[];
|
|
100
|
+
invocationText?: string;
|
|
101
|
+
jobID?: string;
|
|
102
|
+
customData?: string;
|
|
103
|
+
resources?: IntegrationResource[];
|
|
104
|
+
creationTimestamp?: string | Date;
|
|
105
|
+
lastChangeTimestamp?: string | Date;
|
|
106
|
+
dataResult?: {
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export declare type PublicIntegrationListItem = {
|
|
111
|
+
integration: Integration;
|
|
112
|
+
memori: Memori;
|
|
113
|
+
memoriUser: User;
|
|
114
|
+
remoteMemoriId?: string;
|
|
115
|
+
};
|
|
116
|
+
export interface RcFile extends File {
|
|
117
|
+
readonly lastModifiedDate: string | Date;
|
|
118
|
+
uid: string;
|
|
119
|
+
}
|
|
120
|
+
export declare type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
|
|
121
|
+
export interface UploadFile<T = any> {
|
|
122
|
+
uid: string;
|
|
123
|
+
size?: number;
|
|
124
|
+
name: string;
|
|
125
|
+
fileName?: string;
|
|
126
|
+
lastModified?: number;
|
|
127
|
+
lastModifiedDate?: string | Date;
|
|
128
|
+
url?: string;
|
|
129
|
+
status?: UploadFileStatus;
|
|
130
|
+
percent?: number;
|
|
131
|
+
thumbUrl?: string;
|
|
132
|
+
originFileObj?: RcFile;
|
|
133
|
+
response?: T;
|
|
134
|
+
error?: any;
|
|
135
|
+
linkProps?: any;
|
|
136
|
+
type?: string;
|
|
137
|
+
xhr?: T;
|
|
138
|
+
preview?: string;
|
|
139
|
+
}
|
|
140
|
+
export declare type TenantConfig = {
|
|
141
|
+
name: string;
|
|
142
|
+
showNewUser: boolean;
|
|
143
|
+
requirePosition: boolean;
|
|
144
|
+
feedbackURL?: string;
|
|
145
|
+
};
|
|
146
|
+
export declare type Tenant = {
|
|
147
|
+
id: string;
|
|
148
|
+
theme: string;
|
|
149
|
+
config: TenantConfig;
|
|
150
|
+
disableRegistration?: boolean;
|
|
151
|
+
maxMemoriPerAdmin?: number;
|
|
152
|
+
maxMemoriPerUser?: number;
|
|
153
|
+
maxTotalMemori?: number;
|
|
154
|
+
maxAdmins?: number;
|
|
155
|
+
maxUsers?: number;
|
|
156
|
+
usersCanCreateMemori?: boolean;
|
|
157
|
+
usersCanAccessAPI?: boolean;
|
|
158
|
+
usersCanEditIntegrations?: boolean;
|
|
159
|
+
usersCanEditDynamicIntents?: boolean;
|
|
160
|
+
usersCanEditMemoriChaining?: boolean;
|
|
161
|
+
maxFreeSessions?: number;
|
|
162
|
+
maxFreeSessionsPerUser?: number;
|
|
163
|
+
};
|
|
164
|
+
export declare type OpenSession = {
|
|
165
|
+
memoriID: string;
|
|
166
|
+
password?: string;
|
|
167
|
+
recoveryTokens?: string[];
|
|
168
|
+
tag?: string;
|
|
169
|
+
pin?: string;
|
|
170
|
+
initialContextVars?: {
|
|
171
|
+
[key: string]: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
export declare type MemoriSession = {
|
|
175
|
+
sessionID: string;
|
|
176
|
+
currentState: DialogState;
|
|
177
|
+
stats?: Stats;
|
|
178
|
+
};
|
|
179
|
+
export declare type Medium = {
|
|
180
|
+
mediumID: string;
|
|
181
|
+
url?: string;
|
|
182
|
+
content?: string;
|
|
183
|
+
mimeType: string;
|
|
184
|
+
title?: string;
|
|
185
|
+
properties?: {
|
|
186
|
+
[key: string]: string;
|
|
187
|
+
};
|
|
188
|
+
creationTimestamp?: string;
|
|
189
|
+
creationName?: string;
|
|
190
|
+
lastChangeTimestamp?: string;
|
|
191
|
+
lastChangeName?: string;
|
|
192
|
+
};
|
|
193
|
+
export declare type Stats = {
|
|
194
|
+
totalReceivers: number;
|
|
195
|
+
receiversWithMemories: number;
|
|
196
|
+
totalMemories: number;
|
|
197
|
+
publicMemories: number;
|
|
198
|
+
memoriesWithMedia: number;
|
|
199
|
+
totalQuestions: number;
|
|
200
|
+
publicQuestions: number;
|
|
201
|
+
questionsWithMoreThanOneAnswer: number;
|
|
202
|
+
totalStories: number;
|
|
203
|
+
publicStories: number;
|
|
204
|
+
storiesWithDate: number;
|
|
205
|
+
storiesWithPlace: number;
|
|
206
|
+
storiesWithDateAndPlace: number;
|
|
207
|
+
unansweredQuestions: number;
|
|
208
|
+
successfulCorrelations: number;
|
|
209
|
+
failedCorrelations: number;
|
|
210
|
+
};
|
|
211
|
+
export declare type GamificationLevel = {
|
|
212
|
+
points: number;
|
|
213
|
+
badge: string;
|
|
214
|
+
pointsForCurrentBadge: number;
|
|
215
|
+
nextBadge: {
|
|
216
|
+
points: number;
|
|
217
|
+
badge: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
export declare type EventLog = {
|
|
221
|
+
eventLogID: string;
|
|
222
|
+
timestamp: string;
|
|
223
|
+
eventType: string;
|
|
224
|
+
memoriID: string;
|
|
225
|
+
userAgent?: string;
|
|
226
|
+
ipAddress?: string;
|
|
227
|
+
memoryID?: string;
|
|
228
|
+
intentID?: string;
|
|
229
|
+
enteredText?: string;
|
|
230
|
+
receiverTag?: string;
|
|
231
|
+
};
|
|
232
|
+
export declare type UserLog = {
|
|
233
|
+
timestamp: string;
|
|
234
|
+
count: number;
|
|
235
|
+
};
|
|
236
|
+
export declare type UsersLog = {
|
|
237
|
+
timestamp: string;
|
|
238
|
+
countUsers: number;
|
|
239
|
+
countRecurrentUsers: number;
|
|
240
|
+
};
|
|
241
|
+
export declare type TranslatedHint = {
|
|
242
|
+
text: string;
|
|
243
|
+
originalText: string;
|
|
244
|
+
};
|
|
245
|
+
export declare type DialogState = {
|
|
246
|
+
state: string;
|
|
247
|
+
stateName: string;
|
|
248
|
+
previousState: string;
|
|
249
|
+
confidence?: number;
|
|
250
|
+
emission?: string;
|
|
251
|
+
acceptsTimeout?: boolean;
|
|
252
|
+
acceptsAbort?: boolean;
|
|
253
|
+
acceptsMedia?: boolean;
|
|
254
|
+
acceptsDate?: boolean;
|
|
255
|
+
acceptsPlace?: boolean;
|
|
256
|
+
acceptsTag?: boolean;
|
|
257
|
+
hints?: string[];
|
|
258
|
+
translatedHints?: TranslatedHint[];
|
|
259
|
+
currentTag?: string;
|
|
260
|
+
currentDate?: string;
|
|
261
|
+
currentPlaceName?: string;
|
|
262
|
+
currentLatitude?: number;
|
|
263
|
+
currentLongitude?: number;
|
|
264
|
+
currentUncertaintyKm?: number;
|
|
265
|
+
giverID?: string;
|
|
266
|
+
currentReceiverID?: string;
|
|
267
|
+
currentMemoryID?: string;
|
|
268
|
+
media?: Medium[];
|
|
269
|
+
knownTags?: {
|
|
270
|
+
[key: string]: string;
|
|
271
|
+
};
|
|
272
|
+
contextVars?: {
|
|
273
|
+
[key: string]: string;
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
export declare type Person = {
|
|
277
|
+
personID?: string;
|
|
278
|
+
personType: 'Giver' | 'Receiver';
|
|
279
|
+
name?: string;
|
|
280
|
+
information?: string;
|
|
281
|
+
pin: string;
|
|
282
|
+
tag: string;
|
|
283
|
+
creationTimestamp?: string;
|
|
284
|
+
creationName?: string;
|
|
285
|
+
lastChangeTimestamp?: string;
|
|
286
|
+
lastChangeName?: string;
|
|
287
|
+
};
|
|
288
|
+
export declare type PersonificationProfile = {
|
|
289
|
+
tag?: string;
|
|
290
|
+
pin?: string;
|
|
291
|
+
name?: string;
|
|
292
|
+
sessionID: string;
|
|
293
|
+
};
|
|
294
|
+
export declare type Invitation = {
|
|
295
|
+
invitationID?: string;
|
|
296
|
+
memoriID: string;
|
|
297
|
+
isInviter?: boolean;
|
|
298
|
+
isInvitee?: boolean;
|
|
299
|
+
text?: string;
|
|
300
|
+
destinationEMail: string;
|
|
301
|
+
destinationName: string;
|
|
302
|
+
tag: string;
|
|
303
|
+
pin: string;
|
|
304
|
+
type: string;
|
|
305
|
+
state?: 'PENDING' | 'ACCEPTED' | 'REJECTED';
|
|
306
|
+
creationTimestamp?: string;
|
|
307
|
+
lastChangeTimestamp?: string;
|
|
308
|
+
};
|
|
309
|
+
export declare type LocalizationKeyContent = {
|
|
310
|
+
key: string;
|
|
311
|
+
value: string;
|
|
312
|
+
};
|
|
313
|
+
export declare type LocalizationKey = LocalizationKeyContent & {
|
|
314
|
+
creationTimestamp?: string;
|
|
315
|
+
creationName?: string;
|
|
316
|
+
lastChangeTimestamp?: string;
|
|
317
|
+
lastChangeName?: string;
|
|
318
|
+
};
|
|
319
|
+
export declare type Asset = {
|
|
320
|
+
assetID: string;
|
|
321
|
+
assetURL: string;
|
|
322
|
+
mimeType: string;
|
|
323
|
+
memoriID: string;
|
|
324
|
+
originalFileName?: string;
|
|
325
|
+
title?: string;
|
|
326
|
+
engineMemoryID?: string;
|
|
327
|
+
creationTimestamp: string;
|
|
328
|
+
lastChangeTimestamp: string;
|
|
329
|
+
};
|
|
330
|
+
export declare type SearchQuery = {
|
|
331
|
+
text: string;
|
|
332
|
+
searchType?: 'Literal' | 'Semantic';
|
|
333
|
+
date?: string;
|
|
334
|
+
dateUncertaintyDays?: number;
|
|
335
|
+
placeName?: string;
|
|
336
|
+
placeLatitude?: number;
|
|
337
|
+
placeLongitude?: number;
|
|
338
|
+
placeUncertaintyKm?: number;
|
|
339
|
+
tag?: string;
|
|
340
|
+
ignoreLastRead?: boolean;
|
|
341
|
+
excludedMemoryIDs?: string[];
|
|
342
|
+
numberOfResults?: number;
|
|
343
|
+
};
|
|
344
|
+
export declare type SearchMatches = {
|
|
345
|
+
confidence: number;
|
|
346
|
+
confidenceLevel?: 'LOW' | 'MEDIUM' | 'HIGH';
|
|
347
|
+
memory: Memory;
|
|
348
|
+
};
|
|
349
|
+
export declare type Answer = {
|
|
350
|
+
text: string;
|
|
351
|
+
preformatted?: boolean;
|
|
352
|
+
creationTimestamp?: string;
|
|
353
|
+
creationName?: string;
|
|
354
|
+
lastChangeTimestamp?: string;
|
|
355
|
+
lastChangeName?: string;
|
|
356
|
+
};
|
|
357
|
+
export declare type Memory = {
|
|
358
|
+
memoryID: string;
|
|
359
|
+
memoryType: string;
|
|
360
|
+
lastRead?: string;
|
|
361
|
+
readOccurrencies?: number;
|
|
362
|
+
receiverID?: string;
|
|
363
|
+
receiverTag?: string;
|
|
364
|
+
receiverName?: string;
|
|
365
|
+
media?: Medium[];
|
|
366
|
+
text?: string;
|
|
367
|
+
textVariants?: string[];
|
|
368
|
+
answers?: Answer[];
|
|
369
|
+
title?: string;
|
|
370
|
+
titleVariants?: string[];
|
|
371
|
+
date?: string;
|
|
372
|
+
dateUncertaintyDays?: number;
|
|
373
|
+
placeName?: string;
|
|
374
|
+
placeLatitude?: number;
|
|
375
|
+
placeLongitude?: number;
|
|
376
|
+
placeUncertaintyKm?: number;
|
|
377
|
+
preformatted?: boolean;
|
|
378
|
+
conclusive?: boolean;
|
|
379
|
+
help?: boolean;
|
|
380
|
+
notPickable?: boolean;
|
|
381
|
+
contextVarsToSet?: {
|
|
382
|
+
[variable: string]: string;
|
|
383
|
+
};
|
|
384
|
+
contextVarsToMatch?: {
|
|
385
|
+
[variable: string]: string;
|
|
386
|
+
};
|
|
387
|
+
creationTimestamp?: string;
|
|
388
|
+
creationName?: string;
|
|
389
|
+
lastChangeTimestamp?: string;
|
|
390
|
+
lastChangeName?: string;
|
|
391
|
+
};
|
|
392
|
+
export declare type UnansweredQuestion = {
|
|
393
|
+
unansweredQuestionID?: string;
|
|
394
|
+
text: string;
|
|
395
|
+
occurrencies: number;
|
|
396
|
+
receiverID?: string;
|
|
397
|
+
receiverTag?: string;
|
|
398
|
+
receiverName?: string;
|
|
399
|
+
creationTimestamp?: string;
|
|
400
|
+
creationName?: string;
|
|
401
|
+
lastChangeTimestamp?: string;
|
|
402
|
+
lastChangeName?: string;
|
|
403
|
+
candidateAnswers?: SearchMatches[];
|
|
404
|
+
};
|
|
405
|
+
export declare type Message = {
|
|
406
|
+
text: string;
|
|
407
|
+
fromUser?: boolean;
|
|
408
|
+
media?: Medium[];
|
|
409
|
+
initial?: boolean;
|
|
410
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.1.0",
|
|
3
|
+
"main": "dist/index.js",
|
|
4
|
+
"typings": "dist/index.d.ts",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=14"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start": "tsdx watch",
|
|
14
|
+
"build": "tsdx build",
|
|
15
|
+
"test": "NODE_ENV=test tsdx test",
|
|
16
|
+
"test:husky": "NODE_ENV=test CI=true tsdx test --bail --colors",
|
|
17
|
+
"test:ci": "tsdx test --ci",
|
|
18
|
+
"lint": "tsdx lint",
|
|
19
|
+
"format": "prettier --write '**/*.{tsx,ts}'",
|
|
20
|
+
"typecheck": "tsc -b",
|
|
21
|
+
"prepare": "tsdx build; is-ci || husky install",
|
|
22
|
+
"size": "size-limit",
|
|
23
|
+
"analyze": "size-limit --why",
|
|
24
|
+
"prerelase": "tsdx build",
|
|
25
|
+
"release": "release-it"
|
|
26
|
+
},
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"homepage": "https://github.com/memori-ai/memori-api-client#readme",
|
|
29
|
+
"bugs": "https://github.com/memori-ai/memori-api-client/issues",
|
|
30
|
+
"repository": "https://github.com/memori-ai/memori-api-client.git",
|
|
31
|
+
"keywords": [
|
|
32
|
+
"memori",
|
|
33
|
+
"memori-ai",
|
|
34
|
+
"conversational-ai",
|
|
35
|
+
"api-client",
|
|
36
|
+
"api-wrapper"
|
|
37
|
+
],
|
|
38
|
+
"peerDependencies": {},
|
|
39
|
+
"husky": {
|
|
40
|
+
"hooks": {
|
|
41
|
+
"pre-commit": "tsdx lint"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"prettier": {
|
|
45
|
+
"printWidth": 80,
|
|
46
|
+
"semi": true,
|
|
47
|
+
"singleQuote": true,
|
|
48
|
+
"endOfLine": "lf",
|
|
49
|
+
"trailingComma": "es5"
|
|
50
|
+
},
|
|
51
|
+
"name": "@memori.ai/memori-api-client",
|
|
52
|
+
"author": "Memori Srl",
|
|
53
|
+
"module": "dist/memori-api-client.esm.js",
|
|
54
|
+
"size-limit": [
|
|
55
|
+
{
|
|
56
|
+
"path": "dist/memori-api-client.cjs.production.min.js",
|
|
57
|
+
"limit": "10 KB"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "dist/memori-api-client.esm.js",
|
|
61
|
+
"limit": "10 KB"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"release-it": {
|
|
65
|
+
"git": {
|
|
66
|
+
"tagName": "v${version}",
|
|
67
|
+
"commitMessage": "chore: release v${version}"
|
|
68
|
+
},
|
|
69
|
+
"npm": {
|
|
70
|
+
"publish": true,
|
|
71
|
+
"skipChecks": true
|
|
72
|
+
},
|
|
73
|
+
"github": {
|
|
74
|
+
"release": true,
|
|
75
|
+
"releaseName": "${version}"
|
|
76
|
+
},
|
|
77
|
+
"plugins": {
|
|
78
|
+
"@release-it/conventional-changelog": {
|
|
79
|
+
"infile": "CHANGELOG.md",
|
|
80
|
+
"preset": {
|
|
81
|
+
"name": "conventionalcommits",
|
|
82
|
+
"types": [
|
|
83
|
+
{
|
|
84
|
+
"type": "feat",
|
|
85
|
+
"section": "Features"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "fix",
|
|
89
|
+
"section": "Bug Fixes"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "refactor",
|
|
93
|
+
"section": "Changes"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "chore",
|
|
97
|
+
"section": "Maintenance"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"publishConfig": {
|
|
105
|
+
"access": "public",
|
|
106
|
+
"registry": "https://registry.npmjs.org/"
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@commitlint/cli": "17.0.3",
|
|
110
|
+
"@commitlint/config-conventional": "17.0.3",
|
|
111
|
+
"@release-it/conventional-changelog": "5.0.0",
|
|
112
|
+
"@size-limit/preset-small-lib": "7.0.8",
|
|
113
|
+
"husky": "8.0.1",
|
|
114
|
+
"is-ci": "3.0.1",
|
|
115
|
+
"release-it": "15.1.1",
|
|
116
|
+
"size-limit": "7.0.8",
|
|
117
|
+
"tsdx": "0.14.1",
|
|
118
|
+
"tslib": "2.4.0",
|
|
119
|
+
"typescript": "4.7.4"
|
|
120
|
+
},
|
|
121
|
+
"dependencies": {
|
|
122
|
+
"cross-fetch": "^3.1.5",
|
|
123
|
+
"microsoft-cognitiveservices-speech-sdk": "1.22.0"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as fetch } from 'cross-fetch';
|
|
2
|
+
|
|
3
|
+
export const fetcher = (
|
|
4
|
+
path: string,
|
|
5
|
+
opts: {
|
|
6
|
+
apiUrl: string;
|
|
7
|
+
method?: string;
|
|
8
|
+
body?: object;
|
|
9
|
+
headers?: object;
|
|
10
|
+
}
|
|
11
|
+
) =>
|
|
12
|
+
fetch(`${opts.apiUrl}${path}`, {
|
|
13
|
+
...opts,
|
|
14
|
+
body: opts?.body ? JSON.stringify(opts.body) : undefined,
|
|
15
|
+
mode: 'cors',
|
|
16
|
+
credentials: 'include',
|
|
17
|
+
headers: {
|
|
18
|
+
// "Access-Control-Allow-Origin": "*",
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
...opts?.headers,
|
|
21
|
+
},
|
|
22
|
+
}).then(res => res.json());
|
|
23
|
+
|
|
24
|
+
export const devFetcher = (data: any) => Promise.resolve(data);
|
|
25
|
+
|
|
26
|
+
export const apiFetcher =
|
|
27
|
+
process.env.CI === 'true' || process.env.NODE_ENV === 'test'
|
|
28
|
+
? devFetcher
|
|
29
|
+
: fetcher;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ResponseSpec, Asset } from '../types';
|
|
2
|
+
import { apiFetcher } from '../apiFetcher';
|
|
3
|
+
|
|
4
|
+
export default (apiUrl: string) => ({
|
|
5
|
+
/**
|
|
6
|
+
* URL to upload a file creating a new Asset object to access it.
|
|
7
|
+
* @param {string} authToken - The login token
|
|
8
|
+
* @param {string} memoriID - The memori ID
|
|
9
|
+
* @param {string=} memoryID - The memory ID
|
|
10
|
+
* @returns The URL to upload a file
|
|
11
|
+
*/
|
|
12
|
+
getUploadAssetURL: (authToken: string, memoriID: string, memoryID?: string) =>
|
|
13
|
+
`${apiUrl}/Asset/${authToken}/${memoriID}${memoryID ? `/${memoryID}` : ''}`,
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Uploads a file and creates a new Asset object to access it.
|
|
17
|
+
* @param {string} authToken - The login token
|
|
18
|
+
* @param {string} memoriID - The memori ID
|
|
19
|
+
* @param {string=} memoryID - The memory ID
|
|
20
|
+
* @returns Response of an Upload Asset request.
|
|
21
|
+
*/
|
|
22
|
+
uploadAsset: async (
|
|
23
|
+
fileName: string,
|
|
24
|
+
fileUrl: string,
|
|
25
|
+
authToken: string,
|
|
26
|
+
memoriID: string,
|
|
27
|
+
memoryID?: string
|
|
28
|
+
) => {
|
|
29
|
+
const data = new FormData();
|
|
30
|
+
const file = await fetch(fileUrl);
|
|
31
|
+
const fileBlob = await file.blob();
|
|
32
|
+
|
|
33
|
+
data.append(fileName, fileBlob, fileName);
|
|
34
|
+
|
|
35
|
+
const upload = await fetch(
|
|
36
|
+
`${apiUrl}/Asset/${authToken}/${memoriID}${
|
|
37
|
+
memoryID ? `/${memoryID}` : ''
|
|
38
|
+
}`,
|
|
39
|
+
{
|
|
40
|
+
method: 'POST',
|
|
41
|
+
body: data,
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
return (await upload.json()) as Promise<
|
|
45
|
+
ResponseSpec & {
|
|
46
|
+
asset: Asset;
|
|
47
|
+
}
|
|
48
|
+
>;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Downloads a file from an Asset object
|
|
53
|
+
* @param {string} fileName - The file name
|
|
54
|
+
* @param {string} sessionID - The session ID
|
|
55
|
+
* @returns The asset file
|
|
56
|
+
*/
|
|
57
|
+
getAsset: (fileName: string, sessionID: string) =>
|
|
58
|
+
apiFetcher(`/Asset/${fileName}/${sessionID}`, {
|
|
59
|
+
apiUrl,
|
|
60
|
+
method: 'GET',
|
|
61
|
+
}),
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Updates an Asset object
|
|
65
|
+
* @param {string} authToken - The login token
|
|
66
|
+
* @param {string} assetURL - The asset URL
|
|
67
|
+
* @returns The updated asset object
|
|
68
|
+
*/
|
|
69
|
+
updateAsset: (authToken: string, assetURL: string, asset: Asset) =>
|
|
70
|
+
apiFetcher(`/Asset/${authToken}/${assetURL.split('/').reverse()[0]}`, {
|
|
71
|
+
apiUrl,
|
|
72
|
+
method: 'PATCH',
|
|
73
|
+
body: asset,
|
|
74
|
+
}) as Promise<ResponseSpec & { asset: Asset }>,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Deletes an Asset object
|
|
78
|
+
* @param {string} authToken - The login token
|
|
79
|
+
* @param {string} assetURL - The asset URL
|
|
80
|
+
*/
|
|
81
|
+
deleteAsset: (authToken: string, assetURL: string) =>
|
|
82
|
+
apiFetcher(`/Asset/${authToken}/${assetURL.split('/').reverse()[0]}`, {
|
|
83
|
+
apiUrl,
|
|
84
|
+
method: 'DELETE',
|
|
85
|
+
}) as Promise<ResponseSpec>,
|
|
86
|
+
});
|