librechat-data-provider 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/schemas.ts CHANGED
@@ -8,8 +8,107 @@ export enum EModelEndpoint {
8
8
  google = 'google',
9
9
  gptPlugins = 'gptPlugins',
10
10
  anthropic = 'anthropic',
11
+ assistant = 'assistant',
11
12
  }
12
13
 
14
+ export const defaultEndpoints: EModelEndpoint[] = [
15
+ EModelEndpoint.openAI,
16
+ EModelEndpoint.assistant,
17
+ EModelEndpoint.azureOpenAI,
18
+ EModelEndpoint.bingAI,
19
+ EModelEndpoint.chatGPTBrowser,
20
+ EModelEndpoint.gptPlugins,
21
+ EModelEndpoint.google,
22
+ EModelEndpoint.anthropic,
23
+ ];
24
+
25
+ export const alternateName = {
26
+ [EModelEndpoint.openAI]: 'OpenAI',
27
+ [EModelEndpoint.assistant]: 'Assistants',
28
+ [EModelEndpoint.azureOpenAI]: 'Azure OpenAI',
29
+ [EModelEndpoint.bingAI]: 'Bing',
30
+ [EModelEndpoint.chatGPTBrowser]: 'ChatGPT',
31
+ [EModelEndpoint.gptPlugins]: 'Plugins',
32
+ [EModelEndpoint.google]: 'Google',
33
+ [EModelEndpoint.anthropic]: 'Anthropic',
34
+ };
35
+
36
+ export const endpointSettings = {
37
+ [EModelEndpoint.google]: {
38
+ model: {
39
+ default: 'chat-bison',
40
+ },
41
+ maxOutputTokens: {
42
+ min: 1,
43
+ max: 2048,
44
+ step: 1,
45
+ default: 1024,
46
+ },
47
+ temperature: {
48
+ min: 0,
49
+ max: 1,
50
+ step: 0.01,
51
+ default: 0.2,
52
+ },
53
+ topP: {
54
+ min: 0,
55
+ max: 1,
56
+ step: 0.01,
57
+ default: 0.8,
58
+ },
59
+ topK: {
60
+ min: 1,
61
+ max: 40,
62
+ step: 0.01,
63
+ default: 40,
64
+ },
65
+ },
66
+ };
67
+
68
+ const google = endpointSettings[EModelEndpoint.google];
69
+
70
+ export const EndpointURLs: { [key in EModelEndpoint]: string } = {
71
+ [EModelEndpoint.azureOpenAI]: '/api/ask/azureOpenAI',
72
+ [EModelEndpoint.openAI]: '/api/ask/openAI',
73
+ [EModelEndpoint.bingAI]: '/api/ask/bingAI',
74
+ [EModelEndpoint.chatGPTBrowser]: '/api/ask/chatGPTBrowser',
75
+ [EModelEndpoint.google]: '/api/ask/google',
76
+ [EModelEndpoint.gptPlugins]: '/api/ask/gptPlugins',
77
+ [EModelEndpoint.anthropic]: '/api/ask/anthropic',
78
+ [EModelEndpoint.assistant]: '/api/assistants/chat',
79
+ };
80
+
81
+ export const modularEndpoints = new Set<EModelEndpoint | string>([
82
+ EModelEndpoint.gptPlugins,
83
+ EModelEndpoint.anthropic,
84
+ EModelEndpoint.google,
85
+ EModelEndpoint.openAI,
86
+ ]);
87
+
88
+ export const supportsFiles = {
89
+ [EModelEndpoint.openAI]: true,
90
+ [EModelEndpoint.assistant]: true,
91
+ };
92
+
93
+ export const openAIModels = [
94
+ 'gpt-3.5-turbo-16k-0613',
95
+ 'gpt-3.5-turbo-16k',
96
+ 'gpt-4-1106-preview',
97
+ 'gpt-3.5-turbo',
98
+ 'gpt-3.5-turbo-1106',
99
+ 'gpt-4-vision-preview',
100
+ 'gpt-4',
101
+ 'gpt-3.5-turbo-instruct-0914',
102
+ 'gpt-3.5-turbo-0613',
103
+ 'gpt-3.5-turbo-0301',
104
+ 'gpt-3.5-turbo-instruct',
105
+ 'gpt-4-0613',
106
+ 'text-davinci-003',
107
+ 'gpt-4-0314',
108
+ ];
109
+
110
+ export const visionModels = ['gpt-4-vision', 'llava-13b'];
111
+
13
112
  export const eModelEndpointSchema = z.nativeEnum(EModelEndpoint);
14
113
 
15
114
  export const tPluginAuthConfigSchema = z.object({
@@ -99,6 +198,15 @@ export type TMessage = z.input<typeof tMessageSchema> & {
99
198
  children?: TMessage[];
100
199
  plugin?: TResPlugin | null;
101
200
  plugins?: TResPlugin[];
201
+ files?: {
202
+ type: string;
203
+ file_id: string;
204
+ filename?: string;
205
+ preview?: string;
206
+ filepath?: string;
207
+ height?: number;
208
+ width?: number;
209
+ }[];
102
210
  };
103
211
 
104
212
  export const tConversationSchema = z.object({
@@ -134,6 +242,9 @@ export const tConversationSchema = z.object({
134
242
  toneStyle: z.string().nullable().optional(),
135
243
  maxOutputTokens: z.number().optional(),
136
244
  agentOptions: tAgentOptionsSchema.nullable().optional(),
245
+ /* assistant */
246
+ assistant_id: z.string().optional(),
247
+ thread_id: z.string().optional(),
137
248
  });
138
249
 
139
250
  export type TConversation = z.infer<typeof tConversationSchema>;
@@ -150,6 +261,8 @@ export const tPresetSchema = tConversationSchema
150
261
  conversationId: z.string().optional(),
151
262
  presetId: z.string().nullable().optional(),
152
263
  title: z.string().nullable().optional(),
264
+ defaultPreset: z.boolean().optional(),
265
+ order: z.number().optional(),
153
266
  }),
154
267
  );
155
268
 
@@ -198,22 +311,24 @@ export const googleSchema = tConversationSchema
198
311
  })
199
312
  .transform((obj) => ({
200
313
  ...obj,
201
- model: obj.model ?? 'chat-bison',
314
+ model: obj.model ?? google.model.default,
202
315
  modelLabel: obj.modelLabel ?? null,
203
316
  promptPrefix: obj.promptPrefix ?? null,
204
- temperature: obj.temperature ?? 0.2,
205
- maxOutputTokens: obj.maxOutputTokens ?? 1024,
206
- topP: obj.topP ?? 0.95,
207
- topK: obj.topK ?? 40,
317
+ examples: obj.examples ?? [{ input: { content: '' }, output: { content: '' } }],
318
+ temperature: obj.temperature ?? google.temperature.default,
319
+ maxOutputTokens: obj.maxOutputTokens ?? google.maxOutputTokens.default,
320
+ topP: obj.topP ?? google.topP.default,
321
+ topK: obj.topK ?? google.topK.default,
208
322
  }))
209
323
  .catch(() => ({
210
- model: 'chat-bison',
324
+ model: google.model.default,
211
325
  modelLabel: null,
212
326
  promptPrefix: null,
213
- temperature: 0.2,
214
- maxOutputTokens: 1024,
215
- topP: 0.95,
216
- topK: 40,
327
+ examples: [{ input: { content: '' }, output: { content: '' } }],
328
+ temperature: google.temperature.default,
329
+ maxOutputTokens: google.maxOutputTokens.default,
330
+ topP: google.topP.default,
331
+ topK: google.topK.default,
217
332
  }));
218
333
 
219
334
  export const bingAISchema = tConversationSchema
@@ -339,25 +454,48 @@ export const gptPluginsSchema = tConversationSchema
339
454
  },
340
455
  }));
341
456
 
457
+ export function removeNullishValues<T extends object>(obj: T): T {
458
+ const newObj: Partial<T> = { ...obj };
459
+
460
+ (Object.keys(newObj) as Array<keyof T>).forEach((key) => {
461
+ if (newObj[key] === undefined || newObj[key] === null || newObj[key] === '') {
462
+ delete newObj[key];
463
+ }
464
+ });
465
+
466
+ return newObj as T;
467
+ }
468
+
469
+ export const assistantSchema = tConversationSchema
470
+ .pick({
471
+ model: true,
472
+ assistant_id: true,
473
+ thread_id: true,
474
+ })
475
+ .transform(removeNullishValues)
476
+ .catch(() => ({}));
477
+
342
478
  type EndpointSchema =
343
479
  | typeof openAISchema
344
480
  | typeof googleSchema
345
481
  | typeof bingAISchema
346
482
  | typeof anthropicSchema
347
483
  | typeof chatGPTBrowserSchema
348
- | typeof gptPluginsSchema;
484
+ | typeof gptPluginsSchema
485
+ | typeof assistantSchema;
349
486
 
350
487
  const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
351
- openAI: openAISchema,
352
- azureOpenAI: openAISchema,
353
- google: googleSchema,
354
- bingAI: bingAISchema,
355
- anthropic: anthropicSchema,
356
- chatGPTBrowser: chatGPTBrowserSchema,
357
- gptPlugins: gptPluginsSchema,
488
+ [EModelEndpoint.openAI]: openAISchema,
489
+ [EModelEndpoint.azureOpenAI]: openAISchema,
490
+ [EModelEndpoint.google]: googleSchema,
491
+ [EModelEndpoint.bingAI]: bingAISchema,
492
+ [EModelEndpoint.anthropic]: anthropicSchema,
493
+ [EModelEndpoint.chatGPTBrowser]: chatGPTBrowserSchema,
494
+ [EModelEndpoint.gptPlugins]: gptPluginsSchema,
495
+ [EModelEndpoint.assistant]: assistantSchema,
358
496
  };
359
497
 
360
- function getFirstDefinedValue(possibleValues: string[]) {
498
+ export function getFirstDefinedValue(possibleValues: string[]) {
361
499
  let returnValue;
362
500
  for (const value of possibleValues) {
363
501
  if (value) {
@@ -368,7 +506,7 @@ function getFirstDefinedValue(possibleValues: string[]) {
368
506
  return returnValue;
369
507
  }
370
508
 
371
- type TPossibleValues = {
509
+ export type TPossibleValues = {
372
510
  models: string[];
373
511
  secondaryModels?: string[];
374
512
  };
@@ -400,7 +538,7 @@ export const parseConvo = (
400
538
 
401
539
  export type TEndpointOption = {
402
540
  endpoint: EModelEndpoint;
403
- model?: string;
541
+ model?: string | null;
404
542
  promptPrefix?: string;
405
543
  temperature?: number;
406
544
  chatGptLabel?: string | null;
@@ -410,23 +548,259 @@ export type TEndpointOption = {
410
548
  };
411
549
 
412
550
  export const getResponseSender = (endpointOption: TEndpointOption): string => {
413
- const { endpoint, chatGptLabel, modelLabel, jailbreak } = endpointOption;
414
-
415
- if (['openAI', 'azureOpenAI', 'gptPlugins', 'chatGPTBrowser'].includes(endpoint)) {
416
- return chatGptLabel ?? 'ChatGPT';
551
+ const { model, endpoint, chatGptLabel, modelLabel, jailbreak } = endpointOption;
552
+
553
+ if (
554
+ [
555
+ EModelEndpoint.openAI,
556
+ EModelEndpoint.azureOpenAI,
557
+ EModelEndpoint.gptPlugins,
558
+ EModelEndpoint.chatGPTBrowser,
559
+ ].includes(endpoint)
560
+ ) {
561
+ if (chatGptLabel) {
562
+ return chatGptLabel;
563
+ } else if (model && model.includes('gpt-3')) {
564
+ return 'GPT-3.5';
565
+ } else if (model && model.includes('gpt-4')) {
566
+ return 'GPT-4';
567
+ }
568
+ return alternateName[endpoint] ?? 'ChatGPT';
417
569
  }
418
570
 
419
- if (endpoint === 'bingAI') {
571
+ if (endpoint === EModelEndpoint.bingAI) {
420
572
  return jailbreak ? 'Sydney' : 'BingAI';
421
573
  }
422
574
 
423
- if (endpoint === 'anthropic') {
424
- return modelLabel ?? 'Anthropic';
575
+ if (endpoint === EModelEndpoint.anthropic) {
576
+ return modelLabel ?? 'Claude';
425
577
  }
426
578
 
427
- if (endpoint === 'google') {
428
- return modelLabel ?? 'PaLM2';
579
+ if (endpoint === EModelEndpoint.google) {
580
+ if (modelLabel) {
581
+ return modelLabel;
582
+ } else if (model && model.includes('code')) {
583
+ return 'Codey';
584
+ }
585
+
586
+ return 'PaLM2';
429
587
  }
430
588
 
431
589
  return '';
432
590
  };
591
+
592
+ export const compactOpenAISchema = tConversationSchema
593
+ .pick({
594
+ model: true,
595
+ chatGptLabel: true,
596
+ promptPrefix: true,
597
+ temperature: true,
598
+ top_p: true,
599
+ presence_penalty: true,
600
+ frequency_penalty: true,
601
+ })
602
+ .transform((obj: Partial<TConversation>) => {
603
+ const newObj: Partial<TConversation> = { ...obj };
604
+ if (newObj.model === 'gpt-3.5-turbo') {
605
+ delete newObj.model;
606
+ }
607
+ if (newObj.temperature === 1) {
608
+ delete newObj.temperature;
609
+ }
610
+ if (newObj.top_p === 1) {
611
+ delete newObj.top_p;
612
+ }
613
+ if (newObj.presence_penalty === 0) {
614
+ delete newObj.presence_penalty;
615
+ }
616
+ if (newObj.frequency_penalty === 0) {
617
+ delete newObj.frequency_penalty;
618
+ }
619
+
620
+ return removeNullishValues(newObj);
621
+ })
622
+ .catch(() => ({}));
623
+
624
+ export const compactGoogleSchema = tConversationSchema
625
+ .pick({
626
+ model: true,
627
+ modelLabel: true,
628
+ promptPrefix: true,
629
+ examples: true,
630
+ temperature: true,
631
+ maxOutputTokens: true,
632
+ topP: true,
633
+ topK: true,
634
+ })
635
+ .transform((obj) => {
636
+ const newObj: Partial<TConversation> = { ...obj };
637
+ if (newObj.model === google.model.default) {
638
+ delete newObj.model;
639
+ }
640
+ if (newObj.temperature === google.temperature.default) {
641
+ delete newObj.temperature;
642
+ }
643
+ if (newObj.maxOutputTokens === google.maxOutputTokens.default) {
644
+ delete newObj.maxOutputTokens;
645
+ }
646
+ if (newObj.topP === google.topP.default) {
647
+ delete newObj.topP;
648
+ }
649
+ if (newObj.topK === google.topK.default) {
650
+ delete newObj.topK;
651
+ }
652
+
653
+ return removeNullishValues(newObj);
654
+ })
655
+ .catch(() => ({}));
656
+
657
+ export const compactAnthropicSchema = tConversationSchema
658
+ .pick({
659
+ model: true,
660
+ modelLabel: true,
661
+ promptPrefix: true,
662
+ temperature: true,
663
+ maxOutputTokens: true,
664
+ topP: true,
665
+ topK: true,
666
+ })
667
+ .transform((obj) => {
668
+ const newObj: Partial<TConversation> = { ...obj };
669
+ if (newObj.model === 'claude-1') {
670
+ delete newObj.model;
671
+ }
672
+ if (newObj.temperature === 1) {
673
+ delete newObj.temperature;
674
+ }
675
+ if (newObj.maxOutputTokens === 4000) {
676
+ delete newObj.maxOutputTokens;
677
+ }
678
+ if (newObj.topP === 0.7) {
679
+ delete newObj.topP;
680
+ }
681
+ if (newObj.topK === 5) {
682
+ delete newObj.topK;
683
+ }
684
+
685
+ return removeNullishValues(newObj);
686
+ })
687
+ .catch(() => ({}));
688
+
689
+ export const compactChatGPTSchema = tConversationSchema
690
+ .pick({
691
+ model: true,
692
+ })
693
+ .transform((obj) => {
694
+ const newObj: Partial<TConversation> = { ...obj };
695
+ // model: obj.model ?? 'text-davinci-002-render-sha',
696
+ if (newObj.model === 'text-davinci-002-render-sha') {
697
+ delete newObj.model;
698
+ }
699
+
700
+ return removeNullishValues(newObj);
701
+ })
702
+ .catch(() => ({}));
703
+
704
+ export const compactPluginsSchema = tConversationSchema
705
+ .pick({
706
+ model: true,
707
+ chatGptLabel: true,
708
+ promptPrefix: true,
709
+ temperature: true,
710
+ top_p: true,
711
+ presence_penalty: true,
712
+ frequency_penalty: true,
713
+ tools: true,
714
+ agentOptions: true,
715
+ })
716
+ .transform((obj) => {
717
+ const newObj: Partial<TConversation> = { ...obj };
718
+ if (newObj.model === 'gpt-3.5-turbo') {
719
+ delete newObj.model;
720
+ }
721
+ if (newObj.chatGptLabel === null) {
722
+ delete newObj.chatGptLabel;
723
+ }
724
+ if (newObj.promptPrefix === null) {
725
+ delete newObj.promptPrefix;
726
+ }
727
+ if (newObj.temperature === 0.8) {
728
+ delete newObj.temperature;
729
+ }
730
+ if (newObj.top_p === 1) {
731
+ delete newObj.top_p;
732
+ }
733
+ if (newObj.presence_penalty === 0) {
734
+ delete newObj.presence_penalty;
735
+ }
736
+ if (newObj.frequency_penalty === 0) {
737
+ delete newObj.frequency_penalty;
738
+ }
739
+ if (newObj.tools?.length === 0) {
740
+ delete newObj.tools;
741
+ }
742
+
743
+ if (
744
+ newObj.agentOptions &&
745
+ newObj.agentOptions.agent === 'functions' &&
746
+ newObj.agentOptions.skipCompletion === true &&
747
+ newObj.agentOptions.model === 'gpt-3.5-turbo' &&
748
+ newObj.agentOptions.temperature === 0
749
+ ) {
750
+ delete newObj.agentOptions;
751
+ }
752
+
753
+ return removeNullishValues(newObj);
754
+ })
755
+ .catch(() => ({}));
756
+
757
+ type CompactEndpointSchema =
758
+ | typeof compactOpenAISchema
759
+ | typeof assistantSchema
760
+ | typeof compactGoogleSchema
761
+ | typeof bingAISchema
762
+ | typeof compactAnthropicSchema
763
+ | typeof compactChatGPTSchema
764
+ | typeof compactPluginsSchema;
765
+
766
+ const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
767
+ openAI: compactOpenAISchema,
768
+ azureOpenAI: compactOpenAISchema,
769
+ assistant: assistantSchema,
770
+ google: compactGoogleSchema,
771
+ /* BingAI needs all fields */
772
+ bingAI: bingAISchema,
773
+ anthropic: compactAnthropicSchema,
774
+ chatGPTBrowser: compactChatGPTSchema,
775
+ gptPlugins: compactPluginsSchema,
776
+ };
777
+
778
+ export const parseCompactConvo = (
779
+ endpoint: EModelEndpoint | undefined,
780
+ conversation: Partial<TConversation | TPreset>,
781
+ possibleValues?: TPossibleValues,
782
+ ) => {
783
+ if (!endpoint) {
784
+ throw new Error(`undefined endpoint: ${endpoint}`);
785
+ }
786
+
787
+ const schema = compactEndpointSchemas[endpoint];
788
+
789
+ if (!schema) {
790
+ throw new Error(`Unknown endpoint: ${endpoint}`);
791
+ }
792
+
793
+ const convo = schema.parse(conversation) as TConversation;
794
+ // const { models, secondaryModels } = possibleValues ?? {};
795
+ const { models } = possibleValues ?? {};
796
+
797
+ if (models && convo) {
798
+ convo.model = getFirstDefinedValue(models) ?? convo.model;
799
+ }
800
+
801
+ // if (secondaryModels && convo.agentOptions) {
802
+ // convo.agentOptionmodel = getFirstDefinedValue(secondaryModels) ?? convo.agentOptionmodel;
803
+ // }
804
+
805
+ return convo;
806
+ };
package/src/sse.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * All rights reserved.
5
5
  */
6
6
 
7
- import { refreshToken } from './data-service';
7
+ import request from './request';
8
8
  import { setTokenHeader } from './headers-helpers';
9
9
 
10
10
  var SSE = function (url, options) {
@@ -113,7 +113,7 @@ var SSE = function (url, options) {
113
113
  if (this.xhr.status === 401 && !this._retry) {
114
114
  this._retry = true;
115
115
  try {
116
- const refreshResponse = await refreshToken();
116
+ const refreshResponse = await request.refreshToken();
117
117
  this.headers = {
118
118
  'Content-Type': 'application/json',
119
119
  Authorization: `Bearer ${refreshResponse.token}`,
@@ -0,0 +1,72 @@
1
+ export type Metadata = {
2
+ [key: string]: unknown;
3
+ };
4
+
5
+ export enum Tools {
6
+ code_interpreter = 'code_interpreter',
7
+ retrieval = 'retrieval',
8
+ function = 'function',
9
+ }
10
+
11
+ export type Tool = {
12
+ [type: string]: Tools;
13
+ };
14
+
15
+ export type Assistant = {
16
+ id: string;
17
+ created_at: number;
18
+ description: string | null;
19
+ file_ids: string[];
20
+ instructions: string | null;
21
+ metadata: Metadata | null;
22
+ model: string;
23
+ name: string | null;
24
+ object: string;
25
+ tools: Tool[];
26
+ };
27
+
28
+ export type AssistantCreateParams = {
29
+ model: string;
30
+ description?: string | null;
31
+ file_ids?: string[];
32
+ instructions?: string | null;
33
+ metadata?: Metadata | null;
34
+ name?: string | null;
35
+ tools?: Tool[];
36
+ };
37
+
38
+ export type AssistantUpdateParams = {
39
+ model?: string;
40
+ description?: string | null;
41
+ file_ids?: string[];
42
+ instructions?: string | null;
43
+ metadata?: Metadata | null;
44
+ name?: string | null;
45
+ tools?: Tool[];
46
+ };
47
+
48
+ export type AssistantListParams = {
49
+ limit?: number;
50
+ before?: string | null;
51
+ after?: string | null;
52
+ order?: 'asc' | 'desc';
53
+ };
54
+
55
+ export type AssistantListResponse = {
56
+ object: string;
57
+ data: Assistant[];
58
+ first_id: string;
59
+ last_id: string;
60
+ has_more: boolean;
61
+ };
62
+
63
+ export type File = {
64
+ file_id: string;
65
+ id?: string;
66
+ temp_file_id?: string;
67
+ bytes: number;
68
+ created_at: number;
69
+ filename: string;
70
+ object: string;
71
+ purpose: 'fine-tune' | 'fine-tune-results' | 'assistants' | 'assistants_output';
72
+ };
@@ -0,0 +1,42 @@
1
+ export type FileUploadResponse = {
2
+ message: string;
3
+ file_id: string;
4
+ temp_file_id: string;
5
+ filepath: string;
6
+ filename: string;
7
+ type: string;
8
+ size: number;
9
+ height: number;
10
+ width: number;
11
+ };
12
+
13
+ export type FileUploadBody = {
14
+ formData: FormData;
15
+ file_id: string;
16
+ };
17
+
18
+ export type UploadMutationOptions = {
19
+ onSuccess?: (data: FileUploadResponse, variables: FileUploadBody, context?: unknown) => void;
20
+ onMutate?: (variables: FileUploadBody) => void | Promise<unknown>;
21
+ onError?: (error: unknown, variables: FileUploadBody, context?: unknown) => void;
22
+ };
23
+
24
+ export type DeleteFilesResponse = {
25
+ message: string;
26
+ result: Record<string, unknown>;
27
+ };
28
+
29
+ export type BatchFile = {
30
+ file_id: string;
31
+ filepath: string;
32
+ };
33
+
34
+ export type DeleteFilesBody = {
35
+ files: BatchFile[];
36
+ };
37
+
38
+ export type DeleteMutationOptions = {
39
+ onSuccess?: (data: DeleteFilesResponse, variables: DeleteFilesBody, context?: unknown) => void;
40
+ onMutate?: (variables: DeleteFilesBody) => void | Promise<unknown>;
41
+ onError?: (error: unknown, variables: DeleteFilesBody, context?: unknown) => void;
42
+ };
@@ -0,0 +1,28 @@
1
+ import { TPreset } from '../types';
2
+
3
+ export type PresetDeleteResponse = {
4
+ acknowledged: boolean;
5
+ deletedCount: number;
6
+ };
7
+
8
+ export type UpdatePresetOptions = {
9
+ onSuccess?: (data: TPreset, variables: TPreset, context?: unknown) => void;
10
+ onMutate?: (variables: TPreset) => void | Promise<unknown>;
11
+ onError?: (error: unknown, variables: TPreset, context?: unknown) => void;
12
+ };
13
+
14
+ export type DeletePresetOptions = {
15
+ onSuccess?: (
16
+ data: PresetDeleteResponse,
17
+ variables: TPreset | undefined,
18
+ context?: unknown,
19
+ ) => void;
20
+ onMutate?: (variables: TPreset | undefined) => void | Promise<unknown>;
21
+ onError?: (error: unknown, variables: TPreset | undefined, context?: unknown) => void;
22
+ };
23
+
24
+ export type LogoutOptions = {
25
+ onSuccess?: (data: unknown, variables: undefined, context?: unknown) => void;
26
+ onMutate?: (variables: undefined) => void | Promise<unknown>;
27
+ onError?: (error: unknown, variables: undefined, context?: unknown) => void;
28
+ };