@toa.io/core 1.0.0-alpha.30 → 1.0.0-alpha.300
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/package.json +28 -12
- package/transpiled/abandon.d.ts +9 -0
- package/transpiled/abandon.js +37 -0
- package/transpiled/abandon.js.map +1 -0
- package/transpiled/assignment.d.ts +6 -0
- package/transpiled/assignment.js +25 -0
- package/transpiled/assignment.js.map +1 -0
- package/transpiled/call.d.ts +10 -0
- package/transpiled/call.js +146 -0
- package/transpiled/call.js.map +1 -0
- package/transpiled/cascade.d.ts +7 -0
- package/transpiled/cascade.js +28 -0
- package/transpiled/cascade.js.map +1 -0
- package/transpiled/component.d.ts +15 -0
- package/transpiled/component.js +93 -0
- package/transpiled/component.js.map +1 -0
- package/transpiled/composition.d.ts +6 -0
- package/transpiled/composition.js +23 -0
- package/transpiled/composition.js.map +1 -0
- package/transpiled/connector.d.ts +54 -0
- package/transpiled/connector.js +193 -0
- package/transpiled/connector.js.map +1 -0
- package/transpiled/context.d.ts +25 -0
- package/transpiled/context.js +55 -0
- package/transpiled/context.js.map +1 -0
- package/transpiled/contract/contract.d.ts +10 -0
- package/transpiled/contract/contract.js +14 -0
- package/transpiled/contract/contract.js.map +1 -0
- package/transpiled/contract/index.d.ts +2 -0
- package/transpiled/contract/index.js +3 -0
- package/transpiled/contract/index.js.map +1 -0
- package/transpiled/contract/reply.d.ts +7 -0
- package/transpiled/contract/reply.js +48 -0
- package/transpiled/contract/reply.js.map +1 -0
- package/transpiled/contract/request.d.ts +39 -0
- package/transpiled/contract/request.js +111 -0
- package/transpiled/contract/request.js.map +1 -0
- package/transpiled/contract/schemas.d.ts +4 -0
- package/transpiled/contract/schemas.js +36 -0
- package/transpiled/contract/schemas.js.map +1 -0
- package/transpiled/discovery.d.ts +19 -0
- package/transpiled/discovery.js +52 -0
- package/transpiled/discovery.js.map +1 -0
- package/transpiled/effect.d.ts +5 -0
- package/transpiled/effect.js +11 -0
- package/transpiled/effect.js.map +1 -0
- package/transpiled/emission.d.ts +10 -0
- package/transpiled/emission.js +16 -0
- package/transpiled/emission.js.map +1 -0
- package/transpiled/entities/changeset.d.ts +10 -0
- package/transpiled/entities/changeset.js +27 -0
- package/transpiled/entities/changeset.js.map +1 -0
- package/transpiled/entities/entity.d.ts +19 -0
- package/transpiled/entities/entity.js +137 -0
- package/transpiled/entities/entity.js.map +1 -0
- package/transpiled/entities/factory.d.ts +27 -0
- package/transpiled/entities/factory.js +38 -0
- package/transpiled/entities/factory.js.map +1 -0
- package/transpiled/entities/index.d.ts +5 -0
- package/transpiled/entities/index.js +6 -0
- package/transpiled/entities/index.js.map +1 -0
- package/transpiled/entities/newid.d.ts +10 -0
- package/transpiled/entities/newid.js +35 -0
- package/transpiled/entities/newid.js.map +1 -0
- package/transpiled/entities/set.d.ts +10 -0
- package/transpiled/entities/set.js +19 -0
- package/transpiled/entities/set.js.map +1 -0
- package/transpiled/event.d.ts +14 -0
- package/transpiled/event.js +51 -0
- package/transpiled/event.js.map +1 -0
- package/transpiled/exceptions.d.ts +89 -0
- package/transpiled/exceptions.js +180 -0
- package/transpiled/exceptions.js.map +1 -0
- package/transpiled/exposition.d.ts +18 -0
- package/transpiled/exposition.js +18 -0
- package/transpiled/exposition.js.map +1 -0
- package/transpiled/guard.d.ts +7 -0
- package/transpiled/guard.js +12 -0
- package/transpiled/guard.js.map +1 -0
- package/transpiled/index.d.ts +37 -0
- package/transpiled/index.js +31 -0
- package/transpiled/index.js.map +1 -0
- package/transpiled/instance.d.ts +10 -0
- package/transpiled/instance.js +30 -0
- package/transpiled/instance.js.map +1 -0
- package/transpiled/locator.d.ts +12 -0
- package/transpiled/locator.js +32 -0
- package/transpiled/locator.js.map +1 -0
- package/transpiled/observation.d.ts +5 -0
- package/transpiled/observation.js +12 -0
- package/transpiled/observation.js.map +1 -0
- package/transpiled/operation.d.ts +67 -0
- package/transpiled/operation.js +127 -0
- package/transpiled/operation.js.map +1 -0
- package/transpiled/outbox.d.ts +45 -0
- package/transpiled/outbox.js +430 -0
- package/transpiled/outbox.js.map +1 -0
- package/transpiled/query/criteria.d.ts +6 -0
- package/transpiled/query/criteria.js +74 -0
- package/transpiled/query/criteria.js.map +1 -0
- package/transpiled/query/options.d.ts +3 -0
- package/transpiled/query/options.js +27 -0
- package/transpiled/query/options.js.map +1 -0
- package/transpiled/query.d.ts +9 -0
- package/transpiled/query.js +57 -0
- package/transpiled/query.js.map +1 -0
- package/transpiled/receiver.d.ts +20 -0
- package/transpiled/receiver.js +113 -0
- package/transpiled/receiver.js.map +1 -0
- package/transpiled/reflection.d.ts +9 -0
- package/transpiled/reflection.js +13 -0
- package/transpiled/reflection.js.map +1 -0
- package/transpiled/remote.d.ts +10 -0
- package/transpiled/remote.js +11 -0
- package/transpiled/remote.js.map +1 -0
- package/transpiled/state.d.ts +36 -0
- package/transpiled/state.js +131 -0
- package/transpiled/state.js.map +1 -0
- package/transpiled/trail.d.ts +71 -0
- package/transpiled/trail.js +110 -0
- package/transpiled/trail.js.map +1 -0
- package/transpiled/transition.d.ts +14 -0
- package/transpiled/transition.js +51 -0
- package/transpiled/transition.js.map +1 -0
- package/transpiled/transmission.d.ts +8 -0
- package/transpiled/transmission.js +30 -0
- package/transpiled/transmission.js.map +1 -0
- package/transpiled/types/atomicity.d.ts +56 -0
- package/transpiled/types/atomicity.js +2 -0
- package/transpiled/types/atomicity.js.map +1 -0
- package/transpiled/types/bindings.d.ts +77 -0
- package/transpiled/types/bindings.js +2 -0
- package/transpiled/types/bindings.js.map +1 -0
- package/transpiled/types/bridges.d.ts +38 -0
- package/transpiled/types/bridges.js +2 -0
- package/transpiled/types/bridges.js.map +1 -0
- package/transpiled/types/extensions.d.ts +92 -0
- package/transpiled/types/extensions.js +2 -0
- package/transpiled/types/extensions.js.map +1 -0
- package/transpiled/types/inbox.d.ts +22 -0
- package/transpiled/types/inbox.js +2 -0
- package/transpiled/types/inbox.js.map +1 -0
- package/transpiled/types/index.d.ts +14 -0
- package/transpiled/types/index.js +9 -0
- package/transpiled/types/index.js.map +1 -0
- package/transpiled/types/message.d.ts +16 -0
- package/transpiled/types/message.js +2 -0
- package/transpiled/types/message.js.map +1 -0
- package/transpiled/types/operations.d.ts +15 -0
- package/transpiled/types/operations.js +2 -0
- package/transpiled/types/operations.js.map +1 -0
- package/transpiled/types/outbox.d.ts +54 -0
- package/transpiled/types/outbox.js +2 -0
- package/transpiled/types/outbox.js.map +1 -0
- package/transpiled/types/receiver.d.ts +9 -0
- package/transpiled/types/receiver.js +2 -0
- package/transpiled/types/receiver.js.map +1 -0
- package/transpiled/types/request.d.ts +103 -0
- package/transpiled/types/request.js +2 -0
- package/transpiled/types/request.js.map +1 -0
- package/transpiled/types/state.d.ts +9 -0
- package/transpiled/types/state.js +2 -0
- package/transpiled/types/state.js.map +1 -0
- package/transpiled/types/storages.d.ts +146 -0
- package/transpiled/types/storages.js +2 -0
- package/transpiled/types/storages.js.map +1 -0
- package/transpiled/unmanaged.d.ts +5 -0
- package/transpiled/unmanaged.js +7 -0
- package/transpiled/unmanaged.js.map +1 -0
- package/src/assignment.js +0 -31
- package/src/call.js +0 -42
- package/src/cascade.js +0 -35
- package/src/component.js +0 -41
- package/src/composition.js +0 -25
- package/src/connector.js +0 -183
- package/src/context.js +0 -55
- package/src/contract/conditions.js +0 -21
- package/src/contract/index.js +0 -7
- package/src/contract/reply.js +0 -25
- package/src/contract/request.js +0 -67
- package/src/contract/schemas/error.yaml +0 -9
- package/src/contract/schemas/index.js +0 -7
- package/src/contract/schemas/query.yaml +0 -30
- package/src/discovery.js +0 -44
- package/src/emission.js +0 -23
- package/src/entities/changeset.js +0 -38
- package/src/entities/entity.js +0 -74
- package/src/entities/factory.js +0 -33
- package/src/entities/index.js +0 -5
- package/src/entities/set.js +0 -15
- package/src/event.js +0 -40
- package/src/exceptions.js +0 -100
- package/src/exposition.js +0 -27
- package/src/index.js +0 -47
- package/src/locator.js +0 -54
- package/src/observation.js +0 -20
- package/src/operation.js +0 -69
- package/src/query/criteria.js +0 -41
- package/src/query/options.js +0 -40
- package/src/query.js +0 -41
- package/src/receiver.js +0 -65
- package/src/reflection.js +0 -28
- package/src/remote.js +0 -17
- package/src/state.js +0 -99
- package/src/transition.js +0 -67
- package/src/transmission.js +0 -33
- package/test/call.fixtures.js +0 -27
- package/test/call.test.js +0 -46
- package/test/component.fixtures.js +0 -21
- package/test/component.test.js +0 -40
- package/test/connector.fixtures.js +0 -40
- package/test/connector.test.js +0 -176
- package/test/context.fixtures.js +0 -18
- package/test/context.test.js +0 -29
- package/test/contract/conditions.test.js +0 -26
- package/test/contract/contract.fixtures.js +0 -33
- package/test/contract/request.test.js +0 -112
- package/test/emission.fixtures.js +0 -17
- package/test/emission.test.js +0 -35
- package/test/entities/entity.fixtures.js +0 -29
- package/test/entities/entity.test.js +0 -65
- package/test/entities/factory.fixtures.js +0 -18
- package/test/entities/factory.test.js +0 -48
- package/test/entities/set.fixtures.js +0 -11
- package/test/entities/set.test.js +0 -12
- package/test/event.fixtures.js +0 -29
- package/test/event.test.js +0 -118
- package/test/locator.test.js +0 -113
- package/test/query.fixtures.js +0 -100
- package/test/query.test.js +0 -86
- package/test/receiver.fixtures.js +0 -23
- package/test/receiver.test.js +0 -95
- package/test/reflection.test.js +0 -30
- package/test/state.fixtures.js +0 -47
- package/test/state.test.js +0 -46
- package/test/transmission.fixtures.js +0 -15
- package/test/transmission.test.js +0 -46
- package/types/bindings.d.ts +0 -40
- package/types/bridges.ts +0 -30
- package/types/component.d.ts +0 -9
- package/types/connector.d.ts +0 -18
- package/types/context.d.ts +0 -21
- package/types/entity.d.ts +0 -46
- package/types/event.d.ts +0 -11
- package/types/exception.d.ts +0 -4
- package/types/extensions.d.ts +0 -29
- package/types/index.ts +0 -14
- package/types/locator.d.ts +0 -13
- package/types/message.d.ts +0 -3
- package/types/operations.d.ts +0 -2
- package/types/query.d.ts +0 -15
- package/types/receiver.d.ts +0 -12
- package/types/reflection.d.ts +0 -14
- package/types/request.d.ts +0 -23
- package/types/state.d.ts +0 -35
- package/types/storages.d.ts +0 -71
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { SchemaError } from '@toa.io/schemas';
|
|
2
|
+
export declare const codes: {
|
|
3
|
+
System: number;
|
|
4
|
+
Contract: number;
|
|
5
|
+
RequestSyntax: number;
|
|
6
|
+
RequestContract: number;
|
|
7
|
+
RequestConflict: number;
|
|
8
|
+
ResponseContract: number;
|
|
9
|
+
EntityContract: number;
|
|
10
|
+
EntityGuard: number;
|
|
11
|
+
QuerySyntax: number;
|
|
12
|
+
State: number;
|
|
13
|
+
StateNotFound: number;
|
|
14
|
+
StatePrecondition: number;
|
|
15
|
+
StateConcurrency: number;
|
|
16
|
+
StateInitialization: number;
|
|
17
|
+
Duplicate: number;
|
|
18
|
+
/** this call has been made, and what it changed is changed */
|
|
19
|
+
DuplicateCall: number;
|
|
20
|
+
Communication: number;
|
|
21
|
+
Transmission: number;
|
|
22
|
+
Endpoint: number;
|
|
23
|
+
/** nothing held the name an addressed call named */
|
|
24
|
+
Addressee: number;
|
|
25
|
+
/** the caller stopped waiting, and what it called may still run */
|
|
26
|
+
Abandoned: number;
|
|
27
|
+
/** a chain that came back to where it had been, or went further than a chain goes */
|
|
28
|
+
Loop: number;
|
|
29
|
+
};
|
|
30
|
+
export declare class Exception {
|
|
31
|
+
readonly code: number;
|
|
32
|
+
readonly message: string;
|
|
33
|
+
cause?: unknown;
|
|
34
|
+
/** what a contract exception copies off the schema error it refused with */
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
constructor(code: number, message: string, cause?: unknown);
|
|
37
|
+
}
|
|
38
|
+
export declare class SystemException extends Exception {
|
|
39
|
+
readonly stack?: string;
|
|
40
|
+
constructor(error: Error | string);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A call refused for where it has been rather than for what it says. Named, and so permanent:
|
|
44
|
+
* the chain is deterministic, and another attempt reproduces it hop for hop.
|
|
45
|
+
*/
|
|
46
|
+
export declare class LoopException extends Exception {
|
|
47
|
+
/** the whole chain, so what is set aside can be read without guessing */
|
|
48
|
+
readonly trail: string[];
|
|
49
|
+
constructor(message: string, trail: string[]);
|
|
50
|
+
}
|
|
51
|
+
export declare class ContractException extends Exception {
|
|
52
|
+
constructor(code: number | undefined, error: SchemaError | string | null, cause?: unknown);
|
|
53
|
+
}
|
|
54
|
+
export declare class RequestContractException extends ContractException {
|
|
55
|
+
constructor(error: SchemaError | string, cause?: unknown);
|
|
56
|
+
}
|
|
57
|
+
export declare class ResponseContractException extends ContractException {
|
|
58
|
+
constructor(error: SchemaError | string, cause?: unknown);
|
|
59
|
+
}
|
|
60
|
+
export declare class EntityContractException extends ContractException {
|
|
61
|
+
constructor(error: SchemaError | string, cause?: unknown);
|
|
62
|
+
}
|
|
63
|
+
export declare class EntityGuardException extends ContractException {
|
|
64
|
+
constructor(name: string, cause?: unknown);
|
|
65
|
+
}
|
|
66
|
+
type Derived = new (message?: string, cause?: unknown) => Exception;
|
|
67
|
+
export declare const RequestSyntaxException: Derived;
|
|
68
|
+
export declare const RequestConflictException: Derived;
|
|
69
|
+
export declare const QuerySyntaxException: Derived;
|
|
70
|
+
export declare const StateException: Derived;
|
|
71
|
+
export declare const StateNotFoundException: Derived;
|
|
72
|
+
export declare const StatePreconditionException: Derived;
|
|
73
|
+
export declare const StateConcurrencyException: Derived;
|
|
74
|
+
export declare const StateInitializationException: Derived;
|
|
75
|
+
export declare const DuplicateException: Derived;
|
|
76
|
+
export declare const DuplicateCallException: Derived;
|
|
77
|
+
export declare const CommunicationException: Derived;
|
|
78
|
+
export declare const TransmissionException: Derived;
|
|
79
|
+
export declare const EndpointException: Derived;
|
|
80
|
+
export declare const AddresseeException: Derived;
|
|
81
|
+
export declare const AbandonedException: Derived;
|
|
82
|
+
export declare const names: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* Takes `unknown` because a caller has caught something rather than been handed an `Exception`.
|
|
85
|
+
* Anything core did not raise — an error from a driver, a rejection with no code at all — is not
|
|
86
|
+
* on the list, and is therefore worth trying again.
|
|
87
|
+
*/
|
|
88
|
+
export declare function permanent(exception: unknown): boolean;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { swap } from '@toa.io/generic';
|
|
2
|
+
export const codes = {
|
|
3
|
+
System: 0,
|
|
4
|
+
Contract: 200,
|
|
5
|
+
RequestSyntax: 201,
|
|
6
|
+
RequestContract: 202,
|
|
7
|
+
RequestConflict: 203,
|
|
8
|
+
ResponseContract: 211,
|
|
9
|
+
EntityContract: 212,
|
|
10
|
+
EntityGuard: 213,
|
|
11
|
+
QuerySyntax: 221,
|
|
12
|
+
State: 300,
|
|
13
|
+
StateNotFound: 302,
|
|
14
|
+
StatePrecondition: 303,
|
|
15
|
+
StateConcurrency: 304,
|
|
16
|
+
StateInitialization: 305,
|
|
17
|
+
Duplicate: 306,
|
|
18
|
+
/** this call has been made, and what it changed is changed */
|
|
19
|
+
DuplicateCall: 307,
|
|
20
|
+
Communication: 400,
|
|
21
|
+
Transmission: 401,
|
|
22
|
+
Endpoint: 402,
|
|
23
|
+
/** nothing held the name an addressed call named */
|
|
24
|
+
Addressee: 403,
|
|
25
|
+
/** the caller stopped waiting, and what it called may still run */
|
|
26
|
+
Abandoned: 404,
|
|
27
|
+
/** a chain that came back to where it had been, or went further than a chain goes */
|
|
28
|
+
Loop: 500
|
|
29
|
+
};
|
|
30
|
+
export class Exception {
|
|
31
|
+
code;
|
|
32
|
+
message;
|
|
33
|
+
cause;
|
|
34
|
+
constructor(code, message, cause) {
|
|
35
|
+
this.code = code;
|
|
36
|
+
this.message = message;
|
|
37
|
+
if (cause !== undefined)
|
|
38
|
+
this.cause = cause;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class SystemException extends Exception {
|
|
42
|
+
stack;
|
|
43
|
+
constructor(error) {
|
|
44
|
+
super(codes.System, typeof error === 'string' ? error : error.message);
|
|
45
|
+
if (typeof error !== 'string' && error.stack !== undefined)
|
|
46
|
+
this.stack = error.stack;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A call refused for where it has been rather than for what it says. Named, and so permanent:
|
|
51
|
+
* the chain is deterministic, and another attempt reproduces it hop for hop.
|
|
52
|
+
*/
|
|
53
|
+
export class LoopException extends Exception {
|
|
54
|
+
/** the whole chain, so what is set aside can be read without guessing */
|
|
55
|
+
trail;
|
|
56
|
+
constructor(message, trail) {
|
|
57
|
+
super(codes.Loop, message);
|
|
58
|
+
this.trail = trail;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class ContractException extends Exception {
|
|
62
|
+
constructor(code, error, cause) {
|
|
63
|
+
super(code ?? codes.Contract, typeof error === 'string' ? error : (error?.message ?? ''), cause);
|
|
64
|
+
if (typeof error === 'object' && error !== null)
|
|
65
|
+
for (const k of [
|
|
66
|
+
'keyword',
|
|
67
|
+
'instancePath',
|
|
68
|
+
'schemaPath',
|
|
69
|
+
'params',
|
|
70
|
+
'propertyName'
|
|
71
|
+
])
|
|
72
|
+
if (k in error)
|
|
73
|
+
this[k] = error[k];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class RequestContractException extends ContractException {
|
|
77
|
+
constructor(error, cause) {
|
|
78
|
+
super(codes.RequestContract, error, cause);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export class ResponseContractException extends ContractException {
|
|
82
|
+
constructor(error, cause) {
|
|
83
|
+
super(codes.ResponseContract, error, cause);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export class EntityContractException extends ContractException {
|
|
87
|
+
constructor(error, cause) {
|
|
88
|
+
super(codes.EntityContract, error, cause);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export class EntityGuardException extends ContractException {
|
|
92
|
+
constructor(name, cause) {
|
|
93
|
+
super(codes.EntityGuard, name, cause);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function derive(name) {
|
|
97
|
+
const classname = name + 'Exception';
|
|
98
|
+
const derived = class extends Exception {
|
|
99
|
+
constructor(message, cause) {
|
|
100
|
+
super(codes[name], message === undefined ? classname : `${classname}: ${message}`, cause);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
// the name is the class's own, and a class expression has none worth reporting
|
|
104
|
+
Object.defineProperty(derived, 'name', { value: classname });
|
|
105
|
+
return derived;
|
|
106
|
+
}
|
|
107
|
+
export const RequestSyntaxException = derive('RequestSyntax');
|
|
108
|
+
export const RequestConflictException = derive('RequestConflict');
|
|
109
|
+
export const QuerySyntaxException = derive('QuerySyntax');
|
|
110
|
+
export const StateException = derive('State');
|
|
111
|
+
export const StateNotFoundException = derive('StateNotFound');
|
|
112
|
+
export const StatePreconditionException = derive('StatePrecondition');
|
|
113
|
+
export const StateConcurrencyException = derive('StateConcurrency');
|
|
114
|
+
export const StateInitializationException = derive('StateInitialization');
|
|
115
|
+
export const DuplicateException = derive('Duplicate');
|
|
116
|
+
export const DuplicateCallException = derive('DuplicateCall');
|
|
117
|
+
export const CommunicationException = derive('Communication');
|
|
118
|
+
export const TransmissionException = derive('Transmission');
|
|
119
|
+
export const EndpointException = derive('Endpoint');
|
|
120
|
+
export const AddresseeException = derive('Addressee');
|
|
121
|
+
export const AbandonedException = derive('Abandoned');
|
|
122
|
+
export const names = swap(codes);
|
|
123
|
+
// #endregion
|
|
124
|
+
/**
|
|
125
|
+
* Whether a failure means the same thing on a later attempt.
|
|
126
|
+
*
|
|
127
|
+
* Every code answers, and the answer is here rather than inferred: `Record<keyof typeof codes>`
|
|
128
|
+
* refuses to compile until a code added later says which it is. What core names, core raised on
|
|
129
|
+
* purpose — a contract does not start fitting, a version that has passed does not come back.
|
|
130
|
+
* `System` is the exception that proves it: it is a code like any other, and what it wraps is
|
|
131
|
+
* whatever reached core from below, which is the kind that passes.
|
|
132
|
+
*/
|
|
133
|
+
const OUTCOME = {
|
|
134
|
+
// whatever the algorithm or a connector threw: core neither chose it nor can read it
|
|
135
|
+
System: 'transient',
|
|
136
|
+
Contract: 'permanent',
|
|
137
|
+
RequestSyntax: 'permanent',
|
|
138
|
+
RequestContract: 'permanent',
|
|
139
|
+
RequestConflict: 'permanent',
|
|
140
|
+
ResponseContract: 'permanent',
|
|
141
|
+
EntityContract: 'permanent',
|
|
142
|
+
EntityGuard: 'permanent',
|
|
143
|
+
QuerySyntax: 'permanent',
|
|
144
|
+
State: 'permanent',
|
|
145
|
+
// an event about an entity can outrun the one that creates it; nothing promises order
|
|
146
|
+
StateNotFound: 'transient',
|
|
147
|
+
// an entity's version only grows, so one that has passed does not start matching
|
|
148
|
+
StatePrecondition: 'permanent',
|
|
149
|
+
// the compare-and-swap lost, which is the case a later attempt exists for
|
|
150
|
+
StateConcurrency: 'transient',
|
|
151
|
+
StateInitialization: 'permanent',
|
|
152
|
+
Duplicate: 'permanent',
|
|
153
|
+
// a call that has been made stays made: another attempt is refused by the same record
|
|
154
|
+
DuplicateCall: 'permanent',
|
|
155
|
+
Communication: 'transient',
|
|
156
|
+
// nothing is listening on that queue yet — a deployment in progress, most of the time
|
|
157
|
+
Transmission: 'transient',
|
|
158
|
+
// its sibling, and the other way round: nothing carried the call is a moment,
|
|
159
|
+
// there is nothing to carry it to is a fact
|
|
160
|
+
Endpoint: 'permanent',
|
|
161
|
+
// a process that lost its broker connection claims its name again once it is restored
|
|
162
|
+
Addressee: 'transient',
|
|
163
|
+
// what the caller gave up on may have run, and may run yet
|
|
164
|
+
Abandoned: 'transient',
|
|
165
|
+
// the chain is deterministic, so another attempt walks it again: a retry is another cycle
|
|
166
|
+
Loop: 'permanent'
|
|
167
|
+
};
|
|
168
|
+
const PERMANENT = new Set(Object.entries(OUTCOME)
|
|
169
|
+
.filter(([, outcome]) => outcome === 'permanent')
|
|
170
|
+
.map(([name]) => codes[name]));
|
|
171
|
+
/**
|
|
172
|
+
* Takes `unknown` because a caller has caught something rather than been handed an `Exception`.
|
|
173
|
+
* Anything core did not raise — an error from a driver, a rejection with no code at all — is not
|
|
174
|
+
* on the list, and is therefore worth trying again.
|
|
175
|
+
*/
|
|
176
|
+
export function permanent(exception) {
|
|
177
|
+
const code = exception?.code;
|
|
178
|
+
return code !== undefined && PERMANENT.has(code);
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=exceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../source/exceptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAGtC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,CAAC;IAET,QAAQ,EAAE,GAAG;IACb,aAAa,EAAE,GAAG;IAClB,eAAe,EAAE,GAAG;IACpB,eAAe,EAAE,GAAG;IACpB,gBAAgB,EAAE,GAAG;IACrB,cAAc,EAAE,GAAG;IACnB,WAAW,EAAE,GAAG;IAChB,WAAW,EAAE,GAAG;IAEhB,KAAK,EAAE,GAAG;IACV,aAAa,EAAE,GAAG;IAClB,iBAAiB,EAAE,GAAG;IACtB,gBAAgB,EAAE,GAAG;IACrB,mBAAmB,EAAE,GAAG;IACxB,SAAS,EAAE,GAAG;IACd,8DAA8D;IAC9D,aAAa,EAAE,GAAG;IAElB,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,GAAG;IACjB,QAAQ,EAAE,GAAG;IACb,oDAAoD;IACpD,SAAS,EAAE,GAAG;IACd,mEAAmE;IACnE,SAAS,EAAE,GAAG;IAEd,qFAAqF;IACrF,IAAI,EAAE,GAAG;CACV,CAAA;AAED,MAAM,OAAO,SAAS;IACJ,IAAI,CAAQ;IACZ,OAAO,CAAQ;IACxB,KAAK,CAAW;IAKvB,YAAmB,IAAY,EAAE,OAAe,EAAE,KAAe;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QAEtB,IAAI,KAAK,KAAK,SAAS;YAAE,I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WAAW;IAC3B,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,WAAW;IAExB,KAAK,EAAE,WAAW;IAClB,sFAAsF;IACtF,aAAa,EAAE,WAAW;IAC1B,iFAAiF;IACjF,iBAAiB,EAAE,WAAW;IAC9B,0EAA0E;IAC1E,gBAAgB,EAAE,WAAW;IAC7B,mBAAmB,EAAE,WAAW;IAChC,SAAS,EAAE,WAAW;IACtB,sFAAsF;IACtF,aAAa,EAAE,WAAW;IAE1B,aAAa,EAAE,WAAW;IAC1B,sFAAsF;IACtF,YAAY,EAAE,WAAW;IACzB,8EAA8E;IAC9E,4CAA4C;IAC5C,QAAQ,EAAE,WAAW;IACrB,sFAAsF;IACtF,SAAS,EAAE,WAAW;IACtB,2DAA2D;IAC3D,SAAS,EAAE,WAAW;IAEtB,0FAA0F;IAC1F,IAAI,EAAE,WAAW;CAClB,CAAA;AAED,MAAM,SAAS,GAAG,IAAI,GAAG,CACvB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;KACpB,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,WAAW,CAAC;KAChD,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAA0B,CAAC,CAAC,CACtD,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,SAAkB;IAC1C,MAAM,IAAI,GAAI,SAAmC,EAAE,IAAI,CAAA;IAEvD,OAAO,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Connector } from './connector.js';
|
|
2
|
+
import type { Locator } from './locator.js';
|
|
3
|
+
interface Manifest {
|
|
4
|
+
namespace: string;
|
|
5
|
+
name: string;
|
|
6
|
+
entity?: object;
|
|
7
|
+
operations?: object;
|
|
8
|
+
events?: object;
|
|
9
|
+
}
|
|
10
|
+
export declare class Exposition extends Connector {
|
|
11
|
+
#private;
|
|
12
|
+
readonly locator: Locator;
|
|
13
|
+
constructor(locator: Locator, manifest: Manifest);
|
|
14
|
+
invoke(): Promise<{
|
|
15
|
+
output: Partial<Manifest>;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Connector } from './connector.js';
|
|
2
|
+
export class Exposition extends Connector {
|
|
3
|
+
locator;
|
|
4
|
+
#exposition;
|
|
5
|
+
constructor(locator, manifest) {
|
|
6
|
+
super();
|
|
7
|
+
this.locator = locator;
|
|
8
|
+
this.#exposition = expose(manifest);
|
|
9
|
+
}
|
|
10
|
+
async invoke() {
|
|
11
|
+
return { output: this.#exposition };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function expose(manifest) {
|
|
15
|
+
const { namespace, name, entity, operations, events } = manifest;
|
|
16
|
+
return { namespace, name, entity, operations, events };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=exposition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposition.js","sourceRoot":"","sources":["../source/exposition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAW1C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvB,OAAO,CAAS;IAEvB,WAAW,CAAmB;IAEvC,YAAmB,OAAgB,EAAE,QAAkB;QACrD,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;CACF;AAED,SAAS,MAAM,CAAC,QAAkB;IAChC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAA;IAEhE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../source/guard.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,KAAK;IACA,IAAI,CAAQ;IAEnB,OAAO,CAAQ;IAExB,YAAmB,IAAY,EAAE,MAAc;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAEM,GAAG,CAAC,KAAa,EAAE,MAAqB;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export { Assignment } from './assignment.js';
|
|
2
|
+
export { Call } from './call.js';
|
|
3
|
+
export { Cascade } from './cascade.js';
|
|
4
|
+
export { Component } from './component.js';
|
|
5
|
+
export { Composition } from './composition.js';
|
|
6
|
+
export { Connector } from './connector.js';
|
|
7
|
+
export { Context } from './context.js';
|
|
8
|
+
export { Discovery } from './discovery.js';
|
|
9
|
+
export { Effect } from './effect.js';
|
|
10
|
+
export { Emission } from './emission.js';
|
|
11
|
+
export { Event } from './event.js';
|
|
12
|
+
export { Exposition } from './exposition.js';
|
|
13
|
+
export { Locator } from './locator.js';
|
|
14
|
+
export { Observation } from './observation.js';
|
|
15
|
+
export { Outbox } from './outbox.js';
|
|
16
|
+
export { Operation } from './operation.js';
|
|
17
|
+
export { Query } from './query.js';
|
|
18
|
+
export { Receiver } from './receiver.js';
|
|
19
|
+
export { Reflection } from './reflection.js';
|
|
20
|
+
export { Remote } from './remote.js';
|
|
21
|
+
export { State } from './state.js';
|
|
22
|
+
export { Transition } from './transition.js';
|
|
23
|
+
export { Transmission } from './transmission.js';
|
|
24
|
+
export { Unmanaged } from './unmanaged.js';
|
|
25
|
+
export { Guard } from './guard.js';
|
|
26
|
+
export { instance } from './instance.js';
|
|
27
|
+
export * as entities from './entities/index.js';
|
|
28
|
+
export * as exceptions from './exceptions.js';
|
|
29
|
+
export * as trail from './trail.js';
|
|
30
|
+
export * as contract from './contract/index.js';
|
|
31
|
+
export type { Exception } from './exceptions.js';
|
|
32
|
+
export type { Invocable } from './component.js';
|
|
33
|
+
export type { Explicable } from './remote.js';
|
|
34
|
+
export type { Scoped, Store } from './operation.js';
|
|
35
|
+
export type { Source as ReflectionSource } from './reflection.js';
|
|
36
|
+
export type { Explanation } from './contract/request.js';
|
|
37
|
+
export type { JSONSchema } from './contract/schemas.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { Assignment } from './assignment.js';
|
|
2
|
+
export { Call } from './call.js';
|
|
3
|
+
export { Cascade } from './cascade.js';
|
|
4
|
+
export { Component } from './component.js';
|
|
5
|
+
export { Composition } from './composition.js';
|
|
6
|
+
export { Connector } from './connector.js';
|
|
7
|
+
export { Context } from './context.js';
|
|
8
|
+
export { Discovery } from './discovery.js';
|
|
9
|
+
export { Effect } from './effect.js';
|
|
10
|
+
export { Emission } from './emission.js';
|
|
11
|
+
export { Event } from './event.js';
|
|
12
|
+
export { Exposition } from './exposition.js';
|
|
13
|
+
export { Locator } from './locator.js';
|
|
14
|
+
export { Observation } from './observation.js';
|
|
15
|
+
export { Outbox } from './outbox.js';
|
|
16
|
+
export { Operation } from './operation.js';
|
|
17
|
+
export { Query } from './query.js';
|
|
18
|
+
export { Receiver } from './receiver.js';
|
|
19
|
+
export { Reflection } from './reflection.js';
|
|
20
|
+
export { Remote } from './remote.js';
|
|
21
|
+
export { State } from './state.js';
|
|
22
|
+
export { Transition } from './transition.js';
|
|
23
|
+
export { Transmission } from './transmission.js';
|
|
24
|
+
export { Unmanaged } from './unmanaged.js';
|
|
25
|
+
export { Guard } from './guard.js';
|
|
26
|
+
export { instance } from './instance.js';
|
|
27
|
+
export * as entities from './entities/index.js';
|
|
28
|
+
export * as exceptions from './exceptions.js';
|
|
29
|
+
export * as trail from './trail.js';
|
|
30
|
+
export * as contract from './contract/index.js';
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name this process answers addressed calls under, and what a call to one of its stateful
|
|
3
|
+
* operations names: given by `TOA_INSTANCE`, or generated once.
|
|
4
|
+
*
|
|
5
|
+
* It is kept where every copy of this package reads it, because a binding and a component loaded
|
|
6
|
+
* against two copies must agree on whose name a call carries.
|
|
7
|
+
*/
|
|
8
|
+
export declare function instance(): string;
|
|
9
|
+
/** How long an addressed call waits where it names no timeout of its own, in milliseconds. */
|
|
10
|
+
export declare function timeout(): number;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { environment } from '@toa.io/generic';
|
|
2
|
+
import { newid } from './entities/newid.js';
|
|
3
|
+
const KEY = Symbol.for('toa.core.instance');
|
|
4
|
+
// what a queue name may carry, short enough that one made of it stays within a broker's limit
|
|
5
|
+
const NAME = /^[\w.:-]{1,64}$/;
|
|
6
|
+
const TIMEOUT = 5000;
|
|
7
|
+
/**
|
|
8
|
+
* The name this process answers addressed calls under, and what a call to one of its stateful
|
|
9
|
+
* operations names: given by `TOA_INSTANCE`, or generated once.
|
|
10
|
+
*
|
|
11
|
+
* It is kept where every copy of this package reads it, because a binding and a component loaded
|
|
12
|
+
* against two copies must agree on whose name a call carries.
|
|
13
|
+
*/
|
|
14
|
+
export function instance() {
|
|
15
|
+
return (globalThis[KEY] ??= named());
|
|
16
|
+
}
|
|
17
|
+
/** How long an addressed call waits where it names no timeout of its own, in milliseconds. */
|
|
18
|
+
export function timeout() {
|
|
19
|
+
const value = Number(environment.get('TOA_ADDRESSED_TIMEOUT'));
|
|
20
|
+
return Number.isInteger(value) && value > 0 ? value : TIMEOUT;
|
|
21
|
+
}
|
|
22
|
+
function named() {
|
|
23
|
+
const given = environment.get('TOA_INSTANCE');
|
|
24
|
+
if (given === undefined)
|
|
25
|
+
return newid();
|
|
26
|
+
if (!NAME.test(given))
|
|
27
|
+
throw new Error(`TOA_INSTANCE '${given}' must be 1 to 64 letters, digits, '_', '-', '.' or ':'`);
|
|
28
|
+
return given;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../source/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAI3C,8FAA8F;AAC9F,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAE9B,MAAM,OAAO,GAAG,IAAI,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAE,UAAoB,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;AACjD,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,OAAO;IACrB,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAA;IAE9D,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;AAC/D,CAAC;AAED,SAAS,KAAK;IACZ,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAE7C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,EAAE,CAAA;IAEvC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,iBAAiB,KAAK,yDAAyD,CAChF,CAAA;IAEH,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Where a component is, as every name derived from it. */
|
|
2
|
+
export declare class Locator {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly namespace: string | undefined;
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly uppercase: string;
|
|
8
|
+
readonly lowercase: string;
|
|
9
|
+
constructor(name: string, namespace?: string);
|
|
10
|
+
static parse(string: string): Locator;
|
|
11
|
+
hostname(prefix?: string): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { concat } from '@toa.io/generic';
|
|
2
|
+
/** Where a component is, as every name derived from it. */
|
|
3
|
+
export class Locator {
|
|
4
|
+
name;
|
|
5
|
+
namespace;
|
|
6
|
+
id;
|
|
7
|
+
label;
|
|
8
|
+
uppercase;
|
|
9
|
+
lowercase;
|
|
10
|
+
constructor(name, namespace) {
|
|
11
|
+
if (name === undefined)
|
|
12
|
+
throw new TypeError('Locator name must be defined');
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.namespace = namespace;
|
|
15
|
+
this.id = concat(namespace, '.') + name;
|
|
16
|
+
this.label = (concat(namespace, '-') + name).toLowerCase();
|
|
17
|
+
this.uppercase = (concat(namespace, '_') + name).toUpperCase();
|
|
18
|
+
this.lowercase = (concat(namespace, '_') + name).toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
static parse(string) {
|
|
21
|
+
const [namespace, name] = string.split(DOT);
|
|
22
|
+
if (name === undefined)
|
|
23
|
+
return new Locator(namespace);
|
|
24
|
+
else
|
|
25
|
+
return new Locator(name, namespace);
|
|
26
|
+
}
|
|
27
|
+
hostname(prefix) {
|
|
28
|
+
return concat(prefix?.toLowerCase(), '-') + this.label;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const DOT = '.';
|
|
32
|
+
//# sourceMappingURL=locator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locator.js","sourceRoot":"","sources":["../source/locator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,2DAA2D;AAC3D,MAAM,OAAO,OAAO;IACF,IAAI,CAAQ;IACZ,SAAS,CAAoB;IAE7B,EAAE,CAAQ;IACV,KAAK,CAAQ;IACb,SAAS,CAAQ;IACjB,SAAS,CAAQ;IAEjC,YAAmB,IAAY,EAAE,SAAkB;QACjD,IAAI,IAAI,KAAK,SAAS;YAAE,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAA;QAE3E,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAE1B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;QACvC,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;QAC1D,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;QAC9D,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;IAChE,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAc;QAChC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE3C,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,CAAA;;YAChD,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAC1C,CAAC;IAEM,QAAQ,CAAC,MAAe;QAC7B,OAAO,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAA;IACxD,CAAC;CACF;AAED,MAAM,GAAG,GAAG,GAAG,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Operation } from './operation.js';
|
|
2
|
+
export class Observation extends Operation {
|
|
3
|
+
async run(store) {
|
|
4
|
+
const scope = store.scope;
|
|
5
|
+
if (scope === null ||
|
|
6
|
+
(scope?.deleted === true && store.request.query?.options?.deleted !== true))
|
|
7
|
+
store.reply = null;
|
|
8
|
+
else
|
|
9
|
+
await super.run(store);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=observation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observation.js","sourceRoot":"","sources":["../source/observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI1C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACrB,KAAK,CAAC,GAAG,CAAC,KAAY;QACvC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAsB,CAAA;QAE1C,IACE,KAAK,KAAK,IAAI;YACd,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,IAAK,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;YAEpF,KAAK,CAAC,KAAK,GAAG,IAAI,CAAA;;YACf,MAAM,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { Connector } from './connector.js';
|
|
3
|
+
import type { Cascade } from './cascade.js';
|
|
4
|
+
import type { State } from './state.js';
|
|
5
|
+
import type { Query as Translator } from './query.js';
|
|
6
|
+
import type { Contract } from './contract/contract.js';
|
|
7
|
+
import type { Entity } from './entities/entity.js';
|
|
8
|
+
import type { EntitySet } from './entities/set.js';
|
|
9
|
+
import type { Changeset } from './entities/changeset.js';
|
|
10
|
+
import type { scope as Scope } from './types/operations.js';
|
|
11
|
+
import type { Call } from './types/inbox.js';
|
|
12
|
+
import type { Envelope, Query } from './types/request.js';
|
|
13
|
+
/** What an operation acquires for the algorithm to run against. */
|
|
14
|
+
export type Scoped = Entity | EntitySet | Changeset | Readable | null;
|
|
15
|
+
/** What one invocation carries from step to step. */
|
|
16
|
+
export interface Store {
|
|
17
|
+
request: Envelope;
|
|
18
|
+
scope?: Scoped;
|
|
19
|
+
state?: any;
|
|
20
|
+
reply?: any;
|
|
21
|
+
/** set by a transition, which is the only operation that runs its steps again */
|
|
22
|
+
retry?: () => Promise<any>;
|
|
23
|
+
}
|
|
24
|
+
export interface Contracts {
|
|
25
|
+
request: Contract;
|
|
26
|
+
reply: Contract;
|
|
27
|
+
}
|
|
28
|
+
export interface Definition {
|
|
29
|
+
scope: Scope;
|
|
30
|
+
concurrency?: string;
|
|
31
|
+
/** whether the same call arriving twice changes state once; see `documentation/inbox.md` */
|
|
32
|
+
once?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare class Operation extends Connector {
|
|
35
|
+
#private;
|
|
36
|
+
scope: State;
|
|
37
|
+
/**
|
|
38
|
+
* Whether what this operation acquires may be modified and committed. Only a
|
|
39
|
+
* transition commits, and only a commit needs the pre-image an entity keeps
|
|
40
|
+
* to diff the new state against.
|
|
41
|
+
*
|
|
42
|
+
* @protected
|
|
43
|
+
*/
|
|
44
|
+
protected mutable: boolean;
|
|
45
|
+
constructor(cascade: Cascade, scope: State, contracts: Contracts, query: Translator, definition: Definition);
|
|
46
|
+
invoke(request: Envelope): Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* The call, once. What it answered is recorded with what it changed, in one transaction, so a
|
|
49
|
+
* second arrival of the same identity finds the key taken, changes nothing, and is answered
|
|
50
|
+
* with what the first one answered.
|
|
51
|
+
*
|
|
52
|
+
* The read in front of it is not what makes that true — the key is — but it is what keeps the
|
|
53
|
+
* ordinary duplicate from running the algorithm at all, and the ordinary duplicate is a
|
|
54
|
+
* retransmission that arrives after the first call has finished.
|
|
55
|
+
*/
|
|
56
|
+
protected once(store: Store): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* What is recorded with the write. Read where the write is made, which is after the algorithm
|
|
59
|
+
* has run, because the reply is what a duplicate is answered with.
|
|
60
|
+
*/
|
|
61
|
+
protected call(store: Store): Call | undefined;
|
|
62
|
+
protected process(store: Store): Promise<any>;
|
|
63
|
+
protected acquire(store: Store): Promise<void>;
|
|
64
|
+
protected run(store: Store): Promise<void>;
|
|
65
|
+
protected commit(_store: Store): Promise<void>;
|
|
66
|
+
protected query(query?: Query): Promise<Scoped>;
|
|
67
|
+
}
|