@capxul/sdk 1.0.0-alpha.11 → 1.0.0-alpha.13
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-CTXgQ_xR.d.mts → index-D0SflScT.d.mts} +4 -5
- package/dist/index-D0SflScT.d.mts.map +1 -0
- package/dist/index.d.mts +217 -64
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +397 -57
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.d.mts +2 -2
- package/dist/ports/safe-deployment.d.mts +1 -1
- package/dist/{safe-deployment-D3k9yndM.d.mts → safe-deployment-ToMPzqwk.d.mts} +3 -3
- package/dist/{safe-deployment-D3k9yndM.d.mts.map → safe-deployment-ToMPzqwk.d.mts.map} +1 -1
- package/dist/{signer-D9fUJp8o.d.mts → signer-Cp2G98ZK.d.mts} +2 -2
- package/dist/signer-Cp2G98ZK.d.mts.map +1 -0
- package/package.json +3 -3
- package/dist/index-CTXgQ_xR.d.mts.map +0 -1
- package/dist/signer-D9fUJp8o.d.mts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1600,7 +1600,7 @@ async function recoverRawDigestSigner(input) {
|
|
|
1600
1600
|
}
|
|
1601
1601
|
//#endregion
|
|
1602
1602
|
//#region package.json
|
|
1603
|
-
var version = "1.0.0-alpha.
|
|
1603
|
+
var version = "1.0.0-alpha.13";
|
|
1604
1604
|
//#endregion
|
|
1605
1605
|
//#region src/ports/auth-client.ts
|
|
1606
1606
|
var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
|
|
@@ -5909,7 +5909,77 @@ function makeAccountsMethods(deps) {
|
|
|
5909
5909
|
};
|
|
5910
5910
|
}
|
|
5911
5911
|
//#endregion
|
|
5912
|
+
//#region src/client/current-user.ts
|
|
5913
|
+
function makeCurrentUserMethods(deps) {
|
|
5914
|
+
return { async get(options) {
|
|
5915
|
+
if (options?.signal?.aborted) return {
|
|
5916
|
+
ok: false,
|
|
5917
|
+
error: Errors.cancelled({ operation: "currentUser.get" })
|
|
5918
|
+
};
|
|
5919
|
+
const user = await deps.me.get(options);
|
|
5920
|
+
if (!user.ok) return {
|
|
5921
|
+
ok: false,
|
|
5922
|
+
error: user.error
|
|
5923
|
+
};
|
|
5924
|
+
const [account, smartAccount, organizations] = await Promise.all([
|
|
5925
|
+
deps.accounts.read(options),
|
|
5926
|
+
deps.smartAccount.loadCurrent(options),
|
|
5927
|
+
deps.orgs(options)
|
|
5928
|
+
]);
|
|
5929
|
+
if (!account.ok) return {
|
|
5930
|
+
ok: false,
|
|
5931
|
+
error: account.error
|
|
5932
|
+
};
|
|
5933
|
+
if (!smartAccount.ok) return {
|
|
5934
|
+
ok: false,
|
|
5935
|
+
error: smartAccount.error
|
|
5936
|
+
};
|
|
5937
|
+
if (!organizations.ok) return {
|
|
5938
|
+
ok: false,
|
|
5939
|
+
error: organizations.error
|
|
5940
|
+
};
|
|
5941
|
+
return {
|
|
5942
|
+
ok: true,
|
|
5943
|
+
value: {
|
|
5944
|
+
user: {
|
|
5945
|
+
id: user.value.authUserId,
|
|
5946
|
+
email: user.value.email,
|
|
5947
|
+
displayName: user.value.displayName,
|
|
5948
|
+
handle: null,
|
|
5949
|
+
paymentLink: null
|
|
5950
|
+
},
|
|
5951
|
+
personalAccount: {
|
|
5952
|
+
id: account.value.id,
|
|
5953
|
+
address: smartAccount.value?.smartAccountAddress ?? null
|
|
5954
|
+
},
|
|
5955
|
+
organizations: organizations.value.map((organization) => ({
|
|
5956
|
+
id: organization.id,
|
|
5957
|
+
name: organization.name,
|
|
5958
|
+
handle: organization.handle,
|
|
5959
|
+
role: organization.role,
|
|
5960
|
+
account: {
|
|
5961
|
+
id: organization.treasury.id,
|
|
5962
|
+
address: organization.safeAddress
|
|
5963
|
+
}
|
|
5964
|
+
}))
|
|
5965
|
+
}
|
|
5966
|
+
};
|
|
5967
|
+
} };
|
|
5968
|
+
}
|
|
5969
|
+
//#endregion
|
|
5912
5970
|
//#region src/client/financial-ops.ts
|
|
5971
|
+
function actorReferenceToBackend(actor) {
|
|
5972
|
+
if (actor === void 0) return void 0;
|
|
5973
|
+
switch (actor.kind) {
|
|
5974
|
+
case "personal": return { kind: "account" };
|
|
5975
|
+
case "organization": return {
|
|
5976
|
+
kind: "org",
|
|
5977
|
+
orgId: actor.organizationId
|
|
5978
|
+
};
|
|
5979
|
+
case "account":
|
|
5980
|
+
case "org": return actor;
|
|
5981
|
+
}
|
|
5982
|
+
}
|
|
5913
5983
|
const DEFAULT_FUNCTIONS = {
|
|
5914
5984
|
me: makeFunctionReference("financialOps/queries:me"),
|
|
5915
5985
|
depositInstructions: makeFunctionReference("financialOps/queries:depositInstructions"),
|
|
@@ -5969,40 +6039,88 @@ function makeFinancialOpsMethods(deps) {
|
|
|
5969
6039
|
get: (payeeId, options) => runIfActive(options?.signal, "payees.get", () => deps.convexCall.query(fns.getPayee, { payeeId })),
|
|
5970
6040
|
resolve: (recipient, options) => runIfActive(options?.signal, "payees.resolve", () => deps.convexCall.query(fns.resolvePayee, { recipient }))
|
|
5971
6041
|
},
|
|
6042
|
+
targets: { resolve: async (reference, options) => {
|
|
6043
|
+
switch (reference.kind) {
|
|
6044
|
+
case "handle": return mapOk$1(await runIfActive(options?.signal, "targets.resolve.handle", () => deps.convexCall.query(fns.resolveHandle, { handle: reference.handle })), (target) => resolvedTargetFromResolution(reference, target));
|
|
6045
|
+
case "email": return mapOk$1(await runIfActive(options?.signal, "targets.resolve.email", () => deps.convexCall.query(fns.resolvePayee, { recipient: reference.email })), (target) => resolvedTargetFromResolution(reference, target));
|
|
6046
|
+
case "organization": {
|
|
6047
|
+
const resolved = await runIfActive(options?.signal, "targets.resolve.organization", () => deps.convexCall.query(fns.resolveHandle, { handle: reference.handle }));
|
|
6048
|
+
if (!resolved.ok) return {
|
|
6049
|
+
ok: false,
|
|
6050
|
+
error: resolved.error
|
|
6051
|
+
};
|
|
6052
|
+
if (resolved.value.kind !== "org") return {
|
|
6053
|
+
ok: false,
|
|
6054
|
+
error: Errors.invalidInput("reference", "organization handle could not be resolved")
|
|
6055
|
+
};
|
|
6056
|
+
return {
|
|
6057
|
+
ok: true,
|
|
6058
|
+
value: resolvedTargetFromResolution(reference, resolved.value)
|
|
6059
|
+
};
|
|
6060
|
+
}
|
|
6061
|
+
case "payee": {
|
|
6062
|
+
const payee = await runIfActive(options?.signal, "targets.resolve.payee", () => deps.convexCall.query(fns.getPayee, { payeeId: reference.id }));
|
|
6063
|
+
if (!payee.ok) return {
|
|
6064
|
+
ok: false,
|
|
6065
|
+
error: payee.error
|
|
6066
|
+
};
|
|
6067
|
+
if (payee.value === null) return {
|
|
6068
|
+
ok: false,
|
|
6069
|
+
error: Errors.invalidInput("reference", "payee not found")
|
|
6070
|
+
};
|
|
6071
|
+
return {
|
|
6072
|
+
ok: true,
|
|
6073
|
+
value: resolvedTargetFromPayee(reference, payee.value)
|
|
6074
|
+
};
|
|
6075
|
+
}
|
|
6076
|
+
case "destination": return Promise.resolve({
|
|
6077
|
+
ok: false,
|
|
6078
|
+
error: Errors.notImplemented("targets", "resolve.destination")
|
|
6079
|
+
});
|
|
6080
|
+
}
|
|
6081
|
+
} },
|
|
5972
6082
|
destinations: {
|
|
5973
6083
|
add: async (input, options) => {
|
|
5974
|
-
const ref =
|
|
6084
|
+
const ref = normalizeDestinationInputRef(input, "target");
|
|
5975
6085
|
if (!ref.ok) return {
|
|
5976
6086
|
ok: false,
|
|
5977
6087
|
error: ref.error
|
|
5978
6088
|
};
|
|
5979
|
-
|
|
5980
|
-
|
|
6089
|
+
if (ref.value === void 0) return {
|
|
6090
|
+
ok: false,
|
|
6091
|
+
error: Errors.invalidInput("target", "required for destinations.add")
|
|
6092
|
+
};
|
|
6093
|
+
return mapOk$1(await runIfActive(options?.signal, "destinations.add", () => deps.convexCall.mutation(fns.addDestination, {
|
|
6094
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
5981
6095
|
ref: ref.value,
|
|
5982
|
-
kind: input.kind,
|
|
6096
|
+
kind: destinationKindToBackend(input.kind),
|
|
5983
6097
|
...input.label === void 0 ? {} : { label: input.label },
|
|
5984
6098
|
payload: input.payload
|
|
5985
|
-
}));
|
|
6099
|
+
})), destinationFromBackend);
|
|
5986
6100
|
},
|
|
5987
6101
|
list: async (input, options) => {
|
|
5988
|
-
const ref =
|
|
6102
|
+
const ref = normalizeDestinationInputRef(input, "target");
|
|
5989
6103
|
if (!ref.ok) return {
|
|
5990
6104
|
ok: false,
|
|
5991
6105
|
error: ref.error
|
|
5992
6106
|
};
|
|
5993
|
-
return runIfActive(options?.signal, "destinations.list", () => deps.convexCall.query(fns.listDestinations, {
|
|
5994
|
-
...input.actor === void 0 ? {} : { actor: input.actor },
|
|
5995
|
-
ref: ref.value
|
|
5996
|
-
}));
|
|
6107
|
+
return mapOk$1(await runIfActive(options?.signal, "destinations.list", () => deps.convexCall.query(fns.listDestinations, {
|
|
6108
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
6109
|
+
...ref.value === void 0 ? {} : { ref: ref.value }
|
|
6110
|
+
})), (destinations) => destinations.map(destinationFromBackend).filter((destination) => input.kind === void 0 || destination.kind === input.kind));
|
|
5997
6111
|
},
|
|
5998
6112
|
remove: (input, options) => runIfActive(options?.signal, "destinations.remove", () => deps.convexCall.mutation(fns.removeDestination, {
|
|
5999
|
-
...input.actor === void 0 ? {} : { actor: input.actor },
|
|
6113
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
6000
6114
|
destinationId: input.destinationId
|
|
6001
6115
|
}))
|
|
6002
6116
|
},
|
|
6003
6117
|
payments: {
|
|
6004
6118
|
pay: async (input, options) => {
|
|
6005
|
-
|
|
6119
|
+
if (actorReferenceToBackend(input.actor)?.kind === "org") return {
|
|
6120
|
+
ok: false,
|
|
6121
|
+
error: Errors.notImplemented("payments", "pay.organizationActor")
|
|
6122
|
+
};
|
|
6123
|
+
const to = normalizeTargetForBackend(input.to, "to");
|
|
6006
6124
|
if (!to.ok) return {
|
|
6007
6125
|
ok: false,
|
|
6008
6126
|
error: to.error
|
|
@@ -6010,13 +6128,14 @@ function makeFinancialOpsMethods(deps) {
|
|
|
6010
6128
|
return mapOk$1(await runIfActive(options?.signal, "payments.pay", () => deps.convexCall.mutation(fns.pay, {
|
|
6011
6129
|
to: to.value,
|
|
6012
6130
|
amount: input.amount,
|
|
6131
|
+
...input.paymentType === void 0 ? {} : { paymentType: input.paymentType },
|
|
6013
6132
|
...input.document === void 0 ? {} : { document: input.document },
|
|
6014
6133
|
...input.timing === void 0 ? {} : { timing: input.timing },
|
|
6015
6134
|
...input.lineItems === void 0 ? {} : { lineItems: input.lineItems }
|
|
6016
6135
|
})), normalizePaymentTiming$1);
|
|
6017
6136
|
},
|
|
6018
6137
|
payout: async (input, options) => mapOk$1(await runIfActive(options?.signal, "payments.payout", () => deps.convexCall.mutation(fns.payout, {
|
|
6019
|
-
...input.actor === void 0 ? {} : { actor: input.actor },
|
|
6138
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
6020
6139
|
destinationId: input.destinationId,
|
|
6021
6140
|
amount: input.amount
|
|
6022
6141
|
})), normalizePaymentTiming$1),
|
|
@@ -6027,6 +6146,16 @@ function makeFinancialOpsMethods(deps) {
|
|
|
6027
6146
|
})),
|
|
6028
6147
|
list: async (options) => mapOk$1(await runIfActive(options?.signal, "payments.list", () => deps.convexCall.query(fns.listPayments, {})), (payments) => payments.map(normalizePaymentTiming$1)),
|
|
6029
6148
|
get: async (paymentId, options) => mapOk$1(await runIfActive(options?.signal, "payments.get", () => deps.convexCall.query(fns.getPayment, { paymentId })), (payment) => payment === null ? null : normalizePaymentTiming$1(payment)),
|
|
6149
|
+
cancel: (paymentId, options) => {
|
|
6150
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
6151
|
+
ok: false,
|
|
6152
|
+
error: Errors.cancelled({ operation: "payments.cancel" })
|
|
6153
|
+
});
|
|
6154
|
+
return Promise.resolve({
|
|
6155
|
+
ok: false,
|
|
6156
|
+
error: Errors.notImplemented("payments", "cancel")
|
|
6157
|
+
});
|
|
6158
|
+
},
|
|
6030
6159
|
_internal: {
|
|
6031
6160
|
markSettled: (input, options) => runIfActive(options?.signal, "payments.markSettled", () => deps.convexCall.action(fns.markPaymentSettled, {
|
|
6032
6161
|
paymentId: input.paymentId,
|
|
@@ -6087,6 +6216,38 @@ function makeFinancialOpsMethods(deps) {
|
|
|
6087
6216
|
commitmentRef: (paymentId, options) => runIfActive(options?.signal, "payments.commitmentRef", () => deps.convexCall.query(fns.getCommitmentRef, { paymentId }))
|
|
6088
6217
|
}
|
|
6089
6218
|
},
|
|
6219
|
+
activity: { list: (params, options) => {
|
|
6220
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
6221
|
+
ok: false,
|
|
6222
|
+
error: Errors.cancelled({ operation: "activity.list" })
|
|
6223
|
+
});
|
|
6224
|
+
return Promise.resolve({
|
|
6225
|
+
ok: false,
|
|
6226
|
+
error: Errors.notImplemented("activity", "list")
|
|
6227
|
+
});
|
|
6228
|
+
} },
|
|
6229
|
+
offramp: {
|
|
6230
|
+
quote: (input, options) => {
|
|
6231
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
6232
|
+
ok: false,
|
|
6233
|
+
error: Errors.cancelled({ operation: "offramp.quote" })
|
|
6234
|
+
});
|
|
6235
|
+
return Promise.resolve({
|
|
6236
|
+
ok: false,
|
|
6237
|
+
error: Errors.notImplemented("offramp", "quote")
|
|
6238
|
+
});
|
|
6239
|
+
},
|
|
6240
|
+
status: (offrampId, options) => {
|
|
6241
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
6242
|
+
ok: false,
|
|
6243
|
+
error: Errors.cancelled({ operation: "offramp.status" })
|
|
6244
|
+
});
|
|
6245
|
+
return Promise.resolve({
|
|
6246
|
+
ok: false,
|
|
6247
|
+
error: Errors.notImplemented("offramp", "status")
|
|
6248
|
+
});
|
|
6249
|
+
}
|
|
6250
|
+
},
|
|
6090
6251
|
paymentDocuments: {
|
|
6091
6252
|
verify: (documentHash, options) => runIfActive(options?.signal, "paymentDocuments.verify", () => deps.convexCall.query(fns.verifyPaymentDocument, { documentHash })),
|
|
6092
6253
|
render: (documentHash, options) => runIfActive(options?.signal, "paymentDocuments.render", () => deps.convexCall.query(fns.renderStoredDocument, { documentHash }))
|
|
@@ -6166,6 +6327,169 @@ function handleRefValue(value, field) {
|
|
|
6166
6327
|
const trimmed = nonEmptyRefValue(value, field);
|
|
6167
6328
|
return trimmed.startsWith("@") ? trimmed.slice(1) : trimmed;
|
|
6168
6329
|
}
|
|
6330
|
+
function refFromTargetReference(reference, field) {
|
|
6331
|
+
try {
|
|
6332
|
+
if (typeof reference === "string") throw Errors.invalidInput(field, "target must be a typed TargetReference variant");
|
|
6333
|
+
if (typeof reference !== "object" || reference === null || !("kind" in reference)) throw Errors.invalidInput(field, "target must be a typed TargetReference variant");
|
|
6334
|
+
switch (reference.kind) {
|
|
6335
|
+
case "handle": return {
|
|
6336
|
+
ok: true,
|
|
6337
|
+
value: {
|
|
6338
|
+
kind: "handle",
|
|
6339
|
+
handle: reference.handle
|
|
6340
|
+
}
|
|
6341
|
+
};
|
|
6342
|
+
case "email": return {
|
|
6343
|
+
ok: true,
|
|
6344
|
+
value: {
|
|
6345
|
+
kind: "email",
|
|
6346
|
+
email: reference.email
|
|
6347
|
+
}
|
|
6348
|
+
};
|
|
6349
|
+
case "organization": return {
|
|
6350
|
+
ok: true,
|
|
6351
|
+
value: {
|
|
6352
|
+
kind: "orgHandle",
|
|
6353
|
+
orgHandle: reference.handle
|
|
6354
|
+
}
|
|
6355
|
+
};
|
|
6356
|
+
case "payee": return {
|
|
6357
|
+
ok: true,
|
|
6358
|
+
value: {
|
|
6359
|
+
kind: "payeeId",
|
|
6360
|
+
payeeId: reference.id
|
|
6361
|
+
}
|
|
6362
|
+
};
|
|
6363
|
+
case "destination": return {
|
|
6364
|
+
ok: false,
|
|
6365
|
+
error: Errors.notImplemented("targets", "reference.destination")
|
|
6366
|
+
};
|
|
6367
|
+
default: throw Errors.invalidInput(field, "target must be a known TargetReference variant");
|
|
6368
|
+
}
|
|
6369
|
+
} catch (cause) {
|
|
6370
|
+
if (cause instanceof Error && "code" in cause) return {
|
|
6371
|
+
ok: false,
|
|
6372
|
+
error: cause
|
|
6373
|
+
};
|
|
6374
|
+
return {
|
|
6375
|
+
ok: false,
|
|
6376
|
+
error: Errors.invalidInput(field, "target must be a typed TargetReference variant")
|
|
6377
|
+
};
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
function normalizeTargetForBackend(reference, field) {
|
|
6381
|
+
const ref = refFromTargetReference(reference, field);
|
|
6382
|
+
return ref.ok ? normalizeRefForBackend(ref.value, field) : ref;
|
|
6383
|
+
}
|
|
6384
|
+
function normalizeDestinationInputRef(input, field) {
|
|
6385
|
+
if (input.target !== void 0) return normalizeTargetForBackend(input.target, field);
|
|
6386
|
+
if (input.ref !== void 0) return normalizeDestinationRefForBackend(input.ref, "ref");
|
|
6387
|
+
return {
|
|
6388
|
+
ok: true,
|
|
6389
|
+
value: void 0
|
|
6390
|
+
};
|
|
6391
|
+
}
|
|
6392
|
+
function targetReferenceFromBackendRef(ref) {
|
|
6393
|
+
switch (ref.kind) {
|
|
6394
|
+
case "handle": return {
|
|
6395
|
+
kind: "handle",
|
|
6396
|
+
handle: ref.handle
|
|
6397
|
+
};
|
|
6398
|
+
case "email": return {
|
|
6399
|
+
kind: "email",
|
|
6400
|
+
email: ref.email
|
|
6401
|
+
};
|
|
6402
|
+
case "orgHandle": return {
|
|
6403
|
+
kind: "organization",
|
|
6404
|
+
handle: ref.orgHandle
|
|
6405
|
+
};
|
|
6406
|
+
case "payeeId": return {
|
|
6407
|
+
kind: "payee",
|
|
6408
|
+
id: ref.payeeId
|
|
6409
|
+
};
|
|
6410
|
+
case "capxulUserId": throw Errors.notImplemented("targets", "reference.capxulUserId");
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6413
|
+
function resolvedTargetFromResolution(reference, resolution) {
|
|
6414
|
+
const kind = resolution.kind === "org" ? "organization" : resolution.kind === "payee" ? "payee" : "person";
|
|
6415
|
+
return {
|
|
6416
|
+
reference,
|
|
6417
|
+
label: resolution.label,
|
|
6418
|
+
kind,
|
|
6419
|
+
capabilities: {
|
|
6420
|
+
canPay: true,
|
|
6421
|
+
canRequest: true,
|
|
6422
|
+
canPayout: false
|
|
6423
|
+
}
|
|
6424
|
+
};
|
|
6425
|
+
}
|
|
6426
|
+
function resolvedTargetFromPayee(reference, payee) {
|
|
6427
|
+
return {
|
|
6428
|
+
reference,
|
|
6429
|
+
label: payee.label,
|
|
6430
|
+
kind: "payee",
|
|
6431
|
+
capabilities: {
|
|
6432
|
+
canPay: true,
|
|
6433
|
+
canRequest: true,
|
|
6434
|
+
canPayout: false
|
|
6435
|
+
}
|
|
6436
|
+
};
|
|
6437
|
+
}
|
|
6438
|
+
function destinationKindToBackend(kind) {
|
|
6439
|
+
switch (kind) {
|
|
6440
|
+
case "bank_account": return "bank";
|
|
6441
|
+
case "mobile_money": return "mobile-money";
|
|
6442
|
+
case "external_account": return "wallet";
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
function destinationKindFromBackend(kind) {
|
|
6446
|
+
switch (kind) {
|
|
6447
|
+
case "bank": return "bank_account";
|
|
6448
|
+
case "mobile-money": return "mobile_money";
|
|
6449
|
+
case "wallet": return "external_account";
|
|
6450
|
+
}
|
|
6451
|
+
}
|
|
6452
|
+
function destinationRailFromBackend(destination) {
|
|
6453
|
+
switch (destination.kind) {
|
|
6454
|
+
case "bank": {
|
|
6455
|
+
const payload = destination.payload;
|
|
6456
|
+
return {
|
|
6457
|
+
kind: "bank",
|
|
6458
|
+
country: payload.country,
|
|
6459
|
+
currency: payload.currency
|
|
6460
|
+
};
|
|
6461
|
+
}
|
|
6462
|
+
case "mobile-money": {
|
|
6463
|
+
const payload = destination.payload;
|
|
6464
|
+
return {
|
|
6465
|
+
kind: "mobile_money",
|
|
6466
|
+
country: payload.country,
|
|
6467
|
+
currency: payload.currency,
|
|
6468
|
+
provider: payload.provider
|
|
6469
|
+
};
|
|
6470
|
+
}
|
|
6471
|
+
case "wallet": return {
|
|
6472
|
+
kind: "chain",
|
|
6473
|
+
network: destination.payload.network,
|
|
6474
|
+
asset: "USD"
|
|
6475
|
+
};
|
|
6476
|
+
}
|
|
6477
|
+
}
|
|
6478
|
+
function destinationFromBackend(destination) {
|
|
6479
|
+
return {
|
|
6480
|
+
...destination,
|
|
6481
|
+
target: targetReferenceFromBackendRef(destination.ref),
|
|
6482
|
+
kind: destinationKindFromBackend(destination.kind),
|
|
6483
|
+
rail: destinationRailFromBackend(destination)
|
|
6484
|
+
};
|
|
6485
|
+
}
|
|
6486
|
+
function normalizeDestinationRefForBackend(ref, field) {
|
|
6487
|
+
if (typeof ref === "object" && ref !== null && "kind" in ref && ref.kind === "capxulUserId") return {
|
|
6488
|
+
ok: false,
|
|
6489
|
+
error: Errors.notImplemented("targets", "reference.capxulUserId")
|
|
6490
|
+
};
|
|
6491
|
+
return normalizeRefForBackend(ref, field);
|
|
6492
|
+
}
|
|
6169
6493
|
function normalizeRefForBackend(ref, field) {
|
|
6170
6494
|
try {
|
|
6171
6495
|
if (typeof ref === "string") throw Errors.invalidInput(field, "recipient must be a typed Ref variant");
|
|
@@ -6228,10 +6552,18 @@ function normalizePaymentTiming$1(payment) {
|
|
|
6228
6552
|
}
|
|
6229
6553
|
function mapOk$1(result, f) {
|
|
6230
6554
|
if (!result.ok) return result;
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6555
|
+
try {
|
|
6556
|
+
return {
|
|
6557
|
+
ok: true,
|
|
6558
|
+
value: f(result.value)
|
|
6559
|
+
};
|
|
6560
|
+
} catch (cause) {
|
|
6561
|
+
if (cause instanceof Error && "code" in cause) return {
|
|
6562
|
+
ok: false,
|
|
6563
|
+
error: cause
|
|
6564
|
+
};
|
|
6565
|
+
throw cause;
|
|
6566
|
+
}
|
|
6235
6567
|
}
|
|
6236
6568
|
async function runIfActive(signal, operation, effect) {
|
|
6237
6569
|
if (signal?.aborted === true) return {
|
|
@@ -6753,30 +7085,6 @@ function inviteMemberProgram(orgId, input) {
|
|
|
6753
7085
|
return member;
|
|
6754
7086
|
});
|
|
6755
7087
|
}
|
|
6756
|
-
function pendingMembersProgram(orgId) {
|
|
6757
|
-
return Effect.gen(function* () {
|
|
6758
|
-
const deps = yield* OrgDepsTag;
|
|
6759
|
-
if (deps.orgPort?.pendingMembers !== void 0) return yield* deps.orgPort.pendingMembers({ orgId }).pipe(Effect.mapError((error) => error.publicError));
|
|
6760
|
-
if (deps.orgPort !== void 0) return (yield* deps.orgPort.listMembers({ orgId }).pipe(Effect.mapError((error) => error.publicError))).filter((member) => member.status === "pending" || member.status === "pending_safe" || member.status === "pending_grant");
|
|
6761
|
-
return [];
|
|
6762
|
-
});
|
|
6763
|
-
}
|
|
6764
|
-
function resendInviteTokenProgram(orgId, email) {
|
|
6765
|
-
return Effect.gen(function* () {
|
|
6766
|
-
const deps = yield* OrgDepsTag;
|
|
6767
|
-
if (deps.orgPort?.resendInviteToken !== void 0) return yield* deps.orgPort.resendInviteToken({
|
|
6768
|
-
orgId,
|
|
6769
|
-
email
|
|
6770
|
-
}).pipe(Effect.mapError((error) => error.publicError));
|
|
6771
|
-
if (!isHermeticOrgDeps(deps)) return yield* Effect.fail(missingLiveOrgDep("orgPort.resendInviteToken"));
|
|
6772
|
-
return hermeticMember({
|
|
6773
|
-
orgId,
|
|
6774
|
-
email,
|
|
6775
|
-
role: "Member",
|
|
6776
|
-
status: "pending"
|
|
6777
|
-
});
|
|
6778
|
-
});
|
|
6779
|
-
}
|
|
6780
7088
|
function detectAndAcceptPendingInvitationsProgram() {
|
|
6781
7089
|
return Effect.gen(function* () {
|
|
6782
7090
|
const deps = yield* OrgDepsTag;
|
|
@@ -7045,6 +7353,32 @@ function makeOrgMethods(deps) {
|
|
|
7045
7353
|
});
|
|
7046
7354
|
return toCapxulResult(readTreasuryProgram(orgId), layer);
|
|
7047
7355
|
},
|
|
7356
|
+
account: { async get(options) {
|
|
7357
|
+
if (options?.signal?.aborted) return {
|
|
7358
|
+
ok: false,
|
|
7359
|
+
error: Errors.cancelled({ operation: "org.account.get" })
|
|
7360
|
+
};
|
|
7361
|
+
const treasury = await toCapxulResult(readTreasuryProgram(orgId), layer);
|
|
7362
|
+
if (!treasury.ok) return {
|
|
7363
|
+
ok: false,
|
|
7364
|
+
error: treasury.error
|
|
7365
|
+
};
|
|
7366
|
+
const orgs = await toCapxulResult(listOrgsProgram(), layer);
|
|
7367
|
+
if (!orgs.ok) return {
|
|
7368
|
+
ok: false,
|
|
7369
|
+
error: orgs.error
|
|
7370
|
+
};
|
|
7371
|
+
const org = orgs.value.find((candidate) => candidate.id === orgId);
|
|
7372
|
+
return {
|
|
7373
|
+
ok: true,
|
|
7374
|
+
value: {
|
|
7375
|
+
id: treasury.value.id,
|
|
7376
|
+
address: org?.safeAddress ?? null,
|
|
7377
|
+
balance: treasury.value.balance,
|
|
7378
|
+
available: treasury.value.available
|
|
7379
|
+
}
|
|
7380
|
+
};
|
|
7381
|
+
} },
|
|
7048
7382
|
members(_options) {
|
|
7049
7383
|
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7050
7384
|
ok: false,
|
|
@@ -7073,20 +7407,6 @@ function makeOrgMethods(deps) {
|
|
|
7073
7407
|
});
|
|
7074
7408
|
return toCapxulResult(inviteMemberProgram(orgId, _input), layer);
|
|
7075
7409
|
},
|
|
7076
|
-
pendingMembers(_options) {
|
|
7077
|
-
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7078
|
-
ok: false,
|
|
7079
|
-
error: Errors.cancelled({ operation: "org.pendingMembers" })
|
|
7080
|
-
});
|
|
7081
|
-
return toCapxulResult(pendingMembersProgram(orgId), layer);
|
|
7082
|
-
},
|
|
7083
|
-
inviteToken: { resend(_input, _options) {
|
|
7084
|
-
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7085
|
-
ok: false,
|
|
7086
|
-
error: Errors.cancelled({ operation: "org.inviteToken.resend" })
|
|
7087
|
-
});
|
|
7088
|
-
return toCapxulResult(resendInviteTokenProgram(orgId, String(_input.email)), layer);
|
|
7089
|
-
} },
|
|
7090
7410
|
removeMember(_input, _options) {
|
|
7091
7411
|
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7092
7412
|
ok: false,
|
|
@@ -7115,6 +7435,16 @@ function makeOrgMethods(deps) {
|
|
|
7115
7435
|
});
|
|
7116
7436
|
return toCapxulResult(batchPayrollProgram(orgId, _input), layer);
|
|
7117
7437
|
},
|
|
7438
|
+
auditLog(_options) {
|
|
7439
|
+
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7440
|
+
ok: false,
|
|
7441
|
+
error: Errors.cancelled({ operation: "org.auditLog" })
|
|
7442
|
+
});
|
|
7443
|
+
return Promise.resolve({
|
|
7444
|
+
ok: false,
|
|
7445
|
+
error: Errors.notImplemented("organizationAuditLog", "list")
|
|
7446
|
+
});
|
|
7447
|
+
},
|
|
7118
7448
|
payroll: convexCall === void 0 ? makeNotImplementedPayrollMethods() : makePayrollMethods({
|
|
7119
7449
|
orgId: String(orgId),
|
|
7120
7450
|
convexCall
|
|
@@ -7469,6 +7799,12 @@ function assembleCapxulClient(input) {
|
|
|
7469
7799
|
if (selectedOrgPort !== void 0) detectPendingOrgInvitations = async () => {
|
|
7470
7800
|
await orgMethods.orgs.detectAndAcceptPendingInvitations();
|
|
7471
7801
|
};
|
|
7802
|
+
const currentUser = makeCurrentUserMethods({
|
|
7803
|
+
me: financialOps.me,
|
|
7804
|
+
accounts,
|
|
7805
|
+
smartAccount,
|
|
7806
|
+
orgs: orgMethods.orgs
|
|
7807
|
+
});
|
|
7472
7808
|
const onboarding = makeOnboardingMethods({
|
|
7473
7809
|
currentSession: async () => {
|
|
7474
7810
|
const session = await currentSession(actor, authCache);
|
|
@@ -7489,11 +7825,15 @@ function assembleCapxulClient(input) {
|
|
|
7489
7825
|
identity,
|
|
7490
7826
|
account,
|
|
7491
7827
|
accounts,
|
|
7828
|
+
currentUser,
|
|
7492
7829
|
me: financialOps.me,
|
|
7493
7830
|
handles: financialOps.handles,
|
|
7494
7831
|
payees: financialOps.payees,
|
|
7832
|
+
targets: financialOps.targets,
|
|
7495
7833
|
destinations: financialOps.destinations,
|
|
7496
7834
|
payments: financialOps.payments,
|
|
7835
|
+
activity: financialOps.activity,
|
|
7836
|
+
offramp: financialOps.offramp,
|
|
7497
7837
|
paymentDocuments: financialOps.paymentDocuments,
|
|
7498
7838
|
paymentRequests: financialOps.paymentRequests,
|
|
7499
7839
|
workbench: financialOps.workbench,
|
|
@@ -7969,6 +8309,6 @@ async function createCapxulClient(input) {
|
|
|
7969
8309
|
return createCapxulClient$1(input);
|
|
7970
8310
|
}
|
|
7971
8311
|
//#endregion
|
|
7972
|
-
export { captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, injectedWalletSigner, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort };
|
|
8312
|
+
export { CapxulError, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, injectedWalletSigner, isCapxulError, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort };
|
|
7973
8313
|
|
|
7974
8314
|
//# sourceMappingURL=index.mjs.map
|