@chargebee/code-sample-generator 1.0.0 → 1.0.2
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-KvyNre2o.js → LanguageSwitcher-CmrCgNzs.js} +9 -8
- package/dist/browser.js +3 -3
- package/dist/code-sample-generator.css +489 -885
- package/dist/components/CodeSamples.d.ts +1 -1
- package/dist/{generate-code-sample-ioM_ISFV.js → generate-code-sample-DwenHif9.js} +1 -1
- package/dist/{generate-from-sample-D6gdkUpR.js → generate-from-sample-B1Rj07T6.js} +2621 -1816
- package/dist/generated/ops/operation-ids.d.ts +2 -2
- package/dist/generated/ops/operation-params.d.ts +166 -89
- package/dist/generated/ops/v2-pcv1/list_disputes.d.ts +3 -0
- package/dist/generated/ops/v2-pcv1/retrieve_a_dispute.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/delete_a_business_ruleset.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/list_disputes.d.ts +3 -0
- package/dist/generated/ops/v2-pcv2/retrieve_a_dispute.d.ts +3 -0
- package/dist/{highlight-code-IZ3Hy145.js → highlight-code-DEB0Ig2J.js} +1 -1
- package/dist/index.js +12 -9
- package/dist/node.js +3 -3
- package/dist/samples/repo.d.ts +3 -1
- package/dist/types.d.ts +2 -0
- package/package.json +3 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSingletonHighlighter } from "shiki";
|
|
2
|
-
import { y as highlightCurlCode, k as fallbackPlainHtml, j as escapeHtml } from "./generate-from-sample-
|
|
2
|
+
import { y as highlightCurlCode, k as fallbackPlainHtml, j as escapeHtml } from "./generate-from-sample-B1Rj07T6.js";
|
|
3
3
|
function hideImports() {
|
|
4
4
|
return {
|
|
5
5
|
name: "hide-imports",
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C, a, b, c, G, L, T, u, d } from "./LanguageSwitcher-
|
|
2
|
-
import { a as a2, A, C as C2, D, b as b2, L as L2, w, x, O, V, o, p, q, j, s, m, k, t, l, f, g, c as c2, e, d as d2, n, h, i, u as u2, r, v } from "./generate-from-sample-
|
|
1
|
+
import { C, a, b, c, G, L, T, u, d } from "./LanguageSwitcher-CmrCgNzs.js";
|
|
2
|
+
import { a as a2, A, C as C2, D, b as b2, L as L2, w, x, O, V, o, p, q, j, s, m, k, t, l, f, g, c as c2, e, d as d2, n, h, i, u as u2, r, v } from "./generate-from-sample-B1Rj07T6.js";
|
|
3
3
|
import "change-case";
|
|
4
4
|
import pluralize from "pluralize";
|
|
5
|
-
import { D as D2, S, h as h2, i as i2, r as r2 } from "./highlight-code-
|
|
6
|
-
import { L as L3, c as c3, e as e2, d as d3, f as f2, h as h3, a as a3, b as b3, g as g2 } from "./generate-code-sample-
|
|
5
|
+
import { D as D2, S, h as h2, i as i2, r as r2 } from "./highlight-code-DEB0Ig2J.js";
|
|
6
|
+
import { L as L3, c as c3, e as e2, d as d3, f as f2, h as h3, a as a3, b as b3, g as g2 } from "./generate-code-sample-DwenHif9.js";
|
|
7
7
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
function addCopyButton(options = {}) {
|
|
@@ -48,15 +48,18 @@ function getVersionPath(apiVersion, pcVersion) {
|
|
|
48
48
|
}
|
|
49
49
|
return pcVersion === "v2" ? "v2-pcv2" : "v2-pcv1";
|
|
50
50
|
}
|
|
51
|
-
function trimResponse(response) {
|
|
52
|
-
if (Array.isArray(response) && response.length > 0) {
|
|
51
|
+
function trimResponse(response, showFullSampleResponse = false) {
|
|
52
|
+
if (Array.isArray(response) && response.length > 0 && !showFullSampleResponse) {
|
|
53
53
|
const trimmedFirst = trimResponse(response[0]);
|
|
54
54
|
return [trimmedFirst, { d: "d" }];
|
|
55
55
|
}
|
|
56
|
+
if (Array.isArray(response)) {
|
|
57
|
+
return response.map((item) => trimResponse(item, showFullSampleResponse));
|
|
58
|
+
}
|
|
56
59
|
if (typeof response === "object" && response !== null) {
|
|
57
60
|
const trimmed = {};
|
|
58
61
|
for (const key in response) {
|
|
59
|
-
trimmed[key] = trimResponse(response[key]);
|
|
62
|
+
trimmed[key] = trimResponse(response[key], showFullSampleResponse);
|
|
60
63
|
}
|
|
61
64
|
return trimmed;
|
|
62
65
|
}
|
|
@@ -180,7 +183,7 @@ function getManuallyAddedFallbackResponse(identifier) {
|
|
|
180
183
|
return null;
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
|
-
function getDefaultOperationResponse(resource, operation, apiVersion, pcVersion, sampleFileName) {
|
|
186
|
+
function getDefaultOperationResponse(resource, operation, apiVersion, pcVersion, sampleFileName, options = {}) {
|
|
184
187
|
let response = getManuallyAddedOverrideResponse(operation);
|
|
185
188
|
if (response == null) {
|
|
186
189
|
response = getManuallyAddedOverrideResponse(resource);
|
|
@@ -203,7 +206,7 @@ function getDefaultOperationResponse(resource, operation, apiVersion, pcVersion,
|
|
|
203
206
|
if (response) {
|
|
204
207
|
return {
|
|
205
208
|
statusCode: 200,
|
|
206
|
-
body: trimResponse(response)
|
|
209
|
+
body: trimResponse(response, options.showFullSampleResponse)
|
|
207
210
|
};
|
|
208
211
|
}
|
|
209
212
|
return null;
|
package/dist/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a, A, C, D, b, L, w, O, V, o, p, q, j, s, m, k, t, l, f, g, c, e, d, n, h, i, u, r, v } from "./generate-from-sample-
|
|
2
|
-
import { D as D2, S, h as h2, i as i2, r as r2 } from "./highlight-code-
|
|
3
|
-
import { L as L2, c as c2, e as e2, d as d2, f as f2, h as h3, a as a2, b as b2, g as g2 } from "./generate-code-sample-
|
|
1
|
+
import { a, A, C, D, b, L, w, O, V, o, p, q, j, s, m, k, t, l, f, g, c, e, d, n, h, i, u, r, v } from "./generate-from-sample-B1Rj07T6.js";
|
|
2
|
+
import { D as D2, S, h as h2, i as i2, r as r2 } from "./highlight-code-DEB0Ig2J.js";
|
|
3
|
+
import { L as L2, c as c2, e as e2, d as d2, f as f2, h as h3, a as a2, b as b2, g as g2 } from "./generate-code-sample-DwenHif9.js";
|
|
4
4
|
export {
|
|
5
5
|
a as AVAILABLE_LANGUAGES,
|
|
6
6
|
A as AVAILABLE_LANGUAGE_IDS,
|
package/dist/samples/repo.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ import type { ApiVersion, ExtendedSampleRequest, PcVersion, SampleResponse } fro
|
|
|
5
5
|
/**
|
|
6
6
|
* Get default operation response with fallbacks
|
|
7
7
|
*/
|
|
8
|
-
export declare function getDefaultOperationResponse(resource: string, operation: string, apiVersion: ApiVersion, pcVersion: PcVersion, sampleFileName?: string
|
|
8
|
+
export declare function getDefaultOperationResponse(resource: string, operation: string, apiVersion: ApiVersion, pcVersion: PcVersion, sampleFileName?: string, options?: {
|
|
9
|
+
showFullSampleResponse?: boolean;
|
|
10
|
+
}): SampleResponse | null;
|
|
9
11
|
/**
|
|
10
12
|
* Get the first available operation's response for a resource
|
|
11
13
|
* Used to display the resource model when no specific operation is requested
|
package/dist/types.d.ts
CHANGED
|
@@ -97,6 +97,8 @@ export interface CodeSamplesPropsInterface {
|
|
|
97
97
|
description?: string;
|
|
98
98
|
}>;
|
|
99
99
|
responseData?: any;
|
|
100
|
+
/** Show the full sample response JSON without shortening arrays. */
|
|
101
|
+
showFullSampleResponse?: boolean;
|
|
100
102
|
initialLanguage?: string;
|
|
101
103
|
/**
|
|
102
104
|
* Shiki / CodeBlock grammar to use for highlighting (e.g. `"curl"`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chargebee/code-sample-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A self-contained, reusable React component for generating and displaying API code samples from OpenAPI specifications",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -57,11 +57,6 @@
|
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=18"
|
|
59
59
|
},
|
|
60
|
-
"repository": {
|
|
61
|
-
"type": "git",
|
|
62
|
-
"url": "git+https://github.com/chargebee/cb-docs-platform.git",
|
|
63
|
-
"directory": "packages/code-samples"
|
|
64
|
-
},
|
|
65
60
|
"bugs": {
|
|
66
61
|
"url": "https://support.chargebee.com/",
|
|
67
62
|
"email": "support@chargebee.com"
|
|
@@ -118,7 +113,8 @@
|
|
|
118
113
|
"scripts": {
|
|
119
114
|
"dev": "vite",
|
|
120
115
|
"clean": "node -e \"require('fs').rmSync('dist', {recursive: true, force: true})\" || rm -rf dist || true",
|
|
121
|
-
"build": "pnpm run
|
|
116
|
+
"build": "pnpm run bundle-specs && pnpm run generate && pnpm run build:lib",
|
|
117
|
+
"build:lib": "pnpm run clean && vite build && tsc -p tsconfig.build.json",
|
|
122
118
|
"watch": "vite build --watch",
|
|
123
119
|
"preview": "vite preview",
|
|
124
120
|
"bundle-specs": "tsx scripts/bundle-specs.ts",
|