@objectstack/client 3.3.1 → 4.0.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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +45 -0
- package/README.md +9 -6
- package/dist/index.d.mts +83 -13
- package/dist/index.d.ts +83 -13
- package/dist/index.js +74 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/client.hono.test.ts +2 -2
- package/src/client.msw.test.ts +2 -2
- package/src/client.test.ts +70 -0
- package/src/index.ts +127 -40
- package/src/query-builder.ts +10 -1
- package/tsconfig.json +2 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/client@
|
|
2
|
+
> @objectstack/client@4.0.0 build /home/runner/work/spec/spec/packages/client
|
|
3
3
|
> tsup --config ../../tsup.config.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
14
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
16
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
17
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m53.98 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m109.49 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 41ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.js [22m[32m55.15 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m109.54 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 42ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 5329ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m33.59 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m33.59 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @objectstack/client
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f08ffc3: Fix discovery API endpoint routing and protocol consistency.
|
|
8
|
+
|
|
9
|
+
**Discovery route standardization:**
|
|
10
|
+
|
|
11
|
+
- All adapters (Express, Fastify, Hono, NestJS, Next.js, Nuxt, SvelteKit) now mount the discovery endpoint at `{prefix}/discovery` instead of `{prefix}` root.
|
|
12
|
+
- `.well-known/objectstack` redirects now point to `{prefix}/discovery`.
|
|
13
|
+
- Client `connect()` fallback URL changed from `/api/v1` to `/api/v1/discovery`.
|
|
14
|
+
- Runtime dispatcher handles both `/discovery` (standard) and `/` (legacy) for backward compatibility.
|
|
15
|
+
|
|
16
|
+
**Schema & route alignment:**
|
|
17
|
+
|
|
18
|
+
- Added `storage` (service: `file-storage`) and `feed` (service: `data`) routes to `DEFAULT_DISPATCHER_ROUTES`.
|
|
19
|
+
- Added `feed` and `discovery` fields to `ApiRoutesSchema`.
|
|
20
|
+
- Unified `GetDiscoveryResponseSchema` with `DiscoverySchema` as single source of truth.
|
|
21
|
+
- Client `getRoute('feed')` fallback updated from `/api/v1/data` to `/api/v1/feed`.
|
|
22
|
+
|
|
23
|
+
**Type safety:**
|
|
24
|
+
|
|
25
|
+
- Extracted `ApiRouteType` from `ApiRoutes` keys for type-safe client route resolution.
|
|
26
|
+
- Removed `as any` type casting in client route access.
|
|
27
|
+
|
|
28
|
+
- e0b0a78: Deprecate DataEngineQueryOptions in favor of QueryAST-aligned EngineQueryOptions.
|
|
29
|
+
|
|
30
|
+
Engine, Protocol, and Client now use standard QueryAST parameter names:
|
|
31
|
+
|
|
32
|
+
- `filter` → `where`
|
|
33
|
+
- `select` → `fields`
|
|
34
|
+
- `sort` → `orderBy`
|
|
35
|
+
- `skip` → `offset`
|
|
36
|
+
- `populate` → `expand`
|
|
37
|
+
- `top` → `limit`
|
|
38
|
+
|
|
39
|
+
The old DataEngine\* schemas and types are preserved with `@deprecated` markers for backward compatibility.
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [f08ffc3]
|
|
44
|
+
- Updated dependencies [e0b0a78]
|
|
45
|
+
- @objectstack/spec@4.0.0
|
|
46
|
+
- @objectstack/core@4.0.0
|
|
47
|
+
|
|
3
48
|
## 3.3.1
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -147,12 +147,15 @@ Initializes the client by fetching the system discovery manifest from `/api/v1`.
|
|
|
147
147
|
- `setDefault(id, object)`: Set a view as default for an object.
|
|
148
148
|
|
|
149
149
|
### Query Options
|
|
150
|
-
The `find` method accepts an options object:
|
|
151
|
-
- `
|
|
152
|
-
- `
|
|
153
|
-
- `
|
|
154
|
-
- `
|
|
155
|
-
- `
|
|
150
|
+
The `find` method accepts an options object with canonical field names:
|
|
151
|
+
- `where`: Filter conditions (WHERE clause). Accepts object or FilterCondition AST.
|
|
152
|
+
- `fields`: Array of field names to retrieve (SELECT clause).
|
|
153
|
+
- `orderBy`: Sort definition — `'name'`, `['-created_at', 'name']`, or `SortNode[]`.
|
|
154
|
+
- `limit`: Maximum number of records to return (LIMIT).
|
|
155
|
+
- `offset`: Number of records to skip (OFFSET).
|
|
156
|
+
- `expand`: Relations to expand (JOIN / eager-load).
|
|
157
|
+
|
|
158
|
+
> **Deprecated aliases** (accepted for backward compatibility): `select` → `fields`, `filter`/`filters` → `where`, `sort` → `orderBy`, `top` → `limit`, `skip` → `offset`.
|
|
156
159
|
|
|
157
160
|
### Batch Options
|
|
158
161
|
Batch operations support the following options:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FilterCondition, QueryAST, SortNode, AggregationNode } from '@objectstack/spec/data';
|
|
2
|
-
import {
|
|
2
|
+
import { ApiRoutes, GetDiscoveryResponse, WellKnownCapabilities, GetMetaTypesResponse, GetMetaItemsResponse, MetadataCacheRequest, MetadataCacheResponse, LoginRequest, SessionResponse, RegisterRequest, FileUploadResponse, GetPresignedUrlRequest, PresignedUrlResponse, InitiateChunkedUploadRequest, InitiateChunkedUploadResponse, UploadChunkResponse, CompleteChunkedUploadRequest, CompleteChunkedUploadResponse, CheckPermissionRequest, CheckPermissionResponse, GetObjectPermissionsResponse, GetEffectivePermissionsResponse, RealtimeConnectRequest, RealtimeConnectResponse, RealtimeSubscribeRequest, RealtimeSubscribeResponse, SetPresenceRequest, GetPresenceResponse, GetWorkflowConfigResponse, GetWorkflowStateResponse, WorkflowTransitionRequest, WorkflowTransitionResponse, WorkflowApproveRequest, WorkflowApproveResponse, WorkflowRejectRequest, WorkflowRejectResponse, ListViewsResponse, GetViewResponse, CreateViewRequest, CreateViewResponse, UpdateViewRequest, UpdateViewResponse, DeleteViewResponse, RegisterDeviceRequest, RegisterDeviceResponse, UnregisterDeviceResponse, GetNotificationPreferencesResponse, UpdateNotificationPreferencesRequest, UpdateNotificationPreferencesResponse, ListNotificationsResponse, MarkNotificationsReadResponse, MarkAllNotificationsReadResponse, AiNlqRequest, AiNlqResponse, AiChatRequest, AiChatResponse, AiSuggestRequest, AiSuggestResponse, AiInsightsRequest, AiInsightsResponse, GetLocalesResponse, GetTranslationsResponse, GetFieldLabelsResponse, GetFeedResponse, CreateFeedItemResponse, UpdateFeedItemResponse, DeleteFeedItemResponse, AddReactionResponse, RemoveReactionResponse, PinFeedItemResponse, UnpinFeedItemResponse, StarFeedItemResponse, UnstarFeedItemResponse, SearchFeedResponse, GetChangelogResponse, SubscribeResponse, UnsubscribeResponse, BatchUpdateRequest, BatchUpdateResponse, BatchOptions, StandardErrorCode, ErrorCategory } from '@objectstack/spec/api';
|
|
3
3
|
export { AddReactionResponse, AiChatRequest, AiChatResponse, AiInsightsRequest, AiInsightsResponse, AiNlqRequest, AiNlqResponse, AiSuggestRequest, AiSuggestResponse, BatchOperationResult, BatchOptions, BatchRecord, BatchUpdateRequest, BatchUpdateResponse, CheckPermissionRequest, CheckPermissionResponse, CreateFeedItemResponse, CreateViewResponse, DeleteFeedItemResponse, DeleteManyRequest, DeleteViewResponse, ErrorCategory, GetChangelogResponse, GetDiscoveryResponse, GetEffectivePermissionsResponse, GetFeedResponse, GetFieldLabelsResponse, GetLocalesResponse, GetMetaItemsResponse, GetMetaTypesResponse, GetObjectPermissionsResponse, GetPresenceResponse, GetTranslationsResponse, GetViewResponse, GetWorkflowConfigResponse, GetWorkflowStateResponse, ListNotificationsResponse, ListViewsResponse, MetadataCacheRequest, MetadataCacheResponse, PinFeedItemResponse, RealtimeConnectRequest, RealtimeConnectResponse, RealtimeSubscribeRequest, RealtimeSubscribeResponse, RefreshTokenRequest, RegisterDeviceRequest, RegisterDeviceResponse, RegisterRequest, RemoveReactionResponse, SearchFeedResponse, StandardErrorCode, StarFeedItemResponse, SubscribeResponse, UnpinFeedItemResponse, UnstarFeedItemResponse, UnsubscribeResponse, UpdateFeedItemResponse, UpdateManyRequest, UpdateViewResponse, WellKnownCapabilities, WorkflowApproveRequest, WorkflowApproveResponse, WorkflowRejectRequest, WorkflowRejectResponse, WorkflowTransitionRequest, WorkflowTransitionResponse } from '@objectstack/spec/api';
|
|
4
4
|
import { Logger } from '@objectstack/core';
|
|
5
5
|
|
|
@@ -119,9 +119,14 @@ declare class QueryBuilder<T = any> {
|
|
|
119
119
|
*/
|
|
120
120
|
limit(count: number): this;
|
|
121
121
|
/**
|
|
122
|
-
* Skip records (for pagination)
|
|
122
|
+
* Skip records (for pagination).
|
|
123
|
+
* @deprecated Prefer `.offset()` for alignment with Spec canonical field names.
|
|
123
124
|
*/
|
|
124
125
|
skip(count: number): this;
|
|
126
|
+
/**
|
|
127
|
+
* Offset records (for pagination) — canonical alias for `.skip()`
|
|
128
|
+
*/
|
|
129
|
+
offset(count: number): this;
|
|
125
130
|
/**
|
|
126
131
|
* Paginate results
|
|
127
132
|
*/
|
|
@@ -167,6 +172,12 @@ declare function createQuery<T = any>(object: string): QueryBuilder<T>;
|
|
|
167
172
|
*/
|
|
168
173
|
declare function createFilter<T = any>(): FilterBuilder<T>;
|
|
169
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Route types that the client can resolve.
|
|
177
|
+
* Covers all keys from `ApiRoutes` (the discovery schema) plus
|
|
178
|
+
* client-specific virtual routes (`views`, `permissions`).
|
|
179
|
+
*/
|
|
180
|
+
type ApiRouteType = keyof ApiRoutes | 'views' | 'permissions';
|
|
170
181
|
interface ClientConfig {
|
|
171
182
|
baseUrl: string;
|
|
172
183
|
token?: string;
|
|
@@ -188,6 +199,16 @@ interface ClientConfig {
|
|
|
188
199
|
* Re-export from @objectstack/spec/api for convenience
|
|
189
200
|
*/
|
|
190
201
|
type DiscoveryResult = GetDiscoveryResponse;
|
|
202
|
+
/**
|
|
203
|
+
* @deprecated Use `data.query()` with standard QueryAST parameters instead.
|
|
204
|
+
* This interface uses legacy parameter names (filter/sort/top/skip) that
|
|
205
|
+
* require translation to QueryAST. Prefer QueryAST fields directly:
|
|
206
|
+
* - filter → where
|
|
207
|
+
* - select → fields
|
|
208
|
+
* - sort → orderBy
|
|
209
|
+
* - skip → offset
|
|
210
|
+
* - top → limit
|
|
211
|
+
*/
|
|
191
212
|
interface QueryOptions {
|
|
192
213
|
select?: string[];
|
|
193
214
|
/** @canonical Preferred filter parameter (singular). */
|
|
@@ -200,6 +221,36 @@ interface QueryOptions {
|
|
|
200
221
|
aggregations?: AggregationNode[];
|
|
201
222
|
groupBy?: string[];
|
|
202
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Canonical query options using Spec protocol field names.
|
|
226
|
+
* This is the recommended interface for `data.find()` queries.
|
|
227
|
+
*
|
|
228
|
+
* Canonical field mapping (QueryAST-aligned):
|
|
229
|
+
* - `where` — filter conditions (replaces legacy `filter`/`filters`)
|
|
230
|
+
* - `fields` — field selection (replaces legacy `select`)
|
|
231
|
+
* - `orderBy` — sort definition (replaces legacy `sort`)
|
|
232
|
+
* - `limit` — max records (replaces legacy `top`)
|
|
233
|
+
* - `offset` — skip records (replaces legacy `skip`)
|
|
234
|
+
* - `expand` — relation loading (replaces legacy `populate`)
|
|
235
|
+
*/
|
|
236
|
+
interface QueryOptionsV2 {
|
|
237
|
+
/** Filter conditions (WHERE clause). Accepts MongoDB-style $op object or FilterCondition AST. */
|
|
238
|
+
where?: Record<string, any> | unknown[];
|
|
239
|
+
/** Fields to retrieve (SELECT clause). */
|
|
240
|
+
fields?: string[];
|
|
241
|
+
/** Sort definition (ORDER BY clause). */
|
|
242
|
+
orderBy?: string | string[] | SortNode[];
|
|
243
|
+
/** Maximum number of records to return (LIMIT). */
|
|
244
|
+
limit?: number;
|
|
245
|
+
/** Number of records to skip (OFFSET). */
|
|
246
|
+
offset?: number;
|
|
247
|
+
/** Relations to expand (JOIN / eager-load). */
|
|
248
|
+
expand?: Record<string, any> | string[];
|
|
249
|
+
/** Aggregation functions. */
|
|
250
|
+
aggregations?: AggregationNode[];
|
|
251
|
+
/** Group by fields. */
|
|
252
|
+
groupBy?: string[];
|
|
253
|
+
}
|
|
203
254
|
interface PaginatedResult<T = any> {
|
|
204
255
|
/** Spec-compliant: array of matching records */
|
|
205
256
|
records: T[];
|
|
@@ -254,10 +305,12 @@ declare class ObjectStackClient {
|
|
|
254
305
|
*/
|
|
255
306
|
connect(): Promise<{
|
|
256
307
|
version: string;
|
|
257
|
-
|
|
308
|
+
name?: string | undefined;
|
|
309
|
+
environment?: "development" | "production" | "sandbox" | undefined;
|
|
258
310
|
routes?: {
|
|
259
311
|
data: string;
|
|
260
312
|
metadata: string;
|
|
313
|
+
discovery?: string | undefined;
|
|
261
314
|
ui?: string | undefined;
|
|
262
315
|
auth?: string | undefined;
|
|
263
316
|
automation?: string | undefined;
|
|
@@ -270,6 +323,12 @@ declare class ObjectStackClient {
|
|
|
270
323
|
notifications?: string | undefined;
|
|
271
324
|
ai?: string | undefined;
|
|
272
325
|
i18n?: string | undefined;
|
|
326
|
+
feed?: string | undefined;
|
|
327
|
+
} | undefined;
|
|
328
|
+
locale?: {
|
|
329
|
+
default: string;
|
|
330
|
+
supported: string[];
|
|
331
|
+
timezone: string;
|
|
273
332
|
} | undefined;
|
|
274
333
|
services?: Record<string, {
|
|
275
334
|
enabled: boolean;
|
|
@@ -285,20 +344,27 @@ declare class ObjectStackClient {
|
|
|
285
344
|
retryAfterMs?: number | undefined;
|
|
286
345
|
} | undefined;
|
|
287
346
|
}> | undefined;
|
|
288
|
-
capabilities?: {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
347
|
+
capabilities?: Record<string, {
|
|
348
|
+
enabled: boolean;
|
|
349
|
+
features?: Record<string, boolean> | undefined;
|
|
350
|
+
description?: string | undefined;
|
|
351
|
+
}> | undefined;
|
|
352
|
+
schemaDiscovery?: {
|
|
353
|
+
openapi?: string | undefined;
|
|
354
|
+
graphql?: string | undefined;
|
|
355
|
+
jsonSchema?: string | undefined;
|
|
296
356
|
} | undefined;
|
|
357
|
+
metadata?: Record<string, unknown> | undefined;
|
|
358
|
+
apiName?: string | undefined;
|
|
297
359
|
}>;
|
|
298
360
|
/**
|
|
299
361
|
* Well-known capability flags discovered from the server.
|
|
300
362
|
* Returns undefined if the client has not yet connected or the server
|
|
301
363
|
* did not include capabilities in its discovery response.
|
|
364
|
+
*
|
|
365
|
+
* The server may return capabilities in hierarchical format
|
|
366
|
+
* `{ key: { enabled: boolean } }` or flat boolean format `{ key: boolean }`.
|
|
367
|
+
* This getter normalizes both to flat `WellKnownCapabilities`.
|
|
302
368
|
*/
|
|
303
369
|
get capabilities(): WellKnownCapabilities | undefined;
|
|
304
370
|
/**
|
|
@@ -814,7 +880,11 @@ declare class ObjectStackClient {
|
|
|
814
880
|
* Supports both simplified options and full AST
|
|
815
881
|
*/
|
|
816
882
|
query: <T = any>(object: string, query: Partial<QueryAST>) => Promise<PaginatedResult<T>>;
|
|
817
|
-
|
|
883
|
+
/**
|
|
884
|
+
* @deprecated Use `data.query()` with standard QueryAST parameters instead.
|
|
885
|
+
* This method uses legacy parameter names. Internally adapts to HTTP GET params.
|
|
886
|
+
*/
|
|
887
|
+
find: <T = any>(object: string, options?: QueryOptions | QueryOptionsV2) => Promise<PaginatedResult<T>>;
|
|
818
888
|
get: <T = any>(object: string, id: string) => Promise<GetDataResult<T>>;
|
|
819
889
|
create: <T = any>(object: string, data: Partial<T>) => Promise<CreateDataResult<T>>;
|
|
820
890
|
createMany: <T = any>(object: string, data: Partial<T>[]) => Promise<T[]>;
|
|
@@ -858,4 +928,4 @@ declare class ObjectStackClient {
|
|
|
858
928
|
private getRoute;
|
|
859
929
|
}
|
|
860
930
|
|
|
861
|
-
export { type ClientConfig, type CreateDataResult, type DeleteDataResult, type DiscoveryResult, FilterBuilder, type GetDataResult, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type StandardError, type UpdateDataResult, createFilter, createQuery };
|
|
931
|
+
export { type ApiRouteType, type ClientConfig, type CreateDataResult, type DeleteDataResult, type DiscoveryResult, FilterBuilder, type GetDataResult, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type QueryOptionsV2, type StandardError, type UpdateDataResult, createFilter, createQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FilterCondition, QueryAST, SortNode, AggregationNode } from '@objectstack/spec/data';
|
|
2
|
-
import {
|
|
2
|
+
import { ApiRoutes, GetDiscoveryResponse, WellKnownCapabilities, GetMetaTypesResponse, GetMetaItemsResponse, MetadataCacheRequest, MetadataCacheResponse, LoginRequest, SessionResponse, RegisterRequest, FileUploadResponse, GetPresignedUrlRequest, PresignedUrlResponse, InitiateChunkedUploadRequest, InitiateChunkedUploadResponse, UploadChunkResponse, CompleteChunkedUploadRequest, CompleteChunkedUploadResponse, CheckPermissionRequest, CheckPermissionResponse, GetObjectPermissionsResponse, GetEffectivePermissionsResponse, RealtimeConnectRequest, RealtimeConnectResponse, RealtimeSubscribeRequest, RealtimeSubscribeResponse, SetPresenceRequest, GetPresenceResponse, GetWorkflowConfigResponse, GetWorkflowStateResponse, WorkflowTransitionRequest, WorkflowTransitionResponse, WorkflowApproveRequest, WorkflowApproveResponse, WorkflowRejectRequest, WorkflowRejectResponse, ListViewsResponse, GetViewResponse, CreateViewRequest, CreateViewResponse, UpdateViewRequest, UpdateViewResponse, DeleteViewResponse, RegisterDeviceRequest, RegisterDeviceResponse, UnregisterDeviceResponse, GetNotificationPreferencesResponse, UpdateNotificationPreferencesRequest, UpdateNotificationPreferencesResponse, ListNotificationsResponse, MarkNotificationsReadResponse, MarkAllNotificationsReadResponse, AiNlqRequest, AiNlqResponse, AiChatRequest, AiChatResponse, AiSuggestRequest, AiSuggestResponse, AiInsightsRequest, AiInsightsResponse, GetLocalesResponse, GetTranslationsResponse, GetFieldLabelsResponse, GetFeedResponse, CreateFeedItemResponse, UpdateFeedItemResponse, DeleteFeedItemResponse, AddReactionResponse, RemoveReactionResponse, PinFeedItemResponse, UnpinFeedItemResponse, StarFeedItemResponse, UnstarFeedItemResponse, SearchFeedResponse, GetChangelogResponse, SubscribeResponse, UnsubscribeResponse, BatchUpdateRequest, BatchUpdateResponse, BatchOptions, StandardErrorCode, ErrorCategory } from '@objectstack/spec/api';
|
|
3
3
|
export { AddReactionResponse, AiChatRequest, AiChatResponse, AiInsightsRequest, AiInsightsResponse, AiNlqRequest, AiNlqResponse, AiSuggestRequest, AiSuggestResponse, BatchOperationResult, BatchOptions, BatchRecord, BatchUpdateRequest, BatchUpdateResponse, CheckPermissionRequest, CheckPermissionResponse, CreateFeedItemResponse, CreateViewResponse, DeleteFeedItemResponse, DeleteManyRequest, DeleteViewResponse, ErrorCategory, GetChangelogResponse, GetDiscoveryResponse, GetEffectivePermissionsResponse, GetFeedResponse, GetFieldLabelsResponse, GetLocalesResponse, GetMetaItemsResponse, GetMetaTypesResponse, GetObjectPermissionsResponse, GetPresenceResponse, GetTranslationsResponse, GetViewResponse, GetWorkflowConfigResponse, GetWorkflowStateResponse, ListNotificationsResponse, ListViewsResponse, MetadataCacheRequest, MetadataCacheResponse, PinFeedItemResponse, RealtimeConnectRequest, RealtimeConnectResponse, RealtimeSubscribeRequest, RealtimeSubscribeResponse, RefreshTokenRequest, RegisterDeviceRequest, RegisterDeviceResponse, RegisterRequest, RemoveReactionResponse, SearchFeedResponse, StandardErrorCode, StarFeedItemResponse, SubscribeResponse, UnpinFeedItemResponse, UnstarFeedItemResponse, UnsubscribeResponse, UpdateFeedItemResponse, UpdateManyRequest, UpdateViewResponse, WellKnownCapabilities, WorkflowApproveRequest, WorkflowApproveResponse, WorkflowRejectRequest, WorkflowRejectResponse, WorkflowTransitionRequest, WorkflowTransitionResponse } from '@objectstack/spec/api';
|
|
4
4
|
import { Logger } from '@objectstack/core';
|
|
5
5
|
|
|
@@ -119,9 +119,14 @@ declare class QueryBuilder<T = any> {
|
|
|
119
119
|
*/
|
|
120
120
|
limit(count: number): this;
|
|
121
121
|
/**
|
|
122
|
-
* Skip records (for pagination)
|
|
122
|
+
* Skip records (for pagination).
|
|
123
|
+
* @deprecated Prefer `.offset()` for alignment with Spec canonical field names.
|
|
123
124
|
*/
|
|
124
125
|
skip(count: number): this;
|
|
126
|
+
/**
|
|
127
|
+
* Offset records (for pagination) — canonical alias for `.skip()`
|
|
128
|
+
*/
|
|
129
|
+
offset(count: number): this;
|
|
125
130
|
/**
|
|
126
131
|
* Paginate results
|
|
127
132
|
*/
|
|
@@ -167,6 +172,12 @@ declare function createQuery<T = any>(object: string): QueryBuilder<T>;
|
|
|
167
172
|
*/
|
|
168
173
|
declare function createFilter<T = any>(): FilterBuilder<T>;
|
|
169
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Route types that the client can resolve.
|
|
177
|
+
* Covers all keys from `ApiRoutes` (the discovery schema) plus
|
|
178
|
+
* client-specific virtual routes (`views`, `permissions`).
|
|
179
|
+
*/
|
|
180
|
+
type ApiRouteType = keyof ApiRoutes | 'views' | 'permissions';
|
|
170
181
|
interface ClientConfig {
|
|
171
182
|
baseUrl: string;
|
|
172
183
|
token?: string;
|
|
@@ -188,6 +199,16 @@ interface ClientConfig {
|
|
|
188
199
|
* Re-export from @objectstack/spec/api for convenience
|
|
189
200
|
*/
|
|
190
201
|
type DiscoveryResult = GetDiscoveryResponse;
|
|
202
|
+
/**
|
|
203
|
+
* @deprecated Use `data.query()` with standard QueryAST parameters instead.
|
|
204
|
+
* This interface uses legacy parameter names (filter/sort/top/skip) that
|
|
205
|
+
* require translation to QueryAST. Prefer QueryAST fields directly:
|
|
206
|
+
* - filter → where
|
|
207
|
+
* - select → fields
|
|
208
|
+
* - sort → orderBy
|
|
209
|
+
* - skip → offset
|
|
210
|
+
* - top → limit
|
|
211
|
+
*/
|
|
191
212
|
interface QueryOptions {
|
|
192
213
|
select?: string[];
|
|
193
214
|
/** @canonical Preferred filter parameter (singular). */
|
|
@@ -200,6 +221,36 @@ interface QueryOptions {
|
|
|
200
221
|
aggregations?: AggregationNode[];
|
|
201
222
|
groupBy?: string[];
|
|
202
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Canonical query options using Spec protocol field names.
|
|
226
|
+
* This is the recommended interface for `data.find()` queries.
|
|
227
|
+
*
|
|
228
|
+
* Canonical field mapping (QueryAST-aligned):
|
|
229
|
+
* - `where` — filter conditions (replaces legacy `filter`/`filters`)
|
|
230
|
+
* - `fields` — field selection (replaces legacy `select`)
|
|
231
|
+
* - `orderBy` — sort definition (replaces legacy `sort`)
|
|
232
|
+
* - `limit` — max records (replaces legacy `top`)
|
|
233
|
+
* - `offset` — skip records (replaces legacy `skip`)
|
|
234
|
+
* - `expand` — relation loading (replaces legacy `populate`)
|
|
235
|
+
*/
|
|
236
|
+
interface QueryOptionsV2 {
|
|
237
|
+
/** Filter conditions (WHERE clause). Accepts MongoDB-style $op object or FilterCondition AST. */
|
|
238
|
+
where?: Record<string, any> | unknown[];
|
|
239
|
+
/** Fields to retrieve (SELECT clause). */
|
|
240
|
+
fields?: string[];
|
|
241
|
+
/** Sort definition (ORDER BY clause). */
|
|
242
|
+
orderBy?: string | string[] | SortNode[];
|
|
243
|
+
/** Maximum number of records to return (LIMIT). */
|
|
244
|
+
limit?: number;
|
|
245
|
+
/** Number of records to skip (OFFSET). */
|
|
246
|
+
offset?: number;
|
|
247
|
+
/** Relations to expand (JOIN / eager-load). */
|
|
248
|
+
expand?: Record<string, any> | string[];
|
|
249
|
+
/** Aggregation functions. */
|
|
250
|
+
aggregations?: AggregationNode[];
|
|
251
|
+
/** Group by fields. */
|
|
252
|
+
groupBy?: string[];
|
|
253
|
+
}
|
|
203
254
|
interface PaginatedResult<T = any> {
|
|
204
255
|
/** Spec-compliant: array of matching records */
|
|
205
256
|
records: T[];
|
|
@@ -254,10 +305,12 @@ declare class ObjectStackClient {
|
|
|
254
305
|
*/
|
|
255
306
|
connect(): Promise<{
|
|
256
307
|
version: string;
|
|
257
|
-
|
|
308
|
+
name?: string | undefined;
|
|
309
|
+
environment?: "development" | "production" | "sandbox" | undefined;
|
|
258
310
|
routes?: {
|
|
259
311
|
data: string;
|
|
260
312
|
metadata: string;
|
|
313
|
+
discovery?: string | undefined;
|
|
261
314
|
ui?: string | undefined;
|
|
262
315
|
auth?: string | undefined;
|
|
263
316
|
automation?: string | undefined;
|
|
@@ -270,6 +323,12 @@ declare class ObjectStackClient {
|
|
|
270
323
|
notifications?: string | undefined;
|
|
271
324
|
ai?: string | undefined;
|
|
272
325
|
i18n?: string | undefined;
|
|
326
|
+
feed?: string | undefined;
|
|
327
|
+
} | undefined;
|
|
328
|
+
locale?: {
|
|
329
|
+
default: string;
|
|
330
|
+
supported: string[];
|
|
331
|
+
timezone: string;
|
|
273
332
|
} | undefined;
|
|
274
333
|
services?: Record<string, {
|
|
275
334
|
enabled: boolean;
|
|
@@ -285,20 +344,27 @@ declare class ObjectStackClient {
|
|
|
285
344
|
retryAfterMs?: number | undefined;
|
|
286
345
|
} | undefined;
|
|
287
346
|
}> | undefined;
|
|
288
|
-
capabilities?: {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
347
|
+
capabilities?: Record<string, {
|
|
348
|
+
enabled: boolean;
|
|
349
|
+
features?: Record<string, boolean> | undefined;
|
|
350
|
+
description?: string | undefined;
|
|
351
|
+
}> | undefined;
|
|
352
|
+
schemaDiscovery?: {
|
|
353
|
+
openapi?: string | undefined;
|
|
354
|
+
graphql?: string | undefined;
|
|
355
|
+
jsonSchema?: string | undefined;
|
|
296
356
|
} | undefined;
|
|
357
|
+
metadata?: Record<string, unknown> | undefined;
|
|
358
|
+
apiName?: string | undefined;
|
|
297
359
|
}>;
|
|
298
360
|
/**
|
|
299
361
|
* Well-known capability flags discovered from the server.
|
|
300
362
|
* Returns undefined if the client has not yet connected or the server
|
|
301
363
|
* did not include capabilities in its discovery response.
|
|
364
|
+
*
|
|
365
|
+
* The server may return capabilities in hierarchical format
|
|
366
|
+
* `{ key: { enabled: boolean } }` or flat boolean format `{ key: boolean }`.
|
|
367
|
+
* This getter normalizes both to flat `WellKnownCapabilities`.
|
|
302
368
|
*/
|
|
303
369
|
get capabilities(): WellKnownCapabilities | undefined;
|
|
304
370
|
/**
|
|
@@ -814,7 +880,11 @@ declare class ObjectStackClient {
|
|
|
814
880
|
* Supports both simplified options and full AST
|
|
815
881
|
*/
|
|
816
882
|
query: <T = any>(object: string, query: Partial<QueryAST>) => Promise<PaginatedResult<T>>;
|
|
817
|
-
|
|
883
|
+
/**
|
|
884
|
+
* @deprecated Use `data.query()` with standard QueryAST parameters instead.
|
|
885
|
+
* This method uses legacy parameter names. Internally adapts to HTTP GET params.
|
|
886
|
+
*/
|
|
887
|
+
find: <T = any>(object: string, options?: QueryOptions | QueryOptionsV2) => Promise<PaginatedResult<T>>;
|
|
818
888
|
get: <T = any>(object: string, id: string) => Promise<GetDataResult<T>>;
|
|
819
889
|
create: <T = any>(object: string, data: Partial<T>) => Promise<CreateDataResult<T>>;
|
|
820
890
|
createMany: <T = any>(object: string, data: Partial<T>[]) => Promise<T[]>;
|
|
@@ -858,4 +928,4 @@ declare class ObjectStackClient {
|
|
|
858
928
|
private getRoute;
|
|
859
929
|
}
|
|
860
930
|
|
|
861
|
-
export { type ClientConfig, type CreateDataResult, type DeleteDataResult, type DiscoveryResult, FilterBuilder, type GetDataResult, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type StandardError, type UpdateDataResult, createFilter, createQuery };
|
|
931
|
+
export { type ApiRouteType, type ClientConfig, type CreateDataResult, type DeleteDataResult, type DiscoveryResult, FilterBuilder, type GetDataResult, ObjectStackClient, type PaginatedResult, QueryBuilder, type QueryOptions, type QueryOptionsV2, type StandardError, type UpdateDataResult, createFilter, createQuery };
|