@favcrm/sdk 0.1.0

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,15 @@
1
+ import type { CartItem, CreateOrderRequest } from './types/shop.js';
2
+ export interface CheckoutFormFields {
3
+ firstName: string;
4
+ lastName: string;
5
+ email: string;
6
+ phone: string;
7
+ addressLine1: string;
8
+ addressLine2: string;
9
+ city: string;
10
+ country: string;
11
+ }
12
+ export declare function calculateFinalTotal(cartTotal: number, discountAmount: number, shippingCost: number): number;
13
+ export declare function validateCheckoutForm(fields: Pick<CheckoutFormFields, 'firstName' | 'lastName' | 'addressLine1' | 'city'>): string | null;
14
+ export declare function buildCreateOrderRequest(cart: CartItem[], form: CheckoutFormFields, shippingMethodId: number | null, promotionCode?: string): CreateOrderRequest;
15
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACnB,MAAM,CAER;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,MAAM,CAAC,GACnF,MAAM,GAAG,IAAI,CAUf;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,QAAQ,EAAE,EAChB,IAAI,EAAE,kBAAkB,EACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAC/B,aAAa,CAAC,EAAE,MAAM,GACrB,kBAAkB,CAqBpB"}
@@ -0,0 +1,35 @@
1
+ export function calculateFinalTotal(cartTotal, discountAmount, shippingCost) {
2
+ return Math.max(cartTotal - discountAmount + shippingCost, 0);
3
+ }
4
+ export function validateCheckoutForm(fields) {
5
+ if (!fields.firstName.trim() ||
6
+ !fields.lastName.trim() ||
7
+ !fields.addressLine1.trim() ||
8
+ !fields.city.trim()) {
9
+ return 'REQUIRED_FIELDS_MISSING';
10
+ }
11
+ return null;
12
+ }
13
+ export function buildCreateOrderRequest(cart, form, shippingMethodId, promotionCode) {
14
+ return {
15
+ lineItems: cart.map((item) => ({
16
+ productId: item.product.id,
17
+ quantity: item.quantity,
18
+ })),
19
+ customerInfo: {
20
+ firstName: form.firstName.trim(),
21
+ lastName: form.lastName.trim(),
22
+ email: form.email.trim() || undefined,
23
+ phone: form.phone.trim() || undefined,
24
+ },
25
+ shippingAddress: {
26
+ addressLine1: form.addressLine1.trim(),
27
+ addressLine2: form.addressLine2.trim() || undefined,
28
+ city: form.city.trim(),
29
+ country: form.country,
30
+ },
31
+ shippingMethodId: shippingMethodId ?? undefined,
32
+ promotionCode,
33
+ };
34
+ }
35
+ //# sourceMappingURL=checkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.js","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,cAAsB,EACtB,YAAoB;IAEpB,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,cAAc,GAAG,YAAY,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAoF;IAEpF,IACE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QACxB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QACvB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE;QAC3B,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EACnB,CAAC;QACD,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,IAAgB,EAChB,IAAwB,EACxB,gBAA+B,EAC/B,aAAsB;IAEtB,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7B,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;YAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,YAAY,EAAE;YACZ,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;YAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,SAAS;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,SAAS;SACtC;QACD,eAAe,EAAE;YACf,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;YACtC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,SAAS;YACnD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACtB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB;QACD,gBAAgB,EAAE,gBAAgB,IAAI,SAAS;QAC/C,aAAa;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { AppliedCoupon, PromotionValidationResponse } from './types/promotion.js';
2
+ export declare function buildAppliedCoupon(code: string, result: PromotionValidationResponse): AppliedCoupon;
3
+ export declare function getCouponErrorMessage(result: PromotionValidationResponse, errorCodeMap: Record<string, () => string>, fallback: string): string;
4
+ //# sourceMappingURL=coupon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coupon.d.ts","sourceRoot":"","sources":["../src/coupon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAEvF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,2BAA2B,GAClC,aAAa,CAUf;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,2BAA2B,EACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,EAC1C,QAAQ,EAAE,MAAM,GACf,MAAM,CAGR"}
package/dist/coupon.js ADDED
@@ -0,0 +1,16 @@
1
+ export function buildAppliedCoupon(code, result) {
2
+ return {
3
+ code,
4
+ discountType: result.discountType,
5
+ discountValue: result.discountValue,
6
+ discountAmount: result.discountAmount,
7
+ originalPrice: result.originalPrice,
8
+ finalPrice: result.finalPrice,
9
+ savingsPercentage: result.savingsPercentage,
10
+ };
11
+ }
12
+ export function getCouponErrorMessage(result, errorCodeMap, fallback) {
13
+ const errorFn = result.errorCode ? errorCodeMap[result.errorCode] : null;
14
+ return errorFn ? errorFn() : (result.errorMessage || fallback);
15
+ }
16
+ //# sourceMappingURL=coupon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coupon.js","sourceRoot":"","sources":["../src/coupon.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,MAAmC;IAEnC,OAAO;QACL,IAAI;QACJ,YAAY,EAAE,MAAM,CAAC,YAAa;QAClC,aAAa,EAAE,MAAM,CAAC,aAAc;QACpC,cAAc,EAAE,MAAM,CAAC,cAAe;QACtC,aAAa,EAAE,MAAM,CAAC,aAAc;QACpC,UAAU,EAAE,MAAM,CAAC,UAAW;QAC9B,iBAAiB,EAAE,MAAM,CAAC,iBAAkB;KAC7C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,MAAmC,EACnC,YAA0C,EAC1C,QAAgB;IAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzE,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,IAAI,QAAQ,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type { ProductImage, ProductOptionValue, ProductOption, ProductVariation, CategoryRef, Product, ProductListItem, CartItem, ShopCategory, ShippingMethod, CreateOrderRequest, ShopOrderItem, ShopOrder, } from './types/shop.js';
2
+ export type { PromotionValidationRequest, PromotionValidationResponse, AppliedCoupon, } from './types/promotion.js';
3
+ export { getEffectivePrice, hasDiscount, isInStock, getProductLink, getCategoryLabel, getPrimaryImage, toCartProduct, } from './shop.js';
4
+ export { calculateFinalTotal, validateCheckoutForm, buildCreateOrderRequest, } from './checkout.js';
5
+ export type { CheckoutFormFields } from './checkout.js';
6
+ export { buildAppliedCoupon, getCouponErrorMessage } from './coupon.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,aAAa,GACd,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // Shop logic
2
+ export { getEffectivePrice, hasDiscount, isInStock, getProductLink, getCategoryLabel, getPrimaryImage, toCartProduct, } from './shop.js';
3
+ // Checkout logic
4
+ export { calculateFinalTotal, validateCheckoutForm, buildCreateOrderRequest, } from './checkout.js';
5
+ // Coupon logic
6
+ export { buildAppliedCoupon, getCouponErrorMessage } from './coupon.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,aAAa;AACb,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,iBAAiB;AACjB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAGvB,eAAe;AACf,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
package/dist/shop.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { Product, ProductImage, ProductListItem } from './types/shop.js';
2
+ export declare function getEffectivePrice(product: Pick<ProductListItem, 'memberPrice' | 'discountPrice' | 'price'>): number;
3
+ export declare function hasDiscount(product: Pick<ProductListItem, 'discountPrice' | 'memberPrice' | 'price'>): boolean;
4
+ export declare function isInStock(stockStatus: string): boolean;
5
+ export declare function getProductLink(product: Pick<ProductListItem, 'slug' | 'id'>): string;
6
+ export declare function getCategoryLabel(product: Pick<ProductListItem, 'categoryName' | 'categories'>): string;
7
+ export declare function getPrimaryImage(product: Pick<Product, 'images'>): ProductImage | null;
8
+ export declare function toCartProduct(product: Product): ProductListItem;
9
+ //# sourceMappingURL=shop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shop.d.ts","sourceRoot":"","sources":["../src/shop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE9E,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,eAAe,GAAG,OAAO,CAAC,GACxE,MAAM,CAER;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,aAAa,GAAG,OAAO,CAAC,GACxE,OAAO,CAOT;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,CAEpF;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,GAAG,YAAY,CAAC,GAC5D,MAAM,CAKR;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,YAAY,GAAG,IAAI,CAErF;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAiB/D"}
package/dist/shop.js ADDED
@@ -0,0 +1,42 @@
1
+ export function getEffectivePrice(product) {
2
+ return product.memberPrice ?? product.discountPrice ?? product.price ?? 0;
3
+ }
4
+ export function hasDiscount(product) {
5
+ const price = product.price;
6
+ if (price == null)
7
+ return false;
8
+ return ((product.discountPrice != null && product.discountPrice < price) ||
9
+ (product.memberPrice != null && product.memberPrice < price));
10
+ }
11
+ export function isInStock(stockStatus) {
12
+ return stockStatus === 'instock' || stockStatus === 'lowstock';
13
+ }
14
+ export function getProductLink(product) {
15
+ return product.slug ? `/shop/${product.slug}` : `/shop/${product.id}`;
16
+ }
17
+ export function getCategoryLabel(product) {
18
+ return (product.categoryName ??
19
+ (product.categories.length > 0 ? product.categories[0].name : ''));
20
+ }
21
+ export function getPrimaryImage(product) {
22
+ return product.images.length > 0 ? product.images[0] : null;
23
+ }
24
+ export function toCartProduct(product) {
25
+ return {
26
+ id: product.id,
27
+ name: product.name,
28
+ description: product.description ?? '',
29
+ slug: product.slug,
30
+ price: product.price,
31
+ discountPrice: product.discountPrice,
32
+ memberPrice: product.memberPrice,
33
+ seoTitle: product.seoTitle,
34
+ status: product.status,
35
+ stockStatus: product.stockStatus,
36
+ categoryName: product.categoryName,
37
+ categories: product.categories,
38
+ isVariable: product.isVariable,
39
+ image: product.images.length > 0 ? product.images[0].src : null,
40
+ };
41
+ }
42
+ //# sourceMappingURL=shop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shop.js","sourceRoot":"","sources":["../src/shop.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAC/B,OAAyE;IAEzE,OAAO,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,OAAyE;IAEzE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,OAAO,CACL,CAAC,OAAO,CAAC,aAAa,IAAI,IAAI,IAAI,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC;QAChE,CAAC,OAAO,CAAC,WAAW,IAAI,IAAI,IAAI,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAC7D,CAAC;AACJ,CAAC;AAED,MA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EAAE,OAAO,CAAC,UAAU;QAC9B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;KAChE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ export interface PromotionValidationRequest {
2
+ promotionCode: string;
3
+ channel: "booking" | "event" | "online";
4
+ amount: number;
5
+ serviceUuid?: string;
6
+ eventId?: number;
7
+ }
8
+ export interface PromotionValidationResponse {
9
+ isValid: boolean;
10
+ promotionCode: string;
11
+ discountType?: string;
12
+ discountValue?: number;
13
+ discountAmount?: number;
14
+ originalPrice?: number;
15
+ finalPrice?: number;
16
+ savingsPercentage?: number;
17
+ errorMessage?: string;
18
+ errorCode?: string;
19
+ }
20
+ export interface AppliedCoupon {
21
+ code: string;
22
+ discountType: string;
23
+ discountValue: number;
24
+ discountAmount: number;
25
+ originalPrice: number;
26
+ finalPrice: number;
27
+ savingsPercentage: number;
28
+ }
29
+ //# sourceMappingURL=promotion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/types/promotion.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=promotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion.js","sourceRoot":"","sources":["../../src/types/promotion.ts"],"names":[],"mappings":""}
@@ -0,0 +1,158 @@
1
+ export interface ProductImage {
2
+ id: number;
3
+ src: string;
4
+ name: string;
5
+ alt: string;
6
+ blurhash: string;
7
+ thumbUrl: string;
8
+ mediumUrl: string;
9
+ width: number | null;
10
+ height: number | null;
11
+ isPrimary: boolean;
12
+ }
13
+ export interface ProductOptionValue {
14
+ id: number;
15
+ value: string;
16
+ position: number;
17
+ }
18
+ export interface ProductOption {
19
+ id: number;
20
+ name: string;
21
+ position: number;
22
+ required: boolean;
23
+ values: ProductOptionValue[];
24
+ }
25
+ export interface ProductVariation {
26
+ id: number;
27
+ name: string;
28
+ sku: string | null;
29
+ price: number;
30
+ discountPrice: number | null;
31
+ memberPrice: number | null;
32
+ regularPrice: number;
33
+ salePrice: number | null;
34
+ onSale: boolean;
35
+ seoTitle: string;
36
+ shippingWeight: number | null;
37
+ selectedOptions: {
38
+ optionName: string;
39
+ value: string;
40
+ }[];
41
+ stockQuantity: number;
42
+ stockStatus: string;
43
+ parentId: number;
44
+ }
45
+ export interface CategoryRef {
46
+ id: number;
47
+ name: string;
48
+ slug: string | null;
49
+ }
50
+ export interface Product {
51
+ id: number;
52
+ name: string;
53
+ shortName: string | null;
54
+ description: string | null;
55
+ slug: string | null;
56
+ sku: string | null;
57
+ price: number;
58
+ discountPrice: number | null;
59
+ memberPrice: number | null;
60
+ regularPrice: number;
61
+ salePrice: number | null;
62
+ onSale: boolean;
63
+ seoTitle: string | null;
64
+ seoDescription: string | null;
65
+ shippingWeight: number | null;
66
+ status: string;
67
+ stockQuantity: number;
68
+ stockStatus: string;
69
+ categoryId: number | null;
70
+ categoryName: string | null;
71
+ categories: CategoryRef[];
72
+ isVariable: boolean;
73
+ isVariation: boolean;
74
+ parentProductId: number | null;
75
+ images: ProductImage[];
76
+ options: ProductOption[];
77
+ selectedOptions: {
78
+ optionName: string;
79
+ value: string;
80
+ }[];
81
+ variations: ProductVariation[];
82
+ }
83
+ export interface ProductListItem {
84
+ id: number;
85
+ name: string;
86
+ description: string;
87
+ slug: string | null;
88
+ price: number | null;
89
+ discountPrice: number | null;
90
+ memberPrice: number | null;
91
+ seoTitle: string | null;
92
+ status: string | null;
93
+ stockStatus: string;
94
+ categoryName: string | null;
95
+ categories: CategoryRef[];
96
+ isVariable: boolean;
97
+ image: string | null;
98
+ }
99
+ export interface CartItem {
100
+ product: ProductListItem;
101
+ quantity: number;
102
+ }
103
+ export interface ShopCategory {
104
+ id: number;
105
+ name: string;
106
+ slug: string | null;
107
+ productCount: number;
108
+ }
109
+ export interface ShippingMethod {
110
+ id: number;
111
+ name: string;
112
+ description: string;
113
+ cost: number;
114
+ calculationType: string;
115
+ freeShippingThreshold: number | null;
116
+ }
117
+ export interface CreateOrderRequest {
118
+ lineItems: {
119
+ productId: number;
120
+ quantity: number;
121
+ }[];
122
+ customerInfo: {
123
+ firstName: string;
124
+ lastName: string;
125
+ email?: string;
126
+ phone?: string;
127
+ };
128
+ shippingAddress: {
129
+ addressLine1: string;
130
+ addressLine2?: string;
131
+ city: string;
132
+ state?: string;
133
+ zipCode?: string;
134
+ country?: string;
135
+ };
136
+ shippingMethodId?: number;
137
+ promotionCode?: string;
138
+ }
139
+ export interface ShopOrderItem {
140
+ productId: number | null;
141
+ productName: string;
142
+ quantity: number;
143
+ unitPrice: number;
144
+ lineTotal: number;
145
+ }
146
+ export interface ShopOrder {
147
+ id: number;
148
+ orderId: string;
149
+ orderNumber: string | null;
150
+ status: string;
151
+ subtotal: number;
152
+ discountAmount: number;
153
+ shippingCost: number;
154
+ totalAmount: number;
155
+ items: ShopOrderItem[];
156
+ createdAt: string;
157
+ }
158
+ //# sourceMappingURL=shop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shop.d.ts","sourceRoot":"","sources":["../../src/types/shop.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,C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,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shop.js","sourceRoot":"","sources":["../../src/types/shop.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@favcrm/sdk",
3
+ "version": "0.1.0",
4
+ "description": "FavCRM SDK - Shared business logic for shop, checkout, and promotions",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsgo",
19
+ "test": "vitest",
20
+ "test:coverage": "vitest --coverage",
21
+ "type-check": "tsgo --noEmit",
22
+ "lint": "eslint src"
23
+ },
24
+ "keywords": [
25
+ "favcrm",
26
+ "sdk",
27
+ "shop",
28
+ "checkout",
29
+ "promotions"
30
+ ],
31
+ "author": "FavCRM Team",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/favcrm/favcrm-sdk"
36
+ },
37
+ "packageManager": "pnpm@10.28.2",
38
+ "devDependencies": {
39
+ "@typescript/native-preview": "^7.0.0-dev",
40
+ "vitest": "^2.0.0"
41
+ }
42
+ }