Small getAll fixes
This commit is contained in:
@@ -40,7 +40,7 @@ const webflow = new WebflowClient({
|
|||||||
|
|
||||||
const syncer = new ProductSyncer(printful, webflow);
|
const syncer = new ProductSyncer(printful, webflow);
|
||||||
|
|
||||||
const wProducts = await webflow.Products.getAll();
|
const wProducts = await webflow.Products.getAll({ forceAll: true });
|
||||||
|
|
||||||
let invalidCount = 0;
|
let invalidCount = 0;
|
||||||
for (const wProduct of wProducts) {
|
for (const wProduct of wProducts) {
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ const webflow = new WebflowClient({
|
|||||||
export const load = async ({ }: Parameters<PageServerLoad>[0]) => {
|
export const load = async ({ }: Parameters<PageServerLoad>[0]) => {
|
||||||
return {
|
return {
|
||||||
products: {
|
products: {
|
||||||
printful: printful.Products.getAll(),
|
printful: printful.Products.getAll({ forceAll: true }),
|
||||||
webflow: webflow.Products.getAll(),
|
webflow: webflow.Products.getAll({ forceAll: true }),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class ProductsClient {
|
|||||||
this.Variants = new VariantsClient(creds);
|
this.Variants = new VariantsClient(creds);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAll(opt: PagingOptions): Promise<Printful.Products.SyncProduct[]> {
|
async getAll(opt: PagingOptions = {}): Promise<Printful.Products.SyncProduct[]> {
|
||||||
const allSyncProducts: Printful.Products.SyncProduct[] = [];
|
const allSyncProducts: Printful.Products.SyncProduct[] = [];
|
||||||
let offset = opt.offset ?? 0;
|
let offset = opt.offset ?? 0;
|
||||||
do {
|
do {
|
||||||
@@ -103,7 +103,7 @@ class OrdersClient {
|
|||||||
if (!res.ok) throw new PrintfulError("Failed to create Printful order", res.status, await parsePayload(res));
|
if (!res.ok) throw new PrintfulError("Failed to create Printful order", res.status, await parsePayload(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAll(opt: PagingOptions): Promise<Printful.Orders.Order[]> {
|
async getAll(opt: PagingOptions = {}): Promise<Printful.Orders.Order[]> {
|
||||||
const allPrintfulOrders: Printful.Orders.Order[] = [];
|
const allPrintfulOrders: Printful.Orders.Order[] = [];
|
||||||
let offset = opt.offset ?? 0;
|
let offset = opt.offset ?? 0;
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class ProductsClient {
|
|||||||
return payload.product.id;
|
return payload.product.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAll(opt: PagingOptions): Promise<Webflow.Products.ProductAndSkus[]> {
|
async getAll(opt: PagingOptions = {}): Promise<Webflow.Products.ProductAndSkus[]> {
|
||||||
const allWebflowProducts: Webflow.Products.ProductAndSkus[] = [];
|
const allWebflowProducts: Webflow.Products.ProductAndSkus[] = [];
|
||||||
let offset = opt.offset ?? 0;
|
let offset = opt.offset ?? 0;
|
||||||
do {
|
do {
|
||||||
@@ -156,7 +156,7 @@ class ProductsClient {
|
|||||||
class OrdersClient {
|
class OrdersClient {
|
||||||
constructor(private creds: Credentials) { }
|
constructor(private creds: Credentials) { }
|
||||||
|
|
||||||
async getAll(opt: PagingOptions & { status?: Webflow.Orders.Order["status"] }): Promise<Webflow.Orders.Order[]> {
|
async getAll(opt: PagingOptions & { status?: Webflow.Orders.Order["status"] } = {}): Promise<Webflow.Orders.Order[]> {
|
||||||
const allOrders: Webflow.Orders.Order[] = [];
|
const allOrders: Webflow.Orders.Order[] = [];
|
||||||
let offset = opt.offset ?? 0;
|
let offset = opt.offset ?? 0;
|
||||||
do {
|
do {
|
||||||
|
|||||||
Reference in New Issue
Block a user