@alacard-project/config-sdk 1.0.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/.idea/workspace.xml +45 -0
- package/README.md +107 -0
- package/dist/config-client.d.ts +33 -0
- package/dist/config-client.js +172 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/proto/config.d.ts +116 -0
- package/dist/proto/config.js +624 -0
- package/dist/types/types.d.ts +11 -0
- package/dist/types/types.js +2 -0
- package/dist/vault-client.d.ts +21 -0
- package/dist/vault-client.js +72 -0
- package/package.json +25 -0
- package/proto/config.proto +39 -0
- package/src/config-client.ts +180 -0
- package/src/index.ts +1 -0
- package/src/proto/config.ts +835 -0
- package/src/types/types.ts +12 -0
- package/src/vault-client.ts +84 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<list default="true" id="d6ddd62d-b258-48c7-8ac2-ae28e47081ad" name="Changes" comment="" />
|
|
5
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
6
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
7
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
8
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
9
|
+
</component>
|
|
10
|
+
<component name="MarkdownSettingsMigration">
|
|
11
|
+
<option name="stateVersion" value="1" />
|
|
12
|
+
</component>
|
|
13
|
+
<component name="ProjectId" id="38cLw1hfbaQQ7IG2qhtRfg4zBzC" />
|
|
14
|
+
<component name="ProjectViewState">
|
|
15
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
16
|
+
<option name="showLibraryContents" value="true" />
|
|
17
|
+
</component>
|
|
18
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
19
|
+
"keyToString": {
|
|
20
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
21
|
+
"WebServerToolWindowFactoryState": "false",
|
|
22
|
+
"node.js.detected.package.eslint": "true",
|
|
23
|
+
"node.js.detected.package.tslint": "true",
|
|
24
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
25
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
26
|
+
"nodejs_package_manager_path": "npm",
|
|
27
|
+
"vue.rearranger.settings.migration": "true"
|
|
28
|
+
}
|
|
29
|
+
}]]></component>
|
|
30
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
31
|
+
<component name="TaskManager">
|
|
32
|
+
<task active="true" id="Default" summary="Default task">
|
|
33
|
+
<changelist id="d6ddd62d-b258-48c7-8ac2-ae28e47081ad" name="Changes" comment="" />
|
|
34
|
+
<created>1769094147893</created>
|
|
35
|
+
<option name="number" value="Default" />
|
|
36
|
+
<option name="presentableId" value="Default" />
|
|
37
|
+
<updated>1769094147893</updated>
|
|
38
|
+
<workItem from="1769094150802" duration="320000" />
|
|
39
|
+
</task>
|
|
40
|
+
<servers />
|
|
41
|
+
</component>
|
|
42
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
43
|
+
<option name="version" value="3" />
|
|
44
|
+
</component>
|
|
45
|
+
</project>
|
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @alacard/config-sdk
|
|
2
|
+
|
|
3
|
+
**Alacard Config SDK** — это клиентская библиотека для взаимодействия с централизованным микросервисом конфигураций (CCS) через gRPC. SDK обеспечивает строго типизированный доступ к настройкам, поддерживает горячую перезагрузку через Kafka и имеет встроенный fallback на `.env` файлы.
|
|
4
|
+
|
|
5
|
+
## Основные возможности
|
|
6
|
+
|
|
7
|
+
- 🚀 **gRPC-First**: Высокая производительность и низкая задержка при получении конфигураций.
|
|
8
|
+
- 🛡️ **Строгая типизация**: Автоматическая генерация TypeScript-интерфейсов из Protocol Buffers (`ts-proto`).
|
|
9
|
+
- ⚡ **Hot-Reloading**: Мгновенное обновление параметров в памяти приложения при изменении в базе (через Kafka).
|
|
10
|
+
- 📂 **.env Fallback**: Поддержка локальных `.env.<environment>` файлов для разработки и как резервный вариант.
|
|
11
|
+
- 🏗️ **Instance-based**: Поддержка нескольких экземпляров клиента в одном процессе (подготовлено для сложной архитектуры 2026 года).
|
|
12
|
+
|
|
13
|
+
## Установка
|
|
14
|
+
|
|
15
|
+
Так как пакет является приватным, убедитесь, что ваш `.npmrc` настроен для доступа к соответствующему реестру.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @alacard/config-sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Быстрый старт
|
|
22
|
+
|
|
23
|
+
### Инициализация
|
|
24
|
+
|
|
25
|
+
Инициализируйте клиент при запуске вашего приложения (например, в `main.ts` или `bootstrap.ts`):
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { ConfigClient } from '@alacard/config-sdk';
|
|
29
|
+
|
|
30
|
+
async function bootstrap() {
|
|
31
|
+
const config = await ConfigClient.initialize({
|
|
32
|
+
serviceName: 'auth-service',
|
|
33
|
+
environment: process.env.NODE_ENV || 'development',
|
|
34
|
+
grpcUrl: process.env.GRPC_CONFIG_URL || 'localhost:50055',
|
|
35
|
+
internalKey: process.env.INTERNAL_CONFIG_KEY, // Ключ для ConfigGrpcGuard
|
|
36
|
+
|
|
37
|
+
// Опционально: Интеграция с Vault (KV + PKI)
|
|
38
|
+
vault: {
|
|
39
|
+
address: 'https://vault.prod.alacard.local:8200',
|
|
40
|
+
roleId: process.env.VAULT_ROLE_ID!,
|
|
41
|
+
secretId: process.env.VAULT_SECRET_ID!,
|
|
42
|
+
pkiPath: 'pki/issue/config-service', // Путь для динамических сертификатов
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// Опционально: Ручная настройка mTLS (если не используется Vault PKI)
|
|
46
|
+
/*
|
|
47
|
+
tls: {
|
|
48
|
+
rootCert: fs.readFileSync('./certs/ca.crt'),
|
|
49
|
+
clientCert: fs.readFileSync('./certs/client.crt'),
|
|
50
|
+
clientKey: fs.readFileSync('./certs/client.key'),
|
|
51
|
+
},
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
kafkaBrokers: ['localhost:9092'],
|
|
55
|
+
useDotenvFallback: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const dbUrl = config.get('DATABASE_URL');
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Как это работает (Порядок загрузки)
|
|
63
|
+
|
|
64
|
+
1. **.env Fallback**: SDK пробует прочитать локальный `.env.<env>` файл (если `useDotenvFallback: true`).
|
|
65
|
+
2. **Vault KV**: Если настроен `vault`, SDK логинится через AppRole и забирает секреты из `secret/data/config-service/<serviceName>`.
|
|
66
|
+
3. **Vault PKI (mTLS)**: Если в `vault` указан `pkiPath`, SDK получает динамические сертификаты для защиты gRPC соединения.
|
|
67
|
+
4. **gRPC Config Service**: SDK запрашивает финальный конфиг через зашифрованное соединение с микросервиса конфигураций.
|
|
68
|
+
5. **Kafka Watch**: Запускается подписка на изменения для обновления параметров "на лету".
|
|
69
|
+
|
|
70
|
+
// Получение настроек
|
|
71
|
+
const port = config.getInt('PORT', 3000);
|
|
72
|
+
const dbUrl = config.get('DATABASE_URL');
|
|
73
|
+
|
|
74
|
+
console.log(`Сервис запущен на порту ${port}`);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Использование в других частях кода
|
|
79
|
+
|
|
80
|
+
После инициализации вы можете получить доступ к инстансу в любом месте приложения:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { ConfigClient } from '@alacard/config-sdk';
|
|
84
|
+
|
|
85
|
+
const config = ConfigClient.getInstance();
|
|
86
|
+
const apiKey = config.get('EXTERNAL_API_KEY');
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Доступные методы
|
|
90
|
+
|
|
91
|
+
- `get(key: string, defaultValue?: string): string` — получить строковое значение.
|
|
92
|
+
- `getInt(key: string, defaultValue?: number): number` — получить целое число.
|
|
93
|
+
- `getAll(): Record<string, string>` — получить все загруженные настройки.
|
|
94
|
+
|
|
95
|
+
## Команды для разработки
|
|
96
|
+
|
|
97
|
+
Если вы вносите правки в сам SDK:
|
|
98
|
+
|
|
99
|
+
- `npm run gen:proto` — перегенерировать TypeScript-код из `.proto` файлов.
|
|
100
|
+
- `npm run build` — скомпилировать TypeScript в JavaScript для публикации.
|
|
101
|
+
|
|
102
|
+
## Структура конфигурации (gRPC)
|
|
103
|
+
|
|
104
|
+
SDK использует `config.proto` для связи. Запросы отправляются методом `GetConfig`, включая `serviceName`, `environment` и `version`.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
© 2026 Alacard Team
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { VaultOptions } from './vault-client';
|
|
2
|
+
export { VaultOptions };
|
|
3
|
+
export interface ConfigOptions {
|
|
4
|
+
serviceName: string;
|
|
5
|
+
environment: string;
|
|
6
|
+
grpcUrl: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
kafkaBrokers?: string[];
|
|
9
|
+
useDotenvFallback?: boolean;
|
|
10
|
+
internalKey?: string;
|
|
11
|
+
tls?: {
|
|
12
|
+
rootCert: Buffer;
|
|
13
|
+
clientCert: Buffer;
|
|
14
|
+
clientKey: Buffer;
|
|
15
|
+
};
|
|
16
|
+
vault?: VaultOptions;
|
|
17
|
+
}
|
|
18
|
+
export declare class ConfigClient {
|
|
19
|
+
private configMap;
|
|
20
|
+
private consumer;
|
|
21
|
+
private options;
|
|
22
|
+
private vaultClient;
|
|
23
|
+
private static instance;
|
|
24
|
+
constructor(options: ConfigOptions);
|
|
25
|
+
static initialize(options: ConfigOptions): Promise<ConfigClient>;
|
|
26
|
+
static getInstance(): ConfigClient;
|
|
27
|
+
private init;
|
|
28
|
+
private fetchRemoteConfig;
|
|
29
|
+
private startWatching;
|
|
30
|
+
get(key: string, defaultValue?: string): string;
|
|
31
|
+
getInt(key: string, defaultValue?: number): number;
|
|
32
|
+
getAll(): Record<string, string>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConfigClient = void 0;
|
|
37
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
38
|
+
const kafkajs_1 = require("kafkajs");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const dotenv = __importStar(require("dotenv"));
|
|
41
|
+
const config_1 = require("./proto/config");
|
|
42
|
+
const vault_client_1 = require("./vault-client");
|
|
43
|
+
class ConfigClient {
|
|
44
|
+
configMap = {};
|
|
45
|
+
consumer = null;
|
|
46
|
+
options;
|
|
47
|
+
vaultClient = null;
|
|
48
|
+
static instance = null;
|
|
49
|
+
constructor(options) {
|
|
50
|
+
this.options = options;
|
|
51
|
+
}
|
|
52
|
+
static async initialize(options) {
|
|
53
|
+
const client = new ConfigClient(options);
|
|
54
|
+
await client.init();
|
|
55
|
+
this.instance = client;
|
|
56
|
+
return client;
|
|
57
|
+
}
|
|
58
|
+
static getInstance() {
|
|
59
|
+
if (!this.instance) {
|
|
60
|
+
throw new Error('[ConfigSDK] ConfigClient not initialized. Call initialize() first.');
|
|
61
|
+
}
|
|
62
|
+
return this.instance;
|
|
63
|
+
}
|
|
64
|
+
async init() {
|
|
65
|
+
const { serviceName, environment, grpcUrl, version = 'v1', useDotenvFallback = true } = this.options;
|
|
66
|
+
try {
|
|
67
|
+
// 1. Fallback to .env
|
|
68
|
+
if (useDotenvFallback) {
|
|
69
|
+
const envFile = `.env.${environment}`;
|
|
70
|
+
dotenv.config({ path: path.resolve(process.cwd(), envFile) });
|
|
71
|
+
const ALLOWED_ENV_PREFIXES = ['APP_', 'KAFKA_', 'DB_', 'REDIS_', 'GRPC_', 'PORT', 'NODE_ENV'];
|
|
72
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
73
|
+
if (value && ALLOWED_ENV_PREFIXES.some(prefix => key.startsWith(prefix))) {
|
|
74
|
+
this.configMap[key] = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// 2. Load from Vault (KV)
|
|
79
|
+
if (this.options.vault) {
|
|
80
|
+
this.vaultClient = new vault_client_1.VaultClient(this.options.vault);
|
|
81
|
+
const vaultSecrets = await this.vaultClient.getKVSecrets(`config-service/${serviceName}`);
|
|
82
|
+
Object.assign(this.configMap, vaultSecrets);
|
|
83
|
+
console.log(`[ConfigSDK] Loaded secrets from Vault KV for ${serviceName}`);
|
|
84
|
+
// 3. Issue mTLS Certificates from Vault PKI if enabled
|
|
85
|
+
if (this.options.vault.pkiPath && !this.options.tls) {
|
|
86
|
+
const certs = await this.vaultClient.issueCertificate(serviceName);
|
|
87
|
+
this.options.tls = {
|
|
88
|
+
rootCert: Buffer.from(certs.ca),
|
|
89
|
+
clientCert: Buffer.from(certs.certificate),
|
|
90
|
+
clientKey: Buffer.from(certs.privateKey),
|
|
91
|
+
};
|
|
92
|
+
console.log(`[ConfigSDK] Dynamic mTLS certificate issued from Vault PKI`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// 4. Fetch additional config via gRPC
|
|
96
|
+
await this.fetchRemoteConfig(serviceName, environment, grpcUrl, version);
|
|
97
|
+
// 5. Start watching for changes via Kafka
|
|
98
|
+
if (this.options.kafkaBrokers && this.options.kafkaBrokers.length > 0) {
|
|
99
|
+
await this.startWatching();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error(`[ConfigSDK] Initialization failed: ${error.message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async fetchRemoteConfig(serviceName, environment, grpcUrl, version) {
|
|
107
|
+
let credentials = grpc.credentials.createInsecure();
|
|
108
|
+
if (this.options.tls) {
|
|
109
|
+
credentials = grpc.credentials.createSsl(this.options.tls.rootCert, this.options.tls.clientKey, this.options.tls.clientCert);
|
|
110
|
+
}
|
|
111
|
+
const client = new config_1.ConfigServiceClient(grpcUrl, credentials);
|
|
112
|
+
return new Promise((resolve) => {
|
|
113
|
+
const request = { serviceName, environment, version };
|
|
114
|
+
const metadata = new grpc.Metadata();
|
|
115
|
+
if (this.options.internalKey) {
|
|
116
|
+
metadata.set('x-internal-key', this.options.internalKey);
|
|
117
|
+
}
|
|
118
|
+
client.getConfig(request, metadata, (error, response) => {
|
|
119
|
+
if (error) {
|
|
120
|
+
console.warn(`[ConfigSDK] Failed to fetch remote config from gRPC: ${error.message}. Using local/Vault fallback.`);
|
|
121
|
+
return resolve();
|
|
122
|
+
}
|
|
123
|
+
if (response && response.values) {
|
|
124
|
+
Object.assign(this.configMap, response.values);
|
|
125
|
+
console.log(`[ConfigSDK] Remote config loaded for ${serviceName} (${environment}, ${version})`);
|
|
126
|
+
}
|
|
127
|
+
resolve();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async startWatching() {
|
|
132
|
+
if (this.consumer)
|
|
133
|
+
return;
|
|
134
|
+
try {
|
|
135
|
+
const kafka = new kafkajs_1.Kafka({
|
|
136
|
+
clientId: `config-sdk-${this.options.serviceName}`,
|
|
137
|
+
brokers: this.options.kafkaBrokers,
|
|
138
|
+
});
|
|
139
|
+
const groupId = `config-watch-${this.options.serviceName}-${this.options.environment}`;
|
|
140
|
+
this.consumer = kafka.consumer({ groupId });
|
|
141
|
+
await this.consumer.connect();
|
|
142
|
+
await this.consumer.subscribe({ topic: 'config.updated', fromBeginning: false });
|
|
143
|
+
await this.consumer.run({
|
|
144
|
+
eachMessage: async ({ message }) => {
|
|
145
|
+
if (!message.value)
|
|
146
|
+
return;
|
|
147
|
+
const event = JSON.parse(message.value.toString());
|
|
148
|
+
if (event.service === 'global' || event.service === this.options.serviceName) {
|
|
149
|
+
if (event.environment === this.options.environment && event.version === (this.options.version || 'v1')) {
|
|
150
|
+
console.log(`[ConfigSDK] Hot-reload: ${event.key} updated`);
|
|
151
|
+
this.configMap[event.key] = event.value;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.error(`[ConfigSDK] Watch mode failed: ${error.message}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
get(key, defaultValue = '') {
|
|
162
|
+
return this.configMap[key] || defaultValue;
|
|
163
|
+
}
|
|
164
|
+
getInt(key, defaultValue = 0) {
|
|
165
|
+
const val = this.get(key);
|
|
166
|
+
return val ? parseInt(val, 10) : defaultValue;
|
|
167
|
+
}
|
|
168
|
+
getAll() {
|
|
169
|
+
return { ...this.configMap };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.ConfigClient = ConfigClient;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config-client';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config-client"), exports);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
+
import { type CallOptions, type ChannelCredentials, Client, type ClientOptions, type ClientUnaryCall, type handleUnaryCall, type Metadata, type ServiceError, type UntypedServiceImplementation } from "@grpc/grpc-js";
|
|
3
|
+
export interface GetConfigRequest {
|
|
4
|
+
serviceName: string;
|
|
5
|
+
environment: string;
|
|
6
|
+
version: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ConfigResponse {
|
|
9
|
+
values: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface ConfigResponse_ValuesEntry {
|
|
14
|
+
key: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SetConfigRequest {
|
|
18
|
+
serviceName: string;
|
|
19
|
+
environment: string;
|
|
20
|
+
key: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ListConfigsRequest {
|
|
24
|
+
environment: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ServiceConfig {
|
|
27
|
+
serviceName: string;
|
|
28
|
+
values: {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface ServiceConfig_ValuesEntry {
|
|
33
|
+
key: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ListConfigsResponse {
|
|
37
|
+
configs: ServiceConfig[];
|
|
38
|
+
}
|
|
39
|
+
export declare const GetConfigRequest: MessageFns<GetConfigRequest>;
|
|
40
|
+
export declare const ConfigResponse: MessageFns<ConfigResponse>;
|
|
41
|
+
export declare const ConfigResponse_ValuesEntry: MessageFns<ConfigResponse_ValuesEntry>;
|
|
42
|
+
export declare const SetConfigRequest: MessageFns<SetConfigRequest>;
|
|
43
|
+
export declare const ListConfigsRequest: MessageFns<ListConfigsRequest>;
|
|
44
|
+
export declare const ServiceConfig: MessageFns<ServiceConfig>;
|
|
45
|
+
export declare const ServiceConfig_ValuesEntry: MessageFns<ServiceConfig_ValuesEntry>;
|
|
46
|
+
export declare const ListConfigsResponse: MessageFns<ListConfigsResponse>;
|
|
47
|
+
export type ConfigServiceService = typeof ConfigServiceService;
|
|
48
|
+
export declare const ConfigServiceService: {
|
|
49
|
+
readonly getConfig: {
|
|
50
|
+
readonly path: "/config.ConfigService/GetConfig";
|
|
51
|
+
readonly requestStream: false;
|
|
52
|
+
readonly responseStream: false;
|
|
53
|
+
readonly requestSerialize: (value: GetConfigRequest) => Buffer;
|
|
54
|
+
readonly requestDeserialize: (value: Buffer) => GetConfigRequest;
|
|
55
|
+
readonly responseSerialize: (value: ConfigResponse) => Buffer;
|
|
56
|
+
readonly responseDeserialize: (value: Buffer) => ConfigResponse;
|
|
57
|
+
};
|
|
58
|
+
readonly setConfig: {
|
|
59
|
+
readonly path: "/config.ConfigService/SetConfig";
|
|
60
|
+
readonly requestStream: false;
|
|
61
|
+
readonly responseStream: false;
|
|
62
|
+
readonly requestSerialize: (value: SetConfigRequest) => Buffer;
|
|
63
|
+
readonly requestDeserialize: (value: Buffer) => SetConfigRequest;
|
|
64
|
+
readonly responseSerialize: (value: ConfigResponse) => Buffer;
|
|
65
|
+
readonly responseDeserialize: (value: Buffer) => ConfigResponse;
|
|
66
|
+
};
|
|
67
|
+
readonly listConfigs: {
|
|
68
|
+
readonly path: "/config.ConfigService/ListConfigs";
|
|
69
|
+
readonly requestStream: false;
|
|
70
|
+
readonly responseStream: false;
|
|
71
|
+
readonly requestSerialize: (value: ListConfigsRequest) => Buffer;
|
|
72
|
+
readonly requestDeserialize: (value: Buffer) => ListConfigsRequest;
|
|
73
|
+
readonly responseSerialize: (value: ListConfigsResponse) => Buffer;
|
|
74
|
+
readonly responseDeserialize: (value: Buffer) => ListConfigsResponse;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export interface ConfigServiceServer extends UntypedServiceImplementation {
|
|
78
|
+
getConfig: handleUnaryCall<GetConfigRequest, ConfigResponse>;
|
|
79
|
+
setConfig: handleUnaryCall<SetConfigRequest, ConfigResponse>;
|
|
80
|
+
listConfigs: handleUnaryCall<ListConfigsRequest, ListConfigsResponse>;
|
|
81
|
+
}
|
|
82
|
+
export interface ConfigServiceClient extends Client {
|
|
83
|
+
getConfig(request: GetConfigRequest, callback: (error: ServiceError | null, response: ConfigResponse) => void): ClientUnaryCall;
|
|
84
|
+
getConfig(request: GetConfigRequest, metadata: Metadata, callback: (error: ServiceError | null, response: ConfigResponse) => void): ClientUnaryCall;
|
|
85
|
+
getConfig(request: GetConfigRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ConfigResponse) => void): ClientUnaryCall;
|
|
86
|
+
setConfig(request: SetConfigRequest, callback: (error: ServiceError | null, response: ConfigResponse) => void): ClientUnaryCall;
|
|
87
|
+
setConfig(request: SetConfigRequest, metadata: Metadata, callback: (error: ServiceError | null, response: ConfigResponse) => void): ClientUnaryCall;
|
|
88
|
+
setConfig(request: SetConfigRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ConfigResponse) => void): ClientUnaryCall;
|
|
89
|
+
listConfigs(request: ListConfigsRequest, callback: (error: ServiceError | null, response: ListConfigsResponse) => void): ClientUnaryCall;
|
|
90
|
+
listConfigs(request: ListConfigsRequest, metadata: Metadata, callback: (error: ServiceError | null, response: ListConfigsResponse) => void): ClientUnaryCall;
|
|
91
|
+
listConfigs(request: ListConfigsRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ListConfigsResponse) => void): ClientUnaryCall;
|
|
92
|
+
}
|
|
93
|
+
export declare const ConfigServiceClient: {
|
|
94
|
+
new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): ConfigServiceClient;
|
|
95
|
+
service: typeof ConfigServiceService;
|
|
96
|
+
serviceName: string;
|
|
97
|
+
};
|
|
98
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
99
|
+
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
100
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
101
|
+
} : Partial<T>;
|
|
102
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
103
|
+
type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
104
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
105
|
+
} & {
|
|
106
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
107
|
+
};
|
|
108
|
+
interface MessageFns<T> {
|
|
109
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
110
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
111
|
+
fromJSON(object: any): T;
|
|
112
|
+
toJSON(message: T): unknown;
|
|
113
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
114
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
115
|
+
}
|
|
116
|
+
export {};
|