@shushed/helpers 0.0.249 → 0.0.250-main-20260202182038
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.
|
@@ -715,5 +715,28 @@ class DatoHelper extends runtime_1.default {
|
|
|
715
715
|
throw err;
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
+
async publishProduct(productId) {
|
|
719
|
+
try {
|
|
720
|
+
const res = await fetch(`${this.baseUrl}/items/${productId}/publish`, {
|
|
721
|
+
method: "PUT",
|
|
722
|
+
headers: {
|
|
723
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
724
|
+
"X-Api-Version": "3",
|
|
725
|
+
"X-Environment": this.environment,
|
|
726
|
+
"Content-Type": "application/vnd.api+json",
|
|
727
|
+
Accept: "application/json",
|
|
728
|
+
},
|
|
729
|
+
});
|
|
730
|
+
if (!res.ok) {
|
|
731
|
+
const errorText = await res.text();
|
|
732
|
+
throw new Error(`Failed to publish product: ${res.status} ${res.statusText} - ${errorText}`);
|
|
733
|
+
}
|
|
734
|
+
return await res.json();
|
|
735
|
+
}
|
|
736
|
+
catch (err) {
|
|
737
|
+
this.logging.error(`publishProduct failed: ${err.message}`);
|
|
738
|
+
throw err;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
718
741
|
}
|
|
719
742
|
exports.default = DatoHelper;
|
|
@@ -79,7 +79,6 @@ class PubSubHelper extends runtime_1.default {
|
|
|
79
79
|
else if (typeof options.extraAttributes === 'object') {
|
|
80
80
|
nextAttributes = Object.assign({}, nextAttributes, options.extraAttributes);
|
|
81
81
|
}
|
|
82
|
-
const nextAttributesWithoutNullsAndUndefineds = {};
|
|
83
82
|
for (const key in nextAttributes) {
|
|
84
83
|
let resultForKey;
|
|
85
84
|
if (nextAttributes[key] === null || nextAttributes[key] === undefined) {
|
|
@@ -92,18 +91,18 @@ class PubSubHelper extends runtime_1.default {
|
|
|
92
91
|
resultForKey = nextAttributes[key];
|
|
93
92
|
}
|
|
94
93
|
if (typeof resultForKey === 'boolean') {
|
|
95
|
-
|
|
94
|
+
nextAttributes[key] = resultForKey ? 'yes' : 'no';
|
|
96
95
|
}
|
|
97
96
|
else {
|
|
98
|
-
|
|
97
|
+
nextAttributes[key] = `${resultForKey}`;
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
Object.assign(
|
|
100
|
+
nextAttributes = Object.assign(nextAttributes, {
|
|
102
101
|
buildship_id: this.systemEnvName + '-' + this.workflowId + '-' + this.triggerId,
|
|
103
102
|
});
|
|
104
103
|
const message = {
|
|
105
104
|
data: x,
|
|
106
|
-
attributes:
|
|
105
|
+
attributes: nextAttributes
|
|
107
106
|
};
|
|
108
107
|
let messageId = null;
|
|
109
108
|
if (!options.dryRun) {
|
|
@@ -89,5 +89,6 @@ export default class DatoHelper extends Runtime {
|
|
|
89
89
|
updateProductGallery(productId: string, gallery: any[]): Promise<any>;
|
|
90
90
|
updateProductSwatch(productId: string, uploadId: string): Promise<any>;
|
|
91
91
|
updateProductColour(productId: string, colour: any): Promise<any>;
|
|
92
|
+
publishProduct(productId: string): Promise<any>;
|
|
92
93
|
}
|
|
93
94
|
export {};
|