pipework 0.190.0 → 0.191.0
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/CHANGELOG.md +20 -0
- package/dist/REFERENCE.md +10 -131
- package/dist/auth/tenant/scoped-db.d.ts.map +1 -1
- package/dist/auth/tenant/scoped-db.js +349 -186
- package/dist/auth/tenant/scoped-db.js.map +1 -1
- package/dist/data/db/db.d.ts +3 -7
- package/dist/data/db/db.d.ts.map +1 -1
- package/dist/data/db/db.js +3 -7
- package/dist/data/db/db.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.191.0
|
|
4
|
+
|
|
5
|
+
- **Added: `$with` on a tenant-scoped connection** (#748). `db.$with('m').materialized().as(db.select(…).from(tenantTable))` followed by `db.with(m).select().from(m)` returns only the context tenant's rows, the same as an inline subquery.
|
|
6
|
+
- A CTE body must be built by the same scoped connection. The callback form `(qb) => …` gets a scoped query builder.
|
|
7
|
+
- A raw `sql` body, or a builder from `pipe.system()` or another connection, is refused with a message saying why.
|
|
8
|
+
- `db.with(…)` accepts only this connection's CTEs and scopes what follows it.
|
|
9
|
+
- **Fixed: the tenant-scoped connection let other tenants' rows through on several paths** (#748). Postgres row-level security still applied wherever it was configured, but pipework's own tenant filter was missing on these:
|
|
10
|
+
- A scoped select used as a subquery, through `inArray(…)`, `.as()`, `getSQL()` or `toSQL()`, had no tenant filter. The filter used to be added only when the query was awaited. It is now in the SQL as soon as the table is named.
|
|
11
|
+
- A joined tenant table (inner, left, right, full or cross) wasn't filtered. Its condition now goes in the join's ON clause, so a left join keeps its unmatched rows. Right and full joins also keep the tables before them to the tenant.
|
|
12
|
+
- `db.with(x)` passed straight through to the unscoped connection.
|
|
13
|
+
- `db.transaction(cb)` handed `cb` an unscoped `tx`.
|
|
14
|
+
- `$count` counted every tenant's rows.
|
|
15
|
+
- `update().from(tenantTable)` read every tenant's rows.
|
|
16
|
+
- A `union` (or other set operation) accepted an operand built elsewhere.
|
|
17
|
+
- An `onConflictDoUpdate` upsert on a unique key that excludes the tenant column could overwrite another tenant's row. Its update is now limited to the tenant's own rows, and a conflict with another tenant's row updates nothing and returns no row. `pipe.upsert` and audited upserts are covered.
|
|
18
|
+
- The no-tenant guard connection refuses a tenant table on all of the same paths.
|
|
19
|
+
- **Changed:**
|
|
20
|
+
- `insert().select()` into a tenant table is refused on a scoped connection, because the tenant column can't be set from a select.
|
|
21
|
+
- `db.query` (relational queries) is refused on a scoped connection that has tables.
|
|
22
|
+
|
|
3
23
|
## 0.190.0
|
|
4
24
|
|
|
5
25
|
- **Fixed: a NULL element in an array read back wrong** (#747). On every path (column selects, `db.execute`, `arrayAgg`) an unquoted NULL element now reads as `null`, for every array type:
|
package/dist/REFERENCE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Pipework API Reference
|
|
2
2
|
|
|
3
3
|
> Auto-generated from source JSDoc. Do not edit manually.
|
|
4
|
-
> Generated: 2026-10-
|
|
4
|
+
> Generated: 2026-10-20
|
|
5
5
|
|
|
6
6
|
## Contents
|
|
7
7
|
|
|
@@ -816,10 +816,6 @@ Acquires a transaction-scoped advisory lock. Released at commit/rollback.
|
|
|
816
816
|
|
|
817
817
|
Runs a function in a SERIALIZABLE transaction with automatic retry on serialization failures and deadlocks.
|
|
818
818
|
|
|
819
|
-
### `pipe.withTimeouts`
|
|
820
|
-
|
|
821
|
-
Sets statement_timeout and/or lock_timeout for the current transaction in one statement, then runs fn; a statement cancelled for them rejects with StatementTimeoutError or LockTimeoutError.
|
|
822
|
-
|
|
823
819
|
### `pipe.bulkSet`
|
|
824
820
|
|
|
825
821
|
Bulk UPDATE ... FROM (VALUES ...) — updates multiple rows with per-row values in a single statement.
|
|
@@ -828,10 +824,6 @@ Bulk UPDATE ... FROM (VALUES ...) — updates multiple rows with per-row values
|
|
|
828
824
|
|
|
829
825
|
Produces a typed VALUES clause for bulk operations — the base primitive for bulkSet and bulkUpsert.
|
|
830
826
|
|
|
831
|
-
### `pipe.fn`
|
|
832
|
-
|
|
833
|
-
A set-returning SQL function as a typed source for `.from()` and joins — `pipe.fn('schema.f', { args: [field.uuid()], columns: { path: field.text() } })`. Arguments are bound and cast to their declared types.
|
|
834
|
-
|
|
835
827
|
### `pipe.field`
|
|
836
828
|
|
|
837
829
|
Field builders for domain definitions — uuid(), text(), integer(), etc.
|
|
@@ -844,10 +836,6 @@ Registers a domain definition with table, validators, and factory projections. T
|
|
|
844
836
|
|
|
845
837
|
Returns the global registry of all domain definitions.
|
|
846
838
|
|
|
847
|
-
### `pipe.external`
|
|
848
|
-
|
|
849
|
-
Declares a table or view another service owns (`pipe.external(name, fields, { schema, table? })`): typed columns and every query operator, read-only, never migrated, not tenant-scoped.
|
|
850
|
-
|
|
851
839
|
### `pipe.update`
|
|
852
840
|
|
|
853
841
|
Pipework-owned UPDATE builder — the only consumer-facing way to update pipework-managed tables (Q8).
|
|
@@ -878,54 +866,12 @@ interface WindowSpec
|
|
|
878
866
|
interface ValueColumnDef
|
|
879
867
|
```
|
|
880
868
|
|
|
881
|
-
**`JsonbElements`** — A jsonb array read as its elements' text. Produced by {@link jsonbElements}.
|
|
882
|
-
|
|
883
|
-
```typescript
|
|
884
|
-
interface JsonbElements
|
|
885
|
-
```
|
|
886
|
-
|
|
887
|
-
**`ArraySource`** — Something whose elements `arrayAny` / `arrayAll` can test.
|
|
888
|
-
|
|
889
|
-
```typescript
|
|
890
|
-
type ArraySource =
|
|
891
|
-
```
|
|
892
|
-
|
|
893
|
-
**`ElementOf`** — The element type of an {@link ArraySource}.
|
|
894
|
-
|
|
895
|
-
```typescript
|
|
896
|
-
type ElementOf<S> =
|
|
897
|
-
```
|
|
898
|
-
|
|
899
|
-
**`FunctionSpec`** — Declares a SQL function's argument and result-column shapes. See {@link fn}.
|
|
900
|
-
|
|
901
|
-
```typescript
|
|
902
|
-
interface FunctionSpec<TArgs extends readonly AnyField[], TColumns extends Record<string, AnyField>>
|
|
903
|
-
```
|
|
904
|
-
|
|
905
|
-
**`FunctionSourceFields`** — The selected fields of a function source: each result column as a typed SQL expression.
|
|
906
|
-
|
|
907
|
-
```typescript
|
|
908
|
-
type FunctionSourceFields<TColumns extends Record<string, AnyField>> =
|
|
909
|
-
```
|
|
910
|
-
|
|
911
|
-
**`FunctionSource`** — A function call usable in `.from()` and joins; its result columns are properties of it.
|
|
912
|
-
|
|
913
|
-
```typescript
|
|
914
|
-
type FunctionSource<TAlias extends string, TColumns extends Record<string, AnyField>> =
|
|
915
|
-
```
|
|
916
|
-
|
|
917
869
|
**`SerializableOptions`** — Retry policy for {@link serializable}: how many attempts on a serialization failure / deadlock, and the base backoff between them.
|
|
918
870
|
|
|
919
871
|
```typescript
|
|
920
872
|
interface SerializableOptions
|
|
921
873
|
```
|
|
922
874
|
|
|
923
|
-
**`TimeoutOptions`** — Which timeouts {@link withTimeouts} sets; each a positive integer number of milliseconds.
|
|
924
|
-
|
|
925
|
-
```typescript
|
|
926
|
-
interface TimeoutOptions
|
|
927
|
-
```
|
|
928
|
-
|
|
929
875
|
**`ManagedConnection`** — A standalone pooled connection: the raw postgres.js client, its drizzle handle, and a `close()` that ends the pool.
|
|
930
876
|
|
|
931
877
|
```typescript
|
|
@@ -946,10 +892,6 @@ JSONB query operators — typed helpers for PostgreSQL JSONB containment, key ch
|
|
|
946
892
|
|
|
947
893
|
The @> containment operator — tests whether a JSONB column contains the given value.
|
|
948
894
|
|
|
949
|
-
### `jsonb.merge`
|
|
950
|
-
|
|
951
|
-
Merges an object into a JSONB column in `.set()`: `coalesce(col, '{}') || value`. Top-level keys overwrite; others are kept.
|
|
952
|
-
|
|
953
895
|
### `jsonb.containedBy`
|
|
954
896
|
|
|
955
897
|
The <@ contained-by operator — tests whether a JSONB column is contained by the given value.
|
|
@@ -1016,60 +958,6 @@ type Schema<T = unknown> = z.ZodType<T>
|
|
|
1016
958
|
type Infer<T extends Schema> = z.infer<T>
|
|
1017
959
|
```
|
|
1018
960
|
|
|
1019
|
-
**`StringSchema`** — A string validator — what check.string() returns, nameable without importing zod.
|
|
1020
|
-
|
|
1021
|
-
```typescript
|
|
1022
|
-
interface StringSchema extends z.ZodString
|
|
1023
|
-
```
|
|
1024
|
-
|
|
1025
|
-
**`NumberSchema`** — A number validator — what check.number() returns.
|
|
1026
|
-
|
|
1027
|
-
```typescript
|
|
1028
|
-
interface NumberSchema extends z.ZodNumber
|
|
1029
|
-
```
|
|
1030
|
-
|
|
1031
|
-
**`BooleanSchema`** — A boolean validator — what check.boolean() returns.
|
|
1032
|
-
|
|
1033
|
-
```typescript
|
|
1034
|
-
interface BooleanSchema extends z.ZodBoolean
|
|
1035
|
-
```
|
|
1036
|
-
|
|
1037
|
-
**`EnumSchema`** — An enum validator over string literals — what check.enum([...]) returns.
|
|
1038
|
-
|
|
1039
|
-
```typescript
|
|
1040
|
-
interface EnumSchema<V extends string = string> extends z.ZodEnum<
|
|
1041
|
-
```
|
|
1042
|
-
|
|
1043
|
-
**`LiteralSchema`** — A literal validator — what check.literal(v) returns.
|
|
1044
|
-
|
|
1045
|
-
```typescript
|
|
1046
|
-
interface LiteralSchema<V extends string | number | boolean | null = string> extends z.ZodLiteral<V>
|
|
1047
|
-
```
|
|
1048
|
-
|
|
1049
|
-
**`ArraySchema`** — An array validator — what check.array(item) returns.
|
|
1050
|
-
|
|
1051
|
-
```typescript
|
|
1052
|
-
interface ArraySchema<Item extends z.core.SomeType = z.core.SomeType> extends z.ZodArray<Item>
|
|
1053
|
-
```
|
|
1054
|
-
|
|
1055
|
-
**`OptionalSchema`** — An optional validator — what check.optional(inner) returns.
|
|
1056
|
-
|
|
1057
|
-
```typescript
|
|
1058
|
-
interface OptionalSchema<Inner extends z.core.SomeType = z.core.SomeType> extends z.ZodOptional<Inner>
|
|
1059
|
-
```
|
|
1060
|
-
|
|
1061
|
-
**`NullableSchema`** — A nullable validator — what check.nullable(inner) returns.
|
|
1062
|
-
|
|
1063
|
-
```typescript
|
|
1064
|
-
interface NullableSchema<Inner extends z.core.SomeType = z.core.SomeType> extends z.ZodNullable<Inner>
|
|
1065
|
-
```
|
|
1066
|
-
|
|
1067
|
-
**`ObjectSchema`** — An object validator whose .extend, .pick, .omit and .partial results stay ObjectSchema — what check.object({...}) returns.
|
|
1068
|
-
|
|
1069
|
-
```typescript
|
|
1070
|
-
type ObjectSchema<S extends Shape = Shape> =
|
|
1071
|
-
```
|
|
1072
|
-
|
|
1073
961
|
## temporal — Bitemporal Data
|
|
1074
962
|
|
|
1075
963
|
Temporal (bitemporal) data namespace — version history with effective date ranges.
|
|
@@ -1586,11 +1474,7 @@ interface RateLimitConfig
|
|
|
1586
1474
|
interface RateLimitWindow
|
|
1587
1475
|
```
|
|
1588
1476
|
|
|
1589
|
-
**`RateLimitClass`**
|
|
1590
|
-
|
|
1591
|
-
A named limit class: any of a per-user, per-tenant, per-address and total window, each counted on its own.
|
|
1592
|
-
Each key takes one window or an array of windows (distinct `windowSeconds`); a request is counted against
|
|
1593
|
-
all of a key's windows and refused if any is over.
|
|
1477
|
+
**`RateLimitClass`** — A named limit class: any of a per-user, per-tenant and per-address window, each counted on its own.
|
|
1594
1478
|
|
|
1595
1479
|
```typescript
|
|
1596
1480
|
interface RateLimitClass
|
|
@@ -1606,8 +1490,8 @@ interface RateLimitRefusal
|
|
|
1606
1490
|
|
|
1607
1491
|
Named limit classes, checked after auth and counted in Postgres (`pipework_rate_limit_counts`, opted in
|
|
1608
1492
|
with the blueprint's `rateLimits: {}`), so every server process on the same database shares one count.
|
|
1609
|
-
|
|
1610
|
-
refused requests don't spend the tenant's budget.
|
|
1493
|
+
Windows are counted perUser, perTenant, perAddress in turn, up to the first one over its max, so one user's
|
|
1494
|
+
refused requests don't spend the tenant's budget. A route is in `signedIn` (auth required, or optional with
|
|
1611
1495
|
a user), `public` (no auth, or optional without a user) or the class its fitting names with `.rateLimit(name)`.
|
|
1612
1496
|
|
|
1613
1497
|
```typescript
|
|
@@ -1759,20 +1643,15 @@ interface TraceTree
|
|
|
1759
1643
|
|
|
1760
1644
|
## data
|
|
1761
1645
|
|
|
1762
|
-
### `
|
|
1763
|
-
|
|
1764
|
-
A statement was cancelled by Postgres for running past the statement timeout a {@link withTimeouts} call set. `cause` is the driver error.
|
|
1765
|
-
|
|
1766
|
-
```typescript
|
|
1767
|
-
class StatementTimeoutError extends Error constructor(readonly statementTimeoutMs: number, cause: unknown)
|
|
1768
|
-
```
|
|
1769
|
-
|
|
1770
|
-
### `LockTimeoutError`
|
|
1646
|
+
### `tap`
|
|
1771
1647
|
|
|
1772
|
-
|
|
1648
|
+
Opens a standalone managed connection outside the manifold's pools — the
|
|
1649
|
+
sanctioned door for contexts where `pipe()` structurally cannot resolve:
|
|
1650
|
+
`worker_threads`, detached monitors, one-off scripts. Callers own the
|
|
1651
|
+
lifecycle: always `await conn.close()`.
|
|
1773
1652
|
|
|
1774
1653
|
```typescript
|
|
1775
|
-
|
|
1654
|
+
function tap(url: string, options?: ConnectOptions): ManagedConnection
|
|
1776
1655
|
```
|
|
1777
1656
|
|
|
1778
1657
|
## request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-db.d.ts","sourceRoot":"","sources":["../../../src/auth/tenant/scoped-db.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scoped-db.d.ts","sourceRoot":"","sources":["../../../src/auth/tenant/scoped-db.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAA;AAichD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAE9C;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE,CAE3D"}
|
|
@@ -1,236 +1,399 @@
|
|
|
1
|
-
import { eq, and, getTableColumns, getTableName } from '../../data/query/index.js';
|
|
1
|
+
import { eq, and, or, isNull, is, SQL as SQLClass, getTableColumns, getTableName } from '../../data/query/index.js';
|
|
2
2
|
import { getScopeConfig } from './scope.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const scoped = t['where'].call(t, condition);
|
|
34
|
-
return bindMethod(scoped, prop);
|
|
35
|
-
}
|
|
36
|
-
return bindMethod(t, prop);
|
|
37
|
-
}
|
|
38
|
-
const value = Reflect.get(t, prop, t);
|
|
39
|
-
if (typeof value !== 'function')
|
|
40
|
-
return value;
|
|
41
|
-
return (...args) => {
|
|
42
|
-
const result = value.apply(t, args);
|
|
43
|
-
if (result != null && typeof result === 'object' && 'where' in result) {
|
|
44
|
-
return wrap(result);
|
|
45
|
-
}
|
|
46
|
-
if (result != null && typeof result === 'object' && 'then' in result) {
|
|
47
|
-
return passthrough(result);
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
3
|
+
const GUARD = Symbol('tenant-guard');
|
|
4
|
+
const made = new WeakMap();
|
|
5
|
+
const JOINS = {
|
|
6
|
+
leftJoin: 'left', leftJoinLateral: 'left', rightJoin: 'right', innerJoin: 'inner',
|
|
7
|
+
innerJoinLateral: 'inner', fullJoin: 'full', crossJoin: 'cross', crossJoinLateral: 'cross',
|
|
8
|
+
};
|
|
9
|
+
const SET_OPERATORS = ['union', 'unionAll', 'intersect', 'intersectAll', 'except', 'exceptAll'];
|
|
10
|
+
const SELECTS = ['select', 'selectDistinct', 'selectDistinctOn'];
|
|
11
|
+
function throwTenantRequired(tableName, operation) {
|
|
12
|
+
throw new Error(`[pipework] Cannot ${operation} tenant-scoped table "${tableName}" without a tenant in context.\n\n` +
|
|
13
|
+
' This table has a .tenant() field, which means all operations require\n' +
|
|
14
|
+
' an active tenant in the request/job context.\n\n' +
|
|
15
|
+
' If this is a system-level operation that legitimately needs cross-tenant\n' +
|
|
16
|
+
' access — pre-tenant auth (e.g. resolving org membership during login),\n' +
|
|
17
|
+
' public webhook ingress, admin tooling — use pipe.system() instead. It is\n' +
|
|
18
|
+
' the explicit unscoped channel: owner-role connection, outside the request\n' +
|
|
19
|
+
' transaction, never tenant-filtered. Every query through it must be\n' +
|
|
20
|
+
' deliberately cross-tenant-safe.\n');
|
|
21
|
+
}
|
|
22
|
+
function scopedPolicy(tenantId) {
|
|
23
|
+
return {
|
|
24
|
+
owner: tenantId,
|
|
25
|
+
tenantId,
|
|
26
|
+
refuseExecute: true,
|
|
27
|
+
scope(table) {
|
|
28
|
+
const config = getScopeConfig(table);
|
|
29
|
+
if (!config)
|
|
30
|
+
return null;
|
|
31
|
+
const column = getTableColumns(table)[config.columnKey];
|
|
32
|
+
return { cond: eq(column, tenantId), column, columnKey: config.columnKey };
|
|
51
33
|
},
|
|
52
|
-
}
|
|
53
|
-
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const guardPolicy = {
|
|
37
|
+
owner: GUARD,
|
|
38
|
+
tenantId: null,
|
|
39
|
+
refuseExecute: false,
|
|
40
|
+
scope(table, operation) {
|
|
41
|
+
if (getScopeConfig(table))
|
|
42
|
+
throwTenantRequired(getTableName(table), operation);
|
|
43
|
+
return null;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
function refuse(what, why) {
|
|
47
|
+
throw new Error(`[pipework] ${what} is not allowed on this database connection: ${why}\n\n` +
|
|
48
|
+
' A tenant-scoped connection filters every tenant table its own builders read.\n' +
|
|
49
|
+
' Build the statement with this connection (select, insert, update or delete, or\n' +
|
|
50
|
+
' the callback form of $with) so the filter is part of its SQL. A raw sql fragment\n' +
|
|
51
|
+
' or a builder from another connection (pipe.system(), an unscoped db) cannot be\n' +
|
|
52
|
+
' filtered, so it is refused.\n');
|
|
53
|
+
}
|
|
54
|
+
function checkBuilder(policy, what, builder) {
|
|
55
|
+
if (builder != null && typeof builder === 'object' && made.get(builder) === policy.owner)
|
|
56
|
+
return;
|
|
57
|
+
if (is(builder, SQLClass))
|
|
58
|
+
refuse(what, 'a raw sql fragment cannot be scoped to the tenant.');
|
|
59
|
+
refuse(what, 'it was not built by this connection.');
|
|
60
|
+
}
|
|
61
|
+
function withCond(on, cond) {
|
|
62
|
+
if (typeof on === 'function')
|
|
63
|
+
return (...args) => and(on(...args), cond);
|
|
64
|
+
return on === undefined ? cond : and(on, cond);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The where clause of one statement: the user's condition plus the tenant
|
|
68
|
+
* condition of every tenant table the statement reads. It is rewritten onto the
|
|
69
|
+
* builder after every call that changes it, so the filter is in the SQL as soon
|
|
70
|
+
* as the table is named. A table a right or full join can null-extend accepts
|
|
71
|
+
* its null rows (the tenant column is NOT NULL, so null means no row there).
|
|
72
|
+
*/
|
|
73
|
+
class WhereScope {
|
|
74
|
+
target;
|
|
75
|
+
policy;
|
|
76
|
+
user;
|
|
77
|
+
entries = [];
|
|
78
|
+
position = 0;
|
|
79
|
+
widest = -1;
|
|
80
|
+
constructor(target, policy) {
|
|
81
|
+
this.target = target;
|
|
82
|
+
this.policy = policy;
|
|
83
|
+
}
|
|
84
|
+
table(table, operation, strict) {
|
|
85
|
+
this.position++;
|
|
86
|
+
const scope = this.policy.scope(table, operation);
|
|
87
|
+
if (scope)
|
|
88
|
+
this.entries.push({ cond: scope.cond, column: scope.column, position: this.position, strict, tolerant: false });
|
|
89
|
+
this.refresh();
|
|
90
|
+
}
|
|
91
|
+
join(table, type, on) {
|
|
92
|
+
this.position++;
|
|
93
|
+
const wide = type === 'right' || type === 'full';
|
|
94
|
+
const scope = this.policy.scope(table, 'join');
|
|
95
|
+
const conds = [];
|
|
96
|
+
if (scope && type !== 'cross')
|
|
97
|
+
conds.push(scope.cond);
|
|
98
|
+
// A right or full join keeps unmatched rows of the tables before it: a row of
|
|
99
|
+
// another tenant must not match, so those tables' conditions go in its ON too.
|
|
100
|
+
if (wide)
|
|
101
|
+
conds.push(...this.entries.map(e => or(e.cond, isNull(e.column))));
|
|
102
|
+
if (scope && (wide || type === 'cross')) {
|
|
103
|
+
this.entries.push({ cond: scope.cond, column: scope.column, position: this.position, strict: false, tolerant: wide });
|
|
104
|
+
}
|
|
105
|
+
if (wide)
|
|
106
|
+
this.widest = this.position;
|
|
107
|
+
return conds.length > 0 ? withCond(on, and(...conds)) : on;
|
|
108
|
+
}
|
|
109
|
+
where(user) {
|
|
110
|
+
this.user = user;
|
|
111
|
+
this.refresh();
|
|
112
|
+
}
|
|
113
|
+
refresh() {
|
|
114
|
+
if (this.user === undefined && this.entries.length === 0)
|
|
115
|
+
return;
|
|
116
|
+
const conds = this.entries.map(e => e.tolerant || (!e.strict && this.widest > e.position) ? or(e.cond, isNull(e.column)) : e.cond);
|
|
117
|
+
this.target['where'](and(this.user, ...conds));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Wraps a builder so the calls that return it return the wrapper, and `hooks` replace named methods. */
|
|
121
|
+
function wrap(target, policy, hooksFor) {
|
|
122
|
+
let hooks;
|
|
123
|
+
const self = new Proxy(target, {
|
|
54
124
|
get(t, prop) {
|
|
55
|
-
if (
|
|
56
|
-
|
|
125
|
+
if (typeof prop === 'string') {
|
|
126
|
+
hooks ??= hooksFor(self, t);
|
|
127
|
+
if (Object.hasOwn(hooks, prop))
|
|
128
|
+
return hooks[prop];
|
|
57
129
|
}
|
|
58
130
|
const value = Reflect.get(t, prop, t);
|
|
59
131
|
if (typeof value !== 'function')
|
|
60
132
|
return value;
|
|
61
133
|
return (...args) => {
|
|
62
134
|
const result = value.apply(t, args);
|
|
63
|
-
|
|
64
|
-
return passthrough(result);
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
135
|
+
return result === t ? self : result;
|
|
67
136
|
};
|
|
68
137
|
},
|
|
69
138
|
});
|
|
70
|
-
|
|
139
|
+
made.set(self, policy.owner);
|
|
140
|
+
return self;
|
|
141
|
+
}
|
|
142
|
+
function whereHook(scope, self) {
|
|
143
|
+
return (user) => {
|
|
144
|
+
scope.where(user);
|
|
145
|
+
return self;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function joinHooks(scope, self, t) {
|
|
149
|
+
const hooks = {};
|
|
150
|
+
for (const [name, type] of Object.entries(JOINS)) {
|
|
151
|
+
hooks[name] = (table, on) => {
|
|
152
|
+
const scopedOn = scope.join(table, type, on);
|
|
153
|
+
t[name](...(scopedOn === undefined ? [table] : [table, scopedOn]));
|
|
154
|
+
scope.refresh();
|
|
155
|
+
return self;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return hooks;
|
|
71
159
|
}
|
|
72
|
-
function
|
|
160
|
+
function selectBuilder(builder, table, policy) {
|
|
161
|
+
const t = builder;
|
|
162
|
+
const scope = new WhereScope(t, policy);
|
|
163
|
+
scope.table(table, 'select from', false);
|
|
164
|
+
return wrap(builder, policy, (self) => ({
|
|
165
|
+
where: whereHook(scope, self),
|
|
166
|
+
...joinHooks(scope, self, t),
|
|
167
|
+
...Object.fromEntries(SET_OPERATORS.map(name => [name, (right) => {
|
|
168
|
+
const checked = typeof right === 'function'
|
|
169
|
+
? (...ops) => {
|
|
170
|
+
const resolved = right(...ops);
|
|
171
|
+
checkBuilder(policy, `${name}()`, resolved);
|
|
172
|
+
return resolved;
|
|
173
|
+
}
|
|
174
|
+
: right;
|
|
175
|
+
if (typeof right !== 'function')
|
|
176
|
+
checkBuilder(policy, `${name}()`, right);
|
|
177
|
+
t[name](checked);
|
|
178
|
+
return self;
|
|
179
|
+
}])),
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
function selectStart(builder, policy) {
|
|
73
183
|
return new Proxy(builder, {
|
|
74
184
|
get(t, prop) {
|
|
75
|
-
if (prop === '
|
|
76
|
-
return (...
|
|
77
|
-
const result = t['set'].apply(t, args);
|
|
78
|
-
return wrapFinalBuilder(result, condition);
|
|
79
|
-
};
|
|
185
|
+
if (prop === 'from') {
|
|
186
|
+
return (table, ...rest) => selectBuilder(t['from'](table, ...rest), table, policy);
|
|
80
187
|
}
|
|
81
188
|
const value = Reflect.get(t, prop, t);
|
|
82
189
|
return typeof value === 'function' ? value.bind(t) : value;
|
|
83
190
|
},
|
|
84
191
|
});
|
|
85
192
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
' If you need cross-tenant writes, file an issue on the pipework repo.\n');
|
|
98
|
-
}
|
|
99
|
-
return { ...row, [columnKey]: tenantId };
|
|
100
|
-
};
|
|
101
|
-
const scoped = Array.isArray(values)
|
|
102
|
-
? values.map(inject)
|
|
103
|
-
: inject(values);
|
|
104
|
-
return t['values'].call(t, scoped);
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
const value = Reflect.get(t, prop, t);
|
|
108
|
-
return typeof value === 'function' ? value.bind(t) : value;
|
|
193
|
+
function updateBuilder(builder, table, policy) {
|
|
194
|
+
const t = builder;
|
|
195
|
+
const scope = new WhereScope(t, policy);
|
|
196
|
+
scope.table(table, 'update', true);
|
|
197
|
+
return wrap(builder, policy, (self) => ({
|
|
198
|
+
where: whereHook(scope, self),
|
|
199
|
+
...joinHooks(scope, self, t),
|
|
200
|
+
from: (source) => {
|
|
201
|
+
t['from'](source);
|
|
202
|
+
scope.table(source, 'update from', false);
|
|
203
|
+
return self;
|
|
109
204
|
},
|
|
110
|
-
});
|
|
205
|
+
}));
|
|
111
206
|
}
|
|
112
|
-
function
|
|
207
|
+
function updateStart(builder, table, policy) {
|
|
113
208
|
return new Proxy(builder, {
|
|
114
209
|
get(t, prop) {
|
|
115
|
-
if (prop === '
|
|
116
|
-
return (
|
|
117
|
-
const result = t['from'].call(t, table, ...rest);
|
|
118
|
-
const config = getScopeConfig(table);
|
|
119
|
-
if (!config)
|
|
120
|
-
return result;
|
|
121
|
-
const cond = buildTenantCondition(table, config.columnKey, tenantId);
|
|
122
|
-
return wrapFinalBuilder(result, cond);
|
|
123
|
-
};
|
|
210
|
+
if (prop === 'set') {
|
|
211
|
+
return (...args) => updateBuilder(t['set'](...args), table, policy);
|
|
124
212
|
}
|
|
125
213
|
const value = Reflect.get(t, prop, t);
|
|
126
214
|
return typeof value === 'function' ? value.bind(t) : value;
|
|
127
215
|
},
|
|
128
216
|
});
|
|
129
217
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
' If this is a system-level operation that legitimately needs cross-tenant\n' +
|
|
135
|
-
' access — pre-tenant auth (e.g. resolving org membership during login),\n' +
|
|
136
|
-
' public webhook ingress, admin tooling — use pipe.system() instead. It is\n' +
|
|
137
|
-
' the explicit unscoped channel: owner-role connection, outside the request\n' +
|
|
138
|
-
' transaction, never tenant-filtered. Every query through it must be\n' +
|
|
139
|
-
' deliberately cross-tenant-safe.\n');
|
|
218
|
+
function deleteBuilder(builder, table, policy) {
|
|
219
|
+
const scope = new WhereScope(builder, policy);
|
|
220
|
+
scope.table(table, 'delete', true);
|
|
221
|
+
return wrap(builder, policy, (self) => ({ where: whereHook(scope, self) }));
|
|
140
222
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
223
|
+
function insertBuilder(builder, table, policy) {
|
|
224
|
+
const t = builder;
|
|
225
|
+
const scope = policy.scope(table, 'insert');
|
|
226
|
+
// A conflict with another tenant's row must update nothing: the existing row has to be ours.
|
|
227
|
+
const finish = (result) => wrap(result, policy, (self, base) => ({
|
|
228
|
+
...(scope && {
|
|
229
|
+
onConflictDoUpdate: (config) => {
|
|
230
|
+
const { where, setWhere, ...rest } = config;
|
|
231
|
+
base['onConflictDoUpdate']({ ...rest, setWhere: and(where, setWhere, scope.cond) });
|
|
232
|
+
return self;
|
|
233
|
+
},
|
|
234
|
+
}),
|
|
235
|
+
}));
|
|
236
|
+
return wrap(builder, policy, (self) => ({
|
|
237
|
+
values: (values) => {
|
|
238
|
+
if (!scope)
|
|
239
|
+
return finish(t['values'](values));
|
|
240
|
+
const { columnKey } = scope;
|
|
241
|
+
const tenantId = policy.tenantId;
|
|
242
|
+
const inject = (row) => {
|
|
243
|
+
const existing = row[columnKey];
|
|
244
|
+
if (existing !== undefined && existing !== tenantId) {
|
|
245
|
+
throw new Error(`[pipework] Tenant-scoped insert: value has ${columnKey} "${String(existing)}" ` +
|
|
246
|
+
`but the current context tenant is "${tenantId}".\n\n` +
|
|
247
|
+
` Remove the explicit ${columnKey} from your insert values — it's set automatically.\n` +
|
|
248
|
+
' If you need cross-tenant writes, file an issue on the pipework repo.\n');
|
|
249
|
+
}
|
|
250
|
+
return { ...row, [columnKey]: tenantId };
|
|
251
|
+
};
|
|
252
|
+
const scoped = Array.isArray(values)
|
|
253
|
+
? values.map(inject)
|
|
254
|
+
: inject(values);
|
|
255
|
+
return finish(t['values'](scoped));
|
|
256
|
+
},
|
|
257
|
+
select: (source) => {
|
|
258
|
+
if (scope) {
|
|
259
|
+
refuse(`insert().select() into tenant-scoped table "${getTableName(table)}"`, `the tenant column ${scope.columnKey} cannot be set from a select.`);
|
|
151
260
|
}
|
|
152
|
-
if (
|
|
153
|
-
return (
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
261
|
+
if (typeof source === 'function') {
|
|
262
|
+
return finish(t['select']((qb) => {
|
|
263
|
+
const body = source(scopedQueryBuilder(qb, policy));
|
|
264
|
+
checkBuilder(policy, 'insert().select()', body);
|
|
265
|
+
return body;
|
|
266
|
+
}));
|
|
157
267
|
}
|
|
158
|
-
|
|
268
|
+
checkBuilder(policy, 'insert().select()', source);
|
|
269
|
+
return finish(t['select'](source));
|
|
159
270
|
},
|
|
160
|
-
|
|
271
|
+
overridingSystemValue: () => {
|
|
272
|
+
t['overridingSystemValue']();
|
|
273
|
+
return self;
|
|
274
|
+
},
|
|
275
|
+
}));
|
|
161
276
|
}
|
|
162
|
-
function
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
}
|
|
277
|
+
function scopedWith(source, policy) {
|
|
278
|
+
return (alias, selection) => {
|
|
279
|
+
const raw = source['$with'](alias, selection);
|
|
280
|
+
const build = (as) => (body) => {
|
|
281
|
+
const cte = typeof body === 'function'
|
|
282
|
+
? as((qb) => {
|
|
283
|
+
const result = body(scopedQueryBuilder(qb, policy));
|
|
284
|
+
checkBuilder(policy, '$with() body', result);
|
|
285
|
+
return result;
|
|
286
|
+
})
|
|
287
|
+
: (checkBuilder(policy, '$with() body', body), as(body));
|
|
288
|
+
made.set(cte, policy.owner);
|
|
289
|
+
return cte;
|
|
290
|
+
};
|
|
291
|
+
return {
|
|
292
|
+
as: build(raw.as),
|
|
293
|
+
materialized: () => ({ as: build(raw.materialized().as) }),
|
|
294
|
+
notMaterialized: () => ({ as: build(raw.notMaterialized().as) }),
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/** The statement starters of a connection, a `with(...)` result or a query builder. */
|
|
299
|
+
function starters(source, policy) {
|
|
300
|
+
const hooks = {};
|
|
301
|
+
for (const name of SELECTS) {
|
|
302
|
+
if (typeof source[name] !== 'function')
|
|
303
|
+
continue;
|
|
304
|
+
hooks[name] = (...args) => selectStart(source[name](...args), policy);
|
|
305
|
+
}
|
|
306
|
+
if (typeof source['insert'] === 'function') {
|
|
307
|
+
hooks['insert'] = (table) => {
|
|
308
|
+
policy.scope(table, 'insert');
|
|
309
|
+
return insertBuilder(source['insert'](table), table, policy);
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
if (typeof source['update'] === 'function') {
|
|
313
|
+
hooks['update'] = (table) => {
|
|
314
|
+
policy.scope(table, 'update');
|
|
315
|
+
return updateStart(source['update'](table), table, policy);
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
if (typeof source['delete'] === 'function') {
|
|
319
|
+
hooks['delete'] = (table) => {
|
|
320
|
+
policy.scope(table, 'delete');
|
|
321
|
+
return deleteBuilder(source['delete'](table), table, policy);
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return hooks;
|
|
325
|
+
}
|
|
326
|
+
function withHooks(source, policy) {
|
|
327
|
+
return {
|
|
328
|
+
$with: scopedWith(source, policy),
|
|
329
|
+
with: (...ctes) => {
|
|
330
|
+
for (const cte of ctes) {
|
|
331
|
+
if (cte == null || typeof cte !== 'object' || made.get(cte) !== policy.owner) {
|
|
332
|
+
refuse('with()', 'every CTE must come from $with() on this connection.');
|
|
333
|
+
}
|
|
172
334
|
}
|
|
335
|
+
return starters(source['with'](...ctes), policy);
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function scopedQueryBuilder(qb, policy) {
|
|
340
|
+
const source = qb;
|
|
341
|
+
const hooks = { ...starters(source, policy), ...withHooks(source, policy) };
|
|
342
|
+
return new Proxy(qb, {
|
|
343
|
+
get(t, prop) {
|
|
344
|
+
if (typeof prop === 'string' && Object.hasOwn(hooks, prop))
|
|
345
|
+
return hooks[prop];
|
|
173
346
|
const value = Reflect.get(t, prop, t);
|
|
174
347
|
return typeof value === 'function' ? value.bind(t) : value;
|
|
175
348
|
},
|
|
176
349
|
});
|
|
177
350
|
}
|
|
178
|
-
|
|
351
|
+
function createDb(db, policy) {
|
|
352
|
+
const source = db;
|
|
353
|
+
const hooks = {
|
|
354
|
+
...starters(source, policy),
|
|
355
|
+
...withHooks(source, policy),
|
|
356
|
+
$count: (table, filters) => {
|
|
357
|
+
const scope = policy.scope(table, 'count');
|
|
358
|
+
const combined = scope ? (filters !== undefined ? and(filters, scope.cond) : scope.cond) : filters;
|
|
359
|
+
return source['$count'](table, combined);
|
|
360
|
+
},
|
|
361
|
+
transaction: (callback, config) => source['transaction']((tx) => callback(createDb(tx, policy)), config),
|
|
362
|
+
};
|
|
363
|
+
if (policy.refuseExecute) {
|
|
364
|
+
hooks['execute'] = () => {
|
|
365
|
+
throw new Error('[pipework] execute() is not available on a tenant-scoped database connection.\n\n' +
|
|
366
|
+
' Tenant-scoped connections only support select, insert, update, and delete\n' +
|
|
367
|
+
' operations, which are automatically filtered by tenant.\n\n' +
|
|
368
|
+
' If you need to run a query that the builder cannot express, file an issue\n' +
|
|
369
|
+
' on the pipework repo describing your use case.\n');
|
|
370
|
+
};
|
|
371
|
+
}
|
|
179
372
|
return new Proxy(db, {
|
|
180
373
|
get(target, prop, receiver) {
|
|
181
|
-
if (prop === '
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return builder;
|
|
196
|
-
const cond = buildTenantCondition(table, config.columnKey, tenantId);
|
|
197
|
-
return wrapUpdateBuilder(builder, cond);
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
if (prop === 'delete') {
|
|
201
|
-
return (table) => {
|
|
202
|
-
const builder = target.delete(table);
|
|
203
|
-
const config = getScopeConfig(table);
|
|
204
|
-
if (!config)
|
|
205
|
-
return builder;
|
|
206
|
-
const cond = buildTenantCondition(table, config.columnKey, tenantId);
|
|
207
|
-
return wrapFinalBuilder(builder, cond);
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
if (prop === 'select' || prop === 'selectDistinct' || prop === 'selectDistinctOn') {
|
|
211
|
-
return (...args) => {
|
|
212
|
-
const selectBuilder = target[prop](...args);
|
|
213
|
-
return wrapSelectBuilder(selectBuilder, tenantId);
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
if (prop === 'execute') {
|
|
217
|
-
return () => {
|
|
218
|
-
throw new Error('[pipework] execute() is not available on a tenant-scoped database connection.\n\n' +
|
|
219
|
-
' Tenant-scoped connections only support select, insert, update, and delete\n' +
|
|
220
|
-
' operations, which are automatically filtered by tenant.\n\n' +
|
|
221
|
-
' If you need to run a query that the builder cannot express, file an issue\n' +
|
|
222
|
-
' on the pipework repo describing your use case.\n');
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
if (prop === '$with') {
|
|
226
|
-
return () => {
|
|
227
|
-
throw new Error('[pipework] $with() (common table expressions) is not available on a tenant-scoped database connection.\n\n' +
|
|
228
|
-
' CTEs bypass tenant scoping. If you need CTE support, file an issue\n' +
|
|
229
|
-
' on the pipework repo describing your use case.\n');
|
|
230
|
-
};
|
|
374
|
+
if (typeof prop === 'string') {
|
|
375
|
+
if (Object.hasOwn(hooks, prop))
|
|
376
|
+
return hooks[prop];
|
|
377
|
+
if (prop === 'query') {
|
|
378
|
+
const query = Reflect.get(target, prop, receiver);
|
|
379
|
+
if (query && Object.keys(query).length > 0) {
|
|
380
|
+
return new Proxy({}, {
|
|
381
|
+
get() {
|
|
382
|
+
refuse('A relational query (db.query)', 'it reads tables without the tenant filter.');
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return query;
|
|
387
|
+
}
|
|
231
388
|
}
|
|
232
389
|
return Reflect.get(target, prop, receiver);
|
|
233
390
|
},
|
|
234
391
|
});
|
|
235
392
|
}
|
|
393
|
+
export function createTenantGuardDb(db) {
|
|
394
|
+
return createDb(db, guardPolicy);
|
|
395
|
+
}
|
|
396
|
+
export function createScopedDb(db, tenantId) {
|
|
397
|
+
return createDb(db, scopedPolicy(tenantId));
|
|
398
|
+
}
|
|
236
399
|
//# source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AI,EAAE,QAAQ;YACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC;oBAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAA;gBAClD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;oBACrB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAuB,CAAA;oBACvE,IAAI,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC3C,OAAO,IAAI,KAAK,CAAC,EAAE,EAAE;4BACnB,GAAG;gCACD,MAAM,CAAC,+BAA+B,EAAE,4CAA4C,CAAC,CAAA;4BACvF,CAAC;yBACF,CAAC,CAAA;oBACJ,CAAC;oBACD,OAAO,KAAK,CAAA;gBACd,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;QAC5C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,EAAM;IACxC,OAAO,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAM,EAAE,QAAgB;IACrD,OAAO,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;AAC7C,CAAC"}
|
package/dist/data/db/db.d.ts
CHANGED
|
@@ -4,13 +4,9 @@ export declare namespace pipe {
|
|
|
4
4
|
var transaction: <T>(nameOrFn: string | ((tx: DB) => Promise<T>), maybeFnOrConfig?: ((tx: DB) => Promise<T>) | TransactionConfig, maybeConfig?: TransactionConfig) => Promise<T>;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* The unwrapped database handle
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* bypass per-table tenant filtering by design). The compiled SQL is already
|
|
11
|
-
* tenant-scoped at compile time when `ctx.tenant !== null` — the audit CTE
|
|
12
|
-
* is built against the scoped `pipe()` DB, so the user write inside the CTE
|
|
13
|
-
* picks up the tenant filter naturally; this raw handle is only the carrier.
|
|
7
|
+
* The unwrapped database handle: no tenant filter on anything it builds. Only a
|
|
8
|
+
* carrier for statements already compiled against the scoped `pipe()` db, such
|
|
9
|
+
* as the audit-write CTE, which the scoped connection cannot `.execute()`.
|
|
14
10
|
*/
|
|
15
11
|
export declare function pipeRaw(name?: string): DB;
|
|
16
12
|
/**
|
package/dist/data/db/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../src/data/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAqBvD,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,EAAE,CAQtC;yBARe,IAAI;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../src/data/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAqBvD,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,EAAE,CAQtC;yBARe,IAAI;sBAyD0B,CAAC,YACnC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,oBACzB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,iBAAiB,gBAChD,iBAAiB,KAC9B,OAAO,CAAC,CAAC,CAAC;;AAnDb;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,EAAE,CAEzC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,EAAE,CAY5C"}
|
package/dist/data/db/db.js
CHANGED
|
@@ -23,13 +23,9 @@ export function pipe(name) {
|
|
|
23
23
|
return createTenantGuardDb(db);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* The unwrapped database handle
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* bypass per-table tenant filtering by design). The compiled SQL is already
|
|
30
|
-
* tenant-scoped at compile time when `ctx.tenant !== null` — the audit CTE
|
|
31
|
-
* is built against the scoped `pipe()` DB, so the user write inside the CTE
|
|
32
|
-
* picks up the tenant filter naturally; this raw handle is only the carrier.
|
|
26
|
+
* The unwrapped database handle: no tenant filter on anything it builds. Only a
|
|
27
|
+
* carrier for statements already compiled against the scoped `pipe()` db, such
|
|
28
|
+
* as the audit-write CTE, which the scoped connection cannot `.execute()`.
|
|
33
29
|
*/
|
|
34
30
|
export function pipeRaw(name) {
|
|
35
31
|
return resolveDb(name);
|
package/dist/data/db/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../../src/data/db/db.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAEpF,SAAS,SAAS,CAAC,IAAa;IAC9B,MAAM,GAAG,GAAG,cAAc,EAAE,CAAA;IAC5B,MAAM,YAAY,GAAG,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAA;IACtE,MAAM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