@objectstack/objectql 3.3.0 → 3.3.1

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.3.0 build /home/runner/work/spec/spec/packages/objectql
2
+ > @objectstack/objectql@3.3.1 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
- CJS dist/index.js 98.69 KB
14
- CJS dist/index.js.map 199.38 KB
15
- CJS ⚡️ Build success in 147ms
16
- ESM dist/index.mjs 96.95 KB
17
- ESM dist/index.mjs.map 198.08 KB
18
- ESM ⚡️ Build success in 148ms
13
+ ESM dist/index.mjs 98.69 KB
14
+ ESM dist/index.mjs.map 201.00 KB
15
+ ESM ⚡️ Build success in 247ms
16
+ CJS dist/index.js 100.43 KB
17
+ CJS dist/index.js.map 202.30 KB
18
+ CJS ⚡️ Build success in 256ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 25675ms
21
- DTS dist/index.d.mts 78.59 KB
22
- DTS dist/index.d.ts 78.59 KB
20
+ DTS ⚡️ Build success in 25891ms
21
+ DTS dist/index.d.mts 78.82 KB
22
+ DTS dist/index.d.ts 78.82 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @objectstack/objectql
2
2
 
3
+ ## 3.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @objectstack/spec@3.3.1
8
+ - @objectstack/core@3.3.1
9
+ - @objectstack/types@3.3.1
10
+
3
11
  ## 3.3.0
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1897,9 +1897,13 @@ declare class ObjectQLPlugin implements Plugin {
1897
1897
  /**
1898
1898
  * Synchronize all registered object schemas to the database.
1899
1899
  *
1900
- * Iterates every object in the SchemaRegistry and calls the
1901
- * responsible driver's `syncSchema()` for each one. This is
1902
- * idempotent drivers must tolerate repeated calls without
1900
+ * Groups objects by their responsible driver, then:
1901
+ * - If the driver advertises `supports.batchSchemaSync` and implements
1902
+ * `syncSchemasBatch()`, submits all schemas in a single call (reducing
1903
+ * network round-trips for remote drivers like Turso).
1904
+ * - Otherwise falls back to sequential `syncSchema()` per object.
1905
+ *
1906
+ * This is idempotent — drivers must tolerate repeated calls without
1903
1907
  * duplicating tables or erroring out.
1904
1908
  *
1905
1909
  * Drivers that do not implement `syncSchema` are silently skipped.
package/dist/index.d.ts CHANGED
@@ -1897,9 +1897,13 @@ declare class ObjectQLPlugin implements Plugin {
1897
1897
  /**
1898
1898
  * Synchronize all registered object schemas to the database.
1899
1899
  *
1900
- * Iterates every object in the SchemaRegistry and calls the
1901
- * responsible driver's `syncSchema()` for each one. This is
1902
- * idempotent drivers must tolerate repeated calls without
1900
+ * Groups objects by their responsible driver, then:
1901
+ * - If the driver advertises `supports.batchSchemaSync` and implements
1902
+ * `syncSchemasBatch()`, submits all schemas in a single call (reducing
1903
+ * network round-trips for remote drivers like Turso).
1904
+ * - Otherwise falls back to sequential `syncSchema()` per object.
1905
+ *
1906
+ * This is idempotent — drivers must tolerate repeated calls without
1903
1907
  * duplicating tables or erroring out.
1904
1908
  *
1905
1909
  * Drivers that do not implement `syncSchema` are silently skipped.
package/dist/index.js CHANGED
@@ -2770,9 +2770,13 @@ var ObjectQLPlugin = class {
2770
2770
  /**
2771
2771
  * Synchronize all registered object schemas to the database.
2772
2772
  *
2773
- * Iterates every object in the SchemaRegistry and calls the
2774
- * responsible driver's `syncSchema()` for each one. This is
2775
- * idempotent drivers must tolerate repeated calls without
2773
+ * Groups objects by their responsible driver, then:
2774
+ * - If the driver advertises `supports.batchSchemaSync` and implements
2775
+ * `syncSchemasBatch()`, submits all schemas in a single call (reducing
2776
+ * network round-trips for remote drivers like Turso).
2777
+ * - Otherwise falls back to sequential `syncSchema()` per object.
2778
+ *
2779
+ * This is idempotent — drivers must tolerate repeated calls without
2776
2780
  * duplicating tables or erroring out.
2777
2781
  *
2778
2782
  * Drivers that do not implement `syncSchema` are silently skipped.
@@ -2783,6 +2787,7 @@ var ObjectQLPlugin = class {
2783
2787
  if (allObjects.length === 0) return;
2784
2788
  let synced = 0;
2785
2789
  let skipped = 0;
2790
+ const driverGroups = /* @__PURE__ */ new Map();
2786
2791
  for (const obj of allObjects) {
2787
2792
  const driver = this.ql.getDriverForObject(obj.name);
2788
2793
  if (!driver) {
@@ -2801,16 +2806,59 @@ var ObjectQLPlugin = class {
2801
2806
  continue;
2802
2807
  }
2803
2808
  const tableName = obj.tableName || obj.name;
2804
- try {
2805
- await driver.syncSchema(tableName, obj);
2806
- synced++;
2807
- } catch (e) {
2808
- ctx.logger.warn("Failed to sync schema for object", {
2809
- object: obj.name,
2810
- tableName,
2811
- driver: driver.name,
2812
- error: e instanceof Error ? e.message : String(e)
2813
- });
2809
+ let group = driverGroups.get(driver);
2810
+ if (!group) {
2811
+ group = [];
2812
+ driverGroups.set(driver, group);
2813
+ }
2814
+ group.push({ obj, tableName });
2815
+ }
2816
+ for (const [driver, entries] of driverGroups) {
2817
+ if (driver.supports?.batchSchemaSync && typeof driver.syncSchemasBatch === "function") {
2818
+ const batchPayload = entries.map((e) => ({
2819
+ object: e.tableName,
2820
+ schema: e.obj
2821
+ }));
2822
+ try {
2823
+ await driver.syncSchemasBatch(batchPayload);
2824
+ synced += entries.length;
2825
+ ctx.logger.debug("Batch schema sync succeeded", {
2826
+ driver: driver.name,
2827
+ count: entries.length
2828
+ });
2829
+ } catch (e) {
2830
+ ctx.logger.warn("Batch schema sync failed, falling back to sequential", {
2831
+ driver: driver.name,
2832
+ error: e instanceof Error ? e.message : String(e)
2833
+ });
2834
+ for (const { obj, tableName } of entries) {
2835
+ try {
2836
+ await driver.syncSchema(tableName, obj);
2837
+ synced++;
2838
+ } catch (seqErr) {
2839
+ ctx.logger.warn("Failed to sync schema for object", {
2840
+ object: obj.name,
2841
+ tableName,
2842
+ driver: driver.name,
2843
+ error: seqErr instanceof Error ? seqErr.message : String(seqErr)
2844
+ });
2845
+ }
2846
+ }
2847
+ }
2848
+ } else {
2849
+ for (const { obj, tableName } of entries) {
2850
+ try {
2851
+ await driver.syncSchema(tableName, obj);
2852
+ synced++;
2853
+ } catch (e) {
2854
+ ctx.logger.warn("Failed to sync schema for object", {
2855
+ object: obj.name,
2856
+ tableName,
2857
+ driver: driver.name,
2858
+ error: e instanceof Error ? e.message : String(e)
2859
+ });
2860
+ }
2861
+ }
2814
2862
  }
2815
2863
  }
2816
2864
  if (synced > 0 || skipped > 0) {