@gitbook/react-openapi 1.1.10 → 1.2.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 +21 -0
- package/dist/InteractiveSection.d.ts +4 -0
- package/dist/InteractiveSection.jsx +11 -11
- package/dist/OpenAPICodeSample.d.ts +2 -1
- package/dist/OpenAPICodeSample.jsx +6 -5
- package/dist/OpenAPICodeSampleInteractive.d.ts +3 -0
- package/dist/OpenAPICodeSampleInteractive.jsx +19 -43
- package/dist/OpenAPICodeSampleSelector.d.ts +3 -4
- package/dist/OpenAPICodeSampleSelector.jsx +6 -11
- package/dist/OpenAPICopyButton.d.ts +2 -0
- package/dist/OpenAPICopyButton.jsx +5 -2
- package/dist/OpenAPIDisclosure.d.ts +4 -3
- package/dist/OpenAPIDisclosure.jsx +8 -11
- package/dist/OpenAPIDisclosureGroup.d.ts +7 -3
- package/dist/OpenAPIDisclosureGroup.jsx +18 -18
- package/dist/OpenAPIExample.d.ts +4 -22
- package/dist/OpenAPIExample.jsx +5 -72
- package/dist/OpenAPIMediaType.d.ts +21 -0
- package/dist/OpenAPIMediaType.jsx +61 -0
- package/dist/OpenAPIOperation.d.ts +3 -2
- package/dist/OpenAPIOperation.jsx +9 -68
- package/dist/OpenAPIOperationDescription.d.ts +9 -0
- package/dist/OpenAPIOperationDescription.jsx +22 -0
- package/dist/OpenAPIOperationStability.d.ts +9 -0
- package/dist/OpenAPIOperationStability.jsx +27 -0
- package/dist/OpenAPIPath.d.ts +2 -0
- package/dist/OpenAPIPath.jsx +3 -2
- package/dist/OpenAPIRequestBody.d.ts +3 -1
- package/dist/OpenAPIRequestBody.jsx +4 -3
- package/dist/OpenAPIResponse.d.ts +1 -1
- package/dist/OpenAPIResponse.jsx +1 -1
- package/dist/OpenAPIResponseExample.d.ts +3 -2
- package/dist/OpenAPIResponseExample.jsx +24 -63
- package/dist/OpenAPIResponseExampleContent.d.ts +19 -0
- package/dist/OpenAPIResponseExampleContent.jsx +57 -0
- package/dist/OpenAPIResponses.d.ts +1 -1
- package/dist/OpenAPIResponses.jsx +49 -36
- package/dist/OpenAPISchema.d.ts +1 -1
- package/dist/OpenAPISchema.jsx +103 -15
- package/dist/OpenAPISchemaName.d.ts +2 -0
- package/dist/OpenAPISchemaName.jsx +19 -10
- package/dist/OpenAPISchemaServer.d.ts +1 -1
- package/dist/OpenAPISecurities.d.ts +2 -1
- package/dist/OpenAPISecurities.jsx +11 -10
- package/dist/OpenAPISelect.d.ts +10 -3
- package/dist/OpenAPISelect.jsx +20 -9
- package/dist/OpenAPISpec.d.ts +3 -2
- package/dist/OpenAPISpec.jsx +11 -9
- package/dist/OpenAPIWebhook.d.ts +10 -0
- package/dist/OpenAPIWebhook.jsx +23 -0
- package/dist/OpenAPIWebhookExample.d.ts +6 -0
- package/dist/OpenAPIWebhookExample.jsx +41 -0
- package/dist/ScalarApiButton.d.ts +2 -0
- package/dist/ScalarApiButton.jsx +4 -3
- package/dist/StaticSection.d.ts +4 -1
- package/dist/StaticSection.jsx +13 -4
- package/dist/code-samples.js +57 -39
- package/dist/common/OpenAPIColumnSpec.d.ts +6 -0
- package/dist/common/OpenAPIColumnSpec.jsx +20 -0
- package/dist/common/OpenAPIOperationDescription.d.ts +6 -0
- package/dist/common/OpenAPIOperationDescription.jsx +19 -0
- package/dist/common/OpenAPIStability.d.ts +4 -0
- package/dist/common/OpenAPIStability.jsx +15 -0
- package/dist/common/OpenAPISummary.d.ts +6 -0
- package/dist/common/OpenAPISummary.jsx +30 -0
- package/dist/context.d.ts +23 -2
- package/dist/context.js +32 -0
- package/dist/getOrCreateStoreByKey.d.ts +1 -1
- package/dist/getOrCreateStoreByKey.js +0 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -0
- package/dist/resolveOpenAPIWebhook.d.ts +11 -0
- package/dist/resolveOpenAPIWebhook.js +127 -0
- package/dist/schemas/OpenAPISchemas.d.ts +2 -2
- package/dist/schemas/OpenAPISchemas.jsx +19 -23
- package/dist/stringifyOpenAPI.d.ts +1 -1
- package/dist/stringifyOpenAPI.js +6 -3
- package/dist/translate.d.ts +10 -0
- package/dist/translate.jsx +75 -0
- package/dist/translations/de.d.ts +37 -0
- package/dist/translations/de.js +37 -0
- package/dist/translations/en.d.ts +37 -0
- package/dist/translations/en.js +37 -0
- package/dist/translations/es.d.ts +37 -0
- package/dist/translations/es.js +37 -0
- package/dist/translations/fr.d.ts +37 -0
- package/dist/translations/fr.js +37 -0
- package/dist/translations/index.d.ts +341 -0
- package/dist/translations/index.js +27 -0
- package/dist/translations/ja.d.ts +37 -0
- package/dist/translations/ja.js +37 -0
- package/dist/translations/nl.d.ts +37 -0
- package/dist/translations/nl.js +37 -0
- package/dist/translations/no.d.ts +37 -0
- package/dist/translations/no.js +37 -0
- package/dist/translations/pt-br.d.ts +37 -0
- package/dist/translations/pt-br.js +37 -0
- package/dist/translations/types.d.ts +5 -0
- package/dist/translations/types.js +1 -0
- package/dist/translations/zh.d.ts +37 -0
- package/dist/translations/zh.js +37 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types.d.ts +8 -50
- package/dist/util/example.d.ts +35 -0
- package/dist/util/example.jsx +103 -0
- package/dist/utils.d.ts +18 -0
- package/dist/utils.js +57 -0
- package/package.json +3 -3
- package/src/InteractiveSection.tsx +16 -14
- package/src/OpenAPICodeSample.tsx +22 -4
- package/src/OpenAPICodeSampleInteractive.tsx +38 -58
- package/src/OpenAPICodeSampleSelector.tsx +19 -12
- package/src/OpenAPICopyButton.tsx +7 -2
- package/src/OpenAPIDisclosure.tsx +20 -22
- package/src/OpenAPIDisclosureGroup.tsx +41 -22
- package/src/OpenAPIExample.tsx +8 -82
- package/src/OpenAPIMediaType.tsx +139 -0
- package/src/OpenAPIOperation.tsx +11 -100
- package/src/OpenAPIOperationDescription.tsx +34 -0
- package/src/OpenAPIOperationStability.tsx +39 -0
- package/src/OpenAPIPath.tsx +4 -1
- package/src/OpenAPIRequestBody.tsx +9 -4
- package/src/OpenAPIResponse.tsx +2 -2
- package/src/OpenAPIResponseExample.tsx +39 -108
- package/src/OpenAPIResponseExampleContent.tsx +123 -0
- package/src/OpenAPIResponses.tsx +84 -62
- package/src/OpenAPISchema.test.ts +80 -0
- package/src/OpenAPISchema.tsx +123 -16
- package/src/OpenAPISchemaName.tsx +26 -11
- package/src/OpenAPISchemaServer.tsx +1 -1
- package/src/OpenAPISecurities.tsx +33 -12
- package/src/OpenAPISelect.tsx +42 -16
- package/src/OpenAPISpec.tsx +21 -10
- package/src/OpenAPIWebhook.tsx +33 -0
- package/src/OpenAPIWebhookExample.tsx +60 -0
- package/src/ScalarApiButton.tsx +6 -6
- package/src/StaticSection.tsx +37 -5
- package/src/code-samples.test.ts +3 -1
- package/src/code-samples.ts +67 -54
- package/src/common/OpenAPIColumnSpec.tsx +31 -0
- package/src/common/OpenAPIOperationDescription.tsx +31 -0
- package/src/common/OpenAPIStability.tsx +23 -0
- package/src/common/OpenAPISummary.tsx +45 -0
- package/src/context.ts +37 -2
- package/src/getOrCreateStoreByKey.ts +1 -3
- package/src/index.ts +5 -1
- package/src/resolveOpenAPIWebhook.ts +99 -0
- package/src/schemas/OpenAPISchemas.tsx +34 -34
- package/src/stringifyOpenAPI.ts +11 -3
- package/src/translate.tsx +80 -0
- package/src/translations/de.ts +37 -0
- package/src/translations/en.ts +37 -0
- package/src/translations/es.ts +37 -0
- package/src/translations/fr.ts +37 -0
- package/src/translations/index.ts +33 -0
- package/src/translations/ja.ts +37 -0
- package/src/translations/nl.ts +37 -0
- package/src/translations/no.ts +37 -0
- package/src/translations/pt-br.ts +37 -0
- package/src/translations/types.ts +7 -0
- package/src/translations/zh.ts +37 -0
- package/src/types.ts +11 -53
- package/src/util/example.tsx +129 -0
- package/src/utils.ts +67 -0
|
@@ -0,0 +1,127 @@
|
|
|
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,12 +1,12 @@
|
|
|
1
1
|
import type { OpenAPISchema } from '@gitbook/openapi-parser';
|
|
2
|
-
import type
|
|
2
|
+
import { type OpenAPIContextInput } from '../context';
|
|
3
3
|
/**
|
|
4
4
|
* OpenAPI Schemas component.
|
|
5
5
|
*/
|
|
6
6
|
export declare function OpenAPISchemas(props: {
|
|
7
7
|
className?: string;
|
|
8
8
|
schemas: OpenAPISchema[];
|
|
9
|
-
context:
|
|
9
|
+
context: OpenAPIContextInput;
|
|
10
10
|
/**
|
|
11
11
|
* Whether to show the schema directly if there is only one.
|
|
12
12
|
*/
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import {
|
|
3
|
-
import { OpenAPIExample
|
|
2
|
+
import { OpenAPIDisclosure } from '../OpenAPIDisclosure';
|
|
3
|
+
import { OpenAPIExample } from '../OpenAPIExample';
|
|
4
4
|
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
5
5
|
import { Section, SectionBody, StaticSection } from '../StaticSection';
|
|
6
|
-
import { getOpenAPIClientContext } from '../context';
|
|
6
|
+
import { getOpenAPIClientContext, resolveOpenAPIContext, } from '../context';
|
|
7
|
+
import { t } from '../translate';
|
|
8
|
+
import { getExampleFromSchema } from '../util/example';
|
|
7
9
|
/**
|
|
8
10
|
* OpenAPI Schemas component.
|
|
9
11
|
*/
|
|
10
12
|
export function OpenAPISchemas(props) {
|
|
11
|
-
var schemas = props.schemas,
|
|
13
|
+
var schemas = props.schemas, contextInput = props.context, grouped = props.grouped, className = props.className;
|
|
12
14
|
var firstSchema = schemas[0];
|
|
13
15
|
if (!firstSchema) {
|
|
14
16
|
return null;
|
|
15
17
|
}
|
|
18
|
+
var context = resolveOpenAPIContext(contextInput);
|
|
16
19
|
var clientContext = getOpenAPIClientContext(context);
|
|
17
20
|
// If there is only one model and we are not grouping, we show it directly.
|
|
18
21
|
if (schemas.length === 1 && !grouped) {
|
|
@@ -21,11 +24,13 @@ export function OpenAPISchemas(props) {
|
|
|
21
24
|
<div className="openapi-summary" id={context.id}>
|
|
22
25
|
{context.renderHeading({
|
|
23
26
|
title: title,
|
|
27
|
+
deprecated: Boolean(firstSchema.schema.deprecated),
|
|
28
|
+
stability: firstSchema.schema['x-stability'],
|
|
24
29
|
})}
|
|
25
30
|
</div>
|
|
26
31
|
<div className="openapi-columns">
|
|
27
32
|
<div className="openapi-column-spec">
|
|
28
|
-
<StaticSection className="openapi-parameters" header=
|
|
33
|
+
<StaticSection className="openapi-parameters" header={t(context.translation, 'attributes')}>
|
|
29
34
|
<OpenAPIRootSchema schema={firstSchema.schema} context={clientContext}/>
|
|
30
35
|
</StaticSection>
|
|
31
36
|
</div>
|
|
@@ -46,24 +51,15 @@ export function OpenAPISchemas(props) {
|
|
|
46
51
|
}
|
|
47
52
|
// If there are multiple schemas, we use a disclosure group to show them all.
|
|
48
53
|
return (<div className={clsx('openapi-schemas', className)}>
|
|
49
|
-
|
|
54
|
+
{schemas.map(function (_a) {
|
|
50
55
|
var name = _a.name, schema = _a.schema;
|
|
51
|
-
return ({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
body: (<Section className="openapi-section-schemas">
|
|
60
|
-
<SectionBody>
|
|
61
|
-
<OpenAPIRootSchema schema={schema} context={clientContext}/>
|
|
62
|
-
</SectionBody>
|
|
63
|
-
</Section>),
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
});
|
|
67
|
-
})}/>
|
|
56
|
+
return (<OpenAPIDisclosure className="openapi-schemas-disclosure" key={name} icon={context.icons.chevronRight} label={name}>
|
|
57
|
+
<Section className="openapi-section-schemas">
|
|
58
|
+
<SectionBody>
|
|
59
|
+
<OpenAPIRootSchema schema={schema} context={clientContext}/>
|
|
60
|
+
</SectionBody>
|
|
61
|
+
</Section>
|
|
62
|
+
</OpenAPIDisclosure>);
|
|
63
|
+
})}
|
|
68
64
|
</div>);
|
|
69
65
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stringify an OpenAPI object. Same API as JSON.stringify.
|
|
3
3
|
*/
|
|
4
|
-
export declare function stringifyOpenAPI(
|
|
4
|
+
export declare function stringifyOpenAPI(value: any, replacer?: ((this: any, key: string, value: any) => any) | null, space?: string | number): string;
|
package/dist/stringifyOpenAPI.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stringify an OpenAPI object. Same API as JSON.stringify.
|
|
3
3
|
*/
|
|
4
|
-
export function stringifyOpenAPI(
|
|
5
|
-
return JSON.stringify(
|
|
4
|
+
export function stringifyOpenAPI(value, replacer, space) {
|
|
5
|
+
return JSON.stringify(value, function (key, value) {
|
|
6
6
|
// Ignore internal keys
|
|
7
7
|
if (key.startsWith('x-gitbook-')) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
|
+
if (replacer) {
|
|
11
|
+
return replacer(key, value);
|
|
12
|
+
}
|
|
10
13
|
return value;
|
|
11
|
-
},
|
|
14
|
+
}, space);
|
|
12
15
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
authorizations: string;
|
|
23
|
+
responses: string;
|
|
24
|
+
path_parameters: string;
|
|
25
|
+
query_parameters: string;
|
|
26
|
+
header_parameters: string;
|
|
27
|
+
attributes: string;
|
|
28
|
+
test_it: string;
|
|
29
|
+
information: string;
|
|
30
|
+
success: string;
|
|
31
|
+
redirect: string;
|
|
32
|
+
error: string;
|
|
33
|
+
show: string;
|
|
34
|
+
hide: string;
|
|
35
|
+
available_items: string;
|
|
36
|
+
child_attributes: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export var de = {
|
|
2
|
+
required: 'Erforderlich',
|
|
3
|
+
deprecated: 'Veraltet',
|
|
4
|
+
deprecated_and_sunset_on: 'Diese Operation ist veraltet und wird am ${1} eingestellt.',
|
|
5
|
+
stability_experimental: 'Experimentell',
|
|
6
|
+
stability_alpha: 'Alpha',
|
|
7
|
+
stability_beta: 'Beta',
|
|
8
|
+
copy_to_clipboard: 'In die Zwischenablage kopieren',
|
|
9
|
+
copied: 'Kopiert',
|
|
10
|
+
no_content: 'Kein Inhalt',
|
|
11
|
+
unresolved_reference: 'Nicht aufgelöste Referenz',
|
|
12
|
+
circular_reference: 'Zirkuläre Referenz',
|
|
13
|
+
read_only: 'Nur lesen',
|
|
14
|
+
write_only: 'Nur schreiben',
|
|
15
|
+
optional: 'Optional',
|
|
16
|
+
min: 'Min',
|
|
17
|
+
max: 'Max',
|
|
18
|
+
nullable: 'Nullfähig',
|
|
19
|
+
body: 'Rumpf',
|
|
20
|
+
payload: 'Nutzlast',
|
|
21
|
+
headers: 'Kopfzeilen',
|
|
22
|
+
authorizations: 'Autorisierungen',
|
|
23
|
+
responses: 'Antworten',
|
|
24
|
+
path_parameters: 'Pfadparameter',
|
|
25
|
+
query_parameters: 'Abfrageparameter',
|
|
26
|
+
header_parameters: 'Header-Parameter',
|
|
27
|
+
attributes: 'Attribute',
|
|
28
|
+
test_it: 'Teste es',
|
|
29
|
+
information: 'Information',
|
|
30
|
+
success: 'Erfolg',
|
|
31
|
+
redirect: 'Umleitung',
|
|
32
|
+
error: 'Fehler',
|
|
33
|
+
show: 'Anzeigen',
|
|
34
|
+
hide: 'Verstecken',
|
|
35
|
+
available_items: 'Verfügbare Elemente',
|
|
36
|
+
child_attributes: 'Unterattribute',
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const en: {
|
|
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
|
+
authorizations: string;
|
|
23
|
+
responses: string;
|
|
24
|
+
path_parameters: string;
|
|
25
|
+
query_parameters: string;
|
|
26
|
+
header_parameters: string;
|
|
27
|
+
attributes: string;
|
|
28
|
+
test_it: string;
|
|
29
|
+
information: string;
|
|
30
|
+
success: string;
|
|
31
|
+
redirect: string;
|
|
32
|
+
error: string;
|
|
33
|
+
show: string;
|
|
34
|
+
hide: string;
|
|
35
|
+
available_items: string;
|
|
36
|
+
child_attributes: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export var en = {
|
|
2
|
+
required: 'Required',
|
|
3
|
+
deprecated: 'Deprecated',
|
|
4
|
+
deprecated_and_sunset_on: 'This operation is deprecated and will be sunset on ${1}.',
|
|
5
|
+
stability_experimental: 'Experimental',
|
|
6
|
+
stability_alpha: 'Alpha',
|
|
7
|
+
stability_beta: 'Beta',
|
|
8
|
+
copy_to_clipboard: 'Copy to clipboard',
|
|
9
|
+
copied: 'Copied',
|
|
10
|
+
no_content: 'No content',
|
|
11
|
+
unresolved_reference: 'Unresolved reference',
|
|
12
|
+
circular_reference: 'Circular reference',
|
|
13
|
+
read_only: 'Read-only',
|
|
14
|
+
write_only: 'Write-only',
|
|
15
|
+
optional: 'Optional',
|
|
16
|
+
min: 'Min',
|
|
17
|
+
max: 'Max',
|
|
18
|
+
nullable: 'Nullable',
|
|
19
|
+
body: 'Body',
|
|
20
|
+
payload: 'Payload',
|
|
21
|
+
headers: 'Headers',
|
|
22
|
+
authorizations: 'Authorizations',
|
|
23
|
+
responses: 'Responses',
|
|
24
|
+
path_parameters: 'Path parameters',
|
|
25
|
+
query_parameters: 'Query parameters',
|
|
26
|
+
header_parameters: 'Header parameters',
|
|
27
|
+
attributes: 'Attributes',
|
|
28
|
+
test_it: 'Test it',
|
|
29
|
+
information: 'Information',
|
|
30
|
+
success: 'Success',
|
|
31
|
+
redirect: 'Redirect',
|
|
32
|
+
error: 'Error',
|
|
33
|
+
show: 'Show',
|
|
34
|
+
hide: 'Hide',
|
|
35
|
+
available_items: 'Available items',
|
|
36
|
+
child_attributes: 'Child attributes',
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const es: {
|
|
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
|
+
authorizations: string;
|
|
23
|
+
responses: string;
|
|
24
|
+
path_parameters: string;
|
|
25
|
+
query_parameters: string;
|
|
26
|
+
header_parameters: string;
|
|
27
|
+
attributes: string;
|
|
28
|
+
test_it: string;
|
|
29
|
+
information: string;
|
|
30
|
+
success: string;
|
|
31
|
+
redirect: string;
|
|
32
|
+
error: string;
|
|
33
|
+
show: string;
|
|
34
|
+
hide: string;
|
|
35
|
+
available_items: string;
|
|
36
|
+
child_attributes: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export var es = {
|
|
2
|
+
required: 'Requerido',
|
|
3
|
+
deprecated: 'Obsoleto',
|
|
4
|
+
deprecated_and_sunset_on: 'Esta operación está obsoleta y se retirará el ${1}.',
|
|
5
|
+
stability_experimental: 'Experimental',
|
|
6
|
+
stability_alpha: 'Alfa',
|
|
7
|
+
stability_beta: 'Beta',
|
|
8
|
+
copy_to_clipboard: 'Copiar al portapapeles',
|
|
9
|
+
copied: 'Copiado',
|
|
10
|
+
no_content: 'Sin contenido',
|
|
11
|
+
unresolved_reference: 'Referencia no resuelta',
|
|
12
|
+
circular_reference: 'Referencia circular',
|
|
13
|
+
read_only: 'Solo lectura',
|
|
14
|
+
write_only: 'Solo escritura',
|
|
15
|
+
optional: 'Opcional',
|
|
16
|
+
min: 'Mín',
|
|
17
|
+
max: 'Máx',
|
|
18
|
+
nullable: 'Nulo',
|
|
19
|
+
body: 'Cuerpo',
|
|
20
|
+
payload: 'Caga útil',
|
|
21
|
+
headers: 'Encabezados',
|
|
22
|
+
authorizations: 'Autorizaciones',
|
|
23
|
+
responses: 'Respuestas',
|
|
24
|
+
path_parameters: 'Parámetros de ruta',
|
|
25
|
+
query_parameters: 'Parámetros de consulta',
|
|
26
|
+
header_parameters: 'Parámetros de encabezado',
|
|
27
|
+
attributes: 'Atributos',
|
|
28
|
+
test_it: 'Pruébalo',
|
|
29
|
+
information: 'Información',
|
|
30
|
+
success: 'Éxito',
|
|
31
|
+
redirect: 'Redirección',
|
|
32
|
+
error: 'Error',
|
|
33
|
+
show: 'Mostrar',
|
|
34
|
+
hide: 'Ocultar',
|
|
35
|
+
available_items: 'Elementos disponibles',
|
|
36
|
+
child_attributes: 'Atributos secundarios',
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const fr: {
|
|
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
|
+
authorizations: string;
|
|
23
|
+
responses: string;
|
|
24
|
+
path_parameters: string;
|
|
25
|
+
query_parameters: string;
|
|
26
|
+
header_parameters: string;
|
|
27
|
+
attributes: string;
|
|
28
|
+
test_it: string;
|
|
29
|
+
information: string;
|
|
30
|
+
success: string;
|
|
31
|
+
redirect: string;
|
|
32
|
+
error: string;
|
|
33
|
+
show: string;
|
|
34
|
+
hide: string;
|
|
35
|
+
available_items: string;
|
|
36
|
+
child_attributes: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export var fr = {
|
|
2
|
+
required: 'Requis',
|
|
3
|
+
deprecated: 'Obsolète',
|
|
4
|
+
deprecated_and_sunset_on: 'Cette opération est obsolète et sera supprimée le ${1}.',
|
|
5
|
+
stability_experimental: 'Expérimental',
|
|
6
|
+
stability_alpha: 'Alpha',
|
|
7
|
+
stability_beta: 'Bêta',
|
|
8
|
+
copy_to_clipboard: 'Copier dans le presse-papiers',
|
|
9
|
+
copied: 'Copié',
|
|
10
|
+
no_content: 'Aucun contenu',
|
|
11
|
+
unresolved_reference: 'Référence non résolue',
|
|
12
|
+
circular_reference: 'Référence circulaire',
|
|
13
|
+
read_only: 'Lecture seule',
|
|
14
|
+
write_only: 'Écriture seule',
|
|
15
|
+
optional: 'Optionnel',
|
|
16
|
+
min: 'Min',
|
|
17
|
+
max: 'Max',
|
|
18
|
+
nullable: 'Nullable',
|
|
19
|
+
body: 'Corps',
|
|
20
|
+
payload: 'Charge utile',
|
|
21
|
+
headers: 'En-têtes',
|
|
22
|
+
authorizations: 'Autorisations',
|
|
23
|
+
responses: 'Réponses',
|
|
24
|
+
path_parameters: 'Paramètres de chemin',
|
|
25
|
+
query_parameters: 'Paramètres de requête',
|
|
26
|
+
header_parameters: 'Paramètres d’en-tête',
|
|
27
|
+
attributes: 'Attributs',
|
|
28
|
+
test_it: 'Tester',
|
|
29
|
+
information: 'Information',
|
|
30
|
+
success: 'Succès',
|
|
31
|
+
redirect: 'Redirection',
|
|
32
|
+
error: 'Erreur',
|
|
33
|
+
show: 'Afficher',
|
|
34
|
+
hide: 'Masquer',
|
|
35
|
+
available_items: 'Éléments disponibles',
|
|
36
|
+
child_attributes: 'Attributs enfants',
|
|
37
|
+
};
|