@eide/foir-cli 0.5.8 → 0.6.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/dist/cli.js +43 -12
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1913,7 +1913,8 @@ import {
|
|
|
1913
1913
|
ConfigDirection,
|
|
1914
1914
|
ListOperationsRequestSchema,
|
|
1915
1915
|
ApplyConfigRequestSchema,
|
|
1916
|
-
TriggerConfigSyncRequestSchema
|
|
1916
|
+
TriggerConfigSyncRequestSchema,
|
|
1917
|
+
WriteConfigCredentialRequestSchema
|
|
1917
1918
|
} from "@eide/foir-proto-ts/configs/v1/configs_pb";
|
|
1918
1919
|
import { ConfigDirection as ConfigDirection2 } from "@eide/foir-proto-ts/configs/v1/configs_pb";
|
|
1919
1920
|
var DIRECTION_TO_PROTO = {
|
|
@@ -2003,6 +2004,18 @@ function createConfigsMethods(client) {
|
|
|
2003
2004
|
webhookSecret: resp.webhookSecret ?? null
|
|
2004
2005
|
};
|
|
2005
2006
|
},
|
|
2007
|
+
async writeConfigCredential(params) {
|
|
2008
|
+
const resp = await client.writeConfigCredential(
|
|
2009
|
+
create5(WriteConfigCredentialRequestSchema, {
|
|
2010
|
+
configKey: params.configKey,
|
|
2011
|
+
value: params.value
|
|
2012
|
+
})
|
|
2013
|
+
);
|
|
2014
|
+
return {
|
|
2015
|
+
encryptionKeyId: resp.encryptionKeyId,
|
|
2016
|
+
lastWrittenAt: resp.lastWrittenAt
|
|
2017
|
+
};
|
|
2018
|
+
},
|
|
2006
2019
|
async triggerConfigSync(configId) {
|
|
2007
2020
|
const resp = await client.triggerConfigSync(
|
|
2008
2021
|
create5(TriggerConfigSyncRequestSchema, { configId })
|
|
@@ -4884,7 +4897,7 @@ async function reconcileConfig(client, configId, manifest) {
|
|
|
4884
4897
|
await reconcileAuthProviders(client, manifest.authProviders ?? [], summary);
|
|
4885
4898
|
await reconcilePlacements(client, configId, manifest.placements ?? [], summary);
|
|
4886
4899
|
await reconcileProfileSchema(client, manifest, summary);
|
|
4887
|
-
await reconcileApiKeys(client, manifest.apiKeys ?? [], summary);
|
|
4900
|
+
await reconcileApiKeys(client, manifest.key, manifest.apiKeys ?? [], summary);
|
|
4888
4901
|
return summary;
|
|
4889
4902
|
}
|
|
4890
4903
|
async function reconcileModels(client, configId, models, summary) {
|
|
@@ -5188,15 +5201,17 @@ async function reconcilePlacements(client, configId, placements, summary) {
|
|
|
5188
5201
|
const currentConfigJson = config2.config ?? {};
|
|
5189
5202
|
const updatedConfig = {
|
|
5190
5203
|
...currentConfigJson,
|
|
5191
|
-
placements: placements.map((p) =>
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5204
|
+
placements: placements.map((p) => {
|
|
5205
|
+
const out = {};
|
|
5206
|
+
if (p.type !== void 0) out.type = p.type;
|
|
5207
|
+
if (p.url !== void 0) out.url = p.url;
|
|
5208
|
+
if (p.allowedOrigin !== void 0) out.allowedOrigin = p.allowedOrigin;
|
|
5209
|
+
if (p.height !== void 0) out.height = p.height;
|
|
5210
|
+
if (p.tabName !== void 0) out.tabName = p.tabName;
|
|
5211
|
+
if (p.hideContentTab !== void 0) out.hideContentTab = p.hideContentTab;
|
|
5212
|
+
if (p.modelKeys !== void 0) out.modelKeys = p.modelKeys;
|
|
5213
|
+
return out;
|
|
5214
|
+
})
|
|
5200
5215
|
};
|
|
5201
5216
|
await client.configs.updateConfig({
|
|
5202
5217
|
id: configId,
|
|
@@ -5213,12 +5228,13 @@ async function reconcileProfileSchema(client, manifest, summary) {
|
|
|
5213
5228
|
});
|
|
5214
5229
|
summary.profileSchemaUpdated = true;
|
|
5215
5230
|
}
|
|
5216
|
-
async function reconcileApiKeys(client, apiKeys, summary) {
|
|
5231
|
+
async function reconcileApiKeys(client, configKey, apiKeys, summary) {
|
|
5217
5232
|
if (apiKeys.length === 0) return;
|
|
5218
5233
|
const existing = await client.identity.listApiKeys({ limit: 200 });
|
|
5219
5234
|
const existingByName = new Map(
|
|
5220
5235
|
existing.items.map((k) => [k.name, k])
|
|
5221
5236
|
);
|
|
5237
|
+
const newKeys = [];
|
|
5222
5238
|
for (const key of apiKeys) {
|
|
5223
5239
|
if (!key.name || !key.keyType || !key.envVar) continue;
|
|
5224
5240
|
const existingKey = existingByName.get(key.name);
|
|
@@ -5250,6 +5266,21 @@ async function reconcileApiKeys(client, apiKeys, summary) {
|
|
|
5250
5266
|
envVar: key.envVar,
|
|
5251
5267
|
rawKey
|
|
5252
5268
|
});
|
|
5269
|
+
newKeys.push({ name: key.name, rawKey });
|
|
5270
|
+
}
|
|
5271
|
+
}
|
|
5272
|
+
if (newKeys.length > 0) {
|
|
5273
|
+
const credentialPayload = {};
|
|
5274
|
+
for (const k of newKeys) {
|
|
5275
|
+
credentialPayload.platformApiKey = k.rawKey;
|
|
5276
|
+
}
|
|
5277
|
+
try {
|
|
5278
|
+
await client.configs.writeConfigCredential({
|
|
5279
|
+
configKey,
|
|
5280
|
+
value: new TextEncoder().encode(JSON.stringify(credentialPayload))
|
|
5281
|
+
});
|
|
5282
|
+
} catch (err) {
|
|
5283
|
+
console.warn("Warning: could not write platformApiKey to config credentials:", err);
|
|
5253
5284
|
}
|
|
5254
5285
|
}
|
|
5255
5286
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eide/foir-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Universal platform CLI for Foir platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@bufbuild/protovalidate": "^1.1.1",
|
|
51
51
|
"@connectrpc/connect": "^2.0.0",
|
|
52
52
|
"@connectrpc/connect-node": "^2.0.0",
|
|
53
|
-
"@eide/foir-proto-ts": "^0.
|
|
53
|
+
"@eide/foir-proto-ts": "^0.11.0",
|
|
54
54
|
"chalk": "^5.3.0",
|
|
55
55
|
"commander": "^12.1.0",
|
|
56
56
|
"dotenv": "^16.4.5",
|