@forklaunch/implementation-worker-database 0.3.2 → 0.3.3
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 +27 -13
- package/lib/consumers/index.d.ts +27 -13
- package/lib/consumers/index.js +13 -8
- package/lib/consumers/index.mjs +2 -4
- package/lib/domain/schemas/index.d.mts +48 -0
- package/lib/domain/schemas/index.d.ts +48 -0
- package/lib/{schemas → domain/schemas}/index.js +865 -494
- package/lib/{schemas → domain/schemas}/index.mjs +841 -501
- package/lib/{types → domain/types}/index.d.mts +2 -2
- package/lib/{types → domain/types}/index.d.ts +2 -2
- package/lib/{types → domain/types}/index.js +9 -5
- package/lib/eject/consumers/databaseWorker.consumer.ts +1 -1
- package/lib/eject/producers/databaseWorker.producer.ts +1 -1
- package/lib/producers/index.d.mts +10 -7
- package/lib/producers/index.d.ts +10 -7
- package/lib/producers/index.js +12 -7
- package/lib/producers/index.mjs +1 -3
- package/package.json +10 -10
- package/lib/schemas/index.d.mts +0 -16
- package/lib/schemas/index.d.ts +0 -16
- /package/lib/{types → domain/types}/index.mjs +0 -0
- /package/lib/eject/{types → domain/types}/databaseWorker.types.ts +0 -0
- /package/lib/eject/{types → domain/types}/index.ts +0 -0
|
@@ -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
|
-
import { DatabaseWorkerOptions } from '../types/index.mjs';
|
|
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
|
-
import { DatabaseWorkerOptions } from '../types/index.js';
|
|
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 = {};
|
|
@@ -39,7 +43,7 @@ var DatabaseWorkerConsumer = class {
|
|
|
39
43
|
processed: false,
|
|
40
44
|
retryCount: { $lt: this.options.retries }
|
|
41
45
|
},
|
|
42
|
-
orderBy: { createdAt:
|
|
46
|
+
orderBy: { createdAt: 'ASC' }
|
|
43
47
|
});
|
|
44
48
|
}
|
|
45
49
|
async updateEvents(events) {
|
|
@@ -64,6 +68,7 @@ var DatabaseWorkerConsumer = class {
|
|
|
64
68
|
}
|
|
65
69
|
};
|
|
66
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
-
0 &&
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
0 &&
|
|
72
|
+
(module.exports = {
|
|
73
|
+
DatabaseWorkerConsumer
|
|
74
|
+
});
|
package/lib/consumers/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ var DatabaseWorkerConsumer = class {
|
|
|
13
13
|
processed: false,
|
|
14
14
|
retryCount: { $lt: this.options.retries }
|
|
15
15
|
},
|
|
16
|
-
orderBy: { createdAt:
|
|
16
|
+
orderBy: { createdAt: 'ASC' }
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
async updateEvents(events) {
|
|
@@ -37,6 +37,4 @@ var DatabaseWorkerConsumer = class {
|
|
|
37
37
|
}, this.options.interval);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
export {
|
|
41
|
-
DatabaseWorkerConsumer
|
|
42
|
-
};
|
|
40
|
+
export { DatabaseWorkerConsumer };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as _forklaunch_internal from '@forklaunch/internal';
|
|
2
|
+
import * as zod from 'zod';
|
|
3
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
|
+
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
|
+
|
|
6
|
+
declare const DatabaseWorkerSchemas: <
|
|
7
|
+
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
+
>(
|
|
9
|
+
options: Record<string, unknown> & {
|
|
10
|
+
validator: SchemaValidator;
|
|
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>) => {
|
|
43
|
+
retries: zod.ZodEffects<zod.ZodNumber, number, unknown>;
|
|
44
|
+
interval: zod.ZodEffects<zod.ZodNumber, number, unknown>;
|
|
45
|
+
}
|
|
46
|
+
>;
|
|
47
|
+
|
|
48
|
+
export { DatabaseWorkerSchemas };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as _forklaunch_internal from '@forklaunch/internal';
|
|
2
|
+
import * as zod from 'zod';
|
|
3
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
|
+
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
|
+
|
|
6
|
+
declare const DatabaseWorkerSchemas: <
|
|
7
|
+
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
+
>(
|
|
9
|
+
options: Record<string, unknown> & {
|
|
10
|
+
validator: SchemaValidator;
|
|
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>) => {
|
|
43
|
+
retries: zod.ZodEffects<zod.ZodNumber, number, unknown>;
|
|
44
|
+
interval: zod.ZodEffects<zod.ZodNumber, number, unknown>;
|
|
45
|
+
}
|
|
46
|
+
>;
|
|
47
|
+
|
|
48
|
+
export { DatabaseWorkerSchemas };
|