@tryvira/sdk 0.1.61 → 0.1.62

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/index.js +14 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -197,7 +197,20 @@ var ViraClient = class {
197
197
  );
198
198
  }
199
199
  async connectOnce(input) {
200
- const systemResult = await this.connectSystem(input);
200
+ let systemResult;
201
+ try {
202
+ systemResult = await this.connectSystem(input);
203
+ } catch (error) {
204
+ if (!(input.reuseExistingConnectionOnConflict !== false && error instanceof ViraApiError && error.status === 409)) throw error;
205
+ const listed = await this.listAISystems();
206
+ if (!listed) throw error;
207
+ const systems = Array.isArray(listed?.body?.systems) ? listed.body.systems : [];
208
+ const reused = systems.find(
209
+ (system) => String(system.name ?? "") === input.name && String(system.systemType ?? "") === input.systemType && String(system.organizationId ?? "") === input.organizationId && String(system.projectId ?? "") === input.projectId && String(system.environmentId ?? "") === input.environmentId
210
+ );
211
+ if (!reused) throw error;
212
+ systemResult = { status: listed.status, requestId: listed.requestId, body: { system: reused } };
213
+ }
201
214
  if (!systemResult) return null;
202
215
  const systemId = String(systemResult.body.system.id ?? "");
203
216
  required(systemId, "SDK_SYSTEM_ID_MISSING");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/sdk",
3
- "version": "0.1.61",
3
+ "version": "0.1.62",
4
4
  "description": "Typed Vira SDK for connect-once, observation and governed runtime execution.",
5
5
  "keywords": ["vira", "ai-governance", "ai-runtime", "semantic-routing"],
6
6
  "engines": {"node": ">=20"},