apps 0.0.1-beta.82 → 0.0.1-beta.83
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/framework-reference.json +1 -1
- package/js/{chunk-5WGONRKQ.js → chunk-AIXYBMMI.js} +1 -1
- package/js/{chunk-WCGAO3X5.js → chunk-BX2S3T2R.js} +1 -1
- package/js/{chunk-OY47QPQY.js → chunk-HNCCRVIT.js} +39 -1
- package/js/{chunk-YQUG4CES.js → chunk-IGOYMUWZ.js} +1 -1
- package/js/{chunk-HJG4RBYM.js → chunk-JKH7ALFN.js} +1 -1
- package/js/{chunk-Z2SWTZCF.js → chunk-OHBKJ54H.js} +3 -3
- package/js/{chunk-4NFSABEA.js → chunk-T2B6GUVY.js} +2 -2
- package/js/effect.js +4 -4
- package/js/graphql.js +5 -5
- package/js/host.js +4 -4
- package/js/index.js +4 -2
- package/js/mcp/effect.js +6 -6
- package/js/mcp/stdio.js +6 -6
- package/js/mcp.js +7 -7
- package/js/openapi.js +82 -81
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/implementation/router.d.ts +8 -0
- package/types/apps/src/index.d.ts +1 -1
- package/types/apps/src/openapi.d.ts +5 -0
|
@@ -201,6 +201,43 @@ var withApprovals = (source, policy) => {
|
|
|
201
201
|
};
|
|
202
202
|
return routerDeclaration(walk(native, ""));
|
|
203
203
|
};
|
|
204
|
+
var renameTools = (source, rename) => {
|
|
205
|
+
const native = nativeRouter(source);
|
|
206
|
+
if (native?.kind !== "dynamic") throw new Error("renameTools expects a protocol router");
|
|
207
|
+
const exposed = (tools) => {
|
|
208
|
+
const seen = /* @__PURE__ */ new Set();
|
|
209
|
+
return tools.flatMap((tool) => {
|
|
210
|
+
const name = rename(tool.name);
|
|
211
|
+
if (name === void 0 || seen.has(name)) return [];
|
|
212
|
+
seen.add(name);
|
|
213
|
+
return [{ ...tool, name, source: tool.name }];
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
const listed = native.summaries ?? native.list;
|
|
217
|
+
const original = (name) => listed().pipe(Effect_exports.map((tools) => exposed(tools).find((tool) => tool.name === name)?.source));
|
|
218
|
+
const strip = ({
|
|
219
|
+
source: _source,
|
|
220
|
+
...tool
|
|
221
|
+
}) => tool;
|
|
222
|
+
return routerDeclaration({
|
|
223
|
+
...native,
|
|
224
|
+
list: () => native.list().pipe(Effect_exports.map((tools) => exposed(tools).map(strip))),
|
|
225
|
+
...native.summaries === void 0 ? {} : {
|
|
226
|
+
summaries: () => listed().pipe(Effect_exports.map((tools) => exposed(tools).map(strip)))
|
|
227
|
+
},
|
|
228
|
+
describe: (name) => original(name).pipe(
|
|
229
|
+
Effect_exports.flatMap(
|
|
230
|
+
(found) => found === void 0 ? Effect_exports.succeed(void 0) : native.describe?.(found) ?? native.list().pipe(Effect_exports.map((tools) => tools.find((tool) => tool.name === found)))
|
|
231
|
+
),
|
|
232
|
+
Effect_exports.map((tool) => tool === void 0 ? void 0 : { ...tool, name })
|
|
233
|
+
),
|
|
234
|
+
resolve: (name) => original(name).pipe(
|
|
235
|
+
Effect_exports.flatMap(
|
|
236
|
+
(found) => found === void 0 ? Effect_exports.succeed(void 0) : native.resolve(found)
|
|
237
|
+
)
|
|
238
|
+
)
|
|
239
|
+
});
|
|
240
|
+
};
|
|
204
241
|
|
|
205
242
|
export {
|
|
206
243
|
operationDeclaration,
|
|
@@ -217,5 +254,6 @@ export {
|
|
|
217
254
|
joinPath,
|
|
218
255
|
locate,
|
|
219
256
|
declaredOperations,
|
|
220
|
-
withApprovals
|
|
257
|
+
withApprovals,
|
|
258
|
+
renameTools
|
|
221
259
|
};
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
parseSkillLoadFailed,
|
|
13
13
|
readCatalog,
|
|
14
14
|
routerSkills
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JKH7ALFN.js";
|
|
16
16
|
import {
|
|
17
17
|
appInvocationFetch
|
|
18
18
|
} from "./chunk-I6Q7ZPKJ.js";
|
|
@@ -26,12 +26,12 @@ import {
|
|
|
26
26
|
makeEmitter,
|
|
27
27
|
toEffectApp,
|
|
28
28
|
withPlacements
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-AIXYBMMI.js";
|
|
30
30
|
import {
|
|
31
31
|
declaredOperations,
|
|
32
32
|
locate,
|
|
33
33
|
nativeOperation
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-HNCCRVIT.js";
|
|
35
35
|
import {
|
|
36
36
|
accountProviderError,
|
|
37
37
|
appCode,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fixedRouter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JKH7ALFN.js";
|
|
4
4
|
import {
|
|
5
5
|
nativeOperation,
|
|
6
6
|
operationDeclaration,
|
|
7
7
|
routerDeclaration
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HNCCRVIT.js";
|
|
9
9
|
|
|
10
10
|
// src/implementation/protocol-operations.ts
|
|
11
11
|
var protocolOperations = (operations, kinds = {}) => {
|
package/js/effect.js
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
ApprovalDecision,
|
|
4
4
|
createAppHandler,
|
|
5
5
|
prepareElicitation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OHBKJ54H.js";
|
|
7
7
|
import "./chunk-PL5KOEZD.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-JKH7ALFN.js";
|
|
9
9
|
import "./chunk-I6Q7ZPKJ.js";
|
|
10
10
|
import "./chunk-XBG7HHXC.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-AIXYBMMI.js";
|
|
12
|
+
import "./chunk-HNCCRVIT.js";
|
|
13
13
|
import "./chunk-W6XCQAXP.js";
|
|
14
14
|
import {
|
|
15
15
|
ToolAnnotations
|
package/js/graphql.js
CHANGED
|
@@ -4,22 +4,22 @@ import {
|
|
|
4
4
|
} from "./chunk-TE25A7D6.js";
|
|
5
5
|
import {
|
|
6
6
|
protocolOperations
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-T2B6GUVY.js";
|
|
8
8
|
import "./chunk-BCSNKUAC.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-OHBKJ54H.js";
|
|
10
10
|
import {
|
|
11
11
|
cacheKey
|
|
12
12
|
} from "./chunk-PL5KOEZD.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-JKH7ALFN.js";
|
|
14
14
|
import {
|
|
15
15
|
failOnNetworkRefusal
|
|
16
16
|
} from "./chunk-I6Q7ZPKJ.js";
|
|
17
17
|
import "./chunk-XBG7HHXC.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-AIXYBMMI.js";
|
|
19
19
|
import {
|
|
20
20
|
nativeOperation,
|
|
21
21
|
routerDeclaration
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-HNCCRVIT.js";
|
|
23
23
|
import {
|
|
24
24
|
accountProviderError,
|
|
25
25
|
graphqlProviderError,
|
package/js/host.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAppHandler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OHBKJ54H.js";
|
|
4
4
|
import "./chunk-PL5KOEZD.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-JKH7ALFN.js";
|
|
6
6
|
import "./chunk-I6Q7ZPKJ.js";
|
|
7
7
|
import "./chunk-XBG7HHXC.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-AIXYBMMI.js";
|
|
9
|
+
import "./chunk-HNCCRVIT.js";
|
|
10
10
|
import "./chunk-W6XCQAXP.js";
|
|
11
11
|
import {
|
|
12
12
|
ElicitationFailed,
|
package/js/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
query,
|
|
12
12
|
t,
|
|
13
13
|
workflow
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-AIXYBMMI.js";
|
|
15
15
|
import {
|
|
16
16
|
dynamicRouter,
|
|
17
17
|
mutation,
|
|
@@ -19,12 +19,13 @@ import {
|
|
|
19
19
|
nativeRouter,
|
|
20
20
|
operationDeclaration,
|
|
21
21
|
query as query2,
|
|
22
|
+
renameTools,
|
|
22
23
|
router,
|
|
23
24
|
routerDeclaration,
|
|
24
25
|
toolAnnotations,
|
|
25
26
|
withApproval,
|
|
26
27
|
withApprovals
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-HNCCRVIT.js";
|
|
28
29
|
import {
|
|
29
30
|
accountProviderError,
|
|
30
31
|
fromPromise
|
|
@@ -502,6 +503,7 @@ export {
|
|
|
502
503
|
query3 as query,
|
|
503
504
|
raw,
|
|
504
505
|
record,
|
|
506
|
+
renameTools,
|
|
505
507
|
router,
|
|
506
508
|
secrets2 as secrets,
|
|
507
509
|
string,
|
package/js/mcp/effect.js
CHANGED
|
@@ -2,16 +2,16 @@ import {
|
|
|
2
2
|
mcpClientEffect,
|
|
3
3
|
mcpHealthEffect,
|
|
4
4
|
mcpToolsEffect
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-BX2S3T2R.js";
|
|
6
|
+
import "../chunk-IGOYMUWZ.js";
|
|
7
7
|
import "../chunk-BCSNKUAC.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-OHBKJ54H.js";
|
|
9
9
|
import "../chunk-PL5KOEZD.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-JKH7ALFN.js";
|
|
11
11
|
import "../chunk-I6Q7ZPKJ.js";
|
|
12
12
|
import "../chunk-XBG7HHXC.js";
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-AIXYBMMI.js";
|
|
14
|
+
import "../chunk-HNCCRVIT.js";
|
|
15
15
|
import "../chunk-W6XCQAXP.js";
|
|
16
16
|
import "../chunk-NG56RPCA.js";
|
|
17
17
|
import "../chunk-Q4IZAUIF.js";
|
package/js/mcp/stdio.js
CHANGED
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
answeredError,
|
|
4
4
|
mcpClient,
|
|
5
5
|
mcpJsonSchemaValidator
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-IGOYMUWZ.js";
|
|
7
7
|
import {
|
|
8
8
|
protocolRouter
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-T2B6GUVY.js";
|
|
10
10
|
import "../chunk-BCSNKUAC.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-OHBKJ54H.js";
|
|
12
12
|
import "../chunk-PL5KOEZD.js";
|
|
13
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-JKH7ALFN.js";
|
|
14
14
|
import "../chunk-I6Q7ZPKJ.js";
|
|
15
15
|
import "../chunk-XBG7HHXC.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-AIXYBMMI.js";
|
|
17
|
+
import "../chunk-HNCCRVIT.js";
|
|
18
18
|
import "../chunk-W6XCQAXP.js";
|
|
19
19
|
import {
|
|
20
20
|
McpError,
|
package/js/mcp.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpClientEffect,
|
|
3
3
|
mcpHealthEffect
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BX2S3T2R.js";
|
|
5
5
|
import {
|
|
6
6
|
catalogCache,
|
|
7
7
|
catalogScope
|
|
8
8
|
} from "./chunk-TE25A7D6.js";
|
|
9
9
|
import {
|
|
10
10
|
adaptMcpTool
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-IGOYMUWZ.js";
|
|
12
12
|
import {
|
|
13
13
|
protocolOperations
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-T2B6GUVY.js";
|
|
15
15
|
import "./chunk-BCSNKUAC.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-OHBKJ54H.js";
|
|
17
17
|
import {
|
|
18
18
|
cacheKey
|
|
19
19
|
} from "./chunk-PL5KOEZD.js";
|
|
20
20
|
import {
|
|
21
21
|
operationDescription
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-JKH7ALFN.js";
|
|
23
23
|
import "./chunk-I6Q7ZPKJ.js";
|
|
24
24
|
import "./chunk-XBG7HHXC.js";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-AIXYBMMI.js";
|
|
26
26
|
import {
|
|
27
27
|
nativeOperation,
|
|
28
28
|
routerDeclaration
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-HNCCRVIT.js";
|
|
30
30
|
import {
|
|
31
31
|
fromPromise,
|
|
32
32
|
method
|
package/js/openapi.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
protocolOperations,
|
|
10
10
|
protocolRouter
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-T2B6GUVY.js";
|
|
12
12
|
import {
|
|
13
13
|
OpenapiCompileError,
|
|
14
14
|
OpenapiCompileErrorCode,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
isOpenapiTextMedia,
|
|
30
30
|
openapiBinaryResultSchema,
|
|
31
31
|
openapiMediaKind
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-JKH7ALFN.js";
|
|
33
33
|
import {
|
|
34
34
|
failOnNetworkRefusal
|
|
35
35
|
} from "./chunk-I6Q7ZPKJ.js";
|
|
@@ -37,7 +37,7 @@ import "./chunk-XBG7HHXC.js";
|
|
|
37
37
|
import {
|
|
38
38
|
nativeOperation,
|
|
39
39
|
routerDeclaration
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-HNCCRVIT.js";
|
|
41
41
|
import {
|
|
42
42
|
accountProviderError,
|
|
43
43
|
bodyUpstreamError,
|
|
@@ -583,6 +583,83 @@ var openapiToolsEffect = (options, prepared) => Effect_exports.gen(function* ()
|
|
|
583
583
|
return Object.fromEntries(entries);
|
|
584
584
|
});
|
|
585
585
|
|
|
586
|
+
// src/implementation/openapi-names.ts
|
|
587
|
+
var words = (value) => value.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, "$1 $2").replace(/[^a-zA-Z0-9]+/g, " ").trim().split(/\s+/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
|
|
588
|
+
var camel = (value) => {
|
|
589
|
+
const [first, ...rest] = words(value);
|
|
590
|
+
return first === void 0 ? "" : `${first}${rest.map((word) => `${word[0]?.toUpperCase() ?? ""}${word.slice(1)}`).join("")}`;
|
|
591
|
+
};
|
|
592
|
+
var pascal = (value) => {
|
|
593
|
+
const name = camel(value);
|
|
594
|
+
return `${name[0]?.toUpperCase() ?? ""}${name.slice(1)}`;
|
|
595
|
+
};
|
|
596
|
+
var version = /^v\d+(?:[._-]\d+)?$/i;
|
|
597
|
+
var segments = (path) => path.split("/").map((segment) => segment.trim()).filter((segment) => segment.length > 0);
|
|
598
|
+
var resourceSegments = (path) => segments(path).filter(
|
|
599
|
+
(segment) => !version.test(segment) && segment.toLowerCase() !== "api" && !(segment.startsWith("{") && segment.endsWith("}")) && camel(segment) !== ""
|
|
600
|
+
);
|
|
601
|
+
var groupOf = (input) => camel(input.tag ?? "") || camel(resourceSegments(input.path)[0] ?? "") || // Keep "root" for an operation on `/` or a path of only versions and parameters.
|
|
602
|
+
"root";
|
|
603
|
+
var fallbackLeaf = (input, group) => {
|
|
604
|
+
const resources = resourceSegments(input.path).map(camel);
|
|
605
|
+
const others = resources.filter((segment) => segment !== group);
|
|
606
|
+
const suffix = (others.length ? others : resources).map(pascal).join("");
|
|
607
|
+
return camel(`${input.method.toLowerCase()}${suffix || "Operation"}`);
|
|
608
|
+
};
|
|
609
|
+
var leafOf = (input, group) => {
|
|
610
|
+
if (input.operationId === void 0) return fallbackLeaf(input, group);
|
|
611
|
+
const [first, ...rest] = input.operationId.split(/[._/]+/).filter((part) => part.length > 0);
|
|
612
|
+
const seed = first !== void 0 && rest.length > 0 && camel(first).toLowerCase() === group.toLowerCase() ? rest.join(" ") : input.operationId;
|
|
613
|
+
const leaf = camel(seed);
|
|
614
|
+
return leaf === "" || leaf === group ? fallbackLeaf(input, group) : leaf;
|
|
615
|
+
};
|
|
616
|
+
var pathTokens = (path) => segments(path).flatMap((segment) => {
|
|
617
|
+
if (version.test(segment) || segment.toLowerCase() === "api") return [];
|
|
618
|
+
const parameter = segment.startsWith("{") && segment.endsWith("}");
|
|
619
|
+
const word = camel(parameter ? segment.slice(1, -1) : segment);
|
|
620
|
+
return word === "" ? [] : [{ key: `${parameter ? "{" : ""}${word}`, word, parameter }];
|
|
621
|
+
});
|
|
622
|
+
var describePath = (tokens) => tokens.map(
|
|
623
|
+
(token, index) => token.parameter ? `${tokens[index - 1]?.parameter === true ? "And" : "By"}${pascal(token.word)}` : pascal(token.word)
|
|
624
|
+
).join("");
|
|
625
|
+
var hash = (input) => {
|
|
626
|
+
const text = JSON.stringify([input.method.toUpperCase(), input.path, input.operationId ?? null]);
|
|
627
|
+
let value = 0;
|
|
628
|
+
for (let i = 0; i < text.length; i++) value = (value << 5) - value + text.charCodeAt(i) | 0;
|
|
629
|
+
return Math.abs(value).toString(36).padStart(8, "0").slice(0, 8);
|
|
630
|
+
};
|
|
631
|
+
var planOperationNames = (inputs) => {
|
|
632
|
+
const staged = inputs.map((input) => {
|
|
633
|
+
const group = groupOf(input);
|
|
634
|
+
const leaf = leafOf(input, group);
|
|
635
|
+
const versionSegment = segments(input.path).map((segment) => segment.toLowerCase()).find((segment) => version.test(segment));
|
|
636
|
+
const prefix = versionSegment === void 0 ? group : `${group}.${camel(versionSegment)}`;
|
|
637
|
+
const tokens = pathTokens(input.path);
|
|
638
|
+
return { input, group, leaf, prefix, versionSegment, tokens, name: `${group}.${leaf}` };
|
|
639
|
+
});
|
|
640
|
+
const refine = (rename) => {
|
|
641
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
642
|
+
for (const item of staged) buckets.set(item.name, [...buckets.get(item.name) ?? [], item]);
|
|
643
|
+
for (const bucket of buckets.values())
|
|
644
|
+
if (bucket.length > 1) {
|
|
645
|
+
const names = bucket.map((item) => rename(item, bucket));
|
|
646
|
+
for (const [index, item] of bucket.entries()) item.name = names[index] ?? item.name;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
refine((item) => item.versionSegment === void 0 ? item.name : `${item.prefix}.${item.leaf}`);
|
|
650
|
+
refine((item, bucket) => {
|
|
651
|
+
const shared = new Set(
|
|
652
|
+
item.tokens.map((token) => token.key).filter((key) => bucket.every((other) => other.tokens.some((token) => token.key === key)))
|
|
653
|
+
);
|
|
654
|
+
const distinct = item.tokens.filter((token) => !shared.has(token.key));
|
|
655
|
+
return distinct.length === 0 ? item.name : `${item.prefix}.${item.leaf}${describePath(distinct)}`;
|
|
656
|
+
});
|
|
657
|
+
refine((item) => `${item.prefix}.${item.leaf}${describePath(item.tokens)}`);
|
|
658
|
+
refine((item) => `${item.prefix}.${item.leaf}${pascal(item.input.method)}`);
|
|
659
|
+
refine((item) => `${item.prefix}.${item.leaf}${pascal(item.input.method)}${hash(item.input)}`);
|
|
660
|
+
return staged.map((item) => ({ ...item.input, name: item.name }));
|
|
661
|
+
};
|
|
662
|
+
|
|
586
663
|
// ../../node_modules/.bun/js-yaml@5.4.2/node_modules/js-yaml/dist/js-yaml.mjs
|
|
587
664
|
var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
|
|
588
665
|
function defineScalarTag(tagName, options) {
|
|
@@ -4319,83 +4396,6 @@ async function openApiDocument(input) {
|
|
|
4319
4396
|
};
|
|
4320
4397
|
}
|
|
4321
4398
|
|
|
4322
|
-
// src/implementation/openapi-names.ts
|
|
4323
|
-
var words = (value) => value.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, "$1 $2").replace(/[^a-zA-Z0-9]+/g, " ").trim().split(/\s+/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
|
|
4324
|
-
var camel = (value) => {
|
|
4325
|
-
const [first, ...rest] = words(value);
|
|
4326
|
-
return first === void 0 ? "" : `${first}${rest.map((word) => `${word[0]?.toUpperCase() ?? ""}${word.slice(1)}`).join("")}`;
|
|
4327
|
-
};
|
|
4328
|
-
var pascal = (value) => {
|
|
4329
|
-
const name = camel(value);
|
|
4330
|
-
return `${name[0]?.toUpperCase() ?? ""}${name.slice(1)}`;
|
|
4331
|
-
};
|
|
4332
|
-
var version = /^v\d+(?:[._-]\d+)?$/i;
|
|
4333
|
-
var segments = (path) => path.split("/").map((segment) => segment.trim()).filter((segment) => segment.length > 0);
|
|
4334
|
-
var resourceSegments = (path) => segments(path).filter(
|
|
4335
|
-
(segment) => !version.test(segment) && segment.toLowerCase() !== "api" && !(segment.startsWith("{") && segment.endsWith("}")) && camel(segment) !== ""
|
|
4336
|
-
);
|
|
4337
|
-
var groupOf = (input) => camel(input.tag ?? "") || camel(resourceSegments(input.path)[0] ?? "") || // Keep "root" for an operation on `/` or a path of only versions and parameters.
|
|
4338
|
-
"root";
|
|
4339
|
-
var fallbackLeaf = (input, group) => {
|
|
4340
|
-
const resources = resourceSegments(input.path).map(camel);
|
|
4341
|
-
const others = resources.filter((segment) => segment !== group);
|
|
4342
|
-
const suffix = (others.length ? others : resources).map(pascal).join("");
|
|
4343
|
-
return camel(`${input.method.toLowerCase()}${suffix || "Operation"}`);
|
|
4344
|
-
};
|
|
4345
|
-
var leafOf = (input, group) => {
|
|
4346
|
-
if (input.operationId === void 0) return fallbackLeaf(input, group);
|
|
4347
|
-
const [first, ...rest] = input.operationId.split(/[._/]+/).filter((part) => part.length > 0);
|
|
4348
|
-
const seed = first !== void 0 && rest.length > 0 && camel(first).toLowerCase() === group.toLowerCase() ? rest.join(" ") : input.operationId;
|
|
4349
|
-
const leaf = camel(seed);
|
|
4350
|
-
return leaf === "" || leaf === group ? fallbackLeaf(input, group) : leaf;
|
|
4351
|
-
};
|
|
4352
|
-
var pathTokens = (path) => segments(path).flatMap((segment) => {
|
|
4353
|
-
if (version.test(segment) || segment.toLowerCase() === "api") return [];
|
|
4354
|
-
const parameter = segment.startsWith("{") && segment.endsWith("}");
|
|
4355
|
-
const word = camel(parameter ? segment.slice(1, -1) : segment);
|
|
4356
|
-
return word === "" ? [] : [{ key: `${parameter ? "{" : ""}${word}`, word, parameter }];
|
|
4357
|
-
});
|
|
4358
|
-
var describePath = (tokens) => tokens.map(
|
|
4359
|
-
(token, index) => token.parameter ? `${tokens[index - 1]?.parameter === true ? "And" : "By"}${pascal(token.word)}` : pascal(token.word)
|
|
4360
|
-
).join("");
|
|
4361
|
-
var hash = (input) => {
|
|
4362
|
-
const text = JSON.stringify([input.method.toUpperCase(), input.path, input.operationId ?? null]);
|
|
4363
|
-
let value = 0;
|
|
4364
|
-
for (let i = 0; i < text.length; i++) value = (value << 5) - value + text.charCodeAt(i) | 0;
|
|
4365
|
-
return Math.abs(value).toString(36).padStart(8, "0").slice(0, 8);
|
|
4366
|
-
};
|
|
4367
|
-
var planOperationNames = (inputs) => {
|
|
4368
|
-
const staged = inputs.map((input) => {
|
|
4369
|
-
const group = groupOf(input);
|
|
4370
|
-
const leaf = leafOf(input, group);
|
|
4371
|
-
const versionSegment = segments(input.path).map((segment) => segment.toLowerCase()).find((segment) => version.test(segment));
|
|
4372
|
-
const prefix = versionSegment === void 0 ? group : `${group}.${camel(versionSegment)}`;
|
|
4373
|
-
const tokens = pathTokens(input.path);
|
|
4374
|
-
return { input, group, leaf, prefix, versionSegment, tokens, name: `${group}.${leaf}` };
|
|
4375
|
-
});
|
|
4376
|
-
const refine = (rename) => {
|
|
4377
|
-
const buckets = /* @__PURE__ */ new Map();
|
|
4378
|
-
for (const item of staged) buckets.set(item.name, [...buckets.get(item.name) ?? [], item]);
|
|
4379
|
-
for (const bucket of buckets.values())
|
|
4380
|
-
if (bucket.length > 1) {
|
|
4381
|
-
const names = bucket.map((item) => rename(item, bucket));
|
|
4382
|
-
for (const [index, item] of bucket.entries()) item.name = names[index] ?? item.name;
|
|
4383
|
-
}
|
|
4384
|
-
};
|
|
4385
|
-
refine((item) => item.versionSegment === void 0 ? item.name : `${item.prefix}.${item.leaf}`);
|
|
4386
|
-
refine((item, bucket) => {
|
|
4387
|
-
const shared = new Set(
|
|
4388
|
-
item.tokens.map((token) => token.key).filter((key) => bucket.every((other) => other.tokens.some((token) => token.key === key)))
|
|
4389
|
-
);
|
|
4390
|
-
const distinct = item.tokens.filter((token) => !shared.has(token.key));
|
|
4391
|
-
return distinct.length === 0 ? item.name : `${item.prefix}.${item.leaf}${describePath(distinct)}`;
|
|
4392
|
-
});
|
|
4393
|
-
refine((item) => `${item.prefix}.${item.leaf}${describePath(item.tokens)}`);
|
|
4394
|
-
refine((item) => `${item.prefix}.${item.leaf}${pascal(item.input.method)}`);
|
|
4395
|
-
refine((item) => `${item.prefix}.${item.leaf}${pascal(item.input.method)}${hash(item.input)}`);
|
|
4396
|
-
return staged.map((item) => ({ ...item.input, name: item.name }));
|
|
4397
|
-
};
|
|
4398
|
-
|
|
4399
4399
|
// src/implementation/openapi-compile.ts
|
|
4400
4400
|
function fail2(code, reason) {
|
|
4401
4401
|
throw new OpenapiCompileError({ code, reason });
|
|
@@ -5849,7 +5849,8 @@ export {
|
|
|
5849
5849
|
openapiBinaryResultSchema,
|
|
5850
5850
|
openapiMediaKind,
|
|
5851
5851
|
openapiRouter,
|
|
5852
|
-
openapiToolNames
|
|
5852
|
+
openapiToolNames,
|
|
5853
|
+
planOperationNames
|
|
5853
5854
|
};
|
|
5854
5855
|
/*! Bundled license information:
|
|
5855
5856
|
|