@zenstackhq/orm 3.9.4-beta.1 → 3.9.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/dist/index.cjs +50 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -15
- package/dist/index.d.mts +49 -15
- package/dist/index.mjs +50 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.d.cts
CHANGED
|
@@ -733,7 +733,35 @@ type ComputedFieldContext<Schema extends SchemaDef> = {
|
|
|
733
733
|
*/
|
|
734
734
|
client: ClientContract<Schema>;
|
|
735
735
|
};
|
|
736
|
-
|
|
736
|
+
/**
|
|
737
|
+
* The computed fields a model declares itself, keyed by name. A computed field inherited from a
|
|
738
|
+
* delegate base is excluded: it's configured once, on the base model.
|
|
739
|
+
*/
|
|
740
|
+
type OwnComputedFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof { [Field in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Field> extends {
|
|
741
|
+
computed: true;
|
|
742
|
+
} ? GetModelField<Schema, Model, Field> extends {
|
|
743
|
+
originModel: string;
|
|
744
|
+
} ? never : Field : never]: Field };
|
|
745
|
+
/**
|
|
746
|
+
* Implementations of the schema's computed fields, keyed by (uncapitalized) model name and then
|
|
747
|
+
* by field name. Everything is derived from the field definitions: which fields need an
|
|
748
|
+
* implementation, the query-time `args` of a parameterized field (from its `params` metadata,
|
|
749
|
+
* the same source the query input types use), and the value type the expression must produce.
|
|
750
|
+
*/
|
|
751
|
+
type ComputedFieldsOptions<Schema extends SchemaDef> = { [Model in GetModels<Schema> as [OwnComputedFields<Schema, Model>] extends [never] ? never : Uncapitalize<Model>]: { [Field in OwnComputedFields<Schema, Model>]: (p: ExpressionBuilder<ToKyselySchema<Schema>, Model>, context: ComputedFieldContext<Schema>, ...args: ComputedFieldImplArgs<Schema, Model, Field>) => OperandExpression<ComputedFieldResultType<Schema, Model, Field>> } };
|
|
752
|
+
/**
|
|
753
|
+
* The trailing parameter list of a computed field implementation: `[args]` for a parameterized
|
|
754
|
+
* field, empty otherwise.
|
|
755
|
+
*/
|
|
756
|
+
type ComputedFieldImplArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = FieldHasComputedArgs<Schema, Model, Field> extends true ? [args: ComputedFieldArgs<Schema, Model, Field>] : [];
|
|
757
|
+
/**
|
|
758
|
+
* The value type a computed field's expression must produce, from the field's declared type.
|
|
759
|
+
* Scalars map to their JS types (`Decimal` is accepted as `number`); `DateTime`, `Json`,
|
|
760
|
+
* `Bytes`, enums and type defs are `unknown`, since their database-level representation differs
|
|
761
|
+
* from the ORM result type. An optional field also accepts `null`, a list field an array.
|
|
762
|
+
*/
|
|
763
|
+
type ComputedFieldResultType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = WrapType<ComputedFieldBaseType<GetModelFieldType<Schema, Model, Field>>, ModelFieldIsOptional<Schema, Model, Field>, FieldIsArray<Schema, Model, Field>>;
|
|
764
|
+
type ComputedFieldBaseType<T> = T extends 'String' ? string : T extends 'Boolean' ? boolean : T extends 'Int' | 'Float' | 'Decimal' ? number : T extends 'BigInt' ? bigint : unknown;
|
|
737
765
|
type HasComputedFields<Schema extends SchemaDef> = string extends GetModels<Schema> ? false : keyof ComputedFieldsOptions<Schema> extends never ? false : true;
|
|
738
766
|
type ProceduresOptions<Schema extends SchemaDef> = Schema extends {
|
|
739
767
|
procedures: Record<string, ProcedureDef>;
|
|
@@ -1652,12 +1680,18 @@ type FtsRelevanceOrderBy<Schema extends SchemaDef, Model extends GetModels<Schem
|
|
|
1652
1680
|
};
|
|
1653
1681
|
};
|
|
1654
1682
|
/**
|
|
1655
|
-
* The query-time arguments object of a parameterized computed field, derived from the
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
*
|
|
1683
|
+
* The query-time arguments object of a parameterized computed field, derived from the field's
|
|
1684
|
+
* `params` metadata in the schema — the same source the runtime forwards to the implementation
|
|
1685
|
+
* and the zod factory validates against, so typing and validation can never drift apart. Param
|
|
1686
|
+
* types resolve the way procedure params do: scalars to their TS types, enums to their value
|
|
1687
|
+
* union, type defs to their object shape. `ComputedFieldsOptions` reads this too, so the
|
|
1688
|
+
* implementation signature always matches the query input. Resolves to `never` for
|
|
1689
|
+
* non-parameterized fields.
|
|
1659
1690
|
*/
|
|
1660
|
-
type ComputedFieldArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> =
|
|
1691
|
+
type ComputedFieldArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field> extends {
|
|
1692
|
+
computed: true;
|
|
1693
|
+
params: infer Params;
|
|
1694
|
+
} ? MapParamsObject<Schema, Params> : never;
|
|
1661
1695
|
/**
|
|
1662
1696
|
* Whether `Field` is a parameterized computed field (its args object is not `never`).
|
|
1663
1697
|
*/
|
|
@@ -2364,20 +2398,20 @@ type GetProcedureParams<Schema extends SchemaDef, ProcName extends GetProcedureN
|
|
|
2364
2398
|
type GetProcedure<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
2365
2399
|
procedures: Record<string, ProcedureDef>;
|
|
2366
2400
|
} ? Schema['procedures'][ProcName] : never;
|
|
2367
|
-
type
|
|
2401
|
+
type _OptionalParamNames<Params> = keyof { [K in keyof Params as Params[K] extends {
|
|
2368
2402
|
optional: true;
|
|
2369
2403
|
} ? K : never]: K };
|
|
2370
|
-
type
|
|
2404
|
+
type _RequiredParamNames<Params> = keyof { [K in keyof Params as Params[K] extends {
|
|
2371
2405
|
optional: true;
|
|
2372
2406
|
} ? never : K]: K };
|
|
2373
|
-
type
|
|
2374
|
-
type
|
|
2407
|
+
type _HasRequiredParams<Params> = _RequiredParamNames<Params> extends never ? false : true;
|
|
2408
|
+
type MapParamsObject<Schema extends SchemaDef, Params> = Simplify<Optional<{ [K in keyof Params]: MapParam<Schema, Params[K]> }, _OptionalParamNames<Params>>>;
|
|
2375
2409
|
type ProcedureEnvelope<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>, Params = GetProcedureParams<Schema, ProcName>> = keyof Params extends never ? {
|
|
2376
2410
|
args?: Record<string, never>;
|
|
2377
|
-
} :
|
|
2378
|
-
args:
|
|
2411
|
+
} : _HasRequiredParams<Params> extends true ? {
|
|
2412
|
+
args: MapParamsObject<Schema, Params>;
|
|
2379
2413
|
} : {
|
|
2380
|
-
args?:
|
|
2414
|
+
args?: MapParamsObject<Schema, Params>;
|
|
2381
2415
|
};
|
|
2382
2416
|
type ProcedureHandlerCtx<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = {
|
|
2383
2417
|
client: ClientContract<Schema>;
|
|
@@ -2385,7 +2419,7 @@ type ProcedureHandlerCtx<Schema extends SchemaDef, ProcName extends GetProcedure
|
|
|
2385
2419
|
/**
|
|
2386
2420
|
* Shape of a procedure's runtime function.
|
|
2387
2421
|
*/
|
|
2388
|
-
type ProcedureFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (...args:
|
|
2422
|
+
type ProcedureFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (...args: _HasRequiredParams<GetProcedureParams<Schema, ProcName>> extends true ? [input: ProcedureEnvelope<Schema, ProcName>] : [input?: ProcedureEnvelope<Schema, ProcName>]) => MaybePromise<MapProcedureReturn<Schema, GetProcedure<Schema, ProcName>>>;
|
|
2389
2423
|
/**
|
|
2390
2424
|
* Signature for procedure handlers configured via client options.
|
|
2391
2425
|
*/
|
|
@@ -2395,7 +2429,7 @@ type MapProcedureReturn<Schema extends SchemaDef, Proc> = Proc extends {
|
|
|
2395
2429
|
} ? Proc extends {
|
|
2396
2430
|
returnArray: true;
|
|
2397
2431
|
} ? Array<MapType<Schema, R & string>> : MapType<Schema, R & string> : never;
|
|
2398
|
-
type
|
|
2432
|
+
type MapParam<Schema extends SchemaDef, P> = P extends {
|
|
2399
2433
|
type: infer U;
|
|
2400
2434
|
} ? OrUndefinedIf<P extends {
|
|
2401
2435
|
array: true;
|
package/dist/index.d.mts
CHANGED
|
@@ -733,7 +733,35 @@ type ComputedFieldContext<Schema extends SchemaDef> = {
|
|
|
733
733
|
*/
|
|
734
734
|
client: ClientContract<Schema>;
|
|
735
735
|
};
|
|
736
|
-
|
|
736
|
+
/**
|
|
737
|
+
* The computed fields a model declares itself, keyed by name. A computed field inherited from a
|
|
738
|
+
* delegate base is excluded: it's configured once, on the base model.
|
|
739
|
+
*/
|
|
740
|
+
type OwnComputedFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof { [Field in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Field> extends {
|
|
741
|
+
computed: true;
|
|
742
|
+
} ? GetModelField<Schema, Model, Field> extends {
|
|
743
|
+
originModel: string;
|
|
744
|
+
} ? never : Field : never]: Field };
|
|
745
|
+
/**
|
|
746
|
+
* Implementations of the schema's computed fields, keyed by (uncapitalized) model name and then
|
|
747
|
+
* by field name. Everything is derived from the field definitions: which fields need an
|
|
748
|
+
* implementation, the query-time `args` of a parameterized field (from its `params` metadata,
|
|
749
|
+
* the same source the query input types use), and the value type the expression must produce.
|
|
750
|
+
*/
|
|
751
|
+
type ComputedFieldsOptions<Schema extends SchemaDef> = { [Model in GetModels<Schema> as [OwnComputedFields<Schema, Model>] extends [never] ? never : Uncapitalize<Model>]: { [Field in OwnComputedFields<Schema, Model>]: (p: ExpressionBuilder<ToKyselySchema<Schema>, Model>, context: ComputedFieldContext<Schema>, ...args: ComputedFieldImplArgs<Schema, Model, Field>) => OperandExpression<ComputedFieldResultType<Schema, Model, Field>> } };
|
|
752
|
+
/**
|
|
753
|
+
* The trailing parameter list of a computed field implementation: `[args]` for a parameterized
|
|
754
|
+
* field, empty otherwise.
|
|
755
|
+
*/
|
|
756
|
+
type ComputedFieldImplArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = FieldHasComputedArgs<Schema, Model, Field> extends true ? [args: ComputedFieldArgs<Schema, Model, Field>] : [];
|
|
757
|
+
/**
|
|
758
|
+
* The value type a computed field's expression must produce, from the field's declared type.
|
|
759
|
+
* Scalars map to their JS types (`Decimal` is accepted as `number`); `DateTime`, `Json`,
|
|
760
|
+
* `Bytes`, enums and type defs are `unknown`, since their database-level representation differs
|
|
761
|
+
* from the ORM result type. An optional field also accepts `null`, a list field an array.
|
|
762
|
+
*/
|
|
763
|
+
type ComputedFieldResultType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = WrapType<ComputedFieldBaseType<GetModelFieldType<Schema, Model, Field>>, ModelFieldIsOptional<Schema, Model, Field>, FieldIsArray<Schema, Model, Field>>;
|
|
764
|
+
type ComputedFieldBaseType<T> = T extends 'String' ? string : T extends 'Boolean' ? boolean : T extends 'Int' | 'Float' | 'Decimal' ? number : T extends 'BigInt' ? bigint : unknown;
|
|
737
765
|
type HasComputedFields<Schema extends SchemaDef> = string extends GetModels<Schema> ? false : keyof ComputedFieldsOptions<Schema> extends never ? false : true;
|
|
738
766
|
type ProceduresOptions<Schema extends SchemaDef> = Schema extends {
|
|
739
767
|
procedures: Record<string, ProcedureDef>;
|
|
@@ -1652,12 +1680,18 @@ type FtsRelevanceOrderBy<Schema extends SchemaDef, Model extends GetModels<Schem
|
|
|
1652
1680
|
};
|
|
1653
1681
|
};
|
|
1654
1682
|
/**
|
|
1655
|
-
* The query-time arguments object of a parameterized computed field, derived from the
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
*
|
|
1683
|
+
* The query-time arguments object of a parameterized computed field, derived from the field's
|
|
1684
|
+
* `params` metadata in the schema — the same source the runtime forwards to the implementation
|
|
1685
|
+
* and the zod factory validates against, so typing and validation can never drift apart. Param
|
|
1686
|
+
* types resolve the way procedure params do: scalars to their TS types, enums to their value
|
|
1687
|
+
* union, type defs to their object shape. `ComputedFieldsOptions` reads this too, so the
|
|
1688
|
+
* implementation signature always matches the query input. Resolves to `never` for
|
|
1689
|
+
* non-parameterized fields.
|
|
1659
1690
|
*/
|
|
1660
|
-
type ComputedFieldArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> =
|
|
1691
|
+
type ComputedFieldArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field> extends {
|
|
1692
|
+
computed: true;
|
|
1693
|
+
params: infer Params;
|
|
1694
|
+
} ? MapParamsObject<Schema, Params> : never;
|
|
1661
1695
|
/**
|
|
1662
1696
|
* Whether `Field` is a parameterized computed field (its args object is not `never`).
|
|
1663
1697
|
*/
|
|
@@ -2364,20 +2398,20 @@ type GetProcedureParams<Schema extends SchemaDef, ProcName extends GetProcedureN
|
|
|
2364
2398
|
type GetProcedure<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
2365
2399
|
procedures: Record<string, ProcedureDef>;
|
|
2366
2400
|
} ? Schema['procedures'][ProcName] : never;
|
|
2367
|
-
type
|
|
2401
|
+
type _OptionalParamNames<Params> = keyof { [K in keyof Params as Params[K] extends {
|
|
2368
2402
|
optional: true;
|
|
2369
2403
|
} ? K : never]: K };
|
|
2370
|
-
type
|
|
2404
|
+
type _RequiredParamNames<Params> = keyof { [K in keyof Params as Params[K] extends {
|
|
2371
2405
|
optional: true;
|
|
2372
2406
|
} ? never : K]: K };
|
|
2373
|
-
type
|
|
2374
|
-
type
|
|
2407
|
+
type _HasRequiredParams<Params> = _RequiredParamNames<Params> extends never ? false : true;
|
|
2408
|
+
type MapParamsObject<Schema extends SchemaDef, Params> = Simplify<Optional<{ [K in keyof Params]: MapParam<Schema, Params[K]> }, _OptionalParamNames<Params>>>;
|
|
2375
2409
|
type ProcedureEnvelope<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>, Params = GetProcedureParams<Schema, ProcName>> = keyof Params extends never ? {
|
|
2376
2410
|
args?: Record<string, never>;
|
|
2377
|
-
} :
|
|
2378
|
-
args:
|
|
2411
|
+
} : _HasRequiredParams<Params> extends true ? {
|
|
2412
|
+
args: MapParamsObject<Schema, Params>;
|
|
2379
2413
|
} : {
|
|
2380
|
-
args?:
|
|
2414
|
+
args?: MapParamsObject<Schema, Params>;
|
|
2381
2415
|
};
|
|
2382
2416
|
type ProcedureHandlerCtx<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = {
|
|
2383
2417
|
client: ClientContract<Schema>;
|
|
@@ -2385,7 +2419,7 @@ type ProcedureHandlerCtx<Schema extends SchemaDef, ProcName extends GetProcedure
|
|
|
2385
2419
|
/**
|
|
2386
2420
|
* Shape of a procedure's runtime function.
|
|
2387
2421
|
*/
|
|
2388
|
-
type ProcedureFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (...args:
|
|
2422
|
+
type ProcedureFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (...args: _HasRequiredParams<GetProcedureParams<Schema, ProcName>> extends true ? [input: ProcedureEnvelope<Schema, ProcName>] : [input?: ProcedureEnvelope<Schema, ProcName>]) => MaybePromise<MapProcedureReturn<Schema, GetProcedure<Schema, ProcName>>>;
|
|
2389
2423
|
/**
|
|
2390
2424
|
* Signature for procedure handlers configured via client options.
|
|
2391
2425
|
*/
|
|
@@ -2395,7 +2429,7 @@ type MapProcedureReturn<Schema extends SchemaDef, Proc> = Proc extends {
|
|
|
2395
2429
|
} ? Proc extends {
|
|
2396
2430
|
returnArray: true;
|
|
2397
2431
|
} ? Array<MapType<Schema, R & string>> : MapType<Schema, R & string> : never;
|
|
2398
|
-
type
|
|
2432
|
+
type MapParam<Schema extends SchemaDef, P> = P extends {
|
|
2399
2433
|
type: infer U;
|
|
2400
2434
|
} ? OrUndefinedIf<P extends {
|
|
2401
2435
|
array: true;
|
package/dist/index.mjs
CHANGED
|
@@ -1394,7 +1394,7 @@ var BaseCrudDialect = class {
|
|
|
1394
1394
|
}
|
|
1395
1395
|
}
|
|
1396
1396
|
canJoinWithoutNestedSelect(modelDef, payload) {
|
|
1397
|
-
if (modelDef.
|
|
1397
|
+
if (Object.values(modelDef.fields).some((f) => f.computed)) return false;
|
|
1398
1398
|
if (modelDef.baseModel || modelDef.isDelegate) return false;
|
|
1399
1399
|
if (typeof payload === "object" && (payload.orderBy || payload.skip !== void 0 || payload.take !== void 0 || payload.cursor || payload.distinct)) return false;
|
|
1400
1400
|
return true;
|
|
@@ -5820,6 +5820,31 @@ var UpdateOperationHandler = class extends BaseOperationHandler {
|
|
|
5820
5820
|
}
|
|
5821
5821
|
};
|
|
5822
5822
|
//#endregion
|
|
5823
|
+
//#region src/client/executor/connection-mutex.ts
|
|
5824
|
+
/**
|
|
5825
|
+
* This mutex is used to ensure that only one operation at a time can
|
|
5826
|
+
* acquire a connection from the driver. This is necessary when the
|
|
5827
|
+
* driver only has a single connection, like SQLite and PGlite.
|
|
5828
|
+
*
|
|
5829
|
+
* @see {@link https://github.com/kysely-org/kysely/blob/478ec67b2de2568f5590a015d3e120644e81bd87/src/driver/connection-mutex.ts|Kysely Source}
|
|
5830
|
+
*/
|
|
5831
|
+
var ConnectionMutex = class {
|
|
5832
|
+
#promise;
|
|
5833
|
+
#resolve;
|
|
5834
|
+
async obtainLock() {
|
|
5835
|
+
while (this.#promise) await this.#promise;
|
|
5836
|
+
this.#promise = new Promise((resolve) => {
|
|
5837
|
+
this.#resolve = resolve;
|
|
5838
|
+
});
|
|
5839
|
+
}
|
|
5840
|
+
releaseLock() {
|
|
5841
|
+
const resolve = this.#resolve;
|
|
5842
|
+
this.#promise = void 0;
|
|
5843
|
+
this.#resolve = void 0;
|
|
5844
|
+
resolve?.();
|
|
5845
|
+
}
|
|
5846
|
+
};
|
|
5847
|
+
//#endregion
|
|
5823
5848
|
//#region src/client/executor/zenstack-driver.ts
|
|
5824
5849
|
/**
|
|
5825
5850
|
* Copied from kysely's RuntimeDriver
|
|
@@ -5827,15 +5852,17 @@ var UpdateOperationHandler = class extends BaseOperationHandler {
|
|
|
5827
5852
|
var ZenStackDriver = class {
|
|
5828
5853
|
#driver;
|
|
5829
5854
|
#log;
|
|
5855
|
+
#connectionMutex;
|
|
5830
5856
|
#initPromise;
|
|
5831
5857
|
#initDone;
|
|
5832
5858
|
#destroyPromise;
|
|
5833
5859
|
#connections = /* @__PURE__ */ new WeakSet();
|
|
5834
5860
|
#txConnections = /* @__PURE__ */ new WeakMap();
|
|
5835
|
-
constructor(driver, log) {
|
|
5861
|
+
constructor(driver, log, adapter) {
|
|
5836
5862
|
this.#initDone = false;
|
|
5837
5863
|
this.#driver = driver;
|
|
5838
5864
|
this.#log = log;
|
|
5865
|
+
if (!adapter.supportsMultipleConnections) this.#connectionMutex = new ConnectionMutex();
|
|
5839
5866
|
}
|
|
5840
5867
|
async init() {
|
|
5841
5868
|
if (this.#destroyPromise) throw new Error("driver has already been destroyed");
|
|
@@ -5850,15 +5877,25 @@ var ZenStackDriver = class {
|
|
|
5850
5877
|
async acquireConnection() {
|
|
5851
5878
|
if (this.#destroyPromise) throw new Error("driver has already been destroyed");
|
|
5852
5879
|
if (!this.#initDone) await this.init();
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
this.#connections.
|
|
5880
|
+
await this.#connectionMutex?.obtainLock();
|
|
5881
|
+
try {
|
|
5882
|
+
const connection = await this.#driver.acquireConnection();
|
|
5883
|
+
if (!this.#connections.has(connection)) {
|
|
5884
|
+
if (this.#needsLogging()) this.#addLogging(connection);
|
|
5885
|
+
this.#connections.add(connection);
|
|
5886
|
+
}
|
|
5887
|
+
return connection;
|
|
5888
|
+
} catch (error) {
|
|
5889
|
+
this.#connectionMutex?.releaseLock();
|
|
5890
|
+
throw error;
|
|
5857
5891
|
}
|
|
5858
|
-
return connection;
|
|
5859
5892
|
}
|
|
5860
5893
|
async releaseConnection(connection) {
|
|
5861
|
-
|
|
5894
|
+
try {
|
|
5895
|
+
await this.#driver.releaseConnection(connection);
|
|
5896
|
+
} finally {
|
|
5897
|
+
this.#connectionMutex?.releaseLock();
|
|
5898
|
+
}
|
|
5862
5899
|
}
|
|
5863
5900
|
async beginTransaction(connection, settings) {
|
|
5864
5901
|
const result = await this.#driver.beginTransaction(connection, settings);
|
|
@@ -6399,8 +6436,7 @@ var QueryNameMapper = class extends OperationNodeTransformer {
|
|
|
6399
6436
|
}
|
|
6400
6437
|
processEnumSelection(selection, fieldName) {
|
|
6401
6438
|
const { alias, node } = stripAlias(selection);
|
|
6402
|
-
const
|
|
6403
|
-
const fieldScope = this.resolveFieldFromScopes(fieldName, qualifier);
|
|
6439
|
+
const fieldScope = this.resolveFieldFromScopes(fieldName, ReferenceNode.is(node) ? node.table?.table?.identifier.name : void 0);
|
|
6404
6440
|
if (!fieldScope || !fieldScope.model) return selection;
|
|
6405
6441
|
const aliasName = alias && IdentifierNode.is(alias) ? alias.name : fieldName;
|
|
6406
6442
|
const fieldDef = getField(this.schema, fieldScope.model, fieldName);
|
|
@@ -7320,9 +7356,9 @@ var ClientImpl = class ClientImpl {
|
|
|
7320
7356
|
this.auth = baseClient.auth;
|
|
7321
7357
|
this.slowQueries = baseClient.slowQueries;
|
|
7322
7358
|
} else {
|
|
7323
|
-
const driver = new ZenStackDriver(options.dialect.createDriver(), new Log(this.$options.log ?? []));
|
|
7324
|
-
const compiler = options.dialect.createQueryCompiler();
|
|
7325
7359
|
const adapter = options.dialect.createAdapter();
|
|
7360
|
+
const driver = new ZenStackDriver(options.dialect.createDriver(), new Log(this.$options.log ?? []), adapter);
|
|
7361
|
+
const compiler = options.dialect.createQueryCompiler();
|
|
7326
7362
|
const connectionProvider = new DefaultConnectionProvider(driver);
|
|
7327
7363
|
this.kyselyProps = {
|
|
7328
7364
|
config: {
|
|
@@ -7358,7 +7394,8 @@ var ClientImpl = class ClientImpl {
|
|
|
7358
7394
|
*/
|
|
7359
7395
|
validateComputedFieldsConfig(options) {
|
|
7360
7396
|
const computedFieldsConfig = "computedFields" in options ? options.computedFields : void 0;
|
|
7361
|
-
for (const [modelName, modelDef] of Object.entries(this.$schema.models))
|
|
7397
|
+
for (const [modelName, modelDef] of Object.entries(this.$schema.models)) for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) {
|
|
7398
|
+
if (!fieldDef.computed || fieldDef.originModel) continue;
|
|
7362
7399
|
const fieldConfig = (computedFieldsConfig?.[lowerCaseFirst(modelName)] ?? computedFieldsConfig?.[modelName])?.[fieldName];
|
|
7363
7400
|
if (fieldConfig === null || fieldConfig === void 0) throw createConfigError(`Computed field "${fieldName}" in model "${modelName}" does not have a configuration. Please provide an implementation in the computedFields option.`);
|
|
7364
7401
|
if (typeof fieldConfig !== "function") throw createConfigError(`Computed field "${fieldName}" in model "${modelName}" has an invalid configuration: expected a function but received ${typeof fieldConfig}.`);
|