@getstrata/core 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/database/query.d.ts +2 -2
- package/dist/entries/auth/guard.js +6 -8
- package/dist/entries/auth/membershipService.js +3 -0
- package/dist/entries/database.js +6 -8
- package/dist/entries/http/webErrorResponse.js +6 -8
- package/dist/entries/http.js +9 -8
- package/dist/entries/queue/createAppQueue.js +9 -8
- package/dist/entries/queue/publicQueue.js +6 -8
- package/dist/entries/queue/queueMetrics.js +9 -8
- package/dist/entries/view.js +6 -8
- package/dist/framework/public-api.d.ts +1 -0
- package/dist/index.js +90 -81
- package/package.json +1 -1
|
@@ -12,12 +12,12 @@ declare function buildWhereClause<TEntity extends object>(tableName: string, whe
|
|
|
12
12
|
clause: string;
|
|
13
13
|
params: unknown[];
|
|
14
14
|
};
|
|
15
|
-
declare function buildAdvancedWhereClause<TEntity extends object>(tableName: string, where?: QueryWhere<TEntity>, whereNodes?: readonly WhereNode<TEntity>[]): {
|
|
15
|
+
declare function buildAdvancedWhereClause<TEntity extends object>(tableName: string, where?: QueryWhere<TEntity>, whereNodes?: readonly WhereNode<TEntity>[], params?: unknown[]): {
|
|
16
16
|
clause: string;
|
|
17
17
|
params: unknown[];
|
|
18
18
|
};
|
|
19
19
|
declare function resolveSoftDeleteColumn<TEntity>(table: TableDefinition<TEntity>): string | null;
|
|
20
|
-
declare function buildQueryWhereClause<TEntity extends object>(table: TableDefinition<TEntity>, options?: Pick<QueryOptions<TEntity>, "where" | "withTrashed" | "onlyTrashed">, whereNodes?: readonly WhereNode<TEntity>[]): {
|
|
20
|
+
declare function buildQueryWhereClause<TEntity extends object>(table: TableDefinition<TEntity>, options?: Pick<QueryOptions<TEntity>, "where" | "withTrashed" | "onlyTrashed">, whereNodes?: readonly WhereNode<TEntity>[], params?: unknown[]): {
|
|
21
21
|
clause: string;
|
|
22
22
|
params: unknown[];
|
|
23
23
|
};
|
|
@@ -508,8 +508,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
508
508
|
}
|
|
509
509
|
return result;
|
|
510
510
|
}
|
|
511
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
512
|
-
const params = [];
|
|
511
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
513
512
|
const nodes = [];
|
|
514
513
|
if (Object.keys(where).length > 0) {
|
|
515
514
|
nodes.push({ kind: "and", where });
|
|
@@ -544,18 +543,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
544
543
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
545
544
|
}
|
|
546
545
|
}
|
|
547
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
548
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
546
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
547
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
549
548
|
const softDeleteClauses = [];
|
|
550
549
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
551
550
|
if (softDeleteClauses.length === 0) {
|
|
552
|
-
return { clause, params };
|
|
551
|
+
return { clause, params: whereParams };
|
|
553
552
|
}
|
|
554
553
|
const base = clause.replace(/^ WHERE /, "");
|
|
555
554
|
const scope = softDeleteClauses.join(" AND ");
|
|
556
555
|
return {
|
|
557
556
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
558
|
-
params
|
|
557
|
+
params: whereParams
|
|
559
558
|
};
|
|
560
559
|
}
|
|
561
560
|
function isQueryOrder(value) {
|
|
@@ -659,8 +658,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
659
658
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
660
659
|
const params = [];
|
|
661
660
|
const columns = buildSelectList(table, options.select, params);
|
|
662
|
-
const { clause
|
|
663
|
-
params.push(...whereParams);
|
|
661
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
664
662
|
const joins = buildJoinClause(options.joins);
|
|
665
663
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
666
664
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
|
@@ -119,6 +119,9 @@ function resolveService(dependencies, token) {
|
|
|
119
119
|
|
|
120
120
|
// ../../src/bootstrap/applicationRegistry.ts
|
|
121
121
|
var activeContext;
|
|
122
|
+
function setActiveApplicationContext(context) {
|
|
123
|
+
activeContext = context;
|
|
124
|
+
}
|
|
122
125
|
function requireActiveApplicationContext() {
|
|
123
126
|
if (!activeContext) {
|
|
124
127
|
throw new Error("The application context has not been bootstrapped.");
|
package/dist/entries/database.js
CHANGED
|
@@ -306,8 +306,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
306
306
|
}
|
|
307
307
|
return result;
|
|
308
308
|
}
|
|
309
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
310
|
-
const params = [];
|
|
309
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
311
310
|
const nodes = [];
|
|
312
311
|
if (Object.keys(where).length > 0) {
|
|
313
312
|
nodes.push({ kind: "and", where });
|
|
@@ -342,18 +341,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
342
341
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
343
342
|
}
|
|
344
343
|
}
|
|
345
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
346
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
344
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
345
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
347
346
|
const softDeleteClauses = [];
|
|
348
347
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
349
348
|
if (softDeleteClauses.length === 0) {
|
|
350
|
-
return { clause, params };
|
|
349
|
+
return { clause, params: whereParams };
|
|
351
350
|
}
|
|
352
351
|
const base = clause.replace(/^ WHERE /, "");
|
|
353
352
|
const scope = softDeleteClauses.join(" AND ");
|
|
354
353
|
return {
|
|
355
354
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
356
|
-
params
|
|
355
|
+
params: whereParams
|
|
357
356
|
};
|
|
358
357
|
}
|
|
359
358
|
function isQueryOrder(value) {
|
|
@@ -457,8 +456,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
457
456
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
458
457
|
const params = [];
|
|
459
458
|
const columns = buildSelectList(table, options.select, params);
|
|
460
|
-
const { clause
|
|
461
|
-
params.push(...whereParams);
|
|
459
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
462
460
|
const joins = buildJoinClause(options.joins);
|
|
463
461
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
464
462
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
|
@@ -530,8 +530,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
530
530
|
}
|
|
531
531
|
return result;
|
|
532
532
|
}
|
|
533
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
534
|
-
const params = [];
|
|
533
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
535
534
|
const nodes = [];
|
|
536
535
|
if (Object.keys(where).length > 0) {
|
|
537
536
|
nodes.push({ kind: "and", where });
|
|
@@ -566,18 +565,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
566
565
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
567
566
|
}
|
|
568
567
|
}
|
|
569
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
570
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
568
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
569
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
571
570
|
const softDeleteClauses = [];
|
|
572
571
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
573
572
|
if (softDeleteClauses.length === 0) {
|
|
574
|
-
return { clause, params };
|
|
573
|
+
return { clause, params: whereParams };
|
|
575
574
|
}
|
|
576
575
|
const base = clause.replace(/^ WHERE /, "");
|
|
577
576
|
const scope = softDeleteClauses.join(" AND ");
|
|
578
577
|
return {
|
|
579
578
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
580
|
-
params
|
|
579
|
+
params: whereParams
|
|
581
580
|
};
|
|
582
581
|
}
|
|
583
582
|
function isQueryOrder(value) {
|
|
@@ -681,8 +680,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
681
680
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
682
681
|
const params = [];
|
|
683
682
|
const columns = buildSelectList(table, options.select, params);
|
|
684
|
-
const { clause
|
|
685
|
-
params.push(...whereParams);
|
|
683
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
686
684
|
const joins = buildJoinClause(options.joins);
|
|
687
685
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
688
686
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
package/dist/entries/http.js
CHANGED
|
@@ -530,8 +530,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
530
530
|
}
|
|
531
531
|
return result;
|
|
532
532
|
}
|
|
533
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
534
|
-
const params = [];
|
|
533
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
535
534
|
const nodes = [];
|
|
536
535
|
if (Object.keys(where).length > 0) {
|
|
537
536
|
nodes.push({ kind: "and", where });
|
|
@@ -566,18 +565,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
566
565
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
567
566
|
}
|
|
568
567
|
}
|
|
569
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
570
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
568
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
569
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
571
570
|
const softDeleteClauses = [];
|
|
572
571
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
573
572
|
if (softDeleteClauses.length === 0) {
|
|
574
|
-
return { clause, params };
|
|
573
|
+
return { clause, params: whereParams };
|
|
575
574
|
}
|
|
576
575
|
const base = clause.replace(/^ WHERE /, "");
|
|
577
576
|
const scope = softDeleteClauses.join(" AND ");
|
|
578
577
|
return {
|
|
579
578
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
580
|
-
params
|
|
579
|
+
params: whereParams
|
|
581
580
|
};
|
|
582
581
|
}
|
|
583
582
|
function isQueryOrder(value) {
|
|
@@ -681,8 +680,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
681
680
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
682
681
|
const params = [];
|
|
683
682
|
const columns = buildSelectList(table, options.select, params);
|
|
684
|
-
const { clause
|
|
685
|
-
params.push(...whereParams);
|
|
683
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
686
684
|
const joins = buildJoinClause(options.joins);
|
|
687
685
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
688
686
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
|
@@ -3673,6 +3671,9 @@ function resolveService(dependencies, token) {
|
|
|
3673
3671
|
|
|
3674
3672
|
// ../../src/bootstrap/applicationRegistry.ts
|
|
3675
3673
|
var activeContext;
|
|
3674
|
+
function setActiveApplicationContext(context) {
|
|
3675
|
+
activeContext = context;
|
|
3676
|
+
}
|
|
3676
3677
|
function requireActiveApplicationContext() {
|
|
3677
3678
|
if (!activeContext) {
|
|
3678
3679
|
throw new Error("The application context has not been bootstrapped.");
|
|
@@ -119,6 +119,9 @@ function resolveService(dependencies, token) {
|
|
|
119
119
|
|
|
120
120
|
// ../../src/bootstrap/applicationRegistry.ts
|
|
121
121
|
var activeContext;
|
|
122
|
+
function setActiveApplicationContext(context) {
|
|
123
|
+
activeContext = context;
|
|
124
|
+
}
|
|
122
125
|
function requireActiveApplicationContext() {
|
|
123
126
|
if (!activeContext) {
|
|
124
127
|
throw new Error("The application context has not been bootstrapped.");
|
|
@@ -771,8 +774,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
771
774
|
}
|
|
772
775
|
return result;
|
|
773
776
|
}
|
|
774
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
775
|
-
const params = [];
|
|
777
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
776
778
|
const nodes = [];
|
|
777
779
|
if (Object.keys(where).length > 0) {
|
|
778
780
|
nodes.push({ kind: "and", where });
|
|
@@ -807,18 +809,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
807
809
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
808
810
|
}
|
|
809
811
|
}
|
|
810
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
811
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
812
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
813
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
812
814
|
const softDeleteClauses = [];
|
|
813
815
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
814
816
|
if (softDeleteClauses.length === 0) {
|
|
815
|
-
return { clause, params };
|
|
817
|
+
return { clause, params: whereParams };
|
|
816
818
|
}
|
|
817
819
|
const base = clause.replace(/^ WHERE /, "");
|
|
818
820
|
const scope = softDeleteClauses.join(" AND ");
|
|
819
821
|
return {
|
|
820
822
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
821
|
-
params
|
|
823
|
+
params: whereParams
|
|
822
824
|
};
|
|
823
825
|
}
|
|
824
826
|
function isQueryOrder(value) {
|
|
@@ -922,8 +924,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
922
924
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
923
925
|
const params = [];
|
|
924
926
|
const columns = buildSelectList(table, options.select, params);
|
|
925
|
-
const { clause
|
|
926
|
-
params.push(...whereParams);
|
|
927
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
927
928
|
const joins = buildJoinClause(options.joins);
|
|
928
929
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
929
930
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
|
@@ -306,8 +306,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
306
306
|
}
|
|
307
307
|
return result;
|
|
308
308
|
}
|
|
309
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
310
|
-
const params = [];
|
|
309
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
311
310
|
const nodes = [];
|
|
312
311
|
if (Object.keys(where).length > 0) {
|
|
313
312
|
nodes.push({ kind: "and", where });
|
|
@@ -342,18 +341,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
342
341
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
343
342
|
}
|
|
344
343
|
}
|
|
345
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
346
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
344
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
345
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
347
346
|
const softDeleteClauses = [];
|
|
348
347
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
349
348
|
if (softDeleteClauses.length === 0) {
|
|
350
|
-
return { clause, params };
|
|
349
|
+
return { clause, params: whereParams };
|
|
351
350
|
}
|
|
352
351
|
const base = clause.replace(/^ WHERE /, "");
|
|
353
352
|
const scope = softDeleteClauses.join(" AND ");
|
|
354
353
|
return {
|
|
355
354
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
356
|
-
params
|
|
355
|
+
params: whereParams
|
|
357
356
|
};
|
|
358
357
|
}
|
|
359
358
|
function isQueryOrder(value) {
|
|
@@ -457,8 +456,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
457
456
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
458
457
|
const params = [];
|
|
459
458
|
const columns = buildSelectList(table, options.select, params);
|
|
460
|
-
const { clause
|
|
461
|
-
params.push(...whereParams);
|
|
459
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
462
460
|
const joins = buildJoinClause(options.joins);
|
|
463
461
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
464
462
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
|
@@ -129,6 +129,9 @@ function resolveService(dependencies, token) {
|
|
|
129
129
|
|
|
130
130
|
// ../../src/bootstrap/applicationRegistry.ts
|
|
131
131
|
var activeContext;
|
|
132
|
+
function setActiveApplicationContext(context) {
|
|
133
|
+
activeContext = context;
|
|
134
|
+
}
|
|
132
135
|
function requireActiveApplicationContext() {
|
|
133
136
|
if (!activeContext) {
|
|
134
137
|
throw new Error("The application context has not been bootstrapped.");
|
|
@@ -781,8 +784,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
781
784
|
}
|
|
782
785
|
return result;
|
|
783
786
|
}
|
|
784
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
785
|
-
const params = [];
|
|
787
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
786
788
|
const nodes = [];
|
|
787
789
|
if (Object.keys(where).length > 0) {
|
|
788
790
|
nodes.push({ kind: "and", where });
|
|
@@ -817,18 +819,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
817
819
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
818
820
|
}
|
|
819
821
|
}
|
|
820
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
821
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
822
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
823
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
822
824
|
const softDeleteClauses = [];
|
|
823
825
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
824
826
|
if (softDeleteClauses.length === 0) {
|
|
825
|
-
return { clause, params };
|
|
827
|
+
return { clause, params: whereParams };
|
|
826
828
|
}
|
|
827
829
|
const base = clause.replace(/^ WHERE /, "");
|
|
828
830
|
const scope = softDeleteClauses.join(" AND ");
|
|
829
831
|
return {
|
|
830
832
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
831
|
-
params
|
|
833
|
+
params: whereParams
|
|
832
834
|
};
|
|
833
835
|
}
|
|
834
836
|
function isQueryOrder(value) {
|
|
@@ -932,8 +934,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
932
934
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
933
935
|
const params = [];
|
|
934
936
|
const columns = buildSelectList(table, options.select, params);
|
|
935
|
-
const { clause
|
|
936
|
-
params.push(...whereParams);
|
|
937
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
937
938
|
const joins = buildJoinClause(options.joins);
|
|
938
939
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
939
940
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
package/dist/entries/view.js
CHANGED
|
@@ -515,8 +515,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
515
515
|
}
|
|
516
516
|
return result;
|
|
517
517
|
}
|
|
518
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
519
|
-
const params = [];
|
|
518
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
520
519
|
const nodes = [];
|
|
521
520
|
if (Object.keys(where).length > 0) {
|
|
522
521
|
nodes.push({ kind: "and", where });
|
|
@@ -551,18 +550,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
551
550
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
552
551
|
}
|
|
553
552
|
}
|
|
554
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
555
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
553
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
554
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
556
555
|
const softDeleteClauses = [];
|
|
557
556
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
558
557
|
if (softDeleteClauses.length === 0) {
|
|
559
|
-
return { clause, params };
|
|
558
|
+
return { clause, params: whereParams };
|
|
560
559
|
}
|
|
561
560
|
const base = clause.replace(/^ WHERE /, "");
|
|
562
561
|
const scope = softDeleteClauses.join(" AND ");
|
|
563
562
|
return {
|
|
564
563
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
565
|
-
params
|
|
564
|
+
params: whereParams
|
|
566
565
|
};
|
|
567
566
|
}
|
|
568
567
|
function isQueryOrder(value) {
|
|
@@ -666,8 +665,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
666
665
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
667
666
|
const params = [];
|
|
668
667
|
const columns = buildSelectList(table, options.select, params);
|
|
669
|
-
const { clause
|
|
670
|
-
params.push(...whereParams);
|
|
668
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
671
669
|
const joins = buildJoinClause(options.joins);
|
|
672
670
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
673
671
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Stable framework surface for application modules and future package extraction.
|
|
3
3
|
* Import from `@getstrata/core` (workspace) or `src/framework/public-api`.
|
|
4
4
|
*/
|
|
5
|
+
export { resolveApplicationAuth, resolveApplicationCache, resolveApplicationConfig, resolveApplicationDependencies, resolveApplicationLogger, resolveApplicationPolicyGate, resolveApplicationQueue, setActiveApplicationContext, } from "../bootstrap/applicationRegistry.ts";
|
|
5
6
|
export type { ServiceProvider } from "../bootstrap/contracts.ts";
|
|
6
7
|
export { ConfigStore, resolveService, ServiceContainer, } from "../bootstrap/contracts.ts";
|
|
7
8
|
export type { AbilityChecker } from "../core/auth/abilityChecker.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,47 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// ../../src/core/logging/logger.ts
|
|
3
|
+
class Logger {
|
|
4
|
+
channel;
|
|
5
|
+
constructor(channel = "app") {
|
|
6
|
+
this.channel = channel;
|
|
7
|
+
}
|
|
8
|
+
write(level, message, context = {}) {
|
|
9
|
+
const entry = {
|
|
10
|
+
level,
|
|
11
|
+
channel: this.channel,
|
|
12
|
+
message,
|
|
13
|
+
timestamp: new Date().toISOString(),
|
|
14
|
+
...context
|
|
15
|
+
};
|
|
16
|
+
const line = JSON.stringify(entry);
|
|
17
|
+
if (level === "error") {
|
|
18
|
+
console.error(line);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log(line);
|
|
22
|
+
}
|
|
23
|
+
debug(message, context) {
|
|
24
|
+
this.write("debug", message, context);
|
|
25
|
+
}
|
|
26
|
+
info(message, context) {
|
|
27
|
+
this.write("info", message, context);
|
|
28
|
+
}
|
|
29
|
+
warn(message, context) {
|
|
30
|
+
this.write("warn", message, context);
|
|
31
|
+
}
|
|
32
|
+
error(message, context) {
|
|
33
|
+
this.write("error", message, context);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var appLogger = new Logger("app");
|
|
37
|
+
|
|
38
|
+
// ../../src/bootstrap/config.ts
|
|
39
|
+
var CORE_QUEUE_TOKEN = "core.queue";
|
|
40
|
+
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
41
|
+
var CORE_AUTH_TOKEN = "core.auth";
|
|
42
|
+
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
43
|
+
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
44
|
+
|
|
2
45
|
// ../../src/bootstrap/contracts.ts
|
|
3
46
|
class ServiceContainer {
|
|
4
47
|
services = new Map;
|
|
@@ -73,6 +116,39 @@ function getRequiredDependency(dependencies, key) {
|
|
|
73
116
|
function resolveService(dependencies, token) {
|
|
74
117
|
return dependencies.container.resolve(token);
|
|
75
118
|
}
|
|
119
|
+
|
|
120
|
+
// ../../src/bootstrap/applicationRegistry.ts
|
|
121
|
+
var activeContext;
|
|
122
|
+
function setActiveApplicationContext(context) {
|
|
123
|
+
activeContext = context;
|
|
124
|
+
}
|
|
125
|
+
function requireActiveApplicationContext() {
|
|
126
|
+
if (!activeContext) {
|
|
127
|
+
throw new Error("The application context has not been bootstrapped.");
|
|
128
|
+
}
|
|
129
|
+
return activeContext;
|
|
130
|
+
}
|
|
131
|
+
function resolveApplicationCache() {
|
|
132
|
+
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
133
|
+
}
|
|
134
|
+
function resolveApplicationQueue() {
|
|
135
|
+
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
136
|
+
}
|
|
137
|
+
function resolveApplicationAuth() {
|
|
138
|
+
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
139
|
+
}
|
|
140
|
+
function resolveApplicationPolicyGate() {
|
|
141
|
+
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
142
|
+
}
|
|
143
|
+
function resolveApplicationConfig() {
|
|
144
|
+
return requireActiveApplicationContext().config;
|
|
145
|
+
}
|
|
146
|
+
function resolveApplicationLogger() {
|
|
147
|
+
return appLogger;
|
|
148
|
+
}
|
|
149
|
+
function resolveApplicationDependencies() {
|
|
150
|
+
return requireActiveApplicationContext().dependencies;
|
|
151
|
+
}
|
|
76
152
|
// ../../src/core/auth/authContext.ts
|
|
77
153
|
import { AsyncLocalStorage } from "async_hooks";
|
|
78
154
|
var authContext = new AsyncLocalStorage;
|
|
@@ -508,8 +584,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
|
|
|
508
584
|
}
|
|
509
585
|
return result;
|
|
510
586
|
}
|
|
511
|
-
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
|
|
512
|
-
const params = [];
|
|
587
|
+
function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
|
|
513
588
|
const nodes = [];
|
|
514
589
|
if (Object.keys(where).length > 0) {
|
|
515
590
|
nodes.push({ kind: "and", where });
|
|
@@ -544,18 +619,18 @@ function appendSoftDeleteScope(table, options, clauses) {
|
|
|
544
619
|
clauses.push(`${qualifiedColumn} IS NULL`);
|
|
545
620
|
}
|
|
546
621
|
}
|
|
547
|
-
function buildQueryWhereClause(table, options = {}, whereNodes = []) {
|
|
548
|
-
const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
|
|
622
|
+
function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
|
|
623
|
+
const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
|
|
549
624
|
const softDeleteClauses = [];
|
|
550
625
|
appendSoftDeleteScope(table, options, softDeleteClauses);
|
|
551
626
|
if (softDeleteClauses.length === 0) {
|
|
552
|
-
return { clause, params };
|
|
627
|
+
return { clause, params: whereParams };
|
|
553
628
|
}
|
|
554
629
|
const base = clause.replace(/^ WHERE /, "");
|
|
555
630
|
const scope = softDeleteClauses.join(" AND ");
|
|
556
631
|
return {
|
|
557
632
|
clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
|
|
558
|
-
params
|
|
633
|
+
params: whereParams
|
|
559
634
|
};
|
|
560
635
|
}
|
|
561
636
|
function isQueryOrder(value) {
|
|
@@ -659,8 +734,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
|
|
|
659
734
|
function buildSelectQuery(table, options = {}, whereNodes = []) {
|
|
660
735
|
const params = [];
|
|
661
736
|
const columns = buildSelectList(table, options.select, params);
|
|
662
|
-
const { clause
|
|
663
|
-
params.push(...whereParams);
|
|
737
|
+
const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
|
|
664
738
|
const joins = buildJoinClause(options.joins);
|
|
665
739
|
const groupBy = buildGroupByClause(table.name, options.groupBy);
|
|
666
740
|
const havingClause = buildHavingClause(table.name, options.having, params);
|
|
@@ -2505,79 +2579,6 @@ async function runInTransaction(operation) {
|
|
|
2505
2579
|
return await operation(createDatabaseConnection2(transaction));
|
|
2506
2580
|
});
|
|
2507
2581
|
}
|
|
2508
|
-
// ../../src/core/logging/logger.ts
|
|
2509
|
-
class Logger {
|
|
2510
|
-
channel;
|
|
2511
|
-
constructor(channel = "app") {
|
|
2512
|
-
this.channel = channel;
|
|
2513
|
-
}
|
|
2514
|
-
write(level, message, context = {}) {
|
|
2515
|
-
const entry = {
|
|
2516
|
-
level,
|
|
2517
|
-
channel: this.channel,
|
|
2518
|
-
message,
|
|
2519
|
-
timestamp: new Date().toISOString(),
|
|
2520
|
-
...context
|
|
2521
|
-
};
|
|
2522
|
-
const line = JSON.stringify(entry);
|
|
2523
|
-
if (level === "error") {
|
|
2524
|
-
console.error(line);
|
|
2525
|
-
return;
|
|
2526
|
-
}
|
|
2527
|
-
console.log(line);
|
|
2528
|
-
}
|
|
2529
|
-
debug(message, context) {
|
|
2530
|
-
this.write("debug", message, context);
|
|
2531
|
-
}
|
|
2532
|
-
info(message, context) {
|
|
2533
|
-
this.write("info", message, context);
|
|
2534
|
-
}
|
|
2535
|
-
warn(message, context) {
|
|
2536
|
-
this.write("warn", message, context);
|
|
2537
|
-
}
|
|
2538
|
-
error(message, context) {
|
|
2539
|
-
this.write("error", message, context);
|
|
2540
|
-
}
|
|
2541
|
-
}
|
|
2542
|
-
var appLogger = new Logger("app");
|
|
2543
|
-
|
|
2544
|
-
// ../../src/bootstrap/config.ts
|
|
2545
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
2546
|
-
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
2547
|
-
var CORE_AUTH_TOKEN = "core.auth";
|
|
2548
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
2549
|
-
var DEFAULT_QUEUE_DRIVER = "sync";
|
|
2550
|
-
|
|
2551
|
-
// ../../src/bootstrap/applicationRegistry.ts
|
|
2552
|
-
var activeContext;
|
|
2553
|
-
function requireActiveApplicationContext() {
|
|
2554
|
-
if (!activeContext) {
|
|
2555
|
-
throw new Error("The application context has not been bootstrapped.");
|
|
2556
|
-
}
|
|
2557
|
-
return activeContext;
|
|
2558
|
-
}
|
|
2559
|
-
function resolveApplicationCache() {
|
|
2560
|
-
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
2561
|
-
}
|
|
2562
|
-
function resolveApplicationQueue() {
|
|
2563
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
2564
|
-
}
|
|
2565
|
-
function resolveApplicationAuth() {
|
|
2566
|
-
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
2567
|
-
}
|
|
2568
|
-
function resolveApplicationPolicyGate() {
|
|
2569
|
-
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
2570
|
-
}
|
|
2571
|
-
function resolveApplicationConfig() {
|
|
2572
|
-
return requireActiveApplicationContext().config;
|
|
2573
|
-
}
|
|
2574
|
-
function resolveApplicationLogger() {
|
|
2575
|
-
return appLogger;
|
|
2576
|
-
}
|
|
2577
|
-
function resolveApplicationDependencies() {
|
|
2578
|
-
return requireActiveApplicationContext().dependencies;
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2581
2582
|
// ../../src/core/mail/mailer.ts
|
|
2582
2583
|
function resolveSmtpConfig() {
|
|
2583
2584
|
const host = process.env.MAIL_HOST?.trim();
|
|
@@ -5366,6 +5367,7 @@ export {
|
|
|
5366
5367
|
toPaginatedResourceCollection,
|
|
5367
5368
|
stringRule,
|
|
5368
5369
|
storageFacade as storage,
|
|
5370
|
+
setActiveApplicationContext,
|
|
5369
5371
|
serializeDate,
|
|
5370
5372
|
securedBindRouteModelByKey,
|
|
5371
5373
|
securedBindRouteModel,
|
|
@@ -5379,6 +5381,13 @@ export {
|
|
|
5379
5381
|
resolveWebLayoutData,
|
|
5380
5382
|
resolveService,
|
|
5381
5383
|
resolveDatabaseDriver,
|
|
5384
|
+
resolveApplicationQueue,
|
|
5385
|
+
resolveApplicationPolicyGate,
|
|
5386
|
+
resolveApplicationLogger,
|
|
5387
|
+
resolveApplicationDependencies,
|
|
5388
|
+
resolveApplicationConfig,
|
|
5389
|
+
resolveApplicationCache,
|
|
5390
|
+
resolveApplicationAuth,
|
|
5382
5391
|
required,
|
|
5383
5392
|
registerShutdownHandler,
|
|
5384
5393
|
registerModelRepository,
|