@clerk/shared 4.22.2-snapshot.v20260630200444 → 4.23.0
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/loadClerkJsScript.js +1 -1
- package/dist/loadClerkJsScript.js.map +1 -1
- package/dist/loadClerkJsScript.mjs +1 -1
- package/dist/loadClerkJsScript.mjs.map +1 -1
- package/dist/react/hooks/index.d.mts +2 -0
- package/dist/react/hooks/index.d.ts +2 -0
- package/dist/react/hooks/index.js +2 -0
- package/dist/react/hooks/useCreditBalance.d.mts +20 -0
- package/dist/react/hooks/useCreditBalance.d.ts +20 -0
- package/dist/react/hooks/useCreditBalance.js +77 -0
- package/dist/react/hooks/useCreditHistory.d.mts +20 -0
- package/dist/react/hooks/useCreditHistory.d.ts +20 -0
- package/dist/react/hooks/useCreditHistory.js +74 -0
- package/dist/react/hooks/useSafeLayoutEffect.d.mts +1 -1
- package/dist/react/hooks/useSafeLayoutEffect.d.ts +1 -1
- package/dist/react/index.d.mts +3 -1
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +140 -10
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +139 -11
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/stable-keys.js +5 -1
- package/dist/types/billing.d.mts +47 -1
- package/dist/types/billing.d.ts +47 -1
- package/dist/types/elementIds.d.mts +1 -1
- package/dist/types/elementIds.d.ts +1 -1
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/json.d.mts +19 -1
- package/dist/types/json.d.ts +19 -1
- package/dist/types/localization.d.mts +18 -0
- package/dist/types/localization.d.ts +18 -0
- package/dist/versionSelector.js +1 -1
- package/dist/versionSelector.js.map +1 -1
- package/dist/versionSelector.mjs +1 -1
- package/dist/versionSelector.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -128,6 +128,7 @@ const SUBSCRIPTION_KEY = "billing-subscription";
|
|
|
128
128
|
const PAYMENT_METHODS_KEY = "billing-payment-methods";
|
|
129
129
|
const PAYMENT_ATTEMPTS_KEY = "billing-payment-attempts";
|
|
130
130
|
const STATEMENTS_KEY = "billing-statements";
|
|
131
|
+
const CREDIT_BALANCE_KEY = "billing-credit-balance";
|
|
131
132
|
const STABLE_KEYS = {
|
|
132
133
|
USER_MEMBERSHIPS_KEY,
|
|
133
134
|
USER_INVITATIONS_KEY,
|
|
@@ -143,7 +144,8 @@ const STABLE_KEYS = {
|
|
|
143
144
|
STATEMENTS_KEY,
|
|
144
145
|
API_KEYS_KEY,
|
|
145
146
|
ORGANIZATION_CREATION_DEFAULTS_KEY,
|
|
146
|
-
OAUTH_CONSENT_INFO_KEY
|
|
147
|
+
OAUTH_CONSENT_INFO_KEY,
|
|
148
|
+
CREDIT_BALANCE_KEY
|
|
147
149
|
};
|
|
148
150
|
/**
|
|
149
151
|
* Internal stable keys for queries only used by our UI components.
|
|
@@ -157,10 +159,12 @@ const ENTERPRISE_CONNECTION_TEST_RUNS_KEY = "enterpriseConnectionTestRuns";
|
|
|
157
159
|
const ORGANIZATION_ENTERPRISE_CONNECTIONS_KEY = "organizationEnterpriseConnections";
|
|
158
160
|
const ORGANIZATION_ENTERPRISE_CONNECTION_TEST_RUNS_KEY = "organizationEnterpriseConnectionTestRuns";
|
|
159
161
|
const ORGANIZATION_DOMAINS_KEY = "organizationDomains";
|
|
162
|
+
const CREDIT_HISTORY_KEY = "billing-credit-history";
|
|
160
163
|
const INTERNAL_STABLE_KEYS = {
|
|
161
164
|
PAYMENT_ATTEMPT_KEY,
|
|
162
165
|
BILLING_PLANS_KEY,
|
|
163
166
|
BILLING_STATEMENTS_KEY,
|
|
167
|
+
CREDIT_HISTORY_KEY,
|
|
164
168
|
USER_ENTERPRISE_CONNECTIONS_KEY,
|
|
165
169
|
ENTERPRISE_CONNECTION_TEST_RUNS_KEY,
|
|
166
170
|
ORGANIZATION_ENTERPRISE_CONNECTIONS_KEY,
|
|
@@ -848,7 +852,7 @@ function useOAuthConsentCacheKeys(params) {
|
|
|
848
852
|
|
|
849
853
|
//#endregion
|
|
850
854
|
//#region src/react/hooks/useOAuthConsent.tsx
|
|
851
|
-
const HOOK_NAME$
|
|
855
|
+
const HOOK_NAME$4 = "useOAuthConsent";
|
|
852
856
|
/**
|
|
853
857
|
* The `useOAuthConsent()` hook loads OAuth application consent metadata for the **signed-in** user
|
|
854
858
|
* (`GET /me/oauth/consent/{oauthClientId}`). Ensure the user is authenticated before relying on this hook
|
|
@@ -865,12 +869,12 @@ const HOOK_NAME$2 = "useOAuthConsent";
|
|
|
865
869
|
* ```
|
|
866
870
|
*/
|
|
867
871
|
function useOAuthConsent(params) {
|
|
868
|
-
useAssertWrappedByClerkProvider(HOOK_NAME$
|
|
872
|
+
useAssertWrappedByClerkProvider(HOOK_NAME$4);
|
|
869
873
|
const { oauthClientId: oauthClientIdParam, scope, redirectUri, keepPreviousData = true, enabled = true } = params;
|
|
870
874
|
const clerk = useClerkInstanceContext();
|
|
871
875
|
const user = useUserBase();
|
|
872
876
|
const oauthClientId = (oauthClientIdParam ?? "").trim();
|
|
873
|
-
clerk.telemetry?.record(require_telemetry.eventMethodCalled(HOOK_NAME$
|
|
877
|
+
clerk.telemetry?.record(require_telemetry.eventMethodCalled(HOOK_NAME$4));
|
|
874
878
|
const { queryKey } = useOAuthConsentCacheKeys({
|
|
875
879
|
userId: user?.id ?? null,
|
|
876
880
|
oauthClientId,
|
|
@@ -1321,7 +1325,7 @@ function useOrganizationCreationDefaultsCacheKeys(params) {
|
|
|
1321
1325
|
|
|
1322
1326
|
//#endregion
|
|
1323
1327
|
//#region src/react/hooks/useOrganizationCreationDefaults.tsx
|
|
1324
|
-
const HOOK_NAME$
|
|
1328
|
+
const HOOK_NAME$3 = "useOrganizationCreationDefaults";
|
|
1325
1329
|
/**
|
|
1326
1330
|
* The `useOrganizationCreationDefaults()` hook retrieves the organization creation defaults for the current user.
|
|
1327
1331
|
*
|
|
@@ -1347,12 +1351,12 @@ const HOOK_NAME$1 = "useOrganizationCreationDefaults";
|
|
|
1347
1351
|
* ```
|
|
1348
1352
|
*/
|
|
1349
1353
|
function useOrganizationCreationDefaults(params = {}) {
|
|
1350
|
-
useAssertWrappedByClerkProvider(HOOK_NAME$
|
|
1354
|
+
useAssertWrappedByClerkProvider(HOOK_NAME$3);
|
|
1351
1355
|
const { keepPreviousData = true, enabled = true } = params;
|
|
1352
1356
|
const clerk = useClerkInstanceContext();
|
|
1353
1357
|
const user = useUserBase();
|
|
1354
1358
|
const featureEnabled = clerk.__internal_environment?.organizationSettings?.organizationCreationDefaults?.enabled ?? false;
|
|
1355
|
-
clerk.telemetry?.record(require_telemetry.eventMethodCalled(HOOK_NAME$
|
|
1359
|
+
clerk.telemetry?.record(require_telemetry.eventMethodCalled(HOOK_NAME$3));
|
|
1356
1360
|
const { queryKey } = useOrganizationCreationDefaultsCacheKeys({ userId: user?.id ?? null });
|
|
1357
1361
|
const queryEnabled = Boolean(user) && enabled && featureEnabled && clerk.loaded;
|
|
1358
1362
|
const query = useClerkQuery({
|
|
@@ -2377,12 +2381,12 @@ function useSubscriptionCacheKeys(params) {
|
|
|
2377
2381
|
|
|
2378
2382
|
//#endregion
|
|
2379
2383
|
//#region src/react/hooks/useSubscription.tsx
|
|
2380
|
-
const HOOK_NAME = "useSubscription";
|
|
2384
|
+
const HOOK_NAME$2 = "useSubscription";
|
|
2381
2385
|
/**
|
|
2382
2386
|
* @internal
|
|
2383
2387
|
*/
|
|
2384
2388
|
function useSubscription(params) {
|
|
2385
|
-
useAssertWrappedByClerkProvider(HOOK_NAME);
|
|
2389
|
+
useAssertWrappedByClerkProvider(HOOK_NAME$2);
|
|
2386
2390
|
const clerk = useClerkInstanceContext();
|
|
2387
2391
|
const user = useUserBase();
|
|
2388
2392
|
const organization = useOrganizationBase();
|
|
@@ -2390,7 +2394,7 @@ function useSubscription(params) {
|
|
|
2390
2394
|
const recordedRef = (0, react.useRef)(false);
|
|
2391
2395
|
(0, react.useEffect)(() => {
|
|
2392
2396
|
if (!recordedRef.current && clerk?.telemetry) {
|
|
2393
|
-
clerk.telemetry.record(require_telemetry.eventMethodCalled(HOOK_NAME));
|
|
2397
|
+
clerk.telemetry.record(require_telemetry.eventMethodCalled(HOOK_NAME$2));
|
|
2394
2398
|
recordedRef.current = true;
|
|
2395
2399
|
}
|
|
2396
2400
|
}, [clerk]);
|
|
@@ -2478,6 +2482,130 @@ const useCheckout = (options) => {
|
|
|
2478
2482
|
return (0, react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
2479
2483
|
};
|
|
2480
2484
|
|
|
2485
|
+
//#endregion
|
|
2486
|
+
//#region src/react/hooks/useCreditBalance.tsx
|
|
2487
|
+
const HOOK_NAME$1 = "useCreditBalance";
|
|
2488
|
+
/**
|
|
2489
|
+
* @internal
|
|
2490
|
+
*/
|
|
2491
|
+
function __internal_useCreditBalanceQuery(params) {
|
|
2492
|
+
useAssertWrappedByClerkProvider(HOOK_NAME$1);
|
|
2493
|
+
const clerk = useClerkInstanceContext();
|
|
2494
|
+
const user = useUserBase();
|
|
2495
|
+
const organization = useOrganizationBase();
|
|
2496
|
+
const billingEnabled = useBillingIsEnabled(params);
|
|
2497
|
+
const recordedRef = (0, react.useRef)(false);
|
|
2498
|
+
(0, react.useEffect)(() => {
|
|
2499
|
+
if (!recordedRef.current && clerk?.telemetry) {
|
|
2500
|
+
clerk.telemetry.record(require_telemetry.eventMethodCalled(HOOK_NAME$1));
|
|
2501
|
+
recordedRef.current = true;
|
|
2502
|
+
}
|
|
2503
|
+
}, [clerk]);
|
|
2504
|
+
const keepPreviousData = params?.keepPreviousData ?? false;
|
|
2505
|
+
const [queryClient] = useClerkQueryClient();
|
|
2506
|
+
const { queryKey, invalidationKey, stableKey, authenticated } = (0, react.useMemo)(() => {
|
|
2507
|
+
const safeOrgId = params?.for === "organization" ? organization?.id : void 0;
|
|
2508
|
+
return createCacheKeys({
|
|
2509
|
+
stablePrefix: STABLE_KEYS.CREDIT_BALANCE_KEY,
|
|
2510
|
+
authenticated: true,
|
|
2511
|
+
tracked: {
|
|
2512
|
+
userId: user?.id,
|
|
2513
|
+
orgId: safeOrgId
|
|
2514
|
+
},
|
|
2515
|
+
untracked: { args: { orgId: safeOrgId } }
|
|
2516
|
+
});
|
|
2517
|
+
}, [
|
|
2518
|
+
user?.id,
|
|
2519
|
+
organization?.id,
|
|
2520
|
+
params?.for
|
|
2521
|
+
]);
|
|
2522
|
+
const queriesEnabled = Boolean(user?.id && billingEnabled && (params?.enabled ?? true));
|
|
2523
|
+
useClearQueriesOnSignOut({
|
|
2524
|
+
isSignedOut: user === null,
|
|
2525
|
+
authenticated,
|
|
2526
|
+
stableKeys: stableKey
|
|
2527
|
+
});
|
|
2528
|
+
const query = useClerkQuery({
|
|
2529
|
+
queryKey,
|
|
2530
|
+
queryFn: ({ queryKey }) => {
|
|
2531
|
+
const obj = queryKey[3];
|
|
2532
|
+
return clerk.billing.getCreditBalance(obj.args);
|
|
2533
|
+
},
|
|
2534
|
+
staleTime: 1e3 * 60,
|
|
2535
|
+
enabled: queriesEnabled,
|
|
2536
|
+
placeholderData: defineKeepPreviousDataFn(keepPreviousData && queriesEnabled)
|
|
2537
|
+
});
|
|
2538
|
+
const revalidate = (0, react.useCallback)(() => queryClient.invalidateQueries({ queryKey: invalidationKey }), [queryClient, invalidationKey]);
|
|
2539
|
+
return {
|
|
2540
|
+
data: query.data,
|
|
2541
|
+
error: query.error ?? void 0,
|
|
2542
|
+
isLoading: query.isLoading,
|
|
2543
|
+
isFetching: query.isFetching,
|
|
2544
|
+
revalidate
|
|
2545
|
+
};
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
//#endregion
|
|
2549
|
+
//#region src/react/hooks/useCreditHistory.tsx
|
|
2550
|
+
const HOOK_NAME = "useCreditHistory";
|
|
2551
|
+
/**
|
|
2552
|
+
* @internal
|
|
2553
|
+
*/
|
|
2554
|
+
function __internal_useCreditHistoryQuery(params) {
|
|
2555
|
+
useAssertWrappedByClerkProvider(HOOK_NAME);
|
|
2556
|
+
const clerk = useClerkInstanceContext();
|
|
2557
|
+
const user = useUserBase();
|
|
2558
|
+
const organization = useOrganizationBase();
|
|
2559
|
+
const billingEnabled = useBillingIsEnabled(params);
|
|
2560
|
+
const recordedRef = (0, react.useRef)(false);
|
|
2561
|
+
(0, react.useEffect)(() => {
|
|
2562
|
+
if (!recordedRef.current && clerk?.telemetry) {
|
|
2563
|
+
clerk.telemetry.record(require_telemetry.eventMethodCalled(HOOK_NAME));
|
|
2564
|
+
recordedRef.current = true;
|
|
2565
|
+
}
|
|
2566
|
+
}, [clerk]);
|
|
2567
|
+
const [queryClient] = useClerkQueryClient();
|
|
2568
|
+
const { queryKey, invalidationKey, stableKey, authenticated } = (0, react.useMemo)(() => {
|
|
2569
|
+
const safeOrgId = params?.for === "organization" ? organization?.id : void 0;
|
|
2570
|
+
return createCacheKeys({
|
|
2571
|
+
stablePrefix: INTERNAL_STABLE_KEYS.CREDIT_HISTORY_KEY,
|
|
2572
|
+
authenticated: true,
|
|
2573
|
+
tracked: {
|
|
2574
|
+
userId: user?.id,
|
|
2575
|
+
orgId: safeOrgId
|
|
2576
|
+
},
|
|
2577
|
+
untracked: { args: { orgId: safeOrgId } }
|
|
2578
|
+
});
|
|
2579
|
+
}, [
|
|
2580
|
+
user?.id,
|
|
2581
|
+
organization?.id,
|
|
2582
|
+
params?.for
|
|
2583
|
+
]);
|
|
2584
|
+
const queriesEnabled = Boolean(user?.id && billingEnabled && (params?.enabled ?? true));
|
|
2585
|
+
useClearQueriesOnSignOut({
|
|
2586
|
+
isSignedOut: user === null,
|
|
2587
|
+
authenticated,
|
|
2588
|
+
stableKeys: stableKey
|
|
2589
|
+
});
|
|
2590
|
+
const query = useClerkQuery({
|
|
2591
|
+
queryKey,
|
|
2592
|
+
queryFn: ({ queryKey }) => {
|
|
2593
|
+
const obj = queryKey[3];
|
|
2594
|
+
return clerk.billing.getCreditHistory(obj.args);
|
|
2595
|
+
},
|
|
2596
|
+
staleTime: 1e3 * 60,
|
|
2597
|
+
enabled: queriesEnabled
|
|
2598
|
+
});
|
|
2599
|
+
const revalidate = (0, react.useCallback)(() => queryClient.invalidateQueries({ queryKey: invalidationKey }), [queryClient, invalidationKey]);
|
|
2600
|
+
return {
|
|
2601
|
+
data: query.data,
|
|
2602
|
+
error: query.error ?? void 0,
|
|
2603
|
+
isLoading: query.isLoading,
|
|
2604
|
+
isFetching: query.isFetching,
|
|
2605
|
+
revalidate
|
|
2606
|
+
};
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2481
2609
|
//#endregion
|
|
2482
2610
|
//#region src/react/hooks/useStatementQuery.shared.ts
|
|
2483
2611
|
function useStatementQueryCacheKeys(params) {
|
|
@@ -3600,6 +3728,8 @@ exports.__experimental_usePlans = usePlans;
|
|
|
3600
3728
|
exports.__experimental_useStatements = useStatements;
|
|
3601
3729
|
exports.__experimental_useSubscription = useSubscription;
|
|
3602
3730
|
exports.__internal_useClientBase = useClientBase;
|
|
3731
|
+
exports.__internal_useCreditBalanceQuery = __internal_useCreditBalanceQuery;
|
|
3732
|
+
exports.__internal_useCreditHistoryQuery = __internal_useCreditHistoryQuery;
|
|
3603
3733
|
exports.__internal_useOrganizationBase = useOrganizationBase;
|
|
3604
3734
|
exports.__internal_useOrganizationDomains = useOrganizationDomains;
|
|
3605
3735
|
exports.__internal_useOrganizationEnterpriseConnectionTestRuns = useOrganizationEnterpriseConnectionTestRuns;
|