@objectstack/objectql 3.2.8 → 3.2.9

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@3.2.8 build /home/runner/work/spec/spec/packages/objectql
2
+ > @objectstack/objectql@3.2.9 build /home/runner/work/spec/spec/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
- ESM dist/index.mjs 94.28 KB
14
- ESM dist/index.mjs.map 193.23 KB
15
- ESM ⚡️ Build success in 210ms
16
- CJS dist/index.js 96.02 KB
17
- CJS dist/index.js.map 194.53 KB
18
- CJS ⚡️ Build success in 213ms
13
+ ESM dist/index.mjs 96.39 KB
14
+ ESM dist/index.mjs.map 196.70 KB
15
+ ESM ⚡️ Build success in 178ms
16
+ CJS dist/index.js 98.13 KB
17
+ CJS dist/index.js.map 198.00 KB
18
+ CJS ⚡️ Build success in 189ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 24357ms
21
- DTS dist/index.d.mts 77.36 KB
22
- DTS dist/index.d.ts 77.36 KB
20
+ DTS ⚡️ Build success in 24730ms
21
+ DTS dist/index.d.mts 78.30 KB
22
+ DTS dist/index.d.ts 78.30 KB
package/CHANGELOG.md CHANGED
@@ -1,9 +1,21 @@
1
1
  # @objectstack/objectql
2
2
 
3
+ ## 3.2.9
4
+
5
+ ### Patch Changes
6
+
7
+ - c3065dd: fix turso 2
8
+ - @objectstack/spec@3.2.9
9
+ - @objectstack/core@3.2.9
10
+ - @objectstack/types@3.2.9
11
+
3
12
  ## 3.2.8
4
13
 
5
14
  ### Patch Changes
6
15
 
16
+ - Auto-sync all registered object schemas to database on startup: `ObjectQLPlugin.start()` now iterates every object in `SchemaRegistry` and calls `driver.syncSchema()` after driver connections are established. This ensures tables for plugin-registered objects (e.g. `sys_user` from plugin-auth) are created or updated automatically.
17
+ - Added `getDriverForObject(objectName)` public method to `ObjectQL` engine for resolving the responsible driver for a given object.
18
+ - Added optional `syncSchema` method to `DriverInterface` contract, aligning it with the full `IDataDriver` protocol.
7
19
  - @objectstack/spec@3.2.8
8
20
  - @objectstack/core@3.2.8
9
21
  - @objectstack/types@3.2.8
package/dist/index.d.mts CHANGED
@@ -1683,6 +1683,17 @@ declare class ObjectQL implements IDataEngine {
1683
1683
  * this method directly looks up a driver by its registered name.
1684
1684
  */
1685
1685
  getDriverByName(name: string): DriverInterface | undefined;
1686
+ /**
1687
+ * Get the driver responsible for the given object.
1688
+ *
1689
+ * Resolves datasource binding from the object's schema definition,
1690
+ * falling back to the default driver. This is a public version of
1691
+ * the internal getDriver() used by CRUD operations.
1692
+ *
1693
+ * @param objectName - FQN or short name of the registered object.
1694
+ * @returns The resolved DriverInterface, or undefined if no driver is available.
1695
+ */
1696
+ getDriverForObject(objectName: string): DriverInterface | undefined;
1686
1697
  /**
1687
1698
  * Get a registered driver by datasource name.
1688
1699
  * Alias matching @objectql/core datasource() API.
@@ -1877,6 +1888,17 @@ declare class ObjectQLPlugin implements Plugin {
1877
1888
  * for multi-tenant operations.
1878
1889
  */
1879
1890
  private registerTenantMiddleware;
1891
+ /**
1892
+ * Synchronize all registered object schemas to the database.
1893
+ *
1894
+ * Iterates every object in the SchemaRegistry and calls the
1895
+ * responsible driver's `syncSchema()` for each one. This is
1896
+ * idempotent — drivers must tolerate repeated calls without
1897
+ * duplicating tables or erroring out.
1898
+ *
1899
+ * Drivers that do not implement `syncSchema` are silently skipped.
1900
+ */
1901
+ private syncRegisteredSchemas;
1880
1902
  /**
1881
1903
  * Load metadata from external metadata service into ObjectQL registry
1882
1904
  * This enables ObjectQL to use file-based or remote metadata
package/dist/index.d.ts CHANGED
@@ -1683,6 +1683,17 @@ declare class ObjectQL implements IDataEngine {
1683
1683
  * this method directly looks up a driver by its registered name.
1684
1684
  */
1685
1685
  getDriverByName(name: string): DriverInterface | undefined;
1686
+ /**
1687
+ * Get the driver responsible for the given object.
1688
+ *
1689
+ * Resolves datasource binding from the object's schema definition,
1690
+ * falling back to the default driver. This is a public version of
1691
+ * the internal getDriver() used by CRUD operations.
1692
+ *
1693
+ * @param objectName - FQN or short name of the registered object.
1694
+ * @returns The resolved DriverInterface, or undefined if no driver is available.
1695
+ */
1696
+ getDriverForObject(objectName: string): DriverInterface | undefined;
1686
1697
  /**
1687
1698
  * Get a registered driver by datasource name.
1688
1699
  * Alias matching @objectql/core datasource() API.
@@ -1877,6 +1888,17 @@ declare class ObjectQLPlugin implements Plugin {
1877
1888
  * for multi-tenant operations.
1878
1889
  */
1879
1890
  private registerTenantMiddleware;
1891
+ /**
1892
+ * Synchronize all registered object schemas to the database.
1893
+ *
1894
+ * Iterates every object in the SchemaRegistry and calls the
1895
+ * responsible driver's `syncSchema()` for each one. This is
1896
+ * idempotent — drivers must tolerate repeated calls without
1897
+ * duplicating tables or erroring out.
1898
+ *
1899
+ * Drivers that do not implement `syncSchema` are silently skipped.
1900
+ */
1901
+ private syncRegisteredSchemas;
1880
1902
  /**
1881
1903
  * Load metadata from external metadata service into ObjectQL registry
1882
1904
  * This enables ObjectQL to use file-based or remote metadata
package/dist/index.js CHANGED
@@ -2246,6 +2246,23 @@ var _ObjectQL = class _ObjectQL {
2246
2246
  getDriverByName(name) {
2247
2247
  return this.drivers.get(name);
2248
2248
  }
2249
+ /**
2250
+ * Get the driver responsible for the given object.
2251
+ *
2252
+ * Resolves datasource binding from the object's schema definition,
2253
+ * falling back to the default driver. This is a public version of
2254
+ * the internal getDriver() used by CRUD operations.
2255
+ *
2256
+ * @param objectName - FQN or short name of the registered object.
2257
+ * @returns The resolved DriverInterface, or undefined if no driver is available.
2258
+ */
2259
+ getDriverForObject(objectName) {
2260
+ try {
2261
+ return this.getDriver(objectName);
2262
+ } catch {
2263
+ return void 0;
2264
+ }
2265
+ }
2249
2266
  /**
2250
2267
  * Get a registered driver by datasource name.
2251
2268
  * Alias matching @objectql/core datasource() API.
@@ -2643,6 +2660,7 @@ var ObjectQLPlugin = class {
2643
2660
  }
2644
2661
  }
2645
2662
  await this.ql?.init();
2663
+ await this.syncRegisteredSchemas(ctx);
2646
2664
  this.registerAuditHooks(ctx);
2647
2665
  this.registerTenantMiddleware(ctx);
2648
2666
  ctx.logger.info("ObjectQL engine started", {
@@ -2737,6 +2755,54 @@ var ObjectQLPlugin = class {
2737
2755
  });
2738
2756
  ctx.logger.debug("Tenant isolation middleware registered");
2739
2757
  }
2758
+ /**
2759
+ * Synchronize all registered object schemas to the database.
2760
+ *
2761
+ * Iterates every object in the SchemaRegistry and calls the
2762
+ * responsible driver's `syncSchema()` for each one. This is
2763
+ * idempotent — drivers must tolerate repeated calls without
2764
+ * duplicating tables or erroring out.
2765
+ *
2766
+ * Drivers that do not implement `syncSchema` are silently skipped.
2767
+ */
2768
+ async syncRegisteredSchemas(ctx) {
2769
+ if (!this.ql) return;
2770
+ const allObjects = this.ql.registry?.getAllObjects?.() ?? [];
2771
+ if (allObjects.length === 0) return;
2772
+ let synced = 0;
2773
+ let skipped = 0;
2774
+ for (const obj of allObjects) {
2775
+ const driver = this.ql.getDriverForObject(obj.name);
2776
+ if (!driver) {
2777
+ ctx.logger.debug("No driver available for object, skipping schema sync", {
2778
+ object: obj.name
2779
+ });
2780
+ skipped++;
2781
+ continue;
2782
+ }
2783
+ if (typeof driver.syncSchema !== "function") {
2784
+ ctx.logger.debug("Driver does not support syncSchema, skipping", {
2785
+ object: obj.name,
2786
+ driver: driver.name
2787
+ });
2788
+ skipped++;
2789
+ continue;
2790
+ }
2791
+ try {
2792
+ await driver.syncSchema(obj.name, obj);
2793
+ synced++;
2794
+ } catch (e) {
2795
+ ctx.logger.warn("Failed to sync schema for object", {
2796
+ object: obj.name,
2797
+ driver: driver.name,
2798
+ error: e instanceof Error ? e.message : String(e)
2799
+ });
2800
+ }
2801
+ }
2802
+ if (synced > 0 || skipped > 0) {
2803
+ ctx.logger.info("Schema sync complete", { synced, skipped, total: allObjects.length });
2804
+ }
2805
+ }
2740
2806
  /**
2741
2807
  * Load metadata from external metadata service into ObjectQL registry
2742
2808
  * This enables ObjectQL to use file-based or remote metadata