@capxul/sdk 4.20.0-beta.36 → 4.20.0-beta.37

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,4 +1,4 @@
1
- import { $n as InvitationViewSchema, At as buildSafeMultiSendExecTransactionCall, Bi as isCapxulError, Cr as toBudgetId, Ct as SEND_SIGNATURE, En as CAPXUL_OPERATIONS, Er as toRoleKey, Et as deriveCapxulSafeAddress, Fi as toEmail, Fn as replacements, Ft as CONFIGURED_MONEY_ASSETS, Gn as treasuries, Gr as observationOnlyControls, Hn as members, In as PreparedPermissionExecutionSchema, J as subscribeFreshQuery, Jr as awaitCapxulResult, Kn as workspaces, Kr as runCapxulEffect, Kt as withCapturedAttemptContext, Ln as PermissionCommandViewSchema, Lr as absurd, Lt as asCapxulError, Mn as authorities, Mt as MULTI_SEND_CALL_ONLY, N as makePayrollMethods, Nn as commands, Nt as SAFE_SENTINEL_OWNERS, O as retryIdempotentRead, Ot as safe4337ExecuteUserOpCallData, P as makeUnavailablePayrollMethods, Pn as configurations, Pr as toAddress, Pt as callOperation, Qn as toOrgId, R as annotateDepositInstructions, Ri as Errors, Rr as reference, St as SEND_BATCH_SIGNATURE, Tr as toPermissionId, Tt as matchesMoneyExecutionId, U as makeActorRelationshipMethods, Ui as isRecord, Un as roles, V as waitForPaymentSubmission, Vn as invitations, Wn as setups, Xr as runIfActive, Yr as defectAsCapxulError, Zn as decodeChainCause, Zr as toCapxulResult, _ as accountFromAccountPositions, _n as toPartyId, _r as toLowerBytes32, _t as ROLES_SET_ALLOWANCE_ABI, ar as ORG_BUDGET_ACTIONS, b as MONEY_READ_RATES, bt as ROLE_MANAGEMENT_SIGNATURES, cn as signerFailure, ct as resolveOrgPermissionIdentity, dr as deposits, dt as MULTI_SEND_SELECTOR, er as hashPermissionReplacementPreview, fi as attachInvocationObservation, fr as toAccountId, ft as OPERATOR, gr as toLowerAddress, gt as ROLES_EXEC_TRANSACTION_WITH_ROLE_ABI, hr as toExactHex, ht as ROLES_ASSIGN_ROLES_ABI, ir as MONTHLY_REFILL_PERIOD_SECONDS, it as canonicalJson, jr as toExactAssetAmount, jt as BASE_SEPOLIA_CHAIN_ID, kt as safe4337MultiSendUserOpCallData, lt as CREATE_COMMITMENT_SIGNATURE, mi as readInvocationObservation, mt as PARAMETER_TYPE, ni as carryInvocationParentSpan, nr as keepRefillOnChange, or as roleKeyForPermission, ot as moneySafeOpDigest, pi as copyInvocationObservation, pt as OWNER_COMMITMENT_SIGNATURES, qn as OrganizationSetupSchema, qr as withVerifiedOrganizationScope, ri as withInvocationParentSpan, rr as CurrentPolicySchema, st as ZODIAC_MODULE_PROXY_FACTORY, tr as decodePermissionIntent$1, ur as bankDetails, ut as MODULE_PROXY_FACTORY_ABI, v as accountPositionsFromWire, vr as toLowerHex, vt as ROLES_SET_TRANSACTION_UNWRAPPER_ABI, wr as toPermissionAssignmentId, wt as CAPXUL_PAYMENTS_V2_ADDRESS, xt as SAFE_ENABLE_MODULE_ABI, yt as ROLES_SET_UP_ABI, z as makeOrganizationPaymentsMethods, zi as CapxulError } from "./access-D5D77YLI.mjs";
1
+ import { $n as copyInvocationObservation, $r as toAccountId, Ar as treasuries, At as safe4337ExecuteUserOpCallData, B as makeOrganizationPaymentsMethods, Br as InvitationViewSchema, Ci as toAddress, Cn as toPartyId, Ct as SAFE_ENABLE_MODULE_ABI, Di as reference, Dn as noSessionError, Dr as members, Dt as matchesMoneyExecutionId, Ei as absurd, Er as invitations, Et as CAPXUL_PAYMENTS_V2_ADDRESS, F as makeUnavailablePayrollMethods, Fn as awaitCapxulResult, Ft as SAFE_SENTINEL_OWNERS, Gr as MONTHLY_REFILL_PERIOD_SECONDS, H as waitForPaymentSubmission, Hn as withInvocationParentSpan, Hr as decodePermissionIntent$1, In as defectAsCapxulError, It as callOperation, Ji as toEmail, Jt as withCapturedAttemptContext, Kr as ORG_BUDGET_ACTIONS, Ln as runIfActive, Lt as CONFIGURED_MONEY_ASSETS, Mn as observationOnlyControls, Mr as OrganizationSetupSchema, Mt as buildSafeMultiSendExecTransactionCall, Nn as runCapxulEffect, Nt as BASE_SEPOLIA_CHAIN_ID, Or as roles, Ot as deriveCapxulSafeAddress, P as makePayrollMethods, Pn as withVerifiedOrganizationScope, Pt as MULTI_SEND_CALL_ONLY, Qn as attachInvocationObservation, Qr as deposits, Rn as toCapxulResult, Sr as PermissionCommandViewSchema, St as ROLE_MANAGEMENT_SIGNATURES, Tt as SEND_SIGNATURE, Ur as keepRefillOnChange, Vn as carryInvocationParentSpan, Vr as hashPermissionReplacementPreview, W as makeActorRelationshipMethods, Wr as CurrentPolicySchema, X as subscribeFreshQuery, Zi as Errors, Zr as bankDetails, _ as accountFromAccountPositions, _r as authorities, _t as ROLES_ASSIGN_ROLES_ABI, ai as toLowerHex, b as MONEY_READ_RATES, bi as toExactAssetAmount, br as replacements, bt as ROLES_SET_TRANSACTION_UNWRAPPER_ABI, ct as moneySafeOpDigest, dr as CAPXUL_OPERATIONS, dt as CREATE_COMMITMENT_SIGNATURE, er as markFailureOperation, fi as toBudgetId, ft as MODULE_PROXY_FACTORY_ABI, gt as PARAMETER_TYPE, hi as toRoleKey, ht as OWNER_COMMITMENT_SIGNATURES, ii as toLowerBytes32, jr as workspaces, jt as safe4337MultiSendUserOpCallData, k as retryIdempotentRead, kr as setups, lt as ZODIAC_MODULE_PROXY_FACTORY, mi as toPermissionId, mn as signerFailure, mt as OPERATOR, na as CapxulError, ni as toExactHex, oa as isRecord, ot as canonicalJson, pi as toPermissionAssignmentId, pt as MULTI_SEND_SELECTOR, qr as roleKeyForPermission, ra as isCapxulError, ri as toLowerAddress, rn as deserializeCapxulError, tr as readInvocationObservation, ut as resolveOrgPermissionIdentity, v as accountPositionsFromWire, vr as commands, vt as ROLES_EXEC_TRANSACTION_WITH_ROLE_ABI, wt as SEND_BATCH_SIGNATURE, xr as PreparedPermissionExecutionSchema, xt as ROLES_SET_UP_ABI, yr as configurations, yt as ROLES_SET_ALLOWANCE_ABI, z as annotateDepositInstructions, zr as toOrgId, zt as asCapxulError } from "./access-aMjL10vw.mjs";
2
2
  import { Context, Data, Effect, Result, Schema } from "effect";
3
3
  import { BaseError, decodeFunctionData, encodeAbiParameters, encodeFunctionData, formatUnits, getContractAddress, keccak256, padHex, parseAbiParameters, toBytes, toFunctionSelector, toHex } from "viem";
4
4
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
@@ -102,8 +102,8 @@ const ORG_BUDGET_ALLOWANCE_NAMESPACE = "CAPXUL_ORG_BUDGET_ALLOWANCE_V1";
102
102
  function requireBigInt(value, field) {
103
103
  try {
104
104
  return BigInt(value);
105
- } catch {
106
- throw Errors.invalidInput(field, "must be an integer");
105
+ } catch (cause) {
106
+ throw Errors.invalidInput(field, "must be an integer", cause);
107
107
  }
108
108
  }
109
109
  function requireAssetId(value) {
@@ -10934,7 +10934,7 @@ async function execute(deps, orgId, command, signal, controls, verifiedOrganizat
10934
10934
  const session = deps.actor.authSession();
10935
10935
  if (session === null) return {
10936
10936
  ok: false,
10937
- error: Errors.notAuthenticated()
10937
+ error: noSessionError(deps.actor)
10938
10938
  };
10939
10939
  let signerAddress;
10940
10940
  try {
@@ -11023,7 +11023,7 @@ function subscribePermissionCommand(deps, orgId, requestKey, listener, options)
11023
11023
  decode(raw);
11024
11024
  },
11025
11025
  invalidValue: (cause) => isCapxulError(cause) ? cause : Errors.invalidInput("command", "invalid Permission command projection"),
11026
- invalidScope: () => Errors.invalidInput("command", "Permission command subscription scope does not match"),
11026
+ invalidScope: (cause) => Errors.invalidInput("command", "Permission command subscription scope does not match", cause),
11027
11027
  lostValue: () => Errors.invalidInput("command", "Permission command is no longer readable"),
11028
11028
  unavailable: () => Errors.notImplemented("permissions", "subscribeCommand")
11029
11029
  }, options);
@@ -11089,7 +11089,7 @@ function makePermissionMethods(deps, orgId) {
11089
11089
  if (!lookup.ok) return lookup;
11090
11090
  if (session === null || session === void 0) return {
11091
11091
  ok: false,
11092
- error: Errors.notAuthenticated()
11092
+ error: noSessionError(deps.actor)
11093
11093
  };
11094
11094
  const sameActor = () => {
11095
11095
  const current = deps.actor?.authSession();
@@ -11138,7 +11138,7 @@ function makePermissionMethods(deps, orgId) {
11138
11138
  if (!lookup.ok) return lookup;
11139
11139
  if (session === null || session === void 0 || lifetime === void 0) return {
11140
11140
  ok: false,
11141
- error: Errors.notAuthenticated()
11141
+ error: noSessionError(deps.actor)
11142
11142
  };
11143
11143
  const sameActor = () => {
11144
11144
  const current = deps.actor?.authSession();
@@ -11192,29 +11192,6 @@ function makePermissionMethods(deps, orgId) {
11192
11192
  };
11193
11193
  }
11194
11194
  //#endregion
11195
- //#region ../protocol/src/errors/serialize.ts
11196
- function deserializeCapxulError(serialized) {
11197
- const chain = serialized.chain === void 0 ? void 0 : decodeChainCause(serialized.chain) ?? void 0;
11198
- const cause = serialized.cause === void 0 ? void 0 : causeFromSummary(serialized.cause);
11199
- const options = {
11200
- ...cause === void 0 ? {} : { cause },
11201
- ...serialized.details === void 0 ? {} : { details: serialized.details },
11202
- ...serialized.correlationId === void 0 ? {} : { correlationId: serialized.correlationId },
11203
- ...serialized.layer === void 0 ? {} : { layer: serialized.layer },
11204
- ...serialized.mode === void 0 ? {} : { mode: serialized.mode },
11205
- ...chain === void 0 ? {} : { chain }
11206
- };
11207
- return new CapxulError(serialized.code, serialized.message, options);
11208
- }
11209
- /** Rebuild a summary as an `Error` chain, so every later hop reads `cause` the same way. */
11210
- function causeFromSummary(links) {
11211
- return links.reduceRight((cause, link) => {
11212
- const error = cause === void 0 ? new Error(link.message) : new Error(link.message, { cause });
11213
- error.name = link.name;
11214
- return error;
11215
- }, void 0);
11216
- }
11217
- //#endregion
11218
11195
  //#region src/organizations/port.ts
11219
11196
  var OrgError = class extends Data.TaggedError("OrgError") {};
11220
11197
  function orgErrorFromCapxul(operation, error, cause = error) {
@@ -11479,7 +11456,8 @@ function subscribeInvitation(deps, orgId, input, listener, options) {
11479
11456
  if (actor === void 0) return yield* Effect.fail(Errors.notImplemented("invitations", "subscribe"));
11480
11457
  const lifetime = actor.authLifetime();
11481
11458
  const current = () => actor.matchesAuthLifetime(lifetime, lifetime.authUserId);
11482
- if (lifetime.authUserId === null || !current()) return yield* Effect.fail(Errors.notAuthenticated());
11459
+ if (lifetime.authUserId === null) return yield* Effect.fail(noSessionError(actor));
11460
+ if (!current()) return yield* Effect.fail(Errors.notAuthenticated());
11483
11461
  let active = true;
11484
11462
  let connected;
11485
11463
  let remoteStop;
@@ -11523,8 +11501,8 @@ function subscribeInvitation(deps, orgId, input, listener, options) {
11523
11501
  let value;
11524
11502
  try {
11525
11503
  value = Schema.decodeSync(InvitationViewSchema)(snapshot.value);
11526
- } catch {
11527
- return fail(Errors.invalidInput("invitation", "Invalid invitation subscription value"));
11504
+ } catch (cause) {
11505
+ return fail(Errors.invalidInput("invitation", "Invalid invitation subscription value", cause));
11528
11506
  }
11529
11507
  if (value.orgId !== orgId || value.id !== invitationId) return fail(Errors.invalidInput("invitationId", "Invitation subscription scope does not match"));
11530
11508
  notify({
@@ -11537,7 +11515,7 @@ function subscribeInvitation(deps, orgId, input, listener, options) {
11537
11515
  const previous = connected;
11538
11516
  connected = next;
11539
11517
  if (next || previous !== true) return;
11540
- const error = Errors.networkError(operation, "connection unavailable", { provider: "convex" });
11518
+ const error = Errors.networkError(operation, void 0, { provider: "convex" });
11541
11519
  fail(error);
11542
11520
  } }).pipe(Effect.mapError((error) => error.publicError), Effect.onError(() => Effect.sync(stop)));
11543
11521
  if (!active) {
@@ -11780,7 +11758,7 @@ async function executeInvite(deps, orgId, input, signal, controls, verifiedOrgan
11780
11758
  const session = deps.actor.authSession();
11781
11759
  if (session === null) return {
11782
11760
  ok: false,
11783
- error: Errors.notAuthenticated()
11761
+ error: noSessionError(deps.actor)
11784
11762
  };
11785
11763
  const authored = await authorInvitation(deps, orgId, input, signal, controls);
11786
11764
  if (!authored.ok) return authored;
@@ -12028,6 +12006,103 @@ const listOrgsProgram = Effect.gen(function* () {
12028
12006
  };
12029
12007
  });
12030
12008
  //#endregion
12009
+ //#region src/organizations/setup-checks.ts
12010
+ /**
12011
+ * Check the prepare row's reply against the Organization and the signer. The
12012
+ * reply is what fails the check, so a failure names that row.
12013
+ */
12014
+ function validatePrepared(prepared, orgId, signerAddress) {
12015
+ const checked = checkPrepared(prepared, orgId, signerAddress);
12016
+ if (!checked.ok) markFailureOperation(checked.error, setups.prepareAuthorization.name);
12017
+ return checked;
12018
+ }
12019
+ function checkPrepared(prepared, orgId, signerAddress) {
12020
+ const signer = signerAddress.toLowerCase();
12021
+ if (prepared.orgId !== orgId || prepared.expectedSigner.toLowerCase() !== signer) return fail(Errors.invalidInput("authorization", "Prepared signer or Organization does not match"));
12022
+ const founder = prepared.founderPersonalAccount.toLowerCase();
12023
+ const organization = prepared.organizationAccountAddress.toLowerCase();
12024
+ if (founder === signer || organization === signer || organization === founder || prepared.userOp.sender.toLowerCase() !== founder) return fail(Errors.invalidInput("organizationAuthority", "Prepared authorities do not match"));
12025
+ if (!/^0x[0-9a-fA-F]{64}$/u.test(prepared.digest)) return fail(Errors.invalidInput("digest", "Prepared digest must be 32-byte hex"));
12026
+ return {
12027
+ ok: true,
12028
+ value: void 0
12029
+ };
12030
+ }
12031
+ async function signerResult(signer, operation, run) {
12032
+ try {
12033
+ return {
12034
+ ok: true,
12035
+ value: await run()
12036
+ };
12037
+ } catch (cause) {
12038
+ return fail(signerFailure(signer.source, operation, cause));
12039
+ }
12040
+ }
12041
+ function cancelled() {
12042
+ return fail(Errors.cancelled({ operation: CAPXUL_OPERATIONS.organization.setup }));
12043
+ }
12044
+ async function abortable(pending, signal) {
12045
+ if (signal === void 0) return pending;
12046
+ if (signal.aborted) return cancelled();
12047
+ let onAbort;
12048
+ const interrupted = new Promise((resolve) => {
12049
+ onAbort = () => resolve(cancelled());
12050
+ signal.addEventListener("abort", onAbort, { once: true });
12051
+ if (signal.aborted) onAbort();
12052
+ });
12053
+ try {
12054
+ return await Promise.race([pending, interrupted]);
12055
+ } finally {
12056
+ signal.removeEventListener("abort", onAbort);
12057
+ }
12058
+ }
12059
+ function fail(error) {
12060
+ return {
12061
+ ok: false,
12062
+ error
12063
+ };
12064
+ }
12065
+ /**
12066
+ * Run one `org(orgId).setup` method. Apart from `subscribe`, which the host
12067
+ * observer names `org.setup.subscribe`, its path is not an operation. A failure
12068
+ * that a row gave keeps the name of that row. Any other failure (a cancel, the
12069
+ * signer, a missing adapter, a thrown error) did not come from a row, so it
12070
+ * names `organization.setup`, the client side of the setup.
12071
+ */
12072
+ async function invokeSetup(setup, method, call) {
12073
+ let result;
12074
+ try {
12075
+ result = setup === void 0 ? fail(Errors.notImplemented("organizationSetup", method)) : await call();
12076
+ } catch (cause) {
12077
+ result = fail(Errors.unknown(cause));
12078
+ }
12079
+ if (!result.ok) markFailureOperation(result.error, CAPXUL_OPERATIONS.organization.setup);
12080
+ return result;
12081
+ }
12082
+ /** The setup in the reply of one row, scoped to its Organization. A failure names that row. */
12083
+ function setupFromReply(row, orgId, value) {
12084
+ const parsed = value === null ? fail(Errors.invalidInput("orgId", "Organization setup was not found")) : parseOrganizationSetup(value);
12085
+ const scoped = parsed.ok ? validateOrganizationSetupScope(orgId, parsed.value) : parsed;
12086
+ if (!scoped.ok) markFailureOperation(scoped.error, row.name);
12087
+ return scoped;
12088
+ }
12089
+ /** One live setup value, parsed and scoped to the Organization it was read for. */
12090
+ function setupSnapshotFromValue(orgId, value) {
12091
+ const scoped = setupFromReply(setups.get, orgId, value);
12092
+ return scoped.ok ? {
12093
+ status: "value",
12094
+ value: scoped.value
12095
+ } : {
12096
+ status: "error",
12097
+ error: scoped.error
12098
+ };
12099
+ }
12100
+ /** The snapshot a live setup read reports when its connection drops after it connected. */
12101
+ const SETUP_CONNECTION_LOST = {
12102
+ status: "error",
12103
+ error: Errors.networkError(CAPXUL_OPERATIONS.organization.setup, void 0, { provider: "convex" })
12104
+ };
12105
+ //#endregion
12031
12106
  //#region src/organizations/scope-reads.ts
12032
12107
  /** `client.org(id)` reads: profile, treasury, account, members, roles and the audit log. */
12033
12108
  function makeOrgReadMethods(deps, orgId, shared) {
@@ -12363,20 +12438,6 @@ function relationshipExecutionDeps(deps) {
12363
12438
  ...deps.telemetry === void 0 ? {} : { telemetry: deps.telemetry }
12364
12439
  };
12365
12440
  }
12366
- async function invokeSetup(setup, method, call) {
12367
- if (setup === void 0) return {
12368
- ok: false,
12369
- error: Errors.notImplemented("organizationSetup", method)
12370
- };
12371
- try {
12372
- return await call();
12373
- } catch (cause) {
12374
- return {
12375
- ok: false,
12376
- error: Errors.unknown(cause)
12377
- };
12378
- }
12379
- }
12380
12441
  function makeOrgMethods(deps) {
12381
12442
  const orgDeps = {
12382
12443
  runPromise: deps.runPromise,
@@ -12467,71 +12528,6 @@ function makeOrgMethods(deps) {
12467
12528
  };
12468
12529
  }
12469
12530
  //#endregion
12470
- //#region src/organizations/setup-checks.ts
12471
- function validatePrepared(prepared, orgId, signerAddress) {
12472
- const signer = signerAddress.toLowerCase();
12473
- if (prepared.orgId !== orgId || prepared.expectedSigner.toLowerCase() !== signer) return fail(Errors.invalidInput("authorization", "Prepared signer or Organization does not match"));
12474
- const founder = prepared.founderPersonalAccount.toLowerCase();
12475
- const organization = prepared.organizationAccountAddress.toLowerCase();
12476
- if (founder === signer || organization === signer || organization === founder || prepared.userOp.sender.toLowerCase() !== founder) return fail(Errors.invalidInput("organizationAuthority", "Prepared authorities do not match"));
12477
- if (!/^0x[0-9a-fA-F]{64}$/u.test(prepared.digest)) return fail(Errors.invalidInput("digest", "Prepared digest must be 32-byte hex"));
12478
- return {
12479
- ok: true,
12480
- value: void 0
12481
- };
12482
- }
12483
- async function signerResult(signer, operation, run) {
12484
- try {
12485
- return {
12486
- ok: true,
12487
- value: await run()
12488
- };
12489
- } catch (cause) {
12490
- return fail(signerFailure(signer.source, operation, cause));
12491
- }
12492
- }
12493
- function cancelled() {
12494
- return fail(Errors.cancelled({ operation: CAPXUL_OPERATIONS.organization.setup }));
12495
- }
12496
- async function abortable(pending, signal) {
12497
- if (signal === void 0) return pending;
12498
- if (signal.aborted) return cancelled();
12499
- let onAbort;
12500
- const interrupted = new Promise((resolve) => {
12501
- onAbort = () => resolve(cancelled());
12502
- signal.addEventListener("abort", onAbort, { once: true });
12503
- if (signal.aborted) onAbort();
12504
- });
12505
- try {
12506
- return await Promise.race([pending, interrupted]);
12507
- } finally {
12508
- signal.removeEventListener("abort", onAbort);
12509
- }
12510
- }
12511
- function fail(error) {
12512
- return {
12513
- ok: false,
12514
- error
12515
- };
12516
- }
12517
- /** One live setup value, parsed and scoped to the Organization it was read for. */
12518
- function setupSnapshotFromValue(orgId, value) {
12519
- const parsed = value === null ? fail(Errors.invalidInput("orgId", "Organization setup was not found")) : parseOrganizationSetup(value);
12520
- const scoped = parsed.ok ? validateOrganizationSetupScope(orgId, parsed.value) : parsed;
12521
- return scoped.ok ? {
12522
- status: "value",
12523
- value: scoped.value
12524
- } : {
12525
- status: "error",
12526
- error: scoped.error
12527
- };
12528
- }
12529
- /** The snapshot a live setup read reports when its connection drops after it connected. */
12530
- const SETUP_CONNECTION_LOST = {
12531
- status: "error",
12532
- error: Errors.networkError(CAPXUL_OPERATIONS.organization.setup, "connection unavailable", { provider: "convex" })
12533
- };
12534
- //#endregion
12535
12531
  //#region src/organizations/setup-adapter.ts
12536
12532
  /** Convex transport for one backend-owned Organization setup. */
12537
12533
  var ConvexOrganizationSetupAdapter = class {
@@ -12548,7 +12544,7 @@ var ConvexOrganizationSetupAdapter = class {
12548
12544
  this.#runPromise = input.runPromise ?? Effect.runPromise;
12549
12545
  }
12550
12546
  async begin(input) {
12551
- const result = await this.#call("begin", callOperation(this.#convex, setups.begin, copyInvocationObservation(input, {
12547
+ const result = await this.#call(setups.begin, callOperation(this.#convex, setups.begin, copyInvocationObservation(input, {
12552
12548
  ...input,
12553
12549
  chainId: this.#chainId
12554
12550
  })));
@@ -12571,17 +12567,14 @@ var ConvexOrganizationSetupAdapter = class {
12571
12567
  }
12572
12568
  async get(orgId, options) {
12573
12569
  if (options?.signal?.aborted) return cancelled();
12574
- const result = await this.#call("get", callOperation(this.#convex, setups.get, { orgId }));
12575
- if (!result.ok) return result;
12576
- if (result.value === null) return fail(Errors.invalidInput("orgId", "Organization setup was not found"));
12577
- const parsed = parseOrganizationSetup(result.value);
12578
- return parsed.ok ? validateOrganizationSetupScope(orgId, parsed.value) : parsed;
12570
+ const result = await this.#call(setups.get, callOperation(this.#convex, setups.get, { orgId }));
12571
+ return result.ok ? setupFromReply(setups.get, orgId, result.value) : result;
12579
12572
  }
12580
12573
  async listMine(input = {}, options) {
12581
12574
  if (options?.signal?.aborted) return cancelled();
12582
12575
  if (input.cursor !== void 0 && typeof input.cursor !== "string" || input.limit !== void 0 && (!Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 50)) return fail(Errors.invalidInput("organizationSetupPage", "Invalid cursor or limit"));
12583
12576
  const generation = this.#generation;
12584
- const result = await abortable(this.#call("listMine", callOperation(this.#convex, setups.listMine, input)), options?.signal);
12577
+ const result = await abortable(this.#call(setups.listMine, callOperation(this.#convex, setups.listMine, input)), options?.signal);
12585
12578
  if (generation !== this.#generation || options?.signal?.aborted) return cancelled();
12586
12579
  if (!result.ok) return result;
12587
12580
  const items = [];
@@ -12600,10 +12593,8 @@ var ConvexOrganizationSetupAdapter = class {
12600
12593
  }
12601
12594
  async resume(orgId, options) {
12602
12595
  if (options?.signal?.aborted) return cancelled();
12603
- const result = await this.#call("resume", callOperation(this.#convex, setups.resume, { orgId }));
12604
- if (!result.ok) return result;
12605
- const parsed = parseOrganizationSetup(result.value);
12606
- return parsed.ok ? validateOrganizationSetupScope(orgId, parsed.value) : parsed;
12596
+ const result = await this.#call(setups.resume, callOperation(this.#convex, setups.resume, { orgId }));
12597
+ return result.ok ? setupFromReply(setups.resume, orgId, result.value) : result;
12607
12598
  }
12608
12599
  async authorize(orgId, options) {
12609
12600
  if (options?.signal?.aborted) return cancelled();
@@ -12614,7 +12605,7 @@ var ConvexOrganizationSetupAdapter = class {
12614
12605
  if (signer === null) return fail(Errors.capabilityUnavailable("signer", "authorize"));
12615
12606
  const address = await signerResult(signer, "getAddress", () => signer.getAddress());
12616
12607
  if (!address.ok) return address;
12617
- const prepared = await this.#call("prepareAuthorization", callOperation(this.#convex, setups.prepareAuthorization, { orgId }));
12608
+ const prepared = await this.#call(setups.prepareAuthorization, callOperation(this.#convex, setups.prepareAuthorization, { orgId }));
12618
12609
  if (!prepared.ok) return prepared;
12619
12610
  const authority = validatePrepared(prepared.value, orgId, address.value);
12620
12611
  if (!authority.ok) return authority;
@@ -12623,7 +12614,7 @@ var ConvexOrganizationSetupAdapter = class {
12623
12614
  const signature = await signerResult(signer, "signUserOpHash", () => signer.signUserOpHash(digest));
12624
12615
  if (!signature.ok) return signature;
12625
12616
  if (options?.signal?.aborted) return cancelled();
12626
- const submitted = await this.#call("submitAuthorization", callOperation(this.#convex, setups.submitAuthorization, {
12617
+ const submitted = await this.#call(setups.submitAuthorization, callOperation(this.#convex, setups.submitAuthorization, {
12627
12618
  orgId,
12628
12619
  preparationId: prepared.value.preparationId,
12629
12620
  userOp: prepared.value.userOp,
@@ -12633,8 +12624,7 @@ var ConvexOrganizationSetupAdapter = class {
12633
12624
  const acceptedSetup = await this.get(orgId);
12634
12625
  return acceptedSetup.ok && acceptedSetup.value.status !== "awaitingAuthorization" ? acceptedSetup : submitted;
12635
12626
  }
12636
- const parsed = parseOrganizationSetup(submitted.value);
12637
- return parsed.ok ? validateOrganizationSetupScope(orgId, parsed.value) : parsed;
12627
+ return setupFromReply(setups.submitAuthorization, orgId, submitted.value);
12638
12628
  }
12639
12629
  async subscribe(orgId, listener, options) {
12640
12630
  if (options?.signal?.aborted) return cancelled();
@@ -12655,7 +12645,7 @@ var ConvexOrganizationSetupAdapter = class {
12655
12645
  };
12656
12646
  options?.signal?.addEventListener("abort", stop, { once: true });
12657
12647
  this.#subscriptions.add(stop);
12658
- const result = await this.#call("subscribe", this.#convex.subscribe(reference(setups.get), { orgId }, (snapshot) => {
12648
+ const result = await this.#call(setups.get, this.#convex.subscribe(reference(setups.get), { orgId }, (snapshot) => {
12659
12649
  if (!active) return;
12660
12650
  if (snapshot.status === "error") return notify({
12661
12651
  status: "error",
@@ -12690,8 +12680,9 @@ var ConvexOrganizationSetupAdapter = class {
12690
12680
  this.#generation += 1;
12691
12681
  for (const stop of this.#subscriptions) stop();
12692
12682
  }
12693
- async #call(_operation, effect) {
12683
+ async #call(row, effect) {
12694
12684
  const result = await this.#runPromise(Effect.result(effect.pipe(Effect.mapError((error) => "publicError" in error ? error.publicError : error), Effect.catchDefect((defect) => Effect.fail(defectAsCapxulError(defect))))));
12685
+ if (Result.isFailure(result)) markFailureOperation(result.failure, row.name);
12695
12686
  return Result.isSuccess(result) ? {
12696
12687
  ok: true,
12697
12688
  value: result.success
@@ -12699,4 +12690,4 @@ var ConvexOrganizationSetupAdapter = class {
12699
12690
  }
12700
12691
  };
12701
12692
  //#endregion
12702
- export { prepareConfiguration as a, OrgPortTag as c, preparedIdentity as d, verifiedPreparation as f, validateReplacementInput as h, authorInvitation as i, deserializeCapxulError as l, decodePermissionIntent as m, makeOrgMethods as n, verifiedConfiguration as o, buildCommand as p, makeBankingMethods as r, ConvexOrganizationAdapter as s, ConvexOrganizationSetupAdapter as t, preparePermission as u };
12693
+ export { prepareConfiguration as a, OrgPortTag as c, verifiedPreparation as d, buildCommand as f, authorInvitation as i, preparePermission as l, validateReplacementInput as m, makeOrgMethods as n, verifiedConfiguration as o, decodePermissionIntent as p, makeBankingMethods as r, ConvexOrganizationAdapter as s, ConvexOrganizationSetupAdapter as t, preparedIdentity as u };
@@ -1,5 +1,5 @@
1
- import { a as prepareConfiguration, d as preparedIdentity, f as verifiedPreparation, h as validateReplacementInput, i as authorInvitation, o as verifiedConfiguration, p as buildCommand, u as preparePermission } from "./organizations-BKiw2PjB.mjs";
2
- import { En as CAPXUL_OPERATIONS, Lr as absurd, Lt as asCapxulError, Ri as Errors, Y as abandonPrepared, zi as CapxulError } from "./access-D5D77YLI.mjs";
1
+ import { a as prepareConfiguration, d as verifiedPreparation, f as buildCommand, i as authorInvitation, l as preparePermission, m as validateReplacementInput, o as verifiedConfiguration, u as preparedIdentity } from "./organizations-DPpyjjx2.mjs";
2
+ import { Dn as noSessionError, Ei as absurd, Z as abandonPrepared, dr as CAPXUL_OPERATIONS, na as CapxulError, zt as asCapxulError } from "./access-aMjL10vw.mjs";
3
3
  //#region src/accounts/permission-approvals.ts
4
4
  /** Prepare a Permission write or an invitation's configuration for `signerAddress`, checked. */
5
5
  function prepareVerifiedPermissionChange(deps, input, signerAddress, signal) {
@@ -66,7 +66,7 @@ async function prepareVerifiedPermissionWrite(deps, input, signerAddress, signal
66
66
  const session = deps.actor?.authSession() ?? null;
67
67
  if (session === null || deps.chainId === void 0) return {
68
68
  ok: false,
69
- error: Errors.notAuthenticated()
69
+ error: noSessionError(deps.actor)
70
70
  };
71
71
  const built = command(input.permission);
72
72
  if (!built.ok) return built;
@@ -97,7 +97,7 @@ async function prepareVerifiedInvitation(deps, input, signerAddress, signal) {
97
97
  const session = deps.actor?.authSession() ?? null;
98
98
  if (session === null || deps.chainId === void 0) return {
99
99
  ok: false,
100
- error: Errors.notAuthenticated()
100
+ error: noSessionError(deps.actor)
101
101
  };
102
102
  const orgId = input.organizationId;
103
103
  const authored = await authorInvitation(deps, orgId, input.invite, signal, void 0);