@syncbridge/common 2.0.1 → 2.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 +1 -1
- package/constants.d.ts +1 -1
- package/constants.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/models/metadata/variable-metadata.d.ts +3 -2
- package/models/metadata/variable-metadata.js +6 -4
- package/package.json +1 -1
- package/registry/docs-sidebar.d.ts +2 -1
- package/registry/localized-text.d.ts +28 -0
- package/registry/localized-text.js +49 -0
- package/registry/module-catalog.d.ts +2 -1
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ property's TypeScript type when not given. Some options:
|
|
|
117
117
|
|
|
118
118
|
| Option | Meaning |
|
|
119
119
|
| --- | --- |
|
|
120
|
-
| `label`, `description` | How it is shown |
|
|
120
|
+
| `label`, `description` | How it is shown: text, or text by language - `{ en: 'Port', tr: 'Bağlantı noktası' }` - shown in the reader's language in the server's UI and the Marketplace, else in English |
|
|
121
121
|
| `type` | `VariableType`: `String`, `Secret` (a password or key, kept encrypted in the profile), `Number`, `BigInt`, `Boolean`, `Enum`, `Nested` |
|
|
122
122
|
| `default`, `required` | Its default value, and whether it must be given |
|
|
123
123
|
| `enumValues` | The values of an enum |
|
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from './models-document.js';
|
|
|
26
26
|
export * from './registry/docs-sidebar.js';
|
|
27
27
|
export * from './registry/extension-package.js';
|
|
28
28
|
export * from './registry/extension-registry.js';
|
|
29
|
+
export * from './registry/localized-text.js';
|
|
29
30
|
export * from './registry/module-catalog.js';
|
|
30
31
|
export * from './registry/package-docs.js';
|
|
31
32
|
export * from './registry/package-manifest.js';
|
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from './models-document.js';
|
|
|
26
26
|
export * from './registry/docs-sidebar.js';
|
|
27
27
|
export * from './registry/extension-package.js';
|
|
28
28
|
export * from './registry/extension-registry.js';
|
|
29
|
+
export * from './registry/localized-text.js';
|
|
29
30
|
export * from './registry/module-catalog.js';
|
|
30
31
|
export * from './registry/package-docs.js';
|
|
31
32
|
export * from './registry/package-manifest.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedText } from '../../registry/localized-text.js';
|
|
1
2
|
import { EnumSource } from '../enums/enum-source.enum.js';
|
|
2
3
|
import { VariableFormat } from '../enums/variable-format.enum.js';
|
|
3
4
|
import { VariableType } from '../enums/variable-type.enum.js';
|
|
@@ -14,8 +15,8 @@ export declare class VariableMetadata {
|
|
|
14
15
|
ignored?: boolean;
|
|
15
16
|
index?: number;
|
|
16
17
|
hotPlug?: boolean;
|
|
17
|
-
label?:
|
|
18
|
-
description?:
|
|
18
|
+
label?: LocalizedText;
|
|
19
|
+
description?: LocalizedText;
|
|
19
20
|
examples?: string[];
|
|
20
21
|
choice?: string[];
|
|
21
22
|
type?: VariableType;
|
|
@@ -36,15 +36,17 @@ __decorate([
|
|
|
36
36
|
], VariableMetadata.prototype, "hotPlug", void 0);
|
|
37
37
|
__decorate([
|
|
38
38
|
ApiField({
|
|
39
|
-
description: '
|
|
39
|
+
description: "Its label: text, or text by language ({ en: '...', tr: '...' }) - shown in the server's UI and the Marketplace in the reader's language",
|
|
40
|
+
type: 'any',
|
|
40
41
|
}),
|
|
41
|
-
__metadata("design:type",
|
|
42
|
+
__metadata("design:type", Object)
|
|
42
43
|
], VariableMetadata.prototype, "label", void 0);
|
|
43
44
|
__decorate([
|
|
44
45
|
ApiField({
|
|
45
|
-
description: '
|
|
46
|
+
description: "What it is for: text, or text by language ({ en: '...', tr: '...' })",
|
|
47
|
+
type: 'any',
|
|
46
48
|
}),
|
|
47
|
-
__metadata("design:type",
|
|
49
|
+
__metadata("design:type", Object)
|
|
48
50
|
], VariableMetadata.prototype, "description", void 0);
|
|
49
51
|
__decorate([
|
|
50
52
|
ApiField({
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedText } from './localized-text.js';
|
|
1
2
|
/**
|
|
2
3
|
* How a package's documents are listed, where its author tells it: a
|
|
3
4
|
* sidebar.json in docs/ (the package's own) or in docs/<ClassName>/ (an
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
*/
|
|
22
23
|
export declare const SIDEBAR_FILE = "sidebar.json";
|
|
23
24
|
/** Text, or text by language: { "tr": "Ağ", "en": "Network" } */
|
|
24
|
-
export type SidebarText =
|
|
25
|
+
export type SidebarText = LocalizedText;
|
|
25
26
|
/** An item of a sidebar, as its author writes it */
|
|
26
27
|
export type SidebarItemSource = string | {
|
|
27
28
|
doc: string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text, or text by language: { en: 'Port number', tr: 'Port numarası' }.
|
|
3
|
+
* A text alone is in the package's docs language.
|
|
4
|
+
*/
|
|
5
|
+
export type LocalizedText = string | Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* A text in the language asked for: else in its base language ("pt" for
|
|
8
|
+
* "pt-BR"), else in English, else the first told; a text alone as it is
|
|
9
|
+
*/
|
|
10
|
+
export declare function textIn(text: LocalizedText | undefined, language: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* What is wrong with a text told by language: a key not a language, a
|
|
13
|
+
* text empty; a text alone, or none, is right
|
|
14
|
+
*/
|
|
15
|
+
export declare function localizedTextProblems(text: unknown, what: string): string[];
|
|
16
|
+
/** The settings of a definition: those of a group under it too */
|
|
17
|
+
interface VariableTexts {
|
|
18
|
+
label?: unknown;
|
|
19
|
+
description?: unknown;
|
|
20
|
+
variables?: Record<string, VariableTexts>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* What is wrong with the labels and descriptions of an app's, a
|
|
24
|
+
* component's or a plugin's settings, those in groups too: each by its
|
|
25
|
+
* path ("ClassName's tls.cert label")
|
|
26
|
+
*/
|
|
27
|
+
export declare function variableTextProblems(variables: Record<string, VariableTexts> | undefined, owner: string, at?: string): string[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isDocsLanguage } from './package-docs.js';
|
|
2
|
+
/**
|
|
3
|
+
* A text in the language asked for: else in its base language ("pt" for
|
|
4
|
+
* "pt-BR"), else in English, else the first told; a text alone as it is
|
|
5
|
+
*/
|
|
6
|
+
export function textIn(text, language) {
|
|
7
|
+
if (text === undefined || typeof text === 'string')
|
|
8
|
+
return text;
|
|
9
|
+
return (text[language] ??
|
|
10
|
+
text[language.split('-')[0]] ??
|
|
11
|
+
text.en ??
|
|
12
|
+
Object.values(text)[0]);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What is wrong with a text told by language: a key not a language, a
|
|
16
|
+
* text empty; a text alone, or none, is right
|
|
17
|
+
*/
|
|
18
|
+
export function localizedTextProblems(text, what) {
|
|
19
|
+
if (text === undefined || (typeof text === 'string' && text.trim()))
|
|
20
|
+
return [];
|
|
21
|
+
if (!text || typeof text !== 'object' || Array.isArray(text))
|
|
22
|
+
return [`${what} is text, or text by language: { en: '...', tr: '...' }`];
|
|
23
|
+
const entries = Object.entries(text);
|
|
24
|
+
if (!entries.length)
|
|
25
|
+
return [`${what} is text, or text by language: { en: '...', tr: '...' }`];
|
|
26
|
+
const problems = [];
|
|
27
|
+
for (const [language, value] of entries) {
|
|
28
|
+
if (!isDocsLanguage(language))
|
|
29
|
+
problems.push(`${what} is told in "${language}", not a language: en, tr, pt-BR...`);
|
|
30
|
+
else if (typeof value !== 'string' || !value.trim())
|
|
31
|
+
problems.push(`${what} in ${language} is empty`);
|
|
32
|
+
}
|
|
33
|
+
return problems;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What is wrong with the labels and descriptions of an app's, a
|
|
37
|
+
* component's or a plugin's settings, those in groups too: each by its
|
|
38
|
+
* path ("ClassName's tls.cert label")
|
|
39
|
+
*/
|
|
40
|
+
export function variableTextProblems(variables, owner, at = '') {
|
|
41
|
+
const problems = [];
|
|
42
|
+
for (const [key, v] of Object.entries(variables ?? {})) {
|
|
43
|
+
if (!v || typeof v !== 'object')
|
|
44
|
+
continue;
|
|
45
|
+
const path = at + key;
|
|
46
|
+
problems.push(...localizedTextProblems(v.label, `${owner}'s ${path} label`), ...localizedTextProblems(v.description, `${owner}'s ${path} description`), ...variableTextProblems(v.variables, owner, `${path}.`));
|
|
47
|
+
}
|
|
48
|
+
return problems;
|
|
49
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { LocalizedText } from './localized-text.js';
|
|
1
2
|
export declare const SUMMARY_MAX_LENGTH = 160;
|
|
2
3
|
export declare const SCREENSHOTS_MAX = 8;
|
|
3
4
|
/** A summary as told: one in the package's docs language, or one per language */
|
|
4
|
-
export type ModuleSummary =
|
|
5
|
+
export type ModuleSummary = LocalizedText;
|
|
5
6
|
/** What the Marketplace is told of a module, as its makers wrote it */
|
|
6
7
|
export interface ModuleCatalogInput {
|
|
7
8
|
className: string;
|