@kmlckj/licos-platform-sdk 0.6.3 → 0.6.4
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/README.md +57 -47
- package/package.json +2 -2
- package/src/database.js +688 -255
- package/src/index.d.ts +251 -208
package/src/index.d.ts
CHANGED
|
@@ -1,208 +1,251 @@
|
|
|
1
|
-
export class PlatformSdkError extends Error {
|
|
2
|
-
status?: number;
|
|
3
|
-
code?: number;
|
|
4
|
-
details?: unknown;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export class ConfigurationError extends PlatformSdkError {}
|
|
8
|
-
export class ApiError extends PlatformSdkError {}
|
|
9
|
-
|
|
10
|
-
export interface DatabaseFilter {
|
|
11
|
-
field: string;
|
|
12
|
-
op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'not_in' | 'is_null' | 'is_not_null' | 'like' | 'ilike' | string;
|
|
13
|
-
value?: unknown;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface DatabaseOrderBy {
|
|
17
|
-
field: string;
|
|
18
|
-
direction?: 'asc' | 'desc';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface DatabaseRange {
|
|
22
|
-
from: number;
|
|
23
|
-
to: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface DatabaseResponse {
|
|
27
|
-
data?: Record<string, unknown>[];
|
|
28
|
-
count?: number;
|
|
29
|
-
affectedRows?: number;
|
|
30
|
-
message?: string;
|
|
31
|
-
[key: string]: unknown;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface DatabaseQueryOptions {
|
|
35
|
-
select?: string | string[];
|
|
36
|
-
filters?: DatabaseFilter[];
|
|
37
|
-
orderBy?: DatabaseOrderBy[];
|
|
38
|
-
range?: DatabaseRange;
|
|
39
|
-
limit?: number;
|
|
40
|
-
offset?: number;
|
|
41
|
-
count?: boolean;
|
|
42
|
-
head?: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface DatabaseMutationOptions {
|
|
46
|
-
row?: Record<string, unknown>;
|
|
47
|
-
rows?: Record<string, unknown>[];
|
|
48
|
-
values?: Record<string, unknown>;
|
|
49
|
-
filters?: DatabaseFilter[];
|
|
50
|
-
updates?: Array<{ filters?: DatabaseFilter[]; values?: Record<string, unknown> }>;
|
|
51
|
-
deletes?: Array<{ filters?: DatabaseFilter[] }>;
|
|
52
|
-
conflictKeys?: string[];
|
|
53
|
-
returning?: boolean;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface DatabaseOperation {
|
|
57
|
-
type: 'query' | 'insert' | 'update' | 'delete' | 'upsert' | string;
|
|
58
|
-
request: Record<string, unknown>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
export
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
export
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export interface
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
export
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
1
|
+
export class PlatformSdkError extends Error {
|
|
2
|
+
status?: number;
|
|
3
|
+
code?: number;
|
|
4
|
+
details?: unknown;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class ConfigurationError extends PlatformSdkError {}
|
|
8
|
+
export class ApiError extends PlatformSdkError {}
|
|
9
|
+
|
|
10
|
+
export interface DatabaseFilter {
|
|
11
|
+
field: string;
|
|
12
|
+
op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'not_in' | 'is_null' | 'is_not_null' | 'like' | 'ilike' | string;
|
|
13
|
+
value?: unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DatabaseOrderBy {
|
|
17
|
+
field: string;
|
|
18
|
+
direction?: 'asc' | 'desc';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DatabaseRange {
|
|
22
|
+
from: number;
|
|
23
|
+
to: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DatabaseResponse {
|
|
27
|
+
data?: Record<string, unknown>[];
|
|
28
|
+
count?: number;
|
|
29
|
+
affectedRows?: number;
|
|
30
|
+
message?: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface DatabaseQueryOptions {
|
|
35
|
+
select?: string | string[];
|
|
36
|
+
filters?: DatabaseFilter[];
|
|
37
|
+
orderBy?: DatabaseOrderBy[];
|
|
38
|
+
range?: DatabaseRange;
|
|
39
|
+
limit?: number;
|
|
40
|
+
offset?: number;
|
|
41
|
+
count?: boolean;
|
|
42
|
+
head?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface DatabaseMutationOptions {
|
|
46
|
+
row?: Record<string, unknown>;
|
|
47
|
+
rows?: Record<string, unknown>[];
|
|
48
|
+
values?: Record<string, unknown>;
|
|
49
|
+
filters?: DatabaseFilter[];
|
|
50
|
+
updates?: Array<{ filters?: DatabaseFilter[]; values?: Record<string, unknown> }>;
|
|
51
|
+
deletes?: Array<{ filters?: DatabaseFilter[] }>;
|
|
52
|
+
conflictKeys?: string[];
|
|
53
|
+
returning?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface DatabaseOperation {
|
|
57
|
+
type: 'query' | 'insert' | 'update' | 'delete' | 'upsert' | string;
|
|
58
|
+
request: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface DatabaseSchemaColumn {
|
|
62
|
+
name: string;
|
|
63
|
+
type?: string;
|
|
64
|
+
nullable?: boolean;
|
|
65
|
+
primaryKey?: boolean;
|
|
66
|
+
defaultValue?: string | null;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface DatabaseSchemaTable {
|
|
71
|
+
schema?: string;
|
|
72
|
+
name: string;
|
|
73
|
+
description?: string | null;
|
|
74
|
+
columns?: DatabaseSchemaColumn[];
|
|
75
|
+
indexes?: unknown[];
|
|
76
|
+
foreignKeys?: unknown[];
|
|
77
|
+
constraints?: unknown[];
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface DatabaseSchema {
|
|
82
|
+
databaseId?: string;
|
|
83
|
+
environment?: 'dev' | 'prod' | string;
|
|
84
|
+
tables?: DatabaseSchemaTable[];
|
|
85
|
+
views?: unknown[];
|
|
86
|
+
functions?: unknown[];
|
|
87
|
+
enums?: unknown[];
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface GenerateOrmOptions {
|
|
92
|
+
language: 'typescript' | 'python' | 'ts' | 'py' | string;
|
|
93
|
+
orm?: 'drizzle' | 'sqlalchemy' | string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface TableQuery {
|
|
97
|
+
select(...fields: string[]): TableQuery;
|
|
98
|
+
filter(field: string, op: string, value?: unknown): TableQuery;
|
|
99
|
+
eq(field: string, value: unknown): TableQuery;
|
|
100
|
+
neq(field: string, value: unknown): TableQuery;
|
|
101
|
+
gt(field: string, value: unknown): TableQuery;
|
|
102
|
+
gte(field: string, value: unknown): TableQuery;
|
|
103
|
+
lt(field: string, value: unknown): TableQuery;
|
|
104
|
+
lte(field: string, value: unknown): TableQuery;
|
|
105
|
+
in(field: string, value: unknown[]): TableQuery;
|
|
106
|
+
notIn(field: string, value: unknown[]): TableQuery;
|
|
107
|
+
isNull(field: string): TableQuery;
|
|
108
|
+
isNotNull(field: string): TableQuery;
|
|
109
|
+
like(field: string, value: string): TableQuery;
|
|
110
|
+
ilike(field: string, value: string): TableQuery;
|
|
111
|
+
order(field: string, options?: { desc?: boolean }): TableQuery;
|
|
112
|
+
range(from: number, to: number): TableQuery;
|
|
113
|
+
limit(value: number): TableQuery;
|
|
114
|
+
offset(value: number): TableQuery;
|
|
115
|
+
withCount(options?: { head?: boolean }): TableQuery;
|
|
116
|
+
execute(): Promise<DatabaseResponse>;
|
|
117
|
+
single(): Promise<DatabaseResponse>;
|
|
118
|
+
maybeSingle(): Promise<DatabaseResponse>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function query(table: string, options?: DatabaseQueryOptions): Promise<DatabaseResponse>;
|
|
122
|
+
export function single(table: string, options?: DatabaseQueryOptions & { maybe?: boolean }): Promise<DatabaseResponse>;
|
|
123
|
+
export function maybeSingle(table: string, options?: DatabaseQueryOptions): Promise<DatabaseResponse>;
|
|
124
|
+
export function aggregate(table: string, aggregateName: string, options?: { field?: string; groupBy?: string[]; filters?: DatabaseFilter[] }): Promise<DatabaseResponse>;
|
|
125
|
+
export function insert(table: string, options?: DatabaseMutationOptions): Promise<DatabaseResponse>;
|
|
126
|
+
export function updateRows(table: string, options?: DatabaseMutationOptions): Promise<DatabaseResponse>;
|
|
127
|
+
export function deleteRows(table: string, options?: DatabaseMutationOptions): Promise<DatabaseResponse>;
|
|
128
|
+
export function upsert(table: string, options?: DatabaseMutationOptions): Promise<DatabaseResponse>;
|
|
129
|
+
export function transaction(operations: DatabaseOperation[]): Promise<DatabaseResponse[]>;
|
|
130
|
+
export function rpc(functionName: string, args?: Record<string, unknown>): Promise<DatabaseResponse>;
|
|
131
|
+
export function getSchema(): Promise<DatabaseSchema>;
|
|
132
|
+
export function defaultOrm(language: string): string;
|
|
133
|
+
export function generateOrm(schemaPayload: DatabaseSchema, options: GenerateOrmOptions): string;
|
|
134
|
+
export function exportOrm(options: GenerateOrmOptions): Promise<string>;
|
|
135
|
+
export function table(name: string): TableQuery;
|
|
136
|
+
|
|
137
|
+
export const database: {
|
|
138
|
+
query: typeof query;
|
|
139
|
+
single: typeof single;
|
|
140
|
+
maybeSingle: typeof maybeSingle;
|
|
141
|
+
aggregate: typeof aggregate;
|
|
142
|
+
insert: typeof insert;
|
|
143
|
+
updateRows: typeof updateRows;
|
|
144
|
+
deleteRows: typeof deleteRows;
|
|
145
|
+
upsert: typeof upsert;
|
|
146
|
+
transaction: typeof transaction;
|
|
147
|
+
rpc: typeof rpc;
|
|
148
|
+
getSchema: typeof getSchema;
|
|
149
|
+
defaultOrm: typeof defaultOrm;
|
|
150
|
+
generateOrm: typeof generateOrm;
|
|
151
|
+
exportOrm: typeof exportOrm;
|
|
152
|
+
table: typeof table;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export interface StorageSummary {
|
|
156
|
+
workspaceId?: string;
|
|
157
|
+
projectId?: string;
|
|
158
|
+
scope?: string;
|
|
159
|
+
bucketName?: string;
|
|
160
|
+
usedSizeBytes?: number;
|
|
161
|
+
fileCount?: number;
|
|
162
|
+
folderCount?: number;
|
|
163
|
+
serviceEnabled?: boolean;
|
|
164
|
+
[key: string]: unknown;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface StorageFolder {
|
|
168
|
+
id?: string;
|
|
169
|
+
workspaceId?: string;
|
|
170
|
+
projectId?: string;
|
|
171
|
+
scope?: string;
|
|
172
|
+
parentId?: string | null;
|
|
173
|
+
folderName?: string;
|
|
174
|
+
folderPath?: string;
|
|
175
|
+
createdAt?: string;
|
|
176
|
+
updatedAt?: string;
|
|
177
|
+
[key: string]: unknown;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface StorageFile {
|
|
181
|
+
id?: string;
|
|
182
|
+
workspaceId?: string;
|
|
183
|
+
projectId?: string;
|
|
184
|
+
scope?: string;
|
|
185
|
+
folderId?: string | null;
|
|
186
|
+
folderPath?: string;
|
|
187
|
+
fileName?: string;
|
|
188
|
+
contentType?: string;
|
|
189
|
+
sizeBytes?: number;
|
|
190
|
+
storageBucket?: string;
|
|
191
|
+
storageKey?: string;
|
|
192
|
+
downloadUrl?: string;
|
|
193
|
+
createdAt?: string;
|
|
194
|
+
updatedAt?: string;
|
|
195
|
+
[key: string]: unknown;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface StorageEntries {
|
|
199
|
+
currentFolderId?: string | null;
|
|
200
|
+
currentFolderName?: string;
|
|
201
|
+
currentFolderPath?: string;
|
|
202
|
+
breadcrumbs?: unknown[];
|
|
203
|
+
folders?: StorageFolder[];
|
|
204
|
+
files?: StorageFile[];
|
|
205
|
+
[key: string]: unknown;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface UploadFileOptions {
|
|
209
|
+
folderId?: string;
|
|
210
|
+
fileName?: string;
|
|
211
|
+
contentType?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export const MAX_UPLOAD_FILE_BYTES: number;
|
|
215
|
+
|
|
216
|
+
export interface ShareUrlOptions {
|
|
217
|
+
expirySeconds?: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function summary(): Promise<StorageSummary>;
|
|
221
|
+
export function listFolders(): Promise<StorageFolder[]>;
|
|
222
|
+
export function listEntries(options?: { folderId?: string }): Promise<StorageEntries>;
|
|
223
|
+
export function listFiles(): Promise<StorageFile[]>;
|
|
224
|
+
export function createFolder(folderName: string, options?: { parentId?: string }): Promise<StorageFolder>;
|
|
225
|
+
export function renameFolder(folderId: string, folderName: string): Promise<StorageFolder>;
|
|
226
|
+
export function deleteFolder(folderId: string): Promise<void>;
|
|
227
|
+
export function uploadFile(
|
|
228
|
+
input: string | Blob | Buffer | Uint8Array,
|
|
229
|
+
options?: UploadFileOptions,
|
|
230
|
+
): Promise<StorageFile>;
|
|
231
|
+
export function renameFile(fileId: string, fileName: string): Promise<StorageFile>;
|
|
232
|
+
export function moveFile(fileId: string, options?: { folderId?: string }): Promise<StorageFile>;
|
|
233
|
+
export function shareUrl(fileId: string, options?: ShareUrlOptions): Promise<{ url?: string; expiresAt?: string; [key: string]: unknown }>;
|
|
234
|
+
export function objectExists(options?: { fileId?: string; objectKey?: string }): Promise<{ fileId?: string; bucketName?: string; objectKey?: string; exists?: boolean; [key: string]: unknown }>;
|
|
235
|
+
export function deleteFile(fileId: string): Promise<void>;
|
|
236
|
+
|
|
237
|
+
export const storage: {
|
|
238
|
+
summary: typeof summary;
|
|
239
|
+
listFolders: typeof listFolders;
|
|
240
|
+
listEntries: typeof listEntries;
|
|
241
|
+
listFiles: typeof listFiles;
|
|
242
|
+
createFolder: typeof createFolder;
|
|
243
|
+
renameFolder: typeof renameFolder;
|
|
244
|
+
deleteFolder: typeof deleteFolder;
|
|
245
|
+
uploadFile: typeof uploadFile;
|
|
246
|
+
renameFile: typeof renameFile;
|
|
247
|
+
moveFile: typeof moveFile;
|
|
248
|
+
shareUrl: typeof shareUrl;
|
|
249
|
+
objectExists: typeof objectExists;
|
|
250
|
+
deleteFile: typeof deleteFile;
|
|
251
|
+
};
|