@fluxbase/sdk 0.0.1-rc.30 → 0.0.1-rc.31
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/index.cjs +165 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -4
- package/dist/index.d.ts +109 -4
- package/dist/index.js +165 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -155,7 +155,7 @@ interface PostgrestResponse<T> {
|
|
|
155
155
|
status: number;
|
|
156
156
|
statusText: string;
|
|
157
157
|
}
|
|
158
|
-
type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'fts' | 'plfts' | 'wfts';
|
|
158
|
+
type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'adj' | 'not' | 'fts' | 'plfts' | 'wfts';
|
|
159
159
|
interface QueryFilter {
|
|
160
160
|
column: string;
|
|
161
161
|
operator: FilterOperator;
|
|
@@ -167,6 +167,27 @@ interface OrderBy {
|
|
|
167
167
|
direction: OrderDirection;
|
|
168
168
|
nulls?: 'first' | 'last';
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Options for upsert operations (Supabase-compatible)
|
|
172
|
+
*/
|
|
173
|
+
interface UpsertOptions {
|
|
174
|
+
/**
|
|
175
|
+
* Comma-separated columns to use for conflict resolution
|
|
176
|
+
* @example 'email'
|
|
177
|
+
* @example 'user_id,tenant_id'
|
|
178
|
+
*/
|
|
179
|
+
onConflict?: string;
|
|
180
|
+
/**
|
|
181
|
+
* If true, duplicate rows are ignored (not upserted)
|
|
182
|
+
* @default false
|
|
183
|
+
*/
|
|
184
|
+
ignoreDuplicates?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* If true, missing columns default to null instead of using existing values
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
|
+
defaultToNull?: boolean;
|
|
190
|
+
}
|
|
170
191
|
interface RealtimeMessage {
|
|
171
192
|
type: 'subscribe' | 'unsubscribe' | 'heartbeat' | 'broadcast' | 'presence' | 'ack' | 'error';
|
|
172
193
|
channel?: string;
|
|
@@ -4226,10 +4247,13 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4226
4247
|
private table;
|
|
4227
4248
|
private selectQuery;
|
|
4228
4249
|
private filters;
|
|
4250
|
+
private orFilters;
|
|
4251
|
+
private andFilters;
|
|
4229
4252
|
private orderBys;
|
|
4230
4253
|
private limitValue?;
|
|
4231
4254
|
private offsetValue?;
|
|
4232
4255
|
private singleRow;
|
|
4256
|
+
private maybeSingleRow;
|
|
4233
4257
|
private groupByColumns?;
|
|
4234
4258
|
constructor(fetch: FluxbaseFetch, table: string);
|
|
4235
4259
|
/**
|
|
@@ -4244,9 +4268,11 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4244
4268
|
*/
|
|
4245
4269
|
insert(data: Partial<T> | Array<Partial<T>>): Promise<PostgrestResponse<T>>;
|
|
4246
4270
|
/**
|
|
4247
|
-
* Upsert (insert or update) rows
|
|
4271
|
+
* Upsert (insert or update) rows (Supabase-compatible)
|
|
4272
|
+
* @param data - Row(s) to upsert
|
|
4273
|
+
* @param options - Upsert options (onConflict, ignoreDuplicates, defaultToNull)
|
|
4248
4274
|
*/
|
|
4249
|
-
upsert(data: Partial<T> | Array<Partial<T
|
|
4275
|
+
upsert(data: Partial<T> | Array<Partial<T>>, options?: UpsertOptions): Promise<PostgrestResponse<T>>;
|
|
4250
4276
|
/**
|
|
4251
4277
|
* Update rows matching the filters
|
|
4252
4278
|
*/
|
|
@@ -4303,6 +4329,48 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4303
4329
|
* Full-text search
|
|
4304
4330
|
*/
|
|
4305
4331
|
textSearch(column: string, query: string): this;
|
|
4332
|
+
/**
|
|
4333
|
+
* Negate a filter condition (Supabase-compatible)
|
|
4334
|
+
* @example not('status', 'eq', 'deleted')
|
|
4335
|
+
* @example not('completed_at', 'is', null)
|
|
4336
|
+
*/
|
|
4337
|
+
not(column: string, operator: FilterOperator, value: unknown): this;
|
|
4338
|
+
/**
|
|
4339
|
+
* Apply OR logic to filters (Supabase-compatible)
|
|
4340
|
+
* @example or('status.eq.active,status.eq.pending')
|
|
4341
|
+
* @example or('id.eq.2,name.eq.Han')
|
|
4342
|
+
*/
|
|
4343
|
+
or(filters: string): this;
|
|
4344
|
+
/**
|
|
4345
|
+
* Apply AND logic to filters (Supabase-compatible)
|
|
4346
|
+
* Groups multiple conditions that must all be true
|
|
4347
|
+
* @example and('status.eq.active,verified.eq.true')
|
|
4348
|
+
* @example and('age.gte.18,age.lte.65')
|
|
4349
|
+
*/
|
|
4350
|
+
and(filters: string): this;
|
|
4351
|
+
/**
|
|
4352
|
+
* Match multiple columns with exact values (Supabase-compatible)
|
|
4353
|
+
* Shorthand for multiple .eq() calls
|
|
4354
|
+
* @example match({ id: 1, status: 'active', role: 'admin' })
|
|
4355
|
+
*/
|
|
4356
|
+
match(conditions: Record<string, unknown>): this;
|
|
4357
|
+
/**
|
|
4358
|
+
* Generic filter method using PostgREST syntax (Supabase-compatible)
|
|
4359
|
+
* @example filter('name', 'in', '("Han","Yoda")')
|
|
4360
|
+
* @example filter('age', 'gte', '18')
|
|
4361
|
+
*/
|
|
4362
|
+
filter(column: string, operator: FilterOperator, value: unknown): this;
|
|
4363
|
+
/**
|
|
4364
|
+
* Check if column is contained by value (Supabase-compatible)
|
|
4365
|
+
* For arrays and JSONB
|
|
4366
|
+
* @example containedBy('tags', '["news","update"]')
|
|
4367
|
+
*/
|
|
4368
|
+
containedBy(column: string, value: unknown): this;
|
|
4369
|
+
/**
|
|
4370
|
+
* Check if arrays have common elements (Supabase-compatible)
|
|
4371
|
+
* @example overlaps('tags', '["news","sports"]')
|
|
4372
|
+
*/
|
|
4373
|
+
overlaps(column: string, value: unknown): this;
|
|
4306
4374
|
/**
|
|
4307
4375
|
* Order results
|
|
4308
4376
|
*/
|
|
@@ -4320,8 +4388,24 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4320
4388
|
offset(count: number): this;
|
|
4321
4389
|
/**
|
|
4322
4390
|
* Return a single row (adds limit(1))
|
|
4391
|
+
* Errors if no rows found
|
|
4323
4392
|
*/
|
|
4324
4393
|
single(): this;
|
|
4394
|
+
/**
|
|
4395
|
+
* Return a single row or null (adds limit(1))
|
|
4396
|
+
* Does not error if no rows found (Supabase-compatible)
|
|
4397
|
+
* @example
|
|
4398
|
+
* ```typescript
|
|
4399
|
+
* // Returns null instead of erroring when no row exists
|
|
4400
|
+
* const { data, error } = await client
|
|
4401
|
+
* .from('users')
|
|
4402
|
+
* .select('*')
|
|
4403
|
+
* .eq('id', 999)
|
|
4404
|
+
* .maybeSingle()
|
|
4405
|
+
* // data will be null if no row found
|
|
4406
|
+
* ```
|
|
4407
|
+
*/
|
|
4408
|
+
maybeSingle(): this;
|
|
4325
4409
|
/**
|
|
4326
4410
|
* Range selection (pagination)
|
|
4327
4411
|
*/
|
|
@@ -4538,6 +4622,27 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4538
4622
|
* Execute the query and return results
|
|
4539
4623
|
*/
|
|
4540
4624
|
execute(): Promise<PostgrestResponse<T>>;
|
|
4625
|
+
/**
|
|
4626
|
+
* Execute the query and throw an error if one occurs (Supabase-compatible)
|
|
4627
|
+
* Returns the data directly instead of { data, error } wrapper
|
|
4628
|
+
*
|
|
4629
|
+
* @throws {Error} If the query fails or returns an error
|
|
4630
|
+
* @example
|
|
4631
|
+
* ```typescript
|
|
4632
|
+
* // Throws error instead of returning { data, error }
|
|
4633
|
+
* try {
|
|
4634
|
+
* const user = await client
|
|
4635
|
+
* .from('users')
|
|
4636
|
+
* .select('*')
|
|
4637
|
+
* .eq('id', 1)
|
|
4638
|
+
* .single()
|
|
4639
|
+
* .throwOnError()
|
|
4640
|
+
* } catch (error) {
|
|
4641
|
+
* console.error('Query failed:', error)
|
|
4642
|
+
* }
|
|
4643
|
+
* ```
|
|
4644
|
+
*/
|
|
4645
|
+
throwOnError(): Promise<T>;
|
|
4541
4646
|
/**
|
|
4542
4647
|
* Make QueryBuilder awaitable (implements PromiseLike)
|
|
4543
4648
|
* This allows using `await client.from('table').select()` without calling `.execute()`
|
|
@@ -4767,4 +4872,4 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
4767
4872
|
*/
|
|
4768
4873
|
declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
|
|
4769
4874
|
|
|
4770
|
-
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
|
4875
|
+
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -155,7 +155,7 @@ interface PostgrestResponse<T> {
|
|
|
155
155
|
status: number;
|
|
156
156
|
statusText: string;
|
|
157
157
|
}
|
|
158
|
-
type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'fts' | 'plfts' | 'wfts';
|
|
158
|
+
type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'adj' | 'not' | 'fts' | 'plfts' | 'wfts';
|
|
159
159
|
interface QueryFilter {
|
|
160
160
|
column: string;
|
|
161
161
|
operator: FilterOperator;
|
|
@@ -167,6 +167,27 @@ interface OrderBy {
|
|
|
167
167
|
direction: OrderDirection;
|
|
168
168
|
nulls?: 'first' | 'last';
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Options for upsert operations (Supabase-compatible)
|
|
172
|
+
*/
|
|
173
|
+
interface UpsertOptions {
|
|
174
|
+
/**
|
|
175
|
+
* Comma-separated columns to use for conflict resolution
|
|
176
|
+
* @example 'email'
|
|
177
|
+
* @example 'user_id,tenant_id'
|
|
178
|
+
*/
|
|
179
|
+
onConflict?: string;
|
|
180
|
+
/**
|
|
181
|
+
* If true, duplicate rows are ignored (not upserted)
|
|
182
|
+
* @default false
|
|
183
|
+
*/
|
|
184
|
+
ignoreDuplicates?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* If true, missing columns default to null instead of using existing values
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
|
+
defaultToNull?: boolean;
|
|
190
|
+
}
|
|
170
191
|
interface RealtimeMessage {
|
|
171
192
|
type: 'subscribe' | 'unsubscribe' | 'heartbeat' | 'broadcast' | 'presence' | 'ack' | 'error';
|
|
172
193
|
channel?: string;
|
|
@@ -4226,10 +4247,13 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4226
4247
|
private table;
|
|
4227
4248
|
private selectQuery;
|
|
4228
4249
|
private filters;
|
|
4250
|
+
private orFilters;
|
|
4251
|
+
private andFilters;
|
|
4229
4252
|
private orderBys;
|
|
4230
4253
|
private limitValue?;
|
|
4231
4254
|
private offsetValue?;
|
|
4232
4255
|
private singleRow;
|
|
4256
|
+
private maybeSingleRow;
|
|
4233
4257
|
private groupByColumns?;
|
|
4234
4258
|
constructor(fetch: FluxbaseFetch, table: string);
|
|
4235
4259
|
/**
|
|
@@ -4244,9 +4268,11 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4244
4268
|
*/
|
|
4245
4269
|
insert(data: Partial<T> | Array<Partial<T>>): Promise<PostgrestResponse<T>>;
|
|
4246
4270
|
/**
|
|
4247
|
-
* Upsert (insert or update) rows
|
|
4271
|
+
* Upsert (insert or update) rows (Supabase-compatible)
|
|
4272
|
+
* @param data - Row(s) to upsert
|
|
4273
|
+
* @param options - Upsert options (onConflict, ignoreDuplicates, defaultToNull)
|
|
4248
4274
|
*/
|
|
4249
|
-
upsert(data: Partial<T> | Array<Partial<T
|
|
4275
|
+
upsert(data: Partial<T> | Array<Partial<T>>, options?: UpsertOptions): Promise<PostgrestResponse<T>>;
|
|
4250
4276
|
/**
|
|
4251
4277
|
* Update rows matching the filters
|
|
4252
4278
|
*/
|
|
@@ -4303,6 +4329,48 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4303
4329
|
* Full-text search
|
|
4304
4330
|
*/
|
|
4305
4331
|
textSearch(column: string, query: string): this;
|
|
4332
|
+
/**
|
|
4333
|
+
* Negate a filter condition (Supabase-compatible)
|
|
4334
|
+
* @example not('status', 'eq', 'deleted')
|
|
4335
|
+
* @example not('completed_at', 'is', null)
|
|
4336
|
+
*/
|
|
4337
|
+
not(column: string, operator: FilterOperator, value: unknown): this;
|
|
4338
|
+
/**
|
|
4339
|
+
* Apply OR logic to filters (Supabase-compatible)
|
|
4340
|
+
* @example or('status.eq.active,status.eq.pending')
|
|
4341
|
+
* @example or('id.eq.2,name.eq.Han')
|
|
4342
|
+
*/
|
|
4343
|
+
or(filters: string): this;
|
|
4344
|
+
/**
|
|
4345
|
+
* Apply AND logic to filters (Supabase-compatible)
|
|
4346
|
+
* Groups multiple conditions that must all be true
|
|
4347
|
+
* @example and('status.eq.active,verified.eq.true')
|
|
4348
|
+
* @example and('age.gte.18,age.lte.65')
|
|
4349
|
+
*/
|
|
4350
|
+
and(filters: string): this;
|
|
4351
|
+
/**
|
|
4352
|
+
* Match multiple columns with exact values (Supabase-compatible)
|
|
4353
|
+
* Shorthand for multiple .eq() calls
|
|
4354
|
+
* @example match({ id: 1, status: 'active', role: 'admin' })
|
|
4355
|
+
*/
|
|
4356
|
+
match(conditions: Record<string, unknown>): this;
|
|
4357
|
+
/**
|
|
4358
|
+
* Generic filter method using PostgREST syntax (Supabase-compatible)
|
|
4359
|
+
* @example filter('name', 'in', '("Han","Yoda")')
|
|
4360
|
+
* @example filter('age', 'gte', '18')
|
|
4361
|
+
*/
|
|
4362
|
+
filter(column: string, operator: FilterOperator, value: unknown): this;
|
|
4363
|
+
/**
|
|
4364
|
+
* Check if column is contained by value (Supabase-compatible)
|
|
4365
|
+
* For arrays and JSONB
|
|
4366
|
+
* @example containedBy('tags', '["news","update"]')
|
|
4367
|
+
*/
|
|
4368
|
+
containedBy(column: string, value: unknown): this;
|
|
4369
|
+
/**
|
|
4370
|
+
* Check if arrays have common elements (Supabase-compatible)
|
|
4371
|
+
* @example overlaps('tags', '["news","sports"]')
|
|
4372
|
+
*/
|
|
4373
|
+
overlaps(column: string, value: unknown): this;
|
|
4306
4374
|
/**
|
|
4307
4375
|
* Order results
|
|
4308
4376
|
*/
|
|
@@ -4320,8 +4388,24 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4320
4388
|
offset(count: number): this;
|
|
4321
4389
|
/**
|
|
4322
4390
|
* Return a single row (adds limit(1))
|
|
4391
|
+
* Errors if no rows found
|
|
4323
4392
|
*/
|
|
4324
4393
|
single(): this;
|
|
4394
|
+
/**
|
|
4395
|
+
* Return a single row or null (adds limit(1))
|
|
4396
|
+
* Does not error if no rows found (Supabase-compatible)
|
|
4397
|
+
* @example
|
|
4398
|
+
* ```typescript
|
|
4399
|
+
* // Returns null instead of erroring when no row exists
|
|
4400
|
+
* const { data, error } = await client
|
|
4401
|
+
* .from('users')
|
|
4402
|
+
* .select('*')
|
|
4403
|
+
* .eq('id', 999)
|
|
4404
|
+
* .maybeSingle()
|
|
4405
|
+
* // data will be null if no row found
|
|
4406
|
+
* ```
|
|
4407
|
+
*/
|
|
4408
|
+
maybeSingle(): this;
|
|
4325
4409
|
/**
|
|
4326
4410
|
* Range selection (pagination)
|
|
4327
4411
|
*/
|
|
@@ -4538,6 +4622,27 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
4538
4622
|
* Execute the query and return results
|
|
4539
4623
|
*/
|
|
4540
4624
|
execute(): Promise<PostgrestResponse<T>>;
|
|
4625
|
+
/**
|
|
4626
|
+
* Execute the query and throw an error if one occurs (Supabase-compatible)
|
|
4627
|
+
* Returns the data directly instead of { data, error } wrapper
|
|
4628
|
+
*
|
|
4629
|
+
* @throws {Error} If the query fails or returns an error
|
|
4630
|
+
* @example
|
|
4631
|
+
* ```typescript
|
|
4632
|
+
* // Throws error instead of returning { data, error }
|
|
4633
|
+
* try {
|
|
4634
|
+
* const user = await client
|
|
4635
|
+
* .from('users')
|
|
4636
|
+
* .select('*')
|
|
4637
|
+
* .eq('id', 1)
|
|
4638
|
+
* .single()
|
|
4639
|
+
* .throwOnError()
|
|
4640
|
+
* } catch (error) {
|
|
4641
|
+
* console.error('Query failed:', error)
|
|
4642
|
+
* }
|
|
4643
|
+
* ```
|
|
4644
|
+
*/
|
|
4645
|
+
throwOnError(): Promise<T>;
|
|
4541
4646
|
/**
|
|
4542
4647
|
* Make QueryBuilder awaitable (implements PromiseLike)
|
|
4543
4648
|
* This allows using `await client.from('table').select()` without calling `.execute()`
|
|
@@ -4767,4 +4872,4 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
4767
4872
|
*/
|
|
4768
4873
|
declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
|
|
4769
4874
|
|
|
4770
|
-
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
|
4875
|
+
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
package/dist/index.js
CHANGED
|
@@ -3959,8 +3959,11 @@ var QueryBuilder = class {
|
|
|
3959
3959
|
constructor(fetch2, table) {
|
|
3960
3960
|
this.selectQuery = "*";
|
|
3961
3961
|
this.filters = [];
|
|
3962
|
+
this.orFilters = [];
|
|
3963
|
+
this.andFilters = [];
|
|
3962
3964
|
this.orderBys = [];
|
|
3963
3965
|
this.singleRow = false;
|
|
3966
|
+
this.maybeSingleRow = false;
|
|
3964
3967
|
this.fetch = fetch2;
|
|
3965
3968
|
this.table = table;
|
|
3966
3969
|
}
|
|
@@ -3989,15 +3992,29 @@ var QueryBuilder = class {
|
|
|
3989
3992
|
};
|
|
3990
3993
|
}
|
|
3991
3994
|
/**
|
|
3992
|
-
* Upsert (insert or update) rows
|
|
3995
|
+
* Upsert (insert or update) rows (Supabase-compatible)
|
|
3996
|
+
* @param data - Row(s) to upsert
|
|
3997
|
+
* @param options - Upsert options (onConflict, ignoreDuplicates, defaultToNull)
|
|
3993
3998
|
*/
|
|
3994
|
-
async upsert(data) {
|
|
3999
|
+
async upsert(data, options) {
|
|
3995
4000
|
const body = Array.isArray(data) ? data : data;
|
|
3996
|
-
const
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
+
const preferValues = [];
|
|
4002
|
+
if (options?.ignoreDuplicates) {
|
|
4003
|
+
preferValues.push("resolution=ignore-duplicates");
|
|
4004
|
+
} else {
|
|
4005
|
+
preferValues.push("resolution=merge-duplicates");
|
|
4006
|
+
}
|
|
4007
|
+
if (options?.defaultToNull) {
|
|
4008
|
+
preferValues.push("missing=default");
|
|
4009
|
+
}
|
|
4010
|
+
const headers = {
|
|
4011
|
+
Prefer: preferValues.join(",")
|
|
4012
|
+
};
|
|
4013
|
+
let path = `/api/v1/tables/${this.table}`;
|
|
4014
|
+
if (options?.onConflict) {
|
|
4015
|
+
path += `?on_conflict=${encodeURIComponent(options.onConflict)}`;
|
|
4016
|
+
}
|
|
4017
|
+
const response = await this.fetch.post(path, body, { headers });
|
|
4001
4018
|
return {
|
|
4002
4019
|
data: response,
|
|
4003
4020
|
error: null,
|
|
@@ -4120,6 +4137,71 @@ var QueryBuilder = class {
|
|
|
4120
4137
|
this.filters.push({ column, operator: "fts", value: query });
|
|
4121
4138
|
return this;
|
|
4122
4139
|
}
|
|
4140
|
+
/**
|
|
4141
|
+
* Negate a filter condition (Supabase-compatible)
|
|
4142
|
+
* @example not('status', 'eq', 'deleted')
|
|
4143
|
+
* @example not('completed_at', 'is', null)
|
|
4144
|
+
*/
|
|
4145
|
+
not(column, operator, value) {
|
|
4146
|
+
this.filters.push({ column, operator: "not", value: `${operator}.${this.formatValue(value)}` });
|
|
4147
|
+
return this;
|
|
4148
|
+
}
|
|
4149
|
+
/**
|
|
4150
|
+
* Apply OR logic to filters (Supabase-compatible)
|
|
4151
|
+
* @example or('status.eq.active,status.eq.pending')
|
|
4152
|
+
* @example or('id.eq.2,name.eq.Han')
|
|
4153
|
+
*/
|
|
4154
|
+
or(filters) {
|
|
4155
|
+
this.orFilters.push(filters);
|
|
4156
|
+
return this;
|
|
4157
|
+
}
|
|
4158
|
+
/**
|
|
4159
|
+
* Apply AND logic to filters (Supabase-compatible)
|
|
4160
|
+
* Groups multiple conditions that must all be true
|
|
4161
|
+
* @example and('status.eq.active,verified.eq.true')
|
|
4162
|
+
* @example and('age.gte.18,age.lte.65')
|
|
4163
|
+
*/
|
|
4164
|
+
and(filters) {
|
|
4165
|
+
this.andFilters.push(filters);
|
|
4166
|
+
return this;
|
|
4167
|
+
}
|
|
4168
|
+
/**
|
|
4169
|
+
* Match multiple columns with exact values (Supabase-compatible)
|
|
4170
|
+
* Shorthand for multiple .eq() calls
|
|
4171
|
+
* @example match({ id: 1, status: 'active', role: 'admin' })
|
|
4172
|
+
*/
|
|
4173
|
+
match(conditions) {
|
|
4174
|
+
for (const [column, value] of Object.entries(conditions)) {
|
|
4175
|
+
this.eq(column, value);
|
|
4176
|
+
}
|
|
4177
|
+
return this;
|
|
4178
|
+
}
|
|
4179
|
+
/**
|
|
4180
|
+
* Generic filter method using PostgREST syntax (Supabase-compatible)
|
|
4181
|
+
* @example filter('name', 'in', '("Han","Yoda")')
|
|
4182
|
+
* @example filter('age', 'gte', '18')
|
|
4183
|
+
*/
|
|
4184
|
+
filter(column, operator, value) {
|
|
4185
|
+
this.filters.push({ column, operator, value });
|
|
4186
|
+
return this;
|
|
4187
|
+
}
|
|
4188
|
+
/**
|
|
4189
|
+
* Check if column is contained by value (Supabase-compatible)
|
|
4190
|
+
* For arrays and JSONB
|
|
4191
|
+
* @example containedBy('tags', '["news","update"]')
|
|
4192
|
+
*/
|
|
4193
|
+
containedBy(column, value) {
|
|
4194
|
+
this.filters.push({ column, operator: "cd", value });
|
|
4195
|
+
return this;
|
|
4196
|
+
}
|
|
4197
|
+
/**
|
|
4198
|
+
* Check if arrays have common elements (Supabase-compatible)
|
|
4199
|
+
* @example overlaps('tags', '["news","sports"]')
|
|
4200
|
+
*/
|
|
4201
|
+
overlaps(column, value) {
|
|
4202
|
+
this.filters.push({ column, operator: "ov", value });
|
|
4203
|
+
return this;
|
|
4204
|
+
}
|
|
4123
4205
|
/**
|
|
4124
4206
|
* Order results
|
|
4125
4207
|
*/
|
|
@@ -4147,12 +4229,32 @@ var QueryBuilder = class {
|
|
|
4147
4229
|
}
|
|
4148
4230
|
/**
|
|
4149
4231
|
* Return a single row (adds limit(1))
|
|
4232
|
+
* Errors if no rows found
|
|
4150
4233
|
*/
|
|
4151
4234
|
single() {
|
|
4152
4235
|
this.singleRow = true;
|
|
4153
4236
|
this.limitValue = 1;
|
|
4154
4237
|
return this;
|
|
4155
4238
|
}
|
|
4239
|
+
/**
|
|
4240
|
+
* Return a single row or null (adds limit(1))
|
|
4241
|
+
* Does not error if no rows found (Supabase-compatible)
|
|
4242
|
+
* @example
|
|
4243
|
+
* ```typescript
|
|
4244
|
+
* // Returns null instead of erroring when no row exists
|
|
4245
|
+
* const { data, error } = await client
|
|
4246
|
+
* .from('users')
|
|
4247
|
+
* .select('*')
|
|
4248
|
+
* .eq('id', 999)
|
|
4249
|
+
* .maybeSingle()
|
|
4250
|
+
* // data will be null if no row found
|
|
4251
|
+
* ```
|
|
4252
|
+
*/
|
|
4253
|
+
maybeSingle() {
|
|
4254
|
+
this.maybeSingleRow = true;
|
|
4255
|
+
this.limitValue = 1;
|
|
4256
|
+
return this;
|
|
4257
|
+
}
|
|
4156
4258
|
/**
|
|
4157
4259
|
* Range selection (pagination)
|
|
4158
4260
|
*/
|
|
@@ -4420,6 +4522,25 @@ var QueryBuilder = class {
|
|
|
4420
4522
|
statusText: "OK"
|
|
4421
4523
|
};
|
|
4422
4524
|
}
|
|
4525
|
+
if (this.maybeSingleRow) {
|
|
4526
|
+
if (Array.isArray(data) && data.length === 0) {
|
|
4527
|
+
return {
|
|
4528
|
+
data: null,
|
|
4529
|
+
error: null,
|
|
4530
|
+
count: 0,
|
|
4531
|
+
status: 200,
|
|
4532
|
+
statusText: "OK"
|
|
4533
|
+
};
|
|
4534
|
+
}
|
|
4535
|
+
const singleData = Array.isArray(data) ? data[0] : data;
|
|
4536
|
+
return {
|
|
4537
|
+
data: singleData,
|
|
4538
|
+
error: null,
|
|
4539
|
+
count: 1,
|
|
4540
|
+
status: 200,
|
|
4541
|
+
statusText: "OK"
|
|
4542
|
+
};
|
|
4543
|
+
}
|
|
4423
4544
|
return {
|
|
4424
4545
|
data,
|
|
4425
4546
|
error: null,
|
|
@@ -4441,6 +4562,37 @@ var QueryBuilder = class {
|
|
|
4441
4562
|
};
|
|
4442
4563
|
}
|
|
4443
4564
|
}
|
|
4565
|
+
/**
|
|
4566
|
+
* Execute the query and throw an error if one occurs (Supabase-compatible)
|
|
4567
|
+
* Returns the data directly instead of { data, error } wrapper
|
|
4568
|
+
*
|
|
4569
|
+
* @throws {Error} If the query fails or returns an error
|
|
4570
|
+
* @example
|
|
4571
|
+
* ```typescript
|
|
4572
|
+
* // Throws error instead of returning { data, error }
|
|
4573
|
+
* try {
|
|
4574
|
+
* const user = await client
|
|
4575
|
+
* .from('users')
|
|
4576
|
+
* .select('*')
|
|
4577
|
+
* .eq('id', 1)
|
|
4578
|
+
* .single()
|
|
4579
|
+
* .throwOnError()
|
|
4580
|
+
* } catch (error) {
|
|
4581
|
+
* console.error('Query failed:', error)
|
|
4582
|
+
* }
|
|
4583
|
+
* ```
|
|
4584
|
+
*/
|
|
4585
|
+
async throwOnError() {
|
|
4586
|
+
const response = await this.execute();
|
|
4587
|
+
if (response.error) {
|
|
4588
|
+
const error = new Error(response.error.message);
|
|
4589
|
+
if (response.error.code) {
|
|
4590
|
+
error.code = response.error.code;
|
|
4591
|
+
}
|
|
4592
|
+
throw error;
|
|
4593
|
+
}
|
|
4594
|
+
return response.data;
|
|
4595
|
+
}
|
|
4444
4596
|
/**
|
|
4445
4597
|
* Make QueryBuilder awaitable (implements PromiseLike)
|
|
4446
4598
|
* This allows using `await client.from('table').select()` without calling `.execute()`
|
|
@@ -4468,6 +4620,12 @@ var QueryBuilder = class {
|
|
|
4468
4620
|
for (const filter of this.filters) {
|
|
4469
4621
|
params.append(filter.column, `${filter.operator}.${this.formatValue(filter.value)}`);
|
|
4470
4622
|
}
|
|
4623
|
+
for (const orFilter of this.orFilters) {
|
|
4624
|
+
params.append("or", `(${orFilter})`);
|
|
4625
|
+
}
|
|
4626
|
+
for (const andFilter of this.andFilters) {
|
|
4627
|
+
params.append("and", `(${andFilter})`);
|
|
4628
|
+
}
|
|
4471
4629
|
if (this.groupByColumns && this.groupByColumns.length > 0) {
|
|
4472
4630
|
params.append("group_by", this.groupByColumns.join(","));
|
|
4473
4631
|
}
|