@objectstack/objectql 4.0.2 → 4.0.4

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/objectql@4.0.2 build /home/runner/work/framework/framework/packages/objectql
2
+ > @objectstack/objectql@4.0.4 build /home/runner/work/framework/framework/packages/objectql
3
3
  > tsup --config ../../tsup.config.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- CJS dist/index.js 104.57 KB
14
- CJS dist/index.js.map 212.32 KB
15
- CJS ⚡️ Build success in 297ms
16
- ESM dist/index.mjs 102.83 KB
17
- ESM dist/index.mjs.map 211.02 KB
18
- ESM ⚡️ Build success in 297ms
13
+ CJS dist/index.js 117.80 KB
14
+ CJS dist/index.js.map 237.44 KB
15
+ CJS ⚡️ Build success in 238ms
16
+ ESM dist/index.mjs 115.90 KB
17
+ ESM dist/index.mjs.map 236.13 KB
18
+ ESM ⚡️ Build success in 244ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 20150ms
21
- DTS dist/index.d.mts 77.34 KB
22
- DTS dist/index.d.ts 77.34 KB
20
+ DTS ⚡️ Build success in 27180ms
21
+ DTS dist/index.d.mts 79.80 KB
22
+ DTS dist/index.d.ts 79.80 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @objectstack/objectql
2
2
 
3
+ ## 4.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [326b66b]
8
+ - @objectstack/spec@4.0.4
9
+ - @objectstack/core@4.0.4
10
+ - @objectstack/types@4.0.4
11
+
12
+ ## 4.0.3
13
+
14
+ ### Patch Changes
15
+
16
+ - @objectstack/spec@4.0.3
17
+ - @objectstack/core@4.0.3
18
+ - @objectstack/types@4.0.3
19
+
20
+ ## 4.0.3
21
+
22
+ ### Patch Changes
23
+
24
+ - fix: ObjectQL.init() now tracks and warns about failed driver connections instead of silently swallowing errors, improving debuggability for cold-start and serverless issues.
25
+
3
26
  ## 4.0.2
4
27
 
5
28
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import { ObjectOwnership, ServiceObject, QueryAST, HookContext, EngineQueryOptio
4
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, ObjectKernel } from '@objectstack/core';
7
- import { IFeedService } from '@objectstack/spec/contracts';
7
+ import { IFeedService, IRealtimeService } from '@objectstack/spec/contracts';
8
8
 
9
9
  /**
10
10
  * XState-inspired State Machine Protocol
@@ -474,7 +474,7 @@ declare class SchemaRegistry {
474
474
  actions?: {
475
475
  name: string;
476
476
  label: string;
477
- type: "url" | "script" | "modal" | "flow" | "api";
477
+ type: "url" | "flow" | "api" | "script" | "modal";
478
478
  refreshAfter: boolean;
479
479
  objectName?: string | undefined;
480
480
  icon?: string | undefined;
@@ -563,8 +563,9 @@ declare class SchemaRegistry {
563
563
  } | {
564
564
  manifest: {
565
565
  id: string;
566
+ defaultDatasource: string;
566
567
  version: string;
567
- type: "theme" | "driver" | "app" | "server" | "ui" | "module" | "agent" | "objectql" | "plugin" | "gateway" | "adapter";
568
+ type: "theme" | "app" | "agent" | "driver" | "server" | "ui" | "module" | "objectql" | "plugin" | "gateway" | "adapter";
568
569
  name: string;
569
570
  namespace?: string | undefined;
570
571
  description?: string | undefined;
@@ -709,7 +710,7 @@ declare class SchemaRegistry {
709
710
  extensionPoints?: {
710
711
  id: string;
711
712
  name: string;
712
- type: "provider" | "action" | "widget" | "hook" | "transformer" | "validator" | "decorator";
713
+ type: "provider" | "action" | "hook" | "widget" | "transformer" | "validator" | "decorator";
713
714
  cardinality: "multiple" | "single";
714
715
  description?: string | undefined;
715
716
  contract?: {
@@ -888,8 +889,9 @@ declare class SchemaRegistry {
888
889
  registeredNamespaces?: string[] | undefined;
889
890
  } | {
890
891
  id: string;
892
+ defaultDatasource: string;
891
893
  version: string;
892
- type: "theme" | "driver" | "app" | "server" | "ui" | "module" | "agent" | "objectql" | "plugin" | "gateway" | "adapter";
894
+ type: "theme" | "app" | "agent" | "driver" | "server" | "ui" | "module" | "objectql" | "plugin" | "gateway" | "adapter";
893
895
  name: string;
894
896
  namespace?: string | undefined;
895
897
  description?: string | undefined;
@@ -1034,7 +1036,7 @@ declare class SchemaRegistry {
1034
1036
  extensionPoints?: {
1035
1037
  id: string;
1036
1038
  name: string;
1037
- type: "provider" | "action" | "widget" | "hook" | "transformer" | "validator" | "decorator";
1039
+ type: "provider" | "action" | "hook" | "widget" | "transformer" | "validator" | "decorator";
1038
1040
  cardinality: "multiple" | "single";
1039
1041
  description?: string | undefined;
1040
1042
  contract?: {
@@ -1487,10 +1489,13 @@ declare class ObjectQL implements IDataEngine {
1487
1489
  private drivers;
1488
1490
  private defaultDriver;
1489
1491
  private logger;
1492
+ private datasourceMapping;
1493
+ private manifests;
1490
1494
  private hooks;
1491
1495
  private middlewares;
1492
1496
  private actions;
1493
1497
  private hostContext;
1498
+ private realtimeService?;
1494
1499
  constructor(hostContext?: Record<string, any>);
1495
1500
  /**
1496
1501
  * Service Status Report
@@ -1584,6 +1589,13 @@ declare class ObjectQL implements IDataEngine {
1584
1589
  * Register a new storage driver
1585
1590
  */
1586
1591
  registerDriver(driver: DriverInterface, isDefault?: boolean): void;
1592
+ /**
1593
+ * Set the realtime service for publishing data change events.
1594
+ * Should be called after kernel resolves the realtime service.
1595
+ *
1596
+ * @param service - An IRealtimeService instance for event publishing
1597
+ */
1598
+ setRealtimeService(service: IRealtimeService): void;
1587
1599
  /**
1588
1600
  * Helper to get object definition
1589
1601
  */
@@ -1601,8 +1613,38 @@ declare class ObjectQL implements IDataEngine {
1601
1613
  private resolveObjectName;
1602
1614
  /**
1603
1615
  * Helper to get the target driver
1616
+ *
1617
+ * Resolution priority (first match wins):
1618
+ * 1. Object's explicit `datasource` field (if not 'default')
1619
+ * 2. DatasourceMapping rules (namespace/package/pattern matching)
1620
+ * 3. Package's `defaultDatasource` from manifest
1621
+ * 4. Global default driver
1604
1622
  */
1605
1623
  private getDriver;
1624
+ /**
1625
+ * Resolve datasource from mapping rules
1626
+ *
1627
+ * Rules are evaluated in order (or by priority if specified).
1628
+ * First matching rule wins.
1629
+ */
1630
+ private resolveDatasourceFromMapping;
1631
+ /**
1632
+ * Simple glob pattern matching
1633
+ * Supports * (any chars) and ? (single char)
1634
+ */
1635
+ private matchPattern;
1636
+ /**
1637
+ * Set datasource mapping rules
1638
+ * Called by ObjectQLPlugin during bootstrap
1639
+ */
1640
+ setDatasourceMapping(rules: Array<{
1641
+ namespace?: string;
1642
+ package?: string;
1643
+ objectPattern?: string;
1644
+ default?: boolean;
1645
+ datasource: string;
1646
+ priority?: number;
1647
+ }>): void;
1606
1648
  /**
1607
1649
  * Initialize the engine and all registered drivers
1608
1650
  */
@@ -1879,6 +1921,30 @@ declare class ObjectQLPlugin implements Plugin {
1879
1921
  * Drivers that do not implement `syncSchema` are silently skipped.
1880
1922
  */
1881
1923
  private syncRegisteredSchemas;
1924
+ /**
1925
+ * Restore persisted metadata from the database (sys_metadata) on startup.
1926
+ *
1927
+ * Calls `protocol.loadMetaFromDb()` to bulk-load all active metadata
1928
+ * records (objects, views, apps, etc.) into the in-memory SchemaRegistry.
1929
+ * This closes the persistence loop so that user-created schemas survive
1930
+ * kernel cold starts and redeployments.
1931
+ *
1932
+ * Gracefully degrades when:
1933
+ * - The protocol service is unavailable (e.g., in-memory-only mode).
1934
+ * - `loadMetaFromDb` is not implemented by the protocol shim.
1935
+ * - The underlying driver/table does not exist yet (first-run scenario).
1936
+ */
1937
+ private restoreMetadataFromDb;
1938
+ /**
1939
+ * Bridge all SchemaRegistry objects to the metadata service.
1940
+ *
1941
+ * This ensures objects registered by plugins and loaded from sys_metadata
1942
+ * are visible to AI tools and other consumers that query IMetadataService.
1943
+ *
1944
+ * Runs after both restoreMetadataFromDb() and syncRegisteredSchemas() to
1945
+ * catch all objects in the SchemaRegistry regardless of their source.
1946
+ */
1947
+ private bridgeObjectsToMetadataService;
1882
1948
  /**
1883
1949
  * Load metadata from external metadata service into ObjectQL registry
1884
1950
  * This enables ObjectQL to use file-based or remote metadata
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { ObjectOwnership, ServiceObject, QueryAST, HookContext, EngineQueryOptio
4
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, ObjectKernel } from '@objectstack/core';
7
- import { IFeedService } from '@objectstack/spec/contracts';
7
+ import { IFeedService, IRealtimeService } from '@objectstack/spec/contracts';
8
8
 
9
9
  /**
10
10
  * XState-inspired State Machine Protocol
@@ -474,7 +474,7 @@ declare class SchemaRegistry {
474
474
  actions?: {
475
475
  name: string;
476
476
  label: string;
477
- type: "url" | "script" | "modal" | "flow" | "api";
477
+ type: "url" | "flow" | "api" | "script" | "modal";
478
478
  refreshAfter: boolean;
479
479
  objectName?: string | undefined;
480
480
  icon?: string | undefined;
@@ -563,8 +563,9 @@ declare class SchemaRegistry {
563
563
  } | {
564
564
  manifest: {
565
565
  id: string;
566
+ defaultDatasource: string;
566
567
  version: string;
567
- type: "theme" | "driver" | "app" | "server" | "ui" | "module" | "agent" | "objectql" | "plugin" | "gateway" | "adapter";
568
+ type: "theme" | "app" | "agent" | "driver" | "server" | "ui" | "module" | "objectql" | "plugin" | "gateway" | "adapter";
568
569
  name: string;
569
570
  namespace?: string | undefined;
570
571
  description?: string | undefined;
@@ -709,7 +710,7 @@ declare class SchemaRegistry {
709
710
  extensionPoints?: {
710
711
  id: string;
711
712
  name: string;
712
- type: "provider" | "action" | "widget" | "hook" | "transformer" | "validator" | "decorator";
713
+ type: "provider" | "action" | "hook" | "widget" | "transformer" | "validator" | "decorator";
713
714
  cardinality: "multiple" | "single";
714
715
  description?: string | undefined;
715
716
  contract?: {
@@ -888,8 +889,9 @@ declare class SchemaRegistry {
888
889
  registeredNamespaces?: string[] | undefined;
889
890
  } | {
890
891
  id: string;
892
+ defaultDatasource: string;
891
893
  version: string;
892
- type: "theme" | "driver" | "app" | "server" | "ui" | "module" | "agent" | "objectql" | "plugin" | "gateway" | "adapter";
894
+ type: "theme" | "app" | "agent" | "driver" | "server" | "ui" | "module" | "objectql" | "plugin" | "gateway" | "adapter";
893
895
  name: string;
894
896
  namespace?: string | undefined;
895
897
  description?: string | undefined;
@@ -1034,7 +1036,7 @@ declare class SchemaRegistry {
1034
1036
  extensionPoints?: {
1035
1037
  id: string;
1036
1038
  name: string;
1037
- type: "provider" | "action" | "widget" | "hook" | "transformer" | "validator" | "decorator";
1039
+ type: "provider" | "action" | "hook" | "widget" | "transformer" | "validator" | "decorator";
1038
1040
  cardinality: "multiple" | "single";
1039
1041
  description?: string | undefined;
1040
1042
  contract?: {
@@ -1487,10 +1489,13 @@ declare class ObjectQL implements IDataEngine {
1487
1489
  private drivers;
1488
1490
  private defaultDriver;
1489
1491
  private logger;
1492
+ private datasourceMapping;
1493
+ private manifests;
1490
1494
  private hooks;
1491
1495
  private middlewares;
1492
1496
  private actions;
1493
1497
  private hostContext;
1498
+ private realtimeService?;
1494
1499
  constructor(hostContext?: Record<string, any>);
1495
1500
  /**
1496
1501
  * Service Status Report
@@ -1584,6 +1589,13 @@ declare class ObjectQL implements IDataEngine {
1584
1589
  * Register a new storage driver
1585
1590
  */
1586
1591
  registerDriver(driver: DriverInterface, isDefault?: boolean): void;
1592
+ /**
1593
+ * Set the realtime service for publishing data change events.
1594
+ * Should be called after kernel resolves the realtime service.
1595
+ *
1596
+ * @param service - An IRealtimeService instance for event publishing
1597
+ */
1598
+ setRealtimeService(service: IRealtimeService): void;
1587
1599
  /**
1588
1600
  * Helper to get object definition
1589
1601
  */
@@ -1601,8 +1613,38 @@ declare class ObjectQL implements IDataEngine {
1601
1613
  private resolveObjectName;
1602
1614
  /**
1603
1615
  * Helper to get the target driver
1616
+ *
1617
+ * Resolution priority (first match wins):
1618
+ * 1. Object's explicit `datasource` field (if not 'default')
1619
+ * 2. DatasourceMapping rules (namespace/package/pattern matching)
1620
+ * 3. Package's `defaultDatasource` from manifest
1621
+ * 4. Global default driver
1604
1622
  */
1605
1623
  private getDriver;
1624
+ /**
1625
+ * Resolve datasource from mapping rules
1626
+ *
1627
+ * Rules are evaluated in order (or by priority if specified).
1628
+ * First matching rule wins.
1629
+ */
1630
+ private resolveDatasourceFromMapping;
1631
+ /**
1632
+ * Simple glob pattern matching
1633
+ * Supports * (any chars) and ? (single char)
1634
+ */
1635
+ private matchPattern;
1636
+ /**
1637
+ * Set datasource mapping rules
1638
+ * Called by ObjectQLPlugin during bootstrap
1639
+ */
1640
+ setDatasourceMapping(rules: Array<{
1641
+ namespace?: string;
1642
+ package?: string;
1643
+ objectPattern?: string;
1644
+ default?: boolean;
1645
+ datasource: string;
1646
+ priority?: number;
1647
+ }>): void;
1606
1648
  /**
1607
1649
  * Initialize the engine and all registered drivers
1608
1650
  */
@@ -1879,6 +1921,30 @@ declare class ObjectQLPlugin implements Plugin {
1879
1921
  * Drivers that do not implement `syncSchema` are silently skipped.
1880
1922
  */
1881
1923
  private syncRegisteredSchemas;
1924
+ /**
1925
+ * Restore persisted metadata from the database (sys_metadata) on startup.
1926
+ *
1927
+ * Calls `protocol.loadMetaFromDb()` to bulk-load all active metadata
1928
+ * records (objects, views, apps, etc.) into the in-memory SchemaRegistry.
1929
+ * This closes the persistence loop so that user-created schemas survive
1930
+ * kernel cold starts and redeployments.
1931
+ *
1932
+ * Gracefully degrades when:
1933
+ * - The protocol service is unavailable (e.g., in-memory-only mode).
1934
+ * - `loadMetaFromDb` is not implemented by the protocol shim.
1935
+ * - The underlying driver/table does not exist yet (first-run scenario).
1936
+ */
1937
+ private restoreMetadataFromDb;
1938
+ /**
1939
+ * Bridge all SchemaRegistry objects to the metadata service.
1940
+ *
1941
+ * This ensures objects registered by plugins and loaded from sys_metadata
1942
+ * are visible to AI tools and other consumers that query IMetadataService.
1943
+ *
1944
+ * Runs after both restoreMetadataFromDb() and syncRegisteredSchemas() to
1945
+ * catch all objects in the SchemaRegistry regardless of their source.
1946
+ */
1947
+ private bridgeObjectsToMetadataService;
1882
1948
  /**
1883
1949
  * Load metadata from external metadata service into ObjectQL registry
1884
1950
  * This enables ObjectQL to use file-based or remote metadata