@bett3r-dev/pv3-types 1.0.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +305 -0
- package/build/adminPlugin.d.ts +24 -0
- package/build/adminPlugin.d.ts.map +1 -0
- package/build/{eventsourcing/utils.js → adminPlugin.js} +1 -1
- package/build/adminPlugin.js.map +1 -0
- package/build/aggregateSchema.d.ts +94 -0
- package/build/aggregateSchema.d.ts.map +1 -0
- package/build/aggregateSchema.js +287 -0
- package/build/aggregateSchema.js.map +1 -0
- package/build/authentication.d.ts +179 -78
- package/build/authentication.d.ts.map +1 -1
- package/build/authentication.js +62 -19
- package/build/authentication.js.map +1 -1
- package/build/cache.d.ts +50 -4
- package/build/cache.d.ts.map +1 -1
- package/build/clusterAdministration.d.ts +712 -225
- package/build/clusterAdministration.d.ts.map +1 -1
- package/build/clusterAdministration.js +175 -52
- package/build/clusterAdministration.js.map +1 -1
- package/build/configuration.d.ts +26 -5
- package/build/configuration.d.ts.map +1 -1
- package/build/database.d.ts +240 -56
- package/build/database.d.ts.map +1 -1
- package/build/database.js +102 -20
- package/build/database.js.map +1 -1
- package/build/endpoints.d.ts +141 -41
- package/build/endpoints.d.ts.map +1 -1
- package/build/endpoints.js +50 -26
- package/build/endpoints.js.map +1 -1
- package/build/errors.d.ts +166 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +276 -0
- package/build/errors.js.map +1 -0
- package/build/evenstore.d.ts +47 -7
- package/build/evenstore.d.ts.map +1 -1
- package/build/eventsourcing/aggregateBuilder.d.ts +17 -8
- package/build/eventsourcing/aggregateBuilder.d.ts.map +1 -1
- package/build/eventsourcing/commandBuilder.d.ts +20 -13
- package/build/eventsourcing/commandBuilder.d.ts.map +1 -1
- package/build/eventsourcing/commandHandlers.d.ts +155 -33
- package/build/eventsourcing/commandHandlers.d.ts.map +1 -1
- package/build/eventsourcing/commandHandlers.js +62 -14
- package/build/eventsourcing/commandHandlers.js.map +1 -1
- package/build/eventsourcing/eventHandlers.d.ts +173 -44
- package/build/eventsourcing/eventHandlers.d.ts.map +1 -1
- package/build/eventsourcing/eventHandlers.js +29 -21
- package/build/eventsourcing/eventHandlers.js.map +1 -1
- package/build/eventsourcing/eventHandlersBuilder.d.ts +18 -12
- package/build/eventsourcing/eventHandlersBuilder.d.ts.map +1 -1
- package/build/eventsourcing/eventHandlersBuilder.js.map +1 -1
- package/build/eventsourcing/eventsourcing.types.d.ts +322 -0
- package/build/eventsourcing/eventsourcing.types.d.ts.map +1 -0
- package/build/eventsourcing/eventsourcing.types.js +26 -0
- package/build/eventsourcing/eventsourcing.types.js.map +1 -0
- package/build/eventsourcing/externalSystemBuilder.d.ts +8 -7
- package/build/eventsourcing/externalSystemBuilder.d.ts.map +1 -1
- package/build/eventsourcing/index.d.ts +2 -378
- package/build/eventsourcing/index.d.ts.map +1 -1
- package/build/eventsourcing/index.js +2 -23
- package/build/eventsourcing/index.js.map +1 -1
- package/build/eventsourcing/invariants.d.ts +34 -10
- package/build/eventsourcing/invariants.d.ts.map +1 -1
- package/build/eventsourcing/shapeChangeForSubscriber.d.ts +33 -0
- package/build/eventsourcing/shapeChangeForSubscriber.d.ts.map +1 -0
- package/build/eventsourcing/shapeChangeForSubscriber.js +47 -0
- package/build/eventsourcing/shapeChangeForSubscriber.js.map +1 -0
- package/build/index.d.ts +6 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -1
- package/build/index.js.map +1 -1
- package/build/infrastructure.d.ts +9 -1
- package/build/infrastructure.d.ts.map +1 -1
- package/build/infrastructure.js +33 -1
- package/build/infrastructure.js.map +1 -1
- package/build/livenessWatchdog.d.ts +28 -0
- package/build/livenessWatchdog.d.ts.map +1 -0
- package/build/livenessWatchdog.js +43 -0
- package/build/livenessWatchdog.js.map +1 -0
- package/build/logger.d.ts +8 -9
- package/build/logger.d.ts.map +1 -1
- package/build/logger.js +18 -6
- package/build/logger.js.map +1 -1
- package/build/outboxManager.d.ts +858 -14
- package/build/outboxManager.d.ts.map +1 -1
- package/build/outboxManager.js +173 -15
- package/build/outboxManager.js.map +1 -1
- package/build/permissions.d.ts +47 -0
- package/build/permissions.d.ts.map +1 -0
- package/build/permissions.js +3 -0
- package/build/permissions.js.map +1 -0
- package/build/ports.d.ts +10 -10
- package/build/ports.d.ts.map +1 -1
- package/build/routesAuth.d.ts +17 -25
- package/build/routesAuth.d.ts.map +1 -1
- package/build/routesAuth.js +4 -14
- package/build/routesAuth.js.map +1 -1
- package/build/typedEventEmitter.d.ts +7 -13
- package/build/typedEventEmitter.d.ts.map +1 -1
- package/build/typedEventEmitter.js +2 -2
- package/build/typedEventEmitter.js.map +1 -1
- package/build/userSession.d.ts +8 -0
- package/build/userSession.d.ts.map +1 -0
- package/build/userSession.js +3 -0
- package/build/userSession.js.map +1 -0
- package/package.json +22 -7
- package/build/eventsourcing/utils.d.ts +0 -4
- package/build/eventsourcing/utils.d.ts.map +0 -1
- package/build/eventsourcing/utils.js.map +0 -1
- package/build/validation.d.ts +0 -64
- package/build/validation.d.ts.map +0 -1
- package/build/validation.js +0 -57
- package/build/validation.js.map +0 -1
- package/src/authentication.ts +0 -273
- package/src/cache.ts +0 -109
- package/src/clusterAdministration.ts +0 -216
- package/src/configuration.ts +0 -71
- package/src/database.ts +0 -157
- package/src/endpoints.ts +0 -198
- package/src/evenstore.ts +0 -27
- package/src/eventsourcing/aggregateBuilder.ts +0 -11
- package/src/eventsourcing/commandBuilder.ts +0 -64
- package/src/eventsourcing/commandHandlers.ts +0 -137
- package/src/eventsourcing/eventHandlers.ts +0 -118
- package/src/eventsourcing/eventHandlersBuilder.ts +0 -42
- package/src/eventsourcing/externalSystemBuilder.ts +0 -20
- package/src/eventsourcing/index.ts +0 -111
- package/src/eventsourcing/invariants.ts +0 -27
- package/src/eventsourcing/utils.ts +0 -4
- package/src/index.ts +0 -15
- package/src/infrastructure.ts +0 -41
- package/src/logger.ts +0 -45
- package/src/outboxManager.ts +0 -36
- package/src/ports.ts +0 -42
- package/src/routesAuth.ts +0 -58
- package/src/typedEventEmitter.ts +0 -73
- package/src/validation.ts +0 -89
- package/tsconfig.json +0 -15
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import S, { mergeSchemas, omitFromSchema } from '@bett3r-dev/jsonschema-definer';
|
|
2
|
-
import { CommittedEvent, Event } from '@bett3r-dev/pv3-types';
|
|
3
|
-
|
|
4
|
-
export type ClusterStructureType = {
|
|
5
|
-
getCurrentState: ( id?: string ) => Promise<StructureState>,
|
|
6
|
-
getStructureRevision: ( version:number ) => Promise<StructureState | null>,
|
|
7
|
-
subscribeToStructureChanges: ( onStructureChanges: ( change: StructureState ) => void ) => Promise<{ unsubscribe: () => void }>,
|
|
8
|
-
stop: () => Promise<void>,
|
|
9
|
-
} & {
|
|
10
|
-
[key in keyof CommandTypes]: ( payload: CommandTypes[key], expectedVersion?: number ) => Promise<StructureState>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type StructureState = {
|
|
14
|
-
state: StructureAggregateType,
|
|
15
|
-
version: number,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type StructureCommittedEventType = CommittedEvent<StructureAggregateType & {
|
|
19
|
-
change: {
|
|
20
|
-
broker: {host: string};
|
|
21
|
-
service: {host: string};
|
|
22
|
-
subscriptions: {subscriptions: Record<string,number>};
|
|
23
|
-
}
|
|
24
|
-
}>
|
|
25
|
-
|
|
26
|
-
export const StructureServiceSchema = S.shape({
|
|
27
|
-
hosts: S.array().items( S.string()),
|
|
28
|
-
port: S.number().default( 1984 ).optional(),
|
|
29
|
-
channel: S.string().enum( 'tcp', 'http', 'local' ).default( 'http' ).optional(),
|
|
30
|
-
isExternal: S.boolean().default( false ).optional(),
|
|
31
|
-
possibleSubscriptions: S.array().items( S.string()).optional(),
|
|
32
|
-
possibleModules: S.shape({}).additionalProperties( S.array().items( S.string())).optional(),
|
|
33
|
-
isService: S.boolean().optional(),
|
|
34
|
-
isBroker: S.boolean().optional(),
|
|
35
|
-
endpoints: S.array().items( S.string()).optional(),
|
|
36
|
-
openApiEndpoint: S.string().optional().default( '/documentation/json' ),
|
|
37
|
-
produces: S.shape({}).additionalProperties( S.array().items( S.string())).optional(),
|
|
38
|
-
consumes: S.shape({}).additionalProperties( S.array().items( S.string())).optional(),
|
|
39
|
-
});
|
|
40
|
-
export type StructureServiceType = typeof StructureServiceSchema.type;
|
|
41
|
-
|
|
42
|
-
export const RetryableStatuses = [ 429, 503, 504 ];
|
|
43
|
-
|
|
44
|
-
export const StructureSubscriptionSchema = S.shape({
|
|
45
|
-
producers: S.array().items( S.string()),
|
|
46
|
-
module: S.string(),
|
|
47
|
-
consumer: S.string(),
|
|
48
|
-
load: S.number().optional(),
|
|
49
|
-
eventstore: S.string().optional(),
|
|
50
|
-
events: S.array().items( S.string()).optional(),
|
|
51
|
-
manualDataSplits: S.number().minimum( 1 ).optional(),
|
|
52
|
-
mirrorDataSplitsWithConsumers: S.boolean().optional().default( true ),
|
|
53
|
-
customDataSplits: S.array().items( S.array().items( S.string())).optional(),
|
|
54
|
-
streams: S.string().optional(),
|
|
55
|
-
endpoint: S.string().optional(),
|
|
56
|
-
retryAfterSecs: S.number().optional(),
|
|
57
|
-
retryableStatuses: S.array().items( S.number()).default( RetryableStatuses ).optional(),
|
|
58
|
-
dataSplits: S.shape({
|
|
59
|
-
custom: S.array().items( S.string()),
|
|
60
|
-
manual: S.array().items( S.string()),
|
|
61
|
-
automatic: S.array().items( S.string()),
|
|
62
|
-
}).partial().optional(),
|
|
63
|
-
});
|
|
64
|
-
export type StructureSubscriptionType = typeof StructureSubscriptionSchema.type;
|
|
65
|
-
|
|
66
|
-
export const StructureBrokerSubscriptionSchema = S.shape({
|
|
67
|
-
host: S.string(),
|
|
68
|
-
index: S.number(),
|
|
69
|
-
custom: S.array().items( S.string()).optional()
|
|
70
|
-
});
|
|
71
|
-
export type StructureBrokerSubscriptionType = typeof StructureBrokerSubscriptionSchema.type;
|
|
72
|
-
|
|
73
|
-
export const StructureBrokerSchema = S.shape({
|
|
74
|
-
host: S.string(),
|
|
75
|
-
subscriptions: S.shape({}).additionalProperties(
|
|
76
|
-
S.shape({}).additionalProperties( StructureBrokerSubscriptionSchema )
|
|
77
|
-
),
|
|
78
|
-
});
|
|
79
|
-
export type StructureBrokerType = typeof StructureBrokerSchema.type;
|
|
80
|
-
|
|
81
|
-
export const StructureSubscriptionsSchema = S.shape({})
|
|
82
|
-
.additionalProperties( StructureSubscriptionSchema );
|
|
83
|
-
|
|
84
|
-
export const StructureServicesSchema = S.shape({})
|
|
85
|
-
.additionalProperties( StructureServiceSchema );
|
|
86
|
-
export type StructureServicesType = typeof StructureServicesSchema.type;
|
|
87
|
-
|
|
88
|
-
export const StructureBrokersSchema = S.shape({})
|
|
89
|
-
.additionalProperties( omitFromSchema( StructureBrokerSchema, ['host']));
|
|
90
|
-
|
|
91
|
-
export const StructureAggregateSchema = S.shape({
|
|
92
|
-
subscriptions: StructureSubscriptionsSchema,
|
|
93
|
-
services: StructureServicesSchema,
|
|
94
|
-
brokers: StructureBrokersSchema,
|
|
95
|
-
clusterRevision: S.number(),
|
|
96
|
-
servicesRevisionAck: S.array().items( S.string())
|
|
97
|
-
});
|
|
98
|
-
export type StructureAggregateType = typeof StructureAggregateSchema.type;
|
|
99
|
-
|
|
100
|
-
export const AddSubscriptionsCommandSchema = S.shape({
|
|
101
|
-
subscriptions: StructureSubscriptionsSchema, doNotRebalance: S.boolean().optional()
|
|
102
|
-
});
|
|
103
|
-
export const EditSubscriptionCommandSchema = S.shape({
|
|
104
|
-
id: S.string(),
|
|
105
|
-
subscription: StructureSubscriptionSchema.partial(),
|
|
106
|
-
doNotRebalance: S.boolean().optional()
|
|
107
|
-
});
|
|
108
|
-
export const DeleteSubscriptionCommandSchema = S.shape({
|
|
109
|
-
id: S.string(),
|
|
110
|
-
doNotRebalance: S.boolean().optional()
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
export const UpsertHostCommandSchema = mergeSchemas( omitFromSchema( StructureServiceSchema, ['hosts']), S.shape({
|
|
114
|
-
service: S.string(),
|
|
115
|
-
host: S.string(),
|
|
116
|
-
doNotRebalance: S.boolean().optional()
|
|
117
|
-
}));
|
|
118
|
-
export type UpsertHostCommandType = typeof UpsertHostCommandSchema.type;
|
|
119
|
-
|
|
120
|
-
export const RemoveHostCommandSchema = S.shape({ host: S.string() });
|
|
121
|
-
|
|
122
|
-
export const SetStructureUpsertHostCommandSchema = mergeSchemas( StructureServiceSchema, S.shape({
|
|
123
|
-
service: S.string(),
|
|
124
|
-
}));
|
|
125
|
-
export const SetStructureCommandSchema = S.shape({
|
|
126
|
-
upsertHosts: S.array().items( UpsertHostCommandSchema ),
|
|
127
|
-
removeHosts: S.array().items( S.string()),
|
|
128
|
-
subscriptions: StructureSubscriptionsSchema.optional()
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
export const RebalanceSubscriptionsCommandSchema = S.shape({})
|
|
132
|
-
.additionalProperties( omitFromSchema( StructureBrokerSchema, ['host']));
|
|
133
|
-
export type RebalanceSubscriptionsCommandType = typeof RebalanceSubscriptionsCommandSchema.type;
|
|
134
|
-
|
|
135
|
-
export const RemoveBrokerCommandSchema = S.shape({ host: S.string() });
|
|
136
|
-
|
|
137
|
-
export const AckStructureSchema = S.shape({ host: S.string(), revision: S.number() });
|
|
138
|
-
|
|
139
|
-
export type CommandTypes = {
|
|
140
|
-
UpsertHost: typeof UpsertHostCommandSchema.type
|
|
141
|
-
RemoveHost: typeof RemoveHostCommandSchema.type
|
|
142
|
-
RebalanceSubscriptions: typeof RebalanceSubscriptionsCommandSchema.type
|
|
143
|
-
AddSubscriptions: typeof AddSubscriptionsCommandSchema.type
|
|
144
|
-
EditSubscription: typeof EditSubscriptionCommandSchema.type
|
|
145
|
-
DeleteSubscription: typeof DeleteSubscriptionCommandSchema.type
|
|
146
|
-
SetStructure: typeof SetStructureCommandSchema.type
|
|
147
|
-
AckStructure: typeof AckStructureSchema.type
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//*******************************************
|
|
151
|
-
// EVENTS
|
|
152
|
-
//*******************************************
|
|
153
|
-
|
|
154
|
-
export const structureEvents = {
|
|
155
|
-
HostUpserted: () => Event({
|
|
156
|
-
schema: S.shape({
|
|
157
|
-
services: StructureServicesSchema,
|
|
158
|
-
brokers: StructureBrokersSchema.optional(),
|
|
159
|
-
doNotRebalance: S.boolean().optional(),
|
|
160
|
-
})
|
|
161
|
-
}),
|
|
162
|
-
HostRemoved: () => Event({
|
|
163
|
-
schema: S.shape({
|
|
164
|
-
brokers: StructureBrokersSchema,
|
|
165
|
-
host: S.string(),
|
|
166
|
-
service: S.string()
|
|
167
|
-
})
|
|
168
|
-
}),
|
|
169
|
-
SubscriptionsRebalanced: () => Event({
|
|
170
|
-
schema: S.shape({
|
|
171
|
-
brokers: StructureBrokersSchema,
|
|
172
|
-
})
|
|
173
|
-
}),
|
|
174
|
-
SubscriptionsAdded: () => Event({
|
|
175
|
-
schema: S.shape({
|
|
176
|
-
brokers: StructureBrokersSchema.optional(),
|
|
177
|
-
subscriptions: StructureSubscriptionsSchema,
|
|
178
|
-
doNotRebalance: S.boolean().optional(),
|
|
179
|
-
})
|
|
180
|
-
}),
|
|
181
|
-
SubscriptionEdited: () => Event({
|
|
182
|
-
schema: S.shape({
|
|
183
|
-
brokers: StructureBrokersSchema.optional(),
|
|
184
|
-
subscriptions: StructureSubscriptionsSchema,
|
|
185
|
-
doNotRebalance: S.boolean().optional(),
|
|
186
|
-
})
|
|
187
|
-
}),
|
|
188
|
-
SubscriptionDeleted: () => Event({
|
|
189
|
-
schema: S.shape({
|
|
190
|
-
id: S.string(),
|
|
191
|
-
doNotRebalance: S.boolean().optional(),
|
|
192
|
-
brokers: StructureBrokersSchema.optional(),
|
|
193
|
-
})
|
|
194
|
-
}),
|
|
195
|
-
StructureSet: () => Event({
|
|
196
|
-
schema: StructureAggregateSchema
|
|
197
|
-
}),
|
|
198
|
-
StructureAcked: () => Event({
|
|
199
|
-
schema: AckStructureSchema
|
|
200
|
-
})
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
export const ClusterRoutesConfigSchema = S.shape({
|
|
205
|
-
clusterRoutesAggregateCollection: S.string().optional(),
|
|
206
|
-
clusterRoutesEventstoreCollection: S.string().optional(),
|
|
207
|
-
clusterRoutesEventstoreStream: S.string().optional(),
|
|
208
|
-
});
|
|
209
|
-
export type ClusterRoutesConfigType = typeof ClusterRoutesConfigSchema.type;
|
|
210
|
-
|
|
211
|
-
export const ClusterStructureConfigSchema = S.shape({
|
|
212
|
-
structureEventstoreStream: S.string().default( 'environment' ).optional(),
|
|
213
|
-
structureAggregateCollection: S.string().default( 'cluster_infrastructure' ).optional(),
|
|
214
|
-
structureEventstoreCollection: S.string().default( 'cluster_eventstore' ).optional(),
|
|
215
|
-
});
|
|
216
|
-
export type ClusterStructureConfigType = typeof ClusterStructureConfigSchema.type;
|
package/src/configuration.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ObjectSchema } from '@bett3r-dev/jsonschema-definer';
|
|
2
|
-
import { AdapterBase, PortEmitter, PortEmitterEvents } from './ports';
|
|
3
|
-
import { TypedEventEmitter } from './typedEventEmitter';
|
|
4
|
-
|
|
5
|
-
export type ConfigurationPortEmitterEvents = PortEmitterEvents & {
|
|
6
|
-
argsApplied: {config: any},
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Patches the configuration of the system with a specified object
|
|
11
|
-
* @param config The object to patch the configuration with
|
|
12
|
-
*/
|
|
13
|
-
export declare function applyConfig( config: Record<string, any> ): Promise<Record<string, any>>
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @category Main Types
|
|
17
|
-
*/
|
|
18
|
-
export type ConfigurationAdapter = AdapterBase & {
|
|
19
|
-
applyConfig: typeof applyConfig
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns a configuration for an specific module in the system
|
|
24
|
-
* @category Configuration Port
|
|
25
|
-
* @param name The name of the key in the config file structure
|
|
26
|
-
* @param schema The schema of the specific configuration piece
|
|
27
|
-
*/
|
|
28
|
-
export declare function getModuleConfig <CONFIG extends object>( name:string, schema: ObjectSchema<CONFIG, true> | ObjectSchema<CONFIG, false> ): {
|
|
29
|
-
config: CONFIG,
|
|
30
|
-
onArgsApplied: ( callback: ( config: CONFIG ) => void ) => void
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type CliArgDefinition = {
|
|
34
|
-
type: 'string' | 'number' | 'boolean',
|
|
35
|
-
name: string,
|
|
36
|
-
alias?: string,
|
|
37
|
-
description?: string,
|
|
38
|
-
default?: any
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type CliCommandDefinition = {
|
|
42
|
-
/** The name of the command, accepts positional arguments. Use <> for required and [] for optionals. Optionals might optionally accept and array like [optional..]
|
|
43
|
-
* @example
|
|
44
|
-
* 'test <required|requiredAlias> [optional1] [optional2..]'
|
|
45
|
-
*/
|
|
46
|
-
name: string,
|
|
47
|
-
alias?: string,
|
|
48
|
-
description?: string,
|
|
49
|
-
/** The descriptions for the positional arguements of the command. MUST BE SPECIFIED IN THE NAME FIRST */
|
|
50
|
-
arguments?: CliArgDefinition[],
|
|
51
|
-
handler: ( args: Record<string, any> ) => void;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @category Main Types
|
|
56
|
-
*/
|
|
57
|
-
export type ConfigurationType = {
|
|
58
|
-
_getConfig: () => Record<string, any>,
|
|
59
|
-
getModuleConfig: typeof getModuleConfig,
|
|
60
|
-
getModules: () => string[],
|
|
61
|
-
getArgs: () => Promise<Record<string, any>>,
|
|
62
|
-
applyArgs: () => Promise<Record<string, any>>,
|
|
63
|
-
emitter: TypedEventEmitter<ConfigurationPortEmitterEvents>,
|
|
64
|
-
configureCliArg: ( options: CliArgDefinition ) => void,
|
|
65
|
-
configureCliCommand: ( options: CliCommandDefinition ) => void,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @category Main Types
|
|
70
|
-
*/
|
|
71
|
-
export type ConfigurationPort = Omit<PortEmitter, 'emitter'> & ConfigurationType
|
package/src/database.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import S from '@bett3r-dev/jsonschema-definer';
|
|
2
|
-
import { AdapterBase, PortEmitter } from './ports';
|
|
3
|
-
|
|
4
|
-
export type Document = {
|
|
5
|
-
id: string|number,
|
|
6
|
-
[key: string]: any
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type IndexOptions = {
|
|
10
|
-
isUnique: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type DatabaseOps =
|
|
14
|
-
| 'eq'
|
|
15
|
-
| 'neq'
|
|
16
|
-
| 'lt'
|
|
17
|
-
| 'gt'
|
|
18
|
-
| 'lte'
|
|
19
|
-
| 'gte'
|
|
20
|
-
| 'in'
|
|
21
|
-
| 'nin'
|
|
22
|
-
| 'contains'
|
|
23
|
-
| 'notContains'
|
|
24
|
-
| 'some'
|
|
25
|
-
| 'none'
|
|
26
|
-
| 'every'
|
|
27
|
-
| 'exists'
|
|
28
|
-
| 'notExists';
|
|
29
|
-
|
|
30
|
-
export const filterOpMap = {
|
|
31
|
-
eq: <T>( a: T, b: T ) => a === b,
|
|
32
|
-
neq: <T>( a: T, b: T ) => a !== b,
|
|
33
|
-
lt: <T>( a: T, b: T ) => a < b,
|
|
34
|
-
gt: <T>( a: T, b: T ) => a > b,
|
|
35
|
-
lte: <T>( a: T, b: T ) => a <= b,
|
|
36
|
-
gte: <T>( a: T, b: T ) => a >= b,
|
|
37
|
-
in: <T>( a: T, b: T[]) => b.includes( a ),
|
|
38
|
-
nin: <T>( a: T, b: T[]) => !b.includes( a ),
|
|
39
|
-
contains: <T>( a: T[], b: T ) => a.includes( b ),
|
|
40
|
-
notContains: <T>( a: T[], b: T ) => !a.includes( b ),
|
|
41
|
-
some: <T>( a: T[], b: T[]) => a.some( x=> b.includes( x )),
|
|
42
|
-
none: <T>( a: T[], b: T[]) => !a.some( x=> b.includes( x )),
|
|
43
|
-
every: <T>( a: T[], b: T[]) => a.every( x=> b.includes( x )),
|
|
44
|
-
exists: <T>( a:T ) => !!a,
|
|
45
|
-
notExists: <T>( a:T ) => !a
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const CollectionFilterSchema = S.shape({
|
|
49
|
-
field: S.string(),
|
|
50
|
-
op: S.enum([ 'eq', 'neq', 'lt', 'gt', 'lte', 'gte', 'in', 'nin', 'contains', 'notContains', 'some', 'every', 'exists', 'notExists' ]),
|
|
51
|
-
value: S.any()
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export type CollectionFilterOR<T extends Document = any> = {
|
|
55
|
-
OR: CollectionFilter<T>[]
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type CollectionFilterAND<T extends Document = any> = {
|
|
59
|
-
AND: CollectionFilter<T>[]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type CollectionFilterInstance<Model extends Document> = {
|
|
63
|
-
field: keyof Model;
|
|
64
|
-
op: DatabaseOps;
|
|
65
|
-
value: any;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type CollectionFilter<T extends Document = any> = Partial<
|
|
69
|
-
& CollectionFilterOR<T>
|
|
70
|
-
& CollectionFilterAND<T>
|
|
71
|
-
& CollectionFilterInstance<T>
|
|
72
|
-
>
|
|
73
|
-
|
|
74
|
-
export const CollectionSortSchema = S.shape({
|
|
75
|
-
field: S.string(),
|
|
76
|
-
direction: S.enum([ 'asc', 'desc' ])
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export type CollectionSort<Model extends Document> = {
|
|
80
|
-
field: keyof Model;
|
|
81
|
-
direction?: 'asc' | 'desc';
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const CollectionQueryParamsSchema = S.shape({
|
|
85
|
-
sort: S.array().items( CollectionSortSchema ).optional(),
|
|
86
|
-
filter: S.array().items( CollectionFilterSchema ).optional(),
|
|
87
|
-
limit: S.number().optional(),
|
|
88
|
-
after: S.string().optional(),
|
|
89
|
-
select: S.array().items( S.string()).optional()
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export type CollectionQueryParams<Model extends Document> = {
|
|
93
|
-
id?: string | number;
|
|
94
|
-
limit?: number;
|
|
95
|
-
after?: string | number;
|
|
96
|
-
sort?: CollectionSort<Model>[];
|
|
97
|
-
filter?: CollectionFilter<Model>[];
|
|
98
|
-
select?: keyof Model | ( keyof Model )[]
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export type CollectionOperations<Model extends Document> = {
|
|
102
|
-
readById: ( id: string|number ) => Promise<Model|null>
|
|
103
|
-
query: ( params: CollectionQueryParams<Model> ) => Promise<Model[]>,
|
|
104
|
-
forEach: ( params: CollectionQueryParams<Model>, callback: ( record: Model, stop: () => void ) => void | Promise<void> ) => Promise<void>,
|
|
105
|
-
upsert: ( id: string | number, data: Partial<Model> ) => Promise<Model>,
|
|
106
|
-
destroyById: ( id:string | number ) => Promise<void>,
|
|
107
|
-
createMany: ( documents: Model[]) => Promise<Model[]>,
|
|
108
|
-
updateMany: ( filter: CollectionFilter<Model>[], data: Partial<Model> ) => Promise<Model[]>,
|
|
109
|
-
destroyMany: ( filter: CollectionFilter<Model>[]) => Promise<number>,
|
|
110
|
-
atomicIncrement: ( name: string, filter?: CollectionFilter<Model>, amount?: number ) => Promise<number>,
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export type DatabaseChange<Model extends Document = any> = {
|
|
114
|
-
changeType: 'insert'|'update'|'delete',
|
|
115
|
-
data?: Model,
|
|
116
|
-
previous?: Model,
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export type Collection<Model extends Document> = CollectionOperations<Model> & {
|
|
120
|
-
ensureIndex: ( properties: string[], options?: Partial<IndexOptions> ) => Promise<void>,
|
|
121
|
-
destroyIndex: ( properties: string[]) => Promise<void>,
|
|
122
|
-
watch: ( changeTypes: ( 'insert'|'update'|'delete' )[], onData: ( data: DatabaseChange<Model> ) => void, onError?: ( e: Error ) => void ) => Promise<{
|
|
123
|
-
close: () => void
|
|
124
|
-
}>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// export type DatabaseTransaction = {
|
|
128
|
-
// commitTransaction: <Model extends Document>( docs?: Model[]) => Promise<Model[] | void>,
|
|
129
|
-
// rollbackTransaction: ( error: Error ) => Promise<void>,
|
|
130
|
-
// getCollection: <Model extends Document>( collection:string ) => CollectionOperations<Model>
|
|
131
|
-
// _transaction: () => any
|
|
132
|
-
// }
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @category Main Types
|
|
137
|
-
*/
|
|
138
|
-
export type DatabaseTransaction = {
|
|
139
|
-
getCollection: <Model extends Document>( collection: string ) => CollectionOperations<Model>
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* @category Main Types
|
|
143
|
-
*/
|
|
144
|
-
export type DatabaseType = {
|
|
145
|
-
getCollection: <Model extends Document>( name:string ) => Collection<Model>
|
|
146
|
-
initTransaction: <Result = any>( operations: ( getCollection: <Model extends Document>( collection: string ) => CollectionOperations<Model> ) => Promise<Result | undefined>, retryBackoff?: number, options?: any ) => Promise<Result>;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* @category Main Types
|
|
150
|
-
*/
|
|
151
|
-
export type DatabasePort = PortEmitter & DatabaseType & {
|
|
152
|
-
_adapter: DatabaseAdapter
|
|
153
|
-
};
|
|
154
|
-
/**
|
|
155
|
-
* @category Main Types
|
|
156
|
-
*/
|
|
157
|
-
export type DatabaseAdapter<T = any> = DatabaseType & AdapterBase<T>;
|
package/src/endpoints.ts
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import S, { BaseSchema, ObjectSchema, mergeSchemas } from '@bett3r-dev/jsonschema-definer';
|
|
2
|
-
import { METHODS } from 'http';
|
|
3
|
-
import { JSONSchema7 } from 'json-schema';
|
|
4
|
-
import { AddressInfo } from 'net';
|
|
5
|
-
import { OpenAPIV3_1 } from 'openapi-types';
|
|
6
|
-
import { AdapterBase, PortEmitter } from './ports';
|
|
7
|
-
|
|
8
|
-
const CorsOptions = S.shape({
|
|
9
|
-
origin: S.string().optional(),
|
|
10
|
-
methods: S.string().enum( ...METHODS ).optional(),
|
|
11
|
-
allowedHeaders: S.anyOf( S.string(), S.array().items( S.string())).optional(),
|
|
12
|
-
exposedHeaders: S.anyOf( S.string(), S.array().items( S.string())).optional(),
|
|
13
|
-
credentials: S.boolean().optional(),
|
|
14
|
-
maxAge: S.number().optional(),
|
|
15
|
-
preflightContinue: S.boolean().optional(),
|
|
16
|
-
optionsSuccessStatus: S.number().optional(),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const CompressionOptions = S.shape({
|
|
20
|
-
chunkSize: S.number().optional(),
|
|
21
|
-
level: S.number().optional(),
|
|
22
|
-
memLevel: S.number().optional(),
|
|
23
|
-
strategy: S.number().optional(),
|
|
24
|
-
threshold: S.number().optional(),
|
|
25
|
-
windowBits: S.number().optional(),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export const HttpConfigSchema = S.shape({
|
|
29
|
-
port: S.number().optional(),
|
|
30
|
-
cookie: S.shape({
|
|
31
|
-
enabled: S.boolean()
|
|
32
|
-
}).additionalProperties( true ).optional(),
|
|
33
|
-
listeningEnabled: S.boolean().optional(),
|
|
34
|
-
cors: mergeSchemas( CorsOptions, S.shape({
|
|
35
|
-
enabled: S.boolean()
|
|
36
|
-
})).additionalProperties( true ).optional(),
|
|
37
|
-
compression: mergeSchemas( CompressionOptions, S.shape({
|
|
38
|
-
enabled: S.boolean()
|
|
39
|
-
})).additionalProperties( true ).optional(),
|
|
40
|
-
metrics: S.shape({
|
|
41
|
-
enabled: S.boolean().optional(),
|
|
42
|
-
httpRequestDurations: S.shape({
|
|
43
|
-
enabled: S.boolean().optional(),
|
|
44
|
-
buckets: S.array().items( S.number()).optional()
|
|
45
|
-
}).optional()
|
|
46
|
-
}).optional()
|
|
47
|
-
}).optional();
|
|
48
|
-
|
|
49
|
-
export type HttpConfig = typeof HttpConfigSchema.type
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
export type EndpointsFetchInterfaceResponse<T = any> = Pick<Response, 'ok'> & {
|
|
53
|
-
json: () => Promise<T>;
|
|
54
|
-
text: () => Promise<T>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export type RequestObject<RAW extends ReadableStream = any> = {
|
|
58
|
-
type: 'string',
|
|
59
|
-
raw?: RAW,
|
|
60
|
-
body: unknown,
|
|
61
|
-
query: unknown,
|
|
62
|
-
params: unknown,
|
|
63
|
-
method: string,
|
|
64
|
-
route: string,
|
|
65
|
-
filePaths: Record<string, string>,
|
|
66
|
-
headers: Record<string,string | string[]>
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type ResponseObject<RAW extends WritableStream = any> = {
|
|
70
|
-
raw?: RAW,
|
|
71
|
-
send: ( payload: unknown ) => unknown
|
|
72
|
-
header: ( key: string, value: any ) => ResponseObject
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export type EndpointActionParamsContext<USER=any> = {
|
|
76
|
-
res:ResponseObject
|
|
77
|
-
req:RequestObject,
|
|
78
|
-
endpoint: Endpoint,
|
|
79
|
-
user: USER,
|
|
80
|
-
token?: string;
|
|
81
|
-
[key:string]: any
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type EndpointActionParams<BODY=any, QUERY=any, PARAMS=any, USER=any> = {
|
|
85
|
-
query: QUERY
|
|
86
|
-
params: PARAMS
|
|
87
|
-
body: BODY
|
|
88
|
-
context: Partial<EndpointActionParamsContext<USER>>
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export type EndpointSchemas<BODY, QUERY, PARAMS> = {
|
|
92
|
-
body?: BaseSchema<BODY>,
|
|
93
|
-
query?: BaseSchema<QUERY>,
|
|
94
|
-
params?: BaseSchema<PARAMS>,
|
|
95
|
-
headers?: ObjectSchema,
|
|
96
|
-
responses?: Record<number, {schema: BaseSchema , name: string}[]>,
|
|
97
|
-
errors?: Record<number, {schema: BaseSchema, name: string}[]>,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export type EndpointAction<BODY=any, RETURN=any, QUERY=any, PARAMS=any> = ( params: EndpointActionParams<BODY, QUERY, PARAMS> ) => Promise<RETURN>
|
|
101
|
-
|
|
102
|
-
export type Endpoint<BODY=any, RETURN=any, QUERY=any, PARAMS=any> = {
|
|
103
|
-
route: string;
|
|
104
|
-
action: EndpointAction<BODY, RETURN, QUERY, PARAMS>,
|
|
105
|
-
module: string;
|
|
106
|
-
name?: string;
|
|
107
|
-
description?: string;
|
|
108
|
-
schemas?: EndpointSchemas<BODY, QUERY, PARAMS>;
|
|
109
|
-
shouldValidate?: boolean;
|
|
110
|
-
responseContentType?: string;
|
|
111
|
-
tags?: string[]
|
|
112
|
-
//REVIEW: Protocol Specific
|
|
113
|
-
method?: 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'OPTIONS';
|
|
114
|
-
//REVIEW: Protocol Specific
|
|
115
|
-
multipartProperties?: string[],
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export const EndpointSchema = S.shape({
|
|
119
|
-
route: S.string().pattern( /^\/.*/ ),
|
|
120
|
-
action: S.any(),
|
|
121
|
-
module: S.string().optional(),
|
|
122
|
-
name: S.string().optional(),
|
|
123
|
-
description: S.string().optional(),
|
|
124
|
-
schemas: S.any().optional(),
|
|
125
|
-
tags: S.array().items( S.string()).optional(),
|
|
126
|
-
multipartProperties: S.array().items( S.string()).optional(),
|
|
127
|
-
method: S.string().enum( 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT', 'OPTIONS' ).optional(),
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
export type InjectHandlerContext<REQ = any, RES = any> = {
|
|
131
|
-
request: REQ,
|
|
132
|
-
response: RES,
|
|
133
|
-
callInactiveEvent: () => void
|
|
134
|
-
callStartEvent: () => void
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export type CloudFunctionsAdapter = {
|
|
138
|
-
/**
|
|
139
|
-
* Function used when working on a cloud function environment. Internal function.
|
|
140
|
-
* @param context {InjectHandlerContext}
|
|
141
|
-
* @returns {Promise<void>}
|
|
142
|
-
*/
|
|
143
|
-
injectHandler: ( context: InjectHandlerContext )=> Promise<void>,
|
|
144
|
-
/**
|
|
145
|
-
* This method is called when the server is starting a new Events Related connection. Things like SSE, WS, TCP, etc.
|
|
146
|
-
* It is used internally in cloud function environments to keep the function alive.
|
|
147
|
-
* @returns {void}
|
|
148
|
-
*/
|
|
149
|
-
callEventConnectionsActive: () => void,
|
|
150
|
-
/**
|
|
151
|
-
* This method is called when the server has no more Events Related connection. Things like SSE, WS, TCP, etc.
|
|
152
|
-
* It is used internally in cloud function environments to mark the function as idle so it can be killed.
|
|
153
|
-
* @returns {void}
|
|
154
|
-
*/
|
|
155
|
-
callEventConnectionsInactive: () => void,
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export type MetricBaseType = {
|
|
159
|
-
name: string,
|
|
160
|
-
help: string,
|
|
161
|
-
labelNames: string[],
|
|
162
|
-
}
|
|
163
|
-
export type CounterMetricsType = MetricBaseType & {}
|
|
164
|
-
export type GaugeMetricsType = MetricBaseType & {}
|
|
165
|
-
|
|
166
|
-
export type EndpointsAdapter<T = any> = AdapterBase<T> & Partial<CloudFunctionsAdapter> & {
|
|
167
|
-
adapterType?: 'httpHandler',
|
|
168
|
-
getServerAddress?: () => AddressInfo;
|
|
169
|
-
registerOpenApi?: ( openapi: Record<string, any> ) => void;
|
|
170
|
-
registerOpenApiDocument?: () => void;
|
|
171
|
-
registerEndpoint: ( endpoint: Endpoint ) => Endpoint;
|
|
172
|
-
serveStaticDirectory?: ( path: string, endpoint?: string ) => void;
|
|
173
|
-
onServicesDirectorySet?: ( callback: ( serviceDirectory: Record<string, string> ) => void ) => void;
|
|
174
|
-
metrics?: {
|
|
175
|
-
addCounter: ( metric: CounterMetricsType ) => ( labels: string[]) => void
|
|
176
|
-
addGauge: ( metric: CounterMetricsType ) => ( labels: string[], value: number ) => void
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export type EndpointsType = CloudFunctionsAdapter & {
|
|
181
|
-
getEndpoints?(): Endpoint[],
|
|
182
|
-
setServiceSupportedModules: ( modules: Record<string, string[]> ) => void;
|
|
183
|
-
getOpenApiSpec: () => OpenAPIV3_1.Document,
|
|
184
|
-
generateOpenApiSpec: ( servicePath?: string ) => Promise<OpenAPIV3_1.Document>,
|
|
185
|
-
registerEndpoint<BODY, RETURN, QUERY, PARAMS>( endpoint: Endpoint<BODY, RETURN, QUERY, PARAMS> ): void;
|
|
186
|
-
registerSchema( name:string, schema: JSONSchema7, tags: string[]): void;
|
|
187
|
-
addOpenApiTag( name: string ): void;
|
|
188
|
-
call<Type, R=Type>( route: string, method?:string, params?: Partial<Pick<EndpointActionParams<Type>, 'body'|'context'>> ): Promise<R>
|
|
189
|
-
fetch( route: string, params: {method: 'get'| 'post', headers: Record<string,any>, body: string}): Promise<EndpointsFetchInterfaceResponse>
|
|
190
|
-
get<Type, R=Type>( route: string, params?: Partial<Pick<EndpointActionParams<Type>, 'body'|'context'>> ): Promise<R>
|
|
191
|
-
post<Type, R=Type>( route: string, params?: Partial<Pick<EndpointActionParams<Type>, 'body'|'context'>> ): Promise<R>,
|
|
192
|
-
start: () => Promise<void>;
|
|
193
|
-
stop: () => Promise<void>;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export type EndpointsPort = PortEmitter & EndpointsType & {
|
|
197
|
-
_adapters: () => EndpointsAdapter[]
|
|
198
|
-
}
|
package/src/evenstore.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import S from '@bett3r-dev/jsonschema-definer';
|
|
2
|
-
import { DatabaseTransaction } from './database';
|
|
3
|
-
import { CommittedEvent, EventToCommit, ReadMultipleStreamOptions, ReadStreamOptions } from './eventsourcing';
|
|
4
|
-
import { AdapterBase, PortEmitter } from './ports';
|
|
5
|
-
|
|
6
|
-
export const EventStoreConfigSchema = S.shape({
|
|
7
|
-
enabled: S.boolean().optional(),
|
|
8
|
-
collection: S.string().optional()
|
|
9
|
-
}).optional();
|
|
10
|
-
export type EventStoreConfig = typeof EventStoreConfigSchema.type;
|
|
11
|
-
|
|
12
|
-
export type EventStoreType = {
|
|
13
|
-
appendToStream: <Type>( stream:string, events: EventToCommit|EventToCommit[], expectedVersion?: number, transaction?: DatabaseTransaction ) => Promise<CommittedEvent<Type>[]>;
|
|
14
|
-
appendToMultipleStreams?: <Type>( streams: Record<string, { events: EventToCommit|EventToCommit[], expectedVersion?: number, }>, transaction?: DatabaseTransaction ) => Promise<CommittedEvent<Type>[]>;
|
|
15
|
-
readStream: <Model=any>( readOptions: ReadStreamOptions, callback: ( event: CommittedEvent, stop: () => void ) => Partial<Model> | Promise<Partial<Model>> ) => Promise<Model>
|
|
16
|
-
readMultipleStream?: <Model=any>( readOptions: ReadMultipleStreamOptions, callback: ( event: CommittedEvent, stop: () => void ) => Record<string,Partial<Model>> | Promise<Record<string,Partial<Model>>> ) => Promise<Record<string,Model>>
|
|
17
|
-
subscribe: ( onData: ( event: CommittedEvent ) => void, onError?: ( e: Error ) => void ) => Promise<{
|
|
18
|
-
close: () => void
|
|
19
|
-
}>
|
|
20
|
-
flush: () => Promise<void>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type EventStoreAdapter = AdapterBase & EventStoreType;
|
|
24
|
-
|
|
25
|
-
export type EventStorePort = PortEmitter & EventStoreType & {
|
|
26
|
-
_adapter: EventStoreAdapter
|
|
27
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command, EventFactory, EventReducers } from '.';
|
|
2
|
-
import { DatabasePort } from '..';
|
|
3
|
-
import { ExternalSystemBuilderType } from './externalSystemBuilder';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type AggregateBuilderType<Model, EVENTS extends Record<string, EventFactory>> = Omit<ExternalSystemBuilderType<Model, EVENTS>, 'withCommandTemplate'> & {
|
|
7
|
-
withCommandTemplate: ( command: Command ) => AggregateBuilderType<Model, EVENTS>
|
|
8
|
-
notEventsourced: ( database: DatabasePort, collection: string ) => AggregateBuilderType<Model, EVENTS>
|
|
9
|
-
initialValue: ( init: () => ( Partial<Model> | null | undefined )) => Pick<AggregateBuilderType<Model, EVENTS>, 'withEventReducers' | 'withCommands'>
|
|
10
|
-
withEventReducers: ( eventReducers: EventReducers<EVENTS, Model> ) => Pick<AggregateBuilderType<Model, EVENTS>, 'withCommands'>
|
|
11
|
-
}
|