@chargebee/code-sample-generator 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/{LanguageSwitcher-CmrCgNzs.js → TryInApiExplorer-BVv51ABv.js} +185 -178
- package/dist/browser.js +6 -6
- package/dist/code-sample-generator.css +96 -0
- package/dist/components/CodeBlock.d.ts +3 -1
- package/dist/components/CodeSamples.d.ts +1 -1
- package/dist/components/CopyButton.d.ts +3 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/{generate-code-sample-DwenHif9.js → generate-code-sample-BxJGH1rJ.js} +11 -10
- package/dist/{generate-from-sample-B1Rj07T6.js → generate-from-sample-DPxmR-75.js} +6310 -4866
- package/dist/generated/ops/operation-ids.d.ts +2 -2
- package/dist/generated/ops/operation-params.d.ts +159 -18
- package/dist/generated/ops/v2-pcv1/cancel_a_collections_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv1/create_a_collections_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv1/list_collections_payment_promises.d.ts +3 -0
- package/dist/generated/ops/v2-pcv1/list_email_logs_for_a_customer.d.ts +3 -0
- package/dist/generated/ops/v2-pcv1/retrieve_a_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv1/retrieve_a_retry_segment.d.ts +3 -0
- package/dist/generated/ops/v2-pcv1/update_a_collections_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/cancel_a_collections_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/create_a_collections_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/create_a_price_ramp.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/delete_a_price_ramp.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/list_collections_payment_promises.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/list_email_logs_for_a_customer.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/list_price_ramps.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/remove_payment_schedule_scheme_from_an_invoice.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/retrieve_a_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/retrieve_a_price_ramp.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/retrieve_a_retry_segment.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/update_a_collections_payment_promise.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/update_a_price_ramp.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/update_overdraft_limit.d.ts +3 -0
- package/dist/generators/chargebee-cli.d.ts +30 -0
- package/dist/generators/registry.d.ts +12 -3
- package/dist/{highlight-code-DEB0Ig2J.js → highlight-code-WTmlHcwe.js} +11 -10
- package/dist/index.js +33 -33
- package/dist/node.js +32 -32
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -24,6 +24,16 @@ React UI consumers must also install `react`, `react-dom`, and `lucide-react`.
|
|
|
24
24
|
They are optional peer dependencies so headless `/node` consumers do not install
|
|
25
25
|
the React stack.
|
|
26
26
|
|
|
27
|
+
## Releases
|
|
28
|
+
|
|
29
|
+
Generated operation descriptors are committed and reviewed before they become
|
|
30
|
+
part of a package release. After a package `fix` or `feat` change merges,
|
|
31
|
+
Release Please opens a separate version and changelog pull request. Merging that
|
|
32
|
+
release pull request publishes the exact reviewed repository contents to npm.
|
|
33
|
+
After the registry exposes that version, the release workflow notifies the
|
|
34
|
+
Chargebee CLI reconciler. Its manual `version` input can safely re-notify an
|
|
35
|
+
already-published version during bootstrap or recovery.
|
|
36
|
+
|
|
27
37
|
## Entry Points
|
|
28
38
|
|
|
29
39
|
This package has three entry points:
|
|
@@ -706,6 +716,44 @@ results.forEach(result => {
|
|
|
706
716
|
|
|
707
717
|
This is more efficient than generating code sequentially, especially when generating for many languages and sample variations.
|
|
708
718
|
|
|
719
|
+
## Development and descriptor refreshes
|
|
720
|
+
|
|
721
|
+
Operation descriptors under `src/generated/ops/` are committed so API changes
|
|
722
|
+
remain reviewable and package releases can verify their inputs. A normal package
|
|
723
|
+
or monorepo build compiles those committed descriptors and does not rewrite
|
|
724
|
+
tracked source files.
|
|
725
|
+
|
|
726
|
+
After placing the structure-only OpenAPI specs in
|
|
727
|
+
`packages/openapi-utils/oas/`, refresh the descriptors explicitly from the
|
|
728
|
+
monorepo root:
|
|
729
|
+
|
|
730
|
+
```bash
|
|
731
|
+
pnpm refresh:code-sample-ops
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
CI jobs that download fresh specs can use `build:from-specs` to refresh and
|
|
735
|
+
compile the package in one command:
|
|
736
|
+
|
|
737
|
+
```bash
|
|
738
|
+
pnpm --filter @chargebee/code-sample-generator build:from-specs
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
Tests that exercise OpenAPI-driven generation require those prepared inputs.
|
|
742
|
+
After stripping the specs, run the explicit preparation-and-test command:
|
|
743
|
+
|
|
744
|
+
```bash
|
|
745
|
+
pnpm --filter @chargebee/code-sample-generator test:from-specs
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
The `Update OpenAPI Descriptors` workflow performs this refresh on a schedule,
|
|
749
|
+
on manual dispatch, or when `cb-openapi-generator` sends the
|
|
750
|
+
`openapi-specs-published` repository-dispatch event. It opens or updates one PR
|
|
751
|
+
only when the generated descriptors differ. It exchanges the
|
|
752
|
+
`DISTRIBUTED_GITFLOW_GH_APP_CREDENTIALS_TOKEN` secret for a short-lived
|
|
753
|
+
installation token from the distributed-gitflow GitHub App. The App token
|
|
754
|
+
creates the branch and PR so the repository's normal pull-request workflows
|
|
755
|
+
run for generated updates.
|
|
756
|
+
|
|
709
757
|
## License
|
|
710
758
|
|
|
711
759
|
Use of this package is governed by an End User License Agreement. The source
|
|
@@ -1,125 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronLeft, ChevronRight, Check, Copy, Code, SquareArrowOutUpRight, ArrowRight } from "lucide-react";
|
|
3
|
-
import { useState,
|
|
4
|
-
import {
|
|
3
|
+
import { useState, useRef, useEffect, useId } from "react";
|
|
4
|
+
import { j as fallbackPlainHtml, a as AVAILABLE_LANGUAGE_IDS, A as AVAILABLE_LANGUAGES } from "./generate-from-sample-DPxmR-75.js";
|
|
5
5
|
import { snakeCase } from "change-case";
|
|
6
|
-
function useLanguageSelection(initialLanguage, onChange) {
|
|
7
|
-
const [selectedLanguage, setSelectedLanguage] = useState(initialLanguage);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
setSelectedLanguage(initialLanguage);
|
|
10
|
-
}, [initialLanguage]);
|
|
11
|
-
const handleLanguageChange = (lang) => {
|
|
12
|
-
setSelectedLanguage(lang);
|
|
13
|
-
onChange?.(lang);
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
selectedLanguage,
|
|
17
|
-
setSelectedLanguage: handleLanguageChange
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function isSnippetObject(value) {
|
|
21
|
-
return typeof value === "object" && value !== null && "code" in value && typeof value.code === "string";
|
|
22
|
-
}
|
|
23
|
-
function expandAllLanguagesSnippets(snippets) {
|
|
24
|
-
if (!("allLanguages" in snippets)) return snippets;
|
|
25
|
-
const common = snippets.allLanguages;
|
|
26
|
-
if (common === void 0) return snippets;
|
|
27
|
-
const next = { ...snippets };
|
|
28
|
-
delete next.allLanguages;
|
|
29
|
-
for (const lang of AVAILABLE_LANGUAGE_IDS) {
|
|
30
|
-
if (!(lang in next)) {
|
|
31
|
-
next[lang] = common;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return next;
|
|
35
|
-
}
|
|
36
|
-
function flattenSnippets(snippets) {
|
|
37
|
-
const hasObject = Object.values(snippets).some(isSnippetObject);
|
|
38
|
-
if (!hasObject) {
|
|
39
|
-
return {
|
|
40
|
-
languageSnippets: expandAllLanguagesSnippets(
|
|
41
|
-
snippets
|
|
42
|
-
),
|
|
43
|
-
snippetMeta: {}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const languageSnippets = {};
|
|
47
|
-
const snippetMeta = {};
|
|
48
|
-
for (const [key, value] of Object.entries(snippets)) {
|
|
49
|
-
if (typeof value === "string") {
|
|
50
|
-
languageSnippets[key] = value;
|
|
51
|
-
snippetMeta[key] = { language: key, label: key };
|
|
52
|
-
} else {
|
|
53
|
-
languageSnippets[key] = value.code;
|
|
54
|
-
snippetMeta[key] = {
|
|
55
|
-
language: value.language ?? key,
|
|
56
|
-
label: value.label ?? key,
|
|
57
|
-
html: value.html
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return { languageSnippets, snippetMeta };
|
|
62
|
-
}
|
|
63
|
-
function normalizeSamples(samples) {
|
|
64
|
-
if (!samples) return { samples: [], error: null };
|
|
65
|
-
try {
|
|
66
|
-
if (Array.isArray(samples)) {
|
|
67
|
-
const arr = samples.map((s) => {
|
|
68
|
-
const flattened2 = flattenSnippets(s.languageSnippets);
|
|
69
|
-
return {
|
|
70
|
-
displayName: s.displayName,
|
|
71
|
-
description: s.description,
|
|
72
|
-
languageSnippets: flattened2.languageSnippets,
|
|
73
|
-
snippetMeta: Object.keys(flattened2.snippetMeta).length > 0 ? flattened2.snippetMeta : void 0
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
return { samples: arr, error: null };
|
|
77
|
-
}
|
|
78
|
-
const flattened = flattenSnippets(samples);
|
|
79
|
-
return {
|
|
80
|
-
samples: [
|
|
81
|
-
{
|
|
82
|
-
languageSnippets: flattened.languageSnippets,
|
|
83
|
-
snippetMeta: Object.keys(flattened.snippetMeta).length > 0 ? flattened.snippetMeta : void 0
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
error: null
|
|
87
|
-
};
|
|
88
|
-
} catch (err) {
|
|
89
|
-
console.error("Failed to load code samples:", err);
|
|
90
|
-
return {
|
|
91
|
-
samples: [],
|
|
92
|
-
error: err instanceof Error ? err.message : "Failed to load code samples"
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function useSampleLoader(samples) {
|
|
97
|
-
const [prevSamples, setPrevSamples] = useState(samples);
|
|
98
|
-
const [state, setState] = useState(() => normalizeSamples(samples));
|
|
99
|
-
if (prevSamples !== samples) {
|
|
100
|
-
setPrevSamples(samples);
|
|
101
|
-
setState(normalizeSamples(samples));
|
|
102
|
-
}
|
|
103
|
-
return { samples: state.samples, isLoading: false, error: state.error };
|
|
104
|
-
}
|
|
105
|
-
function Card({ children, className = "" }) {
|
|
106
|
-
return /* @__PURE__ */ jsx("div", { className: `code-samples-result-card ${className}`, children });
|
|
107
|
-
}
|
|
108
|
-
function CardHeader({ children, className = "" }) {
|
|
109
|
-
return /* @__PURE__ */ jsx("div", { className: `code-samples-result-card-header px-4 py-3 ${className}`, children });
|
|
110
|
-
}
|
|
111
|
-
function CardTitle({ children, className = "" }) {
|
|
112
|
-
return /* @__PURE__ */ jsx(
|
|
113
|
-
"h4",
|
|
114
|
-
{
|
|
115
|
-
className: `m-0 text-base font-semibold text-gray-900 dark:text-[color:var(--cb-text-primary,#e6edf3)] ${className}`,
|
|
116
|
-
children
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
function CardContent({ children, className = "" }) {
|
|
121
|
-
return /* @__PURE__ */ jsx("div", { className, children });
|
|
122
|
-
}
|
|
123
6
|
function Carousel({
|
|
124
7
|
items,
|
|
125
8
|
className = "",
|
|
@@ -294,7 +177,8 @@ function CopyButton({
|
|
|
294
177
|
className = "",
|
|
295
178
|
toggleDelay = 2e3,
|
|
296
179
|
variant = "labeled",
|
|
297
|
-
reveal = "always"
|
|
180
|
+
reveal = "always",
|
|
181
|
+
onCopy
|
|
298
182
|
}) {
|
|
299
183
|
const isDark = theme === "github-dark";
|
|
300
184
|
const [copied, setCopied] = useState(false);
|
|
@@ -304,6 +188,7 @@ function CopyButton({
|
|
|
304
188
|
try {
|
|
305
189
|
await writeClipboard(code);
|
|
306
190
|
setCopied(true);
|
|
191
|
+
onCopy?.(code);
|
|
307
192
|
setTimeout(() => {
|
|
308
193
|
setCopied(false);
|
|
309
194
|
}, toggleDelay);
|
|
@@ -369,7 +254,8 @@ function CodeBlock({
|
|
|
369
254
|
className = "",
|
|
370
255
|
showLineNumbers = false,
|
|
371
256
|
showCopyButton = false,
|
|
372
|
-
hideImports: hideImportsProp = false
|
|
257
|
+
hideImports: hideImportsProp = false,
|
|
258
|
+
onCopy
|
|
373
259
|
}) {
|
|
374
260
|
const hasPrecomputedHtml = typeof htmlProp === "string" && htmlProp.length > 0;
|
|
375
261
|
const [html, setHtml] = useState(hasPrecomputedHtml ? htmlProp : "");
|
|
@@ -389,7 +275,7 @@ function CodeBlock({
|
|
|
389
275
|
const highlight = async () => {
|
|
390
276
|
setIsLoading(true);
|
|
391
277
|
try {
|
|
392
|
-
const { highlightCode } = await import("./highlight-code-
|
|
278
|
+
const { highlightCode } = await import("./highlight-code-WTmlHcwe.js").then((n) => n.a);
|
|
393
279
|
const result = await highlightCode({
|
|
394
280
|
code,
|
|
395
281
|
language,
|
|
@@ -438,7 +324,8 @@ function CodeBlock({
|
|
|
438
324
|
{
|
|
439
325
|
code,
|
|
440
326
|
variant: "icon",
|
|
441
|
-
reveal: wellActive ? "always" : "hover"
|
|
327
|
+
reveal: wellActive ? "always" : "hover",
|
|
328
|
+
onCopy
|
|
442
329
|
}
|
|
443
330
|
) : null;
|
|
444
331
|
const wellHandlers = showCopyButton ? {
|
|
@@ -573,6 +460,123 @@ function CodeSampleHeader({
|
|
|
573
460
|
)
|
|
574
461
|
] });
|
|
575
462
|
}
|
|
463
|
+
function useLanguageSelection(initialLanguage, onChange) {
|
|
464
|
+
const [selectedLanguage, setSelectedLanguage] = useState(initialLanguage);
|
|
465
|
+
useEffect(() => {
|
|
466
|
+
setSelectedLanguage(initialLanguage);
|
|
467
|
+
}, [initialLanguage]);
|
|
468
|
+
const handleLanguageChange = (lang) => {
|
|
469
|
+
setSelectedLanguage(lang);
|
|
470
|
+
onChange?.(lang);
|
|
471
|
+
};
|
|
472
|
+
return {
|
|
473
|
+
selectedLanguage,
|
|
474
|
+
setSelectedLanguage: handleLanguageChange
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function isSnippetObject(value) {
|
|
478
|
+
return typeof value === "object" && value !== null && "code" in value && typeof value.code === "string";
|
|
479
|
+
}
|
|
480
|
+
function expandAllLanguagesSnippets(snippets) {
|
|
481
|
+
if (!("allLanguages" in snippets)) return snippets;
|
|
482
|
+
const common = snippets.allLanguages;
|
|
483
|
+
if (common === void 0) return snippets;
|
|
484
|
+
const next = { ...snippets };
|
|
485
|
+
delete next.allLanguages;
|
|
486
|
+
for (const lang of AVAILABLE_LANGUAGE_IDS) {
|
|
487
|
+
if (!(lang in next)) {
|
|
488
|
+
next[lang] = common;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return next;
|
|
492
|
+
}
|
|
493
|
+
function flattenSnippets(snippets) {
|
|
494
|
+
const hasObject = Object.values(snippets).some(isSnippetObject);
|
|
495
|
+
if (!hasObject) {
|
|
496
|
+
return {
|
|
497
|
+
languageSnippets: expandAllLanguagesSnippets(
|
|
498
|
+
snippets
|
|
499
|
+
),
|
|
500
|
+
snippetMeta: {}
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
const languageSnippets = {};
|
|
504
|
+
const snippetMeta = {};
|
|
505
|
+
for (const [key, value] of Object.entries(snippets)) {
|
|
506
|
+
if (typeof value === "string") {
|
|
507
|
+
languageSnippets[key] = value;
|
|
508
|
+
snippetMeta[key] = { language: key, label: key };
|
|
509
|
+
} else {
|
|
510
|
+
languageSnippets[key] = value.code;
|
|
511
|
+
snippetMeta[key] = {
|
|
512
|
+
language: value.language ?? key,
|
|
513
|
+
label: value.label ?? key,
|
|
514
|
+
html: value.html
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return { languageSnippets, snippetMeta };
|
|
519
|
+
}
|
|
520
|
+
function normalizeSamples(samples) {
|
|
521
|
+
if (!samples) return { samples: [], error: null };
|
|
522
|
+
try {
|
|
523
|
+
if (Array.isArray(samples)) {
|
|
524
|
+
const arr = samples.map((s) => {
|
|
525
|
+
const flattened2 = flattenSnippets(s.languageSnippets);
|
|
526
|
+
return {
|
|
527
|
+
displayName: s.displayName,
|
|
528
|
+
description: s.description,
|
|
529
|
+
languageSnippets: flattened2.languageSnippets,
|
|
530
|
+
snippetMeta: Object.keys(flattened2.snippetMeta).length > 0 ? flattened2.snippetMeta : void 0
|
|
531
|
+
};
|
|
532
|
+
});
|
|
533
|
+
return { samples: arr, error: null };
|
|
534
|
+
}
|
|
535
|
+
const flattened = flattenSnippets(samples);
|
|
536
|
+
return {
|
|
537
|
+
samples: [
|
|
538
|
+
{
|
|
539
|
+
languageSnippets: flattened.languageSnippets,
|
|
540
|
+
snippetMeta: Object.keys(flattened.snippetMeta).length > 0 ? flattened.snippetMeta : void 0
|
|
541
|
+
}
|
|
542
|
+
],
|
|
543
|
+
error: null
|
|
544
|
+
};
|
|
545
|
+
} catch (err) {
|
|
546
|
+
console.error("Failed to load code samples:", err);
|
|
547
|
+
return {
|
|
548
|
+
samples: [],
|
|
549
|
+
error: err instanceof Error ? err.message : "Failed to load code samples"
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function useSampleLoader(samples) {
|
|
554
|
+
const [prevSamples, setPrevSamples] = useState(samples);
|
|
555
|
+
const [state, setState] = useState(() => normalizeSamples(samples));
|
|
556
|
+
if (prevSamples !== samples) {
|
|
557
|
+
setPrevSamples(samples);
|
|
558
|
+
setState(normalizeSamples(samples));
|
|
559
|
+
}
|
|
560
|
+
return { samples: state.samples, isLoading: false, error: state.error };
|
|
561
|
+
}
|
|
562
|
+
function Card({ children, className = "" }) {
|
|
563
|
+
return /* @__PURE__ */ jsx("div", { className: `code-samples-result-card ${className}`, children });
|
|
564
|
+
}
|
|
565
|
+
function CardHeader({ children, className = "" }) {
|
|
566
|
+
return /* @__PURE__ */ jsx("div", { className: `code-samples-result-card-header px-4 py-3 ${className}`, children });
|
|
567
|
+
}
|
|
568
|
+
function CardTitle({ children, className = "" }) {
|
|
569
|
+
return /* @__PURE__ */ jsx(
|
|
570
|
+
"h4",
|
|
571
|
+
{
|
|
572
|
+
className: `m-0 text-base font-semibold text-gray-900 dark:text-[color:var(--cb-text-primary,#e6edf3)] ${className}`,
|
|
573
|
+
children
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
function CardContent({ children, className = "" }) {
|
|
578
|
+
return /* @__PURE__ */ jsx("div", { className, children });
|
|
579
|
+
}
|
|
576
580
|
function LanguageTabList({
|
|
577
581
|
tabs,
|
|
578
582
|
selectedId,
|
|
@@ -758,7 +762,8 @@ function CollapsibleCodeBlock({
|
|
|
758
762
|
hideImports = true,
|
|
759
763
|
maxCollapsedHeight = MAX_COLLAPSED_CODE_HEIGHT_PX,
|
|
760
764
|
codeBlockKey,
|
|
761
|
-
copyCode
|
|
765
|
+
copyCode,
|
|
766
|
+
onCopy
|
|
762
767
|
}) {
|
|
763
768
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
764
769
|
const [isReady, setIsReady] = useState(false);
|
|
@@ -809,7 +814,8 @@ function CollapsibleCodeBlock({
|
|
|
809
814
|
{
|
|
810
815
|
code: copyCode ?? "",
|
|
811
816
|
variant: "icon",
|
|
812
|
-
reveal: wellActive ? "always" : "hover"
|
|
817
|
+
reveal: wellActive ? "always" : "hover",
|
|
818
|
+
onCopy
|
|
813
819
|
}
|
|
814
820
|
) : null,
|
|
815
821
|
collapsed && /* @__PURE__ */ jsx(
|
|
@@ -851,7 +857,7 @@ function CodeSamples({
|
|
|
851
857
|
style,
|
|
852
858
|
onLanguageChange,
|
|
853
859
|
onCopy: _onCopy,
|
|
854
|
-
//
|
|
860
|
+
// Fired by every copy control: header, panel overlay, response
|
|
855
861
|
onSampleChange,
|
|
856
862
|
replacements,
|
|
857
863
|
codeHighlightLanguage,
|
|
@@ -1125,7 +1131,8 @@ function CodeSamples({
|
|
|
1125
1131
|
theme: highlighter?.theme || codeSamplesTheme,
|
|
1126
1132
|
showLineNumbers: showInlineCopy ? false : showLineNumbers,
|
|
1127
1133
|
hideImports: !useTabs,
|
|
1128
|
-
copyCode: showPanelCopy && showCopyButton && currentCode ? currentCode : void 0
|
|
1134
|
+
copyCode: showPanelCopy && showCopyButton && currentCode ? currentCode : void 0,
|
|
1135
|
+
onCopy: _onCopy
|
|
1129
1136
|
}
|
|
1130
1137
|
)
|
|
1131
1138
|
] })
|
|
@@ -1199,57 +1206,6 @@ function GoToApiExplorer({
|
|
|
1199
1206
|
}
|
|
1200
1207
|
);
|
|
1201
1208
|
}
|
|
1202
|
-
function getApiExplorerUrl(resourceKey, operationName, language, domainName, protocol, activeSite) {
|
|
1203
|
-
const operationSnake = snakeCase(operationName);
|
|
1204
|
-
const siteName = activeSite?.siteName;
|
|
1205
|
-
const isTestSite = activeSite?.siteType === SiteType.TEST;
|
|
1206
|
-
const url = new URL(
|
|
1207
|
-
`${protocol}://api-explorer.${domainName}/${resourceKey}/${operationSnake}`
|
|
1208
|
-
);
|
|
1209
|
-
url.searchParams.set("lang", language);
|
|
1210
|
-
url.searchParams.set("utm_source", "chargebee-api-docs");
|
|
1211
|
-
if (isTestSite && siteName) {
|
|
1212
|
-
url.searchParams.set("site_name", siteName);
|
|
1213
|
-
}
|
|
1214
|
-
return url.toString();
|
|
1215
|
-
}
|
|
1216
|
-
function TryInApiExplorer({
|
|
1217
|
-
resourceKey,
|
|
1218
|
-
operation,
|
|
1219
|
-
language,
|
|
1220
|
-
domainName = "chargebee.com",
|
|
1221
|
-
protocol = "https",
|
|
1222
|
-
className = "",
|
|
1223
|
-
activeSite
|
|
1224
|
-
}) {
|
|
1225
|
-
const url = getApiExplorerUrl(
|
|
1226
|
-
resourceKey,
|
|
1227
|
-
operation.name,
|
|
1228
|
-
language,
|
|
1229
|
-
domainName,
|
|
1230
|
-
protocol,
|
|
1231
|
-
activeSite
|
|
1232
|
-
);
|
|
1233
|
-
return /* @__PURE__ */ jsxs(
|
|
1234
|
-
"a",
|
|
1235
|
-
{
|
|
1236
|
-
href: url,
|
|
1237
|
-
className: `group inline-flex items-center gap-1.5 text-[#FF3300] no-underline text-sm font-medium transition-opacity duration-200 hover:opacity-80 focus-visible:outline-2 focus-visible:outline-[color:var(--cb-spunky-lime,#bff90b)] focus-visible:outline-offset-2 ${className}`,
|
|
1238
|
-
target: "_blank",
|
|
1239
|
-
rel: "noopener noreferrer",
|
|
1240
|
-
children: [
|
|
1241
|
-
"Try in API Explorer",
|
|
1242
|
-
/* @__PURE__ */ jsx(
|
|
1243
|
-
ArrowRight,
|
|
1244
|
-
{
|
|
1245
|
-
className: "w-3 h-3 transition-transform duration-200 group-hover:translate-x-0.5",
|
|
1246
|
-
"aria-hidden": "true"
|
|
1247
|
-
}
|
|
1248
|
-
)
|
|
1249
|
-
]
|
|
1250
|
-
}
|
|
1251
|
-
);
|
|
1252
|
-
}
|
|
1253
1209
|
function LanguageSwitcher({
|
|
1254
1210
|
languages,
|
|
1255
1211
|
selected,
|
|
@@ -1308,6 +1264,57 @@ function LanguageSwitcher({
|
|
|
1308
1264
|
)) })
|
|
1309
1265
|
] });
|
|
1310
1266
|
}
|
|
1267
|
+
function getApiExplorerUrl(resourceKey, operationName, language, domainName, protocol, activeSite) {
|
|
1268
|
+
const operationSnake = snakeCase(operationName);
|
|
1269
|
+
const siteName = activeSite?.siteName;
|
|
1270
|
+
const isTestSite = activeSite?.siteType === SiteType.TEST;
|
|
1271
|
+
const url = new URL(
|
|
1272
|
+
`${protocol}://api-explorer.${domainName}/${resourceKey}/${operationSnake}`
|
|
1273
|
+
);
|
|
1274
|
+
url.searchParams.set("lang", language);
|
|
1275
|
+
url.searchParams.set("utm_source", "chargebee-api-docs");
|
|
1276
|
+
if (isTestSite && siteName) {
|
|
1277
|
+
url.searchParams.set("site_name", siteName);
|
|
1278
|
+
}
|
|
1279
|
+
return url.toString();
|
|
1280
|
+
}
|
|
1281
|
+
function TryInApiExplorer({
|
|
1282
|
+
resourceKey,
|
|
1283
|
+
operation,
|
|
1284
|
+
language,
|
|
1285
|
+
domainName = "chargebee.com",
|
|
1286
|
+
protocol = "https",
|
|
1287
|
+
className = "",
|
|
1288
|
+
activeSite
|
|
1289
|
+
}) {
|
|
1290
|
+
const url = getApiExplorerUrl(
|
|
1291
|
+
resourceKey,
|
|
1292
|
+
operation.name,
|
|
1293
|
+
language,
|
|
1294
|
+
domainName,
|
|
1295
|
+
protocol,
|
|
1296
|
+
activeSite
|
|
1297
|
+
);
|
|
1298
|
+
return /* @__PURE__ */ jsxs(
|
|
1299
|
+
"a",
|
|
1300
|
+
{
|
|
1301
|
+
href: url,
|
|
1302
|
+
className: `group inline-flex items-center gap-1.5 text-[#FF3300] no-underline text-sm font-medium transition-opacity duration-200 hover:opacity-80 focus-visible:outline-2 focus-visible:outline-[color:var(--cb-spunky-lime,#bff90b)] focus-visible:outline-offset-2 ${className}`,
|
|
1303
|
+
target: "_blank",
|
|
1304
|
+
rel: "noopener noreferrer",
|
|
1305
|
+
children: [
|
|
1306
|
+
"Try in API Explorer",
|
|
1307
|
+
/* @__PURE__ */ jsx(
|
|
1308
|
+
ArrowRight,
|
|
1309
|
+
{
|
|
1310
|
+
className: "w-3 h-3 transition-transform duration-200 group-hover:translate-x-0.5",
|
|
1311
|
+
"aria-hidden": "true"
|
|
1312
|
+
}
|
|
1313
|
+
)
|
|
1314
|
+
]
|
|
1315
|
+
}
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1311
1318
|
export {
|
|
1312
1319
|
Carousel as C,
|
|
1313
1320
|
GoToApiExplorer as G,
|
package/dist/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C, a, b, c, G, L, T, u, d } from "./
|
|
2
|
-
import {
|
|
3
|
-
import { a as a2,
|
|
1
|
+
import { C, a, b, c, G, L, T, u, d } from "./TryInApiExplorer-BVv51ABv.js";
|
|
2
|
+
import { v as resolveDescriptor, l as generateFromSample, o as getOperationIds, p as getOperationIdsForVersion } from "./generate-from-sample-DPxmR-75.js";
|
|
3
|
+
import { A, a as a2, C as C2, D, b as b2, L as L2, c as c2, O } from "./generate-from-sample-DPxmR-75.js";
|
|
4
4
|
function validateOperationId(id, version) {
|
|
5
5
|
if (version) {
|
|
6
6
|
const ops = getOperationIdsForVersion(version);
|
|
@@ -115,8 +115,8 @@ function createCodeGenerator(options) {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
A as AVAILABLE_LANGUAGES,
|
|
119
|
+
a2 as AVAILABLE_LANGUAGE_IDS,
|
|
120
120
|
C as Carousel,
|
|
121
121
|
a as CodeBlock,
|
|
122
122
|
C2 as CodeGenerationError,
|
|
@@ -126,7 +126,7 @@ export {
|
|
|
126
126
|
b2 as DEFAULT_THEME,
|
|
127
127
|
G as GoToApiExplorer,
|
|
128
128
|
L2 as LANGUAGE_DISPLAY_NAMES,
|
|
129
|
-
|
|
129
|
+
c2 as LanguageNotSupportedError,
|
|
130
130
|
L as LanguageSwitcher,
|
|
131
131
|
O as OperationNotFoundError,
|
|
132
132
|
T as TryInApiExplorer,
|