@burdenoff/be-sdk 2026.1005.1 → 2026.1008.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/README.md +64 -0
- package/dist/auth/index.d.ts +2 -2
- package/dist/{chunk-FA5ROGTS.js → chunk-CYY4VIRK.js} +257 -131
- package/dist/chunk-CYY4VIRK.js.map +1 -0
- package/dist/{chunk-CVMQRWCB.js → chunk-EOHPDXXW.js} +7 -3
- package/dist/chunk-EOHPDXXW.js.map +1 -0
- package/dist/feature-flags/index.d.ts +3 -3
- package/dist/{index-Daj7nq9V.d.ts → index-Dl8EAdYu.d.ts} +10 -2
- package/dist/{index-Drvw0QPe.d.ts → index-Rc5EphmY.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/lake/index.d.ts +59 -0
- package/dist/lake/index.js +253 -0
- package/dist/lake/index.js.map +1 -0
- package/dist/prisma/index.d.ts +2 -2
- package/dist/prisma/index.js +2 -2
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +1 -1
- package/dist/{types-Biv0uaJk.d.ts → types-C-6m9NoG.d.ts} +1 -1
- package/dist/{workspace-extension-DlxYz3P4.d.ts → workspace-extension-DiNiTLa3.d.ts} +29 -1
- package/package.json +7 -3
- package/dist/chunk-CVMQRWCB.js.map +0 -1
- package/dist/chunk-FA5ROGTS.js.map +0 -1
|
@@ -185,6 +185,105 @@ async function runOperationWithRlsGuc(rootClient, wsCtx, model, operation, args)
|
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
__name(runOperationWithRlsGuc, "runOperationWithRlsGuc");
|
|
188
|
+
function getCallerTransaction(internalParams) {
|
|
189
|
+
const transaction = internalParams?.transaction;
|
|
190
|
+
if (transaction === void 0 || transaction === null) return void 0;
|
|
191
|
+
if (typeof transaction === "object") {
|
|
192
|
+
const { kind, id } = transaction;
|
|
193
|
+
if (kind === "itx" && typeof id === "string" && id.length > 0) {
|
|
194
|
+
return {
|
|
195
|
+
kind: "itx",
|
|
196
|
+
id,
|
|
197
|
+
descriptor: transaction
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (kind === "batch") return {
|
|
201
|
+
kind: "batch"
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
throw new Error("[WorkspaceExtension] Unrecognised Prisma transaction descriptor on __internalParams.transaction; refusing to run the operation outside the caller transaction. This Prisma version is not supported by the be-sdk RLS transaction integration (BOFF-8874).");
|
|
205
|
+
}
|
|
206
|
+
__name(getCallerTransaction, "getCallerTransaction");
|
|
207
|
+
function sanitizeWorkspaceId(workspaceId) {
|
|
208
|
+
return (workspaceId ?? "").replace(/[^a-zA-Z0-9\-_]/g, "");
|
|
209
|
+
}
|
|
210
|
+
__name(sanitizeWorkspaceId, "sanitizeWorkspaceId");
|
|
211
|
+
function buildApplicationNameTag(wsCtx) {
|
|
212
|
+
const safeSvc = (process.env["SERVICE_NAME"] ?? "svc").replace(/[^a-zA-Z0-9\-_]/g, "");
|
|
213
|
+
return `svc=${safeSvc};ws=${sanitizeWorkspaceId(wsCtx.workspaceId)}`;
|
|
214
|
+
}
|
|
215
|
+
__name(buildApplicationNameTag, "buildApplicationNameTag");
|
|
216
|
+
function buildTransactionContextStatement(wsCtx, config) {
|
|
217
|
+
const settings = [];
|
|
218
|
+
const params = [];
|
|
219
|
+
if (config.enableRlsGucTagging) {
|
|
220
|
+
params.push(sanitizeWorkspaceId(wsCtx.workspaceId));
|
|
221
|
+
settings.push(`set_config('app.workspace_id', $${params.length}, true)`);
|
|
222
|
+
}
|
|
223
|
+
if (config.enableApplicationNameTagging) {
|
|
224
|
+
params.push(buildApplicationNameTag(wsCtx));
|
|
225
|
+
settings.push(`set_config('application_name', $${params.length}, true)`);
|
|
226
|
+
}
|
|
227
|
+
if (settings.length === 0) return void 0;
|
|
228
|
+
return {
|
|
229
|
+
sql: `SELECT ${settings.join(", ")}`,
|
|
230
|
+
params,
|
|
231
|
+
key: params.join("\0")
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
__name(buildTransactionContextStatement, "buildTransactionContextStatement");
|
|
235
|
+
var MAX_TRACKED_CALLER_TRANSACTIONS = 4096;
|
|
236
|
+
var callerTransactionStates = /* @__PURE__ */ new Map();
|
|
237
|
+
function rememberCallerTransaction(id, state) {
|
|
238
|
+
callerTransactionStates.delete(id);
|
|
239
|
+
callerTransactionStates.set(id, state);
|
|
240
|
+
if (callerTransactionStates.size > MAX_TRACKED_CALLER_TRANSACTIONS) {
|
|
241
|
+
const oldest = callerTransactionStates.keys().next().value;
|
|
242
|
+
if (oldest !== void 0) callerTransactionStates.delete(oldest);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
__name(rememberCallerTransaction, "rememberCallerTransaction");
|
|
246
|
+
async function applyCallerTransactionContext(rawPrisma, descriptor, statement) {
|
|
247
|
+
const pending = rawPrisma.$executeRawUnsafe(statement.sql, ...statement.params);
|
|
248
|
+
if (typeof pending.requestTransaction !== "function") {
|
|
249
|
+
throw new Error("[WorkspaceExtension] Cannot bind the RLS context statement to the caller transaction (PrismaPromise.requestTransaction is unavailable); refusing to run it on another connection (BOFF-8874).");
|
|
250
|
+
}
|
|
251
|
+
await pending.requestTransaction(descriptor);
|
|
252
|
+
}
|
|
253
|
+
__name(applyCallerTransactionContext, "applyCallerTransactionContext");
|
|
254
|
+
async function runOperationInCallerTransaction(rawPrisma, transaction, wsCtx, config, run) {
|
|
255
|
+
const statement = buildTransactionContextStatement(wsCtx, config);
|
|
256
|
+
if (!statement) return run();
|
|
257
|
+
let state = callerTransactionStates.get(transaction.id);
|
|
258
|
+
if (!state || state.descriptor !== transaction.descriptor || state.key !== statement.key) {
|
|
259
|
+
if (state && state.inflight > 0 && state.key !== statement.key) {
|
|
260
|
+
throw new Error("[WorkspaceExtension] Concurrent operations for different workspaces inside one transaction are not supported: the RLS context is per transaction. Await the other workspace\u2019s operations first.");
|
|
261
|
+
}
|
|
262
|
+
const next = {
|
|
263
|
+
descriptor: transaction.descriptor,
|
|
264
|
+
key: statement.key,
|
|
265
|
+
ready: applyCallerTransactionContext(rawPrisma, transaction.descriptor, statement),
|
|
266
|
+
inflight: 0
|
|
267
|
+
};
|
|
268
|
+
next.ready.catch(() => {
|
|
269
|
+
if (callerTransactionStates.get(transaction.id) === next) callerTransactionStates.delete(transaction.id);
|
|
270
|
+
});
|
|
271
|
+
rememberCallerTransaction(transaction.id, next);
|
|
272
|
+
state = next;
|
|
273
|
+
}
|
|
274
|
+
state.inflight += 1;
|
|
275
|
+
try {
|
|
276
|
+
await state.ready;
|
|
277
|
+
return await run();
|
|
278
|
+
} finally {
|
|
279
|
+
state.inflight -= 1;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
__name(runOperationInCallerTransaction, "runOperationInCallerTransaction");
|
|
283
|
+
function resetCallerTransactionStateForTests() {
|
|
284
|
+
callerTransactionStates.clear();
|
|
285
|
+
}
|
|
286
|
+
__name(resetCallerTransactionStateForTests, "resetCallerTransactionStateForTests");
|
|
188
287
|
function addWorkspaceExtension(baseClient, config) {
|
|
189
288
|
const fullConfig = {
|
|
190
289
|
...defaultWorkspaceExtensionConfig,
|
|
@@ -196,6 +295,33 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
196
295
|
}
|
|
197
296
|
const rawPrisma = baseClient;
|
|
198
297
|
const rawPrismaForTransactions = baseClient;
|
|
298
|
+
const rawPrismaForCallerTransactions = baseClient;
|
|
299
|
+
const tagsTransactions = fullConfig.enableRlsGucTagging || fullConfig.enableApplicationNameTagging;
|
|
300
|
+
const dispatch = /* @__PURE__ */ __name(async (params, wsCtx, operation, finalArgs) => {
|
|
301
|
+
if (!tagsTransactions) return params.query(finalArgs);
|
|
302
|
+
const callerTransaction = getCallerTransaction(params.__internalParams);
|
|
303
|
+
if (callerTransaction?.kind === "itx") {
|
|
304
|
+
return runOperationInCallerTransaction(rawPrismaForCallerTransactions, callerTransaction, wsCtx, fullConfig, () => params.query(finalArgs));
|
|
305
|
+
}
|
|
306
|
+
if (callerTransaction?.kind === "batch") {
|
|
307
|
+
return params.query(finalArgs);
|
|
308
|
+
}
|
|
309
|
+
if (fullConfig.enableApplicationNameTagging) {
|
|
310
|
+
await maybeTagConnection(rawPrisma, wsCtx);
|
|
311
|
+
}
|
|
312
|
+
if (fullConfig.enableRlsGucTagging) {
|
|
313
|
+
return runOperationWithRlsGuc(rawPrismaForTransactions, wsCtx, params.model, operation, finalArgs);
|
|
314
|
+
}
|
|
315
|
+
return params.query(finalArgs);
|
|
316
|
+
}, "dispatch");
|
|
317
|
+
const rawOperation = /* @__PURE__ */ __name(async ({ args, query, __internalParams }) => {
|
|
318
|
+
if (!tagsTransactions) return query(args);
|
|
319
|
+
const callerTransaction = getCallerTransaction(__internalParams);
|
|
320
|
+
if (callerTransaction?.kind !== "itx") return query(args);
|
|
321
|
+
const wsCtx = getWorkspaceContext();
|
|
322
|
+
if (!wsCtx?.workspaceId) return query(args);
|
|
323
|
+
return runOperationInCallerTransaction(rawPrismaForCallerTransactions, callerTransaction, wsCtx, fullConfig, () => query(args));
|
|
324
|
+
}, "rawOperation");
|
|
199
325
|
const prismaClient = baseClient;
|
|
200
326
|
logger.info("[WorkspaceExtension] Workspace extension enabled", {
|
|
201
327
|
populateContextJson: fullConfig.populateContextJson,
|
|
@@ -212,13 +338,21 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
212
338
|
enableApplicationNameTagging: fullConfig.enableApplicationNameTagging,
|
|
213
339
|
enableRlsGucTagging: fullConfig.enableRlsGucTagging
|
|
214
340
|
});
|
|
215
|
-
|
|
341
|
+
const rawOperationHooks = tagsTransactions ? {
|
|
342
|
+
$queryRaw: rawOperation,
|
|
343
|
+
$executeRaw: rawOperation,
|
|
344
|
+
$queryRawUnsafe: rawOperation,
|
|
345
|
+
$executeRawUnsafe: rawOperation,
|
|
346
|
+
$queryRawTyped: rawOperation
|
|
347
|
+
} : {};
|
|
348
|
+
const withQueryHooks = prismaClient.$extends({
|
|
216
349
|
query: {
|
|
350
|
+
...rawOperationHooks,
|
|
217
351
|
$allModels: {
|
|
218
352
|
// ================================================================
|
|
219
353
|
// WRITE OPERATIONS - inject workspaceId into data
|
|
220
354
|
// ================================================================
|
|
221
|
-
async create({ model, args, query }) {
|
|
355
|
+
async create({ model, args, query, __internalParams }) {
|
|
222
356
|
if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) {
|
|
223
357
|
return query(stripSkipFlag(args));
|
|
224
358
|
}
|
|
@@ -227,9 +361,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
227
361
|
if (!wsCtx?.workspaceId) {
|
|
228
362
|
return query(args);
|
|
229
363
|
}
|
|
230
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
231
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
232
|
-
}
|
|
233
364
|
const injectedData = injectCreateFields(args.data, wsCtx, fullConfig);
|
|
234
365
|
if (fullConfig.debug) {
|
|
235
366
|
const injectedKeys = Object.keys(injectedData).filter((k) => !(k in args.data));
|
|
@@ -244,12 +375,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
244
375
|
...stripSkipFlag(args),
|
|
245
376
|
data: injectedData
|
|
246
377
|
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
378
|
+
return dispatch({
|
|
379
|
+
model,
|
|
380
|
+
query,
|
|
381
|
+
__internalParams
|
|
382
|
+
}, wsCtx, "create", finalArgs);
|
|
251
383
|
},
|
|
252
|
-
async createMany({ model, args, query }) {
|
|
384
|
+
async createMany({ model, args, query, __internalParams }) {
|
|
253
385
|
if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) {
|
|
254
386
|
return query(stripSkipFlag(args));
|
|
255
387
|
}
|
|
@@ -258,9 +390,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
258
390
|
if (!wsCtx?.workspaceId) {
|
|
259
391
|
return query(args);
|
|
260
392
|
}
|
|
261
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
262
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
263
|
-
}
|
|
264
393
|
const dataArray = Array.isArray(args.data) ? args.data : [
|
|
265
394
|
args.data
|
|
266
395
|
];
|
|
@@ -269,12 +398,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
269
398
|
...stripSkipFlag(args),
|
|
270
399
|
data: Array.isArray(args.data) ? injectedData : injectedData[0]
|
|
271
400
|
};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
401
|
+
return dispatch({
|
|
402
|
+
model,
|
|
403
|
+
query,
|
|
404
|
+
__internalParams
|
|
405
|
+
}, wsCtx, "createMany", finalArgs);
|
|
276
406
|
},
|
|
277
|
-
async createManyAndReturn({ model, args, query }) {
|
|
407
|
+
async createManyAndReturn({ model, args, query, __internalParams }) {
|
|
278
408
|
if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) {
|
|
279
409
|
return query(stripSkipFlag(args));
|
|
280
410
|
}
|
|
@@ -283,9 +413,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
283
413
|
if (!wsCtx?.workspaceId) {
|
|
284
414
|
return query(args);
|
|
285
415
|
}
|
|
286
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
287
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
288
|
-
}
|
|
289
416
|
const dataArray = Array.isArray(args.data) ? args.data : [
|
|
290
417
|
args.data
|
|
291
418
|
];
|
|
@@ -294,15 +421,16 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
294
421
|
...stripSkipFlag(args),
|
|
295
422
|
data: Array.isArray(args.data) ? injectedData : injectedData[0]
|
|
296
423
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
424
|
+
return dispatch({
|
|
425
|
+
model,
|
|
426
|
+
query,
|
|
427
|
+
__internalParams
|
|
428
|
+
}, wsCtx, "createManyAndReturn", finalArgs);
|
|
301
429
|
},
|
|
302
430
|
// ================================================================
|
|
303
431
|
// UPDATE OPERATIONS - inject updatedBy into data + workspaceId into where
|
|
304
432
|
// ================================================================
|
|
305
|
-
async update({ model, args, query }) {
|
|
433
|
+
async update({ model, args, query, __internalParams }) {
|
|
306
434
|
if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) {
|
|
307
435
|
return query(stripSkipFlag(args));
|
|
308
436
|
}
|
|
@@ -311,9 +439,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
311
439
|
if (!wsCtx?.workspaceId) {
|
|
312
440
|
return query(args);
|
|
313
441
|
}
|
|
314
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
315
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
316
|
-
}
|
|
317
442
|
const injectedData = injectUpdateFields(args.data, wsCtx, fullConfig);
|
|
318
443
|
let injectedWhere = args.where;
|
|
319
444
|
if (fullConfig.enableUpdateWhereIsolation && !isExcludedFromReadIsolation(model, fullConfig)) {
|
|
@@ -331,12 +456,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
331
456
|
data: injectedData,
|
|
332
457
|
where: injectedWhere
|
|
333
458
|
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
459
|
+
return dispatch({
|
|
460
|
+
model,
|
|
461
|
+
query,
|
|
462
|
+
__internalParams
|
|
463
|
+
}, wsCtx, "update", finalArgs);
|
|
338
464
|
},
|
|
339
|
-
async updateMany({ model, args, query }) {
|
|
465
|
+
async updateMany({ model, args, query, __internalParams }) {
|
|
340
466
|
if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) {
|
|
341
467
|
return query(stripSkipFlag(args));
|
|
342
468
|
}
|
|
@@ -345,9 +471,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
345
471
|
if (!wsCtx?.workspaceId) {
|
|
346
472
|
return query(args);
|
|
347
473
|
}
|
|
348
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
349
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
350
|
-
}
|
|
351
474
|
const injectedData = injectUpdateFields(args.data, wsCtx, fullConfig);
|
|
352
475
|
let injectedWhere = args.where;
|
|
353
476
|
if (fullConfig.enableUpdateWhereIsolation && !isExcludedFromReadIsolation(model, fullConfig)) {
|
|
@@ -358,12 +481,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
358
481
|
data: injectedData,
|
|
359
482
|
where: injectedWhere
|
|
360
483
|
};
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
484
|
+
return dispatch({
|
|
485
|
+
model,
|
|
486
|
+
query,
|
|
487
|
+
__internalParams
|
|
488
|
+
}, wsCtx, "updateMany", finalArgs);
|
|
365
489
|
},
|
|
366
|
-
async upsert({ model, args, query }) {
|
|
490
|
+
async upsert({ model, args, query, __internalParams }) {
|
|
367
491
|
if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) {
|
|
368
492
|
return query(stripSkipFlag(args));
|
|
369
493
|
}
|
|
@@ -372,9 +496,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
372
496
|
if (!wsCtx?.workspaceId) {
|
|
373
497
|
return query(args);
|
|
374
498
|
}
|
|
375
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
376
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
377
|
-
}
|
|
378
499
|
const injectedCreate = injectCreateFields(args.create, wsCtx, fullConfig);
|
|
379
500
|
const injectedUpdate = injectUpdateFields(args.update, wsCtx, fullConfig);
|
|
380
501
|
let injectedWhere = args.where;
|
|
@@ -387,15 +508,16 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
387
508
|
update: injectedUpdate,
|
|
388
509
|
where: injectedWhere
|
|
389
510
|
};
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
511
|
+
return dispatch({
|
|
512
|
+
model,
|
|
513
|
+
query,
|
|
514
|
+
__internalParams
|
|
515
|
+
}, wsCtx, "upsert", finalArgs);
|
|
394
516
|
},
|
|
395
517
|
// ================================================================
|
|
396
518
|
// READ OPERATIONS - inject workspaceId into where clause
|
|
397
519
|
// ================================================================
|
|
398
|
-
async findMany({ model, args, query }) {
|
|
520
|
+
async findMany({ model, args, query, __internalParams }) {
|
|
399
521
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
400
522
|
return query(stripSkipFlag(args));
|
|
401
523
|
}
|
|
@@ -404,9 +526,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
404
526
|
if (!wsCtx?.workspaceId) {
|
|
405
527
|
return query(args);
|
|
406
528
|
}
|
|
407
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
408
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
409
|
-
}
|
|
410
529
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
411
530
|
if (fullConfig.debug) {
|
|
412
531
|
logger.debug(`[WorkspaceExtension] ${model}.findMany - injected workspaceId into where`, {
|
|
@@ -417,12 +536,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
417
536
|
...stripSkipFlag(args),
|
|
418
537
|
where: injectedWhere
|
|
419
538
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
539
|
+
return dispatch({
|
|
540
|
+
model,
|
|
541
|
+
query,
|
|
542
|
+
__internalParams
|
|
543
|
+
}, wsCtx, "findMany", finalArgs);
|
|
424
544
|
},
|
|
425
|
-
async findFirst({ model, args, query }) {
|
|
545
|
+
async findFirst({ model, args, query, __internalParams }) {
|
|
426
546
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
427
547
|
return query(stripSkipFlag(args));
|
|
428
548
|
}
|
|
@@ -431,9 +551,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
431
551
|
if (!wsCtx?.workspaceId) {
|
|
432
552
|
return query(args);
|
|
433
553
|
}
|
|
434
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
435
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
436
|
-
}
|
|
437
554
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
438
555
|
if (fullConfig.debug) {
|
|
439
556
|
logger.debug(`[WorkspaceExtension] ${model}.findFirst - injected workspaceId into where`, {
|
|
@@ -444,12 +561,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
444
561
|
...stripSkipFlag(args),
|
|
445
562
|
where: injectedWhere
|
|
446
563
|
};
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
564
|
+
return dispatch({
|
|
565
|
+
model,
|
|
566
|
+
query,
|
|
567
|
+
__internalParams
|
|
568
|
+
}, wsCtx, "findFirst", finalArgs);
|
|
451
569
|
},
|
|
452
|
-
async findFirstOrThrow({ model, args, query }) {
|
|
570
|
+
async findFirstOrThrow({ model, args, query, __internalParams }) {
|
|
453
571
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
454
572
|
return query(stripSkipFlag(args));
|
|
455
573
|
}
|
|
@@ -458,9 +576,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
458
576
|
if (!wsCtx?.workspaceId) {
|
|
459
577
|
return query(args);
|
|
460
578
|
}
|
|
461
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
462
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
463
|
-
}
|
|
464
579
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
465
580
|
if (fullConfig.debug) {
|
|
466
581
|
logger.debug(`[WorkspaceExtension] ${model}.findFirstOrThrow - injected workspaceId into where`, {
|
|
@@ -471,12 +586,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
471
586
|
...stripSkipFlag(args),
|
|
472
587
|
where: injectedWhere
|
|
473
588
|
};
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
589
|
+
return dispatch({
|
|
590
|
+
model,
|
|
591
|
+
query,
|
|
592
|
+
__internalParams
|
|
593
|
+
}, wsCtx, "findFirstOrThrow", finalArgs);
|
|
478
594
|
},
|
|
479
|
-
async findUnique({ model, args, query }) {
|
|
595
|
+
async findUnique({ model, args, query, __internalParams }) {
|
|
480
596
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
481
597
|
return query(stripSkipFlag(args));
|
|
482
598
|
}
|
|
@@ -485,9 +601,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
485
601
|
if (!wsCtx?.workspaceId) {
|
|
486
602
|
return query(args);
|
|
487
603
|
}
|
|
488
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
489
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
490
|
-
}
|
|
491
604
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
492
605
|
if (fullConfig.debug) {
|
|
493
606
|
logger.debug(`[WorkspaceExtension] ${model}.findUnique - injected workspaceId into where`, {
|
|
@@ -498,12 +611,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
498
611
|
...stripSkipFlag(args),
|
|
499
612
|
where: injectedWhere
|
|
500
613
|
};
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
614
|
+
return dispatch({
|
|
615
|
+
model,
|
|
616
|
+
query,
|
|
617
|
+
__internalParams
|
|
618
|
+
}, wsCtx, "findUnique", finalArgs);
|
|
505
619
|
},
|
|
506
|
-
async findUniqueOrThrow({ model, args, query }) {
|
|
620
|
+
async findUniqueOrThrow({ model, args, query, __internalParams }) {
|
|
507
621
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
508
622
|
return query(stripSkipFlag(args));
|
|
509
623
|
}
|
|
@@ -512,9 +626,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
512
626
|
if (!wsCtx?.workspaceId) {
|
|
513
627
|
return query(args);
|
|
514
628
|
}
|
|
515
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
516
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
517
|
-
}
|
|
518
629
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
519
630
|
if (fullConfig.debug) {
|
|
520
631
|
logger.debug(`[WorkspaceExtension] ${model}.findUniqueOrThrow - injected workspaceId into where`, {
|
|
@@ -525,12 +636,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
525
636
|
...stripSkipFlag(args),
|
|
526
637
|
where: injectedWhere
|
|
527
638
|
};
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
639
|
+
return dispatch({
|
|
640
|
+
model,
|
|
641
|
+
query,
|
|
642
|
+
__internalParams
|
|
643
|
+
}, wsCtx, "findUniqueOrThrow", finalArgs);
|
|
532
644
|
},
|
|
533
|
-
async count({ model, args, query }) {
|
|
645
|
+
async count({ model, args, query, __internalParams }) {
|
|
534
646
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
535
647
|
return query(stripSkipFlag(args));
|
|
536
648
|
}
|
|
@@ -539,9 +651,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
539
651
|
if (!wsCtx?.workspaceId) {
|
|
540
652
|
return query(args);
|
|
541
653
|
}
|
|
542
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
543
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
544
|
-
}
|
|
545
654
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
546
655
|
if (fullConfig.debug) {
|
|
547
656
|
logger.debug(`[WorkspaceExtension] ${model}.count - injected workspaceId into where`, {
|
|
@@ -552,12 +661,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
552
661
|
...stripSkipFlag(args),
|
|
553
662
|
where: injectedWhere
|
|
554
663
|
};
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
664
|
+
return dispatch({
|
|
665
|
+
model,
|
|
666
|
+
query,
|
|
667
|
+
__internalParams
|
|
668
|
+
}, wsCtx, "count", finalArgs);
|
|
559
669
|
},
|
|
560
|
-
async aggregate({ model, args, query }) {
|
|
670
|
+
async aggregate({ model, args, query, __internalParams }) {
|
|
561
671
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
562
672
|
return query(stripSkipFlag(args));
|
|
563
673
|
}
|
|
@@ -566,9 +676,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
566
676
|
if (!wsCtx?.workspaceId) {
|
|
567
677
|
return query(args);
|
|
568
678
|
}
|
|
569
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
570
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
571
|
-
}
|
|
572
679
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
573
680
|
if (fullConfig.debug) {
|
|
574
681
|
logger.debug(`[WorkspaceExtension] ${model}.aggregate - injected workspaceId into where`, {
|
|
@@ -579,12 +686,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
579
686
|
...stripSkipFlag(args),
|
|
580
687
|
where: injectedWhere
|
|
581
688
|
};
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
689
|
+
return dispatch({
|
|
690
|
+
model,
|
|
691
|
+
query,
|
|
692
|
+
__internalParams
|
|
693
|
+
}, wsCtx, "aggregate", finalArgs);
|
|
586
694
|
},
|
|
587
|
-
async groupBy({ model, args, query }) {
|
|
695
|
+
async groupBy({ model, args, query, __internalParams }) {
|
|
588
696
|
if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
589
697
|
return query(stripSkipFlag(args));
|
|
590
698
|
}
|
|
@@ -593,9 +701,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
593
701
|
if (!wsCtx?.workspaceId) {
|
|
594
702
|
return query(args);
|
|
595
703
|
}
|
|
596
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
597
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
598
|
-
}
|
|
599
704
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
600
705
|
if (fullConfig.debug) {
|
|
601
706
|
logger.debug(`[WorkspaceExtension] ${model}.groupBy - injected workspaceId into where`, {
|
|
@@ -606,15 +711,16 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
606
711
|
...stripSkipFlag(args),
|
|
607
712
|
where: injectedWhere
|
|
608
713
|
};
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
714
|
+
return dispatch({
|
|
715
|
+
model,
|
|
716
|
+
query,
|
|
717
|
+
__internalParams
|
|
718
|
+
}, wsCtx, "groupBy", finalArgs);
|
|
613
719
|
},
|
|
614
720
|
// ================================================================
|
|
615
721
|
// DELETE OPERATIONS - inject workspaceId into where clause
|
|
616
722
|
// ================================================================
|
|
617
|
-
async delete({ model, args, query }) {
|
|
723
|
+
async delete({ model, args, query, __internalParams }) {
|
|
618
724
|
if (!fullConfig.enableDeleteIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
619
725
|
return query(stripSkipFlag(args));
|
|
620
726
|
}
|
|
@@ -623,9 +729,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
623
729
|
if (!wsCtx?.workspaceId) {
|
|
624
730
|
return query(args);
|
|
625
731
|
}
|
|
626
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
627
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
628
|
-
}
|
|
629
732
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
630
733
|
if (fullConfig.debug) {
|
|
631
734
|
logger.debug(`[WorkspaceExtension] ${model}.delete - injected workspaceId into where`, {
|
|
@@ -636,12 +739,13 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
636
739
|
...stripSkipFlag(args),
|
|
637
740
|
where: injectedWhere
|
|
638
741
|
};
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
742
|
+
return dispatch({
|
|
743
|
+
model,
|
|
744
|
+
query,
|
|
745
|
+
__internalParams
|
|
746
|
+
}, wsCtx, "delete", finalArgs);
|
|
643
747
|
},
|
|
644
|
-
async deleteMany({ model, args, query }) {
|
|
748
|
+
async deleteMany({ model, args, query, __internalParams }) {
|
|
645
749
|
if (!fullConfig.enableDeleteIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) {
|
|
646
750
|
return query(stripSkipFlag(args));
|
|
647
751
|
}
|
|
@@ -650,9 +754,6 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
650
754
|
if (!wsCtx?.workspaceId) {
|
|
651
755
|
return query(args);
|
|
652
756
|
}
|
|
653
|
-
if (fullConfig.enableApplicationNameTagging) {
|
|
654
|
-
await maybeTagConnection(rawPrisma, wsCtx);
|
|
655
|
-
}
|
|
656
757
|
const injectedWhere = injectWhereClause(args.where, wsCtx);
|
|
657
758
|
if (fullConfig.debug) {
|
|
658
759
|
logger.debug(`[WorkspaceExtension] ${model}.deleteMany - injected workspaceId into where`, {
|
|
@@ -663,17 +764,42 @@ function addWorkspaceExtension(baseClient, config) {
|
|
|
663
764
|
...stripSkipFlag(args),
|
|
664
765
|
where: injectedWhere
|
|
665
766
|
};
|
|
666
|
-
|
|
667
|
-
|
|
767
|
+
return dispatch({
|
|
768
|
+
model,
|
|
769
|
+
query,
|
|
770
|
+
__internalParams
|
|
771
|
+
}, wsCtx, "deleteMany", finalArgs);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
if (!tagsTransactions) return withQueryHooks;
|
|
777
|
+
const wrapped = withQueryHooks;
|
|
778
|
+
return wrapped.$extends({
|
|
779
|
+
client: {
|
|
780
|
+
$transaction(input, options) {
|
|
781
|
+
const parent = this.$parent;
|
|
782
|
+
if (!parent) {
|
|
783
|
+
throw new Error("[WorkspaceExtension] $transaction wrapper could not resolve its parent client.");
|
|
784
|
+
}
|
|
785
|
+
if (Array.isArray(input)) {
|
|
786
|
+
const wsCtx = getWorkspaceContext();
|
|
787
|
+
const statement = wsCtx?.workspaceId ? buildTransactionContextStatement(wsCtx, fullConfig) : void 0;
|
|
788
|
+
if (statement) {
|
|
789
|
+
const setContext = rawPrismaForCallerTransactions.$executeRawUnsafe(statement.sql, ...statement.params);
|
|
790
|
+
return parent.$transaction([
|
|
791
|
+
setContext,
|
|
792
|
+
...input
|
|
793
|
+
], options).then((results) => Array.isArray(results) ? results.slice(1) : results);
|
|
668
794
|
}
|
|
669
|
-
return query(finalArgs);
|
|
670
795
|
}
|
|
796
|
+
return parent.$transaction(input, options);
|
|
671
797
|
}
|
|
672
798
|
}
|
|
673
799
|
});
|
|
674
800
|
}
|
|
675
801
|
__name(addWorkspaceExtension, "addWorkspaceExtension");
|
|
676
802
|
|
|
677
|
-
export { addWorkspaceExtension, defaultWorkspaceExtensionConfig, getWorkspaceContext, injectCreateFields, injectWhereWorkspaceId, maybeSetRlsGuc, maybeTagConnection, runOperationWithRlsGuc, setWorkspaceContext, withWorkspaceContext, withWorkspaceContextSync };
|
|
678
|
-
//# sourceMappingURL=chunk-
|
|
679
|
-
//# sourceMappingURL=chunk-
|
|
803
|
+
export { addWorkspaceExtension, buildTransactionContextStatement, defaultWorkspaceExtensionConfig, getCallerTransaction, getWorkspaceContext, injectCreateFields, injectWhereWorkspaceId, maybeSetRlsGuc, maybeTagConnection, resetCallerTransactionStateForTests, runOperationInCallerTransaction, runOperationWithRlsGuc, setWorkspaceContext, withWorkspaceContext, withWorkspaceContextSync };
|
|
804
|
+
//# sourceMappingURL=chunk-CYY4VIRK.js.map
|
|
805
|
+
//# sourceMappingURL=chunk-CYY4VIRK.js.map
|