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