@objectql/types 4.0.2 → 4.0.3
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/app.d.ts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/field.d.ts +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +125 -0
- package/dist/{menu.js → plugin.js} +2 -2
- package/dist/plugin.js.map +1 -0
- package/dist/registry.d.ts +25 -5
- package/dist/registry.js +110 -5
- package/dist/registry.js.map +1 -1
- package/dist/validation.d.ts +31 -6
- package/dist/validation.js.map +1 -1
- package/package.json +5 -6
- package/dist/form.d.ts +0 -322
- package/dist/form.js +0 -10
- package/dist/form.js.map +0 -1
- package/dist/menu.d.ts +0 -89
- package/dist/menu.js.map +0 -1
- package/dist/page.d.ts +0 -279
- package/dist/page.js +0 -10
- package/dist/page.js.map +0 -1
- package/dist/report.d.ts +0 -283
- package/dist/report.js +0 -10
- package/dist/report.js.map +0 -1
- package/dist/view.d.ts +0 -311
- package/dist/view.js +0 -10
- package/dist/view.js.map +0 -1
package/dist/app.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export interface IObjectQL {
|
|
|
24
24
|
registerAction(objectName: string, actionName: string, handler: ActionHandler): void;
|
|
25
25
|
executeAction(objectName: string, actionName: string, ctx: ActionContext): Promise<any>;
|
|
26
26
|
/**
|
|
27
|
-
* Get the underlying
|
|
28
|
-
* @returns The
|
|
27
|
+
* Get the underlying ObjectKernel instance
|
|
28
|
+
* @returns The ObjectKernel instance
|
|
29
29
|
*/
|
|
30
30
|
getKernel(): any;
|
|
31
31
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { MetadataRegistry } from "./registry";
|
|
9
9
|
import { Driver } from "./driver";
|
|
10
10
|
import { ObjectConfig } from "./object";
|
|
11
|
-
import type { RuntimePlugin } from "
|
|
11
|
+
import type { RuntimePlugin } from "./plugin";
|
|
12
12
|
export interface ObjectQLConfig {
|
|
13
13
|
registry?: MetadataRegistry;
|
|
14
14
|
datasources?: Record<string, Driver>;
|
|
@@ -37,7 +37,7 @@ export interface ObjectQLConfig {
|
|
|
37
37
|
modules?: string[];
|
|
38
38
|
/**
|
|
39
39
|
* List of plugins to load.
|
|
40
|
-
* Must implement the RuntimePlugin interface
|
|
40
|
+
* Must implement the RuntimePlugin interface.
|
|
41
41
|
* String plugins (package names) are not supported in core.
|
|
42
42
|
*/
|
|
43
43
|
plugins?: (RuntimePlugin | string)[];
|
package/dist/field.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ export interface FieldOption {
|
|
|
106
106
|
* All other protocol properties (description, defaultValue, maxLength, minLength, precision, scale, min, max,
|
|
107
107
|
* reference, referenceFilters, writeRequiresMasterRead, expression, summaryOperations) are inherited as-is.
|
|
108
108
|
*/
|
|
109
|
-
export interface FieldConfig extends Omit<Field, 'name' | 'label' | 'type' | 'options' | 'required' | 'multiple' | 'unique' | 'deleteBehavior' | 'hidden' | 'readonly' | 'encryption' | 'index' | 'externalId' | 'searchable'> {
|
|
109
|
+
export interface FieldConfig extends Omit<Field, 'name' | 'label' | 'type' | 'options' | 'required' | 'multiple' | 'unique' | 'deleteBehavior' | 'hidden' | 'readonly' | 'encryption' | 'index' | 'externalId' | 'searchable' | 'auditTrail'> {
|
|
110
110
|
/** Field name (inferred from Record key when used in ObjectConfig.fields) */
|
|
111
111
|
name?: string;
|
|
112
112
|
/** Display label (derived from name if not provided) */
|
package/dist/index.d.ts
CHANGED
|
@@ -25,14 +25,10 @@ export * from './config';
|
|
|
25
25
|
export * from './context';
|
|
26
26
|
export * from './validation';
|
|
27
27
|
export * from './permission';
|
|
28
|
-
export * from './page';
|
|
29
28
|
export * from './loader';
|
|
30
29
|
export * from './application';
|
|
31
|
-
export * from './menu';
|
|
32
30
|
export * from './migration';
|
|
33
31
|
export * from './api';
|
|
34
|
-
export * from './view';
|
|
35
32
|
export * from './workflow';
|
|
36
|
-
export * from './report';
|
|
37
|
-
export * from './form';
|
|
38
33
|
export * from './formula';
|
|
34
|
+
export * from './plugin';
|
package/dist/index.js
CHANGED
|
@@ -41,15 +41,11 @@ __exportStar(require("./config"), exports);
|
|
|
41
41
|
__exportStar(require("./context"), exports);
|
|
42
42
|
__exportStar(require("./validation"), exports);
|
|
43
43
|
__exportStar(require("./permission"), exports);
|
|
44
|
-
__exportStar(require("./page"), exports);
|
|
45
44
|
__exportStar(require("./loader"), exports);
|
|
46
45
|
__exportStar(require("./application"), exports);
|
|
47
|
-
__exportStar(require("./menu"), exports);
|
|
48
46
|
__exportStar(require("./migration"), exports);
|
|
49
47
|
__exportStar(require("./api"), exports);
|
|
50
|
-
__exportStar(require("./view"), exports);
|
|
51
48
|
__exportStar(require("./workflow"), exports);
|
|
52
|
-
__exportStar(require("./report"), exports);
|
|
53
|
-
__exportStar(require("./form"), exports);
|
|
54
49
|
__exportStar(require("./formula"), exports);
|
|
50
|
+
__exportStar(require("./plugin"), exports);
|
|
55
51
|
//# 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,
|
|
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"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL Plugin System
|
|
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
|
+
/**
|
|
9
|
+
* Runtime context passed to plugin lifecycle hooks
|
|
10
|
+
*
|
|
11
|
+
* This context provides access to the kernel/engine instance
|
|
12
|
+
* and allows plugins to interact with the ObjectStack runtime.
|
|
13
|
+
*/
|
|
14
|
+
export interface RuntimeContext {
|
|
15
|
+
/**
|
|
16
|
+
* The ObjectStack kernel/engine instance
|
|
17
|
+
*
|
|
18
|
+
* This provides access to:
|
|
19
|
+
* - metadata registry
|
|
20
|
+
* - hook manager
|
|
21
|
+
* - action manager
|
|
22
|
+
* - CRUD operations
|
|
23
|
+
*/
|
|
24
|
+
engine: any;
|
|
25
|
+
/**
|
|
26
|
+
* Get the kernel instance (alternative accessor)
|
|
27
|
+
* Some implementations may use getKernel() instead of engine
|
|
28
|
+
*/
|
|
29
|
+
getKernel?: () => any;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* RuntimePlugin Interface
|
|
33
|
+
*
|
|
34
|
+
* Defines the standard plugin contract for ObjectStack/ObjectQL ecosystem.
|
|
35
|
+
* All plugins (protocol adapters, data drivers, feature extensions) should
|
|
36
|
+
* implement this interface to ensure consistent lifecycle management.
|
|
37
|
+
*
|
|
38
|
+
* Lifecycle Order:
|
|
39
|
+
* 1. install() - Called during kernel initialization
|
|
40
|
+
* 2. onStart() - Called when kernel starts
|
|
41
|
+
* 3. onStop() - Called when kernel stops/shuts down
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* export class MyPlugin implements RuntimePlugin {
|
|
46
|
+
* name = '@myorg/my-plugin';
|
|
47
|
+
* version = '1.0.0';
|
|
48
|
+
*
|
|
49
|
+
* async install(ctx: RuntimeContext): Promise<void> {
|
|
50
|
+
* // Register hooks, load configuration
|
|
51
|
+
* console.log('Plugin installed');
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* async onStart(ctx: RuntimeContext): Promise<void> {
|
|
55
|
+
* // Start servers, connect to services
|
|
56
|
+
* console.log('Plugin started');
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* async onStop(ctx: RuntimeContext): Promise<void> {
|
|
60
|
+
* // Cleanup resources, disconnect
|
|
61
|
+
* console.log('Plugin stopped');
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export interface RuntimePlugin {
|
|
67
|
+
/**
|
|
68
|
+
* Unique plugin identifier
|
|
69
|
+
*
|
|
70
|
+
* Should follow npm package naming convention
|
|
71
|
+
* Examples: '@objectql/plugin-security', '@myorg/my-plugin'
|
|
72
|
+
*/
|
|
73
|
+
name: string;
|
|
74
|
+
/**
|
|
75
|
+
* Plugin version (semantic versioning)
|
|
76
|
+
*
|
|
77
|
+
* Optional but recommended for debugging and compatibility tracking
|
|
78
|
+
* Example: '1.0.0', '2.1.3-beta'
|
|
79
|
+
*/
|
|
80
|
+
version?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Install hook - called during kernel initialization
|
|
83
|
+
*
|
|
84
|
+
* Use this phase to:
|
|
85
|
+
* - Register hooks and event handlers
|
|
86
|
+
* - Initialize plugin state
|
|
87
|
+
* - Load configuration
|
|
88
|
+
* - Register metadata (objects, fields, actions)
|
|
89
|
+
* - Validate dependencies
|
|
90
|
+
*
|
|
91
|
+
* This is called BEFORE the kernel starts, so services may not be available yet.
|
|
92
|
+
*
|
|
93
|
+
* @param ctx - Runtime context with access to kernel/engine
|
|
94
|
+
*/
|
|
95
|
+
install?(ctx: RuntimeContext): void | Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Start hook - called when kernel starts
|
|
98
|
+
*
|
|
99
|
+
* Use this phase to:
|
|
100
|
+
* - Start background processes (servers, workers, schedulers)
|
|
101
|
+
* - Connect to external services (databases, APIs, message queues)
|
|
102
|
+
* - Initialize runtime resources
|
|
103
|
+
* - Perform health checks
|
|
104
|
+
*
|
|
105
|
+
* This is called AFTER install() and AFTER all plugins are installed.
|
|
106
|
+
*
|
|
107
|
+
* @param ctx - Runtime context with access to kernel/engine
|
|
108
|
+
*/
|
|
109
|
+
onStart?(ctx: RuntimeContext): void | Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Stop hook - called when kernel stops/shuts down
|
|
112
|
+
*
|
|
113
|
+
* Use this phase to:
|
|
114
|
+
* - Stop background processes
|
|
115
|
+
* - Disconnect from external services
|
|
116
|
+
* - Cleanup resources (file handles, connections, timers)
|
|
117
|
+
* - Flush pending operations
|
|
118
|
+
* - Save state if needed
|
|
119
|
+
*
|
|
120
|
+
* This is called during graceful shutdown. Ensure cleanup completes quickly.
|
|
121
|
+
*
|
|
122
|
+
* @param ctx - Runtime context with access to kernel/engine
|
|
123
|
+
*/
|
|
124
|
+
onStop?(ctx: RuntimeContext): void | Promise<void>;
|
|
125
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* ObjectQL
|
|
3
|
+
* ObjectQL Plugin System
|
|
4
4
|
* Copyright (c) 2026-present ObjectStack Inc.
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -6,15 +6,35 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Optimized Metadata Registry with O(k) package uninstall complexity
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Uses secondary indexes to achieve O(k) complexity for unregisterPackage
|
|
12
|
+
* operation (where k is the number of items in the package) instead of
|
|
13
|
+
* O(n*m) (where n is types and m is items per type).
|
|
13
14
|
*/
|
|
14
|
-
export
|
|
15
|
+
export declare class MetadataRegistry {
|
|
16
|
+
private items;
|
|
17
|
+
private packageIndex;
|
|
18
|
+
constructor();
|
|
19
|
+
register(type: string, nameOrConfig: any, config?: any): void;
|
|
20
|
+
get<T = any>(type: string, name: string): T;
|
|
21
|
+
list<T = any>(type: string): T[];
|
|
22
|
+
getTypes(): string[];
|
|
23
|
+
getEntry<T = any>(type: string, name: string): T;
|
|
24
|
+
unregister(type: string, name: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Optimized package unregistration with O(k) complexity
|
|
27
|
+
* where k is the number of items in the package.
|
|
28
|
+
*
|
|
29
|
+
* Previous complexity: O(n*m) - iterate all types and all items
|
|
30
|
+
* New complexity: O(k) - direct lookup via secondary index
|
|
31
|
+
*/
|
|
32
|
+
unregisterPackage(packageName: string): void;
|
|
33
|
+
}
|
|
34
|
+
export type MetadataItem = any;
|
|
15
35
|
/**
|
|
16
36
|
* Legacy Metadata interface - kept for backward compatibility
|
|
17
|
-
* @deprecated Use MetadataItem from @
|
|
37
|
+
* @deprecated Use MetadataItem from @objectstack/runtime instead
|
|
18
38
|
*/
|
|
19
39
|
export interface Metadata {
|
|
20
40
|
type: string;
|
package/dist/registry.js
CHANGED
|
@@ -9,11 +9,116 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.MetadataRegistry = void 0;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Optimized Metadata Registry with O(k) package uninstall complexity
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Uses secondary indexes to achieve O(k) complexity for unregisterPackage
|
|
15
|
+
* operation (where k is the number of items in the package) instead of
|
|
16
|
+
* O(n*m) (where n is types and m is items per type).
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
class MetadataRegistry {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.items = {};
|
|
21
|
+
// Secondary index: package name -> list of metadata references
|
|
22
|
+
this.packageIndex = new Map();
|
|
23
|
+
}
|
|
24
|
+
register(type, nameOrConfig, config) {
|
|
25
|
+
if (!this.items[type]) {
|
|
26
|
+
this.items[type] = {};
|
|
27
|
+
}
|
|
28
|
+
let name;
|
|
29
|
+
let item;
|
|
30
|
+
if (config) {
|
|
31
|
+
name = nameOrConfig;
|
|
32
|
+
item = config;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
item = nameOrConfig;
|
|
36
|
+
name = item.name || item.id;
|
|
37
|
+
}
|
|
38
|
+
if (name) {
|
|
39
|
+
this.items[type][name] = item;
|
|
40
|
+
// Update package index
|
|
41
|
+
const packageName = item.package || item._package || item.packageName;
|
|
42
|
+
if (packageName) {
|
|
43
|
+
if (!this.packageIndex.has(packageName)) {
|
|
44
|
+
this.packageIndex.set(packageName, new Set());
|
|
45
|
+
}
|
|
46
|
+
this.packageIndex.get(packageName).add({ type, name });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
get(type, name) {
|
|
51
|
+
var _a;
|
|
52
|
+
const item = (_a = this.items[type]) === null || _a === void 0 ? void 0 : _a[name];
|
|
53
|
+
if (item && item.content) {
|
|
54
|
+
return item.content;
|
|
55
|
+
}
|
|
56
|
+
return item;
|
|
57
|
+
}
|
|
58
|
+
list(type) {
|
|
59
|
+
if (!this.items[type])
|
|
60
|
+
return [];
|
|
61
|
+
return Object.values(this.items[type]).map((item) => {
|
|
62
|
+
if (item && item.content) {
|
|
63
|
+
return item.content;
|
|
64
|
+
}
|
|
65
|
+
return item;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getTypes() {
|
|
69
|
+
return Object.keys(this.items);
|
|
70
|
+
}
|
|
71
|
+
getEntry(type, name) {
|
|
72
|
+
var _a;
|
|
73
|
+
return (_a = this.items[type]) === null || _a === void 0 ? void 0 : _a[name];
|
|
74
|
+
}
|
|
75
|
+
unregister(type, name) {
|
|
76
|
+
var _a;
|
|
77
|
+
const item = (_a = this.items[type]) === null || _a === void 0 ? void 0 : _a[name];
|
|
78
|
+
if (item) {
|
|
79
|
+
// Update package index
|
|
80
|
+
const packageName = item.package || item._package || item.packageName;
|
|
81
|
+
if (packageName) {
|
|
82
|
+
const refs = this.packageIndex.get(packageName);
|
|
83
|
+
if (refs) {
|
|
84
|
+
// Remove this specific reference
|
|
85
|
+
for (const ref of refs) {
|
|
86
|
+
if (ref.type === type && ref.name === name) {
|
|
87
|
+
refs.delete(ref);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Clean up empty package entries
|
|
92
|
+
if (refs.size === 0) {
|
|
93
|
+
this.packageIndex.delete(packageName);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
delete this.items[type][name];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Optimized package unregistration with O(k) complexity
|
|
102
|
+
* where k is the number of items in the package.
|
|
103
|
+
*
|
|
104
|
+
* Previous complexity: O(n*m) - iterate all types and all items
|
|
105
|
+
* New complexity: O(k) - direct lookup via secondary index
|
|
106
|
+
*/
|
|
107
|
+
unregisterPackage(packageName) {
|
|
108
|
+
var _a;
|
|
109
|
+
// Direct lookup via secondary index ✅
|
|
110
|
+
const refs = this.packageIndex.get(packageName);
|
|
111
|
+
if (refs) {
|
|
112
|
+
// Delete each item referenced by this package
|
|
113
|
+
for (const ref of refs) {
|
|
114
|
+
if ((_a = this.items[ref.type]) === null || _a === void 0 ? void 0 : _a[ref.name]) {
|
|
115
|
+
delete this.items[ref.type][ref.name];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Remove package from index
|
|
119
|
+
this.packageIndex.delete(packageName);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.MetadataRegistry = MetadataRegistry;
|
|
19
124
|
//# sourceMappingURL=registry.js.map
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAUH;;;;;;GAMG;AACH,MAAa,gBAAgB;IAMzB;QALQ,UAAK,GAAQ,EAAE,CAAC;QAExB,+DAA+D;QACvD,iBAAY,GAAG,IAAI,GAAG,EAA4B,CAAC;IAE5C,CAAC;IAEhB,QAAQ,CAAC,IAAY,EAAE,YAAiB,EAAE,MAAY;QAClD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC;QAED,IAAI,IAAY,CAAC;QACjB,IAAI,IAAS,CAAC;QAEd,IAAI,MAAM,EAAE,CAAC;YACT,IAAI,GAAG,YAAY,CAAC;YACpB,IAAI,GAAG,MAAM,C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AC;QAClC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,iBAAiB,CAAC,WAAmB;;QACjC,sCAAsC;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,IAAI,EAAE,CAAC;YACP,8CAA8C;YAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACrB,IAAI,MAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,0CAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC1C,CAAC;YACL,CAAC;YACD,4BAA4B;YAC5B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;CACJ;AA9GD,4CA8GC"}
|
package/dist/validation.d.ts
CHANGED
|
@@ -109,12 +109,26 @@ export interface BusinessRuleConstraint {
|
|
|
109
109
|
expression?: string;
|
|
110
110
|
/** Relationships needed for the rule */
|
|
111
111
|
relationships?: Record<string, ValidationRelationship>;
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Logical AND conditions (all must be true).
|
|
114
|
+
* Can be an array of field names (checks if fields are present and non-empty)
|
|
115
|
+
* or ValidationCondition objects for more complex validations.
|
|
116
|
+
*/
|
|
117
|
+
all_of?: (string | ValidationCondition)[];
|
|
118
|
+
/**
|
|
119
|
+
* Logical OR conditions (at least one must be true).
|
|
120
|
+
* Can be an array of field names (checks if at least one field is present and non-empty)
|
|
121
|
+
* or ValidationCondition objects for more complex validations.
|
|
122
|
+
*/
|
|
123
|
+
any_of?: (string | ValidationCondition)[];
|
|
124
|
+
/** Conditional field check - if this field is truthy, then_require fields must be present */
|
|
125
|
+
if_field?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Required fields when if_field condition is met.
|
|
128
|
+
* Can be an array of field names (checks if fields are present and non-empty)
|
|
129
|
+
* or ValidationCondition objects for more complex validations.
|
|
130
|
+
*/
|
|
131
|
+
then_require?: (string | ValidationCondition)[];
|
|
118
132
|
}
|
|
119
133
|
/**
|
|
120
134
|
* Field validation configuration (built into FieldConfig).
|
|
@@ -172,11 +186,22 @@ export interface ValidationRule {
|
|
|
172
186
|
}
|
|
173
187
|
/**
|
|
174
188
|
* Cross-field validation rule.
|
|
189
|
+
* Supports two formats:
|
|
190
|
+
* 1. Using the 'rule' property with a ValidationCondition object
|
|
191
|
+
* 2. Shorthand format with field, operator, and value/compare_to properties directly on the rule
|
|
175
192
|
*/
|
|
176
193
|
export interface CrossFieldValidationRule extends ValidationRule {
|
|
177
194
|
type: 'cross_field';
|
|
178
195
|
/** The validation rule to apply */
|
|
179
196
|
rule?: ValidationCondition;
|
|
197
|
+
/** Shorthand: Field to check (alternative to using rule property) */
|
|
198
|
+
field?: string;
|
|
199
|
+
/** Shorthand: Comparison operator (alternative to using rule property) */
|
|
200
|
+
operator?: ValidationOperator;
|
|
201
|
+
/** Shorthand: Value to compare against (mutually exclusive with compare_to) */
|
|
202
|
+
value?: any;
|
|
203
|
+
/** Shorthand: Field name to compare against for cross-field validation (mutually exclusive with value) */
|
|
204
|
+
compare_to?: string;
|
|
180
205
|
}
|
|
181
206
|
/**
|
|
182
207
|
* Business rule validation.
|
package/dist/validation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAoZH;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACtC,YACI,OAAe,EACR,OAA+B,EAC/B,IAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,YAAO,GAAP,OAAO,CAAwB;QAC/B,SAAI,GAAJ,IAAI,CAAS;QAGpB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ;AATD,0CASC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectql/types",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Pure TypeScript type definitions and interfaces for the ObjectQL protocol - The Contract",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"objectql",
|
|
@@ -26,13 +26,12 @@
|
|
|
26
26
|
"generate:schemas": "node scripts/generate-schemas.js",
|
|
27
27
|
"test": "jest --passWithNoTests"
|
|
28
28
|
},
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
|
|
31
|
-
"@
|
|
29
|
+
"peerDependencies": {},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@objectstack/spec": "^0.8.0",
|
|
32
|
+
"@objectstack/objectql": "^0.8.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@objectstack/spec": "^0.3.3",
|
|
35
|
-
"@objectql/runtime": "workspace:*",
|
|
36
35
|
"ts-json-schema-generator": "^2.4.0",
|
|
37
36
|
"zod": "^3.23.8"
|
|
38
37
|
}
|