@tusent.io/tusentio-cms
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -33,3 +33,10 @@ declare type TusentioCMSOptions = { | ||
deleteValue(type: string, id: string): Promise<void>; | ||
findValues(type: string, selector: any): Promise<string[]>; | ||
findValues(type: string, selector: any): Promise<{ | ||
id: string; | ||
metadata: string; | ||
}[]>; | ||
getMetadata(type: string, id: string): Promise<string>; | ||
setMetadata(type: string, id: string, data: string): Promise<void>; | ||
getSingleMetadata(type: string): Promise<string>; | ||
setSingleMetadata(type: string, data: string): Promise<void>; | ||
getType(name: string): Promise<TusentioCMSType>; | ||
@@ -36,0 +43,0 @@ registerType(name: string, schema: any, options: TusentioCMSTypeOptions): Promise<void>; |
@@ -34,2 +34,14 @@ export default class TusentioCMS { | ||
} | ||
async getMetadata(type, id) { | ||
return rest("GET", assembleUrl(this.#url, "metadata", type, id ?? ""), { session: this.#session }); | ||
} | ||
async setMetadata(type, id, data) { | ||
await rest("PUT", assembleUrl(this.#url, "metadata", type, id ?? ""), { session: this.#session }, data); | ||
} | ||
async getSingleMetadata(type) { | ||
return this.getMetadata(type, undefined); | ||
} | ||
async setSingleMetadata(type, data) { | ||
await this.setMetadata(type, undefined, data); | ||
} | ||
async getType(name) { | ||
@@ -74,8 +86,6 @@ return rest("GET", assembleUrl(this.#url, "type", name), { session: this.#session }); | ||
body: data === undefined ? undefined : JSON.stringify(data), | ||
headers: new Headers({ | ||
"Content-Type": "application/json", | ||
}), | ||
headers: [["Content-Type", "application/json"]], | ||
}); | ||
if (response.status >= 400) { | ||
throw await response.json(); | ||
throw Object.assign(new Error(`${response.status} ${response.statusText}`), await response.json().catch(() => ({}))); | ||
} | ||
@@ -82,0 +92,0 @@ return response.json(); |
{ | ||
"name": "@tusent.io/tusentio-cms", | ||
"version": "1.3.0", | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"prepack": "tsc", | ||
"start": "node app" | ||
"version": "1.4.0", | ||
"homepage": "https://github.com/Tusentio/Tusentio-CMS#readme", | ||
"bugs": { | ||
"url": "https://github.com/Tusentio/Tusentio-CMS/issues" | ||
}, | ||
@@ -13,4 +12,6 @@ "repository": { | ||
}, | ||
"license": "UNLICENSED", | ||
"author": "Tusentio <contact@tusent.io> (https://www.tusent.io/)", | ||
"license": "UNLICENSED", | ||
"type": "module", | ||
"main": "./lib/index.js", | ||
"files": [ | ||
@@ -20,7 +21,6 @@ "/lib/*", | ||
], | ||
"type": "module", | ||
"bugs": { | ||
"url": "https://github.com/Tusentio/Tusentio-CMS/issues" | ||
"scripts": { | ||
"prepack": "tsc", | ||
"start": "node app" | ||
}, | ||
"homepage": "https://github.com/Tusentio/Tusentio-CMS#readme", | ||
"dependencies": { | ||
@@ -27,0 +27,0 @@ "@tusent.io/uid": "github:Tusentio/uid", |
6622
151