@channel.io/app-sdk-server 0.1.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.
- package/dist/__tests__/decorators.test.d.ts +2 -0
- package/dist/__tests__/decorators.test.d.ts.map +1 -0
- package/dist/__tests__/decorators.test.js +259 -0
- package/dist/__tests__/decorators.test.js.map +1 -0
- package/dist/__tests__/testing-utils.test.d.ts +2 -0
- package/dist/__tests__/testing-utils.test.d.ts.map +1 -0
- package/dist/__tests__/testing-utils.test.js +118 -0
- package/dist/__tests__/testing-utils.test.js.map +1 -0
- package/dist/appstore/client.d.ts +70 -0
- package/dist/appstore/client.d.ts.map +1 -0
- package/dist/appstore/client.js +141 -0
- package/dist/appstore/client.js.map +1 -0
- package/dist/appstore/index.d.ts +3 -0
- package/dist/appstore/index.d.ts.map +1 -0
- package/dist/appstore/index.js +3 -0
- package/dist/appstore/index.js.map +1 -0
- package/dist/appstore/types.d.ts +87 -0
- package/dist/appstore/types.d.ts.map +1 -0
- package/dist/appstore/types.js +5 -0
- package/dist/appstore/types.js.map +1 -0
- package/dist/decorators/extension.decorator.d.ts +33 -0
- package/dist/decorators/extension.decorator.d.ts.map +1 -0
- package/dist/decorators/extension.decorator.js +36 -0
- package/dist/decorators/extension.decorator.js.map +1 -0
- package/dist/decorators/function.decorator.d.ts +34 -0
- package/dist/decorators/function.decorator.d.ts.map +1 -0
- package/dist/decorators/function.decorator.js +45 -0
- package/dist/decorators/function.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +5 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +9 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/param.decorator.d.ts +49 -0
- package/dist/decorators/param.decorator.d.ts.map +1 -0
- package/dist/decorators/param.decorator.js +62 -0
- package/dist/decorators/param.decorator.js.map +1 -0
- package/dist/decorators/schema.decorator.d.ts +48 -0
- package/dist/decorators/schema.decorator.d.ts.map +1 -0
- package/dist/decorators/schema.decorator.js +59 -0
- package/dist/decorators/schema.decorator.js.map +1 -0
- package/dist/discovery/extension-discovery.service.d.ts +45 -0
- package/dist/discovery/extension-discovery.service.d.ts.map +1 -0
- package/dist/discovery/extension-discovery.service.js +192 -0
- package/dist/discovery/extension-discovery.service.js.map +1 -0
- package/dist/discovery/index.d.ts +3 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +2 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/metadata.interface.d.ts +42 -0
- package/dist/discovery/metadata.interface.d.ts.map +1 -0
- package/dist/discovery/metadata.interface.js +2 -0
- package/dist/discovery/metadata.interface.js.map +1 -0
- package/dist/guards/index.d.ts +3 -0
- package/dist/guards/index.d.ts.map +1 -0
- package/dist/guards/index.js +3 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/guards/signature.guard.d.ts +65 -0
- package/dist/guards/signature.guard.d.ts.map +1 -0
- package/dist/guards/signature.guard.js +156 -0
- package/dist/guards/signature.guard.js.map +1 -0
- package/dist/guards/signature.middleware.d.ts +76 -0
- package/dist/guards/signature.middleware.d.ts.map +1 -0
- package/dist/guards/signature.middleware.js +110 -0
- package/dist/guards/signature.middleware.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/native/client.d.ts +105 -0
- package/dist/native/client.d.ts.map +1 -0
- package/dist/native/client.js +210 -0
- package/dist/native/client.js.map +1 -0
- package/dist/native/index.d.ts +3 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +3 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native/types.d.ts +198 -0
- package/dist/native/types.d.ts.map +1 -0
- package/dist/native/types.js +8 -0
- package/dist/native/types.js.map +1 -0
- package/dist/nestjs/channel-app.controller.d.ts +22 -0
- package/dist/nestjs/channel-app.controller.d.ts.map +1 -0
- package/dist/nestjs/channel-app.controller.js +87 -0
- package/dist/nestjs/channel-app.controller.js.map +1 -0
- package/dist/nestjs/channel-app.module.d.ts +47 -0
- package/dist/nestjs/channel-app.module.d.ts.map +1 -0
- package/dist/nestjs/channel-app.module.js +93 -0
- package/dist/nestjs/channel-app.module.js.map +1 -0
- package/dist/nestjs/channel-app.service.d.ts +44 -0
- package/dist/nestjs/channel-app.service.d.ts.map +1 -0
- package/dist/nestjs/channel-app.service.js +190 -0
- package/dist/nestjs/channel-app.service.js.map +1 -0
- package/dist/nestjs/index.d.ts +5 -0
- package/dist/nestjs/index.d.ts.map +1 -0
- package/dist/nestjs/index.js +5 -0
- package/dist/nestjs/index.js.map +1 -0
- package/dist/nestjs/types.d.ts +70 -0
- package/dist/nestjs/types.d.ts.map +1 -0
- package/dist/nestjs/types.js +5 -0
- package/dist/nestjs/types.js.map +1 -0
- package/dist/simple/channel-app.d.ts +80 -0
- package/dist/simple/channel-app.d.ts.map +1 -0
- package/dist/simple/channel-app.js +253 -0
- package/dist/simple/channel-app.js.map +1 -0
- package/dist/simple/index.d.ts +2 -0
- package/dist/simple/index.d.ts.map +1 -0
- package/dist/simple/index.js +2 -0
- package/dist/simple/index.js.map +1 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-context.d.ts +32 -0
- package/dist/testing/mock-context.d.ts.map +1 -0
- package/dist/testing/mock-context.js +33 -0
- package/dist/testing/mock-context.js.map +1 -0
- package/dist/testing/test-extension.d.ts +60 -0
- package/dist/testing/test-extension.d.ts.map +1 -0
- package/dist/testing/test-extension.js +113 -0
- package/dist/testing/test-extension.js.map +1 -0
- package/dist/token/cache.d.ts +31 -0
- package/dist/token/cache.d.ts.map +1 -0
- package/dist/token/cache.js +69 -0
- package/dist/token/cache.js.map +1 -0
- package/dist/token/index.d.ts +4 -0
- package/dist/token/index.d.ts.map +1 -0
- package/dist/token/index.js +4 -0
- package/dist/token/index.js.map +1 -0
- package/dist/token/manager.d.ts +111 -0
- package/dist/token/manager.d.ts.map +1 -0
- package/dist/token/manager.js +246 -0
- package/dist/token/manager.js.map +1 -0
- package/dist/token/types.d.ts +85 -0
- package/dist/token/types.d.ts.map +1 -0
- package/dist/token/types.js +5 -0
- package/dist/token/types.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AppStore client types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* AppStore client configuration
|
|
6
|
+
*/
|
|
7
|
+
export interface AppStoreClientConfig {
|
|
8
|
+
/** App ID */
|
|
9
|
+
appId: string;
|
|
10
|
+
/** App secret */
|
|
11
|
+
appSecret: string;
|
|
12
|
+
/** AppStore API base URL (default: https://app-store.channel.io) */
|
|
13
|
+
appStoreUrl?: string | undefined;
|
|
14
|
+
/** Enable debug logging */
|
|
15
|
+
debug?: boolean | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* JSON-RPC request format
|
|
19
|
+
*/
|
|
20
|
+
export interface JsonRpcRequest<T = unknown> {
|
|
21
|
+
jsonrpc: "2.0";
|
|
22
|
+
method: string;
|
|
23
|
+
params: T;
|
|
24
|
+
id?: string | number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* JSON-RPC response format
|
|
28
|
+
*/
|
|
29
|
+
export interface JsonRpcResponse<T = unknown> {
|
|
30
|
+
jsonrpc: "2.0";
|
|
31
|
+
result?: T;
|
|
32
|
+
error?: JsonRpcError;
|
|
33
|
+
id?: string | number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* JSON-RPC error format
|
|
37
|
+
*/
|
|
38
|
+
export interface JsonRpcError {
|
|
39
|
+
code: number;
|
|
40
|
+
message: string;
|
|
41
|
+
data?: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* RegisterExtension request params
|
|
45
|
+
*/
|
|
46
|
+
export interface RegisterExtensionParams {
|
|
47
|
+
app_id: string;
|
|
48
|
+
system_version: string;
|
|
49
|
+
extension_name: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Extension implementation returned from AppStore
|
|
53
|
+
*/
|
|
54
|
+
export interface ExtensionImpl {
|
|
55
|
+
id: string;
|
|
56
|
+
appId: string;
|
|
57
|
+
extensionName: string;
|
|
58
|
+
systemVersion: string;
|
|
59
|
+
exclusive: boolean;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* RegisterExtension response result
|
|
65
|
+
*/
|
|
66
|
+
export interface RegisterExtensionResult {
|
|
67
|
+
success: boolean;
|
|
68
|
+
error_message?: string;
|
|
69
|
+
extensions?: ExtensionImpl[];
|
|
70
|
+
validation_errors?: string[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* UnregisterExtension request params
|
|
74
|
+
*/
|
|
75
|
+
export interface UnregisterExtensionParams {
|
|
76
|
+
app_id: string;
|
|
77
|
+
system_version: string;
|
|
78
|
+
extension_name: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* UnregisterExtension response result
|
|
82
|
+
*/
|
|
83
|
+
export interface UnregisterExtensionResult {
|
|
84
|
+
success: boolean;
|
|
85
|
+
error_message?: string;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/appstore/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,CAAC;IACV,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/appstore/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const EXTENSION_METADATA: unique symbol;
|
|
2
|
+
export interface ExtensionOptions {
|
|
3
|
+
/** Extension name (e.g., "calendar", "oauth") */
|
|
4
|
+
name: string;
|
|
5
|
+
/** System version (default: "v1") */
|
|
6
|
+
systemVersion?: string;
|
|
7
|
+
/** Whether this is an exclusive extension */
|
|
8
|
+
exclusive?: boolean;
|
|
9
|
+
/** Description of the extension */
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Marks a class as a Channel.io App Extension
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* @Extension("calendar")
|
|
18
|
+
* export class CalendarExtension {
|
|
19
|
+
* @Function("getAvailability")
|
|
20
|
+
* async getAvailability(@Ctx() ctx, @Input() params) {
|
|
21
|
+
* return { slots: [] };
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example with options
|
|
27
|
+
* ```typescript
|
|
28
|
+
* @Extension({ name: "calendar", systemVersion: "v1", exclusive: true })
|
|
29
|
+
* export class CalendarExtension { ... }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function Extension(nameOrOptions: string | ExtensionOptions): ClassDecorator;
|
|
33
|
+
//# sourceMappingURL=extension.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/extension.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,gBAAgB,GAAG,cAAc,CAelF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Injectable, SetMetadata } from "@nestjs/common";
|
|
2
|
+
export const EXTENSION_METADATA = Symbol("EXTENSION_METADATA");
|
|
3
|
+
/**
|
|
4
|
+
* Marks a class as a Channel.io App Extension
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* @Extension("calendar")
|
|
9
|
+
* export class CalendarExtension {
|
|
10
|
+
* @Function("getAvailability")
|
|
11
|
+
* async getAvailability(@Ctx() ctx, @Input() params) {
|
|
12
|
+
* return { slots: [] };
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example with options
|
|
18
|
+
* ```typescript
|
|
19
|
+
* @Extension({ name: "calendar", systemVersion: "v1", exclusive: true })
|
|
20
|
+
* export class CalendarExtension { ... }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function Extension(nameOrOptions) {
|
|
24
|
+
const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions;
|
|
25
|
+
return (target) => {
|
|
26
|
+
SetMetadata(EXTENSION_METADATA, {
|
|
27
|
+
name: options.name,
|
|
28
|
+
systemVersion: options.systemVersion ?? "v1",
|
|
29
|
+
exclusive: options.exclusive ?? false,
|
|
30
|
+
description: options.description,
|
|
31
|
+
})(target);
|
|
32
|
+
// Apply @Injectable() decorator automatically
|
|
33
|
+
Injectable()(target);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=extension.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.decorator.js","sourceRoot":"","sources":["../../src/decorators/extension.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAa/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,SAAS,CAAC,aAAwC;IAChE,MAAM,OAAO,GACX,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;IAE9E,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,WAAW,CAAC,kBAAkB,EAAE;YAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI;YAC5C,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK;YACrC,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC,CAAC,MAAM,CAAC,CAAC;QAEX,8CAA8C;QAC9C,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const FUNCTION_METADATA: unique symbol;
|
|
3
|
+
export declare const FUNCTIONS_METADATA: unique symbol;
|
|
4
|
+
export interface FunctionOptions {
|
|
5
|
+
/** Function name (e.g., "getAvailability" or "calendar.getAvailability") */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** Function description for documentation */
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FunctionMetadataValue {
|
|
11
|
+
name: string;
|
|
12
|
+
methodName: string | symbol;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Marks a method as an extension function
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* @Extension("calendar")
|
|
21
|
+
* export class CalendarExtension {
|
|
22
|
+
* @Func() // Uses method name: "getAvailability"
|
|
23
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
24
|
+
*
|
|
25
|
+
* @Func("booking.create") // Custom name
|
|
26
|
+
* async createBooking(@Ctx() ctx, @Input() params) { ... }
|
|
27
|
+
*
|
|
28
|
+
* @Func({ name: "booking.cancel", description: "Cancel a booking" })
|
|
29
|
+
* async cancelBooking(@Ctx() ctx, @Input() params) { ... }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function Func(nameOrOptions?: string | FunctionOptions): MethodDecorator;
|
|
34
|
+
//# sourceMappingURL=function.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/function.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAC7D,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,CA8B9E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export const FUNCTION_METADATA = Symbol("FUNCTION_METADATA");
|
|
3
|
+
export const FUNCTIONS_METADATA = Symbol("FUNCTIONS_METADATA");
|
|
4
|
+
/**
|
|
5
|
+
* Marks a method as an extension function
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Extension("calendar")
|
|
10
|
+
* export class CalendarExtension {
|
|
11
|
+
* @Func() // Uses method name: "getAvailability"
|
|
12
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
13
|
+
*
|
|
14
|
+
* @Func("booking.create") // Custom name
|
|
15
|
+
* async createBooking(@Ctx() ctx, @Input() params) { ... }
|
|
16
|
+
*
|
|
17
|
+
* @Func({ name: "booking.cancel", description: "Cancel a booking" })
|
|
18
|
+
* async cancelBooking(@Ctx() ctx, @Input() params) { ... }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function Func(nameOrOptions) {
|
|
23
|
+
return (target, propertyKey, descriptor) => {
|
|
24
|
+
const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : (nameOrOptions ?? {});
|
|
25
|
+
// Use method name if no explicit name is provided
|
|
26
|
+
const functionName = options.name ?? String(propertyKey);
|
|
27
|
+
const metadata = {
|
|
28
|
+
name: functionName,
|
|
29
|
+
methodName: propertyKey,
|
|
30
|
+
};
|
|
31
|
+
if (options.description) {
|
|
32
|
+
metadata.description = options.description;
|
|
33
|
+
}
|
|
34
|
+
// Store metadata on the method
|
|
35
|
+
Reflect.defineMetadata(FUNCTION_METADATA, metadata, target.constructor, propertyKey);
|
|
36
|
+
// Also maintain a list of all functions on the class
|
|
37
|
+
const existingFunctions = Reflect.getMetadata(FUNCTIONS_METADATA, target.constructor) ?? [];
|
|
38
|
+
if (!existingFunctions.includes(propertyKey)) {
|
|
39
|
+
existingFunctions.push(propertyKey);
|
|
40
|
+
}
|
|
41
|
+
Reflect.defineMetadata(FUNCTIONS_METADATA, existingFunctions, target.constructor);
|
|
42
|
+
return descriptor;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=function.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.decorator.js","sourceRoot":"","sources":["../../src/decorators/function.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAe/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAC,aAAwC;IAC3D,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;QACzC,MAAM,OAAO,GACX,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;QAEtF,kDAAkD;QAClD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;QAEzD,MAAM,QAAQ,GAA0B;YACtC,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,WAAW;SACxB,CAAC;QAEF,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,QAAQ,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QAC7C,CAAC;QAED,+BAA+B;QAC/B,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAErF,qDAAqD;QACrD,MAAM,iBAAiB,GACrB,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACpE,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7C,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAElF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Extension, EXTENSION_METADATA, type ExtensionOptions } from "./extension.decorator.js";
|
|
2
|
+
export { Func, FUNCTION_METADATA, FUNCTIONS_METADATA, type FunctionOptions, type FunctionMetadataValue, } from "./function.decorator.js";
|
|
3
|
+
export { Ctx, Input, Body, PARAM_METADATA, FunctionParamType, type FunctionParamMetadata, } from "./param.decorator.js";
|
|
4
|
+
export { InputSchema, OutputSchema, Description, INPUT_SCHEMA_METADATA, OUTPUT_SCHEMA_METADATA, DESCRIPTION_METADATA, } from "./schema.decorator.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGhG,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,cAAc,EACd,iBAAiB,EACjB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Extension decorator
|
|
2
|
+
export { Extension, EXTENSION_METADATA } from "./extension.decorator.js";
|
|
3
|
+
// Function decorator
|
|
4
|
+
export { Func, FUNCTION_METADATA, FUNCTIONS_METADATA, } from "./function.decorator.js";
|
|
5
|
+
// Parameter decorators
|
|
6
|
+
export { Ctx, Input, Body, PARAM_METADATA, FunctionParamType, } from "./param.decorator.js";
|
|
7
|
+
// Schema decorators
|
|
8
|
+
export { InputSchema, OutputSchema, Description, INPUT_SCHEMA_METADATA, OUTPUT_SCHEMA_METADATA, DESCRIPTION_METADATA, } from "./schema.decorator.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAyB,MAAM,0BAA0B,CAAC;AAEhG,qBAAqB;AACrB,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,kBAAkB,GAGnB,MAAM,yBAAyB,CAAC;AAEjC,uBAAuB;AACvB,OAAO,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,cAAc,EACd,iBAAiB,GAElB,MAAM,sBAAsB,CAAC;AAE9B,oBAAoB;AACpB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const PARAM_METADATA: unique symbol;
|
|
3
|
+
export declare enum FunctionParamType {
|
|
4
|
+
CTX = "ctx",
|
|
5
|
+
INPUT = "input",
|
|
6
|
+
BODY = "body"
|
|
7
|
+
}
|
|
8
|
+
export interface FunctionParamMetadata {
|
|
9
|
+
index: number;
|
|
10
|
+
type: FunctionParamType;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Inject function context into the parameter
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* @Function("getAvailability")
|
|
18
|
+
* async getAvailability(@Ctx() ctx: Context) {
|
|
19
|
+
* console.log(ctx.channel.id);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const Ctx: () => ParameterDecorator;
|
|
24
|
+
/**
|
|
25
|
+
* Inject validated input parameters
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* @Function("createBooking")
|
|
30
|
+
* @InputSchema(CreateBookingInput)
|
|
31
|
+
* async createBooking(@Ctx() ctx: Context, @Input() params: CreateBookingParams) {
|
|
32
|
+
* console.log(params.date);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const Input: () => ParameterDecorator;
|
|
37
|
+
/**
|
|
38
|
+
* Inject raw request body
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* @Function("handleRaw")
|
|
43
|
+
* async handleRaw(@Body() body: FunctionCallRequest) {
|
|
44
|
+
* console.log(body.method);
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const Body: () => ParameterDecorator;
|
|
49
|
+
//# sourceMappingURL=param.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"param.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/param.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,eAAO,MAAM,cAAc,eAA2B,CAAC;AAEvD,oBAAY,iBAAiB;IAC3B,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAuBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,QAAO,kBAAiE,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,QAAO,kBAAmE,CAAC;AAE7F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,QAAO,kBAAkE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export const PARAM_METADATA = Symbol("PARAM_METADATA");
|
|
3
|
+
export var FunctionParamType;
|
|
4
|
+
(function (FunctionParamType) {
|
|
5
|
+
FunctionParamType["CTX"] = "ctx";
|
|
6
|
+
FunctionParamType["INPUT"] = "input";
|
|
7
|
+
FunctionParamType["BODY"] = "body";
|
|
8
|
+
})(FunctionParamType || (FunctionParamType = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Create a parameter decorator for extension functions
|
|
11
|
+
*/
|
|
12
|
+
function createParamDecorator(type) {
|
|
13
|
+
return (target, propertyKey, parameterIndex) => {
|
|
14
|
+
if (propertyKey === undefined) {
|
|
15
|
+
throw new Error("Parameter decorators can only be used on method parameters");
|
|
16
|
+
}
|
|
17
|
+
const existingParams = Reflect.getMetadata(PARAM_METADATA, target.constructor, propertyKey) ?? [];
|
|
18
|
+
existingParams.push({
|
|
19
|
+
index: parameterIndex,
|
|
20
|
+
type,
|
|
21
|
+
});
|
|
22
|
+
Reflect.defineMetadata(PARAM_METADATA, existingParams, target.constructor, propertyKey);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Inject function context into the parameter
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* @Function("getAvailability")
|
|
31
|
+
* async getAvailability(@Ctx() ctx: Context) {
|
|
32
|
+
* console.log(ctx.channel.id);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export const Ctx = () => createParamDecorator(FunctionParamType.CTX);
|
|
37
|
+
/**
|
|
38
|
+
* Inject validated input parameters
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* @Function("createBooking")
|
|
43
|
+
* @InputSchema(CreateBookingInput)
|
|
44
|
+
* async createBooking(@Ctx() ctx: Context, @Input() params: CreateBookingParams) {
|
|
45
|
+
* console.log(params.date);
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export const Input = () => createParamDecorator(FunctionParamType.INPUT);
|
|
50
|
+
/**
|
|
51
|
+
* Inject raw request body
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* @Function("handleRaw")
|
|
56
|
+
* async handleRaw(@Body() body: FunctionCallRequest) {
|
|
57
|
+
* console.log(body.method);
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export const Body = () => createParamDecorator(FunctionParamType.BODY);
|
|
62
|
+
//# sourceMappingURL=param.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"param.decorator.js","sourceRoot":"","sources":["../../src/decorators/param.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,gCAAW,CAAA;IACX,oCAAe,CAAA;IACf,kCAAa,CAAA;AACf,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B;AAOD;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAuB;IACnD,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;QAC7C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QAED,MAAM,cAAc,GAClB,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAE7E,cAAc,CAAC,IAAI,CAAC;YAClB,KAAK,EAAE,cAAc;YACrB,IAAI;SACL,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC1F,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,GAAuB,EAAE,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,GAAuB,EAAE,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAE7F;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAuB,EAAE,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export declare const INPUT_SCHEMA_METADATA: unique symbol;
|
|
4
|
+
export declare const OUTPUT_SCHEMA_METADATA: unique symbol;
|
|
5
|
+
export declare const DESCRIPTION_METADATA: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Define input schema for a function using Zod
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const GetAvailabilityInput = z.object({
|
|
12
|
+
* startDate: z.string(),
|
|
13
|
+
* endDate: z.string(),
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* @Function("getAvailability")
|
|
17
|
+
* @InputSchema(GetAvailabilityInput)
|
|
18
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function InputSchema(schema: z.ZodSchema): MethodDecorator;
|
|
22
|
+
/**
|
|
23
|
+
* Define output schema for a function using Zod
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const GetAvailabilityOutput = z.object({
|
|
28
|
+
* slots: z.array(TimeSlotSchema),
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* @Function("getAvailability")
|
|
32
|
+
* @OutputSchema(GetAvailabilityOutput)
|
|
33
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function OutputSchema(schema: z.ZodSchema): MethodDecorator;
|
|
37
|
+
/**
|
|
38
|
+
* Add description to a function
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* @Function("getAvailability")
|
|
43
|
+
* @Description("Get available time slots for booking")
|
|
44
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function Description(text: string): MethodDecorator;
|
|
48
|
+
//# sourceMappingURL=schema.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/schema.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AACrE,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AACvE,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,eAAe,CAIhE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,eAAe,CAIjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAIzD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export const INPUT_SCHEMA_METADATA = Symbol("INPUT_SCHEMA_METADATA");
|
|
3
|
+
export const OUTPUT_SCHEMA_METADATA = Symbol("OUTPUT_SCHEMA_METADATA");
|
|
4
|
+
export const DESCRIPTION_METADATA = Symbol("DESCRIPTION_METADATA");
|
|
5
|
+
/**
|
|
6
|
+
* Define input schema for a function using Zod
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const GetAvailabilityInput = z.object({
|
|
11
|
+
* startDate: z.string(),
|
|
12
|
+
* endDate: z.string(),
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* @Function("getAvailability")
|
|
16
|
+
* @InputSchema(GetAvailabilityInput)
|
|
17
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function InputSchema(schema) {
|
|
21
|
+
return (target, propertyKey) => {
|
|
22
|
+
Reflect.defineMetadata(INPUT_SCHEMA_METADATA, schema, target.constructor, propertyKey);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Define output schema for a function using Zod
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const GetAvailabilityOutput = z.object({
|
|
31
|
+
* slots: z.array(TimeSlotSchema),
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* @Function("getAvailability")
|
|
35
|
+
* @OutputSchema(GetAvailabilityOutput)
|
|
36
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function OutputSchema(schema) {
|
|
40
|
+
return (target, propertyKey) => {
|
|
41
|
+
Reflect.defineMetadata(OUTPUT_SCHEMA_METADATA, schema, target.constructor, propertyKey);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Add description to a function
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* @Function("getAvailability")
|
|
50
|
+
* @Description("Get available time slots for booking")
|
|
51
|
+
* async getAvailability(@Ctx() ctx, @Input() params) { ... }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function Description(text) {
|
|
55
|
+
return (target, propertyKey) => {
|
|
56
|
+
Reflect.defineMetadata(DESCRIPTION_METADATA, text, target.constructor, propertyKey);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=schema.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.decorator.js","sourceRoot":"","sources":["../../src/decorators/schema.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,OAAO,CAAC,cAAc,CAAC,qBAAqB,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzF,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,MAAmB;IAC9C,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC1F,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { DiscoveryService, Reflector } from "@nestjs/core";
|
|
3
|
+
import type { ExtensionMetadata, FunctionMetadata } from "./metadata.interface.js";
|
|
4
|
+
export declare class ExtensionDiscoveryService implements OnModuleInit {
|
|
5
|
+
private readonly discoveryService;
|
|
6
|
+
private readonly reflector;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private readonly extensions;
|
|
9
|
+
private readonly functionRegistry;
|
|
10
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
11
|
+
onModuleInit(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Discover all @Extension decorated classes
|
|
14
|
+
*/
|
|
15
|
+
private discoverExtensions;
|
|
16
|
+
/**
|
|
17
|
+
* Discover @Function decorated methods on an extension class
|
|
18
|
+
*/
|
|
19
|
+
private discoverFunctions;
|
|
20
|
+
/**
|
|
21
|
+
* Create a handler function with parameter injection and validation
|
|
22
|
+
*/
|
|
23
|
+
private createHandler;
|
|
24
|
+
/**
|
|
25
|
+
* Get all discovered extensions
|
|
26
|
+
*/
|
|
27
|
+
getExtensions(): ExtensionMetadata[];
|
|
28
|
+
/**
|
|
29
|
+
* Get a specific extension by name
|
|
30
|
+
*/
|
|
31
|
+
getExtension(name: string): ExtensionMetadata | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Get a function by its full name (e.g., "extension.calendar.getAvailability")
|
|
34
|
+
*/
|
|
35
|
+
getFunction(fullName: string): FunctionMetadata | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Get all registered functions
|
|
38
|
+
*/
|
|
39
|
+
getAllFunctions(): FunctionMetadata[];
|
|
40
|
+
/**
|
|
41
|
+
* Check if any extensions are registered
|
|
42
|
+
*/
|
|
43
|
+
hasExtensions(): boolean;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=extension-discovery.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-discovery.service.d.ts","sourceRoot":"","sources":["../../src/discovery/extension-discovery.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,YAAY,EAAqB,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAe3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEnF,qBACa,yBAA0B,YAAW,YAAY;IAM1D,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAN5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;IACrE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwC;IACnE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuC;gBAGrD,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS;IAGvC,YAAY;IAIZ;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmC1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAsFzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAyDrB;;OAEG;IACH,aAAa,IAAI,iBAAiB,EAAE;IAIpC;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAIzD;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI3D;;OAEG;IACH,eAAe,IAAI,gBAAgB,EAAE;IAIrC;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB"}
|