More service naming consistency cleanup

This commit is contained in:
Dominic Ferrando
2026-07-04 15:10:06 -04:00
parent f4aad56ad3
commit afdc8de77c
5 changed files with 113 additions and 102 deletions
+13 -13
View File
@@ -30,14 +30,14 @@ export class ProductSyncer {
private log: pino.Logger;
constructor(
private printful: PrintfulClient,
private webflow: WebflowClient,
private Printful: PrintfulClient,
private Webflow: WebflowClient,
log?: pino.Logger,
) {
this.log = (log ?? pino({ level: "silent" })).child({ component: "ProductSyncer" });
}
async sync(opt: ProductSyncerOptions = {}) {
async run(opt: ProductSyncerOptions = {}) {
const startDate = new Date();
await opt.onStart?.(startDate);
@@ -47,10 +47,10 @@ export class ProductSyncer {
this.log.info("sync started (all)");
this.log.debug("retrieving webflow products");
const allWebflowProducts = await this.webflow.Products.list({ forceAll: true });
const allWebflowProducts = await this.Webflow.Products.list({ forceAll: true });
this.log.debug("retrieving printful products");
const allPrintfulProducts = await this.printful.Products.list({ forceAll: true });
const allPrintfulProducts = await this.Printful.Products.list({ forceAll: true });
this.log.info({ printfulProductCount: allPrintfulProducts.length, filter: opt.filter ?? "N/A" }, "generating meta printful products");
const metaPrintfulProducts = await this.generateMetaPrintfulProducts(allWebflowProducts, allPrintfulProducts, opt);
@@ -120,7 +120,7 @@ export class ProductSyncer {
this.log.warn({ webflowSku: newWebflowSkus[0] }, "could not find existing webflow SKU that matches");
}
await this.webflow.Products.update(webflowProduct.product.id, {
await this.Webflow.Products.update(webflowProduct.product.id, {
product: { fieldData: webflowProductFieldData },
sku: newWebflowSkus[0],
});
@@ -133,13 +133,13 @@ export class ProductSyncer {
newWebflowSku.id,
);
if (existingWebflowSku) {
await this.webflow.Products.Skus.update(
await this.Webflow.Products.Skus.update(
metaPrintfulProduct.webflowProductId,
existingWebflowSku.id,
newWebflowSku,
);
} else {
await this.webflow.Products.Skus.create(
await this.Webflow.Products.Skus.create(
metaPrintfulProduct.webflowProductId,
[newWebflowSku],
);
@@ -148,18 +148,18 @@ export class ProductSyncer {
} else {
this.log.info("existing webflow product not found, creating it");
const webflowProductId = await this.webflow.Products.create({
const webflowProductId = await this.Webflow.Products.create({
product: { fieldData: webflowProductFieldData },
sku: newWebflowSkus[0],
});
metaPrintfulProduct.webflowProductId = webflowProductId;
if (newWebflowSkus.length > 1)
await this.webflow.Products.Skus.create(webflowProductId, newWebflowSkus.slice(1));
await this.Webflow.Products.Skus.create(webflowProductId, newWebflowSkus.slice(1));
}
// Re-fetch after SKU mutations so newly created SKUs have their real IDs.
const freshWebflowProduct = await this.webflow.Products.get(metaPrintfulProduct.webflowProductId);
const freshWebflowProduct = await this.Webflow.Products.get(metaPrintfulProduct.webflowProductId);
if (!freshWebflowProduct) throw new Error("webflow product missing");
// Update printful external IDs
@@ -186,7 +186,7 @@ export class ProductSyncer {
await sleep(10000);
this.log.info({ printfulProduct: printfulProduct.sync_product.id, externalId: expectedExternalId }, "updating printful product's external ID");
await this.printful.Products.update(printfulProduct.sync_product.id, {
await this.Printful.Products.update(printfulProduct.sync_product.id, {
sync_product: {
id: printfulProduct.sync_product.id,
external_id: expectedExternalId,
@@ -286,7 +286,7 @@ export class ProductSyncer {
metaPrintfulProduct.webflowProductId = webflowProductId;
}
const fullPrintfulProduct = await this.printful.Products.get(printfulProduct.id);
const fullPrintfulProduct = await this.Printful.Products.get(printfulProduct.id);
if (!fullPrintfulProduct) throw new Error(`Printful product ${printfulProduct.id} not found`);
const isDuplicate = allPrintfulProducts.some((p) => p.id !== printfulProduct.id && p.name === printfulProduct.name);