Skip to content

Commit 64f3758

Browse files
committed
added pb.sql.run() and collection meta handlers
1 parent 0c45714 commit 64f3758

25 files changed

Lines changed: 456 additions & 45 deletions

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.27.0
2+
3+
- Added `pb.sql.run(query)` handler for the upcoming PocketBase v0.39.0 "SQL console" debug interface ([pocketbase#2236](https://github.com/pocketbase/pocketbase/issues/2236)).
4+
5+
- Added missing PocketBase v0.37+ collection meta endpoint handlers (`pb.collections.dryRunViewQuery(query)` and `pb.collections.getAllOAuth2Providers()`).
6+
7+
18
## 0.26.9
29

310
- Optimized realtime `subscribe`/`unsubscribe` calls to minimize async errors ([pocketbase#7684](https://github.com/pocketbase/pocketbase/issues/7684)).

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,12 @@ const result = await batch.send()
959959

960960
// Returns type indexed map with scaffolded collection models populated with their default field values.
961961
🔐 pb.collections.getScaffolds(options = {});
962+
963+
// Returns a list with all configurable OAuth2 providers.
964+
🔐 pb.collections.getAllOAuth2Providers(options = {});
965+
966+
// Tests the specified view query and returns a sample of the resulting records.
967+
🔐 pb.collections.dryRunViewQuery(query, options = {});
962968
```
963969
964970
---
@@ -1068,6 +1074,13 @@ pb.realtime.onDisconnect = function(activeSubscriptions)
10681074
🔐 pb.crons.run(jobId, options = {});
10691075
```
10701076
1077+
##### SQLService
1078+
1079+
```js
1080+
// Runs the specified raw SQL query.
1081+
🔐 pb.sql.run(query, options = {});
1082+
```
1083+
10711084
---
10721085
10731086
##### HealthService

dist/pocketbase.cjs.d.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,16 @@ interface OAuth2Provider {
8080
tokenURL: string;
8181
userInfoURL: string;
8282
displayName: string;
83+
logo: string;
8384
extra?: {
8485
[key: string]: any;
8586
};
8687
}
88+
interface ConfigurableOAuth2Provider {
89+
name: string;
90+
displayName: string;
91+
logo: string;
92+
}
8793
interface OAuth2Config {
8894
enabled: boolean;
8995
mappedFields: {
@@ -960,6 +966,12 @@ declare class CollectionService extends CrudService<CollectionModel> {
960966
* @throws {ClientResponseError}
961967
*/
962968
import(collections: Array<CollectionModel>, deleteMissing?: boolean, options?: CommonOptions): Promise<true>;
969+
/**
970+
* Deletes all records associated with the specified collection.
971+
*
972+
* @throws {ClientResponseError}
973+
*/
974+
truncate(collectionIdOrName: string, options?: CommonOptions): Promise<true>;
963975
/**
964976
* Returns type indexed map with scaffolded collection models
965977
* populated with their default field values.
@@ -970,11 +982,19 @@ declare class CollectionService extends CrudService<CollectionModel> {
970982
[key: string]: CollectionModel;
971983
}>;
972984
/**
973-
* Deletes all records associated with the specified collection.
985+
* Returns a list with all configurable OAuth2 providers.
974986
*
975987
* @throws {ClientResponseError}
976988
*/
977-
truncate(collectionIdOrName: string, options?: CommonOptions): Promise<true>;
989+
getAllOAuth2Providers(options?: CommonOptions): Promise<Array<ConfigurableOAuth2Provider>>;
990+
/**
991+
* Executes the specified view query and returns a sample of the resulting records.
992+
*
993+
* @throws {ClientResponseError}
994+
*/
995+
dryRunViewQuery(query: string, options?: CommonOptions): Promise<Array<{
996+
[key: string]: any;
997+
}>>;
978998
}
979999
interface HourlyStats {
9801000
total: number;
@@ -1113,6 +1133,25 @@ declare class CronService extends BaseService {
11131133
*/
11141134
run(jobId: string, options?: CommonOptions): Promise<boolean>;
11151135
}
1136+
interface SQLResult {
1137+
execTime: number;
1138+
affectedRows: number;
1139+
columns: Array<{
1140+
name: string;
1141+
type: string;
1142+
nullable: boolean;
1143+
}>;
1144+
rows: Array<Array<string | null>>;
1145+
}
1146+
declare class SQLService extends BaseService {
1147+
/**
1148+
* Executes the specified raw SQL query.
1149+
* This operation is allowed only for superusers.
1150+
*
1151+
* @throws {ClientResponseError}
1152+
*/
1153+
run(query: string, options?: CommonOptions): Promise<SQLResult>;
1154+
}
11161155
interface BatchRequest {
11171156
method: string;
11181157
url: string;
@@ -1290,6 +1329,10 @@ declare class Client {
12901329
* An instance of the service that handles the **Cron APIs**.
12911330
*/
12921331
readonly crons: CronService;
1332+
/**
1333+
* An instance of the service that handles the **SQL APIs**.
1334+
*/
1335+
readonly sql: SQLService;
12931336
private cancelControllers;
12941337
private recordServices;
12951338
private enableAutoCancellation;

dist/pocketbase.cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.es.d.mts

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ interface OAuth2Provider {
101101
tokenURL: string;
102102
userInfoURL: string;
103103
displayName: string;
104+
logo: string;
104105
extra?: {
105106
[key: string]: any;
106107
};
107108
}
109+
interface ConfigurableOAuth2Provider {
110+
name: string;
111+
displayName: string;
112+
logo: string;
113+
}
108114
interface OAuth2Config {
109115
enabled: boolean;
110116
mappedFields: {
@@ -1003,6 +1009,12 @@ declare class CollectionService extends CrudService<CollectionModel> {
10031009
* @throws {ClientResponseError}
10041010
*/
10051011
import(collections: Array<CollectionModel>, deleteMissing?: boolean, options?: CommonOptions): Promise<true>;
1012+
/**
1013+
* Deletes all records associated with the specified collection.
1014+
*
1015+
* @throws {ClientResponseError}
1016+
*/
1017+
truncate(collectionIdOrName: string, options?: CommonOptions): Promise<true>;
10061018
/**
10071019
* Returns type indexed map with scaffolded collection models
10081020
* populated with their default field values.
@@ -1013,11 +1025,19 @@ declare class CollectionService extends CrudService<CollectionModel> {
10131025
[key: string]: CollectionModel;
10141026
}>;
10151027
/**
1016-
* Deletes all records associated with the specified collection.
1028+
* Returns a list with all configurable OAuth2 providers.
10171029
*
10181030
* @throws {ClientResponseError}
10191031
*/
1020-
truncate(collectionIdOrName: string, options?: CommonOptions): Promise<true>;
1032+
getAllOAuth2Providers(options?: CommonOptions): Promise<Array<ConfigurableOAuth2Provider>>;
1033+
/**
1034+
* Executes the specified view query and returns a sample of the resulting records.
1035+
*
1036+
* @throws {ClientResponseError}
1037+
*/
1038+
dryRunViewQuery(query: string, options?: CommonOptions): Promise<Array<{
1039+
[key: string]: any;
1040+
}>>;
10211041
}
10221042
interface HourlyStats {
10231043
total: number;
@@ -1156,6 +1176,25 @@ declare class CronService extends BaseService {
11561176
*/
11571177
run(jobId: string, options?: CommonOptions): Promise<boolean>;
11581178
}
1179+
interface SQLResult {
1180+
execTime: number;
1181+
affectedRows: number;
1182+
columns: Array<{
1183+
name: string;
1184+
type: string;
1185+
nullable: boolean;
1186+
}>;
1187+
rows: Array<Array<string | null>>;
1188+
}
1189+
declare class SQLService extends BaseService {
1190+
/**
1191+
* Executes the specified raw SQL query.
1192+
* This operation is allowed only for superusers.
1193+
*
1194+
* @throws {ClientResponseError}
1195+
*/
1196+
run(query: string, options?: CommonOptions): Promise<SQLResult>;
1197+
}
11591198
interface BatchRequest {
11601199
method: string;
11611200
url: string;
@@ -1333,6 +1372,10 @@ declare class Client {
13331372
* An instance of the service that handles the **Cron APIs**.
13341373
*/
13351374
readonly crons: CronService;
1375+
/**
1376+
* An instance of the service that handles the **SQL APIs**.
1377+
*/
1378+
readonly sql: SQLService;
13361379
private cancelControllers;
13371380
private recordServices;
13381381
private enableAutoCancellation;
@@ -1584,4 +1627,4 @@ declare function getTokenPayload(token: string): {
15841627
* @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.
15851628
*/
15861629
declare function isTokenExpired(token: string, expirationThreshold?: number): boolean;
1587-
export { Client as default, BeforeSendResult, ClientResponseError, CollectionService, HealthCheckResponse, HealthService, HourlyStats, LogService, UnsubscribeFunc, RealtimeService, RecordAuthResponse, AuthProviderInfo, AuthMethodsList, RecordSubscription, OAuth2UrlCallback, OAuth2AuthConfig, OTPResponse, RecordService, CrudService, BatchRequest, BatchRequestResult, BatchService, SubBatchService, AsyncSaveFunc, AsyncClearFunc, AsyncAuthStore, AuthRecord, AuthModel, OnStoreChangeFunc, BaseAuthStore, LocalAuthStore, ListResult, BaseModel, LogModel, RecordModel, CollectionField, TokenConfig, AuthAlertConfig, OTPConfig, MFAConfig, PasswordAuthConfig, OAuth2Provider, OAuth2Config, EmailTemplate, BaseCollectionModel, ViewCollectionModel, AuthCollectionModel, CollectionModel, SendOptions, CommonOptions, ListOptions, FullListOptions, RecordOptions, RecordListOptions, RecordFullListOptions, RecordSubscribeOptions, LogStatsOptions, FileOptions, AuthOptions, normalizeUnknownQueryParams, serializeQueryParams, ParseOptions, cookieParse, SerializeOptions, cookieSerialize, getTokenPayload, isTokenExpired };
1630+
export { Client as default, BeforeSendResult, ClientResponseError, CollectionService, HealthCheckResponse, HealthService, HourlyStats, LogService, UnsubscribeFunc, RealtimeService, RecordAuthResponse, AuthProviderInfo, AuthMethodsList, RecordSubscription, OAuth2UrlCallback, OAuth2AuthConfig, OTPResponse, RecordService, CrudService, BatchRequest, BatchRequestResult, BatchService, SubBatchService, AsyncSaveFunc, AsyncClearFunc, AsyncAuthStore, AuthRecord, AuthModel, OnStoreChangeFunc, BaseAuthStore, LocalAuthStore, ListResult, BaseModel, LogModel, RecordModel, CollectionField, TokenConfig, AuthAlertConfig, OTPConfig, MFAConfig, PasswordAuthConfig, OAuth2Provider, ConfigurableOAuth2Provider, OAuth2Config, EmailTemplate, BaseCollectionModel, ViewCollectionModel, AuthCollectionModel, CollectionModel, SendOptions, CommonOptions, ListOptions, FullListOptions, RecordOptions, RecordListOptions, RecordFullListOptions, RecordSubscribeOptions, LogStatsOptions, FileOptions, AuthOptions, normalizeUnknownQueryParams, serializeQueryParams, ParseOptions, cookieParse, SerializeOptions, cookieSerialize, getTokenPayload, isTokenExpired };

dist/pocketbase.es.d.ts

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ interface OAuth2Provider {
101101
tokenURL: string;
102102
userInfoURL: string;
103103
displayName: string;
104+
logo: string;
104105
extra?: {
105106
[key: string]: any;
106107
};
107108
}
109+
interface ConfigurableOAuth2Provider {
110+
name: string;
111+
displayName: string;
112+
logo: string;
113+
}
108114
interface OAuth2Config {
109115
enabled: boolean;
110116
mappedFields: {
@@ -1003,6 +1009,12 @@ declare class CollectionService extends CrudService<CollectionModel> {
10031009
* @throws {ClientResponseError}
10041010
*/
10051011
import(collections: Array<CollectionModel>, deleteMissing?: boolean, options?: CommonOptions): Promise<true>;
1012+
/**
1013+
* Deletes all records associated with the specified collection.
1014+
*
1015+
* @throws {ClientResponseError}
1016+
*/
1017+
truncate(collectionIdOrName: string, options?: CommonOptions): Promise<true>;
10061018
/**
10071019
* Returns type indexed map with scaffolded collection models
10081020
* populated with their default field values.
@@ -1013,11 +1025,19 @@ declare class CollectionService extends CrudService<CollectionModel> {
10131025
[key: string]: CollectionModel;
10141026
}>;
10151027
/**
1016-
* Deletes all records associated with the specified collection.
1028+
* Returns a list with all configurable OAuth2 providers.
10171029
*
10181030
* @throws {ClientResponseError}
10191031
*/
1020-
truncate(collectionIdOrName: string, options?: CommonOptions): Promise<true>;
1032+
getAllOAuth2Providers(options?: CommonOptions): Promise<Array<ConfigurableOAuth2Provider>>;
1033+
/**
1034+
* Executes the specified view query and returns a sample of the resulting records.
1035+
*
1036+
* @throws {ClientResponseError}
1037+
*/
1038+
dryRunViewQuery(query: string, options?: CommonOptions): Promise<Array<{
1039+
[key: string]: any;
1040+
}>>;
10211041
}
10221042
interface HourlyStats {
10231043
total: number;
@@ -1156,6 +1176,25 @@ declare class CronService extends BaseService {
11561176
*/
11571177
run(jobId: string, options?: CommonOptions): Promise<boolean>;
11581178
}
1179+
interface SQLResult {
1180+
execTime: number;
1181+
affectedRows: number;
1182+
columns: Array<{
1183+
name: string;
1184+
type: string;
1185+
nullable: boolean;
1186+
}>;
1187+
rows: Array<Array<string | null>>;
1188+
}
1189+
declare class SQLService extends BaseService {
1190+
/**
1191+
* Executes the specified raw SQL query.
1192+
* This operation is allowed only for superusers.
1193+
*
1194+
* @throws {ClientResponseError}
1195+
*/
1196+
run(query: string, options?: CommonOptions): Promise<SQLResult>;
1197+
}
11591198
interface BatchRequest {
11601199
method: string;
11611200
url: string;
@@ -1333,6 +1372,10 @@ declare class Client {
13331372
* An instance of the service that handles the **Cron APIs**.
13341373
*/
13351374
readonly crons: CronService;
1375+
/**
1376+
* An instance of the service that handles the **SQL APIs**.
1377+
*/
1378+
readonly sql: SQLService;
13361379
private cancelControllers;
13371380
private recordServices;
13381381
private enableAutoCancellation;
@@ -1584,4 +1627,4 @@ declare function getTokenPayload(token: string): {
15841627
* @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.
15851628
*/
15861629
declare function isTokenExpired(token: string, expirationThreshold?: number): boolean;
1587-
export { Client as default, BeforeSendResult, ClientResponseError, CollectionService, HealthCheckResponse, HealthService, HourlyStats, LogService, UnsubscribeFunc, RealtimeService, RecordAuthResponse, AuthProviderInfo, AuthMethodsList, RecordSubscription, OAuth2UrlCallback, OAuth2AuthConfig, OTPResponse, RecordService, CrudService, BatchRequest, BatchRequestResult, BatchService, SubBatchService, AsyncSaveFunc, AsyncClearFunc, AsyncAuthStore, AuthRecord, AuthModel, OnStoreChangeFunc, BaseAuthStore, LocalAuthStore, ListResult, BaseModel, LogModel, RecordModel, CollectionField, TokenConfig, AuthAlertConfig, OTPConfig, MFAConfig, PasswordAuthConfig, OAuth2Provider, OAuth2Config, EmailTemplate, BaseCollectionModel, ViewCollectionModel, AuthCollectionModel, CollectionModel, SendOptions, CommonOptions, ListOptions, FullListOptions, RecordOptions, RecordListOptions, RecordFullListOptions, RecordSubscribeOptions, LogStatsOptions, FileOptions, AuthOptions, normalizeUnknownQueryParams, serializeQueryParams, ParseOptions, cookieParse, SerializeOptions, cookieSerialize, getTokenPayload, isTokenExpired };
1630+
export { Client as default, BeforeSendResult, ClientResponseError, CollectionService, HealthCheckResponse, HealthService, HourlyStats, LogService, UnsubscribeFunc, RealtimeService, RecordAuthResponse, AuthProviderInfo, AuthMethodsList, RecordSubscription, OAuth2UrlCallback, OAuth2AuthConfig, OTPResponse, RecordService, CrudService, BatchRequest, BatchRequestResult, BatchService, SubBatchService, AsyncSaveFunc, AsyncClearFunc, AsyncAuthStore, AuthRecord, AuthModel, OnStoreChangeFunc, BaseAuthStore, LocalAuthStore, ListResult, BaseModel, LogModel, RecordModel, CollectionField, TokenConfig, AuthAlertConfig, OTPConfig, MFAConfig, PasswordAuthConfig, OAuth2Provider, ConfigurableOAuth2Provider, OAuth2Config, EmailTemplate, BaseCollectionModel, ViewCollectionModel, AuthCollectionModel, CollectionModel, SendOptions, CommonOptions, ListOptions, FullListOptions, RecordOptions, RecordListOptions, RecordFullListOptions, RecordSubscribeOptions, LogStatsOptions, FileOptions, AuthOptions, normalizeUnknownQueryParams, serializeQueryParams, ParseOptions, cookieParse, SerializeOptions, cookieSerialize, getTokenPayload, isTokenExpired };

dist/pocketbase.es.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.es.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)