@objectstack/runtime 12.3.0 → 12.4.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/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +22 -22
package/dist/index.js
CHANGED
|
@@ -3975,6 +3975,35 @@ var _HttpDispatcher = class _HttpDispatcher {
|
|
|
3975
3975
|
if (!pkg) return { handled: true, response: this.error(`Package '${id}' not found`, 404) };
|
|
3976
3976
|
return { handled: true, response: this.success(pkg) };
|
|
3977
3977
|
}
|
|
3978
|
+
if (parts.length === 1 && m === "PATCH") {
|
|
3979
|
+
const id = decodeURIComponent(parts[0]);
|
|
3980
|
+
const src = (body?.manifest && typeof body.manifest === "object" ? body.manifest : body) ?? {};
|
|
3981
|
+
const patch = {};
|
|
3982
|
+
if (typeof src.name === "string") patch.name = src.name.trim();
|
|
3983
|
+
if (typeof src.description === "string") patch.description = src.description;
|
|
3984
|
+
if (typeof src.version === "string") patch.version = src.version.trim();
|
|
3985
|
+
if (patch.name !== void 0 && patch.name === "") {
|
|
3986
|
+
return { handled: true, response: this.error("name must not be empty", 400) };
|
|
3987
|
+
}
|
|
3988
|
+
if (patch.version !== void 0 && !/^\d+\.\d+\.\d+$/.test(patch.version)) {
|
|
3989
|
+
return { handled: true, response: this.error("version must be semantic (e.g. 1.0.0)", 400) };
|
|
3990
|
+
}
|
|
3991
|
+
if (patch.name === void 0 && patch.description === void 0 && patch.version === void 0) {
|
|
3992
|
+
return { handled: true, response: this.error("Body { name?, description?, version? } \u2014 nothing to update", 400) };
|
|
3993
|
+
}
|
|
3994
|
+
const protocol = await this.resolveService("protocol");
|
|
3995
|
+
if (protocol && typeof protocol.updatePackage === "function") {
|
|
3996
|
+
try {
|
|
3997
|
+
const updated = await protocol.updatePackage({ packageId: id, patch });
|
|
3998
|
+
return { handled: true, response: this.success(updated?.package ?? updated) };
|
|
3999
|
+
} catch (e) {
|
|
4000
|
+
return { handled: true, response: this.error(e.message, e.statusCode || 500) };
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
const pkg = registry.updatePackageManifest(id, patch);
|
|
4004
|
+
if (!pkg) return { handled: true, response: this.error(`Package '${id}' not found`, 404) };
|
|
4005
|
+
return { handled: true, response: this.success(pkg) };
|
|
4006
|
+
}
|
|
3978
4007
|
if (parts.length === 1 && m === "DELETE") {
|
|
3979
4008
|
const id = decodeURIComponent(parts[0]);
|
|
3980
4009
|
const registryRemoved = registry.uninstallPackage(id);
|