@acceleratxr/core_sdk
Advanced tools
Comparing version 1.16.4 to 1.17.1
@@ -53,2 +53,4 @@ "use strict"; | ||
this.data = ""; | ||
/** Indicates if the script has been deleted and should no longer be included. */ | ||
this.deleted = false; | ||
/** The name of the script file on disk. */ | ||
@@ -70,2 +72,3 @@ this.filename = ""; | ||
this.data = other.data ? (typeof other.data === "string" ? Buffer.from(other.data, "base64") : other.data) : this.data; | ||
this.deleted = other.deleted !== undefined ? other.deleted : this.deleted; | ||
this.filename = other.filename ? other.filename : this.filename; | ||
@@ -72,0 +75,0 @@ this.language = other.language ? other.language : this.language; |
@@ -22,3 +22,3 @@ "use strict"; | ||
/** | ||
* Returns all groups from the system that the user has access to | ||
* Returns all scripts from the system that the user has access to | ||
*/ | ||
@@ -37,3 +37,3 @@ findAll(query) { | ||
/** | ||
* Create a new group | ||
* Create a new script | ||
*/ | ||
@@ -54,8 +54,23 @@ create(obj) { | ||
/** | ||
* Deletes all roles from the service. | ||
* Returns the count of scripts | ||
*/ | ||
truncate() { | ||
count(query) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = this.config.getBaseServicePath(ScriptService); | ||
let url = this.config.getBaseServicePath(ScriptService) + "/count"; | ||
if (url) { | ||
return this.apiClient.getObject(url, Count_1.default, query); | ||
} | ||
else { | ||
throw new Error("Failed to retrieve service base path. Is it configured properly?"); | ||
} | ||
}); | ||
} | ||
/** | ||
* Marks the script as deleted. | ||
*/ | ||
delete(id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = this.config.getBaseServicePath(ScriptService) + "/:id"; | ||
if (url) { | ||
url = url.replace(":id", id); | ||
return this.apiClient.delete(url, undefined); | ||
@@ -69,9 +84,11 @@ } | ||
/** | ||
* Returns the count of groups | ||
* Marks the script as deleted. | ||
*/ | ||
count(query) { | ||
deleteByIdAndVersion(id, version) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = this.config.getBaseServicePath(ScriptService) + "/count"; | ||
let url = this.config.getBaseServicePath(ScriptService) + "/:id/version/:version"; | ||
if (url) { | ||
return this.apiClient.getObject(url, Count_1.default, query); | ||
url = url.replace(":id", id); | ||
url = url.replace(":version", version.toString()); | ||
return this.apiClient.delete(url, undefined); | ||
} | ||
@@ -84,3 +101,3 @@ else { | ||
/** | ||
* Returns a single group from the system that the user has access to | ||
* Returns a single script from the system that the user has access to | ||
*/ | ||
@@ -100,3 +117,3 @@ findById(id) { | ||
/** | ||
* Returns a single group from the system that the user has access to | ||
* Returns a single script from the system that the user has access to | ||
*/ | ||
@@ -133,12 +150,10 @@ findByIdAndVersion(id, version) { | ||
/** | ||
* Updates a single group | ||
* Removes the script from the database. | ||
*/ | ||
update(id, obj) { | ||
purge(id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = this.config.getBaseServicePath(ScriptService) + "/:id"; | ||
let url = this.config.getBaseServicePath(ScriptService) + "/:id/purge"; | ||
if (url) { | ||
url = url.replace(":id", id); | ||
// Convert the data to a base64 string | ||
obj.data = obj.data.toString("base64"); | ||
return this.apiClient.putObject(url, obj, Script_1.Script); | ||
return this.apiClient.delete(url, undefined); | ||
} | ||
@@ -151,9 +166,10 @@ else { | ||
/** | ||
* Deletes the group | ||
* Removes the script from the database. | ||
*/ | ||
delete(id) { | ||
purgeByIdAndVersion(id, version) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = this.config.getBaseServicePath(ScriptService) + "/:id"; | ||
let url = this.config.getBaseServicePath(ScriptService) + "/:id/version/:version/purge"; | ||
if (url) { | ||
url = url.replace(":id", id); | ||
url = url.replace(":version", version.toString()); | ||
return this.apiClient.delete(url, undefined); | ||
@@ -167,2 +183,45 @@ } | ||
/** | ||
* Restores a previously deleted script. | ||
*/ | ||
restore(id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const script = yield this.findById(id); | ||
if (script && script.deleted) { | ||
script.deleted = false; | ||
return this.update(id, script); | ||
} | ||
return script; | ||
}); | ||
} | ||
/** | ||
* Restores a specific version of a previously deleted script. | ||
*/ | ||
restoreByIdAndVersion(id, version) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const script = yield this.findByIdAndVersion(id, version); | ||
if (script && script.deleted) { | ||
script.deleted = false; | ||
return this.update(id, script); | ||
} | ||
return script; | ||
}); | ||
} | ||
/** | ||
* Updates a single script | ||
*/ | ||
update(id, obj) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = this.config.getBaseServicePath(ScriptService) + "/:id"; | ||
if (url) { | ||
url = url.replace(":id", id); | ||
// Convert the data to a base64 string | ||
obj.data = obj.data.toString("base64"); | ||
return this.apiClient.putObject(url, obj, Script_1.Script); | ||
} | ||
else { | ||
throw new Error("Failed to retrieve service base path. Is it configured properly?"); | ||
} | ||
}); | ||
} | ||
/** | ||
* Returns the scripting system's dependencies configuration. | ||
@@ -169,0 +228,0 @@ */ |
@@ -44,2 +44,4 @@ /// <reference types="node" /> | ||
data: Buffer | string; | ||
/** Indicates if the script has been deleted and should no longer be included. */ | ||
deleted: boolean; | ||
/** The name of the script file on disk. */ | ||
@@ -46,0 +48,0 @@ filename: string; |
@@ -9,23 +9,27 @@ import ServiceBase from "../ServiceBase"; | ||
/** | ||
* Returns all groups from the system that the user has access to | ||
* Returns all scripts from the system that the user has access to | ||
*/ | ||
findAll(query?: any): Promise<Script[] | undefined>; | ||
/** | ||
* Create a new group | ||
* Create a new script | ||
*/ | ||
create(obj: Script): Promise<Script | undefined>; | ||
/** | ||
* Deletes all roles from the service. | ||
* Returns the count of scripts | ||
*/ | ||
truncate(): Promise<void>; | ||
count(query?: any): Promise<Count | undefined>; | ||
/** | ||
* Returns the count of groups | ||
* Marks the script as deleted. | ||
*/ | ||
count(query?: any): Promise<Count | undefined>; | ||
delete(id: string): Promise<void>; | ||
/** | ||
* Returns a single group from the system that the user has access to | ||
* Marks the script as deleted. | ||
*/ | ||
deleteByIdAndVersion(id: string, version: number): Promise<void>; | ||
/** | ||
* Returns a single script from the system that the user has access to | ||
*/ | ||
findById(id: string): Promise<Script | undefined>; | ||
/** | ||
* Returns a single group from the system that the user has access to | ||
* Returns a single script from the system that the user has access to | ||
*/ | ||
@@ -38,10 +42,22 @@ findByIdAndVersion(id: string, version: number): Promise<Script | undefined>; | ||
/** | ||
* Updates a single group | ||
* Removes the script from the database. | ||
*/ | ||
update(id: string, obj: Script): Promise<Script | undefined>; | ||
purge(id: string): Promise<void>; | ||
/** | ||
* Deletes the group | ||
* Removes the script from the database. | ||
*/ | ||
delete(id: string): Promise<void>; | ||
purgeByIdAndVersion(id: string, version: number): Promise<void>; | ||
/** | ||
* Restores a previously deleted script. | ||
*/ | ||
restore(id: string): Promise<Script | undefined>; | ||
/** | ||
* Restores a specific version of a previously deleted script. | ||
*/ | ||
restoreByIdAndVersion(id: string, version: number): Promise<Script | undefined>; | ||
/** | ||
* Updates a single script | ||
*/ | ||
update(id: string, obj: Script): Promise<Script | undefined>; | ||
/** | ||
* Returns the scripting system's dependencies configuration. | ||
@@ -48,0 +64,0 @@ */ |
{ | ||
"name": "@acceleratxr/core_sdk", | ||
"version": "1.16.4", | ||
"version": "1.17.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Jean-Philippe Steinmetz <info@acceleratxr.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3975491
14066