commerce-kit 0.6.1-experimental.3 → 0.6.1-experimental.4

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.
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=api-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,18 +1,5 @@
1
- /* AUTO-GENERATED */
2
-
3
- type APIProductsBrowseResult = { data: (({ id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; category: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; storeId: string | null; position: string; active: boolean; parentId: string | null; } | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; bundleProducts: { createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; variant: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; product: { id: string; name: string; slug: string; images: string[]; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }[]; }; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }; }[]; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }[]; } & { variants: ({ price: string; } & { prePromotionPrice: undefined; })[]; }) | ({ id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; category: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; storeId: string | null; position: string; active: boolean; parentId: string | null; } | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; bundleProducts: { createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; variant: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; product: { id: string; name: string; slug: string; images: string[]; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }[]; }; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }; }[]; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }[]; } & { variants: ({ price: string; } & { prePromotionPrice: undefined; })[]; }) | ({ id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; category: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; storeId: string | null; position: string; active: boolean; parentId: string | null; } | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; bundleProducts: { createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; variant: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; product: { id: string; name: string; slug: string; images: string[]; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }[]; }; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }; }[]; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }[]; } & { variants: ({ price: string; } & { prePromotionPrice: undefined; })[]; }) | ({ id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; category: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; storeId: string | null; position: string; active: boolean; parentId: string | null; } | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; bundleProducts: { createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; variant: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; product: { id: string; name: string; slug: string; images: string[]; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }[]; }; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }; }[]; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }[]; } & { variants: ({ price: string; } & { prePromotionPrice: undefined; price: string; })[]; }) | ({ id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; category: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; storeId: string | null; position: string; active: boolean; parentId: string | null; } | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; bundleProducts: { createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; variant: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; product: { id: string; name: string; slug: string; images: string[]; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }[]; }; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }; }[]; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }[]; } & { variants: ({ price: string; } & { prePromotionPrice: string | null; })[]; }))[]; meta: { count: number; }; };
4
-
5
- type APIProductsBrowseParams = { limit: number; offset?: number | undefined; category?: string | undefined; query?: string | undefined; active?: boolean | undefined; excludeBundles?: boolean | undefined; orderBy?: "name" | "createdAt" | "price" | undefined; orderDirection?: "asc" | "desc" | undefined; };
6
-
7
- type APIProductGetByIdResult = ({ id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; category: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; storeId: string | null; position: string; active: boolean; parentId: string | null; } | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; bundleProducts: { createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; variant: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; product: { id: string; name: string; slug: string; images: string[]; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }[]; }; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }; }[]; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; variantsTypes: { id: string; type: "string" | "color"; label: string; variantValues: { id: string; value: string; position: number | null; colorValue: string | null; }[]; }[]; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; position: number | null; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }[]; } & { variants: ({ price: string; } & { prePromotionPrice: undefined; })[]; }) | ({ id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; category: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; storeId: string | null; position: string; active: boolean; parentId: string | null; } | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; bundleProducts: { createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; variant: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; product: { id: string; name: string; slug: string; images: string[]; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }[]; }; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }; }[]; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; variantsTypes: { id: string; type: "string" | "color"; label: string; variantValues: { id: string; value: string; position: number | null; colorValue: string | null; }[]; }[]; variants: { id: string; createdAt: string; updatedAt: string; storeId: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; position: number | null; colorValue: string | null; variantType: { id: string; type: "string" | "color"; label: string; }; }; }[]; }[]; } & { variants: ({ price: string; } & { prePromotionPrice: string | null; })[]; });
8
-
9
- type APIProductGetByIdParams = { idOrSlug: string; };
10
-
11
- type APICartGetResult = { lineItems: { productVariant: ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; price: string; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: string | null; }); id: string; createdAt: string; updatedAt: string; cartId: string; quantity: number; productVariantId: string; subscriptionId: string | null; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; }[]; id: string; createdAt: string; updatedAt: string; storeId: string; addonData: Record<string, unknown> | null | undefined; couponId: string | null; customerId: string | null; stripePaymentIntentId: string | null; checkoutSessionId: string | null; shippingId: string | null; shippingAddressId: string | null; billingAddressId: string | null; shipping: { id: string; name: string; createdAt: string; updatedAt: string; type: "courier" | "parcel" | "pickup_point" | "in_store"; description: string | null; storeId: string; price: string; minShippingTime: number | null; maxShippingTime: number | null; position: number | null; addonId: string | null; addonData: unknown; countries: string[] | null; shippingAddon: { id: string; name: string; createdAt: string; updatedAt: string; type: "shipping" | "analytics" | "products" | "invoicing"; storeId: string; } | null; shippingTaxRate: { createdAt: string; updatedAt: string; shippingId: string; taxRateId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; } | null; coupon: { type: "fixed" | "percentage"; value: string; code: string; startDate: string | null; endDate: string | null; } | null; billingAddress: { id: string; name: string | null; createdAt: string; updatedAt: string; type: "shipping" | "billing" | "merchant"; company: string | null; city: string | null; country: string | null; line1: string | null; line2: string | null; postalCode: string | null; state: string | null; phone: string | null; taxId: string | null; } | null; shippingAddress: { id: string; name: string | null; createdAt: string; updatedAt: string; type: "shipping" | "billing" | "merchant"; company: string | null; city: string | null; country: string | null; line1: string | null; line2: string | null; postalCode: string | null; state: string | null; phone: string | null; taxId: string | null; } | null; customer: { id: string; email: string | null; createdAt: string; updatedAt: string; userId: string | null; storeId: string; couponId: string | null; user: { id: string; name: string; email: string; } | null; coupon: { type: "fixed" | "percentage"; value: string; code: string; startDate: string | null; endDate: string | null; } | null; } | null; } | null | undefined;
12
-
13
- type APICartCreateBody = { variantId: string; quantity: number; cartId?: string | undefined; subscriptionId?: string | null | undefined; };
14
-
15
- type APICartCreateResult = { lineItems: { productVariant: ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: undefined; price: string; }) | ({ storeId: string | null; product: { bundleProducts: { variant: { storeId: string | null; product: { productTaxRate: { taxRate: { rate: string; }; } | null; id: string; name: string; slug: string; images: string[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; }; createdAt: string; updatedAt: string; position: number; bundleId: string; quantity: number; variantId: string; }[]; id: string; name: string; createdAt: string; updatedAt: string; type: "product" | "bundle"; slug: string; flags: unknown; storeId: string; summary: string | null; images: string[]; active: boolean | null; badge: unknown; bundleDiscountPercentage: string | null; categoryId: string | null; productTaxRate: { createdAt: string; updatedAt: string; taxRateId: string; productId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; productCollections: { position: string | null; productId: string; collectionId: string; collection: { id: string; name: string; image: string | null; createdAt: string; updatedAt: string; description: JSONContent | null; slug: string; filter: unknown; storeId: string; active: boolean; }; }[]; }; id: string; createdAt: string; updatedAt: string; price: string; images: string[]; sku: string | null; calculatedPrice: string | null; stock: number | null; depth: number | null; width: number | null; height: number | null; weight: number | null; digital: string[] | null; shippable: boolean; externalId: string | null; productId: string; attributes: unknown; originalPrice: string; combinations: { createdAt: string; updatedAt: string; productVariantId: string; variantValueId: string; variantValue: { id: string; value: string; variantType: { id: string; label: string; }; }; }[]; } & { price: string; } & { prePromotionPrice: string | null; }); id: string; createdAt: string; updatedAt: string; cartId: string; quantity: number; productVariantId: string; subscriptionId: string | null; subscription: { id: string; createdAt: string; updatedAt: string; storeId: string; productId: string; interval: number; cadence: "month" | "week"; } | null; }[]; id: string; createdAt: string; updatedAt: string; storeId: string; addonData: Record<string, unknown> | null | undefined; couponId: string | null; customerId: string | null; stripePaymentIntentId: string | null; checkoutSessionId: string | null; shippingId: string | null; shippingAddressId: string | null; billingAddressId: string | null; shipping: { id: string; name: string; createdAt: string; updatedAt: string; type: "courier" | "parcel" | "pickup_point" | "in_store"; description: string | null; storeId: string; price: string; minShippingTime: number | null; maxShippingTime: number | null; position: number | null; addonId: string | null; addonData: unknown; countries: string[] | null; shippingAddon: { id: string; name: string; createdAt: string; updatedAt: string; type: "shipping" | "analytics" | "products" | "invoicing"; storeId: string; } | null; shippingTaxRate: { createdAt: string; updatedAt: string; shippingId: string; taxRateId: string; taxRate: { id: string; name: string; createdAt: string; updatedAt: string; storeId: string; rate: string; }; } | null; } | null; coupon: { type: "fixed" | "percentage"; value: string; code: string; startDate: string | null; endDate: string | null; } | null; billingAddress: { id: string; name: string | null; createdAt: string; updatedAt: string; type: "shipping" | "billing" | "merchant"; company: string | null; city: string | null; country: string | null; line1: string | null; line2: string | null; postalCode: string | null; state: string | null; phone: string | null; taxId: string | null; } | null; shippingAddress: { id: string; name: string | null; createdAt: string; updatedAt: string; type: "shipping" | "billing" | "merchant"; company: string | null; city: string | null; country: string | null; line1: string | null; line2: string | null; postalCode: string | null; state: string | null; phone: string | null; taxId: string | null; } | null; customer: { id: string; email: string | null; createdAt: string; updatedAt: string; userId: string | null; storeId: string; couponId: string | null; user: { id: string; name: string; email: string; } | null; coupon: { type: "fixed" | "percentage"; value: string; code: string; startDate: string | null; endDate: string | null; } | null; } | null; } | null | undefined;
1
+ import { APIProductsBrowseParams, APIProductsBrowseResult, APIProductGetByIdParams, APIProductGetByIdResult, APICartCreateBody, APICartCreateResult, APICartGetResult } from './api-types.js';
2
+ export { APICartAddBody, APICartAddResult, APICartRemoveItemParams, APICartRemoveItemResult, JSONContent } from './api-types.js';
16
3
 
17
4
  interface YnsProviderConfig {
18
5
  version: "v1";
@@ -34,4 +21,4 @@ declare class YnsProvider {
34
21
  }): Promise<APICartGetResult | null>;
35
22
  }
36
23
 
37
- export { YnsProvider };
24
+ export { APICartCreateBody, APICartCreateResult, APICartGetResult, APIProductGetByIdParams, APIProductGetByIdResult, APIProductsBrowseParams, APIProductsBrowseResult, YnsProvider };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var n={DEBUG:0,LOG:1,WARN:2,ERROR:3},R=process.env.NEXT_PUBLIC_LOG_LEVEL||"LOG",s=n[R],l="\x1B[0m",E="\x1B[34m",y="\x1B[32m",m="\x1B[33m",B="\x1B[31m",L="\u23F1\uFE0F",$="\u{1F41B}",w="\u2714\uFE0F",h="\u26A0\uFE0F",A="\u274C",p=`${L} `,G=`${E}${$}${l} `,v=`${y}${w}${l} `,O=`${m}${h}${l} `,C=`${B}${A}${l} `,g=a=>{let t=a?`[${a}] `:"";return{getLogger(e){return g([a,e].filter(Boolean).join(" > "))},time(e){s>n.DEBUG||console.time([p,t,e].filter(Boolean).join(" "))},timeEnd(e){s>n.DEBUG||console.timeEnd([p,t,e].filter(Boolean).join(" "))},debug(...e){s>n.DEBUG||console.log(...[G,t,...e].filter(Boolean))},log(...e){s>n.LOG||console.log(...[v,t,...e].filter(Boolean))},dir(e,r){s>n.LOG||console.dir(e,r)},warn(...e){s>n.WARN||console.warn(...[O,t,...e].filter(Boolean))},error(...e){s>n.ERROR||console.error(...[C,t,...e].filter(Boolean))}}},T=g();var I=class{#e;#r=g("YnsProvider");constructor(t){this.#e=t,this.#r.debug("YnsProvider initialized")}async#t(t,e="GET",r){let P=this.#r.getLogger("#restRequest"),c=`${this.#e.endpoint}/api/${this.#e.version}${t}`;P.debug(`Making ${e} request to YNS API: ${c}`);let o=await fetch(c,{method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#e.token}`},body:r?JSON.stringify(r):void 0});if(!o.ok){let u=o.headers.get("content-type"),d=`YNS REST request failed: ${o.status} ${o.statusText}`;if(u?.includes("application/json"))try{let f=await o.json();d=f.error||f.message||d}catch{}throw P.error(`YNS API request failed: ${o.status} ${o.statusText}`,d),new Error(d)}let i=o.headers.get("content-type");if(!i?.includes("application/json"))throw new Error(`YNS API returned ${i} instead of JSON for ${t}`);return o.json()}async productBrowse(t){let e=this.#r.getLogger("productBrowse");e.debug("Browsing products with params:",t);let r=new URLSearchParams(Object.entries(t).map(([i,u])=>[i,u?String(u):void 0]).filter(([,i])=>i!==void 0));t.limit&&r.append("limit",t.limit.toString()),t.offset&&r.append("offset",t.offset.toString()),t.category&&r.append("category",t.category),t.query&&r.append("query",t.query),t.active!==void 0&&r.append("active",t.active.toString()),t.orderBy&&r.append("orderBy",t.orderBy),t.orderDirection&&r.append("orderDirection",t.orderDirection);let c=`/products${r.size?`?${r}`:""}`;e.debug("Constructed pathname:",c);let o=await this.#t(c);return e.debug("Received product browse result:",{meta:o.meta}),o}async productGet(t){let e=`/products/${t.idOrSlug}`,r=await this.#t(e);return r||null}async cartCreate(t){return await this.#t("/carts","POST",t)}async cartRemoveItem(t){let e=`/carts/${t.cartId}/line-items/${t.variantId}`,r=await this.#t(e,"DELETE");return null}async cartGet(t){let e=`/carts/${t.cartId}`;return await this.#t(e)}};export{I as YnsProvider};
1
+ export*from"./api-types";export*from"./providers/yns";
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/logger.ts","../src/providers/yns.ts"],"sourcesContent":["import type { InspectOptions } from \"node:util\";\n\ntype LogParms = [message: unknown, ...optionalParams: unknown[]];\n\n/**\n * Vercel only supports 3 levels of logging. We're adding additional DEBUG level.\n * https://vercel.com/docs/observability/runtime-logs#level\n *\n * ERROR - Fatal for a particular request. Should be fixed sooner than later.\n *\n * WARN - A note on something that should probably be looked at eventually.\n *\n * LOG - Detail on regular operation.\n *\n * DEBUG - Debug only info as well as time and timeEnd functions.\n */\nconst LogLevel = {\n\tDEBUG: 0,\n\tLOG: 1,\n\tWARN: 2,\n\tERROR: 3,\n} as const;\ntype LogLevel = keyof typeof LogLevel;\n\nconst strLogLevel = (process.env.NEXT_PUBLIC_LOG_LEVEL || \"LOG\") as LogLevel;\nconst valueLogLevel = LogLevel[strLogLevel];\n\nconst RESET = \"\\x1b[0m\";\nconst BLUE = \"\\x1b[34m\";\nconst GREEN = \"\\x1b[32m\";\nconst YELLOW = \"\\x1b[33m\";\nconst RED = \"\\x1b[31m\";\n\nconst TIME = `⏱️`;\nconst DEBUG = `🐛`;\nconst OK = `✔️`;\nconst WARN = `⚠️`;\nconst ERROR = `❌`;\n\nconst PREFIX_TIME = `${TIME} `;\nconst PREFIX_DEBUG = `${BLUE}${DEBUG}${RESET} `;\nconst PREFIX_OK = `${GREEN}${OK}${RESET} `;\nconst PREFIX_WARN = `${YELLOW}${WARN}${RESET} `;\nconst PREFIX_ERROR = `${RED}${ERROR}${RESET} `;\n\nexport const getLogger = (groupLabel?: string) => {\n\tconst PREFIX = groupLabel ? `[${groupLabel}] ` : \"\";\n\treturn {\n\t\tgetLogger(subGroupLabel: string) {\n\t\t\treturn getLogger([groupLabel, subGroupLabel].filter(Boolean).join(\" > \"));\n\t\t},\n\t\ttime(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.time([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\ttimeEnd(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.timeEnd([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\tdebug(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.log(...[PREFIX_DEBUG, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tlog(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.log(...[PREFIX_OK, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tdir(item?: unknown, options?: InspectOptions) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.dir(item, options);\n\t\t},\n\t\twarn(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.WARN) return;\n\t\t\tconsole.warn(...[PREFIX_WARN, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\terror(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.ERROR) return;\n\t\t\tconsole.error(...[PREFIX_ERROR, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t};\n};\n\nexport const logger = getLogger();\n","import type {\n\tAPICartCreateBody,\n\tAPICartCreateResult,\n\tAPICartGetResult,\n\tAPIProductGetByIdParams,\n\tAPIProductGetByIdResult,\n\tAPIProductsBrowseParams,\n\tAPIProductsBrowseResult,\n} from \"../api-types\";\nimport { getLogger } from \"../logger\";\n\ninterface YnsProviderConfig {\n\tversion: \"v1\";\n\tendpoint: string;\n\ttoken: string;\n}\n\nexport class YnsProvider {\n\t#config;\n\t#logger = getLogger(\"YnsProvider\");\n\tconstructor(config: YnsProviderConfig) {\n\t\tthis.#config = config;\n\t\tthis.#logger.debug(\"YnsProvider initialized\");\n\t}\n\n\tasync #restRequest<T>(\n\t\tpathname: `/${string}`,\n\t\tmethod: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" = \"GET\",\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst logger = this.#logger.getLogger(\"#restRequest\");\n\n\t\tconst endpoint = `${this.#config.endpoint}/api/${this.#config.version}${pathname}`;\n\t\tlogger.debug(`Making ${method} request to YNS API: ${endpoint}`);\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tAuthorization: `Bearer ${this.#config.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\t// Handle different error types\n\t\t\tconst contentType = response.headers.get(\"content-type\");\n\t\t\tlet errorMessage = `YNS REST request failed: ${response.status} ${response.statusText}`;\n\n\t\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\t\ttry {\n\t\t\t\t\tconst errorData = await response.json();\n\t\t\t\t\terrorMessage = errorData.error || errorData.message || errorMessage;\n\t\t\t\t} catch {\n\t\t\t\t\t// If JSON parsing fails, use default message\n\t\t\t\t}\n\t\t\t}\n\t\t\tlogger.error(`YNS API request failed: ${response.status} ${response.statusText}`, errorMessage);\n\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\n\t\t// Check if response is JSON before parsing\n\t\tconst contentType = response.headers.get(\"content-type\");\n\t\tif (!contentType?.includes(\"application/json\")) {\n\t\t\tthrow new Error(`YNS API returned ${contentType} instead of JSON for ${pathname}`);\n\t\t}\n\n\t\treturn response.json();\n\t}\n\n\tasync productBrowse(params: APIProductsBrowseParams): Promise<APIProductsBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"productBrowse\");\n\t\tlogger.debug(\"Browsing products with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams(\n\t\t\tObject.entries(params)\n\t\t\t\t.map(([key, value]) => [key, value ? String(value) : undefined])\n\t\t\t\t.filter(([, value]) => value !== undefined) as [string, string][],\n\t\t);\n\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.category) queryParams.append(\"category\", params.category);\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\t\tif (params.orderBy) queryParams.append(\"orderBy\", params.orderBy);\n\t\tif (params.orderDirection) queryParams.append(\"orderDirection\", params.orderDirection);\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/products${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIProductsBrowseResult>(pathname);\n\t\tlogger.debug(\"Received product browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync productGet(params: APIProductGetByIdParams): Promise<APIProductGetByIdResult | null> {\n\t\tconst pathname = `/products/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APIProductGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// @todo implement this endpoint\n\t// async cartAdd(params: APICartAddBody): Promise<APICartAddResult> {\n\t// \tconst body = {\n\t// \t\tvariantId: params.variantId,\n\t// \t\tcartId: params.cartId,\n\t// \t\tquantity: params.quantity,\n\t// \t\tsubscriptionId: params.subscriptionId,\n\t// \t};\n\n\t// \tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"PUT\", body);\n\t// \treturn result;\n\t// }\n\n\tasync cartCreate(body: APICartCreateBody): Promise<APICartCreateResult> {\n\t\tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"POST\", body);\n\t\treturn result;\n\t}\n\n\tasync cartRemoveItem(params: { cartId: string; variantId: string }): Promise<null> {\n\t\tconst pathname = `/carts/${params.cartId}/line-items/${params.variantId}` as const;\n\t\tconst result = await this.#restRequest<unknown>(pathname, \"DELETE\");\n\t\t// return result;\n\t\treturn null;\n\t}\n\n\tasync cartGet(params: { cartId: string }): Promise<APICartGetResult | null> {\n\t\tconst pathname = `/carts/${params.cartId}` as const;\n\t\tconst result = await this.#restRequest<APICartGetResult>(pathname);\n\t\treturn result;\n\t}\n}\n"],"mappings":"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","names":["LogLevel","strLogLevel","valueLogLevel","RESET","BLUE","GREEN","YELLOW","RED","TIME","DEBUG","OK","WARN","ERROR","PREFIX_TIME","PREFIX_DEBUG","PREFIX_OK","PREFIX_WARN","PREFIX_ERROR","getLogger","groupLabel","PREFIX","subGroupLabel","label","args","item","options","logger","YnsProvider","#config","#logger","getLogger","config","#restRequest","pathname","method","body","logger","endpoint","response","contentType","errorMessage","errorData","params","queryParams","key","value","result"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./api-types\";\nexport * from \"./providers/yns\";\n"],"mappings":"AAAA,WAAc,cACd,WAAc","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "commerce-kit",
4
- "version": "0.6.1-experimental.3",
4
+ "version": "0.6.1-experimental.4",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
7
7
  "keywords": [