@zenstackhq/runtime 3.0.0-alpha.6 → 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.cjs
CHANGED
|
@@ -2554,8 +2554,8 @@ var BaseOperationHandler = class {
|
|
|
2554
2554
|
try {
|
|
2555
2555
|
result = await query.execute();
|
|
2556
2556
|
} catch (err) {
|
|
2557
|
-
const { sql:
|
|
2558
|
-
throw new QueryError(`Failed to execute query: ${err}, sql: ${
|
|
2557
|
+
const { sql: sql11, parameters } = query.compile();
|
|
2558
|
+
throw new QueryError(`Failed to execute query: ${err}, sql: ${sql11}, parameters: ${parameters}`);
|
|
2559
2559
|
}
|
|
2560
2560
|
if (inMemoryDistinct) {
|
|
2561
2561
|
const distinctResult = [];
|
|
@@ -3146,8 +3146,8 @@ var BaseOperationHandler = class {
|
|
|
3146
3146
|
return result;
|
|
3147
3147
|
}
|
|
3148
3148
|
} catch (err) {
|
|
3149
|
-
const { sql:
|
|
3150
|
-
throw new QueryError(`Error during updateMany: ${err}, sql: ${
|
|
3149
|
+
const { sql: sql11, parameters } = query.compile();
|
|
3150
|
+
throw new QueryError(`Error during updateMany: ${err}, sql: ${sql11}, parameters: ${parameters}`);
|
|
3151
3151
|
}
|
|
3152
3152
|
}
|
|
3153
3153
|
buildIdFieldRefs(kysely, model) {
|
|
@@ -5193,7 +5193,8 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends import_kysely13
|
|
|
5193
5193
|
])
|
|
5194
5194
|
};
|
|
5195
5195
|
}
|
|
5196
|
-
const
|
|
5196
|
+
const queryParams = compiledQuery.$raw ? compiledQuery.parameters : void 0;
|
|
5197
|
+
const result = await this.proceedQueryWithKyselyInterceptors(queryNode, queryParams, queryId);
|
|
5197
5198
|
await this.callAfterQueryInterceptionFilters(result, queryNode, mutationInterceptionInfo);
|
|
5198
5199
|
if (oldQueryNode !== queryNode) {
|
|
5199
5200
|
}
|
|
@@ -5201,8 +5202,8 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends import_kysely13
|
|
|
5201
5202
|
}, "task");
|
|
5202
5203
|
return this.executeWithTransaction(task, !!mutationInterceptionInfo?.useTransactionForMutation);
|
|
5203
5204
|
}
|
|
5204
|
-
proceedQueryWithKyselyInterceptors(queryNode, queryId) {
|
|
5205
|
-
let proceed = /* @__PURE__ */ __name((q) => this.proceedQuery(q, queryId), "proceed");
|
|
5205
|
+
proceedQueryWithKyselyInterceptors(queryNode, parameters, queryId) {
|
|
5206
|
+
let proceed = /* @__PURE__ */ __name((q) => this.proceedQuery(q, parameters, queryId), "proceed");
|
|
5206
5207
|
const makeTx = /* @__PURE__ */ __name((p) => (callback) => {
|
|
5207
5208
|
return this.executeWithTransaction(() => callback(p));
|
|
5208
5209
|
}, "makeTx");
|
|
@@ -5222,9 +5223,15 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends import_kysely13
|
|
|
5222
5223
|
}
|
|
5223
5224
|
return proceed(queryNode);
|
|
5224
5225
|
}
|
|
5225
|
-
async proceedQuery(query, queryId) {
|
|
5226
|
+
async proceedQuery(query, parameters, queryId) {
|
|
5226
5227
|
const finalQuery = this.nameMapper.transformNode(query);
|
|
5227
|
-
|
|
5228
|
+
let compiled = this.compileQuery(finalQuery);
|
|
5229
|
+
if (parameters) {
|
|
5230
|
+
compiled = {
|
|
5231
|
+
...compiled,
|
|
5232
|
+
parameters
|
|
5233
|
+
};
|
|
5234
|
+
}
|
|
5228
5235
|
try {
|
|
5229
5236
|
return this.driver.txConnection ? await super.withConnectionProvider(new import_kysely13.SingleConnectionProvider(this.driver.txConnection)).executeQuery(compiled, queryId) : await super.executeQuery(compiled, queryId);
|
|
5230
5237
|
} catch (err) {
|
|
@@ -5971,6 +5978,39 @@ var ClientImpl = class _ClientImpl {
|
|
|
5971
5978
|
get $auth() {
|
|
5972
5979
|
return this.auth;
|
|
5973
5980
|
}
|
|
5981
|
+
$executeRaw(query, ...values) {
|
|
5982
|
+
return createDeferredPromise(async () => {
|
|
5983
|
+
const result = await (0, import_kysely16.sql)(query, ...values).execute(this.kysely);
|
|
5984
|
+
return Number(result.numAffectedRows ?? 0);
|
|
5985
|
+
});
|
|
5986
|
+
}
|
|
5987
|
+
$executeRawUnsafe(query, ...values) {
|
|
5988
|
+
return createDeferredPromise(async () => {
|
|
5989
|
+
const compiledQuery = this.createRawCompiledQuery(query, values);
|
|
5990
|
+
const result = await this.kysely.executeQuery(compiledQuery);
|
|
5991
|
+
return Number(result.numAffectedRows ?? 0);
|
|
5992
|
+
});
|
|
5993
|
+
}
|
|
5994
|
+
$queryRaw(query, ...values) {
|
|
5995
|
+
return createDeferredPromise(async () => {
|
|
5996
|
+
const result = await (0, import_kysely16.sql)(query, ...values).execute(this.kysely);
|
|
5997
|
+
return result.rows;
|
|
5998
|
+
});
|
|
5999
|
+
}
|
|
6000
|
+
$queryRawUnsafe(query, ...values) {
|
|
6001
|
+
return createDeferredPromise(async () => {
|
|
6002
|
+
const compiledQuery = this.createRawCompiledQuery(query, values);
|
|
6003
|
+
const result = await this.kysely.executeQuery(compiledQuery);
|
|
6004
|
+
return result.rows;
|
|
6005
|
+
});
|
|
6006
|
+
}
|
|
6007
|
+
createRawCompiledQuery(query, values) {
|
|
6008
|
+
const q = import_kysely16.CompiledQuery.raw(query, values);
|
|
6009
|
+
return {
|
|
6010
|
+
...q,
|
|
6011
|
+
$raw: true
|
|
6012
|
+
};
|
|
6013
|
+
}
|
|
5974
6014
|
};
|
|
5975
6015
|
function createClientProxy(client) {
|
|
5976
6016
|
const inputValidator = new InputValidator(client.$schema);
|