@objectql/types 3.0.1 → 4.0.1

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.
Files changed (82) hide show
  1. package/dist/action.d.ts +29 -0
  2. package/dist/action.js +7 -0
  3. package/dist/action.js.map +1 -1
  4. package/dist/api.d.ts +13 -6
  5. package/dist/api.js +4 -3
  6. package/dist/api.js.map +1 -1
  7. package/dist/app.d.ts +12 -0
  8. package/dist/app.js +7 -0
  9. package/dist/app.js.map +1 -1
  10. package/dist/application.d.ts +7 -0
  11. package/dist/application.js +7 -0
  12. package/dist/application.js.map +1 -1
  13. package/dist/config.d.ts +11 -3
  14. package/dist/config.js +7 -0
  15. package/dist/config.js.map +1 -1
  16. package/dist/context.d.ts +7 -0
  17. package/dist/context.js +7 -0
  18. package/dist/context.js.map +1 -1
  19. package/dist/driver.d.ts +67 -0
  20. package/dist/driver.js +7 -0
  21. package/dist/driver.js.map +1 -1
  22. package/dist/field.d.ts +132 -53
  23. package/dist/field.js +7 -0
  24. package/dist/field.js.map +1 -1
  25. package/dist/form.d.ts +7 -0
  26. package/dist/form.js +4 -6
  27. package/dist/form.js.map +1 -1
  28. package/dist/formula.d.ts +7 -0
  29. package/dist/formula.js +9 -2
  30. package/dist/formula.js.map +1 -1
  31. package/dist/hook.d.ts +7 -0
  32. package/dist/hook.js +7 -0
  33. package/dist/hook.js.map +1 -1
  34. package/dist/index.d.ts +14 -1
  35. package/dist/index.js +14 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/loader.d.ts +7 -0
  38. package/dist/loader.js +7 -0
  39. package/dist/loader.js.map +1 -1
  40. package/dist/menu.d.ts +7 -0
  41. package/dist/menu.js +7 -0
  42. package/dist/menu.js.map +1 -1
  43. package/dist/migration.d.ts +7 -0
  44. package/dist/migration.js +7 -0
  45. package/dist/migration.js.map +1 -1
  46. package/dist/object.d.ts +91 -4
  47. package/dist/object.js +7 -0
  48. package/dist/object.js.map +1 -1
  49. package/dist/page.d.ts +7 -0
  50. package/dist/page.js +4 -6
  51. package/dist/page.js.map +1 -1
  52. package/dist/permission.d.ts +7 -0
  53. package/dist/permission.js +4 -6
  54. package/dist/permission.js.map +1 -1
  55. package/dist/query.d.ts +39 -3
  56. package/dist/query.js +7 -0
  57. package/dist/query.js.map +1 -1
  58. package/dist/registry.d.ts +19 -10
  59. package/dist/registry.js +15 -50
  60. package/dist/registry.js.map +1 -1
  61. package/dist/report.d.ts +7 -0
  62. package/dist/report.js +4 -5
  63. package/dist/report.js.map +1 -1
  64. package/dist/repository.d.ts +7 -0
  65. package/dist/repository.js +7 -0
  66. package/dist/repository.js.map +1 -1
  67. package/dist/validation.d.ts +7 -0
  68. package/dist/validation.js +5 -2
  69. package/dist/validation.js.map +1 -1
  70. package/dist/view.d.ts +7 -0
  71. package/dist/view.js +4 -6
  72. package/dist/view.js.map +1 -1
  73. package/dist/workflow.d.ts +7 -0
  74. package/dist/workflow.js +4 -5
  75. package/dist/workflow.js.map +1 -1
  76. package/package.json +12 -6
  77. package/schemas/app.schema.json +1 -0
  78. package/schemas/menu.schema.json +1 -0
  79. package/LICENSE +0 -21
  80. package/dist/plugin.d.ts +0 -5
  81. package/dist/plugin.js +0 -3
  82. package/dist/plugin.js.map +0 -1
package/dist/action.d.ts CHANGED
@@ -1,5 +1,24 @@
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { UI } from '@objectstack/spec';
9
+ type Action = UI.Action;
1
10
  import { FieldConfig } from "./field";
2
11
  import { HookAPI } from "./hook";
12
+ /**
13
+ * Re-export Protocol Types from the Constitution
14
+ *
15
+ * @deprecated Import directly from @objectstack/spec instead
16
+ */
17
+ export type { Action as SpecAction };
18
+ /**
19
+ * RUNTIME-SPECIFIC TYPES
20
+ * The following types extend the Protocol Action definition with runtime execution capabilities
21
+ */
3
22
  /**
4
23
  * Defines the scope of the action.
5
24
  * - `record`: Acts on a specific record instance (e.g. "Approve Order").
@@ -13,6 +32,8 @@ export type ActionType = 'record' | 'global';
13
32
  export type ActionInputDefinition = Record<string, FieldConfig>;
14
33
  /**
15
34
  * Context passed to the action handler execution.
35
+ *
36
+ * RUNTIME TYPE: Used during action execution.
16
37
  */
17
38
  export interface ActionContext<BaseT = any, InputT = any> {
18
39
  /** The object this action belongs to. */
@@ -41,11 +62,17 @@ export interface ActionContext<BaseT = any, InputT = any> {
41
62
  };
42
63
  }
43
64
  /**
65
+ * Runtime Action Configuration
66
+ *
44
67
  * The configuration of an Action visible to the Metadata engine (YAML/JSON side).
68
+ * Compatible with Protocol Action but adds runtime-specific options.
45
69
  */
46
70
  export interface ActionConfig {
71
+ /** Display label */
47
72
  label?: string;
73
+ /** Description */
48
74
  description?: string;
75
+ /** Icon name */
49
76
  icon?: string;
50
77
  /**
51
78
  * Default: 'global' if no fields defined, but usually specified explicitly.
@@ -70,6 +97,8 @@ export interface ActionConfig {
70
97
  }
71
98
  /**
72
99
  * The full implementation definition (Code side).
100
+ *
101
+ * RUNTIME TYPE: Includes the handler function for execution.
73
102
  */
74
103
  export interface ActionDefinition<BaseT = any, InputT = any, ReturnT = any> extends ActionConfig {
75
104
  /**
package/dist/action.js CHANGED
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * ObjectQL
4
+ * Copyright (c) 2026-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  //# sourceMappingURL=action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
package/dist/api.d.ts CHANGED
@@ -1,10 +1,17 @@
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
1
8
  /**
2
9
  * API Type Definitions for ObjectQL
3
10
  *
4
11
  * This file contains TypeScript interfaces for Data API and Metadata API endpoints.
5
12
  * These types enable frontend applications to make type-safe API calls.
6
13
  */
7
- import { UnifiedQuery, FilterExpression } from './query';
14
+ import { UnifiedQuery, Filter } from './query';
8
15
  import { ObjectConfig } from './object';
9
16
  import { FieldConfig } from './field';
10
17
  import { ActionConfig } from './action';
@@ -104,8 +111,8 @@ export interface DataApiItemResponse<T = unknown> extends DataApiResponse<T> {
104
111
  * Query parameters for GET /api/data/:object (list records)
105
112
  */
106
113
  export interface DataApiListParams {
107
- /** Filter expression (can be FilterExpression array or JSON string) */
108
- filter?: FilterExpression | string;
114
+ /** Filter expression (can be Filter object or JSON string) */
115
+ filter?: Filter | string;
109
116
  /** Fields to return (array or comma-separated string) */
110
117
  fields?: string[] | string;
111
118
  /** Sort criteria - array of [field, direction] tuples */
@@ -142,7 +149,7 @@ export interface DataApiUpdateRequest {
142
149
  */
143
150
  export interface DataApiBulkUpdateRequest {
144
151
  /** Filter criteria to select records to update */
145
- filters: FilterExpression;
152
+ filters: Filter;
146
153
  /** Data to update */
147
154
  data: Record<string, unknown>;
148
155
  }
@@ -151,7 +158,7 @@ export interface DataApiBulkUpdateRequest {
151
158
  */
152
159
  export interface DataApiBulkDeleteRequest {
153
160
  /** Filter criteria to select records to delete */
154
- filters: FilterExpression;
161
+ filters: Filter;
155
162
  }
156
163
  /**
157
164
  * Response for count operations
@@ -391,7 +398,7 @@ export interface IDataApiClient {
391
398
  * @param objectName - Name of the object
392
399
  * @param filters - Filter criteria
393
400
  */
394
- count(objectName: string, filters?: FilterExpression): Promise<DataApiCountResponse>;
401
+ count(objectName: string, filters?: Filter): Promise<DataApiCountResponse>;
395
402
  }
396
403
  /**
397
404
  * Interface for Metadata API client operations
package/dist/api.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  /**
3
- * API Type Definitions for ObjectQL
3
+ * ObjectQL
4
+ * Copyright (c) 2026-present ObjectStack Inc.
4
5
  *
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.
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
7
8
  */
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.DEFAULT_API_ROUTES = exports.ObjectQLError = exports.ApiErrorCode = void 0;
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAgjBH,4CASC;AAljBD,+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,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AAQ,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/app.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
1
8
  import { ObjectConfig } from "./object";
2
9
  import { Driver } from "./driver";
3
10
  import { MetadataRegistry } from "./registry";
@@ -16,4 +23,9 @@ export interface IObjectQL {
16
23
  triggerHook(event: HookName, objectName: string, ctx: HookContext): Promise<void>;
17
24
  registerAction(objectName: string, actionName: string, handler: ActionHandler): void;
18
25
  executeAction(objectName: string, actionName: string, ctx: ActionContext): Promise<any>;
26
+ /**
27
+ * Get the underlying ObjectStackKernel instance
28
+ * @returns The ObjectStackKernel instance
29
+ */
30
+ getKernel(): any;
19
31
  }
package/dist/app.js CHANGED
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * ObjectQL
4
+ * Copyright (c) 2026-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  //# sourceMappingURL=app.js.map
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
1
8
  export interface AppConfig {
2
9
  /**
3
10
  * Unique identifier for the application
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * ObjectQL
4
+ * Copyright (c) 2026-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  //# sourceMappingURL=application.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
package/dist/config.d.ts CHANGED
@@ -1,7 +1,14 @@
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
1
8
  import { MetadataRegistry } from "./registry";
2
9
  import { Driver } from "./driver";
3
10
  import { ObjectConfig } from "./object";
4
- import { ObjectQLPlugin } from "./plugin";
11
+ import type { RuntimePlugin } from "../../../objectstack/runtime/dist";
5
12
  export interface ObjectQLConfig {
6
13
  registry?: MetadataRegistry;
7
14
  datasources?: Record<string, Driver>;
@@ -30,9 +37,10 @@ export interface ObjectQLConfig {
30
37
  modules?: string[];
31
38
  /**
32
39
  * List of plugins to load.
33
- * Can be an instance of ObjectQLPlugin or a package name string.
40
+ * Must implement the RuntimePlugin interface from @objectql/runtime.
41
+ * String plugins (package names) are not supported in core.
34
42
  */
35
- plugins?: (ObjectQLPlugin | string)[];
43
+ plugins?: (RuntimePlugin | string)[];
36
44
  /**
37
45
  * List of remote ObjectQL instances to connect to.
38
46
  * e.g. ["http://user-service:3000", "http://order-service:3000"]
package/dist/config.js CHANGED
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * ObjectQL
4
+ * Copyright (c) 2026-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
package/dist/context.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
1
8
  import { IObjectRepository } from './repository';
2
9
  export interface ObjectQLContext {
3
10
  userId?: string;
package/dist/context.js CHANGED
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * ObjectQL
4
+ * Copyright (c) 2026-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
package/dist/driver.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
1
8
  /**
2
9
  * Column metadata from database introspection.
3
10
  */
@@ -51,12 +58,42 @@ export interface IntrospectedSchema {
51
58
  tables: Record<string, IntrospectedTable>;
52
59
  }
53
60
  export interface Driver {
61
+ name?: string;
62
+ version?: string;
63
+ supports?: {
64
+ transactions?: boolean;
65
+ joins?: boolean;
66
+ fullTextSearch?: boolean;
67
+ jsonFields?: boolean;
68
+ arrayFields?: boolean;
69
+ queryFilters?: boolean;
70
+ queryAggregations?: boolean;
71
+ querySorting?: boolean;
72
+ queryPagination?: boolean;
73
+ queryWindowFunctions?: boolean;
74
+ querySubqueries?: boolean;
75
+ };
54
76
  find(objectName: string, query: any, options?: any): Promise<any[]>;
55
77
  findOne(objectName: string, id: string | number, query?: any, options?: any): Promise<any>;
56
78
  create(objectName: string, data: any, options?: any): Promise<any>;
57
79
  update(objectName: string, id: string | number, data: any, options?: any): Promise<any>;
58
80
  delete(objectName: string, id: string | number, options?: any): Promise<any>;
59
81
  count(objectName: string, filters: any, options?: any): Promise<number>;
82
+ connect?(): Promise<void>;
83
+ disconnect?(): Promise<void>;
84
+ checkHealth?(): Promise<boolean>;
85
+ execute?(command: any, parameters?: any[], options?: any): Promise<any>;
86
+ bulkCreate?(objectName: string, data: any[], options?: any): Promise<any>;
87
+ bulkUpdate?(objectName: string, updates: Array<{
88
+ id: string | number;
89
+ data: any;
90
+ }>, options?: any): Promise<any>;
91
+ bulkDelete?(objectName: string, ids: Array<string | number>, options?: any): Promise<any>;
92
+ distinct?(objectName: string, field: string, filters?: any, options?: any): Promise<any[]>;
93
+ aggregate?(objectName: string, aggregations: any[], filters?: any, options?: any): Promise<any[]>;
94
+ beginTransaction?(): Promise<any>;
95
+ commitTransaction?(transaction: any): Promise<void>;
96
+ rollbackTransaction?(transaction: any): Promise<void>;
60
97
  init?(objects: any[]): Promise<void>;
61
98
  /**
62
99
  * Introspect the database schema to discover existing tables, columns, and relationships.
@@ -74,4 +111,34 @@ export interface Driver {
74
111
  commitTransaction?(trx: any): Promise<void>;
75
112
  rollbackTransaction?(trx: any): Promise<void>;
76
113
  disconnect?(): Promise<void>;
114
+ /**
115
+ * Execute a query using QueryAST format (DriverInterface v4.0)
116
+ * @param ast - The QueryAST to execute
117
+ * @param options - Driver-specific options
118
+ * @returns Query result with value and optional count
119
+ */
120
+ executeQuery?(ast: any, options?: any): Promise<{
121
+ value: any[];
122
+ count?: number;
123
+ }>;
124
+ /**
125
+ * Execute a command using Command format (DriverInterface v4.0)
126
+ * @param command - The command to execute (create/update/delete/bulk operations)
127
+ * @param options - Driver-specific options
128
+ * @returns Command result with success status and affected count
129
+ */
130
+ executeCommand?(command: any, options?: any): Promise<{
131
+ success: boolean;
132
+ data?: any;
133
+ affected: number;
134
+ }>;
135
+ /**
136
+ * Alternative method names for findOne (some drivers use 'get')
137
+ */
138
+ get?(objectName: string, id: string, options?: any): Promise<any>;
139
+ /**
140
+ * Direct query execution (legacy, some drivers)
141
+ */
142
+ directQuery?(sql: string, params?: any[]): Promise<any[]>;
143
+ query?(sql: string, params?: any[]): Promise<any[]>;
77
144
  }
package/dist/driver.js CHANGED
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * ObjectQL
4
+ * Copyright (c) 2026-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  //# sourceMappingURL=driver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
package/dist/field.d.ts CHANGED
@@ -1,7 +1,31 @@
1
- import { FieldValidation, ValidationAiContext } from './validation';
1
+ /**
2
+ * ObjectQL
3
+ * Copyright (c) 2026-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { Data } from '@objectstack/spec';
9
+ type ProtocolFieldType = Data.FieldType;
10
+ type Field = Data.Field;
11
+ type SpecSelectOption = Data.SelectOption;
12
+ /**
13
+ * Re-export Protocol Types from the Constitution
14
+ * These are the wire-protocol standard types defined in @objectstack/spec
15
+ *
16
+ * @deprecated Import directly from @objectstack/spec instead
17
+ */
18
+ export type { Field as SpecField, SpecSelectOption, ProtocolFieldType };
19
+ /**
20
+ * RUNTIME-SPECIFIC TYPES
21
+ * The following types extend or complement the Protocol Constitution
22
+ * with runtime-specific properties that don't belong in the wire protocol.
23
+ */
2
24
  /**
3
25
  * Attachment field data structure for file and image types.
4
26
  * Stores metadata about uploaded files, with actual file content stored separately.
27
+ *
28
+ * This is a RUNTIME type - not part of the wire protocol.
5
29
  */
6
30
  export interface AttachmentData {
7
31
  /** Unique identifier for this file */
@@ -24,6 +48,8 @@ export interface AttachmentData {
24
48
  /**
25
49
  * Image-specific attachment data with additional metadata.
26
50
  * Extends AttachmentData with image-specific properties.
51
+ *
52
+ * This is a RUNTIME type - not part of the wire protocol.
27
53
  */
28
54
  export interface ImageAttachmentData extends AttachmentData {
29
55
  /** Image width in pixels */
@@ -40,69 +66,109 @@ export interface ImageAttachmentData extends AttachmentData {
40
66
  };
41
67
  }
42
68
  /**
43
- * Represents the supported field data types in the ObjectQL schema.
44
- * These types determine how data is stored, validated, and rendered.
69
+ * Runtime Field Type
45
70
  *
46
- * - `text`: Simple string.
47
- * - `textarea`: Long string.
48
- * - `select`: Choice from a list.
49
- * - `lookup`: Relationship to another object.
50
- * - `file`: File attachment. Value stored as AttachmentData (single) or AttachmentData[] (multiple).
51
- * - `image`: Image attachment. Value stored as ImageAttachmentData (single) or ImageAttachmentData[] (multiple).
71
+ * Extends the Protocol FieldType with runtime-specific types.
72
+ * The Protocol Constitution defines the core field types.
73
+ * We add runtime-specific types like 'vector', 'grid', 'location', 'object' here.
52
74
  */
53
- export type FieldType = 'text' | 'textarea' | 'markdown' | 'html' | 'select' | 'date' | 'datetime' | 'time' | 'number' | 'currency' | 'percent' | 'boolean' | 'email' | 'phone' | 'url' | 'image' | 'file' | 'location' | 'lookup' | 'master_detail' | 'password' | 'formula' | 'summary' | 'auto_number' | 'object' | 'vector' | 'grid';
75
+ export type FieldType = ProtocolFieldType | 'location' | 'object' | 'vector' | 'grid';
54
76
  /**
55
- * Defines a single option for select/multiselect fields.
77
+ * Runtime Field Option
78
+ *
79
+ * Extends the Protocol SelectOption to allow number values (for backwards compatibility).
56
80
  */
57
81
  export interface FieldOption {
58
82
  /** The display label for the option. */
59
83
  label: string;
60
84
  /** The actual value stored in the database. */
61
85
  value: string | number;
86
+ /** Optional color for visual representation */
87
+ color?: string;
88
+ /** Whether this is the default option */
89
+ default?: boolean;
62
90
  }
63
91
  /**
64
- * Configuration for a single field on an object.
65
- * This defines the schema, validation rules, and UI hints for the attribute.
92
+ * Runtime Field Configuration
93
+ *
94
+ * Extends the Protocol Field definition with runtime-specific properties.
95
+ * The Protocol Constitution (SpecField) defines the core field schema.
96
+ * This adds runtime conveniences and extensions.
97
+ *
98
+ * Properties from the protocol Field interface that are re-declared here:
99
+ * - `name`, `label`: Made optional for runtime convenience (auto-populated from Record key)
100
+ * - `type`: Extended union type to include runtime-specific types (vector, grid, location, object)
101
+ * - `options`: Extended to allow numeric values for backwards compatibility
102
+ * - Boolean flags (`required`, `multiple`, `unique`, `hidden`, `readonly`, `encryption`, `index`, `externalId`):
103
+ * Made optional since Zod applies defaults at parse time, but runtime usage typically specifies these explicitly
104
+ * - `deleteBehavior`: Made optional with protocol-compatible enum values
105
+ *
106
+ * All other protocol properties (description, defaultValue, maxLength, minLength, precision, scale, min, max,
107
+ * reference, referenceFilters, writeRequiresMasterRead, expression, formula, summaryOperations) are inherited as-is.
66
108
  */
67
- export interface FieldConfig {
68
- /**
69
- * The unique API name of the field.
70
- * If defined within an object map, this is often automatically populated from the key.
71
- */
109
+ export interface FieldConfig extends Omit<Field, 'name' | 'label' | 'type' | 'options' | 'required' | 'multiple' | 'unique' | 'deleteBehavior' | 'hidden' | 'readonly' | 'encryption' | 'index' | 'externalId' | 'searchable'> {
110
+ /** Field name (inferred from Record key when used in ObjectConfig.fields) */
72
111
  name?: string;
73
- /** The human-readable label used in UIs. */
112
+ /** Display label (derived from name if not provided) */
74
113
  label?: string;
75
- /** Description of the field for documentation or tooltip. */
76
- description?: string;
77
- /** The data type of the field. */
114
+ /** The data type of the field (extended with runtime types) */
78
115
  type: FieldType;
116
+ /** Options for select fields (extended to allow number values) */
117
+ options?: FieldOption[];
79
118
  /** Whether the field is mandatory. Defaults to false. */
80
119
  required?: boolean;
120
+ /** Whether the field allows multiple values. */
121
+ multiple?: boolean;
81
122
  /** Whether the field is unique in the table. */
82
123
  unique?: boolean;
83
- /** Whether to create a database index for this field. */
84
- index?: boolean;
85
- /** Whether the field is read-only in UI. */
86
- readonly?: boolean;
124
+ /** Whether the field is searchable (full-text search). Defaults to false. */
125
+ searchable?: boolean;
126
+ /** Delete behavior for relationships */
127
+ deleteBehavior?: 'set_null' | 'cascade' | 'restrict';
87
128
  /** Whether the field is hidden from default UI/API response. */
88
129
  hidden?: boolean;
89
- /** The default value if not provided during creation. */
90
- defaultValue?: any;
91
- /** Tooltip or help text for the user. */
92
- help_text?: string;
93
- /**
94
- * Whether the field allows multiple values.
95
- * Supported by 'select', 'lookup', 'file', 'image'.
96
- */
97
- multiple?: boolean;
130
+ /** Whether the field is read-only in UI. */
131
+ readonly?: boolean;
132
+ /** Whether the field is encrypted */
133
+ encryption?: boolean;
134
+ /** Whether to create a database index for this field. */
135
+ index?: boolean;
136
+ /** Whether this is an external ID field */
137
+ externalId?: boolean;
98
138
  /**
99
- * Options for select fields.
100
- * List of available choices for select/multiselect fields.
139
+ * RUNTIME EXTENSIONS BELOW
140
+ * These properties are NOT in the wire protocol but are useful for the runtime.
101
141
  */
102
- options?: FieldOption[];
142
+ /** Tooltip or help text for the user. */
143
+ help_text?: string;
103
144
  /**
104
145
  * Reference to another object for lookup/master_detail fields.
105
- * Specifies the target object name for relationship fields.
146
+ *
147
+ * @deprecated Legacy alias for the protocol-level `reference` field (inherited from {@link Field}).
148
+ *
149
+ * **Migration Guidance:**
150
+ * - **New schemas MUST** use the `reference` field (defined in the protocol Field interface) instead of `reference_to`.
151
+ * - **During migration**, engines and tooling SHOULD:
152
+ * - Treat `reference_to` as a fallback alias for `reference` (i.e., if `reference` is undefined and `reference_to`
153
+ * is defined, behave as though `reference` were set to the same value).
154
+ * - Prefer the protocol `reference` value when both are present.
155
+ * - This property is retained only for backward compatibility with older *.object.yml definitions and will be
156
+ * removed in a future major version once all callers have migrated to `reference`.
157
+ *
158
+ * @example
159
+ * ```yaml
160
+ * # Old (deprecated):
161
+ * fields:
162
+ * owner:
163
+ * type: lookup
164
+ * reference_to: users
165
+ *
166
+ * # New (protocol-compliant):
167
+ * fields:
168
+ * owner:
169
+ * type: lookup
170
+ * reference: users
171
+ * ```
106
172
  */
107
173
  reference_to?: string;
108
174
  /**
@@ -135,30 +201,42 @@ export interface FieldConfig {
135
201
  * Minimum image height in pixels for image fields.
136
202
  */
137
203
  min_height?: number;
138
- /** Minimum for number/currency/percent. */
139
- min?: number;
140
- /** Maximum for number/currency/percent. */
141
- max?: number;
142
- /** Minimum length for text based fields. */
143
- min_length?: number;
144
- /** Maximum length for text based fields. */
145
- max_length?: number;
146
- /** Regular expression pattern for validation. */
147
- regex?: string;
148
204
  /**
149
205
  * Field validation configuration.
150
206
  * Defines validation rules applied at the field level.
151
207
  */
152
- validation?: FieldValidation;
208
+ validation?: {
209
+ /** Format validation (email, url, etc.) */
210
+ format?: 'email' | 'url' | 'phone' | 'date' | 'datetime';
211
+ /** Allowed protocols for URL validation */
212
+ protocols?: string[];
213
+ /** Minimum value for numbers */
214
+ min?: number;
215
+ /** Maximum value for numbers */
216
+ max?: number;
217
+ /** Minimum length for strings */
218
+ min_length?: number;
219
+ /** Maximum length for strings */
220
+ max_length?: number;
221
+ /**
222
+ * Regular expression pattern for validation.
223
+ * Use this for custom pattern matching (e.g., /^[A-Z]{2}\d{4}$/ for codes).
224
+ */
225
+ pattern?: string;
226
+ /** Custom validation message */
227
+ message?: string;
228
+ };
153
229
  /**
154
230
  * AI context for the field.
155
231
  * Provides semantic information for AI tools.
156
232
  */
157
- ai_context?: ValidationAiContext;
233
+ ai_context?: {
234
+ intent?: string;
235
+ validation_strategy?: string;
236
+ [key: string]: unknown;
237
+ };
158
238
  /** Dimension of the vector for 'vector' type fields. */
159
239
  dimension?: number;
160
- /** Formula expression (for 'formula' type fields). */
161
- formula?: string;
162
240
  /** Expected return data type for formula fields. */
163
241
  data_type?: 'number' | 'text' | 'date' | 'datetime' | 'boolean' | 'currency' | 'percent';
164
242
  /** Display format for formula results (e.g., "0.00", "YYYY-MM-DD"). */
@@ -175,5 +253,6 @@ export interface FieldConfig {
175
253
  summary_field?: string;
176
254
  /** Type of summary (count, sum, min, max, avg). */
177
255
  summary_type?: string;
256
+ /** Filters for summary */
178
257
  filters?: unknown[];
179
258
  }