lark-billing-mcp 0.7.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/LICENSE +201 -0
- package/README.md +99 -0
- package/code-tool-types.d.mts +13 -0
- package/code-tool-types.d.mts.map +1 -0
- package/code-tool-types.d.ts +13 -0
- package/code-tool-types.d.ts.map +1 -0
- package/code-tool-types.js +4 -0
- package/code-tool-types.js.map +1 -0
- package/code-tool-types.mjs +3 -0
- package/code-tool-types.mjs.map +1 -0
- package/code-tool.d.mts +12 -0
- package/code-tool.d.mts.map +1 -0
- package/code-tool.d.ts +12 -0
- package/code-tool.d.ts.map +1 -0
- package/code-tool.js +85 -0
- package/code-tool.js.map +1 -0
- package/code-tool.mjs +82 -0
- package/code-tool.mjs.map +1 -0
- package/docs-search-tool.d.mts +50 -0
- package/docs-search-tool.d.mts.map +1 -0
- package/docs-search-tool.d.ts +50 -0
- package/docs-search-tool.d.ts.map +1 -0
- package/docs-search-tool.js +51 -0
- package/docs-search-tool.js.map +1 -0
- package/docs-search-tool.mjs +47 -0
- package/docs-search-tool.mjs.map +1 -0
- package/headers.d.mts +4 -0
- package/headers.d.mts.map +1 -0
- package/headers.d.ts +4 -0
- package/headers.d.ts.map +1 -0
- package/headers.js +10 -0
- package/headers.js.map +1 -0
- package/headers.mjs +6 -0
- package/headers.mjs.map +1 -0
- package/http.d.mts +9 -0
- package/http.d.mts.map +1 -0
- package/http.d.ts +9 -0
- package/http.d.ts.map +1 -0
- package/http.js +91 -0
- package/http.js.map +1 -0
- package/http.mjs +83 -0
- package/http.mjs.map +1 -0
- package/index.d.mts +3 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +55 -0
- package/index.js.map +1 -0
- package/index.mjs +53 -0
- package/index.mjs.map +1 -0
- package/options.d.mts +11 -0
- package/options.d.mts.map +1 -0
- package/options.d.ts +11 -0
- package/options.d.ts.map +1 -0
- package/options.js +72 -0
- package/options.js.map +1 -0
- package/options.mjs +65 -0
- package/options.mjs.map +1 -0
- package/package.json +161 -0
- package/server.d.mts +30 -0
- package/server.d.mts.map +1 -0
- package/server.d.ts +30 -0
- package/server.d.ts.map +1 -0
- package/server.js +121 -0
- package/server.js.map +1 -0
- package/server.mjs +109 -0
- package/server.mjs.map +1 -0
- package/src/code-tool-types.ts +15 -0
- package/src/code-tool.ts +96 -0
- package/src/docs-search-tool.ts +59 -0
- package/src/headers.ts +10 -0
- package/src/http.ts +109 -0
- package/src/index.ts +61 -0
- package/src/options.ts +92 -0
- package/src/server.ts +147 -0
- package/src/stdio.ts +12 -0
- package/src/tsconfig.json +11 -0
- package/src/types.ts +115 -0
- package/stdio.d.mts +2 -0
- package/stdio.d.mts.map +1 -0
- package/stdio.d.ts +2 -0
- package/stdio.d.ts.map +1 -0
- package/stdio.js +14 -0
- package/stdio.js.map +1 -0
- package/stdio.mjs +10 -0
- package/stdio.mjs.map +1 -0
- package/types.d.mts +52 -0
- package/types.d.mts.map +1 -0
- package/types.d.ts +52 -0
- package/types.d.ts.map +1 -0
- package/types.js +58 -0
- package/types.js.map +1 -0
- package/types.mjs +53 -0
- package/types.mjs.map +1 -0
package/options.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseCLIOptions = parseCLIOptions;
|
|
7
|
+
exports.parseQueryOptions = parseQueryOptions;
|
|
8
|
+
const qs_1 = __importDefault(require("qs"));
|
|
9
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
10
|
+
const helpers_1 = require("yargs/helpers");
|
|
11
|
+
const zod_1 = __importDefault(require("zod"));
|
|
12
|
+
function parseCLIOptions() {
|
|
13
|
+
const opts = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
14
|
+
.option('tools', {
|
|
15
|
+
type: 'string',
|
|
16
|
+
array: true,
|
|
17
|
+
choices: ['code', 'docs'],
|
|
18
|
+
description: 'Use dynamic tools or all tools',
|
|
19
|
+
})
|
|
20
|
+
.option('no-tools', {
|
|
21
|
+
type: 'string',
|
|
22
|
+
array: true,
|
|
23
|
+
choices: ['code', 'docs'],
|
|
24
|
+
description: 'Do not use any dynamic or all tools',
|
|
25
|
+
})
|
|
26
|
+
.option('transport', {
|
|
27
|
+
type: 'string',
|
|
28
|
+
choices: ['stdio', 'http'],
|
|
29
|
+
default: 'stdio',
|
|
30
|
+
description: 'What transport to use; stdio for local servers or http for remote servers',
|
|
31
|
+
})
|
|
32
|
+
.option('port', {
|
|
33
|
+
type: 'number',
|
|
34
|
+
description: 'Port to serve on if using http transport',
|
|
35
|
+
})
|
|
36
|
+
.option('socket', {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Unix socket to serve on if using http transport',
|
|
39
|
+
})
|
|
40
|
+
.help();
|
|
41
|
+
const argv = opts.parseSync();
|
|
42
|
+
const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
|
|
43
|
+
: argv.tools?.includes(toolType) ? true
|
|
44
|
+
: undefined;
|
|
45
|
+
const includeDocsTools = shouldIncludeToolType('docs');
|
|
46
|
+
const transport = argv.transport;
|
|
47
|
+
return {
|
|
48
|
+
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
49
|
+
transport,
|
|
50
|
+
port: argv.port,
|
|
51
|
+
socket: argv.socket,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const coerceArray = (zodType) => zod_1.default.preprocess((val) => Array.isArray(val) ? val
|
|
55
|
+
: val ? [val]
|
|
56
|
+
: val, zod_1.default.array(zodType).optional());
|
|
57
|
+
const QueryOptions = zod_1.default.object({
|
|
58
|
+
tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
|
|
59
|
+
no_tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
|
|
60
|
+
tool: coerceArray(zod_1.default.string()).describe('Include tools matching the specified names'),
|
|
61
|
+
});
|
|
62
|
+
function parseQueryOptions(defaultOptions, query) {
|
|
63
|
+
const queryObject = typeof query === 'string' ? qs_1.default.parse(query) : query;
|
|
64
|
+
const queryOptions = QueryOptions.parse(queryObject);
|
|
65
|
+
let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
|
|
66
|
+
: queryOptions.tools?.includes('docs') ? true
|
|
67
|
+
: defaultOptions.includeDocsTools;
|
|
68
|
+
return {
|
|
69
|
+
...(docsTools !== undefined && { includeDocsTools: docsTools }),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=options.js.map
|
package/options.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";;;;;AAeA,0CA+CC;AAiBD,8CAYC;AA3FD,4CAAoB;AACpB,kDAA0B;AAC1B,2CAAwC;AACxC,8CAAoB;AAYpB,SAAgB,eAAe;IAC7B,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,gCAAgC;KAC9C,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,qCAAqC;KACnD,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACnB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,OAAO,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opts = yargs(hideBin(process.argv))
|
|
7
|
+
.option('tools', {
|
|
8
|
+
type: 'string',
|
|
9
|
+
array: true,
|
|
10
|
+
choices: ['code', 'docs'],
|
|
11
|
+
description: 'Use dynamic tools or all tools',
|
|
12
|
+
})
|
|
13
|
+
.option('no-tools', {
|
|
14
|
+
type: 'string',
|
|
15
|
+
array: true,
|
|
16
|
+
choices: ['code', 'docs'],
|
|
17
|
+
description: 'Do not use any dynamic or all tools',
|
|
18
|
+
})
|
|
19
|
+
.option('transport', {
|
|
20
|
+
type: 'string',
|
|
21
|
+
choices: ['stdio', 'http'],
|
|
22
|
+
default: 'stdio',
|
|
23
|
+
description: 'What transport to use; stdio for local servers or http for remote servers',
|
|
24
|
+
})
|
|
25
|
+
.option('port', {
|
|
26
|
+
type: 'number',
|
|
27
|
+
description: 'Port to serve on if using http transport',
|
|
28
|
+
})
|
|
29
|
+
.option('socket', {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'Unix socket to serve on if using http transport',
|
|
32
|
+
})
|
|
33
|
+
.help();
|
|
34
|
+
const argv = opts.parseSync();
|
|
35
|
+
const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
|
|
36
|
+
: argv.tools?.includes(toolType) ? true
|
|
37
|
+
: undefined;
|
|
38
|
+
const includeDocsTools = shouldIncludeToolType('docs');
|
|
39
|
+
const transport = argv.transport;
|
|
40
|
+
return {
|
|
41
|
+
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
42
|
+
transport,
|
|
43
|
+
port: argv.port,
|
|
44
|
+
socket: argv.socket,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const coerceArray = (zodType) => z.preprocess((val) => Array.isArray(val) ? val
|
|
48
|
+
: val ? [val]
|
|
49
|
+
: val, z.array(zodType).optional());
|
|
50
|
+
const QueryOptions = z.object({
|
|
51
|
+
tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
|
|
52
|
+
no_tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
|
|
53
|
+
tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
|
|
54
|
+
});
|
|
55
|
+
export function parseQueryOptions(defaultOptions, query) {
|
|
56
|
+
const queryObject = typeof query === 'string' ? qs.parse(query) : query;
|
|
57
|
+
const queryOptions = QueryOptions.parse(queryObject);
|
|
58
|
+
let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
|
|
59
|
+
: queryOptions.tools?.includes('docs') ? true
|
|
60
|
+
: defaultOptions.includeDocsTools;
|
|
61
|
+
return {
|
|
62
|
+
...(docsTools !== undefined && { includeDocsTools: docsTools }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=options.mjs.map
|
package/options.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;AAYnB,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,gCAAgC;KAC9C,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,qCAAqC;KACnD,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACnB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;QAC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AAC,MAAM,CAAC;IAC5B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gCAAgC,CAAC;IACvF,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAC/F,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CACrF,CAAC,CAAC;AAEH,MAAM,UAAU,iBAAiB,CAAC,cAA0B,EAAE,KAAc;IAC1E,MAAM,WAAW,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxE,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAErD,IAAI,SAAS,GACX,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lark-billing-mcp",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "The official MCP Server for the Lark API",
|
|
5
|
+
"author": "Lark <team@uselark.ai>",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"main": "./index.js",
|
|
8
|
+
"type": "commonjs",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/uselark/lark-billing-typescript.git",
|
|
12
|
+
"directory": "packages/mcp-server"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/uselark/lark-billing-typescript/tree/main/packages/mcp-server#readme",
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"private": false,
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"lark-billing": "^0.7.0",
|
|
22
|
+
"@cloudflare/cabidela": "^0.2.4",
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.24.0",
|
|
24
|
+
"@valtown/deno-http-worker": "^0.0.21",
|
|
25
|
+
"cors": "^2.8.5",
|
|
26
|
+
"express": "^5.1.0",
|
|
27
|
+
"fuse.js": "^7.1.0",
|
|
28
|
+
"jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.8/jq-web.tar.gz",
|
|
29
|
+
"qs": "^6.14.0",
|
|
30
|
+
"typescript": "5.8.3",
|
|
31
|
+
"yargs": "^17.7.2",
|
|
32
|
+
"zod": "^3.25.20",
|
|
33
|
+
"zod-to-json-schema": "^3.24.5",
|
|
34
|
+
"zod-validation-error": "^4.0.1"
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"mcp-server": "./index.js"
|
|
38
|
+
},
|
|
39
|
+
"imports": {
|
|
40
|
+
"lark-billing-mcp": ".",
|
|
41
|
+
"lark-billing-mcp/*": "./src/*"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./index.d.ts",
|
|
47
|
+
"default": "./index.js"
|
|
48
|
+
},
|
|
49
|
+
"types": "./index.d.mts",
|
|
50
|
+
"default": "./index.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./code-tool-types": {
|
|
53
|
+
"import": "./code-tool-types.mjs",
|
|
54
|
+
"require": "./code-tool-types.js"
|
|
55
|
+
},
|
|
56
|
+
"./code-tool-types.js": {
|
|
57
|
+
"default": "./code-tool-types.js"
|
|
58
|
+
},
|
|
59
|
+
"./code-tool-types.mjs": {
|
|
60
|
+
"default": "./code-tool-types.mjs"
|
|
61
|
+
},
|
|
62
|
+
"./code-tool": {
|
|
63
|
+
"import": "./code-tool.mjs",
|
|
64
|
+
"require": "./code-tool.js"
|
|
65
|
+
},
|
|
66
|
+
"./code-tool.js": {
|
|
67
|
+
"default": "./code-tool.js"
|
|
68
|
+
},
|
|
69
|
+
"./code-tool.mjs": {
|
|
70
|
+
"default": "./code-tool.mjs"
|
|
71
|
+
},
|
|
72
|
+
"./docs-search-tool": {
|
|
73
|
+
"import": "./docs-search-tool.mjs",
|
|
74
|
+
"require": "./docs-search-tool.js"
|
|
75
|
+
},
|
|
76
|
+
"./docs-search-tool.js": {
|
|
77
|
+
"default": "./docs-search-tool.js"
|
|
78
|
+
},
|
|
79
|
+
"./docs-search-tool.mjs": {
|
|
80
|
+
"default": "./docs-search-tool.mjs"
|
|
81
|
+
},
|
|
82
|
+
"./headers": {
|
|
83
|
+
"import": "./headers.mjs",
|
|
84
|
+
"require": "./headers.js"
|
|
85
|
+
},
|
|
86
|
+
"./headers.js": {
|
|
87
|
+
"default": "./headers.js"
|
|
88
|
+
},
|
|
89
|
+
"./headers.mjs": {
|
|
90
|
+
"default": "./headers.mjs"
|
|
91
|
+
},
|
|
92
|
+
"./http": {
|
|
93
|
+
"import": "./http.mjs",
|
|
94
|
+
"require": "./http.js"
|
|
95
|
+
},
|
|
96
|
+
"./http.js": {
|
|
97
|
+
"default": "./http.js"
|
|
98
|
+
},
|
|
99
|
+
"./http.mjs": {
|
|
100
|
+
"default": "./http.mjs"
|
|
101
|
+
},
|
|
102
|
+
"./index": {
|
|
103
|
+
"import": "./index.mjs",
|
|
104
|
+
"require": "./index.js"
|
|
105
|
+
},
|
|
106
|
+
"./index.js": {
|
|
107
|
+
"default": "./index.js"
|
|
108
|
+
},
|
|
109
|
+
"./index.mjs": {
|
|
110
|
+
"default": "./index.mjs"
|
|
111
|
+
},
|
|
112
|
+
"./options": {
|
|
113
|
+
"import": "./options.mjs",
|
|
114
|
+
"require": "./options.js"
|
|
115
|
+
},
|
|
116
|
+
"./options.js": {
|
|
117
|
+
"default": "./options.js"
|
|
118
|
+
},
|
|
119
|
+
"./options.mjs": {
|
|
120
|
+
"default": "./options.mjs"
|
|
121
|
+
},
|
|
122
|
+
"./server": {
|
|
123
|
+
"import": "./server.mjs",
|
|
124
|
+
"require": "./server.js"
|
|
125
|
+
},
|
|
126
|
+
"./server.js": {
|
|
127
|
+
"default": "./server.js"
|
|
128
|
+
},
|
|
129
|
+
"./server.mjs": {
|
|
130
|
+
"default": "./server.mjs"
|
|
131
|
+
},
|
|
132
|
+
"./stdio": {
|
|
133
|
+
"import": "./stdio.mjs",
|
|
134
|
+
"require": "./stdio.js"
|
|
135
|
+
},
|
|
136
|
+
"./stdio.js": {
|
|
137
|
+
"default": "./stdio.js"
|
|
138
|
+
},
|
|
139
|
+
"./stdio.mjs": {
|
|
140
|
+
"default": "./stdio.mjs"
|
|
141
|
+
},
|
|
142
|
+
"./types": {
|
|
143
|
+
"import": "./types.mjs",
|
|
144
|
+
"require": "./types.js"
|
|
145
|
+
},
|
|
146
|
+
"./types.js": {
|
|
147
|
+
"default": "./types.js"
|
|
148
|
+
},
|
|
149
|
+
"./types.mjs": {
|
|
150
|
+
"default": "./types.mjs"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"scripts": {
|
|
154
|
+
"test": "jest",
|
|
155
|
+
"build": "bash ./build",
|
|
156
|
+
"format": "prettier --write --cache --cache-strategy metadata . !dist",
|
|
157
|
+
"tsn": "ts-node -r tsconfig-paths/register",
|
|
158
|
+
"lint": "eslint --ext ts,js .",
|
|
159
|
+
"fix": "eslint --fix --ext ts,js ."
|
|
160
|
+
}
|
|
161
|
+
}
|
package/server.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { ClientOptions } from 'lark-billing';
|
|
4
|
+
import Lark from 'lark-billing';
|
|
5
|
+
import { McpOptions } from "./options.mjs";
|
|
6
|
+
import { HandlerFunction, McpTool } from "./types.mjs";
|
|
7
|
+
export { McpOptions } from "./options.mjs";
|
|
8
|
+
export { ClientOptions } from 'lark-billing';
|
|
9
|
+
export declare const newMcpServer: () => McpServer;
|
|
10
|
+
export declare const server: McpServer;
|
|
11
|
+
/**
|
|
12
|
+
* Initializes the provided MCP Server with the given tools and handlers.
|
|
13
|
+
* If not provided, the default client, tools and handlers will be used.
|
|
14
|
+
*/
|
|
15
|
+
export declare function initMcpServer(params: {
|
|
16
|
+
server: Server | McpServer;
|
|
17
|
+
clientOptions?: ClientOptions;
|
|
18
|
+
mcpOptions?: McpOptions;
|
|
19
|
+
}): void;
|
|
20
|
+
/**
|
|
21
|
+
* Selects the tools to include in the MCP Server based on the provided options.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectTools(options?: McpOptions): McpTool[];
|
|
24
|
+
/**
|
|
25
|
+
* Runs the provided handler with the given client and arguments.
|
|
26
|
+
*/
|
|
27
|
+
export declare function executeHandler(handler: HandlerFunction, client: Lark, args: Record<string, unknown> | undefined): Promise<import("./types").ToolCallResult>;
|
|
28
|
+
export declare const readEnv: (env: string) => string | undefined;
|
|
29
|
+
export declare const readEnvOrError: (env: string) => string;
|
|
30
|
+
//# sourceMappingURL=server.d.mts.map
|
package/server.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;OACrC,IAAI,MAAM,cAAc;OAGxB,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,cAAc;AAE5C,eAAO,MAAM,YAAY,iBAOtB,CAAC;AAGJ,eAAO,MAAM,MAAM,WAAiB,CAAC;AAErC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACpC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,QAoEA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAM3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC"}
|
package/server.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { ClientOptions } from 'lark-billing';
|
|
4
|
+
import Lark from 'lark-billing';
|
|
5
|
+
import { McpOptions } from "./options.js";
|
|
6
|
+
import { HandlerFunction, McpTool } from "./types.js";
|
|
7
|
+
export { McpOptions } from "./options.js";
|
|
8
|
+
export { ClientOptions } from 'lark-billing';
|
|
9
|
+
export declare const newMcpServer: () => McpServer;
|
|
10
|
+
export declare const server: McpServer;
|
|
11
|
+
/**
|
|
12
|
+
* Initializes the provided MCP Server with the given tools and handlers.
|
|
13
|
+
* If not provided, the default client, tools and handlers will be used.
|
|
14
|
+
*/
|
|
15
|
+
export declare function initMcpServer(params: {
|
|
16
|
+
server: Server | McpServer;
|
|
17
|
+
clientOptions?: ClientOptions;
|
|
18
|
+
mcpOptions?: McpOptions;
|
|
19
|
+
}): void;
|
|
20
|
+
/**
|
|
21
|
+
* Selects the tools to include in the MCP Server based on the provided options.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectTools(options?: McpOptions): McpTool[];
|
|
24
|
+
/**
|
|
25
|
+
* Runs the provided handler with the given client and arguments.
|
|
26
|
+
*/
|
|
27
|
+
export declare function executeHandler(handler: HandlerFunction, client: Lark, args: Record<string, unknown> | undefined): Promise<import("./types").ToolCallResult>;
|
|
28
|
+
export declare const readEnv: (env: string) => string | undefined;
|
|
29
|
+
export declare const readEnvOrError: (env: string) => string;
|
|
30
|
+
//# sourceMappingURL=server.d.ts.map
|
package/server.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;OACrC,IAAI,MAAM,cAAc;OAGxB,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,cAAc;AAE5C,eAAO,MAAM,YAAY,iBAOtB,CAAC;AAGJ,eAAO,MAAM,MAAM,WAAiB,CAAC;AAErC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACpC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,QAoEA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAM3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC"}
|
package/server.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.readEnvOrError = exports.readEnv = exports.server = exports.newMcpServer = void 0;
|
|
8
|
+
exports.initMcpServer = initMcpServer;
|
|
9
|
+
exports.selectTools = selectTools;
|
|
10
|
+
exports.executeHandler = executeHandler;
|
|
11
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
12
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
13
|
+
const lark_billing_1 = __importDefault(require("lark-billing"));
|
|
14
|
+
const code_tool_1 = require("./code-tool.js");
|
|
15
|
+
const docs_search_tool_1 = __importDefault(require("./docs-search-tool.js"));
|
|
16
|
+
const newMcpServer = () => new mcp_js_1.McpServer({
|
|
17
|
+
name: 'lark_billing_api',
|
|
18
|
+
version: '0.7.0',
|
|
19
|
+
}, { capabilities: { tools: {}, logging: {} } });
|
|
20
|
+
exports.newMcpServer = newMcpServer;
|
|
21
|
+
// Create server instance
|
|
22
|
+
exports.server = (0, exports.newMcpServer)();
|
|
23
|
+
/**
|
|
24
|
+
* Initializes the provided MCP Server with the given tools and handlers.
|
|
25
|
+
* If not provided, the default client, tools and handlers will be used.
|
|
26
|
+
*/
|
|
27
|
+
function initMcpServer(params) {
|
|
28
|
+
const server = params.server instanceof mcp_js_1.McpServer ? params.server.server : params.server;
|
|
29
|
+
const logAtLevel = (level) => (message, ...rest) => {
|
|
30
|
+
void server.sendLoggingMessage({
|
|
31
|
+
level,
|
|
32
|
+
data: { message, rest },
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const logger = {
|
|
36
|
+
debug: logAtLevel('debug'),
|
|
37
|
+
info: logAtLevel('info'),
|
|
38
|
+
warn: logAtLevel('warning'),
|
|
39
|
+
error: logAtLevel('error'),
|
|
40
|
+
};
|
|
41
|
+
let client = new lark_billing_1.default({
|
|
42
|
+
logger,
|
|
43
|
+
...params.clientOptions,
|
|
44
|
+
defaultHeaders: {
|
|
45
|
+
...params.clientOptions?.defaultHeaders,
|
|
46
|
+
'X-Stainless-MCP': 'true',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
const providedTools = selectTools(params.mcpOptions);
|
|
50
|
+
const toolMap = Object.fromEntries(providedTools.map((mcpTool) => [mcpTool.tool.name, mcpTool]));
|
|
51
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
52
|
+
return {
|
|
53
|
+
tools: providedTools.map((mcpTool) => mcpTool.tool),
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
57
|
+
const { name, arguments: args } = request.params;
|
|
58
|
+
const mcpTool = toolMap[name];
|
|
59
|
+
if (!mcpTool) {
|
|
60
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
61
|
+
}
|
|
62
|
+
return executeHandler(mcpTool.handler, client, args);
|
|
63
|
+
});
|
|
64
|
+
server.setRequestHandler(types_js_1.SetLevelRequestSchema, async (request) => {
|
|
65
|
+
const { level } = request.params;
|
|
66
|
+
switch (level) {
|
|
67
|
+
case 'debug':
|
|
68
|
+
client = client.withOptions({ logLevel: 'debug' });
|
|
69
|
+
break;
|
|
70
|
+
case 'info':
|
|
71
|
+
client = client.withOptions({ logLevel: 'info' });
|
|
72
|
+
break;
|
|
73
|
+
case 'notice':
|
|
74
|
+
case 'warning':
|
|
75
|
+
client = client.withOptions({ logLevel: 'warn' });
|
|
76
|
+
break;
|
|
77
|
+
case 'error':
|
|
78
|
+
client = client.withOptions({ logLevel: 'error' });
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
client = client.withOptions({ logLevel: 'off' });
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
return {};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Selects the tools to include in the MCP Server based on the provided options.
|
|
89
|
+
*/
|
|
90
|
+
function selectTools(options) {
|
|
91
|
+
const includedTools = [(0, code_tool_1.codeTool)()];
|
|
92
|
+
if (options?.includeDocsTools ?? true) {
|
|
93
|
+
includedTools.push(docs_search_tool_1.default);
|
|
94
|
+
}
|
|
95
|
+
return includedTools;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Runs the provided handler with the given client and arguments.
|
|
99
|
+
*/
|
|
100
|
+
async function executeHandler(handler, client, args) {
|
|
101
|
+
return await handler(client, args || {});
|
|
102
|
+
}
|
|
103
|
+
const readEnv = (env) => {
|
|
104
|
+
if (typeof globalThis.process !== 'undefined') {
|
|
105
|
+
return globalThis.process.env?.[env]?.trim();
|
|
106
|
+
}
|
|
107
|
+
else if (typeof globalThis.Deno !== 'undefined') {
|
|
108
|
+
return globalThis.Deno.env?.get?.(env)?.trim();
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
};
|
|
112
|
+
exports.readEnv = readEnv;
|
|
113
|
+
const readEnvOrError = (env) => {
|
|
114
|
+
let envValue = (0, exports.readEnv)(env);
|
|
115
|
+
if (envValue === undefined) {
|
|
116
|
+
throw new Error(`Environment variable ${env} is not set`);
|
|
117
|
+
}
|
|
118
|
+
return envValue;
|
|
119
|
+
};
|
|
120
|
+
exports.readEnvOrError = readEnvOrError;
|
|
121
|
+
//# sourceMappingURL=server.js.map
|
package/server.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAmCtF,sCAwEC;AAKD,kCAMC;AAKD,wCAMC;AA9HD,oEAAoE;AACpE,iEAI4C;AAE5C,gEAAgC;AAChC,8CAAuC;AACvC,6EAAgD;AAOzC,MAAM,YAAY,GAAG,GAAG,EAAE,CAC/B,IAAI,kBAAS,CACX;IACE,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,OAAO;CACjB,EACD,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAC7C,CAAC;AAPS,QAAA,YAAY,gBAOrB;AAEJ,yBAAyB;AACZ,QAAA,MAAM,GAAG,IAAA,oBAAY,GAAE,CAAC;AAErC;;;GAGG;AACH,SAAgB,aAAa,CAAC,MAI7B;IACC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,YAAY,kBAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEzF,MAAM,UAAU,GACd,CAAC,KAA6C,EAAE,EAAE,CAClD,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QACtC,KAAK,MAAM,CAAC,kBAAkB,CAAC;YAC7B,KAAK;YACL,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;IACJ,MAAM,MAAM,GAAG;QACb,KAAK,EAAE,UAAU,CAAC,O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3C,CAAC;AAEM,MAAM,OAAO,GAAG,CAAC,GAAW,EAAsB,EAAE;IACzD,IAAI,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAPW,QAAA,OAAO,WAOlB;AAEK,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,IAAA,eAAO,EAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB"}
|
package/server.mjs
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import Lark from 'lark-billing';
|
|
5
|
+
import { codeTool } from "./code-tool.mjs";
|
|
6
|
+
import docsSearchTool from "./docs-search-tool.mjs";
|
|
7
|
+
export const newMcpServer = () => new McpServer({
|
|
8
|
+
name: 'lark_billing_api',
|
|
9
|
+
version: '0.7.0',
|
|
10
|
+
}, { capabilities: { tools: {}, logging: {} } });
|
|
11
|
+
// Create server instance
|
|
12
|
+
export const server = newMcpServer();
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the provided MCP Server with the given tools and handlers.
|
|
15
|
+
* If not provided, the default client, tools and handlers will be used.
|
|
16
|
+
*/
|
|
17
|
+
export function initMcpServer(params) {
|
|
18
|
+
const server = params.server instanceof McpServer ? params.server.server : params.server;
|
|
19
|
+
const logAtLevel = (level) => (message, ...rest) => {
|
|
20
|
+
void server.sendLoggingMessage({
|
|
21
|
+
level,
|
|
22
|
+
data: { message, rest },
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const logger = {
|
|
26
|
+
debug: logAtLevel('debug'),
|
|
27
|
+
info: logAtLevel('info'),
|
|
28
|
+
warn: logAtLevel('warning'),
|
|
29
|
+
error: logAtLevel('error'),
|
|
30
|
+
};
|
|
31
|
+
let client = new Lark({
|
|
32
|
+
logger,
|
|
33
|
+
...params.clientOptions,
|
|
34
|
+
defaultHeaders: {
|
|
35
|
+
...params.clientOptions?.defaultHeaders,
|
|
36
|
+
'X-Stainless-MCP': 'true',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const providedTools = selectTools(params.mcpOptions);
|
|
40
|
+
const toolMap = Object.fromEntries(providedTools.map((mcpTool) => [mcpTool.tool.name, mcpTool]));
|
|
41
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
42
|
+
return {
|
|
43
|
+
tools: providedTools.map((mcpTool) => mcpTool.tool),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
47
|
+
const { name, arguments: args } = request.params;
|
|
48
|
+
const mcpTool = toolMap[name];
|
|
49
|
+
if (!mcpTool) {
|
|
50
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
51
|
+
}
|
|
52
|
+
return executeHandler(mcpTool.handler, client, args);
|
|
53
|
+
});
|
|
54
|
+
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
|
55
|
+
const { level } = request.params;
|
|
56
|
+
switch (level) {
|
|
57
|
+
case 'debug':
|
|
58
|
+
client = client.withOptions({ logLevel: 'debug' });
|
|
59
|
+
break;
|
|
60
|
+
case 'info':
|
|
61
|
+
client = client.withOptions({ logLevel: 'info' });
|
|
62
|
+
break;
|
|
63
|
+
case 'notice':
|
|
64
|
+
case 'warning':
|
|
65
|
+
client = client.withOptions({ logLevel: 'warn' });
|
|
66
|
+
break;
|
|
67
|
+
case 'error':
|
|
68
|
+
client = client.withOptions({ logLevel: 'error' });
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
client = client.withOptions({ logLevel: 'off' });
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
return {};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Selects the tools to include in the MCP Server based on the provided options.
|
|
79
|
+
*/
|
|
80
|
+
export function selectTools(options) {
|
|
81
|
+
const includedTools = [codeTool()];
|
|
82
|
+
if (options?.includeDocsTools ?? true) {
|
|
83
|
+
includedTools.push(docsSearchTool);
|
|
84
|
+
}
|
|
85
|
+
return includedTools;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Runs the provided handler with the given client and arguments.
|
|
89
|
+
*/
|
|
90
|
+
export async function executeHandler(handler, client, args) {
|
|
91
|
+
return await handler(client, args || {});
|
|
92
|
+
}
|
|
93
|
+
export const readEnv = (env) => {
|
|
94
|
+
if (typeof globalThis.process !== 'undefined') {
|
|
95
|
+
return globalThis.process.env?.[env]?.trim();
|
|
96
|
+
}
|
|
97
|
+
else if (typeof globalThis.Deno !== 'undefined') {
|
|
98
|
+
return globalThis.Deno.env?.get?.(env)?.trim();
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
};
|
|
102
|
+
export const readEnvOrError = (env) => {
|
|
103
|
+
let envValue = readEnv(env);
|
|
104
|
+
if (envValue === undefined) {
|
|
105
|
+
throw new Error(`Environment variable ${env} is not set`);
|
|
106
|
+
}
|
|
107
|
+
return envValue;
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=server.mjs.map
|
package/server.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC;OAEpC,IAAI,MAAM,cAAc;OACxB,EAAE,QAAQ,EAAE;OACZ,cAAc;AAOrB,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAC/B,IAAI,SAAS,CACX;IACE,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,OAAO;CACjB,EACD,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAC7C,CAAC;AAEJ,yBAAyB;AACzB,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAI7B;IACC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,YAAY,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEzF,MAAM,UAAU,GACd,CAAC,KAA6C,EAAE,EAAE,CAClD,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QACtC,KAAK,MAAM,CAAC,kBAAkB,CAAC;YAC7B,KAAK;YACL,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;IACJ,MAAM,MAAM,GAAG;QACb,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;QACxB,IAAI,EAAE,UAAU,CAAC,SAA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,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { ClientOptions } from 'lark-billing';
|
|
4
|
+
|
|
5
|
+
export type WorkerInput = {
|
|
6
|
+
project_name: string;
|
|
7
|
+
code: string;
|
|
8
|
+
client_opts: ClientOptions;
|
|
9
|
+
};
|
|
10
|
+
export type WorkerOutput = {
|
|
11
|
+
is_error: boolean;
|
|
12
|
+
result: unknown | null;
|
|
13
|
+
log_lines: string[];
|
|
14
|
+
err_lines: string[];
|
|
15
|
+
};
|