@ultrst-armada/kloks 1.22.0 → 1.22.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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "packageName": "@ultrst-armada/kloks",
4
- "version": "1.22.0",
5
- "sourceCommit": "bd97df4894947954e6ac60ddd7418065c5c453ea",
4
+ "version": "1.22.1",
5
+ "sourceCommit": "5b69ae1bba83c72c0b44bc8492928a805948872a",
6
6
  "releaseWorkflow": "npm Release",
7
- "workflowRunId": "41088213772"
7
+ "workflowRunId": "41112820841"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/kloks",
3
- "version": "1.22.0",
3
+ "version": "1.22.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -55,14 +55,6 @@ import {
55
55
  useBackend,
56
56
  useBackendClient
57
57
  } from "./chunk-N7OUR5R5.js";
58
- import {
59
- AuditLogger,
60
- ControlPlaneManager,
61
- DatabaseClusterManager,
62
- detectDatabaseEngine,
63
- getSystemDatabaseUrls,
64
- resolveSystemDatabaseClusterNodes
65
- } from "./chunk-RCCQ7IRM.js";
66
58
  import {
67
59
  BackendRegistry,
68
60
  ConcurrencyConflictError,
@@ -87,6 +79,14 @@ import {
87
79
  WebSocketTransport,
88
80
  createBackendClient
89
81
  } from "./chunk-NIP22V2G.js";
82
+ import {
83
+ AuditLogger,
84
+ ControlPlaneManager,
85
+ DatabaseClusterManager,
86
+ detectDatabaseEngine,
87
+ getSystemDatabaseUrls,
88
+ resolveSystemDatabaseClusterNodes
89
+ } from "./chunk-RCCQ7IRM.js";
90
90
  import {
91
91
  AgentHarnessRuntime,
92
92
  AgentHarnessServiceDefinition,
@@ -336,6 +336,7 @@ interface SrklAccountManifest {
336
336
  appName?: string;
337
337
  categories?: EcosystemServiceCategory[];
338
338
  requiredServices?: string[];
339
+ includeCredentials?: boolean;
339
340
  }
340
341
  interface SrklAccountClientOptions {
341
342
  baseUrl: string;
@@ -354,10 +355,15 @@ declare class SrklAccountClient {
354
355
  private readonly baseUrl;
355
356
  private readonly userId;
356
357
  private readonly appId;
358
+ private cachedAccounts;
357
359
  constructor(options: SrklAccountClientOptions);
358
360
  sync(manifest?: SrklAccountManifest): Promise<SrklAccountSyncResult>;
359
361
  list(manifest?: SrklAccountManifest): Promise<SrklAccountSyncResult>;
360
- getByService(serviceId: string): Promise<SrklAccount | undefined>;
362
+ getCachedAccounts(): SrklAccount[];
363
+ getCachedByService(serviceId: string): SrklAccount | undefined;
364
+ getByService(serviceId: string, options?: {
365
+ forceSync?: boolean;
366
+ }): Promise<SrklAccount | undefined>;
361
367
  }
362
368
  declare function createSrklAccountClient(options: SrklAccountClientOptions): SrklAccountClient;
363
369
  declare function mergeSrklAccounts<T extends {
@@ -2607,6 +2607,7 @@ var SrklAccountClient = class {
2607
2607
  baseUrl;
2608
2608
  userId;
2609
2609
  appId;
2610
+ cachedAccounts = [];
2610
2611
  constructor(options) {
2611
2612
  this.fetchImpl = options.fetchImpl || fetch;
2612
2613
  this.baseUrl = options.baseUrl.replace(/\/+$/, "");
@@ -2614,6 +2615,11 @@ var SrklAccountClient = class {
2614
2615
  this.appId = options.appId;
2615
2616
  }
2616
2617
  async sync(manifest = {}) {
2618
+ const payload = {
2619
+ ...manifest,
2620
+ appId: manifest.appId || this.appId,
2621
+ includeCredentials: manifest.includeCredentials ?? true
2622
+ };
2617
2623
  const response = await this.fetchImpl(`${this.baseUrl}/api/ecosystem/accounts`, {
2618
2624
  method: "POST",
2619
2625
  headers: {
@@ -2621,16 +2627,33 @@ var SrklAccountClient = class {
2621
2627
  "x-user-id": this.userId,
2622
2628
  "x-app-id": this.appId
2623
2629
  },
2624
- body: JSON.stringify({ ...manifest, appId: manifest.appId || this.appId })
2630
+ body: JSON.stringify(payload)
2625
2631
  });
2626
2632
  if (!response.ok) throw new Error(`SRKL account sync failed: ${response.status}`);
2627
- return response.json();
2633
+ const result = await response.json();
2634
+ this.cachedAccounts = result.accounts || [];
2635
+ return result;
2628
2636
  }
2629
2637
  async list(manifest = {}) {
2630
- return this.sync(manifest);
2638
+ return this.sync({
2639
+ ...manifest,
2640
+ includeCredentials: manifest.includeCredentials ?? false
2641
+ });
2631
2642
  }
2632
- async getByService(serviceId) {
2633
- const result = await this.sync({ requiredServices: [serviceId] });
2643
+ getCachedAccounts() {
2644
+ return this.cachedAccounts;
2645
+ }
2646
+ getCachedByService(serviceId) {
2647
+ return this.cachedAccounts.find(
2648
+ (account) => account.serviceId.toLowerCase() === serviceId.toLowerCase() || account.provider.toLowerCase() === serviceId.toLowerCase()
2649
+ );
2650
+ }
2651
+ async getByService(serviceId, options) {
2652
+ if (!options?.forceSync) {
2653
+ const cached = this.getCachedByService(serviceId);
2654
+ if (cached) return cached;
2655
+ }
2656
+ const result = await this.sync({ requiredServices: [serviceId], includeCredentials: true });
2634
2657
  return result.accounts.find(
2635
2658
  (account) => account.serviceId.toLowerCase() === serviceId.toLowerCase() || account.provider.toLowerCase() === serviceId.toLowerCase()
2636
2659
  );