@objectql/types 3.0.0 → 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.
Files changed (82) hide show
  1. package/dist/action.d.ts +28 -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 +61 -0
  20. package/dist/driver.js +7 -0
  21. package/dist/driver.js.map +1 -1
  22. package/dist/field.d.ts +129 -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 +89 -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 +37 -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,23 @@
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 type { Action } from '@objectstack/spec';
1
9
  import { FieldConfig } from "./field";
2
10
  import { HookAPI } from "./hook";
11
+ /**
12
+ * Re-export Protocol Types from the Constitution
13
+ *
14
+ * @deprecated Import directly from @objectstack/spec instead
15
+ */
16
+ export type { Action as SpecAction };
17
+ /**
18
+ * RUNTIME-SPECIFIC TYPES
19
+ * The following types extend the Protocol Action definition with runtime execution capabilities
20
+ */
3
21
  /**
4
22
  * Defines the scope of the action.
5
23
  * - `record`: Acts on a specific record instance (e.g. "Approve Order").
@@ -13,6 +31,8 @@ export type ActionType = 'record' | 'global';
13
31
  export type ActionInputDefinition = Record<string, FieldConfig>;
14
32
  /**
15
33
  * Context passed to the action handler execution.
34
+ *
35
+ * RUNTIME TYPE: Used during action execution.
16
36
  */
17
37
  export interface ActionContext<BaseT = any, InputT = any> {
18
38
  /** The object this action belongs to. */
@@ -41,11 +61,17 @@ export interface ActionContext<BaseT = any, InputT = any> {
41
61
  };
42
62
  }
43
63
  /**
64
+ * Runtime Action Configuration
65
+ *
44
66
  * The configuration of an Action visible to the Metadata engine (YAML/JSON side).
67
+ * Compatible with Protocol Action but adds runtime-specific options.
45
68
  */
46
69
  export interface ActionConfig {
70
+ /** Display label */
47
71
  label?: string;
72
+ /** Description */
48
73
  description?: string;
74
+ /** Icon name */
49
75
  icon?: string;
50
76
  /**
51
77
  * Default: 'global' if no fields defined, but usually specified explicitly.
@@ -70,6 +96,8 @@ export interface ActionConfig {
70
96
  }
71
97
  /**
72
98
  * The full implementation definition (Code side).
99
+ *
100
+ * RUNTIME TYPE: Includes the handler function for execution.
73
101
  */
74
102
  export interface ActionDefinition<BaseT = any, InputT = any, ReturnT = any> extends ActionConfig {
75
103
  /**
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,iBAAiB,CAAC,IA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,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";
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 @objectstack/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,36 @@ 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
+ };
54
70
  find(objectName: string, query: any, options?: any): Promise<any[]>;
55
71
  findOne(objectName: string, id: string | number, query?: any, options?: any): Promise<any>;
56
72
  create(objectName: string, data: any, options?: any): Promise<any>;
57
73
  update(objectName: string, id: string | number, data: any, options?: any): Promise<any>;
58
74
  delete(objectName: string, id: string | number, options?: any): Promise<any>;
59
75
  count(objectName: string, filters: any, options?: any): Promise<number>;
76
+ connect?(): Promise<void>;
77
+ disconnect?(): Promise<void>;
78
+ checkHealth?(): Promise<boolean>;
79
+ execute?(command: any, parameters?: any[], options?: any): Promise<any>;
80
+ bulkCreate?(objectName: string, data: any[], options?: any): Promise<any>;
81
+ bulkUpdate?(objectName: string, updates: Array<{
82
+ id: string | number;
83
+ data: any;
84
+ }>, options?: any): Promise<any>;
85
+ bulkDelete?(objectName: string, ids: Array<string | number>, options?: any): Promise<any>;
86
+ distinct?(objectName: string, field: string, filters?: any, options?: any): Promise<any[]>;
87
+ aggregate?(objectName: string, aggregations: any[], filters?: any, options?: any): Promise<any[]>;
88
+ beginTransaction?(): Promise<any>;
89
+ commitTransaction?(transaction: any): Promise<void>;
90
+ rollbackTransaction?(transaction: any): Promise<void>;
60
91
  init?(objects: any[]): Promise<void>;
61
92
  /**
62
93
  * Introspect the database schema to discover existing tables, columns, and relationships.
@@ -74,4 +105,34 @@ export interface Driver {
74
105
  commitTransaction?(trx: any): Promise<void>;
75
106
  rollbackTransaction?(trx: any): Promise<void>;
76
107
  disconnect?(): Promise<void>;
108
+ /**
109
+ * Execute a query using QueryAST format (DriverInterface v4.0)
110
+ * @param ast - The QueryAST to execute
111
+ * @param options - Driver-specific options
112
+ * @returns Query result with value and optional count
113
+ */
114
+ executeQuery?(ast: any, options?: any): Promise<{
115
+ value: any[];
116
+ count?: number;
117
+ }>;
118
+ /**
119
+ * Execute a command using Command format (DriverInterface v4.0)
120
+ * @param command - The command to execute (create/update/delete/bulk operations)
121
+ * @param options - Driver-specific options
122
+ * @returns Command result with success status and affected count
123
+ */
124
+ executeCommand?(command: any, options?: any): Promise<{
125
+ success: boolean;
126
+ data?: any;
127
+ affected: number;
128
+ }>;
129
+ /**
130
+ * Alternative method names for findOne (some drivers use 'get')
131
+ */
132
+ get?(objectName: string, id: string, options?: any): Promise<any>;
133
+ /**
134
+ * Direct query execution (legacy, some drivers)
135
+ */
136
+ directQuery?(sql: string, params?: any[]): Promise<any[]>;
137
+ query?(sql: string, params?: any[]): Promise<any[]>;
77
138
  }
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,28 @@
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 type { FieldType as ProtocolFieldType, Field, SelectOption as SpecSelectOption } from '@objectstack/spec';
9
+ /**
10
+ * Re-export Protocol Types from the Constitution
11
+ * These are the wire-protocol standard types defined in @objectstack/spec
12
+ *
13
+ * @deprecated Import directly from @objectstack/spec instead
14
+ */
15
+ export type { Field as SpecField, SpecSelectOption, ProtocolFieldType };
16
+ /**
17
+ * RUNTIME-SPECIFIC TYPES
18
+ * The following types extend or complement the Protocol Constitution
19
+ * with runtime-specific properties that don't belong in the wire protocol.
20
+ */
2
21
  /**
3
22
  * Attachment field data structure for file and image types.
4
23
  * Stores metadata about uploaded files, with actual file content stored separately.
24
+ *
25
+ * This is a RUNTIME type - not part of the wire protocol.
5
26
  */
6
27
  export interface AttachmentData {
7
28
  /** Unique identifier for this file */
@@ -24,6 +45,8 @@ export interface AttachmentData {
24
45
  /**
25
46
  * Image-specific attachment data with additional metadata.
26
47
  * Extends AttachmentData with image-specific properties.
48
+ *
49
+ * This is a RUNTIME type - not part of the wire protocol.
27
50
  */
28
51
  export interface ImageAttachmentData extends AttachmentData {
29
52
  /** Image width in pixels */
@@ -40,69 +63,109 @@ export interface ImageAttachmentData extends AttachmentData {
40
63
  };
41
64
  }
42
65
  /**
43
- * Represents the supported field data types in the ObjectQL schema.
44
- * These types determine how data is stored, validated, and rendered.
66
+ * Runtime Field Type
45
67
  *
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).
68
+ * Extends the Protocol FieldType with runtime-specific types.
69
+ * The Protocol Constitution defines the core field types.
70
+ * We add runtime-specific types like 'vector', 'grid', 'location', 'object' here.
52
71
  */
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';
72
+ export type FieldType = ProtocolFieldType | 'location' | 'object' | 'vector' | 'grid';
54
73
  /**
55
- * Defines a single option for select/multiselect fields.
74
+ * Runtime Field Option
75
+ *
76
+ * Extends the Protocol SelectOption to allow number values (for backwards compatibility).
56
77
  */
57
78
  export interface FieldOption {
58
79
  /** The display label for the option. */
59
80
  label: string;
60
81
  /** The actual value stored in the database. */
61
82
  value: string | number;
83
+ /** Optional color for visual representation */
84
+ color?: string;
85
+ /** Whether this is the default option */
86
+ default?: boolean;
62
87
  }
63
88
  /**
64
- * Configuration for a single field on an object.
65
- * This defines the schema, validation rules, and UI hints for the attribute.
89
+ * Runtime Field Configuration
90
+ *
91
+ * Extends the Protocol Field definition with runtime-specific properties.
92
+ * The Protocol Constitution (SpecField) defines the core field schema.
93
+ * This adds runtime conveniences and extensions.
94
+ *
95
+ * Properties from the protocol Field interface that are re-declared here:
96
+ * - `name`, `label`: Made optional for runtime convenience (auto-populated from Record key)
97
+ * - `type`: Extended union type to include runtime-specific types (vector, grid, location, object)
98
+ * - `options`: Extended to allow numeric values for backwards compatibility
99
+ * - Boolean flags (`required`, `multiple`, `unique`, `hidden`, `readonly`, `encryption`, `index`, `externalId`):
100
+ * Made optional since Zod applies defaults at parse time, but runtime usage typically specifies these explicitly
101
+ * - `deleteBehavior`: Made optional with protocol-compatible enum values
102
+ *
103
+ * All other protocol properties (description, defaultValue, maxLength, minLength, precision, scale, min, max,
104
+ * reference, referenceFilters, writeRequiresMasterRead, expression, formula, summaryOperations) are inherited as-is.
66
105
  */
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
- */
106
+ export interface FieldConfig extends Omit<Field, 'name' | 'label' | 'type' | 'options' | 'required' | 'multiple' | 'unique' | 'deleteBehavior' | 'hidden' | 'readonly' | 'encryption' | 'index' | 'externalId' | 'searchable'> {
107
+ /** Field name (inferred from Record key when used in ObjectConfig.fields) */
72
108
  name?: string;
73
- /** The human-readable label used in UIs. */
109
+ /** Display label (derived from name if not provided) */
74
110
  label?: string;
75
- /** Description of the field for documentation or tooltip. */
76
- description?: string;
77
- /** The data type of the field. */
111
+ /** The data type of the field (extended with runtime types) */
78
112
  type: FieldType;
113
+ /** Options for select fields (extended to allow number values) */
114
+ options?: FieldOption[];
79
115
  /** Whether the field is mandatory. Defaults to false. */
80
116
  required?: boolean;
117
+ /** Whether the field allows multiple values. */
118
+ multiple?: boolean;
81
119
  /** Whether the field is unique in the table. */
82
120
  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;
121
+ /** Whether the field is searchable (full-text search). Defaults to false. */
122
+ searchable?: boolean;
123
+ /** Delete behavior for relationships */
124
+ deleteBehavior?: 'set_null' | 'cascade' | 'restrict';
87
125
  /** Whether the field is hidden from default UI/API response. */
88
126
  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;
127
+ /** Whether the field is read-only in UI. */
128
+ readonly?: boolean;
129
+ /** Whether the field is encrypted */
130
+ encryption?: boolean;
131
+ /** Whether to create a database index for this field. */
132
+ index?: boolean;
133
+ /** Whether this is an external ID field */
134
+ externalId?: boolean;
98
135
  /**
99
- * Options for select fields.
100
- * List of available choices for select/multiselect fields.
136
+ * RUNTIME EXTENSIONS BELOW
137
+ * These properties are NOT in the wire protocol but are useful for the runtime.
101
138
  */
102
- options?: FieldOption[];
139
+ /** Tooltip or help text for the user. */
140
+ help_text?: string;
103
141
  /**
104
142
  * Reference to another object for lookup/master_detail fields.
105
- * Specifies the target object name for relationship fields.
143
+ *
144
+ * @deprecated Legacy alias for the protocol-level `reference` field (inherited from {@link Field}).
145
+ *
146
+ * **Migration Guidance:**
147
+ * - **New schemas MUST** use the `reference` field (defined in the protocol Field interface) instead of `reference_to`.
148
+ * - **During migration**, engines and tooling SHOULD:
149
+ * - Treat `reference_to` as a fallback alias for `reference` (i.e., if `reference` is undefined and `reference_to`
150
+ * is defined, behave as though `reference` were set to the same value).
151
+ * - Prefer the protocol `reference` value when both are present.
152
+ * - This property is retained only for backward compatibility with older *.object.yml definitions and will be
153
+ * removed in a future major version once all callers have migrated to `reference`.
154
+ *
155
+ * @example
156
+ * ```yaml
157
+ * # Old (deprecated):
158
+ * fields:
159
+ * owner:
160
+ * type: lookup
161
+ * reference_to: users
162
+ *
163
+ * # New (protocol-compliant):
164
+ * fields:
165
+ * owner:
166
+ * type: lookup
167
+ * reference: users
168
+ * ```
106
169
  */
107
170
  reference_to?: string;
108
171
  /**
@@ -135,30 +198,42 @@ export interface FieldConfig {
135
198
  * Minimum image height in pixels for image fields.
136
199
  */
137
200
  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
201
  /**
149
202
  * Field validation configuration.
150
203
  * Defines validation rules applied at the field level.
151
204
  */
152
- validation?: FieldValidation;
205
+ validation?: {
206
+ /** Format validation (email, url, etc.) */
207
+ format?: 'email' | 'url' | 'phone' | 'date' | 'datetime';
208
+ /** Allowed protocols for URL validation */
209
+ protocols?: string[];
210
+ /** Minimum value for numbers */
211
+ min?: number;
212
+ /** Maximum value for numbers */
213
+ max?: number;
214
+ /** Minimum length for strings */
215
+ min_length?: number;
216
+ /** Maximum length for strings */
217
+ max_length?: number;
218
+ /**
219
+ * Regular expression pattern for validation.
220
+ * Use this for custom pattern matching (e.g., /^[A-Z]{2}\d{4}$/ for codes).
221
+ */
222
+ pattern?: string;
223
+ /** Custom validation message */
224
+ message?: string;
225
+ };
153
226
  /**
154
227
  * AI context for the field.
155
228
  * Provides semantic information for AI tools.
156
229
  */
157
- ai_context?: ValidationAiContext;
230
+ ai_context?: {
231
+ intent?: string;
232
+ validation_strategy?: string;
233
+ [key: string]: unknown;
234
+ };
158
235
  /** Dimension of the vector for 'vector' type fields. */
159
236
  dimension?: number;
160
- /** Formula expression (for 'formula' type fields). */
161
- formula?: string;
162
237
  /** Expected return data type for formula fields. */
163
238
  data_type?: 'number' | 'text' | 'date' | 'datetime' | 'boolean' | 'currency' | 'percent';
164
239
  /** Display format for formula results (e.g., "0.00", "YYYY-MM-DD"). */
@@ -175,5 +250,6 @@ export interface FieldConfig {
175
250
  summary_field?: string;
176
251
  /** Type of summary (count, sum, min, max, avg). */
177
252
  summary_type?: string;
253
+ /** Filters for summary */
178
254
  filters?: unknown[];
179
255
  }
package/dist/field.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=field.js.map