@sdk-it/spec 0.46.10 → 0.47.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/README.md +8 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +2 -2
- package/dist/lib/external-documents.d.ts +10 -0
- package/dist/lib/external-documents.d.ts.map +1 -0
- package/dist/lib/external-documents.js +61 -0
- package/dist/lib/external-documents.js.map +7 -0
- package/dist/lib/finalize-operations.d.ts +8 -0
- package/dist/lib/finalize-operations.d.ts.map +1 -0
- package/dist/lib/finalize-operations.js +134 -0
- package/dist/lib/finalize-operations.js.map +7 -0
- package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
- package/dist/lib/find-polymorphic-varients.js +3 -2
- package/dist/lib/find-polymorphic-varients.js.map +2 -2
- package/dist/lib/find-unique-schema-name.d.ts.map +1 -1
- package/dist/lib/for-each-operation.d.ts +3 -2
- package/dist/lib/for-each-operation.d.ts.map +1 -1
- package/dist/lib/for-each-operation.js +9 -4
- package/dist/lib/for-each-operation.js.map +2 -2
- package/dist/lib/format-name.d.ts.map +1 -1
- package/dist/lib/get-ref-usage.d.ts.map +1 -1
- package/dist/lib/get-ref-usage.js +1 -2
- package/dist/lib/get-ref-usage.js.map +2 -2
- package/dist/lib/guess/guess-resource.d.ts.map +1 -1
- package/dist/lib/guess/guess-resource.js +4 -4
- package/dist/lib/guess/guess-resource.js.map +2 -2
- package/dist/lib/ir.d.ts +2 -2
- package/dist/lib/ir.d.ts.map +1 -1
- package/dist/lib/ir.js +5 -3
- package/dist/lib/ir.js.map +2 -2
- package/dist/lib/is-primitive-schema.d.ts +12 -0
- package/dist/lib/is-primitive-schema.d.ts.map +1 -1
- package/dist/lib/is-primitive-schema.js +34 -1
- package/dist/lib/is-primitive-schema.js.map +2 -2
- package/dist/lib/is.d.ts +10 -1
- package/dist/lib/is.d.ts.map +1 -1
- package/dist/lib/is.js +20 -9
- package/dist/lib/is.js.map +2 -2
- package/dist/lib/loaders/load-spec.d.ts +9 -2
- package/dist/lib/loaders/load-spec.d.ts.map +1 -1
- package/dist/lib/loaders/load-spec.js +15 -20
- package/dist/lib/loaders/load-spec.js.map +2 -2
- package/dist/lib/loaders/local-loader.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.d.ts +1 -1
- package/dist/lib/loaders/postman/postman-converter.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.js +2 -3
- package/dist/lib/loaders/postman/postman-converter.js.map +2 -2
- package/dist/lib/loaders/postman/spec-types.d.ts.map +1 -1
- package/dist/lib/loaders/remote-loader.d.ts.map +1 -1
- package/dist/lib/loaders/remote-loader.js +4 -3
- package/dist/lib/loaders/remote-loader.js.map +2 -2
- package/dist/lib/metadata.d.ts +3 -9
- package/dist/lib/metadata.d.ts.map +1 -1
- package/dist/lib/metadata.js +22 -17
- package/dist/lib/metadata.js.map +2 -2
- package/dist/lib/operation-input.d.ts +33 -0
- package/dist/lib/operation-input.d.ts.map +1 -0
- package/dist/lib/operation-input.js +189 -0
- package/dist/lib/operation-input.js.map +7 -0
- package/dist/lib/options.d.ts +5 -6
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +0 -6
- package/dist/lib/options.js.map +2 -2
- package/dist/lib/overview-docs/doc-text-utils.d.ts +13 -13
- package/dist/lib/overview-docs/doc-text-utils.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-auth.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-auth.js.map +2 -2
- package/dist/lib/overview-docs/overview-docs.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-errors.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-errors.js +8 -5
- package/dist/lib/overview-docs/overview-errors.js.map +2 -2
- package/dist/lib/overview-docs/overview-page.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-page.js +2 -3
- package/dist/lib/overview-docs/overview-page.js.map +2 -2
- package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-sdks.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-sdks.js +2 -1
- package/dist/lib/overview-docs/overview-sdks.js.map +2 -2
- package/dist/lib/overview-docs/types.d.ts.map +1 -1
- package/dist/lib/overview-docs/types.js +1 -1
- package/dist/lib/overview-docs/types.js.map +2 -2
- package/dist/lib/pagination/guess-pagination.d.ts.map +1 -1
- package/dist/lib/pagination/guess-pagination.js.map +2 -2
- package/dist/lib/pagination/pagination-result.d.ts +3 -3
- package/dist/lib/pagination/pagination-result.d.ts.map +1 -1
- package/dist/lib/pagination/pagination-result.js +6 -3
- package/dist/lib/pagination/pagination-result.js.map +2 -2
- package/dist/lib/pagination/pagination.d.ts +31 -1
- package/dist/lib/pagination/pagination.d.ts.map +1 -1
- package/dist/lib/pagination/pagination.js +30 -11
- package/dist/lib/pagination/pagination.js.map +2 -2
- package/dist/lib/processing-plugins/bundle-external-refs.d.ts +17 -0
- package/dist/lib/processing-plugins/bundle-external-refs.d.ts.map +1 -0
- package/dist/lib/processing-plugins/bundle-external-refs.js +241 -0
- package/dist/lib/processing-plugins/bundle-external-refs.js.map +7 -0
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts +2 -2
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts.map +1 -1
- package/dist/lib/processing-plugins/canonicalize-spec.js.map +2 -2
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts +4 -3
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts.map +1 -1
- package/dist/lib/processing-plugins/create-default-processing-plugins.js +10 -3
- package/dist/lib/processing-plugins/create-default-processing-plugins.js.map +2 -2
- package/dist/lib/processing-plugins/enrich-examples.d.ts +4 -4
- package/dist/lib/processing-plugins/enrich-examples.d.ts.map +1 -1
- package/dist/lib/processing-plugins/enrich-examples.js +1 -1
- package/dist/lib/processing-plugins/enrich-examples.js.map +2 -2
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts +2 -2
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts.map +1 -1
- package/dist/lib/processing-plugins/extract-inline-schemas.js.map +2 -2
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts +2 -2
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts.map +1 -1
- package/dist/lib/processing-plugins/extract-overview-docs.js +4 -1
- package/dist/lib/processing-plugins/extract-overview-docs.js.map +2 -2
- package/dist/lib/processing-plugins/index.d.ts +1 -0
- package/dist/lib/processing-plugins/index.d.ts.map +1 -1
- package/dist/lib/processing-plugins/index.js +1 -0
- package/dist/lib/processing-plugins/index.js.map +2 -2
- package/dist/lib/processing-plugins/infer-pagination.d.ts +2 -2
- package/dist/lib/processing-plugins/infer-pagination.d.ts.map +1 -1
- package/dist/lib/processing-plugins/infer-pagination.js +5 -6
- package/dist/lib/processing-plugins/infer-pagination.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-operation-ids.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-parameters.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-parameters.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-parameters.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-paths.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-paths.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-paths.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts +9 -3
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-request-bodies.js +36 -15
- package/dist/lib/processing-plugins/normalize-request-bodies.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-responses.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-responses.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-responses.js +11 -15
- package/dist/lib/processing-plugins/normalize-responses.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-schemas.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-schemas.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-schemas.js +14 -4
- package/dist/lib/processing-plugins/normalize-schemas.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-security.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-security.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-security.js +6 -5
- package/dist/lib/processing-plugins/normalize-security.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-tags.d.ts +8 -2
- package/dist/lib/processing-plugins/normalize-tags.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-tags.js +35 -1
- package/dist/lib/processing-plugins/normalize-tags.js.map +2 -2
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.d.ts +13 -2
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.d.ts.map +1 -1
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.js +68 -90
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.js.map +2 -2
- package/dist/lib/processing.d.ts +25 -11
- package/dist/lib/processing.d.ts.map +1 -1
- package/dist/lib/processing.js +53 -16
- package/dist/lib/processing.js.map +2 -2
- package/dist/lib/reserved-keywords.d.ts.map +1 -1
- package/dist/lib/sidebar.d.ts +5 -4
- package/dist/lib/sidebar.d.ts.map +1 -1
- package/dist/lib/sidebar.js +46 -23
- package/dist/lib/sidebar.js.map +2 -2
- package/dist/lib/tag.d.ts.map +1 -1
- package/dist/lib/types.d.ts +34 -12
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +11 -0
- package/dist/lib/types.js.map +3 -3
- package/dist/lib/walk-schemas.d.ts +4 -2
- package/dist/lib/walk-schemas.d.ts.map +1 -1
- package/dist/lib/walk-schemas.js +15 -13
- package/dist/lib/walk-schemas.js.map +2 -2
- package/package.json +17 -6
- package/dist/lib/create-operation.d.ts +0 -28
- package/dist/lib/create-operation.d.ts.map +0 -1
- package/dist/lib/create-operation.js +0 -62
- package/dist/lib/create-operation.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-auth.d.ts","
|
|
1
|
+
{"version":3,"file":"overview-auth.d.ts","sources":["../../../src/lib/overview-docs/overview-auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AA6FtC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAmDtD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/overview-docs/overview-auth.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OAuthFlowsObject
|
|
5
|
-
"mappings": "AAEA,
|
|
4
|
+
"sourcesContent": ["import type { OAuthFlowsObject } from 'openapi3-ts/oas31';\n\nimport { type OpenAPISecuritySchemeObject, resolveRef } from '@sdk-it/core';\n\nimport type { NavItem } from '../sidebar.js';\nimport type { IR } from '../types.js';\nimport {\n getAuthIntroText,\n getTextByCount,\n presetDocs,\n} from './doc-text-utils.js';\n\nfunction getSecuritySchemeDescription(\n scheme: OpenAPISecuritySchemeObject,\n): string {\n switch (scheme.type) {\n case 'apiKey': {\n const location =\n scheme.in === 'header'\n ? 'HTTP header'\n : scheme.in === 'query'\n ? 'query parameter'\n : 'cookie';\n return `API Key authentication requires you to provide an API key in the ${location} named \\`${scheme.name}\\`.`;\n }\n case 'http':\n if (scheme.scheme === 'bearer') {\n const format = scheme.bearerFormat\n ? ` The expected token format is \\`${scheme.bearerFormat}\\`.`\n : '';\n return `Bearer token authentication requires you to include a bearer token in the \\`Authorization\\` header of your requests.${format}`;\n }\n if (scheme.scheme === 'basic') {\n return `Basic authentication requires you to provide a username and password, encoded in base64 format in the \\`Authorization\\` header.`;\n }\n return `HTTP ${scheme.scheme} authentication is required for accessing this API.`;\n case 'oauth2': {\n const flows = Object.keys(scheme.flows || {});\n const flowDescriptions = flows.map((flow) => {\n switch (flow) {\n case 'authorizationCode':\n return 'Authorization Code (for server-side applications)';\n case 'implicit':\n return 'Implicit (for browser-based applications)';\n case 'password':\n return 'Resource Owner Password Credentials';\n case 'clientCredentials':\n return 'Client Credentials (for machine-to-machine authentication)';\n default:\n return flow;\n }\n });\n return `OAuth 2.0 authentication is supported with the following grant type(s): ${flowDescriptions.join(', ')}.`;\n }\n case 'openIdConnect':\n return `OpenID Connect authentication is used for this API. You will need to authenticate through the OpenID provider to obtain access tokens.`;\n default:\n return 'This API uses a custom authentication scheme. Please refer to the API documentation for specific details.';\n }\n}\n\nfunction formatOAuth2Flows(flows: OAuthFlowsObject): string {\n let result = '';\n\n for (const [flowType, flow] of Object.entries(flows || {})) {\n result += `#### ${getFlowDisplayName(flowType)}\\n\\n`;\n\n if (flow.authorizationUrl) {\n result += `- **Authorization URL:** \\`${flow.authorizationUrl}\\`\\n`;\n }\n if (flow.tokenUrl) {\n result += `- **Token URL:** \\`${flow.tokenUrl}\\`\\n`;\n }\n if (flow.refreshUrl) {\n result += `- **Refresh URL:** \\`${flow.refreshUrl}\\`\\n`;\n }\n if (flow.scopes && Object.keys(flow.scopes).length > 0) {\n result += `- **Available Scopes:**\\n`;\n for (const [scope, description] of Object.entries(flow.scopes)) {\n result += ` - \\`${scope}\\`: ${description}\\n`;\n }\n }\n result += '\\n';\n }\n\n return result;\n}\n\nfunction getFlowDisplayName(flowType: string): string {\n const flowNames: Record<string, string> = {\n authorizationCode: 'Authorization Code Flow',\n implicit: 'Implicit Flow',\n password: 'Resource Owner Password Flow',\n clientCredentials: 'Client Credentials Flow',\n };\n return flowNames[flowType] || flowType;\n}\n\nexport function generateAuthOverview(spec: IR): NavItem {\n let markdown = `# Authentication\\n\\n`;\n\n const securitySchemes = spec.components.securitySchemes;\n const globalSecurity = spec.security || [];\n\n const authMethodCount = Object.keys(securitySchemes).length;\n if (!authMethodCount && !globalSecurity.length) {\n markdown += `This API does not require authentication.\\n\\n`;\n } else {\n if (authMethodCount > 1) {\n markdown += `${getAuthIntroText(authMethodCount)}\\n\\n`;\n markdown += `## ${getTextByCount(authMethodCount, presetDocs.auth.section)}\\n\\n`;\n }\n\n for (const [name, scheme] of Object.entries(securitySchemes)) {\n const schemeObj = resolveRef<OpenAPISecuritySchemeObject>(spec, scheme);\n if (authMethodCount > 1) {\n markdown += `### ${name}\\n\\n`;\n }\n\n const description =\n schemeObj.description || getSecuritySchemeDescription(schemeObj);\n markdown += `${description}\\n\\n`;\n\n if (schemeObj.type === 'apiKey') {\n markdown += `**Details:**\\n`;\n markdown += `- Parameter Name: \\`${schemeObj.name}\\`\\n`;\n markdown += `- Location: ${schemeObj.in === 'header' ? 'HTTP Header' : schemeObj.in === 'query' ? 'Query Parameter' : 'Cookie'}\\n\\n`;\n } else if (schemeObj.type === 'http') {\n if (schemeObj.bearerFormat) {\n markdown += `- Token Format: \\`${schemeObj.bearerFormat}\\`\\n`;\n }\n markdown += '\\n';\n } else if (schemeObj.type === 'oauth2' && schemeObj.flows) {\n markdown += `**OAuth 2.0 Flows:**\\n\\n`;\n markdown += formatOAuth2Flows(schemeObj.flows);\n } else if (schemeObj.type === 'openIdConnect') {\n markdown += `**Details:**\\n`;\n markdown += `- Discovery URL: \\`${schemeObj.openIdConnectUrl}\\`\\n\\n`;\n }\n }\n }\n\n return {\n id: 'authorization',\n url: '/authorization',\n title: 'Authorization',\n description: 'Authentication methods and security schemes',\n content: markdown,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAA2C,kBAAkB;AAI7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,6BACP,QACQ;AACR,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,UAAU;AACb,YAAM,WACJ,OAAO,OAAO,WACV,gBACA,OAAO,OAAO,UACZ,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;AACpC,YAAI,UAAU,cAAc;AAC1B,sBAAY,qBAAqB,UAAU,YAAY;AAAA;AAAA,QACzD;AACA,oBAAY;AAAA,MACd,WAAW,UAAU,SAAS,YAAY,UAAU,OAAO;AACzD,oBAAY;AAAA;AAAA;AACZ,oBAAY,kBAAkB,UAAU,KAAK;AAAA,MAC/C,WAAW,UAAU,SAAS,iBAAiB;AAC7C,oBAAY;AAAA;AACZ,oBAAY,sBAAsB,UAAU,gBAAgB;AAAA;AAAA;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-docs.d.ts","
|
|
1
|
+
{"version":3,"file":"overview-docs.d.ts","sources":["../../../src/lib/overview-docs/overview-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAItC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAIhD,CAAC;AAEH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,EACR,KAAK,EAAE,iBAAiB,GACvB,WAAW,CAyBb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-errors.d.ts","
|
|
1
|
+
{"version":3,"file":"overview-errors.d.ts","sources":["../../../src/lib/overview-docs/overview-errors.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAkGtC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CA6ExD"}
|
|
@@ -50,7 +50,7 @@ function getStatusDescription(statusCode) {
|
|
|
50
50
|
"510": "Not Extended - Further extensions to the request are required for the server to fulfill it.",
|
|
51
51
|
"511": "Network Authentication Required - The client needs to authenticate to gain network access."
|
|
52
52
|
};
|
|
53
|
-
return descriptions[statusCode]
|
|
53
|
+
return descriptions[statusCode];
|
|
54
54
|
}
|
|
55
55
|
function generateErrorsOverview(spec) {
|
|
56
56
|
const errorSchemas = /* @__PURE__ */ new Map();
|
|
@@ -77,7 +77,6 @@ function generateErrorsOverview(spec) {
|
|
|
77
77
|
} else {
|
|
78
78
|
errorSchemas.set(key, {
|
|
79
79
|
statusCode,
|
|
80
|
-
title: response.description || `${statusCode} Error`,
|
|
81
80
|
description: response.description,
|
|
82
81
|
schema: content["application/json"].schema,
|
|
83
82
|
operations: [operation.operationId]
|
|
@@ -97,9 +96,13 @@ function generateErrorsOverview(spec) {
|
|
|
97
96
|
);
|
|
98
97
|
} else {
|
|
99
98
|
for (const error of errors) {
|
|
100
|
-
markdown.push(
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
markdown.push(
|
|
100
|
+
error.description ? `### ${error.statusCode} - ${error.description}` : `### ${error.statusCode}`
|
|
101
|
+
);
|
|
102
|
+
const description = error.description || getStatusDescription(error.statusCode);
|
|
103
|
+
if (description) {
|
|
104
|
+
markdown.push(description);
|
|
105
|
+
}
|
|
103
106
|
if (error.schema) {
|
|
104
107
|
markdown.push(`**Response Schema:**`);
|
|
105
108
|
markdown.push(formatSchemaForDisplay(spec, error.schema));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/overview-docs/overview-errors.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { distillRef } from '@sdk-it/core';\n\nimport { forEachOperation } from '../for-each-operation.js';\nimport { isErrorStatusCode } from '../is.js';\nimport type { NavItem } from '../sidebar.js';\nimport type { IR } from '../types.js';\n\ninterface ErrorSchema {\n statusCode: string;\n
|
|
5
|
-
"mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;
|
|
4
|
+
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { distillRef } from '@sdk-it/core';\n\nimport { forEachOperation } from '../for-each-operation.js';\nimport { isErrorStatusCode } from '../is.js';\nimport type { NavItem } from '../sidebar.js';\nimport type { IR } from '../types.js';\n\ninterface ErrorSchema {\n statusCode: string;\n description: string;\n schema: SchemaObject | ReferenceObject;\n operations: string[]; // Track which operations use this error\n}\n\nfunction formatSchemaForDisplay(\n spec: IR,\n schema: SchemaObject | ReferenceObject,\n): string {\n const resolvedSchema = distillRef(spec, schema);\n\n return `\\`\\`\\`json\n${JSON.stringify(resolvedSchema, null, 2)}\n\\`\\`\\``;\n}\n\nfunction getStatusDescription(statusCode: string): string | undefined {\n const descriptions: Record<string, string> = {\n '400': 'Bad Request - The request was invalid or cannot be served.',\n '401':\n 'Unauthorized - Authentication is required and has failed or has not been provided.',\n '402': 'Payment Required - Payment is required to access this resource.',\n '403':\n 'Forbidden - The request was valid, but the server is refusing action.',\n '404': 'Not Found - The requested resource could not be found.',\n '405':\n 'Method Not Allowed - The request method is not supported for this resource.',\n '406':\n 'Not Acceptable - The requested resource cannot generate content acceptable to the client.',\n '407':\n 'Proxy Authentication Required - Authentication with the proxy is required.',\n '408': 'Request Timeout - The server timed out waiting for the request.',\n '409': 'Conflict - The request could not be completed due to a conflict.',\n '410': 'Gone - The requested resource is no longer available.',\n '411':\n 'Length Required - The request did not specify the length of its content.',\n '412':\n 'Precondition Failed - The server does not meet one of the preconditions.',\n '413':\n 'Payload Too Large - The request is larger than the server is willing to process.',\n '414':\n 'URI Too Long - The URI provided was too long for the server to process.',\n '415':\n 'Unsupported Media Type - The request entity has a media type which the server does not support.',\n '416':\n 'Range Not Satisfiable - The client has asked for a portion of the file that the server cannot supply.',\n '417':\n 'Expectation Failed - The server cannot meet the requirements of the Expect request-header field.',\n '418':\n \"I'm a teapot - The server refuses the attempt to brew coffee with a teapot.\",\n '421':\n 'Misdirected Request - The request was directed at a server that is not able to produce a response.',\n '422':\n 'Unprocessable Entity - The request was well-formed but contains semantic errors.',\n '423': 'Locked - The resource that is being accessed is locked.',\n '424':\n 'Failed Dependency - The request failed due to failure of a previous request.',\n '425':\n 'Too Early - The server is unwilling to risk processing a request that might be replayed.',\n '426':\n 'Upgrade Required - The client should switch to a different protocol.',\n '428':\n 'Precondition Required - The origin server requires the request to be conditional.',\n '429':\n 'Too Many Requests - The user has sent too many requests in a given amount of time.',\n '431':\n 'Request Header Fields Too Large - The server is unwilling to process the request because header fields are too large.',\n '451':\n 'Unavailable For Legal Reasons - The server is denying access to the resource for legal reasons.',\n '500':\n 'Internal Server Error - The server encountered an unexpected condition.',\n '501':\n 'Not Implemented - The server does not support the functionality required to fulfill the request.',\n '502':\n 'Bad Gateway - The server received an invalid response from the upstream server.',\n '503': 'Service Unavailable - The server is currently unavailable.',\n '504':\n 'Gateway Timeout - The server did not receive a timely response from the upstream server.',\n '505':\n 'HTTP Version Not Supported - The server does not support the HTTP protocol version used in the request.',\n '506':\n 'Variant Also Negotiates - The server has an internal configuration error.',\n '507':\n 'Insufficient Storage - The server is unable to store the representation needed to complete the request.',\n '508':\n 'Loop Detected - The server detected an infinite loop while processing the request.',\n '510':\n 'Not Extended - Further extensions to the request are required for the server to fulfill it.',\n '511':\n 'Network Authentication Required - The client needs to authenticate to gain network access.',\n };\n return descriptions[statusCode];\n}\n\nexport function generateErrorsOverview(spec: IR): NavItem {\n const errorSchemas: Map<string, ErrorSchema> = new Map();\n const markdown: string[] = [];\n markdown.push(`# Error Handling`);\n markdown.push(\n `This API uses conventional HTTP response codes to indicate the success or failure of an API request.`,\n );\n\n markdown.push(`## HTTP Status Codes`);\n\n // First, collect all error schemas from operations\n forEachOperation(spec, (entry, operation) => {\n if (operation.responses) {\n for (const [statusCode, response] of Object.entries(\n operation.responses,\n )) {\n if (isErrorStatusCode(statusCode)) {\n const content = response.content;\n if (content?.['application/json']?.schema) {\n const key = `${statusCode}`;\n if (errorSchemas.has(key)) {\n const existing = errorSchemas.get(key);\n if (\n existing &&\n !existing.operations.includes(operation.operationId)\n ) {\n existing.operations.push(operation.operationId);\n }\n } else {\n errorSchemas.set(key, {\n statusCode,\n description: response.description,\n schema: content['application/json'].schema,\n operations: [operation.operationId],\n });\n }\n }\n }\n }\n }\n });\n\n const errors = Array.from(errorSchemas.values()).sort(\n (a, b) => parseInt(a.statusCode) - parseInt(b.statusCode),\n );\n\n if (errors.length === 0) {\n markdown.push(\n `No error responses are documented in this API specification.`,\n );\n } else {\n for (const error of errors) {\n markdown.push(\n error.description\n ? `### ${error.statusCode} - ${error.description}`\n : `### ${error.statusCode}`,\n );\n const description =\n error.description || getStatusDescription(error.statusCode);\n if (description) {\n markdown.push(description);\n }\n\n if (error.schema) {\n markdown.push(`**Response Schema:**`);\n markdown.push(formatSchemaForDisplay(spec, error.schema));\n }\n }\n }\n\n return {\n id: 'errors',\n title: 'Errors',\n url: '/errors',\n description: 'Error handling and HTTP status codes',\n content: markdown.join('\\n\\n'),\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAWlC,SAAS,uBACP,MACA,QACQ;AACR,QAAM,iBAAiB,WAAW,MAAM,MAAM;AAE9C,SAAO;AAAA,EACP,KAAK,UAAU,gBAAgB,MAAM,CAAC,CAAC;AAAA;AAEzC;AAEA,SAAS,qBAAqB,YAAwC;AACpE,QAAM,eAAuC;A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W,SAAS,UAAU,WAAW,GACnD;AACA,yBAAS,WAAW,KAAK,UAAU,WAAW;AAAA,cAChD;AAAA,YACF,OAAO;AACL,2BAAa,IAAI,KAAK;AAAA,gBACpB;AAAA,gBACA,aAAa,SAAS;AAAA,gBACtB,QAAQ,QAAQ,kBAAkB,EAAE;AAAA,gBACpC,YAAY,CAAC,UAAU,WAAW;AAAA,cACpC,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,SAAS,MAAM,KAAK,aAAa,OAAO,CAAC,EAAE;AAAA,IAC/C,CAAC,GAAG,MAAM,SAAS,EAAE,UAAU,IAAI,SAAS,EAAE,UAAU;AAAA,EAC1D;AAEA,MAAI,OAAO,WAAW,GAAG;AACvB,aAAS;AAAA,MACP;AAAA,IACF;AAAA,EACF,OAAO;AACL,eAAW,SAAS,QAAQ;AAC1B,eAAS;AAAA,QACP,MAAM,cACF,OAAO,MAAM,UAAU,MAAM,MAAM,WAAW,KAC9C,OAAO,MAAM,UAAU;AAAA,MAC7B;AACA,YAAM,cACJ,MAAM,eAAe,qBAAqB,MAAM,UAAU;AAC5D,UAAI,aAAa;AACf,iBAAS,KAAK,WAAW;AAAA,MAC3B;AAEA,UAAI,MAAM,QAAQ;AAChB,iBAAS,KAAK,sBAAsB;AACpC,iBAAS,KAAK,uBAAuB,MAAM,MAAM,MAAM,CAAC;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,IACb,SAAS,SAAS,KAAK,MAAM;AAAA,EAC/B;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-page.d.ts","
|
|
1
|
+
{"version":3,"file":"overview-page.d.ts","sources":["../../../src/lib/overview-docs/overview-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAyEtE"}
|
|
@@ -2,8 +2,7 @@ import { getTextByCount, presetDocs } from "./doc-text-utils.js";
|
|
|
2
2
|
import { generateSdkSection } from "./overview-sdks.js";
|
|
3
3
|
function generateOverviewPage(spec, sdks) {
|
|
4
4
|
const info = spec.info;
|
|
5
|
-
const
|
|
6
|
-
const markdown = [`# ${apiTitle}`];
|
|
5
|
+
const markdown = info.title ? [`# ${info.title}`] : [];
|
|
7
6
|
if (info.description) {
|
|
8
7
|
markdown.push(info.description);
|
|
9
8
|
}
|
|
@@ -26,7 +25,7 @@ function generateOverviewPage(spec, sdks) {
|
|
|
26
25
|
).join("\n")
|
|
27
26
|
);
|
|
28
27
|
}
|
|
29
|
-
markdown.push(...generateSdkSection(
|
|
28
|
+
markdown.push(...generateSdkSection(info.title, sdks));
|
|
30
29
|
const supportDocs = spec.externalDocs?.url && spec.externalDocs.description?.toLowerCase().includes("support") ? spec.externalDocs : void 0;
|
|
31
30
|
if (info.contact?.email || info.contact?.url || supportDocs) {
|
|
32
31
|
markdown.push(`## Need Help?`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/overview-docs/overview-page.ts"],
|
|
4
|
-
"sourcesContent": ["import type { NavItem } from '../sidebar.js';\nimport type { IR } from '../types.js';\nimport { getTextByCount, presetDocs } from './doc-text-utils.js';\nimport { generateSdkSection } from './overview-sdks.js';\nimport type { SdkDoc } from './types.js';\n\nexport function generateOverviewPage(spec: IR, sdks: SdkDoc[]): NavItem {\n const info = spec.info;\n const
|
|
5
|
-
"mappings": "AAEA,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,0BAA0B;AAG5B,SAAS,qBAAqB,MAAU,MAAyB;AACtE,QAAM,OAAO,KAAK;AAClB,QAAM,
|
|
4
|
+
"sourcesContent": ["import type { NavItem } from '../sidebar.js';\nimport type { IR } from '../types.js';\nimport { getTextByCount, presetDocs } from './doc-text-utils.js';\nimport { generateSdkSection } from './overview-sdks.js';\nimport type { SdkDoc } from './types.js';\n\nexport function generateOverviewPage(spec: IR, sdks: SdkDoc[]): NavItem {\n const info = spec.info;\n const markdown: string[] = info.title ? [`# ${info.title}`] : [];\n\n if (info.description) {\n markdown.push(info.description);\n }\n\n if (info.version) {\n markdown.push(`**Version:** ${info.version}`);\n }\n\n if (info.license) {\n const license = info.license.url\n ? `${info.license.name} ([${info.license.url}](${info.license.url}))`\n : info.license.name;\n markdown.push(`**License:** ${license}`);\n }\n\n if (spec.servers.length > 0) {\n const serverCount = spec.servers.length;\n markdown.push(\n `## ${getTextByCount(serverCount, presetDocs.server.section)}`,\n );\n markdown.push(getTextByCount(serverCount, presetDocs.server.description));\n markdown.push(\n spec.servers\n .map((server) =>\n server.description\n ? `- **${server.url}** - ${server.description}`\n : `- **${server.url}**`,\n )\n .join('\\n'),\n );\n }\n\n markdown.push(...generateSdkSection(info.title, sdks));\n\n const supportDocs =\n spec.externalDocs?.url &&\n spec.externalDocs.description?.toLowerCase().includes('support')\n ? spec.externalDocs\n : undefined;\n\n if (info.contact?.email || info.contact?.url || supportDocs) {\n markdown.push(`## Need Help?`);\n\n if (info.contact?.email) {\n markdown.push(\n `For support, reach out to us at [${info.contact.email}](mailto:${info.contact.email}).`,\n );\n }\n\n if (info.contact?.url) {\n markdown.push(\n `Visit our support page: [${info.contact.url}](${info.contact.url})`,\n );\n }\n\n if (supportDocs) {\n markdown.push(\n `For additional support, visit our [${supportDocs.description}](${supportDocs.url}).`,\n );\n }\n }\n\n return {\n id: 'overview',\n url: '/',\n title: 'Overview',\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7B,QAAI,KAAK,SAAS,OAAO;AACvB,eAAS;AAAA,QACP,oCAAoC,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ,KAAK;AAAA,MACtF;AAAA,IACF;AAEA,QAAI,KAAK,SAAS,KAAK;AACrB,eAAS;AAAA,QACP,4BAA4B,KAAK,QAAQ,GAAG,KAAK,KAAK,QAAQ,GAAG;AAAA,MACnE;AAAA,IACF;AAEA,QAAI,aAAa;AACf,eAAS;AAAA,QACP,sCAAsC,YAAY,WAAW,KAAK,YAAY,GAAG;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS,SAAS,KAAK,MAAM;AAAA,EAC/B;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-pagination.d.ts","
|
|
1
|
+
{"version":3,"file":"overview-pagination.d.ts","sources":["../../../src/lib/overview-docs/overview-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,CAoG7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-sdks.d.ts","
|
|
1
|
+
{"version":3,"file":"overview-sdks.d.ts","sources":["../../../src/lib/overview-docs/overview-sdks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,YAAY,CAAC;AA4BtD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAsB7E"}
|
|
@@ -22,9 +22,10 @@ function generateSdkSection(apiTitle, sdks) {
|
|
|
22
22
|
const languages = listFormat.format(
|
|
23
23
|
sdks.map((sdk) => sdkLanguages[sdk.language].title)
|
|
24
24
|
);
|
|
25
|
+
const subject = apiTitle === "" ? "This API" : apiTitle;
|
|
25
26
|
const markdown = [
|
|
26
27
|
`## ${getTextByCount(sdks.length, presetDocs.client.section)}`,
|
|
27
|
-
`${
|
|
28
|
+
`${subject} provides ${sdks.length === 1 ? "an official client SDK" : "official client SDKs"} for ${languages}. Install ${sdks.length === 1 ? "it" : "one"} to get started:`
|
|
28
29
|
];
|
|
29
30
|
for (const sdk of sdks) {
|
|
30
31
|
const language = sdkLanguages[sdk.language];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/overview-docs/overview-sdks.ts"],
|
|
4
|
-
"sourcesContent": ["import { getTextByCount, presetDocs } from './doc-text-utils.js';\nimport type { SdkDoc, SdkLanguage } from './types.js';\n\ninterface SdkLanguageDocs {\n title: string;\n install(packageName: string): string;\n registry(packageName: string): string;\n}\n\nconst sdkLanguages: Record<SdkLanguage, SdkLanguageDocs> = {\n typescript: {\n title: 'TypeScript',\n install: (packageName) => `npm install ${packageName}`,\n registry: (packageName) => `https://www.npmjs.com/package/${packageName}`,\n },\n python: {\n title: 'Python',\n install: (packageName) => `pip install ${packageName}`,\n registry: (packageName) => `https://pypi.org/project/${packageName}`,\n },\n dart: {\n title: 'Dart',\n install: (packageName) => `dart pub add ${packageName}`,\n registry: (packageName) => `https://pub.dev/packages/${packageName}`,\n },\n};\n\nconst listFormat = new Intl.ListFormat('en', { type: 'conjunction' });\n\nexport function generateSdkSection(apiTitle: string, sdks: SdkDoc[]): string[] {\n if (sdks.length === 0) return [];\n\n const languages = listFormat.format(\n sdks.map((sdk) => sdkLanguages[sdk.language].title),\n );\n const markdown: string[] = [\n `## ${getTextByCount(sdks.length, presetDocs.client.section)}`,\n `${
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAS3C,MAAM,eAAqD;AAAA,EACzD,YAAY;AAAA,IACV,OAAO;AAAA,IACP,SAAS,CAAC,gBAAgB,eAAe,WAAW;AAAA,IACpD,UAAU,CAAC,gBAAgB,iCAAiC,WAAW;AAAA,EACzE;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,SAAS,CAAC,gBAAgB,eAAe,WAAW;AAAA,IACpD,UAAU,CAAC,gBAAgB,4BAA4B,WAAW;AAAA,EACpE;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,SAAS,CAAC,gBAAgB,gBAAgB,WAAW;AAAA,IACrD,UAAU,CAAC,gBAAgB,4BAA4B,WAAW;AAAA,EACpE;AACF;AAEA,MAAM,aAAa,IAAI,KAAK,WAAW,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7D,SAAS,mBAAmB,UAAkB,MAA0B;AAC7E,MAAI,KAAK,WAAW,EAAG,QAAO,CAAC;AAE/B,QAAM,YAAY,WAAW;AAAA,IAC3B,KAAK,IAAI,CAAC,QAAQ,aAAa,IAAI,QAAQ,EAAE,KAAK;AAAA,EACpD;AACA,QAAM,WAAqB;AAAA,IACzB,MAAM,eAAe,KAAK,QAAQ,WAAW,OAAO,OAAO,CAAC;AAAA,IAC5D,GAAG,
|
|
4
|
+
"sourcesContent": ["import { getTextByCount, presetDocs } from './doc-text-utils.js';\nimport type { SdkDoc, SdkLanguage } from './types.js';\n\ninterface SdkLanguageDocs {\n title: string;\n install(packageName: string): string;\n registry(packageName: string): string;\n}\n\nconst sdkLanguages: Record<SdkLanguage, SdkLanguageDocs> = {\n typescript: {\n title: 'TypeScript',\n install: (packageName) => `npm install ${packageName}`,\n registry: (packageName) => `https://www.npmjs.com/package/${packageName}`,\n },\n python: {\n title: 'Python',\n install: (packageName) => `pip install ${packageName}`,\n registry: (packageName) => `https://pypi.org/project/${packageName}`,\n },\n dart: {\n title: 'Dart',\n install: (packageName) => `dart pub add ${packageName}`,\n registry: (packageName) => `https://pub.dev/packages/${packageName}`,\n },\n};\n\nconst listFormat = new Intl.ListFormat('en', { type: 'conjunction' });\n\nexport function generateSdkSection(apiTitle: string, sdks: SdkDoc[]): string[] {\n if (sdks.length === 0) return [];\n\n const languages = listFormat.format(\n sdks.map((sdk) => sdkLanguages[sdk.language].title),\n );\n const subject = apiTitle === '' ? 'This API' : apiTitle;\n const markdown: string[] = [\n `## ${getTextByCount(sdks.length, presetDocs.client.section)}`,\n `${subject} provides ${sdks.length === 1 ? 'an official client SDK' : 'official client SDKs'} for ${languages}. Install ${sdks.length === 1 ? 'it' : 'one'} to get started:`,\n ];\n\n for (const sdk of sdks) {\n const language = sdkLanguages[sdk.language];\n markdown.push(`### ${language.title}`);\n markdown.push(['```bash', language.install(sdk.package), '```'].join('\\n'));\n markdown.push(\n `[${sdk.package}](${sdk.url ?? language.registry(sdk.package)})`,\n );\n }\n\n return markdown;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAS3C,MAAM,eAAqD;AAAA,EACzD,YAAY;AAAA,IACV,OAAO;AAAA,IACP,SAAS,CAAC,gBAAgB,eAAe,WAAW;AAAA,IACpD,UAAU,CAAC,gBAAgB,iCAAiC,WAAW;AAAA,EACzE;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,SAAS,CAAC,gBAAgB,eAAe,WAAW;AAAA,IACpD,UAAU,CAAC,gBAAgB,4BAA4B,WAAW;AAAA,EACpE;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,SAAS,CAAC,gBAAgB,gBAAgB,WAAW;AAAA,IACrD,UAAU,CAAC,gBAAgB,4BAA4B,WAAW;AAAA,EACpE;AACF;AAEA,MAAM,aAAa,IAAI,KAAK,WAAW,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7D,SAAS,mBAAmB,UAAkB,MAA0B;AAC7E,MAAI,KAAK,WAAW,EAAG,QAAO,CAAC;AAE/B,QAAM,YAAY,WAAW;AAAA,IAC3B,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,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAI/C,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAsB,CAAC;AAUxE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CASlE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CASxD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK7C"}
|
|
@@ -14,7 +14,7 @@ function isAuthoredDoc(value) {
|
|
|
14
14
|
return isRecord(value) && typeof value.title === "string" && value.title.trim() !== "" && isOptionalString(value.id) && isOptionalString(value.description) && isOptionalString(value.content);
|
|
15
15
|
}
|
|
16
16
|
function isSdkDoc(value) {
|
|
17
|
-
return isRecord(value) && typeof value.language === "string" && SDK_LANGUAGES.
|
|
17
|
+
return isRecord(value) && typeof value.language === "string" && SDK_LANGUAGES.some((language) => language === value.language) && typeof value.package === "string" && value.package.trim() !== "" && isOptionalString(value.url);
|
|
18
18
|
}
|
|
19
19
|
function slugify(value) {
|
|
20
20
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/overview-docs/types.ts"],
|
|
4
|
-
"sourcesContent": ["export type AuthoredDoc = {\n id?: string;\n title: string;\n description?: string;\n content?: string;\n};\n\n/** An authored doc whose id has been normalized to a url-safe slug. */\nexport type ResolvedDoc = AuthoredDoc & { id: string };\n\nexport type SdkLanguage = 'typescript' | 'python' | 'dart';\n\nexport type SdkDoc = {\n language: SdkLanguage;\n package: string;\n url?: string;\n};\n\nexport const SDK_LANGUAGES: readonly SdkLanguage[] = [\n 'typescript',\n 'python',\n 'dart',\n];\n\n/** Doc ids the apiref reserves for its own routes. */\nexport const RESERVED_DOC_IDS: ReadonlySet<string> = new Set(['embed']);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isOptionalString(value: unknown): value is string | undefined {\n return value === undefined || typeof value === 'string';\n}\n\nexport function isAuthoredDoc(value: unknown): value is AuthoredDoc {\n return (\n isRecord(value) &&\n typeof value.title === 'string' &&\n value.title.trim() !== '' &&\n isOptionalString(value.id) &&\n isOptionalString(value.description) &&\n isOptionalString(value.content)\n );\n}\n\nexport function isSdkDoc(value: unknown): value is SdkDoc {\n return (\n isRecord(value) &&\n typeof value.language === 'string' &&\n (
|
|
5
|
-
"mappings": "AAkBO,MAAM,gBAAwC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AACF;AAGO,MAAM,mBAAwC,oBAAI,IAAI,CAAC,OAAO,CAAC;AAEtE,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,iBAAiB,OAA6C;AACrE,SAAO,UAAU,UAAa,OAAO,UAAU;AACjD;AAEO,SAAS,cAAc,OAAsC;AAClE,SACE,SAAS,KAAK,KACd,OAAO,MAAM,UAAU,YACvB,MAAM,MAAM,KAAK,MAAM,MACvB,iBAAiB,MAAM,EAAE,KACzB,iBAAiB,MAAM,WAAW,KAClC,iBAAiB,MAAM,OAAO;AAElC;AAEO,SAAS,SAAS,OAAiC;AACxD,SACE,SAAS,KAAK,KACd,OAAO,MAAM,aAAa,
|
|
4
|
+
"sourcesContent": ["export type AuthoredDoc = {\n id?: string;\n title: string;\n description?: string;\n content?: string;\n};\n\n/** An authored doc whose id has been normalized to a url-safe slug. */\nexport type ResolvedDoc = AuthoredDoc & { id: string };\n\nexport type SdkLanguage = 'typescript' | 'python' | 'dart';\n\nexport type SdkDoc = {\n language: SdkLanguage;\n package: string;\n url?: string;\n};\n\nexport const SDK_LANGUAGES: readonly SdkLanguage[] = [\n 'typescript',\n 'python',\n 'dart',\n];\n\n/** Doc ids the apiref reserves for its own routes. */\nexport const RESERVED_DOC_IDS: ReadonlySet<string> = new Set(['embed']);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isOptionalString(value: unknown): value is string | undefined {\n return value === undefined || typeof value === 'string';\n}\n\nexport function isAuthoredDoc(value: unknown): value is AuthoredDoc {\n return (\n isRecord(value) &&\n typeof value.title === 'string' &&\n value.title.trim() !== '' &&\n isOptionalString(value.id) &&\n isOptionalString(value.description) &&\n isOptionalString(value.content)\n );\n}\n\nexport function isSdkDoc(value: unknown): value is SdkDoc {\n return (\n isRecord(value) &&\n typeof value.language === 'string' &&\n SDK_LANGUAGES.some((language) => language === value.language) &&\n typeof value.package === 'string' &&\n value.package.trim() !== '' &&\n isOptionalString(value.url)\n );\n}\n\nexport function slugify(value: string): string {\n return value\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n"],
|
|
5
|
+
"mappings": "AAkBO,MAAM,gBAAwC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AACF;AAGO,MAAM,mBAAwC,oBAAI,IAAI,CAAC,OAAO,CAAC;AAEtE,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,iBAAiB,OAA6C;AACrE,SAAO,UAAU,UAAa,OAAO,UAAU;AACjD;AAEO,SAAS,cAAc,OAAsC;AAClE,SACE,SAAS,KAAK,KACd,OAAO,MAAM,UAAU,YACvB,MAAM,MAAM,KAAK,MAAM,MACvB,iBAAiB,MAAM,EAAE,KACzB,iBAAiB,MAAM,WAAW,KAClC,iBAAiB,MAAM,OAAO;AAElC;AAEO,SAAS,SAAS,OAAiC;AACxD,SACE,SAAS,KAAK,KACd,OAAO,MAAM,aAAa,YAC1B,cAAc,KAAK,CAAC,aAAa,aAAa,MAAM,QAAQ,KAC5D,OAAO,MAAM,YAAY,YACzB,MAAM,QAAQ,KAAK,MAAM,MACzB,iBAAiB,MAAM,GAAG;AAE9B;AAEO,SAAS,QAAQ,OAAuB;AAC7C,SAAO,MACJ,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AAC3B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guess-pagination.d.ts","
|
|
1
|
+
{"version":3,"file":"guess-pagination.d.ts","sources":["../../../src/lib/pagination/guess-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC7C;AAED,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GACvB,CAAC,CACC,sBAAsB,GAAG,oBAAoB,GAAG,sBAAsB,CACvE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACvC,kBAAkB,CAAC;AAIvB,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAKxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAU/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAMvC,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAUrC,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,MAAM,EAWlC,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAUxC,CAAC;AA+JF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,oBAAoB,EAC/B,IAAI,CAAC,EAAE,YAAY,EACnB,QAAQ,CAAC,EAAE,YAAY,GACtB,eAAe,CAqCjB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/pagination/guess-pagination.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n ReferenceObject,\n SchemaObject,\n SchemasObject,\n} from 'openapi3-ts/oas31';\n\nimport { isRef } from '@sdk-it/core/ref.js';\nimport { isEmpty } from '@sdk-it/core/utils.js';\n\nimport { coerceTypes } from '../is.js';\nimport type { TunedOperationObject } from '../types.js';\nimport { getHasMoreName, getItemsName } from './pagination-result.js';\n\ninterface PaginationResultBase {\n type: 'offset' | 'page' | 'cursor' | 'none';\n}\n\nexport interface OffsetPaginationResult extends PaginationResultBase {\n type: 'offset';\n offsetParamName: string;\n offsetKeyword: string; // The actual part of param name that matched\n limitParamName: string;\n limitKeyword: string; // The actual part of param name that matched\n}\n\nexport interface PagePaginationResult extends PaginationResultBase {\n type: 'page';\n pageNumberParamName: string;\n pageNumberKeyword: string;\n pageSizeParamName: string;\n pageSizeKeyword: string;\n}\n\nexport interface CursorPaginationResult extends PaginationResultBase {\n type: 'cursor';\n cursorParamName: string;\n cursorKeyword: string;\n limitParamName: string;\n limitKeyword: string;\n /** Dot-separated response path containing the next request cursor. */\n nextCursor?: string;\n}\n\nexport interface NoPaginationResult extends PaginationResultBase {\n type: 'none';\n reason: string;\n}\n\nexport type PaginationGuess =\n | ((\n OffsetPaginationResult | PagePaginationResult | CursorPaginationResult\n ) & { items: string; hasMore: string })\n | NoPaginationResult;\n\n// --- Keyword Regex Definitions ---\n\nexport const OFFSET_PARAM_REGEXES: RegExp[] = [\n /\\boffset\\b/i,\n /\\bskip\\b/i,\n /\\bstart(?:ing_at|_index)?\\b/i, // e.g., start, starting_at, start_index\n /\\bfrom\\b/i,\n];\n\nexport const GENERIC_LIMIT_PARAM_REGEXES: RegExp[] = [\n /\\blimit\\b/i,\n /\\bcount\\b/i,\n /\\b(?:page_?)?size\\b/i, // e.g., size, page_size, pagesize\n /\\bmax_results\\b/i,\n /\\bnum_results\\b/i,\n /\\bshow\\b/i, // Can sometimes mean limit\n /\\bper_?page\\b/i, // e.g., per_page, perpage\n /\\bper-page\\b/i,\n /\\btake\\b/i,\n];\n\nexport const PAGE_NUMBER_REGEXES: RegExp[] = [\n // /^(currentPage)?page$/i, // Exact match for \"page\"\n // /^currentPage$/i, // Exact match for \"currentPage\"\n /^p$/i, // Exact match for \"p\" (common shorthand)\n // /\\bpage_?(?:number|no|num|idx|index)\\b/i, // e.g., page_number, pageNumber, page_num, page_idx\n /^(current)?_?page(_?)(?:number|no|num|idx|index)?\\b/i,\n];\n\n// Regexes for parameters indicating page size (when used with page number)\nexport const PAGE_SIZE_REGEXES: RegExp[] = [\n /\\bpage_?size\\b/i, // e.g., page_size, pagesize\n /^size$/i, // Exact \"size\"\n // /\\bsize\\b/i, // Broader \"size\" - can be ambiguous, prefer more specific ones first\n /\\blimit\\b/i, // Limit is often used for page size\n /\\bcount\\b/i, // Count can also be used for page size\n /\\bper_?page\\b/i, // e.g., per_page, perpage\n /\\bper-page\\b/i,\n /\\bnum_?(?:items|records|results)\\b/i, // e.g., num_items, numitems\n /\\bresults_?per_?page\\b/i,\n];\n\n// Regexes for parameters indicating a cursor\nexport const CURSOR_REGEXES: RegExp[] = [\n /\\bmarker\\b/i,\n /\\bcursor\\b/i,\n /\\bafter(?:_?cursor)?\\b/i, // e.g., after, after_cursor\n /\\bbefore(?:_?cursor)?\\b/i, // e.g., before, before_cursor\n /\\b(next|prev|previous)_?(?:page_?)?token\\b/i, // e.g., next_page_token, nextPageToken, prev_token\n /\\b(next|prev|previous)_?cursor\\b/i, // e.g., next_cursor, previousCursor\n /\\bcontinuation(?:_?token)?\\b/i, // e.g., continuation, continuation_token\n /\\bpage(?:_?(token|id))?\\b/i, // e.g., after, after_cursor\n\n /\\bstart_?(?:key|cursor|token|after)\\b/i, // e.g., start_key, startCursor, startToken, startAfter\n];\n\n// Regexes for parameters indicating a limit when used with cursors\nexport const CURSOR_LIMIT_REGEXES: RegExp[] = [\n /\\blimit\\b/i,\n /\\bcount\\b/i,\n /\\bsize\\b/i, // General size\n /\\bfirst\\b/i, // Common in Relay-style cursor pagination (forward pagination)\n /\\blast\\b/i, // Common in Relay-style cursor pagination (backward pagination)\n /\\bpage_?size\\b/i, // Sometimes page_size is used with cursors\n /\\bnum_?(?:items|records|results)\\b/i, // e.g., num_items\n /\\bmax_?items\\b/i,\n /\\btake\\b/i,\n];\n\n// --- Helper Function ---\nfunction findParamAndKeyword(\n queryParams: { name: string }[],\n regexes: RegExp[],\n excludeParamName?: string,\n) {\n for (const param of queryParams) {\n if (param.name === excludeParamName) {\n continue;\n }\n for (const regex of regexes) {\n const match = param.name.match(regex);\n if (match) {\n return { param, keyword: match[0] }; // match[0] is the actual matched substring\n }\n }\n }\n return null;\n}\n\nfunction coerceParameters(\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[],\n) {\n const cleanedParameters: {\n name: string;\n schema: Omit<SchemaObject, 'type'> & {\n type: string[]; // Ensure type is always an array\n };\n }[] = [];\n for (const param of parameters) {\n if (!param.schema) {\n continue;\n }\n if (isRef(param.schema)) {\n continue;\n }\n if (param.schema.anyOf || param.schema.oneOf || param.schema.allOf) {\n const schemas = (\n param.schema.anyOf ||\n param.schema.oneOf ||\n param.schema.allOf ||\n []\n ).filter((it): it is SchemaObject => !isRef(it));\n schemas.forEach((schema) => {\n if (schema.type) {\n cleanedParameters.push({\n ...param,\n schema: {\n ...schema,\n type: coerceTypes(schema),\n },\n });\n }\n });\n continue;\n }\n if (!param.schema.type) {\n continue;\n }\n if (param.schema) {\n cleanedParameters.push({\n ...param,\n schema: {\n ...param.schema,\n type: coerceTypes(param.schema),\n },\n });\n }\n }\n return cleanedParameters;\n}\n\nfunction isOffsetPagination(\n operation: TunedOperationObject,\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[],\n): OffsetPaginationResult | null {\n const params = coerceParameters(parameters).filter(\n (it) =>\n it.schema.type.includes('integer') || it.schema.type.includes('number'),\n );\n\n const offsetMatch = findParamAndKeyword(params, OFFSET_PARAM_REGEXES);\n\n if (!offsetMatch) return null;\n\n const limitMatch = findParamAndKeyword(\n params,\n GENERIC_LIMIT_PARAM_REGEXES,\n offsetMatch.param.name,\n );\n if (!limitMatch) return null;\n\n return {\n type: 'offset',\n offsetParamName: offsetMatch.param.name,\n offsetKeyword: offsetMatch.keyword,\n limitParamName: limitMatch.param.name,\n limitKeyword: limitMatch.keyword,\n };\n}\n\nfunction isPagePagination(\n operation: TunedOperationObject,\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[],\n): PagePaginationResult | null {\n const params = coerceParameters(parameters).filter(\n (it) =>\n it.schema.type.includes('integer') || it.schema.type.includes('number'),\n );\n\n if (params.length < 2) return null;\n\n const pageNoMatch = findParamAndKeyword(params, PAGE_NUMBER_REGEXES);\n if (!pageNoMatch) return null;\n\n const pageSizeMatch = findParamAndKeyword(\n params,\n PAGE_SIZE_REGEXES,\n pageNoMatch.param.name,\n );\n if (!pageSizeMatch) return null;\n\n return {\n type: 'page',\n pageNumberParamName: pageNoMatch.param.name,\n pageNumberKeyword: pageNoMatch.keyword,\n pageSizeParamName: pageSizeMatch.param.name,\n pageSizeKeyword: pageSizeMatch.keyword,\n };\n}\n\nfunction isCursorPagination(\n operation: TunedOperationObject,\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[] = [],\n): CursorPaginationResult | null {\n const queryParams = parameters;\n if (queryParams.length < 2) return null; // Need at least a cursor and a limit-like param\n\n const cursorMatch = findParamAndKeyword(queryParams, CURSOR_REGEXES);\n if (!cursorMatch) return null;\n\n const limitMatch = findParamAndKeyword(\n queryParams,\n CURSOR_LIMIT_REGEXES,\n cursorMatch.param.name,\n );\n if (!limitMatch) return null;\n\n return {\n type: 'cursor',\n cursorParamName: cursorMatch.param.name,\n cursorKeyword: cursorMatch.keyword,\n limitParamName: limitMatch.param.name,\n limitKeyword: limitMatch.keyword,\n };\n}\n\n/**\n * Guesses the pagination strategy of an OpenAPI operation based on its query parameters.\n * It checks for offset, page-based, and cursor-based pagination in that order.\n *\n * @param operation The OpenAPI operation object.\n * @returns A PaginationGuess object indicating the detected type and relevant parameters.\n */\nexport function guessPagination(\n operation: TunedOperationObject,\n body?: SchemaObject,\n response?: SchemaObject,\n): PaginationGuess {\n const bodyParameters =\n body && body.properties\n ? Object.entries(body.properties).map(([it, schema]) => ({\n name: it,\n schema,\n }))\n : [];\n const parameters = operation.parameters;\n\n if (isEmpty(operation.parameters) && isEmpty(bodyParameters)) {\n return { type: 'none', reason: 'no parameters' };\n }\n if (!response) {\n return { type: 'none', reason: 'no response' };\n }\n if (!response.properties) {\n return { type: 'none', reason: 'empty response' };\n }\n const properties = response.properties as SchemasObject;\n\n const itemsKey = getItemsName(properties);\n if (!itemsKey) {\n return { type: 'none', reason: 'no items key' };\n }\n const hasMoreKey = getHasMoreName(excludeKey(properties, itemsKey));\n\n if (!hasMoreKey) {\n return { type: 'none', reason: 'no hasMore key' };\n }\n const pagination =\n isOffsetPagination(operation, [...parameters, ...bodyParameters]) ||\n isPagePagination(operation, [...parameters, ...bodyParameters]) ||\n isCursorPagination(operation, [...parameters, ...bodyParameters]);\n return pagination\n ? { ...pagination, items: itemsKey, hasMore: hasMoreKey }\n : { type: 'none', reason: 'no pagination' };\n}\n\nfunction excludeKey<T extends Record<string, any>>(\n obj: T,\n key: string,\n): Omit<T, typeof key> {\n const { [key]: _, ...rest } = obj;\n return rest;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { isRef } from '@sdk-it/core/ref.js';\nimport { isEmpty } from '@sdk-it/core/utils.js';\n\nimport { coerceTypes } from '../is.js';\nimport type { TunedOperationObject } from '../types.js';\nimport { getHasMoreName, getItemsName } from './pagination-result.js';\n\ninterface PaginationResultBase {\n type: 'offset' | 'page' | 'cursor' | 'none';\n}\n\nexport interface OffsetPaginationResult extends PaginationResultBase {\n type: 'offset';\n offsetParamName: string;\n offsetKeyword: string; // The actual part of param name that matched\n limitParamName: string;\n limitKeyword: string; // The actual part of param name that matched\n}\n\nexport interface PagePaginationResult extends PaginationResultBase {\n type: 'page';\n pageNumberParamName: string;\n pageNumberKeyword: string;\n pageSizeParamName: string;\n pageSizeKeyword: string;\n}\n\nexport interface CursorPaginationResult extends PaginationResultBase {\n type: 'cursor';\n cursorParamName: string;\n cursorKeyword: string;\n limitParamName: string;\n limitKeyword: string;\n /** Dot-separated response path containing the next request cursor. */\n nextCursor?: string;\n}\n\nexport interface NoPaginationResult extends PaginationResultBase {\n type: 'none';\n reason: string;\n}\n\nexport type PaginationGuess =\n | ((\n OffsetPaginationResult | PagePaginationResult | CursorPaginationResult\n ) & { items: string; hasMore: string })\n | NoPaginationResult;\n\n// --- Keyword Regex Definitions ---\n\nexport const OFFSET_PARAM_REGEXES: RegExp[] = [\n /\\boffset\\b/i,\n /\\bskip\\b/i,\n /\\bstart(?:ing_at|_index)?\\b/i, // e.g., start, starting_at, start_index\n /\\bfrom\\b/i,\n];\n\nexport const GENERIC_LIMIT_PARAM_REGEXES: RegExp[] = [\n /\\blimit\\b/i,\n /\\bcount\\b/i,\n /\\b(?:page_?)?size\\b/i, // e.g., size, page_size, pagesize\n /\\bmax_results\\b/i,\n /\\bnum_results\\b/i,\n /\\bshow\\b/i, // Can sometimes mean limit\n /\\bper_?page\\b/i, // e.g., per_page, perpage\n /\\bper-page\\b/i,\n /\\btake\\b/i,\n];\n\nexport const PAGE_NUMBER_REGEXES: RegExp[] = [\n // /^(currentPage)?page$/i, // Exact match for \"page\"\n // /^currentPage$/i, // Exact match for \"currentPage\"\n /^p$/i, // Exact match for \"p\" (common shorthand)\n // /\\bpage_?(?:number|no|num|idx|index)\\b/i, // e.g., page_number, pageNumber, page_num, page_idx\n /^(current)?_?page(_?)(?:number|no|num|idx|index)?\\b/i,\n];\n\n// Regexes for parameters indicating page size (when used with page number)\nexport const PAGE_SIZE_REGEXES: RegExp[] = [\n /\\bpage_?size\\b/i, // e.g., page_size, pagesize\n /^size$/i, // Exact \"size\"\n // /\\bsize\\b/i, // Broader \"size\" - can be ambiguous, prefer more specific ones first\n /\\blimit\\b/i, // Limit is often used for page size\n /\\bcount\\b/i, // Count can also be used for page size\n /\\bper_?page\\b/i, // e.g., per_page, perpage\n /\\bper-page\\b/i,\n /\\bnum_?(?:items|records|results)\\b/i, // e.g., num_items, numitems\n /\\bresults_?per_?page\\b/i,\n];\n\n// Regexes for parameters indicating a cursor\nexport const CURSOR_REGEXES: RegExp[] = [\n /\\bmarker\\b/i,\n /\\bcursor\\b/i,\n /\\bafter(?:_?cursor)?\\b/i, // e.g., after, after_cursor\n /\\bbefore(?:_?cursor)?\\b/i, // e.g., before, before_cursor\n /\\b(next|prev|previous)_?(?:page_?)?token\\b/i, // e.g., next_page_token, nextPageToken, prev_token\n /\\b(next|prev|previous)_?cursor\\b/i, // e.g., next_cursor, previousCursor\n /\\bcontinuation(?:_?token)?\\b/i, // e.g., continuation, continuation_token\n /\\bpage(?:_?(token|id))?\\b/i, // e.g., after, after_cursor\n\n /\\bstart_?(?:key|cursor|token|after)\\b/i, // e.g., start_key, startCursor, startToken, startAfter\n];\n\n// Regexes for parameters indicating a limit when used with cursors\nexport const CURSOR_LIMIT_REGEXES: RegExp[] = [\n /\\blimit\\b/i,\n /\\bcount\\b/i,\n /\\bsize\\b/i, // General size\n /\\bfirst\\b/i, // Common in Relay-style cursor pagination (forward pagination)\n /\\blast\\b/i, // Common in Relay-style cursor pagination (backward pagination)\n /\\bpage_?size\\b/i, // Sometimes page_size is used with cursors\n /\\bnum_?(?:items|records|results)\\b/i, // e.g., num_items\n /\\bmax_?items\\b/i,\n /\\btake\\b/i,\n];\n\n// --- Helper Function ---\nfunction findParamAndKeyword(\n queryParams: { name: string }[],\n regexes: RegExp[],\n excludeParamName?: string,\n) {\n for (const param of queryParams) {\n if (param.name === excludeParamName) {\n continue;\n }\n for (const regex of regexes) {\n const match = param.name.match(regex);\n if (match) {\n return { param, keyword: match[0] }; // match[0] is the actual matched substring\n }\n }\n }\n return null;\n}\n\nfunction coerceParameters(\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[],\n) {\n const cleanedParameters: {\n name: string;\n schema: Omit<SchemaObject, 'type'> & {\n type: string[]; // Ensure type is always an array\n };\n }[] = [];\n for (const param of parameters) {\n if (!param.schema) {\n continue;\n }\n if (isRef(param.schema)) {\n continue;\n }\n if (param.schema.anyOf || param.schema.oneOf || param.schema.allOf) {\n const schemas = (\n param.schema.anyOf ||\n param.schema.oneOf ||\n param.schema.allOf ||\n []\n ).filter((it): it is SchemaObject => !isRef(it));\n schemas.forEach((schema) => {\n if (schema.type) {\n cleanedParameters.push({\n ...param,\n schema: {\n ...schema,\n type: coerceTypes(schema),\n },\n });\n }\n });\n continue;\n }\n if (!param.schema.type) {\n continue;\n }\n if (param.schema) {\n cleanedParameters.push({\n ...param,\n schema: {\n ...param.schema,\n type: coerceTypes(param.schema),\n },\n });\n }\n }\n return cleanedParameters;\n}\n\nfunction isOffsetPagination(\n operation: TunedOperationObject,\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[],\n): OffsetPaginationResult | null {\n const params = coerceParameters(parameters).filter(\n (it) =>\n it.schema.type.includes('integer') || it.schema.type.includes('number'),\n );\n\n const offsetMatch = findParamAndKeyword(params, OFFSET_PARAM_REGEXES);\n\n if (!offsetMatch) return null;\n\n const limitMatch = findParamAndKeyword(\n params,\n GENERIC_LIMIT_PARAM_REGEXES,\n offsetMatch.param.name,\n );\n if (!limitMatch) return null;\n\n return {\n type: 'offset',\n offsetParamName: offsetMatch.param.name,\n offsetKeyword: offsetMatch.keyword,\n limitParamName: limitMatch.param.name,\n limitKeyword: limitMatch.keyword,\n };\n}\n\nfunction isPagePagination(\n operation: TunedOperationObject,\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[],\n): PagePaginationResult | null {\n const params = coerceParameters(parameters).filter(\n (it) =>\n it.schema.type.includes('integer') || it.schema.type.includes('number'),\n );\n\n if (params.length < 2) return null;\n\n const pageNoMatch = findParamAndKeyword(params, PAGE_NUMBER_REGEXES);\n if (!pageNoMatch) return null;\n\n const pageSizeMatch = findParamAndKeyword(\n params,\n PAGE_SIZE_REGEXES,\n pageNoMatch.param.name,\n );\n if (!pageSizeMatch) return null;\n\n return {\n type: 'page',\n pageNumberParamName: pageNoMatch.param.name,\n pageNumberKeyword: pageNoMatch.keyword,\n pageSizeParamName: pageSizeMatch.param.name,\n pageSizeKeyword: pageSizeMatch.keyword,\n };\n}\n\nfunction isCursorPagination(\n operation: TunedOperationObject,\n parameters: { name: string; schema?: SchemaObject | ReferenceObject }[] = [],\n): CursorPaginationResult | null {\n const queryParams = parameters;\n if (queryParams.length < 2) return null; // Need at least a cursor and a limit-like param\n\n const cursorMatch = findParamAndKeyword(queryParams, CURSOR_REGEXES);\n if (!cursorMatch) return null;\n\n const limitMatch = findParamAndKeyword(\n queryParams,\n CURSOR_LIMIT_REGEXES,\n cursorMatch.param.name,\n );\n if (!limitMatch) return null;\n\n return {\n type: 'cursor',\n cursorParamName: cursorMatch.param.name,\n cursorKeyword: cursorMatch.keyword,\n limitParamName: limitMatch.param.name,\n limitKeyword: limitMatch.keyword,\n };\n}\n\n/**\n * Guesses the pagination strategy of an OpenAPI operation based on its query parameters.\n * It checks for offset, page-based, and cursor-based pagination in that order.\n *\n * @param operation The OpenAPI operation object.\n * @returns A PaginationGuess object indicating the detected type and relevant parameters.\n */\nexport function guessPagination(\n operation: TunedOperationObject,\n body?: SchemaObject,\n response?: SchemaObject,\n): PaginationGuess {\n const bodyParameters =\n body && body.properties\n ? Object.entries(body.properties).map(([it, schema]) => ({\n name: it,\n schema,\n }))\n : [];\n const parameters = operation.parameters;\n\n if (isEmpty(operation.parameters) && isEmpty(bodyParameters)) {\n return { type: 'none', reason: 'no parameters' };\n }\n if (!response) {\n return { type: 'none', reason: 'no response' };\n }\n if (!response.properties) {\n return { type: 'none', reason: 'empty response' };\n }\n const properties = response.properties;\n\n const itemsKey = getItemsName(properties);\n if (!itemsKey) {\n return { type: 'none', reason: 'no items key' };\n }\n const hasMoreKey = getHasMoreName(excludeKey(properties, itemsKey));\n\n if (!hasMoreKey) {\n return { type: 'none', reason: 'no hasMore key' };\n }\n const pagination =\n isOffsetPagination(operation, [...parameters, ...bodyParameters]) ||\n isPagePagination(operation, [...parameters, ...bodyParameters]) ||\n isCursorPagination(operation, [...parameters, ...bodyParameters]);\n return pagination\n ? { ...pagination, items: itemsKey, hasMore: hasMoreKey }\n : { type: 'none', reason: 'no pagination' };\n}\n\nfunction excludeKey<T extends Record<string, any>>(\n obj: T,\n key: string,\n): Omit<T, typeof key> {\n const { [key]: _, ...rest } = obj;\n return rest;\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,aAAa;AACtB,SAAS,eAAe;AAExB,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB,oBAAoB;AA6CtC,MAAM,uBAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AACF;AAEO,MAAM,8BAAwC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,sBAAgC;AAAA;AAAA;AAAA,EAG3C;AAAA;AAAA;AAAA,EAEA;AACF;AAGO,MAAM,oBAA8B;AAAA,EACzC;AAAA;AAAA,EACA;AAAA;AAAA;AAAA,EAEA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AACF;AAGO,MAAM,iBAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AACF;AAGO,MAAM,uBAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AACF;AAGA,SAAS,oBACP,aACA,SACA,kBACA;AACA,aAAW,SAAS,aAAa;AAC/B,QAAI,MAAM,SAAS,kBAAkB;AACnC;AAAA,IACF;AACA,eAAW,SAAS,SAAS;AAC3B,YAAM,QAAQ,MAAM,KAAK,MAAM,KAAK;AACpC,UAAI,OAAO;AACT,eAAO,EAAE,OAAO,SAAS,MAAM,CAAC,EAAE;AA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2
2
|
import type { IR } from '../types.js';
|
|
3
3
|
export declare function getNextCursorName(schema: SchemaObject, spec: IR, visited?: Set<SchemaObject>): string | undefined;
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ export declare function getNextCursorName(schema: SchemaObject, spec: IR, visite
|
|
|
9
9
|
* @returns The name of the most likely property containing the items array,
|
|
10
10
|
* or null if no array properties are found in the schema.
|
|
11
11
|
*/
|
|
12
|
-
export declare function getItemsName(properties: Record<string, SchemaObject>): string | null;
|
|
12
|
+
export declare function getItemsName(properties: Record<string, SchemaObject | ReferenceObject>): string | null;
|
|
13
13
|
/**
|
|
14
14
|
* Tries to guess the name of a boolean property that indicates if there are more items
|
|
15
15
|
* to fetch (e.g., for pagination).
|
|
@@ -18,5 +18,5 @@ export declare function getItemsName(properties: Record<string, SchemaObject>):
|
|
|
18
18
|
* @returns The name of the most likely boolean property indicating "has more",
|
|
19
19
|
* or null if no suitable boolean property is found.
|
|
20
20
|
*/
|
|
21
|
-
export declare function getHasMoreName(properties:
|
|
21
|
+
export declare function getHasMoreName(properties: Record<string, SchemaObject | ReferenceObject>): string | null;
|
|
22
22
|
//# sourceMappingURL=pagination-result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination-result.d.ts","
|
|
1
|
+
{"version":3,"file":"pagination-result.d.ts","sources":["../../../src/lib/pagination/pagination-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMvE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,EAAE,EACR,OAAO,oBAA0B,GAChC,MAAM,GAAG,SAAS,CAyCpB;AAkID;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,GACzD,MAAM,GAAG,IAAI,CAqFf;AAsFD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,GACzD,MAAM,GAAG,IAAI,CAmBf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pluralize from "pluralize";
|
|
2
|
-
import { resolveRef } from "@sdk-it/core/ref.js";
|
|
2
|
+
import { isRef, resolveRef } from "@sdk-it/core/ref.js";
|
|
3
3
|
import { coerceTypes } from "../is.js";
|
|
4
4
|
function getNextCursorName(schema, spec, visited = /* @__PURE__ */ new Set()) {
|
|
5
5
|
if (visited.has(schema)) return void 0;
|
|
@@ -157,7 +157,7 @@ function getItemsName(properties) {
|
|
|
157
157
|
for (const propName in properties) {
|
|
158
158
|
if (propName in properties) {
|
|
159
159
|
const propSchema = properties[propName];
|
|
160
|
-
if (propSchema && propSchema.type === "array") {
|
|
160
|
+
if (propSchema && !isRef(propSchema) && propSchema.type === "array") {
|
|
161
161
|
arrayPropertyNames.push(propName);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -211,6 +211,9 @@ function guess(properties) {
|
|
|
211
211
|
const booleanPropertyNames = [];
|
|
212
212
|
for (const propName in properties) {
|
|
213
213
|
const propSchema = properties[propName];
|
|
214
|
+
if (isRef(propSchema)) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
214
217
|
if (propSchema.type === "boolean" || propSchema.type === "integer" || propSchema.type === "string") {
|
|
215
218
|
booleanPropertyNames.push(propName);
|
|
216
219
|
}
|
|
@@ -269,7 +272,7 @@ function getHasMoreName(properties) {
|
|
|
269
272
|
}
|
|
270
273
|
for (const propName in properties) {
|
|
271
274
|
const propSchema = properties[propName];
|
|
272
|
-
if (propSchema.type === "object" && propSchema.properties) {
|
|
275
|
+
if (!isRef(propSchema) && propSchema.type === "object" && propSchema.properties) {
|
|
273
276
|
const nested = getHasMoreName(propSchema.properties);
|
|
274
277
|
if (nested) {
|
|
275
278
|
return propName + "." + nested;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/pagination/pagination-result.ts"],
|
|
4
|
-
"sourcesContent": ["import type { SchemaObject, SchemasObject } from 'openapi3-ts/oas31';\nimport pluralize from 'pluralize';\n\nimport { resolveRef } from '@sdk-it/core/ref.js';\n\nimport { coerceTypes } from '../is.js';\nimport type { IR } from '../types.js';\n\nexport function getNextCursorName(\n schema: SchemaObject,\n spec: IR,\n visited = new Set<SchemaObject>(),\n): string | undefined {\n if (visited.has(schema)) return undefined;\n const ancestors = new Set(visited).add(schema);\n const properties = Object.entries(schema.properties ?? {}).map(\n ([name, property]) =>\n [name, resolveRef<SchemaObject>(spec, property)] as const,\n );\n for (const [name, property] of properties) {\n if (\n /^(nextcursor|nextpagetoken|nexttoken|continuationtoken|endcursor)$/i.test(\n name.replaceAll(/[_-]/g, ''),\n ) &&\n (property.anyOf ?? property.oneOf ?? [property]).some((variant) =>\n coerceTypes(resolveRef<SchemaObject>(spec, variant)).includes('string'),\n )\n ) {\n return name;\n }\n }\n for (const [name, property] of properties) {\n const nested = getNextCursorName(property, spec, ancestors);\n if (nested) return `${name}.${nested}`;\n }\n const candidates = new Set<string>();\n for (const variant of [...(schema.anyOf ?? []), ...(schema.oneOf ?? [])]) {\n const resolved = resolveRef<SchemaObject>(spec, variant);\n const types = coerceTypes(resolved, false);\n if (types.length === 1 && types[0] === 'null') continue;\n const candidate = getNextCursorName(resolved, spec, ancestors);\n if (!candidate) return undefined;\n candidates.add(candidate);\n }\n for (const variant of schema.allOf ?? []) {\n const candidate = getNextCursorName(\n resolveRef<SchemaObject>(spec, variant),\n spec,\n ancestors,\n );\n if (candidate) candidates.add(candidate);\n }\n return candidates.size === 1 ? candidates.values().next().value : undefined;\n}\n\nconst PRIMARY_TOP_TIER_KEYWORDS: string[] = [\n 'data',\n 'items',\n 'results',\n 'value',\n];\nconst PRIMARY_OTHER_KEYWORDS: string[] = [\n 'records',\n 'content',\n 'list',\n 'payload',\n 'entities',\n 'collection',\n 'users',\n 'products',\n 'orders',\n 'bookings',\n 'articles',\n 'posts',\n 'documents',\n 'events',\n];\nconst SECONDARY_KEYWORDS: string[] = ['entries', 'rows', 'elements'];\n\nfunction lastWord(propName: string) {\n return (\n propName\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter(Boolean)\n .at(-1) ?? ''\n );\n}\n\nfunction hasKeyword(propName: string, keywords: string[]) {\n return keywords.includes(lastWord(propName));\n}\n\nconst PLURAL_DEPRIORITIZE_LIST: string[] = [\n 'status',\n 'success',\n 'address',\n 'details',\n 'properties',\n 'params',\n 'headers',\n 'cookies',\n 'series',\n 'links',\n 'meta',\n 'metadata',\n 'statistics',\n 'settings',\n 'options',\n 'permissions',\n 'credentials',\n 'diagnostics',\n 'warnings',\n 'errors',\n 'actions',\n 'attributes',\n 'categories',\n 'configurations',\n 'features',\n 'includes',\n 'tags',\n];\n\n// For exact matches (normalized: lowercase, no underscores/hyphens)\nconst HAS_MORE_PRIMARY_POSITIVE_EXACT: string[] = [\n 'hasmore',\n 'hasnext',\n 'hasnextpage',\n 'moreitems',\n 'moreitemsavailable',\n 'nextpage',\n 'nextpageexists',\n 'nextpageavailable',\n 'hasadditionalresults',\n 'moreresultsavailable',\n 'canloadmore',\n 'hasadditional',\n 'additionalitems',\n 'fetchmore',\n];\n\nconst HAS_MORE_SECONDARY_POSITIVE_EXACT: string[] = ['more', 'next'];\n\nconst HAS_MORE_PRIMARY_INVERTED_EXACT: string[] = [\n 'islast',\n 'lastpage',\n 'endofresults',\n 'endoflist',\n 'nomoreitems',\n 'nomoredata',\n 'allitemsloaded',\n 'iscomplete',\n 'completed',\n];\n\n// For regex-based sub-phrase matching (tested against original propName, case-insensitive)\n// These regexes look for meaningful phrases, often using word boundaries (\\b)\n// and allowing for optional underscores.\nconst HAS_MORE_POSITIVE_REGEX_PATTERNS: string[] = [\n '\\\\bhas_?more\\\\b',\n '\\\\bhas_?next\\\\b', // e.g., itemsHasNext, items_has_next\n '\\\\bmore_?items\\\\b',\n '\\\\bnext_?page\\\\b', // e.g., userNextPageFlag\n '\\\\badditional\\\\b', // e.g., hasAdditionalData, additional_results_exist\n '\\\\bcontinuation\\\\b', // e.g., continuationAvailable, has_continuation_token\n '\\\\bmore_?results\\\\b',\n '\\\\bpage_?available\\\\b',\n '\\\\bnext(?:_?(page|marker))?\\\\b',\n];\nconst COMPILED_HAS_MORE_POSITIVE_REGEXES: RegExp[] =\n HAS_MORE_POSITIVE_REGEX_PATTERNS.map((p) => new RegExp(p, 'i'));\n\nconst HAS_MORE_INVERTED_REGEX_PATTERNS: string[] = [\n '\\\\bis_?last\\\\b', // e.g., pageIsLast\n '\\\\blast_?page\\\\b', // e.g., resultsAreLastPage\n '\\\\bend_?of_?(data|results|list|items|stream)\\\\b',\n '\\\\bno_?more_?(items|data|results)?\\\\b',\n '\\\\ball_?(items_?)?loaded\\\\b',\n '\\\\bis_?complete\\\\b',\n];\nconst COMPILED_HAS_MORE_INVERTED_REGEXES: RegExp[] =\n HAS_MORE_INVERTED_REGEX_PATTERNS.map((p) => new RegExp(p, 'i'));\n\n/**\n * Tries to guess the name of the property that holds the main list of items\n * within an object schema using a series of heuristics.\n *\n * @param schema The OpenAPI SchemaObject, expected to be of type 'object'.\n * @returns The name of the most likely property containing the items array,\n * or null if no array properties are found in the schema.\n */\nexport function getItemsName(\n properties: Record<string, SchemaObject>,\n): string | null {\n const arrayPropertyNames: string[] = [];\n for (const propName in properties) {\n if (propName in properties) {\n const propSchema = properties[propName] as SchemaObject;\n if (propSchema && propSchema.type === 'array') {\n arrayPropertyNames.push(propName);\n }\n }\n }\n\n // Heuristic 0: No array properties at all.\n if (arrayPropertyNames.length === 0) {\n return null;\n }\n\n // Heuristic 1: Exactly one array property. This is the strongest signal.\n if (arrayPropertyNames.length === 1) {\n return arrayPropertyNames[0];\n }\n\n // Multiple array properties exist. Apply ranked heuristics:\n let bestCandidate: string | null = null;\n let candidateRank = Infinity; // Lower is better\n\n const updateCandidate = (propName: string, rank: number) => {\n if (rank < candidateRank) {\n bestCandidate = propName;\n candidateRank = rank;\n }\n };\n\n for (const propName of arrayPropertyNames) {\n const lowerPropName = propName.toLowerCase();\n const finalWord = lastWord(propName);\n const isDeprioritized = PLURAL_DEPRIORITIZE_LIST.includes(lowerPropName);\n const isCompoundMetadata =\n finalWord !== lowerPropName &&\n PLURAL_DEPRIORITIZE_LIST.includes(finalWord);\n\n // Heuristic 2: Top-tier primary keywords (e.g., \"data\", \"items\")\n if (hasKeyword(propName, PRIMARY_TOP_TIER_KEYWORDS)) {\n updateCandidate(propName, 2);\n continue; // Move to next property, this is a strong match for this prop\n }\n\n // Heuristic 3: Other primary keywords\n if (candidateRank > 3 && hasKeyword(propName, PRIMARY_OTHER_KEYWORDS)) {\n updateCandidate(propName, 3);\n continue;\n }\n\n // Heuristic 4: Secondary keywords\n if (candidateRank > 4 && hasKeyword(propName, SECONDARY_KEYWORDS)) {\n updateCandidate(propName, 4);\n continue;\n }\n\n // Heuristic 5: Pluralized name, not on the deprioritize list\n if (\n candidateRank > 5 &&\n pluralize.isPlural(propName) &&\n !isDeprioritized &&\n !isCompoundMetadata\n ) {\n updateCandidate(propName, 5);\n continue;\n }\n\n // Heuristic 6: Pluralized name, IS on the deprioritize list (less preferred plural)\n if (candidateRank > 6 && pluralize.isPlural(propName) && isDeprioritized) {\n updateCandidate(propName, 6);\n continue;\n }\n }\n\n // If any of the above heuristics found a candidate, return it.\n if (bestCandidate) {\n return bestCandidate;\n }\n\n // Heuristic 7: Fallback - If no keywords or clear plurals,\n // and multiple arrays exist, return the first array property encountered.\n // This ensures we always return a name if arrays are present.\n return arrayPropertyNames[0];\n}\n\nfunction guess(properties: Record<string, SchemaObject>) {\n const booleanPropertyNames: string[] = [];\n for (const propName in properties) {\n const propSchema = properties[propName] as SchemaObject;\n if (\n propSchema.type === 'boolean' ||\n propSchema.type === 'integer' ||\n propSchema.type === 'string'\n ) {\n booleanPropertyNames.push(propName);\n }\n }\n\n if (booleanPropertyNames.length === 0) {\n return null;\n }\n\n if (booleanPropertyNames.length === 1) {\n return booleanPropertyNames[0];\n }\n\n let bestCandidate: string | null = null;\n let candidateRank = Infinity;\n\n const updateCandidate = (propName: string, rank: number) => {\n if (rank < candidateRank) {\n bestCandidate = propName;\n candidateRank = rank;\n }\n };\n\n for (const propName of booleanPropertyNames) {\n const normalizedForExactMatch = propName.toLowerCase().replace(/[-_]/g, '');\n let currentPropRank = Infinity;\n\n // Rank 1: Primary Exact Positive Match\n if (HAS_MORE_PRIMARY_POSITIVE_EXACT.includes(normalizedForExactMatch)) {\n currentPropRank = 1;\n }\n // Rank 2: Secondary Exact Positive Match\n else if (\n HAS_MORE_SECONDARY_POSITIVE_EXACT.includes(normalizedForExactMatch)\n ) {\n currentPropRank = 2;\n }\n // Rank 3: Positive Regex Match (sub-phrase)\n else {\n let foundPositiveRegex = false;\n for (const regex of COMPILED_HAS_MORE_POSITIVE_REGEXES) {\n if (regex.test(propName)) {\n // Test against original propName\n currentPropRank = 3;\n foundPositiveRegex = true;\n break;\n }\n }\n\n // Only proceed to inverted matches if no positive match of any kind (Rank 1, 2, or 3) was found\n if (!foundPositiveRegex) {\n // Rank 4: Primary Exact Inverted Match\n if (HAS_MORE_PRIMARY_INVERTED_EXACT.includes(normalizedForExactMatch)) {\n currentPropRank = 4;\n }\n // Rank 5: Inverted Regex Match (sub-phrase)\n else {\n for (const regex of COMPILED_HAS_MORE_INVERTED_REGEXES) {\n if (regex.test(propName)) {\n // Test against original propName\n currentPropRank = 5;\n break;\n }\n }\n }\n }\n }\n\n updateCandidate(propName, currentPropRank);\n }\n return bestCandidate;\n}\n\n/**\n * Tries to guess the name of a boolean property that indicates if there are more items\n * to fetch (e.g., for pagination).\n *\n * @param schema The OpenAPI SchemaObject, expected to be of type 'object'.\n * @returns The name of the most likely boolean property indicating \"has more\",\n * or null if no suitable boolean property is found.\n */\nexport function getHasMoreName(properties: SchemasObject): string | null {\n const rootGuess = guess(properties);\n if (rootGuess) {\n return rootGuess;\n }\n for (const propName in properties) {\n const propSchema = properties[propName];\n if (propSchema.type === 'object' && propSchema.properties) {\n const nested = getHasMoreName(propSchema.properties as SchemasObject);\n if (nested) {\n return propName + '.' + nested;\n }\n }\n }\n return null;\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAAO,eAAe;AAEtB,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\nimport pluralize from 'pluralize';\n\nimport { isRef, resolveRef } from '@sdk-it/core/ref.js';\n\nimport { coerceTypes } from '../is.js';\nimport type { IR } from '../types.js';\n\nexport function getNextCursorName(\n schema: SchemaObject,\n spec: IR,\n visited = new Set<SchemaObject>(),\n): string | undefined {\n if (visited.has(schema)) return undefined;\n const ancestors = new Set(visited).add(schema);\n const properties = Object.entries(schema.properties ?? {}).map(\n ([name, property]) =>\n [name, resolveRef<SchemaObject>(spec, property)] as const,\n );\n for (const [name, property] of properties) {\n if (\n /^(nextcursor|nextpagetoken|nexttoken|continuationtoken|endcursor)$/i.test(\n name.replaceAll(/[_-]/g, ''),\n ) &&\n (property.anyOf ?? property.oneOf ?? [property]).some((variant) =>\n coerceTypes(resolveRef<SchemaObject>(spec, variant)).includes('string'),\n )\n ) {\n return name;\n }\n }\n for (const [name, property] of properties) {\n const nested = getNextCursorName(property, spec, ancestors);\n if (nested) return `${name}.${nested}`;\n }\n const candidates = new Set<string>();\n for (const variant of [...(schema.anyOf ?? []), ...(schema.oneOf ?? [])]) {\n const resolved = resolveRef<SchemaObject>(spec, variant);\n const types = coerceTypes(resolved, false);\n if (types.length === 1 && types[0] === 'null') continue;\n const candidate = getNextCursorName(resolved, spec, ancestors);\n if (!candidate) return undefined;\n candidates.add(candidate);\n }\n for (const variant of schema.allOf ?? []) {\n const candidate = getNextCursorName(\n resolveRef<SchemaObject>(spec, variant),\n spec,\n ancestors,\n );\n if (candidate) candidates.add(candidate);\n }\n return candidates.size === 1 ? candidates.values().next().value : undefined;\n}\n\nconst PRIMARY_TOP_TIER_KEYWORDS: string[] = [\n 'data',\n 'items',\n 'results',\n 'value',\n];\nconst PRIMARY_OTHER_KEYWORDS: string[] = [\n 'records',\n 'content',\n 'list',\n 'payload',\n 'entities',\n 'collection',\n 'users',\n 'products',\n 'orders',\n 'bookings',\n 'articles',\n 'posts',\n 'documents',\n 'events',\n];\nconst SECONDARY_KEYWORDS: string[] = ['entries', 'rows', 'elements'];\n\nfunction lastWord(propName: string) {\n return (\n propName\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter(Boolean)\n .at(-1) ?? ''\n );\n}\n\nfunction hasKeyword(propName: string, keywords: string[]) {\n return keywords.includes(lastWord(propName));\n}\n\nconst PLURAL_DEPRIORITIZE_LIST: string[] = [\n 'status',\n 'success',\n 'address',\n 'details',\n 'properties',\n 'params',\n 'headers',\n 'cookies',\n 'series',\n 'links',\n 'meta',\n 'metadata',\n 'statistics',\n 'settings',\n 'options',\n 'permissions',\n 'credentials',\n 'diagnostics',\n 'warnings',\n 'errors',\n 'actions',\n 'attributes',\n 'categories',\n 'configurations',\n 'features',\n 'includes',\n 'tags',\n];\n\n// For exact matches (normalized: lowercase, no underscores/hyphens)\nconst HAS_MORE_PRIMARY_POSITIVE_EXACT: string[] = [\n 'hasmore',\n 'hasnext',\n 'hasnextpage',\n 'moreitems',\n 'moreitemsavailable',\n 'nextpage',\n 'nextpageexists',\n 'nextpageavailable',\n 'hasadditionalresults',\n 'moreresultsavailable',\n 'canloadmore',\n 'hasadditional',\n 'additionalitems',\n 'fetchmore',\n];\n\nconst HAS_MORE_SECONDARY_POSITIVE_EXACT: string[] = ['more', 'next'];\n\nconst HAS_MORE_PRIMARY_INVERTED_EXACT: string[] = [\n 'islast',\n 'lastpage',\n 'endofresults',\n 'endoflist',\n 'nomoreitems',\n 'nomoredata',\n 'allitemsloaded',\n 'iscomplete',\n 'completed',\n];\n\n// For regex-based sub-phrase matching (tested against original propName, case-insensitive)\n// These regexes look for meaningful phrases, often using word boundaries (\\b)\n// and allowing for optional underscores.\nconst HAS_MORE_POSITIVE_REGEX_PATTERNS: string[] = [\n '\\\\bhas_?more\\\\b',\n '\\\\bhas_?next\\\\b', // e.g., itemsHasNext, items_has_next\n '\\\\bmore_?items\\\\b',\n '\\\\bnext_?page\\\\b', // e.g., userNextPageFlag\n '\\\\badditional\\\\b', // e.g., hasAdditionalData, additional_results_exist\n '\\\\bcontinuation\\\\b', // e.g., continuationAvailable, has_continuation_token\n '\\\\bmore_?results\\\\b',\n '\\\\bpage_?available\\\\b',\n '\\\\bnext(?:_?(page|marker))?\\\\b',\n];\nconst COMPILED_HAS_MORE_POSITIVE_REGEXES: RegExp[] =\n HAS_MORE_POSITIVE_REGEX_PATTERNS.map((p) => new RegExp(p, 'i'));\n\nconst HAS_MORE_INVERTED_REGEX_PATTERNS: string[] = [\n '\\\\bis_?last\\\\b', // e.g., pageIsLast\n '\\\\blast_?page\\\\b', // e.g., resultsAreLastPage\n '\\\\bend_?of_?(data|results|list|items|stream)\\\\b',\n '\\\\bno_?more_?(items|data|results)?\\\\b',\n '\\\\ball_?(items_?)?loaded\\\\b',\n '\\\\bis_?complete\\\\b',\n];\nconst COMPILED_HAS_MORE_INVERTED_REGEXES: RegExp[] =\n HAS_MORE_INVERTED_REGEX_PATTERNS.map((p) => new RegExp(p, 'i'));\n\n/**\n * Tries to guess the name of the property that holds the main list of items\n * within an object schema using a series of heuristics.\n *\n * @param schema The OpenAPI SchemaObject, expected to be of type 'object'.\n * @returns The name of the most likely property containing the items array,\n * or null if no array properties are found in the schema.\n */\nexport function getItemsName(\n properties: Record<string, SchemaObject | ReferenceObject>,\n): string | null {\n const arrayPropertyNames: string[] = [];\n for (const propName in properties) {\n if (propName in properties) {\n const propSchema = properties[propName];\n if (propSchema && !isRef(propSchema) && propSchema.type === 'array') {\n arrayPropertyNames.push(propName);\n }\n }\n }\n\n // Heuristic 0: No array properties at all.\n if (arrayPropertyNames.length === 0) {\n return null;\n }\n\n // Heuristic 1: Exactly one array property. This is the strongest signal.\n if (arrayPropertyNames.length === 1) {\n return arrayPropertyNames[0];\n }\n\n // Multiple array properties exist. Apply ranked heuristics:\n let bestCandidate: string | null = null;\n let candidateRank = Infinity; // Lower is better\n\n const updateCandidate = (propName: string, rank: number) => {\n if (rank < candidateRank) {\n bestCandidate = propName;\n candidateRank = rank;\n }\n };\n\n for (const propName of arrayPropertyNames) {\n const lowerPropName = propName.toLowerCase();\n const finalWord = lastWord(propName);\n const isDeprioritized = PLURAL_DEPRIORITIZE_LIST.includes(lowerPropName);\n const isCompoundMetadata =\n finalWord !== lowerPropName &&\n PLURAL_DEPRIORITIZE_LIST.includes(finalWord);\n\n // Heuristic 2: Top-tier primary keywords (e.g., \"data\", \"items\")\n if (hasKeyword(propName, PRIMARY_TOP_TIER_KEYWORDS)) {\n updateCandidate(propName, 2);\n continue; // Move to next property, this is a strong match for this prop\n }\n\n // Heuristic 3: Other primary keywords\n if (candidateRank > 3 && hasKeyword(propName, PRIMARY_OTHER_KEYWORDS)) {\n updateCandidate(propName, 3);\n continue;\n }\n\n // Heuristic 4: Secondary keywords\n if (candidateRank > 4 && hasKeyword(propName, SECONDARY_KEYWORDS)) {\n updateCandidate(propName, 4);\n continue;\n }\n\n // Heuristic 5: Pluralized name, not on the deprioritize list\n if (\n candidateRank > 5 &&\n pluralize.isPlural(propName) &&\n !isDeprioritized &&\n !isCompoundMetadata\n ) {\n updateCandidate(propName, 5);\n continue;\n }\n\n // Heuristic 6: Pluralized name, IS on the deprioritize list (less preferred plural)\n if (candidateRank > 6 && pluralize.isPlural(propName) && isDeprioritized) {\n updateCandidate(propName, 6);\n continue;\n }\n }\n\n // If any of the above heuristics found a candidate, return it.\n if (bestCandidate) {\n return bestCandidate;\n }\n\n // Heuristic 7: Fallback - If no keywords or clear plurals,\n // and multiple arrays exist, return the first array property encountered.\n // This ensures we always return a name if arrays are present.\n return arrayPropertyNames[0];\n}\n\nfunction guess(properties: Record<string, SchemaObject | ReferenceObject>) {\n const booleanPropertyNames: string[] = [];\n for (const propName in properties) {\n const propSchema = properties[propName];\n if (isRef(propSchema)) {\n continue;\n }\n if (\n propSchema.type === 'boolean' ||\n propSchema.type === 'integer' ||\n propSchema.type === 'string'\n ) {\n booleanPropertyNames.push(propName);\n }\n }\n\n if (booleanPropertyNames.length === 0) {\n return null;\n }\n\n if (booleanPropertyNames.length === 1) {\n return booleanPropertyNames[0];\n }\n\n let bestCandidate: string | null = null;\n let candidateRank = Infinity;\n\n const updateCandidate = (propName: string, rank: number) => {\n if (rank < candidateRank) {\n bestCandidate = propName;\n candidateRank = rank;\n }\n };\n\n for (const propName of booleanPropertyNames) {\n const normalizedForExactMatch = propName.toLowerCase().replace(/[-_]/g, '');\n let currentPropRank = Infinity;\n\n // Rank 1: Primary Exact Positive Match\n if (HAS_MORE_PRIMARY_POSITIVE_EXACT.includes(normalizedForExactMatch)) {\n currentPropRank = 1;\n }\n // Rank 2: Secondary Exact Positive Match\n else if (\n HAS_MORE_SECONDARY_POSITIVE_EXACT.includes(normalizedForExactMatch)\n ) {\n currentPropRank = 2;\n }\n // Rank 3: Positive Regex Match (sub-phrase)\n else {\n let foundPositiveRegex = false;\n for (const regex of COMPILED_HAS_MORE_POSITIVE_REGEXES) {\n if (regex.test(propName)) {\n // Test against original propName\n currentPropRank = 3;\n foundPositiveRegex = true;\n break;\n }\n }\n\n // Only proceed to inverted matches if no positive match of any kind (Rank 1, 2, or 3) was found\n if (!foundPositiveRegex) {\n // Rank 4: Primary Exact Inverted Match\n if (HAS_MORE_PRIMARY_INVERTED_EXACT.includes(normalizedForExactMatch)) {\n currentPropRank = 4;\n }\n // Rank 5: Inverted Regex Match (sub-phrase)\n else {\n for (const regex of COMPILED_HAS_MORE_INVERTED_REGEXES) {\n if (regex.test(propName)) {\n // Test against original propName\n currentPropRank = 5;\n break;\n }\n }\n }\n }\n }\n\n updateCandidate(propName, currentPropRank);\n }\n return bestCandidate;\n}\n\n/**\n * Tries to guess the name of a boolean property that indicates if there are more items\n * to fetch (e.g., for pagination).\n *\n * @param schema The OpenAPI SchemaObject, expected to be of type 'object'.\n * @returns The name of the most likely boolean property indicating \"has more\",\n * or null if no suitable boolean property is found.\n */\nexport function getHasMoreName(\n properties: Record<string, SchemaObject | ReferenceObject>,\n): string | null {\n const rootGuess = guess(properties);\n if (rootGuess) {\n return rootGuess;\n }\n for (const propName in properties) {\n const propSchema = properties[propName];\n if (\n !isRef(propSchema) &&\n propSchema.type === 'object' &&\n propSchema.properties\n ) {\n const nested = getHasMoreName(propSchema.properties);\n if (nested) {\n return propName + '.' + nested;\n }\n }\n }\n return null;\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAO,eAAe;AAEtB,SAAS,OAAO,kBAAkB;AAElC,SAAS,mBAAmB;AAGrB,SAAS,kBACd,QACA,MACA,UAAU,oBAAI,IAAkB,GACZ;AACpB,MAAI,QAAQ,IAAI,MAAM,EAAG,QAAO;AAChC,QAAM,YAAY,IAAI,IAAI,OAAO,EAAE,IAAI,MAAM;AAC7C,QAAM,aAAa,OAAO,QAAQ,OAAO,cAAc,CAAC,CAAC,EAAE;AAAA,IACzD,CAAC,CAAC,MAAM,QAAQ,MACd,CAAC,MAAM,WAAyB,MAAM,QAAQ,CAAC;AAAA,EACnD;AACA,aAAW,CAAC,MAAM,QAAQ,KAAK,YAAY;AACzC,QACE,sEAAsE;AAAA,MACpE,KAAK,WAAW,SAAS,EAAE;AAAA,IAC7B,MACC,SAAS,SAAS,SAAS,SAAS,CAAC,QAAQ,GAAG;AAAA,MAAK,CAAC,YACrD,YAAY,WAAyB,MAAM,OAAO,CAAC,EAAE,SAAS,QAAQ;AAAA,IACxE,GACA;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,aAAW,CAAC,MAAM,QAAQ,KAAK,YAAY;AACzC,UAAM,SAAS,kBAAkB,UAAU,MAAM,SAAS;AAC1D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UAAU,KACjB,WAAW,SAAS,YACpB,WAAW,YACX;AACA,YAAM,SAAS,eAAe,WAAW,UAAU;AACnD,UAAI,QAAQ;AACV,eAAO,WAAW,MAAM;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,33 @@
|
|
|
1
1
|
import type { IR, TunedOperationObject } from '../types.js';
|
|
2
|
-
export declare function toPagination(spec: IR, tunedOperation: TunedOperationObject):
|
|
2
|
+
export declare function toPagination(spec: IR, tunedOperation: TunedOperationObject): {
|
|
3
|
+
type: 'cursor';
|
|
4
|
+
cursorParamName: string;
|
|
5
|
+
cursorKeyword: string;
|
|
6
|
+
limitParamName: string;
|
|
7
|
+
limitKeyword: string;
|
|
8
|
+
nextCursor?: string;
|
|
9
|
+
items: string;
|
|
10
|
+
hasMore: string;
|
|
11
|
+
statusCode: number;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'offset';
|
|
14
|
+
offsetParamName: string;
|
|
15
|
+
offsetKeyword: string;
|
|
16
|
+
limitParamName: string;
|
|
17
|
+
limitKeyword: string;
|
|
18
|
+
items: string;
|
|
19
|
+
hasMore: string;
|
|
20
|
+
statusCode: number;
|
|
21
|
+
start?: number | undefined;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'page';
|
|
24
|
+
pageNumberParamName: string;
|
|
25
|
+
pageNumberKeyword: string;
|
|
26
|
+
pageSizeParamName: string;
|
|
27
|
+
pageSizeKeyword: string;
|
|
28
|
+
items: string;
|
|
29
|
+
hasMore: string;
|
|
30
|
+
statusCode: number;
|
|
31
|
+
start?: number | undefined;
|
|
32
|
+
} | undefined;
|
|
3
33
|
//# sourceMappingURL=pagination.d.ts.map
|