@swiftbaseio/admin-sdk 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +454 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -8
- package/dist/index.d.ts +111 -8
- package/dist/index.js +450 -240
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -69,6 +69,47 @@ declare class PaginatedResponse<T> {
|
|
|
69
69
|
back(): Promise<PaginatedResponse<T> | null>;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
interface CustomScope {
|
|
73
|
+
id: string;
|
|
74
|
+
projectId: string;
|
|
75
|
+
name: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
createdAt?: string;
|
|
78
|
+
updatedAt?: string;
|
|
79
|
+
}
|
|
80
|
+
interface ScopeCatalogResponse {
|
|
81
|
+
categories: Array<{
|
|
82
|
+
id: string;
|
|
83
|
+
label: string;
|
|
84
|
+
scopes: Array<{
|
|
85
|
+
key: string;
|
|
86
|
+
description: string;
|
|
87
|
+
sensitive?: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
}>;
|
|
90
|
+
customScopes: CustomScope[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Helper to format a custom scope name with the reserved `custom:` prefix.
|
|
94
|
+
*/
|
|
95
|
+
declare function customScope(name: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Fetch built-in Swiftbase scopes and custom project scopes.
|
|
98
|
+
*/
|
|
99
|
+
declare function getScopes(projectId?: string): Promise<ScopeCatalogResponse>;
|
|
100
|
+
/**
|
|
101
|
+
* Create a project-scoped custom scope (automatically prefixed with `custom:`).
|
|
102
|
+
*/
|
|
103
|
+
declare function createCustomScope(input: {
|
|
104
|
+
projectId?: string;
|
|
105
|
+
name: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
}): Promise<CustomScope>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete a project-scoped custom scope.
|
|
110
|
+
*/
|
|
111
|
+
declare function deleteCustomScope(id: string): Promise<void>;
|
|
112
|
+
|
|
72
113
|
/**
|
|
73
114
|
* Login as a service
|
|
74
115
|
*
|
|
@@ -152,15 +193,25 @@ interface UserInput {
|
|
|
152
193
|
*/
|
|
153
194
|
declare const verifyToken: (token: string) => Promise<User>;
|
|
154
195
|
|
|
196
|
+
interface VerifiedServiceToken {
|
|
197
|
+
valid: boolean;
|
|
198
|
+
service: {
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
projectId: string;
|
|
202
|
+
scopes: string[];
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface VerifyServiceTokenOptions {
|
|
206
|
+
scope?: string;
|
|
207
|
+
scopes?: string[];
|
|
208
|
+
match?: "all" | "any";
|
|
209
|
+
}
|
|
155
210
|
/**
|
|
156
|
-
* Verify a service's access token
|
|
157
|
-
*
|
|
158
|
-
* @param {string} token The access token to verify
|
|
159
|
-
* @param {string} [scope] Optional scope to verify
|
|
160
|
-
*
|
|
161
|
-
* @returns {Promise<Service>} The service associated with the token
|
|
211
|
+
* Verify a service's access token (JWT) against Swiftbase.
|
|
212
|
+
* Enforces same-project isolation and optional built-in or `custom:*` scope requirements.
|
|
162
213
|
*/
|
|
163
|
-
declare const verifyServiceToken: (token: string,
|
|
214
|
+
declare const verifyServiceToken: (token: string, scopeOrOptions?: string | VerifyServiceTokenOptions) => Promise<VerifiedServiceToken>;
|
|
164
215
|
|
|
165
216
|
/**
|
|
166
217
|
* Roles Management
|
|
@@ -741,6 +792,58 @@ declare const db: DbInterface;
|
|
|
741
792
|
|
|
742
793
|
declare function search(indexId: string, query: string): Promise<any[]>;
|
|
743
794
|
|
|
795
|
+
interface StackServiceSpec {
|
|
796
|
+
image: string;
|
|
797
|
+
port?: number;
|
|
798
|
+
replicas?: number;
|
|
799
|
+
resources?: {
|
|
800
|
+
cpu?: number;
|
|
801
|
+
memory?: string;
|
|
802
|
+
};
|
|
803
|
+
domain?: string;
|
|
804
|
+
domains?: string[];
|
|
805
|
+
env?: Record<string, string>;
|
|
806
|
+
volumes?: Array<{
|
|
807
|
+
sizeGB?: number;
|
|
808
|
+
mountPath?: string;
|
|
809
|
+
}>;
|
|
810
|
+
restrict_inbound?: boolean;
|
|
811
|
+
force_https?: boolean;
|
|
812
|
+
depends_on?: string[];
|
|
813
|
+
}
|
|
814
|
+
interface StackManifest {
|
|
815
|
+
version?: string;
|
|
816
|
+
stack: string;
|
|
817
|
+
services: Record<string, StackServiceSpec>;
|
|
818
|
+
}
|
|
819
|
+
interface StackPlanResult {
|
|
820
|
+
stack: string;
|
|
821
|
+
order: string[];
|
|
822
|
+
toCreate: string[];
|
|
823
|
+
toUpdate: string[];
|
|
824
|
+
toDelete: string[];
|
|
825
|
+
unchanged: string[];
|
|
826
|
+
}
|
|
827
|
+
declare const stacks: {
|
|
828
|
+
list(projectId?: string): Promise<any[]>;
|
|
829
|
+
plan(manifest: StackManifest | string, options?: {
|
|
830
|
+
projectId?: string;
|
|
831
|
+
prune?: boolean;
|
|
832
|
+
}): Promise<StackPlanResult>;
|
|
833
|
+
apply(manifest: StackManifest | string, options?: {
|
|
834
|
+
projectId?: string;
|
|
835
|
+
prune?: boolean;
|
|
836
|
+
}): Promise<{
|
|
837
|
+
stackId: string;
|
|
838
|
+
stack: string;
|
|
839
|
+
deployed: any[];
|
|
840
|
+
}>;
|
|
841
|
+
down(stackId: string): Promise<{
|
|
842
|
+
success: boolean;
|
|
843
|
+
removedContainers: number;
|
|
844
|
+
}>;
|
|
845
|
+
};
|
|
846
|
+
|
|
744
847
|
interface StorageOptions {
|
|
745
848
|
bucket: string;
|
|
746
849
|
endpoint?: string;
|
|
@@ -960,4 +1063,4 @@ declare const vault: {
|
|
|
960
1063
|
getLogs: typeof getLogs;
|
|
961
1064
|
};
|
|
962
1065
|
|
|
963
|
-
export { type AIChatCompletionOptions, type AIChatCompletionResponse, type AIChatMessage, type AIPromptRunOptions, type AIPromptRunResponse, type AggregateClause, type BatchQueryResult, type BucketInfo, type ChangePasswordInput, ColumnBuilder, type ColumnDataType, type ColumnDefinitionOptions, type CompiledSQL, type Configuration, type ConfigurationInput, type CreateSecretInput, type DatabaseEngine, type DbClient, type DbInterface, type ExistingTableCatalog, type User as IdentityUser, type IndexDefinition, type JoinClause, type JoinType, type ListObjectsResult, MigrationGenerator, type MigrationOperation, type MigrationPlan, type MigrationResult, MigrationRunner, type OrderByClause, PaginatedResponse, type Profile, type ProfileInput, QueryBuilder, type QueryPayload, type Role, type RoleInput, type RoleUpdateInput, type S3Object, SQLCompiler, SchemaDiff, type Service, type ServiceInput, type ServiceUpdateInput, Storage, type StorageOptions, TableDefinition, type TableOptions, type UpdateSecretInput, type User, type UserInput, type VaultLog, type VaultSecret, type VaultVersion, type WhereCondition, ai, app, assignRole, bigint, blob, boolean, changePassword, createRole, createService, createUser, db, defineTable, deleteRole, deleteService, deleteUser, doublePrecision, generateId, getAccessToken, getConfiguration, getProfile, getRoles, getServices, getUsers, initializeSdk, integer, isLoggedIn, json, login, logout, real, search, setAccessToken, text, timestamp, unassignRole, updateConfiguration, updateProfile, updateRole, updateService, updateUser, uuid, varchar, vault, verifyServiceToken, verifyToken };
|
|
1066
|
+
export { type AIChatCompletionOptions, type AIChatCompletionResponse, type AIChatMessage, type AIPromptRunOptions, type AIPromptRunResponse, type AggregateClause, type BatchQueryResult, type BucketInfo, type ChangePasswordInput, ColumnBuilder, type ColumnDataType, type ColumnDefinitionOptions, type CompiledSQL, type Configuration, type ConfigurationInput, type CreateSecretInput, type DatabaseEngine, type DbClient, type DbInterface, type ExistingTableCatalog, type User as IdentityUser, type IndexDefinition, type JoinClause, type JoinType, type ListObjectsResult, MigrationGenerator, type MigrationOperation, type MigrationPlan, type MigrationResult, MigrationRunner, type OrderByClause, PaginatedResponse, type Profile, type ProfileInput, QueryBuilder, type QueryPayload, type Role, type RoleInput, type RoleUpdateInput, type S3Object, SQLCompiler, SchemaDiff, type Service, type ServiceInput, type ServiceUpdateInput, Storage, type StorageOptions, TableDefinition, type TableOptions, type UpdateSecretInput, type User, type UserInput, type VaultLog, type VaultSecret, type VaultVersion, type WhereCondition, ai, app, assignRole, bigint, blob, boolean, changePassword, createCustomScope, createRole, createService, createUser, customScope, db, defineTable, deleteCustomScope, deleteRole, deleteService, deleteUser, doublePrecision, generateId, getAccessToken, getConfiguration, getProfile, getRoles, getScopes, getServices, getUsers, initializeSdk, integer, isLoggedIn, json, login, logout, real, search, setAccessToken, stacks, text, timestamp, unassignRole, updateConfiguration, updateProfile, updateRole, updateService, updateUser, uuid, varchar, vault, verifyServiceToken, verifyToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,47 @@ declare class PaginatedResponse<T> {
|
|
|
69
69
|
back(): Promise<PaginatedResponse<T> | null>;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
interface CustomScope {
|
|
73
|
+
id: string;
|
|
74
|
+
projectId: string;
|
|
75
|
+
name: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
createdAt?: string;
|
|
78
|
+
updatedAt?: string;
|
|
79
|
+
}
|
|
80
|
+
interface ScopeCatalogResponse {
|
|
81
|
+
categories: Array<{
|
|
82
|
+
id: string;
|
|
83
|
+
label: string;
|
|
84
|
+
scopes: Array<{
|
|
85
|
+
key: string;
|
|
86
|
+
description: string;
|
|
87
|
+
sensitive?: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
}>;
|
|
90
|
+
customScopes: CustomScope[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Helper to format a custom scope name with the reserved `custom:` prefix.
|
|
94
|
+
*/
|
|
95
|
+
declare function customScope(name: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Fetch built-in Swiftbase scopes and custom project scopes.
|
|
98
|
+
*/
|
|
99
|
+
declare function getScopes(projectId?: string): Promise<ScopeCatalogResponse>;
|
|
100
|
+
/**
|
|
101
|
+
* Create a project-scoped custom scope (automatically prefixed with `custom:`).
|
|
102
|
+
*/
|
|
103
|
+
declare function createCustomScope(input: {
|
|
104
|
+
projectId?: string;
|
|
105
|
+
name: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
}): Promise<CustomScope>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete a project-scoped custom scope.
|
|
110
|
+
*/
|
|
111
|
+
declare function deleteCustomScope(id: string): Promise<void>;
|
|
112
|
+
|
|
72
113
|
/**
|
|
73
114
|
* Login as a service
|
|
74
115
|
*
|
|
@@ -152,15 +193,25 @@ interface UserInput {
|
|
|
152
193
|
*/
|
|
153
194
|
declare const verifyToken: (token: string) => Promise<User>;
|
|
154
195
|
|
|
196
|
+
interface VerifiedServiceToken {
|
|
197
|
+
valid: boolean;
|
|
198
|
+
service: {
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
projectId: string;
|
|
202
|
+
scopes: string[];
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface VerifyServiceTokenOptions {
|
|
206
|
+
scope?: string;
|
|
207
|
+
scopes?: string[];
|
|
208
|
+
match?: "all" | "any";
|
|
209
|
+
}
|
|
155
210
|
/**
|
|
156
|
-
* Verify a service's access token
|
|
157
|
-
*
|
|
158
|
-
* @param {string} token The access token to verify
|
|
159
|
-
* @param {string} [scope] Optional scope to verify
|
|
160
|
-
*
|
|
161
|
-
* @returns {Promise<Service>} The service associated with the token
|
|
211
|
+
* Verify a service's access token (JWT) against Swiftbase.
|
|
212
|
+
* Enforces same-project isolation and optional built-in or `custom:*` scope requirements.
|
|
162
213
|
*/
|
|
163
|
-
declare const verifyServiceToken: (token: string,
|
|
214
|
+
declare const verifyServiceToken: (token: string, scopeOrOptions?: string | VerifyServiceTokenOptions) => Promise<VerifiedServiceToken>;
|
|
164
215
|
|
|
165
216
|
/**
|
|
166
217
|
* Roles Management
|
|
@@ -741,6 +792,58 @@ declare const db: DbInterface;
|
|
|
741
792
|
|
|
742
793
|
declare function search(indexId: string, query: string): Promise<any[]>;
|
|
743
794
|
|
|
795
|
+
interface StackServiceSpec {
|
|
796
|
+
image: string;
|
|
797
|
+
port?: number;
|
|
798
|
+
replicas?: number;
|
|
799
|
+
resources?: {
|
|
800
|
+
cpu?: number;
|
|
801
|
+
memory?: string;
|
|
802
|
+
};
|
|
803
|
+
domain?: string;
|
|
804
|
+
domains?: string[];
|
|
805
|
+
env?: Record<string, string>;
|
|
806
|
+
volumes?: Array<{
|
|
807
|
+
sizeGB?: number;
|
|
808
|
+
mountPath?: string;
|
|
809
|
+
}>;
|
|
810
|
+
restrict_inbound?: boolean;
|
|
811
|
+
force_https?: boolean;
|
|
812
|
+
depends_on?: string[];
|
|
813
|
+
}
|
|
814
|
+
interface StackManifest {
|
|
815
|
+
version?: string;
|
|
816
|
+
stack: string;
|
|
817
|
+
services: Record<string, StackServiceSpec>;
|
|
818
|
+
}
|
|
819
|
+
interface StackPlanResult {
|
|
820
|
+
stack: string;
|
|
821
|
+
order: string[];
|
|
822
|
+
toCreate: string[];
|
|
823
|
+
toUpdate: string[];
|
|
824
|
+
toDelete: string[];
|
|
825
|
+
unchanged: string[];
|
|
826
|
+
}
|
|
827
|
+
declare const stacks: {
|
|
828
|
+
list(projectId?: string): Promise<any[]>;
|
|
829
|
+
plan(manifest: StackManifest | string, options?: {
|
|
830
|
+
projectId?: string;
|
|
831
|
+
prune?: boolean;
|
|
832
|
+
}): Promise<StackPlanResult>;
|
|
833
|
+
apply(manifest: StackManifest | string, options?: {
|
|
834
|
+
projectId?: string;
|
|
835
|
+
prune?: boolean;
|
|
836
|
+
}): Promise<{
|
|
837
|
+
stackId: string;
|
|
838
|
+
stack: string;
|
|
839
|
+
deployed: any[];
|
|
840
|
+
}>;
|
|
841
|
+
down(stackId: string): Promise<{
|
|
842
|
+
success: boolean;
|
|
843
|
+
removedContainers: number;
|
|
844
|
+
}>;
|
|
845
|
+
};
|
|
846
|
+
|
|
744
847
|
interface StorageOptions {
|
|
745
848
|
bucket: string;
|
|
746
849
|
endpoint?: string;
|
|
@@ -960,4 +1063,4 @@ declare const vault: {
|
|
|
960
1063
|
getLogs: typeof getLogs;
|
|
961
1064
|
};
|
|
962
1065
|
|
|
963
|
-
export { type AIChatCompletionOptions, type AIChatCompletionResponse, type AIChatMessage, type AIPromptRunOptions, type AIPromptRunResponse, type AggregateClause, type BatchQueryResult, type BucketInfo, type ChangePasswordInput, ColumnBuilder, type ColumnDataType, type ColumnDefinitionOptions, type CompiledSQL, type Configuration, type ConfigurationInput, type CreateSecretInput, type DatabaseEngine, type DbClient, type DbInterface, type ExistingTableCatalog, type User as IdentityUser, type IndexDefinition, type JoinClause, type JoinType, type ListObjectsResult, MigrationGenerator, type MigrationOperation, type MigrationPlan, type MigrationResult, MigrationRunner, type OrderByClause, PaginatedResponse, type Profile, type ProfileInput, QueryBuilder, type QueryPayload, type Role, type RoleInput, type RoleUpdateInput, type S3Object, SQLCompiler, SchemaDiff, type Service, type ServiceInput, type ServiceUpdateInput, Storage, type StorageOptions, TableDefinition, type TableOptions, type UpdateSecretInput, type User, type UserInput, type VaultLog, type VaultSecret, type VaultVersion, type WhereCondition, ai, app, assignRole, bigint, blob, boolean, changePassword, createRole, createService, createUser, db, defineTable, deleteRole, deleteService, deleteUser, doublePrecision, generateId, getAccessToken, getConfiguration, getProfile, getRoles, getServices, getUsers, initializeSdk, integer, isLoggedIn, json, login, logout, real, search, setAccessToken, text, timestamp, unassignRole, updateConfiguration, updateProfile, updateRole, updateService, updateUser, uuid, varchar, vault, verifyServiceToken, verifyToken };
|
|
1066
|
+
export { type AIChatCompletionOptions, type AIChatCompletionResponse, type AIChatMessage, type AIPromptRunOptions, type AIPromptRunResponse, type AggregateClause, type BatchQueryResult, type BucketInfo, type ChangePasswordInput, ColumnBuilder, type ColumnDataType, type ColumnDefinitionOptions, type CompiledSQL, type Configuration, type ConfigurationInput, type CreateSecretInput, type DatabaseEngine, type DbClient, type DbInterface, type ExistingTableCatalog, type User as IdentityUser, type IndexDefinition, type JoinClause, type JoinType, type ListObjectsResult, MigrationGenerator, type MigrationOperation, type MigrationPlan, type MigrationResult, MigrationRunner, type OrderByClause, PaginatedResponse, type Profile, type ProfileInput, QueryBuilder, type QueryPayload, type Role, type RoleInput, type RoleUpdateInput, type S3Object, SQLCompiler, SchemaDiff, type Service, type ServiceInput, type ServiceUpdateInput, Storage, type StorageOptions, TableDefinition, type TableOptions, type UpdateSecretInput, type User, type UserInput, type VaultLog, type VaultSecret, type VaultVersion, type WhereCondition, ai, app, assignRole, bigint, blob, boolean, changePassword, createCustomScope, createRole, createService, createUser, customScope, db, defineTable, deleteCustomScope, deleteRole, deleteService, deleteUser, doublePrecision, generateId, getAccessToken, getConfiguration, getProfile, getRoles, getScopes, getServices, getUsers, initializeSdk, integer, isLoggedIn, json, login, logout, real, search, setAccessToken, stacks, text, timestamp, unassignRole, updateConfiguration, updateProfile, updateRole, updateService, updateUser, uuid, varchar, vault, verifyServiceToken, verifyToken };
|