@tagadapay/plugin-sdk 2.7.4 → 2.7.6

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
@@ -10,8 +10,9 @@
10
10
  *
11
11
  * This main export contains non-React utilities and types.
12
12
  */
13
- export type { Currency, Customer, Environment, EnvironmentConfig, Locale, Order, OrderAddress, OrderItem, OrderSummary, PickupPoint, Session, Store, } from './react/types';
14
- export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from './react/utils/money';
13
+ export type { Currency, Customer, Environment, EnvironmentConfig, Locale, Order, OrderAddress, OrderItem, OrderSummary, PickupPoint, Session, Store } from './react/types';
14
+ export type { CheckoutSessionPreview } from './react/hooks/useCheckout';
15
+ export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from './react/utils/money';
15
16
  export * from './data/iso3166';
16
17
  export * from './data/languages';
17
18
  export * from './v2';
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  * This main export contains non-React utilities and types.
12
12
  */
13
13
  // Export utility functions that don't depend on React
14
- export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from './react/utils/money';
14
+ export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from './react/utils/money';
15
15
  // Export data utilities
16
16
  export * from './data/iso3166';
17
17
  export * from './data/languages';
@@ -31,7 +31,7 @@ export declare const loadPluginConfig: (configVariant?: string, rawConfig?: RawP
31
31
  * Helper to load local config file for development (from /config directory)
32
32
  * Returns the config object that can be passed to TagadaProvider
33
33
  */
34
- export declare function loadLocalConfig(configName?: string): Promise<Record<string, unknown> | null>;
34
+ export declare function loadLocalConfig(configName?: string, defaultConfig?: any): Promise<Record<string, unknown> | null>;
35
35
  export interface CreateRawPluginConfigOptions {
36
36
  config?: any;
37
37
  }
@@ -158,7 +158,7 @@ export const loadPluginConfig = async (configVariant = 'default', rawConfig) =>
158
158
  * Helper to load local config file for development (from /config directory)
159
159
  * Returns the config object that can be passed to TagadaProvider
160
160
  */
161
- export async function loadLocalConfig(configName = 'default') {
161
+ export async function loadLocalConfig(configName = 'default', defaultConfig) {
162
162
  try {
163
163
  // Only load in localhost
164
164
  const isLocalhost = typeof window !== 'undefined' &&
@@ -168,6 +168,9 @@ export async function loadLocalConfig(configName = 'default') {
168
168
  if (!isLocalhost) {
169
169
  return null;
170
170
  }
171
+ if (defaultConfig) {
172
+ return defaultConfig;
173
+ }
171
174
  // Try .tgd.json first, then .json, then .config.json
172
175
  const possiblePaths = [
173
176
  `/config/${configName}.config.json`,
@@ -225,8 +228,11 @@ export async function createRawPluginConfig(options) {
225
228
  console.warn('[createRawPluginConfig] No storeId provided');
226
229
  return undefined;
227
230
  }
228
- const resolvedConfig = options?.config ?? await loadLocalConfig(configName);
229
- console.log("resolvedConfig", resolvedConfig);
231
+ const resolvedConfig = await loadLocalConfig(configName, options?.config);
232
+ if (!resolvedConfig) {
233
+ console.warn('[createRawPluginConfig] No config found');
234
+ return undefined;
235
+ }
230
236
  const rawConfig = {
231
237
  storeId: storeId,
232
238
  accountId: accountId,
@@ -2,16 +2,14 @@
2
2
  * Products Hook using TanStack Query
3
3
  * Replaces manual fetching with automatic caching
4
4
  */
5
- import { useMemo, useCallback } from 'react';
6
5
  import { useQuery } from '@tanstack/react-query';
6
+ import { useCallback, useMemo } from 'react';
7
7
  import { ProductsResource } from '../../core/resources/products';
8
- import { useTagadaContext } from '../providers/TagadaProvider';
9
- import { usePluginConfig } from './usePluginConfig';
10
8
  import { getGlobalApiClient } from './useApiQuery';
9
+ import { usePluginConfig } from './usePluginConfig';
11
10
  export function useProductsQuery(options = {}) {
12
11
  const { productIds = [], enabled = true, includeVariants = true, includePrices = true } = options;
13
12
  const { storeId } = usePluginConfig();
14
- const { isSessionInitialized } = useTagadaContext();
15
13
  // Create products resource client
16
14
  const productsResource = useMemo(() => {
17
15
  try {
@@ -26,7 +24,7 @@ export function useProductsQuery(options = {}) {
26
24
  // Use TanStack Query for fetching products
27
25
  const { data: products = [], isLoading, error, refetch } = useQuery({
28
26
  queryKey,
29
- enabled: enabled && !!storeId && isSessionInitialized,
27
+ enabled: enabled && !!storeId,
30
28
  queryFn: async () => {
31
29
  if (!storeId) {
32
30
  throw new Error('Store ID not found. Make sure the TagadaProvider is properly configured.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.7.4",
3
+ "version": "2.7.6",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",