@objectql/types 1.8.1 → 1.8.2
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/api.d.ts +427 -0
- package/dist/api.js +45 -0
- package/dist/api.js.map +1 -0
- package/dist/driver.d.ts +58 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +14 -1
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Type Definitions for ObjectQL
|
|
3
|
+
*
|
|
4
|
+
* This file contains TypeScript interfaces for Data API and Metadata API endpoints.
|
|
5
|
+
* These types enable frontend applications to make type-safe API calls.
|
|
6
|
+
*/
|
|
7
|
+
import { UnifiedQuery, FilterExpression } from './query';
|
|
8
|
+
import { ObjectConfig } from './object';
|
|
9
|
+
import { FieldConfig } from './field';
|
|
10
|
+
import { ActionConfig } from './action';
|
|
11
|
+
/**
|
|
12
|
+
* Standardized error codes for ObjectQL API responses
|
|
13
|
+
*/
|
|
14
|
+
export declare enum ApiErrorCode {
|
|
15
|
+
INVALID_REQUEST = "INVALID_REQUEST",
|
|
16
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
17
|
+
UNAUTHORIZED = "UNAUTHORIZED",
|
|
18
|
+
FORBIDDEN = "FORBIDDEN",
|
|
19
|
+
NOT_FOUND = "NOT_FOUND",
|
|
20
|
+
CONFLICT = "CONFLICT",
|
|
21
|
+
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
22
|
+
DATABASE_ERROR = "DATABASE_ERROR",
|
|
23
|
+
RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error details structure with optional field-specific information
|
|
27
|
+
*/
|
|
28
|
+
export interface ApiErrorDetails {
|
|
29
|
+
field?: string;
|
|
30
|
+
reason?: string;
|
|
31
|
+
fields?: Record<string, string>;
|
|
32
|
+
required_permission?: string;
|
|
33
|
+
user_roles?: string[];
|
|
34
|
+
retry_after?: number;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Standard error response structure
|
|
39
|
+
*/
|
|
40
|
+
export interface ApiError {
|
|
41
|
+
code: ApiErrorCode | string;
|
|
42
|
+
message: string;
|
|
43
|
+
details?: ApiErrorDetails;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ObjectQL Error class for throwing structured errors
|
|
47
|
+
*/
|
|
48
|
+
export declare class ObjectQLError extends Error {
|
|
49
|
+
code: ApiErrorCode | string;
|
|
50
|
+
details?: ApiErrorDetails;
|
|
51
|
+
constructor(error: {
|
|
52
|
+
code: ApiErrorCode | string;
|
|
53
|
+
message: string;
|
|
54
|
+
details?: ApiErrorDetails;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Pagination metadata for list responses
|
|
59
|
+
*/
|
|
60
|
+
export interface PaginationMeta {
|
|
61
|
+
/** Total number of records */
|
|
62
|
+
total: number;
|
|
63
|
+
/** Current page number (1-indexed) */
|
|
64
|
+
page?: number;
|
|
65
|
+
/** Number of items per page */
|
|
66
|
+
size?: number;
|
|
67
|
+
/** Total number of pages */
|
|
68
|
+
pages?: number;
|
|
69
|
+
/** Whether there is a next page */
|
|
70
|
+
has_next?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Base response structure for Data API operations
|
|
74
|
+
*/
|
|
75
|
+
export interface DataApiResponse<T = unknown> {
|
|
76
|
+
/** Error information if the operation failed */
|
|
77
|
+
error?: ApiError;
|
|
78
|
+
/** Additional response fields for successful operations */
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Response for list operations (find)
|
|
83
|
+
*/
|
|
84
|
+
export interface DataApiListResponse<T = unknown> extends DataApiResponse<T> {
|
|
85
|
+
/** Array of retrieved items */
|
|
86
|
+
items?: T[];
|
|
87
|
+
/** Pagination metadata */
|
|
88
|
+
meta?: PaginationMeta;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Response for single item operations (findOne, create, update)
|
|
92
|
+
*/
|
|
93
|
+
export interface DataApiItemResponse<T = unknown> extends DataApiResponse<T> {
|
|
94
|
+
/** The item ID */
|
|
95
|
+
_id?: string | number;
|
|
96
|
+
/** Object type identifier */
|
|
97
|
+
'@type'?: string;
|
|
98
|
+
/** Timestamp when created */
|
|
99
|
+
created_at?: string | Date;
|
|
100
|
+
/** Timestamp when last updated */
|
|
101
|
+
updated_at?: string | Date;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Query parameters for GET /api/data/:object (list records)
|
|
105
|
+
*/
|
|
106
|
+
export interface DataApiListParams {
|
|
107
|
+
/** Filter expression (can be FilterExpression array or JSON string) */
|
|
108
|
+
filter?: FilterExpression | string;
|
|
109
|
+
/** Fields to return (array or comma-separated string) */
|
|
110
|
+
fields?: string[] | string;
|
|
111
|
+
/** Sort criteria - array of [field, direction] tuples */
|
|
112
|
+
sort?: [string, 'asc' | 'desc'][] | string;
|
|
113
|
+
/** Maximum number of records to return */
|
|
114
|
+
limit?: number;
|
|
115
|
+
/** Number of records to skip (for pagination) */
|
|
116
|
+
skip?: number;
|
|
117
|
+
/** Offset alias for skip */
|
|
118
|
+
offset?: number;
|
|
119
|
+
/** OData-style top parameter (alias for limit) */
|
|
120
|
+
top?: number;
|
|
121
|
+
/** Expand related records */
|
|
122
|
+
expand?: Record<string, UnifiedQuery>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Request body for POST /api/data/:object (create single record)
|
|
126
|
+
*/
|
|
127
|
+
export interface DataApiCreateRequest {
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Request body for POST /api/data/:object (create multiple records)
|
|
132
|
+
*/
|
|
133
|
+
export type DataApiCreateManyRequest = Array<Record<string, unknown>>;
|
|
134
|
+
/**
|
|
135
|
+
* Request body for PUT /api/data/:object/:id (update record)
|
|
136
|
+
*/
|
|
137
|
+
export interface DataApiUpdateRequest {
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Request body for POST /api/data/:object/bulk-update (update many records)
|
|
142
|
+
*/
|
|
143
|
+
export interface DataApiBulkUpdateRequest {
|
|
144
|
+
/** Filter criteria to select records to update */
|
|
145
|
+
filters: FilterExpression;
|
|
146
|
+
/** Data to update */
|
|
147
|
+
data: Record<string, unknown>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Request body for POST /api/data/:object/bulk-delete (delete many records)
|
|
151
|
+
*/
|
|
152
|
+
export interface DataApiBulkDeleteRequest {
|
|
153
|
+
/** Filter criteria to select records to delete */
|
|
154
|
+
filters: FilterExpression;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Response for count operations
|
|
158
|
+
*/
|
|
159
|
+
export interface DataApiCountResponse extends DataApiResponse {
|
|
160
|
+
/** Number of records matching the criteria */
|
|
161
|
+
count?: number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Response for delete operations
|
|
165
|
+
*/
|
|
166
|
+
export interface DataApiDeleteResponse extends DataApiResponse {
|
|
167
|
+
/** Whether the operation was successful */
|
|
168
|
+
success?: boolean;
|
|
169
|
+
/** Number of deleted records (for bulk operations) */
|
|
170
|
+
deleted_count?: number;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Base response structure for Metadata API operations
|
|
174
|
+
*/
|
|
175
|
+
export interface MetadataApiResponse<T = unknown> {
|
|
176
|
+
/** Error information if the operation failed */
|
|
177
|
+
error?: ApiError;
|
|
178
|
+
/** Additional response fields */
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Response for list metadata operations
|
|
183
|
+
*/
|
|
184
|
+
export interface MetadataApiListResponse<T = unknown> extends MetadataApiResponse<T> {
|
|
185
|
+
/** Array of metadata items */
|
|
186
|
+
items: T[];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Simplified object metadata for list views
|
|
190
|
+
*/
|
|
191
|
+
export interface ObjectMetadataSummary {
|
|
192
|
+
/** Object name (internal identifier) */
|
|
193
|
+
name: string;
|
|
194
|
+
/** Display label */
|
|
195
|
+
label?: string;
|
|
196
|
+
/** Icon identifier */
|
|
197
|
+
icon?: string;
|
|
198
|
+
/** Object description */
|
|
199
|
+
description?: string;
|
|
200
|
+
/** Field definitions (simplified) */
|
|
201
|
+
fields?: Record<string, FieldConfig>;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Detailed object metadata for single object view
|
|
205
|
+
*/
|
|
206
|
+
export interface ObjectMetadataDetail extends ObjectConfig {
|
|
207
|
+
/** Formatted fields with name property populated */
|
|
208
|
+
fields: Record<string, FieldConfig & {
|
|
209
|
+
name: string;
|
|
210
|
+
}>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Response for GET /api/metadata/objects (list all objects)
|
|
214
|
+
*/
|
|
215
|
+
export interface MetadataApiObjectListResponse extends MetadataApiListResponse<ObjectMetadataSummary> {
|
|
216
|
+
items: ObjectMetadataSummary[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Response for GET /api/metadata/object/:name (get single object)
|
|
220
|
+
*/
|
|
221
|
+
export interface MetadataApiObjectDetailResponse extends MetadataApiResponse<ObjectMetadataDetail> {
|
|
222
|
+
/** Object name */
|
|
223
|
+
name: string;
|
|
224
|
+
/** Display label */
|
|
225
|
+
label?: string;
|
|
226
|
+
/** Icon identifier */
|
|
227
|
+
icon?: string;
|
|
228
|
+
/** Description */
|
|
229
|
+
description?: string;
|
|
230
|
+
/** Field definitions with populated names */
|
|
231
|
+
fields: Record<string, FieldConfig & {
|
|
232
|
+
name: string;
|
|
233
|
+
}>;
|
|
234
|
+
/** Available actions */
|
|
235
|
+
actions?: Record<string, ActionConfig>;
|
|
236
|
+
/** Validation rules */
|
|
237
|
+
validation?: ObjectConfig['validation'];
|
|
238
|
+
/** AI configuration */
|
|
239
|
+
ai?: ObjectConfig['ai'];
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Field metadata response
|
|
243
|
+
*/
|
|
244
|
+
export interface FieldMetadataResponse extends MetadataApiResponse<FieldConfig> {
|
|
245
|
+
/** Field name */
|
|
246
|
+
name: string;
|
|
247
|
+
/** Field type */
|
|
248
|
+
type: string;
|
|
249
|
+
/** Display label */
|
|
250
|
+
label?: string;
|
|
251
|
+
/** Whether field is required */
|
|
252
|
+
required?: boolean;
|
|
253
|
+
/** Whether field must be unique */
|
|
254
|
+
unique?: boolean;
|
|
255
|
+
/** Default value */
|
|
256
|
+
defaultValue?: unknown;
|
|
257
|
+
/** Options for select/radio fields */
|
|
258
|
+
options?: unknown[];
|
|
259
|
+
/** Minimum value (for number fields) */
|
|
260
|
+
min?: number;
|
|
261
|
+
/** Maximum value (for number fields) */
|
|
262
|
+
max?: number;
|
|
263
|
+
/** Minimum length (for text fields) */
|
|
264
|
+
min_length?: number;
|
|
265
|
+
/** Maximum length (for text fields) */
|
|
266
|
+
max_length?: number;
|
|
267
|
+
/** Regular expression pattern */
|
|
268
|
+
regex?: string;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Action metadata summary
|
|
272
|
+
*/
|
|
273
|
+
export interface ActionMetadataSummary {
|
|
274
|
+
/** Action name (internal identifier) */
|
|
275
|
+
name: string;
|
|
276
|
+
/** Action type (record or global) */
|
|
277
|
+
type: 'record' | 'global';
|
|
278
|
+
/** Display label */
|
|
279
|
+
label?: string;
|
|
280
|
+
/** Action parameters */
|
|
281
|
+
params?: Record<string, unknown>;
|
|
282
|
+
/** Action description */
|
|
283
|
+
description?: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Response for GET /api/metadata/object/:name/actions (list object actions)
|
|
287
|
+
*/
|
|
288
|
+
export interface MetadataApiActionsResponse extends MetadataApiListResponse<ActionMetadataSummary> {
|
|
289
|
+
items: ActionMetadataSummary[];
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Generic metadata entry
|
|
293
|
+
*/
|
|
294
|
+
export interface MetadataEntry {
|
|
295
|
+
/** Metadata type (e.g., 'object', 'view', 'form', 'page') */
|
|
296
|
+
type: string;
|
|
297
|
+
/** Unique identifier */
|
|
298
|
+
id: string;
|
|
299
|
+
/** File path (if loaded from file) */
|
|
300
|
+
path?: string;
|
|
301
|
+
/** Package name (if from a plugin) */
|
|
302
|
+
package?: string;
|
|
303
|
+
/** Actual metadata content */
|
|
304
|
+
content: unknown;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Configuration for Data API client
|
|
308
|
+
*/
|
|
309
|
+
export interface DataApiClientConfig {
|
|
310
|
+
/** Base URL of the ObjectQL server */
|
|
311
|
+
baseUrl: string;
|
|
312
|
+
/** Optional authentication token */
|
|
313
|
+
token?: string;
|
|
314
|
+
/** Custom headers */
|
|
315
|
+
headers?: Record<string, string>;
|
|
316
|
+
/** Request timeout in milliseconds */
|
|
317
|
+
timeout?: number;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Configuration for Metadata API client
|
|
321
|
+
*/
|
|
322
|
+
export interface MetadataApiClientConfig {
|
|
323
|
+
/** Base URL of the ObjectQL server */
|
|
324
|
+
baseUrl: string;
|
|
325
|
+
/** Optional authentication token */
|
|
326
|
+
token?: string;
|
|
327
|
+
/** Custom headers */
|
|
328
|
+
headers?: Record<string, string>;
|
|
329
|
+
/** Request timeout in milliseconds */
|
|
330
|
+
timeout?: number;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Interface for Data API client operations
|
|
334
|
+
*/
|
|
335
|
+
export interface IDataApiClient {
|
|
336
|
+
/**
|
|
337
|
+
* List records from an object
|
|
338
|
+
* @param objectName - Name of the object
|
|
339
|
+
* @param params - Query parameters
|
|
340
|
+
*/
|
|
341
|
+
list<T = unknown>(objectName: string, params?: DataApiListParams): Promise<DataApiListResponse<T>>;
|
|
342
|
+
/**
|
|
343
|
+
* Get a single record by ID
|
|
344
|
+
* @param objectName - Name of the object
|
|
345
|
+
* @param id - Record ID
|
|
346
|
+
*/
|
|
347
|
+
get<T = unknown>(objectName: string, id: string | number): Promise<DataApiItemResponse<T>>;
|
|
348
|
+
/**
|
|
349
|
+
* Create a new record
|
|
350
|
+
* @param objectName - Name of the object
|
|
351
|
+
* @param data - Record data
|
|
352
|
+
*/
|
|
353
|
+
create<T = unknown>(objectName: string, data: DataApiCreateRequest): Promise<DataApiItemResponse<T>>;
|
|
354
|
+
/**
|
|
355
|
+
* Create multiple records
|
|
356
|
+
* @param objectName - Name of the object
|
|
357
|
+
* @param data - Array of record data
|
|
358
|
+
*/
|
|
359
|
+
createMany<T = unknown>(objectName: string, data: DataApiCreateManyRequest): Promise<DataApiListResponse<T>>;
|
|
360
|
+
/**
|
|
361
|
+
* Update a record
|
|
362
|
+
* @param objectName - Name of the object
|
|
363
|
+
* @param id - Record ID
|
|
364
|
+
* @param data - Updated data
|
|
365
|
+
*/
|
|
366
|
+
update<T = unknown>(objectName: string, id: string | number, data: DataApiUpdateRequest): Promise<DataApiItemResponse<T>>;
|
|
367
|
+
/**
|
|
368
|
+
* Update multiple records
|
|
369
|
+
* @param objectName - Name of the object
|
|
370
|
+
* @param request - Bulk update request
|
|
371
|
+
*/
|
|
372
|
+
updateMany(objectName: string, request: DataApiBulkUpdateRequest): Promise<DataApiResponse>;
|
|
373
|
+
/**
|
|
374
|
+
* Delete a record
|
|
375
|
+
* @param objectName - Name of the object
|
|
376
|
+
* @param id - Record ID
|
|
377
|
+
*/
|
|
378
|
+
delete(objectName: string, id: string | number): Promise<DataApiDeleteResponse>;
|
|
379
|
+
/**
|
|
380
|
+
* Delete multiple records
|
|
381
|
+
* @param objectName - Name of the object
|
|
382
|
+
* @param request - Bulk delete request
|
|
383
|
+
*/
|
|
384
|
+
deleteMany(objectName: string, request: DataApiBulkDeleteRequest): Promise<DataApiDeleteResponse>;
|
|
385
|
+
/**
|
|
386
|
+
* Count records
|
|
387
|
+
* @param objectName - Name of the object
|
|
388
|
+
* @param filters - Filter criteria
|
|
389
|
+
*/
|
|
390
|
+
count(objectName: string, filters?: FilterExpression): Promise<DataApiCountResponse>;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Interface for Metadata API client operations
|
|
394
|
+
*/
|
|
395
|
+
export interface IMetadataApiClient {
|
|
396
|
+
/**
|
|
397
|
+
* List all objects
|
|
398
|
+
*/
|
|
399
|
+
listObjects(): Promise<MetadataApiObjectListResponse>;
|
|
400
|
+
/**
|
|
401
|
+
* Get detailed metadata for a specific object
|
|
402
|
+
* @param objectName - Name of the object
|
|
403
|
+
*/
|
|
404
|
+
getObject(objectName: string): Promise<MetadataApiObjectDetailResponse>;
|
|
405
|
+
/**
|
|
406
|
+
* Get field metadata for a specific object field
|
|
407
|
+
* @param objectName - Name of the object
|
|
408
|
+
* @param fieldName - Name of the field
|
|
409
|
+
*/
|
|
410
|
+
getField(objectName: string, fieldName: string): Promise<FieldMetadataResponse>;
|
|
411
|
+
/**
|
|
412
|
+
* List actions for a specific object
|
|
413
|
+
* @param objectName - Name of the object
|
|
414
|
+
*/
|
|
415
|
+
listActions(objectName: string): Promise<MetadataApiActionsResponse>;
|
|
416
|
+
/**
|
|
417
|
+
* List metadata entries by type
|
|
418
|
+
* @param metadataType - Type of metadata (e.g., 'view', 'form', 'page')
|
|
419
|
+
*/
|
|
420
|
+
listByType<T = unknown>(metadataType: string): Promise<MetadataApiListResponse<T>>;
|
|
421
|
+
/**
|
|
422
|
+
* Get a specific metadata entry
|
|
423
|
+
* @param metadataType - Type of metadata
|
|
424
|
+
* @param id - Unique identifier
|
|
425
|
+
*/
|
|
426
|
+
getMetadata<T = unknown>(metadataType: string, id: string): Promise<MetadataApiResponse<T>>;
|
|
427
|
+
}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* API Type Definitions for ObjectQL
|
|
4
|
+
*
|
|
5
|
+
* This file contains TypeScript interfaces for Data API and Metadata API endpoints.
|
|
6
|
+
* These types enable frontend applications to make type-safe API calls.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ObjectQLError = exports.ApiErrorCode = void 0;
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Error Handling Types
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Standardized error codes for ObjectQL API responses
|
|
15
|
+
*/
|
|
16
|
+
var ApiErrorCode;
|
|
17
|
+
(function (ApiErrorCode) {
|
|
18
|
+
ApiErrorCode["INVALID_REQUEST"] = "INVALID_REQUEST";
|
|
19
|
+
ApiErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
20
|
+
ApiErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
|
|
21
|
+
ApiErrorCode["FORBIDDEN"] = "FORBIDDEN";
|
|
22
|
+
ApiErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
23
|
+
ApiErrorCode["CONFLICT"] = "CONFLICT";
|
|
24
|
+
ApiErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
25
|
+
ApiErrorCode["DATABASE_ERROR"] = "DATABASE_ERROR";
|
|
26
|
+
ApiErrorCode["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
|
|
27
|
+
})(ApiErrorCode || (exports.ApiErrorCode = ApiErrorCode = {}));
|
|
28
|
+
/**
|
|
29
|
+
* ObjectQL Error class for throwing structured errors
|
|
30
|
+
*/
|
|
31
|
+
class ObjectQLError extends Error {
|
|
32
|
+
constructor(error) {
|
|
33
|
+
super(error.message);
|
|
34
|
+
this.name = 'ObjectQLError';
|
|
35
|
+
this.code = error.code;
|
|
36
|
+
this.details = error.details;
|
|
37
|
+
// Preserve proper stack traces in Node.js environments
|
|
38
|
+
const ErrorConstructor = Error;
|
|
39
|
+
if (typeof ErrorConstructor.captureStackTrace === 'function') {
|
|
40
|
+
ErrorConstructor.captureStackTrace(this, ObjectQLError);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ObjectQLError = ObjectQLError;
|
|
45
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAOH,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;GAEG;AACH,IAAY,YAUX;AAVD,WAAY,YAAY;IACpB,mDAAmC,CAAA;IACnC,qDAAqC,CAAA;IACrC,6CAA6B,CAAA;IAC7B,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,iDAAiC,CAAA;IACjC,iDAAiC,CAAA;IACjC,2DAA2C,CAAA;AAC/C,CAAC,EAVW,YAAY,4BAAZ,YAAY,QAUvB;AAwBD;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IAIpC,YAAY,KAAkF;QAC1F,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAE7B,uDAAuD;QACvD,MAAM,gBAAgB,GAAG,KAA2F,CAAC;QACrH,IAAI,OAAO,gBAAgB,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;YAC3D,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC;CACJ;AAhBD,sCAgBC"}
|
package/dist/driver.d.ts
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column metadata from database introspection.
|
|
3
|
+
*/
|
|
4
|
+
export interface IntrospectedColumn {
|
|
5
|
+
/** Column name */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Native database type (e.g., 'varchar', 'integer', 'timestamp') */
|
|
8
|
+
type: string;
|
|
9
|
+
/** Whether the column is nullable */
|
|
10
|
+
nullable: boolean;
|
|
11
|
+
/** Default value if any */
|
|
12
|
+
defaultValue?: any;
|
|
13
|
+
/** Whether this is a primary key */
|
|
14
|
+
isPrimary?: boolean;
|
|
15
|
+
/** Whether this column has a unique constraint */
|
|
16
|
+
isUnique?: boolean;
|
|
17
|
+
/** Maximum length for string types */
|
|
18
|
+
maxLength?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Foreign key relationship metadata.
|
|
22
|
+
*/
|
|
23
|
+
export interface IntrospectedForeignKey {
|
|
24
|
+
/** Column name in the source table */
|
|
25
|
+
columnName: string;
|
|
26
|
+
/** Referenced table name */
|
|
27
|
+
referencedTable: string;
|
|
28
|
+
/** Referenced column name */
|
|
29
|
+
referencedColumn: string;
|
|
30
|
+
/** Constraint name */
|
|
31
|
+
constraintName?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Table metadata from database introspection.
|
|
35
|
+
*/
|
|
36
|
+
export interface IntrospectedTable {
|
|
37
|
+
/** Table name */
|
|
38
|
+
name: string;
|
|
39
|
+
/** List of columns */
|
|
40
|
+
columns: IntrospectedColumn[];
|
|
41
|
+
/** List of foreign key relationships */
|
|
42
|
+
foreignKeys: IntrospectedForeignKey[];
|
|
43
|
+
/** Primary key columns */
|
|
44
|
+
primaryKeys: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Complete database schema introspection result.
|
|
48
|
+
*/
|
|
49
|
+
export interface IntrospectedSchema {
|
|
50
|
+
/** Map of table name to table metadata */
|
|
51
|
+
tables: Record<string, IntrospectedTable>;
|
|
52
|
+
}
|
|
1
53
|
export interface Driver {
|
|
2
54
|
find(objectName: string, query: any, options?: any): Promise<any[]>;
|
|
3
55
|
findOne(objectName: string, id: string | number, query?: any, options?: any): Promise<any>;
|
|
@@ -6,6 +58,12 @@ export interface Driver {
|
|
|
6
58
|
delete(objectName: string, id: string | number, options?: any): Promise<any>;
|
|
7
59
|
count(objectName: string, filters: any, options?: any): Promise<number>;
|
|
8
60
|
init?(objects: any[]): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Introspect the database schema to discover existing tables, columns, and relationships.
|
|
63
|
+
* This allows connecting to an existing database without defining metadata.
|
|
64
|
+
* @returns Complete schema information including tables, columns, and foreign keys
|
|
65
|
+
*/
|
|
66
|
+
introspectSchema?(): Promise<IntrospectedSchema>;
|
|
9
67
|
aggregate?(objectName: string, query: any, options?: any): Promise<any>;
|
|
10
68
|
distinct?(objectName: string, field: string, filters?: any, options?: any): Promise<any[]>;
|
|
11
69
|
createMany?(objectName: string, data: any[], options?: any): Promise<any>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,gDAA8B;AAC9B,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,gDAA8B;AAC9B,yCAAuB;AACvB,wCAAsB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectql/types",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
|
+
"description": "Pure TypeScript type definitions and interfaces for the ObjectQL protocol - The Contract",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"objectql",
|
|
7
|
+
"types",
|
|
8
|
+
"typescript",
|
|
9
|
+
"interfaces",
|
|
10
|
+
"protocol",
|
|
11
|
+
"schema",
|
|
12
|
+
"metadata",
|
|
13
|
+
"ai-native",
|
|
14
|
+
"orm",
|
|
15
|
+
"database"
|
|
16
|
+
],
|
|
4
17
|
"license": "MIT",
|
|
5
18
|
"main": "dist/index.js",
|
|
6
19
|
"types": "dist/index.d.ts",
|