@sdk-it/spec 0.22.0 → 0.23.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.
Files changed (91) hide show
  1. package/dist/index.d.ts +7 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +19 -2629
  4. package/dist/index.js.map +4 -4
  5. package/dist/lib/find-polymorphic-varients.d.ts +1 -1
  6. package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
  7. package/dist/lib/find-polymorphic-varients.js +291 -0
  8. package/dist/lib/find-polymorphic-varients.js.map +7 -0
  9. package/dist/lib/find-polymorphic-varients.test.js +615 -0
  10. package/dist/lib/find-polymorphic-varients.test.js.map +7 -0
  11. package/dist/lib/find-unique-schema-name.js +16 -0
  12. package/dist/lib/find-unique-schema-name.js.map +7 -0
  13. package/dist/lib/for-each-operation.d.ts +3 -0
  14. package/dist/lib/for-each-operation.d.ts.map +1 -0
  15. package/dist/lib/for-each-operation.js +30 -0
  16. package/dist/lib/for-each-operation.js.map +7 -0
  17. package/dist/lib/format-name.js +86 -0
  18. package/dist/lib/format-name.js.map +7 -0
  19. package/dist/lib/get-ref-usage.d.ts +1 -1
  20. package/dist/lib/get-ref-usage.d.ts.map +1 -1
  21. package/dist/lib/get-ref-usage.js +52 -0
  22. package/dist/lib/get-ref-usage.js.map +7 -0
  23. package/dist/lib/is-primitive-schema.js +12 -0
  24. package/dist/lib/is-primitive-schema.js.map +7 -0
  25. package/dist/lib/is.d.ts +14 -0
  26. package/dist/lib/is.d.ts.map +1 -0
  27. package/dist/lib/is.js +71 -0
  28. package/dist/lib/is.js.map +7 -0
  29. package/dist/lib/loaders/load-spec.js +25 -0
  30. package/dist/lib/loaders/load-spec.js.map +7 -0
  31. package/dist/lib/loaders/local-loader.js +20 -0
  32. package/dist/lib/loaders/local-loader.js.map +7 -0
  33. package/dist/lib/loaders/postman/postman-converter.js +483 -0
  34. package/dist/lib/loaders/postman/postman-converter.js.map +7 -0
  35. package/dist/lib/loaders/postman/spec-types.js +1 -0
  36. package/dist/lib/loaders/postman/spec-types.js.map +7 -0
  37. package/dist/lib/loaders/remote-loader.js +29 -0
  38. package/dist/lib/loaders/remote-loader.js.map +7 -0
  39. package/dist/lib/metadata.js +51 -0
  40. package/dist/lib/metadata.js.map +7 -0
  41. package/dist/lib/operation.d.ts +4 -75
  42. package/dist/lib/operation.d.ts.map +1 -1
  43. package/dist/lib/operation.js +402 -0
  44. package/dist/lib/operation.js.map +7 -0
  45. package/dist/lib/operation.test.js +261 -0
  46. package/dist/lib/operation.test.js.map +7 -0
  47. package/dist/lib/options.d.ts +30 -0
  48. package/dist/lib/options.d.ts.map +1 -0
  49. package/dist/lib/options.js +54 -0
  50. package/dist/lib/options.js.map +7 -0
  51. package/dist/lib/overview-docs.d.ts +4 -0
  52. package/dist/lib/overview-docs.d.ts.map +1 -0
  53. package/dist/lib/overview-docs.js +276 -0
  54. package/dist/lib/overview-docs.js.map +7 -0
  55. package/dist/lib/pagination/pagination-result.js +235 -0
  56. package/dist/lib/pagination/pagination-result.js.map +7 -0
  57. package/dist/lib/pagination/pagination-result.test.js +548 -0
  58. package/dist/lib/pagination/pagination-result.test.js.map +7 -0
  59. package/dist/lib/pagination/pagination.d.ts +1 -1
  60. package/dist/lib/pagination/pagination.d.ts.map +1 -1
  61. package/dist/lib/pagination/pagination.js +222 -0
  62. package/dist/lib/pagination/pagination.js.map +7 -0
  63. package/dist/lib/pagination/pagination.test.js +378 -0
  64. package/dist/lib/pagination/pagination.test.js.map +7 -0
  65. package/dist/lib/reserved-keywords.d.ts +6 -0
  66. package/dist/lib/reserved-keywords.d.ts.map +1 -0
  67. package/dist/lib/reserved-keywords.js +71 -0
  68. package/dist/lib/reserved-keywords.js.map +7 -0
  69. package/dist/lib/security.d.ts +6 -4
  70. package/dist/lib/security.d.ts.map +1 -1
  71. package/dist/lib/security.js +75 -0
  72. package/dist/lib/security.js.map +7 -0
  73. package/dist/lib/sidebar.d.ts +5 -3
  74. package/dist/lib/sidebar.d.ts.map +1 -1
  75. package/dist/lib/sidebar.js +79 -0
  76. package/dist/lib/sidebar.js.map +7 -0
  77. package/dist/lib/tag.d.ts +19 -0
  78. package/dist/lib/tag.d.ts.map +1 -0
  79. package/dist/lib/tag.js +132 -0
  80. package/dist/lib/tag.js.map +7 -0
  81. package/dist/lib/tune.d.ts +1 -1
  82. package/dist/lib/tune.d.ts.map +1 -1
  83. package/dist/lib/tune.js +291 -0
  84. package/dist/lib/tune.js.map +7 -0
  85. package/dist/lib/tune.test.js +60 -0
  86. package/dist/lib/tune.test.js.map +7 -0
  87. package/dist/lib/types.d.ts +37 -0
  88. package/dist/lib/types.d.ts.map +1 -0
  89. package/dist/lib/types.js +1 -0
  90. package/dist/lib/types.js.map +7 -0
  91. package/package.json +4 -3
@@ -0,0 +1,276 @@
1
+ import { resolveRef } from "@sdk-it/core/ref.js";
2
+ import { forEachOperation } from "./for-each-operation.js";
3
+ import { isErrorStatusCode } from "./is.js";
4
+ function generateIntroductionMarkdown(spec) {
5
+ const info = spec.info;
6
+ let markdown = "";
7
+ if (info.title) {
8
+ markdown += `# ${info.title}
9
+
10
+ `;
11
+ }
12
+ if (info.description) {
13
+ markdown += `${info.description}
14
+
15
+ `;
16
+ }
17
+ if (info.version) {
18
+ markdown += `**Version:** ${info.version}
19
+
20
+ `;
21
+ }
22
+ if (info.contact) {
23
+ markdown += `## Contact
24
+
25
+ `;
26
+ if (info.contact.name) {
27
+ markdown += `**Name:** ${info.contact.name}
28
+
29
+ `;
30
+ }
31
+ if (info.contact.email) {
32
+ markdown += `**Email:** ${info.contact.email}
33
+
34
+ `;
35
+ }
36
+ if (info.contact.url) {
37
+ markdown += `**URL:** ${info.contact.url}
38
+
39
+ `;
40
+ }
41
+ }
42
+ if (info.license) {
43
+ markdown += `## License
44
+
45
+ `;
46
+ if (info.license.name) {
47
+ markdown += `**License:** ${info.license.name}`;
48
+ if (info.license.url) {
49
+ markdown += ` ([${info.license.url}](${info.license.url}))`;
50
+ }
51
+ markdown += `
52
+
53
+ `;
54
+ }
55
+ }
56
+ markdown += `## Available SDKs
57
+
58
+ `;
59
+ const sdkLinks = [
60
+ "/typescript-sdk",
61
+ "/python-sdk",
62
+ "/go-sdk",
63
+ "/java-sdk",
64
+ "/php-sdk",
65
+ "/ruby-sdk",
66
+ "/dart-sdk"
67
+ ];
68
+ for (const link of sdkLinks) {
69
+ const sdkName = link.replace("/", "").replace("-sdk", "").toUpperCase();
70
+ markdown += `- [${sdkName} SDK](${link})
71
+ `;
72
+ }
73
+ return markdown;
74
+ }
75
+ function getStatusDescription(statusCode) {
76
+ const descriptions = {
77
+ "400": "Bad Request - The request was invalid or cannot be served.",
78
+ "401": "Unauthorized - Authentication is required and has failed or has not been provided.",
79
+ "403": "Forbidden - The request was valid, but the server is refusing action.",
80
+ "404": "Not Found - The requested resource could not be found.",
81
+ "422": "Unprocessable Entity - The request was well-formed but contains semantic errors.",
82
+ "429": "Too Many Requests - The user has sent too many requests in a given amount of time.",
83
+ "500": "Internal Server Error - The server encountered an unexpected condition.",
84
+ "502": "Bad Gateway - The server received an invalid response from the upstream server.",
85
+ "503": "Service Unavailable - The server is currently unavailable."
86
+ };
87
+ return descriptions[statusCode] || "An error occurred while processing the request.";
88
+ }
89
+ function generateErrorsMarkdown(errorSchemas) {
90
+ let markdown = `# Error Handling
91
+
92
+ `;
93
+ markdown += `This API uses conventional HTTP response codes to indicate the success or failure of an API request.
94
+
95
+ `;
96
+ markdown += `## HTTP Status Codes
97
+
98
+ `;
99
+ const errors = Array.from(errorSchemas.values()).sort(
100
+ (a, b) => parseInt(a.statusCode) - parseInt(b.statusCode)
101
+ );
102
+ for (const error of errors) {
103
+ markdown += `### ${error.statusCode} - ${error.title}
104
+
105
+ `;
106
+ const description = error.description || getStatusDescription(error.statusCode);
107
+ if (description) {
108
+ markdown += `${description}
109
+
110
+ `;
111
+ }
112
+ if (error.schema) {
113
+ markdown += `**Response Schema:**
114
+
115
+ `;
116
+ markdown += `\`\`\`json
117
+ ${JSON.stringify(
118
+ error.schema,
119
+ null,
120
+ 2
121
+ )}
122
+ \`\`\`
123
+
124
+ `;
125
+ }
126
+ }
127
+ return markdown;
128
+ }
129
+ function getSecuritySchemeDescription(scheme) {
130
+ switch (scheme.type.toLowerCase()) {
131
+ case "apikey":
132
+ return `This API uses an API key for authentication. The key should be sent in the \`${scheme.in}\` named \`${scheme.name}\`.`;
133
+ case "http":
134
+ if (scheme.scheme === "bearer") {
135
+ return `This API uses HTTP Bearer authentication. A token should be included in the Authorization header.`;
136
+ }
137
+ return `This API uses HTTP ${scheme.scheme} authentication.`;
138
+ case "oauth2": {
139
+ const flows = Object.keys(scheme.flows || {});
140
+ return `This API uses OAuth 2.0 for authentication with the following flow(s): ${flows.join(
141
+ ", "
142
+ )}.`;
143
+ }
144
+ case "openidconnect":
145
+ return `This API uses OpenID Connect for authentication. The OpenID Connect URL is: ${scheme.openIdConnectUrl}`;
146
+ default:
147
+ return "This API uses a custom authentication scheme.";
148
+ }
149
+ }
150
+ function generateAuthorizationMarkdown(spec) {
151
+ let markdown = `# Authorization
152
+
153
+ `;
154
+ const securitySchemes = spec.components?.securitySchemes || {};
155
+ const globalSecurity = spec.security || [];
156
+ if (Object.keys(securitySchemes).length > 0) {
157
+ markdown += `This API uses the following authentication schemes:
158
+
159
+ `;
160
+ markdown += `## Security Schemes
161
+
162
+ `;
163
+ for (const [name, scheme] of Object.entries(securitySchemes)) {
164
+ const schemeObj = resolveRef(spec, scheme);
165
+ markdown += `### ${name}
166
+
167
+ `;
168
+ const description = schemeObj.description || getSecuritySchemeDescription(schemeObj);
169
+ markdown += `${description}
170
+
171
+ `;
172
+ markdown += `**Type:** \`${schemeObj.type}\`
173
+
174
+ `;
175
+ if (schemeObj.type === "http") {
176
+ markdown += `**Scheme:** \`${schemeObj.scheme}\`
177
+
178
+ `;
179
+ if (schemeObj.bearerFormat) {
180
+ markdown += `**Bearer Format:** \`${schemeObj.bearerFormat}\`
181
+
182
+ `;
183
+ }
184
+ } else if (schemeObj.type === "oauth2") {
185
+ markdown += `**Flows:**
186
+
187
+ `;
188
+ markdown += `\`\`\`json
189
+ ${JSON.stringify(
190
+ schemeObj.flows,
191
+ null,
192
+ 2
193
+ )}
194
+ \`\`\`
195
+
196
+ `;
197
+ }
198
+ }
199
+ }
200
+ if (globalSecurity.length > 0) {
201
+ markdown += `## Global Security Requirements
202
+
203
+ `;
204
+ markdown += `These security schemes are required for all operations.
205
+
206
+ `;
207
+ markdown += `\`\`\`json
208
+ ${JSON.stringify(
209
+ globalSecurity,
210
+ null,
211
+ 2
212
+ )}
213
+ \`\`\`
214
+
215
+ `;
216
+ }
217
+ return markdown;
218
+ }
219
+ function extractOverviewDocs(spec) {
220
+ const introduction = {
221
+ id: "introduction",
222
+ title: "Introduction",
223
+ url: "/introduction",
224
+ description: "API overview and getting started guide",
225
+ content: generateIntroductionMarkdown(spec)
226
+ };
227
+ const errorSchemas = /* @__PURE__ */ new Map();
228
+ forEachOperation(spec, (entry, operation) => {
229
+ if (operation.responses) {
230
+ for (const [statusCode, response] of Object.entries(
231
+ operation.responses
232
+ )) {
233
+ if (isErrorStatusCode(statusCode)) {
234
+ const content = response.content;
235
+ if (content?.["application/json"]?.schema) {
236
+ const key = `${statusCode}`;
237
+ if (!errorSchemas.has(key)) {
238
+ errorSchemas.set(key, {
239
+ statusCode,
240
+ title: response.description || `${statusCode} Error`,
241
+ description: response.description,
242
+ schema: content["application/json"].schema
243
+ });
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+ });
250
+ const errors = {
251
+ id: "errors",
252
+ title: "Errors",
253
+ url: "/errors",
254
+ description: "Error handling and HTTP status codes",
255
+ content: generateErrorsMarkdown(errorSchemas)
256
+ };
257
+ const authorization = {
258
+ id: "authorization",
259
+ url: "/authorization",
260
+ title: "Authorization",
261
+ description: "Authentication methods and security schemes",
262
+ content: generateAuthorizationMarkdown(spec)
263
+ };
264
+ const docs = [introduction, errors, authorization];
265
+ return [
266
+ {
267
+ id: "overview",
268
+ category: "Overview",
269
+ items: docs
270
+ }
271
+ ];
272
+ }
273
+ export {
274
+ extractOverviewDocs
275
+ };
276
+ //# sourceMappingURL=overview-docs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/overview-docs.ts"],
4
+ "sourcesContent": ["import type { SchemaObject, SecuritySchemeObject } from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core/ref.js';\n\nimport { forEachOperation } from './for-each-operation.js';\nimport { isErrorStatusCode } from './is.js';\nimport type { NavItem, SidebarData } from './sidebar.js';\nimport type { OurOpenAPIObject } from './types.js';\n\ninterface ErrorSchema {\n statusCode: string;\n title: string;\n description?: string;\n schema: SchemaObject;\n}\n\nfunction generateIntroductionMarkdown(spec: OurOpenAPIObject): string {\n const info = spec.info;\n let markdown = '';\n\n if (info.title) {\n markdown += `# ${info.title}\\n\\n`;\n }\n\n if (info.description) {\n markdown += `${info.description}\\n\\n`;\n }\n\n if (info.version) {\n markdown += `**Version:** ${info.version}\\n\\n`;\n }\n\n if (info.contact) {\n markdown += `## Contact\\n\\n`;\n if (info.contact.name) {\n markdown += `**Name:** ${info.contact.name}\\n\\n`;\n }\n if (info.contact.email) {\n markdown += `**Email:** ${info.contact.email}\\n\\n`;\n }\n if (info.contact.url) {\n markdown += `**URL:** ${info.contact.url}\\n\\n`;\n }\n }\n\n if (info.license) {\n markdown += `## License\\n\\n`;\n if (info.license.name) {\n markdown += `**License:** ${info.license.name}`;\n if (info.license.url) {\n markdown += ` ([${info.license.url}](${info.license.url}))`;\n }\n markdown += `\\n\\n`;\n }\n }\n\n // Add SDK links\n markdown += `## Available SDKs\\n\\n`;\n const sdkLinks = [\n '/typescript-sdk',\n '/python-sdk',\n '/go-sdk',\n '/java-sdk',\n '/php-sdk',\n '/ruby-sdk',\n '/dart-sdk',\n ];\n\n for (const link of sdkLinks) {\n const sdkName = link.replace('/', '').replace('-sdk', '').toUpperCase();\n markdown += `- [${sdkName} SDK](${link})\\n`;\n }\n\n return markdown;\n}\n\nfunction getStatusDescription(statusCode: string): string {\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 '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 '422':\n 'Unprocessable Entity - The request was well-formed but contains semantic errors.',\n '429':\n 'Too Many Requests - The user has sent too many requests in a given amount of time.',\n '500':\n 'Internal Server Error - The server encountered an unexpected condition.',\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 };\n return (\n descriptions[statusCode] ||\n 'An error occurred while processing the request.'\n );\n}\n\nfunction generateErrorsMarkdown(\n errorSchemas: Map<string, ErrorSchema>,\n): string {\n let markdown = `# Error Handling\\n\\n`;\n markdown += `This API uses conventional HTTP response codes to indicate the success or failure of an API request.\\n\\n`;\n markdown += `## HTTP Status Codes\\n\\n`;\n\n const errors = Array.from(errorSchemas.values()).sort(\n (a, b) => parseInt(a.statusCode) - parseInt(b.statusCode),\n );\n\n for (const error of errors) {\n markdown += `### ${error.statusCode} - ${error.title}\\n\\n`;\n const description =\n error.description || getStatusDescription(error.statusCode);\n if (description) {\n markdown += `${description}\\n\\n`;\n }\n if (error.schema) {\n markdown += `**Response Schema:**\\n\\n`;\n markdown += `\\`\\`\\`json\\n${JSON.stringify(\n error.schema,\n null,\n 2,\n )}\\n\\`\\`\\`\\n\\n`;\n }\n }\n\n return markdown;\n}\n\nfunction getSecuritySchemeDescription(scheme: SecuritySchemeObject): string {\n switch (scheme.type.toLowerCase()) {\n case 'apikey':\n return `This API uses an API key for authentication. The key should be sent in the \\`${scheme.in}\\` named \\`${scheme.name}\\`.`;\n case 'http':\n if (scheme.scheme === 'bearer') {\n return `This API uses HTTP Bearer authentication. A token should be included in the Authorization header.`;\n }\n return `This API uses HTTP ${scheme.scheme} authentication.`;\n case 'oauth2': {\n const flows = Object.keys(scheme.flows || {});\n return `This API uses OAuth 2.0 for authentication with the following flow(s): ${flows.join(\n ', ',\n )}.`;\n }\n case 'openidconnect':\n return `This API uses OpenID Connect for authentication. The OpenID Connect URL is: ${scheme.openIdConnectUrl}`;\n default:\n return 'This API uses a custom authentication scheme.';\n }\n}\n\nfunction generateAuthorizationMarkdown(spec: OurOpenAPIObject): string {\n let markdown = `# Authorization\\n\\n`;\n\n const securitySchemes = spec.components?.securitySchemes || {};\n const globalSecurity = spec.security || [];\n\n if (Object.keys(securitySchemes).length > 0) {\n markdown += `This API uses the following authentication schemes:\\n\\n`;\n markdown += `## Security Schemes\\n\\n`;\n\n for (const [name, scheme] of Object.entries(securitySchemes)) {\n const schemeObj = resolveRef<SecuritySchemeObject>(spec, scheme);\n markdown += `### ${name}\\n\\n`;\n\n const description =\n schemeObj.description || getSecuritySchemeDescription(schemeObj);\n markdown += `${description}\\n\\n`;\n\n markdown += `**Type:** \\`${schemeObj.type}\\`\\n\\n`;\n\n if (schemeObj.type === 'http') {\n markdown += `**Scheme:** \\`${schemeObj.scheme}\\`\\n\\n`;\n if (schemeObj.bearerFormat) {\n markdown += `**Bearer Format:** \\`${schemeObj.bearerFormat}\\`\\n\\n`;\n }\n } else if (schemeObj.type === 'oauth2') {\n markdown += `**Flows:**\\n\\n`;\n markdown += `\\`\\`\\`json\\n${JSON.stringify(\n schemeObj.flows,\n null,\n 2,\n )}\\n\\`\\`\\`\\n\\n`;\n }\n }\n }\n\n if (globalSecurity.length > 0) {\n markdown += `## Global Security Requirements\\n\\n`;\n markdown += `These security schemes are required for all operations.\\n\\n`;\n markdown += `\\`\\`\\`json\\n${JSON.stringify(\n globalSecurity,\n null,\n 2,\n )}\\n\\`\\`\\`\\n\\n`;\n }\n\n return markdown;\n}\n\nexport function extractOverviewDocs(spec: OurOpenAPIObject): SidebarData {\n const introduction: NavItem = {\n id: 'introduction',\n title: 'Introduction',\n url: '/introduction',\n description: 'API overview and getting started guide',\n content: generateIntroductionMarkdown(spec),\n };\n\n const errorSchemas = new Map<string, ErrorSchema>();\n\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 errorSchemas.set(key, {\n statusCode,\n title: response.description || `${statusCode} Error`,\n description: response.description,\n schema: content['application/json'].schema as SchemaObject,\n });\n }\n }\n }\n }\n }\n });\n\n const errors: NavItem = {\n id: 'errors',\n title: 'Errors',\n url: '/errors',\n description: 'Error handling and HTTP status codes',\n content: generateErrorsMarkdown(errorSchemas),\n };\n\n const authorization: NavItem = {\n id: 'authorization',\n url: '/authorization',\n title: 'Authorization',\n description: 'Authentication methods and security schemes',\n content: generateAuthorizationMarkdown(spec),\n };\n const docs: NavItem[] = [introduction, errors, authorization];\n\n return [\n {\n id: 'overview',\n category: 'Overview',\n items: docs,\n },\n ];\n}\n"],
5
+ "mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAWlC,SAAS,6BAA6B,MAAgC;AACpE,QAAM,OAAO,KAAK;AAClB,MAAI,WAAW;AAEf,MAAI,KAAK,OAAO;AACd,gBAAY,KAAK,KAAK,KAAK;AAAA;AAAA;AAAA,EAC7B;AAEA,MAAI,KAAK,aAAa;AACpB,gBAAY,GAAG,KAAK,WAAW;AAAA;AAAA;AAAA,EACjC;AAEA,MAAI,KAAK,SAAS;AAChB,gBAAY,gBAAgB,KAAK,OAAO;AAAA;AAAA;AAAA,EAC1C;AAEA,MAAI,KAAK,SAAS;AAChB,gBAAY;AAAA;AAAA;AACZ,QAAI,KAAK,QAAQ,MAAM;AACrB,kBAAY,aAAa,KAAK,QAAQ,IAAI;AAAA;AAAA;AAAA,IAC5C;AACA,QAAI,KAAK,QAAQ,OAAO;AACtB,kBA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AG;AAC1B,2BAAa,IAAI,KAAK;AAAA,gBACpB;AAAA,gBACA,OAAO,SAAS,eAAe,GAAG,UAAU;AAAA,gBAC5C,aAAa,SAAS;AAAA,gBACtB,QAAQ,QAAQ,kBAAkB,EAAE;AAAA,cACtC,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,SAAkB;AAAA,IACtB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,IACb,SAAS,uBAAuB,YAAY;AAAA,EAC9C;AAEA,QAAM,gBAAyB;AAAA,IAC7B,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS,8BAA8B,IAAI;AAAA,EAC7C;AACA,QAAM,OAAkB,CAAC,cAAc,QAAQ,aAAa;AAE5D,SAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,OAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,235 @@
1
+ import pluralize from "pluralize";
2
+ const PRIMARY_TOP_TIER_KEYWORDS = [
3
+ "data",
4
+ "items",
5
+ "results",
6
+ "value"
7
+ ];
8
+ const PRIMARY_OTHER_KEYWORDS = [
9
+ "records",
10
+ "content",
11
+ "list",
12
+ "payload",
13
+ "entities",
14
+ "collection",
15
+ "users",
16
+ "products",
17
+ "orders",
18
+ "bookings",
19
+ "articles",
20
+ "posts",
21
+ "documents",
22
+ "events"
23
+ ];
24
+ const SECONDARY_KEYWORDS = ["entries", "rows", "elements"];
25
+ const PLURAL_DEPRIORITIZE_LIST = [
26
+ "status",
27
+ "success",
28
+ "address",
29
+ "details",
30
+ "properties",
31
+ "params",
32
+ "headers",
33
+ "cookies",
34
+ "series",
35
+ "links",
36
+ "meta",
37
+ "metadata",
38
+ "statistics",
39
+ "settings",
40
+ "options",
41
+ "permissions",
42
+ "credentials",
43
+ "diagnostics",
44
+ "warnings",
45
+ "errors",
46
+ "actions",
47
+ "attributes",
48
+ "categories",
49
+ "features",
50
+ "includes",
51
+ "tags"
52
+ ];
53
+ const HAS_MORE_PRIMARY_POSITIVE_EXACT = [
54
+ "hasmore",
55
+ "hasnext",
56
+ "hasnextpage",
57
+ "moreitems",
58
+ "moreitemsavailable",
59
+ "nextpage",
60
+ "nextpageexists",
61
+ "nextpageavailable",
62
+ "hasadditionalresults",
63
+ "moreresultsavailable",
64
+ "canloadmore",
65
+ "hasadditional",
66
+ "additionalitems",
67
+ "fetchmore"
68
+ ];
69
+ const HAS_MORE_SECONDARY_POSITIVE_EXACT = ["more", "next"];
70
+ const HAS_MORE_PRIMARY_INVERTED_EXACT = [
71
+ "islast",
72
+ "lastpage",
73
+ "endofresults",
74
+ "endoflist",
75
+ "nomoreitems",
76
+ "nomoredata",
77
+ "allitemsloaded",
78
+ "iscomplete",
79
+ "completed"
80
+ ];
81
+ const HAS_MORE_POSITIVE_REGEX_PATTERNS = [
82
+ "\\bhas_?more\\b",
83
+ "\\bhas_?next\\b",
84
+ // e.g., itemsHasNext, items_has_next
85
+ "\\bmore_?items\\b",
86
+ "\\bnext_?page\\b",
87
+ // e.g., userNextPageFlag
88
+ "\\badditional\\b",
89
+ // e.g., hasAdditionalData, additional_results_exist
90
+ "\\bcontinuation\\b",
91
+ // e.g., continuationAvailable, has_continuation_token
92
+ "\\bmore_?results\\b",
93
+ "\\bpage_?available\\b",
94
+ "\\bnext(?:_?(page|marker))?\\b"
95
+ ];
96
+ const COMPILED_HAS_MORE_POSITIVE_REGEXES = HAS_MORE_POSITIVE_REGEX_PATTERNS.map((p) => new RegExp(p, "i"));
97
+ const HAS_MORE_INVERTED_REGEX_PATTERNS = [
98
+ "\\bis_?last\\b",
99
+ // e.g., pageIsLast
100
+ "\\blast_?page\\b",
101
+ // e.g., resultsAreLastPage
102
+ "\\bend_?of_?(data|results|list|items|stream)\\b",
103
+ "\\bno_?more_?(items|data|results)?\\b",
104
+ "\\ball_?(items_?)?loaded\\b",
105
+ "\\bis_?complete\\b"
106
+ ];
107
+ const COMPILED_HAS_MORE_INVERTED_REGEXES = HAS_MORE_INVERTED_REGEX_PATTERNS.map((p) => new RegExp(p, "i"));
108
+ function getItemsName(properties) {
109
+ const arrayPropertyNames = [];
110
+ for (const propName in properties) {
111
+ if (propName in properties) {
112
+ const propSchema = properties[propName];
113
+ if (propSchema && propSchema.type === "array") {
114
+ arrayPropertyNames.push(propName);
115
+ }
116
+ }
117
+ }
118
+ if (arrayPropertyNames.length === 0) {
119
+ return null;
120
+ }
121
+ if (arrayPropertyNames.length === 1) {
122
+ return arrayPropertyNames[0];
123
+ }
124
+ let bestCandidate = null;
125
+ let candidateRank = Infinity;
126
+ const updateCandidate = (propName, rank) => {
127
+ if (rank < candidateRank) {
128
+ bestCandidate = propName;
129
+ candidateRank = rank;
130
+ }
131
+ };
132
+ for (const propName of arrayPropertyNames) {
133
+ const lowerPropName = propName.toLowerCase();
134
+ if (PRIMARY_TOP_TIER_KEYWORDS.includes(lowerPropName)) {
135
+ updateCandidate(propName, 2);
136
+ continue;
137
+ }
138
+ if (candidateRank > 3 && PRIMARY_OTHER_KEYWORDS.includes(lowerPropName)) {
139
+ updateCandidate(propName, 3);
140
+ continue;
141
+ }
142
+ if (candidateRank > 4 && SECONDARY_KEYWORDS.includes(lowerPropName)) {
143
+ updateCandidate(propName, 4);
144
+ continue;
145
+ }
146
+ if (candidateRank > 5 && pluralize.isPlural(propName) && !PLURAL_DEPRIORITIZE_LIST.includes(lowerPropName)) {
147
+ updateCandidate(propName, 5);
148
+ continue;
149
+ }
150
+ if (candidateRank > 6 && pluralize.isPlural(propName) && PLURAL_DEPRIORITIZE_LIST.includes(lowerPropName)) {
151
+ updateCandidate(propName, 6);
152
+ continue;
153
+ }
154
+ }
155
+ if (bestCandidate) {
156
+ return bestCandidate;
157
+ }
158
+ return arrayPropertyNames[0];
159
+ }
160
+ function guess(properties) {
161
+ const booleanPropertyNames = [];
162
+ for (const propName in properties) {
163
+ const propSchema = properties[propName];
164
+ if (propSchema.type === "boolean" || propSchema.type === "integer" || propSchema.type === "string") {
165
+ booleanPropertyNames.push(propName);
166
+ }
167
+ }
168
+ if (booleanPropertyNames.length === 0) {
169
+ return null;
170
+ }
171
+ if (booleanPropertyNames.length === 1) {
172
+ return booleanPropertyNames[0];
173
+ }
174
+ let bestCandidate = null;
175
+ let candidateRank = Infinity;
176
+ const updateCandidate = (propName, rank) => {
177
+ if (rank < candidateRank) {
178
+ bestCandidate = propName;
179
+ candidateRank = rank;
180
+ }
181
+ };
182
+ for (const propName of booleanPropertyNames) {
183
+ const normalizedForExactMatch = propName.toLowerCase().replace(/[-_]/g, "");
184
+ let currentPropRank = Infinity;
185
+ if (HAS_MORE_PRIMARY_POSITIVE_EXACT.includes(normalizedForExactMatch)) {
186
+ currentPropRank = 1;
187
+ } else if (HAS_MORE_SECONDARY_POSITIVE_EXACT.includes(normalizedForExactMatch)) {
188
+ currentPropRank = 2;
189
+ } else {
190
+ let foundPositiveRegex = false;
191
+ for (const regex of COMPILED_HAS_MORE_POSITIVE_REGEXES) {
192
+ if (regex.test(propName)) {
193
+ currentPropRank = 3;
194
+ foundPositiveRegex = true;
195
+ break;
196
+ }
197
+ }
198
+ if (!foundPositiveRegex) {
199
+ if (HAS_MORE_PRIMARY_INVERTED_EXACT.includes(normalizedForExactMatch)) {
200
+ currentPropRank = 4;
201
+ } else {
202
+ for (const regex of COMPILED_HAS_MORE_INVERTED_REGEXES) {
203
+ if (regex.test(propName)) {
204
+ currentPropRank = 5;
205
+ break;
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+ updateCandidate(propName, currentPropRank);
212
+ }
213
+ return bestCandidate;
214
+ }
215
+ function getHasMoreName(properties) {
216
+ const rootGuess = guess(properties);
217
+ if (rootGuess) {
218
+ return rootGuess;
219
+ }
220
+ for (const propName in properties) {
221
+ const propSchema = properties[propName];
222
+ if (propSchema.type === "object" && propSchema.properties) {
223
+ const nested = getHasMoreName(propSchema.properties);
224
+ if (nested) {
225
+ return propName + "." + nested;
226
+ }
227
+ }
228
+ }
229
+ return null;
230
+ }
231
+ export {
232
+ getHasMoreName,
233
+ getItemsName
234
+ };
235
+ //# sourceMappingURL=pagination-result.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/pagination/pagination-result.ts"],
4
+ "sourcesContent": ["import type { SchemaObject, SchemasObject } from 'openapi3-ts/oas31';\nimport pluralize from 'pluralize';\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\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 '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\n // Heuristic 2: Top-tier primary keywords (e.g., \"data\", \"items\")\n if (PRIMARY_TOP_TIER_KEYWORDS.includes(lowerPropName)) {\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 && PRIMARY_OTHER_KEYWORDS.includes(lowerPropName)) {\n updateCandidate(propName, 3);\n continue;\n }\n\n // Heuristic 4: Secondary keywords\n if (candidateRank > 4 && SECONDARY_KEYWORDS.includes(lowerPropName)) {\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 !PLURAL_DEPRIORITIZE_LIST.includes(lowerPropName)\n ) {\n updateCandidate(propName, 5);\n continue;\n }\n\n // Heuristic 6: Pluralized name, IS on the deprioritize list (less preferred plural)\n if (\n candidateRank > 6 &&\n pluralize.isPlural(propName) &&\n PLURAL_DEPRIORITIZE_LIST.includes(lowerPropName)\n ) {\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,MAAM,4BAAsC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,yBAAmC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,qBAA+B,CAAC,WAAW,QAAQ,UAAU;AAEnE,MAAM,2BAAqC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,kCAA4C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,oCAA8C,CAAC,QA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