@funnelsgrove/runtime 0.11.1 → 0.11.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.
- package/README.md +51 -0
- package/dist/components/ManageSubscriptionScreen.js +7 -2
- package/dist/runtime/funnel-attribution.js +34 -1
- package/dist/services/api.service.d.ts +28 -104
- package/dist/services/api.service.js +24 -519
- package/dist/services/funnel-sdk/checkout/chargeOneClickPayment.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/chargeOneClickPayment.js +17 -0
- package/dist/services/funnel-sdk/checkout/createHostedCheckoutSession.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/createHostedCheckoutSession.js +9 -0
- package/dist/services/funnel-sdk/checkout/createOneTimeCheckout.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/createOneTimeCheckout.js +18 -0
- package/dist/services/funnel-sdk/checkout/createOneTimePaymentIntent.d.ts +3 -0
- package/dist/services/funnel-sdk/checkout/createOneTimePaymentIntent.js +10 -0
- package/dist/services/funnel-sdk/checkout/createSubscriptionCheckout.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/createSubscriptionCheckout.js +19 -0
- package/dist/services/funnel-sdk/checkout/requests.d.ts +126 -0
- package/dist/services/funnel-sdk/checkout/requests.js +111 -0
- package/dist/services/funnel-sdk/checkout/types.d.ts +183 -0
- package/dist/services/funnel-sdk/checkout/types.js +1 -0
- package/dist/services/funnel-sdk/checkout/updateSubscriptionCheckoutPlan.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/updateSubscriptionCheckoutPlan.js +18 -0
- package/dist/services/funnel-sdk/checkout/verifySubscriptionCheckout.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/verifySubscriptionCheckout.js +18 -0
- package/dist/services/funnel-sdk/shared/http.d.ts +20 -0
- package/dist/services/funnel-sdk/shared/http.js +65 -0
- package/dist/services/funnel-sdk/shared/runtimeConfig.d.ts +17 -0
- package/dist/services/funnel-sdk/shared/runtimeConfig.js +42 -0
- package/dist/services/funnel-sdk/shared/types.d.ts +9 -0
- package/dist/services/funnel-sdk/shared/types.js +1 -0
- package/dist/services/funnel-sdk/subscriptions/listSubscriptions.d.ts +3 -0
- package/dist/services/funnel-sdk/subscriptions/listSubscriptions.js +17 -0
- package/dist/services/funnel-sdk/subscriptions/types.d.ts +24 -0
- package/dist/services/funnel-sdk/subscriptions/types.js +1 -0
- package/dist/services/funnel-sdk/subscriptions/updateSubscription.d.ts +2 -0
- package/dist/services/funnel-sdk/subscriptions/updateSubscription.js +33 -0
- package/dist/services/funnel-sdk/subscriptions/validator.d.ts +2 -0
- package/dist/services/funnel-sdk/subscriptions/validator.js +15 -0
- package/dist/services/funnel-sdk/uploads/preparePhotoUpload.d.ts +4 -0
- package/dist/services/funnel-sdk/uploads/preparePhotoUpload.js +19 -0
- package/dist/services/funnel-sdk/uploads/types.d.ts +32 -0
- package/dist/services/funnel-sdk/uploads/types.js +1 -0
- package/dist/services/funnel-sdk/uploads/uploadPhoto.d.ts +7 -0
- package/dist/services/funnel-sdk/uploads/uploadPhoto.js +18 -0
- package/dist/services/funnel-sdk/uploads/uploadPhotoFile.d.ts +2 -0
- package/dist/services/funnel-sdk/uploads/uploadPhotoFile.js +26 -0
- package/dist/services/funnel-sdk/users/bootstrapUser.d.ts +3 -0
- package/dist/services/funnel-sdk/users/bootstrapUser.js +15 -0
- package/dist/services/funnel-sdk/users/captureEmail.d.ts +2 -0
- package/dist/services/funnel-sdk/users/captureEmail.js +15 -0
- package/dist/services/funnel-sdk/users/claimUserSubscription.d.ts +3 -0
- package/dist/services/funnel-sdk/users/claimUserSubscription.js +7 -0
- package/dist/services/funnel-sdk/users/getCurrentUser.d.ts +3 -0
- package/dist/services/funnel-sdk/users/getCurrentUser.js +13 -0
- package/dist/services/funnel-sdk/users/getUserSubscriptionStatus.d.ts +3 -0
- package/dist/services/funnel-sdk/users/getUserSubscriptionStatus.js +14 -0
- package/dist/services/funnel-sdk/users/types.d.ts +57 -0
- package/dist/services/funnel-sdk/users/types.js +1 -0
- package/dist/services/funnel-sdk/users/updateFunnelUser.d.ts +3 -0
- package/dist/services/funnel-sdk/users/updateFunnelUser.js +18 -0
- package/dist/services/funnel-sdk.service.d.ts +26 -319
- package/dist/services/funnel-sdk.service.js +38 -456
- package/dist/services/session/bootstrap/bootstrapSession.d.ts +8 -0
- package/dist/services/session/bootstrap/bootstrapSession.js +23 -0
- package/dist/services/session/bootstrap/currentUser.d.ts +1 -0
- package/dist/services/session/bootstrap/currentUser.js +37 -0
- package/dist/services/session/bootstrap/idempotency.d.ts +9 -0
- package/dist/services/session/bootstrap/idempotency.js +97 -0
- package/dist/services/session/bootstrap/requests.d.ts +23 -0
- package/dist/services/session/bootstrap/requests.js +25 -0
- package/dist/services/session/bootstrap/responses.d.ts +3 -0
- package/dist/services/session/bootstrap/responses.js +10 -0
- package/dist/services/session/bootstrap/types.d.ts +11 -0
- package/dist/services/session/bootstrap/types.js +1 -0
- package/dist/services/session/emailCapture/captureEmail.d.ts +8 -0
- package/dist/services/session/emailCapture/captureEmail.js +13 -0
- package/dist/services/session/emailCapture/requests.d.ts +12 -0
- package/dist/services/session/emailCapture/requests.js +6 -0
- package/dist/services/session/emailCapture/responses.d.ts +3 -0
- package/dist/services/session/emailCapture/responses.js +14 -0
- package/dist/services/session/emailCapture/types.d.ts +8 -0
- package/dist/services/session/emailCapture/types.js +1 -0
- package/dist/services/session/emailCapture/validator.d.ts +16 -0
- package/dist/services/session/emailCapture/validator.js +37 -0
- package/dist/services/session/identity.d.ts +6 -0
- package/dist/services/session/identity.js +48 -0
- package/dist/services/session/ping/pingUserContext.d.ts +2 -0
- package/dist/services/session/ping/pingUserContext.js +10 -0
- package/dist/services/session/ping/transport.d.ts +2 -0
- package/dist/services/session/ping/transport.js +41 -0
- package/dist/services/session/shared/values.d.ts +6 -0
- package/dist/services/session/shared/values.js +25 -0
- package/dist/services/session/subscriptions/getManageSubscriptions.d.ts +3 -0
- package/dist/services/session/subscriptions/getManageSubscriptions.js +8 -0
- package/dist/services/session/subscriptions/identity.d.ts +3 -0
- package/dist/services/session/subscriptions/identity.js +8 -0
- package/dist/services/session/subscriptions/types.d.ts +35 -0
- package/dist/services/session/subscriptions/types.js +1 -0
- package/dist/services/session/subscriptions/updateSubscription.d.ts +10 -0
- package/dist/services/session/subscriptions/updateSubscription.js +7 -0
- package/dist/services/session/subscriptions/validator.d.ts +6 -0
- package/dist/services/session/subscriptions/validator.js +13 -0
- package/dist/services/session/uploads/localPhoto.d.ts +2 -0
- package/dist/services/session/uploads/localPhoto.js +10 -0
- package/dist/services/session/uploads/requests.d.ts +10 -0
- package/dist/services/session/uploads/requests.js +7 -0
- package/dist/services/session/uploads/types.d.ts +7 -0
- package/dist/services/session/uploads/types.js +1 -0
- package/dist/services/session/uploads/uploadTempPhoto.d.ts +6 -0
- package/dist/services/session/uploads/uploadTempPhoto.js +13 -0
- package/dist/services/session/uploads/validator.d.ts +3 -0
- package/dist/services/session/uploads/validator.js +12 -0
- package/dist/services/session/users/mappers.d.ts +13 -0
- package/dist/services/session/users/mappers.js +33 -0
- package/dist/services/session/users/requests.d.ts +15 -0
- package/dist/services/session/users/requests.js +8 -0
- package/dist/services/session/users/syncUrlUserAttributes.d.ts +10 -0
- package/dist/services/session/users/syncUrlUserAttributes.js +21 -0
- package/dist/services/session/users/types.d.ts +20 -0
- package/dist/services/session/users/types.js +1 -0
- package/dist/services/session/users/updateUser.d.ts +6 -0
- package/dist/services/session/users/updateUser.js +18 -0
- package/package.json +1 -1
- /package/dist/services/{funnel-sdk-payments.functions.d.ts → funnel-sdk/checkout/selection.d.ts} +0 -0
- /package/dist/services/{funnel-sdk-payments.functions.js → funnel-sdk/checkout/selection.js} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FunnelSdkRuntimeConfigOverrides } from '../shared/types.js';
|
|
2
|
+
export type FunnelSdkSubscriptionRef = {
|
|
3
|
+
provider: 'stripe' | 'solidgate';
|
|
4
|
+
paymentProfileId: string;
|
|
5
|
+
providerSubscriptionId: string;
|
|
6
|
+
environment: 'test' | 'live';
|
|
7
|
+
};
|
|
8
|
+
export type FunnelSdkUpdateSubscriptionInput = {
|
|
9
|
+
subscriptionId: string;
|
|
10
|
+
subscriptionRef?: FunnelSdkSubscriptionRef | null;
|
|
11
|
+
action: 'cancel' | 'renew' | 'apply-discount';
|
|
12
|
+
couponId?: string | null;
|
|
13
|
+
cancellationMode?: 'period_end' | 'immediate';
|
|
14
|
+
funnelId?: string | null;
|
|
15
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
16
|
+
stripeCustomerId?: string | null;
|
|
17
|
+
userId?: string | null;
|
|
18
|
+
};
|
|
19
|
+
export type FunnelSdkListSubscriptionsInput = {
|
|
20
|
+
funnelId?: string | null;
|
|
21
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
22
|
+
stripeCustomerId?: string | null;
|
|
23
|
+
userId?: string | null;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { postJson } from '../shared/http.js';
|
|
2
|
+
import { resolveRuntimeConfig } from '../shared/runtimeConfig.js';
|
|
3
|
+
import { requireSubscriptionRef } from './validator.js';
|
|
4
|
+
export const updateSubscription = async (input) => {
|
|
5
|
+
if (resolveRuntimeConfig(input.runtimeConfig).paymentsApiVersion === 'v2') {
|
|
6
|
+
return postJson(`/sdk/public/v2/subscriptions/${input.action}`, {
|
|
7
|
+
runtimeConfig: input.runtimeConfig,
|
|
8
|
+
body: {
|
|
9
|
+
userId: input.userId,
|
|
10
|
+
stripeCustomerId: input.stripeCustomerId,
|
|
11
|
+
funnelId: input.funnelId,
|
|
12
|
+
subscriptionRef: requireSubscriptionRef(input.subscriptionRef),
|
|
13
|
+
cancellationMode: input.cancellationMode,
|
|
14
|
+
couponId: input.couponId,
|
|
15
|
+
},
|
|
16
|
+
includeRuntimeFields: false,
|
|
17
|
+
includePublishableKey: false,
|
|
18
|
+
errorMessage: 'Failed to update subscription',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return postJson(`/sdk/public/subscriptions/${encodeURIComponent(input.subscriptionId)}/${input.action}`, {
|
|
22
|
+
runtimeConfig: input.runtimeConfig,
|
|
23
|
+
body: {
|
|
24
|
+
user_id: input.userId,
|
|
25
|
+
stripe_customer_id: input.stripeCustomerId,
|
|
26
|
+
funnelId: input.funnelId,
|
|
27
|
+
coupon_id: input.couponId,
|
|
28
|
+
},
|
|
29
|
+
includeRuntimeFields: false,
|
|
30
|
+
includePublishableKey: false,
|
|
31
|
+
errorMessage: 'Failed to update subscription',
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const requireSubscriptionRef = (value) => {
|
|
2
|
+
if (!value ||
|
|
3
|
+
(value.provider !== 'stripe' && value.provider !== 'solidgate') ||
|
|
4
|
+
!value.paymentProfileId.trim() ||
|
|
5
|
+
!value.providerSubscriptionId.trim() ||
|
|
6
|
+
(value.environment !== 'test' && value.environment !== 'live')) {
|
|
7
|
+
throw new Error('V2 subscription reference is required');
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
provider: value.provider,
|
|
11
|
+
paymentProfileId: value.paymentProfileId.trim(),
|
|
12
|
+
providerSubscriptionId: value.providerSubscriptionId.trim(),
|
|
13
|
+
environment: value.environment,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { postJson } from '../shared/http.js';
|
|
2
|
+
import { resolveRuntimeConfig } from '../shared/runtimeConfig.js';
|
|
3
|
+
export const preparePhotoUpload = async (input) => {
|
|
4
|
+
const { funnelId } = resolveRuntimeConfig(input.runtimeConfig);
|
|
5
|
+
return postJson('/sdk/public/uploads/photos/prepare', {
|
|
6
|
+
runtimeConfig: input.runtimeConfig,
|
|
7
|
+
body: {
|
|
8
|
+
funnelId,
|
|
9
|
+
userId: input.userId,
|
|
10
|
+
fileName: input.fileName,
|
|
11
|
+
contentType: input.contentType,
|
|
12
|
+
sizeBytes: input.sizeBytes,
|
|
13
|
+
source: input.source,
|
|
14
|
+
},
|
|
15
|
+
includeRuntimeFields: false,
|
|
16
|
+
includePublishableKey: false,
|
|
17
|
+
errorMessage: 'Failed to prepare photo upload',
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FunnelSdkRuntimeConfigOverrides } from '../shared/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Compatibility contract for already-published funnel bundles.
|
|
4
|
+
* New runtime code must use FunnelSdkUploadPhotoFileInput and uploadPhotoFile.
|
|
5
|
+
*/
|
|
6
|
+
export type FunnelSdkUploadPhotoInput = {
|
|
7
|
+
fileName: string;
|
|
8
|
+
imageDataUrl: string;
|
|
9
|
+
mimeType?: string | null;
|
|
10
|
+
source?: 'camera' | 'upload' | string | null;
|
|
11
|
+
userId?: string | null;
|
|
12
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
13
|
+
};
|
|
14
|
+
export type FunnelSdkUploadPhotoFileInput = {
|
|
15
|
+
file: Blob;
|
|
16
|
+
fileName: string;
|
|
17
|
+
contentType?: string | null;
|
|
18
|
+
source?: 'camera' | 'upload' | string | null;
|
|
19
|
+
userId?: string | null;
|
|
20
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
21
|
+
};
|
|
22
|
+
export type FunnelSdkPreparedPhotoUpload = {
|
|
23
|
+
key: string;
|
|
24
|
+
publicUrl: string;
|
|
25
|
+
uploadUrl: string;
|
|
26
|
+
uploadHeaders: Record<string, string>;
|
|
27
|
+
contentType: string;
|
|
28
|
+
sizeBytes: number;
|
|
29
|
+
};
|
|
30
|
+
export type FunnelSdkUploadedPhoto = Omit<FunnelSdkPreparedPhotoUpload, 'uploadUrl' | 'uploadHeaders'> & {
|
|
31
|
+
uploadedAt: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FunnelSdkUploadPhotoInput } from './types.js';
|
|
2
|
+
import type { FunnelSdkJsonObject } from '../shared/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Compatibility transport for already-published funnel bundles.
|
|
5
|
+
* New runtime code must use uploadPhotoFile so image bytes go directly to R2.
|
|
6
|
+
*/
|
|
7
|
+
export declare const uploadPhoto: <ResponsePayload = FunnelSdkJsonObject>(input: FunnelSdkUploadPhotoInput) => Promise<ResponsePayload>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { postJson } from '../shared/http.js';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Compatibility transport for already-published funnel bundles.
|
|
4
|
+
* New runtime code must use uploadPhotoFile so image bytes go directly to R2.
|
|
5
|
+
*/
|
|
6
|
+
export const uploadPhoto = async (input) => {
|
|
7
|
+
return postJson('/sdk/public/uploads/photos', {
|
|
8
|
+
runtimeConfig: input.runtimeConfig,
|
|
9
|
+
body: {
|
|
10
|
+
user_id: input.userId,
|
|
11
|
+
fileName: input.fileName,
|
|
12
|
+
mimeType: input.mimeType,
|
|
13
|
+
imageDataUrl: input.imageDataUrl,
|
|
14
|
+
source: input.source,
|
|
15
|
+
},
|
|
16
|
+
errorMessage: 'Failed to upload photo',
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { preparePhotoUpload } from './preparePhotoUpload.js';
|
|
2
|
+
export const uploadPhotoFile = async (input) => {
|
|
3
|
+
const prepared = await preparePhotoUpload({
|
|
4
|
+
fileName: input.fileName,
|
|
5
|
+
contentType: input.contentType,
|
|
6
|
+
sizeBytes: input.file.size,
|
|
7
|
+
source: input.source,
|
|
8
|
+
userId: input.userId,
|
|
9
|
+
runtimeConfig: input.runtimeConfig,
|
|
10
|
+
});
|
|
11
|
+
const response = await fetch(prepared.uploadUrl, {
|
|
12
|
+
method: 'PUT',
|
|
13
|
+
headers: prepared.uploadHeaders,
|
|
14
|
+
body: input.file,
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`Failed to upload photo (${response.status})`);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
key: prepared.key,
|
|
21
|
+
publicUrl: prepared.publicUrl,
|
|
22
|
+
contentType: prepared.contentType,
|
|
23
|
+
sizeBytes: prepared.sizeBytes,
|
|
24
|
+
uploadedAt: new Date().toISOString(),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { postJson } from '../shared/http.js';
|
|
2
|
+
export const bootstrapUser = async (input = {}) => {
|
|
3
|
+
return postJson('/sdk/public/users/bootstrap', {
|
|
4
|
+
runtimeConfig: input.runtimeConfig,
|
|
5
|
+
body: {
|
|
6
|
+
user_id: input.userId,
|
|
7
|
+
idempotencyKey: input.idempotencyKey,
|
|
8
|
+
email: input.email,
|
|
9
|
+
fullName: input.fullName,
|
|
10
|
+
metadata: input.metadata,
|
|
11
|
+
attribution: input.attribution,
|
|
12
|
+
},
|
|
13
|
+
errorMessage: 'Failed to bootstrap user session',
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { postJson } from '../shared/http.js';
|
|
2
|
+
import { CURRENT_STEP_CONTRACT_VERSION } from '../../../steps/step-contract.js';
|
|
3
|
+
export const captureEmail = async (input) => {
|
|
4
|
+
return postJson('/sdk/public/users/email-capture', {
|
|
5
|
+
runtimeConfig: input.runtimeConfig,
|
|
6
|
+
body: {
|
|
7
|
+
user_id: input.userId,
|
|
8
|
+
email: input.email,
|
|
9
|
+
environment: input.environment,
|
|
10
|
+
answers: input.answers,
|
|
11
|
+
stepContractVersion: CURRENT_STEP_CONTRACT_VERSION,
|
|
12
|
+
},
|
|
13
|
+
errorMessage: 'Failed to capture email',
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FunnelSdkClaimUserSubscriptionInput } from './types.js';
|
|
2
|
+
import type { FunnelSdkJsonObject } from '../shared/types.js';
|
|
3
|
+
export declare const claimUserSubscription: <ResponsePayload = FunnelSdkJsonObject>(input: FunnelSdkClaimUserSubscriptionInput) => Promise<ResponsePayload>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { postJson } from '../shared/http.js';
|
|
2
|
+
export const claimUserSubscription = async (input) => {
|
|
3
|
+
return postJson(`/sdk/public/users/${encodeURIComponent(input.userId)}/claim_subscription`, {
|
|
4
|
+
runtimeConfig: input.runtimeConfig,
|
|
5
|
+
errorMessage: 'Failed to claim user subscription',
|
|
6
|
+
});
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getJson } from '../shared/http.js';
|
|
2
|
+
import { resolveRuntimeConfig } from '../shared/runtimeConfig.js';
|
|
3
|
+
export const getCurrentUser = async (input) => {
|
|
4
|
+
const { funnelId } = resolveRuntimeConfig(input.runtimeConfig);
|
|
5
|
+
return getJson('/sdk/public/users/me', {
|
|
6
|
+
runtimeConfig: input.runtimeConfig,
|
|
7
|
+
searchParams: {
|
|
8
|
+
funnelId,
|
|
9
|
+
user_id: input.userId,
|
|
10
|
+
},
|
|
11
|
+
errorMessage: 'Failed to load user',
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FunnelSdkGetUserSubscriptionStatusInput } from './types.js';
|
|
2
|
+
import type { FunnelSdkJsonObject } from '../shared/types.js';
|
|
3
|
+
export declare const getUserSubscriptionStatus: <ResponsePayload = FunnelSdkJsonObject>(input?: FunnelSdkGetUserSubscriptionStatusInput) => Promise<ResponsePayload>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getJson } from '../shared/http.js';
|
|
2
|
+
import { resolveRuntimeConfig } from '../shared/runtimeConfig.js';
|
|
3
|
+
export const getUserSubscriptionStatus = async (input = {}) => {
|
|
4
|
+
const { funnelId } = resolveRuntimeConfig(input.runtimeConfig);
|
|
5
|
+
return getJson('/sdk/public/users/subscription', {
|
|
6
|
+
runtimeConfig: input.runtimeConfig,
|
|
7
|
+
searchParams: {
|
|
8
|
+
funnelId,
|
|
9
|
+
user_id: input.userId,
|
|
10
|
+
email: input.email,
|
|
11
|
+
},
|
|
12
|
+
errorMessage: 'Failed to load user subscription status',
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { FunnelSdkRuntimeMode, FunnelSdkRuntimeConfigOverrides, FunnelSdkJsonObject } from '../shared/types.js';
|
|
2
|
+
export type FunnelSdkBootstrapUserInput = {
|
|
3
|
+
userId?: string | null;
|
|
4
|
+
idempotencyKey?: string | null;
|
|
5
|
+
email?: string | null;
|
|
6
|
+
fullName?: string | null;
|
|
7
|
+
metadata?: FunnelSdkJsonObject | null;
|
|
8
|
+
attribution?: FunnelSdkJsonObject | null;
|
|
9
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
10
|
+
};
|
|
11
|
+
export type FunnelSdkCaptureEmailInput = {
|
|
12
|
+
userId: string;
|
|
13
|
+
email: string;
|
|
14
|
+
environment: FunnelSdkRuntimeMode;
|
|
15
|
+
answers?: FunnelSdkJsonObject;
|
|
16
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
17
|
+
};
|
|
18
|
+
export type FunnelSdkCaptureEmailResponse = {
|
|
19
|
+
user: {
|
|
20
|
+
user_id?: unknown;
|
|
21
|
+
fullName?: unknown;
|
|
22
|
+
email?: unknown;
|
|
23
|
+
document?: unknown;
|
|
24
|
+
};
|
|
25
|
+
canonicalUser?: {
|
|
26
|
+
user_id?: unknown;
|
|
27
|
+
email?: unknown;
|
|
28
|
+
} | null;
|
|
29
|
+
activeSubscription: boolean;
|
|
30
|
+
eventId: string;
|
|
31
|
+
eventCreated: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type FunnelSdkGetCurrentUserInput = {
|
|
34
|
+
userId: string;
|
|
35
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
36
|
+
};
|
|
37
|
+
export type FunnelSdkGetUserSubscriptionStatusInput = {
|
|
38
|
+
userId?: string | null;
|
|
39
|
+
email?: string | null;
|
|
40
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
41
|
+
};
|
|
42
|
+
export type FunnelSdkClaimUserSubscriptionInput = {
|
|
43
|
+
userId: string;
|
|
44
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
45
|
+
};
|
|
46
|
+
export type FunnelSdkUpdateFunnelUserInput = {
|
|
47
|
+
userId: string;
|
|
48
|
+
email?: string | null;
|
|
49
|
+
fullName?: string | null;
|
|
50
|
+
document?: FunnelSdkJsonObject | null;
|
|
51
|
+
progress?: FunnelSdkJsonObject | null;
|
|
52
|
+
metadata?: FunnelSdkJsonObject | null;
|
|
53
|
+
attribution?: FunnelSdkJsonObject | null;
|
|
54
|
+
subscription?: FunnelSdkJsonObject | null;
|
|
55
|
+
subscriptionStatus?: string | null;
|
|
56
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FunnelSdkUpdateFunnelUserInput } from './types.js';
|
|
2
|
+
import type { FunnelSdkJsonObject } from '../shared/types.js';
|
|
3
|
+
export declare const updateFunnelUser: <ResponsePayload = FunnelSdkJsonObject>(input: FunnelSdkUpdateFunnelUserInput) => Promise<ResponsePayload>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { postJson } from '../shared/http.js';
|
|
2
|
+
export const updateFunnelUser = async (input) => {
|
|
3
|
+
return postJson('/public/funnel-users/upsert', {
|
|
4
|
+
runtimeConfig: input.runtimeConfig,
|
|
5
|
+
body: {
|
|
6
|
+
user_id: input.userId,
|
|
7
|
+
email: input.email,
|
|
8
|
+
fullName: input.fullName,
|
|
9
|
+
document: input.document,
|
|
10
|
+
progress: input.progress,
|
|
11
|
+
metadata: input.metadata,
|
|
12
|
+
attribution: input.attribution,
|
|
13
|
+
subscription: input.subscription,
|
|
14
|
+
subscriptionStatus: input.subscriptionStatus,
|
|
15
|
+
},
|
|
16
|
+
errorMessage: 'Failed to update user',
|
|
17
|
+
});
|
|
18
|
+
};
|