@gitbook/react-openapi 1.4.3 → 1.5.1
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/CHANGELOG.md +27 -0
- package/dist/index.d.ts +663 -10
- package/dist/index.js +3873 -8
- package/package.json +11 -7
- package/dist/InteractiveSection.d.ts +0 -33
- package/dist/InteractiveSection.jsx +0 -61
- package/dist/Markdown.d.ts +0 -4
- package/dist/Markdown.jsx +0 -5
- package/dist/OpenAPICodeSample.d.ts +0 -19
- package/dist/OpenAPICodeSample.jsx +0 -230
- package/dist/OpenAPICodeSampleInteractive.d.ts +0 -14
- package/dist/OpenAPICodeSampleInteractive.jsx +0 -73
- package/dist/OpenAPICodeSampleSelector.d.ts +0 -14
- package/dist/OpenAPICodeSampleSelector.jsx +0 -44
- package/dist/OpenAPICopyButton.d.ts +0 -13
- package/dist/OpenAPICopyButton.jsx +0 -35
- package/dist/OpenAPIDisclosure.d.ts +0 -11
- package/dist/OpenAPIDisclosure.jsx +0 -30
- package/dist/OpenAPIDisclosureGroup.d.ts +0 -23
- package/dist/OpenAPIDisclosureGroup.jsx +0 -83
- package/dist/OpenAPIExample.d.ts +0 -16
- package/dist/OpenAPIExample.jsx +0 -36
- package/dist/OpenAPIMediaType.d.ts +0 -21
- package/dist/OpenAPIMediaType.jsx +0 -61
- package/dist/OpenAPIOperation.d.ts +0 -10
- package/dist/OpenAPIOperation.jsx +0 -25
- package/dist/OpenAPIOperationContext.d.ts +0 -16
- package/dist/OpenAPIOperationContext.jsx +0 -26
- package/dist/OpenAPIOperationDescription.d.ts +0 -9
- package/dist/OpenAPIOperationDescription.jsx +0 -22
- package/dist/OpenAPIOperationStability.d.ts +0 -9
- package/dist/OpenAPIOperationStability.jsx +0 -27
- package/dist/OpenAPIPath.d.ts +0 -18
- package/dist/OpenAPIPath.jsx +0 -55
- package/dist/OpenAPIPrefillContextProvider.d.ts +0 -22
- package/dist/OpenAPIPrefillContextProvider.jsx +0 -19
- package/dist/OpenAPIRequestBody.d.ts +0 -11
- package/dist/OpenAPIRequestBody.jsx +0 -28
- package/dist/OpenAPIRequestBodyHeaderType.d.ts +0 -8
- package/dist/OpenAPIRequestBodyHeaderType.jsx +0 -25
- package/dist/OpenAPIResponse.d.ts +0 -10
- package/dist/OpenAPIResponse.jsx +0 -57
- package/dist/OpenAPIResponseExample.d.ts +0 -9
- package/dist/OpenAPIResponseExample.jsx +0 -105
- package/dist/OpenAPIResponseExampleContent.d.ts +0 -22
- package/dist/OpenAPIResponseExampleContent.jsx +0 -60
- package/dist/OpenAPIResponses.d.ts +0 -9
- package/dist/OpenAPIResponses.jsx +0 -77
- package/dist/OpenAPISchema.d.ts +0 -27
- package/dist/OpenAPISchema.jsx +0 -400
- package/dist/OpenAPISchemaName.d.ts +0 -16
- package/dist/OpenAPISchemaName.jsx +0 -43
- package/dist/OpenAPISchemaServer.d.ts +0 -12
- package/dist/OpenAPISchemaServer.jsx +0 -8
- package/dist/OpenAPISecurities.d.ts +0 -9
- package/dist/OpenAPISecurities.jsx +0 -114
- package/dist/OpenAPISelect.d.ts +0 -22
- package/dist/OpenAPISelect.jsx +0 -44
- package/dist/OpenAPISpec.d.ts +0 -6
- package/dist/OpenAPISpec.jsx +0 -80
- package/dist/OpenAPITabs.d.ts +0 -26
- package/dist/OpenAPITabs.jsx +0 -109
- package/dist/OpenAPIWebhook.d.ts +0 -10
- package/dist/OpenAPIWebhook.jsx +0 -23
- package/dist/OpenAPIWebhookExample.d.ts +0 -6
- package/dist/OpenAPIWebhookExample.jsx +0 -41
- package/dist/ScalarApiButton.d.ts +0 -14
- package/dist/ScalarApiButton.jsx +0 -81
- package/dist/StaticSection.d.ts +0 -13
- package/dist/StaticSection.jsx +0 -32
- package/dist/code-samples.d.ts +0 -17
- package/dist/code-samples.js +0 -427
- package/dist/common/OpenAPIColumnSpec.d.ts +0 -6
- package/dist/common/OpenAPIColumnSpec.jsx +0 -20
- package/dist/common/OpenAPIOperationDescription.d.ts +0 -6
- package/dist/common/OpenAPIOperationDescription.jsx +0 -19
- package/dist/common/OpenAPIStability.d.ts +0 -4
- package/dist/common/OpenAPIStability.jsx +0 -15
- package/dist/common/OpenAPISummary.d.ts +0 -6
- package/dist/common/OpenAPISummary.jsx +0 -30
- package/dist/contentTypeChecks.d.ts +0 -10
- package/dist/contentTypeChecks.js +0 -30
- package/dist/context.d.ts +0 -75
- package/dist/context.js +0 -43
- package/dist/decycle.d.ts +0 -2
- package/dist/decycle.js +0 -70
- package/dist/dereference.d.ts +0 -5
- package/dist/dereference.js +0 -68
- package/dist/generateSchemaExample.d.ts +0 -45
- package/dist/generateSchemaExample.js +0 -342
- package/dist/getDisclosureLabel.d.ts +0 -7
- package/dist/getDisclosureLabel.js +0 -18
- package/dist/getOrCreateStoreByKey.d.ts +0 -10
- package/dist/getOrCreateStoreByKey.js +0 -19
- package/dist/json2xml.d.ts +0 -4
- package/dist/json2xml.js +0 -7
- package/dist/resolveOpenAPIOperation.d.ts +0 -11
- package/dist/resolveOpenAPIOperation.js +0 -173
- package/dist/resolveOpenAPIWebhook.d.ts +0 -11
- package/dist/resolveOpenAPIWebhook.js +0 -127
- package/dist/schemas/OpenAPISchemaItem.d.ts +0 -7
- package/dist/schemas/OpenAPISchemaItem.jsx +0 -16
- package/dist/schemas/OpenAPISchemas.d.ts +0 -14
- package/dist/schemas/OpenAPISchemas.jsx +0 -59
- package/dist/schemas/index.d.ts +0 -2
- package/dist/schemas/index.js +0 -2
- package/dist/schemas/resolveOpenAPISchemas.d.ts +0 -10
- package/dist/schemas/resolveOpenAPISchemas.js +0 -61
- package/dist/stringifyOpenAPI.d.ts +0 -4
- package/dist/stringifyOpenAPI.js +0 -15
- package/dist/translate.d.ts +0 -10
- package/dist/translate.jsx +0 -75
- package/dist/translations/de.d.ts +0 -43
- package/dist/translations/de.js +0 -43
- package/dist/translations/en.d.ts +0 -43
- package/dist/translations/en.js +0 -43
- package/dist/translations/es.d.ts +0 -43
- package/dist/translations/es.js +0 -43
- package/dist/translations/fr.d.ts +0 -43
- package/dist/translations/fr.js +0 -43
- package/dist/translations/index.d.ts +0 -395
- package/dist/translations/index.js +0 -27
- package/dist/translations/ja.d.ts +0 -43
- package/dist/translations/ja.js +0 -43
- package/dist/translations/nl.d.ts +0 -43
- package/dist/translations/nl.js +0 -43
- package/dist/translations/no.d.ts +0 -43
- package/dist/translations/no.js +0 -43
- package/dist/translations/pt-br.d.ts +0 -43
- package/dist/translations/pt-br.js +0 -43
- package/dist/translations/types.d.ts +0 -5
- package/dist/translations/types.js +0 -1
- package/dist/translations/zh.d.ts +0 -43
- package/dist/translations/zh.js +0 -43
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types.d.ts +0 -31
- package/dist/types.js +0 -1
- package/dist/util/example.d.ts +0 -35
- package/dist/util/example.jsx +0 -103
- package/dist/util/server.d.ts +0 -9
- package/dist/util/server.js +0 -44
- package/dist/util/tryit-prefill.d.ts +0 -20
- package/dist/util/tryit-prefill.js +0 -129
- package/dist/utils.d.ts +0 -50
- package/dist/utils.js +0 -224
- package/src/InteractiveSection.tsx +0 -147
- package/src/Markdown.tsx +0 -12
- package/src/OpenAPICodeSample.tsx +0 -330
- package/src/OpenAPICodeSampleInteractive.tsx +0 -136
- package/src/OpenAPICodeSampleSelector.tsx +0 -94
- package/src/OpenAPICopyButton.tsx +0 -72
- package/src/OpenAPIDisclosure.tsx +0 -46
- package/src/OpenAPIDisclosureGroup.tsx +0 -158
- package/src/OpenAPIExample.tsx +0 -55
- package/src/OpenAPIMediaType.tsx +0 -139
- package/src/OpenAPIOperation.tsx +0 -35
- package/src/OpenAPIOperationContext.tsx +0 -45
- package/src/OpenAPIOperationDescription.tsx +0 -34
- package/src/OpenAPIOperationStability.tsx +0 -39
- package/src/OpenAPIPath.tsx +0 -90
- package/src/OpenAPIPrefillContextProvider.tsx +0 -40
- package/src/OpenAPIRequestBody.tsx +0 -54
- package/src/OpenAPIRequestBodyHeaderType.tsx +0 -36
- package/src/OpenAPIResponse.tsx +0 -82
- package/src/OpenAPIResponseExample.tsx +0 -151
- package/src/OpenAPIResponseExampleContent.tsx +0 -125
- package/src/OpenAPIResponses.tsx +0 -125
- package/src/OpenAPISchema.test.ts +0 -172
- package/src/OpenAPISchema.tsx +0 -654
- package/src/OpenAPISchemaName.tsx +0 -80
- package/src/OpenAPISchemaServer.tsx +0 -34
- package/src/OpenAPISecurities.tsx +0 -231
- package/src/OpenAPISelect.tsx +0 -96
- package/src/OpenAPISpec.tsx +0 -138
- package/src/OpenAPITabs.tsx +0 -147
- package/src/OpenAPIWebhook.tsx +0 -33
- package/src/OpenAPIWebhookExample.tsx +0 -60
- package/src/ScalarApiButton.tsx +0 -132
- package/src/StaticSection.tsx +0 -91
- package/src/__snapshots__/json2xml.test.ts.snap +0 -18
- package/src/code-samples.test.ts +0 -714
- package/src/code-samples.ts +0 -448
- package/src/common/OpenAPIColumnSpec.tsx +0 -31
- package/src/common/OpenAPIOperationDescription.tsx +0 -31
- package/src/common/OpenAPIStability.tsx +0 -23
- package/src/common/OpenAPISummary.tsx +0 -45
- package/src/contentTypeChecks.ts +0 -39
- package/src/context.ts +0 -99
- package/src/decycle.ts +0 -68
- package/src/dereference.ts +0 -29
- package/src/generateSchemaExample.test.ts +0 -1040
- package/src/generateSchemaExample.ts +0 -530
- package/src/getDisclosureLabel.ts +0 -25
- package/src/getOrCreateStoreByKey.ts +0 -33
- package/src/index.ts +0 -10
- package/src/json2xml.test.ts +0 -46
- package/src/json2xml.ts +0 -8
- package/src/resolveOpenAPIOperation.test.ts +0 -177
- package/src/resolveOpenAPIOperation.ts +0 -151
- package/src/resolveOpenAPIWebhook.ts +0 -99
- package/src/schemas/OpenAPISchemaItem.tsx +0 -34
- package/src/schemas/OpenAPISchemas.tsx +0 -98
- package/src/schemas/index.ts +0 -2
- package/src/schemas/resolveOpenAPISchemas.test.ts +0 -174
- package/src/schemas/resolveOpenAPISchemas.ts +0 -28
- package/src/stringifyOpenAPI.ts +0 -25
- package/src/translate.tsx +0 -80
- package/src/translations/de.ts +0 -43
- package/src/translations/en.ts +0 -43
- package/src/translations/es.ts +0 -43
- package/src/translations/fr.ts +0 -43
- package/src/translations/index.ts +0 -33
- package/src/translations/ja.ts +0 -43
- package/src/translations/nl.ts +0 -43
- package/src/translations/no.ts +0 -43
- package/src/translations/pt-br.ts +0 -43
- package/src/translations/types.ts +0 -7
- package/src/translations/zh.ts +0 -43
- package/src/types.ts +0 -46
- package/src/util/example.tsx +0 -129
- package/src/util/server.test.ts +0 -58
- package/src/util/server.ts +0 -47
- package/src/util/tryit-prefill.test.ts +0 -311
- package/src/util/tryit-prefill.ts +0 -160
- package/src/utils.ts +0 -255
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { fromJSON, toJSON } from 'flatted';
|
|
58
|
-
import { dereferenceFilesystem } from './dereference';
|
|
59
|
-
import { checkIsReference } from './utils';
|
|
60
|
-
export { fromJSON, toJSON };
|
|
61
|
-
/**
|
|
62
|
-
* Resolve an OpenAPI operation in a file and compile it to a more usable format.
|
|
63
|
-
*/
|
|
64
|
-
export function resolveOpenAPIOperation(filesystem, operationDescriptor) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
-
var path, method, schema, operation, commonParameters, servers, schemaSecurity, security, isOptionalSecurity, flatSecurities, securities, _i, flatSecurities_1, entry, securityKey, securityScheme;
|
|
67
|
-
var _a, _b, _c, _d, _e;
|
|
68
|
-
return __generator(this, function (_f) {
|
|
69
|
-
switch (_f.label) {
|
|
70
|
-
case 0:
|
|
71
|
-
path = operationDescriptor.path, method = operationDescriptor.method;
|
|
72
|
-
return [4 /*yield*/, dereferenceFilesystem(filesystem)];
|
|
73
|
-
case 1:
|
|
74
|
-
schema = _f.sent();
|
|
75
|
-
operation = getOperationByPathAndMethod(schema, path, method);
|
|
76
|
-
if (!operation) {
|
|
77
|
-
return [2 /*return*/, null];
|
|
78
|
-
}
|
|
79
|
-
commonParameters = getPathObjectParameter(schema, path);
|
|
80
|
-
if (commonParameters) {
|
|
81
|
-
operation = __assign(__assign({}, operation), { parameters: __spreadArray(__spreadArray([], commonParameters, true), ((_a = operation.parameters) !== null && _a !== void 0 ? _a : []), true) });
|
|
82
|
-
}
|
|
83
|
-
servers = 'servers' in schema ? ((_b = schema.servers) !== null && _b !== void 0 ? _b : []) : [];
|
|
84
|
-
schemaSecurity = Array.isArray(schema.security)
|
|
85
|
-
? schema.security
|
|
86
|
-
: schema.security
|
|
87
|
-
? [schema.security]
|
|
88
|
-
: [];
|
|
89
|
-
security = (_c = operation.security) !== null && _c !== void 0 ? _c : schemaSecurity;
|
|
90
|
-
isOptionalSecurity = security.some(function (entry) { return Object.keys(entry).length === 0; });
|
|
91
|
-
flatSecurities = flattenSecurities(security);
|
|
92
|
-
securities = [];
|
|
93
|
-
for (_i = 0, flatSecurities_1 = flatSecurities; _i < flatSecurities_1.length; _i++) {
|
|
94
|
-
entry = flatSecurities_1[_i];
|
|
95
|
-
securityKey = Object.keys(entry)[0];
|
|
96
|
-
if (securityKey) {
|
|
97
|
-
securityScheme = (_e = (_d = schema.components) === null || _d === void 0 ? void 0 : _d.securitySchemes) === null || _e === void 0 ? void 0 : _e[securityKey];
|
|
98
|
-
if (securityScheme && !checkIsReference(securityScheme)) {
|
|
99
|
-
securities.push([
|
|
100
|
-
securityKey,
|
|
101
|
-
__assign(__assign({}, securityScheme), { required: !isOptionalSecurity }),
|
|
102
|
-
]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return [2 /*return*/, {
|
|
107
|
-
servers: servers,
|
|
108
|
-
operation: operation,
|
|
109
|
-
method: method,
|
|
110
|
-
path: path,
|
|
111
|
-
securities: securities,
|
|
112
|
-
'x-codeSamples': typeof schema['x-codeSamples'] === 'boolean' ? schema['x-codeSamples'] : undefined,
|
|
113
|
-
'x-hideTryItPanel': typeof schema['x-hideTryItPanel'] === 'boolean'
|
|
114
|
-
? schema['x-hideTryItPanel']
|
|
115
|
-
: undefined,
|
|
116
|
-
}];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Get a path object from its path.
|
|
123
|
-
*/
|
|
124
|
-
function getPathObject(schema, path) {
|
|
125
|
-
var _a;
|
|
126
|
-
if ((_a = schema.paths) === null || _a === void 0 ? void 0 : _a[path]) {
|
|
127
|
-
return schema.paths[path];
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Resolve parameters from a path in an OpenAPI schema.
|
|
133
|
-
*/
|
|
134
|
-
function getPathObjectParameter(schema, path) {
|
|
135
|
-
var pathObject = getPathObject(schema, path);
|
|
136
|
-
if (pathObject === null || pathObject === void 0 ? void 0 : pathObject.parameters) {
|
|
137
|
-
return pathObject.parameters;
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Get an operation by its path and method.
|
|
143
|
-
*/
|
|
144
|
-
function getOperationByPathAndMethod(schema, path, method) {
|
|
145
|
-
// Types are buffy for OpenAPIV3_1.OperationObject, so we use v3
|
|
146
|
-
var pathObject = getPathObject(schema, path);
|
|
147
|
-
if (!pathObject) {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
var normalizedMethod = method.toLowerCase();
|
|
151
|
-
if (!pathObject[normalizedMethod]) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
return pathObject[normalizedMethod];
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Flatten security objects in case they are nested.
|
|
158
|
-
* @example [{bearerAuth:[], basicAuth:[]}] => [{ bearerAuth: [] }, { basicAuth: [] }]
|
|
159
|
-
*/
|
|
160
|
-
function flattenSecurities(security) {
|
|
161
|
-
if (!Array.isArray(security) || security.length === 0) {
|
|
162
|
-
return [];
|
|
163
|
-
}
|
|
164
|
-
return security.flatMap(function (securityObject) {
|
|
165
|
-
return Object.entries(securityObject).map(function (_a) {
|
|
166
|
-
var _b;
|
|
167
|
-
var authType = _a[0], config = _a[1];
|
|
168
|
-
return (_b = {},
|
|
169
|
-
_b[authType] = config,
|
|
170
|
-
_b);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { fromJSON, toJSON } from 'flatted';
|
|
2
|
-
import type { Filesystem, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
|
|
3
|
-
import type { OpenAPIWebhookData } from './types';
|
|
4
|
-
export { fromJSON, toJSON };
|
|
5
|
-
/**
|
|
6
|
-
* Resolve an OpenAPI webhook in a file and compile it to a more usable format.
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveOpenAPIWebhook(filesystem: Filesystem<OpenAPIV3xDocument>, webhookDescriptor: {
|
|
9
|
-
name: string;
|
|
10
|
-
method: string;
|
|
11
|
-
}): Promise<OpenAPIWebhookData | null>;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { fromJSON, toJSON } from 'flatted';
|
|
58
|
-
import { dereferenceFilesystem } from './dereference';
|
|
59
|
-
export { fromJSON, toJSON };
|
|
60
|
-
/**
|
|
61
|
-
* Resolve an OpenAPI webhook in a file and compile it to a more usable format.
|
|
62
|
-
*/
|
|
63
|
-
export function resolveOpenAPIWebhook(filesystem, webhookDescriptor) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var name, method, schema, operation, commonParameters, servers;
|
|
66
|
-
var _a, _b;
|
|
67
|
-
return __generator(this, function (_c) {
|
|
68
|
-
switch (_c.label) {
|
|
69
|
-
case 0:
|
|
70
|
-
name = webhookDescriptor.name, method = webhookDescriptor.method;
|
|
71
|
-
return [4 /*yield*/, dereferenceFilesystem(filesystem)];
|
|
72
|
-
case 1:
|
|
73
|
-
schema = _c.sent();
|
|
74
|
-
operation = getWebhookByNameAndMethod(schema, name, method);
|
|
75
|
-
if (!operation) {
|
|
76
|
-
return [2 /*return*/, null];
|
|
77
|
-
}
|
|
78
|
-
commonParameters = getPathObjectParameter(schema, name);
|
|
79
|
-
if (commonParameters) {
|
|
80
|
-
operation = __assign(__assign({}, operation), { parameters: __spreadArray(__spreadArray([], commonParameters, true), ((_a = operation.parameters) !== null && _a !== void 0 ? _a : []), true) });
|
|
81
|
-
}
|
|
82
|
-
servers = 'servers' in schema ? ((_b = schema.servers) !== null && _b !== void 0 ? _b : []) : [];
|
|
83
|
-
return [2 /*return*/, {
|
|
84
|
-
servers: servers,
|
|
85
|
-
operation: operation,
|
|
86
|
-
method: method,
|
|
87
|
-
name: name,
|
|
88
|
-
}];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get a path object from its path.
|
|
95
|
-
*/
|
|
96
|
-
function getPathObject(schema, name) {
|
|
97
|
-
var _a;
|
|
98
|
-
if ((_a = schema.webhooks) === null || _a === void 0 ? void 0 : _a[name]) {
|
|
99
|
-
return schema.webhooks[name];
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Resolve parameters from a path in an OpenAPI schema.
|
|
105
|
-
*/
|
|
106
|
-
function getPathObjectParameter(schema, path) {
|
|
107
|
-
var pathObject = getPathObject(schema, path);
|
|
108
|
-
if (pathObject === null || pathObject === void 0 ? void 0 : pathObject.parameters) {
|
|
109
|
-
return pathObject.parameters;
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Get an operation by its path and method.
|
|
115
|
-
*/
|
|
116
|
-
function getWebhookByNameAndMethod(schema, name, method) {
|
|
117
|
-
// Types are buffy for OpenAPIV3_1.OperationObject, so we use v3
|
|
118
|
-
var pathObject = getPathObject(schema, name);
|
|
119
|
-
if (!pathObject) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
var normalizedMethod = method.toLowerCase();
|
|
123
|
-
if (!pathObject[normalizedMethod]) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
return pathObject[normalizedMethod];
|
|
127
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
-
import type { OpenAPIClientContext } from '../context';
|
|
3
|
-
export declare function OpenAPISchemaItem(props: {
|
|
4
|
-
name: string;
|
|
5
|
-
schema: OpenAPIV3.SchemaObject;
|
|
6
|
-
context: OpenAPIClientContext;
|
|
7
|
-
}): import("react").JSX.Element;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { SectionBody } from '../StaticSection';
|
|
3
|
-
import { OpenAPIDisclosure } from '../OpenAPIDisclosure';
|
|
4
|
-
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
5
|
-
import { Section } from '../StaticSection';
|
|
6
|
-
import { getDisclosureLabel } from '../getDisclosureLabel';
|
|
7
|
-
export function OpenAPISchemaItem(props) {
|
|
8
|
-
var schema = props.schema, context = props.context, name = props.name;
|
|
9
|
-
return (<OpenAPIDisclosure className="openapi-schemas-disclosure" key={name} icon={context.icons.plus} header={name} label={function (isExpanded) { return getDisclosureLabel({ schema: schema, isExpanded: isExpanded, context: context }); }}>
|
|
10
|
-
<Section className="openapi-section-schemas">
|
|
11
|
-
<SectionBody>
|
|
12
|
-
<OpenAPIRootSchema schema={schema} context={context}/>
|
|
13
|
-
</SectionBody>
|
|
14
|
-
</Section>
|
|
15
|
-
</OpenAPIDisclosure>);
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { OpenAPISchema } from '@gitbook/openapi-parser';
|
|
2
|
-
import { type OpenAPIContextInput } from '../context';
|
|
3
|
-
/**
|
|
4
|
-
* OpenAPI Schemas component.
|
|
5
|
-
*/
|
|
6
|
-
export declare function OpenAPISchemas(props: {
|
|
7
|
-
className?: string;
|
|
8
|
-
schemas: OpenAPISchema[];
|
|
9
|
-
context: OpenAPIContextInput;
|
|
10
|
-
/**
|
|
11
|
-
* Whether to show the schema directly if there is only one.
|
|
12
|
-
*/
|
|
13
|
-
grouped?: boolean;
|
|
14
|
-
}): import("react").JSX.Element | null;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { OpenAPIExample } from '../OpenAPIExample';
|
|
3
|
-
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
4
|
-
import { StaticSection } from '../StaticSection';
|
|
5
|
-
import { getOpenAPIClientContext, resolveOpenAPIContext, } from '../context';
|
|
6
|
-
import { t } from '../translate';
|
|
7
|
-
import { getExampleFromSchema } from '../util/example';
|
|
8
|
-
import { OpenAPISchemaItem } from './OpenAPISchemaItem';
|
|
9
|
-
/**
|
|
10
|
-
* OpenAPI Schemas component.
|
|
11
|
-
*/
|
|
12
|
-
export function OpenAPISchemas(props) {
|
|
13
|
-
var schemas = props.schemas, contextInput = props.context, grouped = props.grouped, className = props.className;
|
|
14
|
-
var firstSchema = schemas[0];
|
|
15
|
-
if (!firstSchema) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
var context = resolveOpenAPIContext(contextInput);
|
|
19
|
-
var clientContext = getOpenAPIClientContext(context);
|
|
20
|
-
// If there is only one model and we are not grouping, we show it directly.
|
|
21
|
-
if (schemas.length === 1 && !grouped) {
|
|
22
|
-
var title = "The ".concat(firstSchema.name, " object");
|
|
23
|
-
return (<div className={clsx('openapi-schemas', className)}>
|
|
24
|
-
<div className="openapi-summary" id={context.id}>
|
|
25
|
-
{context.renderHeading({
|
|
26
|
-
title: title,
|
|
27
|
-
deprecated: Boolean(firstSchema.schema.deprecated),
|
|
28
|
-
stability: firstSchema.schema['x-stability'],
|
|
29
|
-
})}
|
|
30
|
-
</div>
|
|
31
|
-
<div className="openapi-columns">
|
|
32
|
-
<div className="openapi-column-spec">
|
|
33
|
-
<StaticSection className="openapi-parameters" header={t(context.translation, 'attributes')}>
|
|
34
|
-
<OpenAPIRootSchema schema={firstSchema.schema} context={clientContext}/>
|
|
35
|
-
</StaticSection>
|
|
36
|
-
</div>
|
|
37
|
-
<div className="openapi-column-preview">
|
|
38
|
-
<div className="openapi-column-preview-body">
|
|
39
|
-
<div className="openapi-panel">
|
|
40
|
-
<h4 className="openapi-panel-heading">{title}</h4>
|
|
41
|
-
<div className="openapi-panel-body">
|
|
42
|
-
<OpenAPIExample example={getExampleFromSchema({
|
|
43
|
-
schema: firstSchema.schema,
|
|
44
|
-
})} context={context} syntax="json"/>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>);
|
|
51
|
-
}
|
|
52
|
-
// If there are multiple schemas, we use a disclosure group to show them all.
|
|
53
|
-
return (<div className={clsx('openapi-schemas', className)}>
|
|
54
|
-
{schemas.map(function (_a) {
|
|
55
|
-
var name = _a.name, schema = _a.schema;
|
|
56
|
-
return (<OpenAPISchemaItem key={name} name={name} context={clientContext} schema={schema}/>);
|
|
57
|
-
})}
|
|
58
|
-
</div>);
|
|
59
|
-
}
|
package/dist/schemas/index.d.ts
DELETED
package/dist/schemas/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Filesystem, OpenAPISchema, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve an OpenAPI schemas from a file and compile it to a more usable format.
|
|
4
|
-
* Schemas are extracted from the OpenAPI components.schemas
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveOpenAPISchemas(filesystem: Filesystem<OpenAPIV3xDocument>, options: {
|
|
7
|
-
schemas: string[];
|
|
8
|
-
}): Promise<{
|
|
9
|
-
schemas: OpenAPISchema[];
|
|
10
|
-
} | null>;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { filterSelectedOpenAPISchemas } from '@gitbook/openapi-parser';
|
|
38
|
-
import { dereferenceFilesystem } from '../dereference';
|
|
39
|
-
/**
|
|
40
|
-
* Resolve an OpenAPI schemas from a file and compile it to a more usable format.
|
|
41
|
-
* Schemas are extracted from the OpenAPI components.schemas
|
|
42
|
-
*/
|
|
43
|
-
export function resolveOpenAPISchemas(filesystem, options) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var selectedSchemas, schema, schemas;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
selectedSchemas = options.schemas;
|
|
50
|
-
return [4 /*yield*/, dereferenceFilesystem(filesystem)];
|
|
51
|
-
case 1:
|
|
52
|
-
schema = _a.sent();
|
|
53
|
-
schemas = filterSelectedOpenAPISchemas(schema, selectedSchemas);
|
|
54
|
-
if (schemas.length === 0) {
|
|
55
|
-
return [2 /*return*/, null];
|
|
56
|
-
}
|
|
57
|
-
return [2 /*return*/, { schemas: schemas }];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
package/dist/stringifyOpenAPI.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stringify an OpenAPI object. Same API as JSON.stringify.
|
|
3
|
-
*/
|
|
4
|
-
export function stringifyOpenAPI(value, replacer, space) {
|
|
5
|
-
return JSON.stringify(value, function (key, value) {
|
|
6
|
-
// Ignore internal keys
|
|
7
|
-
if (key.startsWith('x-gitbook-')) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
if (replacer) {
|
|
11
|
-
return replacer(key, value);
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
14
|
-
}, space);
|
|
15
|
-
}
|
package/dist/translate.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Translation, TranslationKey } from './translations';
|
|
3
|
-
/**
|
|
4
|
-
* Translate a string.
|
|
5
|
-
*/
|
|
6
|
-
export declare function t(translation: Translation, id: TranslationKey, ...args: React.ReactNode[]): React.ReactNode;
|
|
7
|
-
/**
|
|
8
|
-
* Version of `t` that returns a string.
|
|
9
|
-
*/
|
|
10
|
-
export declare function tString(translation: Translation, id: TranslationKey, ...args: React.ReactNode[]): string;
|
package/dist/translate.jsx
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
|
-
import React from 'react';
|
|
11
|
-
/**
|
|
12
|
-
* Translate a string.
|
|
13
|
-
*/
|
|
14
|
-
export function t(translation, id) {
|
|
15
|
-
var args = [];
|
|
16
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
17
|
-
args[_i - 2] = arguments[_i];
|
|
18
|
-
}
|
|
19
|
-
var string = translation[id];
|
|
20
|
-
if (!string) {
|
|
21
|
-
throw new Error("Translation not found for \"".concat(id, "\""));
|
|
22
|
-
}
|
|
23
|
-
// Now we are going to replace the arguments
|
|
24
|
-
// but we want to return a string as long as it's possible
|
|
25
|
-
// (eg. if there isn't any argument that is a ReactNode)
|
|
26
|
-
var parts = [];
|
|
27
|
-
var currentStringToReplace = string;
|
|
28
|
-
args.forEach(function (arg, i) {
|
|
29
|
-
if (typeof arg === 'string') {
|
|
30
|
-
currentStringToReplace = currentStringToReplace.replace("${".concat(i + 1, "}"), arg);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
var _a = currentStringToReplace.split("${".concat(i + 1, "}")), partToPush = _a[0], partToReplace = _a[1];
|
|
34
|
-
if (partToPush === undefined || partToReplace === undefined) {
|
|
35
|
-
throw new Error("Invalid translation \"".concat(id, "\""));
|
|
36
|
-
}
|
|
37
|
-
parts.push(<React.Fragment key={"string-".concat(i)}>{partToPush}</React.Fragment>);
|
|
38
|
-
parts.push(<React.Fragment key={"arg-".concat(i)}>{arg}</React.Fragment>);
|
|
39
|
-
currentStringToReplace = partToReplace;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
if (!parts.length) {
|
|
43
|
-
return currentStringToReplace;
|
|
44
|
-
}
|
|
45
|
-
return (<>
|
|
46
|
-
{parts}
|
|
47
|
-
{currentStringToReplace}
|
|
48
|
-
</>);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Version of `t` that returns a string.
|
|
52
|
-
*/
|
|
53
|
-
export function tString(translation, id) {
|
|
54
|
-
var args = [];
|
|
55
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
56
|
-
args[_i - 2] = arguments[_i];
|
|
57
|
-
}
|
|
58
|
-
var result = t.apply(void 0, __spreadArray([translation, id], args, false));
|
|
59
|
-
return reactToString(result);
|
|
60
|
-
}
|
|
61
|
-
function reactToString(el) {
|
|
62
|
-
if (typeof el === 'string' || typeof el === 'number' || typeof el === 'boolean') {
|
|
63
|
-
return "".concat(el);
|
|
64
|
-
}
|
|
65
|
-
if (el === null || el === undefined) {
|
|
66
|
-
return '';
|
|
67
|
-
}
|
|
68
|
-
if (Array.isArray(el)) {
|
|
69
|
-
return el.map(reactToString).join('');
|
|
70
|
-
}
|
|
71
|
-
if (typeof el === 'object' && 'props' in el) {
|
|
72
|
-
return el.props.children.map(reactToString).join('');
|
|
73
|
-
}
|
|
74
|
-
throw new Error("Unsupported type ".concat(typeof el));
|
|
75
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export declare const de: {
|
|
2
|
-
required: string;
|
|
3
|
-
deprecated: string;
|
|
4
|
-
deprecated_and_sunset_on: string;
|
|
5
|
-
stability_experimental: string;
|
|
6
|
-
stability_alpha: string;
|
|
7
|
-
stability_beta: string;
|
|
8
|
-
copy_to_clipboard: string;
|
|
9
|
-
copied: string;
|
|
10
|
-
no_content: string;
|
|
11
|
-
unresolved_reference: string;
|
|
12
|
-
circular_reference: string;
|
|
13
|
-
read_only: string;
|
|
14
|
-
write_only: string;
|
|
15
|
-
optional: string;
|
|
16
|
-
min: string;
|
|
17
|
-
max: string;
|
|
18
|
-
nullable: string;
|
|
19
|
-
body: string;
|
|
20
|
-
payload: string;
|
|
21
|
-
headers: string;
|
|
22
|
-
header: string;
|
|
23
|
-
authorizations: string;
|
|
24
|
-
responses: string;
|
|
25
|
-
response: string;
|
|
26
|
-
path_parameters: string;
|
|
27
|
-
query_parameters: string;
|
|
28
|
-
header_parameters: string;
|
|
29
|
-
attributes: string;
|
|
30
|
-
test_it: string;
|
|
31
|
-
information: string;
|
|
32
|
-
success: string;
|
|
33
|
-
redirect: string;
|
|
34
|
-
error: string;
|
|
35
|
-
show: string;
|
|
36
|
-
hide: string;
|
|
37
|
-
available_items: string;
|
|
38
|
-
available_scopes: string;
|
|
39
|
-
properties: string;
|
|
40
|
-
or: string;
|
|
41
|
-
and: string;
|
|
42
|
-
possible_values: string;
|
|
43
|
-
};
|