@motherbase/client 1.5.0 → 1.5.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.
Files changed (93) hide show
  1. package/dist/admin.d.ts +131 -0
  2. package/dist/admin.d.ts.map +1 -0
  3. package/dist/admin.js +121 -0
  4. package/dist/admin.js.map +1 -0
  5. package/dist/auth.d.ts +459 -0
  6. package/dist/auth.d.ts.map +1 -0
  7. package/dist/auth.js +861 -0
  8. package/dist/auth.js.map +1 -0
  9. package/dist/channel.d.ts +129 -0
  10. package/dist/channel.d.ts.map +1 -0
  11. package/dist/channel.js +215 -0
  12. package/dist/channel.js.map +1 -0
  13. package/dist/compat.d.ts +40 -0
  14. package/dist/compat.d.ts.map +1 -0
  15. package/dist/compat.js +100 -0
  16. package/dist/compat.js.map +1 -0
  17. package/dist/cookie.d.ts +68 -0
  18. package/dist/cookie.d.ts.map +1 -0
  19. package/dist/cookie.js +152 -0
  20. package/dist/cookie.js.map +1 -0
  21. package/dist/database.d.ts +188 -0
  22. package/dist/database.d.ts.map +1 -0
  23. package/dist/database.js +2 -0
  24. package/dist/database.js.map +1 -0
  25. package/dist/functions.d.ts +60 -0
  26. package/dist/functions.d.ts.map +1 -0
  27. package/dist/functions.js +75 -0
  28. package/dist/functions.js.map +1 -0
  29. package/dist/http.d.ts +122 -0
  30. package/dist/http.d.ts.map +1 -0
  31. package/dist/http.js +206 -0
  32. package/dist/http.js.map +1 -0
  33. package/dist/index.d.ts +215 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +365 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/mfa.d.ts +126 -0
  38. package/dist/mfa.d.ts.map +1 -0
  39. package/dist/mfa.js +156 -0
  40. package/dist/mfa.js.map +1 -0
  41. package/dist/organization.d.ts +234 -0
  42. package/dist/organization.d.ts.map +1 -0
  43. package/dist/organization.js +157 -0
  44. package/dist/organization.js.map +1 -0
  45. package/dist/passkey.d.ts +59 -0
  46. package/dist/passkey.d.ts.map +1 -0
  47. package/dist/passkey.js +87 -0
  48. package/dist/passkey.js.map +1 -0
  49. package/dist/pkce.d.ts +13 -0
  50. package/dist/pkce.d.ts.map +1 -0
  51. package/dist/pkce.js +52 -0
  52. package/dist/pkce.js.map +1 -0
  53. package/dist/plugin-endpoint.d.ts +20 -0
  54. package/dist/plugin-endpoint.d.ts.map +1 -0
  55. package/dist/plugin-endpoint.js +24 -0
  56. package/dist/plugin-endpoint.js.map +1 -0
  57. package/dist/postgrest.d.ts +326 -0
  58. package/dist/postgrest.d.ts.map +1 -0
  59. package/dist/postgrest.js +625 -0
  60. package/dist/postgrest.js.map +1 -0
  61. package/dist/query.d.ts +97 -0
  62. package/dist/query.d.ts.map +1 -0
  63. package/dist/query.js +94 -0
  64. package/dist/query.js.map +1 -0
  65. package/dist/realtime.d.ts +114 -0
  66. package/dist/realtime.d.ts.map +1 -0
  67. package/dist/realtime.js +376 -0
  68. package/dist/realtime.js.map +1 -0
  69. package/dist/session.d.ts +47 -0
  70. package/dist/session.d.ts.map +1 -0
  71. package/dist/session.js +136 -0
  72. package/dist/session.js.map +1 -0
  73. package/dist/sso.d.ts +147 -0
  74. package/dist/sso.d.ts.map +1 -0
  75. package/dist/sso.js +35 -0
  76. package/dist/sso.js.map +1 -0
  77. package/dist/storage.d.ts +268 -0
  78. package/dist/storage.d.ts.map +1 -0
  79. package/dist/storage.js +441 -0
  80. package/dist/storage.js.map +1 -0
  81. package/dist/testing.d.ts +38 -0
  82. package/dist/testing.d.ts.map +1 -0
  83. package/dist/testing.js +50 -0
  84. package/dist/testing.js.map +1 -0
  85. package/dist/types.d.ts +348 -0
  86. package/dist/types.d.ts.map +1 -0
  87. package/dist/types.js +2 -0
  88. package/dist/types.js.map +1 -0
  89. package/dist/warn.d.ts +2 -0
  90. package/dist/warn.d.ts.map +1 -0
  91. package/dist/warn.js +23 -0
  92. package/dist/warn.js.map +1 -0
  93. package/package.json +4 -2
package/dist/sso.d.ts ADDED
@@ -0,0 +1,147 @@
1
+ import type { HttpClient } from './http.js';
2
+ import type { MotherbaseResponse } from './types.js';
3
+ /**
4
+ * `client.auth.sso`: identity providers registered at runtime, typically by an
5
+ * organization's admins for their own members (Better Auth's SSO plugin).
6
+ * Signing in through one is `client.auth.signInWithSSO()`.
7
+ *
8
+ * supabase-js has no runtime equivalent: Supabase registers SSO providers from
9
+ * its CLI or management API, per project. Here a provider is tenant data, so the
10
+ * app's own admin screens manage it, and an `organizationId` scopes it to that
11
+ * organization's members.
12
+ *
13
+ * Needs Auth · SSO on in the project settings; otherwise every call is a 404.
14
+ * The callback URL to configure at the identity provider is
15
+ * `<project url>/api/auth/sso/callback/<providerId>`, also returned as
16
+ * `redirectURI` by `register`.
17
+ */
18
+ export interface OidcMapping {
19
+ id: string;
20
+ email: string;
21
+ emailVerified?: string;
22
+ name: string;
23
+ image?: string;
24
+ extraFields?: Record<string, string>;
25
+ }
26
+ export interface SamlMapping {
27
+ id: string;
28
+ email: string;
29
+ emailVerified?: string;
30
+ name: string;
31
+ firstName?: string;
32
+ lastName?: string;
33
+ extraFields?: Record<string, string>;
34
+ }
35
+ export interface OidcProviderConfig {
36
+ clientId: string;
37
+ clientSecret: string;
38
+ /** The issuer's `.well-known/openid-configuration`. Fills in every endpoint below. */
39
+ discoveryEndpoint?: string;
40
+ authorizationEndpoint?: string;
41
+ tokenEndpoint?: string;
42
+ userInfoEndpoint?: string;
43
+ jwksEndpoint?: string;
44
+ tokenEndpointAuthentication?: 'client_secret_post' | 'client_secret_basic';
45
+ /** Skip discovery at registration; then the endpoints above are required. */
46
+ skipDiscovery?: boolean;
47
+ /** Defaults to `['openid', 'email', 'profile', 'offline_access']`. */
48
+ scopes?: string[];
49
+ /** Defaults to true. */
50
+ pkce?: boolean;
51
+ mapping?: OidcMapping;
52
+ }
53
+ export interface SamlProviderConfig {
54
+ entryPoint: string;
55
+ /** The IdP's signing certificate, PEM. */
56
+ cert: string;
57
+ callbackUrl: string;
58
+ audience?: string;
59
+ /** IdP metadata XML in `metadata`, or its parts. */
60
+ idpMetadata?: {
61
+ metadata?: string;
62
+ entityID?: string;
63
+ cert?: string;
64
+ };
65
+ spMetadata: {
66
+ metadata?: string;
67
+ entityID?: string;
68
+ binding?: string;
69
+ };
70
+ wantAssertionsSigned?: boolean;
71
+ authnRequestsSigned?: boolean;
72
+ signatureAlgorithm?: string;
73
+ digestAlgorithm?: string;
74
+ identifierFormat?: string;
75
+ mapping?: SamlMapping;
76
+ }
77
+ export interface RegisterSsoProviderParams {
78
+ /** Stable id of your choosing; it appears in the callback URL. */
79
+ providerId: string;
80
+ issuer: string;
81
+ /** Email domain routed to this provider. Several, comma-separated, for one IdP serving many domains. */
82
+ domain: string;
83
+ /** Scope the provider to one organization, whose members it signs in and provisions. */
84
+ organizationId?: string;
85
+ /** Overwrite the user's profile from the IdP on every sign-in. Defaults to false. */
86
+ overrideUserInfo?: boolean;
87
+ /** Exactly one of `oidcConfig` and `samlConfig`. */
88
+ oidcConfig?: OidcProviderConfig;
89
+ samlConfig?: SamlProviderConfig;
90
+ }
91
+ /**
92
+ * A provider as listed: secrets withheld, the client id masked to its last four
93
+ * characters.
94
+ */
95
+ export interface SsoProvider {
96
+ providerId: string;
97
+ type: 'oidc' | 'saml';
98
+ issuer: string;
99
+ domain: string;
100
+ organizationId: string | null;
101
+ domainVerified: boolean;
102
+ oidcConfig?: Omit<OidcProviderConfig, 'clientId' | 'clientSecret' | 'skipDiscovery' | 'mapping'> & {
103
+ clientIdLastFour?: string;
104
+ };
105
+ samlConfig?: Pick<SamlProviderConfig, 'entryPoint' | 'callbackUrl' | 'audience' | 'wantAssertionsSigned' | 'authnRequestsSigned' | 'identifierFormat' | 'signatureAlgorithm' | 'digestAlgorithm'> & {
106
+ certificate?: unknown;
107
+ };
108
+ /** Where the IdP fetches this project's SAML service provider metadata. */
109
+ spMetadataUrl: string;
110
+ }
111
+ export declare class SsoClient {
112
+ private readonly http;
113
+ constructor(http: HttpClient);
114
+ /**
115
+ * Register an identity provider. For an organization's provider, the caller
116
+ * must be that organization's owner or admin.
117
+ */
118
+ register(params: RegisterSsoProviderParams): Promise<MotherbaseResponse<{
119
+ providerId: string;
120
+ issuer: string;
121
+ domain: string;
122
+ organizationId?: string | null;
123
+ redirectURI: string;
124
+ }>>;
125
+ /** Providers the signed-in user may manage: their own, and their admin organizations'. */
126
+ listProviders(): Promise<MotherbaseResponse<{
127
+ providers: SsoProvider[];
128
+ }>>;
129
+ getProvider(params: {
130
+ providerId: string;
131
+ }): Promise<MotherbaseResponse<SsoProvider>>;
132
+ /** Change a provider. Config objects are merged into the stored ones, so send only what changes. */
133
+ updateProvider(params: {
134
+ providerId: string;
135
+ issuer?: string;
136
+ domain?: string;
137
+ } & {
138
+ oidcConfig?: Partial<OidcProviderConfig>;
139
+ samlConfig?: Partial<SamlProviderConfig>;
140
+ }): Promise<MotherbaseResponse<SsoProvider>>;
141
+ deleteProvider(params: {
142
+ providerId: string;
143
+ }): Promise<MotherbaseResponse<{
144
+ success: boolean;
145
+ }>>;
146
+ }
147
+ //# sourceMappingURL=sso.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso.d.ts","sourceRoot":"","sources":["../src/sso.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAA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AAC;CACvB;AAUD,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAClD,kBAAkB,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAChI;IAID,0FAA0F;IAC1F,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;QAAE,SAAS,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC,CAAC;IAI1E,WAAW,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAIrF,oGAAoG;IACpG,cAAc,CACZ,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QACjE,UAAU,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACzC,UAAU,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;KAC1C,GACA,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAI3C,cAAc,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAGlG"}
package/dist/sso.js ADDED
@@ -0,0 +1,35 @@
1
+ import { pluginGet, pluginPost } from './plugin-endpoint.js';
2
+ const R = {
3
+ register: '/api/auth/sso/register',
4
+ list: '/api/auth/sso/providers',
5
+ get: '/api/auth/sso/get-provider',
6
+ update: '/api/auth/sso/update-provider',
7
+ delete: '/api/auth/sso/delete-provider',
8
+ };
9
+ export class SsoClient {
10
+ constructor(http) {
11
+ this.http = http;
12
+ }
13
+ /**
14
+ * Register an identity provider. For an organization's provider, the caller
15
+ * must be that organization's owner or admin.
16
+ */
17
+ register(params) {
18
+ return pluginPost(this.http, R.register, params);
19
+ }
20
+ /** Providers the signed-in user may manage: their own, and their admin organizations'. */
21
+ listProviders() {
22
+ return pluginGet(this.http, R.list);
23
+ }
24
+ getProvider(params) {
25
+ return pluginGet(this.http, R.get, params);
26
+ }
27
+ /** Change a provider. Config objects are merged into the stored ones, so send only what changes. */
28
+ updateProvider(params) {
29
+ return pluginPost(this.http, R.update, params);
30
+ }
31
+ deleteProvider(params) {
32
+ return pluginPost(this.http, R.delete, params);
33
+ }
34
+ }
35
+ //# sourceMappingURL=sso.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso.js","sourceRoot":"","sources":["../src/sso.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAuH7D,MAAM,CAAC,GAAG;IACR,QAAQ,EAAE,wBAAwB;IAClC,IAAI,EAAE,yBAAyB;IAC/B,GAAG,EAAE,4BAA4B;IACjC,MAAM,EAAE,+BAA+B;IACvC,MAAM,EAAE,+BAA+B;CAC/B,CAAC;AAEX,MAAM,OAAO,SAAS;IACpB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,QAAQ,CAAC,MAAiC;QAGxC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,0FAA0F;IAC1F,aAAa;QACX,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,WAAW,CAAC,MAA8B;QACxC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,oGAAoG;IACpG,cAAc,CACZ,MAGC;QAED,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,cAAc,CAAC,MAA8B;QAC3C,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;CACF"}
@@ -0,0 +1,268 @@
1
+ import type { HttpClient } from './http.js';
2
+ import type { FileObject, FileVisibility, MotherbaseResponse, StorageRemoveResponse, UploadInput } from './types.js';
3
+ export interface UploadOptions {
4
+ /** Object visibility. Defaults to the backend's default (private). */
5
+ visibility?: FileVisibility;
6
+ /** Content type stored with the object. Overrides what the file itself declares. */
7
+ contentType?: string;
8
+ upsert?: boolean;
9
+ }
10
+ export interface UploadResult {
11
+ /** The object key, exactly as passed to `upload`. */
12
+ path: string;
13
+ /** The server-issued file id. Still accepted anywhere a path is. */
14
+ id: string;
15
+ /** `bucket/key`. */
16
+ fullPath: string;
17
+ }
18
+ /** A bucket, in the supabase-js shape. `id` is the slug. */
19
+ export interface BucketInfo {
20
+ id: string;
21
+ name: string;
22
+ owner: string;
23
+ public: boolean;
24
+ /** Largest object the bucket accepts, in bytes. `null` defers to the project limit. */
25
+ file_size_limit: number | null;
26
+ /** MIME allowlist (`image/*` wildcards allowed). `null` accepts any type. */
27
+ allowed_mime_types: string[] | null;
28
+ created_at: string | null;
29
+ updated_at: string | null;
30
+ }
31
+ /** supabase-js `createBucket` / `updateBucket` options. */
32
+ export interface BucketOptions {
33
+ public?: boolean;
34
+ name?: string;
35
+ /** Bytes, or a string with a unit: `'20MB'`, `'1GB'`. `null` removes the limit. */
36
+ fileSizeLimit?: number | string | null;
37
+ /** `['image/*', 'application/pdf']`. `null` or `[]` accepts any type. */
38
+ allowedMimeTypes?: string[] | null;
39
+ }
40
+ /** One object's metadata, in the supabase-js `info()` shape. */
41
+ export interface ObjectInfo {
42
+ name: string;
43
+ id: string;
44
+ version: string | null;
45
+ bucket_id: string;
46
+ created_at: string | null;
47
+ updated_at: string | null;
48
+ last_accessed_at: string | null;
49
+ size: number;
50
+ content_type: string | null;
51
+ cache_control: string | null;
52
+ metadata: Record<string, unknown>;
53
+ }
54
+ /**
55
+ * supabase-js image transform options. Served by `/storage/v1/render/image`,
56
+ * resized with the same limits Supabase applies (1 to 2500 px, quality 20 to
57
+ * 100). Without `format` the server answers WebP to clients that accept it.
58
+ */
59
+ export interface TransformOptions {
60
+ width?: number;
61
+ height?: number;
62
+ resize?: 'cover' | 'contain' | 'fill';
63
+ quality?: number;
64
+ format?: 'origin' | 'webp' | 'avif';
65
+ }
66
+ export interface ListOptions {
67
+ limit?: number;
68
+ offset?: number;
69
+ search?: string;
70
+ sortBy?: {
71
+ column?: 'name' | 'created_at' | 'updated_at';
72
+ order?: 'asc' | 'desc';
73
+ };
74
+ }
75
+ export declare class StorageBucket {
76
+ private readonly http;
77
+ private readonly baseUrl;
78
+ private readonly bucket;
79
+ /** Used only by `uploadToSignedUrl`, which PUTs straight to object storage. */
80
+ private readonly fetchImpl;
81
+ constructor(http: HttpClient, baseUrl: string, bucket: string,
82
+ /** Used only by `uploadToSignedUrl`, which PUTs straight to object storage. */
83
+ fetchImpl: typeof fetch);
84
+ /**
85
+ * Route for one object. A bare uuid is treated as a file id (the pre-path
86
+ * addressing form, which existing callers have stored); anything else is a
87
+ * key inside this bucket.
88
+ */
89
+ private objectPath;
90
+ upload(path: string, file: UploadInput, options?: UploadOptions): Promise<MotherbaseResponse<UploadResult>>;
91
+ /**
92
+ * Upload several objects, a few at a time, reporting progress per file.
93
+ *
94
+ * Uploading a folder is the common case and `Promise.all` is the common
95
+ * mistake: a hundred parallel multipart posts saturate the connection, and
96
+ * the server rate limiter answers 429 to the tail of them. Four at a time
97
+ * finishes sooner in practice and fails less.
98
+ *
99
+ * One failing file does not cancel the rest. The result reports every entry
100
+ * in the order it was given, each with its own error or `null`, so the caller
101
+ * can retry exactly what failed.
102
+ *
103
+ * ponytail: progress is per file, not per byte. Byte-level progress needs
104
+ * XMLHttpRequest, which does not exist outside a browser; if a progress bar
105
+ * has to move within one large file, that is the upgrade path.
106
+ */
107
+ uploadMany(files: Array<{
108
+ path: string;
109
+ file: UploadInput;
110
+ options?: UploadOptions;
111
+ }>, options?: {
112
+ /** Uploads in flight at once. Default 4. */
113
+ concurrency?: number;
114
+ /** Called after each file settles, with how many have settled so far. */
115
+ onProgress?: (progress: {
116
+ completed: number;
117
+ total: number;
118
+ path: string;
119
+ error: string | null;
120
+ }) => void;
121
+ }): Promise<MotherbaseResponse<Array<{
122
+ path: string;
123
+ data: UploadResult | null;
124
+ error: string | null;
125
+ }>>>;
126
+ /** The object's bytes. With `transform`, a resized image from the render endpoint instead. */
127
+ download(path: string, options?: {
128
+ transform?: TransformOptions;
129
+ }): Promise<MotherbaseResponse<Blob>>;
130
+ remove(paths: string[]): Promise<MotherbaseResponse<StorageRemoveResponse[]>>;
131
+ /** Objects under a prefix, in the Supabase response shape. */
132
+ list(prefix?: string, options?: ListOptions): Promise<MotherbaseResponse<FileObject[]>>;
133
+ /**
134
+ * Synchronous public URL (Supabase parity). Serves through the public bucket
135
+ * endpoint, or through the render endpoint when `transform` is given.
136
+ */
137
+ getPublicUrl(path: string, options?: {
138
+ transform?: TransformOptions;
139
+ }): {
140
+ data: {
141
+ publicUrl: string;
142
+ };
143
+ };
144
+ /**
145
+ * A download URL for the object, valid for `expiresIn` seconds (default 3600,
146
+ * maximum 7 days: the AWS SigV4 ceiling; anything outside that is a `400`).
147
+ *
148
+ * `expiresAt` reports when the URL actually stops working, and is `null` when
149
+ * nothing expires: a public object's URL is permanent, and a private object on
150
+ * the `local` storage driver resolves to the authenticated streaming endpoint,
151
+ * which is bound to the session rather than to a clock and so cannot be handed
152
+ * to a third party at all. Check it rather than assuming `expiresIn` applied,
153
+ * that assumption is exactly what this used to get wrong, silently.
154
+ */
155
+ createSignedUrl(path: string, expiresIn?: number, options?: {
156
+ transform?: TransformOptions;
157
+ }): Promise<MotherbaseResponse<{
158
+ signedUrl: string;
159
+ expiresAt: string | null;
160
+ }>>;
161
+ /**
162
+ * Sign several objects in one call.
163
+ *
164
+ * There is no batch endpoint behind this: it signs each key and reports per
165
+ * entry, exactly as supabase-js does, so one missing object yields one entry
166
+ * with an `error` rather than failing the whole batch.
167
+ */
168
+ createSignedUrls(paths: string[], expiresIn?: number): Promise<MotherbaseResponse<Array<{
169
+ path: string;
170
+ signedUrl: string | null;
171
+ error: string | null;
172
+ }>>>;
173
+ /**
174
+ * Replace the object at `path`. In supabase-js `update` is `upload` with
175
+ * upsert forced on, and the same is true here.
176
+ */
177
+ update(path: string, file: UploadInput, options?: UploadOptions): Promise<MotherbaseResponse<UploadResult>>;
178
+ /** Copy an object to another key in this bucket. */
179
+ copy(from: string, to: string, options?: {
180
+ upsert?: boolean;
181
+ }): Promise<MotherbaseResponse<{
182
+ path: string;
183
+ }>>;
184
+ /** Move an object to another key in this bucket (copy, then delete the source). */
185
+ move(from: string, to: string, options?: {
186
+ upsert?: boolean;
187
+ }): Promise<MotherbaseResponse<{
188
+ path: string;
189
+ }>>;
190
+ private transfer;
191
+ /** One object's metadata, without downloading it. */
192
+ info(path: string): Promise<MotherbaseResponse<ObjectInfo>>;
193
+ /**
194
+ * Whether an object exists and this caller can read it.
195
+ *
196
+ * A 404 is the answer `false`, not a failure. Anything else (a 403, a network
197
+ * error) is reported as an error rather than as "no": treating an
198
+ * authorization failure as absence is how a UI ends up offering to create
199
+ * something that is already there.
200
+ */
201
+ exists(path: string): Promise<MotherbaseResponse<boolean>>;
202
+ /**
203
+ * Mint a URL the browser can PUT the bytes to directly, skipping this server.
204
+ *
205
+ * Unlike supabase-js this needs the file's `size` and content type up front:
206
+ * the upload is reserved against the bucket quota and the signature is bound
207
+ * to that exact length, which is what stops a signed URL from becoming an
208
+ * unbounded write. Pair it with `uploadToSignedUrl`.
209
+ *
210
+ * Requires the S3 driver; the local driver has no presigned uploads.
211
+ */
212
+ createSignedUploadUrl(path: string, options: {
213
+ size: number;
214
+ contentType?: string;
215
+ visibility?: FileVisibility;
216
+ }): Promise<MotherbaseResponse<{
217
+ signedUrl: string;
218
+ token: string;
219
+ path: string;
220
+ }>>;
221
+ /**
222
+ * Upload to a URL from `createSignedUploadUrl`: PUT the bytes to storage,
223
+ * then tell the server the object landed. The finalise step is what makes the
224
+ * row readable, so a PUT that succeeds and a finalise that fails leaves the
225
+ * reservation to expire rather than a half-visible object.
226
+ */
227
+ uploadToSignedUrl(path: string, token: string, file: UploadInput, options?: {
228
+ contentType?: string;
229
+ }): Promise<MotherbaseResponse<UploadResult>>;
230
+ }
231
+ /** Supabase-compatible storage client: `client.storage.from(bucket)`. */
232
+ export declare class StorageClient {
233
+ private readonly http;
234
+ private readonly baseUrl;
235
+ private readonly fetchImpl;
236
+ constructor(http: HttpClient, baseUrl: string, fetchImpl: typeof fetch);
237
+ from(bucket: string): StorageBucket;
238
+ /**
239
+ * Bucket administration, supabase-js shaped.
240
+ *
241
+ * Every method here needs a SECRET project API key, which is the same rule
242
+ * Supabase applies (bucket administration is a service-role operation). With
243
+ * a publishable key they resolve with a 401 error, so keep them in server
244
+ * code and setup scripts, never in a browser bundle.
245
+ */
246
+ listBuckets(): Promise<MotherbaseResponse<BucketInfo[]>>;
247
+ getBucket(id: string): Promise<MotherbaseResponse<BucketInfo>>;
248
+ createBucket(id: string, options?: BucketOptions): Promise<MotherbaseResponse<BucketInfo>>;
249
+ updateBucket(id: string, options: BucketOptions): Promise<MotherbaseResponse<BucketInfo>>;
250
+ /** Delete every object in the bucket, keeping the bucket itself. */
251
+ emptyBucket(id: string): Promise<MotherbaseResponse<{
252
+ emptied: boolean;
253
+ removed: number;
254
+ }>>;
255
+ /**
256
+ * Delete the bucket. A bucket that still holds objects is a `409` unless
257
+ * `force` is set, which queues a background deletion of its contents: an
258
+ * accidental `deleteBucket` must not be able to destroy a project's files in
259
+ * one unqualified call.
260
+ */
261
+ deleteBucket(id: string, options?: {
262
+ force?: boolean;
263
+ }): Promise<MotherbaseResponse<{
264
+ deleted: boolean;
265
+ }>>;
266
+ private bucketCall;
267
+ }
268
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EAErB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,4DAA4D;AAC5D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,uFAAuF;IACvF,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,6EAA6E;IAC7E,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,2DAA2D;AAC3D,MAAM,WAA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