@shushed/helpers 0.0.200-v2-20251126161921 → 0.0.200-v2-20251128093319
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.
|
@@ -652,5 +652,29 @@ class DatoHelper extends runtime_1.default {
|
|
|
652
652
|
throw err;
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
|
+
async publishProduct(productId) {
|
|
656
|
+
try {
|
|
657
|
+
const res = await fetch(`${this.baseUrl}/items/${productId}/publish`, {
|
|
658
|
+
method: "PUT",
|
|
659
|
+
headers: {
|
|
660
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
661
|
+
"X-Api-Version": "3",
|
|
662
|
+
"X-Environment": this.environment,
|
|
663
|
+
"Content-Type": "application/vnd.api+json",
|
|
664
|
+
Accept: "application/json",
|
|
665
|
+
},
|
|
666
|
+
});
|
|
667
|
+
this.handle429(res);
|
|
668
|
+
if (!res.ok) {
|
|
669
|
+
const errorText = await res.text();
|
|
670
|
+
throw new Error(`Failed to publish product: ${res.status} ${res.statusText} - ${errorText}`);
|
|
671
|
+
}
|
|
672
|
+
return await res.json();
|
|
673
|
+
}
|
|
674
|
+
catch (err) {
|
|
675
|
+
this.logging.error(`publishProduct failed: ${err.message}`);
|
|
676
|
+
throw err;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
655
679
|
}
|
|
656
680
|
exports.default = DatoHelper;
|
|
@@ -92,6 +92,9 @@ class Runtime {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
getRuntimeUrl(options) {
|
|
95
|
+
if (options.runtimeUrl && this.isDeployment) {
|
|
96
|
+
return options.runtimeUrl;
|
|
97
|
+
}
|
|
95
98
|
const systemEnvName = this.getSystemEnvName(options);
|
|
96
99
|
const [_, ...idParts] = (process.env.GCLOUD_PROJECT || '').split('-');
|
|
97
100
|
if (process.env.RUNTIME_URL) {
|
|
@@ -130,6 +133,9 @@ class Runtime {
|
|
|
130
133
|
}
|
|
131
134
|
return systemEnvName || 'test-env';
|
|
132
135
|
}
|
|
136
|
+
get isDeployment() {
|
|
137
|
+
return process.env.K_SERVICE === 'manager';
|
|
138
|
+
}
|
|
133
139
|
}
|
|
134
140
|
exports.default = Runtime;
|
|
135
141
|
;
|
|
@@ -90,5 +90,6 @@ export default class DatoHelper extends Runtime {
|
|
|
90
90
|
createProduct(sku: string, productTypeId: string): Promise<any>;
|
|
91
91
|
updateProductGallery(productId: string, gallery: any[]): Promise<any>;
|
|
92
92
|
updateProductSwatch(productId: string, uploadId: string): Promise<any>;
|
|
93
|
+
publishProduct(productId: string): Promise<any>;
|
|
93
94
|
}
|
|
94
95
|
export {};
|