@chargebee/code-sample-generator 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{LanguageSwitcher-BBOha8f7.js → LanguageSwitcher-BxJ9EXsh.js} +37 -52
- package/dist/LanguageSwitcher-BxJ9EXsh.js.map +1 -0
- package/dist/browser.js +3 -3
- package/dist/code-sample-generator.css +101 -62
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/CodeBlock.d.ts.map +1 -1
- package/dist/components/CodeSamples.d.ts.map +1 -1
- package/dist/components/code-block-properties.d.ts +18 -0
- package/dist/components/code-block-properties.d.ts.map +1 -0
- package/dist/core/ir-builder.d.ts +7 -0
- package/dist/core/ir-builder.d.ts.map +1 -1
- package/dist/{generate-code-sample-CdI4Vitd.js → generate-code-sample-JkPVVgWV.js} +6 -3
- package/dist/{generate-code-sample-CdI4Vitd.js.map → generate-code-sample-JkPVVgWV.js.map} +1 -1
- package/dist/{generate-from-sample-WBk3LIHW.js → generate-from-sample-CcOkhgar.js} +1612 -174
- package/dist/{generate-from-sample-WBk3LIHW.js.map → generate-from-sample-CcOkhgar.js.map} +1 -1
- package/dist/generated/ops/operation-params.d.ts +90 -63
- package/dist/generated/ops/operation-params.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/collect_payment_for_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_a_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_a_gift.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_a_payment_intent.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_a_webhook_endpoint.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_an_invoice.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_subscription_for_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_using_gateway_temporary_token.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_using_payment_intent.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/create_using_permanent_token.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/export_transactions.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/gift_subscription_estimate.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/import_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/import_credit_note.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/import_invoice.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/import_subscription_for_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/list_events.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/list_payment_sources.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/list_transactions.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/reactivate_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/record_an_excess_payment_for_a_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/record_an_invoice_payment.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/record_an_offline_refund.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/record_refund_for_a_credit_note.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/record_refund_for_an_invoice.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/resume_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/update_a_payment_intent.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/update_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/update_a_webhook_endpoint.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv1/update_payment_method_for_a_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/accept_a_quote.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/authorize.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/capture.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/capture_authorization.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/checkout_charge-items_and_one-time_charges.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/checkout_gift_subscription_for_items.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/claim_a_gift_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/collect_now.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/collect_payment_for_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_bank_account_payment_source.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_card_payment_source.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_gift_subscription_for_items.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_payment_intent.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_pre-cancel_hosted_page.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_purchase.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_voucher_payment_method.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_a_webhook_endpoint.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_checkout_for_a_new_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_checkout_to_update_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_invoice_for_items_and_one-time_charges.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_pricing_page_for_new_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_subscription_for_items.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_using_chargebee_token.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_using_gateway_temporary_token.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_using_payment_intent.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/create_using_permanent_token.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/estimate_for_creating_a_customer_and_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/estimate_for_creating_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/estimate_for_updating_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/export_transactions.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/extend_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/gift_subscription_estimate_for_items.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/import_credit_note.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/import_invoice.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/import_subscription_for_items.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/list_events.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/list_ledger_operations.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/list_payment_sources.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/list_transactions.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/manage_payment_sources.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/reactivate_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/record_an_excess_payment_for_a_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/record_an_invoice_payment.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/record_an_offline_refund.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/record_refund_for_a_credit_note.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/record_refund_for_an_invoice.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/release_authorization.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/resume_a_subscription.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/update_a_payment_intent.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/update_a_webhook_endpoint.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/update_payment_method_for_a_customer.d.ts.map +1 -1
- package/dist/generated/ops/v2-pcv2/update_subscription_for_items.d.ts.map +1 -1
- package/dist/generators/curl.d.ts.map +1 -1
- package/dist/generators/dotnet.d.ts.map +1 -1
- package/dist/generators/go.d.ts.map +1 -1
- package/dist/generators/headers.d.ts +13 -0
- package/dist/generators/headers.d.ts.map +1 -0
- package/dist/generators/java/v3.d.ts.map +1 -1
- package/dist/generators/java/v4.d.ts.map +1 -1
- package/dist/generators/nodejs.d.ts.map +1 -1
- package/dist/generators/php.d.ts.map +1 -1
- package/dist/generators/python.d.ts.map +1 -1
- package/dist/generators/ruby.d.ts.map +1 -1
- package/dist/{highlight-code-DiQznhna.js → highlight-code-CBL2d8Y3.js} +2 -2
- package/dist/{highlight-code-DiQznhna.js.map → highlight-code-CBL2d8Y3.js.map} +1 -1
- package/dist/index.js +5 -5
- package/dist/node.js +3 -3
- package/dist/samples/types.d.ts +5 -0
- package/dist/samples/types.d.ts.map +1 -1
- package/dist/utils/generate-code-sample.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/LanguageSwitcher-BBOha8f7.js.map +0 -1
|
@@ -118,6 +118,60 @@
|
|
|
118
118
|
display: none !important;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Icon overlay on a code well. Plain CSS so hosts without Tailwind
|
|
123
|
+
* preflight (cb-docs) do not keep the UA 3D button chrome.
|
|
124
|
+
*/
|
|
125
|
+
.code-block-copy-button {
|
|
126
|
+
appearance: none;
|
|
127
|
+
-webkit-appearance: none;
|
|
128
|
+
margin: 0;
|
|
129
|
+
border: 0;
|
|
130
|
+
box-shadow: none;
|
|
131
|
+
background: transparent;
|
|
132
|
+
position: absolute;
|
|
133
|
+
top: 0.5rem;
|
|
134
|
+
right: 0.75rem;
|
|
135
|
+
z-index: 10;
|
|
136
|
+
display: inline-flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
padding: 0.375rem;
|
|
140
|
+
border-radius: 0.375rem;
|
|
141
|
+
color: #6b7280;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
line-height: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.code-block-copy-button:hover,
|
|
147
|
+
.code-block-copy-button:focus-visible {
|
|
148
|
+
color: #111827;
|
|
149
|
+
background: rgb(0 0 0 / 0.06);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
html.dark .code-block-copy-button,
|
|
153
|
+
.dark .code-block-copy-button {
|
|
154
|
+
color: #9ca3af;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
html.dark .code-block-copy-button:hover,
|
|
158
|
+
html.dark .code-block-copy-button:focus-visible,
|
|
159
|
+
.dark .code-block-copy-button:hover,
|
|
160
|
+
.dark .code-block-copy-button:focus-visible {
|
|
161
|
+
color: #e5e7eb;
|
|
162
|
+
background: rgb(255 255 255 / 0.1);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.code-block-copy-button--hover {
|
|
166
|
+
opacity: 0;
|
|
167
|
+
transition: opacity 0.15s ease;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.group:hover .code-block-copy-button--hover,
|
|
171
|
+
.group:focus-within .code-block-copy-button--hover,
|
|
172
|
+
.code-block-copy-button--hover:focus-visible {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
}
|
|
121
175
|
/**
|
|
122
176
|
* Custom CSS-based syntax highlighting for cURL commands
|
|
123
177
|
* Matches JavaScript color scheme: purple keywords, blue keys, green values
|
|
@@ -206,60 +260,6 @@ html.dark .curl-token-equals {
|
|
|
206
260
|
html.dark .curl-token-placeholder {
|
|
207
261
|
color: #ffcb6b; /* Yellow/orange - matches JavaScript template literal placeholders */
|
|
208
262
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Icon overlay on a code well. Plain CSS so hosts without Tailwind
|
|
211
|
-
* preflight (cb-docs) do not keep the UA 3D button chrome.
|
|
212
|
-
*/
|
|
213
|
-
.code-block-copy-button {
|
|
214
|
-
appearance: none;
|
|
215
|
-
-webkit-appearance: none;
|
|
216
|
-
margin: 0;
|
|
217
|
-
border: 0;
|
|
218
|
-
box-shadow: none;
|
|
219
|
-
background: transparent;
|
|
220
|
-
position: absolute;
|
|
221
|
-
top: 0.5rem;
|
|
222
|
-
right: 0.75rem;
|
|
223
|
-
z-index: 10;
|
|
224
|
-
display: inline-flex;
|
|
225
|
-
align-items: center;
|
|
226
|
-
justify-content: center;
|
|
227
|
-
padding: 0.375rem;
|
|
228
|
-
border-radius: 0.375rem;
|
|
229
|
-
color: #6b7280;
|
|
230
|
-
cursor: pointer;
|
|
231
|
-
line-height: 0;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.code-block-copy-button:hover,
|
|
235
|
-
.code-block-copy-button:focus-visible {
|
|
236
|
-
color: #111827;
|
|
237
|
-
background: rgb(0 0 0 / 0.06);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
html.dark .code-block-copy-button,
|
|
241
|
-
.dark .code-block-copy-button {
|
|
242
|
-
color: #9ca3af;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
html.dark .code-block-copy-button:hover,
|
|
246
|
-
html.dark .code-block-copy-button:focus-visible,
|
|
247
|
-
.dark .code-block-copy-button:hover,
|
|
248
|
-
.dark .code-block-copy-button:focus-visible {
|
|
249
|
-
color: #e5e7eb;
|
|
250
|
-
background: rgb(255 255 255 / 0.1);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.code-block-copy-button--hover {
|
|
254
|
-
opacity: 0;
|
|
255
|
-
transition: opacity 0.15s ease;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.group:hover .code-block-copy-button--hover,
|
|
259
|
-
.group:focus-within .code-block-copy-button--hover,
|
|
260
|
-
.code-block-copy-button--hover:focus-visible {
|
|
261
|
-
opacity: 1;
|
|
262
|
-
}
|
|
263
263
|
@layer theme, base, components, utilities;
|
|
264
264
|
/**
|
|
265
265
|
* Production-style code samples component
|
|
@@ -1187,6 +1187,9 @@ html.dark .code-block-copy-button:focus-visible,
|
|
|
1187
1187
|
--code-samples-response-json-badge-bg: var(--cb-gray-haze, #f8f9fa);
|
|
1188
1188
|
--code-samples-response-json-badge-text: var(--cb-slate, #6c757d);
|
|
1189
1189
|
--code-samples-max-height: 800px;
|
|
1190
|
+
/* Rendered code geometry — mirrored in components/code-block-metrics.ts */
|
|
1191
|
+
--code-samples-code-line-height: 21px;
|
|
1192
|
+
--code-samples-code-padding: 16px;
|
|
1190
1193
|
/* Sample Request container + Sample Result/Response card (matches rounded-3xl) */
|
|
1191
1194
|
--code-samples-card-border-radius: 1.5rem;
|
|
1192
1195
|
/* Standalone code shells (api-doc resource JSON, PreWrapper, CodeBlock chrome) */
|
|
@@ -1246,6 +1249,18 @@ html.dark {
|
|
|
1246
1249
|
.code-samples-result-card {
|
|
1247
1250
|
border-radius: var(--code-samples-card-border-radius);
|
|
1248
1251
|
overflow: hidden;
|
|
1252
|
+
background-color: var(--code-samples-response-card-bg);
|
|
1253
|
+
border: 1px solid var(--code-samples-response-card-border);
|
|
1254
|
+
}
|
|
1255
|
+
.code-samples-result-card-header {
|
|
1256
|
+
background-color: var(--code-samples-response-card-header-bg);
|
|
1257
|
+
border-bottom: 1px solid var(--code-samples-response-card-border);
|
|
1258
|
+
}
|
|
1259
|
+
.code-samples-see-more {
|
|
1260
|
+
border: 0;
|
|
1261
|
+
border-top: 1px solid var(--code-samples-response-card-border);
|
|
1262
|
+
background: transparent;
|
|
1263
|
+
color: var(--cb-link-blue, #0833dd);
|
|
1249
1264
|
}
|
|
1250
1265
|
.code-samples-header {
|
|
1251
1266
|
/* No margin/padding that could create gaps */
|
|
@@ -1490,6 +1505,35 @@ html.dark {
|
|
|
1490
1505
|
margin: 0;
|
|
1491
1506
|
display: block;
|
|
1492
1507
|
}
|
|
1508
|
+
/* ============================================================================
|
|
1509
|
+
LOADING SKELETON
|
|
1510
|
+
----------------------------------------------------------------------------
|
|
1511
|
+
Shiki highlights asynchronously, so every code block starts life as this
|
|
1512
|
+
skeleton. It repeats the geometry of the highlighted <pre> — same padding,
|
|
1513
|
+
one row per code line — so the block already stands at its final height and
|
|
1514
|
+
nothing shifts when the real markup arrives. That is what lets the block size
|
|
1515
|
+
to its content rather than to a fixed floor.
|
|
1516
|
+
============================================================================ */
|
|
1517
|
+
.code-block-skeleton {
|
|
1518
|
+
padding: var(--code-samples-code-padding);
|
|
1519
|
+
overflow: hidden;
|
|
1520
|
+
}
|
|
1521
|
+
/* Simple `codeString` mode nests the block in .code-block, whose <pre> is padded
|
|
1522
|
+
to 1.5rem rather than the shared variable. Match it so the skeleton stands at
|
|
1523
|
+
the right height there too. */
|
|
1524
|
+
.code-block .code-block-skeleton {
|
|
1525
|
+
padding: 1.5rem;
|
|
1526
|
+
}
|
|
1527
|
+
.code-block-skeleton-row {
|
|
1528
|
+
display: flex;
|
|
1529
|
+
align-items: center;
|
|
1530
|
+
height: var(--code-samples-code-line-height);
|
|
1531
|
+
}
|
|
1532
|
+
.code-block-skeleton-line {
|
|
1533
|
+
height: 0.75rem;
|
|
1534
|
+
border-radius: 2px;
|
|
1535
|
+
background-color: var(--code-block-skeleton-line-bg);
|
|
1536
|
+
}
|
|
1493
1537
|
/* ============================================================================
|
|
1494
1538
|
CODE BLOCK WRAPPER (prevents layout shift)
|
|
1495
1539
|
============================================================================ */
|
|
@@ -1500,14 +1544,9 @@ html.dark {
|
|
|
1500
1544
|
background-color: var(
|
|
1501
1545
|
--code-samples-code-bg
|
|
1502
1546
|
); /* Dark background to match code blocks */
|
|
1503
|
-
/*
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
Getting Started uses div.code-block (not .code-block-wrapper) so is unaffected. */
|
|
1507
|
-
/* Typical operation-page request block is 5-10 lines (~10rem).
|
|
1508
|
-
Setting min-height here means the container never collapses to skeleton
|
|
1509
|
-
height while CodeBlock's async Shiki highlight is in progress. */
|
|
1510
|
-
min-height: 10rem;
|
|
1547
|
+
/* No min-height: the skeleton already reserves the block's final height while
|
|
1548
|
+
Shiki highlights (see LOADING SKELETON above), so a floor here would only
|
|
1549
|
+
leave dead space under short snippets. */
|
|
1511
1550
|
/* No max-height here - flex layout determines available space */
|
|
1512
1551
|
/* flex: 1 and min-height: 0 are set in context-specific rules below */
|
|
1513
1552
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,SAAS;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,SAAc,EAAE,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,SAAS;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,SAAc,EAAE,EAAE,SAAS,2CAI3D;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,SAAc,EAAE,EAAE,eAAe,2CAMvE;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,SAAc,EAAE,EAAE,cAAc,2CAQrE;AAED,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAc,EAAE,EAAE,gBAAgB,2CAEzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../src/components/CodeBlock.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,0BAA0B,CAAC;AAClC,OAAO,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../src/components/CodeBlock.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,0BAA0B,CAAC;AAClC,OAAO,4BAA4B,CAAC;AAIpC,OAAO,sBAAsB,CAAC;AAK9B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,IAAI,EAAE,QAAQ,EACd,SAAS,EACT,KAAK,EAAE,SAAS,EAChB,SAAc,EACd,eAAuB,EACvB,cAAsB,EACtB,WAAW,EAAE,eAAuB,GACrC,EAAE,cAAc,2CA8JhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeSamples.d.ts","sourceRoot":"","sources":["../../src/components/CodeSamples.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAQH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeSamples.d.ts","sourceRoot":"","sources":["../../src/components/CodeSamples.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAQH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAkS1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,WAAW,CAAC,EAC1B,UAAU,EACV,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,eAAwB,EACxB,KAAK,EAAE,SAAS,EAChB,aAAa,EAAE,iBAAiB,EAChC,WAAW,EACX,QAAa,EACb,SAAc,EACd,KAAK,EACL,gBAAgB,EAChB,MAAM,EAAE,OAAO,EAAE,8DAA8D;AAC/E,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,aAAa,GACd,EAAE,yBAAyB,2CA0iB3B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometry of a rendered code block.
|
|
3
|
+
*
|
|
4
|
+
* Shiki highlights asynchronously, so a code block is a skeleton before it is
|
|
5
|
+
* code. These numbers let the skeleton stand at the height the highlighted
|
|
6
|
+
* `<pre>` will take, which is what lets a block size to its content instead of
|
|
7
|
+
* to a fixed floor: nothing has to be reserved "just in case".
|
|
8
|
+
*
|
|
9
|
+
* They mirror `--code-samples-code-line-height` / `--code-samples-code-padding`
|
|
10
|
+
* in styles/default.css — keep the two in sync.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CODE_LINE_HEIGHT_PX = 21;
|
|
13
|
+
export declare const CODE_PADDING_Y_PX = 32;
|
|
14
|
+
/** Height at which a block stops growing and becomes internally scrollable. */
|
|
15
|
+
export declare const MAX_COLLAPSED_CODE_HEIGHT_PX = 400;
|
|
16
|
+
/** Rows the loading skeleton should draw to stand in for `code`. */
|
|
17
|
+
export declare function skeletonLineCount(code: string): number;
|
|
18
|
+
//# sourceMappingURL=code-block-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block-properties.d.ts","sourceRoot":"","sources":["../../src/components/code-block-properties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,+EAA+E;AAC/E,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAOhD,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGtD"}
|
|
@@ -43,6 +43,11 @@ export interface IR {
|
|
|
43
43
|
hasFilterParams: boolean;
|
|
44
44
|
/** Optional request note (e.g. for cURL # NOTE comment) */
|
|
45
45
|
note?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Custom HTTP request headers from the sample JSON (e.g. async Prefer).
|
|
48
|
+
* Omitted when the sample has no headers so generators stay unchanged.
|
|
49
|
+
*/
|
|
50
|
+
headers?: Record<string, string>;
|
|
46
51
|
/**
|
|
47
52
|
* Map of custom field name -> inferred data type (e.g. `{ cf_amount: "number" }`).
|
|
48
53
|
* Used by generators to select typed filter APIs for dynamic `cf_*` fields.
|
|
@@ -103,6 +108,8 @@ export interface IROptions {
|
|
|
103
108
|
apiVersion?: string;
|
|
104
109
|
/** Optional request note for code comment (e.g. cURL # NOTE) */
|
|
105
110
|
note?: string;
|
|
111
|
+
/** Optional HTTP request headers from the sample */
|
|
112
|
+
headers?: Record<string, string>;
|
|
106
113
|
/** Custom host (e.g., "validator.mockserver.in") */
|
|
107
114
|
host?: string;
|
|
108
115
|
/** Custom port (e.g., 3001) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir-builder.d.ts","sourceRoot":"","sources":["../../src/core/ir-builder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMhE;;;GAGG;AACH,MAAM,WAAW,EAAE;IACjB,+BAA+B;IAC/B,SAAS,EAAE,mBAAmB,CAAC;IAG/B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IAGnB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,0DAA0D;IAC1D,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,gDAAgD;IAChD,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;IAGtC,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAGnC,gDAAgD;IAChD,aAAa,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,eAAe,EAAE,OAAO,CAAC;IAEzB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AA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AAmB,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAE,SAAc,GACtB,EAAE,CA6EJ;AA6lBD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAoCvE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as generateFromSample, f as getGenerator, w as LanguageNotSupportedError, h as getSupportedLanguages, r as resolveDescriptor, O as OperationNotFoundError, s as expandDescriptor, o as assertValid, p as buildIR, C as CodeGenerationError } from "./generate-from-sample-
|
|
1
|
+
import { l as generateFromSample, f as getGenerator, w as LanguageNotSupportedError, h as getSupportedLanguages, r as resolveDescriptor, O as OperationNotFoundError, s as expandDescriptor, o as assertValid, p as buildIR, C as CodeGenerationError } from "./generate-from-sample-CcOkhgar.js";
|
|
2
2
|
const LANGUAGES = [
|
|
3
3
|
"curl",
|
|
4
4
|
"node-v2",
|
|
@@ -234,11 +234,13 @@ async function generateCodeSample(options) {
|
|
|
234
234
|
const descriptor = expandDescriptor(minimalDescriptor);
|
|
235
235
|
let params = {};
|
|
236
236
|
let note;
|
|
237
|
+
let headers;
|
|
237
238
|
if (request) {
|
|
238
239
|
const sampleRequest = Array.isArray(request) ? request[0] : request;
|
|
239
240
|
const reqParams = sampleRequest.params || {};
|
|
240
241
|
params = reqParams.map ? reqParams.map : reqParams;
|
|
241
242
|
note = sampleRequest.note;
|
|
243
|
+
headers = sampleRequest.headers;
|
|
242
244
|
}
|
|
243
245
|
const shouldValidate = options.validate ?? true;
|
|
244
246
|
if (shouldValidate) {
|
|
@@ -255,7 +257,8 @@ async function generateCodeSample(options) {
|
|
|
255
257
|
apiKey: apiKey || "{site_api_key}",
|
|
256
258
|
apiVersion: apiVersion || "v2",
|
|
257
259
|
domainName: domainName ?? "chargebee.com",
|
|
258
|
-
note
|
|
260
|
+
note,
|
|
261
|
+
headers
|
|
259
262
|
});
|
|
260
263
|
let code;
|
|
261
264
|
try {
|
|
@@ -339,4 +342,4 @@ export {
|
|
|
339
342
|
generateCodeSamplesBatch as g,
|
|
340
343
|
findOperationById as h
|
|
341
344
|
};
|
|
342
|
-
//# sourceMappingURL=generate-code-sample-
|
|
345
|
+
//# sourceMappingURL=generate-code-sample-JkPVVgWV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-code-sample-CdI4Vitd.js","sources":["../src/core/types.ts","../src/core/openapi-returns.ts","../src/utils/generate-batch.ts","../src/utils/generate-code-sample.ts"],"sourcesContent":["/**\n * Core type definitions for the code-samples package.\n * These types define the full/expanded format used at runtime by renderers.\n */\n\n// =============================================================================\n// Language Types\n// =============================================================================\n\n/**\n * Supported programming languages for code generation.\n * Matches the generator registry in src/generators/index.ts\n */\nexport type Language =\n | \"curl\"\n | \"node-v2\"\n | \"node-v3\"\n | \"python-v2\"\n | \"python-v3\"\n | \"java-v3\"\n | \"java-v4\"\n | \"php-v3\"\n | \"php-v4\"\n | \"ruby\"\n | \"go-v3\"\n | \"go-v4\"\n | \"dotnet\";\n\nexport const LANGUAGES: Language[] = [\n \"curl\",\n \"node-v2\",\n \"node-v3\",\n \"python-v2\",\n \"python-v3\",\n \"java-v3\",\n \"java-v4\",\n \"php-v3\",\n \"php-v4\",\n \"ruby\",\n \"go-v3\",\n \"go-v4\",\n \"dotnet\",\n];\n\n// =============================================================================\n// API Version Types\n// =============================================================================\n\nexport type ApiVersion = \"v1\" | \"v2\";\nexport type PcVersion = \"v1\" | \"v2\";\n\n/**\n * Combined API version format used for sample organization.\n * - v1: API v1\n * - v2-pcv1: API v2 with Product Catalog v1\n * - v2-pcv2: API v2 with Product Catalog v2\n */\nexport type CombinedApiVersion = \"v1\" | \"v2-pcv1\" | \"v2-pcv2\";\n\n// =============================================================================\n// Parameter Schema Types\n// =============================================================================\n\n/**\n * Schema definition for a parameter.\n * This is the expanded runtime format used by generators.\n *\n * CB-specific extensions (x-cb-*) are normalized to camelCase properties.\n * See src/constants/openapi-extensions.ts for the original extension names.\n *\n * Mapping from OpenAPI extensions to ParamSchema properties:\n * - x-cb-is-filter-parameter → isFilter\n * - x-cb-sdk-filter-name → sdkFilterName\n * - x-cb-is-global-enum → isGlobalEnum\n * - x-cb-is-external-enum → isExternalEnum\n * - x-cb-sdk-enum-api-name → sdkEnumName\n * - x-cb-is-money-column → isMoneyColumn\n * - x-cb-is-sub-resource → isSubResource\n */\nexport interface ParamSchema {\n // JSON Schema standard fields\n type: \"string\" | \"integer\" | \"number\" | \"boolean\" | \"array\" | \"object\";\n format?: \"int32\" | \"int64\" | \"unix-time\" | \"decimal\" | \"double\" | \"boolean\";\n enum?: string[];\n required?: string[];\n properties?: Record<string, ParamSchema>;\n items?: ParamSchema;\n additionalProperties?: boolean;\n\n // CB-specific extensions (from x-cb-* OpenAPI extensions)\n\n /** Whether this is a filter parameter (x-cb-is-filter-parameter) */\n isFilter?: boolean;\n\n /** Filter type for SDK filter classes (derived from x-cb-sdk-filter-name) */\n filterType?: \"string\" | \"timestamp\" | \"enum\" | \"number\" | \"boolean\";\n\n /** SDK filter class name (x-cb-sdk-filter-name) e.g., \"StringFilter\", \"EnumFilter\" */\n sdkFilterName?: string;\n\n /** Whether this is a global enum (x-cb-is-global-enum) */\n isGlobalEnum?: boolean;\n\n /** Whether this is an external enum requiring separate class (x-cb-is-external-enum) */\n isExternalEnum?: boolean;\n\n /** SDK enum class name (x-cb-sdk-enum-api-name) e.g., \"BillingAlignmentMode\" */\n sdkEnumName?: string;\n\n /** Whether this is a money/currency column (x-cb-is-money-column) */\n isMoneyColumn?: boolean;\n\n /** Whether this is a sub-resource (x-cb-is-sub-resource) */\n isSubResource?: boolean;\n\n /**\n * From IR `tlr`: true when some resource declares this array-sub-object enum's\n * attribute. Go v4 and .NET use this to keep the enum on its own class. Java v3 /\n * Go v3 / Python v3 also use `isOperationSubResource` /\n * `isGlobalResourceReference` / `isDependentAttribute` / `isExternalEnum`.\n */\n isTopLevelResourceEnum?: boolean;\n\n /**\n * From IR `opsr`: the operation resource declares the enum's container with\n * `x-cb-is-sub-resource` (e.g. `alert.filter_conditions`).\n */\n isOperationSubResource?: boolean;\n\n /**\n * From IR `grr`: the container has `x-cb-is-global-resource-reference`\n * (e.g. `metered_feature.column_definitions`).\n */\n isGlobalResourceReference?: boolean;\n\n /**\n * From IR `dep`: the container has `x-cb-is-dependent-attribute`.\n */\n isDependentAttribute?: boolean;\n\n /**\n * From IR `ro`: the single-object form of `isTopLevelResourceEnum` (e.g.\n * `contract_term` in `import_contract_term`). Only Go v4 uses it, writing the\n * enum with the owning resource's type (`ContractTermActionAtTermEnd`).\n */\n isResourceOwnedEnum?: boolean;\n\n /** Owning resource name in plural snake_case (x-cb-meta-model-name), e.g., \"credit_notes\" */\n metaModelName?: string;\n}\n\n// =============================================================================\n// Operation Descriptor Types\n// =============================================================================\n\n/**\n * HTTP method types supported by the API.\n */\nexport type HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\n\n/**\n * Full operation descriptor used at runtime by generators.\n * This is the expanded format after minimal descriptor expansion.\n */\nexport interface OperationDescriptor {\n /** Unique operation identifier, e.g., \"create_a_customer\" */\n id: string;\n\n /** HTTP request details */\n http: {\n /** HTTP method */\n method: HttpMethod;\n /** Path template with placeholders, e.g., \"/customers/{customer-id}\" */\n path: string;\n };\n\n /** Resource name (singular), e.g., \"customer\" (from OpenAPIExtensions.RESOURCE_ID) */\n resource: string;\n\n /** SDK method name, e.g., \"create\" (from x-cb-operation-method-name; primary for Python/Node/Ruby) */\n method: string;\n\n /**\n * Java v4 SDK method name (x-cb-sdk-method-name).\n * Java v4 generator uses methodSdk ?? method.\n */\n methodSdk?: string;\n\n /**\n * @deprecated Kept for backward compat. Python v3 uses methodAbbreviated ?? method.\n */\n methodAbbreviated?: string;\n\n // Operation flags (from x-cb-* extensions)\n\n /** Whether this is a list operation returning multiple items (x-cb-operation-is-list) */\n isListOperation: boolean;\n\n /** Whether request body should be JSON instead of form-encoded (x-cb-is-operation-needs-json-input) */\n isJsonInput: boolean;\n\n /** Whether this is a batch operation (x-cb-operation-is-batch) */\n isBatch?: boolean;\n\n /** Whether idempotency key is supported (x-cb-idempotency-supported) */\n idempotencySupported?: boolean;\n\n /** Whether the OpenAPI spec defines a requestBody for this operation */\n hasRequestBody?: boolean;\n\n /** API subdomain for this operation, e.g., \"ingest\", \"grow\", \"file-ingest\" */\n subDomain?: string;\n\n /** Parameter schema for the operation */\n params: ParamSchema;\n\n /** Return type descriptors (optional, for response type generation) */\n returns?: ReturnDescriptor[];\n}\n\n/**\n * Describes a return type from an operation response.\n */\nexport interface ReturnDescriptor {\n /** Property name in response, e.g., \"customer\" */\n name: string;\n\n /** Data type for the property, e.g., \"Customer\" */\n dataType: string;\n\n /** Whether the return is an array */\n isArray: boolean;\n\n /** Whether this is a resource type (vs primitive) */\n isResource: boolean;\n}\n","/**\n * OpenAPI Return Type Extraction\n *\n * Extracts return types from OpenAPI response schemas to enrich operation descriptors\n * with full return type information.\n *\n * This module bridges the gap between minimal descriptors (which may have limited\n * return types) and full OpenAPI specs (which have complete response schemas).\n */\n\nimport type { OperationDescriptor, ReturnDescriptor } from \"./types\";\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Converts a string to PascalCase.\n */\nfunction toPascalCase(str: string): string {\n return str\n .split(/[-_]/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n}\n\n// =============================================================================\n// OpenAPI Return Type Extraction\n// =============================================================================\n\n/**\n * Extracts return types from an OpenAPI operation's response schema.\n *\n * This function reads the response schema from the OpenAPI spec and extracts\n * all return properties, including their types and array status.\n *\n * @param openapiSpec - The full OpenAPI specification object\n * @param path - The API path, e.g., \"/customers\" or \"/customers/{id}\"\n * @param method - The HTTP method, e.g., \"POST\" or \"GET\"\n * @returns Array of ReturnDescriptor objects\n *\n * @example\n * ```typescript\n * const returns = extractReturnsFromOpenAPI(spec, \"/customers\", \"POST\");\n * // Returns: [\n * // { name: \"customer\", dataType: \"Customer\", isArray: false, isResource: true },\n * // { name: \"card\", dataType: \"Card\", isArray: false, isResource: true }\n * // ]\n * ```\n */\nexport function extractReturnsFromOpenAPI(\n openapiSpec: any,\n path: string,\n method: string,\n): ReturnDescriptor[] {\n const returns: ReturnDescriptor[] = [];\n\n if (!openapiSpec?.paths) {\n return returns;\n }\n\n // Normalize method to lowercase\n const httpMethod = method.toLowerCase();\n\n // Try to find the operation in the spec\n // First try exact path match\n let operation = openapiSpec.paths?.[path]?.[httpMethod];\n\n // If not found, try to find matching path with path parameters\n if (!operation) {\n for (const specPath of Object.keys(openapiSpec.paths)) {\n // Convert path params to regex pattern\n // e.g., \"/customers/{customer-id}\" -> /\\/customers\\/[^/]+/\n const pathRegex = new RegExp(\n \"^\" + specPath.replace(/\\{[^}]+\\}/g, \"[^/]+\") + \"$\",\n );\n if (pathRegex.test(path)) {\n operation = openapiSpec.paths[specPath]?.[httpMethod];\n break;\n }\n }\n }\n\n if (!operation) {\n return returns;\n }\n\n // Get response schema from OpenAPI spec.\n // Use same order as sdk-generator Action.onSuccessSchema(): 200 → 202 → 204\n // so return names align with SDK response attribute names (same property keys).\n const successCodes = [\"200\", \"202\", \"204\"];\n let responseSchema: any = null;\n\n for (const code of successCodes) {\n const response = operation?.responses?.[code];\n if (response?.content?.[\"application/json\"]?.schema) {\n responseSchema = response.content[\"application/json\"].schema;\n break;\n }\n }\n\n if (!responseSchema?.properties) {\n return returns;\n }\n\n // Extract return params from response schema properties\n for (const [key, propSchema] of Object.entries(responseSchema.properties)) {\n // Skip metadata fields\n if (key === \"next_offset\" || key === \"api_version\") {\n continue;\n }\n\n const schema = propSchema as any;\n\n // Check if it's an array type\n const isArray = schema.type === \"array\";\n\n // Check if it's a resource (has $ref to a schema or is an object type)\n const isResource =\n !!schema.$ref ||\n !!schema.items?.$ref ||\n schema.type === \"object\" ||\n (isArray && schema.items?.type === \"object\");\n\n // Handle \"list\" field specially - it contains array of resources\n if (key === \"list\" && isArray && schema.items?.properties) {\n // Extract the resource types from list items\n for (const [itemKey, itemSchema] of Object.entries(\n schema.items.properties,\n )) {\n const itemSchemaTyped = itemSchema as any;\n returns.push({\n name: itemKey,\n dataType: toPascalCase(itemKey),\n isArray: false,\n isResource:\n !!itemSchemaTyped.$ref || itemSchemaTyped.type === \"object\",\n });\n }\n continue;\n }\n\n returns.push({\n name: key,\n dataType: toPascalCase(key),\n isArray,\n isResource,\n });\n }\n\n return returns;\n}\n\n/**\n * Finds an operation in the OpenAPI spec by operationId.\n *\n * @param openapiSpec - The full OpenAPI specification object\n * @param operationId - The operationId to find\n * @returns Object with path, method, and operation, or null if not found\n */\nexport function findOperationById(\n openapiSpec: any,\n operationId: string,\n): { path: string; method: string; operation: any } | null {\n if (!openapiSpec?.paths) {\n return null;\n }\n\n for (const [path, pathItem] of Object.entries(openapiSpec.paths)) {\n if (!pathItem) continue;\n\n for (const [method, operation] of Object.entries(pathItem as any)) {\n if (\n typeof operation === \"object\" &&\n operation !== null &&\n \"operationId\" in operation &&\n operation.operationId === operationId\n ) {\n return { path, method: method.toUpperCase(), operation };\n }\n }\n }\n\n return null;\n}\n\n/**\n * Extracts returns from OpenAPI using an operationId.\n *\n * @param openapiSpec - The full OpenAPI specification object\n * @param operationId - The operationId to look up\n * @returns Array of ReturnDescriptor objects\n */\nexport function extractReturnsByOperationId(\n openapiSpec: any,\n operationId: string,\n): ReturnDescriptor[] {\n const found = findOperationById(openapiSpec, operationId);\n if (!found) {\n return [];\n }\n\n return extractReturnsFromOpenAPI(openapiSpec, found.path, found.method);\n}\n\n// =============================================================================\n// Descriptor Enrichment\n// =============================================================================\n\n/**\n * Options for enriching a descriptor with OpenAPI data.\n */\nexport interface EnrichOptions {\n /** The OpenAPI specification object */\n openapiSpec: any;\n\n /** Whether to overwrite existing returns (default: false - merge) */\n overwrite?: boolean;\n}\n\n/**\n * Enriches an operation descriptor with return types from OpenAPI.\n *\n * This function takes an existing descriptor (which may have limited returns)\n * and adds/updates return types from the OpenAPI specification.\n *\n * @param descriptor - The operation descriptor to enrich\n * @param options - Enrichment options including OpenAPI spec\n * @returns A new descriptor with enriched returns\n *\n * @example\n * ```typescript\n * const minimal = expandDescriptor(minimalDescriptor);\n * const enriched = enrichDescriptorWithOpenAPI(minimal, { openapiSpec: spec });\n * // enriched.returns now has full return types from OpenAPI\n * ```\n */\nexport function enrichDescriptorWithOpenAPI(\n descriptor: OperationDescriptor,\n options: EnrichOptions,\n): OperationDescriptor {\n const { openapiSpec, overwrite = false } = options;\n\n // Try to get returns from OpenAPI by operationId first\n let openapiReturns = extractReturnsByOperationId(openapiSpec, descriptor.id);\n\n // If not found by operationId, try by path and method\n if (openapiReturns.length === 0) {\n openapiReturns = extractReturnsFromOpenAPI(\n openapiSpec,\n descriptor.http.path,\n descriptor.http.method,\n );\n }\n\n // If no OpenAPI returns found, return original descriptor\n if (openapiReturns.length === 0) {\n return descriptor;\n }\n\n // If overwrite mode or no existing returns, use OpenAPI returns\n if (overwrite || !descriptor.returns || descriptor.returns.length === 0) {\n return {\n ...descriptor,\n returns: openapiReturns,\n };\n }\n\n // Merge mode: start with existing returns\n const existingNames = new Set(descriptor.returns.map((r) => r.name));\n const mergedReturns = [...descriptor.returns];\n\n // Add any OpenAPI returns that aren't already present\n for (const ret of openapiReturns) {\n if (!existingNames.has(ret.name)) {\n mergedReturns.push(ret);\n }\n }\n\n return {\n ...descriptor,\n returns: mergedReturns,\n };\n}\n\n/**\n * Batch enriches multiple descriptors with OpenAPI returns.\n *\n * @param descriptors - Array of descriptors to enrich\n * @param openapiSpec - The OpenAPI specification object\n * @returns Array of enriched descriptors\n */\nexport function enrichDescriptorsWithOpenAPI(\n descriptors: OperationDescriptor[],\n openapiSpec: any,\n): OperationDescriptor[] {\n return descriptors.map((desc) =>\n enrichDescriptorWithOpenAPI(desc, { openapiSpec }),\n );\n}\n","/**\n * Batch Code Generation for SSG\n *\n * Optimized batch generation function for generating code samples for multiple\n * languages and multiple sample variations in parallel. Designed for SSG build processes.\n */\n\nimport type { SampleRequest } from \"../samples/types\";\nimport type { GeneratorConfig } from \"../types\";\nimport { generateFromSample } from \"./generate-from-sample\";\n\n/**\n * Options for batch code generation\n */\nexport interface BatchGenerationOptions {\n /** Array of sample requests with display names */\n samples: Array<{ name: string; sample: SampleRequest }>;\n /** Languages to generate code for */\n languages: string[];\n /** Generator configuration (must include openapi and/or descriptor) */\n config: {\n apiVersion: string;\n pcVersion: string;\n operation: string;\n site?: string;\n apiKey?: string;\n /** OpenAPI document — required unless `descriptor` is set */\n openapi?: unknown;\n /** Pre-extracted descriptor — required unless `openapi` is set */\n descriptor?: import(\"../core/minimal-types\").MinimalOperationDescriptor;\n };\n}\n\n/**\n * Result of batch generation\n */\nexport interface BatchGenerationResult {\n /** Display name for this sample variation */\n displayName: string;\n /** Generated code snippets by language */\n languageSnippets: Record<string, string>;\n /** Original sample params (for reference) */\n params?: Record<string, unknown>;\n /** Description if available */\n description?: string;\n}\n\n/**\n * Generate code samples for multiple languages and multiple sample variations in parallel\n *\n * This function is optimized for SSG build processes where you need to generate\n * code for all languages and all sample variations efficiently.\n *\n * @param options - Batch generation options\n * @returns Array of results with language snippets for each sample\n *\n * @example\n * ```typescript\n * const results = await generateCodeSamplesBatch({\n * samples: [\n * { name: \"Create with card\", sample: { uri: \"/customers\", method: \"POST\", params: { first_name: \"John\" } } },\n * { name: \"Create with token\", sample: { uri: \"/customers\", method: \"POST\", params: { payment_method: { type: \"card\" } } } }\n * ],\n * languages: [\"curl\", \"node-v3\", \"python-v3\"],\n * config: {\n * apiVersion: \"v2\",\n * pcVersion: \"v2\",\n * operation: \"create_a_customer\",\n * openapi, // or descriptor\n * site: \"{site}\",\n * apiKey: \"{site_api_key}\"\n * }\n * });\n * ```\n */\nexport async function generateCodeSamplesBatch(\n options: BatchGenerationOptions,\n): Promise<BatchGenerationResult[]> {\n const { samples, languages, config } = options;\n\n // Generate all samples in parallel\n const results = await Promise.all(\n samples.map(async ({ name, sample }) => {\n const languageSnippets: Record<string, string> = {};\n\n // Generate code for all languages in parallel for this sample\n await Promise.all(\n languages.map(async (lang) => {\n try {\n // Create GeneratorConfig with required fields (provide defaults if not specified)\n const generatorConfig: GeneratorConfig = {\n site: config.site || \"{site}\",\n apiKey: config.apiKey || \"{site_api_key}\",\n apiVersion: config.apiVersion,\n pcVersion: config.pcVersion,\n operation: config.operation,\n openapi: config.openapi,\n descriptor: config.descriptor,\n };\n const code = await generateFromSample(\n sample,\n generatorConfig,\n lang,\n );\n languageSnippets[lang] = code;\n } catch (error) {\n // Log error but continue with other languages\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n console.error(\n `Failed to generate ${lang} code for sample \"${name}\":`,\n errorMessage,\n );\n languageSnippets[lang] =\n `// Error generating code: ${errorMessage}`;\n }\n }),\n );\n\n return {\n displayName: name,\n languageSnippets,\n params: sample.params,\n description: sample.description || sample.note,\n };\n }),\n );\n\n return results;\n}\n","/**\n * Pure function API for generating code samples\n *\n * This module provides a non-React API for generating code samples that can be used\n * by any JavaScript/TypeScript environment, including LLMs and non-React libraries.\n *\n * @example\n * ```typescript\n * import { generateCodeSample } from '@chargebee/code-sample-generator';\n *\n * // Generate code for a specific language\n * const code = await generateCodeSample({\n * language: 'node-v3',\n * resource: 'customer',\n * operation: 'create_a_customer',\n * apiVersion: 'v2',\n * pcVersion: 'v2',\n * site: 'acme-test',\n * apiKey: 'test_api_key'\n * });\n * ```\n */\n\nimport type { MinimalOperationDescriptor, ValidationOptions } from \"../core\";\nimport { assertValid, buildIR, expandDescriptor } from \"../core\";\nimport {\n CodeGenerationError,\n LanguageNotSupportedError,\n OperationNotFoundError,\n} from \"../errors\";\nimport type { OperationId } from \"../generated/ops/operation-ids\";\nimport type { ParamsForOperation } from \"../generated/ops/operation-params\";\nimport { getGenerator, getSupportedLanguages } from \"../generators/registry\";\nimport type { SampleRequest } from \"../samples/types\";\nimport { resolveDescriptor } from \"./resolve-descriptor\";\n\n/**\n * Options for generating code samples\n *\n * @template Op - The operation ID. When provided, params type in request is inferred from OperationParamsMap.\n *\n * @example\n * ```typescript\n * // Basic usage (backward compatible):\n * const code = await generateCodeSample({\n * operation: 'create_a_customer',\n * request: {\n * params: { first_name: 'John' }\n * }\n * });\n * ```\n *\n * @example\n * ```typescript\n * // With operation-aware types (if OperationParamsMap is extended via module augmentation):\n * // In your project:\n * // declare module '@chargebee/code-sample-generator' {\n * // interface OperationParamsMap {\n * // create_a_customer: { first_name?: string; last_name?: string; };\n * // }\n * // }\n *\n * const code = await generateCodeSample<'create_a_customer'>({\n * operation: 'create_a_customer',\n * request: {\n * params: {\n * first_name: 'John', // ✅ Type-safe\n * fsrtName: 'John', // ❌ TypeScript error\n * }\n * }\n * });\n * ```\n */\nexport interface GenerateCodeSampleOptions<\n Op extends OperationId = OperationId,\n> {\n /**\n * Target language/SDK version (e.g., \"curl\", \"node-v3\", \"python-v2\", \"java-v3\")\n */\n language?: string;\n\n /**\n * Pre-generated code samples (if available)\n * Format: { [language]: codeString }\n */\n samples?: Record<string, string>;\n\n /**\n * Resource name (e.g., \"customer\", \"subscription\")\n */\n resource?: string;\n\n /**\n * Operation name (e.g., \"create_a_customer\", \"list_subscriptions\")\n *\n * When you type \"operation:\" and hit Ctrl+Space, TypeScript will show\n * all available operations with autocomplete.\n *\n * @example\n * ```typescript\n * operation: 'create_a_customer' // ← Autocomplete shows all operations\n * ```\n */\n operation?: OperationId | string; // Union type provides autocomplete, string for backward compatibility\n\n /**\n * API version (\"v1\" or \"v2\")\n * Defaults to \"v2\"\n */\n apiVersion?: \"v1\" | \"v2\";\n\n /**\n * Product Catalog version (\"v1\" or \"v2\")\n * Defaults to apiVersion if not specified\n */\n pcVersion?: \"v1\" | \"v2\";\n\n /**\n * Sample request data\n *\n * If using operation-aware types, the params in request will be type-checked\n * based on the operation specified.\n */\n request?:\n | SampleRequest<ParamsForOperation<Op>>\n | SampleRequest<ParamsForOperation<Op>>[];\n\n /**\n * Site name (e.g., \"acme-test\")\n * Defaults to \"your-site\"\n */\n site?: string;\n\n /**\n * API key\n * Defaults to \"test_api_key\"\n */\n apiKey?: string;\n\n /** Domain name (e.g. \"chargebee.com\"). Defaults to \"chargebee.com\" when not set. */\n domainName?: string;\n\n /**\n * String replacements (e.g., { \"{site}\": \"acme\" })\n */\n replacements?: Record<string, string>;\n\n /**\n * Runtime param validation against the operation schema.\n * - true (default): strict validation — rejects unknown fields, validates types/enums/required.\n * Throws ValidationError with detailed issues on invalid params.\n * - false: no validation (params passed through as-is)\n * - ValidationOptions: custom validation config\n */\n validate?: boolean | ValidationOptions;\n\n /**\n * OpenAPI document for this operation. Descriptors are extracted from it\n * (cached per document). When omitted (and no `descriptor`), the frozen\n * registry is used.\n */\n openapi?: unknown;\n\n /**\n * Pre-extracted descriptor for this operation. Takes precedence over\n * `openapi` when `descriptor.id` matches `operation`. Prefer this when the\n * host extracted descriptors from its own spec at build time.\n */\n descriptor?: MinimalOperationDescriptor;\n}\n\n/**\n * Result of code sample generation\n */\nexport interface GenerateCodeSampleResult {\n /** Generated code string */\n code: string;\n\n /** Language/SDK version that was used */\n language: string;\n}\n\n/**\n * Generate a code sample string for a specific language\n *\n * @param options - Generation options\n * @returns Generated code sample\n *\n * @template Op - The operation ID. Type is inferred from options.operation when possible.\n */\nexport async function generateCodeSample<Op extends OperationId = OperationId>(\n options: GenerateCodeSampleOptions<Op>,\n): Promise<GenerateCodeSampleResult> {\n const {\n language = \"curl\",\n samples,\n resource,\n operation,\n apiVersion = \"v2\",\n pcVersion,\n request,\n site = \"your-site\",\n apiKey = \"test_api_key\",\n domainName,\n replacements,\n openapi,\n descriptor: providedDescriptor,\n } = options;\n\n // If pre-generated samples are provided, return the requested language\n if (samples?.[language]) {\n let code = samples[language];\n\n // Apply string replacements if provided\n if (replacements) {\n for (const [key, value] of Object.entries(replacements)) {\n code = code.replace(\n new RegExp(key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"g\"),\n value,\n );\n }\n }\n\n return { code, language };\n }\n\n // Generate code using generators (all generators are v2 IR-based)\n if (!operation) {\n throw new Error(\n \"Operation is required for code generation. Either provide 'operation' option or use 'samples' with pre-generated code.\",\n );\n }\n\n // Get the generator (all generators are v2)\n const generator = getGenerator(language);\n if (!generator) {\n const supportedLanguages = getSupportedLanguages();\n throw new LanguageNotSupportedError(language, supportedLanguages);\n }\n\n // Get combined version\n const combinedVersion = getCombinedVersion(\n apiVersion,\n pcVersion || apiVersion,\n );\n\n // Load operation descriptor\n const minimalDescriptor = resolveDescriptor(\n combinedVersion,\n operation,\n openapi,\n providedDescriptor,\n );\n if (!minimalDescriptor) {\n throw new OperationNotFoundError(operation, combinedVersion);\n }\n\n // Expand descriptor\n const descriptor = expandDescriptor(minimalDescriptor);\n\n // Extract params and note from sample request\n let params: Record<string, unknown> = {};\n let note: string | undefined;\n if (request) {\n const sampleRequest = Array.isArray(request) ? request[0] : request;\n const reqParams = sampleRequest.params || {};\n params = (reqParams as any).map ? (reqParams as any).map : reqParams;\n note = sampleRequest.note;\n }\n\n // Validate params against operation schema (on by default)\n const shouldValidate = options.validate ?? true;\n if (shouldValidate) {\n const validationOpts: ValidationOptions =\n typeof shouldValidate === \"object\"\n ? shouldValidate\n : { allowUnknown: false };\n // Strip path params before validation — they're in the URL, not the body schema\n const bodyParams = stripPathParams(\n params,\n descriptor.http.path,\n descriptor.params,\n );\n assertValid(operation, descriptor.params, bodyParams, validationOpts);\n }\n\n // Build IR\n const ir = buildIR(descriptor, params, {\n site: site || \"{site}\",\n apiKey: apiKey || \"{site_api_key}\",\n apiVersion: apiVersion || \"v2\",\n domainName: domainName ?? \"chargebee.com\",\n note,\n });\n\n // Generate code\n let code: string;\n try {\n code = generator(ir);\n } catch (error) {\n throw new CodeGenerationError(\n operation,\n language,\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n\n // Apply string replacements if provided\n if (replacements) {\n for (const [key, value] of Object.entries(replacements)) {\n code = code.replace(\n new RegExp(key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"g\"),\n value,\n );\n }\n }\n\n return { code, language };\n}\n\n/**\n * Generate code samples for multiple languages at once\n *\n * @param options - Generation options with array of languages\n * @returns Map of language to generated code\n */\nexport async function generateCodeSamples<Op extends OperationId = OperationId>(\n options: GenerateCodeSampleOptions<Op> & {\n languages: string[];\n },\n): Promise<Record<string, string>> {\n const { languages, ...baseOptions } = options;\n\n const results: Record<string, string> = {};\n\n await Promise.all(\n languages.map(async (lang) => {\n try {\n const result = await generateCodeSample({\n ...baseOptions,\n language: lang,\n });\n results[lang] = result.code;\n } catch (error) {\n console.error(`Failed to generate code for ${lang}:`, error);\n const errorMessage =\n error instanceof CodeGenerationError\n ? error.message\n : error instanceof Error\n ? error.message\n : String(error);\n results[lang] = `// Error generating code: ${errorMessage}`;\n }\n }),\n );\n\n return results;\n}\n\n/**\n * Convert apiVersion + pcVersion to combined version format\n */\nfunction getCombinedVersion(\n apiVersion?: string,\n pcVersion?: string,\n): \"v1\" | \"v2-pcv1\" | \"v2-pcv2\" {\n if (apiVersion === \"v1\") {\n return \"v1\";\n }\n\n const pc = pcVersion || \"v2\";\n if (pc === \"v1\") {\n return \"v2-pcv1\";\n }\n\n return \"v2-pcv2\";\n}\n\n/**\n * Strips path-only params from a params object before validation.\n * Path params (e.g., customer-id from \"/customers/{customer-id}\") are in the URL,\n * not in the body schema. Keeps params that are BOTH path and body params (e.g., item_id).\n */\nfunction stripPathParams(\n params: Record<string, unknown>,\n pathTemplate: string,\n bodySchema: import(\"../core/types\").ParamSchema,\n): Record<string, unknown> {\n const pathParamKeys = new Set<string>();\n const placeholderRegex = /\\{([^}]+)\\}/g;\n let match = placeholderRegex.exec(pathTemplate);\n while (match !== null) {\n const name = match[1];\n pathParamKeys.add(name);\n pathParamKeys.add(name.replace(/-/g, \"_\"));\n if (name.endsWith(\"-id\") || name.endsWith(\"_id\")) {\n pathParamKeys.add(\"id\");\n }\n match = placeholderRegex.exec(pathTemplate);\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(params)) {\n // Keep if it's a body param OR not a path param\n if (bodySchema.properties?.[key] !== undefined || !pathParamKeys.has(key)) {\n result[key] = value;\n }\n }\n return result;\n}\n"],"names":["code"],"mappings":";AA4BO,MAAM,YAAwB;AAAA,EACnC;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;ACvBA,SAAS,aAAa,KAAqB;AACzC,SAAO,IACJ,MAAM,MAAM,EACZ,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAA,IAAgB,KAAK,MAAM,CAAC,EAAE,YAAA,CAAa,EACxE,KAAK,EAAE;AACZ;AA0BO,SAAS,0BACd,aACA,MACA,QACoB;AACpB,QAAM,UAA8B,CAAA;AAEpC,MAAI,CAAC,aAAa,OAAO;AACvB,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,OAAO,YAAA;AAI1B,MAAI,YAAY,YAAY,QAAQ,IAAI,IAAI,UAAU;AAGtD,MAAI,CAAC,WAAW;AACd,eAAW,YAAY,OAAO,KAAK,YAAY,KAAK,GAAG;AAGrD,YAAM,YAAY,IAAI;AAAA,QACpB,MAAM,SAAS,QAAQ,cAAc,OAAO,IAAI;AAAA,MAAA;AAElD,UAAI,UAAU,KAAK,IAAI,GAAG;AACxB,oBAAY,YAAY,MAAM,QAAQ,IAAI,UAAU;AACpD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAKA,QAAM,eAAe,CAAC,OAAO,OAAO,KAAK;AACzC,MAAI,iBAAsB;AAE1B,aAAW,QAAQ,cAAc;AAC/B,UAAM,WAAW,WAAW,YAAY,IAAI;AAC5C,QAAI,UAAU,UAAU,kBAAkB,GAAG,QAAQ;AACnD,uBAAiB,SAAS,QAA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oB,IAAA;AAC1B,QAAM,mBAAmB;AACzB,MAAI,QAAQ,iBAAiB,KAAK,YAAY;AAC9C,SAAO,UAAU,MAAM;AACrB,UAAM,OAAO,MAAM,CAAC;AACpB,kBAAc,IAAI,IAAI;AACtB,kBAAc,IAAI,KAAK,QAAQ,MAAM,GAAG,CAAC;AACzC,QAAI,KAAK,SAAS,KAAK,KAAK,KAAK,SAAS,KAAK,GAAG;AAChD,oBAAc,IAAI,IAAI;AAAA,IACxB;AACA,YAAQ,iBAAiB,KAAK,YAAY;AAAA,EAC5C;AAEA,QAAM,SAAkC,CAAA;AACxC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAEjD,QAAI,WAAW,aAAa,GAAG,MAAM,UAAa,CAAC,cAAc,IAAI,GAAG,GAAG;AACzE,aAAO,GAAG,IAAI;AAAA,IAChB;AAAA,EACF;AACA,SAAO;AACT;"}
|
|
1
|
+
{"version":3,"file":"generate-code-sample-JkPVVgWV.js","sources":["../src/core/types.ts","../src/core/openapi-returns.ts","../src/utils/generate-batch.ts","../src/utils/generate-code-sample.ts"],"sourcesContent":["/**\n * Core type definitions for the code-samples package.\n * These types define the full/expanded format used at runtime by renderers.\n */\n\n// =============================================================================\n// Language Types\n// =============================================================================\n\n/**\n * Supported programming languages for code generation.\n * Matches the generator registry in src/generators/index.ts\n */\nexport type Language =\n | \"curl\"\n | \"node-v2\"\n | \"node-v3\"\n | \"python-v2\"\n | \"python-v3\"\n | \"java-v3\"\n | \"java-v4\"\n | \"php-v3\"\n | \"php-v4\"\n | \"ruby\"\n | \"go-v3\"\n | \"go-v4\"\n | \"dotnet\";\n\nexport const LANGUAGES: Language[] = [\n \"curl\",\n \"node-v2\",\n \"node-v3\",\n \"python-v2\",\n \"python-v3\",\n \"java-v3\",\n \"java-v4\",\n \"php-v3\",\n \"php-v4\",\n \"ruby\",\n \"go-v3\",\n \"go-v4\",\n \"dotnet\",\n];\n\n// =============================================================================\n// API Version Types\n// =============================================================================\n\nexport type ApiVersion = \"v1\" | \"v2\";\nexport type PcVersion = \"v1\" | \"v2\";\n\n/**\n * Combined API version format used for sample organization.\n * - v1: API v1\n * - v2-pcv1: API v2 with Product Catalog v1\n * - v2-pcv2: API v2 with Product Catalog v2\n */\nexport type CombinedApiVersion = \"v1\" | \"v2-pcv1\" | \"v2-pcv2\";\n\n// =============================================================================\n// Parameter Schema Types\n// =============================================================================\n\n/**\n * Schema definition for a parameter.\n * This is the expanded runtime format used by generators.\n *\n * CB-specific extensions (x-cb-*) are normalized to camelCase properties.\n * See src/constants/openapi-extensions.ts for the original extension names.\n *\n * Mapping from OpenAPI extensions to ParamSchema properties:\n * - x-cb-is-filter-parameter → isFilter\n * - x-cb-sdk-filter-name → sdkFilterName\n * - x-cb-is-global-enum → isGlobalEnum\n * - x-cb-is-external-enum → isExternalEnum\n * - x-cb-sdk-enum-api-name → sdkEnumName\n * - x-cb-is-money-column → isMoneyColumn\n * - x-cb-is-sub-resource → isSubResource\n */\nexport interface ParamSchema {\n // JSON Schema standard fields\n type: \"string\" | \"integer\" | \"number\" | \"boolean\" | \"array\" | \"object\";\n format?: \"int32\" | \"int64\" | \"unix-time\" | \"decimal\" | \"double\" | \"boolean\";\n enum?: string[];\n required?: string[];\n properties?: Record<string, ParamSchema>;\n items?: ParamSchema;\n additionalProperties?: boolean;\n\n // CB-specific extensions (from x-cb-* OpenAPI extensions)\n\n /** Whether this is a filter parameter (x-cb-is-filter-parameter) */\n isFilter?: boolean;\n\n /** Filter type for SDK filter classes (derived from x-cb-sdk-filter-name) */\n filterType?: \"string\" | \"timestamp\" | \"enum\" | \"number\" | \"boolean\";\n\n /** SDK filter class name (x-cb-sdk-filter-name) e.g., \"StringFilter\", \"EnumFilter\" */\n sdkFilterName?: string;\n\n /** Whether this is a global enum (x-cb-is-global-enum) */\n isGlobalEnum?: boolean;\n\n /** Whether this is an external enum requiring separate class (x-cb-is-external-enum) */\n isExternalEnum?: boolean;\n\n /** SDK enum class name (x-cb-sdk-enum-api-name) e.g., \"BillingAlignmentMode\" */\n sdkEnumName?: string;\n\n /** Whether this is a money/currency column (x-cb-is-money-column) */\n isMoneyColumn?: boolean;\n\n /** Whether this is a sub-resource (x-cb-is-sub-resource) */\n isSubResource?: boolean;\n\n /**\n * From IR `tlr`: true when some resource declares this array-sub-object enum's\n * attribute. Go v4 and .NET use this to keep the enum on its own class. Java v3 /\n * Go v3 / Python v3 also use `isOperationSubResource` /\n * `isGlobalResourceReference` / `isDependentAttribute` / `isExternalEnum`.\n */\n isTopLevelResourceEnum?: boolean;\n\n /**\n * From IR `opsr`: the operation resource declares the enum's container with\n * `x-cb-is-sub-resource` (e.g. `alert.filter_conditions`).\n */\n isOperationSubResource?: boolean;\n\n /**\n * From IR `grr`: the container has `x-cb-is-global-resource-reference`\n * (e.g. `metered_feature.column_definitions`).\n */\n isGlobalResourceReference?: boolean;\n\n /**\n * From IR `dep`: the container has `x-cb-is-dependent-attribute`.\n */\n isDependentAttribute?: boolean;\n\n /**\n * From IR `ro`: the single-object form of `isTopLevelResourceEnum` (e.g.\n * `contract_term` in `import_contract_term`). Only Go v4 uses it, writing the\n * enum with the owning resource's type (`ContractTermActionAtTermEnd`).\n */\n isResourceOwnedEnum?: boolean;\n\n /** Owning resource name in plural snake_case (x-cb-meta-model-name), e.g., \"credit_notes\" */\n metaModelName?: string;\n}\n\n// =============================================================================\n// Operation Descriptor Types\n// =============================================================================\n\n/**\n * HTTP method types supported by the API.\n */\nexport type HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\n\n/**\n * Full operation descriptor used at runtime by generators.\n * This is the expanded format after minimal descriptor expansion.\n */\nexport interface OperationDescriptor {\n /** Unique operation identifier, e.g., \"create_a_customer\" */\n id: string;\n\n /** HTTP request details */\n http: {\n /** HTTP method */\n method: HttpMethod;\n /** Path template with placeholders, e.g., \"/customers/{customer-id}\" */\n path: string;\n };\n\n /** Resource name (singular), e.g., \"customer\" (from OpenAPIExtensions.RESOURCE_ID) */\n resource: string;\n\n /** SDK method name, e.g., \"create\" (from x-cb-operation-method-name; primary for Python/Node/Ruby) */\n method: string;\n\n /**\n * Java v4 SDK method name (x-cb-sdk-method-name).\n * Java v4 generator uses methodSdk ?? method.\n */\n methodSdk?: string;\n\n /**\n * @deprecated Kept for backward compat. Python v3 uses methodAbbreviated ?? method.\n */\n methodAbbreviated?: string;\n\n // Operation flags (from x-cb-* extensions)\n\n /** Whether this is a list operation returning multiple items (x-cb-operation-is-list) */\n isListOperation: boolean;\n\n /** Whether request body should be JSON instead of form-encoded (x-cb-is-operation-needs-json-input) */\n isJsonInput: boolean;\n\n /** Whether this is a batch operation (x-cb-operation-is-batch) */\n isBatch?: boolean;\n\n /** Whether idempotency key is supported (x-cb-idempotency-supported) */\n idempotencySupported?: boolean;\n\n /** Whether the OpenAPI spec defines a requestBody for this operation */\n hasRequestBody?: boolean;\n\n /** API subdomain for this operation, e.g., \"ingest\", \"grow\", \"file-ingest\" */\n subDomain?: string;\n\n /** Parameter schema for the operation */\n params: ParamSchema;\n\n /** Return type descriptors (optional, for response type generation) */\n returns?: ReturnDescriptor[];\n}\n\n/**\n * Describes a return type from an operation response.\n */\nexport interface ReturnDescriptor {\n /** Property name in response, e.g., \"customer\" */\n name: string;\n\n /** Data type for the property, e.g., \"Customer\" */\n dataType: string;\n\n /** Whether the return is an array */\n isArray: boolean;\n\n /** Whether this is a resource type (vs primitive) */\n isResource: boolean;\n}\n","/**\n * OpenAPI Return Type Extraction\n *\n * Extracts return types from OpenAPI response schemas to enrich operation descriptors\n * with full return type information.\n *\n * This module bridges the gap between minimal descriptors (which may have limited\n * return types) and full OpenAPI specs (which have complete response schemas).\n */\n\nimport type { OperationDescriptor, ReturnDescriptor } from \"./types\";\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Converts a string to PascalCase.\n */\nfunction toPascalCase(str: string): string {\n return str\n .split(/[-_]/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n}\n\n// =============================================================================\n// OpenAPI Return Type Extraction\n// =============================================================================\n\n/**\n * Extracts return types from an OpenAPI operation's response schema.\n *\n * This function reads the response schema from the OpenAPI spec and extracts\n * all return properties, including their types and array status.\n *\n * @param openapiSpec - The full OpenAPI specification object\n * @param path - The API path, e.g., \"/customers\" or \"/customers/{id}\"\n * @param method - The HTTP method, e.g., \"POST\" or \"GET\"\n * @returns Array of ReturnDescriptor objects\n *\n * @example\n * ```typescript\n * const returns = extractReturnsFromOpenAPI(spec, \"/customers\", \"POST\");\n * // Returns: [\n * // { name: \"customer\", dataType: \"Customer\", isArray: false, isResource: true },\n * // { name: \"card\", dataType: \"Card\", isArray: false, isResource: true }\n * // ]\n * ```\n */\nexport function extractReturnsFromOpenAPI(\n openapiSpec: any,\n path: string,\n method: string,\n): ReturnDescriptor[] {\n const returns: ReturnDescriptor[] = [];\n\n if (!openapiSpec?.paths) {\n return returns;\n }\n\n // Normalize method to lowercase\n const httpMethod = method.toLowerCase();\n\n // Try to find the operation in the spec\n // First try exact path match\n let operation = openapiSpec.paths?.[path]?.[httpMethod];\n\n // If not found, try to find matching path with path parameters\n if (!operation) {\n for (const specPath of Object.keys(openapiSpec.paths)) {\n // Convert path params to regex pattern\n // e.g., \"/customers/{customer-id}\" -> /\\/customers\\/[^/]+/\n const pathRegex = new RegExp(\n \"^\" + specPath.replace(/\\{[^}]+\\}/g, \"[^/]+\") + \"$\",\n );\n if (pathRegex.test(path)) {\n operation = openapiSpec.paths[specPath]?.[httpMethod];\n break;\n }\n }\n }\n\n if (!operation) {\n return returns;\n }\n\n // Get response schema from OpenAPI spec.\n // Use same order as sdk-generator Action.onSuccessSchema(): 200 → 202 → 204\n // so return names align with SDK response attribute names (same property keys).\n const successCodes = [\"200\", \"202\", \"204\"];\n let responseSchema: any = null;\n\n for (const code of successCodes) {\n const response = operation?.responses?.[code];\n if (response?.content?.[\"application/json\"]?.schema) {\n responseSchema = response.content[\"application/json\"].schema;\n break;\n }\n }\n\n if (!responseSchema?.properties) {\n return returns;\n }\n\n // Extract return params from response schema properties\n for (const [key, propSchema] of Object.entries(responseSchema.properties)) {\n // Skip metadata fields\n if (key === \"next_offset\" || key === \"api_version\") {\n continue;\n }\n\n const schema = propSchema as any;\n\n // Check if it's an array type\n const isArray = schema.type === \"array\";\n\n // Check if it's a resource (has $ref to a schema or is an object type)\n const isResource =\n !!schema.$ref ||\n !!schema.items?.$ref ||\n schema.type === \"object\" ||\n (isArray && schema.items?.type === \"object\");\n\n // Handle \"list\" field specially - it contains array of resources\n if (key === \"list\" && isArray && schema.items?.properties) {\n // Extract the resource types from list items\n for (const [itemKey, itemSchema] of Object.entries(\n schema.items.properties,\n )) {\n const itemSchemaTyped = itemSchema as any;\n returns.push({\n name: itemKey,\n dataType: toPascalCase(itemKey),\n isArray: false,\n isResource:\n !!itemSchemaTyped.$ref || itemSchemaTyped.type === \"object\",\n });\n }\n continue;\n }\n\n returns.push({\n name: key,\n dataType: toPascalCase(key),\n isArray,\n isResource,\n });\n }\n\n return returns;\n}\n\n/**\n * Finds an operation in the OpenAPI spec by operationId.\n *\n * @param openapiSpec - The full OpenAPI specification object\n * @param operationId - The operationId to find\n * @returns Object with path, method, and operation, or null if not found\n */\nexport function findOperationById(\n openapiSpec: any,\n operationId: string,\n): { path: string; method: string; operation: any } | null {\n if (!openapiSpec?.paths) {\n return null;\n }\n\n for (const [path, pathItem] of Object.entries(openapiSpec.paths)) {\n if (!pathItem) continue;\n\n for (const [method, operation] of Object.entries(pathItem as any)) {\n if (\n typeof operation === \"object\" &&\n operation !== null &&\n \"operationId\" in operation &&\n operation.operationId === operationId\n ) {\n return { path, method: method.toUpperCase(), operation };\n }\n }\n }\n\n return null;\n}\n\n/**\n * Extracts returns from OpenAPI using an operationId.\n *\n * @param openapiSpec - The full OpenAPI specification object\n * @param operationId - The operationId to look up\n * @returns Array of ReturnDescriptor objects\n */\nexport function extractReturnsByOperationId(\n openapiSpec: any,\n operationId: string,\n): ReturnDescriptor[] {\n const found = findOperationById(openapiSpec, operationId);\n if (!found) {\n return [];\n }\n\n return extractReturnsFromOpenAPI(openapiSpec, found.path, found.method);\n}\n\n// =============================================================================\n// Descriptor Enrichment\n// =============================================================================\n\n/**\n * Options for enriching a descriptor with OpenAPI data.\n */\nexport interface EnrichOptions {\n /** The OpenAPI specification object */\n openapiSpec: any;\n\n /** Whether to overwrite existing returns (default: false - merge) */\n overwrite?: boolean;\n}\n\n/**\n * Enriches an operation descriptor with return types from OpenAPI.\n *\n * This function takes an existing descriptor (which may have limited returns)\n * and adds/updates return types from the OpenAPI specification.\n *\n * @param descriptor - The operation descriptor to enrich\n * @param options - Enrichment options including OpenAPI spec\n * @returns A new descriptor with enriched returns\n *\n * @example\n * ```typescript\n * const minimal = expandDescriptor(minimalDescriptor);\n * const enriched = enrichDescriptorWithOpenAPI(minimal, { openapiSpec: spec });\n * // enriched.returns now has full return types from OpenAPI\n * ```\n */\nexport function enrichDescriptorWithOpenAPI(\n descriptor: OperationDescriptor,\n options: EnrichOptions,\n): OperationDescriptor {\n const { openapiSpec, overwrite = false } = options;\n\n // Try to get returns from OpenAPI by operationId first\n let openapiReturns = extractReturnsByOperationId(openapiSpec, descriptor.id);\n\n // If not found by operationId, try by path and method\n if (openapiReturns.length === 0) {\n openapiReturns = extractReturnsFromOpenAPI(\n openapiSpec,\n descriptor.http.path,\n descriptor.http.method,\n );\n }\n\n // If no OpenAPI returns found, return original descriptor\n if (openapiReturns.length === 0) {\n return descriptor;\n }\n\n // If overwrite mode or no existing returns, use OpenAPI returns\n if (overwrite || !descriptor.returns || descriptor.returns.length === 0) {\n return {\n ...descriptor,\n returns: openapiReturns,\n };\n }\n\n // Merge mode: start with existing returns\n const existingNames = new Set(descriptor.returns.map((r) => r.name));\n const mergedReturns = [...descriptor.returns];\n\n // Add any OpenAPI returns that aren't already present\n for (const ret of openapiReturns) {\n if (!existingNames.has(ret.name)) {\n mergedReturns.push(ret);\n }\n }\n\n return {\n ...descriptor,\n returns: mergedReturns,\n };\n}\n\n/**\n * Batch enriches multiple descriptors with OpenAPI returns.\n *\n * @param descriptors - Array of descriptors to enrich\n * @param openapiSpec - The OpenAPI specification object\n * @returns Array of enriched descriptors\n */\nexport function enrichDescriptorsWithOpenAPI(\n descriptors: OperationDescriptor[],\n openapiSpec: any,\n): OperationDescriptor[] {\n return descriptors.map((desc) =>\n enrichDescriptorWithOpenAPI(desc, { openapiSpec }),\n );\n}\n","/**\n * Batch Code Generation for SSG\n *\n * Optimized batch generation function for generating code samples for multiple\n * languages and multiple sample variations in parallel. Designed for SSG build processes.\n */\n\nimport type { SampleRequest } from \"../samples/types\";\nimport type { GeneratorConfig } from \"../types\";\nimport { generateFromSample } from \"./generate-from-sample\";\n\n/**\n * Options for batch code generation\n */\nexport interface BatchGenerationOptions {\n /** Array of sample requests with display names */\n samples: Array<{ name: string; sample: SampleRequest }>;\n /** Languages to generate code for */\n languages: string[];\n /** Generator configuration (must include openapi and/or descriptor) */\n config: {\n apiVersion: string;\n pcVersion: string;\n operation: string;\n site?: string;\n apiKey?: string;\n /** OpenAPI document — required unless `descriptor` is set */\n openapi?: unknown;\n /** Pre-extracted descriptor — required unless `openapi` is set */\n descriptor?: import(\"../core/minimal-types\").MinimalOperationDescriptor;\n };\n}\n\n/**\n * Result of batch generation\n */\nexport interface BatchGenerationResult {\n /** Display name for this sample variation */\n displayName: string;\n /** Generated code snippets by language */\n languageSnippets: Record<string, string>;\n /** Original sample params (for reference) */\n params?: Record<string, unknown>;\n /** Description if available */\n description?: string;\n}\n\n/**\n * Generate code samples for multiple languages and multiple sample variations in parallel\n *\n * This function is optimized for SSG build processes where you need to generate\n * code for all languages and all sample variations efficiently.\n *\n * @param options - Batch generation options\n * @returns Array of results with language snippets for each sample\n *\n * @example\n * ```typescript\n * const results = await generateCodeSamplesBatch({\n * samples: [\n * { name: \"Create with card\", sample: { uri: \"/customers\", method: \"POST\", params: { first_name: \"John\" } } },\n * { name: \"Create with token\", sample: { uri: \"/customers\", method: \"POST\", params: { payment_method: { type: \"card\" } } } }\n * ],\n * languages: [\"curl\", \"node-v3\", \"python-v3\"],\n * config: {\n * apiVersion: \"v2\",\n * pcVersion: \"v2\",\n * operation: \"create_a_customer\",\n * openapi, // or descriptor\n * site: \"{site}\",\n * apiKey: \"{site_api_key}\"\n * }\n * });\n * ```\n */\nexport async function generateCodeSamplesBatch(\n options: BatchGenerationOptions,\n): Promise<BatchGenerationResult[]> {\n const { samples, languages, config } = options;\n\n // Generate all samples in parallel\n const results = await Promise.all(\n samples.map(async ({ name, sample }) => {\n const languageSnippets: Record<string, string> = {};\n\n // Generate code for all languages in parallel for this sample\n await Promise.all(\n languages.map(async (lang) => {\n try {\n // Create GeneratorConfig with required fields (provide defaults if not specified)\n const generatorConfig: GeneratorConfig = {\n site: config.site || \"{site}\",\n apiKey: config.apiKey || \"{site_api_key}\",\n apiVersion: config.apiVersion,\n pcVersion: config.pcVersion,\n operation: config.operation,\n openapi: config.openapi,\n descriptor: config.descriptor,\n };\n const code = await generateFromSample(\n sample,\n generatorConfig,\n lang,\n );\n languageSnippets[lang] = code;\n } catch (error) {\n // Log error but continue with other languages\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n console.error(\n `Failed to generate ${lang} code for sample \"${name}\":`,\n errorMessage,\n );\n languageSnippets[lang] =\n `// Error generating code: ${errorMessage}`;\n }\n }),\n );\n\n return {\n displayName: name,\n languageSnippets,\n params: sample.params,\n description: sample.description || sample.note,\n };\n }),\n );\n\n return results;\n}\n","/**\n * Pure function API for generating code samples\n *\n * This module provides a non-React API for generating code samples that can be used\n * by any JavaScript/TypeScript environment, including LLMs and non-React libraries.\n *\n * @example\n * ```typescript\n * import { generateCodeSample } from '@chargebee/code-sample-generator';\n *\n * // Generate code for a specific language\n * const code = await generateCodeSample({\n * language: 'node-v3',\n * resource: 'customer',\n * operation: 'create_a_customer',\n * apiVersion: 'v2',\n * pcVersion: 'v2',\n * site: 'acme-test',\n * apiKey: 'test_api_key'\n * });\n * ```\n */\n\nimport type { MinimalOperationDescriptor, ValidationOptions } from \"../core\";\nimport { assertValid, buildIR, expandDescriptor } from \"../core\";\nimport {\n CodeGenerationError,\n LanguageNotSupportedError,\n OperationNotFoundError,\n} from \"../errors\";\nimport type { OperationId } from \"../generated/ops/operation-ids\";\nimport type { ParamsForOperation } from \"../generated/ops/operation-params\";\nimport { getGenerator, getSupportedLanguages } from \"../generators/registry\";\nimport type { SampleRequest } from \"../samples/types\";\nimport { resolveDescriptor } from \"./resolve-descriptor\";\n\n/**\n * Options for generating code samples\n *\n * @template Op - The operation ID. When provided, params type in request is inferred from OperationParamsMap.\n *\n * @example\n * ```typescript\n * // Basic usage (backward compatible):\n * const code = await generateCodeSample({\n * operation: 'create_a_customer',\n * request: {\n * params: { first_name: 'John' }\n * }\n * });\n * ```\n *\n * @example\n * ```typescript\n * // With operation-aware types (if OperationParamsMap is extended via module augmentation):\n * // In your project:\n * // declare module '@chargebee/code-sample-generator' {\n * // interface OperationParamsMap {\n * // create_a_customer: { first_name?: string; last_name?: string; };\n * // }\n * // }\n *\n * const code = await generateCodeSample<'create_a_customer'>({\n * operation: 'create_a_customer',\n * request: {\n * params: {\n * first_name: 'John', // ✅ Type-safe\n * fsrtName: 'John', // ❌ TypeScript error\n * }\n * }\n * });\n * ```\n */\nexport interface GenerateCodeSampleOptions<\n Op extends OperationId = OperationId,\n> {\n /**\n * Target language/SDK version (e.g., \"curl\", \"node-v3\", \"python-v2\", \"java-v3\")\n */\n language?: string;\n\n /**\n * Pre-generated code samples (if available)\n * Format: { [language]: codeString }\n */\n samples?: Record<string, string>;\n\n /**\n * Resource name (e.g., \"customer\", \"subscription\")\n */\n resource?: string;\n\n /**\n * Operation name (e.g., \"create_a_customer\", \"list_subscriptions\")\n *\n * When you type \"operation:\" and hit Ctrl+Space, TypeScript will show\n * all available operations with autocomplete.\n *\n * @example\n * ```typescript\n * operation: 'create_a_customer' // ← Autocomplete shows all operations\n * ```\n */\n operation?: OperationId | string; // Union type provides autocomplete, string for backward compatibility\n\n /**\n * API version (\"v1\" or \"v2\")\n * Defaults to \"v2\"\n */\n apiVersion?: \"v1\" | \"v2\";\n\n /**\n * Product Catalog version (\"v1\" or \"v2\")\n * Defaults to apiVersion if not specified\n */\n pcVersion?: \"v1\" | \"v2\";\n\n /**\n * Sample request data\n *\n * If using operation-aware types, the params in request will be type-checked\n * based on the operation specified.\n */\n request?:\n | SampleRequest<ParamsForOperation<Op>>\n | SampleRequest<ParamsForOperation<Op>>[];\n\n /**\n * Site name (e.g., \"acme-test\")\n * Defaults to \"your-site\"\n */\n site?: string;\n\n /**\n * API key\n * Defaults to \"test_api_key\"\n */\n apiKey?: string;\n\n /** Domain name (e.g. \"chargebee.com\"). Defaults to \"chargebee.com\" when not set. */\n domainName?: string;\n\n /**\n * String replacements (e.g., { \"{site}\": \"acme\" })\n */\n replacements?: Record<string, string>;\n\n /**\n * Runtime param validation against the operation schema.\n * - true (default): strict validation — rejects unknown fields, validates types/enums/required.\n * Throws ValidationError with detailed issues on invalid params.\n * - false: no validation (params passed through as-is)\n * - ValidationOptions: custom validation config\n */\n validate?: boolean | ValidationOptions;\n\n /**\n * OpenAPI document for this operation. Descriptors are extracted from it\n * (cached per document). When omitted (and no `descriptor`), the frozen\n * registry is used.\n */\n openapi?: unknown;\n\n /**\n * Pre-extracted descriptor for this operation. Takes precedence over\n * `openapi` when `descriptor.id` matches `operation`. Prefer this when the\n * host extracted descriptors from its own spec at build time.\n */\n descriptor?: MinimalOperationDescriptor;\n}\n\n/**\n * Result of code sample generation\n */\nexport interface GenerateCodeSampleResult {\n /** Generated code string */\n code: string;\n\n /** Language/SDK version that was used */\n language: string;\n}\n\n/**\n * Generate a code sample string for a specific language\n *\n * @param options - Generation options\n * @returns Generated code sample\n *\n * @template Op - The operation ID. Type is inferred from options.operation when possible.\n */\nexport async function generateCodeSample<Op extends OperationId = OperationId>(\n options: GenerateCodeSampleOptions<Op>,\n): Promise<GenerateCodeSampleResult> {\n const {\n language = \"curl\",\n samples,\n resource,\n operation,\n apiVersion = \"v2\",\n pcVersion,\n request,\n site = \"your-site\",\n apiKey = \"test_api_key\",\n domainName,\n replacements,\n openapi,\n descriptor: providedDescriptor,\n } = options;\n\n // If pre-generated samples are provided, return the requested language\n if (samples?.[language]) {\n let code = samples[language];\n\n // Apply string replacements if provided\n if (replacements) {\n for (const [key, value] of Object.entries(replacements)) {\n code = code.replace(\n new RegExp(key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"g\"),\n value,\n );\n }\n }\n\n return { code, language };\n }\n\n // Generate code using generators (all generators are v2 IR-based)\n if (!operation) {\n throw new Error(\n \"Operation is required for code generation. Either provide 'operation' option or use 'samples' with pre-generated code.\",\n );\n }\n\n // Get the generator (all generators are v2)\n const generator = getGenerator(language);\n if (!generator) {\n const supportedLanguages = getSupportedLanguages();\n throw new LanguageNotSupportedError(language, supportedLanguages);\n }\n\n // Get combined version\n const combinedVersion = getCombinedVersion(\n apiVersion,\n pcVersion || apiVersion,\n );\n\n // Load operation descriptor\n const minimalDescriptor = resolveDescriptor(\n combinedVersion,\n operation,\n openapi,\n providedDescriptor,\n );\n if (!minimalDescriptor) {\n throw new OperationNotFoundError(operation, combinedVersion);\n }\n\n // Expand descriptor\n const descriptor = expandDescriptor(minimalDescriptor);\n\n // Extract params, note, and headers from sample request\n let params: Record<string, unknown> = {};\n let note: string | undefined;\n let headers: Record<string, string> | undefined;\n if (request) {\n const sampleRequest = Array.isArray(request) ? request[0] : request;\n const reqParams = sampleRequest.params || {};\n params = (reqParams as any).map ? (reqParams as any).map : reqParams;\n note = sampleRequest.note;\n headers = sampleRequest.headers;\n }\n\n // Validate params against operation schema (on by default)\n const shouldValidate = options.validate ?? true;\n if (shouldValidate) {\n const validationOpts: ValidationOptions =\n typeof shouldValidate === \"object\"\n ? shouldValidate\n : { allowUnknown: false };\n // Strip path params before validation — they're in the URL, not the body schema\n const bodyParams = stripPathParams(\n params,\n descriptor.http.path,\n descriptor.params,\n );\n assertValid(operation, descriptor.params, bodyParams, validationOpts);\n }\n\n // Build IR\n const ir = buildIR(descriptor, params, {\n site: site || \"{site}\",\n apiKey: apiKey || \"{site_api_key}\",\n apiVersion: apiVersion || \"v2\",\n domainName: domainName ?? \"chargebee.com\",\n note,\n headers,\n });\n\n // Generate code\n let code: string;\n try {\n code = generator(ir);\n } catch (error) {\n throw new CodeGenerationError(\n operation,\n language,\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n\n // Apply string replacements if provided\n if (replacements) {\n for (const [key, value] of Object.entries(replacements)) {\n code = code.replace(\n new RegExp(key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"g\"),\n value,\n );\n }\n }\n\n return { code, language };\n}\n\n/**\n * Generate code samples for multiple languages at once\n *\n * @param options - Generation options with array of languages\n * @returns Map of language to generated code\n */\nexport async function generateCodeSamples<Op extends OperationId = OperationId>(\n options: GenerateCodeSampleOptions<Op> & {\n languages: string[];\n },\n): Promise<Record<string, string>> {\n const { languages, ...baseOptions } = options;\n\n const results: Record<string, string> = {};\n\n await Promise.all(\n languages.map(async (lang) => {\n try {\n const result = await generateCodeSample({\n ...baseOptions,\n language: lang,\n });\n results[lang] = result.code;\n } catch (error) {\n console.error(`Failed to generate code for ${lang}:`, error);\n const errorMessage =\n error instanceof CodeGenerationError\n ? error.message\n : error instanceof Error\n ? error.message\n : String(error);\n results[lang] = `// Error generating code: ${errorMessage}`;\n }\n }),\n );\n\n return results;\n}\n\n/**\n * Convert apiVersion + pcVersion to combined version format\n */\nfunction getCombinedVersion(\n apiVersion?: string,\n pcVersion?: string,\n): \"v1\" | \"v2-pcv1\" | \"v2-pcv2\" {\n if (apiVersion === \"v1\") {\n return \"v1\";\n }\n\n const pc = pcVersion || \"v2\";\n if (pc === \"v1\") {\n return \"v2-pcv1\";\n }\n\n return \"v2-pcv2\";\n}\n\n/**\n * Strips path-only params from a params object before validation.\n * Path params (e.g., customer-id from \"/customers/{customer-id}\") are in the URL,\n * not in the body schema. Keeps params that are BOTH path and body params (e.g., item_id).\n */\nfunction stripPathParams(\n params: Record<string, unknown>,\n pathTemplate: string,\n bodySchema: import(\"../core/types\").ParamSchema,\n): Record<string, unknown> {\n const pathParamKeys = new Set<string>();\n const placeholderRegex = /\\{([^}]+)\\}/g;\n let match = placeholderRegex.exec(pathTemplate);\n while (match !== null) {\n const name = match[1];\n pathParamKeys.add(name);\n pathParamKeys.add(name.replace(/-/g, \"_\"));\n if (name.endsWith(\"-id\") || name.endsWith(\"_id\")) {\n pathParamKeys.add(\"id\");\n }\n match = placeholderRegex.exec(pathTemplate);\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(params)) {\n // Keep if it's a body param OR not a path param\n if (bodySchema.properties?.[key] !== undefined || !pathParamKeys.has(key)) {\n result[key] = value;\n }\n }\n return result;\n}\n"],"names":["code"],"mappings":";AA4BO,MAAM,YAAwB;AAAA,EACnC;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;ACvBA,SAAS,aAAa,KAAqB;AACzC,SAAO,IACJ,MAAM,MAAM,EACZ,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAA,IAAgB,KAAK,MAAM,CAAC,EAAE,YAAA,CAAa,EACxE,KAAK,EAAE;AACZ;AA0BO,SAAS,0BACd,aACA,MACA,QACoB;AACpB,QAAM,UAA8B,CAAA;AAEpC,MAAI,CAAC,aAAa,OAAO;AACvB,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,OAAO,YAAA;AAI1B,MAAI,YAAY,YAAY,QAAQ,IAAI,IAAI,UAAU;AAGtD,MAAI,CAAC,WAAW;AACd,eAAW,YAAY,OAAO,KAAK,YAAY,KAAK,GAAG;AAGrD,YAAM,YAAY,IAAI;AAAA,QACpB,MAAM,SAAS,QAAQ,cAAc,OA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