@objectstack/client 1.0.4 → 1.0.5
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/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +333 -0
- package/dist/index.d.ts +137 -10
- package/dist/index.js +696 -491
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +684 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/tsconfig.json +3 -7
- package/dist/query-builder.d.ts +0 -124
- package/dist/query-builder.js +0 -221
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
> @objectstack/client@1.0.5 build /home/runner/work/spec/spec/packages/client
|
|
3
|
+
> tsup --config ../../tsup.config.ts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/spec/spec/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: es2020
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[34mCJS[39m Build start
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m20.62 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m40.53 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 60ms
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m19.46 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m40.47 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 61ms
|
|
19
|
+
[34mDTS[39m Build start
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 9730ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m10.28 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m10.28 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @objectstack/client
|
|
2
2
|
|
|
3
|
+
## 1.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b1d24bd: refactor: migrate build system from tsc to tsup for faster builds
|
|
8
|
+
- Replaced `tsc` with `tsup` (using esbuild) across all packages
|
|
9
|
+
- Added shared `tsup.config.ts` in workspace root
|
|
10
|
+
- Added `tsup` as workspace dev dependency
|
|
11
|
+
- significantly improved build performance
|
|
12
|
+
- Updated dependencies [b1d24bd]
|
|
13
|
+
- @objectstack/core@1.0.5
|
|
14
|
+
- @objectstack/spec@1.0.5
|
|
15
|
+
|
|
3
16
|
## 1.0.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { FilterCondition, QueryAST, SortNode, AggregationNode } from '@objectstack/spec/data';
|
|
2
|
+
import { GetDiscoveryResponse, StandardErrorCode, ErrorCategory, GetMetaTypesResponse, GetMetaItemsResponse, MetadataCacheRequest, MetadataCacheResponse, LoginRequest, SessionResponse, FileUploadResponse, BatchUpdateRequest, BatchUpdateResponse, BatchOptions } from '@objectstack/spec/api';
|
|
3
|
+
export { BatchOperationResult, BatchOptions, BatchRecord, BatchUpdateRequest, BatchUpdateResponse, DeleteManyRequest, ErrorCategory, GetDiscoveryResponse, GetMetaItemsResponse, GetMetaTypesResponse, MetadataCacheRequest, MetadataCacheResponse, StandardErrorCode, UpdateManyRequest } from '@objectstack/spec/api';
|
|
4
|
+
import { Logger } from '@objectstack/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type-Safe Query Builder
|
|
8
|
+
*
|
|
9
|
+
* Provides a fluent API for building ObjectStack queries with:
|
|
10
|
+
* - Compile-time type checking
|
|
11
|
+
* - Intelligent code completion
|
|
12
|
+
* - Runtime validation
|
|
13
|
+
* - Type-safe filters and selections
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Type-safe filter builder
|
|
18
|
+
*/
|
|
19
|
+
declare class FilterBuilder<T = any> {
|
|
20
|
+
private conditions;
|
|
21
|
+
/**
|
|
22
|
+
* Equality filter: field = value
|
|
23
|
+
*/
|
|
24
|
+
equals<K extends keyof T>(field: K, value: T[K]): this;
|
|
25
|
+
/**
|
|
26
|
+
* Not equals filter: field != value
|
|
27
|
+
*/
|
|
28
|
+
notEquals<K extends keyof T>(field: K, value: T[K]): this;
|
|
29
|
+
/**
|
|
30
|
+
* Greater than filter: field > value
|
|
31
|
+
*/
|
|
32
|
+
greaterThan<K extends keyof T>(field: K, value: T[K]): this;
|
|
33
|
+
/**
|
|
34
|
+
* Greater than or equal filter: field >= value
|
|
35
|
+
*/
|
|
36
|
+
greaterThanOrEqual<K extends keyof T>(field: K, value: T[K]): this;
|
|
37
|
+
/**
|
|
38
|
+
* Less than filter: field < value
|
|
39
|
+
*/
|
|
40
|
+
lessThan<K extends keyof T>(field: K, value: T[K]): this;
|
|
41
|
+
/**
|
|
42
|
+
* Less than or equal filter: field <= value
|
|
43
|
+
*/
|
|
44
|
+
lessThanOrEqual<K extends keyof T>(field: K, value: T[K]): this;
|
|
45
|
+
/**
|
|
46
|
+
* IN filter: field IN (value1, value2, ...)
|
|
47
|
+
*/
|
|
48
|
+
in<K extends keyof T>(field: K, values: T[K][]): this;
|
|
49
|
+
/**
|
|
50
|
+
* NOT IN filter: field NOT IN (value1, value2, ...)
|
|
51
|
+
*/
|
|
52
|
+
notIn<K extends keyof T>(field: K, values: T[K][]): this;
|
|
53
|
+
/**
|
|
54
|
+
* LIKE filter: field LIKE pattern
|
|
55
|
+
*/
|
|
56
|
+
like<K extends keyof T>(field: K, pattern: string): this;
|
|
57
|
+
/**
|
|
58
|
+
* IS NULL filter: field IS NULL
|
|
59
|
+
*/
|
|
60
|
+
isNull<K extends keyof T>(field: K): this;
|
|
61
|
+
/**
|
|
62
|
+
* IS NOT NULL filter: field IS NOT NULL
|
|
63
|
+
*/
|
|
64
|
+
isNotNull<K extends keyof T>(field: K): this;
|
|
65
|
+
/**
|
|
66
|
+
* Build the filter condition
|
|
67
|
+
*/
|
|
68
|
+
build(): FilterCondition;
|
|
69
|
+
/**
|
|
70
|
+
* Get raw conditions array
|
|
71
|
+
*/
|
|
72
|
+
getConditions(): FilterCondition[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Type-safe query builder
|
|
76
|
+
*/
|
|
77
|
+
declare class QueryBuilder<T = any> {
|
|
78
|
+
private query;
|
|
79
|
+
private _object;
|
|
80
|
+
constructor(object: string);
|
|
81
|
+
/**
|
|
82
|
+
* Select specific fields
|
|
83
|
+
*/
|
|
84
|
+
select<K extends keyof T>(...fields: K[]): this;
|
|
85
|
+
/**
|
|
86
|
+
* Add filters using a builder function
|
|
87
|
+
*/
|
|
88
|
+
where(builderFn: (builder: FilterBuilder<T>) => void): this;
|
|
89
|
+
/**
|
|
90
|
+
* Add raw filter condition
|
|
91
|
+
*/
|
|
92
|
+
filter(condition: FilterCondition): this;
|
|
93
|
+
/**
|
|
94
|
+
* Sort by fields
|
|
95
|
+
*/
|
|
96
|
+
orderBy<K extends keyof T>(field: K, order?: 'asc' | 'desc'): this;
|
|
97
|
+
/**
|
|
98
|
+
* Limit the number of results
|
|
99
|
+
*/
|
|
100
|
+
limit(count: number): this;
|
|
101
|
+
/**
|
|
102
|
+
* Skip records (for pagination)
|
|
103
|
+
*/
|
|
104
|
+
skip(count: number): this;
|
|
105
|
+
/**
|
|
106
|
+
* Paginate results
|
|
107
|
+
*/
|
|
108
|
+
paginate(page: number, pageSize: number): this;
|
|
109
|
+
/**
|
|
110
|
+
* Group by fields
|
|
111
|
+
*/
|
|
112
|
+
groupBy<K extends keyof T>(...fields: K[]): this;
|
|
113
|
+
/**
|
|
114
|
+
* Build the final query AST
|
|
115
|
+
*/
|
|
116
|
+
build(): QueryAST;
|
|
117
|
+
/**
|
|
118
|
+
* Get the current query state
|
|
119
|
+
*/
|
|
120
|
+
getQuery(): Partial<QueryAST>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a type-safe query builder for an object
|
|
124
|
+
*/
|
|
125
|
+
declare function createQuery<T = any>(object: string): QueryBuilder<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Create a type-safe filter builder
|
|
128
|
+
*/
|
|
129
|
+
declare function createFilter<T = any>(): FilterBuilder<T>;
|
|
130
|
+
|
|
131
|
+
interface ClientConfig {
|
|
132
|
+
baseUrl: string;
|
|
133
|
+
token?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Custom fetch implementation (e.g. node-fetch or for Next.js caching)
|
|
136
|
+
*/
|
|
137
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
138
|
+
/**
|
|
139
|
+
* Logger instance for debugging
|
|
140
|
+
*/
|
|
141
|
+
logger?: Logger;
|
|
142
|
+
/**
|
|
143
|
+
* Enable debug logging
|
|
144
|
+
*/
|
|
145
|
+
debug?: boolean;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Discovery Result
|
|
149
|
+
* Re-export from @objectstack/spec/api for convenience
|
|
150
|
+
*/
|
|
151
|
+
type DiscoveryResult = GetDiscoveryResponse;
|
|
152
|
+
interface QueryOptions {
|
|
153
|
+
select?: string[];
|
|
154
|
+
filters?: Record<string, any>;
|
|
155
|
+
sort?: string | string[] | SortNode[];
|
|
156
|
+
top?: number;
|
|
157
|
+
skip?: number;
|
|
158
|
+
aggregations?: AggregationNode[];
|
|
159
|
+
groupBy?: string[];
|
|
160
|
+
}
|
|
161
|
+
interface PaginatedResult<T = any> {
|
|
162
|
+
value: T[];
|
|
163
|
+
count: number;
|
|
164
|
+
}
|
|
165
|
+
interface StandardError {
|
|
166
|
+
code: StandardErrorCode;
|
|
167
|
+
message: string;
|
|
168
|
+
category: ErrorCategory;
|
|
169
|
+
httpStatus: number;
|
|
170
|
+
retryable: boolean;
|
|
171
|
+
details?: Record<string, any>;
|
|
172
|
+
}
|
|
173
|
+
declare class ObjectStackClient {
|
|
174
|
+
private baseUrl;
|
|
175
|
+
private token?;
|
|
176
|
+
private fetchImpl;
|
|
177
|
+
private discoveryInfo?;
|
|
178
|
+
private logger;
|
|
179
|
+
constructor(config: ClientConfig);
|
|
180
|
+
/**
|
|
181
|
+
* Initialize the client by discovering server capabilities.
|
|
182
|
+
*/
|
|
183
|
+
connect(): Promise<{
|
|
184
|
+
version: string;
|
|
185
|
+
apiName: string;
|
|
186
|
+
capabilities?: {
|
|
187
|
+
search: boolean;
|
|
188
|
+
files: boolean;
|
|
189
|
+
graphql: boolean;
|
|
190
|
+
analytics: boolean;
|
|
191
|
+
hub: boolean;
|
|
192
|
+
websockets: boolean;
|
|
193
|
+
} | undefined;
|
|
194
|
+
endpoints?: {
|
|
195
|
+
data: string;
|
|
196
|
+
metadata: string;
|
|
197
|
+
auth: string;
|
|
198
|
+
graphql?: string | undefined;
|
|
199
|
+
storage?: string | undefined;
|
|
200
|
+
automation?: string | undefined;
|
|
201
|
+
analytics?: string | undefined;
|
|
202
|
+
hub?: string | undefined;
|
|
203
|
+
} | undefined;
|
|
204
|
+
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Metadata Operations
|
|
207
|
+
*/
|
|
208
|
+
meta: {
|
|
209
|
+
/**
|
|
210
|
+
* Get all available metadata types
|
|
211
|
+
* Returns types like 'object', 'plugin', 'view', etc.
|
|
212
|
+
*/
|
|
213
|
+
getTypes: () => Promise<GetMetaTypesResponse>;
|
|
214
|
+
/**
|
|
215
|
+
* Get all items of a specific metadata type
|
|
216
|
+
* @param type - Metadata type name (e.g., 'object', 'plugin')
|
|
217
|
+
*/
|
|
218
|
+
getItems: (type: string) => Promise<GetMetaItemsResponse>;
|
|
219
|
+
/**
|
|
220
|
+
* Get a specific object definition by name
|
|
221
|
+
* @deprecated Use `getItem('object', name)` instead for consistency with spec protocol
|
|
222
|
+
* @param name - Object name (snake_case identifier)
|
|
223
|
+
*/
|
|
224
|
+
getObject: (name: string) => Promise<any>;
|
|
225
|
+
/**
|
|
226
|
+
* Get a specific metadata item by type and name
|
|
227
|
+
* @param type - Metadata type (e.g., 'object', 'plugin')
|
|
228
|
+
* @param name - Item name (snake_case identifier)
|
|
229
|
+
*/
|
|
230
|
+
getItem: (type: string, name: string) => Promise<any>;
|
|
231
|
+
/**
|
|
232
|
+
* Save a metadata item
|
|
233
|
+
* @param type - Metadata type (e.g., 'object', 'plugin')
|
|
234
|
+
* @param name - Item name
|
|
235
|
+
* @param item - The metadata content to save
|
|
236
|
+
*/
|
|
237
|
+
saveItem: (type: string, name: string, item: any) => Promise<any>;
|
|
238
|
+
/**
|
|
239
|
+
* Get object metadata with cache support
|
|
240
|
+
* Supports ETag-based conditional requests for efficient caching
|
|
241
|
+
*/
|
|
242
|
+
getCached: (name: string, cacheOptions?: MetadataCacheRequest) => Promise<MetadataCacheResponse>;
|
|
243
|
+
getView: (object: string, type?: "list" | "form") => Promise<any>;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Analytics Services
|
|
247
|
+
*/
|
|
248
|
+
analytics: {
|
|
249
|
+
query: (payload: any) => Promise<any>;
|
|
250
|
+
meta: (cube: string) => Promise<any>;
|
|
251
|
+
explain: (payload: any) => Promise<any>;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Hub Management Services
|
|
255
|
+
*/
|
|
256
|
+
hub: {
|
|
257
|
+
spaces: {
|
|
258
|
+
list: () => Promise<any>;
|
|
259
|
+
create: (payload: any) => Promise<any>;
|
|
260
|
+
};
|
|
261
|
+
plugins: {
|
|
262
|
+
install: (pkg: string, version?: string) => Promise<any>;
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Authentication Services
|
|
267
|
+
*/
|
|
268
|
+
auth: {
|
|
269
|
+
login: (request: LoginRequest) => Promise<SessionResponse>;
|
|
270
|
+
logout: () => Promise<void>;
|
|
271
|
+
me: () => Promise<SessionResponse>;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Storage Services
|
|
275
|
+
*/
|
|
276
|
+
storage: {
|
|
277
|
+
upload: (file: any, scope?: string) => Promise<FileUploadResponse>;
|
|
278
|
+
getDownloadUrl: (fileId: string) => Promise<string>;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Automation Services
|
|
282
|
+
*/
|
|
283
|
+
automation: {
|
|
284
|
+
trigger: (triggerName: string, payload: any) => Promise<any>;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Data Operations
|
|
288
|
+
*/
|
|
289
|
+
data: {
|
|
290
|
+
/**
|
|
291
|
+
* Advanced Query using ObjectStack Query Protocol
|
|
292
|
+
* Supports both simplified options and full AST
|
|
293
|
+
*/
|
|
294
|
+
query: <T = any>(object: string, query: Partial<QueryAST>) => Promise<PaginatedResult<T>>;
|
|
295
|
+
find: <T = any>(object: string, options?: QueryOptions) => Promise<PaginatedResult<T>>;
|
|
296
|
+
get: <T = any>(object: string, id: string) => Promise<T>;
|
|
297
|
+
create: <T = any>(object: string, data: Partial<T>) => Promise<T>;
|
|
298
|
+
createMany: <T = any>(object: string, data: Partial<T>[]) => Promise<T[]>;
|
|
299
|
+
update: <T = any>(object: string, id: string, data: Partial<T>) => Promise<T>;
|
|
300
|
+
/**
|
|
301
|
+
* Batch update multiple records
|
|
302
|
+
* Uses the new BatchUpdateRequest schema with full control over options
|
|
303
|
+
*/
|
|
304
|
+
batch: (object: string, request: BatchUpdateRequest) => Promise<BatchUpdateResponse>;
|
|
305
|
+
/**
|
|
306
|
+
* Update multiple records (simplified batch update)
|
|
307
|
+
* Convenience method for batch updates without full BatchUpdateRequest
|
|
308
|
+
*/
|
|
309
|
+
updateMany: <T = any>(object: string, records: Array<{
|
|
310
|
+
id: string;
|
|
311
|
+
data: Partial<T>;
|
|
312
|
+
}>, options?: BatchOptions) => Promise<BatchUpdateResponse>;
|
|
313
|
+
delete: (object: string, id: string) => Promise<{
|
|
314
|
+
success: boolean;
|
|
315
|
+
}>;
|
|
316
|
+
/**
|
|
317
|
+
* Delete multiple records by IDs
|
|
318
|
+
*/
|
|
319
|
+
deleteMany: (object: string, ids: string[], options?: BatchOptions) => Promise<BatchUpdateResponse>;
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Private Helpers
|
|
323
|
+
*/
|
|
324
|
+
private isFilterAST;
|
|
325
|
+
private fetch;
|
|
326
|
+
/**
|
|
327
|
+
* Get the conventional route path for a given API endpoint type
|
|
328
|
+
* ObjectStack uses standard conventions: /api/v1/data, /api/v1/metadata, /api/v1/ui
|
|
329
|
+
*/
|
|
330
|
+
private getRoute;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export { type ClientConfig, type DiscoveryResult, FilterBuilder, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type StandardError, createFilter, createQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,134 @@
|
|
|
1
|
-
import { QueryAST, SortNode, AggregationNode } from '@objectstack/spec/data';
|
|
2
|
-
import {
|
|
1
|
+
import { FilterCondition, QueryAST, SortNode, AggregationNode } from '@objectstack/spec/data';
|
|
2
|
+
import { GetDiscoveryResponse, StandardErrorCode, ErrorCategory, GetMetaTypesResponse, GetMetaItemsResponse, MetadataCacheRequest, MetadataCacheResponse, LoginRequest, SessionResponse, FileUploadResponse, BatchUpdateRequest, BatchUpdateResponse, BatchOptions } from '@objectstack/spec/api';
|
|
3
|
+
export { BatchOperationResult, BatchOptions, BatchRecord, BatchUpdateRequest, BatchUpdateResponse, DeleteManyRequest, ErrorCategory, GetDiscoveryResponse, GetMetaItemsResponse, GetMetaTypesResponse, MetadataCacheRequest, MetadataCacheResponse, StandardErrorCode, UpdateManyRequest } from '@objectstack/spec/api';
|
|
3
4
|
import { Logger } from '@objectstack/core';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type-Safe Query Builder
|
|
8
|
+
*
|
|
9
|
+
* Provides a fluent API for building ObjectStack queries with:
|
|
10
|
+
* - Compile-time type checking
|
|
11
|
+
* - Intelligent code completion
|
|
12
|
+
* - Runtime validation
|
|
13
|
+
* - Type-safe filters and selections
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Type-safe filter builder
|
|
18
|
+
*/
|
|
19
|
+
declare class FilterBuilder<T = any> {
|
|
20
|
+
private conditions;
|
|
21
|
+
/**
|
|
22
|
+
* Equality filter: field = value
|
|
23
|
+
*/
|
|
24
|
+
equals<K extends keyof T>(field: K, value: T[K]): this;
|
|
25
|
+
/**
|
|
26
|
+
* Not equals filter: field != value
|
|
27
|
+
*/
|
|
28
|
+
notEquals<K extends keyof T>(field: K, value: T[K]): this;
|
|
29
|
+
/**
|
|
30
|
+
* Greater than filter: field > value
|
|
31
|
+
*/
|
|
32
|
+
greaterThan<K extends keyof T>(field: K, value: T[K]): this;
|
|
33
|
+
/**
|
|
34
|
+
* Greater than or equal filter: field >= value
|
|
35
|
+
*/
|
|
36
|
+
greaterThanOrEqual<K extends keyof T>(field: K, value: T[K]): this;
|
|
37
|
+
/**
|
|
38
|
+
* Less than filter: field < value
|
|
39
|
+
*/
|
|
40
|
+
lessThan<K extends keyof T>(field: K, value: T[K]): this;
|
|
41
|
+
/**
|
|
42
|
+
* Less than or equal filter: field <= value
|
|
43
|
+
*/
|
|
44
|
+
lessThanOrEqual<K extends keyof T>(field: K, value: T[K]): this;
|
|
45
|
+
/**
|
|
46
|
+
* IN filter: field IN (value1, value2, ...)
|
|
47
|
+
*/
|
|
48
|
+
in<K extends keyof T>(field: K, values: T[K][]): this;
|
|
49
|
+
/**
|
|
50
|
+
* NOT IN filter: field NOT IN (value1, value2, ...)
|
|
51
|
+
*/
|
|
52
|
+
notIn<K extends keyof T>(field: K, values: T[K][]): this;
|
|
53
|
+
/**
|
|
54
|
+
* LIKE filter: field LIKE pattern
|
|
55
|
+
*/
|
|
56
|
+
like<K extends keyof T>(field: K, pattern: string): this;
|
|
57
|
+
/**
|
|
58
|
+
* IS NULL filter: field IS NULL
|
|
59
|
+
*/
|
|
60
|
+
isNull<K extends keyof T>(field: K): this;
|
|
61
|
+
/**
|
|
62
|
+
* IS NOT NULL filter: field IS NOT NULL
|
|
63
|
+
*/
|
|
64
|
+
isNotNull<K extends keyof T>(field: K): this;
|
|
65
|
+
/**
|
|
66
|
+
* Build the filter condition
|
|
67
|
+
*/
|
|
68
|
+
build(): FilterCondition;
|
|
69
|
+
/**
|
|
70
|
+
* Get raw conditions array
|
|
71
|
+
*/
|
|
72
|
+
getConditions(): FilterCondition[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Type-safe query builder
|
|
76
|
+
*/
|
|
77
|
+
declare class QueryBuilder<T = any> {
|
|
78
|
+
private query;
|
|
79
|
+
private _object;
|
|
80
|
+
constructor(object: string);
|
|
81
|
+
/**
|
|
82
|
+
* Select specific fields
|
|
83
|
+
*/
|
|
84
|
+
select<K extends keyof T>(...fields: K[]): this;
|
|
85
|
+
/**
|
|
86
|
+
* Add filters using a builder function
|
|
87
|
+
*/
|
|
88
|
+
where(builderFn: (builder: FilterBuilder<T>) => void): this;
|
|
89
|
+
/**
|
|
90
|
+
* Add raw filter condition
|
|
91
|
+
*/
|
|
92
|
+
filter(condition: FilterCondition): this;
|
|
93
|
+
/**
|
|
94
|
+
* Sort by fields
|
|
95
|
+
*/
|
|
96
|
+
orderBy<K extends keyof T>(field: K, order?: 'asc' | 'desc'): this;
|
|
97
|
+
/**
|
|
98
|
+
* Limit the number of results
|
|
99
|
+
*/
|
|
100
|
+
limit(count: number): this;
|
|
101
|
+
/**
|
|
102
|
+
* Skip records (for pagination)
|
|
103
|
+
*/
|
|
104
|
+
skip(count: number): this;
|
|
105
|
+
/**
|
|
106
|
+
* Paginate results
|
|
107
|
+
*/
|
|
108
|
+
paginate(page: number, pageSize: number): this;
|
|
109
|
+
/**
|
|
110
|
+
* Group by fields
|
|
111
|
+
*/
|
|
112
|
+
groupBy<K extends keyof T>(...fields: K[]): this;
|
|
113
|
+
/**
|
|
114
|
+
* Build the final query AST
|
|
115
|
+
*/
|
|
116
|
+
build(): QueryAST;
|
|
117
|
+
/**
|
|
118
|
+
* Get the current query state
|
|
119
|
+
*/
|
|
120
|
+
getQuery(): Partial<QueryAST>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a type-safe query builder for an object
|
|
124
|
+
*/
|
|
125
|
+
declare function createQuery<T = any>(object: string): QueryBuilder<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Create a type-safe filter builder
|
|
128
|
+
*/
|
|
129
|
+
declare function createFilter<T = any>(): FilterBuilder<T>;
|
|
130
|
+
|
|
131
|
+
interface ClientConfig {
|
|
5
132
|
baseUrl: string;
|
|
6
133
|
token?: string;
|
|
7
134
|
/**
|
|
@@ -21,8 +148,8 @@ export interface ClientConfig {
|
|
|
21
148
|
* Discovery Result
|
|
22
149
|
* Re-export from @objectstack/spec/api for convenience
|
|
23
150
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
151
|
+
type DiscoveryResult = GetDiscoveryResponse;
|
|
152
|
+
interface QueryOptions {
|
|
26
153
|
select?: string[];
|
|
27
154
|
filters?: Record<string, any>;
|
|
28
155
|
sort?: string | string[] | SortNode[];
|
|
@@ -31,11 +158,11 @@ export interface QueryOptions {
|
|
|
31
158
|
aggregations?: AggregationNode[];
|
|
32
159
|
groupBy?: string[];
|
|
33
160
|
}
|
|
34
|
-
|
|
161
|
+
interface PaginatedResult<T = any> {
|
|
35
162
|
value: T[];
|
|
36
163
|
count: number;
|
|
37
164
|
}
|
|
38
|
-
|
|
165
|
+
interface StandardError {
|
|
39
166
|
code: StandardErrorCode;
|
|
40
167
|
message: string;
|
|
41
168
|
category: ErrorCategory;
|
|
@@ -43,7 +170,7 @@ export interface StandardError {
|
|
|
43
170
|
retryable: boolean;
|
|
44
171
|
details?: Record<string, any>;
|
|
45
172
|
}
|
|
46
|
-
|
|
173
|
+
declare class ObjectStackClient {
|
|
47
174
|
private baseUrl;
|
|
48
175
|
private token?;
|
|
49
176
|
private fetchImpl;
|
|
@@ -202,5 +329,5 @@ export declare class ObjectStackClient {
|
|
|
202
329
|
*/
|
|
203
330
|
private getRoute;
|
|
204
331
|
}
|
|
205
|
-
|
|
206
|
-
export
|
|
332
|
+
|
|
333
|
+
export { type ClientConfig, type DiscoveryResult, FilterBuilder, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type StandardError, createFilter, createQuery };
|