@favcrm/sdk 0.1.0 → 0.1.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.
Files changed (45) hide show
  1. package/dist/browser.d.ts +26 -0
  2. package/dist/browser.d.ts.map +1 -0
  3. package/dist/browser.js +17 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/client.d.ts +43 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +110 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/events.d.ts +4 -0
  10. package/dist/events.d.ts.map +1 -0
  11. package/dist/events.js +45 -0
  12. package/dist/events.js.map +1 -0
  13. package/dist/index.d.ts +11 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +10 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/members.d.ts +4 -0
  18. package/dist/members.d.ts.map +1 -0
  19. package/dist/members.js +20 -0
  20. package/dist/members.js.map +1 -0
  21. package/dist/modules.d.ts +5 -0
  22. package/dist/modules.d.ts.map +1 -0
  23. package/dist/modules.js +20 -0
  24. package/dist/modules.js.map +1 -0
  25. package/dist/types/booking.d.ts +41 -0
  26. package/dist/types/booking.d.ts.map +1 -0
  27. package/dist/types/booking.js +2 -0
  28. package/dist/types/booking.js.map +1 -0
  29. package/dist/types/event.d.ts +84 -0
  30. package/dist/types/event.d.ts.map +1 -0
  31. package/dist/types/event.js +2 -0
  32. package/dist/types/event.js.map +1 -0
  33. package/dist/types/member.d.ts +115 -0
  34. package/dist/types/member.d.ts.map +1 -0
  35. package/dist/types/member.js +2 -0
  36. package/dist/types/member.js.map +1 -0
  37. package/dist/types/portal.d.ts +19 -0
  38. package/dist/types/portal.d.ts.map +1 -0
  39. package/dist/types/portal.js +2 -0
  40. package/dist/types/portal.js.map +1 -0
  41. package/dist/validation.d.ts +18 -0
  42. package/dist/validation.d.ts.map +1 -0
  43. package/dist/validation.js +74 -0
  44. package/dist/validation.js.map +1 -0
  45. package/package.json +10 -2
@@ -0,0 +1,26 @@
1
+ import { FavCRMClient } from './client.js';
2
+ import * as checkout from './checkout.js';
3
+ import * as validation from './validation.js';
4
+ declare const FavCRM: {
5
+ getEffectivePrice(product: Pick<import("./index.js").ProductListItem, "discountPrice" | "memberPrice" | "price">): number;
6
+ hasDiscount(product: Pick<import("./index.js").ProductListItem, "discountPrice" | "memberPrice" | "price">): boolean;
7
+ isInStock(stockStatus: string): boolean;
8
+ getProductLink(product: Pick<import("./index.js").ProductListItem, "id" | "slug">): string;
9
+ getCategoryLabel(product: Pick<import("./index.js").ProductListItem, "categories" | "categoryName">): string;
10
+ getPrimaryImage(product: Pick<import("./index.js").Product, "images">): import("./index.js").ProductImage | null;
11
+ toCartProduct(product: import("./index.js").Product): import("./index.js").ProductListItem;
12
+ calculateFinalTotal(cartTotal: number, discountAmount: number, shippingCost: number): number;
13
+ validateCheckoutForm(fields: Pick<checkout.CheckoutFormFields, "addressLine1" | "city" | "firstName" | "lastName">): string | null;
14
+ buildCreateOrderRequest(cart: import("./index.js").CartItem[], form: checkout.CheckoutFormFields, shippingMethodId: number | null, promotionCode?: string | undefined): import("./index.js").CreateOrderRequest;
15
+ buildAppliedCoupon(code: string, result: import("./index.js").PromotionValidationResponse): import("./index.js").AppliedCoupon;
16
+ getCouponErrorMessage(result: import("./index.js").PromotionValidationResponse, errorCodeMap: Record<string, () => string>, fallback: string): string;
17
+ validateEmail(email: string): boolean;
18
+ validatePhone(phone: string): boolean;
19
+ validateOtp(otp: string): boolean;
20
+ validateRequired(fields: Record<string, unknown>, required: string[]): string | null;
21
+ validateRegistrationForm(data: Partial<import("./index.js").RegistrationSubmission>): validation.ValidationError[];
22
+ validateEventRegistrationForm(data: Partial<import("./index.js").EventRegistrationSubmission>): validation.ValidationError[];
23
+ Client: typeof FavCRMClient;
24
+ };
25
+ export default FavCRM;
26
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAE9C,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;CAMX,CAAC;AAMF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { FavCRMClient } from './client.js';
2
+ import * as shop from './shop.js';
3
+ import * as checkout from './checkout.js';
4
+ import * as coupon from './coupon.js';
5
+ import * as validation from './validation.js';
6
+ const FavCRM = {
7
+ Client: FavCRMClient,
8
+ ...shop,
9
+ ...checkout,
10
+ ...coupon,
11
+ ...validation,
12
+ };
13
+ if (typeof window !== 'undefined') {
14
+ window.FavCRM = FavCRM;
15
+ }
16
+ export default FavCRM;
17
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,YAAY;IACpB,GAAG,IAAI;IACP,GAAG,QAAQ;IACX,GAAG,MAAM;IACT,GAAG,UAAU;CACd,CAAC;AAEF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACjC,MAA6C,CAAC,MAAM,GAAG,MAAM,CAAC;AACjE,CAAC;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { RegistrationSubmission, RegistrationResult } from './types/member.js';
2
+ import type { ApiEvent, EventRegistrationSubmission, EventRegistrationResult } from './types/event.js';
3
+ import type { CouponClaimSubmission, CouponClaimResult } from './types/portal.js';
4
+ import type { Product, ProductListItem, ShopCategory, ShippingMethod, CreateOrderRequest, ShopOrder } from './types/shop.js';
5
+ import type { PromotionValidationRequest, PromotionValidationResponse } from './types/promotion.js';
6
+ export interface FavCRMConfig {
7
+ baseUrl: string;
8
+ brandUuid: string;
9
+ portalToken?: string;
10
+ locale?: string;
11
+ }
12
+ export declare class FavCRMError extends Error {
13
+ code: string;
14
+ details?: Record<string, unknown>;
15
+ constructor(code: string, message: string, details?: Record<string, unknown>);
16
+ }
17
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
18
+ export declare class FavCRMClient {
19
+ private config;
20
+ private readonly brandPath;
21
+ constructor(config: FavCRMConfig);
22
+ request<T>(method: HttpMethod, path: string, body?: unknown): Promise<T>;
23
+ submitRegistration(data: RegistrationSubmission): Promise<RegistrationResult>;
24
+ submitEventRegistration(data: EventRegistrationSubmission): Promise<EventRegistrationResult>;
25
+ createOrder(data: CreateOrderRequest): Promise<ShopOrder>;
26
+ claimCoupon(data: CouponClaimSubmission): Promise<CouponClaimResult>;
27
+ validatePromotion(data: PromotionValidationRequest): Promise<PromotionValidationResponse>;
28
+ getProducts(params?: ProductListParams): Promise<ProductListItem[]>;
29
+ getProduct(slug: string): Promise<Product>;
30
+ getCategories(): Promise<ShopCategory[]>;
31
+ getShippingMethods(): Promise<ShippingMethod[]>;
32
+ getEvents(): Promise<ApiEvent[]>;
33
+ getEvent(slug: string): Promise<ApiEvent>;
34
+ }
35
+ export interface ProductListParams {
36
+ category?: string;
37
+ search?: string;
38
+ ordering?: string;
39
+ page?: number;
40
+ pageSize?: number;
41
+ }
42
+ export {};
43
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,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K,uBAAuB,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAEjG;IAEK,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC,CAE9D;IAEK,WAAW,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAEzE;IAEK,iBAAiB,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAE9F;IAIK,WAAW,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAGxE;IAEK,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE/C;IAEK,aAAa,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAE7C;IAEK,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAEpD;IAEK,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAErC;IAEK,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE9C;CACF;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
package/dist/client.js ADDED
@@ -0,0 +1,110 @@
1
+ export class FavCRMError extends Error {
2
+ code;
3
+ details;
4
+ constructor(code, message, details) {
5
+ super(message);
6
+ this.name = 'FavCRMError';
7
+ this.code = code;
8
+ this.details = details;
9
+ }
10
+ }
11
+ export class FavCRMClient {
12
+ config;
13
+ brandPath;
14
+ constructor(config) {
15
+ this.config = config;
16
+ this.brandPath = `/v6/member-portal/brands/${config.brandUuid}`;
17
+ }
18
+ async request(method, path, body) {
19
+ const url = `${this.config.baseUrl}${path}`;
20
+ const headers = {
21
+ 'Accept': 'application/json',
22
+ };
23
+ if (body != null) {
24
+ headers['Content-Type'] = 'application/json';
25
+ }
26
+ if (this.config.portalToken) {
27
+ headers['X-Portal-Token'] = this.config.portalToken;
28
+ }
29
+ if (this.config.locale) {
30
+ headers['Accept-Language'] = this.config.locale;
31
+ }
32
+ let response;
33
+ try {
34
+ response = await fetch(url, {
35
+ method,
36
+ headers,
37
+ body: body != null ? JSON.stringify(body) : undefined,
38
+ });
39
+ }
40
+ catch (err) {
41
+ throw new FavCRMError('NETWORK_ERROR', err instanceof Error ? err.message : 'Network request failed');
42
+ }
43
+ if (!response.ok) {
44
+ let errorBody;
45
+ try {
46
+ errorBody = await response.json();
47
+ }
48
+ catch {
49
+ // response body is not JSON
50
+ }
51
+ throw new FavCRMError(`HTTP_${response.status}`, errorBody?.message ?? errorBody?.detail ?? response.statusText, errorBody);
52
+ }
53
+ // Handle 204 No Content
54
+ if (response.status === 204) {
55
+ return undefined;
56
+ }
57
+ try {
58
+ return await response.json();
59
+ }
60
+ catch {
61
+ throw new FavCRMError('PARSE_ERROR', 'Failed to parse response JSON');
62
+ }
63
+ }
64
+ // --- Public portal submission endpoints ---
65
+ async submitRegistration(data) {
66
+ return this.request('POST', `${this.brandPath}/registration/`, data);
67
+ }
68
+ async submitEventRegistration(data) {
69
+ return this.request('POST', `${this.brandPath}/events/${data.eventSlug}/register/`, data);
70
+ }
71
+ async createOrder(data) {
72
+ return this.request('POST', `${this.brandPath}/shop/orders/`, data);
73
+ }
74
+ async claimCoupon(data) {
75
+ return this.request('POST', `${this.brandPath}/claim-coupon/`, data);
76
+ }
77
+ async validatePromotion(data) {
78
+ return this.request('POST', `${this.brandPath}/validate-promotion/`, data);
79
+ }
80
+ // --- Public read endpoints (no auth needed) ---
81
+ async getProducts(params) {
82
+ const qs = params ? `?${new URLSearchParams(toStringRecord(params))}` : '';
83
+ return this.request('GET', `${this.brandPath}/shop/products/${qs}`);
84
+ }
85
+ async getProduct(slug) {
86
+ return this.request('GET', `${this.brandPath}/shop/products/${slug}/`);
87
+ }
88
+ async getCategories() {
89
+ return this.request('GET', `${this.brandPath}/shop/categories/`);
90
+ }
91
+ async getShippingMethods() {
92
+ return this.request('GET', `${this.brandPath}/shop/shipping-methods/`);
93
+ }
94
+ async getEvents() {
95
+ return this.request('GET', `${this.brandPath}/events/`);
96
+ }
97
+ async getEvent(slug) {
98
+ return this.request('GET', `${this.brandPath}/events/${slug}/`);
99
+ }
100
+ }
101
+ function toStringRecord(obj) {
102
+ const result = {};
103
+ for (const [key, value] of Object.entries(obj)) {
104
+ if (value != null) {
105
+ result[key] = String(value);
106
+ }
107
+ }
108
+ return result;
109
+ }
110
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAoBA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,IAAI,CAAS;IACb,OAAO,CAA2B;IAElC,YAAY,IAAY,EAAE,OAAe,EAAE,OAAiC;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAID,MAAM,OAAO,YAAY;IACf,MAAM,CAAe;IACZ,SAAS,CAAS;IAEnC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,4BAA4B,MAAM,CAAC,SAAS,EAAE,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,OAAO,CAAI,MAAkB,EAAE,IAAY,EAAE,IAAc;QAC/D,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QAC5C,MAAM,OAAO,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
@@ -0,0 +1,4 @@
1
+ import type { ApiEvent, Event } from './types/event.js';
2
+ /** Map raw v6 API event to the normalized Event shape. */
3
+ export declare function mapApiEvent(raw: ApiEvent): Event;
4
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAExD,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,KAAK,CA0ChD"}
package/dist/events.js ADDED
@@ -0,0 +1,45 @@
1
+ /** Map raw v6 API event to the normalized Event shape. */
2
+ export function mapApiEvent(raw) {
3
+ const firstDate = raw.dates?.[0] ?? null;
4
+ const startDate = firstDate?.startTime ?? null;
5
+ const endDate = firstDate?.endTime ?? null;
6
+ const statusLower = raw.status.toLowerCase();
7
+ let status;
8
+ if (statusLower === "cancelled") {
9
+ status = "cancelled";
10
+ }
11
+ else if (statusLower === "published") {
12
+ status = "published";
13
+ }
14
+ else if (startDate && new Date(startDate) < new Date()) {
15
+ status = endDate && new Date(endDate) > new Date() ? "ongoing" : "past";
16
+ }
17
+ else {
18
+ status = "upcoming";
19
+ }
20
+ const quota = raw.quota ? parseInt(raw.quota, 10) : null;
21
+ return {
22
+ id: raw.id,
23
+ slug: raw.slug,
24
+ title: raw.title,
25
+ description: raw.introduction || raw.content || "",
26
+ imageUrl: raw.image || null,
27
+ startDate,
28
+ endDate,
29
+ dates: (raw.dates || []).map((d) => ({
30
+ id: d.id ?? null,
31
+ startTime: d.startTime,
32
+ endTime: d.endTime ?? null,
33
+ allDay: d.allDay ?? false,
34
+ remainingQuota: d.remainingQuota ?? null,
35
+ })),
36
+ location: raw.venue || null,
37
+ price: raw.price,
38
+ currency: raw.currency,
39
+ isFree: raw.price === 0,
40
+ capacity: isNaN(quota) ? null : quota,
41
+ remainingQuota: null,
42
+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AAI,GAAG,CAAC,OAAO,IAAI,EAAE;QAClD,QAAQ,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI;QAC3B,SAAS;QACT,OAAO;QACP,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,IAAI;YAChB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI;YAC1B,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK;YACzB,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,IAAI;SACzC,CAAC,CAAC;QACH,QAAQ,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI;QAC3B,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,MAAM,EAAE,GAAG,CAAC,KAAK,KAAK,CAAC;QACvB,QAAQ,EAAE,KAAK,CAAC,KAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QAC/C,cAAc,EAAE,IAAI;QACpB,MAAM;KACP,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,18 @@
1
1
  export type { ProductImage, ProductOptionValue, ProductOption, ProductVariation, CategoryRef, Product, ProductListItem, CartItem, ShopCategory, ShippingMethod, CreateOrderRequest, ShopOrderItem, ShopOrder, } from './types/shop.js';
2
2
  export type { PromotionValidationRequest, PromotionValidationResponse, AppliedCoupon, } from './types/promotion.js';
3
+ export type { MembershipTier, Member, ApiMembershipTier, ApiMember, CardSettings, PaymentMethod, RegistrationField, RegistrationFormConfig, ReferralLookupResult, RegistrationSubmission, RegistrationResult, } from './types/member.js';
4
+ export type { ApiEvent, ApiEventDate, EventDate, EventStatus, Event, EventRegistrationStatus, EventRegistration, EventRegistrationSubmission, EventRegistrationResult, } from './types/event.js';
5
+ export type { BookingService, BookingStatus, Booking, TimeSlot, } from './types/booking.js';
6
+ export type { CouponClaimSubmission, CouponClaimResult, PortalConfig, FeatureKey, } from './types/portal.js';
7
+ export { MODULE_CODE_TO_FEATURE, ALL_FEATURE_KEYS, modulesToFeatures } from './modules.js';
8
+ export { mapApiEvent } from './events.js';
9
+ export { mapApiMember } from './members.js';
3
10
  export { getEffectivePrice, hasDiscount, isInStock, getProductLink, getCategoryLabel, getPrimaryImage, toCartProduct, } from './shop.js';
4
11
  export { calculateFinalTotal, validateCheckoutForm, buildCreateOrderRequest, } from './checkout.js';
5
12
  export type { CheckoutFormFields } from './checkout.js';
6
13
  export { buildAppliedCoupon, getCouponErrorMessage } from './coupon.js';
14
+ export { FavCRMClient, FavCRMError } from './client.js';
15
+ export type { FavCRMConfig, ProductListParams } from './client.js';
16
+ export { validateEmail, validatePhone, validateOtp, validateRequired, validateRegistrationForm, validateEventRegistrationForm, } from './validation.js';
17
+ export type { ValidationError } from './validation.js';
7
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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,E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AAM,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;AAGxE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,17 @@
1
+ // Modules logic
2
+ export { MODULE_CODE_TO_FEATURE, ALL_FEATURE_KEYS, modulesToFeatures } from './modules.js';
3
+ // Event logic
4
+ export { mapApiEvent } from './events.js';
5
+ // Member logic
6
+ export { mapApiMember } from './members.js';
1
7
  // Shop logic
2
8
  export { getEffectivePrice, hasDiscount, isInStock, getProductLink, getCategoryLabel, getPrimaryImage, toCartProduct, } from './shop.js';
3
9
  // Checkout logic
4
10
  export { calculateFinalTotal, validateCheckoutForm, buildCreateOrderRequest, } from './checkout.js';
5
11
  // Coupon logic
6
12
  export { buildAppliedCoupon, getCouponErrorMessage } from './coupon.js';
13
+ // API Client
14
+ export { FavCRMClient, FavCRMError } from './client.js';
15
+ // Validation
16
+ export { validateEmail, validatePhone, validateOtp, validateRequired, validateRegistrationForm, validateEventRegistrationForm, } from './validation.js';
7
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmEA,gBAAgB;AAChB,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE3F,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,eAAe;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,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;AAExE,aAAa;AACb,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGxD,aAAa;AACb,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ApiMember, Member } from './types/member.js';
2
+ /** Map v6 API member response to the normalized Member shape. */
3
+ export declare function mapApiMember(api: ApiMember): Member;
4
+ //# sourceMappingURL=members.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../src/members.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3D,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAiBnD"}
@@ -0,0 +1,20 @@
1
+ /** Map v6 API member response to the normalized Member shape. */
2
+ export function mapApiMember(api) {
3
+ return {
4
+ uuid: api.uuid,
5
+ name: api.name ?? "",
6
+ email: api.email ?? null,
7
+ phone: api.phone ?? "",
8
+ avatarUrl: null,
9
+ membershipTier: api.membershipTier
10
+ ? {
11
+ id: String(api.membershipTier.id),
12
+ name: api.membershipTier.name,
13
+ level: api.membershipTier.priority ?? 0,
14
+ color: "",
15
+ benefits: [],
16
+ }
17
+ : null,
18
+ };
19
+ }
20
+ //# sourceMappingURL=members.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"members.js","sourceRoot":"","sources":["../src/members.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAAC,GAAc;IACzC,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE;QACpB,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI;QACxB,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE;QACtB,SAAS,EAAE,IAAI;QACf,cAAc,EAAE,GAAG,CAAC,cAAc;YAChC,CAAC,CAAC;gBACE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;gBACjC,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI;gBAC7B,KAAK,EAAE,GAAG,CAAC,cAAc,CAAC,QAAQ,IAAI,CAAC;gBACvC,KAAK,EAAE,EAAE;gBACT,QAAQ,EAAE,EAAE;aACb;YACH,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { FeatureKey } from './types/portal.js';
2
+ export declare const MODULE_CODE_TO_FEATURE: Record<string, FeatureKey>;
3
+ export declare const ALL_FEATURE_KEYS: FeatureKey[];
4
+ export declare function modulesToFeatures(moduleCodes: string[]): Set<FeatureKey>;
5
+ //# sourceMappingURL=modules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAM7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,UAAU,EAExC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAOxE"}
@@ -0,0 +1,20 @@
1
+ export const MODULE_CODE_TO_FEATURE = {
2
+ bookings: "spaces",
3
+ events: "events",
4
+ payment_gateway: "payments",
5
+ card_builder: "memberCard",
6
+ orders_shop: "shop",
7
+ };
8
+ export const ALL_FEATURE_KEYS = [
9
+ "spaces", "events", "payments", "memberCard", "shop",
10
+ ];
11
+ export function modulesToFeatures(moduleCodes) {
12
+ const result = new Set();
13
+ for (const code of moduleCodes) {
14
+ const feature = MODULE_CODE_TO_FEATURE[code];
15
+ if (feature)
16
+ result.add(feature);
17
+ }
18
+ return result;
19
+ }
20
+ //# sourceMappingURL=modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAA+B;IAChE,QAAQ,EAAE,QAAQ;IAClB,MAAM,EAAE,QAAQ;IAChB,eAAe,EAAE,UAAU;IAC3B,YAAY,EAAE,YAAY;IAC1B,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC5C,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM;CACrD,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,WAAqB;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAc,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,OAAO;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,41 @@
1
+ export interface BookingService {
2
+ id: string;
3
+ name: string;
4
+ description: string | null;
5
+ type: string;
6
+ durationMinutes: number;
7
+ capacity: number;
8
+ price: string;
9
+ currency: string;
10
+ coverImage: string | null;
11
+ requiresStaff: boolean;
12
+ requiresResource: boolean;
13
+ categoryId: string | null;
14
+ categoryName: string | null;
15
+ }
16
+ export type BookingStatus = "draft" | "confirmed" | "cancelled" | "completed";
17
+ export interface Booking {
18
+ id: string;
19
+ serviceId: string;
20
+ serviceName: string;
21
+ status: BookingStatus;
22
+ bookingDate: string;
23
+ startTime: string;
24
+ endTime: string;
25
+ totalPrice: string;
26
+ currency: string;
27
+ createdAt: string;
28
+ }
29
+ export interface TimeSlot {
30
+ startTime: string;
31
+ endTime: string;
32
+ available: boolean;
33
+ remainingCapacity: number;
34
+ scheduleId?: string;
35
+ quoteId?: string;
36
+ basePrice?: string;
37
+ tierPrice?: string;
38
+ tierName?: string | null;
39
+ priceType?: string;
40
+ }
41
+ //# sourceMappingURL=booking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booking.d.ts","sourceRoot":"","sources":["../../src/types/booking.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IA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 {"version":3,"file":"booking.js","sourceRoot":"","sources":["../../src/types/booking.ts"],"names":[],"mappings":""}
@@ -0,0 +1,84 @@
1
+ /** Raw event shape from the v6 customer-portal API. */
2
+ export interface ApiEvent {
3
+ id: string;
4
+ slug: string;
5
+ title: string;
6
+ introduction?: string | null;
7
+ content?: string | null;
8
+ price: number;
9
+ currency: string;
10
+ status: string;
11
+ venue: string | null;
12
+ venueAddress?: string | null;
13
+ image?: string | null;
14
+ quota?: string | null;
15
+ showRemainingQuota?: boolean;
16
+ dates: ApiEventDate[];
17
+ }
18
+ /** Raw event date shape from the v6 API. */
19
+ export interface ApiEventDate {
20
+ id?: string;
21
+ startTime: string;
22
+ endTime?: string | null;
23
+ allDay?: boolean;
24
+ remainingQuota?: number;
25
+ }
26
+ /** Normalized event date used throughout the app. */
27
+ export interface EventDate {
28
+ id: string | null;
29
+ startTime: string;
30
+ endTime: string | null;
31
+ allDay: boolean;
32
+ remainingQuota: number | null;
33
+ }
34
+ export type EventStatus = "upcoming" | "ongoing" | "past" | "cancelled" | "published";
35
+ /** Normalized event used throughout the app. */
36
+ export interface Event {
37
+ id: string;
38
+ slug: string;
39
+ title: string;
40
+ description: string;
41
+ imageUrl: string | null;
42
+ startDate: string | null;
43
+ endDate: string | null;
44
+ dates: EventDate[];
45
+ location: string | null;
46
+ price: number;
47
+ currency: string;
48
+ isFree: boolean;
49
+ capacity: number | null;
50
+ remainingQuota: number | null;
51
+ status: EventStatus;
52
+ }
53
+ export type EventRegistrationStatus = "pending" | "confirmed" | "cancelled" | "paid";
54
+ export interface EventRegistration {
55
+ id: string;
56
+ eventSlug: string;
57
+ eventTitle: string;
58
+ status: EventRegistrationStatus;
59
+ registeredAt: string;
60
+ totalAmount: number;
61
+ currency: string;
62
+ paymentRequired: boolean;
63
+ }
64
+ export interface EventRegistrationSubmission {
65
+ eventSlug: string;
66
+ sessionId: number;
67
+ quantity: number;
68
+ guestName: string;
69
+ email: string;
70
+ phone: string;
71
+ data?: Record<string, unknown>;
72
+ promotionCode?: string;
73
+ }
74
+ export interface EventRegistrationResult {
75
+ id: number;
76
+ eventSlug: string;
77
+ eventTitle: string;
78
+ status: string;
79
+ registeredAt: string;
80
+ totalAmount: number;
81
+ currency: string;
82
+ paymentRequired: boolean;
83
+ }
84
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/types/event.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAA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,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/types/event.ts"],"names":[],"mappings":""}
@@ -0,0 +1,115 @@
1
+ export interface MembershipTier {
2
+ id: string;
3
+ name: string;
4
+ level: number;
5
+ color: string;
6
+ benefits: string[];
7
+ spendingProgress?: {
8
+ currentSpending: number;
9
+ requiredSpending: number;
10
+ nextTier: string | null;
11
+ };
12
+ }
13
+ export interface Member {
14
+ uuid: string;
15
+ name: string;
16
+ email: string | null;
17
+ phone: string;
18
+ avatarUrl: string | null;
19
+ membershipTier: MembershipTier | null;
20
+ }
21
+ /** Raw membership tier shape from the v6 API (CamelCaseJSONRenderer). */
22
+ export interface ApiMembershipTier {
23
+ id: number;
24
+ name: string;
25
+ spendingCount: number;
26
+ totalSpendingAmount: number;
27
+ description: string | null;
28
+ multiplier: number;
29
+ discount: number;
30
+ priority: number | null;
31
+ isUpgradeable: boolean;
32
+ paymentGateway: string;
33
+ gatewayProductId: string | null;
34
+ gatewayPriceId: string | null;
35
+ validPeriodValue: number;
36
+ validPeriodUnit: string;
37
+ createdAt: string;
38
+ updatedAt: string;
39
+ }
40
+ /** Raw member shape from the v6 profile endpoint (CamelCaseJSONRenderer). */
41
+ export interface ApiMember {
42
+ id: number;
43
+ code: string | null;
44
+ name: string | null;
45
+ lastName: string | null;
46
+ phone: string | null;
47
+ email: string | null;
48
+ points: number;
49
+ stamps: number;
50
+ uuid: string;
51
+ agreeToReceivePromotion: boolean;
52
+ expiryDate: string | null;
53
+ createdAt: string;
54
+ updatedAt: string;
55
+ membershipTier: ApiMembershipTier | null;
56
+ }
57
+ export interface CardSettings {
58
+ brandName: string;
59
+ brandLogoUrl: string | null;
60
+ brandColor: string;
61
+ cardBackgroundUrl: string | null;
62
+ showQrCode: boolean;
63
+ }
64
+ export interface PaymentMethod {
65
+ id: string;
66
+ brand: string;
67
+ last4: string;
68
+ expMonth: number;
69
+ expYear: number;
70
+ isDefault: boolean;
71
+ }
72
+ export interface RegistrationField {
73
+ key: string;
74
+ label: string;
75
+ type: 'text' | 'phone' | 'email' | 'select' | 'date' | 'checkbox';
76
+ required: boolean;
77
+ enabled: boolean;
78
+ order: number;
79
+ checkboxLabel?: string;
80
+ }
81
+ export interface RegistrationFormConfig {
82
+ fields: RegistrationField[];
83
+ defaultCountryCode: string;
84
+ }
85
+ export interface ReferralLookupResult {
86
+ accountId: string;
87
+ name: string;
88
+ }
89
+ export interface RegistrationSubmission {
90
+ name: string;
91
+ lastName?: string;
92
+ phone: string;
93
+ email?: string;
94
+ birthMonthAndDay?: string;
95
+ gender?: 'M' | 'F' | 'O';
96
+ agreeToReceivePromotion: boolean;
97
+ agreeToPrivacyPolicy: boolean;
98
+ membershipTier?: number;
99
+ source?: string;
100
+ utmData?: Record<string, string>;
101
+ }
102
+ export interface RegistrationResult {
103
+ id: number;
104
+ uuid: string;
105
+ code: string;
106
+ name: string;
107
+ email?: string;
108
+ phone: string;
109
+ membershipTier: {
110
+ id: number;
111
+ name: string;
112
+ };
113
+ token: string;
114
+ }
115
+ //# sourceMappingURL=member.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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AC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACzB,uBAAuB,EAAE,OAAO,CAAC;IACjC,oBAAoB,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=member.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member.js","sourceRoot":"","sources":["../../src/types/member.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ export interface CouponClaimSubmission {
2
+ name: string;
3
+ email?: string;
4
+ phone?: string;
5
+ }
6
+ export interface CouponClaimResult {
7
+ couponCode: string;
8
+ expiresAt?: string;
9
+ message: string;
10
+ }
11
+ export type FeatureKey = "spaces" | "events" | "payments" | "memberCard" | "shop";
12
+ export interface PortalConfig {
13
+ portalType: string;
14
+ brandName: string;
15
+ brandUuid: string;
16
+ portalToken: string;
17
+ config: Record<string, unknown>;
18
+ }
19
+ //# sourceMappingURL=portal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/types/portal.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;AAElF,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=portal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal.js","sourceRoot":"","sources":["../../src/types/portal.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import type { RegistrationSubmission } from './types/member.js';
2
+ import type { EventRegistrationSubmission } from './types/event.js';
3
+ export interface ValidationError {
4
+ field: string;
5
+ code: 'REQUIRED' | 'INVALID_FORMAT';
6
+ message: string;
7
+ }
8
+ export declare function validateEmail(email: string): boolean;
9
+ /**
10
+ * Basic phone format validation. For strict international validation,
11
+ * use libphonenumber-js at the call site.
12
+ */
13
+ export declare function validatePhone(phone: string): boolean;
14
+ export declare function validateOtp(otp: string): boolean;
15
+ export declare function validateRequired(fields: Record<string, unknown>, required: string[]): string | null;
16
+ export declare function validateRegistrationForm(data: Partial<RegistrationSubmission>): ValidationError[];
17
+ export declare function validateEventRegistrationForm(data: Partial<EventRegistrationSubmission>): ValidationError[];
18
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAOD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,GAAG,IAAI,CAQf;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACpC,eAAe,EAAE,CAsBnB;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,CAAC,2BAA2B,CAAC,GACzC,eAAe,EAAE,CAgCnB"}
@@ -0,0 +1,74 @@
1
+ const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2
+ const PHONE_RE = /^\+?[\d\s\-().]{7,20}$/;
3
+ const OTP_RE = /^\d{6}$/;
4
+ const BIRTH_MMDD_RE = /^\d{4}$/;
5
+ export function validateEmail(email) {
6
+ return EMAIL_RE.test(email.trim());
7
+ }
8
+ /**
9
+ * Basic phone format validation. For strict international validation,
10
+ * use libphonenumber-js at the call site.
11
+ */
12
+ export function validatePhone(phone) {
13
+ return PHONE_RE.test(phone.trim());
14
+ }
15
+ export function validateOtp(otp) {
16
+ return OTP_RE.test(otp);
17
+ }
18
+ export function validateRequired(fields, required) {
19
+ for (const key of required) {
20
+ const value = fields[key];
21
+ if (value == null || (typeof value === 'string' && value.trim() === '')) {
22
+ return key;
23
+ }
24
+ }
25
+ return null;
26
+ }
27
+ export function validateRegistrationForm(data) {
28
+ const errors = [];
29
+ if (!data.name?.trim()) {
30
+ errors.push({ field: 'name', code: 'REQUIRED', message: 'Name is required' });
31
+ }
32
+ if (!data.phone?.trim()) {
33
+ errors.push({ field: 'phone', code: 'REQUIRED', message: 'Phone is required' });
34
+ }
35
+ else if (!validatePhone(data.phone)) {
36
+ errors.push({ field: 'phone', code: 'INVALID_FORMAT', message: 'Invalid phone number format' });
37
+ }
38
+ if (data.email != null && data.email.trim() !== '' && !validateEmail(data.email)) {
39
+ errors.push({ field: 'email', code: 'INVALID_FORMAT', message: 'Invalid email format' });
40
+ }
41
+ if (data.birthMonthAndDay != null && !BIRTH_MMDD_RE.test(data.birthMonthAndDay)) {
42
+ errors.push({ field: 'birthMonthAndDay', code: 'INVALID_FORMAT', message: 'Must be MMDD format' });
43
+ }
44
+ return errors;
45
+ }
46
+ export function validateEventRegistrationForm(data) {
47
+ const errors = [];
48
+ if (!data.eventSlug?.trim()) {
49
+ errors.push({ field: 'eventSlug', code: 'REQUIRED', message: 'Event slug is required' });
50
+ }
51
+ if (data.sessionId == null) {
52
+ errors.push({ field: 'sessionId', code: 'REQUIRED', message: 'Session is required' });
53
+ }
54
+ if (data.quantity == null || data.quantity < 1) {
55
+ errors.push({ field: 'quantity', code: 'REQUIRED', message: 'Quantity must be at least 1' });
56
+ }
57
+ if (!data.guestName?.trim()) {
58
+ errors.push({ field: 'guestName', code: 'REQUIRED', message: 'Guest name is required' });
59
+ }
60
+ if (!data.email?.trim()) {
61
+ errors.push({ field: 'email', code: 'REQUIRED', message: 'Email is required' });
62
+ }
63
+ else if (!validateEmail(data.email)) {
64
+ errors.push({ field: 'email', code: 'INVALID_FORMAT', message: 'Invalid email format' });
65
+ }
66
+ if (!data.phone?.trim()) {
67
+ errors.push({ field: 'phone', code: 'REQUIRED', message: 'Phone is required' });
68
+ }
69
+ else if (!validatePhone(data.phone)) {
70
+ errors.push({ field: 'phone', code: 'INVALID_FORMAT', message: 'Invalid phone number format' });
71
+ }
72
+ return errors;
73
+ }
74
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AASA,MAAM,QAAQ,GAAG,4BAA4B,CAAC;AAC9C,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAC1C,MAAM,MAAM,GAAG,SAAS,CAAC;AACzB,MAAM,aAAa,GAAG,SAAS,CAAC;AAEhC,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,MAA+B,EAC/B,QAAkB;IAElB,KAAK,MAAM,GAAG,IAA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AAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAClF,CAAC;SAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAClF,CAAC;SAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC,CAAC;IAClG,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@favcrm/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "FavCRM SDK - Shared business logic for shop, checkout, and promotions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
+ "browser": "./dist/favcrm-sdk.iife.js",
8
9
  "exports": {
9
10
  ".": {
10
11
  "import": "./dist/index.js",
11
12
  "types": "./dist/index.d.ts"
13
+ },
14
+ "./browser": {
15
+ "import": "./dist/favcrm-sdk.js",
16
+ "script": "./dist/favcrm-sdk.iife.js"
12
17
  }
13
18
  },
14
19
  "files": [
@@ -16,6 +21,7 @@
16
21
  ],
17
22
  "scripts": {
18
23
  "build": "tsgo",
24
+ "build:lib": "vite build --config vite.config.lib.ts",
19
25
  "test": "vitest",
20
26
  "test:coverage": "vitest --coverage",
21
27
  "type-check": "tsgo --noEmit",
@@ -37,6 +43,8 @@
37
43
  "packageManager": "pnpm@10.28.2",
38
44
  "devDependencies": {
39
45
  "@typescript/native-preview": "^7.0.0-dev",
40
- "vitest": "^2.0.0"
46
+ "@vitest/coverage-v8": "^2.1.9",
47
+ "vite": "^6.0.0",
48
+ "vitest": "^2.1.9"
41
49
  }
42
50
  }