@objectstack/objectql 9.4.0 → 9.5.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.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2089,8 +2089,10 @@ var SysMetadataRepository = class {
|
|
|
2089
2089
|
*/
|
|
2090
2090
|
async promoteDraft(ref, opts) {
|
|
2091
2091
|
this.assertOpen();
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2092
|
+
const draftRow = await this.engine.findOne("sys_metadata", {
|
|
2093
|
+
where: this.whereFor(ref, "draft")
|
|
2094
|
+
});
|
|
2095
|
+
if (!draftRow) {
|
|
2094
2096
|
const err = new Error(
|
|
2095
2097
|
`[no_draft] No pending draft exists for ${ref.type}/${ref.name} \u2014 nothing to publish.`
|
|
2096
2098
|
);
|
|
@@ -2098,7 +2100,9 @@ var SysMetadataRepository = class {
|
|
|
2098
2100
|
err.status = 404;
|
|
2099
2101
|
throw err;
|
|
2100
2102
|
}
|
|
2101
|
-
const
|
|
2103
|
+
const draftPackageId = draftRow.package_id ?? null;
|
|
2104
|
+
const draft = this.rowToItem(ref, draftRow);
|
|
2105
|
+
const currentActive = await this.get(ref, { state: "active", packageId: draftPackageId });
|
|
2102
2106
|
const result = await this.put(ref, draft.body, {
|
|
2103
2107
|
parentVersion: currentActive?.hash ?? null,
|
|
2104
2108
|
actor: opts.actor,
|
|
@@ -2106,7 +2110,8 @@ var SysMetadataRepository = class {
|
|
|
2106
2110
|
message: opts.message ?? `publish draft (hash ${draft.hash})`,
|
|
2107
2111
|
intent: opts.intent ?? "override-artifact",
|
|
2108
2112
|
state: "active",
|
|
2109
|
-
opType: "publish"
|
|
2113
|
+
opType: "publish",
|
|
2114
|
+
packageId: draftPackageId
|
|
2110
2115
|
});
|
|
2111
2116
|
try {
|
|
2112
2117
|
await this.delete(ref, {
|
|
@@ -2199,10 +2204,15 @@ var SysMetadataRepository = class {
|
|
|
2199
2204
|
*/
|
|
2200
2205
|
async listDrafts(filter) {
|
|
2201
2206
|
this.assertOpen();
|
|
2202
|
-
const where = {
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2207
|
+
const where = { state: "draft" };
|
|
2208
|
+
if (this.organizationId != null) {
|
|
2209
|
+
where.$or = [
|
|
2210
|
+
{ organization_id: this.organizationId },
|
|
2211
|
+
{ organization_id: null }
|
|
2212
|
+
];
|
|
2213
|
+
} else {
|
|
2214
|
+
where.organization_id = null;
|
|
2215
|
+
}
|
|
2206
2216
|
if (filter?.type) where.type = filter.type;
|
|
2207
2217
|
if (filter?.packageId) where.package_id = filter.packageId;
|
|
2208
2218
|
const rows = await this.engine.find("sys_metadata", { where });
|