@devbookhq/extension-admin
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -24,9 +24,9 @@ export declare enum APIVersion { | ||
private request; | ||
search(indexes: string[] | string, query: string, pageSize?: number, pageNumber?: number): Promise<Entry[]>; | ||
search(indexOrIndexes: string[] | string, query: string, pageSize?: number, pageNumber?: number): Promise<Required<Entry>[]>; | ||
index(index: string, entries: Entry[]): Promise<void>; | ||
delete(index: string): Promise<void>; | ||
entry(index: string, id: string): Promise<Entry>; | ||
entry(index: string, id: string): Promise<Required<Entry>>; | ||
entries(index: string, pageSize?: number, pageID?: string): Promise<{ | ||
entries: Entry[]; | ||
pageID: string; | ||
entries: Required<Entry>[]; | ||
pageID: string | undefined; | ||
}>; | ||
@@ -33,0 +33,0 @@ info(): Promise<ExtensionInfo>; |
@@ -59,3 +59,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var method, route, data, params, result; | ||
var method, route, data, params, result, error_1; | ||
return __generator(this, function (_a) { | ||
@@ -65,2 +65,5 @@ switch (_a.label) { | ||
method = options.method, route = options.route, data = options.data, params = options.params; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, axios_1.default({ | ||
@@ -73,7 +76,17 @@ url: "https://api.usedevbook.com/" + this.apiVersion + "/extension/" + this.extensionID + (route ? route : ''), | ||
'Authorization': "ApiKey " + this.secretAPIKey, | ||
} | ||
}, | ||
})]; | ||
case 1: | ||
case 2: | ||
result = _a.sent(); | ||
return [2 /*return*/, result.data]; | ||
case 3: | ||
error_1 = _a.sent(); | ||
if (error_1.response) { | ||
throw new Error(error_1.response.data.error.message); | ||
} | ||
else { | ||
throw error_1; | ||
} | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -83,7 +96,14 @@ }); | ||
}; | ||
Devbook.prototype.search = function (indexes, query, pageSize, pageNumber) { | ||
Devbook.prototype.search = function (indexOrIndexes, query, pageSize, pageNumber) { | ||
if (pageSize === void 0) { pageSize = 10; } | ||
if (pageNumber === void 0) { pageNumber = 0; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var indexes; | ||
return __generator(this, function (_a) { | ||
if (typeof indexOrIndexes === 'string') { | ||
indexes = [indexOrIndexes]; | ||
} | ||
else { | ||
indexes = indexOrIndexes; | ||
} | ||
return [2 /*return*/, this.request({ | ||
@@ -93,3 +113,2 @@ method: 'POST', | ||
params: { | ||
indexes: indexes, | ||
pageSize: pageSize, | ||
@@ -99,2 +118,3 @@ pageNumber: pageNumber, | ||
data: { | ||
indexes: indexes, | ||
query: query, | ||
@@ -147,11 +167,17 @@ }, | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.request({ | ||
method: 'GET', | ||
route: "/entry", | ||
params: { | ||
index: index, | ||
entryID: id, | ||
}, | ||
})]; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.request({ | ||
method: 'GET', | ||
route: "/entry", | ||
params: { | ||
index: index, | ||
entryID: id, | ||
}, | ||
})]; | ||
case 1: | ||
data = _a.sent(); | ||
return [2 /*return*/, data.entry]; | ||
} | ||
}); | ||
@@ -163,12 +189,18 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.request({ | ||
method: 'GET', | ||
route: '/entry', | ||
params: { | ||
index: index, | ||
pageSize: pageSize, | ||
pageID: pageID, | ||
} | ||
})]; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.request({ | ||
method: 'GET', | ||
route: '/entry', | ||
params: { | ||
index: index, | ||
pageSize: pageSize, | ||
pageID: pageID, | ||
} | ||
})]; | ||
case 1: | ||
data = _a.sent(); | ||
return [2 /*return*/, data]; | ||
} | ||
}); | ||
@@ -175,0 +207,0 @@ }); |
{ | ||
"name": "@devbookhq/extension-admin", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"lockfileVersion": 1, | ||
@@ -5,0 +5,0 @@ "requires": true, |
{ | ||
"name": "@devbookhq/extension-admin", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "NodeJS wrapper around the Devbook extension API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -48,5 +48,4 @@ # Devbook Extension Node.js library | ||
// Arguments: | ||
// - Data index from where you want to delete the data. | ||
// - IDs of entries in the index. | ||
await devbook.delete('indexName', ['entryID-1', 'entryID-2']); | ||
// - Data index from where you want to delete the all the data. | ||
await devbook.delete('indexName'); | ||
@@ -53,0 +52,0 @@ // Read a single entry from an index. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61158
927
74