@objectql/types 4.0.1 → 4.0.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/README.md +4 -0
- package/dist/api.d.ts +14 -8
- package/dist/api.js.map +1 -1
- package/dist/field.d.ts +1 -1
- package/dist/object.d.ts +1 -10
- package/dist/query.d.ts +48 -11
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# @objectql/types
|
|
2
2
|
|
|
3
|
+
> **Implementation Status**: ✅ **Complete** - All type definitions available. See [Implementation Status](https://github.com/objectstack-ai/objectql/blob/main/IMPLEMENTATION_STATUS.md) for runtime implementation details.
|
|
4
|
+
|
|
3
5
|
Type definitions for the ObjectQL system, including object schemas, field configurations, validation rules, queries, hooks, and actions.
|
|
4
6
|
|
|
7
|
+
> **Note**: This package defines the type system. Some types (like permissions and workflows) are defined but require application-layer implementation. See the implementation status document for details.
|
|
8
|
+
|
|
5
9
|
## Features
|
|
6
10
|
|
|
7
11
|
- **Object & Field Types**: Define data models with `ObjectConfig` and `FieldConfig`
|
package/dist/api.d.ts
CHANGED
|
@@ -96,16 +96,22 @@ export interface DataApiListResponse<T = unknown> extends DataApiResponse<T> {
|
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Response for single item operations (findOne, create, update)
|
|
99
|
+
* Single item operations wrap the data in a 'data' field
|
|
99
100
|
*/
|
|
100
101
|
export interface DataApiItemResponse<T = unknown> extends DataApiResponse<T> {
|
|
101
|
-
/** The item
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
/** The returned item data */
|
|
103
|
+
data?: T & {
|
|
104
|
+
/** The item ID */
|
|
105
|
+
_id?: string | number;
|
|
106
|
+
/** Object type identifier */
|
|
107
|
+
'@type'?: string;
|
|
108
|
+
/** Timestamp when created */
|
|
109
|
+
created_at?: string | Date;
|
|
110
|
+
/** Timestamp when last updated */
|
|
111
|
+
updated_at?: string | Date;
|
|
112
|
+
/** Additional item fields */
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
};
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
111
117
|
* Query parameters for GET /api/data/:object (list records)
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA6jBH,4CASC;AAxjBD,+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;AAqeD;;GAEG;AACU,QAAA,kBAAkB,GAA2B;IACtD,GAAG,EAAE,eAAe;IACpB,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,YAAY;CACtB,CAAC;AAEF;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAAuB;;IACpD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAEzF,OAAO;QACH,GAAG,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,0BAAkB,CAAC,GAAG,CAAC;QACzD,IAAI,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,0BAAkB,CAAC,IAAI,CAAC;QAC5D,QAAQ,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,0BAAkB,CAAC,QAAQ,CAAC;QACxE,KAAK,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,mCAAI,0BAAkB,CAAC,KAAK,CAAC;KAClE,CAAC;AACN,CAAC"}
|
package/dist/field.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ export interface FieldOption {
|
|
|
104
104
|
* - `deleteBehavior`: Made optional with protocol-compatible enum values
|
|
105
105
|
*
|
|
106
106
|
* All other protocol properties (description, defaultValue, maxLength, minLength, precision, scale, min, max,
|
|
107
|
-
* reference, referenceFilters, writeRequiresMasterRead, expression,
|
|
107
|
+
* reference, referenceFilters, writeRequiresMasterRead, expression, summaryOperations) are inherited as-is.
|
|
108
108
|
*/
|
|
109
109
|
export interface FieldConfig extends Omit<Field, 'name' | 'label' | 'type' | 'options' | 'required' | 'multiple' | 'unique' | 'deleteBehavior' | 'hidden' | 'readonly' | 'encryption' | 'index' | 'externalId' | 'searchable'> {
|
|
110
110
|
/** Field name (inferred from Record key when used in ObjectConfig.fields) */
|
package/dist/object.d.ts
CHANGED
|
@@ -5,18 +5,9 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import { Data } from '@objectstack/spec';
|
|
9
|
-
type ServiceObject = Data.ServiceObject;
|
|
10
|
-
type IndexSchema = NonNullable<ServiceObject['indexes']>[number];
|
|
11
8
|
import { FieldConfig } from './field';
|
|
12
9
|
import { ActionConfig } from './action';
|
|
13
10
|
import { AnyValidationRule } from './validation';
|
|
14
|
-
/**
|
|
15
|
-
* Re-export Protocol Types from the Constitution
|
|
16
|
-
*
|
|
17
|
-
* @deprecated Import directly from @objectstack/spec instead
|
|
18
|
-
*/
|
|
19
|
-
export type { ServiceObject as SpecObject, IndexSchema };
|
|
20
11
|
/**
|
|
21
12
|
* RUNTIME-SPECIFIC TYPES
|
|
22
13
|
* The following types extend or complement the Protocol Constitution
|
|
@@ -63,7 +54,7 @@ export interface ObjectAiConfig {
|
|
|
63
54
|
* Runtime Object Configuration
|
|
64
55
|
*
|
|
65
56
|
* Extends the Protocol ServiceObject with runtime-specific properties.
|
|
66
|
-
* The Protocol Constitution
|
|
57
|
+
* The Protocol Constitution defines the core object schema.
|
|
67
58
|
* This adds runtime conveniences like actions, AI config, and validation rules.
|
|
68
59
|
*/
|
|
69
60
|
export interface ObjectConfig {
|
package/dist/query.d.ts
CHANGED
|
@@ -22,33 +22,70 @@ type FilterCondition = Data.FilterCondition;
|
|
|
22
22
|
* Note: $not operator is not supported. Use $ne for field-level negation.
|
|
23
23
|
*/
|
|
24
24
|
export type Filter = FilterCondition;
|
|
25
|
-
|
|
25
|
+
/** @deprecated Use AggregationFunctionType instead */
|
|
26
|
+
export type AggregateFunction = AggregationFunctionType;
|
|
27
|
+
/** @deprecated Use AggregationNode instead */
|
|
26
28
|
export interface AggregateOption {
|
|
27
29
|
func: AggregateFunction;
|
|
28
30
|
field: string;
|
|
29
31
|
alias?: string;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Sort Node - Standard Protocol Format
|
|
35
|
+
* Represents an "Order By" clause.
|
|
36
|
+
*/
|
|
37
|
+
export interface SortNode {
|
|
38
|
+
/** Field name to sort by */
|
|
39
|
+
field: string;
|
|
40
|
+
/** Sort direction - defaults to 'asc' */
|
|
41
|
+
order: 'asc' | 'desc';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Aggregation Function - Standard Protocol Format
|
|
45
|
+
*/
|
|
46
|
+
export type AggregationFunctionType = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct' | 'array_agg' | 'string_agg';
|
|
47
|
+
/**
|
|
48
|
+
* Aggregation Node - Standard Protocol Format
|
|
49
|
+
* Represents an aggregated field with function.
|
|
50
|
+
*/
|
|
51
|
+
export interface AggregationNode {
|
|
52
|
+
/** Aggregation function to apply */
|
|
53
|
+
function: AggregationFunctionType;
|
|
54
|
+
/** Field to aggregate (optional for count) */
|
|
55
|
+
field?: string;
|
|
56
|
+
/** Alias for the result field */
|
|
57
|
+
alias: string;
|
|
58
|
+
/** Apply DISTINCT to the field before aggregation */
|
|
59
|
+
distinct?: boolean;
|
|
60
|
+
/** Optional filter condition for this aggregation */
|
|
61
|
+
filter?: Filter;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Unified Query Interface - Standard Protocol Format
|
|
33
65
|
*
|
|
34
|
-
*
|
|
66
|
+
* Uses @objectstack/spec QueryAST format directly.
|
|
67
|
+
* This is the single source of truth for query structure.
|
|
35
68
|
*/
|
|
36
69
|
export interface UnifiedQuery {
|
|
37
70
|
/** Field selection - specify which fields to return */
|
|
38
71
|
fields?: string[];
|
|
39
|
-
/** Filter conditions using
|
|
40
|
-
|
|
41
|
-
/** Sort order - array of
|
|
42
|
-
|
|
43
|
-
/** Pagination - number of records to skip */
|
|
44
|
-
|
|
72
|
+
/** Filter conditions using standard FilterCondition syntax (was: filters) */
|
|
73
|
+
where?: Filter;
|
|
74
|
+
/** Sort order - array of SortNode objects (was: sort as tuples) */
|
|
75
|
+
orderBy?: SortNode[];
|
|
76
|
+
/** Pagination - number of records to skip (was: skip) */
|
|
77
|
+
offset?: number;
|
|
45
78
|
/** Pagination - maximum number of records to return */
|
|
46
79
|
limit?: number;
|
|
47
80
|
/** Relation expansion - load related records */
|
|
48
81
|
expand?: Record<string, UnifiedQuery>;
|
|
49
82
|
/** Aggregation - group by fields */
|
|
50
83
|
groupBy?: string[];
|
|
51
|
-
/** Aggregation - aggregate functions to apply */
|
|
52
|
-
|
|
84
|
+
/** Aggregation - aggregate functions to apply (was: aggregate with func) */
|
|
85
|
+
aggregations?: AggregationNode[];
|
|
86
|
+
/** Filter for aggregated results (HAVING clause) */
|
|
87
|
+
having?: Filter;
|
|
88
|
+
/** Enable distinct results */
|
|
89
|
+
distinct?: boolean;
|
|
53
90
|
}
|
|
54
91
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectql/types",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Pure TypeScript type definitions and interfaces for the ObjectQL protocol - The Contract",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"objectql",
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"test": "jest --passWithNoTests"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@objectstack/spec": "^0.3.
|
|
30
|
+
"@objectstack/spec": "^0.3.3",
|
|
31
31
|
"@objectql/runtime": "^0.2.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@objectstack/spec": "^0.3.
|
|
34
|
+
"@objectstack/spec": "^0.3.3",
|
|
35
35
|
"@objectql/runtime": "workspace:*",
|
|
36
|
-
"ts-json-schema-generator": "^2.4.0"
|
|
36
|
+
"ts-json-schema-generator": "^2.4.0",
|
|
37
|
+
"zod": "^3.23.8"
|
|
37
38
|
}
|
|
38
39
|
}
|