@eide/foir-cli 0.5.8 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +32 -3
  2. 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) {
@@ -5213,12 +5226,13 @@ async function reconcileProfileSchema(client, manifest, summary) {
5213
5226
  });
5214
5227
  summary.profileSchemaUpdated = true;
5215
5228
  }
5216
- async function reconcileApiKeys(client, apiKeys, summary) {
5229
+ async function reconcileApiKeys(client, configKey, apiKeys, summary) {
5217
5230
  if (apiKeys.length === 0) return;
5218
5231
  const existing = await client.identity.listApiKeys({ limit: 200 });
5219
5232
  const existingByName = new Map(
5220
5233
  existing.items.map((k) => [k.name, k])
5221
5234
  );
5235
+ const newKeys = [];
5222
5236
  for (const key of apiKeys) {
5223
5237
  if (!key.name || !key.keyType || !key.envVar) continue;
5224
5238
  const existingKey = existingByName.get(key.name);
@@ -5250,6 +5264,21 @@ async function reconcileApiKeys(client, apiKeys, summary) {
5250
5264
  envVar: key.envVar,
5251
5265
  rawKey
5252
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);
5253
5282
  }
5254
5283
  }
5255
5284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.5.8",
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.10.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",