@forklaunch/implementation-worker-database 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/consumers/index.d.mts +26 -12
- package/lib/consumers/index.d.ts +26 -12
- package/lib/consumers/index.js +13 -8
- package/lib/consumers/index.mjs +2 -4
- package/lib/domain/schemas/index.d.mts +38 -6
- package/lib/domain/schemas/index.d.ts +38 -6
- package/lib/domain/schemas/index.js +571 -529
- package/lib/domain/schemas/index.mjs +535 -533
- package/lib/domain/types/index.d.mts +2 -2
- package/lib/domain/types/index.d.ts +2 -2
- package/lib/domain/types/index.js +8 -4
- package/lib/producers/index.d.mts +9 -6
- package/lib/producers/index.d.ts +9 -6
- package/lib/producers/index.js +12 -7
- package/lib/producers/index.mjs +1 -3
- package/package.json +7 -7
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
WorkerEventEntity,
|
|
4
|
+
WorkerProcessFunction,
|
|
5
|
+
WorkerFailureHandler
|
|
6
|
+
} from '@forklaunch/interfaces-worker/types';
|
|
3
7
|
import { BaseEntity, EntityName, EntityManager } from '@mikro-orm/core';
|
|
4
8
|
import { DatabaseWorkerOptions } from '../domain/types/index.mjs';
|
|
5
9
|
|
|
6
|
-
declare class DatabaseWorkerConsumer<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
declare class DatabaseWorkerConsumer<
|
|
11
|
+
EventEntity extends WorkerEventEntity & BaseEntity,
|
|
12
|
+
Options extends DatabaseWorkerOptions
|
|
13
|
+
> implements WorkerConsumer<EventEntity>
|
|
14
|
+
{
|
|
15
|
+
protected readonly entityName: EntityName<EventEntity>;
|
|
16
|
+
protected readonly em: EntityManager;
|
|
17
|
+
protected readonly options: Options;
|
|
18
|
+
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
19
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
20
|
+
constructor(
|
|
21
|
+
entityName: EntityName<EventEntity>,
|
|
22
|
+
em: EntityManager,
|
|
23
|
+
options: Options,
|
|
24
|
+
processEvents: WorkerProcessFunction<EventEntity>,
|
|
25
|
+
failureHandler: WorkerFailureHandler<EventEntity>
|
|
26
|
+
);
|
|
27
|
+
private retrieveEvents;
|
|
28
|
+
private updateEvents;
|
|
29
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
30
|
+
start(): Promise<void>;
|
|
17
31
|
}
|
|
18
32
|
|
|
19
33
|
export { DatabaseWorkerConsumer };
|
package/lib/consumers/index.d.ts
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
WorkerEventEntity,
|
|
4
|
+
WorkerProcessFunction,
|
|
5
|
+
WorkerFailureHandler
|
|
6
|
+
} from '@forklaunch/interfaces-worker/types';
|
|
3
7
|
import { BaseEntity, EntityName, EntityManager } from '@mikro-orm/core';
|
|
4
8
|
import { DatabaseWorkerOptions } from '../domain/types/index.js';
|
|
5
9
|
|
|
6
|
-
declare class DatabaseWorkerConsumer<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
declare class DatabaseWorkerConsumer<
|
|
11
|
+
EventEntity extends WorkerEventEntity & BaseEntity,
|
|
12
|
+
Options extends DatabaseWorkerOptions
|
|
13
|
+
> implements WorkerConsumer<EventEntity>
|
|
14
|
+
{
|
|
15
|
+
protected readonly entityName: EntityName<EventEntity>;
|
|
16
|
+
protected readonly em: EntityManager;
|
|
17
|
+
protected readonly options: Options;
|
|
18
|
+
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
19
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
20
|
+
constructor(
|
|
21
|
+
entityName: EntityName<EventEntity>,
|
|
22
|
+
em: EntityManager,
|
|
23
|
+
options: Options,
|
|
24
|
+
processEvents: WorkerProcessFunction<EventEntity>,
|
|
25
|
+
failureHandler: WorkerFailureHandler<EventEntity>
|
|
26
|
+
);
|
|
27
|
+
private retrieveEvents;
|
|
28
|
+
private updateEvents;
|
|
29
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
30
|
+
start(): Promise<void>;
|
|
17
31
|
}
|
|
18
32
|
|
|
19
33
|
export { DatabaseWorkerConsumer };
|
package/lib/consumers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -8,14 +8,18 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from ===
|
|
11
|
+
if ((from && typeof from === 'object') || typeof from === 'function') {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
15
18
|
}
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
18
|
-
var __toCommonJS = (mod) =>
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
|
19
23
|
|
|
20
24
|
// consumers/index.ts
|
|
21
25
|
var consumers_exports = {};
|
|
@@ -45,7 +49,7 @@ var DatabaseWorkerConsumer = class {
|
|
|
45
49
|
retryCount: { $lt: this.options.retries }
|
|
46
50
|
},
|
|
47
51
|
{
|
|
48
|
-
orderBy: { createdAt:
|
|
52
|
+
orderBy: { createdAt: 'ASC' }
|
|
49
53
|
}
|
|
50
54
|
);
|
|
51
55
|
}
|
|
@@ -71,6 +75,7 @@ var DatabaseWorkerConsumer = class {
|
|
|
71
75
|
}
|
|
72
76
|
};
|
|
73
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 &&
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
0 &&
|
|
79
|
+
(module.exports = {
|
|
80
|
+
DatabaseWorkerConsumer
|
|
81
|
+
});
|
package/lib/consumers/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ var DatabaseWorkerConsumer = class {
|
|
|
19
19
|
retryCount: { $lt: this.options.retries }
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
orderBy: { createdAt:
|
|
22
|
+
orderBy: { createdAt: 'ASC' }
|
|
23
23
|
}
|
|
24
24
|
);
|
|
25
25
|
}
|
|
@@ -44,6 +44,4 @@ var DatabaseWorkerConsumer = class {
|
|
|
44
44
|
}, this.options.interval);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
export {
|
|
48
|
-
DatabaseWorkerConsumer
|
|
49
|
-
};
|
|
47
|
+
export { DatabaseWorkerConsumer };
|
|
@@ -3,14 +3,46 @@ import * as zod_v3 from 'zod/v3';
|
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
5
|
|
|
6
|
-
declare const DatabaseWorkerSchemas: <
|
|
6
|
+
declare const DatabaseWorkerSchemas: <
|
|
7
|
+
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
+
>(
|
|
9
|
+
options: Record<string, unknown> & {
|
|
7
10
|
validator: SchemaValidator;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
) => _forklaunch_internal.SchemasByValidator<
|
|
13
|
+
SchemaValidator,
|
|
14
|
+
(options: Record<string, unknown>) => {
|
|
15
|
+
retries: _sinclair_typebox.TTransform<
|
|
16
|
+
_sinclair_typebox.TUnion<
|
|
17
|
+
[
|
|
18
|
+
_sinclair_typebox.TNumber,
|
|
19
|
+
_sinclair_typebox.TString,
|
|
20
|
+
_sinclair_typebox.TBoolean,
|
|
21
|
+
_sinclair_typebox.TNull,
|
|
22
|
+
_sinclair_typebox.TBigInt,
|
|
23
|
+
_sinclair_typebox.TDate
|
|
24
|
+
]
|
|
25
|
+
>,
|
|
26
|
+
number
|
|
27
|
+
>;
|
|
28
|
+
interval: _sinclair_typebox.TTransform<
|
|
29
|
+
_sinclair_typebox.TUnion<
|
|
30
|
+
[
|
|
31
|
+
_sinclair_typebox.TNumber,
|
|
32
|
+
_sinclair_typebox.TString,
|
|
33
|
+
_sinclair_typebox.TBoolean,
|
|
34
|
+
_sinclair_typebox.TNull,
|
|
35
|
+
_sinclair_typebox.TBigInt,
|
|
36
|
+
_sinclair_typebox.TDate
|
|
37
|
+
]
|
|
38
|
+
>,
|
|
39
|
+
number
|
|
40
|
+
>;
|
|
41
|
+
},
|
|
42
|
+
(options: Record<string, unknown>) => {
|
|
12
43
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
13
44
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
14
|
-
}
|
|
45
|
+
}
|
|
46
|
+
>;
|
|
15
47
|
|
|
16
48
|
export { DatabaseWorkerSchemas };
|
|
@@ -3,14 +3,46 @@ import * as zod_v3 from 'zod/v3';
|
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
5
|
|
|
6
|
-
declare const DatabaseWorkerSchemas: <
|
|
6
|
+
declare const DatabaseWorkerSchemas: <
|
|
7
|
+
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
+
>(
|
|
9
|
+
options: Record<string, unknown> & {
|
|
7
10
|
validator: SchemaValidator;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
) => _forklaunch_internal.SchemasByValidator<
|
|
13
|
+
SchemaValidator,
|
|
14
|
+
(options: Record<string, unknown>) => {
|
|
15
|
+
retries: _sinclair_typebox.TTransform<
|
|
16
|
+
_sinclair_typebox.TUnion<
|
|
17
|
+
[
|
|
18
|
+
_sinclair_typebox.TNumber,
|
|
19
|
+
_sinclair_typebox.TString,
|
|
20
|
+
_sinclair_typebox.TBoolean,
|
|
21
|
+
_sinclair_typebox.TNull,
|
|
22
|
+
_sinclair_typebox.TBigInt,
|
|
23
|
+
_sinclair_typebox.TDate
|
|
24
|
+
]
|
|
25
|
+
>,
|
|
26
|
+
number
|
|
27
|
+
>;
|
|
28
|
+
interval: _sinclair_typebox.TTransform<
|
|
29
|
+
_sinclair_typebox.TUnion<
|
|
30
|
+
[
|
|
31
|
+
_sinclair_typebox.TNumber,
|
|
32
|
+
_sinclair_typebox.TString,
|
|
33
|
+
_sinclair_typebox.TBoolean,
|
|
34
|
+
_sinclair_typebox.TNull,
|
|
35
|
+
_sinclair_typebox.TBigInt,
|
|
36
|
+
_sinclair_typebox.TDate
|
|
37
|
+
]
|
|
38
|
+
>,
|
|
39
|
+
number
|
|
40
|
+
>;
|
|
41
|
+
},
|
|
42
|
+
(options: Record<string, unknown>) => {
|
|
12
43
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
13
44
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
14
|
-
}
|
|
45
|
+
}
|
|
46
|
+
>;
|
|
15
47
|
|
|
16
48
|
export { DatabaseWorkerSchemas };
|