@objectstack/objectql 2.0.3 → 2.0.5
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +19 -0
- package/dist/index.d.mts +167 -97
- package/dist/index.d.ts +167 -97
- package/dist/index.js +632 -165
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +629 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/engine.ts +415 -141
- package/src/index.ts +5 -4
- package/src/metadata-facade.ts +74 -0
- package/src/plugin.integration.test.ts +241 -0
- package/src/plugin.ts +198 -7
- package/src/protocol-discovery.test.ts +137 -0
- package/src/protocol.ts +107 -41
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/objectql@2.0.
|
|
2
|
+
> @objectstack/objectql@2.0.5 build /home/runner/work/spec/spec/packages/objectql
|
|
3
3
|
> tsup --config ../../tsup.config.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
14
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
16
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
17
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m71.78 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m145.78 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 150ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.js [22m[32m73.33 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m146.65 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 161ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 13396ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m70.72 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m70.72 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @objectstack/objectql
|
|
2
2
|
|
|
3
|
+
## 2.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @objectstack/spec@2.0.5
|
|
9
|
+
- @objectstack/core@2.0.5
|
|
10
|
+
- @objectstack/types@2.0.5
|
|
11
|
+
|
|
12
|
+
## 2.0.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Patch release for maintenance and stability improvements
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @objectstack/spec@2.0.4
|
|
19
|
+
- @objectstack/core@2.0.4
|
|
20
|
+
- @objectstack/types@2.0.4
|
|
21
|
+
|
|
3
22
|
## 2.0.3
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as _objectstack_spec_data from '@objectstack/spec/data';
|
|
3
|
-
import { ServiceObject, ObjectOwnership, HookContext, DataEngineQueryOptions, DataEngineInsertOptions, DataEngineUpdateOptions, DataEngineDeleteOptions, DataEngineCountOptions, DataEngineAggregateOptions } from '@objectstack/spec/data';
|
|
4
|
-
import { ObjectStackManifest, InstalledPackage } from '@objectstack/spec/kernel';
|
|
3
|
+
import { ServiceObject, ObjectOwnership, HookContext, QueryAST, DataEngineQueryOptions, DataEngineInsertOptions, DataEngineUpdateOptions, DataEngineDeleteOptions, DataEngineCountOptions, DataEngineAggregateOptions } from '@objectstack/spec/data';
|
|
4
|
+
import { ObjectStackManifest, InstalledPackage, ExecutionContext } from '@objectstack/spec/kernel';
|
|
5
5
|
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
|
|
6
6
|
import { IDataEngine, DriverInterface, Logger, Plugin, PluginContext } from '@objectstack/core';
|
|
7
7
|
|
|
@@ -1121,7 +1121,8 @@ declare class SchemaRegistry {
|
|
|
1121
1121
|
|
|
1122
1122
|
declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
1123
1123
|
private engine;
|
|
1124
|
-
|
|
1124
|
+
private getServicesRegistry?;
|
|
1125
|
+
constructor(engine: IDataEngine, getServicesRegistry?: () => Map<string, any>);
|
|
1125
1126
|
getDiscovery(): Promise<{
|
|
1126
1127
|
version: string;
|
|
1127
1128
|
apiName: string;
|
|
@@ -1139,99 +1140,26 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1139
1140
|
endpoints: {
|
|
1140
1141
|
data: string;
|
|
1141
1142
|
metadata: string;
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
status: "available";
|
|
1155
|
-
route: string;
|
|
1156
|
-
provider: string;
|
|
1157
|
-
};
|
|
1158
|
-
analytics: {
|
|
1159
|
-
enabled: boolean;
|
|
1160
|
-
status: "available";
|
|
1161
|
-
route: string;
|
|
1162
|
-
provider: string;
|
|
1163
|
-
};
|
|
1164
|
-
auth: {
|
|
1165
|
-
enabled: boolean;
|
|
1166
|
-
status: "unavailable";
|
|
1167
|
-
message: string;
|
|
1168
|
-
};
|
|
1169
|
-
automation: {
|
|
1170
|
-
enabled: boolean;
|
|
1171
|
-
status: "unavailable";
|
|
1172
|
-
message: string;
|
|
1173
|
-
};
|
|
1174
|
-
cache: {
|
|
1175
|
-
enabled: boolean;
|
|
1176
|
-
status: "unavailable";
|
|
1177
|
-
message: string;
|
|
1178
|
-
};
|
|
1179
|
-
queue: {
|
|
1180
|
-
enabled: boolean;
|
|
1181
|
-
status: "unavailable";
|
|
1182
|
-
message: string;
|
|
1183
|
-
};
|
|
1184
|
-
job: {
|
|
1185
|
-
enabled: boolean;
|
|
1186
|
-
status: "unavailable";
|
|
1187
|
-
message: string;
|
|
1188
|
-
};
|
|
1189
|
-
ui: {
|
|
1190
|
-
enabled: boolean;
|
|
1191
|
-
status: "unavailable";
|
|
1192
|
-
message: string;
|
|
1193
|
-
};
|
|
1194
|
-
workflow: {
|
|
1195
|
-
enabled: boolean;
|
|
1196
|
-
status: "unavailable";
|
|
1197
|
-
message: string;
|
|
1198
|
-
};
|
|
1199
|
-
realtime: {
|
|
1200
|
-
enabled: boolean;
|
|
1201
|
-
status: "unavailable";
|
|
1202
|
-
message: string;
|
|
1203
|
-
};
|
|
1204
|
-
notification: {
|
|
1205
|
-
enabled: boolean;
|
|
1206
|
-
status: "unavailable";
|
|
1207
|
-
message: string;
|
|
1208
|
-
};
|
|
1209
|
-
ai: {
|
|
1210
|
-
enabled: boolean;
|
|
1211
|
-
status: "unavailable";
|
|
1212
|
-
message: string;
|
|
1213
|
-
};
|
|
1214
|
-
i18n: {
|
|
1215
|
-
enabled: boolean;
|
|
1216
|
-
status: "unavailable";
|
|
1217
|
-
message: string;
|
|
1218
|
-
};
|
|
1219
|
-
graphql: {
|
|
1220
|
-
enabled: boolean;
|
|
1221
|
-
status: "unavailable";
|
|
1222
|
-
message: string;
|
|
1223
|
-
};
|
|
1224
|
-
'file-storage': {
|
|
1225
|
-
enabled: boolean;
|
|
1226
|
-
status: "unavailable";
|
|
1227
|
-
message: string;
|
|
1228
|
-
};
|
|
1229
|
-
search: {
|
|
1230
|
-
enabled: boolean;
|
|
1231
|
-
status: "unavailable";
|
|
1232
|
-
message: string;
|
|
1233
|
-
};
|
|
1143
|
+
ui?: string | undefined;
|
|
1144
|
+
auth?: string | undefined;
|
|
1145
|
+
automation?: string | undefined;
|
|
1146
|
+
storage?: string | undefined;
|
|
1147
|
+
analytics?: string | undefined;
|
|
1148
|
+
graphql?: string | undefined;
|
|
1149
|
+
packages?: string | undefined;
|
|
1150
|
+
workflow?: string | undefined;
|
|
1151
|
+
realtime?: string | undefined;
|
|
1152
|
+
notifications?: string | undefined;
|
|
1153
|
+
ai?: string | undefined;
|
|
1154
|
+
i18n?: string | undefined;
|
|
1234
1155
|
};
|
|
1156
|
+
services: Record<string, {
|
|
1157
|
+
enabled: boolean;
|
|
1158
|
+
status: "degraded" | "available" | "unavailable" | "stub";
|
|
1159
|
+
route?: string | undefined;
|
|
1160
|
+
provider?: string | undefined;
|
|
1161
|
+
message?: string | undefined;
|
|
1162
|
+
}>;
|
|
1235
1163
|
}>;
|
|
1236
1164
|
getMetaTypes(): Promise<{
|
|
1237
1165
|
types: string[];
|
|
@@ -1362,6 +1290,30 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1362
1290
|
}
|
|
1363
1291
|
|
|
1364
1292
|
type HookHandler = (context: HookContext) => Promise<void> | void;
|
|
1293
|
+
/**
|
|
1294
|
+
* Per-object hook entry with priority support
|
|
1295
|
+
*/
|
|
1296
|
+
interface HookEntry {
|
|
1297
|
+
handler: HookHandler;
|
|
1298
|
+
object?: string | string[];
|
|
1299
|
+
priority: number;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Operation Context for Middleware Chain
|
|
1303
|
+
*/
|
|
1304
|
+
interface OperationContext {
|
|
1305
|
+
object: string;
|
|
1306
|
+
operation: 'find' | 'findOne' | 'insert' | 'update' | 'delete' | 'count' | 'aggregate';
|
|
1307
|
+
ast?: QueryAST;
|
|
1308
|
+
data?: any;
|
|
1309
|
+
options?: any;
|
|
1310
|
+
context?: ExecutionContext;
|
|
1311
|
+
result?: any;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Engine Middleware (Onion model)
|
|
1315
|
+
*/
|
|
1316
|
+
type EngineMiddleware = (ctx: OperationContext, next: () => Promise<void>) => Promise<void>;
|
|
1365
1317
|
/**
|
|
1366
1318
|
* Host Context provided to plugins (Internal ObjectQL Plugin System)
|
|
1367
1319
|
*/
|
|
@@ -1383,6 +1335,7 @@ declare class ObjectQL implements IDataEngine {
|
|
|
1383
1335
|
private defaultDriver;
|
|
1384
1336
|
private logger;
|
|
1385
1337
|
private hooks;
|
|
1338
|
+
private middlewares;
|
|
1386
1339
|
private hostContext;
|
|
1387
1340
|
constructor(hostContext?: Record<string, any>);
|
|
1388
1341
|
/**
|
|
@@ -1407,9 +1360,30 @@ declare class ObjectQL implements IDataEngine {
|
|
|
1407
1360
|
* Register a hook
|
|
1408
1361
|
* @param event The event name (e.g. 'beforeFind', 'afterInsert')
|
|
1409
1362
|
* @param handler The handler function
|
|
1363
|
+
* @param options Optional: target object(s) and priority
|
|
1410
1364
|
*/
|
|
1411
|
-
registerHook(event: string, handler: HookHandler
|
|
1365
|
+
registerHook(event: string, handler: HookHandler, options?: {
|
|
1366
|
+
object?: string | string[];
|
|
1367
|
+
priority?: number;
|
|
1368
|
+
}): void;
|
|
1412
1369
|
triggerHooks(event: string, context: HookContext): Promise<void>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Register a middleware function
|
|
1372
|
+
* Middlewares execute in onion model around every data operation.
|
|
1373
|
+
* @param fn The middleware function
|
|
1374
|
+
* @param options Optional: target object filter
|
|
1375
|
+
*/
|
|
1376
|
+
registerMiddleware(fn: EngineMiddleware, options?: {
|
|
1377
|
+
object?: string;
|
|
1378
|
+
}): void;
|
|
1379
|
+
/**
|
|
1380
|
+
* Execute an operation through the middleware chain
|
|
1381
|
+
*/
|
|
1382
|
+
private executeWithMiddleware;
|
|
1383
|
+
/**
|
|
1384
|
+
* Build a HookContext.session from ExecutionContext
|
|
1385
|
+
*/
|
|
1386
|
+
private buildSession;
|
|
1413
1387
|
/**
|
|
1414
1388
|
* Register contribution (Manifest)
|
|
1415
1389
|
*
|
|
@@ -1725,6 +1699,87 @@ declare class ObjectQL implements IDataEngine {
|
|
|
1725
1699
|
count(object: string, query?: DataEngineCountOptions): Promise<number>;
|
|
1726
1700
|
aggregate(object: string, query: DataEngineAggregateOptions): Promise<any[]>;
|
|
1727
1701
|
execute(command: any, options?: Record<string, any>): Promise<any>;
|
|
1702
|
+
/**
|
|
1703
|
+
* Create a scoped execution context bound to this engine.
|
|
1704
|
+
*
|
|
1705
|
+
* Usage:
|
|
1706
|
+
* const ctx = engine.createContext({ userId: '...', tenantId: '...' });
|
|
1707
|
+
* const users = ctx.object('user');
|
|
1708
|
+
* await users.find({ filter: { status: 'active' } });
|
|
1709
|
+
*/
|
|
1710
|
+
createContext(ctx: Partial<ExecutionContext>): ScopedContext;
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Repository scoped to a single object, bound to an execution context.
|
|
1714
|
+
*/
|
|
1715
|
+
declare class ObjectRepository {
|
|
1716
|
+
private objectName;
|
|
1717
|
+
private context;
|
|
1718
|
+
private engine;
|
|
1719
|
+
constructor(objectName: string, context: ExecutionContext, engine: IDataEngine);
|
|
1720
|
+
find(query?: any): Promise<any[]>;
|
|
1721
|
+
findOne(query?: any): Promise<any>;
|
|
1722
|
+
insert(data: any): Promise<any>;
|
|
1723
|
+
update(data: any, options?: any): Promise<any>;
|
|
1724
|
+
delete(options?: any): Promise<any>;
|
|
1725
|
+
count(query?: any): Promise<number>;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Scoped execution context with object() accessor.
|
|
1729
|
+
*/
|
|
1730
|
+
declare class ScopedContext {
|
|
1731
|
+
private executionContext;
|
|
1732
|
+
private engine;
|
|
1733
|
+
constructor(executionContext: ExecutionContext, engine: IDataEngine);
|
|
1734
|
+
/** Get a repository scoped to this context */
|
|
1735
|
+
object(name: string): ObjectRepository;
|
|
1736
|
+
/** Create an elevated (system) context */
|
|
1737
|
+
sudo(): ScopedContext;
|
|
1738
|
+
get userId(): string | undefined;
|
|
1739
|
+
get tenantId(): string | undefined;
|
|
1740
|
+
get roles(): string[];
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* MetadataFacade
|
|
1745
|
+
*
|
|
1746
|
+
* Provides a clean, injectable interface over SchemaRegistry.
|
|
1747
|
+
* Registered as the 'metadata' kernel service to eliminate
|
|
1748
|
+
* downstream packages needing to manually wrap SchemaRegistry.
|
|
1749
|
+
*/
|
|
1750
|
+
declare class MetadataFacade {
|
|
1751
|
+
/**
|
|
1752
|
+
* Register a metadata item
|
|
1753
|
+
*/
|
|
1754
|
+
register(type: string, definition: any): void;
|
|
1755
|
+
/**
|
|
1756
|
+
* Get a metadata item by type and name
|
|
1757
|
+
*/
|
|
1758
|
+
get(type: string, name: string): any;
|
|
1759
|
+
/**
|
|
1760
|
+
* Get the raw entry (with metadata wrapper)
|
|
1761
|
+
*/
|
|
1762
|
+
getEntry(type: string, name: string): any;
|
|
1763
|
+
/**
|
|
1764
|
+
* List all items of a type
|
|
1765
|
+
*/
|
|
1766
|
+
list(type: string): any[];
|
|
1767
|
+
/**
|
|
1768
|
+
* Unregister a metadata item
|
|
1769
|
+
*/
|
|
1770
|
+
unregister(type: string, name: string): void;
|
|
1771
|
+
/**
|
|
1772
|
+
* Unregister all metadata from a package
|
|
1773
|
+
*/
|
|
1774
|
+
unregisterPackage(packageName: string): void;
|
|
1775
|
+
/**
|
|
1776
|
+
* Convenience: get object definition
|
|
1777
|
+
*/
|
|
1778
|
+
getObject(name: string): any;
|
|
1779
|
+
/**
|
|
1780
|
+
* Convenience: list all objects
|
|
1781
|
+
*/
|
|
1782
|
+
listObjects(): any[];
|
|
1728
1783
|
}
|
|
1729
1784
|
|
|
1730
1785
|
declare class ObjectQLPlugin implements Plugin {
|
|
@@ -1736,6 +1791,21 @@ declare class ObjectQLPlugin implements Plugin {
|
|
|
1736
1791
|
constructor(ql?: ObjectQL, hostContext?: Record<string, any>);
|
|
1737
1792
|
init: (ctx: PluginContext) => Promise<void>;
|
|
1738
1793
|
start: (ctx: PluginContext) => Promise<void>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Register built-in audit hooks for auto-stamping createdBy/modifiedBy
|
|
1796
|
+
* and fetching previousData for update/delete operations.
|
|
1797
|
+
*/
|
|
1798
|
+
private registerAuditHooks;
|
|
1799
|
+
/**
|
|
1800
|
+
* Register tenant isolation middleware that auto-injects space_id filter
|
|
1801
|
+
* for multi-tenant operations.
|
|
1802
|
+
*/
|
|
1803
|
+
private registerTenantMiddleware;
|
|
1804
|
+
/**
|
|
1805
|
+
* Load metadata from external metadata service into ObjectQL registry
|
|
1806
|
+
* This enables ObjectQL to use file-based or remote metadata
|
|
1807
|
+
*/
|
|
1808
|
+
private loadMetadataFromService;
|
|
1739
1809
|
}
|
|
1740
1810
|
|
|
1741
|
-
export { DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type HookHandler, type ObjectContributor, ObjectQL, type ObjectQLHostContext, ObjectQLPlugin, ObjectStackProtocolImplementation, RESERVED_NAMESPACES, SchemaRegistry, computeFQN, parseFQN };
|
|
1811
|
+
export { DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type EngineMiddleware, type HookEntry, type HookHandler, MetadataFacade, type ObjectContributor, ObjectQL, type ObjectQLHostContext, ObjectQLPlugin, ObjectRepository, ObjectStackProtocolImplementation, type OperationContext, RESERVED_NAMESPACES, SchemaRegistry, ScopedContext, computeFQN, parseFQN };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as _objectstack_spec_data from '@objectstack/spec/data';
|
|
3
|
-
import { ServiceObject, ObjectOwnership, HookContext, DataEngineQueryOptions, DataEngineInsertOptions, DataEngineUpdateOptions, DataEngineDeleteOptions, DataEngineCountOptions, DataEngineAggregateOptions } from '@objectstack/spec/data';
|
|
4
|
-
import { ObjectStackManifest, InstalledPackage } from '@objectstack/spec/kernel';
|
|
3
|
+
import { ServiceObject, ObjectOwnership, HookContext, QueryAST, DataEngineQueryOptions, DataEngineInsertOptions, DataEngineUpdateOptions, DataEngineDeleteOptions, DataEngineCountOptions, DataEngineAggregateOptions } from '@objectstack/spec/data';
|
|
4
|
+
import { ObjectStackManifest, InstalledPackage, ExecutionContext } from '@objectstack/spec/kernel';
|
|
5
5
|
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
|
|
6
6
|
import { IDataEngine, DriverInterface, Logger, Plugin, PluginContext } from '@objectstack/core';
|
|
7
7
|
|
|
@@ -1121,7 +1121,8 @@ declare class SchemaRegistry {
|
|
|
1121
1121
|
|
|
1122
1122
|
declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
1123
1123
|
private engine;
|
|
1124
|
-
|
|
1124
|
+
private getServicesRegistry?;
|
|
1125
|
+
constructor(engine: IDataEngine, getServicesRegistry?: () => Map<string, any>);
|
|
1125
1126
|
getDiscovery(): Promise<{
|
|
1126
1127
|
version: string;
|
|
1127
1128
|
apiName: string;
|
|
@@ -1139,99 +1140,26 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1139
1140
|
endpoints: {
|
|
1140
1141
|
data: string;
|
|
1141
1142
|
metadata: string;
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
status: "available";
|
|
1155
|
-
route: string;
|
|
1156
|
-
provider: string;
|
|
1157
|
-
};
|
|
1158
|
-
analytics: {
|
|
1159
|
-
enabled: boolean;
|
|
1160
|
-
status: "available";
|
|
1161
|
-
route: string;
|
|
1162
|
-
provider: string;
|
|
1163
|
-
};
|
|
1164
|
-
auth: {
|
|
1165
|
-
enabled: boolean;
|
|
1166
|
-
status: "unavailable";
|
|
1167
|
-
message: string;
|
|
1168
|
-
};
|
|
1169
|
-
automation: {
|
|
1170
|
-
enabled: boolean;
|
|
1171
|
-
status: "unavailable";
|
|
1172
|
-
message: string;
|
|
1173
|
-
};
|
|
1174
|
-
cache: {
|
|
1175
|
-
enabled: boolean;
|
|
1176
|
-
status: "unavailable";
|
|
1177
|
-
message: string;
|
|
1178
|
-
};
|
|
1179
|
-
queue: {
|
|
1180
|
-
enabled: boolean;
|
|
1181
|
-
status: "unavailable";
|
|
1182
|
-
message: string;
|
|
1183
|
-
};
|
|
1184
|
-
job: {
|
|
1185
|
-
enabled: boolean;
|
|
1186
|
-
status: "unavailable";
|
|
1187
|
-
message: string;
|
|
1188
|
-
};
|
|
1189
|
-
ui: {
|
|
1190
|
-
enabled: boolean;
|
|
1191
|
-
status: "unavailable";
|
|
1192
|
-
message: string;
|
|
1193
|
-
};
|
|
1194
|
-
workflow: {
|
|
1195
|
-
enabled: boolean;
|
|
1196
|
-
status: "unavailable";
|
|
1197
|
-
message: string;
|
|
1198
|
-
};
|
|
1199
|
-
realtime: {
|
|
1200
|
-
enabled: boolean;
|
|
1201
|
-
status: "unavailable";
|
|
1202
|
-
message: string;
|
|
1203
|
-
};
|
|
1204
|
-
notification: {
|
|
1205
|
-
enabled: boolean;
|
|
1206
|
-
status: "unavailable";
|
|
1207
|
-
message: string;
|
|
1208
|
-
};
|
|
1209
|
-
ai: {
|
|
1210
|
-
enabled: boolean;
|
|
1211
|
-
status: "unavailable";
|
|
1212
|
-
message: string;
|
|
1213
|
-
};
|
|
1214
|
-
i18n: {
|
|
1215
|
-
enabled: boolean;
|
|
1216
|
-
status: "unavailable";
|
|
1217
|
-
message: string;
|
|
1218
|
-
};
|
|
1219
|
-
graphql: {
|
|
1220
|
-
enabled: boolean;
|
|
1221
|
-
status: "unavailable";
|
|
1222
|
-
message: string;
|
|
1223
|
-
};
|
|
1224
|
-
'file-storage': {
|
|
1225
|
-
enabled: boolean;
|
|
1226
|
-
status: "unavailable";
|
|
1227
|
-
message: string;
|
|
1228
|
-
};
|
|
1229
|
-
search: {
|
|
1230
|
-
enabled: boolean;
|
|
1231
|
-
status: "unavailable";
|
|
1232
|
-
message: string;
|
|
1233
|
-
};
|
|
1143
|
+
ui?: string | undefined;
|
|
1144
|
+
auth?: string | undefined;
|
|
1145
|
+
automation?: string | undefined;
|
|
1146
|
+
storage?: string | undefined;
|
|
1147
|
+
analytics?: string | undefined;
|
|
1148
|
+
graphql?: string | undefined;
|
|
1149
|
+
packages?: string | undefined;
|
|
1150
|
+
workflow?: string | undefined;
|
|
1151
|
+
realtime?: string | undefined;
|
|
1152
|
+
notifications?: string | undefined;
|
|
1153
|
+
ai?: string | undefined;
|
|
1154
|
+
i18n?: string | undefined;
|
|
1234
1155
|
};
|
|
1156
|
+
services: Record<string, {
|
|
1157
|
+
enabled: boolean;
|
|
1158
|
+
status: "degraded" | "available" | "unavailable" | "stub";
|
|
1159
|
+
route?: string | undefined;
|
|
1160
|
+
provider?: string | undefined;
|
|
1161
|
+
message?: string | undefined;
|
|
1162
|
+
}>;
|
|
1235
1163
|
}>;
|
|
1236
1164
|
getMetaTypes(): Promise<{
|
|
1237
1165
|
types: string[];
|
|
@@ -1362,6 +1290,30 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1362
1290
|
}
|
|
1363
1291
|
|
|
1364
1292
|
type HookHandler = (context: HookContext) => Promise<void> | void;
|
|
1293
|
+
/**
|
|
1294
|
+
* Per-object hook entry with priority support
|
|
1295
|
+
*/
|
|
1296
|
+
interface HookEntry {
|
|
1297
|
+
handler: HookHandler;
|
|
1298
|
+
object?: string | string[];
|
|
1299
|
+
priority: number;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Operation Context for Middleware Chain
|
|
1303
|
+
*/
|
|
1304
|
+
interface OperationContext {
|
|
1305
|
+
object: string;
|
|
1306
|
+
operation: 'find' | 'findOne' | 'insert' | 'update' | 'delete' | 'count' | 'aggregate';
|
|
1307
|
+
ast?: QueryAST;
|
|
1308
|
+
data?: any;
|
|
1309
|
+
options?: any;
|
|
1310
|
+
context?: ExecutionContext;
|
|
1311
|
+
result?: any;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Engine Middleware (Onion model)
|
|
1315
|
+
*/
|
|
1316
|
+
type EngineMiddleware = (ctx: OperationContext, next: () => Promise<void>) => Promise<void>;
|
|
1365
1317
|
/**
|
|
1366
1318
|
* Host Context provided to plugins (Internal ObjectQL Plugin System)
|
|
1367
1319
|
*/
|
|
@@ -1383,6 +1335,7 @@ declare class ObjectQL implements IDataEngine {
|
|
|
1383
1335
|
private defaultDriver;
|
|
1384
1336
|
private logger;
|
|
1385
1337
|
private hooks;
|
|
1338
|
+
private middlewares;
|
|
1386
1339
|
private hostContext;
|
|
1387
1340
|
constructor(hostContext?: Record<string, any>);
|
|
1388
1341
|
/**
|
|
@@ -1407,9 +1360,30 @@ declare class ObjectQL implements IDataEngine {
|
|
|
1407
1360
|
* Register a hook
|
|
1408
1361
|
* @param event The event name (e.g. 'beforeFind', 'afterInsert')
|
|
1409
1362
|
* @param handler The handler function
|
|
1363
|
+
* @param options Optional: target object(s) and priority
|
|
1410
1364
|
*/
|
|
1411
|
-
registerHook(event: string, handler: HookHandler
|
|
1365
|
+
registerHook(event: string, handler: HookHandler, options?: {
|
|
1366
|
+
object?: string | string[];
|
|
1367
|
+
priority?: number;
|
|
1368
|
+
}): void;
|
|
1412
1369
|
triggerHooks(event: string, context: HookContext): Promise<void>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Register a middleware function
|
|
1372
|
+
* Middlewares execute in onion model around every data operation.
|
|
1373
|
+
* @param fn The middleware function
|
|
1374
|
+
* @param options Optional: target object filter
|
|
1375
|
+
*/
|
|
1376
|
+
registerMiddleware(fn: EngineMiddleware, options?: {
|
|
1377
|
+
object?: string;
|
|
1378
|
+
}): void;
|
|
1379
|
+
/**
|
|
1380
|
+
* Execute an operation through the middleware chain
|
|
1381
|
+
*/
|
|
1382
|
+
private executeWithMiddleware;
|
|
1383
|
+
/**
|
|
1384
|
+
* Build a HookContext.session from ExecutionContext
|
|
1385
|
+
*/
|
|
1386
|
+
private buildSession;
|
|
1413
1387
|
/**
|
|
1414
1388
|
* Register contribution (Manifest)
|
|
1415
1389
|
*
|
|
@@ -1725,6 +1699,87 @@ declare class ObjectQL implements IDataEngine {
|
|
|
1725
1699
|
count(object: string, query?: DataEngineCountOptions): Promise<number>;
|
|
1726
1700
|
aggregate(object: string, query: DataEngineAggregateOptions): Promise<any[]>;
|
|
1727
1701
|
execute(command: any, options?: Record<string, any>): Promise<any>;
|
|
1702
|
+
/**
|
|
1703
|
+
* Create a scoped execution context bound to this engine.
|
|
1704
|
+
*
|
|
1705
|
+
* Usage:
|
|
1706
|
+
* const ctx = engine.createContext({ userId: '...', tenantId: '...' });
|
|
1707
|
+
* const users = ctx.object('user');
|
|
1708
|
+
* await users.find({ filter: { status: 'active' } });
|
|
1709
|
+
*/
|
|
1710
|
+
createContext(ctx: Partial<ExecutionContext>): ScopedContext;
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Repository scoped to a single object, bound to an execution context.
|
|
1714
|
+
*/
|
|
1715
|
+
declare class ObjectRepository {
|
|
1716
|
+
private objectName;
|
|
1717
|
+
private context;
|
|
1718
|
+
private engine;
|
|
1719
|
+
constructor(objectName: string, context: ExecutionContext, engine: IDataEngine);
|
|
1720
|
+
find(query?: any): Promise<any[]>;
|
|
1721
|
+
findOne(query?: any): Promise<any>;
|
|
1722
|
+
insert(data: any): Promise<any>;
|
|
1723
|
+
update(data: any, options?: any): Promise<any>;
|
|
1724
|
+
delete(options?: any): Promise<any>;
|
|
1725
|
+
count(query?: any): Promise<number>;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Scoped execution context with object() accessor.
|
|
1729
|
+
*/
|
|
1730
|
+
declare class ScopedContext {
|
|
1731
|
+
private executionContext;
|
|
1732
|
+
private engine;
|
|
1733
|
+
constructor(executionContext: ExecutionContext, engine: IDataEngine);
|
|
1734
|
+
/** Get a repository scoped to this context */
|
|
1735
|
+
object(name: string): ObjectRepository;
|
|
1736
|
+
/** Create an elevated (system) context */
|
|
1737
|
+
sudo(): ScopedContext;
|
|
1738
|
+
get userId(): string | undefined;
|
|
1739
|
+
get tenantId(): string | undefined;
|
|
1740
|
+
get roles(): string[];
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* MetadataFacade
|
|
1745
|
+
*
|
|
1746
|
+
* Provides a clean, injectable interface over SchemaRegistry.
|
|
1747
|
+
* Registered as the 'metadata' kernel service to eliminate
|
|
1748
|
+
* downstream packages needing to manually wrap SchemaRegistry.
|
|
1749
|
+
*/
|
|
1750
|
+
declare class MetadataFacade {
|
|
1751
|
+
/**
|
|
1752
|
+
* Register a metadata item
|
|
1753
|
+
*/
|
|
1754
|
+
register(type: string, definition: any): void;
|
|
1755
|
+
/**
|
|
1756
|
+
* Get a metadata item by type and name
|
|
1757
|
+
*/
|
|
1758
|
+
get(type: string, name: string): any;
|
|
1759
|
+
/**
|
|
1760
|
+
* Get the raw entry (with metadata wrapper)
|
|
1761
|
+
*/
|
|
1762
|
+
getEntry(type: string, name: string): any;
|
|
1763
|
+
/**
|
|
1764
|
+
* List all items of a type
|
|
1765
|
+
*/
|
|
1766
|
+
list(type: string): any[];
|
|
1767
|
+
/**
|
|
1768
|
+
* Unregister a metadata item
|
|
1769
|
+
*/
|
|
1770
|
+
unregister(type: string, name: string): void;
|
|
1771
|
+
/**
|
|
1772
|
+
* Unregister all metadata from a package
|
|
1773
|
+
*/
|
|
1774
|
+
unregisterPackage(packageName: string): void;
|
|
1775
|
+
/**
|
|
1776
|
+
* Convenience: get object definition
|
|
1777
|
+
*/
|
|
1778
|
+
getObject(name: string): any;
|
|
1779
|
+
/**
|
|
1780
|
+
* Convenience: list all objects
|
|
1781
|
+
*/
|
|
1782
|
+
listObjects(): any[];
|
|
1728
1783
|
}
|
|
1729
1784
|
|
|
1730
1785
|
declare class ObjectQLPlugin implements Plugin {
|
|
@@ -1736,6 +1791,21 @@ declare class ObjectQLPlugin implements Plugin {
|
|
|
1736
1791
|
constructor(ql?: ObjectQL, hostContext?: Record<string, any>);
|
|
1737
1792
|
init: (ctx: PluginContext) => Promise<void>;
|
|
1738
1793
|
start: (ctx: PluginContext) => Promise<void>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Register built-in audit hooks for auto-stamping createdBy/modifiedBy
|
|
1796
|
+
* and fetching previousData for update/delete operations.
|
|
1797
|
+
*/
|
|
1798
|
+
private registerAuditHooks;
|
|
1799
|
+
/**
|
|
1800
|
+
* Register tenant isolation middleware that auto-injects space_id filter
|
|
1801
|
+
* for multi-tenant operations.
|
|
1802
|
+
*/
|
|
1803
|
+
private registerTenantMiddleware;
|
|
1804
|
+
/**
|
|
1805
|
+
* Load metadata from external metadata service into ObjectQL registry
|
|
1806
|
+
* This enables ObjectQL to use file-based or remote metadata
|
|
1807
|
+
*/
|
|
1808
|
+
private loadMetadataFromService;
|
|
1739
1809
|
}
|
|
1740
1810
|
|
|
1741
|
-
export { DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type HookHandler, type ObjectContributor, ObjectQL, type ObjectQLHostContext, ObjectQLPlugin, ObjectStackProtocolImplementation, RESERVED_NAMESPACES, SchemaRegistry, computeFQN, parseFQN };
|
|
1811
|
+
export { DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type EngineMiddleware, type HookEntry, type HookHandler, MetadataFacade, type ObjectContributor, ObjectQL, type ObjectQLHostContext, ObjectQLPlugin, ObjectRepository, ObjectStackProtocolImplementation, type OperationContext, RESERVED_NAMESPACES, SchemaRegistry, ScopedContext, computeFQN, parseFQN };
|