@porulle/core 0.20.0 → 0.20.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.
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* org-scoped tables automatically include the actor's organizationId,
|
|
6
6
|
* and SELECT / UPDATE / DELETE against org-scoped tables constrain rows to
|
|
7
7
|
* that organization — including when the caller supplies no WHERE clause.
|
|
8
|
+
* Joins and ordering stay within the organization scope across the fluent chain.
|
|
8
9
|
*
|
|
9
10
|
* Plugin route handlers receive this scoped db via PluginContext.database.db
|
|
10
11
|
* (organization resolved per operation from AsyncLocalStorage when used from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-db.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/scoped-db.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scoped-db.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/scoped-db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;AAgE3D,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,oBAAoB,GAAG,GAAG,CA2GpF"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* org-scoped tables automatically include the actor's organizationId,
|
|
6
6
|
* and SELECT / UPDATE / DELETE against org-scoped tables constrain rows to
|
|
7
7
|
* that organization — including when the caller supplies no WHERE clause.
|
|
8
|
+
* Joins and ordering stay within the organization scope across the fluent chain.
|
|
8
9
|
*
|
|
9
10
|
* Plugin route handlers receive this scoped db via PluginContext.database.db
|
|
10
11
|
* (organization resolved per operation from AsyncLocalStorage when used from
|
|
@@ -57,7 +58,17 @@ function wrapWhereable(builder, orgEq) {
|
|
|
57
58
|
return wrapWhereable(next, orgEq);
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
if (typeof sv !== "function")
|
|
62
|
+
return sv;
|
|
63
|
+
return (...args) => {
|
|
64
|
+
const next = sv.call(st, ...args);
|
|
65
|
+
if (next !== null && (typeof next === "object" || typeof next === "function")) {
|
|
66
|
+
const where = Reflect.get(next, "where");
|
|
67
|
+
if (typeof where === "function")
|
|
68
|
+
return wrapWhereable(next, orgEq);
|
|
69
|
+
}
|
|
70
|
+
return next;
|
|
71
|
+
};
|
|
61
72
|
},
|
|
62
73
|
});
|
|
63
74
|
}
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* org-scoped tables automatically include the actor's organizationId,
|
|
6
6
|
* and SELECT / UPDATE / DELETE against org-scoped tables constrain rows to
|
|
7
7
|
* that organization — including when the caller supplies no WHERE clause.
|
|
8
|
+
* Joins and ordering stay within the organization scope across the fluent chain.
|
|
8
9
|
*
|
|
9
10
|
* Plugin route handlers receive this scoped db via PluginContext.database.db
|
|
10
11
|
* (organization resolved per operation from AsyncLocalStorage when used from
|
|
@@ -63,7 +64,16 @@ function wrapWhereable(builder: unknown, orgEq: SQL): unknown {
|
|
|
63
64
|
return wrapWhereable(next, orgEq);
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
if (typeof sv !== "function") return sv;
|
|
68
|
+
|
|
69
|
+
return (...args: unknown[]) => {
|
|
70
|
+
const next = (sv as (...a: unknown[]) => unknown).call(st, ...args);
|
|
71
|
+
if (next !== null && (typeof next === "object" || typeof next === "function")) {
|
|
72
|
+
const where = Reflect.get(next, "where");
|
|
73
|
+
if (typeof where === "function") return wrapWhereable(next, orgEq);
|
|
74
|
+
}
|
|
75
|
+
return next;
|
|
76
|
+
};
|
|
67
77
|
},
|
|
68
78
|
});
|
|
69
79
|
}
|