@smplkit/sdk 1.3.15 → 1.3.17

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/index.d.cts CHANGED
@@ -101,9 +101,13 @@ declare class Config {
101
101
  save(): Promise<void>;
102
102
  /**
103
103
  * Walk the parent chain and return config data objects, child-to-root.
104
+ *
105
+ * @param configs - Optional pre-fetched list of configs to look up parents
106
+ * by ID, avoiding extra network calls and the key-vs-UUID mismatch with
107
+ * {@link ConfigClient.get}.
104
108
  * @internal
105
109
  */
106
- _buildChain(): Promise<Array<{
110
+ _buildChain(configs?: Config[]): Promise<Array<{
107
111
  id: string;
108
112
  items: Record<string, unknown>;
109
113
  environments: Record<string, unknown>;
package/dist/index.d.ts CHANGED
@@ -101,9 +101,13 @@ declare class Config {
101
101
  save(): Promise<void>;
102
102
  /**
103
103
  * Walk the parent chain and return config data objects, child-to-root.
104
+ *
105
+ * @param configs - Optional pre-fetched list of configs to look up parents
106
+ * by ID, avoiding extra network calls and the key-vs-UUID mismatch with
107
+ * {@link ConfigClient.get}.
104
108
  * @internal
105
109
  */
106
- _buildChain(): Promise<Array<{
110
+ _buildChain(configs?: Config[]): Promise<Array<{
107
111
  id: string;
108
112
  items: Record<string, unknown>;
109
113
  environments: Record<string, unknown>;
package/dist/index.js CHANGED
@@ -195,13 +195,18 @@ var Config = class {
195
195
  }
196
196
  /**
197
197
  * Walk the parent chain and return config data objects, child-to-root.
198
+ *
199
+ * @param configs - Optional pre-fetched list of configs to look up parents
200
+ * by ID, avoiding extra network calls and the key-vs-UUID mismatch with
201
+ * {@link ConfigClient.get}.
198
202
  * @internal
199
203
  */
200
- async _buildChain() {
204
+ async _buildChain(configs) {
201
205
  const chain = [{ id: this.id ?? "", items: this.items, environments: this.environments }];
206
+ const configsById = new Map(configs?.map((c) => [c.id, c]) ?? []);
202
207
  let parentId = this.parent;
203
208
  while (parentId !== null) {
204
- const parentConfig = await this._client._getById(parentId);
209
+ const parentConfig = configsById.get(parentId) ?? await this._client._getById(parentId);
205
210
  chain.push({
206
211
  id: parentConfig.id ?? "",
207
212
  items: parentConfig.items,
@@ -632,7 +637,7 @@ var ConfigClient = class {
632
637
  const configs = await this.list();
633
638
  const newCache = {};
634
639
  for (const cfg of configs) {
635
- const chain = await cfg._buildChain();
640
+ const chain = await cfg._buildChain(configs);
636
641
  newCache[cfg.key] = resolveChain(chain, environment);
637
642
  }
638
643
  const oldCache = this._configCache;
@@ -652,7 +657,7 @@ var ConfigClient = class {
652
657
  const configs = await this.list();
653
658
  const cache = {};
654
659
  for (const cfg of configs) {
655
- const chain = await cfg._buildChain();
660
+ const chain = await cfg._buildChain(configs);
656
661
  cache[cfg.key] = resolveChain(chain, environment);
657
662
  }
658
663
  this._configCache = cache;
@@ -668,7 +673,7 @@ var ConfigClient = class {
668
673
  const configs = await this.list();
669
674
  const cache = {};
670
675
  for (const cfg of configs) {
671
- const chain = await cfg._buildChain();
676
+ const chain = await cfg._buildChain(configs);
672
677
  cache[cfg.key] = resolveChain(chain, environment);
673
678
  }
674
679
  this._configCache = cache;