ofcoop-shared-core 0.1.0-alpha.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 +18 -0
- package/dist/OfcoopCore.d.ts +60 -0
- package/dist/OfcoopCore.js +273 -0
- package/dist/contracts/MemberContract.d.ts +52 -0
- package/dist/contracts/MemberContract.js +2 -0
- package/dist/contracts/MemberNumberPolicyContract.d.ts +44 -0
- package/dist/contracts/MemberNumberPolicyContract.js +2 -0
- package/dist/contracts/SavingComplianceSnapshotContract.d.ts +34 -0
- package/dist/contracts/SavingComplianceSnapshotContract.js +2 -0
- package/dist/contracts/SavingLedgerContract.d.ts +49 -0
- package/dist/contracts/SavingLedgerContract.js +2 -0
- package/dist/contracts/SavingPolicyContract.d.ts +63 -0
- package/dist/contracts/SavingPolicyContract.js +2 -0
- package/dist/contracts/ShuConfigContract.d.ts +39 -0
- package/dist/contracts/ShuConfigContract.js +2 -0
- package/dist/contracts/ShuContract.d.ts +58 -0
- package/dist/contracts/ShuContract.js +2 -0
- package/dist/contracts/crossDomainPrimitives.d.ts +5 -0
- package/dist/contracts/crossDomainPrimitives.js +2 -0
- package/dist/data/applyPendingMigrations.d.ts +2 -0
- package/dist/data/applyPendingMigrations.js +30 -0
- package/dist/data/migrations.d.ts +2 -0
- package/dist/data/migrations.js +20 -0
- package/dist/data/repositories.d.ts +114 -0
- package/dist/data/repositories.js +324 -0
- package/dist/data/schemas.d.ts +14 -0
- package/dist/data/schemas.js +179 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +54 -0
- package/dist/services/AuditTrailQueryService.d.ts +35 -0
- package/dist/services/AuditTrailQueryService.js +62 -0
- package/dist/services/CoopOrchestrationService.d.ts +35 -0
- package/dist/services/CoopOrchestrationService.js +71 -0
- package/dist/services/DailyOpsService.d.ts +2 -0
- package/dist/services/DailyOpsService.js +7 -0
- package/dist/services/DashboardSummaryService.d.ts +180 -0
- package/dist/services/DashboardSummaryService.js +211 -0
- package/dist/services/DashboardViewModelService.d.ts +42 -0
- package/dist/services/DashboardViewModelService.js +193 -0
- package/dist/services/Member360Service.d.ts +75 -0
- package/dist/services/Member360Service.js +79 -0
- package/dist/services/Member360ViewModelService.d.ts +33 -0
- package/dist/services/Member360ViewModelService.js +66 -0
- package/dist/services/MemberNumberPolicyService.d.ts +4 -0
- package/dist/services/MemberNumberPolicyService.js +18 -0
- package/dist/services/MemberService.d.ts +4 -0
- package/dist/services/MemberService.js +18 -0
- package/dist/services/ReportSummaryService.d.ts +81 -0
- package/dist/services/ReportSummaryService.js +160 -0
- package/dist/services/ReportViewModelService.d.ts +24 -0
- package/dist/services/ReportViewModelService.js +90 -0
- package/dist/services/SavingComplianceSnapshotService.d.ts +4 -0
- package/dist/services/SavingComplianceSnapshotService.js +10 -0
- package/dist/services/SavingLedgerService.d.ts +4 -0
- package/dist/services/SavingLedgerService.js +13 -0
- package/dist/services/SavingPolicyService.d.ts +5 -0
- package/dist/services/SavingPolicyService.js +20 -0
- package/dist/services/ShuConfigService.d.ts +4 -0
- package/dist/services/ShuConfigService.js +16 -0
- package/dist/services/ShuService.d.ts +4 -0
- package/dist/services/ShuService.js +14 -0
- package/dist/services/createActivityAuditTrailProvider.d.ts +22 -0
- package/dist/services/createActivityAuditTrailProvider.js +73 -0
- package/dist/services/createAuditTrailCompositionProvider.d.ts +13 -0
- package/dist/services/createAuditTrailCompositionProvider.js +21 -0
- package/dist/services/createDbAdapterOfcoopServices.d.ts +20 -0
- package/dist/services/createDbAdapterOfcoopServices.js +23 -0
- package/dist/services/createMember360CompositionProviders.d.ts +6 -0
- package/dist/services/createMember360CompositionProviders.js +43 -0
- package/dist/services/createOfauthCompositionProviders.d.ts +39 -0
- package/dist/services/createOfauthCompositionProviders.js +80 -0
- package/dist/services/createOfcoopCreditCompositionProviders.d.ts +59 -0
- package/dist/services/createOfcoopCreditCompositionProviders.js +233 -0
- package/dist/services/createOfcoopDashboardCompositionProviders.d.ts +18 -0
- package/dist/services/createOfcoopDashboardCompositionProviders.js +228 -0
- package/dist/services/createOfcoopDomainAuditCompositionProviders.d.ts +36 -0
- package/dist/services/createOfcoopDomainAuditCompositionProviders.js +117 -0
- package/dist/services/createOfcoopReportCompositionProviders.d.ts +10 -0
- package/dist/services/createOfcoopReportCompositionProviders.js +30 -0
- package/dist/services/errors.d.ts +8 -0
- package/dist/services/errors.js +23 -0
- package/dist/services/impl/DbAdapterMemberNumberPolicyService.d.ts +9 -0
- package/dist/services/impl/DbAdapterMemberNumberPolicyService.js +37 -0
- package/dist/services/impl/DbAdapterMemberService.d.ts +21 -0
- package/dist/services/impl/DbAdapterMemberService.js +142 -0
- package/dist/services/impl/DbAdapterSavingComplianceSnapshotService.d.ts +9 -0
- package/dist/services/impl/DbAdapterSavingComplianceSnapshotService.js +74 -0
- package/dist/services/impl/DbAdapterSavingLedgerService.d.ts +18 -0
- package/dist/services/impl/DbAdapterSavingLedgerService.js +115 -0
- package/dist/services/impl/DbAdapterSavingPolicyService.d.ts +14 -0
- package/dist/services/impl/DbAdapterSavingPolicyService.js +139 -0
- package/dist/services/impl/DbAdapterShuConfigService.d.ts +12 -0
- package/dist/services/impl/DbAdapterShuConfigService.js +62 -0
- package/dist/services/impl/DbAdapterShuService.d.ts +26 -0
- package/dist/services/impl/DbAdapterShuService.js +376 -0
- package/dist/services/impl/runtimeSupport.d.ts +18 -0
- package/dist/services/impl/runtimeSupport.js +29 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# ofcoop-shared-core
|
|
2
|
+
|
|
3
|
+
Shared-core domain koperasi umum (anggota, simpanan, SHU, dan policy) di atas primitive `ofcore`.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
- `npm run typecheck`
|
|
7
|
+
- `npm run build`
|
|
8
|
+
- `npm run verify:contract`
|
|
9
|
+
- `npm run verify:surface`
|
|
10
|
+
- `npm run verify:ofcore-primitives`
|
|
11
|
+
- `npm run verify:logic`
|
|
12
|
+
- `npm run test`
|
|
13
|
+
- `npm run ci:check`
|
|
14
|
+
|
|
15
|
+
## Publish
|
|
16
|
+
1. `npm run ci:check`
|
|
17
|
+
2. `npm pack --dry-run`
|
|
18
|
+
3. `npm publish --access public`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CoreAdapterRegistry, CoreRuntime, CoreRuntimeStartOptions } from 'ofcore';
|
|
2
|
+
import type { CoreRuntimeHooks } from 'ofcore';
|
|
3
|
+
import type { DbAdapter } from 'ofcore';
|
|
4
|
+
import type { HttpAdapter } from 'ofcore';
|
|
5
|
+
import type { LoggerAdapter } from 'ofcore';
|
|
6
|
+
import type { PlatformAdapter } from 'ofcore';
|
|
7
|
+
import type { SocketAdapter } from 'ofcore';
|
|
8
|
+
import type { ActivitySink } from 'ofcore';
|
|
9
|
+
import type { ReadonlyStore, Store } from 'ofcore';
|
|
10
|
+
import type { OfcoopDomainEvent } from './services/createDbAdapterOfcoopServices';
|
|
11
|
+
import type { OfcoopDomainServices } from './services/createDbAdapterOfcoopServices';
|
|
12
|
+
export type OfcoopDomainServicesOverride = Partial<OfcoopDomainServices>;
|
|
13
|
+
export type OfcoopDomainServicesFactory = () => Promise<OfcoopDomainServices> | OfcoopDomainServices;
|
|
14
|
+
export type OfcoopRuntimeHooks = Pick<CoreRuntimeHooks<OfcoopDomainServices, never>, 'runMigrations' | 'runSeed' | 'onInit' | 'onStop'>;
|
|
15
|
+
export interface OfcoopRuntimeState {
|
|
16
|
+
phase: 'idle' | 'starting' | 'started' | 'stopping' | 'stopped' | 'error';
|
|
17
|
+
started: boolean;
|
|
18
|
+
startCount: number;
|
|
19
|
+
stopCount: number;
|
|
20
|
+
lastError: string | null;
|
|
21
|
+
lastTransitionAt: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class OfcoopCore {
|
|
24
|
+
private readonly runtime;
|
|
25
|
+
private readonly runtimeStateStore;
|
|
26
|
+
domainServices?: OfcoopDomainServices;
|
|
27
|
+
readonly runtimeStore: ReadonlyStore<OfcoopRuntimeState>;
|
|
28
|
+
constructor(runtime: CoreRuntime<OfcoopDomainServices, never>, runtimeStateStore: Store<OfcoopRuntimeState>);
|
|
29
|
+
static builder(): OfcoopCoreBuilder;
|
|
30
|
+
get registry(): CoreAdapterRegistry | undefined;
|
|
31
|
+
start(options?: CoreRuntimeStartOptions): Promise<void>;
|
|
32
|
+
init(options?: CoreRuntimeStartOptions): Promise<void>;
|
|
33
|
+
stop(): Promise<void>;
|
|
34
|
+
restart(): Promise<void>;
|
|
35
|
+
isStarted(): boolean;
|
|
36
|
+
createCorrelationId(prefix?: string): string;
|
|
37
|
+
use(name: string, init: (core: OfcoopCore) => Promise<void>, deps?: string[]): this;
|
|
38
|
+
}
|
|
39
|
+
export declare class OfcoopCoreBuilder {
|
|
40
|
+
private readonly runtimeBuilder;
|
|
41
|
+
private domainServicesFactory?;
|
|
42
|
+
private domainServiceOverrides;
|
|
43
|
+
private runtimeHooks;
|
|
44
|
+
private domainEventSink?;
|
|
45
|
+
constructor();
|
|
46
|
+
withPlatformAdapter(factory: (core: CoreRuntime<any, any>) => PlatformAdapter): this;
|
|
47
|
+
withDbAdapter(factory: (core: CoreRuntime<any, any>) => DbAdapter): this;
|
|
48
|
+
withHttpAdapter(factory: (core: CoreRuntime<any, any>) => HttpAdapter): this;
|
|
49
|
+
withSocketAdapter(factory: (core: CoreRuntime<any, any>) => SocketAdapter): this;
|
|
50
|
+
withLoggerAdapter(factory: (core: CoreRuntime<any, any>) => LoggerAdapter): this;
|
|
51
|
+
withActivitySink(factory: (core: CoreRuntime<any, any>) => ActivitySink): this;
|
|
52
|
+
withExtension(name: string, factory: (core: CoreRuntime<any, any>) => unknown): this;
|
|
53
|
+
withDomainServicesFactory(factory: OfcoopDomainServicesFactory): this;
|
|
54
|
+
overrideDomainServices(overrides: OfcoopDomainServicesOverride): this;
|
|
55
|
+
withRuntimeHooks(hooks: Partial<OfcoopRuntimeHooks>): this;
|
|
56
|
+
withMigrationRunner(runner: NonNullable<OfcoopRuntimeHooks['runMigrations']>): this;
|
|
57
|
+
withSeedRunner(runner: NonNullable<OfcoopRuntimeHooks['runSeed']>): this;
|
|
58
|
+
withDomainEventSink(sink: (event: OfcoopDomainEvent) => Promise<void> | void): this;
|
|
59
|
+
build(): OfcoopCore;
|
|
60
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OfcoopCoreBuilder = exports.OfcoopCore = void 0;
|
|
4
|
+
const ofcore_1 = require("ofcore");
|
|
5
|
+
const ofcore_2 = require("ofcore");
|
|
6
|
+
const ofcore_3 = require("ofcore");
|
|
7
|
+
const applyPendingMigrations_1 = require("./data/applyPendingMigrations");
|
|
8
|
+
const createDbAdapterOfcoopServices_1 = require("./services/createDbAdapterOfcoopServices");
|
|
9
|
+
class OfcoopCore {
|
|
10
|
+
constructor(runtime, runtimeStateStore) {
|
|
11
|
+
this.runtime = runtime;
|
|
12
|
+
this.runtimeStateStore = runtimeStateStore;
|
|
13
|
+
this.runtimeStore = (0, ofcore_3.asReadonlyStore)(this.runtimeStateStore);
|
|
14
|
+
}
|
|
15
|
+
static builder() {
|
|
16
|
+
return new OfcoopCoreBuilder();
|
|
17
|
+
}
|
|
18
|
+
get registry() {
|
|
19
|
+
return this.runtime.registry;
|
|
20
|
+
}
|
|
21
|
+
async start(options = {}) {
|
|
22
|
+
this.runtimeStateStore.setState({
|
|
23
|
+
phase: 'starting',
|
|
24
|
+
started: false,
|
|
25
|
+
lastError: null,
|
|
26
|
+
lastTransitionAt: new Date().toISOString(),
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
await this.runtime.start(options);
|
|
30
|
+
this.domainServices = this.runtime.domainServices;
|
|
31
|
+
this.runtimeStateStore.setState((state) => ({
|
|
32
|
+
...state,
|
|
33
|
+
phase: 'started',
|
|
34
|
+
started: true,
|
|
35
|
+
startCount: state.startCount + 1,
|
|
36
|
+
lastError: null,
|
|
37
|
+
lastTransitionAt: new Date().toISOString(),
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.runtimeStateStore.setState({
|
|
42
|
+
phase: 'error',
|
|
43
|
+
started: false,
|
|
44
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
45
|
+
lastTransitionAt: new Date().toISOString(),
|
|
46
|
+
});
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async init(options = {}) {
|
|
51
|
+
this.runtimeStateStore.setState({
|
|
52
|
+
phase: 'starting',
|
|
53
|
+
started: false,
|
|
54
|
+
lastError: null,
|
|
55
|
+
lastTransitionAt: new Date().toISOString(),
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
await this.runtime.init(options);
|
|
59
|
+
this.domainServices = this.runtime.domainServices;
|
|
60
|
+
this.runtimeStateStore.setState((state) => ({
|
|
61
|
+
...state,
|
|
62
|
+
phase: 'started',
|
|
63
|
+
started: true,
|
|
64
|
+
startCount: state.startCount + 1,
|
|
65
|
+
lastError: null,
|
|
66
|
+
lastTransitionAt: new Date().toISOString(),
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
this.runtimeStateStore.setState({
|
|
71
|
+
phase: 'error',
|
|
72
|
+
started: false,
|
|
73
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
74
|
+
lastTransitionAt: new Date().toISOString(),
|
|
75
|
+
});
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async stop() {
|
|
80
|
+
this.runtimeStateStore.setState({
|
|
81
|
+
phase: 'stopping',
|
|
82
|
+
started: this.runtime.isStarted(),
|
|
83
|
+
lastError: null,
|
|
84
|
+
lastTransitionAt: new Date().toISOString(),
|
|
85
|
+
});
|
|
86
|
+
try {
|
|
87
|
+
await this.runtime.stop();
|
|
88
|
+
this.runtimeStateStore.setState((state) => ({
|
|
89
|
+
...state,
|
|
90
|
+
phase: 'stopped',
|
|
91
|
+
started: false,
|
|
92
|
+
stopCount: state.stopCount + 1,
|
|
93
|
+
lastError: null,
|
|
94
|
+
lastTransitionAt: new Date().toISOString(),
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
this.runtimeStateStore.setState({
|
|
99
|
+
phase: 'error',
|
|
100
|
+
started: this.runtime.isStarted(),
|
|
101
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
102
|
+
lastTransitionAt: new Date().toISOString(),
|
|
103
|
+
});
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async restart() {
|
|
108
|
+
this.runtimeStateStore.setState({
|
|
109
|
+
phase: 'starting',
|
|
110
|
+
started: this.runtime.isStarted(),
|
|
111
|
+
lastError: null,
|
|
112
|
+
lastTransitionAt: new Date().toISOString(),
|
|
113
|
+
});
|
|
114
|
+
try {
|
|
115
|
+
await this.runtime.restart();
|
|
116
|
+
this.domainServices = this.runtime.domainServices;
|
|
117
|
+
this.runtimeStateStore.setState((state) => ({
|
|
118
|
+
...state,
|
|
119
|
+
phase: 'started',
|
|
120
|
+
started: true,
|
|
121
|
+
startCount: state.startCount + 1,
|
|
122
|
+
lastError: null,
|
|
123
|
+
lastTransitionAt: new Date().toISOString(),
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
this.runtimeStateStore.setState({
|
|
128
|
+
phase: 'error',
|
|
129
|
+
started: this.runtime.isStarted(),
|
|
130
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
131
|
+
lastTransitionAt: new Date().toISOString(),
|
|
132
|
+
});
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
isStarted() {
|
|
137
|
+
return this.runtime.isStarted();
|
|
138
|
+
}
|
|
139
|
+
createCorrelationId(prefix = 'ofcoop') {
|
|
140
|
+
return this.runtime.createCorrelationId(prefix);
|
|
141
|
+
}
|
|
142
|
+
use(name, init, deps = []) {
|
|
143
|
+
this.runtime.use(name, async () => init(this), deps);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.OfcoopCore = OfcoopCore;
|
|
148
|
+
class OfcoopCoreBuilder {
|
|
149
|
+
constructor() {
|
|
150
|
+
this.runtimeBuilder = ofcore_1.CoreRuntime.builder();
|
|
151
|
+
this.domainServiceOverrides = {};
|
|
152
|
+
this.runtimeHooks = {};
|
|
153
|
+
this.runtimeBuilder.withDbAdapter(() => new ofcore_2.InMemoryDbAdapter());
|
|
154
|
+
}
|
|
155
|
+
withPlatformAdapter(factory) {
|
|
156
|
+
this.runtimeBuilder.withPlatformAdapter(factory);
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
withDbAdapter(factory) {
|
|
160
|
+
this.runtimeBuilder.withDbAdapter(factory);
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
withHttpAdapter(factory) {
|
|
164
|
+
this.runtimeBuilder.withHttpAdapter(factory);
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
withSocketAdapter(factory) {
|
|
168
|
+
this.runtimeBuilder.withSocketAdapter(factory);
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
withLoggerAdapter(factory) {
|
|
172
|
+
this.runtimeBuilder.withLoggerAdapter(factory);
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
withActivitySink(factory) {
|
|
176
|
+
this.runtimeBuilder.withActivitySink(factory);
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
withExtension(name, factory) {
|
|
180
|
+
this.runtimeBuilder.withExtension(name, factory);
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
withDomainServicesFactory(factory) {
|
|
184
|
+
this.domainServicesFactory = factory;
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
overrideDomainServices(overrides) {
|
|
188
|
+
this.domainServiceOverrides = { ...this.domainServiceOverrides, ...overrides };
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
withRuntimeHooks(hooks) {
|
|
192
|
+
this.runtimeHooks = { ...this.runtimeHooks, ...hooks };
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
withMigrationRunner(runner) {
|
|
196
|
+
return this.withRuntimeHooks({ runMigrations: runner });
|
|
197
|
+
}
|
|
198
|
+
withSeedRunner(runner) {
|
|
199
|
+
return this.withRuntimeHooks({ runSeed: runner });
|
|
200
|
+
}
|
|
201
|
+
withDomainEventSink(sink) {
|
|
202
|
+
this.domainEventSink = sink;
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
build() {
|
|
206
|
+
const runtimeStateStore = (0, ofcore_3.createStore)({
|
|
207
|
+
phase: 'idle',
|
|
208
|
+
started: false,
|
|
209
|
+
startCount: 0,
|
|
210
|
+
stopCount: 0,
|
|
211
|
+
lastError: null,
|
|
212
|
+
lastTransitionAt: new Date().toISOString(),
|
|
213
|
+
});
|
|
214
|
+
const defaultRunMigrations = async (runtime) => {
|
|
215
|
+
const dbAdapter = runtime.registry?.dbAdapter;
|
|
216
|
+
if (!dbAdapter)
|
|
217
|
+
return;
|
|
218
|
+
await (0, applyPendingMigrations_1.applyPendingMigrations)(dbAdapter, runtime.registry?.loggerAdapter);
|
|
219
|
+
};
|
|
220
|
+
this.runtimeBuilder.withHooks({
|
|
221
|
+
...this.runtimeHooks,
|
|
222
|
+
runMigrations: this.runtimeHooks.runMigrations ?? defaultRunMigrations,
|
|
223
|
+
createDomainServices: async (runtime) => {
|
|
224
|
+
const emitEvent = async (event) => {
|
|
225
|
+
const errors = [];
|
|
226
|
+
if (this.domainEventSink) {
|
|
227
|
+
try {
|
|
228
|
+
await this.domainEventSink(event);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
errors.push(error);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (runtime.registry?.activitySink) {
|
|
235
|
+
try {
|
|
236
|
+
await runtime.registry.activitySink.publish({
|
|
237
|
+
activityId: runtime.createCorrelationId('ofcoop-event'),
|
|
238
|
+
activityType: `ofcoop.${event.name}`,
|
|
239
|
+
occurredAt: event.occurredAt,
|
|
240
|
+
scopeRef: {
|
|
241
|
+
domain: 'ofcoop',
|
|
242
|
+
...(event.tenantId ? { tenantId: event.tenantId } : {}),
|
|
243
|
+
...(event.branchId ? { branchId: event.branchId } : {}),
|
|
244
|
+
},
|
|
245
|
+
payload: {
|
|
246
|
+
entityId: event.entityId ?? null,
|
|
247
|
+
...(event.payload ?? {}),
|
|
248
|
+
},
|
|
249
|
+
correlationId: runtime.createCorrelationId('ofcoop-corr'),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
errors.push(error);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (errors.length > 0) {
|
|
257
|
+
throw errors[0];
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const base = this.domainServicesFactory
|
|
261
|
+
? await this.domainServicesFactory()
|
|
262
|
+
: await (0, createDbAdapterOfcoopServices_1.createDbAdapterOfcoopServices)(runtime.registry?.dbAdapter ?? new ofcore_2.InMemoryDbAdapter(), {
|
|
263
|
+
logger: runtime.registry?.loggerAdapter,
|
|
264
|
+
emitEvent,
|
|
265
|
+
});
|
|
266
|
+
return { ...base, ...this.domainServiceOverrides };
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
const runtime = this.runtimeBuilder.build();
|
|
270
|
+
return new OfcoopCore(runtime, runtimeStateStore);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports.OfcoopCoreBuilder = OfcoopCoreBuilder;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type MemberStatus = 'active' | 'inactive' | 'exited';
|
|
2
|
+
export interface MemberContract {
|
|
3
|
+
id: string;
|
|
4
|
+
memberNumber: string;
|
|
5
|
+
fullName: string;
|
|
6
|
+
status: MemberStatus;
|
|
7
|
+
joinDate: string;
|
|
8
|
+
exitDate?: string | null;
|
|
9
|
+
branchId?: string | null;
|
|
10
|
+
tenantId?: string | null;
|
|
11
|
+
version: number;
|
|
12
|
+
lastModified: string;
|
|
13
|
+
deleted: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateMemberInput {
|
|
16
|
+
memberNumber: string;
|
|
17
|
+
fullName: string;
|
|
18
|
+
joinDate: string;
|
|
19
|
+
branchId?: string | null;
|
|
20
|
+
tenantId?: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface UpdateMemberInput {
|
|
23
|
+
fullName?: string;
|
|
24
|
+
memberNumber?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MemberQueryOptions {
|
|
27
|
+
includeDeleted?: boolean;
|
|
28
|
+
status?: MemberStatus;
|
|
29
|
+
tenantId?: string | null;
|
|
30
|
+
branchId?: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface MemberWaConsentInput {
|
|
33
|
+
granted: boolean;
|
|
34
|
+
source?: string | null;
|
|
35
|
+
note?: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface MemberExitInput {
|
|
38
|
+
reason?: string | null;
|
|
39
|
+
requestedBy?: string | null;
|
|
40
|
+
referenceId?: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface MemberServiceContract {
|
|
43
|
+
createMember(input: CreateMemberInput): Promise<MemberContract>;
|
|
44
|
+
updateMember(id: string, updates: UpdateMemberInput): Promise<MemberContract>;
|
|
45
|
+
getMemberById(id: string): Promise<MemberContract | null>;
|
|
46
|
+
listMembers(options?: MemberQueryOptions): Promise<MemberContract[]>;
|
|
47
|
+
changeMemberStatus(id: string, status: MemberStatus): Promise<MemberContract>;
|
|
48
|
+
setMemberWaConsent(id: string, consent: MemberWaConsentInput): Promise<MemberContract>;
|
|
49
|
+
requestMemberExit(id: string, payload: MemberExitInput): Promise<MemberContract>;
|
|
50
|
+
settleMemberExit(id: string, payload: MemberExitInput): Promise<MemberContract>;
|
|
51
|
+
cancelMemberExit(id: string, payload: MemberExitInput): Promise<MemberContract>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type CounterResetPolicy = 'never' | 'yearly';
|
|
2
|
+
export interface MemberNumberPolicyContract {
|
|
3
|
+
id: string;
|
|
4
|
+
koperasiId: string;
|
|
5
|
+
branchId?: string | null;
|
|
6
|
+
tenantId?: string | null;
|
|
7
|
+
prefix?: string | null;
|
|
8
|
+
includeYear: boolean;
|
|
9
|
+
includeMonth: boolean;
|
|
10
|
+
separator: string;
|
|
11
|
+
paddingDigits: number;
|
|
12
|
+
counterResetPolicy: CounterResetPolicy;
|
|
13
|
+
counterStart: number;
|
|
14
|
+
manualOverrideAllowed: boolean;
|
|
15
|
+
effectiveDate: string;
|
|
16
|
+
approvalRef?: string | null;
|
|
17
|
+
version: number;
|
|
18
|
+
lastModified: string;
|
|
19
|
+
deleted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface MemberNumberPolicyScope {
|
|
22
|
+
koperasiId: string;
|
|
23
|
+
tenantId: string;
|
|
24
|
+
branchId?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface UpsertMemberNumberPolicyInput {
|
|
27
|
+
koperasiId: string;
|
|
28
|
+
tenantId: string;
|
|
29
|
+
branchId?: string | null;
|
|
30
|
+
prefix?: string | null;
|
|
31
|
+
includeYear: boolean;
|
|
32
|
+
includeMonth: boolean;
|
|
33
|
+
separator: string;
|
|
34
|
+
paddingDigits: number;
|
|
35
|
+
counterResetPolicy: CounterResetPolicy;
|
|
36
|
+
counterStart: number;
|
|
37
|
+
manualOverrideAllowed: boolean;
|
|
38
|
+
effectiveDate: string;
|
|
39
|
+
approvalRef?: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface MemberNumberPolicyServiceContract {
|
|
42
|
+
getActiveMemberNumberPolicy(scope: MemberNumberPolicyScope): Promise<MemberNumberPolicyContract | null>;
|
|
43
|
+
upsertMemberNumberPolicy(input: UpsertMemberNumberPolicyInput): Promise<MemberNumberPolicyContract>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type SavingComplianceStatus = 'compliant' | 'underpaid' | 'no-policy';
|
|
2
|
+
export interface SavingComplianceSnapshotContract {
|
|
3
|
+
id: string;
|
|
4
|
+
memberId: string;
|
|
5
|
+
koperasiId: string;
|
|
6
|
+
tenantId?: string | null;
|
|
7
|
+
branchId?: string | null;
|
|
8
|
+
referenceDate: string;
|
|
9
|
+
monthlyWajibNominalIdr: number;
|
|
10
|
+
wajibCreditTotalIdr: number;
|
|
11
|
+
wajibDebitTotalIdr: number;
|
|
12
|
+
wajibNetTotalIdr: number;
|
|
13
|
+
status: SavingComplianceStatus;
|
|
14
|
+
monthsInArrears: number;
|
|
15
|
+
recommendedAction: string;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
version: number;
|
|
18
|
+
lastModified: string;
|
|
19
|
+
deleted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SavingComplianceSnapshotScope {
|
|
22
|
+
koperasiId: string;
|
|
23
|
+
tenantId: string;
|
|
24
|
+
branchId?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface SavingComplianceSnapshotQueryOptions {
|
|
27
|
+
memberId?: string;
|
|
28
|
+
status?: SavingComplianceStatus;
|
|
29
|
+
includeDeleted?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface SavingComplianceSnapshotServiceContract {
|
|
32
|
+
listComplianceSnapshots(scope: SavingComplianceSnapshotScope, options?: SavingComplianceSnapshotQueryOptions): Promise<SavingComplianceSnapshotContract[]>;
|
|
33
|
+
getComplianceSnapshotByMember(memberId: string, scope: SavingComplianceSnapshotScope): Promise<SavingComplianceSnapshotContract | null>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type SavingType = 'pokok' | 'wajib' | 'sukarela';
|
|
2
|
+
export type SavingEntryType = 'credit' | 'debit';
|
|
3
|
+
export interface SavingLedgerContract {
|
|
4
|
+
id: string;
|
|
5
|
+
memberId: string;
|
|
6
|
+
savingType: SavingType;
|
|
7
|
+
entryType: SavingEntryType;
|
|
8
|
+
amount: number;
|
|
9
|
+
transactionDate: string;
|
|
10
|
+
referenceType?: string | null;
|
|
11
|
+
referenceId?: string | null;
|
|
12
|
+
notes?: string | null;
|
|
13
|
+
branchId?: string | null;
|
|
14
|
+
tenantId?: string | null;
|
|
15
|
+
version: number;
|
|
16
|
+
lastModified: string;
|
|
17
|
+
deleted: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface SavingEntryInput {
|
|
20
|
+
memberId: string;
|
|
21
|
+
savingType: SavingType;
|
|
22
|
+
amount: number;
|
|
23
|
+
transactionDate: string;
|
|
24
|
+
referenceType?: string | null;
|
|
25
|
+
referenceId?: string | null;
|
|
26
|
+
notes?: string | null;
|
|
27
|
+
branchId?: string | null;
|
|
28
|
+
tenantId?: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface SavingBalance {
|
|
31
|
+
pokok: number;
|
|
32
|
+
wajib: number;
|
|
33
|
+
sukarela: number;
|
|
34
|
+
total: number;
|
|
35
|
+
}
|
|
36
|
+
export interface SavingLedgerQueryOptions {
|
|
37
|
+
includeDeleted?: boolean;
|
|
38
|
+
dateFrom?: string;
|
|
39
|
+
dateTo?: string;
|
|
40
|
+
tenantId?: string | null;
|
|
41
|
+
branchId?: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface SavingLedgerServiceContract {
|
|
44
|
+
recordSavingCredit(input: SavingEntryInput): Promise<SavingLedgerContract>;
|
|
45
|
+
recordSavingDebit(input: SavingEntryInput): Promise<SavingLedgerContract>;
|
|
46
|
+
recordSavingWithdrawal(input: SavingEntryInput): Promise<SavingLedgerContract>;
|
|
47
|
+
listSavingEntriesByMember(memberId: string, options?: SavingLedgerQueryOptions): Promise<SavingLedgerContract[]>;
|
|
48
|
+
getSavingBalanceByMember(memberId: string): Promise<SavingBalance>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type FineType = 'fixed' | 'percentage';
|
|
2
|
+
export interface SavingPolicyContract {
|
|
3
|
+
id: string;
|
|
4
|
+
koperasiId: string;
|
|
5
|
+
branchId?: string | null;
|
|
6
|
+
tenantId?: string | null;
|
|
7
|
+
simpananPokokNominalIdr: number;
|
|
8
|
+
monthlyWajibNominalIdr: number;
|
|
9
|
+
gracePeriodMonth: number;
|
|
10
|
+
dendaType: FineType;
|
|
11
|
+
dendaAmountIdr: number;
|
|
12
|
+
dendaPercentage: number;
|
|
13
|
+
warningAtMonths: number;
|
|
14
|
+
nonaktifAtMonths: number;
|
|
15
|
+
autoSetAnggotaNonaktif: boolean;
|
|
16
|
+
effectiveDate: string;
|
|
17
|
+
changeReason?: string | null;
|
|
18
|
+
approvalRef?: string | null;
|
|
19
|
+
version: number;
|
|
20
|
+
lastModified: string;
|
|
21
|
+
deleted: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface SavingPolicyScope {
|
|
24
|
+
koperasiId: string;
|
|
25
|
+
tenantId: string;
|
|
26
|
+
branchId?: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface UpsertSavingPolicyInput {
|
|
29
|
+
koperasiId: string;
|
|
30
|
+
tenantId: string;
|
|
31
|
+
branchId?: string | null;
|
|
32
|
+
simpananPokokNominalIdr: number;
|
|
33
|
+
monthlyWajibNominalIdr: number;
|
|
34
|
+
gracePeriodMonth: number;
|
|
35
|
+
dendaType: FineType;
|
|
36
|
+
dendaAmountIdr: number;
|
|
37
|
+
dendaPercentage: number;
|
|
38
|
+
warningAtMonths: number;
|
|
39
|
+
nonaktifAtMonths: number;
|
|
40
|
+
autoSetAnggotaNonaktif: boolean;
|
|
41
|
+
effectiveDate: string;
|
|
42
|
+
changeReason?: string | null;
|
|
43
|
+
approvalRef?: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface SavingComplianceEvaluation {
|
|
46
|
+
summary: Record<string, number>;
|
|
47
|
+
referenceDate: string;
|
|
48
|
+
}
|
|
49
|
+
export interface SavingComplianceWorklistItem {
|
|
50
|
+
id: string;
|
|
51
|
+
memberId: string;
|
|
52
|
+
priority: 'low' | 'medium' | 'high' | 'critical';
|
|
53
|
+
reasonCode: string;
|
|
54
|
+
reasonText: string;
|
|
55
|
+
recommendedAction: string;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
export interface SavingPolicyServiceContract {
|
|
59
|
+
getActiveSavingPolicy(scope: SavingPolicyScope): Promise<SavingPolicyContract | null>;
|
|
60
|
+
upsertSavingPolicy(input: UpsertSavingPolicyInput): Promise<SavingPolicyContract>;
|
|
61
|
+
evaluateWajibCompliance(scope: SavingPolicyScope): Promise<SavingComplianceEvaluation>;
|
|
62
|
+
getComplianceWorklist(scope: SavingPolicyScope): Promise<SavingComplianceWorklistItem[]>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface ShuConfigContract {
|
|
2
|
+
id: string;
|
|
3
|
+
koperasiId: string;
|
|
4
|
+
tenantId?: string | null;
|
|
5
|
+
branchId?: string | null;
|
|
6
|
+
effectiveDate: string;
|
|
7
|
+
cadanganPercent: number;
|
|
8
|
+
jasaUsahaPercent: number;
|
|
9
|
+
jasaModalPercent: number;
|
|
10
|
+
notes?: string | null;
|
|
11
|
+
approvalRef?: string | null;
|
|
12
|
+
version: number;
|
|
13
|
+
lastModified: string;
|
|
14
|
+
deleted: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ShuConfigScope {
|
|
17
|
+
koperasiId: string;
|
|
18
|
+
tenantId: string;
|
|
19
|
+
branchId?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface UpsertShuConfigInput {
|
|
22
|
+
koperasiId: string;
|
|
23
|
+
tenantId: string;
|
|
24
|
+
branchId?: string | null;
|
|
25
|
+
effectiveDate: string;
|
|
26
|
+
cadanganPercent: number;
|
|
27
|
+
jasaUsahaPercent: number;
|
|
28
|
+
jasaModalPercent: number;
|
|
29
|
+
notes?: string | null;
|
|
30
|
+
approvalRef?: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface ShuConfigQueryOptions {
|
|
33
|
+
includeDeleted?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ShuConfigServiceContract {
|
|
36
|
+
getActiveShuConfig(scope: ShuConfigScope): Promise<ShuConfigContract | null>;
|
|
37
|
+
upsertShuConfig(input: UpsertShuConfigInput): Promise<ShuConfigContract>;
|
|
38
|
+
listShuConfigs(scope: ShuConfigScope, options?: ShuConfigQueryOptions): Promise<ShuConfigContract[]>;
|
|
39
|
+
}
|