@funnelsgrove/runtime 0.7.29 → 0.7.30

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.
@@ -56,10 +56,15 @@ export type GeneratedOfferSetDiscount = {
56
56
  readonly position?: number | null;
57
57
  readonly metadata?: Record<string, unknown> | null;
58
58
  };
59
+ export type GeneratedOfferSetPaymentProviderModeConfig = {
60
+ readonly provider?: 'stripe' | 'solidgate' | null;
61
+ readonly stripePublishableKey?: string | null;
62
+ };
59
63
  export type GeneratedOfferSet = {
60
64
  readonly id?: string | null;
61
65
  readonly key: string;
62
66
  readonly paymentProfileId?: string | null;
67
+ readonly paymentProviderConfigByMode?: Partial<Record<RuntimeMode, GeneratedOfferSetPaymentProviderModeConfig>> | null;
63
68
  readonly isActive?: boolean | null;
64
69
  readonly metadata?: Record<string, unknown> | null;
65
70
  readonly items: readonly GeneratedOfferSetPlanItem[];
@@ -149,8 +149,22 @@ const normalizePublishedOfferSets = (config) => {
149
149
  ? { oldPriceLabel: pickString(item, 'oldPriceLabel', 'old_price_label') }
150
150
  : {})), { isDefault: (_a = pickBoolean(item, 'isDefault', 'is_default')) !== null && _a !== void 0 ? _a : false, providerMappingsByMode: Object.assign(Object.assign({}, (testMapping ? { test: testMapping } : {})), (liveMapping ? { live: liveMapping } : {})), metadata });
151
151
  });
152
- return Object.assign(Object.assign(Object.assign(Object.assign({}, (pickString(offerSet, 'id') ? { id: pickString(offerSet, 'id') } : {})), { key }), (pickString(offerSet, 'paymentProfileId', 'payment_profile_id')
152
+ const rawPaymentProviderConfigByMode = pick(offerSet, 'paymentProviderConfigByMode', 'payment_provider_config_by_mode');
153
+ const paymentProviderConfigByMode = isRecord(rawPaymentProviderConfigByMode)
154
+ ? Object.fromEntries(['test', 'live'].flatMap((mode) => {
155
+ const rawModeConfig = rawPaymentProviderConfigByMode[mode];
156
+ if (!isRecord(rawModeConfig)) {
157
+ return [];
158
+ }
159
+ const provider = parsePaymentProvider(pick(rawModeConfig, 'provider'), `Published runtime offer set "${key}" ${mode} payment provider config`);
160
+ const stripePublishableKey = pickString(rawModeConfig, 'stripePublishableKey', 'stripe_publishable_key');
161
+ return [[mode, Object.assign(Object.assign({}, (provider ? { provider } : {})), (stripePublishableKey ? { stripePublishableKey } : {}))]];
162
+ }))
163
+ : {};
164
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (pickString(offerSet, 'id') ? { id: pickString(offerSet, 'id') } : {})), { key }), (pickString(offerSet, 'paymentProfileId', 'payment_profile_id')
153
165
  ? { paymentProfileId: pickString(offerSet, 'paymentProfileId', 'payment_profile_id') }
166
+ : {})), (Object.keys(paymentProviderConfigByMode).length > 0
167
+ ? { paymentProviderConfigByMode }
154
168
  : {})), { isActive: (_a = pickBoolean(offerSet, 'isActive', 'is_active')) !== null && _a !== void 0 ? _a : true, metadata: isRecord(offerSet.metadata) ? offerSet.metadata : {}, items });
155
169
  });
156
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.7.29",
3
+ "version": "0.7.30",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",