@punks/backend-entity-manager 0.0.365 → 0.0.367
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/dist/cjs/index.js +305 -96
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/index.d.ts +1 -0
- package/dist/cjs/types/abstractions/serializer.d.ts +2 -0
- package/dist/cjs/types/abstractions/tasks.d.ts +13 -0
- package/dist/cjs/types/platforms/nest/__test__/tests/tasks/parallel-task.test.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/tests/tasks/single-task.test.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/tests/tasks/tasks.d.ts +12 -0
- package/dist/cjs/types/platforms/nest/decorators/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/decorators/tasks.d.ts +13 -0
- package/dist/cjs/types/platforms/nest/extensions/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/tasks/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/tasks/initializer.d.ts +13 -0
- package/dist/cjs/types/platforms/nest/extensions/tasks/module.d.ts +7 -0
- package/dist/cjs/types/platforms/nest/extensions/tasks/task-scheduler/index.d.ts +13 -0
- package/dist/cjs/types/platforms/nest/extensions/tasks/task-shell/index.d.ts +15 -0
- package/dist/cjs/types/utils/cron.d.ts +1 -0
- package/dist/cjs/types/utils/dates.d.ts +1 -0
- package/dist/esm/index.js +305 -97
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/index.d.ts +1 -0
- package/dist/esm/types/abstractions/serializer.d.ts +2 -0
- package/dist/esm/types/abstractions/tasks.d.ts +13 -0
- package/dist/esm/types/platforms/nest/__test__/tests/tasks/parallel-task.test.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/tests/tasks/single-task.test.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/tests/tasks/tasks.d.ts +12 -0
- package/dist/esm/types/platforms/nest/decorators/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/decorators/tasks.d.ts +13 -0
- package/dist/esm/types/platforms/nest/extensions/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/tasks/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/tasks/initializer.d.ts +13 -0
- package/dist/esm/types/platforms/nest/extensions/tasks/module.d.ts +7 -0
- package/dist/esm/types/platforms/nest/extensions/tasks/task-scheduler/index.d.ts +13 -0
- package/dist/esm/types/platforms/nest/extensions/tasks/task-shell/index.d.ts +15 -0
- package/dist/esm/types/utils/cron.d.ts +1 -0
- package/dist/esm/types/utils/dates.d.ts +1 -0
- package/dist/index.d.ts +60 -2
- package/package.json +16 -16
|
@@ -34,5 +34,6 @@ export { IAppSessionService } from "./session";
|
|
|
34
34
|
export { EntityManagerSettings } from "./settings";
|
|
35
35
|
export { IEntitySnapshotService } from "./snapshot";
|
|
36
36
|
export { IEntitySearchResults, IEntityFacet, IEntityFacetValue, IEntityFacets, ISearchResultsPaging, } from "./searchResults";
|
|
37
|
+
export { ITask } from "./tasks";
|
|
37
38
|
export * from "./tracking";
|
|
38
39
|
export { EntityVersionOperation, EntityVersionInput, IEntityVersioningResults, IEntityVersioningProvider, IEntityVersionsSearchInput, } from "./versioning";
|
|
@@ -24,6 +24,7 @@ export type EntitySerializerColumnValidator<TSheetItem> = {
|
|
|
24
24
|
key: string;
|
|
25
25
|
fn: (item: TSheetItem) => EntryValidationResult;
|
|
26
26
|
};
|
|
27
|
+
export type EntitySerializerSheetCustomParser = "date";
|
|
27
28
|
export type EntitySerializerColumnDefinition<TSheetItem> = {
|
|
28
29
|
name: string;
|
|
29
30
|
key: string;
|
|
@@ -35,6 +36,7 @@ export type EntitySerializerColumnDefinition<TSheetItem> = {
|
|
|
35
36
|
converter?: EntitySerializerColumnConverter<TSheetItem>;
|
|
36
37
|
validators?: EntitySerializerColumnValidator<TSheetItem>[];
|
|
37
38
|
idColumn?: boolean;
|
|
39
|
+
sheetParser?: EntitySerializerSheetCustomParser;
|
|
38
40
|
};
|
|
39
41
|
export type EntitySerializerSheetDefinition<TSheetItem> = {
|
|
40
42
|
columns: EntitySerializerColumnDefinition<TSheetItem>[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum TaskRunType {
|
|
2
|
+
Scheduled = "Scheduled",
|
|
3
|
+
OnDemand = "OnDemand"
|
|
4
|
+
}
|
|
5
|
+
export type TaskContext = {
|
|
6
|
+
name: string;
|
|
7
|
+
runId: string;
|
|
8
|
+
runType: TaskRunType;
|
|
9
|
+
startedAt: Date;
|
|
10
|
+
};
|
|
11
|
+
export interface ITask {
|
|
12
|
+
execute(context: TaskContext): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ITask } from "../../../../../abstractions";
|
|
2
|
+
import { TaskContext } from "../../../../../abstractions/tasks";
|
|
3
|
+
export declare class SingleTask implements ITask {
|
|
4
|
+
private static counter;
|
|
5
|
+
execute(context: TaskContext): Promise<void>;
|
|
6
|
+
static getCounter(): number;
|
|
7
|
+
}
|
|
8
|
+
export declare class ParallelTask implements ITask {
|
|
9
|
+
private static counter;
|
|
10
|
+
execute(context: TaskContext): Promise<void>;
|
|
11
|
+
static getCounter(): number;
|
|
12
|
+
}
|
|
@@ -20,5 +20,6 @@ export { WpEntitySeeder, EntitySeederProps } from "./seed";
|
|
|
20
20
|
export { WpEntitySerializer, EntitySerializerProps } from "./serializer";
|
|
21
21
|
export { WpEntitySnapshotService, EntitySnapshotServiceProps } from "./snapshot";
|
|
22
22
|
export { EntityManagerSymbols } from "./symbols";
|
|
23
|
+
export { WpTask, TaskSettings } from "./tasks";
|
|
23
24
|
export { WpEventsTracker, EventsTrackerProps } from "./tracking";
|
|
24
25
|
export { WpEntityVersioningProvider, EntityVersioningProviderProps, } from "./versioning";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const TASK_KEY = "wp_task";
|
|
2
|
+
export declare enum TaskConcurrency {
|
|
3
|
+
Single = "single",
|
|
4
|
+
Multiple = "multiple"
|
|
5
|
+
}
|
|
6
|
+
export type TaskSettings = {
|
|
7
|
+
cronExpression: string;
|
|
8
|
+
concurrency: TaskConcurrency;
|
|
9
|
+
};
|
|
10
|
+
export type TaskProps = TaskSettings & {
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function WpTask(name: string, settings: TaskSettings): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TasksModule } from "./module";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { INestApplicationContext } from "@nestjs/common";
|
|
2
|
+
import { IAppInitializer } from "../../../../abstractions";
|
|
3
|
+
import { CustomDiscoveryService } from "../../ioc/discovery";
|
|
4
|
+
import { TaskScheduler } from "./task-scheduler";
|
|
5
|
+
export declare class TasksInitializer implements IAppInitializer {
|
|
6
|
+
private readonly discover;
|
|
7
|
+
private readonly scheduler;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
constructor(discover: CustomDiscoveryService, scheduler: TaskScheduler);
|
|
10
|
+
initialize(app: INestApplicationContext): Promise<void>;
|
|
11
|
+
private registerCronJobs;
|
|
12
|
+
private discoverTasks;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SchedulerRegistry } from "@nestjs/schedule";
|
|
2
|
+
import { TaskProps } from "../../../decorators/tasks";
|
|
3
|
+
import { ITask } from "../../../../../abstractions";
|
|
4
|
+
import { TaskShell } from "../task-shell";
|
|
5
|
+
export declare class TaskScheduler {
|
|
6
|
+
private schedulerRegistry;
|
|
7
|
+
private readonly jobShell;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private jobs;
|
|
10
|
+
constructor(schedulerRegistry: SchedulerRegistry, jobShell: TaskShell);
|
|
11
|
+
registerTask(job: TaskProps, instance: ITask): Promise<void>;
|
|
12
|
+
stopAllTasks(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TaskProps } from "../../../decorators/tasks";
|
|
2
|
+
import { ILockRepository, ITask } from "../../../../../abstractions";
|
|
3
|
+
import { EntityManagerRegistry } from "../../../ioc";
|
|
4
|
+
export declare class TaskShell {
|
|
5
|
+
private readonly registry;
|
|
6
|
+
private readonly operations;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(registry: EntityManagerRegistry, operations: ILockRepository);
|
|
9
|
+
executeTask(instance: ITask, settings: TaskProps): Promise<void>;
|
|
10
|
+
private executeTaskParallel;
|
|
11
|
+
private executeTaskSequential;
|
|
12
|
+
private getTaskLockKey;
|
|
13
|
+
private invokeTask;
|
|
14
|
+
private get operationsLockService();
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCronCurrentSchedule: (cronExpression: string, ref: Date) => Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function floorDateToSecond(date: Date): Date;
|