@somewhere-cloud/sdk 0.0.0-stage → 0.13.1
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/LICENSE +21 -0
- package/README.md +191 -2
- package/dist/cjs/auth/client.js +1142 -0
- package/dist/cjs/auth/client.js.map +1 -0
- package/dist/cjs/auth/continuation.js +27 -0
- package/dist/cjs/auth/continuation.js.map +1 -0
- package/dist/cjs/auth/index.js +21 -0
- package/dist/cjs/auth/index.js.map +1 -0
- package/dist/cjs/auth/react.js +295 -0
- package/dist/cjs/auth/react.js.map +1 -0
- package/dist/cjs/auth/server.js +368 -0
- package/dist/cjs/auth/server.js.map +1 -0
- package/dist/cjs/client.js +392 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.js +16 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.cjs +215 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/query-cache.js +91 -0
- package/dist/cjs/query-cache.js.map +1 -0
- package/dist/cjs/resources/auth.js +875 -0
- package/dist/cjs/resources/auth.js.map +1 -0
- package/dist/cjs/resources/calls.js +42 -0
- package/dist/cjs/resources/calls.js.map +1 -0
- package/dist/cjs/resources/chat.js +82 -0
- package/dist/cjs/resources/chat.js.map +1 -0
- package/dist/cjs/resources/db.js +124 -0
- package/dist/cjs/resources/db.js.map +1 -0
- package/dist/cjs/resources/emails.js +39 -0
- package/dist/cjs/resources/emails.js.map +1 -0
- package/dist/cjs/resources/fs.js +141 -0
- package/dist/cjs/resources/fs.js.map +1 -0
- package/dist/cjs/resources/functions.js +145 -0
- package/dist/cjs/resources/functions.js.map +1 -0
- package/dist/cjs/resources/inbox.js +76 -0
- package/dist/cjs/resources/inbox.js.map +1 -0
- package/dist/cjs/resources/payments.js +68 -0
- package/dist/cjs/resources/payments.js.map +1 -0
- package/dist/cjs/resources/postgrest.js +391 -0
- package/dist/cjs/resources/postgrest.js.map +1 -0
- package/dist/cjs/resources/projects.js +71 -0
- package/dist/cjs/resources/projects.js.map +1 -0
- package/dist/cjs/resources/storage.js +191 -0
- package/dist/cjs/resources/storage.js.map +1 -0
- package/dist/cjs/resources/tasks.js +99 -0
- package/dist/cjs/resources/tasks.js.map +1 -0
- package/dist/cjs/resources/video.js +50 -0
- package/dist/cjs/resources/video.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/auth/client.js +1137 -0
- package/dist/esm/auth/client.js.map +1 -0
- package/dist/esm/auth/continuation.js +22 -0
- package/dist/esm/auth/continuation.js.map +1 -0
- package/dist/esm/auth/index.js +5 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/auth/react.js +279 -0
- package/dist/esm/auth/react.js.map +1 -0
- package/dist/esm/auth/server.js +365 -0
- package/dist/esm/auth/server.js.map +1 -0
- package/dist/esm/client.js +388 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.js +12 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +188 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/query-cache.js +87 -0
- package/dist/esm/query-cache.js.map +1 -0
- package/dist/esm/resources/auth.js +871 -0
- package/dist/esm/resources/auth.js.map +1 -0
- package/dist/esm/resources/calls.js +38 -0
- package/dist/esm/resources/calls.js.map +1 -0
- package/dist/esm/resources/chat.js +77 -0
- package/dist/esm/resources/chat.js.map +1 -0
- package/dist/esm/resources/db.js +120 -0
- package/dist/esm/resources/db.js.map +1 -0
- package/dist/esm/resources/emails.js +35 -0
- package/dist/esm/resources/emails.js.map +1 -0
- package/dist/esm/resources/fs.js +137 -0
- package/dist/esm/resources/fs.js.map +1 -0
- package/dist/esm/resources/functions.js +141 -0
- package/dist/esm/resources/functions.js.map +1 -0
- package/dist/esm/resources/inbox.js +70 -0
- package/dist/esm/resources/inbox.js.map +1 -0
- package/dist/esm/resources/payments.js +64 -0
- package/dist/esm/resources/payments.js.map +1 -0
- package/dist/esm/resources/postgrest.js +386 -0
- package/dist/esm/resources/postgrest.js.map +1 -0
- package/dist/esm/resources/projects.js +67 -0
- package/dist/esm/resources/projects.js.map +1 -0
- package/dist/esm/resources/storage.js +186 -0
- package/dist/esm/resources/storage.js.map +1 -0
- package/dist/esm/resources/tasks.js +95 -0
- package/dist/esm/resources/tasks.js.map +1 -0
- package/dist/esm/resources/video.js +46 -0
- package/dist/esm/resources/video.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/auth/client.d.ts +272 -0
- package/dist/types/auth/client.d.ts.map +1 -0
- package/dist/types/auth/continuation.d.ts +10 -0
- package/dist/types/auth/continuation.d.ts.map +1 -0
- package/dist/types/auth/index.d.ts +2 -0
- package/dist/types/auth/index.d.ts.map +1 -0
- package/dist/types/auth/react.d.ts +140 -0
- package/dist/types/auth/react.d.ts.map +1 -0
- package/dist/types/auth/server.d.ts +124 -0
- package/dist/types/auth/server.d.ts.map +1 -0
- package/dist/types/client.d.ts +128 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/errors.d.ts +17 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +145 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/query-cache.d.ts +59 -0
- package/dist/types/query-cache.d.ts.map +1 -0
- package/dist/types/resources/auth.d.ts +188 -0
- package/dist/types/resources/auth.d.ts.map +1 -0
- package/dist/types/resources/calls.d.ts +27 -0
- package/dist/types/resources/calls.d.ts.map +1 -0
- package/dist/types/resources/chat.d.ts +24 -0
- package/dist/types/resources/chat.d.ts.map +1 -0
- package/dist/types/resources/db.d.ts +81 -0
- package/dist/types/resources/db.d.ts.map +1 -0
- package/dist/types/resources/emails.d.ts +20 -0
- package/dist/types/resources/emails.d.ts.map +1 -0
- package/dist/types/resources/fs.d.ts +68 -0
- package/dist/types/resources/fs.d.ts.map +1 -0
- package/dist/types/resources/functions.d.ts +30 -0
- package/dist/types/resources/functions.d.ts.map +1 -0
- package/dist/types/resources/inbox.d.ts +52 -0
- package/dist/types/resources/inbox.d.ts.map +1 -0
- package/dist/types/resources/payments.d.ts +31 -0
- package/dist/types/resources/payments.d.ts.map +1 -0
- package/dist/types/resources/postgrest.d.ts +121 -0
- package/dist/types/resources/postgrest.d.ts.map +1 -0
- package/dist/types/resources/projects.d.ts +79 -0
- package/dist/types/resources/projects.d.ts.map +1 -0
- package/dist/types/resources/storage.d.ts +63 -0
- package/dist/types/resources/storage.d.ts.map +1 -0
- package/dist/types/resources/tasks.d.ts +87 -0
- package/dist/types/resources/tasks.d.ts.map +1 -0
- package/dist/types/resources/video.d.ts +30 -0
- package/dist/types/resources/video.d.ts.map +1 -0
- package/dist/types/types.d.ts +379 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +86 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-cache.d.ts","sourceRoot":"","sources":["../../src/query-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAoBD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAC5D;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IACzD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;gBAEvB,IAAI,GAAE,YAAiB,EAAE,GAAG,GAAE,MAAM,MAAiB;IAKjE;;;;OAIG;IACG,IAAI,CACR,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EACnC,KAAK,UAAQ,GACZ,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IA+B3B;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;IAMhE;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAU/B,sDAAsD;IACtD,KAAK,IAAI,IAAI;CAOd"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { Client } from '../client.js';
|
|
2
|
+
import type { AuthChangeEvent, AuthResponse, AuthSubscription, Result, Session, User } from '../types.js';
|
|
3
|
+
export declare class AuthClient {
|
|
4
|
+
private readonly client;
|
|
5
|
+
private currentSession;
|
|
6
|
+
/**
|
|
7
|
+
* Cookie mode's only client-side state: the last-known user object.
|
|
8
|
+
* NOT a credential — the session itself lives in httpOnly cookies the
|
|
9
|
+
* page can't read. Cached (localStorage when available) so a reload
|
|
10
|
+
* paints the signed-in UI immediately; `/me` validates in the background.
|
|
11
|
+
*/
|
|
12
|
+
private cookieUser;
|
|
13
|
+
private readonly authListeners;
|
|
14
|
+
constructor(client: Client);
|
|
15
|
+
/**
|
|
16
|
+
* Cookie transport applies only while no header session is held — an
|
|
17
|
+
* adopted token session (setSession / a tokens-returning backend) keeps
|
|
18
|
+
* header transport untouched for its lifetime.
|
|
19
|
+
*/
|
|
20
|
+
private get cookieMode();
|
|
21
|
+
/** The synthetic Session a cookie session presents: user, no readable tokens. */
|
|
22
|
+
private cookieSession;
|
|
23
|
+
private setCookieUser;
|
|
24
|
+
/**
|
|
25
|
+
* Subscribe to sign-in / sign-out / token-refresh / user-update events.
|
|
26
|
+
* The callback fires immediately with
|
|
27
|
+
* `('INITIAL_SESSION', currentSession)` (asynchronously), then on every
|
|
28
|
+
* later transition.
|
|
29
|
+
*
|
|
30
|
+
* const { data: { subscription } } =
|
|
31
|
+
* sw.auth.onAuthStateChange((event, session) => { ... })
|
|
32
|
+
* // later: subscription.unsubscribe()
|
|
33
|
+
*/
|
|
34
|
+
onAuthStateChange(callback: (event: AuthChangeEvent, session: Session | null) => void): AuthSubscription;
|
|
35
|
+
private emit;
|
|
36
|
+
signUp(credentials: {
|
|
37
|
+
email: string;
|
|
38
|
+
password: string;
|
|
39
|
+
}): Promise<Result<AuthResponse>>;
|
|
40
|
+
signInWithPassword(credentials: {
|
|
41
|
+
email: string;
|
|
42
|
+
password: string;
|
|
43
|
+
}): Promise<Result<AuthResponse>>;
|
|
44
|
+
/** Auth-subpath-compatible alias. Result semantics stay SDK-shaped. */
|
|
45
|
+
signIn(credentials: {
|
|
46
|
+
email: string;
|
|
47
|
+
password: string;
|
|
48
|
+
}): Promise<Result<AuthResponse>>;
|
|
49
|
+
/** Send a passwordless magic-link/OTP email through the shared auth contract. */
|
|
50
|
+
sendMagicLink(input: {
|
|
51
|
+
email: string;
|
|
52
|
+
redirectUri?: string;
|
|
53
|
+
}): Promise<Result<{
|
|
54
|
+
sent: true;
|
|
55
|
+
}>>;
|
|
56
|
+
/** Complete passwordless sign-in; distinct from the legacy password-reset verifyOtp alias. */
|
|
57
|
+
verifyMagicLink(input: {
|
|
58
|
+
token: string;
|
|
59
|
+
}): Promise<Result<AuthResponse>>;
|
|
60
|
+
/**
|
|
61
|
+
* Returns a Google OAuth redirect URL from `signInWithOAuth`. The platform
|
|
62
|
+
* currently supports Google. The caller redirects the browser to `data.url`.
|
|
63
|
+
*/
|
|
64
|
+
signInWithOAuth(options: {
|
|
65
|
+
provider: 'google';
|
|
66
|
+
redirectTo?: string;
|
|
67
|
+
}): Promise<Result<{
|
|
68
|
+
provider: 'google';
|
|
69
|
+
url: string;
|
|
70
|
+
}>>;
|
|
71
|
+
/** Finish the current sign-in; pending credentials remain private to this instance. */
|
|
72
|
+
completeMfa(input: {
|
|
73
|
+
code: string;
|
|
74
|
+
}): Promise<Result<AuthResponse>>;
|
|
75
|
+
signOut(): Promise<Result<null>>;
|
|
76
|
+
private performSignOut;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the current session held in SDK memory — never makes an HTTP
|
|
79
|
+
* call. In cookie mode the session is the httpOnly cookie the browser
|
|
80
|
+
* owns: the returned Session has `cookie_session: true`, the cached user,
|
|
81
|
+
* and deliberately NO readable tokens. Call `getUser()` to validate it
|
|
82
|
+
* against the server.
|
|
83
|
+
*/
|
|
84
|
+
getSession(): Promise<Result<{
|
|
85
|
+
session: Session | null;
|
|
86
|
+
}>>;
|
|
87
|
+
/** Fetch the current user — `GET /v1/auth/me` (header mode) or the app's own `/me` route (cookie mode). */
|
|
88
|
+
getUser(): Promise<Result<{
|
|
89
|
+
user: User | null;
|
|
90
|
+
}>>;
|
|
91
|
+
/**
|
|
92
|
+
* Restore a session the caller stored themselves (e.g. in localStorage).
|
|
93
|
+
* This flips the SDK's auth header to the supplied `access_token` so
|
|
94
|
+
* subsequent calls run as that user.
|
|
95
|
+
*/
|
|
96
|
+
setSession(session: {
|
|
97
|
+
access_token: string;
|
|
98
|
+
session_token?: string;
|
|
99
|
+
}): Promise<Result<{
|
|
100
|
+
session: Session | null;
|
|
101
|
+
}>>;
|
|
102
|
+
/** Patch the currently-signed-in user's profile (display name, metadata). */
|
|
103
|
+
updateUser(attrs: {
|
|
104
|
+
display_name?: string;
|
|
105
|
+
metadata?: Record<string, unknown>;
|
|
106
|
+
}): Promise<Result<{
|
|
107
|
+
user: User | null;
|
|
108
|
+
}>>;
|
|
109
|
+
/**
|
|
110
|
+
* Exchange a refresh token for a fresh `(access_token, refresh_token)` pair.
|
|
111
|
+
* Refresh tokens rotate — the old one is invalidated. Run this from your
|
|
112
|
+
* server, not browser code (the developer key is required).
|
|
113
|
+
*/
|
|
114
|
+
refreshSession(refreshToken?: string): Promise<Result<{
|
|
115
|
+
session: Session | null;
|
|
116
|
+
}>>;
|
|
117
|
+
/**
|
|
118
|
+
* Change the password for the currently signed-in user. Pass
|
|
119
|
+
* `currentPassword` unless the user has never set one (e.g. signed up
|
|
120
|
+
* via Google). On success the platform wipes every session and refresh
|
|
121
|
+
* token for the user — they will need to log in again everywhere.
|
|
122
|
+
*/
|
|
123
|
+
updatePassword(params: {
|
|
124
|
+
newPassword: string;
|
|
125
|
+
currentPassword?: string;
|
|
126
|
+
}): Promise<Result<{
|
|
127
|
+
updated: true;
|
|
128
|
+
}>>;
|
|
129
|
+
/** Send the logged-in user a 6-digit email verification code. */
|
|
130
|
+
resendVerification(): Promise<Result<{
|
|
131
|
+
sent: true;
|
|
132
|
+
}>>;
|
|
133
|
+
/** Verify the 6-digit code that was emailed to the user. */
|
|
134
|
+
verifyEmail(code: string): Promise<Result<{
|
|
135
|
+
verified: true;
|
|
136
|
+
}>>;
|
|
137
|
+
/**
|
|
138
|
+
* Permanently delete the currently signed-in user. Wipes app_users
|
|
139
|
+
* row + sessions + refresh tokens + pending resets/verifications.
|
|
140
|
+
* App-level data your project stored about them is NOT touched —
|
|
141
|
+
* call your own cleanup before this.
|
|
142
|
+
*/
|
|
143
|
+
deleteAccount(): Promise<Result<{
|
|
144
|
+
deleted: true;
|
|
145
|
+
}>>;
|
|
146
|
+
/** Trigger a password-reset email. */
|
|
147
|
+
resetPasswordForEmail(email: string): Promise<Result<{
|
|
148
|
+
sent: true;
|
|
149
|
+
}>>;
|
|
150
|
+
/** Complete a password reset using the token from the email. */
|
|
151
|
+
verifyPasswordReset(params: {
|
|
152
|
+
token: string;
|
|
153
|
+
newPassword: string;
|
|
154
|
+
}): Promise<Result<{
|
|
155
|
+
reset: true;
|
|
156
|
+
}>>;
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated This historical name verifies a password-reset token, not a
|
|
159
|
+
* magic-link/OTP sign-in. Use `verifyPasswordReset`; use `verifyMagicLink`
|
|
160
|
+
* for passwordless sign-in. Kept unchanged under rule 9.
|
|
161
|
+
*/
|
|
162
|
+
verifyOtp(params: {
|
|
163
|
+
token: string;
|
|
164
|
+
newPassword: string;
|
|
165
|
+
}): Promise<Result<{
|
|
166
|
+
reset: true;
|
|
167
|
+
}>>;
|
|
168
|
+
private sessionMutation;
|
|
169
|
+
/**
|
|
170
|
+
* Cookie-mode sign-in/up: POST to the app's own backend route (same
|
|
171
|
+
* origin), which calls `sw.auth.loginWithCookie` / `signupWithCookie`
|
|
172
|
+
* server-side and sets the httpOnly pair on the response. Never throws —
|
|
173
|
+
* expected failures (wrong password, duplicate email) come back as a
|
|
174
|
+
* `Result` error with the server's real code + message.
|
|
175
|
+
*/
|
|
176
|
+
private runCookieSessionFlow;
|
|
177
|
+
/** Cookie-mode action that does not itself establish a session. */
|
|
178
|
+
private runCookieAction;
|
|
179
|
+
/**
|
|
180
|
+
* The platform's user-profile endpoints authenticate with a Bearer JWT the
|
|
181
|
+
* cookie client deliberately doesn't have (the session is an httpOnly
|
|
182
|
+
* cookie scoped to YOUR app's backend, not the platform API). Teach the
|
|
183
|
+
* fix instead of failing with a misleading "sign in first".
|
|
184
|
+
*/
|
|
185
|
+
private cookieModeNeedsBackend;
|
|
186
|
+
private runAuthFlow;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/resources/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,IAAI,EACL,MAAM,aAAa,CAAC;AAiErB,qBAAa,UAAU;IAaT,OAAO,CAAC,QAAQ,CAAC,MAAM;IAZnC,OAAO,CAAC,cAAc,CAAwB;IAC9C;;;;;OAKG;IACH,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAE1B;gBAEyB,MAAM,EAAE,MAAM;IA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
|
+
* Real-time voice/video. A thin passthrough over a global WebRTC SFU —
|
|
5
|
+
* the platform mediates session creation (so the upstream secret stays
|
|
6
|
+
* server-side) and the SDP exchanges flow through unchanged.
|
|
7
|
+
*
|
|
8
|
+
* const { data } = await sw.calls.createSession()
|
|
9
|
+
* // → use data.session_id with `addTracks` / `renegotiate` /
|
|
10
|
+
* // `closeTracks`. SDP bodies are opaque — pass through whatever
|
|
11
|
+
* // the WebRTC layer hands you.
|
|
12
|
+
*
|
|
13
|
+
* Sessions are not persisted by the platform — the developer holds the
|
|
14
|
+
* `session_id` client-side (typical WebRTC UX).
|
|
15
|
+
*/
|
|
16
|
+
export declare class CallsClient {
|
|
17
|
+
private readonly client;
|
|
18
|
+
constructor(client: Client);
|
|
19
|
+
createSession(input?: CallsSessionCreateRequest): Promise<Result<CallsSessionCreateResponse>>;
|
|
20
|
+
/** Add new published or subscribed tracks. SDP body passed through verbatim. */
|
|
21
|
+
addTracks(sessionId: string, body: Record<string, unknown>): Promise<Result<Record<string, unknown>>>;
|
|
22
|
+
/** Renegotiate the SDP for an existing session. */
|
|
23
|
+
renegotiate(sessionId: string, body: Record<string, unknown>): Promise<Result<Record<string, unknown>>>;
|
|
24
|
+
/** Close one or more tracks on a session. */
|
|
25
|
+
closeTracks(sessionId: string, body: Record<string, unknown>): Promise<Result<Record<string, unknown>>>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../src/resources/calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,MAAM,EACP,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAErC,aAAa,CAAC,KAAK,GAAE,yBAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAQvG,gFAAgF;IAC1E,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAQ3G,mDAAmD;IAC7C,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAQ7G,6CAA6C;IACvC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAO9G"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Client } from '../client.js';
|
|
2
|
+
import type { ChatCompletion, ChatCompletionRequest } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* OpenAI-style `chat.completions.create(...)`. Unlike every other
|
|
5
|
+
* surface on the Somewhere SDK, this one THROWS on error instead of
|
|
6
|
+
* returning a `{data, error}` envelope — matching the behaviour of the
|
|
7
|
+
* official OpenAI Node client exactly.
|
|
8
|
+
*
|
|
9
|
+
* const completion = await sw.chat.completions.create({
|
|
10
|
+
* model: 'gpt-5.4',
|
|
11
|
+
* messages: [{ role: 'user', content: 'Hello' }],
|
|
12
|
+
* })
|
|
13
|
+
* const text = completion.choices[0].message.content
|
|
14
|
+
*/
|
|
15
|
+
export declare class ChatClient {
|
|
16
|
+
readonly completions: ChatCompletionsClient;
|
|
17
|
+
constructor(client: Client);
|
|
18
|
+
}
|
|
19
|
+
export declare class ChatCompletionsClient {
|
|
20
|
+
private readonly client;
|
|
21
|
+
constructor(client: Client);
|
|
22
|
+
create(request: ChatCompletionRequest): Promise<ChatCompletion>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/resources/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;gBAChC,MAAM,EAAE,MAAM;CAG3B;AAED,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAErC,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;CAmBtE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Client } from '../client.js';
|
|
2
|
+
import type { Result } from '../types.js';
|
|
3
|
+
import { SomewhereQueryBuilder } from './postgrest.js';
|
|
4
|
+
/**
|
|
5
|
+
* Database namespace with raw SQL plus the fluent
|
|
6
|
+
* query builder under one roof.
|
|
7
|
+
*
|
|
8
|
+
* // Raw SQL — parameterized with $1, $2…
|
|
9
|
+
* const rows = await sw.db.query(
|
|
10
|
+
* 'SELECT * FROM posts WHERE author_id = $1',
|
|
11
|
+
* [authorId],
|
|
12
|
+
* );
|
|
13
|
+
*
|
|
14
|
+
* // DDL / migrations — developer key required
|
|
15
|
+
* await sw.db.migrate(`
|
|
16
|
+
* CREATE TABLE IF NOT EXISTS posts (
|
|
17
|
+
* id INTEGER PRIMARY KEY,
|
|
18
|
+
* title TEXT NOT NULL
|
|
19
|
+
* )
|
|
20
|
+
* `);
|
|
21
|
+
*
|
|
22
|
+
* // Fluent query builder (alias of sw.from)
|
|
23
|
+
* const { data } = await sw.db.from('posts').select('*').eq('id', 1);
|
|
24
|
+
*/
|
|
25
|
+
export declare class DbClient {
|
|
26
|
+
private readonly client;
|
|
27
|
+
constructor(client: Client);
|
|
28
|
+
/**
|
|
29
|
+
* Run a raw SQL query. Postgres-style `$1` placeholders are normalized
|
|
30
|
+
* to positional binds. Returns the rows array on success and throws a
|
|
31
|
+
* `SomewhereError` on failure (use `try/catch`, not `{data, error}`).
|
|
32
|
+
*
|
|
33
|
+
* Requires a server-side `smt_` developer key. App-user/browser callers
|
|
34
|
+
* should invoke a server function and use its runtime `sw.db` binding.
|
|
35
|
+
* The SDK deliberately returns only canonical result `data`; runtime and
|
|
36
|
+
* REST result metadata (`count`, `changes`, `last_row_id`) is not returned.
|
|
37
|
+
*/
|
|
38
|
+
query<Row = Record<string, unknown>>(sql: string, params?: unknown[], options?: {
|
|
39
|
+
projectId?: string;
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
}): Promise<Row[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Run DDL (CREATE TABLE / ALTER / DROP / etc). Developer-only — the
|
|
44
|
+
* server rejects app-user JWTs on this route.
|
|
45
|
+
*/
|
|
46
|
+
migrate(sql: string, options?: {
|
|
47
|
+
projectId?: string;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Fluent query builder. Identical to `sw.from(table)` — exposed
|
|
51
|
+
* here so devs who think in `sw.db.*` namespacing find it naturally.
|
|
52
|
+
*/
|
|
53
|
+
from(table: string): SomewhereQueryBuilder;
|
|
54
|
+
/**
|
|
55
|
+
* List user tables in this project's database.
|
|
56
|
+
*/
|
|
57
|
+
tables(options?: {
|
|
58
|
+
projectId?: string;
|
|
59
|
+
}): Promise<string[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Inspect a single table's columns + indexes. Returns null if the
|
|
62
|
+
* table doesn't exist.
|
|
63
|
+
*/
|
|
64
|
+
schema(table: string, options?: {
|
|
65
|
+
projectId?: string;
|
|
66
|
+
}): Promise<Record<string, unknown> | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Run a batch of mutations as one atomic transaction. Statements
|
|
69
|
+
* execute in order; if any fails the whole batch rolls back.
|
|
70
|
+
*/
|
|
71
|
+
batch(statements: Array<{
|
|
72
|
+
sql: string;
|
|
73
|
+
params?: unknown[];
|
|
74
|
+
}>, options?: {
|
|
75
|
+
projectId?: string;
|
|
76
|
+
}): Promise<Result<Array<{
|
|
77
|
+
rows: Record<string, unknown>[];
|
|
78
|
+
rows_affected: number;
|
|
79
|
+
}>>>;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../src/resources/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C;;;;;;;;;OASG;IACG,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAO,EAAO,EACtB,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACvD,OAAO,CAAC,GAAG,EAAE,CAAC;IAuBjB;;;OAGG;IACG,OAAO,CACX,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,IAAI,CAAC;IAQhB;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB;IAI1C;;OAEG;IACG,MAAM,CAAC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IASrE;;;OAGG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAc1C;;;OAGG;IACG,KAAK,CACT,UAAU,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,EACtD,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CAgBtF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Client } from '../client.js';
|
|
2
|
+
import type { Result, SendEmailRequest, SendEmailResponse } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resend-style email client. Matches `resend.emails.send({...})` exactly,
|
|
5
|
+
* including the `{ from, to, subject, html, text, reply_to, cc, bcc }`
|
|
6
|
+
* body shape and the `{ data, error }` return envelope.
|
|
7
|
+
*
|
|
8
|
+
* const { data, error } = await sw.emails.send({
|
|
9
|
+
* from: 'noreply@myapp.com',
|
|
10
|
+
* to: 'user@example.com',
|
|
11
|
+
* subject: 'Welcome!',
|
|
12
|
+
* html: '<h1>Welcome</h1>',
|
|
13
|
+
* })
|
|
14
|
+
*/
|
|
15
|
+
export declare class EmailsClient {
|
|
16
|
+
private readonly client;
|
|
17
|
+
constructor(client: Client);
|
|
18
|
+
send(input: SendEmailRequest): Promise<Result<SendEmailResponse>>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=emails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emails.d.ts","sourceRoot":"","sources":["../../../src/resources/emails.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAErC,IAAI,CACR,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;CAiBtC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Client } from '../client.js';
|
|
2
|
+
import type { Result, StorageDownloadResult } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Raw filesystem namespace. Path-based read / write / list / delete
|
|
5
|
+
* without the bucket abstraction. Use this when you're
|
|
6
|
+
* thinking in absolute paths inside your project (`/assets/logo.png`,
|
|
7
|
+
* `/data/users.json`).
|
|
8
|
+
*
|
|
9
|
+
* await sw.fs.write('avatar.png', bytes, { contentType: 'image/png' });
|
|
10
|
+
* const file = await sw.fs.read('avatar.png');
|
|
11
|
+
* const entries = await sw.fs.list('/');
|
|
12
|
+
* await sw.fs.delete('avatar.png');
|
|
13
|
+
*
|
|
14
|
+
* For the prefix-oriented API see `sw.storage.from(bucket)`.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FsClient {
|
|
17
|
+
private readonly client;
|
|
18
|
+
constructor(client: Client);
|
|
19
|
+
/**
|
|
20
|
+
* Write a file. Body can be a string, ArrayBuffer, Blob, ReadableStream,
|
|
21
|
+
* or anything fetch accepts as a BodyInit. Path is stored verbatim
|
|
22
|
+
* (no bucket prefix prepended).
|
|
23
|
+
*/
|
|
24
|
+
write(path: string, body: BodyInit, options?: {
|
|
25
|
+
contentType?: string;
|
|
26
|
+
projectId?: string;
|
|
27
|
+
}): Promise<Result<{
|
|
28
|
+
path: string;
|
|
29
|
+
size_bytes?: number;
|
|
30
|
+
content_type?: string;
|
|
31
|
+
}>>;
|
|
32
|
+
/**
|
|
33
|
+
* Read a file. Returns `{ body: ArrayBuffer, contentType, size }`.
|
|
34
|
+
* Use `new TextDecoder().decode(result.data.body)` to get a string.
|
|
35
|
+
*/
|
|
36
|
+
read(path: string, options?: {
|
|
37
|
+
projectId?: string;
|
|
38
|
+
}): Promise<Result<StorageDownloadResult>>;
|
|
39
|
+
/**
|
|
40
|
+
* List entries under a directory path. Returns an array of `{ name,
|
|
41
|
+
* size, content_type?, updated_at? }` objects.
|
|
42
|
+
*/
|
|
43
|
+
list(prefix?: string, options?: {
|
|
44
|
+
projectId?: string;
|
|
45
|
+
}): Promise<Result<Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
size: number;
|
|
48
|
+
content_type?: string;
|
|
49
|
+
updated_at?: string;
|
|
50
|
+
}>>>;
|
|
51
|
+
/**
|
|
52
|
+
* Delete a single file. To delete many in one call use
|
|
53
|
+
* `sw.storage.from(bucket).remove([...])`.
|
|
54
|
+
*/
|
|
55
|
+
delete(path: string, options?: {
|
|
56
|
+
projectId?: string;
|
|
57
|
+
}): Promise<Result<{
|
|
58
|
+
deleted: true;
|
|
59
|
+
}>>;
|
|
60
|
+
/**
|
|
61
|
+
* Public URL for a file. Only resolves if the file was marked public.
|
|
62
|
+
* Does not perform a HEAD — the URL is constructed locally.
|
|
63
|
+
*/
|
|
64
|
+
publicUrl(path: string, options?: {
|
|
65
|
+
projectId?: string;
|
|
66
|
+
}): string;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=fs.d.ts.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nC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IAWrC;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,MAAM;CAKtE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Client } from '../client.js';
|
|
2
|
+
import type { FunctionInvokeOptions, Result } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Application-function invocation client.
|
|
5
|
+
*
|
|
6
|
+
* const { data, error } = await sw.functions.invoke('checkout', {
|
|
7
|
+
* body: { plan: 'pro' },
|
|
8
|
+
* })
|
|
9
|
+
*
|
|
10
|
+
* `invoke(name)` calls `POST {projectUrl}/api/{name}` — the project's own
|
|
11
|
+
* deployed function (an `api/{name}` file). `data` is the function's parsed
|
|
12
|
+
* JSON response (or text); `error` is set on any non-2xx status or network
|
|
13
|
+
* failure, using the established `{ data, error }` envelope.
|
|
14
|
+
*
|
|
15
|
+
* The function host is the app URL you passed to `createClient(appUrl, key)`
|
|
16
|
+
* or as `functionsUrl`. It is never derived from `projectId`: a project id
|
|
17
|
+
* can be a slug that is unique only to its owner, and the same text can be
|
|
18
|
+
* another customer's subdomain, so a derived host could receive your
|
|
19
|
+
* credentials. Without an app URL `invoke` returns `NO_FUNCTION_HOST` before
|
|
20
|
+
* any request. In a project folder the CLI records the platform-reported URL
|
|
21
|
+
* as `app_url` in `.somewhere.json`, and `somewhere status --json` prints it.
|
|
22
|
+
*/
|
|
23
|
+
export declare class FunctionsClient {
|
|
24
|
+
private readonly client;
|
|
25
|
+
constructor(client: Client);
|
|
26
|
+
invoke<T = unknown>(name: string, options?: FunctionInvokeOptions): Promise<Result<T>>;
|
|
27
|
+
/** The caller-supplied app URL, or null. Never derived from projectId. */
|
|
28
|
+
private resolveBase;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/resources/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAErC,MAAM,CAAC,CAAC,GAAG,OAAO,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAkGrB,0EAA0E;IAC1E,OAAO,CAAC,WAAW;CAGpB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Client } from '../client.js';
|
|
2
|
+
import type { InboxAddress, InboxAddressCreateRequest, InboxAddressListResponse, InboxListOptions, InboxMessageDetail, InboxMessageListResponse, Result } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Inbound email — the receive side of `sw.emails.send(...)`.
|
|
5
|
+
* Each project can mint addresses on the platform's inbox subdomain,
|
|
6
|
+
* and incoming mail is persisted with subject + text preview + raw MIME.
|
|
7
|
+
*
|
|
8
|
+
* // Create an inbox address (e.g. orders@inbox.somewhere.tech).
|
|
9
|
+
* await sw.inbox.addresses.create({ local: 'orders', label: 'Orders' })
|
|
10
|
+
*
|
|
11
|
+
* // List recent messages.
|
|
12
|
+
* const { data } = await sw.inbox.messages.list({ limit: 20 })
|
|
13
|
+
*
|
|
14
|
+
* // Fetch the full message + a path for the raw .eml.
|
|
15
|
+
* const msg = await sw.inbox.messages.get('msg-id')
|
|
16
|
+
*
|
|
17
|
+
* // Raw MIME bytes (forwarding, archival, parsing).
|
|
18
|
+
* const raw = await sw.inbox.messages.getRaw('msg-id')
|
|
19
|
+
*/
|
|
20
|
+
export declare class InboxAddressesClient {
|
|
21
|
+
private readonly client;
|
|
22
|
+
constructor(client: Client);
|
|
23
|
+
create(input: InboxAddressCreateRequest): Promise<Result<InboxAddress>>;
|
|
24
|
+
list(opts?: {
|
|
25
|
+
projectId?: string;
|
|
26
|
+
}): Promise<Result<InboxAddressListResponse>>;
|
|
27
|
+
delete(id: string): Promise<Result<{
|
|
28
|
+
id: string;
|
|
29
|
+
deleted: true;
|
|
30
|
+
}>>;
|
|
31
|
+
}
|
|
32
|
+
export declare class InboxMessagesClient {
|
|
33
|
+
private readonly client;
|
|
34
|
+
constructor(client: Client);
|
|
35
|
+
list(opts?: InboxListOptions): Promise<Result<InboxMessageListResponse>>;
|
|
36
|
+
get(id: string): Promise<Result<InboxMessageDetail>>;
|
|
37
|
+
/** Raw MIME bytes (`.eml`) and content type. */
|
|
38
|
+
getRaw(id: string): Promise<{
|
|
39
|
+
body: ArrayBuffer;
|
|
40
|
+
contentType: string;
|
|
41
|
+
}>;
|
|
42
|
+
delete(id: string): Promise<Result<{
|
|
43
|
+
id: string;
|
|
44
|
+
deleted: true;
|
|
45
|
+
}>>;
|
|
46
|
+
}
|
|
47
|
+
export declare class InboxClient {
|
|
48
|
+
readonly addresses: InboxAddressesClient;
|
|
49
|
+
readonly messages: InboxMessagesClient;
|
|
50
|
+
constructor(client: Client);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=inbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../../../src/resources/inbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EACV,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,MAAM,EACP,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;GAgBG;AACH,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, PaymentsCheckoutResponse, PaymentsDashboardLinkResponse, PaymentsOnboardRequest, PaymentsOnboardResponse, PaymentsStatusOptions, PaymentsStatusResponse, Result } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stripe-Connect-style payments. The platform is the Stripe platform
|
|
5
|
+
* account; each project gets its own connected account. somewhere.tech
|
|
6
|
+
* takes zero platform fee — every charge settles 100% to the developer's
|
|
7
|
+
* connected account. The developer never holds a Stripe key — they call:
|
|
8
|
+
*
|
|
9
|
+
* await sw.payments.onboard({ return_url, refresh_url })
|
|
10
|
+
* // → redirect end-user to result.onboarding_url
|
|
11
|
+
*
|
|
12
|
+
* const status = await sw.payments.status()
|
|
13
|
+
* if (!status.data?.charges_enabled) ...
|
|
14
|
+
*
|
|
15
|
+
* await sw.payments.checkout({
|
|
16
|
+
* line_items: [{ amount: 4999, currency: 'usd', name: 'Pro' }],
|
|
17
|
+
* success_url, cancel_url,
|
|
18
|
+
* })
|
|
19
|
+
* // → redirect end-user to result.url
|
|
20
|
+
*/
|
|
21
|
+
export declare class PaymentsClient {
|
|
22
|
+
private readonly client;
|
|
23
|
+
constructor(client: Client);
|
|
24
|
+
onboard(input?: PaymentsOnboardRequest): Promise<Result<PaymentsOnboardResponse>>;
|
|
25
|
+
status(opts?: PaymentsStatusOptions): Promise<Result<PaymentsStatusResponse>>;
|
|
26
|
+
checkout(input: PaymentsCheckoutRequest): Promise<Result<PaymentsCheckoutResponse>>;
|
|
27
|
+
dashboardLink(opts?: {
|
|
28
|
+
projectId?: string;
|
|
29
|
+
}): Promise<Result<PaymentsDashboardLinkResponse>>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=payments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../../../src/resources/payments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,MAAM,EACP,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAErC,OAAO,CAAC,KAAK,GAAE,sBAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAYrF,MAAM,CAAC,IAAI,GAAE,qBAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAQjF,QAAQ,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAgBnF,aAAa,CAAC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC;CAOvG"}
|