@fluxbase/sdk 0.0.1-rc.106 → 0.0.1-rc.107
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 +506 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +570 -5
- package/dist/index.d.ts +570 -5
- package/dist/index.js +506 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -474,7 +474,14 @@ var FluxbaseAuth = class {
|
|
|
474
474
|
*/
|
|
475
475
|
async signIn(credentials) {
|
|
476
476
|
return wrapAsync(async () => {
|
|
477
|
-
const
|
|
477
|
+
const requestBody = {
|
|
478
|
+
email: credentials.email,
|
|
479
|
+
password: credentials.password
|
|
480
|
+
};
|
|
481
|
+
if (credentials.captchaToken) {
|
|
482
|
+
requestBody.captcha_token = credentials.captchaToken;
|
|
483
|
+
}
|
|
484
|
+
const response = await this.fetch.post("/api/v1/auth/signin", requestBody);
|
|
478
485
|
if ("requires_2fa" in response && response.requires_2fa) {
|
|
479
486
|
return response;
|
|
480
487
|
}
|
|
@@ -509,6 +516,9 @@ var FluxbaseAuth = class {
|
|
|
509
516
|
if (credentials.options?.data) {
|
|
510
517
|
requestBody.user_metadata = credentials.options.data;
|
|
511
518
|
}
|
|
519
|
+
if (credentials.captchaToken) {
|
|
520
|
+
requestBody.captcha_token = credentials.captchaToken;
|
|
521
|
+
}
|
|
512
522
|
const response = await this.fetch.post(
|
|
513
523
|
"/api/v1/auth/signup",
|
|
514
524
|
requestBody
|
|
@@ -524,6 +534,16 @@ var FluxbaseAuth = class {
|
|
|
524
534
|
return { user: response.user, session: null };
|
|
525
535
|
});
|
|
526
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Get CAPTCHA configuration from the server
|
|
539
|
+
* Use this to determine which CAPTCHA provider to load and configure
|
|
540
|
+
* @returns Promise with CAPTCHA configuration (provider, site key, enabled endpoints)
|
|
541
|
+
*/
|
|
542
|
+
async getCaptchaConfig() {
|
|
543
|
+
return wrapAsync(async () => {
|
|
544
|
+
return await this.fetch.get("/api/v1/auth/captcha/config");
|
|
545
|
+
});
|
|
546
|
+
}
|
|
527
547
|
/**
|
|
528
548
|
* Sign out the current user
|
|
529
549
|
*/
|
|
@@ -735,22 +755,29 @@ var FluxbaseAuth = class {
|
|
|
735
755
|
* Send password reset email (Supabase-compatible)
|
|
736
756
|
* Sends a password reset link to the provided email address
|
|
737
757
|
* @param email - Email address to send reset link to
|
|
758
|
+
* @param options - Optional configuration including CAPTCHA token
|
|
738
759
|
* @returns Promise with OTP-style response
|
|
739
760
|
*/
|
|
740
|
-
async sendPasswordReset(email) {
|
|
761
|
+
async sendPasswordReset(email, options) {
|
|
741
762
|
return wrapAsync(async () => {
|
|
742
|
-
|
|
763
|
+
const requestBody = { email };
|
|
764
|
+
if (options?.captchaToken) {
|
|
765
|
+
requestBody.captcha_token = options.captchaToken;
|
|
766
|
+
}
|
|
767
|
+
await this.fetch.post("/api/v1/auth/password/reset", requestBody);
|
|
743
768
|
return { user: null, session: null };
|
|
744
769
|
});
|
|
745
770
|
}
|
|
746
771
|
/**
|
|
747
772
|
* Supabase-compatible alias for sendPasswordReset()
|
|
748
773
|
* @param email - Email address to send reset link to
|
|
749
|
-
* @param
|
|
774
|
+
* @param options - Optional redirect and CAPTCHA configuration
|
|
750
775
|
* @returns Promise with OTP-style response
|
|
751
776
|
*/
|
|
752
|
-
async resetPasswordForEmail(email,
|
|
753
|
-
return this.sendPasswordReset(email
|
|
777
|
+
async resetPasswordForEmail(email, options) {
|
|
778
|
+
return this.sendPasswordReset(email, {
|
|
779
|
+
captchaToken: options?.captchaToken
|
|
780
|
+
});
|
|
754
781
|
}
|
|
755
782
|
/**
|
|
756
783
|
* Verify password reset token
|
|
@@ -799,10 +826,14 @@ var FluxbaseAuth = class {
|
|
|
799
826
|
*/
|
|
800
827
|
async sendMagicLink(email, options) {
|
|
801
828
|
return wrapAsync(async () => {
|
|
802
|
-
|
|
829
|
+
const requestBody = {
|
|
803
830
|
email,
|
|
804
831
|
redirect_to: options?.redirect_to
|
|
805
|
-
}
|
|
832
|
+
};
|
|
833
|
+
if (options?.captchaToken) {
|
|
834
|
+
requestBody.captcha_token = options.captchaToken;
|
|
835
|
+
}
|
|
836
|
+
await this.fetch.post("/api/v1/auth/magiclink", requestBody);
|
|
806
837
|
return { user: null, session: null };
|
|
807
838
|
});
|
|
808
839
|
}
|
|
@@ -1045,6 +1076,139 @@ var FluxbaseAuth = class {
|
|
|
1045
1076
|
return { user: session.user, session };
|
|
1046
1077
|
});
|
|
1047
1078
|
}
|
|
1079
|
+
// ==========================================================================
|
|
1080
|
+
// SAML SSO Methods
|
|
1081
|
+
// ==========================================================================
|
|
1082
|
+
/**
|
|
1083
|
+
* Get list of available SAML SSO providers
|
|
1084
|
+
* @returns Promise with list of configured SAML providers
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* ```typescript
|
|
1088
|
+
* const { data, error } = await client.auth.getSAMLProviders()
|
|
1089
|
+
* if (!error) {
|
|
1090
|
+
* console.log('Available providers:', data.providers)
|
|
1091
|
+
* }
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
1094
|
+
async getSAMLProviders() {
|
|
1095
|
+
return wrapAsync(async () => {
|
|
1096
|
+
return await this.fetch.get(
|
|
1097
|
+
"/api/v1/auth/saml/providers"
|
|
1098
|
+
);
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Get SAML login URL for a specific provider
|
|
1103
|
+
* Use this to redirect the user to the IdP for authentication
|
|
1104
|
+
* @param provider - SAML provider name/ID
|
|
1105
|
+
* @param options - Optional login configuration
|
|
1106
|
+
* @returns Promise with SAML login URL
|
|
1107
|
+
*
|
|
1108
|
+
* @example
|
|
1109
|
+
* ```typescript
|
|
1110
|
+
* const { data, error } = await client.auth.getSAMLLoginUrl('okta')
|
|
1111
|
+
* if (!error) {
|
|
1112
|
+
* window.location.href = data.url
|
|
1113
|
+
* }
|
|
1114
|
+
* ```
|
|
1115
|
+
*/
|
|
1116
|
+
async getSAMLLoginUrl(provider, options) {
|
|
1117
|
+
return wrapAsync(async () => {
|
|
1118
|
+
const params = new URLSearchParams();
|
|
1119
|
+
if (options?.redirectUrl) {
|
|
1120
|
+
params.append("redirect_url", options.redirectUrl);
|
|
1121
|
+
}
|
|
1122
|
+
const queryString = params.toString();
|
|
1123
|
+
const url = queryString ? `/api/v1/auth/saml/login/${provider}?${queryString}` : `/api/v1/auth/saml/login/${provider}`;
|
|
1124
|
+
const response = await this.fetch.get(url);
|
|
1125
|
+
return response;
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Initiate SAML login and redirect to IdP
|
|
1130
|
+
* This is a convenience method that redirects the user to the SAML IdP
|
|
1131
|
+
* @param provider - SAML provider name/ID
|
|
1132
|
+
* @param options - Optional login configuration
|
|
1133
|
+
* @returns Promise with provider and URL (browser will redirect)
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* ```typescript
|
|
1137
|
+
* // In browser, this will redirect to the SAML IdP
|
|
1138
|
+
* await client.auth.signInWithSAML('okta')
|
|
1139
|
+
* ```
|
|
1140
|
+
*/
|
|
1141
|
+
async signInWithSAML(provider, options) {
|
|
1142
|
+
return wrapAsync(async () => {
|
|
1143
|
+
const result = await this.getSAMLLoginUrl(provider, options);
|
|
1144
|
+
if (result.error) {
|
|
1145
|
+
throw result.error;
|
|
1146
|
+
}
|
|
1147
|
+
const url = result.data.url;
|
|
1148
|
+
if (typeof window !== "undefined") {
|
|
1149
|
+
window.location.href = url;
|
|
1150
|
+
} else {
|
|
1151
|
+
throw new Error(
|
|
1152
|
+
"signInWithSAML can only be called in a browser environment"
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
return { provider, url };
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Handle SAML callback after IdP authentication
|
|
1160
|
+
* Call this from your SAML callback page to complete authentication
|
|
1161
|
+
* @param samlResponse - Base64-encoded SAML response from the ACS endpoint
|
|
1162
|
+
* @param provider - SAML provider name (optional, extracted from RelayState)
|
|
1163
|
+
* @returns Promise with user and session
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* ```typescript
|
|
1167
|
+
* // In your SAML callback page
|
|
1168
|
+
* const urlParams = new URLSearchParams(window.location.search)
|
|
1169
|
+
* const samlResponse = urlParams.get('SAMLResponse')
|
|
1170
|
+
*
|
|
1171
|
+
* if (samlResponse) {
|
|
1172
|
+
* const { data, error } = await client.auth.handleSAMLCallback(samlResponse)
|
|
1173
|
+
* if (!error) {
|
|
1174
|
+
* console.log('Logged in:', data.user)
|
|
1175
|
+
* }
|
|
1176
|
+
* }
|
|
1177
|
+
* ```
|
|
1178
|
+
*/
|
|
1179
|
+
async handleSAMLCallback(samlResponse, provider) {
|
|
1180
|
+
return wrapAsync(async () => {
|
|
1181
|
+
const response = await this.fetch.post(
|
|
1182
|
+
"/api/v1/auth/saml/acs",
|
|
1183
|
+
{
|
|
1184
|
+
saml_response: samlResponse,
|
|
1185
|
+
provider
|
|
1186
|
+
}
|
|
1187
|
+
);
|
|
1188
|
+
const session = {
|
|
1189
|
+
...response,
|
|
1190
|
+
expires_at: Date.now() + response.expires_in * 1e3
|
|
1191
|
+
};
|
|
1192
|
+
this.setSessionInternal(session);
|
|
1193
|
+
return { user: session.user, session };
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Get SAML Service Provider metadata for a specific provider configuration
|
|
1198
|
+
* Use this when configuring your IdP to download the SP metadata XML
|
|
1199
|
+
* @param provider - SAML provider name/ID
|
|
1200
|
+
* @returns Promise with SP metadata URL
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* ```typescript
|
|
1204
|
+
* const metadataUrl = client.auth.getSAMLMetadataUrl('okta')
|
|
1205
|
+
* // Share this URL with your IdP administrator
|
|
1206
|
+
* ```
|
|
1207
|
+
*/
|
|
1208
|
+
getSAMLMetadataUrl(provider) {
|
|
1209
|
+
const baseUrl = this.fetch["baseUrl"];
|
|
1210
|
+
return `${baseUrl}/api/v1/auth/saml/metadata/${provider}`;
|
|
1211
|
+
}
|
|
1048
1212
|
/**
|
|
1049
1213
|
* Internal: Set the session and persist it
|
|
1050
1214
|
*/
|
|
@@ -2783,17 +2947,114 @@ var StorageBucket = class {
|
|
|
2783
2947
|
const publicUrl = `${this.fetch["baseUrl"]}/api/v1/storage/${this.bucketName}/${path}`;
|
|
2784
2948
|
return { data: { publicUrl } };
|
|
2785
2949
|
}
|
|
2950
|
+
/**
|
|
2951
|
+
* Build query string from transform options
|
|
2952
|
+
* @private
|
|
2953
|
+
*/
|
|
2954
|
+
buildTransformQuery(transform) {
|
|
2955
|
+
const params = new URLSearchParams();
|
|
2956
|
+
if (transform.width !== void 0 && transform.width > 0) {
|
|
2957
|
+
params.set("w", String(transform.width));
|
|
2958
|
+
}
|
|
2959
|
+
if (transform.height !== void 0 && transform.height > 0) {
|
|
2960
|
+
params.set("h", String(transform.height));
|
|
2961
|
+
}
|
|
2962
|
+
if (transform.format) {
|
|
2963
|
+
params.set("fmt", transform.format);
|
|
2964
|
+
}
|
|
2965
|
+
if (transform.quality !== void 0 && transform.quality > 0) {
|
|
2966
|
+
params.set("q", String(transform.quality));
|
|
2967
|
+
}
|
|
2968
|
+
if (transform.fit) {
|
|
2969
|
+
params.set("fit", transform.fit);
|
|
2970
|
+
}
|
|
2971
|
+
return params.toString();
|
|
2972
|
+
}
|
|
2973
|
+
/**
|
|
2974
|
+
* Get a public URL for a file with image transformations applied
|
|
2975
|
+
* Only works for image files (JPEG, PNG, WebP, GIF, AVIF, etc.)
|
|
2976
|
+
*
|
|
2977
|
+
* @param path - The file path
|
|
2978
|
+
* @param transform - Transformation options (width, height, format, quality, fit)
|
|
2979
|
+
*
|
|
2980
|
+
* @example
|
|
2981
|
+
* ```typescript
|
|
2982
|
+
* // Get a 300x200 WebP thumbnail
|
|
2983
|
+
* const url = storage.from('images').getTransformUrl('photo.jpg', {
|
|
2984
|
+
* width: 300,
|
|
2985
|
+
* height: 200,
|
|
2986
|
+
* format: 'webp',
|
|
2987
|
+
* quality: 85,
|
|
2988
|
+
* fit: 'cover'
|
|
2989
|
+
* });
|
|
2990
|
+
*
|
|
2991
|
+
* // Get a resized image maintaining aspect ratio
|
|
2992
|
+
* const url = storage.from('images').getTransformUrl('photo.jpg', {
|
|
2993
|
+
* width: 800,
|
|
2994
|
+
* format: 'webp'
|
|
2995
|
+
* });
|
|
2996
|
+
* ```
|
|
2997
|
+
*/
|
|
2998
|
+
getTransformUrl(path, transform) {
|
|
2999
|
+
const baseUrl = `${this.fetch["baseUrl"]}/api/v1/storage/${this.bucketName}/${path}`;
|
|
3000
|
+
const queryString = this.buildTransformQuery(transform);
|
|
3001
|
+
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
3002
|
+
}
|
|
2786
3003
|
/**
|
|
2787
3004
|
* Create a signed URL for temporary access to a file
|
|
3005
|
+
* Optionally include image transformation parameters
|
|
3006
|
+
*
|
|
2788
3007
|
* @param path - The file path
|
|
2789
|
-
* @param options - Signed URL options
|
|
3008
|
+
* @param options - Signed URL options including expiration and transforms
|
|
3009
|
+
*
|
|
3010
|
+
* @example
|
|
3011
|
+
* ```typescript
|
|
3012
|
+
* // Simple signed URL (1 hour expiry)
|
|
3013
|
+
* const { data, error } = await storage.from('images').createSignedUrl('photo.jpg');
|
|
3014
|
+
*
|
|
3015
|
+
* // Signed URL with custom expiry
|
|
3016
|
+
* const { data, error } = await storage.from('images').createSignedUrl('photo.jpg', {
|
|
3017
|
+
* expiresIn: 7200 // 2 hours
|
|
3018
|
+
* });
|
|
3019
|
+
*
|
|
3020
|
+
* // Signed URL with image transformation
|
|
3021
|
+
* const { data, error } = await storage.from('images').createSignedUrl('photo.jpg', {
|
|
3022
|
+
* expiresIn: 3600,
|
|
3023
|
+
* transform: {
|
|
3024
|
+
* width: 400,
|
|
3025
|
+
* height: 300,
|
|
3026
|
+
* format: 'webp',
|
|
3027
|
+
* quality: 85,
|
|
3028
|
+
* fit: 'cover'
|
|
3029
|
+
* }
|
|
3030
|
+
* });
|
|
3031
|
+
* ```
|
|
2790
3032
|
*/
|
|
2791
3033
|
async createSignedUrl(path, options) {
|
|
2792
3034
|
try {
|
|
2793
3035
|
const expiresIn = options?.expiresIn || 3600;
|
|
3036
|
+
const requestBody = { expires_in: expiresIn };
|
|
3037
|
+
if (options?.transform) {
|
|
3038
|
+
const transform = options.transform;
|
|
3039
|
+
if (transform.width !== void 0 && transform.width > 0) {
|
|
3040
|
+
requestBody.width = transform.width;
|
|
3041
|
+
}
|
|
3042
|
+
if (transform.height !== void 0 && transform.height > 0) {
|
|
3043
|
+
requestBody.height = transform.height;
|
|
3044
|
+
}
|
|
3045
|
+
if (transform.format) {
|
|
3046
|
+
requestBody.format = transform.format;
|
|
3047
|
+
}
|
|
3048
|
+
if (transform.quality !== void 0 && transform.quality > 0) {
|
|
3049
|
+
requestBody.quality = transform.quality;
|
|
3050
|
+
}
|
|
3051
|
+
if (transform.fit) {
|
|
3052
|
+
requestBody.fit = transform.fit;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
2794
3055
|
const data = await this.fetch.post(
|
|
2795
3056
|
`/api/v1/storage/${this.bucketName}/sign/${path}`,
|
|
2796
|
-
|
|
3057
|
+
requestBody
|
|
2797
3058
|
);
|
|
2798
3059
|
return { data: { signedUrl: data.signed_url }, error: null };
|
|
2799
3060
|
} catch (error) {
|
|
@@ -9201,6 +9462,239 @@ var FluxbaseVector = class {
|
|
|
9201
9462
|
}
|
|
9202
9463
|
};
|
|
9203
9464
|
|
|
9465
|
+
// src/graphql.ts
|
|
9466
|
+
var FluxbaseGraphQL = class {
|
|
9467
|
+
/**
|
|
9468
|
+
* Create a new GraphQL client
|
|
9469
|
+
* @param fetch - The HTTP client to use for requests
|
|
9470
|
+
*/
|
|
9471
|
+
constructor(fetch2) {
|
|
9472
|
+
this.fetch = fetch2;
|
|
9473
|
+
}
|
|
9474
|
+
/**
|
|
9475
|
+
* Execute a GraphQL query
|
|
9476
|
+
*
|
|
9477
|
+
* @typeParam T - The expected response data type
|
|
9478
|
+
* @param query - The GraphQL query string
|
|
9479
|
+
* @param variables - Variables to pass to the query
|
|
9480
|
+
* @param options - Additional request options
|
|
9481
|
+
* @returns Promise resolving to the GraphQL response
|
|
9482
|
+
*
|
|
9483
|
+
* @example
|
|
9484
|
+
* ```typescript
|
|
9485
|
+
* interface UsersQuery {
|
|
9486
|
+
* users: Array<{ id: string; email: string }>
|
|
9487
|
+
* }
|
|
9488
|
+
*
|
|
9489
|
+
* const { data, errors } = await client.graphql.query<UsersQuery>(`
|
|
9490
|
+
* query {
|
|
9491
|
+
* users { id email }
|
|
9492
|
+
* }
|
|
9493
|
+
* `)
|
|
9494
|
+
*
|
|
9495
|
+
* if (data) {
|
|
9496
|
+
* console.log(data.users)
|
|
9497
|
+
* }
|
|
9498
|
+
* ```
|
|
9499
|
+
*/
|
|
9500
|
+
async query(query, variables, options) {
|
|
9501
|
+
return this.execute(query, variables, void 0, options);
|
|
9502
|
+
}
|
|
9503
|
+
/**
|
|
9504
|
+
* Execute a GraphQL mutation
|
|
9505
|
+
*
|
|
9506
|
+
* @typeParam T - The expected response data type
|
|
9507
|
+
* @param mutation - The GraphQL mutation string
|
|
9508
|
+
* @param variables - Variables to pass to the mutation
|
|
9509
|
+
* @param options - Additional request options
|
|
9510
|
+
* @returns Promise resolving to the GraphQL response
|
|
9511
|
+
*
|
|
9512
|
+
* @example
|
|
9513
|
+
* ```typescript
|
|
9514
|
+
* interface CreateUserMutation {
|
|
9515
|
+
* insertUser: { id: string; email: string }
|
|
9516
|
+
* }
|
|
9517
|
+
*
|
|
9518
|
+
* const { data, errors } = await client.graphql.mutation<CreateUserMutation>(`
|
|
9519
|
+
* mutation CreateUser($data: UserInput!) {
|
|
9520
|
+
* insertUser(data: $data) {
|
|
9521
|
+
* id
|
|
9522
|
+
* email
|
|
9523
|
+
* }
|
|
9524
|
+
* }
|
|
9525
|
+
* `, { data: { email: 'user@example.com' } })
|
|
9526
|
+
* ```
|
|
9527
|
+
*/
|
|
9528
|
+
async mutation(mutation, variables, options) {
|
|
9529
|
+
return this.execute(mutation, variables, void 0, options);
|
|
9530
|
+
}
|
|
9531
|
+
/**
|
|
9532
|
+
* Execute a GraphQL request with an operation name
|
|
9533
|
+
*
|
|
9534
|
+
* Use this when your query document contains multiple operations
|
|
9535
|
+
* and you need to specify which one to execute.
|
|
9536
|
+
*
|
|
9537
|
+
* @typeParam T - The expected response data type
|
|
9538
|
+
* @param query - The GraphQL document containing one or more operations
|
|
9539
|
+
* @param variables - Variables to pass to the operation
|
|
9540
|
+
* @param operationName - The name of the operation to execute
|
|
9541
|
+
* @param options - Additional request options
|
|
9542
|
+
* @returns Promise resolving to the GraphQL response
|
|
9543
|
+
*
|
|
9544
|
+
* @example
|
|
9545
|
+
* ```typescript
|
|
9546
|
+
* const { data } = await client.graphql.execute(`
|
|
9547
|
+
* query GetUser($id: ID!) {
|
|
9548
|
+
* user(id: $id) { id email }
|
|
9549
|
+
* }
|
|
9550
|
+
* query ListUsers {
|
|
9551
|
+
* users { id email }
|
|
9552
|
+
* }
|
|
9553
|
+
* `, { id: '123' }, 'GetUser')
|
|
9554
|
+
* ```
|
|
9555
|
+
*/
|
|
9556
|
+
async execute(query, variables, operationName, options) {
|
|
9557
|
+
const body = { query };
|
|
9558
|
+
if (variables && Object.keys(variables).length > 0) {
|
|
9559
|
+
body.variables = variables;
|
|
9560
|
+
}
|
|
9561
|
+
if (operationName) {
|
|
9562
|
+
body.operationName = operationName;
|
|
9563
|
+
}
|
|
9564
|
+
const headers = {
|
|
9565
|
+
"Content-Type": "application/json",
|
|
9566
|
+
...options?.headers
|
|
9567
|
+
};
|
|
9568
|
+
try {
|
|
9569
|
+
const response = await this.fetch.post(
|
|
9570
|
+
"/api/v1/graphql",
|
|
9571
|
+
body,
|
|
9572
|
+
{ headers }
|
|
9573
|
+
);
|
|
9574
|
+
return response || { errors: [{ message: "No response received" }] };
|
|
9575
|
+
} catch (err) {
|
|
9576
|
+
const message = err instanceof Error ? err.message : "GraphQL request failed";
|
|
9577
|
+
return {
|
|
9578
|
+
errors: [{ message }]
|
|
9579
|
+
};
|
|
9580
|
+
}
|
|
9581
|
+
}
|
|
9582
|
+
/**
|
|
9583
|
+
* Fetch the GraphQL schema via introspection
|
|
9584
|
+
*
|
|
9585
|
+
* Returns the full schema information including types, fields, and directives.
|
|
9586
|
+
* Useful for tooling and documentation.
|
|
9587
|
+
*
|
|
9588
|
+
* @param options - Additional request options
|
|
9589
|
+
* @returns Promise resolving to the introspection result
|
|
9590
|
+
*
|
|
9591
|
+
* @example
|
|
9592
|
+
* ```typescript
|
|
9593
|
+
* const { data, errors } = await client.graphql.introspect()
|
|
9594
|
+
*
|
|
9595
|
+
* if (data) {
|
|
9596
|
+
* console.log('Types:', data.__schema.types.length)
|
|
9597
|
+
* }
|
|
9598
|
+
* ```
|
|
9599
|
+
*/
|
|
9600
|
+
async introspect(options) {
|
|
9601
|
+
return this.query(INTROSPECTION_QUERY, void 0, options);
|
|
9602
|
+
}
|
|
9603
|
+
};
|
|
9604
|
+
var INTROSPECTION_QUERY = `
|
|
9605
|
+
query IntrospectionQuery {
|
|
9606
|
+
__schema {
|
|
9607
|
+
queryType { name }
|
|
9608
|
+
mutationType { name }
|
|
9609
|
+
subscriptionType { name }
|
|
9610
|
+
types {
|
|
9611
|
+
...FullType
|
|
9612
|
+
}
|
|
9613
|
+
directives {
|
|
9614
|
+
name
|
|
9615
|
+
description
|
|
9616
|
+
locations
|
|
9617
|
+
args {
|
|
9618
|
+
...InputValue
|
|
9619
|
+
}
|
|
9620
|
+
}
|
|
9621
|
+
}
|
|
9622
|
+
}
|
|
9623
|
+
|
|
9624
|
+
fragment FullType on __Type {
|
|
9625
|
+
kind
|
|
9626
|
+
name
|
|
9627
|
+
description
|
|
9628
|
+
fields(includeDeprecated: true) {
|
|
9629
|
+
name
|
|
9630
|
+
description
|
|
9631
|
+
args {
|
|
9632
|
+
...InputValue
|
|
9633
|
+
}
|
|
9634
|
+
type {
|
|
9635
|
+
...TypeRef
|
|
9636
|
+
}
|
|
9637
|
+
isDeprecated
|
|
9638
|
+
deprecationReason
|
|
9639
|
+
}
|
|
9640
|
+
inputFields {
|
|
9641
|
+
...InputValue
|
|
9642
|
+
}
|
|
9643
|
+
interfaces {
|
|
9644
|
+
...TypeRef
|
|
9645
|
+
}
|
|
9646
|
+
enumValues(includeDeprecated: true) {
|
|
9647
|
+
name
|
|
9648
|
+
description
|
|
9649
|
+
isDeprecated
|
|
9650
|
+
deprecationReason
|
|
9651
|
+
}
|
|
9652
|
+
possibleTypes {
|
|
9653
|
+
...TypeRef
|
|
9654
|
+
}
|
|
9655
|
+
}
|
|
9656
|
+
|
|
9657
|
+
fragment InputValue on __InputValue {
|
|
9658
|
+
name
|
|
9659
|
+
description
|
|
9660
|
+
type { ...TypeRef }
|
|
9661
|
+
defaultValue
|
|
9662
|
+
}
|
|
9663
|
+
|
|
9664
|
+
fragment TypeRef on __Type {
|
|
9665
|
+
kind
|
|
9666
|
+
name
|
|
9667
|
+
ofType {
|
|
9668
|
+
kind
|
|
9669
|
+
name
|
|
9670
|
+
ofType {
|
|
9671
|
+
kind
|
|
9672
|
+
name
|
|
9673
|
+
ofType {
|
|
9674
|
+
kind
|
|
9675
|
+
name
|
|
9676
|
+
ofType {
|
|
9677
|
+
kind
|
|
9678
|
+
name
|
|
9679
|
+
ofType {
|
|
9680
|
+
kind
|
|
9681
|
+
name
|
|
9682
|
+
ofType {
|
|
9683
|
+
kind
|
|
9684
|
+
name
|
|
9685
|
+
ofType {
|
|
9686
|
+
kind
|
|
9687
|
+
name
|
|
9688
|
+
}
|
|
9689
|
+
}
|
|
9690
|
+
}
|
|
9691
|
+
}
|
|
9692
|
+
}
|
|
9693
|
+
}
|
|
9694
|
+
}
|
|
9695
|
+
}
|
|
9696
|
+
`;
|
|
9697
|
+
|
|
9204
9698
|
// src/query-builder.ts
|
|
9205
9699
|
var URL_LENGTH_THRESHOLD = 4096;
|
|
9206
9700
|
var QueryBuilder = class {
|
|
@@ -10533,6 +11027,7 @@ var FluxbaseClient = class {
|
|
|
10533
11027
|
const wsBaseUrl = fluxbaseUrl.replace(/^https?:/, wsProtocol + ":");
|
|
10534
11028
|
this.ai = new FluxbaseAI(this.fetch, wsBaseUrl);
|
|
10535
11029
|
this.vector = new FluxbaseVector(this.fetch);
|
|
11030
|
+
this.graphql = new FluxbaseGraphQL(this.fetch);
|
|
10536
11031
|
const rpcInstance = new FluxbaseRPC(this.fetch);
|
|
10537
11032
|
const rpcCallable = async (fn, params) => {
|
|
10538
11033
|
const result = await rpcInstance.invoke(fn, params);
|
|
@@ -10779,6 +11274,6 @@ function assertType(value, validator, errorMessage = "Type assertion failed") {
|
|
|
10779
11274
|
}
|
|
10780
11275
|
}
|
|
10781
11276
|
|
|
10782
|
-
export { APIKeysManager, AppSettingsManager, AuthSettingsManager, DDLManager, EmailSettingsManager, EmailTemplateManager, ExecutionLogsChannel, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAdminStorage, FluxbaseAuth, FluxbaseClient, FluxbaseFetch, FluxbaseFunctions, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, FluxbaseVector, ImpersonationManager, InvitationsManager, OAuthProviderManager, QueryBuilder, RealtimeChannel, SchemaQueryBuilder, SettingsClient, StorageBucket, SystemSettingsManager, WebhooksManager, assertType, bundleCode, createClient, denoExternalPlugin, hasPostgrestError, isArray, isAuthError, isAuthSuccess, isBoolean, isFluxbaseError, isFluxbaseSuccess, isNumber, isObject, isPostgrestSuccess, isString, loadImportMap };
|
|
11277
|
+
export { APIKeysManager, AppSettingsManager, AuthSettingsManager, DDLManager, EmailSettingsManager, EmailTemplateManager, ExecutionLogsChannel, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAdminStorage, FluxbaseAuth, FluxbaseClient, FluxbaseFetch, FluxbaseFunctions, FluxbaseGraphQL, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, FluxbaseVector, ImpersonationManager, InvitationsManager, OAuthProviderManager, QueryBuilder, RealtimeChannel, SchemaQueryBuilder, SettingsClient, StorageBucket, SystemSettingsManager, WebhooksManager, assertType, bundleCode, createClient, denoExternalPlugin, hasPostgrestError, isArray, isAuthError, isAuthSuccess, isBoolean, isFluxbaseError, isFluxbaseSuccess, isNumber, isObject, isPostgrestSuccess, isString, loadImportMap };
|
|
10783
11278
|
//# sourceMappingURL=index.js.map
|
|
10784
11279
|
//# sourceMappingURL=index.js.map
|