@elsikora/nestjs-crud-automator 4.4.0 → 4.5.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/README.md +26 -0
- package/dist/cjs/class/api/function/transaction/registry.class.d.ts +24 -2
- package/dist/cjs/class/api/function/transaction/registry.class.js +114 -2
- package/dist/cjs/class/api/function/transaction/registry.class.js.map +1 -1
- package/dist/cjs/class/api/function/transaction/runtime.class.d.ts +2 -0
- package/dist/cjs/class/api/function/transaction/runtime.class.js +21 -11
- package/dist/cjs/class/api/function/transaction/runtime.class.js.map +1 -1
- package/dist/cjs/class/api/function/transaction/scope.class.d.ts +2 -0
- package/dist/cjs/class/api/function/transaction/scope.class.js +1 -0
- package/dist/cjs/class/api/function/transaction/scope.class.js.map +1 -1
- package/dist/cjs/constant/api-function-transaction-observation.constant.d.ts +5 -0
- package/dist/cjs/constant/api-function-transaction-observation.constant.js +13 -0
- package/dist/cjs/constant/api-function-transaction-observation.constant.js.map +1 -0
- package/dist/cjs/constant/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interface/class/api/function/transaction/index.d.ts +1 -0
- package/dist/cjs/interface/class/api/function/transaction/observation/index.d.ts +4 -0
- package/dist/cjs/interface/class/api/function/transaction/observation/measurement.interface.d.ts +6 -0
- package/dist/cjs/interface/class/api/function/transaction/observation/options.interface.d.ts +6 -0
- package/dist/cjs/interface/class/api/function/transaction/observation/selector.interface.d.ts +7 -0
- package/dist/cjs/interface/class/api/function/transaction/observation/snapshot.interface.d.ts +7 -0
- package/dist/cjs/utility/api/function-transaction.utility.js +4 -1
- package/dist/cjs/utility/api/function-transaction.utility.js.map +1 -1
- package/dist/esm/class/api/function/transaction/registry.class.d.ts +24 -2
- package/dist/esm/class/api/function/transaction/registry.class.js +114 -2
- package/dist/esm/class/api/function/transaction/registry.class.js.map +1 -1
- package/dist/esm/class/api/function/transaction/runtime.class.d.ts +2 -0
- package/dist/esm/class/api/function/transaction/runtime.class.js +21 -11
- package/dist/esm/class/api/function/transaction/runtime.class.js.map +1 -1
- package/dist/esm/class/api/function/transaction/scope.class.d.ts +2 -0
- package/dist/esm/class/api/function/transaction/scope.class.js +1 -0
- package/dist/esm/class/api/function/transaction/scope.class.js.map +1 -1
- package/dist/esm/constant/api-function-transaction-observation.constant.d.ts +5 -0
- package/dist/esm/constant/api-function-transaction-observation.constant.js +11 -0
- package/dist/esm/constant/api-function-transaction-observation.constant.js.map +1 -0
- package/dist/esm/constant/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interface/class/api/function/transaction/index.d.ts +1 -0
- package/dist/esm/interface/class/api/function/transaction/observation/index.d.ts +4 -0
- package/dist/esm/interface/class/api/function/transaction/observation/measurement.interface.d.ts +6 -0
- package/dist/esm/interface/class/api/function/transaction/observation/options.interface.d.ts +6 -0
- package/dist/esm/interface/class/api/function/transaction/observation/selector.interface.d.ts +7 -0
- package/dist/esm/interface/class/api/function/transaction/observation/snapshot.interface.d.ts +7 -0
- package/dist/esm/utility/api/function-transaction.utility.js +4 -1
- package/dist/esm/utility/api/function-transaction.utility.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -652,6 +652,32 @@ await ApiFunctionTransactionScope.runWithDataSource(dataSource, { name: "registe
|
|
|
652
652
|
|
|
653
653
|
The callback receives the exact manager owned by the named scope. Decorated operations join it automatically; use the argument for transaction-bound raw repository or migration work. The scope name is trimmed and must be non-empty. `runWithEntityManager()` is join-only: it accepts only the manager already bound to an active Automator transaction and never opens a second transaction.
|
|
654
654
|
|
|
655
|
+
Named scopes can also select bounded execution measurements without adding ordinary function subscribers:
|
|
656
|
+
|
|
657
|
+
```typescript
|
|
658
|
+
await ApiFunctionTransactionScope.runWithDataSource(
|
|
659
|
+
dataSource,
|
|
660
|
+
{
|
|
661
|
+
name: "register-user",
|
|
662
|
+
observation: {
|
|
663
|
+
selectors: [{ entity: UserEntity, functionType: EApiFunctionType.CREATE, methodName: "create" }],
|
|
664
|
+
onSettled(snapshot) {
|
|
665
|
+
captureTransactionObservation(snapshot);
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
async () => await userService.create(properties),
|
|
670
|
+
);
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
`captureTransactionObservation` is an application-provided bounded synchronous capture function, not a package API. Selectors match the exact entity constructor, native function type (or `EApiFunctionTransactionTraceType.STEP`) and method name. The package copies the selectors and callback before query-runner work, rejects duplicate selectors and invalid configuration, and allows at most 32 selectors with nonblank method names of at most 256 characters. An empty selector list produces only the owner settlement. `runWithEntityManager()` continues to join the existing owner and cannot replace observation.
|
|
674
|
+
|
|
675
|
+
Each owner reserves at most 256 selected invocations at their start, including overlapping work. The detached, frozen snapshot contains `measurements` with only `selectorIndex`, fractional `durationMs` and native execution `status`, plus the existing transaction `outcome` and `droppedCount`. The index refers to the configured selector order. Omitted intervals include capacity overflow, incomplete work at settlement and unavailable/invalid clock samples. Late completions are ignored. No transaction IDs, arguments, results, entities, managers or raw errors enter this projection; ordinary transaction event shapes and pending-event rules stay unchanged.
|
|
676
|
+
|
|
677
|
+
Duration covers the actual native execution callback, including STEP context construction or CUSTOM subscriber work, and excludes its own transaction preflight and event bookkeeping. Nested intervals are inclusive: do not sum them or label them as isolated method-body, SQL or lock-wait time. A successful execution remains `SUCCEEDED` if its owner later rolls back or has an unknown commit outcome. Disabled and unmatched observation performs no clock sampling; rejected preflight or failed owner startup creates no fabricated duration.
|
|
678
|
+
|
|
679
|
+
`onSettled` runs once after the best-effort release attempt, context exit and terminal lifecycle hooks have finished or failed. It does not run when owner startup fails. Its synchronous throws and accidental Promise/thenable rejections are contained; returned asynchronous work is never awaited and cannot replace the original result or error. Synchronous callback work still adds latency, so capture into a bounded application buffer and let its existing transport own delivery. STEP remains trace-only and does not become an ordinary subscriber event. The public observation types and `API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT` are available from the package root.
|
|
680
|
+
|
|
655
681
|
Function subscribers can react once after the outer commit or rollback. The observed service must use `@ApiServiceObservable()`, and the subscriber must be registered as a Nest provider:
|
|
656
682
|
|
|
657
683
|
```typescript
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EApiFunctionTransactionOutcome, EApiFunctionTransactionEventStatus } from '../../../../enum/decorator/api';
|
|
2
|
+
import { IApiFunctionTransaction, IApiFunctionTransactionObservationOptions, IApiFunctionTransactionObservationSelector } from '../../../../interface/class/api/function';
|
|
2
3
|
import { IApiSubscriberFunctionTransactionContext } from '../../../../interface/class/api/subscriber/function';
|
|
3
4
|
import { TApiFunctionTransactionEvent, TApiFunctionTransactionOwner, TApiFunctionTransactionTraceType } from '../../../../type/class/api/function/transaction';
|
|
4
5
|
export declare class ApiFunctionTransactionRegistry {
|
|
5
6
|
private readonly EVENTS;
|
|
6
7
|
private eventSnapshot?;
|
|
8
|
+
private isObservationClosed;
|
|
9
|
+
private readonly MEASUREMENTS;
|
|
10
|
+
private readonly OBSERVATION?;
|
|
11
|
+
private observationDroppedCount;
|
|
7
12
|
private readonly TRANSACTION;
|
|
8
|
-
constructor(id: string, owner: TApiFunctionTransactionOwner);
|
|
13
|
+
constructor(id: string, owner: TApiFunctionTransactionOwner, observation?: Readonly<IApiFunctionTransactionObservationOptions>);
|
|
9
14
|
beginEvent(options: {
|
|
10
15
|
action?: string;
|
|
11
16
|
entityName: string;
|
|
@@ -13,11 +18,28 @@ export declare class ApiFunctionTransactionRegistry {
|
|
|
13
18
|
isSubscriberObservable: boolean;
|
|
14
19
|
methodName: string;
|
|
15
20
|
}): number;
|
|
21
|
+
/**
|
|
22
|
+
* Reserves one selected native callback interval without changing lifecycle events.
|
|
23
|
+
* @param {Readonly<IApiFunctionTransactionObservationSelector>} selector Reached native invocation.
|
|
24
|
+
* @returns {number | undefined} Reserved measurement index, or no admitted measurement.
|
|
25
|
+
*/
|
|
26
|
+
beginObservation(selector: Readonly<IApiFunctionTransactionObservationSelector>): number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Samples completion before native event bookkeeping; late completion is ignored.
|
|
29
|
+
* @param {number | undefined} index Reserved measurement index.
|
|
30
|
+
* @param {EApiFunctionTransactionEventStatus} status Native callback status.
|
|
31
|
+
*/
|
|
32
|
+
completeObservation(index: number | undefined, status: EApiFunctionTransactionEventStatus): void;
|
|
16
33
|
createContext(matchedEvents: ReadonlyArray<TApiFunctionTransactionEvent>): IApiSubscriberFunctionTransactionContext;
|
|
17
34
|
failEvent(sequence: number, error: unknown): void;
|
|
18
35
|
getEvents(): ReadonlyArray<TApiFunctionTransactionEvent>;
|
|
19
36
|
getObservableEvents(): ReadonlyArray<TApiFunctionTransactionEvent>;
|
|
20
37
|
getTransaction(): Readonly<IApiFunctionTransaction>;
|
|
38
|
+
/**
|
|
39
|
+
* Publishes the bounded projection once after the owning transaction lifecycle settles.
|
|
40
|
+
* @param {EApiFunctionTransactionOutcome} outcome Settled database outcome.
|
|
41
|
+
*/
|
|
42
|
+
settleObservation(outcome: EApiFunctionTransactionOutcome): void;
|
|
21
43
|
succeedEvent(sequence: number): void;
|
|
22
44
|
private getPendingEvent;
|
|
23
45
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var apiFunctionTransactionObservation_constant = require('../../../../constant/api-function-transaction-observation.constant.js');
|
|
3
4
|
require('../../../../enum/decorator/api/action.enum.js');
|
|
4
5
|
require('../../../../enum/decorator/api/authentication-type.enum.js');
|
|
5
6
|
require('../../../../enum/decorator/api/controller/get-list/query/filter/missing-behavior.enum.js');
|
|
@@ -18,7 +19,7 @@ require('../../../../enum/decorator/api/function/transaction/mode.enum.js');
|
|
|
18
19
|
require('../../../../enum/decorator/api/function/transaction/outcome.enum.js');
|
|
19
20
|
require('../../../../enum/decorator/api/function/transaction/owner-kind.enum.js');
|
|
20
21
|
var traceType_enum = require('../../../../enum/decorator/api/function/transaction/trace-type.enum.js');
|
|
21
|
-
require('../../../../enum/decorator/api/function/type.enum.js');
|
|
22
|
+
var type_enum = require('../../../../enum/decorator/api/function/type.enum.js');
|
|
22
23
|
require('../../../../enum/decorator/api/function/update-persistence-mode.enum.js');
|
|
23
24
|
require('../../../../enum/decorator/api/on-type.enum.js');
|
|
24
25
|
require('../../../../enum/decorator/api/property/data-type.enum.js');
|
|
@@ -34,8 +35,38 @@ var exception_utility = require('../../../../utility/error/exception.utility.js'
|
|
|
34
35
|
class ApiFunctionTransactionRegistry {
|
|
35
36
|
EVENTS = [];
|
|
36
37
|
eventSnapshot;
|
|
38
|
+
isObservationClosed = false;
|
|
39
|
+
MEASUREMENTS = [];
|
|
40
|
+
OBSERVATION;
|
|
41
|
+
observationDroppedCount = 0;
|
|
37
42
|
TRANSACTION;
|
|
38
|
-
constructor(id, owner) {
|
|
43
|
+
constructor(id, owner, observation) {
|
|
44
|
+
if (observation !== undefined) {
|
|
45
|
+
const onSettled = observation?.onSettled;
|
|
46
|
+
const selectors = observation?.selectors;
|
|
47
|
+
if (typeof onSettled !== "function" || !Array.isArray(selectors) || selectors.length > apiFunctionTransactionObservation_constant.API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT.MAXIMUM_SELECTORS) {
|
|
48
|
+
throw exception_utility.ErrorException("Invalid transaction observation options");
|
|
49
|
+
}
|
|
50
|
+
const copiedSelectors = [];
|
|
51
|
+
for (const selector of selectors) {
|
|
52
|
+
if (typeof selector !== "object" || selector === null || !("entity" in selector) || !("functionType" in selector) || !("methodName" in selector)) {
|
|
53
|
+
throw exception_utility.ErrorException("Invalid transaction observation selector");
|
|
54
|
+
}
|
|
55
|
+
const entity = selector.entity;
|
|
56
|
+
const functionType = selector.functionType;
|
|
57
|
+
const methodName = selector.methodName;
|
|
58
|
+
if (typeof entity !== "function" ||
|
|
59
|
+
![...Object.values(type_enum.EApiFunctionType), traceType_enum.EApiFunctionTransactionTraceType.STEP].includes(functionType) ||
|
|
60
|
+
typeof methodName !== "string" ||
|
|
61
|
+
methodName.trim().length === 0 ||
|
|
62
|
+
methodName.length > apiFunctionTransactionObservation_constant.API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT.MAXIMUM_METHOD_NAME_LENGTH ||
|
|
63
|
+
copiedSelectors.some((candidate) => candidate.entity === entity && candidate.functionType === functionType && candidate.methodName === methodName)) {
|
|
64
|
+
throw exception_utility.ErrorException("Invalid transaction observation selector");
|
|
65
|
+
}
|
|
66
|
+
copiedSelectors.push(Object.freeze({ entity: entity, functionType: functionType, methodName }));
|
|
67
|
+
}
|
|
68
|
+
this.OBSERVATION = Object.freeze({ onSettled, selectors: Object.freeze(copiedSelectors) });
|
|
69
|
+
}
|
|
39
70
|
this.TRANSACTION = Object.freeze({
|
|
40
71
|
id,
|
|
41
72
|
owner: Object.freeze({ ...owner }),
|
|
@@ -52,6 +83,58 @@ class ApiFunctionTransactionRegistry {
|
|
|
52
83
|
});
|
|
53
84
|
return sequence;
|
|
54
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Reserves one selected native callback interval without changing lifecycle events.
|
|
88
|
+
* @param {Readonly<IApiFunctionTransactionObservationSelector>} selector Reached native invocation.
|
|
89
|
+
* @returns {number | undefined} Reserved measurement index, or no admitted measurement.
|
|
90
|
+
*/
|
|
91
|
+
beginObservation(selector) {
|
|
92
|
+
if (!this.OBSERVATION || this.isObservationClosed)
|
|
93
|
+
return undefined;
|
|
94
|
+
const selectorIndex = this.OBSERVATION.selectors.findIndex((candidate) => candidate.entity === selector.entity && candidate.functionType === selector.functionType && candidate.methodName === selector.methodName);
|
|
95
|
+
if (selectorIndex === -1)
|
|
96
|
+
return undefined;
|
|
97
|
+
if (this.MEASUREMENTS.length >= apiFunctionTransactionObservation_constant.API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT.MAXIMUM_MEASUREMENTS) {
|
|
98
|
+
this.observationDroppedCount = Math.min(Number.MAX_SAFE_INTEGER, this.observationDroppedCount + 1);
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const index = this.MEASUREMENTS.length;
|
|
102
|
+
const measurement = { selectorIndex };
|
|
103
|
+
this.MEASUREMENTS.push(measurement);
|
|
104
|
+
try {
|
|
105
|
+
const startedAtMs = performance.now();
|
|
106
|
+
if (Number.isFinite(startedAtMs))
|
|
107
|
+
measurement.startedAtMs = startedAtMs;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// A missing clock sample drops only this diagnostic interval.
|
|
111
|
+
}
|
|
112
|
+
return index;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Samples completion before native event bookkeeping; late completion is ignored.
|
|
116
|
+
* @param {number | undefined} index Reserved measurement index.
|
|
117
|
+
* @param {EApiFunctionTransactionEventStatus} status Native callback status.
|
|
118
|
+
*/
|
|
119
|
+
completeObservation(index, status) {
|
|
120
|
+
if (index === undefined || this.isObservationClosed)
|
|
121
|
+
return;
|
|
122
|
+
const measurement = this.MEASUREMENTS[index];
|
|
123
|
+
if (!measurement || measurement.status !== undefined)
|
|
124
|
+
return;
|
|
125
|
+
measurement.status = status;
|
|
126
|
+
try {
|
|
127
|
+
const completedAtMs = performance.now();
|
|
128
|
+
if (measurement.startedAtMs !== undefined && Number.isFinite(completedAtMs)) {
|
|
129
|
+
const durationMs = completedAtMs - measurement.startedAtMs;
|
|
130
|
+
if (Number.isFinite(durationMs) && durationMs >= 0)
|
|
131
|
+
measurement.durationMs = durationMs;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// Capture failures cannot alter a native result or error.
|
|
136
|
+
}
|
|
137
|
+
}
|
|
55
138
|
createContext(matchedEvents) {
|
|
56
139
|
const events = this.getEvents();
|
|
57
140
|
return Object.freeze({
|
|
@@ -101,6 +184,35 @@ class ApiFunctionTransactionRegistry {
|
|
|
101
184
|
getTransaction() {
|
|
102
185
|
return this.TRANSACTION;
|
|
103
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Publishes the bounded projection once after the owning transaction lifecycle settles.
|
|
189
|
+
* @param {EApiFunctionTransactionOutcome} outcome Settled database outcome.
|
|
190
|
+
*/
|
|
191
|
+
settleObservation(outcome) {
|
|
192
|
+
if (!this.OBSERVATION || this.isObservationClosed)
|
|
193
|
+
return;
|
|
194
|
+
this.isObservationClosed = true;
|
|
195
|
+
try {
|
|
196
|
+
const measurements = [];
|
|
197
|
+
for (const measurement of this.MEASUREMENTS) {
|
|
198
|
+
if (measurement.durationMs === undefined || measurement.status === undefined) {
|
|
199
|
+
this.observationDroppedCount = Math.min(Number.MAX_SAFE_INTEGER, this.observationDroppedCount + 1);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
measurements.push(Object.freeze({ durationMs: measurement.durationMs, selectorIndex: measurement.selectorIndex, status: measurement.status }));
|
|
203
|
+
}
|
|
204
|
+
this.MEASUREMENTS.length = 0;
|
|
205
|
+
const onSettled = this.OBSERVATION.onSettled;
|
|
206
|
+
const delivery = onSettled(Object.freeze({ droppedCount: this.observationDroppedCount, measurements: Object.freeze(measurements), outcome }));
|
|
207
|
+
if (delivery !== undefined)
|
|
208
|
+
void Promise.resolve(delivery).catch(() => {
|
|
209
|
+
// An accidental asynchronous observer rejection remains diagnostic-only.
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
// Diagnostic callbacks never participate in transaction error handling.
|
|
214
|
+
}
|
|
215
|
+
}
|
|
104
216
|
succeedEvent(sequence) {
|
|
105
217
|
const event = this.getPendingEvent(sequence);
|
|
106
218
|
event.status = eventStatus_enum.EApiFunctionTransactionEventStatus.SUCCEEDED;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.class.js","sources":["../../../../../../../src/class/api/function/transaction/registry.class.ts"],"sourcesContent":[null],"names":["ErrorException","
|
|
1
|
+
{"version":3,"file":"registry.class.js","sources":["../../../../../../../src/class/api/function/transaction/registry.class.ts"],"sourcesContent":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AAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YAEtJ,IAAI,QAAQ,KAAK,SAAS;gBACzB,KAAK,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,MAAK;;AAE1C,gBAAA,CAAC,CAAC;QACJ;AAAE,QAAA,MAAM;;QAER;IACD;AAEO,IAAA,YAAY,CAAC,QAAgB,EAAA;QACnC,MAAM,KAAK,GAAiC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;AAE1E,QAAA,KAAK,CAAC,MAAM,GAAGC,mDAAkC,CAAC,SAAS;IAC5D;AAEQ,IAAA,eAAe,CAAC,QAAgB,EAAA;QACvC,MAAM,KAAK,GAA6C,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;AAEjF,QAAA,IAAI,KAAK,EAAE,QAAQ,KAAK,QAAQ,EAAE;AACjC,YAAA,MAAMH,gCAAc,CAAC,CAAA,kBAAA,EAAqB,QAAQ,CAAA,kBAAA,CAAoB,CAAC;QACxE;AAEA,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE;AACjB,YAAA,MAAMA,gCAAc,CAAC,CAAA,kBAAA,EAAqB,QAAQ,CAAA,sBAAA,CAAwB,CAAC;QAC5E;AAEA,QAAA,OAAO,KAAK;IACb;AACA;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { IApiFunctionTransactionObservationOptions } from '../../../../interface/class/api/function';
|
|
1
2
|
import { TApiFunctionTransactionOwner } from '../../../../type/class/api/function';
|
|
2
3
|
import { DataSource, EntityManager } from 'typeorm';
|
|
3
4
|
export declare class ApiFunctionTransactionRuntime {
|
|
4
5
|
static execute<R>(options: {
|
|
5
6
|
callback: (entityManager: EntityManager) => Promise<R>;
|
|
6
7
|
dataSource: DataSource;
|
|
8
|
+
observation?: Readonly<IApiFunctionTransactionObservationOptions>;
|
|
7
9
|
owner: TApiFunctionTransactionOwner;
|
|
8
10
|
}): Promise<R>;
|
|
9
11
|
private static releaseBestEffort;
|
|
@@ -19,7 +19,7 @@ require('../../../../enum/decorator/api/function/subscriber-transaction-expectat
|
|
|
19
19
|
require('../../../../enum/decorator/api/function/transaction/event-status.enum.js');
|
|
20
20
|
var failureStage_enum = require('../../../../enum/decorator/api/function/transaction/failure-stage.enum.js');
|
|
21
21
|
require('../../../../enum/decorator/api/function/transaction/mode.enum.js');
|
|
22
|
-
require('../../../../enum/decorator/api/function/transaction/outcome.enum.js');
|
|
22
|
+
var outcome_enum = require('../../../../enum/decorator/api/function/transaction/outcome.enum.js');
|
|
23
23
|
require('../../../../enum/decorator/api/function/transaction/owner-kind.enum.js');
|
|
24
24
|
require('../../../../enum/decorator/api/function/transaction/trace-type.enum.js');
|
|
25
25
|
require('../../../../enum/decorator/api/function/type.enum.js');
|
|
@@ -43,6 +43,7 @@ class ApiFunctionTransactionRuntime {
|
|
|
43
43
|
if (contextStorage_class.ApiFunctionContextStorage.getTransactionRegistry()) {
|
|
44
44
|
throw exception_utility.ErrorException("Cannot open an owning transaction inside an active Automator transaction");
|
|
45
45
|
}
|
|
46
|
+
const registry = new registry_class.ApiFunctionTransactionRegistry(node_crypto.randomUUID(), options.owner, options.observation);
|
|
46
47
|
const queryRunner = options.dataSource.createQueryRunner();
|
|
47
48
|
try {
|
|
48
49
|
await queryRunner.connect();
|
|
@@ -52,7 +53,6 @@ class ApiFunctionTransactionRuntime {
|
|
|
52
53
|
await ApiFunctionTransactionRuntime.releaseBestEffort(queryRunner);
|
|
53
54
|
throw error;
|
|
54
55
|
}
|
|
55
|
-
const registry = new registry_class.ApiFunctionTransactionRegistry(node_crypto.randomUUID(), options.owner);
|
|
56
56
|
const result = {};
|
|
57
57
|
let commitCleanupFailure;
|
|
58
58
|
let commitError;
|
|
@@ -81,17 +81,27 @@ class ApiFunctionTransactionRuntime {
|
|
|
81
81
|
}
|
|
82
82
|
await ApiFunctionTransactionRuntime.releaseBestEffort(queryRunner);
|
|
83
83
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
|
|
84
|
+
let outcome = outcome_enum.EApiFunctionTransactionOutcome.COMMITTED;
|
|
85
|
+
if (hasCommitError || rollbackFailure)
|
|
86
|
+
outcome = outcome_enum.EApiFunctionTransactionOutcome.UNKNOWN;
|
|
87
|
+
else if (hasOperationError)
|
|
88
|
+
outcome = outcome_enum.EApiFunctionTransactionOutcome.ROLLED_BACK;
|
|
89
|
+
try {
|
|
90
|
+
if (hasOperationError) {
|
|
91
|
+
return await lifecycle_class.ApiFunctionTransactionLifecycle.executeAfterRollback(registry, operationError, rollbackFailure);
|
|
92
|
+
}
|
|
93
|
+
if (hasCommitError) {
|
|
94
|
+
return await lifecycle_class.ApiFunctionTransactionLifecycle.executeCommitUnknown(registry, commitError, commitCleanupFailure);
|
|
95
|
+
}
|
|
96
|
+
if (!("value" in result)) {
|
|
97
|
+
throw exception_utility.ErrorException("Automator transaction completed without a committed result");
|
|
98
|
+
}
|
|
99
|
+
await lifecycle_class.ApiFunctionTransactionLifecycle.executeAfterCommit(registry);
|
|
100
|
+
return result.value;
|
|
89
101
|
}
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
finally {
|
|
103
|
+
registry.settleObservation(outcome);
|
|
92
104
|
}
|
|
93
|
-
await lifecycle_class.ApiFunctionTransactionLifecycle.executeAfterCommit(registry);
|
|
94
|
-
return result.value;
|
|
95
105
|
}
|
|
96
106
|
static async releaseBestEffort(queryRunner) {
|
|
97
107
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.class.js","sources":["../../../../../../../src/class/api/function/transaction/runtime.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","ApiFunctionContextStorage","ErrorException","ApiFunctionTransactionRegistry","randomUUID","ApiFunctionTransactionLifecycle","FormatErrorEvidenceForLog","EApiFunctionTransactionFailureStage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,iBAAiB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,+BAA+B,CAAC;MAEpF,6BAA6B,CAAA;AAClC,IAAA,aAAa,OAAO,CAAI,
|
|
1
|
+
{"version":3,"file":"runtime.class.js","sources":["../../../../../../../src/class/api/function/transaction/runtime.class.ts"],"sourcesContent":[null],"names":["LoggerUtility","ApiFunctionContextStorage","ErrorException","ApiFunctionTransactionRegistry","randomUUID","EApiFunctionTransactionOutcome","ApiFunctionTransactionLifecycle","FormatErrorEvidenceForLog","EApiFunctionTransactionFailureStage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,iBAAiB,GAAkBA,4BAAa,CAAC,SAAS,CAAC,+BAA+B,CAAC;MAEpF,6BAA6B,CAAA;AAClC,IAAA,aAAa,OAAO,CAAI,OAAmM,EAAA;AACjO,QAAA,IAAIC,8CAAyB,CAAC,sBAAsB,EAAE,EAAE;AACvD,YAAA,MAAMC,gCAAc,CAAC,0EAA0E,CAAC;QACjG;AAEA,QAAA,MAAM,QAAQ,GAAmC,IAAIC,6CAA8B,CAACC,sBAAU,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC;QAErI,MAAM,WAAW,GAAgB,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE;AAEvE,QAAA,IAAI;AACH,YAAA,MAAM,WAAW,CAAC,OAAO,EAAE;AAC3B,YAAA,MAAM,WAAW,CAAC,gBAAgB,EAAE;QACrC;QAAE,OAAO,KAAK,EAAE;AACf,YAAA,MAAM,6BAA6B,CAAC,iBAAiB,CAAC,WAAW,CAAC;AAElE,YAAA,MAAM,KAAK;QACZ;QAEA,MAAM,MAAM,GAAkB,EAAE;AAChC,QAAA,IAAI,oBAAgE;AACpE,QAAA,IAAI,WAAoB;QACxB,IAAI,cAAc,GAAY,KAAK;QACnC,IAAI,iBAAiB,GAAY,KAAK;AACtC,QAAA,IAAI,cAAuB;AAC3B,QAAA,IAA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AO,IAAI,MAAM,CAAC,EAAE;AACzB,gBAAA,MAAMJ,gCAAc,CAAC,4DAA4D,CAAC;YACnF;AAEA,YAAA,MAAMI,+CAA+B,CAAC,kBAAkB,CAAC,QAAQ,CAAC;YAElE,OAAO,MAAM,CAAC,KAAU;QACzB;gBAAU;AACT,YAAA,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC;QACpC;IACD;AAEQ,IAAA,aAAa,iBAAiB,CAAC,WAAwB,EAAA;AAC9D,QAAA,IAAI;AACH,YAAA,MAAM,WAAW,CAAC,OAAO,EAAE;QAC5B;QAAE,OAAO,KAAK,EAAE;YACf,iBAAiB,CAAC,KAAK,CAAC,CAAA,4CAAA,EAA+CC,gDAAyB,CAAC,KAAK,CAAC,CAAA,CAAE,CAAC;QAC3G;IACD;AAEQ,IAAA,aAAa,kBAAkB,CAAC,WAAwB,EAAA;AAC/D,QAAA,IAAI;AACH,YAAA,MAAM,WAAW,CAAC,mBAAmB,EAAE;AAEvC,YAAA,OAAO,SAAS;QACjB;QAAE,OAAO,KAAK,EAAE;YACf,OAAO,MAAM,CAAC,MAAM,CAAC;gBACpB,KAAK;gBACL,KAAK,EAAEC,qDAAmC,CAAC,QAAQ;AACnD,aAAA,CAAC;QACH;IACD;AACA;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { IApiFunctionTransactionObservationOptions } from '../../../../interface/class/api/function';
|
|
1
2
|
import { DataSource, EntityManager } from 'typeorm';
|
|
2
3
|
export declare class ApiFunctionTransactionScope {
|
|
3
4
|
static runWithDataSource<R>(dataSource: DataSource, properties: {
|
|
4
5
|
name: string;
|
|
6
|
+
observation?: Readonly<IApiFunctionTransactionObservationOptions>;
|
|
5
7
|
}, callback: (entityManager: EntityManager) => Promise<R>): Promise<R>;
|
|
6
8
|
static runWithEntityManager<R>(entityManager: EntityManager, callback: () => Promise<R>): Promise<R>;
|
|
7
9
|
private static createMissingServiceContextError;
|
|
@@ -42,6 +42,7 @@ class ApiFunctionTransactionScope {
|
|
|
42
42
|
return await runtime_class.ApiFunctionTransactionRuntime.execute({
|
|
43
43
|
callback: async (entityManager) => await ApiFunctionTransactionScope.runWithEntityManager(entityManager, async () => await callback(entityManager)),
|
|
44
44
|
dataSource,
|
|
45
|
+
observation: properties.observation,
|
|
45
46
|
owner: {
|
|
46
47
|
kind: ownerKind_enum.EApiFunctionTransactionOwnerKind.SCOPE,
|
|
47
48
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.class.js","sources":["../../../../../../../src/class/api/function/transaction/scope.class.ts"],"sourcesContent":[null],"names":["ErrorException","ApiFunctionTransactionRuntime","EApiFunctionTransactionOwnerKind","ApiFunctionContextStorage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAUa,2BAA2B,CAAA;IAChC,aAAa,iBAAiB,CAAI,UAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"scope.class.js","sources":["../../../../../../../src/class/api/function/transaction/scope.class.ts"],"sourcesContent":[null],"names":["ErrorException","ApiFunctionTransactionRuntime","EApiFunctionTransactionOwnerKind","ApiFunctionContextStorage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAUa,2BAA2B,CAAA;IAChC,aAAa,iBAAiB,CAAI,UAAsB,EAAE,UAA+F,EAAE,QAAsD,EAAA;QACvN,MAAM,IAAI,GAAW,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;AAE3C,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,YAAA,MAAMA,gCAAc,CAAC,6DAA6D,CAAC;QACpF;AAEA,QAAA,OAAO,MAAMC,2CAA6B,CAAC,OAAO,CAAC;YAClD,QAAQ,EAAE,OAAO,aAA4B,KAAiB,MAAM,2BAA2B,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAwB,MAAM,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC1L,UAAU;YACV,WAAW,EAAE,UAAU,CA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,CAAC;AACxI,gBAAA,MAAM,EAAE,MAA+B,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAC,gCAAgC,EAAE,CAAC;AACrH,aAAA;AACD,YAAA,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC;SAC/C;QAED,OAAO,MAAMG,8CAAyB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC9D;AAEQ,IAAA,OAAO,gCAAgC,GAAA;AAC9C,QAAA,OAAOH,gCAAc,CAAC,4EAA4E,CAAC;IACpG;AACA;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const MAXIMUM_MEASUREMENTS = 256;
|
|
4
|
+
const MAXIMUM_METHOD_NAME_LENGTH = 256;
|
|
5
|
+
const MAXIMUM_SELECTORS = 32;
|
|
6
|
+
const API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT = {
|
|
7
|
+
MAXIMUM_MEASUREMENTS,
|
|
8
|
+
MAXIMUM_METHOD_NAME_LENGTH,
|
|
9
|
+
MAXIMUM_SELECTORS,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT = API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT;
|
|
13
|
+
//# sourceMappingURL=api-function-transaction-observation.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-function-transaction-observation.constant.js","sources":["../../../../src/constant/api-function-transaction-observation.constant.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA,MAAM,oBAAoB,GAAW,GAAG;AACxC,MAAM,0BAA0B,GAAW,GAAG;AAC9C,MAAM,iBAAiB,GAAW,EAAE;AAE7B,MAAM,6CAA6C,GAItD;IACH,oBAAoB;IACpB,0BAA0B;IAC1B,iBAAiB;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ var body_class = require('./class/utility/dto/strategy/body.class.js');
|
|
|
48
48
|
var query_class = require('./class/utility/dto/strategy/query.class.js');
|
|
49
49
|
var request_class = require('./class/utility/dto/strategy/request.class.js');
|
|
50
50
|
var response_class = require('./class/utility/dto/strategy/response.class.js');
|
|
51
|
+
var apiFunctionTransactionObservation_constant = require('./constant/api-function-transaction-observation.constant.js');
|
|
51
52
|
var auditSinkToken_constant = require('./constant/class/authorization/audit-sink-token.constant.js');
|
|
52
53
|
var hookPermissionSourcesToken_constant = require('./constant/class/authorization/hook-permission-sources-token.constant.js');
|
|
53
54
|
var metadataDecision_constant = require('./constant/class/authorization/metadata-decision.constant.js');
|
|
@@ -352,6 +353,7 @@ exports.DtoStrategyBody = body_class.DtoStrategyBody;
|
|
|
352
353
|
exports.DtoStrategyQuery = query_class.DtoStrategyQuery;
|
|
353
354
|
exports.DtoStrategyRequest = request_class.DtoStrategyRequest;
|
|
354
355
|
exports.DtoStrategyResponse = response_class.DtoStrategyResponse;
|
|
356
|
+
exports.API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT = apiFunctionTransactionObservation_constant.API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT;
|
|
355
357
|
exports.AUTHORIZATION_AUDIT_SINK_TOKEN = auditSinkToken_constant.AUTHORIZATION_AUDIT_SINK_TOKEN;
|
|
356
358
|
exports.AUTHORIZATION_HOOK_PERMISSION_SOURCES_TOKEN = hookPermissionSourcesToken_constant.AUTHORIZATION_HOOK_PERMISSION_SOURCES_TOKEN;
|
|
357
359
|
exports.AUTHORIZATION_DECISION_METADATA_CONSTANT = metadataDecision_constant.AUTHORIZATION_DECISION_METADATA_CONSTANT;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type IApiFunctionTransactionObservationMeasurement } from './measurement.interface';
|
|
2
|
+
export { type IApiFunctionTransactionObservationOptions } from './options.interface';
|
|
3
|
+
export { type IApiFunctionTransactionObservationSelector } from './selector.interface';
|
|
4
|
+
export { type IApiFunctionTransactionObservationSnapshot } from './snapshot.interface';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IApiFunctionTransactionObservationSelector } from './selector.interface';
|
|
2
|
+
import { IApiFunctionTransactionObservationSnapshot } from './snapshot.interface';
|
|
3
|
+
export interface IApiFunctionTransactionObservationOptions {
|
|
4
|
+
onSettled: (snapshot: Readonly<IApiFunctionTransactionObservationSnapshot>) => void;
|
|
5
|
+
selectors: ReadonlyArray<Readonly<IApiFunctionTransactionObservationSelector>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IApiBaseEntity } from '../../../../../api-base-entity.interface';
|
|
2
|
+
import { TApiFunctionTransactionTraceType } from '../../../../../../type/class/api/function/transaction';
|
|
3
|
+
export interface IApiFunctionTransactionObservationSelector {
|
|
4
|
+
entity: new (...arguments_: Array<unknown>) => IApiBaseEntity;
|
|
5
|
+
functionType: TApiFunctionTransactionTraceType;
|
|
6
|
+
methodName: string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EApiFunctionTransactionOutcome } from '../../../../../../enum/decorator/api';
|
|
2
|
+
import { IApiFunctionTransactionObservationMeasurement } from './measurement.interface';
|
|
3
|
+
export interface IApiFunctionTransactionObservationSnapshot {
|
|
4
|
+
droppedCount: number;
|
|
5
|
+
measurements: ReadonlyArray<Readonly<IApiFunctionTransactionObservationMeasurement>>;
|
|
6
|
+
outcome: EApiFunctionTransactionOutcome;
|
|
7
|
+
}
|
|
@@ -15,7 +15,7 @@ require('../../enum/decorator/api/controller/response-target.enum.js');
|
|
|
15
15
|
require('../../enum/decorator/api/dto-type.enum.js');
|
|
16
16
|
require('../../enum/decorator/api/function/context-storage-kind.enum.js');
|
|
17
17
|
require('../../enum/decorator/api/function/subscriber-transaction-expectation.enum.js');
|
|
18
|
-
require('../../enum/decorator/api/function/transaction/event-status.enum.js');
|
|
18
|
+
var eventStatus_enum = require('../../enum/decorator/api/function/transaction/event-status.enum.js');
|
|
19
19
|
require('../../enum/decorator/api/function/transaction/failure-stage.enum.js');
|
|
20
20
|
var mode_enum = require('../../enum/decorator/api/function/transaction/mode.enum.js');
|
|
21
21
|
require('../../enum/decorator/api/function/transaction/outcome.enum.js');
|
|
@@ -65,14 +65,17 @@ async function ApiFunctionExecuteWithTransaction(options) {
|
|
|
65
65
|
isSubscriberObservable,
|
|
66
66
|
methodName: options.methodName,
|
|
67
67
|
});
|
|
68
|
+
const observationIndex = registry?.beginObservation(options);
|
|
68
69
|
try {
|
|
69
70
|
const result = await options.callback(eventManager);
|
|
71
|
+
registry?.completeObservation(observationIndex, eventStatus_enum.EApiFunctionTransactionEventStatus.SUCCEEDED);
|
|
70
72
|
if (sequence !== undefined) {
|
|
71
73
|
registry?.succeedEvent(sequence);
|
|
72
74
|
}
|
|
73
75
|
return result;
|
|
74
76
|
}
|
|
75
77
|
catch (error) {
|
|
78
|
+
registry?.completeObservation(observationIndex, eventStatus_enum.EApiFunctionTransactionEventStatus.FAILED);
|
|
76
79
|
if (sequence !== undefined) {
|
|
77
80
|
registry?.failEvent(sequence, error);
|
|
78
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-transaction.utility.js","sources":["../../../../../src/utility/api/function-transaction.utility.ts"],"sourcesContent":[null],"names":["ApiFunctionContextStorage","SERVICE_API_DECORATOR_CONSTANT","EApiFunctionTransactionMode","ErrorException","ApiFunctionTransactionRuntime","EApiFunctionTransactionOwnerKind"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;AAgBG;AACI,eAAe,iCAAiC,CAA8B,OAWpF,EAAA;AACA,IAAA,MAAM,cAAc,GAA+CA,8CAAyB,CAAC,sBAAsB,EAAE;AACrH,IAAA,MAAM,kBAAkB,GAA8B,cAAc,GAAGA,8CAAyB,CAAC,eAAe,EAAE,GAAG,SAAS;AAC9H,IAAA,MAAM,KAAK,GAAW,OAAO,CAAC,KAAK,IAAI,aAAa;IACpD,MAAM,sBAAsB,GAAY,OAAO,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAACC,+CAA8B,CAAC,uBAAuB,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEtL,IAAA,MAAM,uBAAuB,GAAG,OAAO,YAAuC,KAAgB;AAC7F,QAAA,MAAM,QAAQ,GAA+CD,8CAAyB,CAAC,sBAAsB,EAAE;AAE/G,QAAA,MAAM,QAAQ,GAAuB,QAAQ,EAAE,UAAU,CAAC;YACzD,MAAM,EAAE,OAAO,CAAC,MAAM;AACtB,YAAA,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI;YAC/B,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,sBAAsB;YACtB,UAAU,EAAE,OAAO,CAAC,UAAU;AAC9B,SAAA,CAAC;
|
|
1
|
+
{"version":3,"file":"function-transaction.utility.js","sources":["../../../../../src/utility/api/function-transaction.utility.ts"],"sourcesContent":[null],"names":["ApiFunctionContextStorage","SERVICE_API_DECORATOR_CONSTANT","EApiFunctionTransactionEventStatus","EApiFunctionTransactionMode","ErrorException","ApiFunctionTransactionRuntime","EApiFunctionTransactionOwnerKind"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;AAgBG;AACI,eAAe,iCAAiC,CAA8B,OAWpF,EAAA;AACA,IAAA,MAAM,cAAc,GAA+CA,8CAAyB,CAAC,sBAAsB,EAAE;AACrH,IAAA,MAAM,kBAAkB,GAA8B,cAAc,GAAGA,8CAAyB,CAAC,eAAe,EAAE,GAAG,SAAS;AAC9H,IAAA,MAAM,KAAK,GAAW,OAAO,CAAC,KAAK,IAAI,aAAa;IACpD,MAAM,sBAAsB,GAAY,OAAO,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAACC,+CAA8B,CAAC,uBAAuB,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEtL,IAAA,MAAM,uBAAuB,GAAG,OAAO,YAAuC,KAAgB;AAC7F,QAAA,MAAM,QAAQ,GAA+CD,8CAAyB,CAAC,sBAAsB,EAAE;AAE/G,QAAA,MAAM,QAAQ,GAAuB,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AK,EAAE;gBACN,MAAM,EAAE,OAAO,CAAC,MAAM;AACtB,gBAAA,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI;gBAC/B,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,IAAI,EAAEC,+CAAgC,CAAC,QAAQ;gBAC/C,UAAU,EAAE,OAAO,CAAC,UAAU;AAC9B,aAAA;AACD,SAAA,CAAC;IACH;AAEA,IAAA,OAAO,MAAM,uBAAuB,CAAC,YAAY,CAAC;AACnD;;"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EApiFunctionTransactionOutcome, EApiFunctionTransactionEventStatus } from '../../../../enum/decorator/api';
|
|
2
|
+
import { IApiFunctionTransaction, IApiFunctionTransactionObservationOptions, IApiFunctionTransactionObservationSelector } from '../../../../interface/class/api/function';
|
|
2
3
|
import { IApiSubscriberFunctionTransactionContext } from '../../../../interface/class/api/subscriber/function';
|
|
3
4
|
import { TApiFunctionTransactionEvent, TApiFunctionTransactionOwner, TApiFunctionTransactionTraceType } from '../../../../type/class/api/function/transaction';
|
|
4
5
|
export declare class ApiFunctionTransactionRegistry {
|
|
5
6
|
private readonly EVENTS;
|
|
6
7
|
private eventSnapshot?;
|
|
8
|
+
private isObservationClosed;
|
|
9
|
+
private readonly MEASUREMENTS;
|
|
10
|
+
private readonly OBSERVATION?;
|
|
11
|
+
private observationDroppedCount;
|
|
7
12
|
private readonly TRANSACTION;
|
|
8
|
-
constructor(id: string, owner: TApiFunctionTransactionOwner);
|
|
13
|
+
constructor(id: string, owner: TApiFunctionTransactionOwner, observation?: Readonly<IApiFunctionTransactionObservationOptions>);
|
|
9
14
|
beginEvent(options: {
|
|
10
15
|
action?: string;
|
|
11
16
|
entityName: string;
|
|
@@ -13,11 +18,28 @@ export declare class ApiFunctionTransactionRegistry {
|
|
|
13
18
|
isSubscriberObservable: boolean;
|
|
14
19
|
methodName: string;
|
|
15
20
|
}): number;
|
|
21
|
+
/**
|
|
22
|
+
* Reserves one selected native callback interval without changing lifecycle events.
|
|
23
|
+
* @param {Readonly<IApiFunctionTransactionObservationSelector>} selector Reached native invocation.
|
|
24
|
+
* @returns {number | undefined} Reserved measurement index, or no admitted measurement.
|
|
25
|
+
*/
|
|
26
|
+
beginObservation(selector: Readonly<IApiFunctionTransactionObservationSelector>): number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Samples completion before native event bookkeeping; late completion is ignored.
|
|
29
|
+
* @param {number | undefined} index Reserved measurement index.
|
|
30
|
+
* @param {EApiFunctionTransactionEventStatus} status Native callback status.
|
|
31
|
+
*/
|
|
32
|
+
completeObservation(index: number | undefined, status: EApiFunctionTransactionEventStatus): void;
|
|
16
33
|
createContext(matchedEvents: ReadonlyArray<TApiFunctionTransactionEvent>): IApiSubscriberFunctionTransactionContext;
|
|
17
34
|
failEvent(sequence: number, error: unknown): void;
|
|
18
35
|
getEvents(): ReadonlyArray<TApiFunctionTransactionEvent>;
|
|
19
36
|
getObservableEvents(): ReadonlyArray<TApiFunctionTransactionEvent>;
|
|
20
37
|
getTransaction(): Readonly<IApiFunctionTransaction>;
|
|
38
|
+
/**
|
|
39
|
+
* Publishes the bounded projection once after the owning transaction lifecycle settles.
|
|
40
|
+
* @param {EApiFunctionTransactionOutcome} outcome Settled database outcome.
|
|
41
|
+
*/
|
|
42
|
+
settleObservation(outcome: EApiFunctionTransactionOutcome): void;
|
|
21
43
|
succeedEvent(sequence: number): void;
|
|
22
44
|
private getPendingEvent;
|
|
23
45
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT } from '../../../../constant/api-function-transaction-observation.constant.js';
|
|
1
2
|
import '../../../../enum/decorator/api/action.enum.js';
|
|
2
3
|
import '../../../../enum/decorator/api/authentication-type.enum.js';
|
|
3
4
|
import '../../../../enum/decorator/api/controller/get-list/query/filter/missing-behavior.enum.js';
|
|
@@ -16,7 +17,7 @@ import '../../../../enum/decorator/api/function/transaction/mode.enum.js';
|
|
|
16
17
|
import '../../../../enum/decorator/api/function/transaction/outcome.enum.js';
|
|
17
18
|
import '../../../../enum/decorator/api/function/transaction/owner-kind.enum.js';
|
|
18
19
|
import { EApiFunctionTransactionTraceType } from '../../../../enum/decorator/api/function/transaction/trace-type.enum.js';
|
|
19
|
-
import '../../../../enum/decorator/api/function/type.enum.js';
|
|
20
|
+
import { EApiFunctionType } from '../../../../enum/decorator/api/function/type.enum.js';
|
|
20
21
|
import '../../../../enum/decorator/api/function/update-persistence-mode.enum.js';
|
|
21
22
|
import '../../../../enum/decorator/api/on-type.enum.js';
|
|
22
23
|
import '../../../../enum/decorator/api/property/data-type.enum.js';
|
|
@@ -32,8 +33,38 @@ import { ErrorException } from '../../../../utility/error/exception.utility.js';
|
|
|
32
33
|
class ApiFunctionTransactionRegistry {
|
|
33
34
|
EVENTS = [];
|
|
34
35
|
eventSnapshot;
|
|
36
|
+
isObservationClosed = false;
|
|
37
|
+
MEASUREMENTS = [];
|
|
38
|
+
OBSERVATION;
|
|
39
|
+
observationDroppedCount = 0;
|
|
35
40
|
TRANSACTION;
|
|
36
|
-
constructor(id, owner) {
|
|
41
|
+
constructor(id, owner, observation) {
|
|
42
|
+
if (observation !== undefined) {
|
|
43
|
+
const onSettled = observation?.onSettled;
|
|
44
|
+
const selectors = observation?.selectors;
|
|
45
|
+
if (typeof onSettled !== "function" || !Array.isArray(selectors) || selectors.length > API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT.MAXIMUM_SELECTORS) {
|
|
46
|
+
throw ErrorException("Invalid transaction observation options");
|
|
47
|
+
}
|
|
48
|
+
const copiedSelectors = [];
|
|
49
|
+
for (const selector of selectors) {
|
|
50
|
+
if (typeof selector !== "object" || selector === null || !("entity" in selector) || !("functionType" in selector) || !("methodName" in selector)) {
|
|
51
|
+
throw ErrorException("Invalid transaction observation selector");
|
|
52
|
+
}
|
|
53
|
+
const entity = selector.entity;
|
|
54
|
+
const functionType = selector.functionType;
|
|
55
|
+
const methodName = selector.methodName;
|
|
56
|
+
if (typeof entity !== "function" ||
|
|
57
|
+
![...Object.values(EApiFunctionType), EApiFunctionTransactionTraceType.STEP].includes(functionType) ||
|
|
58
|
+
typeof methodName !== "string" ||
|
|
59
|
+
methodName.trim().length === 0 ||
|
|
60
|
+
methodName.length > API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT.MAXIMUM_METHOD_NAME_LENGTH ||
|
|
61
|
+
copiedSelectors.some((candidate) => candidate.entity === entity && candidate.functionType === functionType && candidate.methodName === methodName)) {
|
|
62
|
+
throw ErrorException("Invalid transaction observation selector");
|
|
63
|
+
}
|
|
64
|
+
copiedSelectors.push(Object.freeze({ entity: entity, functionType: functionType, methodName }));
|
|
65
|
+
}
|
|
66
|
+
this.OBSERVATION = Object.freeze({ onSettled, selectors: Object.freeze(copiedSelectors) });
|
|
67
|
+
}
|
|
37
68
|
this.TRANSACTION = Object.freeze({
|
|
38
69
|
id,
|
|
39
70
|
owner: Object.freeze({ ...owner }),
|
|
@@ -50,6 +81,58 @@ class ApiFunctionTransactionRegistry {
|
|
|
50
81
|
});
|
|
51
82
|
return sequence;
|
|
52
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Reserves one selected native callback interval without changing lifecycle events.
|
|
86
|
+
* @param {Readonly<IApiFunctionTransactionObservationSelector>} selector Reached native invocation.
|
|
87
|
+
* @returns {number | undefined} Reserved measurement index, or no admitted measurement.
|
|
88
|
+
*/
|
|
89
|
+
beginObservation(selector) {
|
|
90
|
+
if (!this.OBSERVATION || this.isObservationClosed)
|
|
91
|
+
return undefined;
|
|
92
|
+
const selectorIndex = this.OBSERVATION.selectors.findIndex((candidate) => candidate.entity === selector.entity && candidate.functionType === selector.functionType && candidate.methodName === selector.methodName);
|
|
93
|
+
if (selectorIndex === -1)
|
|
94
|
+
return undefined;
|
|
95
|
+
if (this.MEASUREMENTS.length >= API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT.MAXIMUM_MEASUREMENTS) {
|
|
96
|
+
this.observationDroppedCount = Math.min(Number.MAX_SAFE_INTEGER, this.observationDroppedCount + 1);
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
const index = this.MEASUREMENTS.length;
|
|
100
|
+
const measurement = { selectorIndex };
|
|
101
|
+
this.MEASUREMENTS.push(measurement);
|
|
102
|
+
try {
|
|
103
|
+
const startedAtMs = performance.now();
|
|
104
|
+
if (Number.isFinite(startedAtMs))
|
|
105
|
+
measurement.startedAtMs = startedAtMs;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// A missing clock sample drops only this diagnostic interval.
|
|
109
|
+
}
|
|
110
|
+
return index;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Samples completion before native event bookkeeping; late completion is ignored.
|
|
114
|
+
* @param {number | undefined} index Reserved measurement index.
|
|
115
|
+
* @param {EApiFunctionTransactionEventStatus} status Native callback status.
|
|
116
|
+
*/
|
|
117
|
+
completeObservation(index, status) {
|
|
118
|
+
if (index === undefined || this.isObservationClosed)
|
|
119
|
+
return;
|
|
120
|
+
const measurement = this.MEASUREMENTS[index];
|
|
121
|
+
if (!measurement || measurement.status !== undefined)
|
|
122
|
+
return;
|
|
123
|
+
measurement.status = status;
|
|
124
|
+
try {
|
|
125
|
+
const completedAtMs = performance.now();
|
|
126
|
+
if (measurement.startedAtMs !== undefined && Number.isFinite(completedAtMs)) {
|
|
127
|
+
const durationMs = completedAtMs - measurement.startedAtMs;
|
|
128
|
+
if (Number.isFinite(durationMs) && durationMs >= 0)
|
|
129
|
+
measurement.durationMs = durationMs;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Capture failures cannot alter a native result or error.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
53
136
|
createContext(matchedEvents) {
|
|
54
137
|
const events = this.getEvents();
|
|
55
138
|
return Object.freeze({
|
|
@@ -99,6 +182,35 @@ class ApiFunctionTransactionRegistry {
|
|
|
99
182
|
getTransaction() {
|
|
100
183
|
return this.TRANSACTION;
|
|
101
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Publishes the bounded projection once after the owning transaction lifecycle settles.
|
|
187
|
+
* @param {EApiFunctionTransactionOutcome} outcome Settled database outcome.
|
|
188
|
+
*/
|
|
189
|
+
settleObservation(outcome) {
|
|
190
|
+
if (!this.OBSERVATION || this.isObservationClosed)
|
|
191
|
+
return;
|
|
192
|
+
this.isObservationClosed = true;
|
|
193
|
+
try {
|
|
194
|
+
const measurements = [];
|
|
195
|
+
for (const measurement of this.MEASUREMENTS) {
|
|
196
|
+
if (measurement.durationMs === undefined || measurement.status === undefined) {
|
|
197
|
+
this.observationDroppedCount = Math.min(Number.MAX_SAFE_INTEGER, this.observationDroppedCount + 1);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
measurements.push(Object.freeze({ durationMs: measurement.durationMs, selectorIndex: measurement.selectorIndex, status: measurement.status }));
|
|
201
|
+
}
|
|
202
|
+
this.MEASUREMENTS.length = 0;
|
|
203
|
+
const onSettled = this.OBSERVATION.onSettled;
|
|
204
|
+
const delivery = onSettled(Object.freeze({ droppedCount: this.observationDroppedCount, measurements: Object.freeze(measurements), outcome }));
|
|
205
|
+
if (delivery !== undefined)
|
|
206
|
+
void Promise.resolve(delivery).catch(() => {
|
|
207
|
+
// An accidental asynchronous observer rejection remains diagnostic-only.
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
// Diagnostic callbacks never participate in transaction error handling.
|
|
212
|
+
}
|
|
213
|
+
}
|
|
102
214
|
succeedEvent(sequence) {
|
|
103
215
|
const event = this.getPendingEvent(sequence);
|
|
104
216
|
event.status = EApiFunctionTransactionEventStatus.SUCCEEDED;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.class.js","sources":["../../../../../../../src/class/api/function/transaction/registry.class.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":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EtJ,IAAI,QAAQ,KAAK,SAAS;gBACzB,KAAK,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,MAAK;;AAE1C,gBAAA,CAAC,CAAC;QACJ;AAAE,QAAA,MAAM;;QAER;IACD;AAEO,IAAA,YAAY,CAAC,QAAgB,EAAA;QACnC,MAAM,KAAK,GAAiC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;AAE1E,QAAA,KAAK,CAAC,MAAM,GAAG,kCAAkC,CAAC,SAAS;IAC5D;AAEQ,IAAA,eAAe,CAAC,QAAgB,EAAA;QACvC,MAAM,KAAK,GAA6C,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;AAEjF,QAAA,IAAI,KAAK,EAAE,QAAQ,KAAK,QAAQ,EAAE;AACjC,YAAA,MAAM,cAAc,CAAC,CAAA,kBAAA,EAAqB,QAAQ,CAAA,kBAAA,CAAoB,CAAC;QACxE;AAEA,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE;AACjB,YAAA,MAAM,cAAc,CAAC,CAAA,kBAAA,EAAqB,QAAQ,CAAA,sBAAA,CAAwB,CAAC;QAC5E;AAEA,QAAA,OAAO,KAAK;IACb;AACA;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { IApiFunctionTransactionObservationOptions } from '../../../../interface/class/api/function';
|
|
1
2
|
import { TApiFunctionTransactionOwner } from '../../../../type/class/api/function';
|
|
2
3
|
import { DataSource, EntityManager } from 'typeorm';
|
|
3
4
|
export declare class ApiFunctionTransactionRuntime {
|
|
4
5
|
static execute<R>(options: {
|
|
5
6
|
callback: (entityManager: EntityManager) => Promise<R>;
|
|
6
7
|
dataSource: DataSource;
|
|
8
|
+
observation?: Readonly<IApiFunctionTransactionObservationOptions>;
|
|
7
9
|
owner: TApiFunctionTransactionOwner;
|
|
8
10
|
}): Promise<R>;
|
|
9
11
|
private static releaseBestEffort;
|
|
@@ -17,7 +17,7 @@ import '../../../../enum/decorator/api/function/subscriber-transaction-expectati
|
|
|
17
17
|
import '../../../../enum/decorator/api/function/transaction/event-status.enum.js';
|
|
18
18
|
import { EApiFunctionTransactionFailureStage } from '../../../../enum/decorator/api/function/transaction/failure-stage.enum.js';
|
|
19
19
|
import '../../../../enum/decorator/api/function/transaction/mode.enum.js';
|
|
20
|
-
import '../../../../enum/decorator/api/function/transaction/outcome.enum.js';
|
|
20
|
+
import { EApiFunctionTransactionOutcome } from '../../../../enum/decorator/api/function/transaction/outcome.enum.js';
|
|
21
21
|
import '../../../../enum/decorator/api/function/transaction/owner-kind.enum.js';
|
|
22
22
|
import '../../../../enum/decorator/api/function/transaction/trace-type.enum.js';
|
|
23
23
|
import '../../../../enum/decorator/api/function/type.enum.js';
|
|
@@ -41,6 +41,7 @@ class ApiFunctionTransactionRuntime {
|
|
|
41
41
|
if (ApiFunctionContextStorage.getTransactionRegistry()) {
|
|
42
42
|
throw ErrorException("Cannot open an owning transaction inside an active Automator transaction");
|
|
43
43
|
}
|
|
44
|
+
const registry = new ApiFunctionTransactionRegistry(randomUUID(), options.owner, options.observation);
|
|
44
45
|
const queryRunner = options.dataSource.createQueryRunner();
|
|
45
46
|
try {
|
|
46
47
|
await queryRunner.connect();
|
|
@@ -50,7 +51,6 @@ class ApiFunctionTransactionRuntime {
|
|
|
50
51
|
await ApiFunctionTransactionRuntime.releaseBestEffort(queryRunner);
|
|
51
52
|
throw error;
|
|
52
53
|
}
|
|
53
|
-
const registry = new ApiFunctionTransactionRegistry(randomUUID(), options.owner);
|
|
54
54
|
const result = {};
|
|
55
55
|
let commitCleanupFailure;
|
|
56
56
|
let commitError;
|
|
@@ -79,17 +79,27 @@ class ApiFunctionTransactionRuntime {
|
|
|
79
79
|
}
|
|
80
80
|
await ApiFunctionTransactionRuntime.releaseBestEffort(queryRunner);
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
82
|
+
let outcome = EApiFunctionTransactionOutcome.COMMITTED;
|
|
83
|
+
if (hasCommitError || rollbackFailure)
|
|
84
|
+
outcome = EApiFunctionTransactionOutcome.UNKNOWN;
|
|
85
|
+
else if (hasOperationError)
|
|
86
|
+
outcome = EApiFunctionTransactionOutcome.ROLLED_BACK;
|
|
87
|
+
try {
|
|
88
|
+
if (hasOperationError) {
|
|
89
|
+
return await ApiFunctionTransactionLifecycle.executeAfterRollback(registry, operationError, rollbackFailure);
|
|
90
|
+
}
|
|
91
|
+
if (hasCommitError) {
|
|
92
|
+
return await ApiFunctionTransactionLifecycle.executeCommitUnknown(registry, commitError, commitCleanupFailure);
|
|
93
|
+
}
|
|
94
|
+
if (!("value" in result)) {
|
|
95
|
+
throw ErrorException("Automator transaction completed without a committed result");
|
|
96
|
+
}
|
|
97
|
+
await ApiFunctionTransactionLifecycle.executeAfterCommit(registry);
|
|
98
|
+
return result.value;
|
|
87
99
|
}
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
finally {
|
|
101
|
+
registry.settleObservation(outcome);
|
|
90
102
|
}
|
|
91
|
-
await ApiFunctionTransactionLifecycle.executeAfterCommit(registry);
|
|
92
|
-
return result.value;
|
|
93
103
|
}
|
|
94
104
|
static async releaseBestEffort(queryRunner) {
|
|
95
105
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.class.js","sources":["../../../../../../../src/class/api/function/transaction/runtime.class.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,iBAAiB,GAAkB,aAAa,CAAC,SAAS,CAAC,+BAA+B,CAAC;MAEpF,6BAA6B,CAAA;AAClC,IAAA,aAAa,OAAO,CAAI,
|
|
1
|
+
{"version":3,"file":"runtime.class.js","sources":["../../../../../../../src/class/api/function/transaction/runtime.class.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,iBAAiB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A+C,yBAAyB,CAAC,KAAK,CAAC,CAAA,CAAE,CAAC;QAC3G;IACD;AAEQ,IAAA,aAAa,kBAAkB,CAAC,WAAwB,EAAA;AAC/D,QAAA,IAAI;AACH,YAAA,MAAM,WAAW,CAAC,mBAAmB,EAAE;AAEvC,YAAA,OAAO,SAAS;QACjB;QAAE,OAAO,KAAK,EAAE;YACf,OAAO,MAAM,CAAC,MAAM,CAAC;gBACpB,KAAK;gBACL,KAAK,EAAE,mCAAmC,CAAC,QAAQ;AACnD,aAAA,CAAC;QACH;IACD;AACA;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { IApiFunctionTransactionObservationOptions } from '../../../../interface/class/api/function';
|
|
1
2
|
import { DataSource, EntityManager } from 'typeorm';
|
|
2
3
|
export declare class ApiFunctionTransactionScope {
|
|
3
4
|
static runWithDataSource<R>(dataSource: DataSource, properties: {
|
|
4
5
|
name: string;
|
|
6
|
+
observation?: Readonly<IApiFunctionTransactionObservationOptions>;
|
|
5
7
|
}, callback: (entityManager: EntityManager) => Promise<R>): Promise<R>;
|
|
6
8
|
static runWithEntityManager<R>(entityManager: EntityManager, callback: () => Promise<R>): Promise<R>;
|
|
7
9
|
private static createMissingServiceContextError;
|
|
@@ -40,6 +40,7 @@ class ApiFunctionTransactionScope {
|
|
|
40
40
|
return await ApiFunctionTransactionRuntime.execute({
|
|
41
41
|
callback: async (entityManager) => await ApiFunctionTransactionScope.runWithEntityManager(entityManager, async () => await callback(entityManager)),
|
|
42
42
|
dataSource,
|
|
43
|
+
observation: properties.observation,
|
|
43
44
|
owner: {
|
|
44
45
|
kind: EApiFunctionTransactionOwnerKind.SCOPE,
|
|
45
46
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.class.js","sources":["../../../../../../../src/class/api/function/transaction/scope.class.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAUa,2BAA2B,CAAA;IAChC,aAAa,iBAAiB,CAAI,UAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"scope.class.js","sources":["../../../../../../../src/class/api/function/transaction/scope.class.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAUa,2BAA2B,CAAA;IAChC,aAAa,iBAAiB,CAAI,UAAsB,EAAE,UAA+F,EAAE,QAAsD,EAAA;QACvN,MAAM,IAAI,GAAW,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;AAE3C,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,YAAA,MAAM,cAAc,CAAC,6DAA6D,CAAC;QACpF;AAEA,QAAA,OAAO,MAAM,6BAA6B,CAAC,OAAO,CAAC;YAClD,QAAQ,EAAE,OAAO,aAA4B,KAAiB,MAAM,2BAA2B,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAwB,MAAM,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC1L,UAAU;YACV,WAAW,EAAE,UAAU,CAAC,WAAW;AACnC,YAAA,KAAK,EAAE;gBACN,IAAI,EAAE,gCAAgC,CAAC,KAAK;gBAC5C,IAAI;AACJ,aAAA;AACD,SAAA,CAAC;IACH;AAEO,IAAA,aAAa,oBAAoB,CAAI,aAA4B,EAAE,QAA0B,EAAA;QACnG,MAAM,QAAQ,GAA+C,yBAAyB,CAAC,sCAAsC,CAAC,aAAa,CAAC;QAE5I,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,yBAAyB,CAAC,sBAAsB,EAAE,IAAI,yBAAyB,CAAC,eAAe,EAAE,KAAK,aAAa,IAAI,yBAAyB,CAAC,yBAAyB,EAAE,EAAE,OAAO,KAAK,aAAa,EAAE;AACtO,YAAA,MAAM,cAAc,CAAC,4GAA4G,CAAC;QACnI;QAEA,MAAM,MAAM,GAA6B,MAAM;AAE/C,QAAA,MAAM,OAAO,GAAwC;YACpD,MAAM;AACN,YAAA,YAAY,EAAE,aAAa;YAC3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XIMUM_METHOD_NAME_LENGTH,
|
|
7
|
+
MAXIMUM_SELECTORS,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT };
|
|
11
|
+
//# sourceMappingURL=api-function-transaction-observation.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-function-transaction-observation.constant.js","sources":["../../../../src/constant/api-function-transaction-observation.constant.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAW,GAAG;AACxC,MAAM,0BAA0B,GAAW,GAAG;AAC9C,MAAM,iBAAiB,GAAW,EAAE;AAE7B,MAAM,6CAA6C,GAItD;IACH,oBAAoB;IACpB,0BAA0B;IAC1B,iBAAiB;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -46,6 +46,7 @@ export { DtoStrategyBody } from './class/utility/dto/strategy/body.class.js';
|
|
|
46
46
|
export { DtoStrategyQuery } from './class/utility/dto/strategy/query.class.js';
|
|
47
47
|
export { DtoStrategyRequest } from './class/utility/dto/strategy/request.class.js';
|
|
48
48
|
export { DtoStrategyResponse } from './class/utility/dto/strategy/response.class.js';
|
|
49
|
+
export { API_FUNCTION_TRANSACTION_OBSERVATION_CONSTANT } from './constant/api-function-transaction-observation.constant.js';
|
|
49
50
|
export { AUTHORIZATION_AUDIT_SINK_TOKEN } from './constant/class/authorization/audit-sink-token.constant.js';
|
|
50
51
|
export { AUTHORIZATION_HOOK_PERMISSION_SOURCES_TOKEN } from './constant/class/authorization/hook-permission-sources-token.constant.js';
|
|
51
52
|
export { AUTHORIZATION_DECISION_METADATA_CONSTANT } from './constant/class/authorization/metadata-decision.constant.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type IApiFunctionTransactionObservationMeasurement } from './measurement.interface';
|
|
2
|
+
export { type IApiFunctionTransactionObservationOptions } from './options.interface';
|
|
3
|
+
export { type IApiFunctionTransactionObservationSelector } from './selector.interface';
|
|
4
|
+
export { type IApiFunctionTransactionObservationSnapshot } from './snapshot.interface';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IApiFunctionTransactionObservationSelector } from './selector.interface';
|
|
2
|
+
import { IApiFunctionTransactionObservationSnapshot } from './snapshot.interface';
|
|
3
|
+
export interface IApiFunctionTransactionObservationOptions {
|
|
4
|
+
onSettled: (snapshot: Readonly<IApiFunctionTransactionObservationSnapshot>) => void;
|
|
5
|
+
selectors: ReadonlyArray<Readonly<IApiFunctionTransactionObservationSelector>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IApiBaseEntity } from '../../../../../api-base-entity.interface';
|
|
2
|
+
import { TApiFunctionTransactionTraceType } from '../../../../../../type/class/api/function/transaction';
|
|
3
|
+
export interface IApiFunctionTransactionObservationSelector {
|
|
4
|
+
entity: new (...arguments_: Array<unknown>) => IApiBaseEntity;
|
|
5
|
+
functionType: TApiFunctionTransactionTraceType;
|
|
6
|
+
methodName: string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EApiFunctionTransactionOutcome } from '../../../../../../enum/decorator/api';
|
|
2
|
+
import { IApiFunctionTransactionObservationMeasurement } from './measurement.interface';
|
|
3
|
+
export interface IApiFunctionTransactionObservationSnapshot {
|
|
4
|
+
droppedCount: number;
|
|
5
|
+
measurements: ReadonlyArray<Readonly<IApiFunctionTransactionObservationMeasurement>>;
|
|
6
|
+
outcome: EApiFunctionTransactionOutcome;
|
|
7
|
+
}
|
|
@@ -13,7 +13,7 @@ import '../../enum/decorator/api/controller/response-target.enum.js';
|
|
|
13
13
|
import '../../enum/decorator/api/dto-type.enum.js';
|
|
14
14
|
import '../../enum/decorator/api/function/context-storage-kind.enum.js';
|
|
15
15
|
import '../../enum/decorator/api/function/subscriber-transaction-expectation.enum.js';
|
|
16
|
-
import '../../enum/decorator/api/function/transaction/event-status.enum.js';
|
|
16
|
+
import { EApiFunctionTransactionEventStatus } from '../../enum/decorator/api/function/transaction/event-status.enum.js';
|
|
17
17
|
import '../../enum/decorator/api/function/transaction/failure-stage.enum.js';
|
|
18
18
|
import { EApiFunctionTransactionMode } from '../../enum/decorator/api/function/transaction/mode.enum.js';
|
|
19
19
|
import '../../enum/decorator/api/function/transaction/outcome.enum.js';
|
|
@@ -63,14 +63,17 @@ async function ApiFunctionExecuteWithTransaction(options) {
|
|
|
63
63
|
isSubscriberObservable,
|
|
64
64
|
methodName: options.methodName,
|
|
65
65
|
});
|
|
66
|
+
const observationIndex = registry?.beginObservation(options);
|
|
66
67
|
try {
|
|
67
68
|
const result = await options.callback(eventManager);
|
|
69
|
+
registry?.completeObservation(observationIndex, EApiFunctionTransactionEventStatus.SUCCEEDED);
|
|
68
70
|
if (sequence !== undefined) {
|
|
69
71
|
registry?.succeedEvent(sequence);
|
|
70
72
|
}
|
|
71
73
|
return result;
|
|
72
74
|
}
|
|
73
75
|
catch (error) {
|
|
76
|
+
registry?.completeObservation(observationIndex, EApiFunctionTransactionEventStatus.FAILED);
|
|
74
77
|
if (sequence !== undefined) {
|
|
75
78
|
registry?.failEvent(sequence, error);
|
|
76
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-transaction.utility.js","sources":["../../../../../src/utility/api/function-transaction.utility.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;AAgBG;AACI,eAAe,iCAAiC,CAA8B,OAWpF,EAAA;AACA,IAAA,MAAM,cAAc,GAA+C,yBAAyB,CAAC,sBAAsB,EAAE;AACrH,IAAA,MAAM,kBAAkB,GAA8B,cAAc,GAAG,yBAAyB,CAAC,eAAe,EAAE,GAAG,SAAS;AAC9H,IAAA,MAAM,KAAK,GAAW,OAAO,CAAC,KAAK,IAAI,aAAa;IACpD,MAAM,sBAAsB,GAAY,OAAO,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC,8BAA8B,CAAC,uBAAuB,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEtL,IAAA,MAAM,uBAAuB,GAAG,OAAO,YAAuC,KAAgB;AAC7F,QAAA,MAAM,QAAQ,GAA+C,yBAAyB,CAAC,sBAAsB,EAAE;AAE/G,QAAA,MAAM,QAAQ,GAAuB,QAAQ,EAAE,UAAU,CAAC;YACzD,MAAM,EAAE,OAAO,CAAC,MAAM;AACtB,YAAA,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI;YAC/B,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,sBAAsB;YACtB,UAAU,EAAE,OAAO,CAAC,UAAU;AAC9B,SAAA,CAAC;
|
|
1
|
+
{"version":3,"file":"function-transaction.utility.js","sources":["../../../../../src/utility/api/function-transaction.utility.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;AAgBG;AACI,eAAe,iCAAiC,CAA8B,OAWpF,EAAA;AACA,IAAA,MAAM,cAAc,GAA+C,yBAAyB,CAAC,sBAAsB,EAAE;AACrH,IAAA,MAAM,kBAAkB,GAA8B,cAAc,GAAG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