@giaeulate/baas-sdk 1.0.10 → 1.1.0
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 +77 -4
- package/dist/index.d.cts +68 -3
- package/dist/index.d.ts +68 -3
- package/dist/index.js +77 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -430,6 +430,9 @@ function createDatabaseModule(client) {
|
|
|
430
430
|
async getSchema(name) {
|
|
431
431
|
return get(`/api/schemas/${name}`);
|
|
432
432
|
},
|
|
433
|
+
async saveSchemas(data) {
|
|
434
|
+
return post("/api/schemas", data);
|
|
435
|
+
},
|
|
433
436
|
// Tables
|
|
434
437
|
async createTable(tableName, definition) {
|
|
435
438
|
return post("/api/schemas/tables", { table_name: tableName, definition });
|
|
@@ -657,17 +660,23 @@ function createFunctionsModule(client) {
|
|
|
657
660
|
async invoke(id, data = {}) {
|
|
658
661
|
return post(`/api/functions/${id}/execute`, data);
|
|
659
662
|
},
|
|
663
|
+
async get(id) {
|
|
664
|
+
return get(`/api/functions/${id}`);
|
|
665
|
+
},
|
|
660
666
|
async list() {
|
|
661
667
|
return get("/api/functions");
|
|
662
668
|
},
|
|
663
|
-
async create(name, code) {
|
|
664
|
-
return post("/api/functions", { name, code });
|
|
669
|
+
async create(name, code, options) {
|
|
670
|
+
return post("/api/functions", { name, code, ...options });
|
|
665
671
|
},
|
|
666
672
|
async delete(id) {
|
|
667
673
|
return del(`/api/functions/${id}`);
|
|
668
674
|
},
|
|
669
|
-
async update(id, code) {
|
|
670
|
-
return put(`/api/functions/${id}`, { code });
|
|
675
|
+
async update(id, code, options) {
|
|
676
|
+
return put(`/api/functions/${id}`, { code, ...options });
|
|
677
|
+
},
|
|
678
|
+
async executeCode(code, options) {
|
|
679
|
+
return post("/api/functions/execute", { code, ...options });
|
|
671
680
|
},
|
|
672
681
|
async listHooks() {
|
|
673
682
|
return get("/api/hooks");
|
|
@@ -803,11 +812,15 @@ function createSearchModule(client) {
|
|
|
803
812
|
|
|
804
813
|
// src/modules/graphql.ts
|
|
805
814
|
function createGraphQLModule(client) {
|
|
815
|
+
const get = (endpoint) => client.get(endpoint);
|
|
806
816
|
const post = (endpoint, body) => client.post(endpoint, body);
|
|
807
817
|
return {
|
|
808
818
|
async query(query, variables) {
|
|
809
819
|
return post("/api/graphql", { query, variables });
|
|
810
820
|
},
|
|
821
|
+
async getSchema() {
|
|
822
|
+
return get("/api/graphql/schema");
|
|
823
|
+
},
|
|
811
824
|
getPlaygroundUrl() {
|
|
812
825
|
return `${client.url}/api/graphql/playground`;
|
|
813
826
|
}
|
|
@@ -1171,6 +1184,42 @@ function createCorsOriginsModule(client) {
|
|
|
1171
1184
|
};
|
|
1172
1185
|
}
|
|
1173
1186
|
|
|
1187
|
+
// src/modules/policies.ts
|
|
1188
|
+
function createPoliciesModule(client) {
|
|
1189
|
+
const get = (endpoint) => client.get(endpoint);
|
|
1190
|
+
const post = (endpoint, body) => client.post(endpoint, body);
|
|
1191
|
+
const del = (endpoint) => client.delete(endpoint);
|
|
1192
|
+
return {
|
|
1193
|
+
async create(input) {
|
|
1194
|
+
return post("/api/policies", input);
|
|
1195
|
+
},
|
|
1196
|
+
async list() {
|
|
1197
|
+
return get("/api/policies");
|
|
1198
|
+
},
|
|
1199
|
+
async delete(id) {
|
|
1200
|
+
return del(`/api/policies/${id}`);
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// src/modules/ip-whitelist.ts
|
|
1206
|
+
function createIPWhitelistModule(client) {
|
|
1207
|
+
const get = (endpoint) => client.get(endpoint);
|
|
1208
|
+
const post = (endpoint, body) => client.post(endpoint, body);
|
|
1209
|
+
const del = (endpoint) => client.delete(endpoint);
|
|
1210
|
+
return {
|
|
1211
|
+
async list() {
|
|
1212
|
+
return get("/api/ip-whitelist");
|
|
1213
|
+
},
|
|
1214
|
+
async create(ipAddress, description) {
|
|
1215
|
+
return post("/api/ip-whitelist", { ip_address: ipAddress, description: description || "" });
|
|
1216
|
+
},
|
|
1217
|
+
async delete(id) {
|
|
1218
|
+
return del(`/api/ip-whitelist/${id}`);
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1174
1223
|
// src/client.ts
|
|
1175
1224
|
var BaasClient = class extends HttpClient {
|
|
1176
1225
|
// Feature modules
|
|
@@ -1195,6 +1244,8 @@ var BaasClient = class extends HttpClient {
|
|
|
1195
1244
|
apiKeys;
|
|
1196
1245
|
environments;
|
|
1197
1246
|
corsOrigins;
|
|
1247
|
+
policies;
|
|
1248
|
+
ipWhitelist;
|
|
1198
1249
|
constructor(url, apiKey) {
|
|
1199
1250
|
super(url, apiKey);
|
|
1200
1251
|
this.auth = createAuthModule(this);
|
|
@@ -1218,6 +1269,8 @@ var BaasClient = class extends HttpClient {
|
|
|
1218
1269
|
this.apiKeys = createApiKeysModule(this);
|
|
1219
1270
|
this.environments = createEnvironmentsModule(this);
|
|
1220
1271
|
this.corsOrigins = createCorsOriginsModule(this);
|
|
1272
|
+
this.policies = createPoliciesModule(this);
|
|
1273
|
+
this.ipWhitelist = createIPWhitelistModule(this);
|
|
1221
1274
|
}
|
|
1222
1275
|
/**
|
|
1223
1276
|
* Create a query builder for fluent data queries
|
|
@@ -1619,6 +1672,26 @@ var BaasClient = class extends HttpClient {
|
|
|
1619
1672
|
async deleteCorsOrigin(id) {
|
|
1620
1673
|
return this.corsOrigins.delete(id);
|
|
1621
1674
|
}
|
|
1675
|
+
// Policies shortcuts
|
|
1676
|
+
async listPolicies() {
|
|
1677
|
+
return this.policies.list();
|
|
1678
|
+
}
|
|
1679
|
+
async createPolicy(input) {
|
|
1680
|
+
return this.policies.create(input);
|
|
1681
|
+
}
|
|
1682
|
+
async deletePolicy(id) {
|
|
1683
|
+
return this.policies.delete(id);
|
|
1684
|
+
}
|
|
1685
|
+
// IP Whitelist shortcuts
|
|
1686
|
+
async listIPWhitelist() {
|
|
1687
|
+
return this.ipWhitelist.list();
|
|
1688
|
+
}
|
|
1689
|
+
async addIPWhitelistEntry(ipAddress, description) {
|
|
1690
|
+
return this.ipWhitelist.create(ipAddress, description);
|
|
1691
|
+
}
|
|
1692
|
+
async deleteIPWhitelistEntry(id) {
|
|
1693
|
+
return this.ipWhitelist.delete(id);
|
|
1694
|
+
}
|
|
1622
1695
|
};
|
|
1623
1696
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1624
1697
|
0 && (module.exports = {
|
package/dist/index.d.cts
CHANGED
|
@@ -234,6 +234,10 @@ interface DatabaseModule {
|
|
|
234
234
|
offset?: number;
|
|
235
235
|
}): Promise<any>;
|
|
236
236
|
getSchema(name: string): Promise<any>;
|
|
237
|
+
saveSchemas(data: {
|
|
238
|
+
table_name: string;
|
|
239
|
+
definition: any;
|
|
240
|
+
}): Promise<any>;
|
|
237
241
|
createTable(tableName: string, definition: Record<string, string | {
|
|
238
242
|
type: string;
|
|
239
243
|
nullable?: boolean;
|
|
@@ -366,10 +370,22 @@ interface MigrationsModule {
|
|
|
366
370
|
|
|
367
371
|
interface FunctionsModule {
|
|
368
372
|
invoke(id: string, data?: any): Promise<any>;
|
|
373
|
+
get(id: string): Promise<any>;
|
|
369
374
|
list(): Promise<any>;
|
|
370
|
-
create(name: string, code: string
|
|
375
|
+
create(name: string, code: string, options?: {
|
|
376
|
+
runtime?: 'wazero' | 'deno';
|
|
377
|
+
timeout_ms?: number;
|
|
378
|
+
}): Promise<any>;
|
|
371
379
|
delete(id: string): Promise<any>;
|
|
372
|
-
update(id: string, code: string
|
|
380
|
+
update(id: string, code: string, options?: {
|
|
381
|
+
runtime?: 'wazero' | 'deno';
|
|
382
|
+
timeout_ms?: number;
|
|
383
|
+
}): Promise<any>;
|
|
384
|
+
executeCode(code: string, options?: {
|
|
385
|
+
data?: any;
|
|
386
|
+
runtime?: 'wazero' | 'deno';
|
|
387
|
+
timeout_ms?: number;
|
|
388
|
+
}): Promise<any>;
|
|
373
389
|
listHooks(): Promise<any>;
|
|
374
390
|
createHook(data: {
|
|
375
391
|
event_type: string;
|
|
@@ -493,6 +509,7 @@ interface SearchModule {
|
|
|
493
509
|
|
|
494
510
|
interface GraphQLModule {
|
|
495
511
|
query(query: string, variables?: Record<string, any>): Promise<any>;
|
|
512
|
+
getSchema(): Promise<any>;
|
|
496
513
|
getPlaygroundUrl(): string;
|
|
497
514
|
}
|
|
498
515
|
|
|
@@ -654,6 +671,46 @@ interface CorsOriginsModule {
|
|
|
654
671
|
delete(id: string): Promise<any>;
|
|
655
672
|
}
|
|
656
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Policies Module - Row-Level Security policy management
|
|
676
|
+
*/
|
|
677
|
+
|
|
678
|
+
interface Policy {
|
|
679
|
+
id: string;
|
|
680
|
+
table_name: string;
|
|
681
|
+
action: 'select' | 'insert' | 'update' | 'delete';
|
|
682
|
+
role: string;
|
|
683
|
+
condition: string;
|
|
684
|
+
created_at?: string;
|
|
685
|
+
}
|
|
686
|
+
interface CreatePolicyInput {
|
|
687
|
+
table_name: string;
|
|
688
|
+
action: 'select' | 'insert' | 'update' | 'delete';
|
|
689
|
+
role: string;
|
|
690
|
+
condition: string;
|
|
691
|
+
}
|
|
692
|
+
interface PoliciesModule {
|
|
693
|
+
create(input: CreatePolicyInput): Promise<Policy>;
|
|
694
|
+
list(): Promise<Policy[]>;
|
|
695
|
+
delete(id: string): Promise<any>;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* IP Whitelist Module - IP-based access control
|
|
700
|
+
*/
|
|
701
|
+
|
|
702
|
+
interface IPWhitelistEntry {
|
|
703
|
+
id: string;
|
|
704
|
+
ip_address: string;
|
|
705
|
+
description: string;
|
|
706
|
+
created_at?: string;
|
|
707
|
+
}
|
|
708
|
+
interface IPWhitelistModule {
|
|
709
|
+
list(): Promise<IPWhitelistEntry[]>;
|
|
710
|
+
create(ipAddress: string, description?: string): Promise<IPWhitelistEntry>;
|
|
711
|
+
delete(id: string): Promise<any>;
|
|
712
|
+
}
|
|
713
|
+
|
|
657
714
|
/**
|
|
658
715
|
* Main BaaS Client - Composes all feature modules
|
|
659
716
|
*
|
|
@@ -693,6 +750,8 @@ declare class BaasClient extends HttpClient {
|
|
|
693
750
|
readonly apiKeys: ApiKeysModule;
|
|
694
751
|
readonly environments: EnvironmentsModule;
|
|
695
752
|
readonly corsOrigins: CorsOriginsModule;
|
|
753
|
+
readonly policies: PoliciesModule;
|
|
754
|
+
readonly ipWhitelist: IPWhitelistModule;
|
|
696
755
|
constructor(url?: string, apiKey?: string);
|
|
697
756
|
/**
|
|
698
757
|
* Create a query builder for fluent data queries
|
|
@@ -821,6 +880,12 @@ declare class BaasClient extends HttpClient {
|
|
|
821
880
|
listCorsOrigins(): Promise<any>;
|
|
822
881
|
addCorsOrigin(origin: string, description?: string): Promise<any>;
|
|
823
882
|
deleteCorsOrigin(id: string): Promise<any>;
|
|
883
|
+
listPolicies(): Promise<Policy[]>;
|
|
884
|
+
createPolicy(input: any): Promise<Policy>;
|
|
885
|
+
deletePolicy(id: string): Promise<any>;
|
|
886
|
+
listIPWhitelist(): Promise<IPWhitelistEntry[]>;
|
|
887
|
+
addIPWhitelistEntry(ipAddress: string, description?: string): Promise<IPWhitelistEntry>;
|
|
888
|
+
deleteIPWhitelistEntry(id: string): Promise<any>;
|
|
824
889
|
}
|
|
825
890
|
|
|
826
|
-
export { type ApiKeysModule, type ApiResponse, type ApplicationLogsOptions, type AuditLogsOptions, type AuditModule, type AuthModule, BaasClient, type BackupsModule, type BranchesModule, type CorsOriginsModule, type DatabaseModule, type EmailConfig, type EmailModule, type EmailTemplate, type EnvVarsModule, type FunctionsModule, type GraphQLModule, HttpClient, type HttpMethod, type JobInput, type JobUpdateInput, type JobsModule, type LogDrainInput, type LogDrainUpdateInput, type LogDrainsModule, type MetricsModule, type MigrationsModule, type PaginationOptions, QueryBuilder, type QueryFilter, type RealtimeModule, type RequestLogsOptions, type RequestOptions, type SearchModule, type SearchOptions, type SendEmailInput, type StorageBucket, type StorageFile, type StorageFileWithUrl, type StorageModule, type Subscription, type TimeseriesOptions, type UsersModule, type WebhookInput, type WebhookUpdateInput, type WebhooksModule };
|
|
891
|
+
export { type ApiKeysModule, type ApiResponse, type ApplicationLogsOptions, type AuditLogsOptions, type AuditModule, type AuthModule, BaasClient, type BackupsModule, type BranchesModule, type CorsOriginsModule, type CreatePolicyInput, type DatabaseModule, type EmailConfig, type EmailModule, type EmailTemplate, type EnvVarsModule, type EnvironmentsModule, type FunctionsModule, type GraphQLModule, HttpClient, type HttpMethod, type IPWhitelistEntry, type IPWhitelistModule, type JobInput, type JobUpdateInput, type JobsModule, type LogDrainInput, type LogDrainUpdateInput, type LogDrainsModule, type MetricsModule, type MigrationsModule, type PaginationOptions, type PoliciesModule, type Policy, QueryBuilder, type QueryFilter, type RealtimeModule, type RequestLogsOptions, type RequestOptions, type SearchModule, type SearchOptions, type SendEmailInput, type StorageBucket, type StorageFile, type StorageFileWithUrl, type StorageModule, type Subscription, type TimeseriesOptions, type UsersModule, type WebhookInput, type WebhookUpdateInput, type WebhooksModule };
|
package/dist/index.d.ts
CHANGED
|
@@ -234,6 +234,10 @@ interface DatabaseModule {
|
|
|
234
234
|
offset?: number;
|
|
235
235
|
}): Promise<any>;
|
|
236
236
|
getSchema(name: string): Promise<any>;
|
|
237
|
+
saveSchemas(data: {
|
|
238
|
+
table_name: string;
|
|
239
|
+
definition: any;
|
|
240
|
+
}): Promise<any>;
|
|
237
241
|
createTable(tableName: string, definition: Record<string, string | {
|
|
238
242
|
type: string;
|
|
239
243
|
nullable?: boolean;
|
|
@@ -366,10 +370,22 @@ interface MigrationsModule {
|
|
|
366
370
|
|
|
367
371
|
interface FunctionsModule {
|
|
368
372
|
invoke(id: string, data?: any): Promise<any>;
|
|
373
|
+
get(id: string): Promise<any>;
|
|
369
374
|
list(): Promise<any>;
|
|
370
|
-
create(name: string, code: string
|
|
375
|
+
create(name: string, code: string, options?: {
|
|
376
|
+
runtime?: 'wazero' | 'deno';
|
|
377
|
+
timeout_ms?: number;
|
|
378
|
+
}): Promise<any>;
|
|
371
379
|
delete(id: string): Promise<any>;
|
|
372
|
-
update(id: string, code: string
|
|
380
|
+
update(id: string, code: string, options?: {
|
|
381
|
+
runtime?: 'wazero' | 'deno';
|
|
382
|
+
timeout_ms?: number;
|
|
383
|
+
}): Promise<any>;
|
|
384
|
+
executeCode(code: string, options?: {
|
|
385
|
+
data?: any;
|
|
386
|
+
runtime?: 'wazero' | 'deno';
|
|
387
|
+
timeout_ms?: number;
|
|
388
|
+
}): Promise<any>;
|
|
373
389
|
listHooks(): Promise<any>;
|
|
374
390
|
createHook(data: {
|
|
375
391
|
event_type: string;
|
|
@@ -493,6 +509,7 @@ interface SearchModule {
|
|
|
493
509
|
|
|
494
510
|
interface GraphQLModule {
|
|
495
511
|
query(query: string, variables?: Record<string, any>): Promise<any>;
|
|
512
|
+
getSchema(): Promise<any>;
|
|
496
513
|
getPlaygroundUrl(): string;
|
|
497
514
|
}
|
|
498
515
|
|
|
@@ -654,6 +671,46 @@ interface CorsOriginsModule {
|
|
|
654
671
|
delete(id: string): Promise<any>;
|
|
655
672
|
}
|
|
656
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Policies Module - Row-Level Security policy management
|
|
676
|
+
*/
|
|
677
|
+
|
|
678
|
+
interface Policy {
|
|
679
|
+
id: string;
|
|
680
|
+
table_name: string;
|
|
681
|
+
action: 'select' | 'insert' | 'update' | 'delete';
|
|
682
|
+
role: string;
|
|
683
|
+
condition: string;
|
|
684
|
+
created_at?: string;
|
|
685
|
+
}
|
|
686
|
+
interface CreatePolicyInput {
|
|
687
|
+
table_name: string;
|
|
688
|
+
action: 'select' | 'insert' | 'update' | 'delete';
|
|
689
|
+
role: string;
|
|
690
|
+
condition: string;
|
|
691
|
+
}
|
|
692
|
+
interface PoliciesModule {
|
|
693
|
+
create(input: CreatePolicyInput): Promise<Policy>;
|
|
694
|
+
list(): Promise<Policy[]>;
|
|
695
|
+
delete(id: string): Promise<any>;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* IP Whitelist Module - IP-based access control
|
|
700
|
+
*/
|
|
701
|
+
|
|
702
|
+
interface IPWhitelistEntry {
|
|
703
|
+
id: string;
|
|
704
|
+
ip_address: string;
|
|
705
|
+
description: string;
|
|
706
|
+
created_at?: string;
|
|
707
|
+
}
|
|
708
|
+
interface IPWhitelistModule {
|
|
709
|
+
list(): Promise<IPWhitelistEntry[]>;
|
|
710
|
+
create(ipAddress: string, description?: string): Promise<IPWhitelistEntry>;
|
|
711
|
+
delete(id: string): Promise<any>;
|
|
712
|
+
}
|
|
713
|
+
|
|
657
714
|
/**
|
|
658
715
|
* Main BaaS Client - Composes all feature modules
|
|
659
716
|
*
|
|
@@ -693,6 +750,8 @@ declare class BaasClient extends HttpClient {
|
|
|
693
750
|
readonly apiKeys: ApiKeysModule;
|
|
694
751
|
readonly environments: EnvironmentsModule;
|
|
695
752
|
readonly corsOrigins: CorsOriginsModule;
|
|
753
|
+
readonly policies: PoliciesModule;
|
|
754
|
+
readonly ipWhitelist: IPWhitelistModule;
|
|
696
755
|
constructor(url?: string, apiKey?: string);
|
|
697
756
|
/**
|
|
698
757
|
* Create a query builder for fluent data queries
|
|
@@ -821,6 +880,12 @@ declare class BaasClient extends HttpClient {
|
|
|
821
880
|
listCorsOrigins(): Promise<any>;
|
|
822
881
|
addCorsOrigin(origin: string, description?: string): Promise<any>;
|
|
823
882
|
deleteCorsOrigin(id: string): Promise<any>;
|
|
883
|
+
listPolicies(): Promise<Policy[]>;
|
|
884
|
+
createPolicy(input: any): Promise<Policy>;
|
|
885
|
+
deletePolicy(id: string): Promise<any>;
|
|
886
|
+
listIPWhitelist(): Promise<IPWhitelistEntry[]>;
|
|
887
|
+
addIPWhitelistEntry(ipAddress: string, description?: string): Promise<IPWhitelistEntry>;
|
|
888
|
+
deleteIPWhitelistEntry(id: string): Promise<any>;
|
|
824
889
|
}
|
|
825
890
|
|
|
826
|
-
export { type ApiKeysModule, type ApiResponse, type ApplicationLogsOptions, type AuditLogsOptions, type AuditModule, type AuthModule, BaasClient, type BackupsModule, type BranchesModule, type CorsOriginsModule, type DatabaseModule, type EmailConfig, type EmailModule, type EmailTemplate, type EnvVarsModule, type FunctionsModule, type GraphQLModule, HttpClient, type HttpMethod, type JobInput, type JobUpdateInput, type JobsModule, type LogDrainInput, type LogDrainUpdateInput, type LogDrainsModule, type MetricsModule, type MigrationsModule, type PaginationOptions, QueryBuilder, type QueryFilter, type RealtimeModule, type RequestLogsOptions, type RequestOptions, type SearchModule, type SearchOptions, type SendEmailInput, type StorageBucket, type StorageFile, type StorageFileWithUrl, type StorageModule, type Subscription, type TimeseriesOptions, type UsersModule, type WebhookInput, type WebhookUpdateInput, type WebhooksModule };
|
|
891
|
+
export { type ApiKeysModule, type ApiResponse, type ApplicationLogsOptions, type AuditLogsOptions, type AuditModule, type AuthModule, BaasClient, type BackupsModule, type BranchesModule, type CorsOriginsModule, type CreatePolicyInput, type DatabaseModule, type EmailConfig, type EmailModule, type EmailTemplate, type EnvVarsModule, type EnvironmentsModule, type FunctionsModule, type GraphQLModule, HttpClient, type HttpMethod, type IPWhitelistEntry, type IPWhitelistModule, type JobInput, type JobUpdateInput, type JobsModule, type LogDrainInput, type LogDrainUpdateInput, type LogDrainsModule, type MetricsModule, type MigrationsModule, type PaginationOptions, type PoliciesModule, type Policy, QueryBuilder, type QueryFilter, type RealtimeModule, type RequestLogsOptions, type RequestOptions, type SearchModule, type SearchOptions, type SendEmailInput, type StorageBucket, type StorageFile, type StorageFileWithUrl, type StorageModule, type Subscription, type TimeseriesOptions, type UsersModule, type WebhookInput, type WebhookUpdateInput, type WebhooksModule };
|
package/dist/index.js
CHANGED
|
@@ -402,6 +402,9 @@ function createDatabaseModule(client) {
|
|
|
402
402
|
async getSchema(name) {
|
|
403
403
|
return get(`/api/schemas/${name}`);
|
|
404
404
|
},
|
|
405
|
+
async saveSchemas(data) {
|
|
406
|
+
return post("/api/schemas", data);
|
|
407
|
+
},
|
|
405
408
|
// Tables
|
|
406
409
|
async createTable(tableName, definition) {
|
|
407
410
|
return post("/api/schemas/tables", { table_name: tableName, definition });
|
|
@@ -629,17 +632,23 @@ function createFunctionsModule(client) {
|
|
|
629
632
|
async invoke(id, data = {}) {
|
|
630
633
|
return post(`/api/functions/${id}/execute`, data);
|
|
631
634
|
},
|
|
635
|
+
async get(id) {
|
|
636
|
+
return get(`/api/functions/${id}`);
|
|
637
|
+
},
|
|
632
638
|
async list() {
|
|
633
639
|
return get("/api/functions");
|
|
634
640
|
},
|
|
635
|
-
async create(name, code) {
|
|
636
|
-
return post("/api/functions", { name, code });
|
|
641
|
+
async create(name, code, options) {
|
|
642
|
+
return post("/api/functions", { name, code, ...options });
|
|
637
643
|
},
|
|
638
644
|
async delete(id) {
|
|
639
645
|
return del(`/api/functions/${id}`);
|
|
640
646
|
},
|
|
641
|
-
async update(id, code) {
|
|
642
|
-
return put(`/api/functions/${id}`, { code });
|
|
647
|
+
async update(id, code, options) {
|
|
648
|
+
return put(`/api/functions/${id}`, { code, ...options });
|
|
649
|
+
},
|
|
650
|
+
async executeCode(code, options) {
|
|
651
|
+
return post("/api/functions/execute", { code, ...options });
|
|
643
652
|
},
|
|
644
653
|
async listHooks() {
|
|
645
654
|
return get("/api/hooks");
|
|
@@ -775,11 +784,15 @@ function createSearchModule(client) {
|
|
|
775
784
|
|
|
776
785
|
// src/modules/graphql.ts
|
|
777
786
|
function createGraphQLModule(client) {
|
|
787
|
+
const get = (endpoint) => client.get(endpoint);
|
|
778
788
|
const post = (endpoint, body) => client.post(endpoint, body);
|
|
779
789
|
return {
|
|
780
790
|
async query(query, variables) {
|
|
781
791
|
return post("/api/graphql", { query, variables });
|
|
782
792
|
},
|
|
793
|
+
async getSchema() {
|
|
794
|
+
return get("/api/graphql/schema");
|
|
795
|
+
},
|
|
783
796
|
getPlaygroundUrl() {
|
|
784
797
|
return `${client.url}/api/graphql/playground`;
|
|
785
798
|
}
|
|
@@ -1143,6 +1156,42 @@ function createCorsOriginsModule(client) {
|
|
|
1143
1156
|
};
|
|
1144
1157
|
}
|
|
1145
1158
|
|
|
1159
|
+
// src/modules/policies.ts
|
|
1160
|
+
function createPoliciesModule(client) {
|
|
1161
|
+
const get = (endpoint) => client.get(endpoint);
|
|
1162
|
+
const post = (endpoint, body) => client.post(endpoint, body);
|
|
1163
|
+
const del = (endpoint) => client.delete(endpoint);
|
|
1164
|
+
return {
|
|
1165
|
+
async create(input) {
|
|
1166
|
+
return post("/api/policies", input);
|
|
1167
|
+
},
|
|
1168
|
+
async list() {
|
|
1169
|
+
return get("/api/policies");
|
|
1170
|
+
},
|
|
1171
|
+
async delete(id) {
|
|
1172
|
+
return del(`/api/policies/${id}`);
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
// src/modules/ip-whitelist.ts
|
|
1178
|
+
function createIPWhitelistModule(client) {
|
|
1179
|
+
const get = (endpoint) => client.get(endpoint);
|
|
1180
|
+
const post = (endpoint, body) => client.post(endpoint, body);
|
|
1181
|
+
const del = (endpoint) => client.delete(endpoint);
|
|
1182
|
+
return {
|
|
1183
|
+
async list() {
|
|
1184
|
+
return get("/api/ip-whitelist");
|
|
1185
|
+
},
|
|
1186
|
+
async create(ipAddress, description) {
|
|
1187
|
+
return post("/api/ip-whitelist", { ip_address: ipAddress, description: description || "" });
|
|
1188
|
+
},
|
|
1189
|
+
async delete(id) {
|
|
1190
|
+
return del(`/api/ip-whitelist/${id}`);
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1146
1195
|
// src/client.ts
|
|
1147
1196
|
var BaasClient = class extends HttpClient {
|
|
1148
1197
|
// Feature modules
|
|
@@ -1167,6 +1216,8 @@ var BaasClient = class extends HttpClient {
|
|
|
1167
1216
|
apiKeys;
|
|
1168
1217
|
environments;
|
|
1169
1218
|
corsOrigins;
|
|
1219
|
+
policies;
|
|
1220
|
+
ipWhitelist;
|
|
1170
1221
|
constructor(url, apiKey) {
|
|
1171
1222
|
super(url, apiKey);
|
|
1172
1223
|
this.auth = createAuthModule(this);
|
|
@@ -1190,6 +1241,8 @@ var BaasClient = class extends HttpClient {
|
|
|
1190
1241
|
this.apiKeys = createApiKeysModule(this);
|
|
1191
1242
|
this.environments = createEnvironmentsModule(this);
|
|
1192
1243
|
this.corsOrigins = createCorsOriginsModule(this);
|
|
1244
|
+
this.policies = createPoliciesModule(this);
|
|
1245
|
+
this.ipWhitelist = createIPWhitelistModule(this);
|
|
1193
1246
|
}
|
|
1194
1247
|
/**
|
|
1195
1248
|
* Create a query builder for fluent data queries
|
|
@@ -1591,6 +1644,26 @@ var BaasClient = class extends HttpClient {
|
|
|
1591
1644
|
async deleteCorsOrigin(id) {
|
|
1592
1645
|
return this.corsOrigins.delete(id);
|
|
1593
1646
|
}
|
|
1647
|
+
// Policies shortcuts
|
|
1648
|
+
async listPolicies() {
|
|
1649
|
+
return this.policies.list();
|
|
1650
|
+
}
|
|
1651
|
+
async createPolicy(input) {
|
|
1652
|
+
return this.policies.create(input);
|
|
1653
|
+
}
|
|
1654
|
+
async deletePolicy(id) {
|
|
1655
|
+
return this.policies.delete(id);
|
|
1656
|
+
}
|
|
1657
|
+
// IP Whitelist shortcuts
|
|
1658
|
+
async listIPWhitelist() {
|
|
1659
|
+
return this.ipWhitelist.list();
|
|
1660
|
+
}
|
|
1661
|
+
async addIPWhitelistEntry(ipAddress, description) {
|
|
1662
|
+
return this.ipWhitelist.create(ipAddress, description);
|
|
1663
|
+
}
|
|
1664
|
+
async deleteIPWhitelistEntry(id) {
|
|
1665
|
+
return this.ipWhitelist.delete(id);
|
|
1666
|
+
}
|
|
1594
1667
|
};
|
|
1595
1668
|
export {
|
|
1596
1669
|
BaasClient,
|