@objectstack/objectql 3.2.9 → 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.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +77 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/engine.test.ts +5 -5
- package/src/engine.ts +7 -4
- package/src/plugin.integration.test.ts +291 -0
- package/src/plugin.ts +73 -12
- package/src/registry.test.ts +25 -0
- package/src/registry.ts +17 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/objectql@3.
|
|
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
|
[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[32m98.69 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m201.00 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 247ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.js [22m[32m100.43 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m202.30 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 256ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m78.
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m78.
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 25891ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m78.82 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m78.82 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
11
|
+
## 3.3.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @objectstack/spec@3.3.0
|
|
16
|
+
- @objectstack/core@3.3.0
|
|
17
|
+
- @objectstack/types@3.3.0
|
|
18
|
+
|
|
3
19
|
## 3.2.9
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -167,8 +167,14 @@ declare class SchemaRegistry {
|
|
|
167
167
|
*/
|
|
168
168
|
static resolveObject(fqn: string): ServiceObject | undefined;
|
|
169
169
|
/**
|
|
170
|
-
* Get object by name (FQN
|
|
171
|
-
*
|
|
170
|
+
* Get object by name (FQN, short name, or physical table name).
|
|
171
|
+
*
|
|
172
|
+
* Resolution order:
|
|
173
|
+
* 1. Exact FQN match (e.g., 'crm__account')
|
|
174
|
+
* 2. Short name fallback (e.g., 'account' → 'crm__account')
|
|
175
|
+
* 3. Physical table name match (e.g., 'sys_user' → 'sys__user')
|
|
176
|
+
* ObjectSchema.create() auto-derives tableName as {namespace}_{name},
|
|
177
|
+
* which uses a single underscore — different from the FQN double underscore.
|
|
172
178
|
*/
|
|
173
179
|
static getObject(name: string): ServiceObject | undefined;
|
|
174
180
|
/**
|
|
@@ -1891,9 +1897,13 @@ declare class ObjectQLPlugin implements Plugin {
|
|
|
1891
1897
|
/**
|
|
1892
1898
|
* Synchronize all registered object schemas to the database.
|
|
1893
1899
|
*
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
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
|
|
1897
1907
|
* duplicating tables or erroring out.
|
|
1898
1908
|
*
|
|
1899
1909
|
* Drivers that do not implement `syncSchema` are silently skipped.
|
package/dist/index.d.ts
CHANGED
|
@@ -167,8 +167,14 @@ declare class SchemaRegistry {
|
|
|
167
167
|
*/
|
|
168
168
|
static resolveObject(fqn: string): ServiceObject | undefined;
|
|
169
169
|
/**
|
|
170
|
-
* Get object by name (FQN
|
|
171
|
-
*
|
|
170
|
+
* Get object by name (FQN, short name, or physical table name).
|
|
171
|
+
*
|
|
172
|
+
* Resolution order:
|
|
173
|
+
* 1. Exact FQN match (e.g., 'crm__account')
|
|
174
|
+
* 2. Short name fallback (e.g., 'account' → 'crm__account')
|
|
175
|
+
* 3. Physical table name match (e.g., 'sys_user' → 'sys__user')
|
|
176
|
+
* ObjectSchema.create() auto-derives tableName as {namespace}_{name},
|
|
177
|
+
* which uses a single underscore — different from the FQN double underscore.
|
|
172
178
|
*/
|
|
173
179
|
static getObject(name: string): ServiceObject | undefined;
|
|
174
180
|
/**
|
|
@@ -1891,9 +1897,13 @@ declare class ObjectQLPlugin implements Plugin {
|
|
|
1891
1897
|
/**
|
|
1892
1898
|
* Synchronize all registered object schemas to the database.
|
|
1893
1899
|
*
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
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
|
|
1897
1907
|
* duplicating tables or erroring out.
|
|
1898
1908
|
*
|
|
1899
1909
|
* Drivers that do not implement `syncSchema` are silently skipped.
|
package/dist/index.js
CHANGED
|
@@ -207,8 +207,14 @@ var SchemaRegistry = class {
|
|
|
207
207
|
return merged;
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
|
-
* Get object by name (FQN
|
|
211
|
-
*
|
|
210
|
+
* Get object by name (FQN, short name, or physical table name).
|
|
211
|
+
*
|
|
212
|
+
* Resolution order:
|
|
213
|
+
* 1. Exact FQN match (e.g., 'crm__account')
|
|
214
|
+
* 2. Short name fallback (e.g., 'account' → 'crm__account')
|
|
215
|
+
* 3. Physical table name match (e.g., 'sys_user' → 'sys__user')
|
|
216
|
+
* ObjectSchema.create() auto-derives tableName as {namespace}_{name},
|
|
217
|
+
* which uses a single underscore — different from the FQN double underscore.
|
|
212
218
|
*/
|
|
213
219
|
static getObject(name) {
|
|
214
220
|
const direct = this.resolveObject(name);
|
|
@@ -219,6 +225,12 @@ var SchemaRegistry = class {
|
|
|
219
225
|
return this.resolveObject(fqn);
|
|
220
226
|
}
|
|
221
227
|
}
|
|
228
|
+
for (const fqn of this.objectContributors.keys()) {
|
|
229
|
+
const resolved = this.resolveObject(fqn);
|
|
230
|
+
if (resolved?.tableName === name) {
|
|
231
|
+
return resolved;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
222
234
|
return void 0;
|
|
223
235
|
}
|
|
224
236
|
/**
|
|
@@ -1760,7 +1772,7 @@ var _ObjectQL = class _ObjectQL {
|
|
|
1760
1772
|
resolveObjectName(name) {
|
|
1761
1773
|
const schema = SchemaRegistry.getObject(name);
|
|
1762
1774
|
if (schema) {
|
|
1763
|
-
return schema.name;
|
|
1775
|
+
return schema.tableName || schema.name;
|
|
1764
1776
|
}
|
|
1765
1777
|
return name;
|
|
1766
1778
|
}
|
|
@@ -2758,9 +2770,13 @@ var ObjectQLPlugin = class {
|
|
|
2758
2770
|
/**
|
|
2759
2771
|
* Synchronize all registered object schemas to the database.
|
|
2760
2772
|
*
|
|
2761
|
-
*
|
|
2762
|
-
*
|
|
2763
|
-
*
|
|
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
|
|
2764
2780
|
* duplicating tables or erroring out.
|
|
2765
2781
|
*
|
|
2766
2782
|
* Drivers that do not implement `syncSchema` are silently skipped.
|
|
@@ -2771,6 +2787,7 @@ var ObjectQLPlugin = class {
|
|
|
2771
2787
|
if (allObjects.length === 0) return;
|
|
2772
2788
|
let synced = 0;
|
|
2773
2789
|
let skipped = 0;
|
|
2790
|
+
const driverGroups = /* @__PURE__ */ new Map();
|
|
2774
2791
|
for (const obj of allObjects) {
|
|
2775
2792
|
const driver = this.ql.getDriverForObject(obj.name);
|
|
2776
2793
|
if (!driver) {
|
|
@@ -2788,15 +2805,60 @@ var ObjectQLPlugin = class {
|
|
|
2788
2805
|
skipped++;
|
|
2789
2806
|
continue;
|
|
2790
2807
|
}
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2808
|
+
const tableName = obj.tableName || obj.name;
|
|
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
|
+
}
|
|
2800
2862
|
}
|
|
2801
2863
|
}
|
|
2802
2864
|
if (synced > 0 || skipped > 0) {
|