@zenstackhq/runtime 3.0.0-alpha.15 → 3.0.0-alpha.17
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/{contract-BYc34jr_.d.cts → contract-C6xcEG6Q.d.cts} +4 -5
- package/dist/{contract-BYc34jr_.d.ts → contract-C6xcEG6Q.d.ts} +4 -5
- package/dist/index.cjs +5 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -17
- package/dist/index.js.map +1 -1
- package/dist/plugins/policy/index.d.cts +1 -1
- package/dist/plugins/policy/index.d.ts +1 -1
- package/package.json +9 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Decimal, { Decimal as Decimal$1 } from 'decimal.js';
|
|
2
|
-
import { SchemaDef, GetModels, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, NonRelationFields, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, GetEnums, GetEnum, BuiltinType, GetModel, FieldDef, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, IsDelegateModel, GetModelDiscriminator, GetSubModels, FieldIsRelationArray, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, DataSourceProviderType,
|
|
3
|
-
import { Generated, Kysely, ExpressionBuilder, OperandExpression, SqlBool, SelectQueryBuilder, Expression, ExpressionWrapper, RootOperationNode, QueryResult, UnknownRow, OperationNode,
|
|
2
|
+
import { SchemaDef, GetModels, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, NonRelationFields, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, GetEnums, GetEnum, BuiltinType, GetModel, FieldDef, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, IsDelegateModel, GetModelDiscriminator, GetSubModels, FieldIsRelationArray, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, DataSourceProviderType, ProcedureDef } from '@zenstackhq/sdk/schema';
|
|
3
|
+
import { Generated, Kysely, ExpressionBuilder, OperandExpression, SqlBool, SelectQueryBuilder, Expression, ExpressionWrapper, RootOperationNode, QueryResult, UnknownRow, OperationNode, Dialect, KyselyConfig } from 'kysely';
|
|
4
4
|
|
|
5
5
|
type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
6
6
|
type NullableIf<T, Condition extends boolean> = Condition extends true ? T | null : T;
|
|
@@ -705,7 +705,6 @@ type OnQueryHookContext<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
705
705
|
*/
|
|
706
706
|
declare function definePlugin<Schema extends SchemaDef>(plugin: RuntimePlugin<Schema>): RuntimePlugin<Schema>;
|
|
707
707
|
|
|
708
|
-
type DialectConfig<Provider extends DataSourceProvider> = Provider['type'] extends 'sqlite' ? Optional<SqliteDialectConfig, 'database'> : Provider['type'] extends 'postgresql' ? Optional<PostgresDialectConfig, 'pool'> : never;
|
|
709
708
|
type ZModelFunctionContext<Schema extends SchemaDef> = {
|
|
710
709
|
dialect: BaseCrudDialect<Schema>;
|
|
711
710
|
model: GetModels<Schema>;
|
|
@@ -717,9 +716,9 @@ type ZModelFunction<Schema extends SchemaDef> = (eb: ExpressionBuilder<ToKyselyS
|
|
|
717
716
|
*/
|
|
718
717
|
type ClientOptions<Schema extends SchemaDef> = {
|
|
719
718
|
/**
|
|
720
|
-
*
|
|
719
|
+
* Kysely dialect.
|
|
721
720
|
*/
|
|
722
|
-
|
|
721
|
+
dialect: Dialect;
|
|
723
722
|
/**
|
|
724
723
|
* Custom function definitions.
|
|
725
724
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Decimal, { Decimal as Decimal$1 } from 'decimal.js';
|
|
2
|
-
import { SchemaDef, GetModels, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, NonRelationFields, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, GetEnums, GetEnum, BuiltinType, GetModel, FieldDef, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, IsDelegateModel, GetModelDiscriminator, GetSubModels, FieldIsRelationArray, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, DataSourceProviderType,
|
|
3
|
-
import { Generated, Kysely, ExpressionBuilder, OperandExpression, SqlBool, SelectQueryBuilder, Expression, ExpressionWrapper, RootOperationNode, QueryResult, UnknownRow, OperationNode,
|
|
2
|
+
import { SchemaDef, GetModels, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, NonRelationFields, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, GetEnums, GetEnum, BuiltinType, GetModel, FieldDef, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, IsDelegateModel, GetModelDiscriminator, GetSubModels, FieldIsRelationArray, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, DataSourceProviderType, ProcedureDef } from '@zenstackhq/sdk/schema';
|
|
3
|
+
import { Generated, Kysely, ExpressionBuilder, OperandExpression, SqlBool, SelectQueryBuilder, Expression, ExpressionWrapper, RootOperationNode, QueryResult, UnknownRow, OperationNode, Dialect, KyselyConfig } from 'kysely';
|
|
4
4
|
|
|
5
5
|
type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
6
6
|
type NullableIf<T, Condition extends boolean> = Condition extends true ? T | null : T;
|
|
@@ -705,7 +705,6 @@ type OnQueryHookContext<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
705
705
|
*/
|
|
706
706
|
declare function definePlugin<Schema extends SchemaDef>(plugin: RuntimePlugin<Schema>): RuntimePlugin<Schema>;
|
|
707
707
|
|
|
708
|
-
type DialectConfig<Provider extends DataSourceProvider> = Provider['type'] extends 'sqlite' ? Optional<SqliteDialectConfig, 'database'> : Provider['type'] extends 'postgresql' ? Optional<PostgresDialectConfig, 'pool'> : never;
|
|
709
708
|
type ZModelFunctionContext<Schema extends SchemaDef> = {
|
|
710
709
|
dialect: BaseCrudDialect<Schema>;
|
|
711
710
|
model: GetModels<Schema>;
|
|
@@ -717,9 +716,9 @@ type ZModelFunction<Schema extends SchemaDef> = (eb: ExpressionBuilder<ToKyselyS
|
|
|
717
716
|
*/
|
|
718
717
|
type ClientOptions<Schema extends SchemaDef> = {
|
|
719
718
|
/**
|
|
720
|
-
*
|
|
719
|
+
* Kysely dialect.
|
|
721
720
|
*/
|
|
722
|
-
|
|
721
|
+
dialect: Dialect;
|
|
723
722
|
/**
|
|
724
723
|
* Custom function definitions.
|
|
725
724
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
43
43
|
// src/client/client-impl.ts
|
|
44
44
|
var import_common_helpers13 = require("@zenstackhq/common-helpers");
|
|
45
45
|
var import_kysely16 = require("kysely");
|
|
46
|
-
var import_ts_pattern19 = require("ts-pattern");
|
|
47
46
|
|
|
48
47
|
// src/client/crud/operations/aggregate.ts
|
|
49
48
|
var import_kysely9 = require("kysely");
|
|
@@ -6460,17 +6459,16 @@ var ClientImpl = class _ClientImpl {
|
|
|
6460
6459
|
this.kyselyRaw = baseClient.kyselyRaw;
|
|
6461
6460
|
this.auth = baseClient.auth;
|
|
6462
6461
|
} else {
|
|
6463
|
-
const
|
|
6464
|
-
const
|
|
6465
|
-
const
|
|
6466
|
-
const adapter = dialect.createAdapter();
|
|
6462
|
+
const driver = new ZenStackDriver(options.dialect.createDriver(), new import_kysely16.Log(this.$options.log ?? []));
|
|
6463
|
+
const compiler = options.dialect.createQueryCompiler();
|
|
6464
|
+
const adapter = options.dialect.createAdapter();
|
|
6467
6465
|
const connectionProvider = new import_kysely16.DefaultConnectionProvider(driver);
|
|
6468
6466
|
this.kyselyProps = {
|
|
6469
6467
|
config: {
|
|
6470
|
-
dialect,
|
|
6468
|
+
dialect: options.dialect,
|
|
6471
6469
|
log: this.$options.log
|
|
6472
6470
|
},
|
|
6473
|
-
dialect,
|
|
6471
|
+
dialect: options.dialect,
|
|
6474
6472
|
driver,
|
|
6475
6473
|
executor: executor ?? new ZenStackQueryExecutor(this, driver, compiler, adapter, connectionProvider)
|
|
6476
6474
|
};
|
|
@@ -6497,15 +6495,6 @@ var ClientImpl = class _ClientImpl {
|
|
|
6497
6495
|
withExecutor(executor) {
|
|
6498
6496
|
return new _ClientImpl(this.schema, this.$options, this, executor);
|
|
6499
6497
|
}
|
|
6500
|
-
getKyselyDialect() {
|
|
6501
|
-
return (0, import_ts_pattern19.match)(this.schema.provider.type).with("sqlite", () => this.makeSqliteKyselyDialect()).with("postgresql", () => this.makePostgresKyselyDialect()).exhaustive();
|
|
6502
|
-
}
|
|
6503
|
-
makePostgresKyselyDialect() {
|
|
6504
|
-
return new import_kysely16.PostgresDialect(this.options.dialectConfig);
|
|
6505
|
-
}
|
|
6506
|
-
makeSqliteKyselyDialect() {
|
|
6507
|
-
return new import_kysely16.SqliteDialect(this.options.dialectConfig);
|
|
6508
|
-
}
|
|
6509
6498
|
// implementation
|
|
6510
6499
|
async $transaction(input, options) {
|
|
6511
6500
|
(0, import_common_helpers13.invariant)(typeof input === "function" || Array.isArray(input) && input.every((p) => p.then && p.cb), "Invalid transaction input, expected a function or an array of ZenStackPromise");
|