@funnelsgrove/runtime 0.1.2 → 0.1.3

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,6 +38,7 @@ export declare const RUNTIME_ENV_KEYS: {
38
38
  readonly claimbeeMonthlyPriceId: readonly ["NEXT_PUBLIC_CLAIMBEE_MONTHLY_PRICE_ID", "CLAIMBEE_MONTHLY_PRICE_ID"];
39
39
  readonly claimbeeYearlyPriceId: readonly ["NEXT_PUBLIC_CLAIMBEE_YEARLY_PRICE_ID", "CLAIMBEE_YEARLY_PRICE_ID"];
40
40
  };
41
+ export declare const resolveRuntimeSdkApiBaseUrl: (value: string) => string;
41
42
  export type RuntimeEnvConfig = {
42
43
  readonly [Key in keyof typeof RUNTIME_ENV_KEYS]: string | undefined;
43
44
  };
@@ -60,6 +60,20 @@ export const RUNTIME_ENV_KEYS = {
60
60
  claimbeeMonthlyPriceId: ['NEXT_PUBLIC_CLAIMBEE_MONTHLY_PRICE_ID', 'CLAIMBEE_MONTHLY_PRICE_ID'],
61
61
  claimbeeYearlyPriceId: ['NEXT_PUBLIC_CLAIMBEE_YEARLY_PRICE_ID', 'CLAIMBEE_YEARLY_PRICE_ID'],
62
62
  };
63
+ const FUNNELSGROVE_CONTROL_PLANE_API_BASE_URL = 'https://api.funnelsgrove.com';
64
+ const FUNNELSGROVE_SDK_API_BASE_URL = 'https://sdk-api.funnelsgrove.com';
65
+ const trimTrailingSlash = (value) => {
66
+ return value.trim().replace(/\/+$/, '');
67
+ };
68
+ export const resolveRuntimeSdkApiBaseUrl = (value) => {
69
+ const normalized = trimTrailingSlash(value);
70
+ if (!normalized) {
71
+ return FUNNELSGROVE_SDK_API_BASE_URL;
72
+ }
73
+ return normalized === FUNNELSGROVE_CONTROL_PLANE_API_BASE_URL
74
+ ? FUNNELSGROVE_SDK_API_BASE_URL
75
+ : normalized;
76
+ };
63
77
  const RUNTIME_ENV_VALUES = {
64
78
  APP_DEALS_API_BASE_URL: readRuntimeEnv(() => process.env.APP_DEALS_API_BASE_URL),
65
79
  FUNNEL_ID: readRuntimeEnv(() => process.env.FUNNEL_ID),
@@ -1,4 +1,5 @@
1
1
  import { RUNTIME_PUBLIC_DEFAULTS, runtimePublicConfig } from './public-env.js';
2
+ import { resolveRuntimeSdkApiBaseUrl } from '../config/env.config.js';
2
3
  const trimTrailingSlash = (value) => {
3
4
  return value.replace(/\/+$/, '');
4
5
  };
@@ -16,7 +17,7 @@ const isPreviewFrameRuntime = () => {
16
17
  return false;
17
18
  }
18
19
  };
19
- export const APP_DEALS_API_BASE_URL = trimTrailingSlash(runtimePublicConfig.apiBaseUrl);
20
+ export const APP_DEALS_API_BASE_URL = trimTrailingSlash(resolveRuntimeSdkApiBaseUrl(runtimePublicConfig.apiBaseUrl));
20
21
  export const FUNNEL_SDK_PUBLISHABLE_KEY = runtimePublicConfig.funnelSdkPublishableKey;
21
22
  export const FUNNEL_ID = runtimePublicConfig.funnelId;
22
23
  export const FUNNEL_VERSION_ID = runtimePublicConfig.funnelVersionId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",