@objectql/core 1.4.0 → 1.6.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/CHANGELOG.md +23 -0
- package/README.md +287 -0
- package/dist/app.d.ts +2 -6
- package/dist/app.js +53 -124
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/util.d.ts +1 -0
- package/dist/util.js +9 -0
- package/dist/util.js.map +1 -0
- package/dist/validator.d.ts +69 -0
- package/dist/validator.js +464 -0
- package/dist/validator.js.map +1 -0
- package/package.json +2 -5
- package/src/app.ts +64 -104
- package/src/index.ts +5 -4
- package/src/util.ts +5 -0
- package/src/validator.ts +553 -0
- package/tsconfig.json +2 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/driver.d.ts +0 -2
- package/dist/driver.js +0 -55
- package/dist/driver.js.map +0 -1
- package/dist/loader.d.ts +0 -12
- package/dist/loader.js +0 -276
- package/dist/loader.js.map +0 -1
- package/dist/plugin.d.ts +0 -2
- package/dist/plugin.js +0 -56
- package/dist/plugin.js.map +0 -1
- package/dist/remote.d.ts +0 -8
- package/dist/remote.js +0 -43
- package/dist/remote.js.map +0 -1
- package/src/driver.ts +0 -54
- package/src/loader.ts +0 -259
- package/src/plugin.ts +0 -53
- package/src/remote.ts +0 -50
- package/test/dynamic.test.ts +0 -34
- package/test/fixtures/project.action.js +0 -8
- package/test/fixtures/project.object.yml +0 -41
- package/test/loader.test.ts +0 -15
- package/test/metadata.test.ts +0 -49
- package/test/remote.test.ts +0 -119
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @objectql/core
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Minor version release - 1.6.0
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @objectql/types@1.6.0
|
|
13
|
+
|
|
14
|
+
## 1.5.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- Minor version release - 1.5.0
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @objectql/driver-remote@1.5.0
|
|
24
|
+
- @objectql/types@1.5.0
|
|
25
|
+
|
|
3
26
|
## 1.4.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# @objectql/core
|
|
2
|
+
|
|
3
|
+
The core ORM and runtime engine for ObjectQL. This package handles object querying, CRUD operations, database driver coordination, transaction management, and **metadata-driven validation**.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Unified Query Language**: A generic way to query data across different databases (SQL, Mongo, etc.).
|
|
8
|
+
- **Repository Pattern**: `ObjectRepository` for managing object records.
|
|
9
|
+
- **Driver Agnostic**: Abstraction layer for database drivers.
|
|
10
|
+
- **Dynamic Schema**: Loads object definitions from metadata.
|
|
11
|
+
- **Hooks & Actions**: Runtime logic injection.
|
|
12
|
+
- **Validation Engine**: Metadata-driven validation with field-level, cross-field, and state machine rules.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @objectql/core @objectql/types
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Basic Setup
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { ObjectQL } from '@objectql/core';
|
|
26
|
+
// Import a driver, e.g., @objectql/driver-knex
|
|
27
|
+
|
|
28
|
+
const objectql = new ObjectQL({
|
|
29
|
+
datasources: {
|
|
30
|
+
default: new MyDriver({ ... })
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await objectql.init();
|
|
35
|
+
|
|
36
|
+
// Use context for operations
|
|
37
|
+
const ctx = objectql.createContext({ userId: 'u-1' });
|
|
38
|
+
const projects = await ctx.object('project').find({
|
|
39
|
+
filters: [['status', '=', 'active']]
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Validation System
|
|
44
|
+
|
|
45
|
+
The validation system allows you to define validation rules in your object metadata and execute them programmatically.
|
|
46
|
+
|
|
47
|
+
#### Field-Level Validation
|
|
48
|
+
|
|
49
|
+
Define validation rules directly in field configuration:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { ObjectConfig } from '@objectql/types';
|
|
53
|
+
|
|
54
|
+
const projectObject: ObjectConfig = {
|
|
55
|
+
name: 'project',
|
|
56
|
+
fields: {
|
|
57
|
+
email: {
|
|
58
|
+
type: 'email',
|
|
59
|
+
required: true,
|
|
60
|
+
validation: {
|
|
61
|
+
format: 'email',
|
|
62
|
+
message: 'Please enter a valid email address'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
budget: {
|
|
66
|
+
type: 'currency',
|
|
67
|
+
validation: {
|
|
68
|
+
min: 0,
|
|
69
|
+
max: 10000000,
|
|
70
|
+
message: 'Budget must be between 0 and 10,000,000'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
name: {
|
|
74
|
+
type: 'text',
|
|
75
|
+
required: true,
|
|
76
|
+
validation: {
|
|
77
|
+
min_length: 3,
|
|
78
|
+
max_length: 100,
|
|
79
|
+
pattern: '^[a-zA-Z0-9\\s]+$',
|
|
80
|
+
message: 'Name must be 3-100 alphanumeric characters'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Using the Validator Class
|
|
88
|
+
|
|
89
|
+
Execute validation rules programmatically:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { Validator } from '@objectql/core';
|
|
93
|
+
import { ValidationContext, CrossFieldValidationRule } from '@objectql/types';
|
|
94
|
+
|
|
95
|
+
// Create validator with optional language configuration
|
|
96
|
+
const validator = new Validator({
|
|
97
|
+
language: 'en',
|
|
98
|
+
languageFallback: ['en', 'zh-CN']
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Define cross-field validation rules
|
|
102
|
+
const rules: CrossFieldValidationRule[] = [
|
|
103
|
+
{
|
|
104
|
+
name: 'valid_date_range',
|
|
105
|
+
type: 'cross_field',
|
|
106
|
+
rule: {
|
|
107
|
+
field: 'end_date',
|
|
108
|
+
operator: '>=',
|
|
109
|
+
compare_to: 'start_date' // Cross-field comparison
|
|
110
|
+
},
|
|
111
|
+
message: 'End date must be on or after start date',
|
|
112
|
+
error_code: 'INVALID_DATE_RANGE'
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
// Validate a record
|
|
117
|
+
const context: ValidationContext = {
|
|
118
|
+
record: {
|
|
119
|
+
start_date: '2024-01-01',
|
|
120
|
+
end_date: '2024-12-31'
|
|
121
|
+
},
|
|
122
|
+
operation: 'create'
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const result = await validator.validate(rules, context);
|
|
126
|
+
|
|
127
|
+
if (!result.valid) {
|
|
128
|
+
console.log('Validation errors:', result.errors);
|
|
129
|
+
// Output: Array of ValidationRuleResult objects
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### State Machine Validation
|
|
134
|
+
|
|
135
|
+
Enforce valid state transitions:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { StateMachineValidationRule } from '@objectql/types';
|
|
139
|
+
|
|
140
|
+
const statusRule: StateMachineValidationRule = {
|
|
141
|
+
name: 'status_transition',
|
|
142
|
+
type: 'state_machine',
|
|
143
|
+
field: 'status',
|
|
144
|
+
transitions: {
|
|
145
|
+
planning: {
|
|
146
|
+
allowed_next: ['active', 'cancelled']
|
|
147
|
+
},
|
|
148
|
+
active: {
|
|
149
|
+
allowed_next: ['on_hold', 'completed', 'cancelled']
|
|
150
|
+
},
|
|
151
|
+
completed: {
|
|
152
|
+
allowed_next: [],
|
|
153
|
+
is_terminal: true
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
message: 'Invalid status transition from {{old_status}} to {{new_status}}',
|
|
157
|
+
error_code: 'INVALID_STATE_TRANSITION'
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Validate on update
|
|
161
|
+
const updateContext: ValidationContext = {
|
|
162
|
+
record: { status: 'completed' },
|
|
163
|
+
previousRecord: { status: 'active' },
|
|
164
|
+
operation: 'update'
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const result = await validator.validate([statusRule], updateContext);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### Validation in Object Configuration
|
|
171
|
+
|
|
172
|
+
Add validation rules to your object metadata:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const projectConfig: ObjectConfig = {
|
|
176
|
+
name: 'project',
|
|
177
|
+
fields: {
|
|
178
|
+
// ... field definitions
|
|
179
|
+
},
|
|
180
|
+
validation: {
|
|
181
|
+
ai_context: {
|
|
182
|
+
intent: 'Ensure project data integrity',
|
|
183
|
+
validation_strategy: 'Fail fast with clear error messages'
|
|
184
|
+
},
|
|
185
|
+
rules: [
|
|
186
|
+
{
|
|
187
|
+
name: 'valid_date_range',
|
|
188
|
+
type: 'cross_field',
|
|
189
|
+
rule: {
|
|
190
|
+
field: 'end_date',
|
|
191
|
+
operator: '>=',
|
|
192
|
+
compare_to: 'start_date'
|
|
193
|
+
},
|
|
194
|
+
message: 'End date must be on or after start date',
|
|
195
|
+
error_code: 'INVALID_DATE_RANGE'
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'status_transition',
|
|
199
|
+
type: 'state_machine',
|
|
200
|
+
field: 'status',
|
|
201
|
+
transitions: {
|
|
202
|
+
planning: { allowed_next: ['active', 'cancelled'] },
|
|
203
|
+
active: { allowed_next: ['completed', 'cancelled'] }
|
|
204
|
+
},
|
|
205
|
+
message: 'Invalid status transition'
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### Validation Features
|
|
213
|
+
|
|
214
|
+
**Supported Validation Types:**
|
|
215
|
+
- `field` - Built-in field validation (required, format, min/max, length, pattern)
|
|
216
|
+
- `cross_field` - Validate relationships between fields
|
|
217
|
+
- `state_machine` - Enforce valid state transitions
|
|
218
|
+
- `unique` - Uniqueness validation (stub - requires database integration)
|
|
219
|
+
- `business_rule` - Complex business rules (stub - requires expression evaluation)
|
|
220
|
+
- `custom` - Custom validation logic (stub - requires safe function execution)
|
|
221
|
+
- `dependency` - Related record validation (stub - requires database integration)
|
|
222
|
+
|
|
223
|
+
**Comparison Operators:**
|
|
224
|
+
- `=`, `!=` - Equality/inequality
|
|
225
|
+
- `>`, `>=`, `<`, `<=` - Comparison
|
|
226
|
+
- `in`, `not_in` - Array membership
|
|
227
|
+
- `contains`, `not_contains` - String containment
|
|
228
|
+
- `starts_with`, `ends_with` - String prefix/suffix
|
|
229
|
+
|
|
230
|
+
**Validation Triggers:**
|
|
231
|
+
- `create` - Run on record creation
|
|
232
|
+
- `update` - Run on record update
|
|
233
|
+
- `delete` - Run on record deletion
|
|
234
|
+
|
|
235
|
+
**Severity Levels:**
|
|
236
|
+
- `error` - Blocks the operation
|
|
237
|
+
- `warning` - Shows warning but allows operation
|
|
238
|
+
- `info` - Informational message
|
|
239
|
+
|
|
240
|
+
**Advanced Features:**
|
|
241
|
+
- Field-specific triggers (validate only when specific fields change)
|
|
242
|
+
- Conditional validation with `apply_when`
|
|
243
|
+
- Template message formatting with `{{field}}` placeholders
|
|
244
|
+
- Internationalization support with language fallback
|
|
245
|
+
- AI context for documentation and LLM understanding
|
|
246
|
+
|
|
247
|
+
## Shared Metadata
|
|
248
|
+
|
|
249
|
+
You can pass an existing `MetadataRegistry` to ObjectQL:
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
const registry = new MetadataRegistry();
|
|
253
|
+
// ... pre-load metadata ...
|
|
254
|
+
|
|
255
|
+
const objectql = new ObjectQL({
|
|
256
|
+
registry: registry,
|
|
257
|
+
datasources: { ... }
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## API Reference
|
|
262
|
+
|
|
263
|
+
### Validator Class
|
|
264
|
+
|
|
265
|
+
**Constructor:**
|
|
266
|
+
```typescript
|
|
267
|
+
new Validator(options?: ValidatorOptions)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Options:**
|
|
271
|
+
- `language?: string` - Preferred language for validation messages (default: 'en')
|
|
272
|
+
- `languageFallback?: string[]` - Fallback languages (default: ['en', 'zh-CN'])
|
|
273
|
+
|
|
274
|
+
**Methods:**
|
|
275
|
+
|
|
276
|
+
- `validate(rules: AnyValidationRule[], context: ValidationContext): Promise<ValidationResult>`
|
|
277
|
+
- Executes validation rules against a record
|
|
278
|
+
- Returns validation result with errors, warnings, and info messages
|
|
279
|
+
|
|
280
|
+
- `validateField(fieldName: string, fieldConfig: FieldConfig, value: any, context: ValidationContext): Promise<ValidationRuleResult[]>`
|
|
281
|
+
- Validates a single field value
|
|
282
|
+
- Returns array of validation results
|
|
283
|
+
|
|
284
|
+
## See Also
|
|
285
|
+
|
|
286
|
+
- [@objectql/types](../types) - Type definitions including validation types
|
|
287
|
+
- [Validation Specification](../../docs/spec/validation.md) - Complete validation metadata specification
|
package/dist/app.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MetadataRegistry, Driver, ObjectConfig, ObjectQLContext, ObjectQLContextOptions, IObjectQL, ObjectQLConfig, ObjectQLPlugin, HookName, HookHandler, HookContext, ActionHandler, ActionContext
|
|
1
|
+
import { MetadataRegistry, Driver, ObjectConfig, ObjectQLContext, ObjectQLContextOptions, IObjectQL, ObjectQLConfig, ObjectQLPlugin, HookName, HookHandler, HookContext, ActionHandler, ActionContext } from '@objectql/types';
|
|
2
2
|
export declare class ObjectQL implements IObjectQL {
|
|
3
3
|
metadata: MetadataRegistry;
|
|
4
|
-
private loader;
|
|
5
4
|
private datasources;
|
|
6
5
|
private remotes;
|
|
7
6
|
private hooks;
|
|
@@ -9,16 +8,12 @@ export declare class ObjectQL implements IObjectQL {
|
|
|
9
8
|
private pluginsList;
|
|
10
9
|
private config;
|
|
11
10
|
constructor(config: ObjectQLConfig);
|
|
12
|
-
addPackage(name: string): void;
|
|
13
11
|
use(plugin: ObjectQLPlugin): void;
|
|
14
12
|
removePackage(name: string): void;
|
|
15
13
|
on(event: HookName, objectName: string, handler: HookHandler, packageName?: string): void;
|
|
16
14
|
triggerHook(event: HookName, objectName: string, ctx: HookContext): Promise<void>;
|
|
17
15
|
registerAction(objectName: string, actionName: string, handler: ActionHandler, packageName?: string): void;
|
|
18
16
|
executeAction(objectName: string, actionName: string, ctx: ActionContext): Promise<any>;
|
|
19
|
-
loadFromDirectory(dir: string, packageName?: string): void;
|
|
20
|
-
addLoader(plugin: LoaderPlugin): void;
|
|
21
|
-
updateMetadata(type: string, id: string, content: any): Promise<void>;
|
|
22
17
|
createContext(options: ObjectQLContextOptions): ObjectQLContext;
|
|
23
18
|
registerObject(object: ObjectConfig): void;
|
|
24
19
|
unregisterObject(name: string): void;
|
|
@@ -26,4 +21,5 @@ export declare class ObjectQL implements IObjectQL {
|
|
|
26
21
|
getConfigs(): Record<string, ObjectConfig>;
|
|
27
22
|
datasource(name: string): Driver;
|
|
28
23
|
init(): Promise<void>;
|
|
24
|
+
private processInitialData;
|
|
29
25
|
}
|
package/dist/app.js
CHANGED
|
@@ -1,48 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.ObjectQL = void 0;
|
|
37
4
|
const types_1 = require("@objectql/types");
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
|
-
const path = __importStar(require("path"));
|
|
40
|
-
const yaml = __importStar(require("js-yaml"));
|
|
41
|
-
const loader_1 = require("./loader");
|
|
42
5
|
const repository_1 = require("./repository");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const remote_1 = require("./remote");
|
|
6
|
+
// import { createDriverFromConnection } from './driver'; // REMOVE THIS
|
|
7
|
+
// import { loadRemoteFromUrl } from './remote';
|
|
46
8
|
const action_1 = require("./action");
|
|
47
9
|
const hook_1 = require("./hook");
|
|
48
10
|
const object_1 = require("./object");
|
|
@@ -55,17 +17,16 @@ class ObjectQL {
|
|
|
55
17
|
this.pluginsList = [];
|
|
56
18
|
this.config = config;
|
|
57
19
|
this.metadata = config.registry || new types_1.MetadataRegistry();
|
|
58
|
-
this.loader = new loader_1.ObjectLoader(this.metadata);
|
|
59
20
|
this.datasources = config.datasources || {};
|
|
60
|
-
this.remotes = config.remotes || [];
|
|
21
|
+
// this.remotes = config.remotes || [];
|
|
61
22
|
if (config.connection) {
|
|
62
|
-
|
|
23
|
+
throw new Error("Connection strings are not supported in core directly. Use @objectql/platform-node's createDriverFromConnection or pass a driver instance to 'datasources'.");
|
|
63
24
|
}
|
|
64
25
|
// Initialize Plugin List (but don't setup yet)
|
|
65
26
|
if (config.plugins) {
|
|
66
27
|
for (const plugin of config.plugins) {
|
|
67
28
|
if (typeof plugin === 'string') {
|
|
68
|
-
|
|
29
|
+
throw new Error("String plugins are not supported in core. Use @objectql/platform-node or pass plugin instance.");
|
|
69
30
|
}
|
|
70
31
|
else {
|
|
71
32
|
this.use(plugin);
|
|
@@ -73,9 +34,6 @@ class ObjectQL {
|
|
|
73
34
|
}
|
|
74
35
|
}
|
|
75
36
|
}
|
|
76
|
-
addPackage(name) {
|
|
77
|
-
this.loader.loadPackage(name);
|
|
78
|
-
}
|
|
79
37
|
use(plugin) {
|
|
80
38
|
this.pluginsList.push(plugin);
|
|
81
39
|
}
|
|
@@ -104,51 +62,6 @@ class ObjectQL {
|
|
|
104
62
|
async executeAction(objectName, actionName, ctx) {
|
|
105
63
|
return await (0, action_1.executeActionHelper)(this.metadata, this.actions, objectName, actionName, ctx);
|
|
106
64
|
}
|
|
107
|
-
loadFromDirectory(dir, packageName) {
|
|
108
|
-
this.loader.load(dir, packageName);
|
|
109
|
-
}
|
|
110
|
-
addLoader(plugin) {
|
|
111
|
-
this.loader.use(plugin);
|
|
112
|
-
}
|
|
113
|
-
async updateMetadata(type, id, content) {
|
|
114
|
-
// Use registry to find the entry so we can get the file path
|
|
115
|
-
const entry = this.metadata.getEntry(type, id);
|
|
116
|
-
if (!entry) {
|
|
117
|
-
throw new Error(`Metadata ${type}:${id} not found`);
|
|
118
|
-
}
|
|
119
|
-
if (!entry.path) {
|
|
120
|
-
throw new Error('Cannot update: Metadata source file not found (in-memory only?)');
|
|
121
|
-
}
|
|
122
|
-
// Safety Check: Prevent writing to node_modules
|
|
123
|
-
if (entry.path.includes('node_modules')) {
|
|
124
|
-
throw new Error(`Cannot update metadata ${type}:${id}: File is inside node_modules (read-only package).`);
|
|
125
|
-
}
|
|
126
|
-
// Check file extension
|
|
127
|
-
const ext = path.extname(entry.path).toLowerCase();
|
|
128
|
-
let newContent = '';
|
|
129
|
-
if (ext === '.yml' || ext === '.yaml') {
|
|
130
|
-
newContent = yaml.dump(content);
|
|
131
|
-
}
|
|
132
|
-
else if (ext === '.json') {
|
|
133
|
-
newContent = JSON.stringify(content, null, 2);
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
throw new Error(`Cannot update: Unsupported file format ${ext} (only .yml, .yaml, .json supported)`);
|
|
137
|
-
}
|
|
138
|
-
// Write file
|
|
139
|
-
try {
|
|
140
|
-
await fs.promises.chmod(entry.path, 0o666).catch(() => { }); // Try to ensure writable
|
|
141
|
-
await fs.promises.writeFile(entry.path, newContent, 'utf8');
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
throw new Error(`Failed to write file ${entry.path}: ${e.message}`);
|
|
145
|
-
}
|
|
146
|
-
// Update registry in-memory
|
|
147
|
-
entry.content = content;
|
|
148
|
-
// If it's an object update, we might need some re-processing?
|
|
149
|
-
// For now, assume a restart or reload is needed for deep schema changes,
|
|
150
|
-
// but simple property updates are reflected immediately in registry.
|
|
151
|
-
}
|
|
152
65
|
createContext(options) {
|
|
153
66
|
const ctx = {
|
|
154
67
|
userId: options.userId,
|
|
@@ -234,45 +147,16 @@ class ObjectQL {
|
|
|
234
147
|
}
|
|
235
148
|
await plugin.setup(app);
|
|
236
149
|
}
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
for (const name of this.config.packages) {
|
|
240
|
-
this.addPackage(name);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (this.config.presets) {
|
|
244
|
-
for (const name of this.config.presets) {
|
|
245
|
-
this.addPackage(name);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
// 2. Load Local Sources (Application Layer)
|
|
249
|
-
if (this.config.source) {
|
|
250
|
-
const sources = Array.isArray(this.config.source) ? this.config.source : [this.config.source];
|
|
251
|
-
for (const src of sources) {
|
|
252
|
-
this.loader.load(src);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
150
|
+
// Packages, Presets, Source, Objects loading logic removed from Core.
|
|
151
|
+
// Use @objectql/platform-node's ObjectLoader or platform-specific loaders.
|
|
255
152
|
// 3. Load In-Memory Objects (Dynamic Layer)
|
|
256
153
|
if (this.config.objects) {
|
|
257
154
|
for (const [key, obj] of Object.entries(this.config.objects)) {
|
|
258
155
|
this.registerObject(obj);
|
|
259
156
|
}
|
|
260
157
|
}
|
|
261
|
-
// 4. Load Remotes
|
|
262
|
-
if (this.remotes.length > 0) {
|
|
263
|
-
console.log(`Loading ${this.remotes.length} remotes...`);
|
|
264
|
-
const results = await Promise.all(this.remotes.map(url => (0, remote_1.loadRemoteFromUrl)(url)));
|
|
265
|
-
for (const res of results) {
|
|
266
|
-
if (res) {
|
|
267
|
-
this.datasources[res.driverName] = res.driver;
|
|
268
|
-
for (const obj of res.objects) {
|
|
269
|
-
this.registerObject(obj);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
158
|
const objects = this.metadata.list('object');
|
|
275
|
-
// 5. Init
|
|
159
|
+
// 5. Init Datasources
|
|
276
160
|
// Let's pass all objects to all configured drivers.
|
|
277
161
|
for (const [name, driver] of Object.entries(this.datasources)) {
|
|
278
162
|
if (driver.init) {
|
|
@@ -280,6 +164,51 @@ class ObjectQL {
|
|
|
280
164
|
await driver.init(objects);
|
|
281
165
|
}
|
|
282
166
|
}
|
|
167
|
+
// 6. Process Initial Data
|
|
168
|
+
await this.processInitialData();
|
|
169
|
+
}
|
|
170
|
+
async processInitialData() {
|
|
171
|
+
const dataEntries = this.metadata.list('data');
|
|
172
|
+
if (dataEntries.length === 0)
|
|
173
|
+
return;
|
|
174
|
+
console.log(`Processing ${dataEntries.length} initial data files...`);
|
|
175
|
+
// We need a system context to write data
|
|
176
|
+
const ctx = this.createContext({ isSystem: true });
|
|
177
|
+
for (const entry of dataEntries) {
|
|
178
|
+
// Expected format:
|
|
179
|
+
// 1. { object: 'User', records: [...] }
|
|
180
|
+
// 2. [ record1, record2 ] (with name property added by loader inferred from filename)
|
|
181
|
+
let objectName = entry.object;
|
|
182
|
+
let records = entry.records;
|
|
183
|
+
if (Array.isArray(entry)) {
|
|
184
|
+
records = entry;
|
|
185
|
+
if (!objectName && entry.name) {
|
|
186
|
+
objectName = entry.name;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (!objectName || !records || !Array.isArray(records)) {
|
|
190
|
+
console.warn(`Skipping invalid data entry:`, entry);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const repo = ctx.object(objectName);
|
|
194
|
+
for (const record of records) {
|
|
195
|
+
try {
|
|
196
|
+
// Check existence if a unique key is provided?
|
|
197
|
+
// For now, let's assume if it has an ID, we check it.
|
|
198
|
+
// Or we could try to find existing record by some key matching logic.
|
|
199
|
+
// Simple approach: create. If it fails (constraint), ignore.
|
|
200
|
+
// Actually, a better approach for initial data is "upsert" or "create if not exists".
|
|
201
|
+
// But without unique keys defined in data, we can't reliably dedup.
|
|
202
|
+
// Let's try to 'create' and catch errors.
|
|
203
|
+
await repo.create(record);
|
|
204
|
+
console.log(`Initialized record for ${objectName}`);
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
// Ignore duplicate key errors silently-ish
|
|
208
|
+
console.warn(`Failed to insert initial data for ${objectName}: ${e.message}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
283
212
|
}
|
|
284
213
|
}
|
|
285
214
|
exports.ObjectQL = ObjectQL;
|
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,2CAeyB;AACzB,6CAAgD;AAChD,wEAAwE;AAExE,gDAAgD;AAChD,qCAAkF;AAClF,iCAA0E;AAC1E,qCAAkE;AAElE,MAAa,QAAQ;IAWjB,YAAY,MAAsB;QAT1B,gBAAW,GAA2B,EAAE,CAAC;QACzC,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GAAgC,EAAE,CAAC;QACxC,YAAO,GAAgC,EAAE,CAAC;QAC1C,gBAAW,GAAqB,EAAE,CAAC;QAMvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,wBAAgB,EAAE,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC;QAC5C,uCAAuC;QAEvC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,6JAA6J,CAAC,CAAC;QACpL,CAAC;QAED,+CAA+C;QAC/C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBAClC,IAAI,OAAO,MAAM,KAAK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,IAAI,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;YAC9B,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAE5B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO,GAAG,KAAK,CAAC;gBAChB,IAAI,CAAC,UAAU,IAAK,KAAa,CAAC,IAAI,EAAE,CAAC;oBACrC,UAAU,GAAI,KAAa,CAAC,IAAI,CAAC;gBACrC,CAAC;YACL,CAAC;YAED,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACrD,OAAO,CAAC,IAAI,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;gBACpD,SAAS;YACb,CAAC;YAED,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAEpC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC3B,IAAI,CAAC;oBACD,+CAA+C;oBAC/C,sDAAsD;oBACtD,sEAAsE;oBACtE,6DAA6D;oBAE7D,sFAAsF;oBACtF,oEAAoE;oBACpE,0CAA0C;oBAC1C,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC1B,OAAO,CAAC,GAAG,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;gBACxD,CAAC;gBAAC,OAAO,CAAM,EAAE,CAAC;oBACd,2CAA2C;oBAC1C,OAAO,CAAC,IAAI,CAAC,qCAAqC,UAAU,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;gBACnF,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AA/OD,4BA+OC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export * from './loader';
|
|
2
1
|
export * from './repository';
|
|
3
2
|
export * from './app';
|
|
4
|
-
export * from './plugin';
|
|
5
|
-
export * from './driver';
|
|
6
|
-
export * from './remote';
|
|
7
3
|
export * from './action';
|
|
8
4
|
export * from './hook';
|
|
9
5
|
export * from './object';
|
|
6
|
+
export * from './validator';
|
|
7
|
+
export * from './util';
|
|
8
|
+
export * from './util';
|
package/dist/index.js
CHANGED
|
@@ -14,13 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./loader"), exports);
|
|
18
17
|
__exportStar(require("./repository"), exports);
|
|
19
18
|
__exportStar(require("./app"), exports);
|
|
20
|
-
__exportStar(require("./plugin"), exports);
|
|
21
|
-
__exportStar(require("./driver"), exports);
|
|
22
|
-
__exportStar(require("./remote"), exports);
|
|
23
19
|
__exportStar(require("./action"), exports);
|
|
24
20
|
__exportStar(require("./hook"), exports);
|
|
25
21
|
__exportStar(require("./object"), exports);
|
|
22
|
+
__exportStar(require("./validator"), exports);
|
|
23
|
+
__exportStar(require("./util"), exports);
|
|
24
|
+
__exportStar(require("./util"), exports);
|
|
26
25
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,wCAAsB;AAEtB,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB;AAEvB,yCAAuB"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toTitleCase(str: string): string;
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toTitleCase = toTitleCase;
|
|
4
|
+
function toTitleCase(str) {
|
|
5
|
+
return str
|
|
6
|
+
.replace(/_/g, ' ')
|
|
7
|
+
.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=util.js.map
|