commerce-kit 0.6.0 → 0.6.1-experimental.2

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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,37 @@
1
- export { formatMoney } from './currencies.js';
2
- export { MappedCart, MappedProduct, MappedShippingRate } from './internal.js';
3
- export { B as BaseProvider, C as Cart, a as CartAddParams, b as CartClearParams, c as CartGetParams, d as CartItem, e as CartRemoveParams, f as CartUpdateParams, g as Customer, O as Order, h as OrderGetParams, i as OrderListParams, j as OrderListResult, P as Product, k as ProductBrowseParams, l as ProductBrowseResult, m as ProductGetParams, n as ProductInfo, o as ProductSearchParams, p as ProductSearchResult, S as StripeProviderConfig, Y as YnsProduct, q as YnsProviderConfig } from './provider-CeP9uHnB.js';
4
- export { Commerce } from './yns.js';
5
- import 'stripe';
6
- import 'zod';
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;
16
+
17
+ interface YnsProviderConfig {
18
+ version: "v1";
19
+ endpoint: string;
20
+ token: string;
21
+ }
22
+ declare class YnsProvider {
23
+ #private;
24
+ constructor(config: YnsProviderConfig);
25
+ productBrowse(params: APIProductsBrowseParams): Promise<APIProductsBrowseResult>;
26
+ productGet(params: APIProductGetByIdParams): Promise<APIProductGetByIdResult | null>;
27
+ cartCreate(body: APICartCreateBody): Promise<APICartCreateResult>;
28
+ cartRemoveItem(params: {
29
+ cartId: string;
30
+ variantId: string;
31
+ }): Promise<null>;
32
+ cartGet(params: {
33
+ cartId: string;
34
+ }): Promise<APICartGetResult | null>;
35
+ }
36
+
37
+ export { YnsProvider };
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- var v=Object.defineProperty;var f=(o,r)=>()=>(o&&(r=o(o=0)),r);var g=(o,r)=>{for(var t in r)v(o,t,{get:r[t],enumerable:!0})};var P={};g(P,{YnsProvider:()=>d,createYnsProvider:()=>I});function I(o){return new d(o)}var d,l=f(()=>{"use strict";d=class{config;constructor(r){this.config=r}async graphqlRequest(r,t){let e=await fetch(`${this.config.endpoint}/api/graphql`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.token}`},body:JSON.stringify({query:r,variables:t})});if(!e.ok)throw new Error(`YNS GraphQL request failed: ${e.status} ${e.statusText}`);let i=await e.json();if(i.errors)throw new Error(`YNS GraphQL errors: ${JSON.stringify(i.errors)}`);return i.data}async restRequest(r,t="GET",e){let i=await fetch(`${this.config.endpoint}/api${r}`,{method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.token}`},body:e?JSON.stringify(e):void 0});if(!i.ok){let s=i.headers.get("content-type"),n=`YNS REST request failed: ${i.status} ${i.statusText}`;if(s?.includes("application/json"))try{let p=await i.json();n=p.error||p.message||n}catch{}throw new Error(n)}let a=i.headers.get("content-type");if(!a?.includes("application/json"))throw new Error(`YNS API returned ${a} instead of JSON for ${r}`);return i.json()}mapYnsProduct(r){return{id:r.id,name:r.name,slug:r.slug,summary:r.summary,images:r.images||[],active:r.active,price:r.variants?.[0]?.price?Number.parseFloat(r.variants[0].price):0,currency:"USD",stock:r.variants?.[0]?.stock,category:r.category,variants:r.variants?.map(t=>({id:t.id,price:Number.parseFloat(t.price),stock:t.stock,attributes:t.attributes}))||[]}}mapCart(r){let t=this.mapCartItems(r.lineItems);return{id:r.id,customerId:r.customerId,storeId:r.storeId,customer:this.mapCustomer(r.customer),items:t,total:this.calculateTotal(t),currency:"USD",createdAt:r.createdAt,updatedAt:r.updatedAt}}mapCartItems(r){return r?.map(t=>this.mapCartItem(t))||[]}mapCartItem(r){let t=r.productVariant;return{id:r.id,productId:t?.product?.id||t?.id||"",variantId:t?.id,quantity:r.quantity,price:Number.parseFloat(t?.price||"0"),stock:t?.stock,product:this.mapProduct(t?.product)}}mapCustomer(r){if(r)return{id:r.id,email:r.email}}mapProduct(r){if(r)return{id:r.id,name:r.name,images:r.images||[]}}calculateTotal(r){return r.reduce((t,e)=>t+e.price*e.quantity,0)}async productBrowse(r){if(r.graphql){let t={offset:r.offset||0,limit:r.first||10,category:r.category,query:r.query,active:r.active,orderBy:r.orderBy,orderDirection:r.orderDirection},e=await this.graphqlRequest(r.graphql,t);return{data:e.products.data.map(i=>this.mapYnsProduct(i)),meta:e.products.meta}}else{let t=new URLSearchParams;r.first&&t.append("limit",r.first.toString()),r.offset&&t.append("offset",r.offset.toString()),r.category&&t.append("category",r.category),r.query&&t.append("q",r.query),r.active!==void 0&&t.append("active",r.active.toString()),r.orderBy&&t.append("orderBy",r.orderBy),r.orderDirection&&t.append("orderDirection",r.orderDirection);let e=`/products${t.toString()?`?${t.toString()}`:""}`,i=await this.restRequest(e);return{data:i.data.map(a=>this.mapYnsProduct(a)),meta:i.meta}}}async productGet(r){if(!r.slug&&!r.id)throw new Error("Either slug or id is required for productGet");if(r.graphql){let t={slug:r.slug,id:r.id},e=await this.graphqlRequest(r.graphql,t);return e.product?this.mapYnsProduct(e.product):null}else{let t=`/products/${r.id||r.slug}`,e=await this.restRequest(t);return e?this.mapYnsProduct(e):null}}async cartAdd(r){let t=r.quantity;if(r.cartId)try{let a=await this.cartGet({cartId:r.cartId});if(a){let s=a.items.find(n=>n.variantId===r.variantId);s&&(t=s.quantity+r.quantity)}}catch{}let e={variantId:r.variantId,cartId:r.cartId,quantity:t,subscriptionId:r.subscriptionId},i=await this.restRequest("/cart","POST",e);return this.mapCart(i)}async cartUpdate(r){let t={variantId:r.variantId,cartId:r.cartId,quantity:r.quantity},e=await this.restRequest("/cart","POST",t);return this.mapCart(e)}async cartRemove(r){let t=`/cart/${r.cartId}/items/${r.variantId}`,e=await this.restRequest(t,"DELETE");return this.mapCart(e)}async cartClear(r){let t=await this.restRequest(`/cart/${r.cartId}`,"DELETE");return this.mapCart(t)}async cartGet(r){let t=await this.restRequest(`/cart/${r.cartId}`);return t?this.mapCart(t):null}}});function c(o,r){if(!o)throw new Error(r)}var m=o=>{c(Number.isInteger(o),"Value must be an integer")};var y=o=>(c(o.length===3,"currency needs to be a 3-letter code"),w[o.toUpperCase()]??2);var h=({amount:o,currency:r})=>{m(o);let t=y(r),e=10**t;return Number.parseFloat((o/e).toFixed(t))},C=({amount:o,currency:r,locale:t="en-US"})=>{let e=h({amount:o,currency:r});return new Intl.NumberFormat(t,{style:"currency",currency:r}).format(e)},w={BIF:0,CLP:0,DJF:0,GNF:0,JPY:0,KMF:0,KRW:0,MGA:0,PYG:0,RWF:0,UGX:0,VND:0,VUV:0,XAF:0,XOF:0,XPF:0,BHD:3,JOD:3,KWD:3,OMR:3,TND:3};var u=class{config;provider;providerPromise;constructor(r){if(this.config=r||this.detectFromEnv(),!this.config.endpoint||!this.config.token)throw new Error("YNS configuration required. Provide endpoint and token in constructor or set YNS_ENDPOINT and YNS_TOKEN environment variables.")}detectFromEnv(){return{endpoint:process.env.YNS_ENDPOINT||"",token:process.env.YNS_TOKEN||""}}async getProvider(){return this.provider?this.provider:(this.providerPromise||(this.providerPromise=this.loadProvider()),this.provider=await this.providerPromise,this.provider)}async loadProvider(){try{let{createYnsProvider:r}=await Promise.resolve().then(()=>(l(),P));return r(this.config)}catch(r){throw new Error(`Failed to initialize YNS provider: ${r instanceof Error?r.message:"Unknown error"}`)}}get product(){return{browse:async(r={})=>(await this.getProvider()).productBrowse(r),get:async r=>(await this.getProvider()).productGet(r),search:async r=>{let t=await this.getProvider();if(!t.productSearch)throw new Error("Product search is not supported by YNS provider");return t.productSearch(r)}}}get cart(){return{add:async r=>(await this.getProvider()).cartAdd(r),update:async r=>(await this.getProvider()).cartUpdate(r),remove:async r=>(await this.getProvider()).cartRemove(r),clear:async r=>(await this.getProvider()).cartClear(r),get:async r=>(await this.getProvider()).cartGet(r)}}get order(){return{get:async r=>{let t=await this.getProvider();if(!t.orderGet)throw new Error("Order retrieval is not supported by YNS provider");return t.orderGet(r)},list:async(r={})=>{let t=await this.getProvider();if(!t.orderList)throw new Error("Order listing is not supported by YNS provider");return t.orderList(r)}}}};export{u as Commerce,C as formatMoney};
1
+ var n={DEBUG:0,LOG:1,WARN:2,ERROR:3},p=process.env.NEXT_PUBLIC_LOG_LEVEL||"LOG",i=n[p],l="\x1B[0m",I="\x1B[34m",R="\x1B[32m",E="\x1B[33m",y="\x1B[31m",m="\u23F1\uFE0F",B="\u{1F41B}",L="\u2714\uFE0F",w="\u26A0\uFE0F",$="\u274C",P=`${m} `,h=`${I}${B}${l} `,A=`${R}${L}${l} `,G=`${E}${w}${l} `,v=`${y}${$}${l} `,g=u=>{let t=u?`[${u}] `:"";return{getLogger(e){return g([u,e].filter(Boolean).join(" > "))},time(e){i>n.DEBUG||console.time([P,t,e].filter(Boolean).join(" "))},timeEnd(e){i>n.DEBUG||console.timeEnd([P,t,e].filter(Boolean).join(" "))},debug(...e){i>n.DEBUG||console.log(...[h,t,...e].filter(Boolean))},log(...e){i>n.LOG||console.log(...[A,t,...e].filter(Boolean))},dir(e,r){i>n.LOG||console.dir(e,r)},warn(...e){i>n.WARN||console.warn(...[G,t,...e].filter(Boolean))},error(...e){i>n.ERROR||console.error(...[v,t,...e].filter(Boolean))}}},O=g();var f=class{#e;#r=g("YnsProvider");constructor(t){this.#e=t,this.#r.debug("YnsProvider initialized")}async#t(t,e="GET",r){let o=await fetch(`${this.#e.endpoint}/api/${this.#e.version}${t}`,{method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#e.token}`},body:r?JSON.stringify(r):void 0});if(!o.ok){let d=o.headers.get("content-type"),s=`YNS REST request failed: ${o.status} ${o.statusText}`;if(d?.includes("application/json"))try{let a=await o.json();s=a.error||a.message||s}catch{}throw new Error(s)}let c=o.headers.get("content-type");if(!c?.includes("application/json"))throw new Error(`YNS API returned ${c} 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(([s,a])=>[s,a?String(a):void 0]).filter(([,s])=>s!==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 d=await this.#t(c);return e.debug("Received product browse result:",{meta:d.meta}),d}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{f as YnsProvider};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 response = await fetch(`${this.#config.endpoint}/api/${this.#config.version}${pathname}`, {\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\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","response","contentType","errorMessage","errorData","params","logger","queryParams","key","value","result"]}
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.0",
4
+ "version": "0.6.1-experimental.2",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
7
7
  "keywords": [
@@ -22,30 +22,6 @@
22
22
  ".": {
23
23
  "import": "./dist/index.js",
24
24
  "types": "./dist/index.d.ts"
25
- },
26
- "./yns": {
27
- "import": "./dist/yns.js",
28
- "types": "./dist/yns.d.ts"
29
- },
30
- "./stripe": {
31
- "import": "./dist/stripe.js",
32
- "types": "./dist/stripe.d.ts"
33
- },
34
- "./currencies": {
35
- "import": "./dist/currencies.js",
36
- "types": "./dist/currencies.d.ts"
37
- },
38
- "./internal": {
39
- "import": "./dist/internal.js",
40
- "types": "./dist/internal.d.ts"
41
- },
42
- "./yns-context": {
43
- "import": "./dist/yns-context.js",
44
- "types": "./dist/yns-context.d.ts"
45
- },
46
- "./db": {
47
- "import": "./dist/db.js",
48
- "types": "./dist/db.d.ts"
49
25
  }
50
26
  },
51
27
  "files": [
@@ -60,42 +36,45 @@
60
36
  "prepublishOnly": "bun run build",
61
37
  "dev": "tsup --config tsup.config.ts --watch",
62
38
  "lint": "biome check --write --unsafe",
63
- "test": "bun test"
39
+ "test": "bun test",
40
+ "prepare": "husky"
64
41
  },
65
42
  "devDependencies": {
66
43
  "@biomejs/biome": "2.2.3",
67
- "@neondatabase/serverless": "^1.0.1",
68
44
  "@types/node": "^24.3.1",
69
- "@types/react": "^19.1.12",
70
- "@types/react-dom": "^19.1.9",
71
- "next": "15.5.2",
72
- "react": "19.1.1",
73
- "react-dom": "19.1.1",
45
+ "@typescript/native-preview": "7.0.0-dev.20251022.1",
46
+ "husky": "9.1.7",
47
+ "lint-staged": "16.2.5",
74
48
  "rimraf": "6.0.1",
75
- "server-only": "0.0.1",
76
- "stripe": "^18.5.0",
77
49
  "tsup": "8.5.0",
78
50
  "tsx": "^4.20.5",
51
+ "typescript": "5.9.3",
79
52
  "zod": "^4.1.5"
80
53
  },
81
54
  "peerDependencies": {
82
- "@neondatabase/serverless": "^0.9.5",
83
55
  "@types/node": "^24.3.0",
84
- "@types/react": "^19.0.8",
85
- "@types/react-dom": "^19.0.3",
86
- "next": "15.5.2",
87
- "react": "^19.1.1",
88
- "react-dom": "19.1.1",
89
- "server-only": "0.0.1",
90
- "stripe": "^18.5.0",
91
- "typescript": "^5.9.2",
56
+ "typescript": "5.9.3",
57
+ "@typescript/native-preview": "7.0.0-dev.20251022.1",
92
58
  "zod": "^4.1.5"
93
59
  },
60
+ "peerDependenciesMeta": {
61
+ "typescript": {
62
+ "optional": true
63
+ },
64
+ "@typescript/native-preview": {
65
+ "optional": true
66
+ }
67
+ },
94
68
  "peerDependencyRules": {
95
69
  "allowedVersions": {
96
70
  "react": "^19",
97
71
  "react-dom": "^19"
98
72
  }
99
73
  },
100
- "packageManager": "bun@1.2.21"
74
+ "packageManager": "bun@1.2.21",
75
+ "lint-staged": {
76
+ "*": [
77
+ "bun biome check --write --unsafe --staged --no-errors-on-unmatched --files-ignore-unknown=true"
78
+ ]
79
+ }
101
80
  }