@objectql/types 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/action.d.ts CHANGED
@@ -6,7 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { UI } from '@objectstack/spec';
9
- type Action = UI.Action;
9
+ import { z } from 'zod';
10
+ type Action = z.infer<typeof UI.ActionSchema>;
10
11
  import { FieldConfig } from "./field";
11
12
  import { HookAPI } from "./hook";
12
13
  /**
package/dist/ai.d.ts ADDED
@@ -0,0 +1,118 @@
1
+ /**
2
+ * ObjectQL - AI Namespace Types
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
+ * RUNTIME EXTENSIONS: Not part of the wire protocol.
9
+ * These types define stable integration points for AI features.
10
+ */
11
+ /** AI model task types */
12
+ export type AiModelType = 'chat' | 'embedding' | 'rerank' | 'completion' | 'tool';
13
+ /** Model capability flags */
14
+ export interface AiModelCapabilities {
15
+ readonly chat?: boolean;
16
+ readonly embedding?: boolean;
17
+ readonly rerank?: boolean;
18
+ readonly toolCalling?: boolean;
19
+ readonly vision?: boolean;
20
+ }
21
+ /** AI model definition for registry */
22
+ export interface AiModelDefinition {
23
+ /** Unique identifier for registry lookup */
24
+ readonly id: string;
25
+ /** Provider name (e.g., openai, anthropic, local) */
26
+ readonly provider: string;
27
+ /** Provider model name */
28
+ readonly model: string;
29
+ /** Task type */
30
+ readonly type: AiModelType;
31
+ /** Optional display name */
32
+ readonly displayName?: string;
33
+ /** Max output tokens for generation */
34
+ readonly maxTokens?: number;
35
+ /** Context window size */
36
+ readonly contextWindow?: number;
37
+ /** Embedding dimensions (if embedding model) */
38
+ readonly embeddingDimensions?: number;
39
+ /** Capability flags */
40
+ readonly capabilities?: AiModelCapabilities;
41
+ /** Arbitrary metadata */
42
+ readonly metadata?: Record<string, unknown>;
43
+ }
44
+ /** Registry for AI models */
45
+ export interface ModelRegistry {
46
+ register(model: AiModelDefinition): void;
47
+ get(id: string): AiModelDefinition | undefined;
48
+ list(): readonly AiModelDefinition[];
49
+ remove(id: string): void;
50
+ }
51
+ /** Prompt template definition */
52
+ export interface PromptTemplate {
53
+ /** Stable prompt identifier */
54
+ readonly id: string;
55
+ /** Optional semantic version tag */
56
+ readonly version?: string;
57
+ /** Optional display name */
58
+ readonly name?: string;
59
+ /** Prompt template string */
60
+ readonly template: string;
61
+ /** Declared variables for the template */
62
+ readonly variables?: readonly string[];
63
+ /** Optional description */
64
+ readonly description?: string;
65
+ /** Arbitrary metadata */
66
+ readonly metadata?: Record<string, unknown>;
67
+ }
68
+ /** Registry for prompt templates */
69
+ export interface PromptRegistry {
70
+ register(template: PromptTemplate): void;
71
+ get(id: string, version?: string): PromptTemplate | undefined;
72
+ list(id?: string): readonly PromptTemplate[];
73
+ remove(id: string, version?: string): void;
74
+ }
75
+ /** Document for RAG indexing */
76
+ export interface RagDocument {
77
+ readonly id: string;
78
+ readonly content: string;
79
+ readonly metadata?: Record<string, unknown>;
80
+ }
81
+ /** RAG search options */
82
+ export interface RagSearchOptions {
83
+ readonly topK?: number;
84
+ readonly filter?: Record<string, unknown>;
85
+ readonly minScore?: number;
86
+ readonly namespace?: string;
87
+ }
88
+ /** RAG search result */
89
+ export interface RagSearchResult {
90
+ readonly document: RagDocument;
91
+ readonly score: number;
92
+ }
93
+ /** Embedding provider interface */
94
+ export interface EmbeddingProvider {
95
+ embed(texts: readonly string[], modelId: string, options?: {
96
+ readonly dimensions?: number;
97
+ }): Promise<number[][]>;
98
+ }
99
+ /** Vector store interface for RAG */
100
+ export interface VectorStore {
101
+ upsert(documents: readonly RagDocument[], embeddings?: number[][], options?: {
102
+ readonly namespace?: string;
103
+ }): Promise<void>;
104
+ query(embedding: number[], options?: RagSearchOptions): Promise<RagSearchResult[]>;
105
+ delete(ids: readonly string[], options?: {
106
+ readonly namespace?: string;
107
+ }): Promise<void>;
108
+ clear(options?: {
109
+ readonly namespace?: string;
110
+ }): Promise<void>;
111
+ }
112
+ /** AI registry surface for runtime */
113
+ export interface AiRegistry {
114
+ readonly models: ModelRegistry;
115
+ readonly prompts: PromptRegistry;
116
+ readonly embeddings?: EmbeddingProvider;
117
+ readonly vectorStore?: VectorStore;
118
+ }
package/dist/ai.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * ObjectQL - AI Namespace Types
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
+ *
9
+ * RUNTIME EXTENSIONS: Not part of the wire protocol.
10
+ * These types define stable integration points for AI features.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ //# sourceMappingURL=ai.js.map
package/dist/ai.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
package/dist/config.d.ts CHANGED
@@ -9,6 +9,7 @@ import { MetadataRegistry } from "./registry";
9
9
  import { Driver } from "./driver";
10
10
  import { ObjectConfig } from "./object";
11
11
  import type { RuntimePlugin } from "./plugin";
12
+ import type { Logger } from "./logger";
12
13
  export interface ObjectQLConfig {
13
14
  registry?: MetadataRegistry;
14
15
  datasources?: Record<string, Driver>;
@@ -46,4 +47,9 @@ export interface ObjectQLConfig {
46
47
  * e.g. ["http://user-service:3000", "http://order-service:3000"]
47
48
  */
48
49
  remotes?: string[];
50
+ /**
51
+ * Optional structured logger instance.
52
+ * If not provided, a ConsoleLogger with level 'info' is used.
53
+ */
54
+ logger?: Logger;
49
55
  }
package/dist/driver.d.ts CHANGED
@@ -57,22 +57,72 @@ export interface IntrospectedSchema {
57
57
  /** Map of table name to table metadata */
58
58
  tables: Record<string, IntrospectedTable>;
59
59
  }
60
+ /**
61
+ * Transaction isolation levels supported by the driver.
62
+ */
63
+ export type IsolationLevel = 'read-uncommitted' | 'read-committed' | 'repeatable-read' | 'serializable';
64
+ /**
65
+ * Driver Capabilities
66
+ *
67
+ * Declares what features a driver supports. Aligned with the canonical
68
+ * DriverCapabilitiesSchema from @objectstack/spec.
69
+ *
70
+ * All boolean fields default to `false`. Drivers only set `true` for supported features.
71
+ */
72
+ export interface DriverCapabilities {
73
+ readonly create?: boolean;
74
+ readonly read?: boolean;
75
+ readonly update?: boolean;
76
+ readonly delete?: boolean;
77
+ readonly bulkCreate?: boolean;
78
+ readonly bulkUpdate?: boolean;
79
+ readonly bulkDelete?: boolean;
80
+ readonly transactions?: boolean;
81
+ readonly savepoints?: boolean;
82
+ readonly isolationLevels?: readonly IsolationLevel[];
83
+ readonly queryFilters?: boolean;
84
+ readonly queryAggregations?: boolean;
85
+ readonly querySorting?: boolean;
86
+ readonly queryPagination?: boolean;
87
+ readonly queryWindowFunctions?: boolean;
88
+ readonly querySubqueries?: boolean;
89
+ readonly queryCTE?: boolean;
90
+ readonly joins?: boolean;
91
+ readonly fullTextSearch?: boolean;
92
+ readonly jsonQuery?: boolean;
93
+ readonly geospatialQuery?: boolean;
94
+ readonly streaming?: boolean;
95
+ readonly jsonFields?: boolean;
96
+ readonly arrayFields?: boolean;
97
+ readonly vectorSearch?: boolean;
98
+ /** @deprecated Use `geospatialQuery` instead */
99
+ readonly geoSpatial?: boolean;
100
+ readonly schemaSync?: boolean;
101
+ readonly migrations?: boolean;
102
+ readonly indexes?: boolean;
103
+ readonly connectionPooling?: boolean;
104
+ readonly preparedStatements?: boolean;
105
+ readonly queryCache?: boolean;
106
+ }
107
+ /**
108
+ * Driver type discriminator — aligned with @objectstack/spec DriverConfigSchema.
109
+ */
110
+ export type DriverType = 'sql' | 'nosql' | 'cache' | 'search' | 'graph' | 'timeseries';
111
+ /**
112
+ * Base driver configuration common to all drivers.
113
+ * Individual drivers extend this with driver-specific fields.
114
+ */
115
+ export interface BaseDriverConfig {
116
+ /** Driver type discriminator */
117
+ readonly type?: DriverType;
118
+ }
60
119
  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
- };
120
+ /** Driver identifier (e.g., 'memory', 'sql', 'mongo') */
121
+ readonly name?: string;
122
+ /** Driver version (semver) */
123
+ readonly version?: string;
124
+ /** Capabilities declaration — what this driver supports */
125
+ readonly supports?: DriverCapabilities;
76
126
  find(objectName: string, query: any, options?: any): Promise<any[]>;
77
127
  findOne(objectName: string, id: string | number, query?: any, options?: any): Promise<any>;
78
128
  create(objectName: string, data: any, options?: any): Promise<any>;
@@ -90,32 +140,22 @@ export interface Driver {
90
140
  }>, options?: any): Promise<any>;
91
141
  bulkDelete?(objectName: string, ids: Array<string | number>, options?: any): Promise<any>;
92
142
  distinct?(objectName: string, field: string, filters?: any, options?: any): Promise<any[]>;
93
- aggregate?(objectName: string, aggregations: any[], filters?: any, options?: any): Promise<any[]>;
143
+ aggregate?(objectName: string, query: any, options?: any): Promise<any[]>;
94
144
  beginTransaction?(): Promise<any>;
95
145
  commitTransaction?(transaction: any): Promise<void>;
96
146
  rollbackTransaction?(transaction: any): Promise<void>;
97
147
  init?(objects: any[]): Promise<void>;
98
148
  /**
99
149
  * Introspect the database schema to discover existing tables, columns, and relationships.
100
- * This allows connecting to an existing database without defining metadata.
101
150
  * @returns Complete schema information including tables, columns, and foreign keys
102
151
  */
103
152
  introspectSchema?(): Promise<IntrospectedSchema>;
104
- aggregate?(objectName: string, query: any, options?: any): Promise<any>;
105
- distinct?(objectName: string, field: string, filters?: any, options?: any): Promise<any[]>;
106
153
  createMany?(objectName: string, data: any[], options?: any): Promise<any>;
107
154
  updateMany?(objectName: string, filters: any, data: any, options?: any): Promise<any>;
108
155
  deleteMany?(objectName: string, filters: any, options?: any): Promise<any>;
109
156
  findOneAndUpdate?(objectName: string, filters: any, update: any, options?: any): Promise<any>;
110
- beginTransaction?(): Promise<any>;
111
- commitTransaction?(trx: any): Promise<void>;
112
- rollbackTransaction?(trx: any): Promise<void>;
113
- disconnect?(): Promise<void>;
114
157
  /**
115
158
  * 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
159
  */
120
160
  executeQuery?(ast: any, options?: any): Promise<{
121
161
  value: any[];
@@ -123,9 +163,6 @@ export interface Driver {
123
163
  }>;
124
164
  /**
125
165
  * 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
166
  */
130
167
  executeCommand?(command: any, options?: any): Promise<{
131
168
  success: boolean;
@@ -133,11 +170,11 @@ export interface Driver {
133
170
  affected: number;
134
171
  }>;
135
172
  /**
136
- * Alternative method names for findOne (some drivers use 'get')
173
+ * Alternative method name for findOne (some drivers use 'get')
137
174
  */
138
175
  get?(objectName: string, id: string, options?: any): Promise<any>;
139
176
  /**
140
- * Direct query execution (legacy, some drivers)
177
+ * Direct query execution (legacy)
141
178
  */
142
179
  directQuery?(sql: string, params?: any[]): Promise<any[]>;
143
180
  query?(sql: string, params?: any[]): Promise<any[]>;
package/dist/field.d.ts CHANGED
@@ -6,9 +6,10 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { Data } from '@objectstack/spec';
9
- type ProtocolFieldType = Data.FieldType;
10
- type Field = Data.Field;
11
- type SpecSelectOption = Data.SelectOption;
9
+ import { z } from 'zod';
10
+ type ProtocolFieldType = z.infer<typeof Data.FieldType>;
11
+ type Field = z.infer<typeof Data.FieldSchema>;
12
+ type SpecSelectOption = z.infer<typeof Data.SelectOption>;
12
13
  /**
13
14
  * Re-export Protocol Types from the Constitution
14
15
  * These are the wire-protocol standard types defined in @objectstack/spec
package/dist/index.d.ts CHANGED
@@ -33,3 +33,5 @@ export * from './workflow';
33
33
  export * from './formula';
34
34
  export * from './plugin';
35
35
  export * from './gateway';
36
+ export * from './logger';
37
+ export * from './ai';
package/dist/index.js CHANGED
@@ -49,4 +49,6 @@ __exportStar(require("./workflow"), exports);
49
49
  __exportStar(require("./formula"), exports);
50
50
  __exportStar(require("./plugin"), exports);
51
51
  __exportStar(require("./gateway"), exports);
52
+ __exportStar(require("./logger"), exports);
53
+ __exportStar(require("./ai"), exports);
52
54
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH;;;;;;GAMG;AACH,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,4CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH;;;;;;GAMG;AACH,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB;AACzB,uCAAqB"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * ObjectQL - Logger Type Definitions
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
+ * Defines the canonical Logger interface for the ObjectQL ecosystem.
9
+ * All packages must use this interface instead of direct console.* calls.
10
+ */
11
+ /**
12
+ * Log severity levels (RFC 5424 Syslog)
13
+ */
14
+ export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
15
+ /**
16
+ * Log output format
17
+ */
18
+ export type LogFormat = 'json' | 'pretty' | 'compact';
19
+ /**
20
+ * Structured log entry for serialization
21
+ */
22
+ export interface LogEntry {
23
+ /** ISO 8601 timestamp */
24
+ readonly timestamp: string;
25
+ /** Log severity level */
26
+ readonly level: LogLevel;
27
+ /** Logger name / component identifier */
28
+ readonly name: string;
29
+ /** Human-readable message */
30
+ readonly message: string;
31
+ /** Structured metadata (key-value pairs) */
32
+ readonly data?: Record<string, unknown>;
33
+ /** Error object, if applicable */
34
+ readonly error?: {
35
+ readonly name: string;
36
+ readonly message: string;
37
+ readonly stack?: string;
38
+ };
39
+ }
40
+ /**
41
+ * Logger configuration
42
+ */
43
+ export interface LoggerConfig {
44
+ /** Logger name / component identifier */
45
+ readonly name: string;
46
+ /** Minimum log level to emit */
47
+ readonly level?: LogLevel;
48
+ /** Output format */
49
+ readonly format?: LogFormat;
50
+ }
51
+ /**
52
+ * Canonical Logger interface for the ObjectQL ecosystem
53
+ *
54
+ * All packages must program against this interface.
55
+ * Implementations are provided by the runtime layer (`@objectstack/core`
56
+ * or a custom adapter), keeping foundation packages runtime-agnostic.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * class MyPlugin {
61
+ * private logger: Logger;
62
+ * constructor(logger: Logger) {
63
+ * this.logger = logger;
64
+ * }
65
+ * async process() {
66
+ * this.logger.info('Processing started', { batch: 42 });
67
+ * }
68
+ * }
69
+ * ```
70
+ */
71
+ export interface Logger {
72
+ /** Finest-grained informational events */
73
+ trace(message: string, data?: Record<string, unknown>): void;
74
+ /** Detailed debug information */
75
+ debug(message: string, data?: Record<string, unknown>): void;
76
+ /** Informational messages that highlight progress */
77
+ info(message: string, data?: Record<string, unknown>): void;
78
+ /** Potentially harmful situations */
79
+ warn(message: string, data?: Record<string, unknown>): void;
80
+ /** Error events that might still allow the application to continue */
81
+ error(message: string, error?: Error, data?: Record<string, unknown>): void;
82
+ /** Severe error events that will presumably lead to application abort */
83
+ fatal(message: string, error?: Error, data?: Record<string, unknown>): void;
84
+ }
85
+ /**
86
+ * Factory function signature for creating Logger instances.
87
+ * Typically provided by the runtime layer.
88
+ */
89
+ export type LoggerFactory = (config: LoggerConfig) => Logger;
90
+ /**
91
+ * Console-based Logger implementation
92
+ *
93
+ * A zero-dependency reference implementation suitable for:
94
+ * - Unit tests (without mocking an external logger library)
95
+ * - Development environments
96
+ * - Packages that cannot depend on `@objectstack/core`
97
+ *
98
+ * For production use, prefer the structured logger from `@objectstack/core`.
99
+ */
100
+ export declare class ConsoleLogger implements Logger {
101
+ private readonly name;
102
+ private readonly level;
103
+ private static readonly LEVELS;
104
+ constructor(config: LoggerConfig);
105
+ private shouldLog;
106
+ private format;
107
+ trace(message: string, data?: Record<string, unknown>): void;
108
+ debug(message: string, data?: Record<string, unknown>): void;
109
+ info(message: string, data?: Record<string, unknown>): void;
110
+ warn(message: string, data?: Record<string, unknown>): void;
111
+ error(message: string, error?: Error, data?: Record<string, unknown>): void;
112
+ fatal(message: string, error?: Error, data?: Record<string, unknown>): void;
113
+ }
114
+ /**
115
+ * No-op Logger implementation
116
+ *
117
+ * Useful for suppressing all log output (e.g., in benchmarks or silent tests).
118
+ */
119
+ export declare class NullLogger implements Logger {
120
+ trace(): void;
121
+ debug(): void;
122
+ info(): void;
123
+ warn(): void;
124
+ error(): void;
125
+ fatal(): void;
126
+ }
package/dist/logger.js ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ /**
3
+ * ObjectQL - Logger Type Definitions
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
+ *
9
+ * Defines the canonical Logger interface for the ObjectQL ecosystem.
10
+ * All packages must use this interface instead of direct console.* calls.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.NullLogger = exports.ConsoleLogger = void 0;
14
+ /**
15
+ * Console-based Logger implementation
16
+ *
17
+ * A zero-dependency reference implementation suitable for:
18
+ * - Unit tests (without mocking an external logger library)
19
+ * - Development environments
20
+ * - Packages that cannot depend on `@objectstack/core`
21
+ *
22
+ * For production use, prefer the structured logger from `@objectstack/core`.
23
+ */
24
+ class ConsoleLogger {
25
+ constructor(config) {
26
+ var _a;
27
+ this.name = config.name;
28
+ this.level = (_a = config.level) !== null && _a !== void 0 ? _a : 'info';
29
+ }
30
+ shouldLog(level) {
31
+ return ConsoleLogger.LEVELS[level] >= ConsoleLogger.LEVELS[this.level];
32
+ }
33
+ format(level, message, data) {
34
+ const ts = new Date().toISOString();
35
+ const prefix = `${ts} [${level.toUpperCase().padEnd(5)}] [${this.name}]`;
36
+ if (data && Object.keys(data).length > 0) {
37
+ return `${prefix} ${message} ${JSON.stringify(data)}`;
38
+ }
39
+ return `${prefix} ${message}`;
40
+ }
41
+ trace(message, data) {
42
+ if (this.shouldLog('trace'))
43
+ console.debug(this.format('trace', message, data));
44
+ }
45
+ debug(message, data) {
46
+ if (this.shouldLog('debug'))
47
+ console.debug(this.format('debug', message, data));
48
+ }
49
+ info(message, data) {
50
+ if (this.shouldLog('info'))
51
+ console.log(this.format('info', message, data));
52
+ }
53
+ warn(message, data) {
54
+ if (this.shouldLog('warn'))
55
+ console.warn(this.format('warn', message, data));
56
+ }
57
+ error(message, error, data) {
58
+ if (this.shouldLog('error')) {
59
+ console.error(this.format('error', message, data));
60
+ if (error === null || error === void 0 ? void 0 : error.stack)
61
+ console.error(error.stack);
62
+ }
63
+ }
64
+ fatal(message, error, data) {
65
+ if (this.shouldLog('fatal')) {
66
+ console.error(this.format('fatal', message, data));
67
+ if (error === null || error === void 0 ? void 0 : error.stack)
68
+ console.error(error.stack);
69
+ }
70
+ }
71
+ }
72
+ exports.ConsoleLogger = ConsoleLogger;
73
+ ConsoleLogger.LEVELS = {
74
+ trace: 0,
75
+ debug: 1,
76
+ info: 2,
77
+ warn: 3,
78
+ error: 4,
79
+ fatal: 5,
80
+ };
81
+ /**
82
+ * No-op Logger implementation
83
+ *
84
+ * Useful for suppressing all log output (e.g., in benchmarks or silent tests).
85
+ */
86
+ class NullLogger {
87
+ trace() { }
88
+ debug() { }
89
+ info() { }
90
+ warn() { }
91
+ error() { }
92
+ fatal() { }
93
+ }
94
+ exports.NullLogger = NullLogger;
95
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAuFH;;;;;;;;;GASG;AACH,MAAa,aAAa;IAYxB,YAAY,MAAoB;;QAC9B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,MAAA,MAAM,CAAC,KAAK,mCAAI,MAAM,CAAC;IACtC,CAAC;IAEO,SAAS,CAAC,KAAe;QAC/B,OAAO,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzE,CAAC;IAEO,MAAM,CAAC,KAAe,EAAE,OAAe,EAAE,IAA8B;QAC7E,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,GAAG,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,GAAG,CAAC;QACzE,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzC,OAAO,GAAG,MAAM,IAAI,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACxD,CAAC;QACD,OAAO,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAA8B;QACnD,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAA8B;QACnD,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAA8B;QAClD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAA8B;QAClD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,KAAa,EAAE,IAA8B;QAClE,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;YACnD,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK;gBAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,KAAa,EAAE,IAA8B;QAClE,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;YACnD,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK;gBAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;;AA1DH,sCA2DC;AAxDyB,oBAAM,GAA6B;IACzD,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;CACT,CAAC;AAmDJ;;;;GAIG;AACH,MAAa,UAAU;IACrB,KAAK,KAAuB,CAAC;IAC7B,KAAK,KAAuB,CAAC;IAC7B,IAAI,KAAuB,CAAC;IAC5B,IAAI,KAAuB,CAAC;IAC5B,KAAK,KAAuB,CAAC;IAC7B,KAAK,KAAuB,CAAC;CAC9B;AAPD,gCAOC"}
package/dist/object.d.ts CHANGED
@@ -5,9 +5,24 @@
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, Automation } from '@objectstack/spec';
9
+ import { z } from 'zod';
8
10
  import { FieldConfig } from './field';
9
11
  import { ActionConfig } from './action';
10
12
  import { AnyValidationRule } from './validation';
13
+ /**
14
+ * Re-export Protocol Types from @objectstack/spec 1.1.0
15
+ * State Machine, Object Ownership, and Object Extension types.
16
+ */
17
+ export type StateMachineConfig = z.infer<typeof Automation.StateMachineSchema>;
18
+ export type StateNodeConfig = z.infer<typeof Automation.StateNodeSchema>;
19
+ export type Transition = z.infer<typeof Automation.TransitionSchema>;
20
+ export type ActionRef = z.infer<typeof Automation.ActionRefSchema>;
21
+ export type ObjectOwnership = z.infer<typeof Data.ObjectOwnershipEnum>;
22
+ export type ObjectExtension = z.infer<typeof Data.ObjectExtensionSchema>;
23
+ export type ServiceObject = z.infer<typeof Data.ObjectSchema>;
24
+ /** Re-export Zod schemas for validation */
25
+ export { Data, Automation };
11
26
  /**
12
27
  * RUNTIME-SPECIFIC TYPES
13
28
  * The following types extend or complement the Protocol Constitution
@@ -104,6 +119,18 @@ export interface ObjectConfig {
104
119
  /**
105
120
  * RUNTIME EXTENSIONS BELOW
106
121
  */
122
+ /**
123
+ * State Machine definition for object lifecycle management.
124
+ * Follows the @objectstack/spec StateMachineConfig protocol.
125
+ * Enables declarative state transitions, guards, and entry/exit actions.
126
+ */
127
+ stateMachine?: StateMachineConfig;
128
+ /**
129
+ * Named state machines for multi-field lifecycle.
130
+ * Each key is a state machine identifier, useful when an object
131
+ * has multiple independent state fields.
132
+ */
133
+ stateMachines?: Record<string, StateMachineConfig>;
107
134
  /** AI capabilities configuration (RUNTIME ONLY) */
108
135
  ai?: ObjectAiConfig;
109
136
  /** Custom actions (RUNTIME ONLY) */
package/dist/object.js CHANGED
@@ -7,4 +7,8 @@
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Automation = exports.Data = void 0;
11
+ const spec_1 = require("@objectstack/spec");
12
+ Object.defineProperty(exports, "Data", { enumerable: true, get: function () { return spec_1.Data; } });
13
+ Object.defineProperty(exports, "Automation", { enumerable: true, get: function () { return spec_1.Automation; } });
10
14
  //# sourceMappingURL=object.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,4CAAqD;AAmB5C,qFAnBA,WAAI,OAmBA;AAAE,2FAnBA,iBAAU,OAmBA"}
package/dist/plugin.d.ts CHANGED
@@ -78,6 +78,11 @@ export interface RuntimePlugin {
78
78
  * Example: '1.0.0', '2.1.3-beta'
79
79
  */
80
80
  version?: string;
81
+ /**
82
+ * Initialize the plugin
83
+ * Called when the plugin is loaded into the kernel
84
+ */
85
+ init?(ctx: RuntimeContext): Promise<void>;
81
86
  /**
82
87
  * Install hook - called during kernel initialization
83
88
  *
package/dist/query.d.ts CHANGED
@@ -6,22 +6,27 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { Data } from '@objectstack/spec';
9
- type FilterCondition = Data.FilterCondition;
9
+ import { z } from 'zod';
10
+ export type Filter = z.infer<typeof Data.FilterCondition>;
11
+ export type SortNode = z.infer<typeof Data.SortNodeSchema>;
12
+ export type AggregationFunctionType = z.infer<typeof Data.AggregationFunction>;
13
+ export type AggregationNode = z.infer<typeof Data.AggregationNodeSchema>;
10
14
  /**
11
- * Modern Query Filter using @objectstack/spec FilterCondition
12
- *
13
- * Supports MongoDB/Prisma-style object-based syntax:
14
- * - Implicit equality: { field: value }
15
- * - Explicit operators: { field: { $eq: value, $gt: 10 } }
16
- * - Logical operators: { $and: [...], $or: [...] }
17
- * - String operators: { name: { $contains: "text" } }
18
- * - Range operators: { age: { $gte: 18, $lte: 65 } }
19
- * - Set operators: { status: { $in: ["active", "pending"] } }
20
- * - Null checks: { field: { $null: true } }
15
+ * Unified Query Interface - Standard Protocol Format
21
16
  *
22
- * Note: $not operator is not supported. Use $ne for field-level negation.
17
+ * Uses @objectstack/spec QuerySchema inference directly.
18
+ * We make 'object' optional because in many contexts (like Repository.find),
19
+ * the object is implicit.
20
+ */
21
+ type SpecQuery = z.infer<typeof Data.QuerySchema>;
22
+ export interface UnifiedQuery extends Omit<SpecQuery, 'object'> {
23
+ object?: string;
24
+ }
25
+ /**
26
+ * Standard QueryAST definition.
27
+ * Aliased to UnifiedQuery for backward compatibility and consistency.
23
28
  */
24
- export type Filter = FilterCondition;
29
+ export type QueryAST = UnifiedQuery;
25
30
  /** @deprecated Use AggregationFunctionType instead */
26
31
  export type AggregateFunction = AggregationFunctionType;
27
32
  /** @deprecated Use AggregationNode instead */
@@ -30,62 +35,4 @@ export interface AggregateOption {
30
35
  field: string;
31
36
  alias?: string;
32
37
  }
33
- /**
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
65
- *
66
- * Uses @objectstack/spec QueryAST format directly.
67
- * This is the single source of truth for query structure.
68
- */
69
- export interface UnifiedQuery {
70
- /** Field selection - specify which fields to return */
71
- fields?: string[];
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;
78
- /** Pagination - maximum number of records to return */
79
- limit?: number;
80
- /** Relation expansion - load related records */
81
- expand?: Record<string, UnifiedQuery>;
82
- /** Aggregation - group by fields */
83
- groupBy?: string[];
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;
90
- }
91
38
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectql/types",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Pure TypeScript type definitions and interfaces for the ObjectQL protocol - The Contract",
5
5
  "keywords": [
6
6
  "objectql",
@@ -17,6 +17,12 @@
17
17
  "license": "MIT",
18
18
  "main": "dist/index.js",
19
19
  "types": "dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
25
+ },
20
26
  "files": [
21
27
  "dist",
22
28
  "schemas"
@@ -24,12 +30,11 @@
24
30
  "scripts": {
25
31
  "build": "tsc",
26
32
  "generate:schemas": "node scripts/generate-schemas.js",
27
- "test": "jest --passWithNoTests"
28
- },
29
- "dependencies": {
30
- "@objectstack/spec": "^1.0.0"
33
+ "test": "vitest run"
31
34
  },
35
+ "dependencies": {},
32
36
  "devDependencies": {
37
+ "@objectstack/spec": "^1.1.0",
33
38
  "ts-json-schema-generator": "^2.4.0",
34
39
  "zod": "^3.23.8"
35
40
  }