@depup/typesense 3.0.3-depup.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 +201 -0
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/typesense.js +13031 -0
- package/dist/typesense.js.map +1 -0
- package/dist/typesense.min.js +3 -0
- package/dist/typesense.min.js.LICENSE.txt +1 -0
- package/dist/typesense.min.js.map +1 -0
- package/lib/Typesense/Alias.d.ts +10 -0
- package/lib/Typesense/Alias.js +30 -0
- package/lib/Typesense/Alias.js.map +1 -0
- package/lib/Typesense/Aliases.d.ts +18 -0
- package/lib/Typesense/Aliases.js +36 -0
- package/lib/Typesense/Aliases.js.map +1 -0
- package/lib/Typesense/Analytics.d.ts +15 -0
- package/lib/Typesense/Analytics.js +40 -0
- package/lib/Typesense/Analytics.js.map +1 -0
- package/lib/Typesense/AnalyticsEvent.d.ts +5 -0
- package/lib/Typesense/AnalyticsEvent.js +3 -0
- package/lib/Typesense/AnalyticsEvent.js.map +1 -0
- package/lib/Typesense/AnalyticsEvents.d.ts +26 -0
- package/lib/Typesense/AnalyticsEvents.js +37 -0
- package/lib/Typesense/AnalyticsEvents.js.map +1 -0
- package/lib/Typesense/AnalyticsRule.d.ts +47 -0
- package/lib/Typesense/AnalyticsRule.js +30 -0
- package/lib/Typesense/AnalyticsRule.js.map +1 -0
- package/lib/Typesense/AnalyticsRuleV1.d.ts +35 -0
- package/lib/Typesense/AnalyticsRuleV1.js +30 -0
- package/lib/Typesense/AnalyticsRuleV1.js.map +1 -0
- package/lib/Typesense/AnalyticsRules.d.ts +16 -0
- package/lib/Typesense/AnalyticsRules.js +49 -0
- package/lib/Typesense/AnalyticsRules.js.map +1 -0
- package/lib/Typesense/AnalyticsRulesV1.d.ts +13 -0
- package/lib/Typesense/AnalyticsRulesV1.js +37 -0
- package/lib/Typesense/AnalyticsRulesV1.js.map +1 -0
- package/lib/Typesense/AnalyticsV1.d.ts +19 -0
- package/lib/Typesense/AnalyticsV1.js +49 -0
- package/lib/Typesense/AnalyticsV1.js.map +1 -0
- package/lib/Typesense/ApiCall.d.ts +99 -0
- package/lib/Typesense/ApiCall.js +777 -0
- package/lib/Typesense/ApiCall.js.map +1 -0
- package/lib/Typesense/Client.d.ts +79 -0
- package/lib/Typesense/Client.js +170 -0
- package/lib/Typesense/Client.js.map +1 -0
- package/lib/Typesense/Collection.d.ts +63 -0
- package/lib/Typesense/Collection.js +109 -0
- package/lib/Typesense/Collection.js.map +1 -0
- package/lib/Typesense/Collections.d.ts +42 -0
- package/lib/Typesense/Collections.js +34 -0
- package/lib/Typesense/Collections.js.map +1 -0
- package/lib/Typesense/Configuration.d.ts +143 -0
- package/lib/Typesense/Configuration.js +113 -0
- package/lib/Typesense/Configuration.js.map +1 -0
- package/lib/Typesense/Conversation.d.ts +22 -0
- package/lib/Typesense/Conversation.js +37 -0
- package/lib/Typesense/Conversation.js.map +1 -0
- package/lib/Typesense/ConversationModel.d.ts +30 -0
- package/lib/Typesense/ConversationModel.js +37 -0
- package/lib/Typesense/ConversationModel.js.map +1 -0
- package/lib/Typesense/ConversationModels.d.ts +10 -0
- package/lib/Typesense/ConversationModels.js +37 -0
- package/lib/Typesense/ConversationModels.js.map +1 -0
- package/lib/Typesense/Conversations.d.ts +17 -0
- package/lib/Typesense/Conversations.js +42 -0
- package/lib/Typesense/Conversations.js.map +1 -0
- package/lib/Typesense/CurationSet.d.ts +17 -0
- package/lib/Typesense/CurationSet.js +52 -0
- package/lib/Typesense/CurationSet.js.map +1 -0
- package/lib/Typesense/CurationSetItem.d.ts +15 -0
- package/lib/Typesense/CurationSetItem.js +38 -0
- package/lib/Typesense/CurationSetItem.js.map +1 -0
- package/lib/Typesense/CurationSetItems.d.ts +9 -0
- package/lib/Typesense/CurationSetItems.js +23 -0
- package/lib/Typesense/CurationSetItems.js.map +1 -0
- package/lib/Typesense/CurationSets.d.ts +56 -0
- package/lib/Typesense/CurationSets.js +19 -0
- package/lib/Typesense/CurationSets.js.map +1 -0
- package/lib/Typesense/Debug.d.ts +10 -0
- package/lib/Typesense/Debug.js +19 -0
- package/lib/Typesense/Debug.js.map +1 -0
- package/lib/Typesense/Document.d.ts +12 -0
- package/lib/Typesense/Document.js +41 -0
- package/lib/Typesense/Document.js.map +1 -0
- package/lib/Typesense/Documents.d.ts +196 -0
- package/lib/Typesense/Documents.js +204 -0
- package/lib/Typesense/Documents.js.map +1 -0
- package/lib/Typesense/Errors/HTTPError.d.ts +3 -0
- package/lib/Typesense/Errors/HTTPError.js +13 -0
- package/lib/Typesense/Errors/HTTPError.js.map +1 -0
- package/lib/Typesense/Errors/ImportError.d.ts +15 -0
- package/lib/Typesense/Errors/ImportError.js +16 -0
- package/lib/Typesense/Errors/ImportError.js.map +1 -0
- package/lib/Typesense/Errors/MissingConfigurationError.d.ts +3 -0
- package/lib/Typesense/Errors/MissingConfigurationError.js +13 -0
- package/lib/Typesense/Errors/MissingConfigurationError.js.map +1 -0
- package/lib/Typesense/Errors/ObjectAlreadyExists.d.ts +3 -0
- package/lib/Typesense/Errors/ObjectAlreadyExists.js +13 -0
- package/lib/Typesense/Errors/ObjectAlreadyExists.js.map +1 -0
- package/lib/Typesense/Errors/ObjectNotFound.d.ts +3 -0
- package/lib/Typesense/Errors/ObjectNotFound.js +13 -0
- package/lib/Typesense/Errors/ObjectNotFound.js.map +1 -0
- package/lib/Typesense/Errors/ObjectUnprocessable.d.ts +3 -0
- package/lib/Typesense/Errors/ObjectUnprocessable.js +13 -0
- package/lib/Typesense/Errors/ObjectUnprocessable.js.map +1 -0
- package/lib/Typesense/Errors/RequestMalformed.d.ts +3 -0
- package/lib/Typesense/Errors/RequestMalformed.js +13 -0
- package/lib/Typesense/Errors/RequestMalformed.js.map +1 -0
- package/lib/Typesense/Errors/RequestUnauthorized.d.ts +3 -0
- package/lib/Typesense/Errors/RequestUnauthorized.js +13 -0
- package/lib/Typesense/Errors/RequestUnauthorized.js.map +1 -0
- package/lib/Typesense/Errors/ServerError.d.ts +3 -0
- package/lib/Typesense/Errors/ServerError.js +13 -0
- package/lib/Typesense/Errors/ServerError.js.map +1 -0
- package/lib/Typesense/Errors/TypesenseError.d.ts +5 -0
- package/lib/Typesense/Errors/TypesenseError.js +19 -0
- package/lib/Typesense/Errors/TypesenseError.js.map +1 -0
- package/lib/Typesense/Errors/index.d.ts +11 -0
- package/lib/Typesense/Errors/index.js +25 -0
- package/lib/Typesense/Errors/index.js.map +1 -0
- package/lib/Typesense/Health.d.ts +9 -0
- package/lib/Typesense/Health.js +19 -0
- package/lib/Typesense/Health.js.map +1 -0
- package/lib/Typesense/Key.d.ts +33 -0
- package/lib/Typesense/Key.js +30 -0
- package/lib/Typesense/Key.js.map +1 -0
- package/lib/Typesense/Keys.d.ts +19 -0
- package/lib/Typesense/Keys.js +46 -0
- package/lib/Typesense/Keys.js.map +1 -0
- package/lib/Typesense/Metrics.d.ts +25 -0
- package/lib/Typesense/Metrics.js +19 -0
- package/lib/Typesense/Metrics.js.map +1 -0
- package/lib/Typesense/MultiSearch.d.ts +25 -0
- package/lib/Typesense/MultiSearch.js +63 -0
- package/lib/Typesense/MultiSearch.js.map +1 -0
- package/lib/Typesense/NLSearchModel.d.ts +16 -0
- package/lib/Typesense/NLSearchModel.js +37 -0
- package/lib/Typesense/NLSearchModel.js.map +1 -0
- package/lib/Typesense/NLSearchModels.d.ts +36 -0
- package/lib/Typesense/NLSearchModels.js +36 -0
- package/lib/Typesense/NLSearchModels.js.map +1 -0
- package/lib/Typesense/Operations.d.ts +12 -0
- package/lib/Typesense/Operations.js +27 -0
- package/lib/Typesense/Operations.js.map +1 -0
- package/lib/Typesense/Override.d.ts +17 -0
- package/lib/Typesense/Override.js +32 -0
- package/lib/Typesense/Override.js.map +1 -0
- package/lib/Typesense/Overrides.d.ts +43 -0
- package/lib/Typesense/Overrides.js +38 -0
- package/lib/Typesense/Overrides.js.map +1 -0
- package/lib/Typesense/Preset.d.ts +17 -0
- package/lib/Typesense/Preset.js +30 -0
- package/lib/Typesense/Preset.js.map +1 -0
- package/lib/Typesense/Presets.d.ts +18 -0
- package/lib/Typesense/Presets.js +49 -0
- package/lib/Typesense/Presets.js.map +1 -0
- package/lib/Typesense/RequestWithCache.d.ts +15 -0
- package/lib/Typesense/RequestWithCache.js +117 -0
- package/lib/Typesense/RequestWithCache.js.map +1 -0
- package/lib/Typesense/SearchClient.d.ts +13 -0
- package/lib/Typesense/SearchClient.js +45 -0
- package/lib/Typesense/SearchClient.js.map +1 -0
- package/lib/Typesense/SearchOnlyCollection.d.ts +11 -0
- package/lib/Typesense/SearchOnlyCollection.js +18 -0
- package/lib/Typesense/SearchOnlyCollection.js.map +1 -0
- package/lib/Typesense/SearchOnlyDocuments.d.ts +16 -0
- package/lib/Typesense/SearchOnlyDocuments.js +57 -0
- package/lib/Typesense/SearchOnlyDocuments.js.map +1 -0
- package/lib/Typesense/Stats.d.ts +24 -0
- package/lib/Typesense/Stats.js +19 -0
- package/lib/Typesense/Stats.js.map +1 -0
- package/lib/Typesense/Stemming.d.ts +12 -0
- package/lib/Typesense/Stemming.js +35 -0
- package/lib/Typesense/Stemming.js.map +1 -0
- package/lib/Typesense/StemmingDictionaries.d.ts +13 -0
- package/lib/Typesense/StemmingDictionaries.js +58 -0
- package/lib/Typesense/StemmingDictionaries.js.map +1 -0
- package/lib/Typesense/StemmingDictionary.d.ts +20 -0
- package/lib/Typesense/StemmingDictionary.js +30 -0
- package/lib/Typesense/StemmingDictionary.js.map +1 -0
- package/lib/Typesense/Stopword.d.ts +20 -0
- package/lib/Typesense/Stopword.js +30 -0
- package/lib/Typesense/Stopword.js.map +1 -0
- package/lib/Typesense/Stopwords.d.ts +17 -0
- package/lib/Typesense/Stopwords.js +36 -0
- package/lib/Typesense/Stopwords.js.map +1 -0
- package/lib/Typesense/Synonym.d.ts +21 -0
- package/lib/Typesense/Synonym.js +41 -0
- package/lib/Typesense/Synonym.js.map +1 -0
- package/lib/Typesense/SynonymSet.d.ts +21 -0
- package/lib/Typesense/SynonymSet.js +52 -0
- package/lib/Typesense/SynonymSet.js.map +1 -0
- package/lib/Typesense/SynonymSetItem.d.ts +14 -0
- package/lib/Typesense/SynonymSetItem.js +31 -0
- package/lib/Typesense/SynonymSetItem.js.map +1 -0
- package/lib/Typesense/SynonymSetItems.d.ts +10 -0
- package/lib/Typesense/SynonymSetItems.js +30 -0
- package/lib/Typesense/SynonymSetItems.js.map +1 -0
- package/lib/Typesense/SynonymSets.d.ts +23 -0
- package/lib/Typesense/SynonymSets.js +19 -0
- package/lib/Typesense/SynonymSets.js.map +1 -0
- package/lib/Typesense/Synonyms.d.ts +24 -0
- package/lib/Typesense/Synonyms.js +47 -0
- package/lib/Typesense/Synonyms.js.map +1 -0
- package/lib/Typesense/Types.d.ts +201 -0
- package/lib/Typesense/Types.js +22 -0
- package/lib/Typesense/Types.js.map +1 -0
- package/lib/Typesense/Utils.d.ts +11 -0
- package/lib/Typesense/Utils.js +50 -0
- package/lib/Typesense/Utils.js.map +1 -0
- package/lib/Typesense.d.ts +46 -0
- package/lib/Typesense.js +12 -0
- package/lib/Typesense.js.map +1 -0
- package/package.json +141 -0
- package/src/Typesense/Alias.ts +18 -0
- package/src/Typesense/Aliases.ts +41 -0
- package/src/Typesense/Analytics.ts +39 -0
- package/src/Typesense/AnalyticsEvent.ts +5 -0
- package/src/Typesense/AnalyticsEvents.ts +53 -0
- package/src/Typesense/AnalyticsRule.ts +63 -0
- package/src/Typesense/AnalyticsRuleV1.ts +52 -0
- package/src/Typesense/AnalyticsRules.ts +67 -0
- package/src/Typesense/AnalyticsRulesV1.ts +43 -0
- package/src/Typesense/AnalyticsV1.ts +52 -0
- package/src/Typesense/ApiCall.ts +1103 -0
- package/src/Typesense/Client.ts +225 -0
- package/src/Typesense/Collection.ts +179 -0
- package/src/Typesense/Collections.ts +68 -0
- package/src/Typesense/Configuration.ts +328 -0
- package/src/Typesense/Conversation.ts +45 -0
- package/src/Typesense/ConversationModel.ts +55 -0
- package/src/Typesense/ConversationModels.ts +38 -0
- package/src/Typesense/Conversations.ts +47 -0
- package/src/Typesense/CurationSet.ts +56 -0
- package/src/Typesense/CurationSetItem.ts +35 -0
- package/src/Typesense/CurationSetItems.ts +18 -0
- package/src/Typesense/CurationSets.ts +60 -0
- package/src/Typesense/Debug.ts +16 -0
- package/src/Typesense/Document.ts +34 -0
- package/src/Typesense/Documents.ts +445 -0
- package/src/Typesense/Errors/HTTPError.ts +3 -0
- package/src/Typesense/Errors/ImportError.ts +24 -0
- package/src/Typesense/Errors/MissingConfigurationError.ts +3 -0
- package/src/Typesense/Errors/ObjectAlreadyExists.ts +3 -0
- package/src/Typesense/Errors/ObjectNotFound.ts +3 -0
- package/src/Typesense/Errors/ObjectUnprocessable.ts +3 -0
- package/src/Typesense/Errors/RequestMalformed.ts +3 -0
- package/src/Typesense/Errors/RequestUnauthorized.ts +3 -0
- package/src/Typesense/Errors/ServerError.ts +3 -0
- package/src/Typesense/Errors/TypesenseError.ts +13 -0
- package/src/Typesense/Errors/index.ts +23 -0
- package/src/Typesense/Health.ts +15 -0
- package/src/Typesense/Key.ts +73 -0
- package/src/Typesense/Keys.ts +59 -0
- package/src/Typesense/Metrics.ts +31 -0
- package/src/Typesense/MultiSearch.ts +144 -0
- package/src/Typesense/NLSearchModel.ts +35 -0
- package/src/Typesense/NLSearchModels.ts +61 -0
- package/src/Typesense/Operations.ts +35 -0
- package/src/Typesense/Override.ts +31 -0
- package/src/Typesense/Overrides.ts +73 -0
- package/src/Typesense/Preset.ts +31 -0
- package/src/Typesense/Presets.ts +62 -0
- package/src/Typesense/RequestWithCache.ts +209 -0
- package/src/Typesense/SearchClient.ts +64 -0
- package/src/Typesense/SearchOnlyCollection.ts +24 -0
- package/src/Typesense/SearchOnlyDocuments.ts +87 -0
- package/src/Typesense/Stats.ts +31 -0
- package/src/Typesense/Stemming.ts +38 -0
- package/src/Typesense/StemmingDictionaries.ts +59 -0
- package/src/Typesense/StemmingDictionary.ts +37 -0
- package/src/Typesense/Stopword.ts +31 -0
- package/src/Typesense/Stopwords.ts +41 -0
- package/src/Typesense/Synonym.ts +42 -0
- package/src/Typesense/SynonymSet.ts +57 -0
- package/src/Typesense/SynonymSetItem.ts +28 -0
- package/src/Typesense/SynonymSetItems.ts +31 -0
- package/src/Typesense/SynonymSets.ts +30 -0
- package/src/Typesense/Synonyms.ts +55 -0
- package/src/Typesense/Types.ts +355 -0
- package/src/Typesense/Utils.ts +80 -0
- package/src/Typesense.ts +43 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import * as logger from "loglevel";
|
|
2
|
+
import { Logger, LogLevelDesc } from "loglevel";
|
|
3
|
+
import { MissingConfigurationError } from "./Errors";
|
|
4
|
+
import type { Agent as HTTPAgent } from "http";
|
|
5
|
+
import type { Agent as HTTPSAgent } from "https";
|
|
6
|
+
import type { AxiosRequestConfig } from "axios";
|
|
7
|
+
import { DocumentSchema, SearchResponse } from "./Documents";
|
|
8
|
+
|
|
9
|
+
export interface NodeConfiguration {
|
|
10
|
+
host: string;
|
|
11
|
+
port: number;
|
|
12
|
+
protocol: string;
|
|
13
|
+
path?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface NodeConfigurationWithHostname {
|
|
18
|
+
host: string;
|
|
19
|
+
port: number;
|
|
20
|
+
protocol: string;
|
|
21
|
+
path?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NodeConfigurationWithUrl {
|
|
25
|
+
url: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ConfigurationOptions {
|
|
29
|
+
apiKey: string;
|
|
30
|
+
nodes:
|
|
31
|
+
| NodeConfiguration[]
|
|
32
|
+
| NodeConfigurationWithHostname[]
|
|
33
|
+
| NodeConfigurationWithUrl[];
|
|
34
|
+
randomizeNodes?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated
|
|
37
|
+
* masterNode is now consolidated to nodes, starting with Typesense Server v0.12'
|
|
38
|
+
*/
|
|
39
|
+
masterNode?:
|
|
40
|
+
| NodeConfiguration
|
|
41
|
+
| NodeConfigurationWithHostname
|
|
42
|
+
| NodeConfigurationWithUrl;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated
|
|
45
|
+
* readReplicaNodes is now consolidated to nodes, starting with Typesense Server v0.12'
|
|
46
|
+
*/
|
|
47
|
+
readReplicaNodes?:
|
|
48
|
+
| NodeConfiguration[]
|
|
49
|
+
| NodeConfigurationWithHostname[]
|
|
50
|
+
| NodeConfigurationWithUrl[];
|
|
51
|
+
nearestNode?:
|
|
52
|
+
| NodeConfiguration
|
|
53
|
+
| NodeConfigurationWithHostname
|
|
54
|
+
| NodeConfigurationWithUrl;
|
|
55
|
+
connectionTimeoutSeconds?: number;
|
|
56
|
+
timeoutSeconds?: number;
|
|
57
|
+
healthcheckIntervalSeconds?: number;
|
|
58
|
+
numRetries?: number;
|
|
59
|
+
retryIntervalSeconds?: number;
|
|
60
|
+
sendApiKeyAsQueryParam?: boolean | undefined;
|
|
61
|
+
useServerSideSearchCache?: boolean;
|
|
62
|
+
cacheSearchResultsForSeconds?: number;
|
|
63
|
+
additionalHeaders?: Record<string, string>;
|
|
64
|
+
|
|
65
|
+
logLevel?: LogLevelDesc;
|
|
66
|
+
logger?: Logger;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set a custom HTTP Agent
|
|
70
|
+
*
|
|
71
|
+
* This is helpful for eg, to enable keepAlive which helps prevents ECONNRESET socket hang up errors
|
|
72
|
+
* Usage:
|
|
73
|
+
* const { Agent: HTTPAgent } = require("http");
|
|
74
|
+
* ...
|
|
75
|
+
* httpAgent: new HTTPAgent({ keepAlive: true }),
|
|
76
|
+
* @type {HTTPAgent}
|
|
77
|
+
*/
|
|
78
|
+
httpAgent?: HTTPAgent;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Set a custom HTTPS Agent
|
|
82
|
+
*
|
|
83
|
+
* This is helpful for eg, to enable keepAlive which helps prevents ECONNRESET socket hang up errors
|
|
84
|
+
* Usage:
|
|
85
|
+
* const { Agent: HTTPSAgent } = require("https");
|
|
86
|
+
* ...
|
|
87
|
+
* httpsAgent: new HTTPSAgent({ keepAlive: true }),
|
|
88
|
+
* @type {HTTPSAgent}
|
|
89
|
+
*/
|
|
90
|
+
httpsAgent?: HTTPSAgent;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Set a custom paramsSerializer
|
|
94
|
+
*
|
|
95
|
+
* See axios documentation for more information on how to use this parameter: https://axios-http.com/docs/req_config
|
|
96
|
+
* This is helpful for handling React Native issues like this: https://github.com/axios/axios/issues/6102#issuecomment-2085301397
|
|
97
|
+
* @type {any}
|
|
98
|
+
*/
|
|
99
|
+
paramsSerializer?: any;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Set a custom axios adapter
|
|
103
|
+
*
|
|
104
|
+
* Useful for customizing the underlying HTTP client library used by Typesense.
|
|
105
|
+
*
|
|
106
|
+
* For example, you can use this to use a custom HTTP client library like `fetch`, in order for the library to work on the edge.
|
|
107
|
+
* Related GiHub issue: https://github.com/typesense/typesense-js/issues/161
|
|
108
|
+
*
|
|
109
|
+
* See axios documentation for more information on how to use this parameter: https://axios-http.com/docs/req_config
|
|
110
|
+
*/
|
|
111
|
+
axiosAdapter?: AxiosRequestConfig["adapter"];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Configuration options for streaming responses
|
|
116
|
+
*/
|
|
117
|
+
export interface BaseStreamConfig {
|
|
118
|
+
/**
|
|
119
|
+
* Callback function that will be called for each chunk of data received
|
|
120
|
+
* during streaming
|
|
121
|
+
*/
|
|
122
|
+
onChunk?: (data: { conversation_id: string; message: string }) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Callback function that will be called if there is an error during streaming
|
|
125
|
+
*/
|
|
126
|
+
onError?: (error: Error) => void;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Stream configuration for standard search responses
|
|
131
|
+
* For specialized responses like MultiSearch, extend BaseStreamConfig with the appropriate onComplete signature
|
|
132
|
+
*/
|
|
133
|
+
export interface StreamConfig<T extends DocumentSchema>
|
|
134
|
+
extends BaseStreamConfig {
|
|
135
|
+
/**
|
|
136
|
+
* Callback function that will be called when the streaming is complete
|
|
137
|
+
*/
|
|
138
|
+
onComplete?: (data: SearchResponse<T>) => void;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default class Configuration {
|
|
142
|
+
readonly nodes:
|
|
143
|
+
| NodeConfiguration[]
|
|
144
|
+
| NodeConfigurationWithHostname[]
|
|
145
|
+
| NodeConfigurationWithUrl[];
|
|
146
|
+
readonly nearestNode?:
|
|
147
|
+
| NodeConfiguration
|
|
148
|
+
| NodeConfigurationWithHostname
|
|
149
|
+
| NodeConfigurationWithUrl;
|
|
150
|
+
readonly connectionTimeoutSeconds: number;
|
|
151
|
+
readonly healthcheckIntervalSeconds: number;
|
|
152
|
+
readonly numRetries: number;
|
|
153
|
+
readonly retryIntervalSeconds: number;
|
|
154
|
+
readonly apiKey: string;
|
|
155
|
+
readonly sendApiKeyAsQueryParam?: boolean;
|
|
156
|
+
readonly cacheSearchResultsForSeconds: number;
|
|
157
|
+
readonly useServerSideSearchCache: boolean;
|
|
158
|
+
readonly logger: Logger;
|
|
159
|
+
readonly logLevel: LogLevelDesc;
|
|
160
|
+
readonly additionalHeaders?: Record<string, string>;
|
|
161
|
+
readonly httpAgent?: HTTPAgent;
|
|
162
|
+
readonly httpsAgent?: HTTPSAgent;
|
|
163
|
+
readonly paramsSerializer?: any;
|
|
164
|
+
readonly axiosAdapter?: AxiosRequestConfig["adapter"];
|
|
165
|
+
|
|
166
|
+
constructor(options: ConfigurationOptions) {
|
|
167
|
+
this.nodes = options.nodes || [];
|
|
168
|
+
this.nodes = this.nodes
|
|
169
|
+
.map((node) => this.setDefaultPathInNode(node))
|
|
170
|
+
.map((node) => this.setDefaultPortInNode(node))
|
|
171
|
+
.map((node) => ({ ...node })) as NodeConfiguration[]; // Make a deep copy
|
|
172
|
+
|
|
173
|
+
if (options.randomizeNodes == null) {
|
|
174
|
+
options.randomizeNodes = true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (options.randomizeNodes === true) {
|
|
178
|
+
this.shuffleArray(this.nodes);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this.nearestNode = options.nearestNode;
|
|
182
|
+
this.nearestNode = this.setDefaultPathInNode(this.nearestNode);
|
|
183
|
+
this.nearestNode = this.setDefaultPortInNode(this.nearestNode);
|
|
184
|
+
|
|
185
|
+
this.connectionTimeoutSeconds =
|
|
186
|
+
options.connectionTimeoutSeconds || options.timeoutSeconds || 5;
|
|
187
|
+
this.healthcheckIntervalSeconds = options.healthcheckIntervalSeconds || 60;
|
|
188
|
+
this.numRetries =
|
|
189
|
+
(options.numRetries !== undefined && options.numRetries >= 0
|
|
190
|
+
? options.numRetries
|
|
191
|
+
: this.nodes.length + (this.nearestNode == null ? 0 : 1)) || 3;
|
|
192
|
+
this.retryIntervalSeconds = options.retryIntervalSeconds || 0.1;
|
|
193
|
+
|
|
194
|
+
this.apiKey = options.apiKey;
|
|
195
|
+
this.sendApiKeyAsQueryParam = options.sendApiKeyAsQueryParam; // We will set a default for this in Client and SearchClient
|
|
196
|
+
|
|
197
|
+
this.cacheSearchResultsForSeconds =
|
|
198
|
+
options.cacheSearchResultsForSeconds || 0; // Disable client-side cache by default
|
|
199
|
+
this.useServerSideSearchCache = options.useServerSideSearchCache || false;
|
|
200
|
+
|
|
201
|
+
this.axiosAdapter = options.axiosAdapter;
|
|
202
|
+
this.logger = options.logger || logger;
|
|
203
|
+
this.logLevel = options.logLevel || "warn";
|
|
204
|
+
this.logger.setLevel(this.logLevel);
|
|
205
|
+
|
|
206
|
+
this.additionalHeaders = options.additionalHeaders;
|
|
207
|
+
|
|
208
|
+
this.httpAgent = options.httpAgent;
|
|
209
|
+
this.httpsAgent = options.httpsAgent;
|
|
210
|
+
|
|
211
|
+
this.paramsSerializer = options.paramsSerializer;
|
|
212
|
+
|
|
213
|
+
this.showDeprecationWarnings(options);
|
|
214
|
+
this.validate();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
validate(): boolean {
|
|
218
|
+
if (this.nodes == null || this.nodes.length === 0 || this.validateNodes()) {
|
|
219
|
+
throw new MissingConfigurationError(
|
|
220
|
+
"Ensure that nodes[].protocol, nodes[].host and nodes[].port are set",
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (
|
|
225
|
+
this.nearestNode != null &&
|
|
226
|
+
this.isNodeMissingAnyParameters(this.nearestNode)
|
|
227
|
+
) {
|
|
228
|
+
throw new MissingConfigurationError(
|
|
229
|
+
"Ensure that nearestNodes.protocol, nearestNodes.host and nearestNodes.port are set",
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (this.apiKey == null) {
|
|
234
|
+
throw new MissingConfigurationError("Ensure that apiKey is set");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private validateNodes(): boolean {
|
|
241
|
+
return this.nodes.some((node) => {
|
|
242
|
+
return this.isNodeMissingAnyParameters(node);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private isNodeMissingAnyParameters(
|
|
247
|
+
node:
|
|
248
|
+
| NodeConfiguration
|
|
249
|
+
| NodeConfigurationWithHostname
|
|
250
|
+
| NodeConfigurationWithUrl,
|
|
251
|
+
): boolean {
|
|
252
|
+
return (
|
|
253
|
+
!["protocol", "host", "port", "path"].every((key) => {
|
|
254
|
+
return node.hasOwnProperty(key);
|
|
255
|
+
}) && node["url"] == null
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private setDefaultPathInNode(
|
|
260
|
+
node:
|
|
261
|
+
| NodeConfiguration
|
|
262
|
+
| NodeConfigurationWithHostname
|
|
263
|
+
| NodeConfigurationWithUrl
|
|
264
|
+
| undefined,
|
|
265
|
+
):
|
|
266
|
+
| NodeConfiguration
|
|
267
|
+
| NodeConfigurationWithHostname
|
|
268
|
+
| NodeConfigurationWithUrl
|
|
269
|
+
| undefined {
|
|
270
|
+
if (node != null && !node.hasOwnProperty("path")) {
|
|
271
|
+
node["path"] = "";
|
|
272
|
+
}
|
|
273
|
+
return node;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private setDefaultPortInNode(
|
|
277
|
+
node:
|
|
278
|
+
| NodeConfiguration
|
|
279
|
+
| NodeConfigurationWithHostname
|
|
280
|
+
| NodeConfigurationWithUrl
|
|
281
|
+
| undefined,
|
|
282
|
+
):
|
|
283
|
+
| NodeConfiguration
|
|
284
|
+
| NodeConfigurationWithHostname
|
|
285
|
+
| NodeConfigurationWithUrl
|
|
286
|
+
| undefined {
|
|
287
|
+
if (
|
|
288
|
+
node != null &&
|
|
289
|
+
!node.hasOwnProperty("port") &&
|
|
290
|
+
node.hasOwnProperty("protocol")
|
|
291
|
+
) {
|
|
292
|
+
switch (node["protocol"]) {
|
|
293
|
+
case "https":
|
|
294
|
+
node["port"] = 443;
|
|
295
|
+
break;
|
|
296
|
+
case "http":
|
|
297
|
+
node["port"] = 80;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return node;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
private showDeprecationWarnings(options: ConfigurationOptions): void {
|
|
305
|
+
if (options.timeoutSeconds) {
|
|
306
|
+
this.logger.warn(
|
|
307
|
+
"Deprecation warning: timeoutSeconds is now renamed to connectionTimeoutSeconds",
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
if (options.masterNode) {
|
|
311
|
+
this.logger.warn(
|
|
312
|
+
"Deprecation warning: masterNode is now consolidated to nodes, starting with Typesense Server v0.12",
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
if (options.readReplicaNodes) {
|
|
316
|
+
this.logger.warn(
|
|
317
|
+
"Deprecation warning: readReplicaNodes is now consolidated to nodes, starting with Typesense Server v0.12",
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private shuffleArray(array) {
|
|
323
|
+
for (let i = array.length - 1; i > 0; i--) {
|
|
324
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
325
|
+
[array[i], array[j]] = [array[j], array[i]];
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import Conversations from "./Conversations";
|
|
3
|
+
|
|
4
|
+
export interface ConversationDeleteSchema {
|
|
5
|
+
id: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ConversationUpdateSchema {
|
|
9
|
+
ttl: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ConversationSchema {
|
|
13
|
+
id: number;
|
|
14
|
+
conversation: object[];
|
|
15
|
+
last_updated: number;
|
|
16
|
+
ttl: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class Conversation {
|
|
20
|
+
constructor(
|
|
21
|
+
private id: string,
|
|
22
|
+
private apiCall: ApiCall,
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
async retrieve(): Promise<ConversationSchema[]> {
|
|
26
|
+
return this.apiCall.get<ConversationSchema[]>(this.endpointPath());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async update(
|
|
30
|
+
params: ConversationUpdateSchema,
|
|
31
|
+
): Promise<ConversationUpdateSchema> {
|
|
32
|
+
return this.apiCall.put<ConversationUpdateSchema>(
|
|
33
|
+
this.endpointPath(),
|
|
34
|
+
params,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async delete(): Promise<ConversationDeleteSchema> {
|
|
39
|
+
return this.apiCall.delete<ConversationDeleteSchema>(this.endpointPath());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private endpointPath(): string {
|
|
43
|
+
return `${Conversations.RESOURCEPATH}/${encodeURIComponent(this.id)}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import ConversationModels from "./ConversationModels";
|
|
3
|
+
|
|
4
|
+
export interface ConversationModelCreateSchema {
|
|
5
|
+
id?: string;
|
|
6
|
+
model_name: string;
|
|
7
|
+
api_key?: string;
|
|
8
|
+
system_prompt?: string;
|
|
9
|
+
max_bytes: number;
|
|
10
|
+
history_collection?: string;
|
|
11
|
+
account_id?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
ttl?: number;
|
|
14
|
+
vllm_url?: string;
|
|
15
|
+
openai_url?: string;
|
|
16
|
+
openai_path?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ConversationModelDeleteSchema {
|
|
20
|
+
id: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ConversationModelSchema extends ConversationModelCreateSchema {
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default class ConversationModel {
|
|
28
|
+
constructor(
|
|
29
|
+
private id: string,
|
|
30
|
+
private apiCall: ApiCall,
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
async update(
|
|
34
|
+
params: ConversationModelCreateSchema,
|
|
35
|
+
): Promise<ConversationModelCreateSchema> {
|
|
36
|
+
return this.apiCall.put<ConversationModelCreateSchema>(
|
|
37
|
+
this.endpointPath(),
|
|
38
|
+
params,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async retrieve(): Promise<ConversationModelSchema> {
|
|
43
|
+
return this.apiCall.get<ConversationModelSchema>(this.endpointPath());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async delete(): Promise<ConversationModelDeleteSchema> {
|
|
47
|
+
return this.apiCall.delete<ConversationModelDeleteSchema>(
|
|
48
|
+
this.endpointPath(),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private endpointPath(): string {
|
|
53
|
+
return `${ConversationModels.RESOURCEPATH}/${encodeURIComponent(this.id)}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import {
|
|
3
|
+
ConversationModelCreateSchema,
|
|
4
|
+
ConversationModelSchema,
|
|
5
|
+
} from "./ConversationModel";
|
|
6
|
+
|
|
7
|
+
const RESOURCEPATH = "/conversations/models";
|
|
8
|
+
|
|
9
|
+
export default class ConversationModels {
|
|
10
|
+
constructor(private readonly apiCall: ApiCall) {
|
|
11
|
+
this.apiCall = apiCall;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async create(
|
|
15
|
+
params: ConversationModelCreateSchema,
|
|
16
|
+
): Promise<ConversationModelCreateSchema> {
|
|
17
|
+
return this.apiCall.post<ConversationModelCreateSchema>(
|
|
18
|
+
this.endpointPath(),
|
|
19
|
+
params,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async retrieve(): Promise<ConversationModelSchema[]> {
|
|
24
|
+
return this.apiCall.get<ConversationModelSchema[]>(
|
|
25
|
+
this.endpointPath(),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private endpointPath(operation?: string): string {
|
|
30
|
+
return `${ConversationModels.RESOURCEPATH}${
|
|
31
|
+
operation === undefined ? "" : "/" + encodeURIComponent(operation)
|
|
32
|
+
}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static get RESOURCEPATH() {
|
|
36
|
+
return RESOURCEPATH;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import ConversationModels from "./ConversationModels";
|
|
3
|
+
import ConversationModel from "./ConversationModel";
|
|
4
|
+
import { ConversationSchema } from "./Conversation";
|
|
5
|
+
|
|
6
|
+
const RESOURCEPATH = "/conversations";
|
|
7
|
+
|
|
8
|
+
export interface ConversationsRetrieveSchema {
|
|
9
|
+
conversations: ConversationSchema[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default class Conversations {
|
|
13
|
+
private readonly _conversationsModels: ConversationModels;
|
|
14
|
+
private readonly individualConversationModels: Record<
|
|
15
|
+
string,
|
|
16
|
+
ConversationModel
|
|
17
|
+
> = {};
|
|
18
|
+
|
|
19
|
+
constructor(private readonly apiCall: ApiCall) {
|
|
20
|
+
this.apiCall = apiCall;
|
|
21
|
+
this._conversationsModels = new ConversationModels(this.apiCall);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async retrieve(): Promise<ConversationsRetrieveSchema> {
|
|
25
|
+
return this.apiCall.get<ConversationsRetrieveSchema>(RESOURCEPATH);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
models(): ConversationModels;
|
|
29
|
+
models(id: string): ConversationModel;
|
|
30
|
+
models(id?: string): ConversationModels | ConversationModel {
|
|
31
|
+
if (id === undefined) {
|
|
32
|
+
return this._conversationsModels;
|
|
33
|
+
} else {
|
|
34
|
+
if (this.individualConversationModels[id] === undefined) {
|
|
35
|
+
this.individualConversationModels[id] = new ConversationModel(
|
|
36
|
+
id,
|
|
37
|
+
this.apiCall,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return this.individualConversationModels[id];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static get RESOURCEPATH() {
|
|
45
|
+
return RESOURCEPATH;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import CurationSets from "./CurationSets";
|
|
3
|
+
import type {
|
|
4
|
+
CurationSetDeleteResponseSchema,
|
|
5
|
+
CurationSetSchema,
|
|
6
|
+
CurationSetUpsertSchema,
|
|
7
|
+
} from "./CurationSets";
|
|
8
|
+
import CurationSetItems from "./CurationSetItems";
|
|
9
|
+
import CurationSetItem from "./CurationSetItem";
|
|
10
|
+
|
|
11
|
+
export default class CurationSet {
|
|
12
|
+
private readonly _items: CurationSetItems;
|
|
13
|
+
private individualItems: Record<string, CurationSetItem> = {};
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
private name: string,
|
|
17
|
+
private apiCall: ApiCall,
|
|
18
|
+
) {
|
|
19
|
+
this._items = new CurationSetItems(this.name, apiCall);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async upsert(params: CurationSetUpsertSchema): Promise<CurationSetSchema> {
|
|
23
|
+
return this.apiCall.put<CurationSetSchema>(this.endpointPath(), params);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async retrieve(): Promise<CurationSetSchema> {
|
|
27
|
+
return this.apiCall.get<CurationSetSchema>(this.endpointPath());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async delete(): Promise<CurationSetDeleteResponseSchema> {
|
|
31
|
+
return this.apiCall.delete<CurationSetDeleteResponseSchema>(
|
|
32
|
+
this.endpointPath(),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
items(): CurationSetItems;
|
|
37
|
+
items(itemId: string): CurationSetItem;
|
|
38
|
+
items(itemId?: string): CurationSetItems | CurationSetItem {
|
|
39
|
+
if (itemId === undefined) {
|
|
40
|
+
return this._items;
|
|
41
|
+
} else {
|
|
42
|
+
if (this.individualItems[itemId] === undefined) {
|
|
43
|
+
this.individualItems[itemId] = new CurationSetItem(
|
|
44
|
+
this.name,
|
|
45
|
+
itemId,
|
|
46
|
+
this.apiCall,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return this.individualItems[itemId];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private endpointPath(): string {
|
|
54
|
+
return `${CurationSets.RESOURCEPATH}/${encodeURIComponent(this.name)}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import CurationSets from "./CurationSets";
|
|
3
|
+
import type { CurationObjectSchema } from "./CurationSets";
|
|
4
|
+
|
|
5
|
+
export interface CurationItemDeleteResponseSchema {
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class CurationSetItem {
|
|
10
|
+
constructor(
|
|
11
|
+
private name: string,
|
|
12
|
+
private itemId: string,
|
|
13
|
+
private apiCall: ApiCall,
|
|
14
|
+
) {}
|
|
15
|
+
|
|
16
|
+
async retrieve(): Promise<CurationObjectSchema> {
|
|
17
|
+
return this.apiCall.get<CurationObjectSchema>(this.endpointPath());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async upsert(params: CurationObjectSchema): Promise<CurationObjectSchema> {
|
|
21
|
+
return this.apiCall.put<CurationObjectSchema>(this.endpointPath(), params);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async delete(): Promise<CurationItemDeleteResponseSchema> {
|
|
25
|
+
return this.apiCall.delete<CurationItemDeleteResponseSchema>(
|
|
26
|
+
this.endpointPath(),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private endpointPath(): string {
|
|
31
|
+
return `${CurationSets.RESOURCEPATH}/${encodeURIComponent(
|
|
32
|
+
this.name,
|
|
33
|
+
)}/items/${encodeURIComponent(this.itemId)}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import CurationSets, { CurationObjectSchema } from "./CurationSets";
|
|
3
|
+
|
|
4
|
+
export default class CurationSetItems {
|
|
5
|
+
constructor(private name: string, private apiCall: ApiCall) {}
|
|
6
|
+
|
|
7
|
+
async retrieve(): Promise<CurationObjectSchema[]> {
|
|
8
|
+
return this.apiCall.get<CurationObjectSchema[]>(this.endpointPath());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
private endpointPath(operation?: string): string {
|
|
12
|
+
return `${CurationSets.RESOURCEPATH}/${encodeURIComponent(this.name)}/items${
|
|
13
|
+
operation === undefined ? "" : "/" + encodeURIComponent(operation)
|
|
14
|
+
}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
|
|
3
|
+
export type CurationRuleSchema =
|
|
4
|
+
| { tags: string[]; query?: never; match?: never; filter_by?: never }
|
|
5
|
+
| {
|
|
6
|
+
query: string;
|
|
7
|
+
match: "exact" | "contains";
|
|
8
|
+
tags?: never;
|
|
9
|
+
filter_by?: never;
|
|
10
|
+
}
|
|
11
|
+
| { filter_by: string; tags?: never; query?: never; match?: never };
|
|
12
|
+
|
|
13
|
+
export interface CurationObjectSchema {
|
|
14
|
+
id: string;
|
|
15
|
+
rule: CurationRuleSchema;
|
|
16
|
+
includes?: {
|
|
17
|
+
id: string;
|
|
18
|
+
position: number;
|
|
19
|
+
}[];
|
|
20
|
+
excludes?: {
|
|
21
|
+
id: string;
|
|
22
|
+
}[];
|
|
23
|
+
filter_by?: string;
|
|
24
|
+
sort_by?: string;
|
|
25
|
+
replace_query?: string;
|
|
26
|
+
remove_matched_tokens?: boolean;
|
|
27
|
+
filter_curated_hits?: boolean;
|
|
28
|
+
stop_processing?: boolean;
|
|
29
|
+
effective_from_ts?: number;
|
|
30
|
+
effective_to_ts?: number;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CurationSetUpsertSchema {
|
|
35
|
+
items: CurationObjectSchema[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface CurationSetSchema extends CurationSetUpsertSchema {
|
|
39
|
+
name?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CurationSetsListEntrySchema {
|
|
43
|
+
name: string;
|
|
44
|
+
items: CurationObjectSchema[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface CurationSetDeleteResponseSchema {
|
|
48
|
+
name: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default class CurationSets {
|
|
52
|
+
constructor(private apiCall: ApiCall) {}
|
|
53
|
+
static readonly RESOURCEPATH = "/curation_sets";
|
|
54
|
+
|
|
55
|
+
async retrieve(): Promise<CurationSetsListEntrySchema[]> {
|
|
56
|
+
return this.apiCall.get<CurationSetsListEntrySchema[]>(
|
|
57
|
+
CurationSets.RESOURCEPATH,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
|
|
3
|
+
const RESOURCEPATH = "/debug";
|
|
4
|
+
|
|
5
|
+
export interface DebugResponseSchema {
|
|
6
|
+
state: number;
|
|
7
|
+
version: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default class Debug {
|
|
11
|
+
constructor(private apiCall: ApiCall) {}
|
|
12
|
+
|
|
13
|
+
async retrieve(): Promise<DebugResponseSchema> {
|
|
14
|
+
return this.apiCall.get<DebugResponseSchema>(RESOURCEPATH);
|
|
15
|
+
}
|
|
16
|
+
}
|