@anchan828/nest-cloud-run-queue-common 3.1.7 → 3.1.8

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.
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces";
2
+ export * from "./providers";
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces";
2
+ export * from "./providers";
@@ -0,0 +1,22 @@
1
+ import { Type } from "@nestjs/common";
2
+ import { ModuleMetadata } from "@nestjs/common/interfaces";
3
+ export type ModuleOptions = {};
4
+ export interface ModuleAsyncOptions<T extends ModuleOptions = ModuleOptions> extends Pick<ModuleMetadata, "imports"> {
5
+ useClass?: Type<ModuleOptionsFactory<T>>;
6
+ useExisting?: Type<ModuleOptionsFactory<T>>;
7
+ useFactory?: (...args: any[]) => Promise<T> | T;
8
+ inject?: Array<Type<ModuleOptionsFactory<T>> | string | any>;
9
+ }
10
+ export interface ModuleOptionsFactory<T extends ModuleOptions = ModuleOptions> {
11
+ createModuleOptions(): Promise<T> | T;
12
+ }
13
+ export type QueueWorkerName = string;
14
+ export interface Message<T = any> {
15
+ name: QueueWorkerName;
16
+ data?: T;
17
+ }
18
+ export type PublishExtraConfig<T extends Message = Message> = {
19
+ prePublish?: (message: T) => T | Promise<T>;
20
+ postPublish?: (message: T, resultId: string) => void | Promise<void>;
21
+ stringifyReplacer?: (key: string, value: any) => any;
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Provider, Type } from "@nestjs/common";
2
+ import { Abstract, FactoryProvider } from "@nestjs/common/interfaces";
3
+ import { ModuleAsyncOptions, ModuleOptions } from "./interfaces";
4
+ type ProvideType = string | symbol | Type<any> | Abstract<any> | (() => any);
5
+ export declare function createOptionProvider(provide: ProvideType, options: ModuleOptions): Provider;
6
+ export declare function createAsyncOptionsProvider(provide: ProvideType, options: ModuleAsyncOptions): FactoryProvider;
7
+ export declare function createAsyncProviders(provide: ProvideType, options: ModuleAsyncOptions): Provider[];
8
+ export {};
@@ -0,0 +1,30 @@
1
+ export function createOptionProvider(provide, options) {
2
+ return { provide, useFactory: () => options };
3
+ }
4
+ export function createAsyncOptionsProvider(provide, options) {
5
+ if (options.useFactory) {
6
+ return {
7
+ inject: options.inject || [],
8
+ provide,
9
+ useFactory: options.useFactory,
10
+ };
11
+ }
12
+ return {
13
+ inject: [options.useClass || options.useExisting].filter((x) => x !== undefined),
14
+ provide,
15
+ useFactory: async (optionsFactory) => optionsFactory.createModuleOptions(),
16
+ };
17
+ }
18
+ export function createAsyncProviders(provide, options) {
19
+ const asyncOptionsProvider = createAsyncOptionsProvider(provide, options);
20
+ if (options.useExisting || options.useFactory) {
21
+ return [asyncOptionsProvider];
22
+ }
23
+ return [
24
+ asyncOptionsProvider,
25
+ {
26
+ provide: options.useClass,
27
+ useClass: options.useClass,
28
+ },
29
+ ];
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anchan828/nest-cloud-run-queue-common",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "https://github.com/anchan828/nest-cloud-run-queue/tree/master/packages/common#readme",
6
6
  "bugs": {
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "anchan828 <anchan828@gmail.com>",
15
- "main": "./dist/index.js",
16
- "types": "./dist/index.d.ts",
15
+ "main": "dist/cjs/index.js",
16
+ "types": "dist/cjs/index.d.ts",
17
17
  "directories": {
18
18
  "dist": "dist"
19
19
  },
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "scripts": {
24
- "build": "tsc -p tsconfig.build.json",
24
+ "build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
25
25
  "build:watch": "tsc --watch",
26
26
  "copy:license": "cp ../../LICENSE ./",
27
27
  "lint": "TIMING=1 eslint '**/*.ts'",
@@ -43,5 +43,19 @@
43
43
  "access": "public"
44
44
  },
45
45
  "packageManager": "npm@10.8.2",
46
- "gitHead": "d63c1143192396b815ac6b72d54925971d00497a"
46
+ "exports": {
47
+ ".": {
48
+ "import": {
49
+ "types": "./dist/esm/index.d.ts",
50
+ "default": "./dist/esm/index.js"
51
+ },
52
+ "require": {
53
+ "types": "./dist/cjs/index.d.ts",
54
+ "default": "./dist/cjs/index.js"
55
+ },
56
+ "types": "./dist/cjs/index.d.ts",
57
+ "default": "./dist/cjs/index.js"
58
+ }
59
+ },
60
+ "gitHead": "c6565dcca7c5ed619b5929f3342f55804b05519c"
47
61
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes