@ai-matrx/vault 0.1.37 → 0.1.38

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.js CHANGED
@@ -9594,6 +9594,8 @@ function createApiVaultPort(hostApi, options = {}) {
9594
9594
  const sharedP = retrying(() => account9.sharedWithMe(api));
9595
9595
  const quiet = (p) => void p.catch(() => void 0);
9596
9596
  [catalogP, authP, userP, sharedP].forEach(quiet);
9597
+ const orgItemsP = retrying(() => account9.organizationItems(api));
9598
+ quiet(orgItemsP);
9597
9599
  const raw = {
9598
9600
  orgLists: [],
9599
9601
  orgsKnown: options.organizations !== void 0,
@@ -9641,6 +9643,26 @@ function createApiVaultPort(hostApi, options = {}) {
9641
9643
  raw.orgLists = orgs.map(() => void 0);
9642
9644
  raw.orgsKnown = true;
9643
9645
  progress();
9646
+ const one = await orgItemsP.then(
9647
+ (r) => r,
9648
+ (e) => {
9649
+ if (e?.status === 404) return null;
9650
+ return "failed";
9651
+ }
9652
+ );
9653
+ if (one) {
9654
+ const byOrg = one === "failed" ? /* @__PURE__ */ new Map() : new Map(one.views.map((v) => [v.organization_id, v.items]));
9655
+ const failed = one === "failed" ? new Set(orgs.map((o) => o.id)) : new Set(one.unavailable);
9656
+ const settled = orgs.map((o, i) => {
9657
+ if (failed.has(o.id)) return Promise.reject(new Error(`${o.name} is unavailable`));
9658
+ const items = byOrg.get(o.id) ?? [];
9659
+ raw.orgLists[i] = { items, count: items.length };
9660
+ return Promise.resolve(raw.orgLists[i]);
9661
+ });
9662
+ settled.forEach(quiet);
9663
+ progress();
9664
+ return settled;
9665
+ }
9644
9666
  return orgs.map((o, i) => {
9645
9667
  const p = retrying(() => account9.listItems(api, { query: { principal_type: "organization", organization_id: o.id } }, { organizationId: o.id }));
9646
9668
  const arrived = p.then((l) => {