@zenstackhq/runtime 3.0.0-alpha.7 → 3.0.0-alpha.8
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/client.cjs +49 -9
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +50 -10
- package/dist/client.js.map +1 -1
- package/dist/{contract-DW8XGrtV.d.cts → contract-BnvK1nW0.d.cts} +34 -0
- package/dist/{contract-DW8XGrtV.d.ts → contract-BnvK1nW0.d.ts} +34 -0
- package/dist/index.cjs +49 -9
- 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 +50 -10
- package/dist/index.js.map +1 -1
- package/dist/plugins/policy.d.cts +1 -1
- package/dist/plugins/policy.d.ts +1 -1
- package/package.json +7 -7
package/dist/client.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ZenStackClient } from './index.cjs';
|
|
2
|
-
export { L as AggregateArgs, P as AggregateResult, B as BatchResult, f as BooleanFilter, e as BytesFilter, C as ClientConstructor, a as ClientContract, b as ClientOptions, c as CommonPrimitiveFilter, J as CountAggregateInput, I as CountArgs, K as CountResult, r as CreateArgs, v as CreateInput, t as CreateManyAndReturnArgs, s as CreateManyArgs, u as CreateManyPayload, D as DateTimeFilter, G as DeleteArgs, H as DeleteManyArgs, F as FindArgs, q as FindUniqueArgs, Q as GroupByArgs, R as GroupByResult, m as MapFieldType, M as ModelResult, h as NullsOrder, N as NumberFilter, p as OppositeRelationAndFK, o as OppositeRelationFields, n as OptionalFieldsForCreate, O as OrderBy, j as SelectIncludeOmit, l as SelectSubset, g as SortOrder, S as StringFilter, k as Subset, T as ToKysely, U as UpdateArgs, E as UpdateInput, x as UpdateManyAndReturnArgs, w as UpdateManyArgs, A as UpdateRelationInput, z as UpdateScalarInput, y as UpsertArgs, W as WhereInput, i as WhereUniqueInput, d as definePlugin } from './contract-
|
|
2
|
+
export { L as AggregateArgs, P as AggregateResult, B as BatchResult, f as BooleanFilter, e as BytesFilter, C as ClientConstructor, a as ClientContract, b as ClientOptions, c as CommonPrimitiveFilter, J as CountAggregateInput, I as CountArgs, K as CountResult, r as CreateArgs, v as CreateInput, t as CreateManyAndReturnArgs, s as CreateManyArgs, u as CreateManyPayload, D as DateTimeFilter, G as DeleteArgs, H as DeleteManyArgs, F as FindArgs, q as FindUniqueArgs, Q as GroupByArgs, R as GroupByResult, m as MapFieldType, M as ModelResult, h as NullsOrder, N as NumberFilter, p as OppositeRelationAndFK, o as OppositeRelationFields, n as OptionalFieldsForCreate, O as OrderBy, j as SelectIncludeOmit, l as SelectSubset, g as SortOrder, S as StringFilter, k as Subset, T as ToKysely, U as UpdateArgs, E as UpdateInput, x as UpdateManyAndReturnArgs, w as UpdateManyArgs, A as UpdateRelationInput, z as UpdateScalarInput, y as UpsertArgs, W as WhereInput, i as WhereUniqueInput, d as definePlugin } from './contract-BnvK1nW0.cjs';
|
|
3
3
|
import 'decimal.js';
|
|
4
4
|
import '@zenstackhq/sdk/schema';
|
|
5
5
|
import 'kysely';
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ZenStackClient } from './index.js';
|
|
2
|
-
export { L as AggregateArgs, P as AggregateResult, B as BatchResult, f as BooleanFilter, e as BytesFilter, C as ClientConstructor, a as ClientContract, b as ClientOptions, c as CommonPrimitiveFilter, J as CountAggregateInput, I as CountArgs, K as CountResult, r as CreateArgs, v as CreateInput, t as CreateManyAndReturnArgs, s as CreateManyArgs, u as CreateManyPayload, D as DateTimeFilter, G as DeleteArgs, H as DeleteManyArgs, F as FindArgs, q as FindUniqueArgs, Q as GroupByArgs, R as GroupByResult, m as MapFieldType, M as ModelResult, h as NullsOrder, N as NumberFilter, p as OppositeRelationAndFK, o as OppositeRelationFields, n as OptionalFieldsForCreate, O as OrderBy, j as SelectIncludeOmit, l as SelectSubset, g as SortOrder, S as StringFilter, k as Subset, T as ToKysely, U as UpdateArgs, E as UpdateInput, x as UpdateManyAndReturnArgs, w as UpdateManyArgs, A as UpdateRelationInput, z as UpdateScalarInput, y as UpsertArgs, W as WhereInput, i as WhereUniqueInput, d as definePlugin } from './contract-
|
|
2
|
+
export { L as AggregateArgs, P as AggregateResult, B as BatchResult, f as BooleanFilter, e as BytesFilter, C as ClientConstructor, a as ClientContract, b as ClientOptions, c as CommonPrimitiveFilter, J as CountAggregateInput, I as CountArgs, K as CountResult, r as CreateArgs, v as CreateInput, t as CreateManyAndReturnArgs, s as CreateManyArgs, u as CreateManyPayload, D as DateTimeFilter, G as DeleteArgs, H as DeleteManyArgs, F as FindArgs, q as FindUniqueArgs, Q as GroupByArgs, R as GroupByResult, m as MapFieldType, M as ModelResult, h as NullsOrder, N as NumberFilter, p as OppositeRelationAndFK, o as OppositeRelationFields, n as OptionalFieldsForCreate, O as OrderBy, j as SelectIncludeOmit, l as SelectSubset, g as SortOrder, S as StringFilter, k as Subset, T as ToKysely, U as UpdateArgs, E as UpdateInput, x as UpdateManyAndReturnArgs, w as UpdateManyArgs, A as UpdateRelationInput, z as UpdateScalarInput, y as UpsertArgs, W as WhereInput, i as WhereUniqueInput, d as definePlugin } from './contract-BnvK1nW0.js';
|
|
3
3
|
import 'decimal.js';
|
|
4
4
|
import '@zenstackhq/sdk/schema';
|
|
5
5
|
import 'kysely';
|
package/dist/client.js
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/client/client-impl.ts
|
|
9
9
|
import { lowerCaseFirst as lowerCaseFirst2 } from "@zenstackhq/common-helpers";
|
|
10
|
-
import { DefaultConnectionProvider, DefaultQueryExecutor as DefaultQueryExecutor2, Kysely, Log, PostgresDialect, SqliteDialect } from "kysely";
|
|
10
|
+
import { CompiledQuery, DefaultConnectionProvider, DefaultQueryExecutor as DefaultQueryExecutor2, Kysely, Log, PostgresDialect, sql as sql10, SqliteDialect } from "kysely";
|
|
11
11
|
import { match as match19 } from "ts-pattern";
|
|
12
12
|
|
|
13
13
|
// src/client/crud/operations/aggregate.ts
|
|
@@ -2520,8 +2520,8 @@ var BaseOperationHandler = class {
|
|
|
2520
2520
|
try {
|
|
2521
2521
|
result = await query.execute();
|
|
2522
2522
|
} catch (err) {
|
|
2523
|
-
const { sql:
|
|
2524
|
-
throw new QueryError(`Failed to execute query: ${err}, sql: ${
|
|
2523
|
+
const { sql: sql11, parameters } = query.compile();
|
|
2524
|
+
throw new QueryError(`Failed to execute query: ${err}, sql: ${sql11}, parameters: ${parameters}`);
|
|
2525
2525
|
}
|
|
2526
2526
|
if (inMemoryDistinct) {
|
|
2527
2527
|
const distinctResult = [];
|
|
@@ -3112,8 +3112,8 @@ var BaseOperationHandler = class {
|
|
|
3112
3112
|
return result;
|
|
3113
3113
|
}
|
|
3114
3114
|
} catch (err) {
|
|
3115
|
-
const { sql:
|
|
3116
|
-
throw new QueryError(`Error during updateMany: ${err}, sql: ${
|
|
3115
|
+
const { sql: sql11, parameters } = query.compile();
|
|
3116
|
+
throw new QueryError(`Error during updateMany: ${err}, sql: ${sql11}, parameters: ${parameters}`);
|
|
3117
3117
|
}
|
|
3118
3118
|
}
|
|
3119
3119
|
buildIdFieldRefs(kysely, model) {
|
|
@@ -5159,7 +5159,8 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends DefaultQueryExe
|
|
|
5159
5159
|
])
|
|
5160
5160
|
};
|
|
5161
5161
|
}
|
|
5162
|
-
const
|
|
5162
|
+
const queryParams = compiledQuery.$raw ? compiledQuery.parameters : void 0;
|
|
5163
|
+
const result = await this.proceedQueryWithKyselyInterceptors(queryNode, queryParams, queryId);
|
|
5163
5164
|
await this.callAfterQueryInterceptionFilters(result, queryNode, mutationInterceptionInfo);
|
|
5164
5165
|
if (oldQueryNode !== queryNode) {
|
|
5165
5166
|
}
|
|
@@ -5167,8 +5168,8 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends DefaultQueryExe
|
|
|
5167
5168
|
}, "task");
|
|
5168
5169
|
return this.executeWithTransaction(task, !!mutationInterceptionInfo?.useTransactionForMutation);
|
|
5169
5170
|
}
|
|
5170
|
-
proceedQueryWithKyselyInterceptors(queryNode, queryId) {
|
|
5171
|
-
let proceed = /* @__PURE__ */ __name((q) => this.proceedQuery(q, queryId), "proceed");
|
|
5171
|
+
proceedQueryWithKyselyInterceptors(queryNode, parameters, queryId) {
|
|
5172
|
+
let proceed = /* @__PURE__ */ __name((q) => this.proceedQuery(q, parameters, queryId), "proceed");
|
|
5172
5173
|
const makeTx = /* @__PURE__ */ __name((p) => (callback) => {
|
|
5173
5174
|
return this.executeWithTransaction(() => callback(p));
|
|
5174
5175
|
}, "makeTx");
|
|
@@ -5188,9 +5189,15 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends DefaultQueryExe
|
|
|
5188
5189
|
}
|
|
5189
5190
|
return proceed(queryNode);
|
|
5190
5191
|
}
|
|
5191
|
-
async proceedQuery(query, queryId) {
|
|
5192
|
+
async proceedQuery(query, parameters, queryId) {
|
|
5192
5193
|
const finalQuery = this.nameMapper.transformNode(query);
|
|
5193
|
-
|
|
5194
|
+
let compiled = this.compileQuery(finalQuery);
|
|
5195
|
+
if (parameters) {
|
|
5196
|
+
compiled = {
|
|
5197
|
+
...compiled,
|
|
5198
|
+
parameters
|
|
5199
|
+
};
|
|
5200
|
+
}
|
|
5194
5201
|
try {
|
|
5195
5202
|
return this.driver.txConnection ? await super.withConnectionProvider(new SingleConnectionProvider(this.driver.txConnection)).executeQuery(compiled, queryId) : await super.executeQuery(compiled, queryId);
|
|
5196
5203
|
} catch (err) {
|
|
@@ -5937,6 +5944,39 @@ var ClientImpl = class _ClientImpl {
|
|
|
5937
5944
|
get $auth() {
|
|
5938
5945
|
return this.auth;
|
|
5939
5946
|
}
|
|
5947
|
+
$executeRaw(query, ...values) {
|
|
5948
|
+
return createDeferredPromise(async () => {
|
|
5949
|
+
const result = await sql10(query, ...values).execute(this.kysely);
|
|
5950
|
+
return Number(result.numAffectedRows ?? 0);
|
|
5951
|
+
});
|
|
5952
|
+
}
|
|
5953
|
+
$executeRawUnsafe(query, ...values) {
|
|
5954
|
+
return createDeferredPromise(async () => {
|
|
5955
|
+
const compiledQuery = this.createRawCompiledQuery(query, values);
|
|
5956
|
+
const result = await this.kysely.executeQuery(compiledQuery);
|
|
5957
|
+
return Number(result.numAffectedRows ?? 0);
|
|
5958
|
+
});
|
|
5959
|
+
}
|
|
5960
|
+
$queryRaw(query, ...values) {
|
|
5961
|
+
return createDeferredPromise(async () => {
|
|
5962
|
+
const result = await sql10(query, ...values).execute(this.kysely);
|
|
5963
|
+
return result.rows;
|
|
5964
|
+
});
|
|
5965
|
+
}
|
|
5966
|
+
$queryRawUnsafe(query, ...values) {
|
|
5967
|
+
return createDeferredPromise(async () => {
|
|
5968
|
+
const compiledQuery = this.createRawCompiledQuery(query, values);
|
|
5969
|
+
const result = await this.kysely.executeQuery(compiledQuery);
|
|
5970
|
+
return result.rows;
|
|
5971
|
+
});
|
|
5972
|
+
}
|
|
5973
|
+
createRawCompiledQuery(query, values) {
|
|
5974
|
+
const q = CompiledQuery.raw(query, values);
|
|
5975
|
+
return {
|
|
5976
|
+
...q,
|
|
5977
|
+
$raw: true
|
|
5978
|
+
};
|
|
5979
|
+
}
|
|
5940
5980
|
};
|
|
5941
5981
|
function createClientProxy(client) {
|
|
5942
5982
|
const inputValidator = new InputValidator(client.$schema);
|