@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,9 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import { CurationObjectSchema } from "./CurationSets";
|
|
3
|
+
export default class CurationSetItems {
|
|
4
|
+
private name;
|
|
5
|
+
private apiCall;
|
|
6
|
+
constructor(name: string, apiCall: ApiCall);
|
|
7
|
+
retrieve(): Promise<CurationObjectSchema[]>;
|
|
8
|
+
private endpointPath;
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var CurationSets_1 = tslib_1.__importDefault(require("./CurationSets"));
|
|
5
|
+
var CurationSetItems = /** @class */ (function () {
|
|
6
|
+
function CurationSetItems(name, apiCall) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.apiCall = apiCall;
|
|
9
|
+
}
|
|
10
|
+
CurationSetItems.prototype.retrieve = function () {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
12
|
+
return tslib_1.__generator(this, function (_a) {
|
|
13
|
+
return [2 /*return*/, this.apiCall.get(this.endpointPath())];
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
CurationSetItems.prototype.endpointPath = function (operation) {
|
|
18
|
+
return "".concat(CurationSets_1.default.RESOURCEPATH, "/").concat(encodeURIComponent(this.name), "/items").concat(operation === undefined ? "" : "/" + encodeURIComponent(operation));
|
|
19
|
+
};
|
|
20
|
+
return CurationSetItems;
|
|
21
|
+
}());
|
|
22
|
+
exports.default = CurationSetItems;
|
|
23
|
+
//# sourceMappingURL=CurationSetItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurationSetItems.js","sourceRoot":"","sources":["../../src/Typesense/CurationSetItems.ts"],"names":[],"mappings":";;;AACA,wEAAoE;AAEpE;IACE,0BAAoB,IAAY,EAAU,OAAgB;QAAtC,SAAI,GAAJ,IAAI,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAExD,mCAAQ,GAAd;;;gBACE,sBAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAyB,IAAI,CAAC,YAAY,EAAE,CAAC,EAAC;;;KACtE;IAEO,uCAAY,GAApB,UAAqB,SAAkB;QACrC,OAAO,UAAG,sBAAY,CAAC,YAAY,cAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,mBAClE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAClE,CAAC;IACL,CAAC;IACH,uBAAC;AAAD,CAAC,AAZD,IAYC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
export type CurationRuleSchema = {
|
|
3
|
+
tags: string[];
|
|
4
|
+
query?: never;
|
|
5
|
+
match?: never;
|
|
6
|
+
filter_by?: never;
|
|
7
|
+
} | {
|
|
8
|
+
query: string;
|
|
9
|
+
match: "exact" | "contains";
|
|
10
|
+
tags?: never;
|
|
11
|
+
filter_by?: never;
|
|
12
|
+
} | {
|
|
13
|
+
filter_by: string;
|
|
14
|
+
tags?: never;
|
|
15
|
+
query?: never;
|
|
16
|
+
match?: never;
|
|
17
|
+
};
|
|
18
|
+
export interface CurationObjectSchema {
|
|
19
|
+
id: string;
|
|
20
|
+
rule: CurationRuleSchema;
|
|
21
|
+
includes?: {
|
|
22
|
+
id: string;
|
|
23
|
+
position: number;
|
|
24
|
+
}[];
|
|
25
|
+
excludes?: {
|
|
26
|
+
id: string;
|
|
27
|
+
}[];
|
|
28
|
+
filter_by?: string;
|
|
29
|
+
sort_by?: string;
|
|
30
|
+
replace_query?: string;
|
|
31
|
+
remove_matched_tokens?: boolean;
|
|
32
|
+
filter_curated_hits?: boolean;
|
|
33
|
+
stop_processing?: boolean;
|
|
34
|
+
effective_from_ts?: number;
|
|
35
|
+
effective_to_ts?: number;
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface CurationSetUpsertSchema {
|
|
39
|
+
items: CurationObjectSchema[];
|
|
40
|
+
}
|
|
41
|
+
export interface CurationSetSchema extends CurationSetUpsertSchema {
|
|
42
|
+
name?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CurationSetsListEntrySchema {
|
|
45
|
+
name: string;
|
|
46
|
+
items: CurationObjectSchema[];
|
|
47
|
+
}
|
|
48
|
+
export interface CurationSetDeleteResponseSchema {
|
|
49
|
+
name: string;
|
|
50
|
+
}
|
|
51
|
+
export default class CurationSets {
|
|
52
|
+
private apiCall;
|
|
53
|
+
constructor(apiCall: ApiCall);
|
|
54
|
+
static readonly RESOURCEPATH = "/curation_sets";
|
|
55
|
+
retrieve(): Promise<CurationSetsListEntrySchema[]>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var CurationSets = /** @class */ (function () {
|
|
5
|
+
function CurationSets(apiCall) {
|
|
6
|
+
this.apiCall = apiCall;
|
|
7
|
+
}
|
|
8
|
+
CurationSets.prototype.retrieve = function () {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
10
|
+
return tslib_1.__generator(this, function (_a) {
|
|
11
|
+
return [2 /*return*/, this.apiCall.get(CurationSets.RESOURCEPATH)];
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
CurationSets.RESOURCEPATH = "/curation_sets";
|
|
16
|
+
return CurationSets;
|
|
17
|
+
}());
|
|
18
|
+
exports.default = CurationSets;
|
|
19
|
+
//# sourceMappingURL=CurationSets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurationSets.js","sourceRoot":"","sources":["../../src/Typesense/CurationSets.ts"],"names":[],"mappings":";;;AAkDA;IACE,sBAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAGlC,+BAAQ,GAAd;;;gBACE,sBAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,YAAY,CAAC,YAAY,CAC1B,EAAC;;;KACH;IANe,yBAAY,GAAG,gBAAgB,CAAC;IAOlD,mBAAC;CAAA,AATD,IASC;kBAToB,YAAY"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var RESOURCEPATH = "/debug";
|
|
5
|
+
var Debug = /** @class */ (function () {
|
|
6
|
+
function Debug(apiCall) {
|
|
7
|
+
this.apiCall = apiCall;
|
|
8
|
+
}
|
|
9
|
+
Debug.prototype.retrieve = function () {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
11
|
+
return tslib_1.__generator(this, function (_a) {
|
|
12
|
+
return [2 /*return*/, this.apiCall.get(RESOURCEPATH)];
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
return Debug;
|
|
17
|
+
}());
|
|
18
|
+
exports.default = Debug;
|
|
19
|
+
//# sourceMappingURL=Debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Debug.js","sourceRoot":"","sources":["../../src/Typesense/Debug.ts"],"names":[],"mappings":";;;AAEA,IAAM,YAAY,GAAG,QAAQ,CAAC;AAO9B;IACE,eAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAElC,wBAAQ,GAAd;;;gBACE,sBAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAsB,YAAY,CAAC,EAAC;;;KAC5D;IACH,YAAC;AAAD,CAAC,AAND,IAMC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ApiCall from "./ApiCall";
|
|
2
|
+
import { DeleteQuery, DocumentSchema, DocumentWriteParameters } from "./Documents";
|
|
3
|
+
export declare class Document<T extends DocumentSchema = object> {
|
|
4
|
+
private collectionName;
|
|
5
|
+
private documentId;
|
|
6
|
+
private apiCall;
|
|
7
|
+
constructor(collectionName: string, documentId: string, apiCall: ApiCall);
|
|
8
|
+
retrieve(): Promise<T>;
|
|
9
|
+
delete(options?: DeleteQuery): Promise<T>;
|
|
10
|
+
update(partialDocument: Partial<T>, options?: DocumentWriteParameters): Promise<T>;
|
|
11
|
+
private endpointPath;
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Document = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var Collections_1 = tslib_1.__importDefault(require("./Collections"));
|
|
6
|
+
var Documents_1 = tslib_1.__importDefault(require("./Documents"));
|
|
7
|
+
var Document = /** @class */ (function () {
|
|
8
|
+
function Document(collectionName, documentId, apiCall) {
|
|
9
|
+
this.collectionName = collectionName;
|
|
10
|
+
this.documentId = documentId;
|
|
11
|
+
this.apiCall = apiCall;
|
|
12
|
+
}
|
|
13
|
+
Document.prototype.retrieve = function () {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
15
|
+
return tslib_1.__generator(this, function (_a) {
|
|
16
|
+
return [2 /*return*/, this.apiCall.get(this.endpointPath())];
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Document.prototype.delete = function (options) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
22
|
+
return tslib_1.__generator(this, function (_a) {
|
|
23
|
+
return [2 /*return*/, this.apiCall.delete(this.endpointPath(), options)];
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
Document.prototype.update = function (partialDocument_1) {
|
|
28
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (partialDocument, options) {
|
|
29
|
+
if (options === void 0) { options = {}; }
|
|
30
|
+
return tslib_1.__generator(this, function (_a) {
|
|
31
|
+
return [2 /*return*/, this.apiCall.patch(this.endpointPath(), partialDocument, options)];
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
Document.prototype.endpointPath = function () {
|
|
36
|
+
return "".concat(Collections_1.default.RESOURCEPATH, "/").concat(encodeURIComponent(this.collectionName)).concat(Documents_1.default.RESOURCEPATH, "/").concat(encodeURIComponent(this.documentId));
|
|
37
|
+
};
|
|
38
|
+
return Document;
|
|
39
|
+
}());
|
|
40
|
+
exports.Document = Document;
|
|
41
|
+
//# sourceMappingURL=Document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Document.js","sourceRoot":"","sources":["../../src/Typesense/Document.ts"],"names":[],"mappings":";;;;AACA,sEAAwC;AACxC,kEAIqB;AAErB;IACE,kBACU,cAAsB,EACtB,UAAkB,EAClB,OAAgB;QAFhB,mBAAc,GAAd,cAAc,CAAQ;QACtB,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAS;IACvB,CAAC;IAEE,2BAAQ,GAAd;;;gBACE,sBAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAI,IAAI,CAAC,YAAY,EAAE,CAAC,EAAC;;;KACjD;IAEK,yBAAM,GAAZ,UAAa,OAAqB;;;gBAChC,sBAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAI,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,CAAC,EAAC;;;KAC7D;IAEK,yBAAM,GAAZ;oEACE,eAA2B,EAC3B,OAAqC;YAArC,wBAAA,EAAA,YAAqC;;gBAErC,sBAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAI,IAAI,CAAC,YAAY,EAAE,EAAE,eAAe,EAAE,OAAO,CAAC,EAAC;;;KAC7E;IAEO,+BAAY,GAApB;QACE,OAAO,UAAG,qBAAW,CAAC,YAAY,cAAI,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,SAAG,mBAAS,CAAC,YAAY,cAAI,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAE,CAAC;IAClJ,CAAC;IACH,eAAC;AAAD,CAAC,AAzBD,IAyBC;AAzBY,4BAAQ"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { ReadStream } from "fs";
|
|
2
|
+
import ApiCall from "./ApiCall";
|
|
3
|
+
import Configuration from "./Configuration";
|
|
4
|
+
import { SearchOnlyDocuments } from "./SearchOnlyDocuments";
|
|
5
|
+
import { SearchParams, SearchResponseRequestParams, WriteableDocuments } from "./Types";
|
|
6
|
+
export type DeleteQuery = {
|
|
7
|
+
truncate?: true;
|
|
8
|
+
} | {
|
|
9
|
+
truncate?: never;
|
|
10
|
+
filter_by?: string;
|
|
11
|
+
batch_size?: number;
|
|
12
|
+
ignore_not_found?: boolean;
|
|
13
|
+
return_doc?: boolean;
|
|
14
|
+
return_id?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export interface DeleteResponse<T extends DocumentSchema = DocumentSchema> {
|
|
17
|
+
num_deleted: number;
|
|
18
|
+
documents?: T[];
|
|
19
|
+
ids?: string[];
|
|
20
|
+
}
|
|
21
|
+
interface ImportResponseSuccess<T extends DocumentSchema = DocumentSchema> {
|
|
22
|
+
success: true;
|
|
23
|
+
error?: never;
|
|
24
|
+
document?: T;
|
|
25
|
+
id?: string;
|
|
26
|
+
code?: never;
|
|
27
|
+
}
|
|
28
|
+
export interface ImportResponseFail<T extends DocumentSchema = DocumentSchema> {
|
|
29
|
+
success: false;
|
|
30
|
+
error: string;
|
|
31
|
+
document?: T;
|
|
32
|
+
id?: string;
|
|
33
|
+
code: number;
|
|
34
|
+
}
|
|
35
|
+
export type ImportResponse<T extends DocumentSchema = DocumentSchema> = ImportResponseSuccess<T> | ImportResponseFail<T>;
|
|
36
|
+
export type DocumentSchema = Record<string, any>;
|
|
37
|
+
export interface SearchParamsWithPreset<T extends DocumentSchema, Infix extends string> extends Partial<SearchParams<T, Infix>> {
|
|
38
|
+
preset: string;
|
|
39
|
+
}
|
|
40
|
+
type SearchResponseHighlightObject = {
|
|
41
|
+
matched_tokens?: string[];
|
|
42
|
+
snippet?: string;
|
|
43
|
+
value?: string;
|
|
44
|
+
};
|
|
45
|
+
export type SearchResponseHighlight<T> = T extends string | number ? SearchResponseHighlightObject : {
|
|
46
|
+
[TAttribute in keyof T]?: SearchResponseHighlight<T[TAttribute]>;
|
|
47
|
+
};
|
|
48
|
+
export interface SearchResponseHit<T extends DocumentSchema> {
|
|
49
|
+
curated?: true;
|
|
50
|
+
highlights?: [
|
|
51
|
+
{
|
|
52
|
+
field: keyof T;
|
|
53
|
+
snippet?: string;
|
|
54
|
+
value?: string;
|
|
55
|
+
snippets?: string[];
|
|
56
|
+
indices?: number[];
|
|
57
|
+
matched_tokens: string[][] | string[];
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
highlight: SearchResponseHighlight<T>;
|
|
61
|
+
document: T;
|
|
62
|
+
text_match: number;
|
|
63
|
+
text_match_info?: {
|
|
64
|
+
best_field_score: `${number}`;
|
|
65
|
+
best_field_weight: number;
|
|
66
|
+
fields_matched: number;
|
|
67
|
+
score: `${number}`;
|
|
68
|
+
tokens_matched: number;
|
|
69
|
+
};
|
|
70
|
+
geo_distance_meters?: {
|
|
71
|
+
location: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface SearchResponseFacetCountSchema<T extends DocumentSchema> {
|
|
75
|
+
counts: {
|
|
76
|
+
count: number;
|
|
77
|
+
highlighted: string;
|
|
78
|
+
value: string;
|
|
79
|
+
parent?: Record<string, string | number | boolean>;
|
|
80
|
+
}[];
|
|
81
|
+
field_name: keyof T;
|
|
82
|
+
sampled: boolean;
|
|
83
|
+
stats: {
|
|
84
|
+
avg?: number;
|
|
85
|
+
max?: number;
|
|
86
|
+
min?: number;
|
|
87
|
+
sum?: number;
|
|
88
|
+
total_values?: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
interface LLMResponse {
|
|
92
|
+
content: string;
|
|
93
|
+
extraction_method: string;
|
|
94
|
+
model: string;
|
|
95
|
+
}
|
|
96
|
+
export interface SearchResponse<T extends DocumentSchema> {
|
|
97
|
+
facet_counts?: SearchResponseFacetCountSchema<T>[];
|
|
98
|
+
found: number;
|
|
99
|
+
found_docs?: number;
|
|
100
|
+
out_of: number;
|
|
101
|
+
page: number;
|
|
102
|
+
request_params: SearchResponseRequestParams;
|
|
103
|
+
search_time_ms: number;
|
|
104
|
+
search_cutoff?: boolean;
|
|
105
|
+
hits?: SearchResponseHit<T>[];
|
|
106
|
+
grouped_hits?: {
|
|
107
|
+
group_key: string[];
|
|
108
|
+
hits: SearchResponseHit<T>[];
|
|
109
|
+
found?: number;
|
|
110
|
+
}[];
|
|
111
|
+
parsed_nl_query?: {
|
|
112
|
+
parse_time_ms: number;
|
|
113
|
+
generated_params: SearchParams<T>;
|
|
114
|
+
augmented_params: SearchParams<T>;
|
|
115
|
+
llm_response?: LLMResponse;
|
|
116
|
+
};
|
|
117
|
+
conversation?: {
|
|
118
|
+
answer: string;
|
|
119
|
+
conversation_history: {
|
|
120
|
+
conversation: object[];
|
|
121
|
+
id: string;
|
|
122
|
+
last_updated: number;
|
|
123
|
+
ttl: number;
|
|
124
|
+
};
|
|
125
|
+
conversation_id: string;
|
|
126
|
+
query: string;
|
|
127
|
+
};
|
|
128
|
+
error?: string;
|
|
129
|
+
code?: number;
|
|
130
|
+
metadata?: JsonRecord;
|
|
131
|
+
}
|
|
132
|
+
type JSONPrimitive = string | number | boolean | null;
|
|
133
|
+
type JsonRecord = {
|
|
134
|
+
[key: string]: JSONPrimitive | JSONPrimitive[] | JsonRecord;
|
|
135
|
+
};
|
|
136
|
+
export interface DocumentWriteParameters {
|
|
137
|
+
dirty_values?: "coerce_or_reject" | "coerce_or_drop" | "drop" | "reject";
|
|
138
|
+
action?: "create" | "update" | "upsert" | "emplace";
|
|
139
|
+
}
|
|
140
|
+
export interface UpdateByFilterParameters {
|
|
141
|
+
filter_by?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface UpdateByFilterResponse {
|
|
144
|
+
num_updated: number;
|
|
145
|
+
}
|
|
146
|
+
export interface DocumentImportParameters extends DocumentWriteParameters {
|
|
147
|
+
batch_size?: number;
|
|
148
|
+
remote_embedding_batch_size?: number;
|
|
149
|
+
remote_embedding_timeout_ms?: number;
|
|
150
|
+
remote_embedding_num_tries?: number;
|
|
151
|
+
return_doc?: boolean;
|
|
152
|
+
return_id?: boolean;
|
|
153
|
+
throwOnFail?: boolean;
|
|
154
|
+
}
|
|
155
|
+
export interface DocumentsExportParameters {
|
|
156
|
+
filter_by?: string;
|
|
157
|
+
include_fields?: string;
|
|
158
|
+
exclude_fields?: string;
|
|
159
|
+
}
|
|
160
|
+
export interface SearchOptions {
|
|
161
|
+
cacheSearchResultsForSeconds?: number;
|
|
162
|
+
abortSignal?: AbortSignal | null;
|
|
163
|
+
}
|
|
164
|
+
export default class Documents<T extends DocumentSchema = object> extends SearchOnlyDocuments<T> implements WriteableDocuments<T> {
|
|
165
|
+
constructor(collectionName: string, apiCall: ApiCall, configuration: Configuration);
|
|
166
|
+
create(document: T, options?: DocumentWriteParameters): Promise<T>;
|
|
167
|
+
upsert(document: T, options?: DocumentWriteParameters): Promise<T>;
|
|
168
|
+
update(document: T, options: UpdateByFilterParameters): Promise<UpdateByFilterResponse>;
|
|
169
|
+
update(document: T, options: DocumentWriteParameters): Promise<T>;
|
|
170
|
+
delete(query?: DeleteQuery): Promise<DeleteResponse<T>>;
|
|
171
|
+
createMany(documents: T[], options?: DocumentImportParameters): Promise<ImportResponse<T>[]>;
|
|
172
|
+
/**
|
|
173
|
+
* Import a set of documents in a batch.
|
|
174
|
+
* @param {string|Array} documents - Can be a JSONL string of documents or an array of document objects.
|
|
175
|
+
* @param options
|
|
176
|
+
* @return {string|Array} Returns a JSONL string if the input was a JSONL string, otherwise it returns an array of results.
|
|
177
|
+
*/
|
|
178
|
+
import(documents: string, options?: DocumentImportParameters): Promise<string>;
|
|
179
|
+
import(documents: T[], options?: DocumentImportParameters): Promise<ImportResponse<T>[]>;
|
|
180
|
+
/**
|
|
181
|
+
* Imports documents from a NodeJS readable stream of JSONL.
|
|
182
|
+
*/
|
|
183
|
+
importStream(readableStream: ReadStream, options?: DocumentImportParameters): Promise<ImportResponse<T>[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Returns a JSONL string for all the documents in this collection
|
|
186
|
+
*/
|
|
187
|
+
export(options?: DocumentsExportParameters): Promise<string>;
|
|
188
|
+
/**
|
|
189
|
+
* Returns a NodeJS readable stream of JSONL for all the documents in this collection.
|
|
190
|
+
*/
|
|
191
|
+
exportStream(options?: DocumentsExportParameters): Promise<ReadStream>;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @deprecated Import from './Types' instead
|
|
195
|
+
*/
|
|
196
|
+
export type { SearchParams, WriteableDocuments, SearchableDocuments, DropTokensMode, OperationMode, UnionArrayKeys, UnionArraySearchParams, ArraybleParams, ExtractBaseTypes, SearchResponseRequestParams, } from "./Types";
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var Errors_1 = require("./Errors");
|
|
5
|
+
var SearchOnlyDocuments_1 = require("./SearchOnlyDocuments");
|
|
6
|
+
var isNodeJSEnvironment = typeof process !== "undefined" &&
|
|
7
|
+
process.versions != null &&
|
|
8
|
+
process.versions.node != null;
|
|
9
|
+
var Documents = /** @class */ (function (_super) {
|
|
10
|
+
tslib_1.__extends(Documents, _super);
|
|
11
|
+
function Documents(collectionName, apiCall, configuration) {
|
|
12
|
+
return _super.call(this, collectionName, apiCall, configuration) || this;
|
|
13
|
+
}
|
|
14
|
+
Documents.prototype.create = function (document_1) {
|
|
15
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (document, options) {
|
|
16
|
+
if (options === void 0) { options = {}; }
|
|
17
|
+
return tslib_1.__generator(this, function (_a) {
|
|
18
|
+
if (!document)
|
|
19
|
+
throw new Error("No document provided");
|
|
20
|
+
return [2 /*return*/, this.apiCall.post(this.endpointPath(), document, options)];
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
Documents.prototype.upsert = function (document_1) {
|
|
25
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (document, options) {
|
|
26
|
+
if (options === void 0) { options = {}; }
|
|
27
|
+
return tslib_1.__generator(this, function (_a) {
|
|
28
|
+
if (!document)
|
|
29
|
+
throw new Error("No document provided");
|
|
30
|
+
return [2 /*return*/, this.apiCall.post(this.endpointPath(), document, Object.assign({}, options, { action: "upsert" }))];
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Documents.prototype.update = function (document_1) {
|
|
35
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (document, options) {
|
|
36
|
+
if (options === void 0) { options = {}; }
|
|
37
|
+
return tslib_1.__generator(this, function (_a) {
|
|
38
|
+
if (!document)
|
|
39
|
+
throw new Error("No document provided");
|
|
40
|
+
if (options["filter_by"] != null) {
|
|
41
|
+
return [2 /*return*/, this.apiCall.patch(this.endpointPath(), document, Object.assign({}, options))];
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return [2 /*return*/, this.apiCall.post(this.endpointPath(), document, Object.assign({}, options, { action: "update" }))];
|
|
45
|
+
}
|
|
46
|
+
return [2 /*return*/];
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
Documents.prototype.delete = function () {
|
|
51
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (query) {
|
|
52
|
+
if (query === void 0) { query = {}; }
|
|
53
|
+
return tslib_1.__generator(this, function (_a) {
|
|
54
|
+
return [2 /*return*/, this.apiCall.delete(this.endpointPath(), query)];
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
Documents.prototype.createMany = function (documents_1) {
|
|
59
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (documents, options) {
|
|
60
|
+
if (options === void 0) { options = {}; }
|
|
61
|
+
return tslib_1.__generator(this, function (_a) {
|
|
62
|
+
this.configuration.logger.warn("createMany is deprecated and will be removed in a future version. Use import instead, which now takes both an array of documents or a JSONL string of documents");
|
|
63
|
+
return [2 /*return*/, this.import(documents, options)];
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
Documents.prototype.import = function (documents_1) {
|
|
68
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (documents, options) {
|
|
69
|
+
var finalOptions, documentsInJSONLFormat, resultsInJSONLFormat, resultsInJSONFormat, failedItems;
|
|
70
|
+
if (options === void 0) { options = {}; }
|
|
71
|
+
return tslib_1.__generator(this, function (_a) {
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
finalOptions = tslib_1.__assign({ throwOnFail: true }, options);
|
|
75
|
+
if (Array.isArray(documents)) {
|
|
76
|
+
if (documents.length === 0) {
|
|
77
|
+
throw new Errors_1.RequestMalformed("No documents provided");
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
documentsInJSONLFormat = documents
|
|
81
|
+
.map(function (document) { return JSON.stringify(document); })
|
|
82
|
+
.join("\n");
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
// if rangeerror, throw custom error message
|
|
86
|
+
if (error instanceof RangeError &&
|
|
87
|
+
error.message.includes("Too many properties to enumerate")) {
|
|
88
|
+
throw new Error("".concat(error, "\n It looks like you have reached a Node.js limit that restricts the number of keys in an Object: https://stackoverflow.com/questions/9282869/are-there-limits-to-the-number-of-properties-in-a-javascript-object\n\n Please try reducing the number of keys in your document, or using CURL to import your data.\n "));
|
|
89
|
+
}
|
|
90
|
+
// else, throw the non-range error anyways
|
|
91
|
+
throw new Error(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
documentsInJSONLFormat = documents;
|
|
96
|
+
if (isEmptyString(documentsInJSONLFormat)) {
|
|
97
|
+
throw new Errors_1.RequestMalformed("No documents provided");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [4 /*yield*/, this.apiCall.performRequest("post", this.endpointPath("import"), {
|
|
101
|
+
queryParameters: finalOptions,
|
|
102
|
+
bodyParameters: documentsInJSONLFormat,
|
|
103
|
+
additionalHeaders: { "Content-Type": "text/plain" },
|
|
104
|
+
skipConnectionTimeout: true, // We never want to client-side-timeout on an import and retry, since imports are syncronous and we want to let them take as long as it takes to complete fully
|
|
105
|
+
enableKeepAlive: isNodeJSEnvironment ? true : false, // This is to prevent ECONNRESET socket hang up errors. Reference: https://github.com/axios/axios/issues/2936#issuecomment-779439991
|
|
106
|
+
})];
|
|
107
|
+
case 1:
|
|
108
|
+
resultsInJSONLFormat = _a.sent();
|
|
109
|
+
if (Array.isArray(documents)) {
|
|
110
|
+
resultsInJSONFormat = resultsInJSONLFormat
|
|
111
|
+
.split("\n")
|
|
112
|
+
.map(function (r) { return JSON.parse(r); });
|
|
113
|
+
failedItems = resultsInJSONFormat.filter(function (r) { return r.success === false; });
|
|
114
|
+
if (failedItems.length > 0 && finalOptions.throwOnFail) {
|
|
115
|
+
throw new Errors_1.ImportError("".concat(resultsInJSONFormat.length - failedItems.length, " documents imported successfully, ").concat(failedItems.length, " documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."), resultsInJSONFormat, {
|
|
116
|
+
documentsInJSONLFormat: documentsInJSONLFormat,
|
|
117
|
+
options: finalOptions,
|
|
118
|
+
failedItems: failedItems,
|
|
119
|
+
successCount: resultsInJSONFormat.length - failedItems.length,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
return [2 /*return*/, resultsInJSONFormat];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return [2 /*return*/, resultsInJSONLFormat];
|
|
128
|
+
}
|
|
129
|
+
return [2 /*return*/];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Imports documents from a NodeJS readable stream of JSONL.
|
|
136
|
+
*/
|
|
137
|
+
Documents.prototype.importStream = function (readableStream_1) {
|
|
138
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (readableStream, options) {
|
|
139
|
+
var finalOptions, resultsInJSONLFormat, resultsInJSONFormat, failedItems;
|
|
140
|
+
if (options === void 0) { options = {}; }
|
|
141
|
+
return tslib_1.__generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
finalOptions = tslib_1.__assign({ throwOnFail: true }, options);
|
|
145
|
+
return [4 /*yield*/, this.apiCall.performRequest("post", this.endpointPath("import"), {
|
|
146
|
+
queryParameters: finalOptions,
|
|
147
|
+
bodyParameters: readableStream,
|
|
148
|
+
additionalHeaders: { "Content-Type": "text/plain" },
|
|
149
|
+
skipConnectionTimeout: true, // We never want to client-side-timeout on an import and retry, since imports are syncronous and we want to let them take as long as it takes to complete fully
|
|
150
|
+
enableKeepAlive: isNodeJSEnvironment ? true : false, // This is to prevent ECONNRESET socket hang up errors. Reference: https://github.com/axios/axios/issues/2936#issuecomment-779439991
|
|
151
|
+
})];
|
|
152
|
+
case 1:
|
|
153
|
+
resultsInJSONLFormat = _a.sent();
|
|
154
|
+
resultsInJSONFormat = resultsInJSONLFormat
|
|
155
|
+
.split("\n")
|
|
156
|
+
.map(function (r) { return JSON.parse(r); });
|
|
157
|
+
failedItems = resultsInJSONFormat.filter(function (r) { return r.success === false; });
|
|
158
|
+
if (failedItems.length > 0 && finalOptions.throwOnFail) {
|
|
159
|
+
throw new Errors_1.ImportError("".concat(resultsInJSONFormat.length - failedItems.length, " documents imported successfully, ").concat(failedItems.length, " documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."), resultsInJSONFormat, {
|
|
160
|
+
documentsInJSONLFormat: readableStream,
|
|
161
|
+
options: finalOptions,
|
|
162
|
+
failedItems: failedItems,
|
|
163
|
+
successCount: resultsInJSONFormat.length - failedItems.length,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
return [2 /*return*/, resultsInJSONFormat];
|
|
168
|
+
}
|
|
169
|
+
return [2 /*return*/];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Returns a JSONL string for all the documents in this collection
|
|
176
|
+
*/
|
|
177
|
+
Documents.prototype.export = function () {
|
|
178
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (options) {
|
|
179
|
+
if (options === void 0) { options = {}; }
|
|
180
|
+
return tslib_1.__generator(this, function (_a) {
|
|
181
|
+
return [2 /*return*/, this.apiCall.get(this.endpointPath("export"), options)];
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Returns a NodeJS readable stream of JSONL for all the documents in this collection.
|
|
187
|
+
*/
|
|
188
|
+
Documents.prototype.exportStream = function () {
|
|
189
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (options) {
|
|
190
|
+
if (options === void 0) { options = {}; }
|
|
191
|
+
return tslib_1.__generator(this, function (_a) {
|
|
192
|
+
return [2 /*return*/, this.apiCall.get(this.endpointPath("export"), options, {
|
|
193
|
+
responseType: "stream",
|
|
194
|
+
})];
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
return Documents;
|
|
199
|
+
}(SearchOnlyDocuments_1.SearchOnlyDocuments));
|
|
200
|
+
exports.default = Documents;
|
|
201
|
+
function isEmptyString(str) {
|
|
202
|
+
return str == null || str === "" || str.length === 0;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=Documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Documents.js","sourceRoot":"","sources":["../../src/Typesense/Documents.ts"],"names":[],"mappings":";;;AAGA,mCAAyD;AACzD,6DAA4D;AAmM5D,IAAM,mBAAmB,GACvB,OAAO,OAAO,KAAK,WAAW;IAC9B,OAAO,CAAC,QAAQ,IAAI,IAAI;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC;AAEhC;IACU,qCAAsB;IAG9B,mBACE,cAAsB,EACtB,OAAgB,EAChB,aAA4B;QAE5B,OAAA,MAAK,YAAC,cAAc,EAAE,OAAO,EAAE,aAAa,CAAC,SAAC;IAChD,CAAC;IAEK,0BAAM,GAAZ;oEAAa,QAAW,EAAE,OAAqC;YAArC,wBAAA,EAAA,YAAqC;;gBAC7D,IAAI,CAAC,QAAQ;oBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACvD,sBAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAI,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAC;;;KACrE;IAEK,0BAAM,GAAZ;oEAAa,QAAW,EAAE,OAAqC;YAArC,wBAAA,EAAA,YAAqC;;gBAC7D,IAAI,CAAC,QAAQ;oBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACvD,sBAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,IAAI,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E;IAED;;OAEG;IACG,gCAAY,GAAlB;oEACE,OAAuC;YAAvC,wBAAA,EAAA,YAAuC;;gBAEvC,sBAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAa,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE;wBACxE,YAAY,EAAE,QAAQ;qBACvB,CAAC,EAAC;;;KACJ;IACH,gBAAC;AAAD,CAAC,AA5ND,CACU,yCAAmB,GA2N5B;;AAED,SAAS,aAAa,CAAC,GAA8B;IACnD,OAAO,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var TypesenseError_1 = tslib_1.__importDefault(require("./TypesenseError"));
|
|
5
|
+
var HTTPError = /** @class */ (function (_super) {
|
|
6
|
+
tslib_1.__extends(HTTPError, _super);
|
|
7
|
+
function HTTPError() {
|
|
8
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
9
|
+
}
|
|
10
|
+
return HTTPError;
|
|
11
|
+
}(TypesenseError_1.default));
|
|
12
|
+
exports.default = HTTPError;
|
|
13
|
+
//# sourceMappingURL=HTTPError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTTPError.js","sourceRoot":"","sources":["../../../src/Typesense/Errors/HTTPError.ts"],"names":[],"mappings":";;;AAAA,4EAA8C;AAE9C;IAAuC,qCAAc;IAArD;;IAAuD,CAAC;IAAD,gBAAC;AAAD,CAAC,AAAxD,CAAuC,wBAAc,GAAG"}
|