@akanjs/nest 0.0.39 → 0.0.41
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/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/authGuards.d.ts +51 -0
- package/src/authentication.d.ts +18 -0
- package/src/authorization.d.ts +3 -0
- package/src/cacheClient.d.ts +4 -0
- package/src/databaseClient.d.ts +5 -0
- package/src/decorators.d.ts +13 -0
- package/src/exceptions.d.ts +5 -0
- package/src/exporter.d.ts +22 -0
- package/src/generateSecrets.d.ts +36 -0
- package/src/index.d.ts +18 -0
- package/src/interceptors.d.ts +17 -0
- package/src/mongoose.d.ts +5 -0
- package/src/pipes.d.ts +48 -0
- package/src/redis-io.adapter.d.ts +19 -0
- package/src/searchClient.d.ts +28 -0
- package/src/sso.d.ts +75 -0
- package/src/verifyPayment.d.ts +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src";
|
package/package.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Account as SerAccount } from "@akanjs/signal";
|
|
2
|
+
import { CanActivate, ExecutionContext } from "@nestjs/common";
|
|
3
|
+
import type { Socket } from "socket.io";
|
|
4
|
+
export interface RequestContext {
|
|
5
|
+
account: SerAccount;
|
|
6
|
+
ip?: string;
|
|
7
|
+
userAgent?: string;
|
|
8
|
+
geolocation?: string;
|
|
9
|
+
headers: Record<string, string | undefined>;
|
|
10
|
+
cookies?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export interface ReqType {
|
|
13
|
+
method: string;
|
|
14
|
+
url: string;
|
|
15
|
+
params: object;
|
|
16
|
+
query: object;
|
|
17
|
+
body: object;
|
|
18
|
+
}
|
|
19
|
+
export interface GqlReqType {
|
|
20
|
+
parentType?: {
|
|
21
|
+
name?: string;
|
|
22
|
+
};
|
|
23
|
+
fieldName?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const getRequest: (context: ExecutionContext) => unknown;
|
|
26
|
+
export declare const getResponse: (context: ExecutionContext) => unknown;
|
|
27
|
+
export declare const getArgs: (context: ExecutionContext) => {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
export declare const getSocket: (context: ExecutionContext) => Socket<import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, any>;
|
|
31
|
+
export declare class Public implements CanActivate {
|
|
32
|
+
canActivate(context: ExecutionContext): boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare class None implements CanActivate {
|
|
35
|
+
canActivate(): boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare class Every implements CanActivate {
|
|
38
|
+
canActivate(context: ExecutionContext): boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare class Owner implements CanActivate {
|
|
41
|
+
canActivate(context: ExecutionContext): boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare class Admin implements CanActivate {
|
|
44
|
+
canActivate(context: ExecutionContext): boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare class SuperAdmin implements CanActivate {
|
|
47
|
+
canActivate(context: ExecutionContext): boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare class User implements CanActivate {
|
|
50
|
+
canActivate(context: ExecutionContext): boolean;
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const Account: (...dataOrPipes: ({
|
|
2
|
+
nullable?: boolean;
|
|
3
|
+
} | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
4
|
+
export declare const Self: (...dataOrPipes: ({
|
|
5
|
+
nullable?: boolean;
|
|
6
|
+
} | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
7
|
+
export declare const Me: (...dataOrPipes: ({
|
|
8
|
+
nullable?: boolean;
|
|
9
|
+
} | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
10
|
+
export declare const UserIp: (...dataOrPipes: ({
|
|
11
|
+
nullable?: boolean;
|
|
12
|
+
} | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
13
|
+
export declare const Access: (...dataOrPipes: ({
|
|
14
|
+
nullable?: boolean;
|
|
15
|
+
} | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
16
|
+
export declare const Req: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
17
|
+
export declare const Res: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
18
|
+
export declare const Ws: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { CronExpression } from "@nestjs/schedule";
|
|
3
|
+
export declare const Try: () => (target: any, key: string, descriptor: PropertyDescriptor) => void;
|
|
4
|
+
interface TimerOptions {
|
|
5
|
+
lock?: boolean;
|
|
6
|
+
serverMode?: "federation" | "batch";
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const Cron: (cronTime: CronExpression | string, { lock, serverMode, enabled }?: TimerOptions) => (target: any, key: string, descriptor: PropertyDescriptor) => void;
|
|
10
|
+
export declare const Interval: (ms: number, { lock, serverMode, enabled }?: TimerOptions) => (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor | undefined;
|
|
11
|
+
export declare const Transaction: () => (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
12
|
+
export declare const Cache: (timeout?: number, getCacheKey?: (...args: any) => string) => MethodDecorator;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
export declare const objPath: (o: unknown, p: string) => unknown;
|
|
3
|
+
export declare class FileSystem {
|
|
4
|
+
filename: string;
|
|
5
|
+
dirname: string;
|
|
6
|
+
writeStream?: fs.WriteStream;
|
|
7
|
+
constructor(dirname?: string, filename?: string);
|
|
8
|
+
init(): Promise<unknown>;
|
|
9
|
+
write(body: string): boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ExportForm<T> {
|
|
12
|
+
items: T[];
|
|
13
|
+
path: string;
|
|
14
|
+
fields?: string[];
|
|
15
|
+
options?: {
|
|
16
|
+
append: boolean;
|
|
17
|
+
};
|
|
18
|
+
delimiter?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const exportToCsv: <T>({ items, path, fields, delimiter, options }: ExportForm<T>) => Promise<void>;
|
|
21
|
+
export declare const exportToJson: <T>(items: T | T[], localPath: string) => void;
|
|
22
|
+
export declare const readJson: (localPath: string) => unknown;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BackendEnv, type BaseEnv } from "@akanjs/base";
|
|
2
|
+
import { SshOptions } from "tunnel-ssh";
|
|
3
|
+
export declare const generateJwtSecret: (appName: string, environment: "debug" | "develop" | "main" | "testing") => string;
|
|
4
|
+
export declare const generateAeskey: (appName: string, environment: "debug" | "develop" | "main" | "testing") => string;
|
|
5
|
+
interface RedisEnv {
|
|
6
|
+
appName: string;
|
|
7
|
+
appCode: number;
|
|
8
|
+
environment: BaseEnv["environment"];
|
|
9
|
+
operationMode: BaseEnv["operationMode"];
|
|
10
|
+
sshOptions?: SshOptions;
|
|
11
|
+
}
|
|
12
|
+
export declare const generateRedisUri: ({ appName, appCode, environment, operationMode, sshOptions }: RedisEnv) => Promise<string>;
|
|
13
|
+
interface MongoEnv {
|
|
14
|
+
appName: string;
|
|
15
|
+
appCode: number;
|
|
16
|
+
environment: BaseEnv["environment"];
|
|
17
|
+
operationMode: BaseEnv["operationMode"];
|
|
18
|
+
username?: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
sshOptions?: SshOptions;
|
|
21
|
+
}
|
|
22
|
+
export declare const generateMongoUri: ({ appName, appCode, environment, operationMode, username, password, sshOptions, }: MongoEnv) => Promise<string>;
|
|
23
|
+
interface MeiliEnv {
|
|
24
|
+
appName: string;
|
|
25
|
+
appCode: number;
|
|
26
|
+
environment: BaseEnv["environment"];
|
|
27
|
+
operationMode: BaseEnv["operationMode"];
|
|
28
|
+
}
|
|
29
|
+
export declare const generateMeiliUri: ({ appName, appCode, environment, operationMode }: MeiliEnv) => string;
|
|
30
|
+
export declare const SALT_ROUNDS = 11;
|
|
31
|
+
export declare const generateHost: (env: BackendEnv) => string;
|
|
32
|
+
export declare const generateMeiliKey: ({ appName, environment }: {
|
|
33
|
+
appName: string;
|
|
34
|
+
environment: string;
|
|
35
|
+
}) => string;
|
|
36
|
+
export {};
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./authorization";
|
|
2
|
+
export * from "./authGuards";
|
|
3
|
+
export * as guards from "./authGuards";
|
|
4
|
+
export * from "./authentication";
|
|
5
|
+
export * from "./interceptors";
|
|
6
|
+
export * from "./redis-io.adapter";
|
|
7
|
+
export * from "./pipes";
|
|
8
|
+
export * as Exporter from "./exporter";
|
|
9
|
+
export * from "./exporter";
|
|
10
|
+
export * from "./verifyPayment";
|
|
11
|
+
export * from "./sso";
|
|
12
|
+
export * from "./exceptions";
|
|
13
|
+
export * from "./generateSecrets";
|
|
14
|
+
export * from "./mongoose";
|
|
15
|
+
export * from "./searchClient";
|
|
16
|
+
export * from "./cacheClient";
|
|
17
|
+
export * from "./databaseClient";
|
|
18
|
+
export * from "./decorators";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Logger } from "@akanjs/common";
|
|
2
|
+
import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
|
|
3
|
+
import type { RedisClientType } from "redis";
|
|
4
|
+
import { Observable } from "rxjs";
|
|
5
|
+
export declare class CacheInterceptor implements NestInterceptor {
|
|
6
|
+
#private;
|
|
7
|
+
private readonly redis;
|
|
8
|
+
constructor(redis: RedisClientType<any, any, any>);
|
|
9
|
+
intercept<T>(context: ExecutionContext, next: CallHandler): Promise<Observable<T>>;
|
|
10
|
+
}
|
|
11
|
+
export declare class TimeoutInterceptor implements NestInterceptor {
|
|
12
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
13
|
+
}
|
|
14
|
+
export declare class LoggingInterceptor implements NestInterceptor {
|
|
15
|
+
logger: Logger;
|
|
16
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
17
|
+
}
|
package/src/pipes.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Type } from "@akanjs/base";
|
|
2
|
+
import { ArgMeta } from "@akanjs/signal";
|
|
3
|
+
import { ArgumentMetadata, PipeTransform } from "@nestjs/common";
|
|
4
|
+
import { Readable } from "stream";
|
|
5
|
+
export declare class ArrayifyPipe implements PipeTransform {
|
|
6
|
+
transform(value: string | string[], metadata: ArgumentMetadata): string[];
|
|
7
|
+
}
|
|
8
|
+
export declare class IntPipe implements PipeTransform {
|
|
9
|
+
transform(value: string, metadata: ArgumentMetadata): number[];
|
|
10
|
+
}
|
|
11
|
+
export declare class FloatPipe implements PipeTransform {
|
|
12
|
+
transform(value: string, metadata: ArgumentMetadata): number[];
|
|
13
|
+
}
|
|
14
|
+
export declare class BooleanPipe implements PipeTransform {
|
|
15
|
+
transform(value: string, metadata: ArgumentMetadata): boolean[];
|
|
16
|
+
}
|
|
17
|
+
export declare class DayjsPipe implements PipeTransform {
|
|
18
|
+
transform(value: string, metadata: ArgumentMetadata): import("dayjs").Dayjs[];
|
|
19
|
+
}
|
|
20
|
+
export declare class JSONPipe implements PipeTransform {
|
|
21
|
+
transform(value: string | object, metadata: ArgumentMetadata): object;
|
|
22
|
+
}
|
|
23
|
+
interface FileStream {
|
|
24
|
+
originalname: string;
|
|
25
|
+
mimetype: string;
|
|
26
|
+
encoding: string;
|
|
27
|
+
buffer: Buffer;
|
|
28
|
+
}
|
|
29
|
+
export declare class MulterToUploadPipe implements PipeTransform {
|
|
30
|
+
transform(value: FileStream, metadata: ArgumentMetadata): {
|
|
31
|
+
filename: string;
|
|
32
|
+
mimetype: string;
|
|
33
|
+
encoding: string;
|
|
34
|
+
createReadStream: () => Readable;
|
|
35
|
+
} | {
|
|
36
|
+
filename: string;
|
|
37
|
+
mimetype: string;
|
|
38
|
+
encoding: string;
|
|
39
|
+
createReadStream: () => Readable;
|
|
40
|
+
}[];
|
|
41
|
+
}
|
|
42
|
+
export declare const getQueryPipes: (modelRef: Type, arrDepth: number) => Type[];
|
|
43
|
+
export declare const getBodyPipes: (argMeta: ArgMeta) => {
|
|
44
|
+
new (): {
|
|
45
|
+
transform(value: any, metadata: ArgumentMetadata): object[] | null;
|
|
46
|
+
};
|
|
47
|
+
}[];
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { INestApplicationContext } from "@nestjs/common";
|
|
2
|
+
import { IoAdapter } from "@nestjs/platform-socket.io";
|
|
3
|
+
import { ServerOptions } from "socket.io";
|
|
4
|
+
interface RedisIoAdapterOption extends Partial<ServerOptions> {
|
|
5
|
+
jwtSecret: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class RedisIoAdapter extends IoAdapter {
|
|
8
|
+
private adapterConstructor;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private server;
|
|
11
|
+
private pubClient;
|
|
12
|
+
private subClient;
|
|
13
|
+
option: RedisIoAdapterOption;
|
|
14
|
+
constructor(appOrHttpServer: INestApplicationContext, option: RedisIoAdapterOption);
|
|
15
|
+
connectToRedis(url: string): Promise<void>;
|
|
16
|
+
createIOServer(port: number, options?: ServerOptions): any;
|
|
17
|
+
destroy(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type TextDoc } from "@akanjs/constant";
|
|
2
|
+
import { default as MeiliSearch } from "meilisearch";
|
|
3
|
+
export declare class SearchClient {
|
|
4
|
+
meili: MeiliSearch;
|
|
5
|
+
getIndexNames(): Promise<string[]>;
|
|
6
|
+
getSearchResult(indexName: string, option: {
|
|
7
|
+
skip?: number;
|
|
8
|
+
limit?: number;
|
|
9
|
+
sort?: string;
|
|
10
|
+
searchString?: string;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
docs: Record<string, any>[];
|
|
13
|
+
skip: number;
|
|
14
|
+
limit: number;
|
|
15
|
+
sort: string;
|
|
16
|
+
total: number;
|
|
17
|
+
query?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
docs: import("meilisearch").Hits<Record<string, any>>;
|
|
20
|
+
skip: number;
|
|
21
|
+
limit: number;
|
|
22
|
+
sort: string;
|
|
23
|
+
total: number;
|
|
24
|
+
query: string;
|
|
25
|
+
}>;
|
|
26
|
+
upsertDocuments(indexName: string, documents: TextDoc[]): Promise<import("meilisearch").EnqueuedTask>;
|
|
27
|
+
dropIndex(indexName: string): Promise<import("meilisearch").EnqueuedTask>;
|
|
28
|
+
}
|
package/src/sso.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Type } from "@akanjs/base";
|
|
2
|
+
import type { SSOType } from "@akanjs/signal";
|
|
3
|
+
import * as jwt from "jsonwebtoken";
|
|
4
|
+
export interface SSOCredential {
|
|
5
|
+
clientID: string;
|
|
6
|
+
clientSecret?: string;
|
|
7
|
+
}
|
|
8
|
+
export type AppleCredential = SSOCredential & {
|
|
9
|
+
teamID: string;
|
|
10
|
+
keyID: string;
|
|
11
|
+
keyFilePath: string;
|
|
12
|
+
};
|
|
13
|
+
export type SSOOptions = {
|
|
14
|
+
[key in SSOType]?: SSOCredential | AppleCredential;
|
|
15
|
+
};
|
|
16
|
+
export declare const getSsoProviders: (host: string, ssoOptions: SSOOptions) => Type[];
|
|
17
|
+
export interface KakaoResponse {
|
|
18
|
+
name?: string;
|
|
19
|
+
email: string;
|
|
20
|
+
}
|
|
21
|
+
export interface NaverResponse {
|
|
22
|
+
name?: string;
|
|
23
|
+
email: string;
|
|
24
|
+
}
|
|
25
|
+
export interface GithubResponse {
|
|
26
|
+
id: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
username: string;
|
|
29
|
+
profileUrl: string;
|
|
30
|
+
photos: {
|
|
31
|
+
value: string;
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
34
|
+
export interface GoogleResponse {
|
|
35
|
+
id: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
name: {
|
|
38
|
+
familyName: string;
|
|
39
|
+
givenName: string;
|
|
40
|
+
};
|
|
41
|
+
emails: {
|
|
42
|
+
value: string;
|
|
43
|
+
verified: boolean;
|
|
44
|
+
}[];
|
|
45
|
+
photos: {
|
|
46
|
+
value: string;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
export interface FacebookResponse {
|
|
50
|
+
id: string;
|
|
51
|
+
name: {
|
|
52
|
+
familyName: string;
|
|
53
|
+
givenName: string;
|
|
54
|
+
};
|
|
55
|
+
emails: {
|
|
56
|
+
value: string;
|
|
57
|
+
verified: boolean;
|
|
58
|
+
}[];
|
|
59
|
+
}
|
|
60
|
+
export interface SsoCookie {
|
|
61
|
+
prepareUserId?: string;
|
|
62
|
+
ssoFor: "user" | "admin";
|
|
63
|
+
signinRedirect: string;
|
|
64
|
+
signupRedirect: string;
|
|
65
|
+
adminRedirect?: string;
|
|
66
|
+
errorRedirect?: string;
|
|
67
|
+
}
|
|
68
|
+
export declare const verifyAppleUser: (payload: {
|
|
69
|
+
code: string;
|
|
70
|
+
}, origin: string, sso: AppleCredential) => Promise<{
|
|
71
|
+
tokens: {
|
|
72
|
+
id_token?: string;
|
|
73
|
+
};
|
|
74
|
+
data: string | jwt.JwtPayload | null;
|
|
75
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface VerifyPaymentType {
|
|
2
|
+
packageName: string;
|
|
3
|
+
platform: string;
|
|
4
|
+
productId: string;
|
|
5
|
+
receipt: string;
|
|
6
|
+
secret?: string;
|
|
7
|
+
subscription?: boolean;
|
|
8
|
+
keyObject?: any;
|
|
9
|
+
}
|
|
10
|
+
export declare const verifyPayment: (payment: VerifyPaymentType) => Promise<unknown>;
|
|
11
|
+
export {};
|