@channel.io/app-sdk-core 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/errors/index.d.ts +35 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +55 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/extensions/alftask.d.ts +257 -0
- package/dist/extensions/alftask.d.ts.map +1 -0
- package/dist/extensions/alftask.js +55 -0
- package/dist/extensions/alftask.js.map +1 -0
- package/dist/extensions/apikey.d.ts +160 -0
- package/dist/extensions/apikey.d.ts.map +1 -0
- package/dist/extensions/apikey.js +41 -0
- package/dist/extensions/apikey.js.map +1 -0
- package/dist/extensions/calendar.d.ts +139 -0
- package/dist/extensions/calendar.d.ts.map +1 -0
- package/dist/extensions/calendar.js +55 -0
- package/dist/extensions/calendar.js.map +1 -0
- package/dist/extensions/command.d.ts +50 -0
- package/dist/extensions/command.d.ts.map +1 -0
- package/dist/extensions/command.js +31 -0
- package/dist/extensions/command.js.map +1 -0
- package/dist/extensions/customtab.d.ts +69 -0
- package/dist/extensions/customtab.d.ts.map +1 -0
- package/dist/extensions/customtab.js +38 -0
- package/dist/extensions/customtab.js.map +1 -0
- package/dist/extensions/index.d.ts +9 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +17 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/interfaces/alftask.d.ts +58 -0
- package/dist/extensions/interfaces/alftask.d.ts.map +1 -0
- package/dist/extensions/interfaces/alftask.js +7 -0
- package/dist/extensions/interfaces/alftask.js.map +1 -0
- package/dist/extensions/interfaces/apikey.d.ts +66 -0
- package/dist/extensions/interfaces/apikey.d.ts.map +1 -0
- package/dist/extensions/interfaces/apikey.js +8 -0
- package/dist/extensions/interfaces/apikey.js.map +1 -0
- package/dist/extensions/interfaces/calendar.d.ts +153 -0
- package/dist/extensions/interfaces/calendar.d.ts.map +1 -0
- package/dist/extensions/interfaces/calendar.js +12 -0
- package/dist/extensions/interfaces/calendar.js.map +1 -0
- package/dist/extensions/interfaces/command.d.ts +92 -0
- package/dist/extensions/interfaces/command.d.ts.map +1 -0
- package/dist/extensions/interfaces/command.js +8 -0
- package/dist/extensions/interfaces/command.js.map +1 -0
- package/dist/extensions/interfaces/customtab.d.ts +82 -0
- package/dist/extensions/interfaces/customtab.d.ts.map +1 -0
- package/dist/extensions/interfaces/customtab.js +8 -0
- package/dist/extensions/interfaces/customtab.js.map +1 -0
- package/dist/extensions/interfaces/index.d.ts +25 -0
- package/dist/extensions/interfaces/index.d.ts.map +1 -0
- package/dist/extensions/interfaces/index.js +25 -0
- package/dist/extensions/interfaces/index.js.map +1 -0
- package/dist/extensions/interfaces/oauth.d.ts +78 -0
- package/dist/extensions/interfaces/oauth.d.ts.map +1 -0
- package/dist/extensions/interfaces/oauth.js +8 -0
- package/dist/extensions/interfaces/oauth.js.map +1 -0
- package/dist/extensions/interfaces/widget.d.ts +87 -0
- package/dist/extensions/interfaces/widget.d.ts.map +1 -0
- package/dist/extensions/interfaces/widget.js +8 -0
- package/dist/extensions/interfaces/widget.js.map +1 -0
- package/dist/extensions/oauth.d.ts +45 -0
- package/dist/extensions/oauth.d.ts.map +1 -0
- package/dist/extensions/oauth.js +21 -0
- package/dist/extensions/oauth.js.map +1 -0
- package/dist/extensions/widget.d.ts +90 -0
- package/dist/extensions/widget.d.ts.map +1 -0
- package/dist/extensions/widget.js +42 -0
- package/dist/extensions/widget.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/extension.d.ts +15 -0
- package/dist/schemas/extension.d.ts.map +1 -0
- package/dist/schemas/extension.js +39 -0
- package/dist/schemas/extension.js.map +1 -0
- package/dist/schemas/function.d.ts +7 -0
- package/dist/schemas/function.d.ts.map +1 -0
- package/dist/schemas/function.js +31 -0
- package/dist/schemas/function.js.map +1 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +3 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/types/context.d.ts +55 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/extension.d.ts +53 -0
- package/dist/types/extension.d.ts.map +1 -0
- package/dist/types/extension.js +2 -0
- package/dist/types/extension.js.map +1 -0
- package/dist/types/function.d.ts +58 -0
- package/dist/types/function.d.ts.map +1 -0
- package/dist/types/function.js +2 -0
- package/dist/types/function.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/zod-to-json-schema.d.ts +6 -0
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema.js +10 -0
- package/dist/utils/zod-to-json-schema.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* OAuth 2.0 configuration schema
|
|
4
|
+
*/
|
|
5
|
+
export declare const OAuthConfigSchema: z.ZodObject<{
|
|
6
|
+
authorizationUrl: z.ZodString;
|
|
7
|
+
tokenUrl: z.ZodString;
|
|
8
|
+
scopes: z.ZodArray<z.ZodString, "many">;
|
|
9
|
+
clientId: z.ZodString;
|
|
10
|
+
pkceRequired: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
additionalParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
authorizationUrl: string;
|
|
14
|
+
tokenUrl: string;
|
|
15
|
+
scopes: string[];
|
|
16
|
+
clientId: string;
|
|
17
|
+
pkceRequired?: boolean | undefined;
|
|
18
|
+
additionalParams?: Record<string, string> | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
authorizationUrl: string;
|
|
21
|
+
tokenUrl: string;
|
|
22
|
+
scopes: string[];
|
|
23
|
+
clientId: string;
|
|
24
|
+
pkceRequired?: boolean | undefined;
|
|
25
|
+
additionalParams?: Record<string, string> | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export type OAuthConfig = z.infer<typeof OAuthConfigSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Credential validation result schema
|
|
30
|
+
*/
|
|
31
|
+
export declare const CredentialValidationResultSchema: z.ZodObject<{
|
|
32
|
+
valid: z.ZodBoolean;
|
|
33
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
34
|
+
error: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
valid: boolean;
|
|
37
|
+
expiresAt?: string | undefined;
|
|
38
|
+
error?: string | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
valid: boolean;
|
|
41
|
+
expiresAt?: string | undefined;
|
|
42
|
+
error?: string | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
export type CredentialValidationResult = z.infer<typeof CredentialValidationResultSchema>;
|
|
45
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/extensions/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;EAI3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* OAuth 2.0 configuration schema
|
|
4
|
+
*/
|
|
5
|
+
export const OAuthConfigSchema = z.object({
|
|
6
|
+
authorizationUrl: z.string().url(),
|
|
7
|
+
tokenUrl: z.string().url(),
|
|
8
|
+
scopes: z.array(z.string()),
|
|
9
|
+
clientId: z.string(),
|
|
10
|
+
pkceRequired: z.boolean().optional(),
|
|
11
|
+
additionalParams: z.record(z.string()).optional(),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Credential validation result schema
|
|
15
|
+
*/
|
|
16
|
+
export const CredentialValidationResultSchema = z.object({
|
|
17
|
+
valid: z.boolean(),
|
|
18
|
+
expiresAt: z.string().optional(),
|
|
19
|
+
error: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/extensions/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC1B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAClD,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE;IAClB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Widget scope - where the widget is displayed
|
|
4
|
+
*/
|
|
5
|
+
export declare const WidgetScope: z.ZodEnum<["front", "desk"]>;
|
|
6
|
+
export type WidgetScope = z.infer<typeof WidgetScope>;
|
|
7
|
+
/**
|
|
8
|
+
* Widget type - how the widget behaves
|
|
9
|
+
*/
|
|
10
|
+
export declare const WidgetType: z.ZodEnum<["wam", "snippet"]>;
|
|
11
|
+
export type WidgetType = z.infer<typeof WidgetType>;
|
|
12
|
+
/**
|
|
13
|
+
* I18n name/description pair
|
|
14
|
+
*/
|
|
15
|
+
export declare const NameDescI18nSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type NameDescI18n = z.infer<typeof NameDescI18nSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Widget configuration schema
|
|
28
|
+
*/
|
|
29
|
+
export declare const WidgetConfigSchema: z.ZodObject<{
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
description: z.ZodOptional<z.ZodString>;
|
|
32
|
+
scope: z.ZodEnum<["front", "desk"]>;
|
|
33
|
+
widgetType: z.ZodDefault<z.ZodEnum<["wam", "snippet"]>>;
|
|
34
|
+
/**
|
|
35
|
+
* i18n name/description map keyed by language code (e.g., "ko", "en", "ja")
|
|
36
|
+
*/
|
|
37
|
+
nameDescI18nMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
name: string;
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
}>>>;
|
|
47
|
+
/**
|
|
48
|
+
* For snippet type: external URL to load
|
|
49
|
+
*/
|
|
50
|
+
snippetApiUrl: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
name: string;
|
|
53
|
+
scope: "front" | "desk";
|
|
54
|
+
widgetType: "wam" | "snippet";
|
|
55
|
+
description?: string | undefined;
|
|
56
|
+
nameDescI18nMap?: Record<string, {
|
|
57
|
+
name: string;
|
|
58
|
+
description?: string | undefined;
|
|
59
|
+
}> | undefined;
|
|
60
|
+
snippetApiUrl?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
name: string;
|
|
63
|
+
scope: "front" | "desk";
|
|
64
|
+
description?: string | undefined;
|
|
65
|
+
widgetType?: "wam" | "snippet" | undefined;
|
|
66
|
+
nameDescI18nMap?: Record<string, {
|
|
67
|
+
name: string;
|
|
68
|
+
description?: string | undefined;
|
|
69
|
+
}> | undefined;
|
|
70
|
+
snippetApiUrl?: string | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
export type WidgetConfig = z.infer<typeof WidgetConfigSchema>;
|
|
73
|
+
/**
|
|
74
|
+
* Widget action result schema
|
|
75
|
+
*/
|
|
76
|
+
export declare const WidgetActionResultSchema: z.ZodObject<{
|
|
77
|
+
success: z.ZodBoolean;
|
|
78
|
+
message: z.ZodOptional<z.ZodString>;
|
|
79
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
success: boolean;
|
|
82
|
+
message?: string | undefined;
|
|
83
|
+
data?: Record<string, unknown> | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
success: boolean;
|
|
86
|
+
message?: string | undefined;
|
|
87
|
+
data?: Record<string, unknown> | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
export type WidgetActionResult = z.infer<typeof WidgetActionResultSchema>;
|
|
90
|
+
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/extensions/widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,WAAW,8BAA4B,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,UAAU,+BAA6B,CAAC;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;IAK7B;;OAEG;;;;;;;;;;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Widget scope - where the widget is displayed
|
|
4
|
+
*/
|
|
5
|
+
export const WidgetScope = z.enum(["front", "desk"]);
|
|
6
|
+
/**
|
|
7
|
+
* Widget type - how the widget behaves
|
|
8
|
+
*/
|
|
9
|
+
export const WidgetType = z.enum(["wam", "snippet"]);
|
|
10
|
+
/**
|
|
11
|
+
* I18n name/description pair
|
|
12
|
+
*/
|
|
13
|
+
export const NameDescI18nSchema = z.object({
|
|
14
|
+
name: z.string(),
|
|
15
|
+
description: z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Widget configuration schema
|
|
19
|
+
*/
|
|
20
|
+
export const WidgetConfigSchema = z.object({
|
|
21
|
+
name: z.string(),
|
|
22
|
+
description: z.string().optional(),
|
|
23
|
+
scope: WidgetScope,
|
|
24
|
+
widgetType: WidgetType.default("wam"),
|
|
25
|
+
/**
|
|
26
|
+
* i18n name/description map keyed by language code (e.g., "ko", "en", "ja")
|
|
27
|
+
*/
|
|
28
|
+
nameDescI18nMap: z.record(NameDescI18nSchema).optional(),
|
|
29
|
+
/**
|
|
30
|
+
* For snippet type: external URL to load
|
|
31
|
+
*/
|
|
32
|
+
snippetApiUrl: z.string().optional(),
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Widget action result schema
|
|
36
|
+
*/
|
|
37
|
+
export const WidgetActionResultSchema = z.object({
|
|
38
|
+
success: z.boolean(),
|
|
39
|
+
message: z.string().optional(),
|
|
40
|
+
data: z.record(z.unknown()).optional(),
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../src/extensions/widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAGrD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;AAGrD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,WAAW;IAClB,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;IACrC;;OAEG;IACH,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE;IACxD;;OAEG;IACH,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export * from "./types/index.js";
|
|
3
|
+
// Schemas
|
|
4
|
+
export * from "./schemas/index.js";
|
|
5
|
+
// Utilities
|
|
6
|
+
export * from "./utils/index.js";
|
|
7
|
+
// Errors
|
|
8
|
+
export * from "./errors/index.js";
|
|
9
|
+
// Base Extensions
|
|
10
|
+
export * from "./extensions/index.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,UAAU;AACV,cAAc,oBAAoB,CAAC;AAEnC,YAAY;AACZ,cAAc,kBAAkB,CAAC;AAEjC,SAAS;AACT,cAAc,mBAAmB,CAAC;AAElC,kBAAkB;AAClB,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExtensionDefinition, RegisteredExtension } from "../types/extension.js";
|
|
2
|
+
import type { RegisteredFunction } from "../types/function.js";
|
|
3
|
+
/**
|
|
4
|
+
* Register an extension and extract all functions
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerExtension(definition: ExtensionDefinition): RegisteredExtension & {
|
|
8
|
+
functions: RegisteredFunction[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Get the full method name including extension prefix
|
|
12
|
+
* Used for matching incoming requests
|
|
13
|
+
*/
|
|
14
|
+
export declare function getFullMethodName(extensionName: string, functionName: string): string;
|
|
15
|
+
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/schemas/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGnF;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,mBAAmB,GAC9B,mBAAmB,GAAG;IAAE,SAAS,EAAE,kBAAkB,EAAE,CAAA;CAAE,CA8B3D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAErF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createRegisteredFunction } from "./function.js";
|
|
2
|
+
/**
|
|
3
|
+
* Register an extension and extract all functions
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export function registerExtension(definition) {
|
|
7
|
+
const groups = new Map();
|
|
8
|
+
const functions = [];
|
|
9
|
+
for (const [groupName, group] of Object.entries(definition.groups)) {
|
|
10
|
+
const functionMap = new Map();
|
|
11
|
+
for (const [funcName, funcDef] of Object.entries(group)) {
|
|
12
|
+
// Skip _config property
|
|
13
|
+
if (funcName === "_config")
|
|
14
|
+
continue;
|
|
15
|
+
const funcDefinition = funcDef;
|
|
16
|
+
functionMap.set(funcName, funcDefinition);
|
|
17
|
+
// Create full function name: {groupName}.{functionName}
|
|
18
|
+
const fullName = `${groupName}.${funcName}`;
|
|
19
|
+
const registered = createRegisteredFunction(fullName, funcDefinition);
|
|
20
|
+
functions.push(registered);
|
|
21
|
+
}
|
|
22
|
+
groups.set(groupName, functionMap);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
name: definition.name,
|
|
26
|
+
systemVersion: definition.systemVersion ?? "v1",
|
|
27
|
+
exclusive: definition.exclusive ?? false,
|
|
28
|
+
groups,
|
|
29
|
+
functions,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the full method name including extension prefix
|
|
34
|
+
* Used for matching incoming requests
|
|
35
|
+
*/
|
|
36
|
+
export function getFullMethodName(extensionName, functionName) {
|
|
37
|
+
return `extension.${extensionName}.${functionName}`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/schemas/extension.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA+B;IAE/B,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2C,CAAC;IAClE,MAAM,SAAS,GAAyB,EAAE,CAAC;IAE3C,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA8B,CAAC;QAE1D,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxD,wBAAwB;YACxB,IAAI,QAAQ,KAAK,SAAS;gBAAE,SAAS;YAErC,MAAM,cAAc,GAAG,OAA6B,CAAC;YACrD,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YAE1C,wDAAwD;YACxD,MAAM,QAAQ,GAAG,GAAG,SAAS,IAAI,QAAQ,EAAE,CAAC;YAC5C,MAAM,UAAU,GAAG,wBAAwB,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YACtE,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,IAAI;QAC/C,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,KAAK;QACxC,MAAM;QACN,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAqB,EAAE,YAAoB;IAC3E,OAAO,aAAa,aAAa,IAAI,YAAY,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FunctionDefinition, RegisteredFunction } from "../types/function.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a registered function from a definition
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function createRegisteredFunction(name: string, definition: FunctionDefinition): RegisteredFunction;
|
|
7
|
+
//# sourceMappingURL=function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/schemas/function.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAmB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGpG;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,kBAAkB,GAC7B,kBAAkB,CA+BpB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { zodToJsonSchema } from "../utils/zod-to-json-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a registered function from a definition
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export function createRegisteredFunction(name, definition) {
|
|
7
|
+
const inputSchema = zodToJsonSchema(definition.input);
|
|
8
|
+
const outputSchema = definition.output ? zodToJsonSchema(definition.output) : undefined;
|
|
9
|
+
// Wrap handler to validate input
|
|
10
|
+
const wrappedHandler = async (ctx, params) => {
|
|
11
|
+
const validatedInput = definition.input.parse(params);
|
|
12
|
+
const result = await definition.handler(ctx, validatedInput);
|
|
13
|
+
if (definition.output) {
|
|
14
|
+
return definition.output.parse(result);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
const result = {
|
|
19
|
+
name,
|
|
20
|
+
inputSchema,
|
|
21
|
+
handler: wrappedHandler,
|
|
22
|
+
};
|
|
23
|
+
if (definition.description !== undefined) {
|
|
24
|
+
result.description = definition.description;
|
|
25
|
+
}
|
|
26
|
+
if (outputSchema !== undefined) {
|
|
27
|
+
result.outputSchema = outputSchema;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../src/schemas/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAIjE;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAY,EACZ,UAA8B;IAE9B,MAAM,WAAW,GAAG,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAExF,iCAAiC;IACjC,MAAM,cAAc,GAAoB,KAAK,EAAE,GAAY,EAAE,MAAe,EAAE,EAAE;QAC9E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAE7D,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,MAAM,GAAuB;QACjC,IAAI;QACJ,WAAW;QACX,OAAO,EAAE,cAAc;KACxB,CAAC;IAEF,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC9C,CAAC;IAED,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Caller information from the function call context
|
|
3
|
+
*/
|
|
4
|
+
export interface Caller {
|
|
5
|
+
/** Caller's unique identifier */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Caller type (e.g., "manager", "user") */
|
|
8
|
+
type?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Channel information from the function call context
|
|
12
|
+
*/
|
|
13
|
+
export interface Channel {
|
|
14
|
+
/** Channel's unique identifier */
|
|
15
|
+
id: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* App information from the function call context
|
|
19
|
+
*/
|
|
20
|
+
export interface App {
|
|
21
|
+
/** App's unique identifier */
|
|
22
|
+
id: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Context passed to function handlers
|
|
26
|
+
*/
|
|
27
|
+
export interface Context {
|
|
28
|
+
/** Caller information */
|
|
29
|
+
caller: Caller;
|
|
30
|
+
/** Channel information */
|
|
31
|
+
channel: Channel;
|
|
32
|
+
/** App information */
|
|
33
|
+
app: App;
|
|
34
|
+
/** Additional context data */
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Raw request body from Channel.io
|
|
39
|
+
*/
|
|
40
|
+
export interface FunctionCallRequest {
|
|
41
|
+
/** Function method name (e.g., "extension.calendar.booking.createBooking") */
|
|
42
|
+
method: string;
|
|
43
|
+
/** Function call context */
|
|
44
|
+
context: Context;
|
|
45
|
+
/** Function parameters */
|
|
46
|
+
params?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Response format for function calls
|
|
50
|
+
*/
|
|
51
|
+
export interface FunctionCallResponse<T = unknown> {
|
|
52
|
+
/** Result data */
|
|
53
|
+
result: T;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB;IACtB,GAAG,EAAE,GAAG,CAAC;IACT,8BAA8B;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC/C,kBAAkB;IAClB,MAAM,EAAE,CAAC,CAAC;CACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FunctionDefinition } from "./function.js";
|
|
2
|
+
/**
|
|
3
|
+
* Available extension names
|
|
4
|
+
*/
|
|
5
|
+
export type ExtensionName = "oauth" | "apikey" | "calendar" | "messenger" | "command" | "widget" | "customtab" | "commerce" | "alfTask" | (string & {});
|
|
6
|
+
/**
|
|
7
|
+
* Extension configuration
|
|
8
|
+
*/
|
|
9
|
+
export interface ExtensionConfig {
|
|
10
|
+
/** Extension name (e.g., "calendar", "oauth") */
|
|
11
|
+
name: ExtensionName;
|
|
12
|
+
/** System version (e.g., "v1", "v2") */
|
|
13
|
+
systemVersion?: string;
|
|
14
|
+
/** Whether this is an exclusive extension (only one app can be default) */
|
|
15
|
+
exclusive?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Function group configuration
|
|
19
|
+
*/
|
|
20
|
+
export interface FunctionGroupConfig {
|
|
21
|
+
/** Whether this function group is required */
|
|
22
|
+
required?: boolean;
|
|
23
|
+
/** Dependencies on other function groups */
|
|
24
|
+
dependencies?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Function group containing multiple functions
|
|
28
|
+
*/
|
|
29
|
+
export type FunctionGroup<TFunctions extends Record<string, FunctionDefinition> = Record<string, FunctionDefinition>> = {
|
|
30
|
+
/** Function group configuration */
|
|
31
|
+
_config?: FunctionGroupConfig;
|
|
32
|
+
} & TFunctions;
|
|
33
|
+
/**
|
|
34
|
+
* Extension definition with function groups
|
|
35
|
+
*/
|
|
36
|
+
export interface ExtensionDefinition<TGroups extends Record<string, FunctionGroup> = Record<string, FunctionGroup>> extends ExtensionConfig {
|
|
37
|
+
/** Function groups */
|
|
38
|
+
groups: TGroups;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Registered extension with metadata
|
|
42
|
+
*/
|
|
43
|
+
export interface RegisteredExtension {
|
|
44
|
+
/** Extension name */
|
|
45
|
+
name: string;
|
|
46
|
+
/** System version (e.g., "v1", "v2") */
|
|
47
|
+
systemVersion: string;
|
|
48
|
+
/** Whether exclusive */
|
|
49
|
+
exclusive: boolean;
|
|
50
|
+
/** Function groups with their functions */
|
|
51
|
+
groups: Map<string, Map<string, FunctionDefinition>>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/types/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,QAAQ,GACR,UAAU,GACV,WAAW,GACX,SAAS,GACT,QAAQ,GACR,WAAW,GACX,UAAU,GACV,SAAS,GACT,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,IAAI,EAAE,aAAa,CAAC;IACpB,wCAAwC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CACvB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,IACxF;IACF,mCAAmC;IACnC,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B,GAAG,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAClC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAC7E,SAAQ,eAAe;IACvB,sBAAsB;IACtB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/types/extension.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { Context } from "./context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Function handler type
|
|
5
|
+
*/
|
|
6
|
+
export type FunctionHandler<TInput = unknown, TOutput = unknown> = (ctx: Context, params: TInput) => Promise<TOutput> | TOutput;
|
|
7
|
+
/**
|
|
8
|
+
* Function definition configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface FunctionDefinition<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> {
|
|
11
|
+
/** Function description for documentation */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Zod schema for input validation */
|
|
14
|
+
input: TInput;
|
|
15
|
+
/** Zod schema for output validation (optional) */
|
|
16
|
+
output?: TOutput;
|
|
17
|
+
/** Function handler */
|
|
18
|
+
handler: FunctionHandler<z.infer<TInput>, z.infer<TOutput>>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Registered function with metadata
|
|
22
|
+
*/
|
|
23
|
+
export interface RegisteredFunction {
|
|
24
|
+
/** Full function name (e.g., "calendar.booking.createBooking") */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Function description */
|
|
27
|
+
description?: string;
|
|
28
|
+
/** JSON Schema for input */
|
|
29
|
+
inputSchema: Record<string, unknown>;
|
|
30
|
+
/** JSON Schema for output */
|
|
31
|
+
outputSchema?: Record<string, unknown>;
|
|
32
|
+
/** Function handler */
|
|
33
|
+
handler: FunctionHandler;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Function schema for getFunctions response
|
|
37
|
+
*/
|
|
38
|
+
export interface FunctionSchema {
|
|
39
|
+
/** Full function name */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Function description */
|
|
42
|
+
description?: string;
|
|
43
|
+
/** JSON Schema for input parameters */
|
|
44
|
+
inputSchema: Record<string, unknown>;
|
|
45
|
+
/** JSON Schema for output */
|
|
46
|
+
outputSchema?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Response type for extension.core.function.getFunctions
|
|
50
|
+
*/
|
|
51
|
+
export interface GetFunctionsResponse {
|
|
52
|
+
result: {
|
|
53
|
+
functions: FunctionSchema[];
|
|
54
|
+
success: boolean;
|
|
55
|
+
errorMessage: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/types/function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,CACjE,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,kBAAkB,CACjC,MAAM,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EACpC,OAAO,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;IAErC,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uBAAuB;IACvB,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,uBAAuB;IACvB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE;QACN,SAAS,EAAE,cAAc,EAAE,CAAC;QAC5B,OAAO,EAAE,OAAO,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../src/types/function.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-to-json-schema.d.ts","sourceRoot":"","sources":["../../src/utils/zod-to-json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI1E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { zodToJsonSchema as zodToJsonSchemaLib } from "zod-to-json-schema";
|
|
2
|
+
/**
|
|
3
|
+
* Convert Zod schema to JSON Schema
|
|
4
|
+
*/
|
|
5
|
+
export function zodToJsonSchema(schema) {
|
|
6
|
+
return zodToJsonSchemaLib(schema, {
|
|
7
|
+
$refStrategy: "none",
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=zod-to-json-schema.js.map
|