@eide/foir-cli 0.5.7 → 0.6.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/dist/cli.js +49 -5
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -978,7 +978,9 @@ function createIdentityMethods(client) {
|
|
|
978
978
|
id: params.id,
|
|
979
979
|
name: params.name,
|
|
980
980
|
isActive: params.isActive,
|
|
981
|
-
rateLimitPerHour: params.rateLimitPerHour
|
|
981
|
+
rateLimitPerHour: params.rateLimitPerHour,
|
|
982
|
+
scopes: params.scopes,
|
|
983
|
+
updateScopes: params.updateScopes
|
|
982
984
|
})
|
|
983
985
|
);
|
|
984
986
|
return { apiKey: resp.apiKey ?? null };
|
|
@@ -1911,7 +1913,8 @@ import {
|
|
|
1911
1913
|
ConfigDirection,
|
|
1912
1914
|
ListOperationsRequestSchema,
|
|
1913
1915
|
ApplyConfigRequestSchema,
|
|
1914
|
-
TriggerConfigSyncRequestSchema
|
|
1916
|
+
TriggerConfigSyncRequestSchema,
|
|
1917
|
+
WriteConfigCredentialRequestSchema
|
|
1915
1918
|
} from "@eide/foir-proto-ts/configs/v1/configs_pb";
|
|
1916
1919
|
import { ConfigDirection as ConfigDirection2 } from "@eide/foir-proto-ts/configs/v1/configs_pb";
|
|
1917
1920
|
var DIRECTION_TO_PROTO = {
|
|
@@ -2001,6 +2004,18 @@ function createConfigsMethods(client) {
|
|
|
2001
2004
|
webhookSecret: resp.webhookSecret ?? null
|
|
2002
2005
|
};
|
|
2003
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
|
+
},
|
|
2004
2019
|
async triggerConfigSync(configId) {
|
|
2005
2020
|
const resp = await client.triggerConfigSync(
|
|
2006
2021
|
create5(TriggerConfigSyncRequestSchema, { configId })
|
|
@@ -4882,7 +4897,7 @@ async function reconcileConfig(client, configId, manifest) {
|
|
|
4882
4897
|
await reconcileAuthProviders(client, manifest.authProviders ?? [], summary);
|
|
4883
4898
|
await reconcilePlacements(client, configId, manifest.placements ?? [], summary);
|
|
4884
4899
|
await reconcileProfileSchema(client, manifest, summary);
|
|
4885
|
-
await reconcileApiKeys(client, manifest.apiKeys ?? [], summary);
|
|
4900
|
+
await reconcileApiKeys(client, manifest.key, manifest.apiKeys ?? [], summary);
|
|
4886
4901
|
return summary;
|
|
4887
4902
|
}
|
|
4888
4903
|
async function reconcileModels(client, configId, models, summary) {
|
|
@@ -5211,15 +5226,29 @@ async function reconcileProfileSchema(client, manifest, summary) {
|
|
|
5211
5226
|
});
|
|
5212
5227
|
summary.profileSchemaUpdated = true;
|
|
5213
5228
|
}
|
|
5214
|
-
async function reconcileApiKeys(client, apiKeys, summary) {
|
|
5229
|
+
async function reconcileApiKeys(client, configKey, apiKeys, summary) {
|
|
5215
5230
|
if (apiKeys.length === 0) return;
|
|
5216
5231
|
const existing = await client.identity.listApiKeys({ limit: 200 });
|
|
5217
5232
|
const existingByName = new Map(
|
|
5218
5233
|
existing.items.map((k) => [k.name, k])
|
|
5219
5234
|
);
|
|
5235
|
+
const newKeys = [];
|
|
5220
5236
|
for (const key of apiKeys) {
|
|
5221
5237
|
if (!key.name || !key.keyType || !key.envVar) continue;
|
|
5222
|
-
|
|
5238
|
+
const existingKey = existingByName.get(key.name);
|
|
5239
|
+
if (existingKey) {
|
|
5240
|
+
const wantScopes = (key.scopes ?? []).slice().sort();
|
|
5241
|
+
const haveScopes = (existingKey.scopes ?? []).slice().sort();
|
|
5242
|
+
const scopesChanged = wantScopes.length !== haveScopes.length || wantScopes.some((s, i) => s !== haveScopes[i]);
|
|
5243
|
+
if (scopesChanged) {
|
|
5244
|
+
await client.identity.updateApiKey({
|
|
5245
|
+
id: existingKey.id,
|
|
5246
|
+
scopes: key.scopes ?? [],
|
|
5247
|
+
updateScopes: true
|
|
5248
|
+
});
|
|
5249
|
+
}
|
|
5250
|
+
continue;
|
|
5251
|
+
}
|
|
5223
5252
|
const result = await client.identity.createApiKey({
|
|
5224
5253
|
name: key.name,
|
|
5225
5254
|
keyType: key.keyType === "secret" ? 2 : 1,
|
|
@@ -5235,6 +5264,21 @@ async function reconcileApiKeys(client, apiKeys, summary) {
|
|
|
5235
5264
|
envVar: key.envVar,
|
|
5236
5265
|
rawKey
|
|
5237
5266
|
});
|
|
5267
|
+
newKeys.push({ name: key.name, rawKey });
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
if (newKeys.length > 0) {
|
|
5271
|
+
const credentialPayload = {};
|
|
5272
|
+
for (const k of newKeys) {
|
|
5273
|
+
credentialPayload.platformApiKey = k.rawKey;
|
|
5274
|
+
}
|
|
5275
|
+
try {
|
|
5276
|
+
await client.configs.writeConfigCredential({
|
|
5277
|
+
configKey,
|
|
5278
|
+
value: new TextEncoder().encode(JSON.stringify(credentialPayload))
|
|
5279
|
+
});
|
|
5280
|
+
} catch (err) {
|
|
5281
|
+
console.warn("Warning: could not write platformApiKey to config credentials:", err);
|
|
5238
5282
|
}
|
|
5239
5283
|
}
|
|
5240
5284
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eide/foir-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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",
|