@getstrata/core 0.7.5 → 1.0.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 +4 -0
- package/README.md +1 -1
- package/dist/entries/auth/scimAuthMiddleware.js +2 -2
- package/dist/entries/auth/sessionCookie.js +2 -2
- package/dist/entries/auth/sessionGuard.js +2 -2
- package/dist/entries/database/model.js +4 -4
- package/dist/entries/database/query.js +2 -2
- package/dist/entries/database/repositoryQuery.js +20 -20
- package/dist/entries/database/schema.js +2 -2
- package/dist/entries/openapi/generator.js +4 -4
- package/dist/entries/tenant/tenantDatabaseScope.js +2 -2
- package/dist/index.js +51 -51
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ import type { Migration } from "@getstrata/core/database/migrations/types";
|
|
|
65
65
|
Package name: **`@getstrata/core`** (npm org [`@getstrata`](https://www.npmjs.com/org/getstrata)).
|
|
66
66
|
|
|
67
67
|
1. Add `NPM_TOKEN` to GitHub repository secrets.
|
|
68
|
-
2. Tag a release: `git tag
|
|
68
|
+
2. Tag a release: `git tag v1.0.0 && git push origin v1.0.0`
|
|
69
69
|
3. [Release workflow](../../.github/workflows/release.yml) builds and runs `npm publish --access public`.
|
|
70
70
|
|
|
71
71
|
See [docs/PACKAGING.md](../../docs/PACKAGING.md).
|
|
@@ -136,8 +136,8 @@ async function runWithTenantDatabase(tenant, callback) {
|
|
|
136
136
|
return await runWithTenant(tenant, callback);
|
|
137
137
|
}
|
|
138
138
|
if (hasActiveDatabaseConnection()) {
|
|
139
|
-
const
|
|
140
|
-
await applyTenantContextToTransaction(
|
|
139
|
+
const activeConnection = getActiveDatabaseConnection(getDefaultDatabasePool());
|
|
140
|
+
await applyTenantContextToTransaction(activeConnection, tenant.id);
|
|
141
141
|
return await runWithTenant(tenant, callback);
|
|
142
142
|
}
|
|
143
143
|
return await getDefaultDatabasePool().begin(async (transaction) => {
|
|
@@ -127,8 +127,8 @@ function readSession(request) {
|
|
|
127
127
|
}
|
|
128
128
|
const parts = cookieValue.split(".");
|
|
129
129
|
if (parts.length === 4) {
|
|
130
|
-
const [
|
|
131
|
-
return readSignedSession(String(
|
|
130
|
+
const [userIdRaw, issuedAtRaw, ttlRaw, cookieSignature] = parts;
|
|
131
|
+
return readSignedSession(String(userIdRaw), String(issuedAtRaw), cookieSignature, Number.parseInt(String(ttlRaw), 10), true);
|
|
132
132
|
}
|
|
133
133
|
if (parts.length !== 3) {
|
|
134
134
|
return null;
|
|
@@ -194,8 +194,8 @@ function readSession(request) {
|
|
|
194
194
|
}
|
|
195
195
|
const parts = cookieValue.split(".");
|
|
196
196
|
if (parts.length === 4) {
|
|
197
|
-
const [
|
|
198
|
-
return readSignedSession(String(
|
|
197
|
+
const [userIdRaw, issuedAtRaw, ttlRaw, cookieSignature] = parts;
|
|
198
|
+
return readSignedSession(String(userIdRaw), String(issuedAtRaw), cookieSignature, Number.parseInt(String(ttlRaw), 10), true);
|
|
199
199
|
}
|
|
200
200
|
if (parts.length !== 3) {
|
|
201
201
|
return null;
|
|
@@ -298,8 +298,8 @@ function buildSelectList(table, select, params = []) {
|
|
|
298
298
|
}
|
|
299
299
|
return select.map((item) => {
|
|
300
300
|
if (item.kind === "column") {
|
|
301
|
-
const
|
|
302
|
-
return item.as ? `${
|
|
301
|
+
const column = qualifyColumn(item.table, item.column);
|
|
302
|
+
return item.as ? `${column} AS ${quoteIdentifier(item.as)}` : column;
|
|
303
303
|
}
|
|
304
304
|
if (item.kind === "literalText") {
|
|
305
305
|
return `${currentSqlDialect().castToText(pushParam(params, item.value))} AS ${quoteIdentifier(item.as)}`;
|
|
@@ -1919,8 +1919,8 @@ class Model {
|
|
|
1919
1919
|
}
|
|
1920
1920
|
if (updating) {
|
|
1921
1921
|
const changes = applyTimestampsOnUpdate(table.columns, applyCasts(this.attributes, casts, "dehydrate"), timestamps);
|
|
1922
|
-
const
|
|
1923
|
-
this.attributes = ModelClass.hydrateAttributes(
|
|
1922
|
+
const record = await this.repository.updateByIdOrThrow(this.id, changes);
|
|
1923
|
+
this.attributes = ModelClass.hydrateAttributes(record);
|
|
1924
1924
|
await runObservers(this, "updated");
|
|
1925
1925
|
await runObservers(this, "saved");
|
|
1926
1926
|
return this;
|
|
@@ -275,8 +275,8 @@ function buildSelectList(table, select, params = []) {
|
|
|
275
275
|
}
|
|
276
276
|
return select.map((item) => {
|
|
277
277
|
if (item.kind === "column") {
|
|
278
|
-
const
|
|
279
|
-
return item.as ? `${
|
|
278
|
+
const column = qualifyColumn(item.table, item.column);
|
|
279
|
+
return item.as ? `${column} AS ${quoteIdentifier(item.as)}` : column;
|
|
280
280
|
}
|
|
281
281
|
if (item.kind === "literalText") {
|
|
282
282
|
return `${currentSqlDialect().castToText(pushParam(params, item.value))} AS ${quoteIdentifier(item.as)}`;
|
|
@@ -275,8 +275,8 @@ function buildSelectList(table, select, params = []) {
|
|
|
275
275
|
}
|
|
276
276
|
return select.map((item) => {
|
|
277
277
|
if (item.kind === "column") {
|
|
278
|
-
const
|
|
279
|
-
return item.as ? `${
|
|
278
|
+
const column = qualifyColumn(item.table, item.column);
|
|
279
|
+
return item.as ? `${column} AS ${quoteIdentifier(item.as)}` : column;
|
|
280
280
|
}
|
|
281
281
|
if (item.kind === "literalText") {
|
|
282
282
|
return `${currentSqlDialect().castToText(pushParam(params, item.value))} AS ${quoteIdentifier(item.as)}`;
|
|
@@ -925,50 +925,50 @@ class RepositoryQuery {
|
|
|
925
925
|
}
|
|
926
926
|
async hydrateEagerLoad(rows, result, load) {
|
|
927
927
|
if (load.kind === "hasMany") {
|
|
928
|
-
const
|
|
929
|
-
const
|
|
928
|
+
const relation = load.relation;
|
|
929
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadHasManyForParents(rows, relation, load.options);
|
|
930
930
|
for (const row of result) {
|
|
931
|
-
row[load.as] = getByRelationKey(
|
|
931
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]) ?? [];
|
|
932
932
|
}
|
|
933
933
|
return;
|
|
934
934
|
}
|
|
935
935
|
if (load.kind === "morphMany") {
|
|
936
|
-
const
|
|
937
|
-
const
|
|
936
|
+
const relation = load.relation;
|
|
937
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadMorphManyForParents(rows, relation, load.options);
|
|
938
938
|
for (const row of result) {
|
|
939
|
-
row[load.as] = getByRelationKey(
|
|
939
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]) ?? [];
|
|
940
940
|
}
|
|
941
941
|
return;
|
|
942
942
|
}
|
|
943
943
|
if (load.kind === "morphOne") {
|
|
944
|
-
const
|
|
945
|
-
const
|
|
944
|
+
const relation = load.relation;
|
|
945
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadMorphOneForParents(rows, relation, load.options);
|
|
946
946
|
for (const row of result) {
|
|
947
|
-
row[load.as] = getByRelationKey(
|
|
947
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]);
|
|
948
948
|
}
|
|
949
949
|
return;
|
|
950
950
|
}
|
|
951
951
|
if (load.kind === "hasManyThrough") {
|
|
952
|
-
const
|
|
953
|
-
const
|
|
952
|
+
const relation = load.relation;
|
|
953
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadHasManyThroughForParents(rows, relation, load.options);
|
|
954
954
|
for (const row of result) {
|
|
955
|
-
row[load.as] = getByRelationKey(
|
|
955
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]) ?? [];
|
|
956
956
|
}
|
|
957
957
|
return;
|
|
958
958
|
}
|
|
959
959
|
if (load.kind === "belongsToMany") {
|
|
960
|
-
const
|
|
961
|
-
const
|
|
960
|
+
const relation = load.relation;
|
|
961
|
+
const grouped = await this.repository.loadBelongsToManyForParents(rows, relation, load.repository, load.options);
|
|
962
962
|
for (const row of result) {
|
|
963
|
-
row[load.as] = getByRelationKey(
|
|
963
|
+
row[load.as] = getByRelationKey(grouped, row[relation.parentKey]) ?? [];
|
|
964
964
|
}
|
|
965
965
|
return;
|
|
966
966
|
}
|
|
967
967
|
if (load.kind === "morphTo") {
|
|
968
|
-
const
|
|
969
|
-
const
|
|
968
|
+
const relation = load.relation;
|
|
969
|
+
const grouped = await this.repository.loadMorphToForChildren(rows, relation, load.morphRepositories ?? new Map, load.options);
|
|
970
970
|
for (const row of result) {
|
|
971
|
-
row[load.as] = getByRelationKey(
|
|
971
|
+
row[load.as] = getByRelationKey(grouped, row[relation.morphIdKey]);
|
|
972
972
|
}
|
|
973
973
|
return;
|
|
974
974
|
}
|
|
@@ -542,8 +542,8 @@ function buildSelectList(table, select, params = []) {
|
|
|
542
542
|
}
|
|
543
543
|
return select.map((item) => {
|
|
544
544
|
if (item.kind === "column") {
|
|
545
|
-
const
|
|
546
|
-
return item.as ? `${
|
|
545
|
+
const column = qualifyColumn(item.table, item.column);
|
|
546
|
+
return item.as ? `${column} AS ${quoteIdentifier(item.as)}` : column;
|
|
547
547
|
}
|
|
548
548
|
if (item.kind === "literalText") {
|
|
549
549
|
return `${currentSqlDialect().castToText(pushParam(params, item.value))} AS ${quoteIdentifier(item.as)}`;
|
|
@@ -254,13 +254,13 @@ function renderOpenApiDocument(spec) {
|
|
|
254
254
|
return `${JSON.stringify(spec, null, 2)}
|
|
255
255
|
`;
|
|
256
256
|
}
|
|
257
|
-
function toMethodName(method, path,
|
|
258
|
-
const relativePath = path.startsWith(
|
|
257
|
+
function toMethodName(method, path, apiPrefix) {
|
|
258
|
+
const relativePath = path.startsWith(apiPrefix) ? path.slice(apiPrefix.length) || "/" : path;
|
|
259
259
|
const segments = relativePath.replace(/\{|\}/g, "").split("/").filter(Boolean).flatMap((segment) => segment.split("-")).map((segment) => segment.replace(/[^a-zA-Z0-9]/g, "")).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1));
|
|
260
260
|
return `${method.toLowerCase()}${segments.join("")}`;
|
|
261
261
|
}
|
|
262
|
-
function toRequestPath(path,
|
|
263
|
-
return path.startsWith(
|
|
262
|
+
function toRequestPath(path, apiPrefix) {
|
|
263
|
+
return path.startsWith(apiPrefix) ? path.slice(apiPrefix.length) || "/" : path;
|
|
264
264
|
}
|
|
265
265
|
function renderTypeScriptSdk(spec, prefix = apiPrefix()) {
|
|
266
266
|
const lines = [
|
|
@@ -64,8 +64,8 @@ async function runWithTenantDatabase(tenant, callback) {
|
|
|
64
64
|
return await runWithTenant(tenant, callback);
|
|
65
65
|
}
|
|
66
66
|
if (hasActiveDatabaseConnection()) {
|
|
67
|
-
const
|
|
68
|
-
await applyTenantContextToTransaction(
|
|
67
|
+
const activeConnection = getActiveDatabaseConnection(getDefaultDatabasePool());
|
|
68
|
+
await applyTenantContextToTransaction(activeConnection, tenant.id);
|
|
69
69
|
return await runWithTenant(tenant, callback);
|
|
70
70
|
}
|
|
71
71
|
return await getDefaultDatabasePool().begin(async (transaction) => {
|
package/dist/index.js
CHANGED
|
@@ -326,11 +326,11 @@ function abilityCatalog() {
|
|
|
326
326
|
|
|
327
327
|
// ../../src/core/auth/guard.ts
|
|
328
328
|
function devHeaderAbilities(role) {
|
|
329
|
-
const
|
|
329
|
+
const catalog = abilityCatalog();
|
|
330
330
|
if (role === "admin") {
|
|
331
|
-
return [...
|
|
331
|
+
return [...catalog.admin];
|
|
332
332
|
}
|
|
333
|
-
return [...
|
|
333
|
+
return [...catalog.member];
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
class GuestGuard {
|
|
@@ -1144,7 +1144,7 @@ function resolveScimTenantFromToken(token) {
|
|
|
1144
1144
|
function resolveRepositoryConnection() {
|
|
1145
1145
|
return getBoundDatabaseConnection() ?? getDefaultDatabaseQuery();
|
|
1146
1146
|
}
|
|
1147
|
-
var repositoryConnection = new Proxy(function
|
|
1147
|
+
var repositoryConnection = new Proxy(function repositoryConnection() {}, {
|
|
1148
1148
|
apply(_target, _thisArg, args) {
|
|
1149
1149
|
return resolveRepositoryConnection()(...args);
|
|
1150
1150
|
},
|
|
@@ -1202,8 +1202,8 @@ async function runWithTenantDatabase(tenant, callback) {
|
|
|
1202
1202
|
return await runWithTenant(tenant, callback);
|
|
1203
1203
|
}
|
|
1204
1204
|
if (hasActiveDatabaseConnection()) {
|
|
1205
|
-
const
|
|
1206
|
-
await applyTenantContextToTransaction(
|
|
1205
|
+
const activeConnection = getActiveDatabaseConnection(getDefaultDatabasePool());
|
|
1206
|
+
await applyTenantContextToTransaction(activeConnection, tenant.id);
|
|
1207
1207
|
return await runWithTenant(tenant, callback);
|
|
1208
1208
|
}
|
|
1209
1209
|
return await getDefaultDatabasePool().begin(async (transaction) => {
|
|
@@ -2316,8 +2316,8 @@ function buildSelectList(table, select, params = []) {
|
|
|
2316
2316
|
}
|
|
2317
2317
|
return select.map((item) => {
|
|
2318
2318
|
if (item.kind === "column") {
|
|
2319
|
-
const
|
|
2320
|
-
return item.as ? `${
|
|
2319
|
+
const column = qualifyColumn(item.table, item.column);
|
|
2320
|
+
return item.as ? `${column} AS ${quoteIdentifier(item.as)}` : column;
|
|
2321
2321
|
}
|
|
2322
2322
|
if (item.kind === "literalText") {
|
|
2323
2323
|
return `${currentSqlDialect().castToText(pushParam(params, item.value))} AS ${quoteIdentifier(item.as)}`;
|
|
@@ -2966,50 +2966,50 @@ class RepositoryQuery {
|
|
|
2966
2966
|
}
|
|
2967
2967
|
async hydrateEagerLoad(rows, result, load) {
|
|
2968
2968
|
if (load.kind === "hasMany") {
|
|
2969
|
-
const
|
|
2970
|
-
const
|
|
2969
|
+
const relation = load.relation;
|
|
2970
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadHasManyForParents(rows, relation, load.options);
|
|
2971
2971
|
for (const row of result) {
|
|
2972
|
-
row[load.as] = getByRelationKey(
|
|
2972
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]) ?? [];
|
|
2973
2973
|
}
|
|
2974
2974
|
return;
|
|
2975
2975
|
}
|
|
2976
2976
|
if (load.kind === "morphMany") {
|
|
2977
|
-
const
|
|
2978
|
-
const
|
|
2977
|
+
const relation = load.relation;
|
|
2978
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadMorphManyForParents(rows, relation, load.options);
|
|
2979
2979
|
for (const row of result) {
|
|
2980
|
-
row[load.as] = getByRelationKey(
|
|
2980
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]) ?? [];
|
|
2981
2981
|
}
|
|
2982
2982
|
return;
|
|
2983
2983
|
}
|
|
2984
2984
|
if (load.kind === "morphOne") {
|
|
2985
|
-
const
|
|
2986
|
-
const
|
|
2985
|
+
const relation = load.relation;
|
|
2986
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadMorphOneForParents(rows, relation, load.options);
|
|
2987
2987
|
for (const row of result) {
|
|
2988
|
-
row[load.as] = getByRelationKey(
|
|
2988
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]);
|
|
2989
2989
|
}
|
|
2990
2990
|
return;
|
|
2991
2991
|
}
|
|
2992
2992
|
if (load.kind === "hasManyThrough") {
|
|
2993
|
-
const
|
|
2994
|
-
const
|
|
2993
|
+
const relation = load.relation;
|
|
2994
|
+
const grouped = await load.repository.withConnection(this.repository.getConnection()).loadHasManyThroughForParents(rows, relation, load.options);
|
|
2995
2995
|
for (const row of result) {
|
|
2996
|
-
row[load.as] = getByRelationKey(
|
|
2996
|
+
row[load.as] = getByRelationKey(grouped, row[relation.localKey]) ?? [];
|
|
2997
2997
|
}
|
|
2998
2998
|
return;
|
|
2999
2999
|
}
|
|
3000
3000
|
if (load.kind === "belongsToMany") {
|
|
3001
|
-
const
|
|
3002
|
-
const
|
|
3001
|
+
const relation = load.relation;
|
|
3002
|
+
const grouped = await this.repository.loadBelongsToManyForParents(rows, relation, load.repository, load.options);
|
|
3003
3003
|
for (const row of result) {
|
|
3004
|
-
row[load.as] = getByRelationKey(
|
|
3004
|
+
row[load.as] = getByRelationKey(grouped, row[relation.parentKey]) ?? [];
|
|
3005
3005
|
}
|
|
3006
3006
|
return;
|
|
3007
3007
|
}
|
|
3008
3008
|
if (load.kind === "morphTo") {
|
|
3009
|
-
const
|
|
3010
|
-
const
|
|
3009
|
+
const relation = load.relation;
|
|
3010
|
+
const grouped = await this.repository.loadMorphToForChildren(rows, relation, load.morphRepositories ?? new Map, load.options);
|
|
3011
3011
|
for (const row of result) {
|
|
3012
|
-
row[load.as] = getByRelationKey(
|
|
3012
|
+
row[load.as] = getByRelationKey(grouped, row[relation.morphIdKey]);
|
|
3013
3013
|
}
|
|
3014
3014
|
return;
|
|
3015
3015
|
}
|
|
@@ -4946,8 +4946,8 @@ class Model {
|
|
|
4946
4946
|
}
|
|
4947
4947
|
if (updating) {
|
|
4948
4948
|
const changes = applyTimestampsOnUpdate(table.columns, applyCasts(this.attributes, casts, "dehydrate"), timestamps);
|
|
4949
|
-
const
|
|
4950
|
-
this.attributes = ModelClass.hydrateAttributes(
|
|
4949
|
+
const record = await this.repository.updateByIdOrThrow(this.id, changes);
|
|
4950
|
+
this.attributes = ModelClass.hydrateAttributes(record);
|
|
4951
4951
|
await runObservers(this, "updated");
|
|
4952
4952
|
await runObservers(this, "saved");
|
|
4953
4953
|
return this;
|
|
@@ -6920,9 +6920,9 @@ class FormRequest {
|
|
|
6920
6920
|
}
|
|
6921
6921
|
}
|
|
6922
6922
|
// ../../src/core/http/authMiddleware.ts
|
|
6923
|
-
function createAuthMiddleware(
|
|
6923
|
+
function createAuthMiddleware(auth) {
|
|
6924
6924
|
return async (request, next) => {
|
|
6925
|
-
const user = await
|
|
6925
|
+
const user = await auth.resolve(request);
|
|
6926
6926
|
return await runWithAuthUser(user, async () => {
|
|
6927
6927
|
const response = await next();
|
|
6928
6928
|
if (user) {
|
|
@@ -6939,9 +6939,9 @@ function createAuthMiddleware(auth2) {
|
|
|
6939
6939
|
};
|
|
6940
6940
|
}
|
|
6941
6941
|
// ../../src/core/http/authorizeMiddleware.ts
|
|
6942
|
-
function createAuthorizeMiddleware(gate,
|
|
6942
|
+
function createAuthorizeMiddleware(gate, auth, resource, action) {
|
|
6943
6943
|
return async (request, next) => {
|
|
6944
|
-
const user = currentAuthUser() ?? await
|
|
6944
|
+
const user = currentAuthUser() ?? await auth.resolve(request);
|
|
6945
6945
|
if (!gate.allows(resource, action, user)) {
|
|
6946
6946
|
const error = new ForbiddenError;
|
|
6947
6947
|
return Response.json({ error: error.message }, { status: error.status });
|
|
@@ -7115,9 +7115,9 @@ async function parseMultipartUpload(request, fieldName = "file") {
|
|
|
7115
7115
|
};
|
|
7116
7116
|
}
|
|
7117
7117
|
// ../../src/core/http/requireAuthMiddleware.ts
|
|
7118
|
-
function createRequireAuthMiddleware(
|
|
7118
|
+
function createRequireAuthMiddleware(auth) {
|
|
7119
7119
|
return async (request, next) => {
|
|
7120
|
-
if (!await
|
|
7120
|
+
if (!await auth.check(request)) {
|
|
7121
7121
|
const error = new UnauthorizedError;
|
|
7122
7122
|
return Response.json({ error: error.message }, { status: error.status });
|
|
7123
7123
|
}
|
|
@@ -7513,8 +7513,8 @@ function securedBindRouteModel(param, resolver, authorization, handler) {
|
|
|
7513
7513
|
const id = parsePositiveIntParam(String(request.params[param]), String(param));
|
|
7514
7514
|
const model = requireResolvedModel(await resolver(id, request));
|
|
7515
7515
|
const gate = resolveApplicationPolicyGate();
|
|
7516
|
-
const
|
|
7517
|
-
const user = currentAuthUser() ?? await
|
|
7516
|
+
const auth = resolveApplicationAuth();
|
|
7517
|
+
const user = currentAuthUser() ?? await auth.resolve(request);
|
|
7518
7518
|
gate.authorize(authorization.resource, authorization.action, user, model);
|
|
7519
7519
|
if (isEtagEnabled() && isMutatingPolicyAction(authorization.action)) {
|
|
7520
7520
|
assertIfMatch(request, etagFromResource(model), {
|
|
@@ -7536,8 +7536,8 @@ function securedBindRouteModelByKey(param, resolver, authorization, handler) {
|
|
|
7536
7536
|
}
|
|
7537
7537
|
const model = requireResolvedModel(await resolver(key, request));
|
|
7538
7538
|
const gate = resolveApplicationPolicyGate();
|
|
7539
|
-
const
|
|
7540
|
-
const user = currentAuthUser() ?? await
|
|
7539
|
+
const auth = resolveApplicationAuth();
|
|
7540
|
+
const user = currentAuthUser() ?? await auth.resolve(request);
|
|
7541
7541
|
gate.authorize(authorization.resource, authorization.action, user, model);
|
|
7542
7542
|
if (isEtagEnabled() && isMutatingPolicyAction(authorization.action)) {
|
|
7543
7543
|
assertIfMatch(request, etagFromResource(model), {
|
|
@@ -7859,9 +7859,9 @@ function createIntendedUrlCookieFromRequest(request) {
|
|
|
7859
7859
|
}
|
|
7860
7860
|
|
|
7861
7861
|
// ../../src/core/http/requireWebAuthMiddleware.ts
|
|
7862
|
-
function createRequireWebAuthMiddleware(
|
|
7862
|
+
function createRequireWebAuthMiddleware(auth) {
|
|
7863
7863
|
return async (request, next) => {
|
|
7864
|
-
const user = await
|
|
7864
|
+
const user = await auth.resolve(request);
|
|
7865
7865
|
if (user) {
|
|
7866
7866
|
return await runWithAuthUser(user, () => next());
|
|
7867
7867
|
}
|
|
@@ -8290,15 +8290,15 @@ function buildMarkdownMailMessage(input) {
|
|
|
8290
8290
|
html: rendered.html
|
|
8291
8291
|
};
|
|
8292
8292
|
}
|
|
8293
|
-
async function sendMarkdownMail(
|
|
8294
|
-
await
|
|
8293
|
+
async function sendMarkdownMail(mailer, input) {
|
|
8294
|
+
await mailer.send(buildMarkdownMailMessage(input));
|
|
8295
8295
|
}
|
|
8296
8296
|
// ../../src/core/notifications/dispatcher.ts
|
|
8297
8297
|
class NotificationDispatcher {
|
|
8298
8298
|
mailer;
|
|
8299
8299
|
databaseStore;
|
|
8300
|
-
constructor(
|
|
8301
|
-
this.mailer =
|
|
8300
|
+
constructor(mailer, databaseStore = null) {
|
|
8301
|
+
this.mailer = mailer;
|
|
8302
8302
|
this.databaseStore = databaseStore;
|
|
8303
8303
|
}
|
|
8304
8304
|
async send(notifiable, notification) {
|
|
@@ -8350,8 +8350,8 @@ class NotificationDispatcher {
|
|
|
8350
8350
|
});
|
|
8351
8351
|
}
|
|
8352
8352
|
}
|
|
8353
|
-
function createNotificationDispatcher(
|
|
8354
|
-
return new NotificationDispatcher(
|
|
8353
|
+
function createNotificationDispatcher(mailer, databaseStore) {
|
|
8354
|
+
return new NotificationDispatcher(mailer, databaseStore ?? null);
|
|
8355
8355
|
}
|
|
8356
8356
|
// ../../src/core/notifications/notification.ts
|
|
8357
8357
|
class Notification {
|
|
@@ -8481,9 +8481,9 @@ function readSharedJobRegistry() {
|
|
|
8481
8481
|
if (globalRegistry) {
|
|
8482
8482
|
return globalRegistry;
|
|
8483
8483
|
}
|
|
8484
|
-
const
|
|
8485
|
-
globalThis[JOB_REGISTRY_KEY] =
|
|
8486
|
-
return
|
|
8484
|
+
const registry = new JobRegistry;
|
|
8485
|
+
globalThis[JOB_REGISTRY_KEY] = registry;
|
|
8486
|
+
return registry;
|
|
8487
8487
|
}
|
|
8488
8488
|
var jobRegistry = readSharedJobRegistry();
|
|
8489
8489
|
|
|
@@ -9298,9 +9298,9 @@ class EtaViewEngine {
|
|
|
9298
9298
|
autoTrim: false
|
|
9299
9299
|
});
|
|
9300
9300
|
this.resolveLayoutData = resolveLayoutData;
|
|
9301
|
-
const
|
|
9301
|
+
const readFile = this.eta.readFile?.bind(this.eta);
|
|
9302
9302
|
this.eta.readFile = (path) => {
|
|
9303
|
-
const source =
|
|
9303
|
+
const source = readFile ? readFile(path) : "";
|
|
9304
9304
|
assertEtaHtmlSource(relative(viewsDirectory, path) || path, source);
|
|
9305
9305
|
return source;
|
|
9306
9306
|
};
|