@forklaunch/implementation-worker-database 0.2.2 → 0.3.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.
Files changed (47) hide show
  1. package/lib/consumers/index.d.mts +19 -0
  2. package/lib/consumers/index.d.ts +19 -2
  3. package/lib/consumers/index.js +69 -1
  4. package/lib/consumers/{databaseWorker.consumer.js → index.mjs} +7 -8
  5. package/lib/producers/index.d.mts +13 -0
  6. package/lib/producers/index.d.ts +13 -2
  7. package/lib/producers/index.js +43 -1
  8. package/lib/producers/{databaseWorker.producer.js → index.mjs} +6 -4
  9. package/lib/schemas/index.d.mts +16 -0
  10. package/lib/schemas/index.d.ts +16 -2
  11. package/lib/schemas/index.js +1369 -1
  12. package/lib/schemas/index.mjs +1373 -0
  13. package/lib/types/index.d.mts +6 -0
  14. package/lib/types/index.d.ts +6 -2
  15. package/lib/types/index.js +18 -1
  16. package/lib/types/index.mjs +0 -0
  17. package/package.json +6 -5
  18. package/lib/__test__/schemaEquality.test.d.ts +0 -2
  19. package/lib/__test__/schemaEquality.test.d.ts.map +0 -1
  20. package/lib/__test__/schemaEquality.test.js +0 -20
  21. package/lib/consumers/databaseWorker.consumer.d.ts +0 -31
  22. package/lib/consumers/databaseWorker.consumer.d.ts.map +0 -1
  23. package/lib/consumers/index.d.ts.map +0 -1
  24. package/lib/jest.config.d.ts +0 -4
  25. package/lib/jest.config.d.ts.map +0 -1
  26. package/lib/jest.config.js +0 -19
  27. package/lib/producers/databaseWorker.producer.d.ts +0 -14
  28. package/lib/producers/databaseWorker.producer.d.ts.map +0 -1
  29. package/lib/producers/index.d.ts.map +0 -1
  30. package/lib/schemas/databaseWorker.schema.d.ts +0 -46
  31. package/lib/schemas/databaseWorker.schema.d.ts.map +0 -1
  32. package/lib/schemas/databaseWorker.schema.js +0 -7
  33. package/lib/schemas/index.d.ts.map +0 -1
  34. package/lib/schemas/typebox/databaseWorker.schema.d.ts +0 -29
  35. package/lib/schemas/typebox/databaseWorker.schema.d.ts.map +0 -1
  36. package/lib/schemas/typebox/databaseWorker.schema.js +0 -5
  37. package/lib/schemas/zod/databaseWorker.schema.d.ts +0 -5
  38. package/lib/schemas/zod/databaseWorker.schema.d.ts.map +0 -1
  39. package/lib/schemas/zod/databaseWorker.schema.js +0 -5
  40. package/lib/tsconfig.tsbuildinfo +0 -1
  41. package/lib/types/databaseWorker.types.d.ts +0 -5
  42. package/lib/types/databaseWorker.types.d.ts.map +0 -1
  43. package/lib/types/databaseWorker.types.js +0 -1
  44. package/lib/types/index.d.ts.map +0 -1
  45. package/lib/vitest.config.d.ts +0 -3
  46. package/lib/vitest.config.d.ts.map +0 -1
  47. package/lib/vitest.config.js +0 -7
@@ -0,0 +1,6 @@
1
+ type DatabaseWorkerOptions = {
2
+ retries: number;
3
+ interval: number;
4
+ };
5
+
6
+ export type { DatabaseWorkerOptions };
@@ -1,2 +1,6 @@
1
- export * from './databaseWorker.types';
2
- //# sourceMappingURL=index.d.ts.map
1
+ type DatabaseWorkerOptions = {
2
+ retries: number;
3
+ interval: number;
4
+ };
5
+
6
+ export type { DatabaseWorkerOptions };
@@ -1 +1,18 @@
1
- export * from './databaseWorker.types';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // types/index.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-worker-database",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Database implementation for forklaunch workers",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -38,13 +38,14 @@
38
38
  "lib/**"
39
39
  ],
40
40
  "dependencies": {
41
- "@forklaunch/core": "^0.9.10",
41
+ "@forklaunch/core": "^0.9.13",
42
42
  "@mikro-orm/core": "^6.4.16",
43
43
  "@sinclair/typebox": "^0.34.33",
44
- "zod": "^3.25.61",
45
- "@forklaunch/interfaces-worker": "0.1.10"
44
+ "zod": "^3.25.62",
45
+ "@forklaunch/interfaces-worker": "0.2.0"
46
46
  },
47
47
  "devDependencies": {
48
+ "@typescript/native-preview": "7.0.0-dev.20250611.1",
48
49
  "depcheck": "^1.4.7",
49
50
  "eslint": "^9.28.0",
50
51
  "prettier": "^3.5.3",
@@ -52,7 +53,7 @@
52
53
  "typescript-eslint": "^8.34.0"
53
54
  },
54
55
  "scripts": {
55
- "build": "tsc && if [ -f eject-package.bash ]; then pnpm package:eject; fi",
56
+ "build": "tsc --noEmit && tsup producers/index.ts consumers/index.ts schemas/index.ts types/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean && if [ -f eject-package.bash ]; then pnpm package:eject; fi",
56
57
  "clean": "rm -rf lib pnpm.lock.yaml node_modules",
57
58
  "docs": "typedoc --out docs *",
58
59
  "format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=schemaEquality.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemaEquality.test.d.ts","sourceRoot":"","sources":["../../__test__/schemaEquality.test.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- import { isTrue } from '@forklaunch/common';
2
- import { testSchemaEquality } from '@forklaunch/core/test';
3
- import { DatabaseWorkerOptionsSchema as TypeboxDatabaseWorkerOptionsSchema } from '../schemas/typebox/databaseWorker.schema';
4
- import { DatabaseWorkerOptionsSchema as ZodDatabaseWorkerOptionsSchema } from '../schemas/zod/databaseWorker.schema';
5
- describe('schema equality', () => {
6
- it('should be equal for bullmq worker', () => {
7
- expect(
8
- isTrue(
9
- testSchemaEquality(
10
- ZodDatabaseWorkerOptionsSchema,
11
- TypeboxDatabaseWorkerOptionsSchema,
12
- {
13
- retries: 1,
14
- interval: 1000
15
- }
16
- )
17
- )
18
- ).toBeTruthy();
19
- });
20
- });
@@ -1,31 +0,0 @@
1
- import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
2
- import {
3
- WorkerEventEntity,
4
- WorkerFailureHandler,
5
- WorkerProcessFunction
6
- } from '@forklaunch/interfaces-worker/types';
7
- import { BaseEntity, EntityManager, EntityName } from '@mikro-orm/core';
8
- import { DatabaseWorkerOptions } from '../types/databaseWorker.types';
9
- export declare class DatabaseWorkerConsumer<
10
- EventEntity extends WorkerEventEntity & BaseEntity,
11
- Options extends DatabaseWorkerOptions
12
- > implements WorkerConsumer<EventEntity>
13
- {
14
- protected readonly entityName: EntityName<EventEntity>;
15
- protected readonly em: EntityManager;
16
- protected readonly options: Options;
17
- protected readonly processEvents: WorkerProcessFunction<EventEntity>;
18
- protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
19
- constructor(
20
- entityName: EntityName<EventEntity>,
21
- em: EntityManager,
22
- options: Options,
23
- processEvents: WorkerProcessFunction<EventEntity>,
24
- failureHandler: WorkerFailureHandler<EventEntity>
25
- );
26
- private retrieveEvents;
27
- private updateEvents;
28
- peekEvents(): Promise<EventEntity[]>;
29
- start(): Promise<void>;
30
- }
31
- //# sourceMappingURL=databaseWorker.consumer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"databaseWorker.consumer.d.ts","sourceRoot":"","sources":["../../consumers/databaseWorker.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,qBAAa,sBAAsB,CACjC,WAAW,SAAS,iBAAiB,GAAG,UAAU,EAClD,OAAO,SAAS,qBAAqB,CACrC,YAAW,cAAc,CAAC,WAAW,CAAC;IAGpC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,WAAW,CAAC;IACtD,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,aAAa;IACpC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO;IACnC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC,WAAW,CAAC;IACpE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;gBAJjD,UAAU,EAAE,UAAU,CAAC,WAAW,CAAC,EACnC,EAAE,EAAE,aAAa,EACjB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,qBAAqB,CAAC,WAAW,CAAC,EACjD,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;YAGxD,cAAc;YAUd,YAAY;IASpB,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAIpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAS7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../consumers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { JestConfigWithTsJest } from 'ts-jest';
2
- declare const jestConfig: JestConfigWithTsJest;
3
- export default jestConfig;
4
- //# sourceMappingURL=jest.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../jest.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,QAAA,MAAM,UAAU,EAAE,oBAiBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,19 +0,0 @@
1
- const jestConfig = {
2
- preset: 'ts-jest/presets/default-esm', // or other ESM presets
3
- moduleNameMapper: {
4
- '^(\\.{1,2}/.*)\\.js$': '$1'
5
- },
6
- transform: {
7
- // '^.+\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`
8
- // '^.+\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`
9
- '^.+\\.[tj]sx?$': [
10
- 'ts-jest',
11
- {
12
- useESM: true
13
- }
14
- ],
15
- '^.+\\.js$': 'babel-jest'
16
- },
17
- testPathIgnorePatterns: ['.*dist/', '.*node_modules/']
18
- };
19
- export default jestConfig;
@@ -1,14 +0,0 @@
1
- import { WorkerEventEntity } from '@forklaunch/interfaces-worker/types';
2
- import { BaseEntity, EntityManager } from '@mikro-orm/core';
3
- import { DatabaseWorkerOptions } from '../types/databaseWorker.types';
4
- export declare class DatabaseWorkerProducer<
5
- EventEntity extends WorkerEventEntity & BaseEntity,
6
- Options extends DatabaseWorkerOptions
7
- > {
8
- private readonly em;
9
- private readonly options;
10
- constructor(em: EntityManager, options: Options);
11
- enqueueJob(event: EventEntity): Promise<void>;
12
- enqueueBatchJobs(events: EventEntity[]): Promise<void>;
13
- }
14
- //# sourceMappingURL=databaseWorker.producer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"databaseWorker.producer.d.ts","sourceRoot":"","sources":["../../producers/databaseWorker.producer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,qBAAa,sBAAsB,CACjC,WAAW,SAAS,iBAAiB,GAAG,UAAU,EAClD,OAAO,SAAS,qBAAqB;IAGnC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,EAAE,EAAE,aAAa,EACjB,OAAO,EAAE,OAAO;IAG7B,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG7D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../producers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -1,46 +0,0 @@
1
- export declare const DatabaseWorkerSchemas: <
2
- SchemaValidator extends import('@forklaunch/validator').AnySchemaValidator
3
- >(
4
- options: Record<string, unknown> & {
5
- validator: SchemaValidator;
6
- }
7
- ) => import('@forklaunch/core/mappers').SchemasByValidator<
8
- SchemaValidator,
9
- (options: Record<string, unknown>) => {
10
- retries: import('@sinclair/typebox').TTransform<
11
- import('@sinclair/typebox').TUnion<
12
- [
13
- import('@sinclair/typebox').TNumber,
14
- import('@sinclair/typebox').TString,
15
- import('@sinclair/typebox').TBoolean,
16
- import('@sinclair/typebox').TNull,
17
- import('@sinclair/typebox').TBigInt,
18
- import('@sinclair/typebox').TDate
19
- ]
20
- >,
21
- number
22
- >;
23
- interval: import('@sinclair/typebox').TTransform<
24
- import('@sinclair/typebox').TUnion<
25
- [
26
- import('@sinclair/typebox').TNumber,
27
- import('@sinclair/typebox').TString,
28
- import('@sinclair/typebox').TBoolean,
29
- import('@sinclair/typebox').TNull,
30
- import('@sinclair/typebox').TBigInt,
31
- import('@sinclair/typebox').TDate
32
- ]
33
- >,
34
- number
35
- >;
36
- },
37
- (options: Record<string, unknown>) => {
38
- retries: import('zod').ZodEffects<import('zod').ZodNumber, number, unknown>;
39
- interval: import('zod').ZodEffects<
40
- import('zod').ZodNumber,
41
- number,
42
- unknown
43
- >;
44
- }
45
- >;
46
- //# sourceMappingURL=databaseWorker.schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"databaseWorker.schema.d.ts","sourceRoot":"","sources":["../../schemas/databaseWorker.schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB;;;;;;;;EAGjC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { serviceSchemaResolver } from '@forklaunch/core/mappers';
2
- import { DatabaseWorkerOptionsSchema as TypeBoxSchemas } from './typebox/databaseWorker.schema';
3
- import { DatabaseWorkerOptionsSchema as ZodSchemas } from './zod/databaseWorker.schema';
4
- export const DatabaseWorkerSchemas = serviceSchemaResolver(
5
- () => TypeBoxSchemas,
6
- () => ZodSchemas
7
- );
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -1,29 +0,0 @@
1
- export declare const DatabaseWorkerOptionsSchema: {
2
- retries: import('@sinclair/typebox').TTransform<
3
- import('@sinclair/typebox').TUnion<
4
- [
5
- import('@sinclair/typebox').TNumber,
6
- import('@sinclair/typebox').TString,
7
- import('@sinclair/typebox').TBoolean,
8
- import('@sinclair/typebox').TNull,
9
- import('@sinclair/typebox').TBigInt,
10
- import('@sinclair/typebox').TDate
11
- ]
12
- >,
13
- number
14
- >;
15
- interval: import('@sinclair/typebox').TTransform<
16
- import('@sinclair/typebox').TUnion<
17
- [
18
- import('@sinclair/typebox').TNumber,
19
- import('@sinclair/typebox').TString,
20
- import('@sinclair/typebox').TBoolean,
21
- import('@sinclair/typebox').TNull,
22
- import('@sinclair/typebox').TBigInt,
23
- import('@sinclair/typebox').TDate
24
- ]
25
- >,
26
- number
27
- >;
28
- };
29
- //# sourceMappingURL=databaseWorker.schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"databaseWorker.schema.d.ts","sourceRoot":"","sources":["../../../schemas/typebox/databaseWorker.schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B;;;CAGvC,CAAC"}
@@ -1,5 +0,0 @@
1
- import { number } from '@forklaunch/validator/typebox';
2
- export const DatabaseWorkerOptionsSchema = {
3
- retries: number,
4
- interval: number
5
- };
@@ -1,5 +0,0 @@
1
- export declare const DatabaseWorkerOptionsSchema: {
2
- retries: import('zod').ZodEffects<import('zod').ZodNumber, number, unknown>;
3
- interval: import('zod').ZodEffects<import('zod').ZodNumber, number, unknown>;
4
- };
5
- //# sourceMappingURL=databaseWorker.schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"databaseWorker.schema.d.ts","sourceRoot":"","sources":["../../../schemas/zod/databaseWorker.schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B;;;CAGvC,CAAC"}
@@ -1,5 +0,0 @@
1
- import { number } from '@forklaunch/validator/zod';
2
- export const DatabaseWorkerOptionsSchema = {
3
- retries: number,
4
- interval: number
5
- };