@tagadapay/plugin-sdk 2.8.0 → 2.8.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.
@@ -38,11 +38,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
38
38
  borderTop: '1.5px solid #9ca3af',
39
39
  borderRadius: '50%',
40
40
  animation: 'tagada-spin 1s linear infinite',
41
- } }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
42
- @keyframes tagada-spin {
43
- 0% { transform: rotate(0deg); }
44
- 100% { transform: rotate(360deg); }
45
- }
41
+ } }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
42
+ @keyframes tagada-spin {
43
+ 0% { transform: rotate(0deg); }
44
+ 100% { transform: rotate(360deg); }
45
+ }
46
46
  ` })] }));
47
47
  const TagadaContext = createContext(null);
48
48
  export function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
@@ -12,7 +12,7 @@ import { ApiClient } from './apiClient';
12
12
  * Common types (for logging/tracking):
13
13
  * - Any string value is accepted, but these are commonly used examples
14
14
  */
15
- export declare enum FunnelEventType {
15
+ export declare enum FunnelActionType {
16
16
  DIRECT_NAVIGATION = "direct_navigation",
17
17
  BACK_NAVIGATION = "back_navigation",
18
18
  PAYMENT_SUCCESS = "payment_success",
@@ -65,16 +65,16 @@ interface BaseFunnelEvent {
65
65
  * Discriminated union for FunnelEvent based on event type
66
66
  */
67
67
  export type FunnelAction = BaseFunnelEvent & (({
68
- type: FunnelEventType.DIRECT_NAVIGATION;
68
+ type: FunnelActionType.DIRECT_NAVIGATION;
69
69
  data: NextEvent<DirectNavigationEventData>;
70
70
  }) | ({
71
- type: FunnelEventType.BACK_NAVIGATION;
71
+ type: FunnelActionType.BACK_NAVIGATION;
72
72
  data: NextEvent<BackNavigationEventData>;
73
73
  }) | ({
74
- type: FunnelEventType.PAYMENT_SUCCESS;
74
+ type: FunnelActionType.PAYMENT_SUCCESS;
75
75
  data: NextEvent<PaymentSuccessEventData>;
76
76
  }) | ({
77
- type: FunnelEventType.CUSTOM;
77
+ type: FunnelActionType.CUSTOM;
78
78
  data?: NextEvent<any>;
79
79
  }));
80
80
  export interface FunnelNavigationAction {
@@ -11,14 +11,14 @@
11
11
  * Common types (for logging/tracking):
12
12
  * - Any string value is accepted, but these are commonly used examples
13
13
  */
14
- export var FunnelEventType;
15
- (function (FunnelEventType) {
14
+ export var FunnelActionType;
15
+ (function (FunnelActionType) {
16
16
  // Special navigation types
17
- FunnelEventType["DIRECT_NAVIGATION"] = "direct_navigation";
18
- FunnelEventType["BACK_NAVIGATION"] = "back_navigation";
19
- FunnelEventType["PAYMENT_SUCCESS"] = "payment_success";
20
- FunnelEventType["CUSTOM"] = "custom";
21
- })(FunnelEventType || (FunnelEventType = {}));
17
+ FunnelActionType["DIRECT_NAVIGATION"] = "direct_navigation";
18
+ FunnelActionType["BACK_NAVIGATION"] = "back_navigation";
19
+ FunnelActionType["PAYMENT_SUCCESS"] = "payment_success";
20
+ FunnelActionType["CUSTOM"] = "custom";
21
+ })(FunnelActionType || (FunnelActionType = {}));
22
22
  export class FunnelResource {
23
23
  constructor(apiClient) {
24
24
  this.apiClient = apiClient;
@@ -21,7 +21,7 @@ export type { ShippingRate, ShippingRatesResponse } from './core/resources/shipp
21
21
  export type { ApplyDiscountResponse, Discount, DiscountCodeValidation, RemoveDiscountResponse } from './core/resources/discounts';
22
22
  export type { ToggleOrderBumpResponse, VipOffer, VipPreviewResponse } from './core/resources/vipOffers';
23
23
  export type { StoreConfig } from './core/resources/storeConfig';
24
- export { FunnelEventType } from './core/resources/funnel';
24
+ export { FunnelActionType } from './core/resources/funnel';
25
25
  export type { BackNavigationEventData, DirectNavigationEventData, FunnelContextUpdateRequest, FunnelContextUpdateResponse, FunnelAction as FunnelEvent, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelNavigationAction, FunnelNavigationResult, NextEvent, PaymentSuccessEventData, SimpleFunnelContext } from './core/resources/funnel';
26
26
  export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
27
27
  export type { TranslateFunction, TranslationText, UseTranslationOptions, UseTranslationResult } from './react/hooks/useTranslation';
package/dist/v2/index.js CHANGED
@@ -13,6 +13,6 @@ export * from './core/utils/pluginConfig';
13
13
  export * from './core/utils/products';
14
14
  // Path remapping helpers (framework-agnostic)
15
15
  export * from './core/pathRemapping';
16
- export { FunnelEventType } from './core/resources/funnel';
16
+ export { FunnelActionType } from './core/resources/funnel';
17
17
  // React exports (hooks and components only, types are exported above)
18
18
  export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
8
8
  import { useCallback, useEffect, useMemo, useState } from 'react';
9
- import { FunnelEventType, FunnelResource } from '../../core/resources/funnel';
9
+ import { FunnelActionType, FunnelResource } from '../../core/resources/funnel';
10
10
  import { useTagadaContext } from '../providers/TagadaProvider';
11
11
  import { getGlobalApiClient } from './useApiQuery';
12
12
  // Query keys for funnel operations
@@ -405,7 +405,7 @@ export function useFunnel(options) {
405
405
  }, [navigateMutation]);
406
406
  const goToStep = useCallback(async (stepId) => {
407
407
  return next({
408
- type: FunnelEventType.DIRECT_NAVIGATION,
408
+ type: FunnelActionType.DIRECT_NAVIGATION,
409
409
  data: { targetStepId: stepId },
410
410
  timestamp: new Date().toISOString()
411
411
  });
@@ -9,7 +9,7 @@ export interface UsePostPurchasesQueryOptions {
9
9
  autoInitializeCheckout?: boolean;
10
10
  }
11
11
  export interface UsePostPurchasesQueryResult {
12
- offers: PostPurchaseOffer[];
12
+ offers: PostPurchaseOffer[] | undefined;
13
13
  isLoading: boolean;
14
14
  error: Error | null;
15
15
  acceptOffer: (offerId: string, items: PostPurchaseOfferItem[]) => Promise<{
@@ -8,7 +8,6 @@ import { PostPurchasesResource } from '../../core/resources/postPurchases';
8
8
  import { useTagadaContext } from '../providers/TagadaProvider';
9
9
  import { getGlobalApiClient, getGlobalApiClientOrNull } from './useApiQuery';
10
10
  export function usePostPurchasesQuery(options) {
11
- console.log('usePostPurchasesQuery');
12
11
  const { orderId, enabled = true, autoInitializeCheckout = false } = options;
13
12
  const queryClient = useQueryClient();
14
13
  const { session, isSessionInitialized, apiService } = useTagadaContext();
@@ -165,7 +164,7 @@ export function usePostPurchasesQuery(options) {
165
164
  }
166
165
  }, [session?.customerId, orderId, postPurchasesResource, fetchOrderSummary]);
167
166
  // Main post-purchase offers query
168
- const { data: offers = [], isLoading, error, refetch, } = useQuery({
167
+ const { data: offers = undefined, isLoading, error, refetch, } = useQuery({
169
168
  queryKey: ['post-purchase-offers', orderId],
170
169
  queryFn: async () => {
171
170
  // Double-check token is available before making the request
@@ -193,7 +192,7 @@ export function usePostPurchasesQuery(options) {
193
192
  });
194
193
  // Auto-initialize checkout sessions if enabled
195
194
  useEffect(() => {
196
- if (autoInitializeCheckout && offers.length > 0 && session?.customerId && isSessionInitialized) {
195
+ if (autoInitializeCheckout && offers && offers.length > 0 && session?.customerId && isSessionInitialized) {
197
196
  // Initialize checkout sessions for all offers
198
197
  offers.forEach((offer) => {
199
198
  // The initializeOfferCheckout function will check if already initialized or initializing
@@ -293,21 +292,21 @@ export function usePostPurchasesQuery(options) {
293
292
  return await postPurchasesResource.initCheckoutSessionWithVariants(offerId, orderId, lineItems);
294
293
  },
295
294
  getOffer: (offerId) => {
296
- return offers.find(offer => offer.id === offerId);
295
+ return offers?.find(offer => offer.id === offerId);
297
296
  },
298
297
  getTotalValue: () => {
299
- return offers.reduce((total, offer) => {
298
+ return offers?.reduce((total, offer) => {
300
299
  return total + offer.summaries.reduce((summaryTotal, summary) => {
301
300
  return summaryTotal + summary.totalAmount;
302
301
  }, 0);
303
- }, 0);
302
+ }, 0) ?? 0;
304
303
  },
305
304
  getTotalSavings: () => {
306
- return offers.reduce((total, offer) => {
305
+ return offers?.reduce((total, offer) => {
307
306
  return total + offer.summaries.reduce((summaryTotal, summary) => {
308
307
  return summaryTotal + (summary.totalAmount - summary.totalAdjustedAmount);
309
308
  }, 0);
310
- }, 0);
309
+ }, 0) ?? 0;
311
310
  },
312
311
  // Checkout session management - exact same as V1
313
312
  getCheckoutSessionState: (offerId) => {
@@ -55,7 +55,7 @@ export type { ExtractedAddress, GooglePlaceDetails, GooglePrediction, UseGoogleA
55
55
  export type { ISOCountry, ISORegion, UseISODataResult } from './hooks/useISOData';
56
56
  export type { UsePluginConfigOptions, UsePluginConfigResult } from './hooks/usePluginConfig';
57
57
  export type { TranslateFunction, UseTranslationOptions, UseTranslationResult } from './hooks/useTranslation';
58
- export { FunnelEventType } from '../core/resources/funnel';
58
+ export { FunnelActionType } from '../core/resources/funnel';
59
59
  export type { UseCheckoutQueryOptions as UseCheckoutOptions, UseCheckoutQueryResult as UseCheckoutResult } from './hooks/useCheckoutQuery';
60
60
  export type { UseDiscountsQueryOptions as UseDiscountsOptions, UseDiscountsQueryResult as UseDiscountsResult } from './hooks/useDiscountsQuery';
61
61
  export type { FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext, UseFunnelOptions, UseFunnelResult } from './hooks/useFunnel';
@@ -45,6 +45,6 @@ export { useVipOffersQuery as useVipOffers } from './hooks/useVipOffersQuery';
45
45
  // Funnel hooks
46
46
  export { useFunnel, useSimpleFunnel } from './hooks/useFunnel';
47
47
  // TanStack Query types
48
- export { FunnelEventType } from '../core/resources/funnel';
48
+ export { FunnelActionType } from '../core/resources/funnel';
49
49
  // Re-export utilities from main react
50
50
  export { formatMoney } from '../../react/utils/money';
@@ -42,11 +42,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
42
42
  borderTop: '1.5px solid #9ca3af',
43
43
  borderRadius: '50%',
44
44
  animation: 'tagada-spin 1s linear infinite',
45
- } }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
46
- @keyframes tagada-spin {
47
- 0% { transform: rotate(0deg); }
48
- 100% { transform: rotate(360deg); }
49
- }
45
+ } }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
46
+ @keyframes tagada-spin {
47
+ 0% { transform: rotate(0deg); }
48
+ 100% { transform: rotate(360deg); }
49
+ }
50
50
  ` })] }));
51
51
  const isEnvironment = (value) => value === 'production' || value === 'development' || value === 'local';
52
52
  const resolveEnvironmentFromVariables = () => {
package/package.json CHANGED
@@ -1,97 +1,97 @@
1
- {
2
- "name": "@tagadapay/plugin-sdk",
3
- "version": "2.8.0",
4
- "description": "Modern React SDK for building Tagada Pay plugins",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js",
11
- "require": "./dist/index.js"
12
- },
13
- "./react": {
14
- "types": "./dist/react/index.d.ts",
15
- "import": "./dist/react/index.js",
16
- "require": "./dist/react/index.js"
17
- },
18
- "./v2": {
19
- "types": "./dist/v2/index.d.ts",
20
- "import": "./dist/v2/index.js",
21
- "require": "./dist/v2/index.js"
22
- }
23
- },
24
- "scripts": {
25
- "build": "tsc",
26
- "clean": "rm -rf dist",
27
- "lint": "echo \"No linting configured\"",
28
- "test": "jest --no-watchman",
29
- "test:watch": "jest --watch --no-watchman",
30
- "test:coverage": "jest --coverage --no-watchman",
31
- "dev": "tsc --watch",
32
- "prepublishOnly": "npm run clean && npm run build",
33
- "publish:patch": "npm version patch && npm publish",
34
- "publish:minor": "npm version minor && npm publish",
35
- "publish:major": "npm version major && npm publish",
36
- "publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
37
- "publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
38
- "version:patch": "npm version patch",
39
- "version:minor": "npm version minor",
40
- "version:major": "npm version major",
41
- "version:beta": "npm version prerelease --preid=beta",
42
- "version:alpha": "npm version prerelease --preid=alpha",
43
- "version:check": "node version-sync.js check",
44
- "version:sync": "node version-sync.js sync",
45
- "version:list": "node version-sync.js list",
46
- "version:next": "node version-sync.js next",
47
- "postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
48
- },
49
- "keywords": [
50
- "tagadapay",
51
- "cms",
52
- "plugin",
53
- "sdk",
54
- "react",
55
- "typescript"
56
- ],
57
- "author": "Tagada Pay",
58
- "license": "MIT",
59
- "dependencies": {
60
- "@basis-theory/apple-pay-js": "^2.0.2",
61
- "@basis-theory/basis-theory-js": "^4.30.0",
62
- "@basis-theory/basis-theory-react": "^1.32.5",
63
- "@basis-theory/web-threeds": "^1.0.1",
64
- "@google-pay/button-react": "^3.0.10",
65
- "@tanstack/react-query": "^5.90.2",
66
- "axios": "^1.10.0",
67
- "iso3166-2-db": "^2.3.11",
68
- "path-to-regexp": "^8.2.0",
69
- "react-intl": "^7.1.11",
70
- "swr": "^2.3.6"
71
- },
72
- "devDependencies": {
73
- "@types/jest": "^29.5.0",
74
- "@types/node": "^18.0.0",
75
- "@types/react": "^19",
76
- "@types/react-dom": "^19",
77
- "jest": "^29.5.0",
78
- "ts-jest": "^29.1.0",
79
- "typescript": "^5.0.0"
80
- },
81
- "peerDependencies": {
82
- "react": "^18.0.0 || ^19.0.0",
83
- "react-dom": "^18.0.0 || ^19.0.0"
84
- },
85
- "files": [
86
- "dist/**/*",
87
- "README.md"
88
- ],
89
- "repository": {
90
- "type": "git",
91
- "url": "git+https://github.com/tagadapay/plugin-sdk.git"
92
- },
93
- "bugs": {
94
- "url": "https://github.com/tagadapay/plugin-sdk/issues"
95
- },
96
- "homepage": "https://github.com/tagadapay/plugin-sdk#readme"
97
- }
1
+ {
2
+ "name": "@tagadapay/plugin-sdk",
3
+ "version": "2.8.2",
4
+ "description": "Modern React SDK for building Tagada Pay plugins",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
+ },
13
+ "./react": {
14
+ "types": "./dist/react/index.d.ts",
15
+ "import": "./dist/react/index.js",
16
+ "require": "./dist/react/index.js"
17
+ },
18
+ "./v2": {
19
+ "types": "./dist/v2/index.d.ts",
20
+ "import": "./dist/v2/index.js",
21
+ "require": "./dist/v2/index.js"
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build": "tsc",
26
+ "clean": "rm -rf dist",
27
+ "lint": "echo \"No linting configured\"",
28
+ "test": "jest --no-watchman",
29
+ "test:watch": "jest --watch --no-watchman",
30
+ "test:coverage": "jest --coverage --no-watchman",
31
+ "dev": "tsc --watch",
32
+ "prepublishOnly": "npm run clean && npm run build",
33
+ "publish:patch": "npm version patch && npm publish",
34
+ "publish:minor": "npm version minor && npm publish",
35
+ "publish:major": "npm version major && npm publish",
36
+ "publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
37
+ "publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
38
+ "version:patch": "npm version patch",
39
+ "version:minor": "npm version minor",
40
+ "version:major": "npm version major",
41
+ "version:beta": "npm version prerelease --preid=beta",
42
+ "version:alpha": "npm version prerelease --preid=alpha",
43
+ "version:check": "node version-sync.js check",
44
+ "version:sync": "node version-sync.js sync",
45
+ "version:list": "node version-sync.js list",
46
+ "version:next": "node version-sync.js next",
47
+ "postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
48
+ },
49
+ "keywords": [
50
+ "tagadapay",
51
+ "cms",
52
+ "plugin",
53
+ "sdk",
54
+ "react",
55
+ "typescript"
56
+ ],
57
+ "author": "Tagada Pay",
58
+ "license": "MIT",
59
+ "dependencies": {
60
+ "@basis-theory/apple-pay-js": "^2.0.2",
61
+ "@basis-theory/basis-theory-js": "^4.30.0",
62
+ "@basis-theory/basis-theory-react": "^1.32.5",
63
+ "@basis-theory/web-threeds": "^1.0.1",
64
+ "@google-pay/button-react": "^3.0.10",
65
+ "@tanstack/react-query": "^5.90.2",
66
+ "axios": "^1.10.0",
67
+ "iso3166-2-db": "^2.3.11",
68
+ "path-to-regexp": "^8.2.0",
69
+ "react-intl": "^7.1.11",
70
+ "swr": "^2.3.6"
71
+ },
72
+ "devDependencies": {
73
+ "@types/jest": "^29.5.0",
74
+ "@types/node": "^18.0.0",
75
+ "@types/react": "^19",
76
+ "@types/react-dom": "^19",
77
+ "jest": "^29.5.0",
78
+ "ts-jest": "^29.1.0",
79
+ "typescript": "^5.0.0"
80
+ },
81
+ "peerDependencies": {
82
+ "react": "^18.0.0 || ^19.0.0",
83
+ "react-dom": "^18.0.0 || ^19.0.0"
84
+ },
85
+ "files": [
86
+ "dist/**/*",
87
+ "README.md"
88
+ ],
89
+ "repository": {
90
+ "type": "git",
91
+ "url": "git+https://github.com/tagadapay/plugin-sdk.git"
92
+ },
93
+ "bugs": {
94
+ "url": "https://github.com/tagadapay/plugin-sdk/issues"
95
+ },
96
+ "homepage": "https://github.com/tagadapay/plugin-sdk#readme"
97
+ }