@scalemule/nextjs 0.0.39 → 0.0.40
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/client.d.mts +5 -1
- package/dist/client.d.ts +5 -1
- package/dist/{index-BoENfro3.d.mts → index-BIIUrnPr.d.mts} +54 -1
- package/dist/{index-BoENfro3.d.ts → index-BIIUrnPr.d.ts} +54 -1
- package/dist/index.d.mts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +176 -89
- package/dist/index.mjs +168 -90
- package/dist/server/auth.js +275 -6
- package/dist/server/auth.mjs +275 -6
- package/dist/server/index.d.mts +135 -4
- package/dist/server/index.d.ts +135 -4
- package/dist/server/index.js +333 -6
- package/dist/server/index.mjs +325 -7
- package/dist/server/webhook-handler.d.mts +3 -2
- package/dist/server/webhook-handler.d.ts +3 -2
- package/dist/server/webhook-handler.js +3 -0
- package/dist/server/webhook-handler.mjs +3 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{webhook-handler-CjSSCdvI.d.ts → webhook-handler-BjFbqZuq.d.ts} +4 -1
- package/dist/{webhook-handler-Cz9jtet2.d.mts → webhook-handler-BqzCYRNJ.d.mts} +4 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createContext, useState, useMemo, useEffect, useCallback, useContext, useRef } from 'react';
|
|
2
|
+
import { createMoneyClient } from '@scalemule/money';
|
|
3
|
+
export { MoneyClient, createMoneyClient } from '@scalemule/money';
|
|
2
4
|
import { jsx } from 'react/jsx-runtime';
|
|
3
5
|
|
|
4
6
|
var __defProp = Object.defineProperty;
|
|
@@ -3087,7 +3089,6 @@ var RealtimeService = class extends ServiceModule {
|
|
|
3087
3089
|
super(...arguments);
|
|
3088
3090
|
this.basePath = "/v1/realtime";
|
|
3089
3091
|
this.ws = null;
|
|
3090
|
-
this.usedTicketAuth = false;
|
|
3091
3092
|
this.subscriptions = /* @__PURE__ */ new Map();
|
|
3092
3093
|
this.presenceCallbacks = /* @__PURE__ */ new Map();
|
|
3093
3094
|
this.statusCallbacks = /* @__PURE__ */ new Set();
|
|
@@ -3216,31 +3217,10 @@ var RealtimeService = class extends ServiceModule {
|
|
|
3216
3217
|
// --------------------------------------------------------------------------
|
|
3217
3218
|
connect() {
|
|
3218
3219
|
if (this._status === "connecting" || this._status === "connected") return;
|
|
3219
|
-
this.setStatus(this.reconnectAttempt > 0 ? "reconnecting" : "connecting");
|
|
3220
|
-
this.fetchTicketAndConnect();
|
|
3221
|
-
}
|
|
3222
|
-
async fetchTicketAndConnect() {
|
|
3223
3220
|
const baseUrl = this.client.getBaseUrl();
|
|
3221
|
+
const wsUrl = baseUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
|
|
3222
|
+
this.setStatus(this.reconnectAttempt > 0 ? "reconnecting" : "connecting");
|
|
3224
3223
|
try {
|
|
3225
|
-
const headers = { "Content-Type": "application/json" };
|
|
3226
|
-
const apiKey = this.client.getApiKey();
|
|
3227
|
-
if (apiKey) headers["x-api-key"] = apiKey;
|
|
3228
|
-
const token = this.client.getSessionToken();
|
|
3229
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
3230
|
-
const ticketRes = await fetch(`${baseUrl}/v1/realtime/ws/ticket`, {
|
|
3231
|
-
method: "POST",
|
|
3232
|
-
headers
|
|
3233
|
-
});
|
|
3234
|
-
let wsUrl;
|
|
3235
|
-
if (ticketRes.ok) {
|
|
3236
|
-
const ticketData = await ticketRes.json();
|
|
3237
|
-
const ticket = ticketData.ticket;
|
|
3238
|
-
wsUrl = baseUrl.replace(/^http/, "ws") + `/v1/realtime/ws?ticket=${encodeURIComponent(ticket)}`;
|
|
3239
|
-
this.usedTicketAuth = true;
|
|
3240
|
-
} else {
|
|
3241
|
-
wsUrl = baseUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
|
|
3242
|
-
this.usedTicketAuth = false;
|
|
3243
|
-
}
|
|
3244
3224
|
this.ws = new WebSocket(wsUrl);
|
|
3245
3225
|
} catch {
|
|
3246
3226
|
this.scheduleReconnect();
|
|
@@ -3248,21 +3228,8 @@ var RealtimeService = class extends ServiceModule {
|
|
|
3248
3228
|
}
|
|
3249
3229
|
this.ws.onopen = () => {
|
|
3250
3230
|
this.reconnectAttempt = 0;
|
|
3251
|
-
|
|
3252
|
-
this.authenticate();
|
|
3253
|
-
}
|
|
3231
|
+
this.authenticate();
|
|
3254
3232
|
this.startHeartbeat();
|
|
3255
|
-
if (this.usedTicketAuth) {
|
|
3256
|
-
setTimeout(() => {
|
|
3257
|
-
if (!this.authenticated) {
|
|
3258
|
-
this.authenticated = true;
|
|
3259
|
-
this.setStatus("connected");
|
|
3260
|
-
for (const channel of this.subscriptions.keys()) {
|
|
3261
|
-
this.sendWs({ type: "subscribe", channel });
|
|
3262
|
-
}
|
|
3263
|
-
}
|
|
3264
|
-
}, 2e3);
|
|
3265
|
-
}
|
|
3266
3233
|
};
|
|
3267
3234
|
this.ws.onmessage = (event) => {
|
|
3268
3235
|
try {
|
|
@@ -6949,6 +6916,8 @@ function ScaleMuleProvider({
|
|
|
6949
6916
|
analyticsProxyUrl,
|
|
6950
6917
|
authProxyUrl,
|
|
6951
6918
|
publishableKey,
|
|
6919
|
+
enableAccountSwitcher,
|
|
6920
|
+
accountSwitcherPrivacy,
|
|
6952
6921
|
children,
|
|
6953
6922
|
onLogin,
|
|
6954
6923
|
onLogout,
|
|
@@ -6958,20 +6927,30 @@ function ScaleMuleProvider({
|
|
|
6958
6927
|
const [user, setUser] = useState(null);
|
|
6959
6928
|
const [initializing, setInitializing] = useState(true);
|
|
6960
6929
|
const [error, setError] = useState(null);
|
|
6930
|
+
const resolvedGatewayUrl = gatewayUrl || (environment === "dev" ? "https://api-dev.scalemule.com" : "https://api.scalemule.com");
|
|
6961
6931
|
const client = useMemo(
|
|
6962
6932
|
() => createClient({
|
|
6963
6933
|
apiKey,
|
|
6964
6934
|
applicationId,
|
|
6965
6935
|
environment,
|
|
6966
|
-
gatewayUrl,
|
|
6936
|
+
gatewayUrl: resolvedGatewayUrl,
|
|
6967
6937
|
debug,
|
|
6968
6938
|
storage,
|
|
6969
6939
|
pendingSessionInit: !!authProxyUrl
|
|
6970
6940
|
}),
|
|
6971
|
-
[apiKey, applicationId, environment,
|
|
6941
|
+
[apiKey, applicationId, environment, resolvedGatewayUrl, debug, storage, authProxyUrl]
|
|
6942
|
+
);
|
|
6943
|
+
const money = useMemo(
|
|
6944
|
+
() => createMoneyClient({
|
|
6945
|
+
apiKey,
|
|
6946
|
+
gatewayUrl: resolvedGatewayUrl,
|
|
6947
|
+
environment,
|
|
6948
|
+
accessToken: client.getSessionToken() || void 0,
|
|
6949
|
+
fetch: globalThis.fetch.bind(globalThis)
|
|
6950
|
+
}),
|
|
6951
|
+
[apiKey, resolvedGatewayUrl, environment, client]
|
|
6972
6952
|
);
|
|
6973
6953
|
const baseClient = useMemo(() => {
|
|
6974
|
-
const resolvedGatewayUrl = gatewayUrl || (environment === "dev" ? "https://api-dev.scalemule.com" : "https://api.scalemule.com");
|
|
6975
6954
|
return new ScaleMule({
|
|
6976
6955
|
apiKey,
|
|
6977
6956
|
applicationId,
|
|
@@ -6979,15 +6958,17 @@ function ScaleMuleProvider({
|
|
|
6979
6958
|
environment,
|
|
6980
6959
|
debug
|
|
6981
6960
|
});
|
|
6982
|
-
}, [apiKey, applicationId, environment,
|
|
6961
|
+
}, [apiKey, applicationId, environment, resolvedGatewayUrl, debug]);
|
|
6983
6962
|
useEffect(() => {
|
|
6984
6963
|
const token = client.getSessionToken();
|
|
6985
6964
|
if (token) {
|
|
6986
6965
|
baseClient.setAccessToken(token);
|
|
6966
|
+
money.setAccessToken(token);
|
|
6987
6967
|
} else {
|
|
6988
6968
|
baseClient.clearAccessToken();
|
|
6969
|
+
money.setAccessToken(void 0);
|
|
6989
6970
|
}
|
|
6990
|
-
}, [client, baseClient, user]);
|
|
6971
|
+
}, [client, baseClient, money, user]);
|
|
6991
6972
|
useEffect(() => {
|
|
6992
6973
|
let mounted = true;
|
|
6993
6974
|
async function initialize() {
|
|
@@ -7075,6 +7056,7 @@ function ScaleMuleProvider({
|
|
|
7075
7056
|
const value = useMemo(
|
|
7076
7057
|
() => ({
|
|
7077
7058
|
client,
|
|
7059
|
+
money,
|
|
7078
7060
|
realtime: baseClient.realtime,
|
|
7079
7061
|
user,
|
|
7080
7062
|
setUser: handleSetUser,
|
|
@@ -7084,11 +7066,13 @@ function ScaleMuleProvider({
|
|
|
7084
7066
|
analyticsProxyUrl,
|
|
7085
7067
|
authProxyUrl,
|
|
7086
7068
|
publishableKey,
|
|
7087
|
-
gatewayUrl:
|
|
7069
|
+
gatewayUrl: resolvedGatewayUrl,
|
|
7088
7070
|
environment: environment || void 0,
|
|
7071
|
+
enableAccountSwitcher,
|
|
7072
|
+
accountSwitcherPrivacy,
|
|
7089
7073
|
bootstrapFlags
|
|
7090
7074
|
}),
|
|
7091
|
-
[client, baseClient, user, handleSetUser, initializing, error, analyticsProxyUrl, authProxyUrl, publishableKey,
|
|
7075
|
+
[client, money, baseClient, user, handleSetUser, initializing, error, analyticsProxyUrl, authProxyUrl, publishableKey, resolvedGatewayUrl, environment, enableAccountSwitcher, accountSwitcherPrivacy, bootstrapFlags]
|
|
7092
7076
|
);
|
|
7093
7077
|
return /* @__PURE__ */ jsx(ScaleMuleContext.Provider, { value, children });
|
|
7094
7078
|
}
|
|
@@ -7105,6 +7089,45 @@ function useScaleMuleClient() {
|
|
|
7105
7089
|
const { client } = useScaleMule();
|
|
7106
7090
|
return client;
|
|
7107
7091
|
}
|
|
7092
|
+
function useMoneyClient() {
|
|
7093
|
+
const { money } = useScaleMule();
|
|
7094
|
+
return money;
|
|
7095
|
+
}
|
|
7096
|
+
function maskEmail2(email) {
|
|
7097
|
+
const [local, domain] = email.split("@");
|
|
7098
|
+
if (!domain) return "***@***.***";
|
|
7099
|
+
const tldDot = domain.lastIndexOf(".");
|
|
7100
|
+
const tld = tldDot > 0 ? domain.slice(tldDot) : "";
|
|
7101
|
+
const domainBase = tldDot > 0 ? domain.slice(0, tldDot) : domain;
|
|
7102
|
+
return `${local[0] || "*"}***@${domainBase[0] || "*"}***${tld}`;
|
|
7103
|
+
}
|
|
7104
|
+
function stableColorIndex2(userId) {
|
|
7105
|
+
let hash = 0;
|
|
7106
|
+
for (let i = 0; i < userId.length; i++) {
|
|
7107
|
+
hash = (hash << 5) - hash + userId.charCodeAt(i) | 0;
|
|
7108
|
+
}
|
|
7109
|
+
return Math.abs(hash) % 8;
|
|
7110
|
+
}
|
|
7111
|
+
function applyClientPrivacy(entry, privacy) {
|
|
7112
|
+
if (!privacy || privacy === "full") return entry;
|
|
7113
|
+
if (privacy === "masked") {
|
|
7114
|
+
return {
|
|
7115
|
+
userId: entry.userId,
|
|
7116
|
+
email: entry.email ? maskEmail2(entry.email) : void 0,
|
|
7117
|
+
fullName: entry.fullName ? `${entry.fullName[0].toUpperCase()}.` : void 0,
|
|
7118
|
+
provider: entry.provider,
|
|
7119
|
+
lastActiveAt: entry.lastActiveAt,
|
|
7120
|
+
colorIndex: stableColorIndex2(entry.userId)
|
|
7121
|
+
};
|
|
7122
|
+
}
|
|
7123
|
+
return {
|
|
7124
|
+
userId: entry.userId,
|
|
7125
|
+
provider: entry.provider,
|
|
7126
|
+
lastActiveAt: entry.lastActiveAt,
|
|
7127
|
+
displayLabel: "Account",
|
|
7128
|
+
colorIndex: stableColorIndex2(entry.userId)
|
|
7129
|
+
};
|
|
7130
|
+
}
|
|
7108
7131
|
function getCookie(name) {
|
|
7109
7132
|
if (typeof document === "undefined") return void 0;
|
|
7110
7133
|
const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
|
|
@@ -7133,7 +7156,7 @@ async function proxyFetch(proxyUrl, path, options = {}) {
|
|
|
7133
7156
|
return data;
|
|
7134
7157
|
}
|
|
7135
7158
|
function useAuth() {
|
|
7136
|
-
const { client, user, setUser, initializing, error, setError, authProxyUrl } = useScaleMule();
|
|
7159
|
+
const { client, user, setUser, initializing, error, setError, authProxyUrl, enableAccountSwitcher, accountSwitcherPrivacy } = useScaleMule();
|
|
7137
7160
|
const register = useCallback(
|
|
7138
7161
|
async (data) => {
|
|
7139
7162
|
setError(null);
|
|
@@ -7741,6 +7764,63 @@ function useAuth() {
|
|
|
7741
7764
|
},
|
|
7742
7765
|
[client, setUser, setError, authProxyUrl]
|
|
7743
7766
|
);
|
|
7767
|
+
const readKnownAccountsCookie = useCallback(() => {
|
|
7768
|
+
if (!enableAccountSwitcher) return [];
|
|
7769
|
+
if (typeof document === "undefined") return [];
|
|
7770
|
+
const match = document.cookie.match(/(?:^|; )sm_known_accounts=([^;]*)/);
|
|
7771
|
+
if (!match) return [];
|
|
7772
|
+
try {
|
|
7773
|
+
const decoded = decodeURIComponent(match[1]);
|
|
7774
|
+
const accounts = JSON.parse(decoded);
|
|
7775
|
+
let entries = Object.values(accounts);
|
|
7776
|
+
if (accountSwitcherPrivacy && accountSwitcherPrivacy !== "full") {
|
|
7777
|
+
entries = entries.map((e) => applyClientPrivacy(e, accountSwitcherPrivacy));
|
|
7778
|
+
}
|
|
7779
|
+
return entries;
|
|
7780
|
+
} catch {
|
|
7781
|
+
return [];
|
|
7782
|
+
}
|
|
7783
|
+
}, [enableAccountSwitcher, accountSwitcherPrivacy]);
|
|
7784
|
+
const [knownAccounts, setKnownAccounts] = useState([]);
|
|
7785
|
+
useEffect(() => {
|
|
7786
|
+
setKnownAccounts(readKnownAccountsCookie());
|
|
7787
|
+
}, [readKnownAccountsCookie, user]);
|
|
7788
|
+
const switchAccount = useCallback(
|
|
7789
|
+
async (userId) => {
|
|
7790
|
+
const target = knownAccounts.find((a) => a.userId === userId) || null;
|
|
7791
|
+
if (!target) return null;
|
|
7792
|
+
if (authProxyUrl) {
|
|
7793
|
+
await proxyFetch(authProxyUrl, "switch-account");
|
|
7794
|
+
} else {
|
|
7795
|
+
const sessionToken = client.getSessionToken();
|
|
7796
|
+
if (sessionToken) {
|
|
7797
|
+
try {
|
|
7798
|
+
await client.post("/v1/auth/logout", { session_token: sessionToken });
|
|
7799
|
+
} catch {
|
|
7800
|
+
}
|
|
7801
|
+
}
|
|
7802
|
+
await client.clearSession();
|
|
7803
|
+
}
|
|
7804
|
+
setUser(null);
|
|
7805
|
+
return target;
|
|
7806
|
+
},
|
|
7807
|
+
[client, setUser, knownAccounts, authProxyUrl]
|
|
7808
|
+
);
|
|
7809
|
+
const removeKnownAccount = useCallback(
|
|
7810
|
+
async (userId) => {
|
|
7811
|
+
if (authProxyUrl) {
|
|
7812
|
+
await proxyFetch(authProxyUrl, "forget-account", { body: { user_id: userId } });
|
|
7813
|
+
}
|
|
7814
|
+
setKnownAccounts((prev) => prev.filter((a) => a.userId !== userId));
|
|
7815
|
+
},
|
|
7816
|
+
[authProxyUrl]
|
|
7817
|
+
);
|
|
7818
|
+
const clearKnownAccounts = useCallback(async () => {
|
|
7819
|
+
if (authProxyUrl) {
|
|
7820
|
+
await proxyFetch(authProxyUrl, "forget-all-accounts");
|
|
7821
|
+
}
|
|
7822
|
+
setKnownAccounts([]);
|
|
7823
|
+
}, [authProxyUrl]);
|
|
7744
7824
|
return useMemo(
|
|
7745
7825
|
() => ({
|
|
7746
7826
|
user,
|
|
@@ -7772,7 +7852,12 @@ function useAuth() {
|
|
|
7772
7852
|
// Phone auth
|
|
7773
7853
|
sendPhoneCode,
|
|
7774
7854
|
verifyPhone,
|
|
7775
|
-
loginWithPhone
|
|
7855
|
+
loginWithPhone,
|
|
7856
|
+
// Account switcher
|
|
7857
|
+
knownAccounts,
|
|
7858
|
+
switchAccount,
|
|
7859
|
+
removeKnownAccount,
|
|
7860
|
+
clearKnownAccounts
|
|
7776
7861
|
}),
|
|
7777
7862
|
[
|
|
7778
7863
|
user,
|
|
@@ -7799,10 +7884,20 @@ function useAuth() {
|
|
|
7799
7884
|
regenerateBackupCodes,
|
|
7800
7885
|
sendPhoneCode,
|
|
7801
7886
|
verifyPhone,
|
|
7802
|
-
loginWithPhone
|
|
7887
|
+
loginWithPhone,
|
|
7888
|
+
knownAccounts,
|
|
7889
|
+
switchAccount,
|
|
7890
|
+
removeKnownAccount,
|
|
7891
|
+
clearKnownAccounts
|
|
7803
7892
|
]
|
|
7804
7893
|
);
|
|
7805
7894
|
}
|
|
7895
|
+
function retiredBillingRouteError(route) {
|
|
7896
|
+
return {
|
|
7897
|
+
code: "MONEY_BILLING_ROUTE_RETIRED",
|
|
7898
|
+
message: `${route} was retired after the money-services cutover. Use @scalemule/money for subscriptions, pricing, and asset operations.`
|
|
7899
|
+
};
|
|
7900
|
+
}
|
|
7806
7901
|
function useBilling() {
|
|
7807
7902
|
const { client } = useScaleMule();
|
|
7808
7903
|
const [loading, setLoading] = useState(false);
|
|
@@ -7812,7 +7907,7 @@ function useBilling() {
|
|
|
7812
7907
|
setError(null);
|
|
7813
7908
|
setLoading(true);
|
|
7814
7909
|
try {
|
|
7815
|
-
return await client.post("/v1/billing/connected-accounts", data);
|
|
7910
|
+
return await client.post("/v1/money/billing/connected-accounts", data);
|
|
7816
7911
|
} catch (err) {
|
|
7817
7912
|
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
7818
7913
|
setError(apiError);
|
|
@@ -7827,7 +7922,7 @@ function useBilling() {
|
|
|
7827
7922
|
setError(null);
|
|
7828
7923
|
setLoading(true);
|
|
7829
7924
|
try {
|
|
7830
|
-
return await client.get("/v1/billing/connected-accounts/me");
|
|
7925
|
+
return await client.get("/v1/money/billing/connected-accounts/me");
|
|
7831
7926
|
} catch (err) {
|
|
7832
7927
|
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
7833
7928
|
setError(apiError);
|
|
@@ -7841,7 +7936,7 @@ function useBilling() {
|
|
|
7841
7936
|
setError(null);
|
|
7842
7937
|
setLoading(true);
|
|
7843
7938
|
try {
|
|
7844
|
-
return await client.get(`/v1/billing/connected-accounts/${id}`);
|
|
7939
|
+
return await client.get(`/v1/money/billing/connected-accounts/${id}`);
|
|
7845
7940
|
} catch (err) {
|
|
7846
7941
|
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
7847
7942
|
setError(apiError);
|
|
@@ -7858,7 +7953,7 @@ function useBilling() {
|
|
|
7858
7953
|
setLoading(true);
|
|
7859
7954
|
try {
|
|
7860
7955
|
const result = await client.post(
|
|
7861
|
-
`/v1/billing/connected-accounts/${id}/onboarding-link`,
|
|
7956
|
+
`/v1/money/billing/connected-accounts/${id}/onboarding-link`,
|
|
7862
7957
|
data
|
|
7863
7958
|
);
|
|
7864
7959
|
return result.url;
|
|
@@ -7877,11 +7972,7 @@ function useBilling() {
|
|
|
7877
7972
|
setError(null);
|
|
7878
7973
|
setLoading(true);
|
|
7879
7974
|
try {
|
|
7880
|
-
|
|
7881
|
-
`/v1/billing/connected-accounts/${id}/balance`
|
|
7882
|
-
);
|
|
7883
|
-
} catch (err) {
|
|
7884
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
7975
|
+
const apiError = retiredBillingRouteError(`/v1/money/billing/connected-accounts/${id}/balance`);
|
|
7885
7976
|
setError(apiError);
|
|
7886
7977
|
return null;
|
|
7887
7978
|
} finally {
|
|
@@ -7895,9 +7986,8 @@ function useBilling() {
|
|
|
7895
7986
|
setError(null);
|
|
7896
7987
|
setLoading(true);
|
|
7897
7988
|
try {
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
7989
|
+
void data;
|
|
7990
|
+
const apiError = retiredBillingRouteError("/v1/money/billing/payments");
|
|
7901
7991
|
setError(apiError);
|
|
7902
7992
|
return null;
|
|
7903
7993
|
} finally {
|
|
@@ -7911,9 +8001,7 @@ function useBilling() {
|
|
|
7911
8001
|
setError(null);
|
|
7912
8002
|
setLoading(true);
|
|
7913
8003
|
try {
|
|
7914
|
-
|
|
7915
|
-
} catch (err) {
|
|
7916
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
8004
|
+
const apiError = retiredBillingRouteError(`/v1/money/billing/payments/${id}`);
|
|
7917
8005
|
setError(apiError);
|
|
7918
8006
|
return null;
|
|
7919
8007
|
} finally {
|
|
@@ -7927,10 +8015,8 @@ function useBilling() {
|
|
|
7927
8015
|
setError(null);
|
|
7928
8016
|
setLoading(true);
|
|
7929
8017
|
try {
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
} catch (err) {
|
|
7933
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
8018
|
+
void params;
|
|
8019
|
+
const apiError = retiredBillingRouteError("/v1/money/billing/payments");
|
|
7934
8020
|
setError(apiError);
|
|
7935
8021
|
return [];
|
|
7936
8022
|
} finally {
|
|
@@ -7944,9 +8030,8 @@ function useBilling() {
|
|
|
7944
8030
|
setError(null);
|
|
7945
8031
|
setLoading(true);
|
|
7946
8032
|
try {
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
8033
|
+
void data;
|
|
8034
|
+
const apiError = retiredBillingRouteError(`/v1/money/billing/payments/${id}/refund`);
|
|
7950
8035
|
setError(apiError);
|
|
7951
8036
|
return null;
|
|
7952
8037
|
} finally {
|
|
@@ -7960,12 +8045,8 @@ function useBilling() {
|
|
|
7960
8045
|
setError(null);
|
|
7961
8046
|
setLoading(true);
|
|
7962
8047
|
try {
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
`/v1/billing/connected-accounts/${accountId}/payouts${query}`
|
|
7966
|
-
);
|
|
7967
|
-
} catch (err) {
|
|
7968
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
8048
|
+
void params;
|
|
8049
|
+
const apiError = retiredBillingRouteError(`/v1/money/billing/connected-accounts/${accountId}/payouts`);
|
|
7969
8050
|
setError(apiError);
|
|
7970
8051
|
return [];
|
|
7971
8052
|
} finally {
|
|
@@ -7980,7 +8061,7 @@ function useBilling() {
|
|
|
7980
8061
|
setLoading(true);
|
|
7981
8062
|
try {
|
|
7982
8063
|
return await client.get(
|
|
7983
|
-
`/v1/billing/connected-accounts/${accountId}/payout-schedule`
|
|
8064
|
+
`/v1/money/billing/connected-accounts/${accountId}/payout-schedule`
|
|
7984
8065
|
);
|
|
7985
8066
|
} catch (err) {
|
|
7986
8067
|
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
@@ -7998,7 +8079,7 @@ function useBilling() {
|
|
|
7998
8079
|
setLoading(true);
|
|
7999
8080
|
try {
|
|
8000
8081
|
return await client.put(
|
|
8001
|
-
`/v1/billing/connected-accounts/${accountId}/payout-schedule`,
|
|
8082
|
+
`/v1/money/billing/connected-accounts/${accountId}/payout-schedule`,
|
|
8002
8083
|
data
|
|
8003
8084
|
);
|
|
8004
8085
|
} catch (err) {
|
|
@@ -8016,10 +8097,8 @@ function useBilling() {
|
|
|
8016
8097
|
setError(null);
|
|
8017
8098
|
setLoading(true);
|
|
8018
8099
|
try {
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
} catch (err) {
|
|
8022
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
8100
|
+
void params;
|
|
8101
|
+
const apiError = retiredBillingRouteError("/v1/money/billing/transactions");
|
|
8023
8102
|
setError(apiError);
|
|
8024
8103
|
return [];
|
|
8025
8104
|
} finally {
|
|
@@ -8033,12 +8112,8 @@ function useBilling() {
|
|
|
8033
8112
|
setError(null);
|
|
8034
8113
|
setLoading(true);
|
|
8035
8114
|
try {
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
`/v1/billing/transactions/summary${query}`
|
|
8039
|
-
);
|
|
8040
|
-
} catch (err) {
|
|
8041
|
-
const apiError = err instanceof ScaleMuleApiError ? err : { code: "UNKNOWN", message: err instanceof Error ? err.message : "Unknown error" };
|
|
8115
|
+
void params;
|
|
8116
|
+
const apiError = retiredBillingRouteError("/v1/money/billing/transactions/summary");
|
|
8042
8117
|
setError(apiError);
|
|
8043
8118
|
return null;
|
|
8044
8119
|
} finally {
|
|
@@ -8053,7 +8128,7 @@ function useBilling() {
|
|
|
8053
8128
|
setLoading(true);
|
|
8054
8129
|
try {
|
|
8055
8130
|
const result = await client.post(
|
|
8056
|
-
"/v1/billing/setup-sessions",
|
|
8131
|
+
"/v1/money/billing/setup-sessions",
|
|
8057
8132
|
data
|
|
8058
8133
|
);
|
|
8059
8134
|
return result.client_secret;
|
|
@@ -8295,6 +8370,9 @@ function useContent(options = {}) {
|
|
|
8295
8370
|
]
|
|
8296
8371
|
);
|
|
8297
8372
|
}
|
|
8373
|
+
|
|
8374
|
+
// src/hooks/useMoney.ts
|
|
8375
|
+
var useMoney = useMoneyClient;
|
|
8298
8376
|
function useUser() {
|
|
8299
8377
|
const { client, user, setUser, setError } = useScaleMule();
|
|
8300
8378
|
const [loading, setLoading] = useState(false);
|
|
@@ -9650,4 +9728,4 @@ function createSafeLogger(prefix) {
|
|
|
9650
9728
|
};
|
|
9651
9729
|
}
|
|
9652
9730
|
|
|
9653
|
-
export { ScaleMuleApiError, ScaleMuleClient2 as ScaleMuleClient, ScaleMuleProvider, composePhone, createClient, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
|
|
9731
|
+
export { ScaleMuleApiError, ScaleMuleClient2 as ScaleMuleClient, ScaleMuleProvider, composePhone, createClient, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
|