@capxul/cli 4.20.0-beta.26 → 4.20.0-beta.27
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/README.md +25 -31
- package/dist/browser/signer.js +28 -10
- package/dist/browser/signer.js.map +1 -1
- package/dist/{entry-CXlsnqyc.mjs → entry-GLdITgH4.mjs} +1171 -1519
- package/dist/entry-GLdITgH4.mjs.map +1 -0
- package/dist/{fast-BYzVdpNs.mjs → fast-BQEiHMyp.mjs} +2 -2
- package/dist/{fast-BYzVdpNs.mjs.map → fast-BQEiHMyp.mjs.map} +1 -1
- package/dist/main.mjs +2 -2
- package/dist/{where-view-C0WT0ARR.mjs → where-view-Csv4lEES.mjs} +2 -2
- package/dist/{where-view-C0WT0ARR.mjs.map → where-view-Csv4lEES.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/entry-CXlsnqyc.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __exportAll, o as __require, r as __commonJSMin, s as __toESM } from "./lib-DnmstTkB.mjs";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as assertSize, B as pad, C as keccak256$1, D as createCursor, E as toRlp, F as boolToHex, G as IntegerOutOfRangeError, H as trim$1, I as bytesToHex, K as InvalidBytesBooleanError, L as numberToHex, M as hexToNumber, N as hexToBytes, O as concat$1, P as toBytes$1, R as stringToHex, S as getAddress$1, T as format, U as size, V as padHex, W as isHex$1, _ as readField, a as ENVIRONMENT_NAMES, b as isAddress$1, d as explicitOrganization$2, f as flagValue, g as isRecord, h as parseWhere, j as hexToBigInt, k as concatHex, l as describeWhere, m as networkName, n as styleFor, o as STAGING_ORIGIN, p as flagValues, q as BaseError$1, r as whoamiLines, s as chooseEnvironment, t as headerLine, u as environmentOf, v as slice, w as InvalidAddressError, x as checksumAddress, y as sliceBytes, z as toHex } from "./where-view-Csv4lEES.mjs";
|
|
3
3
|
import { t as require_lib } from "./lib-CoGPQsbr.mjs";
|
|
4
4
|
import process$1, { arch, platform } from "node:process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -4844,10 +4844,19 @@ const ApprovalNetworkSchema = Schema.Struct({
|
|
|
4844
4844
|
name: Schema.String,
|
|
4845
4845
|
explorerUrl: Schema.String
|
|
4846
4846
|
});
|
|
4847
|
+
/**
|
|
4848
|
+
* Whose money the operation moves: the person's own, or an Organization's,
|
|
4849
|
+
* which a reader follows through that Organization's scope.
|
|
4850
|
+
*/
|
|
4851
|
+
const ApprovalActorSchema = Schema.Union([Schema.Struct({ kind: Schema.Literal("personal") }), Schema.Struct({
|
|
4852
|
+
kind: Schema.Literal("organization"),
|
|
4853
|
+
orgId: Schema.NonEmptyString
|
|
4854
|
+
})]);
|
|
4847
4855
|
/** What the person reads before they sign. */
|
|
4848
4856
|
const ApprovalSummarySchema = Schema.Struct({
|
|
4849
4857
|
title: Schema.String,
|
|
4850
4858
|
from: Schema.Struct({
|
|
4859
|
+
kind: Schema.Literals(["personal", "organization"]),
|
|
4851
4860
|
label: Schema.String,
|
|
4852
4861
|
address: AddressSchema$1
|
|
4853
4862
|
}),
|
|
@@ -4869,6 +4878,7 @@ const ApprovalSchema = Schema.Struct({
|
|
|
4869
4878
|
url: Schema.String,
|
|
4870
4879
|
kind: Schema.Literals(APPROVAL_KINDS),
|
|
4871
4880
|
state: Schema.Literals(APPROVAL_STATES),
|
|
4881
|
+
actor: ApprovalActorSchema,
|
|
4872
4882
|
summary: ApprovalSummarySchema,
|
|
4873
4883
|
operation: ApprovalOperationSchema,
|
|
4874
4884
|
/** Who must sign: the owner key of the paying Safe. */
|
|
@@ -5023,7 +5033,7 @@ faucetMint: Operation.action("accounts.grants.faucetMint", {
|
|
|
5023
5033
|
]
|
|
5024
5034
|
}) };
|
|
5025
5035
|
/** Every approval call: the record is not the signed-in person's, or there is none. */
|
|
5026
|
-
const APPROVAL = ["ROLE_PERMISSION_DENIED"];
|
|
5036
|
+
const APPROVAL$1 = ["ROLE_PERMISSION_DENIED"];
|
|
5027
5037
|
/**
|
|
5028
5038
|
* A prepared money action waits here for the person to sign it with their own
|
|
5029
5039
|
* key, on the approval page. The backend never signs: it records the person's
|
|
@@ -5048,7 +5058,7 @@ const approvals = {
|
|
|
5048
5058
|
errors: [
|
|
5049
5059
|
...CALL$10,
|
|
5050
5060
|
...DEFECTS,
|
|
5051
|
-
...APPROVAL
|
|
5061
|
+
...APPROVAL$1
|
|
5052
5062
|
]
|
|
5053
5063
|
}),
|
|
5054
5064
|
/** The person opened the approval page: stamp the first review of a pending approval. */
|
|
@@ -5058,7 +5068,7 @@ const approvals = {
|
|
|
5058
5068
|
errors: [
|
|
5059
5069
|
...CALL$10,
|
|
5060
5070
|
...DEFECTS,
|
|
5061
|
-
...APPROVAL
|
|
5071
|
+
...APPROVAL$1
|
|
5062
5072
|
]
|
|
5063
5073
|
}),
|
|
5064
5074
|
/**
|
|
@@ -5074,7 +5084,7 @@ const approvals = {
|
|
|
5074
5084
|
errors: [
|
|
5075
5085
|
...CALL$10,
|
|
5076
5086
|
...DEFECTS,
|
|
5077
|
-
...APPROVAL,
|
|
5087
|
+
...APPROVAL$1,
|
|
5078
5088
|
"WRONG_STATE"
|
|
5079
5089
|
]
|
|
5080
5090
|
}),
|
|
@@ -5085,7 +5095,7 @@ const approvals = {
|
|
|
5085
5095
|
errors: [
|
|
5086
5096
|
...CALL$10,
|
|
5087
5097
|
...DEFECTS,
|
|
5088
|
-
...APPROVAL,
|
|
5098
|
+
...APPROVAL$1,
|
|
5089
5099
|
"WRONG_STATE"
|
|
5090
5100
|
]
|
|
5091
5101
|
}),
|
|
@@ -5096,7 +5106,7 @@ const approvals = {
|
|
|
5096
5106
|
errors: [
|
|
5097
5107
|
...CALL$10,
|
|
5098
5108
|
...DEFECTS,
|
|
5099
|
-
...APPROVAL,
|
|
5109
|
+
...APPROVAL$1,
|
|
5100
5110
|
"WRONG_STATE"
|
|
5101
5111
|
]
|
|
5102
5112
|
})
|
|
@@ -9528,7 +9538,11 @@ const ORGANIZATION_OPERATIONS = {
|
|
|
9528
9538
|
seedNativeReadiness: "operator.fixtures.seedNativeReadiness",
|
|
9529
9539
|
seedPrerequisites: "operator.fixtures.seedPrerequisites"
|
|
9530
9540
|
},
|
|
9531
|
-
identities: {
|
|
9541
|
+
identities: {
|
|
9542
|
+
purgeByEmail: "operator.identities.purgeByEmail",
|
|
9543
|
+
/** One Account and every row that refers to it, unless it has Payments or an Organization tie. */
|
|
9544
|
+
purgeAccount: "operator.identities.purgeAccount"
|
|
9545
|
+
}
|
|
9532
9546
|
},
|
|
9533
9547
|
/** Organizations' internal functions; its public rows join from `OPERATIONS`. */
|
|
9534
9548
|
organizations: {
|
|
@@ -9778,7 +9792,11 @@ const PLATFORM_OPERATIONS = {
|
|
|
9778
9792
|
recordUse: "applications.bootstraps.recordUse",
|
|
9779
9793
|
resolve: "applications.bootstraps.resolve"
|
|
9780
9794
|
},
|
|
9781
|
-
keys: {
|
|
9795
|
+
keys: {
|
|
9796
|
+
issue: "applications.keys.issue",
|
|
9797
|
+
/** Operator-only: revoke one key by its id, whoever owns it. */
|
|
9798
|
+
revokeById: "applications.keys.revokeById"
|
|
9799
|
+
},
|
|
9782
9800
|
quickstarts: {
|
|
9783
9801
|
claim: "applications.quickstarts.claim",
|
|
9784
9802
|
mint: "applications.quickstarts.mint"
|
|
@@ -14852,7 +14870,7 @@ function mapAccountLifecycle(input) {
|
|
|
14852
14870
|
}
|
|
14853
14871
|
//#endregion
|
|
14854
14872
|
//#region ../../packages/sdk/package.json
|
|
14855
|
-
var version$2 = "4.20.0-beta.
|
|
14873
|
+
var version$2 = "4.20.0-beta.27";
|
|
14856
14874
|
//#endregion
|
|
14857
14875
|
//#region ../../packages/sdk/src/observability/telemetry/exception-projection.ts
|
|
14858
14876
|
/** Fixed fallback for failures that have no safe message. */
|
|
@@ -19211,6 +19229,13 @@ function subscribeFreshQuery(deps, args, listener, operation, projection, option
|
|
|
19211
19229
|
}
|
|
19212
19230
|
//#endregion
|
|
19213
19231
|
//#region ../../packages/sdk/src/payments/lifecycle-execution.ts
|
|
19232
|
+
/**
|
|
19233
|
+
* The prepared command is this lifecycle intent; a retry also names the
|
|
19234
|
+
* original birth command of the scope it was asked for.
|
|
19235
|
+
*/
|
|
19236
|
+
const lifecycleCommandCheck = (intent, expectedOrganizationId) => async (request, evidence) => await matchesIntent(intent)(request, evidence) && (intent.kind !== "retry" || (expectedOrganizationId === void 0 ? evidence.sourceCommand?.kind === "birth" && evidence.sourceCommand.actor.kind === "account" : evidence.sourceCommand?.kind === "birth" && evidence.sourceCommand.actor.kind === "organization" && evidence.sourceCommand.actor.orgId === expectedOrganizationId));
|
|
19237
|
+
/** The prepared command pays exactly the request the payer confirmed. */
|
|
19238
|
+
const requestPaymentCheck = (confirmation) => async (request) => "kind" in request && request.kind === "payment_request" && canonicalJson(request.confirmation) === canonicalJson(confirmation);
|
|
19214
19239
|
function executePaymentLifecycle(deps, intent, signal, controls, expectedOrganizationId, onPrepared) {
|
|
19215
19240
|
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, lifecycles.prepareScoped, copyInvocationObservation(controls, {
|
|
19216
19241
|
signerAddress,
|
|
@@ -19219,13 +19244,13 @@ function executePaymentLifecycle(deps, intent, signal, controls, expectedOrganiz
|
|
|
19219
19244
|
kind: "organization",
|
|
19220
19245
|
orgId: expectedOrganizationId
|
|
19221
19246
|
}
|
|
19222
|
-
})).pipe(Effect.mapError((publicError) => ({ publicError })))), controls), deps.runPromise),
|
|
19247
|
+
})).pipe(Effect.mapError((publicError) => ({ publicError })))), controls), deps.runPromise), lifecycleCommandCheck(intent, expectedOrganizationId), false, void 0, signal, controls, onPrepared);
|
|
19223
19248
|
}
|
|
19224
19249
|
function executeRequestPayment(deps, confirmation, controls, onPrepared) {
|
|
19225
19250
|
return executePrepared(deps, (signerAddress) => runIfActive(controls?.signal, commands$1.prepareRequest.name, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, commands$1.prepareRequest, copyInvocationObservation(controls, {
|
|
19226
19251
|
confirmation,
|
|
19227
19252
|
signerAddress
|
|
19228
|
-
})).pipe(Effect.mapError((publicError) => ({ publicError })))), controls), deps.runPromise),
|
|
19253
|
+
})).pipe(Effect.mapError((publicError) => ({ publicError })))), controls), deps.runPromise), requestPaymentCheck(confirmation), false, void 0, controls?.signal, controls, onPrepared);
|
|
19229
19254
|
}
|
|
19230
19255
|
function executeOrganizationPayment(deps, input, signal, onPreparedClosed, controls, onPrepared) {
|
|
19231
19256
|
return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.organizationPayments.prepareExecution, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, commands$1.prepareOrganization, copyInvocationObservation(controls, {
|
|
@@ -21705,6 +21730,524 @@ function sleep(ms, signal) {
|
|
|
21705
21730
|
});
|
|
21706
21731
|
}
|
|
21707
21732
|
//#endregion
|
|
21733
|
+
//#region ../../packages/protocol/src/payroll/model.ts
|
|
21734
|
+
function toPayrollRunId(raw) {
|
|
21735
|
+
return toNonEmptyStringBrand(raw, "payrollRunId", (value) => isNonEmptyString(value));
|
|
21736
|
+
}
|
|
21737
|
+
function toPayrollGroupId(raw) {
|
|
21738
|
+
return toNonEmptyStringBrand(raw, "payrollGroupId", (value) => isNonEmptyString(value));
|
|
21739
|
+
}
|
|
21740
|
+
//#endregion
|
|
21741
|
+
//#region ../../packages/sdk/src/payroll/run-checks.ts
|
|
21742
|
+
/** Match the caller's compensation to the committed V3 Payslip. */
|
|
21743
|
+
function payslipIdentityMatches(message, item, index, runId, period) {
|
|
21744
|
+
return message.runId === runId && message.itemIndex === index && message.employeeRef === item.partyId && message.periodStart === period.start && message.periodEnd === period.end && message.adjustmentsHash === hashAdjustmentsV3(item.adjustments);
|
|
21745
|
+
}
|
|
21746
|
+
function payslipAmountMatches(message, item) {
|
|
21747
|
+
const exact = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
21748
|
+
return message.gross.asset === exact.asset && message.gross.minorUnits === item.gross && message.gross.decimals === exact.decimals && message.net.asset === exact.asset && message.net.minorUnits === item.net && message.net.decimals === exact.decimals;
|
|
21749
|
+
}
|
|
21750
|
+
function isRunItem(prepared, item, evidence, index, runId, period) {
|
|
21751
|
+
if (prepared === void 0) return false;
|
|
21752
|
+
const bundle = evidence.preparedCommand?.documentBundles?.[index];
|
|
21753
|
+
const preparedItem = evidence.preparedCommand?.items[index];
|
|
21754
|
+
const payslip = bundle?.envelope;
|
|
21755
|
+
if (bundle === void 0 || payslip?.primaryType !== "Payslip") return false;
|
|
21756
|
+
return canonicalJson(prepared.to) === canonicalJson(item.to) && prepared.paymentType === "payroll" && canonicalJson(prepared.amount) === canonicalJson(item.amount) && bundle.adjustments !== void 0 && canonicalJson(bundle.adjustments) === canonicalJson(item.adjustments) && payslipIdentityMatches(payslip.message, item, index, runId, period) && payslipAmountMatches(payslip.message, item) && (preparedItem?.operation === "send" || preparedItem?.operation === "create_commitment") && preparedItem.documentHash === evidence.preparedCommand?.instructionDocuments?.[index]?.documentHash;
|
|
21757
|
+
}
|
|
21758
|
+
/**
|
|
21759
|
+
* The batch the backend derived from a payroll intent must be the batch this
|
|
21760
|
+
* caller asked for, checked before the digest is signed.
|
|
21761
|
+
*
|
|
21762
|
+
* The payslip envelope on each item is server-built and carries the run row's
|
|
21763
|
+
* own `issuedAt`, so the batch cannot be fingerprinted against a local copy
|
|
21764
|
+
* (`matchesIntent` is unavailable here). What CAN be verified is every field
|
|
21765
|
+
* the caller supplied — the org, the Budget, the request key, and per item the
|
|
21766
|
+
* recipient, the amount and the payslip figures — plus the lineage binding the
|
|
21767
|
+
* batch to the run just written. A prepared command that pays a different
|
|
21768
|
+
* person, a different amount, from a different Budget, or under a different
|
|
21769
|
+
* run never reaches the signer.
|
|
21770
|
+
*/
|
|
21771
|
+
function isRunBatch(input) {
|
|
21772
|
+
return (batch, evidence) => Promise.resolve(!("kind" in batch) && batch.orgId === input.orgId && batch.permissionId === input.permissionId && batch.requestKey === input.requestKey && batch.lineage?.kind === "payroll" && batch.lineage.runId === input.runId && batch.items.length === input.items.length && batch.items.every((item) => item.amount.asset === input.asset) && input.items.every((item, index) => isRunItem(batch.items[index], item, evidence, index, input.runId, input.period)));
|
|
21773
|
+
}
|
|
21774
|
+
/**
|
|
21775
|
+
* The batch is `isRunBatch` for the run the backend just wrote, and that run
|
|
21776
|
+
* is the period the caller asked for: the payslip's `period` is a
|
|
21777
|
+
* server-formatted label, so the stored run is where the caller's own two
|
|
21778
|
+
* numbers are checkable.
|
|
21779
|
+
*/
|
|
21780
|
+
function isAuthorizedRunBatch(input, run) {
|
|
21781
|
+
return (request, evidence) => run === void 0 || run.periodStart !== input.period.start || run.periodEnd !== input.period.end ? Promise.resolve(false) : isRunBatch({
|
|
21782
|
+
...input,
|
|
21783
|
+
runId: run.id
|
|
21784
|
+
})(request, evidence);
|
|
21785
|
+
}
|
|
21786
|
+
/** A decoded detail is the run asked for, whole: its scope, membership and quantities agree. */
|
|
21787
|
+
function checkPayrollRunDetail(value, orgId, runId) {
|
|
21788
|
+
if (value === null) return {
|
|
21789
|
+
ok: true,
|
|
21790
|
+
value: null
|
|
21791
|
+
};
|
|
21792
|
+
if (value.orgId !== orgId || value.run.id !== runId || value.items.length === 0 || value.items.length !== value.run.recipientCount || new Set(value.items.map((item) => item.payment.id)).size !== value.items.length || value.items.some((item, index) => item.itemIndex !== index || item.amount.asset !== value.run.total.asset || item.payment.amount.asset !== item.amount.asset || item.payment.paymentType !== "payroll")) return {
|
|
21793
|
+
ok: false,
|
|
21794
|
+
error: Errors.invalidInput("run", "Payroll run scope or membership does not match")
|
|
21795
|
+
};
|
|
21796
|
+
try {
|
|
21797
|
+
const total = toExactAssetAmount(value.run.total, CONFIGURED_MONEY_ASSETS);
|
|
21798
|
+
let rawTotal = 0n;
|
|
21799
|
+
for (const item of value.items) {
|
|
21800
|
+
const amount = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
21801
|
+
const payment = toExactAssetAmount(item.payment.amount, CONFIGURED_MONEY_ASSETS);
|
|
21802
|
+
if (amount.minorUnits !== payment.minorUnits) return {
|
|
21803
|
+
ok: false,
|
|
21804
|
+
error: Errors.invalidInput("run", "Payroll item quantity does not match its Payment")
|
|
21805
|
+
};
|
|
21806
|
+
rawTotal += BigInt(amount.minorUnits);
|
|
21807
|
+
}
|
|
21808
|
+
if (rawTotal !== BigInt(total.minorUnits)) return {
|
|
21809
|
+
ok: false,
|
|
21810
|
+
error: Errors.invalidInput("run", "Payroll run total does not match its items")
|
|
21811
|
+
};
|
|
21812
|
+
} catch {
|
|
21813
|
+
return {
|
|
21814
|
+
ok: false,
|
|
21815
|
+
error: Errors.invalidInput("run", "Payroll run quantities are invalid")
|
|
21816
|
+
};
|
|
21817
|
+
}
|
|
21818
|
+
return {
|
|
21819
|
+
ok: true,
|
|
21820
|
+
value
|
|
21821
|
+
};
|
|
21822
|
+
}
|
|
21823
|
+
//#endregion
|
|
21824
|
+
//#region ../../packages/sdk/src/payroll/run-decoding.ts
|
|
21825
|
+
function toPayrollRun(wire) {
|
|
21826
|
+
return {
|
|
21827
|
+
id: toPayrollRunId(wire.id),
|
|
21828
|
+
status: wire.status,
|
|
21829
|
+
periodStart: wire.periodStart,
|
|
21830
|
+
periodEnd: wire.periodEnd,
|
|
21831
|
+
total: wire.total,
|
|
21832
|
+
recipientCount: wire.recipientCount
|
|
21833
|
+
};
|
|
21834
|
+
}
|
|
21835
|
+
function toPayrollRuns(wire) {
|
|
21836
|
+
return {
|
|
21837
|
+
...mapPage(wire, toPayrollRun),
|
|
21838
|
+
settledThisMonth: wire.settledThisMonth
|
|
21839
|
+
};
|
|
21840
|
+
}
|
|
21841
|
+
function toPayrollGroup(wire) {
|
|
21842
|
+
return {
|
|
21843
|
+
id: toPayrollGroupId(wire.id),
|
|
21844
|
+
name: wire.name,
|
|
21845
|
+
tone: wire.tone,
|
|
21846
|
+
members: wire.members.map((member) => ({
|
|
21847
|
+
partyId: member.partyId,
|
|
21848
|
+
amount: member.amount,
|
|
21849
|
+
currency: member.currency
|
|
21850
|
+
}))
|
|
21851
|
+
};
|
|
21852
|
+
}
|
|
21853
|
+
function validateRunItems(input) {
|
|
21854
|
+
for (const [index, item] of input.items.entries()) {
|
|
21855
|
+
if (Schema.decodeResult(PayrollRunItemInputSchema, { onExcessProperty: "error" })(item)._tag === "Failure") return Errors.invalidInput(`items.${index}`, "invalid Payroll item");
|
|
21856
|
+
try {
|
|
21857
|
+
const exact = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
21858
|
+
const net = BigInt(item.net);
|
|
21859
|
+
const gross = BigInt(item.gross);
|
|
21860
|
+
const adjustments = item.adjustments.reduce((sum, row) => sum + BigInt(row.amount), 0n);
|
|
21861
|
+
if (item.amount.asset !== input.asset || item.net !== exact.minorUnits || gross + adjustments !== net) return Errors.invalidInput(`items.${index}`, "invalid Payroll units");
|
|
21862
|
+
} catch {
|
|
21863
|
+
return Errors.invalidInput(`items.${index}`, "invalid Payroll units");
|
|
21864
|
+
}
|
|
21865
|
+
}
|
|
21866
|
+
return null;
|
|
21867
|
+
}
|
|
21868
|
+
const RunInputSchema = Schema.Struct({
|
|
21869
|
+
permissionId: AuthorizePayrollRunExecutionInputSchema.fields.permissionId,
|
|
21870
|
+
asset: AuthorizePayrollRunExecutionInputSchema.fields.asset,
|
|
21871
|
+
period: AuthorizePayrollRunExecutionInputSchema.fields.period,
|
|
21872
|
+
items: AuthorizePayrollRunExecutionInputSchema.fields.items,
|
|
21873
|
+
requestKey: Schema.optional(AuthorizePayrollRunExecutionInputSchema.fields.requestKey)
|
|
21874
|
+
});
|
|
21875
|
+
/** Decode caller input before session or signer work. Keep routing outside the input. */
|
|
21876
|
+
function decodePayrollRunInput(value) {
|
|
21877
|
+
try {
|
|
21878
|
+
const decoded = Schema.decodeUnknownSync(RunInputSchema, { onExcessProperty: "error" })(value);
|
|
21879
|
+
const input = {
|
|
21880
|
+
permissionId: decoded.permissionId,
|
|
21881
|
+
asset: decoded.asset,
|
|
21882
|
+
period: decoded.period,
|
|
21883
|
+
...decoded.requestKey === void 0 ? {} : { requestKey: decoded.requestKey },
|
|
21884
|
+
items: decoded.items.map((item) => ({
|
|
21885
|
+
amount: item.amount,
|
|
21886
|
+
gross: item.gross,
|
|
21887
|
+
net: item.net,
|
|
21888
|
+
adjustments: item.adjustments,
|
|
21889
|
+
partyId: toPartyId(item.partyId),
|
|
21890
|
+
to: item.to.kind === "party" ? {
|
|
21891
|
+
kind: "party",
|
|
21892
|
+
partyId: toPartyId(item.to.partyId)
|
|
21893
|
+
} : item.to.kind === "address" ? {
|
|
21894
|
+
kind: "address",
|
|
21895
|
+
address: toAddress(item.to.address)
|
|
21896
|
+
} : item.to
|
|
21897
|
+
}))
|
|
21898
|
+
};
|
|
21899
|
+
if (input.items.length === 0 || input.period.start > input.period.end) throw Errors.invalidInput("input", "Payroll requires items and an ordered period");
|
|
21900
|
+
const error = validateRunItems(input);
|
|
21901
|
+
if (error !== null) throw error;
|
|
21902
|
+
return input;
|
|
21903
|
+
} catch (cause) {
|
|
21904
|
+
throw cause instanceof CapxulError ? cause : Errors.invalidInput("input", "Invalid Payroll input");
|
|
21905
|
+
}
|
|
21906
|
+
}
|
|
21907
|
+
/** Read only the exact backend prepare receipt, never an arbitrary signer failure. */
|
|
21908
|
+
function payrollResolution(error, requestKey) {
|
|
21909
|
+
const details = error.details;
|
|
21910
|
+
if (error.code !== "WRONG_STATE" || details?.method !== runs.authorize.name || details.requestKey !== requestKey || typeof details.commandId !== "string" || typeof details.runId !== "string") return void 0;
|
|
21911
|
+
return details.payrollResolution === "failed" || details.payrollResolution === "settled" ? details.payrollResolution : void 0;
|
|
21912
|
+
}
|
|
21913
|
+
function validatePayrollRunLookup(orgId, runId) {
|
|
21914
|
+
return !Schema.is(PayrollRunIdSchema)(runId) || orgId.length === 0 ? {
|
|
21915
|
+
ok: false,
|
|
21916
|
+
error: Errors.invalidInput("runId", "Organization and run ID must be valid")
|
|
21917
|
+
} : {
|
|
21918
|
+
ok: true,
|
|
21919
|
+
value: void 0
|
|
21920
|
+
};
|
|
21921
|
+
}
|
|
21922
|
+
/** Strict saved detail decoder shared by the read and fresh stream. */
|
|
21923
|
+
function decodePayrollRunDetail(raw, orgId, runId) {
|
|
21924
|
+
const decoded = Schema.decodeUnknownResult(Schema.NullOr(PayrollRunDetailSchema), { onExcessProperty: "error" })(raw);
|
|
21925
|
+
if (decoded._tag === "Failure") return {
|
|
21926
|
+
ok: false,
|
|
21927
|
+
error: Errors.invalidInput("run", "Invalid Payroll run detail")
|
|
21928
|
+
};
|
|
21929
|
+
return checkPayrollRunDetail(decoded.success, orgId, runId);
|
|
21930
|
+
}
|
|
21931
|
+
//#endregion
|
|
21932
|
+
//#region ../../packages/sdk/src/payroll/run-subscription.ts
|
|
21933
|
+
function detailValue(result) {
|
|
21934
|
+
if (!result.ok) throw result.error;
|
|
21935
|
+
return result.value;
|
|
21936
|
+
}
|
|
21937
|
+
function subscribePayrollRun(deps, orgId, runId, listener, options) {
|
|
21938
|
+
const operation = CAPXUL_OPERATIONS.org.payroll.subscribeRun;
|
|
21939
|
+
const valid = deps.validate(orgId, runId);
|
|
21940
|
+
if (!valid.ok) return runCapxulEffect(Effect.fail(valid.error), observationOnlyControls(deps.invocationControls?.(options) ?? options), operation, deps.runPromise);
|
|
21941
|
+
const decode = (raw) => detailValue(deps.decode(raw, orgId, runId));
|
|
21942
|
+
return subscribeFreshQuery(deps, {
|
|
21943
|
+
orgId,
|
|
21944
|
+
runId
|
|
21945
|
+
}, listener, operation, {
|
|
21946
|
+
decode,
|
|
21947
|
+
validateCached: (raw) => {
|
|
21948
|
+
decode(raw);
|
|
21949
|
+
},
|
|
21950
|
+
invalidValue: (cause) => isCapxulError(cause) ? cause : Errors.invalidInput("run", "Invalid Payroll run detail"),
|
|
21951
|
+
invalidScope: () => Errors.invalidInput("run", "Payroll run subscription scope does not match"),
|
|
21952
|
+
lostValue: () => Errors.invalidInput("run", "Payroll run is no longer readable"),
|
|
21953
|
+
unavailable: () => Errors.notImplemented("payroll", "subscribeRun")
|
|
21954
|
+
}, options);
|
|
21955
|
+
}
|
|
21956
|
+
//#endregion
|
|
21957
|
+
//#region ../../packages/sdk/src/payroll/run-authorization.ts
|
|
21958
|
+
/**
|
|
21959
|
+
* Authorize one payroll run: a stable request key, the prepared batch checked
|
|
21960
|
+
* against the run the caller asked for, the signature, and the submission.
|
|
21961
|
+
*/
|
|
21962
|
+
async function authorizePayrollRun(scope, input, controls, onRequestKey, onResolved) {
|
|
21963
|
+
const { deps, orgId, requestKeyScope } = scope;
|
|
21964
|
+
const signal = controls?.signal;
|
|
21965
|
+
const execution = executionDependencies(deps);
|
|
21966
|
+
if (execution === null) return {
|
|
21967
|
+
ok: false,
|
|
21968
|
+
error: Errors.notImplemented("payroll", "executionComposition")
|
|
21969
|
+
};
|
|
21970
|
+
try {
|
|
21971
|
+
input = decodePayrollRunInput(input);
|
|
21972
|
+
} catch (cause) {
|
|
21973
|
+
return {
|
|
21974
|
+
ok: false,
|
|
21975
|
+
error: asCapxulError(cause)
|
|
21976
|
+
};
|
|
21977
|
+
}
|
|
21978
|
+
const { requestKey: provided, ...canonicalInput } = input;
|
|
21979
|
+
const actorId = onRequestKey === void 0 ? void 0 : execution.actor.authSession()?.authUserId;
|
|
21980
|
+
if (onRequestKey !== void 0 && actorId === void 0) return {
|
|
21981
|
+
ok: false,
|
|
21982
|
+
error: Errors.notAuthenticated()
|
|
21983
|
+
};
|
|
21984
|
+
const requestKey = await paymentRequestKeyLifecycle(`${requestKeyScope}:${AUTHORIZE_RUN}`, onRequestKey === void 0 ? {
|
|
21985
|
+
orgId,
|
|
21986
|
+
input
|
|
21987
|
+
} : {
|
|
21988
|
+
actorId,
|
|
21989
|
+
orgId,
|
|
21990
|
+
input: canonicalInput
|
|
21991
|
+
}, provided, onRequestKey === void 0 ? void 0 : { manageProvidedKey: true });
|
|
21992
|
+
try {
|
|
21993
|
+
await onRequestKey?.(requestKey.key);
|
|
21994
|
+
if (onRequestKey !== void 0 && execution.actor.authSession()?.authUserId !== actorId) {
|
|
21995
|
+
await requestKey.finish(false).catch(() => void 0);
|
|
21996
|
+
return {
|
|
21997
|
+
ok: false,
|
|
21998
|
+
error: Errors.notAuthenticated()
|
|
21999
|
+
};
|
|
22000
|
+
}
|
|
22001
|
+
} catch (cause) {
|
|
22002
|
+
await requestKey.finish(false).catch(() => void 0);
|
|
22003
|
+
return {
|
|
22004
|
+
ok: false,
|
|
22005
|
+
error: asCapxulError(cause)
|
|
22006
|
+
};
|
|
22007
|
+
}
|
|
22008
|
+
let authorized;
|
|
22009
|
+
let acceptedReplay;
|
|
22010
|
+
let preparedClosed = false;
|
|
22011
|
+
let terminalReplay;
|
|
22012
|
+
const submitted = await executePrepared(execution, async (signerAddress) => {
|
|
22013
|
+
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, runs.authorize, copyInvocationObservation(controls, {
|
|
22014
|
+
orgId,
|
|
22015
|
+
permissionId: input.permissionId,
|
|
22016
|
+
asset: input.asset,
|
|
22017
|
+
requestKey: requestKey.key,
|
|
22018
|
+
signerAddress,
|
|
22019
|
+
period: input.period,
|
|
22020
|
+
items: input.items
|
|
22021
|
+
}))).pipe(Effect.mapError((publicError) => ({ publicError }))), controls), deps.runPromise);
|
|
22022
|
+
if (!prepared.ok) {
|
|
22023
|
+
terminalReplay = payrollResolution(prepared.error, requestKey.key);
|
|
22024
|
+
return prepared;
|
|
22025
|
+
}
|
|
22026
|
+
authorized = prepared.value.run;
|
|
22027
|
+
acceptedReplay = prepared.value.replay.kind === "accepted" ? prepared.value.replay.submission : void 0;
|
|
22028
|
+
return {
|
|
22029
|
+
ok: true,
|
|
22030
|
+
value: prepared.value.execution
|
|
22031
|
+
};
|
|
22032
|
+
}, (request, evidence) => isAuthorizedRunBatch({
|
|
22033
|
+
orgId,
|
|
22034
|
+
permissionId: input.permissionId,
|
|
22035
|
+
requestKey: requestKey.key,
|
|
22036
|
+
asset: input.asset,
|
|
22037
|
+
period: input.period,
|
|
22038
|
+
items: input.items
|
|
22039
|
+
}, authorized)(request, evidence), true, () => preparedClosed = true, signal, controls, void 0, () => acceptedReplay);
|
|
22040
|
+
const resolution = preparedClosed ? "failed" : terminalReplay;
|
|
22041
|
+
if (resolution !== void 0) try {
|
|
22042
|
+
await onResolved?.(resolution);
|
|
22043
|
+
} catch {}
|
|
22044
|
+
try {
|
|
22045
|
+
await requestKey.finish(submitted.ok || resolution !== void 0);
|
|
22046
|
+
} catch {}
|
|
22047
|
+
if (!submitted.ok) return submitted;
|
|
22048
|
+
return authorized === void 0 ? {
|
|
22049
|
+
ok: false,
|
|
22050
|
+
error: Errors.unknown()
|
|
22051
|
+
} : {
|
|
22052
|
+
ok: true,
|
|
22053
|
+
value: toPayrollRun(authorized)
|
|
22054
|
+
};
|
|
22055
|
+
}
|
|
22056
|
+
const AUTHORIZE_RUN = runs.authorize.name;
|
|
22057
|
+
function executionDependencies(deps) {
|
|
22058
|
+
return deps.actor === void 0 || deps.chainId === void 0 || deps.signer === void 0 ? null : {
|
|
22059
|
+
actor: deps.actor,
|
|
22060
|
+
chainId: deps.chainId,
|
|
22061
|
+
convexCall: deps.convexCall,
|
|
22062
|
+
runPromise: deps.runPromise,
|
|
22063
|
+
signer: deps.signer,
|
|
22064
|
+
...deps.telemetry === void 0 ? {} : { telemetry: deps.telemetry }
|
|
22065
|
+
};
|
|
22066
|
+
}
|
|
22067
|
+
//#endregion
|
|
22068
|
+
//#region ../../packages/sdk/src/payroll/runs.ts
|
|
22069
|
+
function makePayrollMethods(deps, orgId) {
|
|
22070
|
+
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
22071
|
+
/** One observed call of one payroll row, its reply projected inside the call, under the row's name. */
|
|
22072
|
+
const call = (row, args, options, project) => {
|
|
22073
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
22074
|
+
return runPortEffect(callOperation(deps.convexCall, row, copyInvocationObservation(controls, args)).pipe(Effect.map(project), Effect.mapError((publicError) => ({ publicError }))), controls, row.name, deps.runPromise);
|
|
22075
|
+
};
|
|
22076
|
+
return {
|
|
22077
|
+
subscribeRun: (runId, listener, options) => subscribePayrollRun({
|
|
22078
|
+
actor: deps.actor,
|
|
22079
|
+
convexCall: deps.convexCall,
|
|
22080
|
+
query: reference(runs.get),
|
|
22081
|
+
runPromise: deps.runPromise,
|
|
22082
|
+
invocationControls: deps.invocationControls,
|
|
22083
|
+
decode: decodePayrollRunDetail,
|
|
22084
|
+
validate: validatePayrollRunLookup
|
|
22085
|
+
}, orgId, runId, listener, options),
|
|
22086
|
+
getRun: (runId, options) => {
|
|
22087
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
22088
|
+
const lifetime = deps.actor?.authLifetime();
|
|
22089
|
+
const operation = runs.get.name;
|
|
22090
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
22091
|
+
const lookup = validatePayrollRunLookup(orgId, runId);
|
|
22092
|
+
if (!lookup.ok) return yield* Effect.fail(lookup.error);
|
|
22093
|
+
if (lifetime === void 0 || lifetime.authUserId === null || deps.actor === void 0) return yield* Effect.fail(Errors.notAuthenticated());
|
|
22094
|
+
const current = () => deps.actor?.matchesAuthLifetime(lifetime, lifetime.authUserId) === true;
|
|
22095
|
+
if (!current()) return yield* Effect.fail(Errors.notAuthenticated());
|
|
22096
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
22097
|
+
const captured = carryInvocationParentSpan(controls, parent);
|
|
22098
|
+
const run = yield* awaitCapxulResult(() => runIfActive(controls?.signal, operation, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, runs.get, copyInvocationObservation(captured, {
|
|
22099
|
+
orgId,
|
|
22100
|
+
runId
|
|
22101
|
+
}))).pipe(Effect.mapError((publicError) => ({ publicError }))), captured), deps.runPromise));
|
|
22102
|
+
if (!current()) return yield* Effect.fail(Errors.cancelled({ operation }));
|
|
22103
|
+
const checked = checkPayrollRunDetail(run, orgId, runId);
|
|
22104
|
+
return yield* checked.ok ? Effect.succeed(checked.value) : Effect.fail(checked.error);
|
|
22105
|
+
}), observationOnlyControls(controls), operation, deps.runPromise);
|
|
22106
|
+
},
|
|
22107
|
+
runs: (options) => call(runs.list, { orgId }, options, toPayrollRuns),
|
|
22108
|
+
authorizeRun: (input, options) => {
|
|
22109
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
22110
|
+
return runCapxulEffect(Effect.gen(function* () {
|
|
22111
|
+
if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: AUTHORIZE_RUN }));
|
|
22112
|
+
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
22113
|
+
return yield* awaitCapxulResult(() => authorizePayrollRun({
|
|
22114
|
+
deps,
|
|
22115
|
+
orgId,
|
|
22116
|
+
requestKeyScope
|
|
22117
|
+
}, input, carryInvocationParentSpan(controls, parent), options?.onRequestKey, options?.onResolved));
|
|
22118
|
+
}), observationOnlyControls(controls), AUTHORIZE_RUN, deps.runPromise);
|
|
22119
|
+
},
|
|
22120
|
+
terms: (options) => call(terms.list, { orgId }, options, (rates) => rates),
|
|
22121
|
+
groups: {
|
|
22122
|
+
list: (options) => call(groups$1.list, { orgId }, options, (saved) => mapPage(saved, toPayrollGroup)),
|
|
22123
|
+
save: (input, options) => call(groups$1.save, {
|
|
22124
|
+
orgId,
|
|
22125
|
+
...input.id === void 0 ? {} : { id: String(input.id) },
|
|
22126
|
+
name: input.name,
|
|
22127
|
+
tone: input.tone,
|
|
22128
|
+
members: input.members
|
|
22129
|
+
}, options, toPayrollGroup),
|
|
22130
|
+
remove: (id, options) => call(groups$1.remove, {
|
|
22131
|
+
orgId,
|
|
22132
|
+
id
|
|
22133
|
+
}, options, () => void 0)
|
|
22134
|
+
}
|
|
22135
|
+
};
|
|
22136
|
+
}
|
|
22137
|
+
const payrollUnavailable = () => Promise.resolve({
|
|
22138
|
+
ok: false,
|
|
22139
|
+
error: Errors.notImplemented("payroll", "executionComposition")
|
|
22140
|
+
});
|
|
22141
|
+
/** The bundle an unconfigured client exposes — every verb refuses, none throws. */
|
|
22142
|
+
function makeUnavailablePayrollMethods() {
|
|
22143
|
+
return {
|
|
22144
|
+
getRun: payrollUnavailable,
|
|
22145
|
+
subscribeRun: payrollUnavailable,
|
|
22146
|
+
runs: payrollUnavailable,
|
|
22147
|
+
authorizeRun: payrollUnavailable,
|
|
22148
|
+
terms: payrollUnavailable,
|
|
22149
|
+
groups: {
|
|
22150
|
+
list: payrollUnavailable,
|
|
22151
|
+
save: payrollUnavailable,
|
|
22152
|
+
remove: payrollUnavailable
|
|
22153
|
+
}
|
|
22154
|
+
};
|
|
22155
|
+
}
|
|
22156
|
+
//#endregion
|
|
22157
|
+
//#region ../../packages/sdk/src/accounts/command-approvals.ts
|
|
22158
|
+
/**
|
|
22159
|
+
* Keep a prepared command only when it is the one asked for and its operation
|
|
22160
|
+
* is the person's own. A mismatch is closed unsent when `close`, as the signed
|
|
22161
|
+
* path closes a new Payment; a retry or a request keeps its Payment open.
|
|
22162
|
+
*/
|
|
22163
|
+
async function checked(deps, signerAddress, prepared, expected, close) {
|
|
22164
|
+
if (!prepared.ok) return prepared;
|
|
22165
|
+
const session = deps.actor?.authSession() ?? null;
|
|
22166
|
+
if (session === null || deps.chainId === void 0) return {
|
|
22167
|
+
ok: false,
|
|
22168
|
+
error: Errors.notAuthenticated()
|
|
22169
|
+
};
|
|
22170
|
+
const evidence = prepared.value;
|
|
22171
|
+
if (await expected(evidence.request, evidence) && await verifiedPreparedCommand(evidence, session.email, signerAddress, deps.chainId)) return prepared;
|
|
22172
|
+
const refused = {
|
|
22173
|
+
ok: false,
|
|
22174
|
+
error: Errors.invalidInput("execution", "prepared command mismatch")
|
|
22175
|
+
};
|
|
22176
|
+
return close ? abandonPrepared(deps, evidence.executionId, "prepared_mismatch", refused) : refused;
|
|
22177
|
+
}
|
|
22178
|
+
/** A retry, a request payment or a payroll run, rather than a new Payment. */
|
|
22179
|
+
const isCommandApproval = (input) => "retry" in input || "request" in input || "payrollRun" in input;
|
|
22180
|
+
/** Prepare a retry, a request payment or a payroll run for `signerAddress`, checked. */
|
|
22181
|
+
function prepareVerifiedCommand(deps, input, signerAddress, signal) {
|
|
22182
|
+
if ("retry" in input) return prepareVerifiedRetry(deps, input, signerAddress, signal);
|
|
22183
|
+
if ("request" in input) return prepareVerifiedRequestPayment(deps, input, signerAddress, signal);
|
|
22184
|
+
return prepareVerifiedPayrollRun(deps, input, signerAddress, signal);
|
|
22185
|
+
}
|
|
22186
|
+
/** The retry of one Payment, prepared in the scope that paid it. */
|
|
22187
|
+
async function prepareVerifiedRetry(deps, input, signerAddress, signal) {
|
|
22188
|
+
const intent = {
|
|
22189
|
+
kind: "retry",
|
|
22190
|
+
paymentId: input.retry
|
|
22191
|
+
};
|
|
22192
|
+
return checked(deps, signerAddress, await runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => callOperation(deps.convexCall, lifecycles.prepareScoped, {
|
|
22193
|
+
signerAddress,
|
|
22194
|
+
intent,
|
|
22195
|
+
expectedScope: input.organizationId === void 0 ? { kind: "account" } : {
|
|
22196
|
+
kind: "organization",
|
|
22197
|
+
orgId: input.organizationId
|
|
22198
|
+
}
|
|
22199
|
+
}).pipe(Effect.mapError((publicError) => ({ publicError }))), deps.runPromise), lifecycleCommandCheck(intent, input.organizationId), false);
|
|
22200
|
+
}
|
|
22201
|
+
/** The Payment of one request, exactly as the request froze it. */
|
|
22202
|
+
async function prepareVerifiedRequestPayment(deps, input, signerAddress, signal) {
|
|
22203
|
+
const decoded = Schema.decodeResult(RequestPaymentConfirmationSchema, { onExcessProperty: "error" })(input.request);
|
|
22204
|
+
if (decoded._tag === "Failure") return {
|
|
22205
|
+
ok: false,
|
|
22206
|
+
error: Errors.invalidInput("confirmation", "invalid request confirmation")
|
|
22207
|
+
};
|
|
22208
|
+
const confirmation = decoded.success;
|
|
22209
|
+
return checked(deps, signerAddress, await runIfActive(signal, commands$1.prepareRequest.name, () => callOperation(deps.convexCall, commands$1.prepareRequest, {
|
|
22210
|
+
confirmation,
|
|
22211
|
+
signerAddress
|
|
22212
|
+
}).pipe(Effect.mapError((publicError) => ({ publicError }))), deps.runPromise), requestPaymentCheck(confirmation), false);
|
|
22213
|
+
}
|
|
22214
|
+
/** One payroll run: the run the backend writes and the batch that pays it, checked together. */
|
|
22215
|
+
async function prepareVerifiedPayrollRun(deps, input, signerAddress, signal) {
|
|
22216
|
+
let run;
|
|
22217
|
+
try {
|
|
22218
|
+
run = decodePayrollRunInput(input.payrollRun);
|
|
22219
|
+
} catch (cause) {
|
|
22220
|
+
return {
|
|
22221
|
+
ok: false,
|
|
22222
|
+
error: asCapxulError(cause)
|
|
22223
|
+
};
|
|
22224
|
+
}
|
|
22225
|
+
const orgId = input.organizationId;
|
|
22226
|
+
const requestKey = run.requestKey ?? `payroll_${crypto.randomUUID()}`;
|
|
22227
|
+
const { permissionId, asset, period, items } = run;
|
|
22228
|
+
const authorized = await runIfActive(signal, runs.authorize.name, () => callOperation(deps.convexCall, runs.authorize, {
|
|
22229
|
+
orgId,
|
|
22230
|
+
permissionId,
|
|
22231
|
+
asset,
|
|
22232
|
+
requestKey,
|
|
22233
|
+
signerAddress,
|
|
22234
|
+
period,
|
|
22235
|
+
items
|
|
22236
|
+
}).pipe(Effect.mapError((publicError) => ({ publicError }))), deps.runPromise);
|
|
22237
|
+
if (!authorized.ok) return authorized;
|
|
22238
|
+
return checked(deps, signerAddress, {
|
|
22239
|
+
ok: true,
|
|
22240
|
+
value: authorized.value.execution
|
|
22241
|
+
}, isAuthorizedRunBatch({
|
|
22242
|
+
orgId,
|
|
22243
|
+
permissionId,
|
|
22244
|
+
requestKey,
|
|
22245
|
+
asset,
|
|
22246
|
+
period,
|
|
22247
|
+
items
|
|
22248
|
+
}, authorized.value.run), authorized.value.replay.kind !== "accepted");
|
|
22249
|
+
}
|
|
22250
|
+
//#endregion
|
|
21708
22251
|
//#region ../../packages/sdk/src/accounts/organization-approvals.ts
|
|
21709
22252
|
/** The Organization Payment prepared for `signerAddress` and checked, before any approval. */
|
|
21710
22253
|
async function prepareVerifiedOrganizationPayment(deps, input, signerAddress, signal) {
|
|
@@ -21811,6 +22354,7 @@ function makeApprovalsMethods(deps) {
|
|
|
21811
22354
|
};
|
|
21812
22355
|
const prepare = async (input, options) => {
|
|
21813
22356
|
const signal = options?.signal;
|
|
22357
|
+
if (isCommandApproval(input)) return openApproval(signal, (signerAddress) => prepareVerifiedCommand(deps, input, signerAddress, signal));
|
|
21814
22358
|
if ("organizationId" in input) return openApproval(signal, (signerAddress) => prepareVerifiedOrganizationPayment(deps, input, signerAddress, signal));
|
|
21815
22359
|
const intent = paymentExecutionIntent(input);
|
|
21816
22360
|
if (!intent.ok) return intent;
|
|
@@ -21903,7 +22447,7 @@ function makeApprovalsMethods(deps) {
|
|
|
21903
22447
|
ok: true,
|
|
21904
22448
|
value: null
|
|
21905
22449
|
};
|
|
21906
|
-
const payments = await readApprovalPayments(deps, approval.operation.paymentIds, organizationId, signal);
|
|
22450
|
+
const payments = await readApprovalPayments(deps, approval.operation.paymentIds, organizationId ?? (approval.actor.kind === "organization" ? approval.actor.orgId : void 0), signal);
|
|
21907
22451
|
if (!payments.ok) return payments;
|
|
21908
22452
|
if (unsent(approval, payments.value)) {
|
|
21909
22453
|
const sent = await submit(approvalId);
|
|
@@ -24761,14 +25305,6 @@ function executeIdentityProductObservation(telemetry, record, state) {
|
|
|
24761
25305
|
return ignoreTransportFailure(() => invocationTelemetry.emit(mapped), "emit", mapped.name).pipe(Effect.andThen(ignoreTransportFailure(after, mapped.name === "auth_signed_out" ? "reset" : "identify", mapped.name)));
|
|
24762
25306
|
}
|
|
24763
25307
|
//#endregion
|
|
24764
|
-
//#region ../../packages/protocol/src/payroll/model.ts
|
|
24765
|
-
function toPayrollRunId(raw) {
|
|
24766
|
-
return toNonEmptyStringBrand(raw, "payrollRunId", (value) => isNonEmptyString(value));
|
|
24767
|
-
}
|
|
24768
|
-
function toPayrollGroupId(raw) {
|
|
24769
|
-
return toNonEmptyStringBrand(raw, "payrollGroupId", (value) => isNonEmptyString(value));
|
|
24770
|
-
}
|
|
24771
|
-
//#endregion
|
|
24772
25308
|
//#region ../../packages/sdk/src/permissions/command-decoding.ts
|
|
24773
25309
|
/** The caller's input as a command: ids branded and the intent decoded, or invalid input thrown. */
|
|
24774
25310
|
const buildCommand = {
|
|
@@ -35678,7 +36214,7 @@ function preparedIdentity(verified) {
|
|
|
35678
36214
|
...effect?.operation === "assign" || effect?.operation === "revoke" ? { assignmentEffect: effect } : {}
|
|
35679
36215
|
};
|
|
35680
36216
|
}
|
|
35681
|
-
async function execute$
|
|
36217
|
+
async function execute$93(deps, orgId, command, signal, controls, verifiedOrganization, onPrepared, expectedSnapshotHash) {
|
|
35682
36218
|
if (isAborted$1(signal)) return {
|
|
35683
36219
|
ok: false,
|
|
35684
36220
|
error: Errors.cancelled({ operation: "permissions" })
|
|
@@ -35804,7 +36340,7 @@ function makePermissionMethods(deps, orgId) {
|
|
|
35804
36340
|
};
|
|
35805
36341
|
return result;
|
|
35806
36342
|
};
|
|
35807
|
-
const command = (operation, build, options) => observed$1(deps, operation, options, (signal, captured, verifiedOrganization) => execute$
|
|
36343
|
+
const command = (operation, build, options) => observed$1(deps, operation, options, (signal, captured, verifiedOrganization) => execute$93(deps, orgId, build(), signal, captured, verifiedOrganization, options?.onPrepared));
|
|
35808
36344
|
return {
|
|
35809
36345
|
previewReplacement: (requestKey, options) => {
|
|
35810
36346
|
const session = deps.actor?.authSession();
|
|
@@ -35896,7 +36432,7 @@ function makePermissionMethods(deps, orgId) {
|
|
|
35896
36432
|
change: (input, options) => command(ops.change, () => buildCommand.change(input), options),
|
|
35897
36433
|
assign: (input, options) => command(ops.assign, () => buildCommand.assign(input), options),
|
|
35898
36434
|
revoke: (input, options) => command(ops.revoke, () => buildCommand.revoke(input), options),
|
|
35899
|
-
replace: (input, options) => observed$1(deps, ops.replace, options, (signal, captured, verifiedOrganization) => execute$
|
|
36435
|
+
replace: (input, options) => observed$1(deps, ops.replace, options, (signal, captured, verifiedOrganization) => execute$93(deps, orgId, {
|
|
35900
36436
|
operation: "replace",
|
|
35901
36437
|
requestKey: input.requestKey
|
|
35902
36438
|
}, signal, captured, verifiedOrganization, options?.onPrepared, input.expectedSnapshotHash)),
|
|
@@ -35912,411 +36448,6 @@ function makePermissionMethods(deps, orgId) {
|
|
|
35912
36448
|
};
|
|
35913
36449
|
}
|
|
35914
36450
|
//#endregion
|
|
35915
|
-
//#region ../../packages/sdk/src/payroll/run-checks.ts
|
|
35916
|
-
/** Match the caller's compensation to the committed V3 Payslip. */
|
|
35917
|
-
function payslipIdentityMatches(message, item, index, runId, period) {
|
|
35918
|
-
return message.runId === runId && message.itemIndex === index && message.employeeRef === item.partyId && message.periodStart === period.start && message.periodEnd === period.end && message.adjustmentsHash === hashAdjustmentsV3(item.adjustments);
|
|
35919
|
-
}
|
|
35920
|
-
function payslipAmountMatches(message, item) {
|
|
35921
|
-
const exact = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
35922
|
-
return message.gross.asset === exact.asset && message.gross.minorUnits === item.gross && message.gross.decimals === exact.decimals && message.net.asset === exact.asset && message.net.minorUnits === item.net && message.net.decimals === exact.decimals;
|
|
35923
|
-
}
|
|
35924
|
-
function isRunItem(prepared, item, evidence, index, runId, period) {
|
|
35925
|
-
if (prepared === void 0) return false;
|
|
35926
|
-
const bundle = evidence.preparedCommand?.documentBundles?.[index];
|
|
35927
|
-
const preparedItem = evidence.preparedCommand?.items[index];
|
|
35928
|
-
const payslip = bundle?.envelope;
|
|
35929
|
-
if (bundle === void 0 || payslip?.primaryType !== "Payslip") return false;
|
|
35930
|
-
return canonicalJson(prepared.to) === canonicalJson(item.to) && prepared.paymentType === "payroll" && canonicalJson(prepared.amount) === canonicalJson(item.amount) && bundle.adjustments !== void 0 && canonicalJson(bundle.adjustments) === canonicalJson(item.adjustments) && payslipIdentityMatches(payslip.message, item, index, runId, period) && payslipAmountMatches(payslip.message, item) && (preparedItem?.operation === "send" || preparedItem?.operation === "create_commitment") && preparedItem.documentHash === evidence.preparedCommand?.instructionDocuments?.[index]?.documentHash;
|
|
35931
|
-
}
|
|
35932
|
-
/**
|
|
35933
|
-
* The batch the backend derived from a payroll intent must be the batch this
|
|
35934
|
-
* caller asked for, checked before the digest is signed.
|
|
35935
|
-
*
|
|
35936
|
-
* The payslip envelope on each item is server-built and carries the run row's
|
|
35937
|
-
* own `issuedAt`, so the batch cannot be fingerprinted against a local copy
|
|
35938
|
-
* (`matchesIntent` is unavailable here). What CAN be verified is every field
|
|
35939
|
-
* the caller supplied — the org, the Budget, the request key, and per item the
|
|
35940
|
-
* recipient, the amount and the payslip figures — plus the lineage binding the
|
|
35941
|
-
* batch to the run just written. A prepared command that pays a different
|
|
35942
|
-
* person, a different amount, from a different Budget, or under a different
|
|
35943
|
-
* run never reaches the signer.
|
|
35944
|
-
*/
|
|
35945
|
-
function isRunBatch(input) {
|
|
35946
|
-
return (batch, evidence) => Promise.resolve(!("kind" in batch) && batch.orgId === input.orgId && batch.permissionId === input.permissionId && batch.requestKey === input.requestKey && batch.lineage?.kind === "payroll" && batch.lineage.runId === input.runId && batch.items.length === input.items.length && batch.items.every((item) => item.amount.asset === input.asset) && input.items.every((item, index) => isRunItem(batch.items[index], item, evidence, index, input.runId, input.period)));
|
|
35947
|
-
}
|
|
35948
|
-
/** A decoded detail is the run asked for, whole: its scope, membership and quantities agree. */
|
|
35949
|
-
function checkPayrollRunDetail(value, orgId, runId) {
|
|
35950
|
-
if (value === null) return {
|
|
35951
|
-
ok: true,
|
|
35952
|
-
value: null
|
|
35953
|
-
};
|
|
35954
|
-
if (value.orgId !== orgId || value.run.id !== runId || value.items.length === 0 || value.items.length !== value.run.recipientCount || new Set(value.items.map((item) => item.payment.id)).size !== value.items.length || value.items.some((item, index) => item.itemIndex !== index || item.amount.asset !== value.run.total.asset || item.payment.amount.asset !== item.amount.asset || item.payment.paymentType !== "payroll")) return {
|
|
35955
|
-
ok: false,
|
|
35956
|
-
error: Errors.invalidInput("run", "Payroll run scope or membership does not match")
|
|
35957
|
-
};
|
|
35958
|
-
try {
|
|
35959
|
-
const total = toExactAssetAmount(value.run.total, CONFIGURED_MONEY_ASSETS);
|
|
35960
|
-
let rawTotal = 0n;
|
|
35961
|
-
for (const item of value.items) {
|
|
35962
|
-
const amount = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
35963
|
-
const payment = toExactAssetAmount(item.payment.amount, CONFIGURED_MONEY_ASSETS);
|
|
35964
|
-
if (amount.minorUnits !== payment.minorUnits) return {
|
|
35965
|
-
ok: false,
|
|
35966
|
-
error: Errors.invalidInput("run", "Payroll item quantity does not match its Payment")
|
|
35967
|
-
};
|
|
35968
|
-
rawTotal += BigInt(amount.minorUnits);
|
|
35969
|
-
}
|
|
35970
|
-
if (rawTotal !== BigInt(total.minorUnits)) return {
|
|
35971
|
-
ok: false,
|
|
35972
|
-
error: Errors.invalidInput("run", "Payroll run total does not match its items")
|
|
35973
|
-
};
|
|
35974
|
-
} catch {
|
|
35975
|
-
return {
|
|
35976
|
-
ok: false,
|
|
35977
|
-
error: Errors.invalidInput("run", "Payroll run quantities are invalid")
|
|
35978
|
-
};
|
|
35979
|
-
}
|
|
35980
|
-
return {
|
|
35981
|
-
ok: true,
|
|
35982
|
-
value
|
|
35983
|
-
};
|
|
35984
|
-
}
|
|
35985
|
-
//#endregion
|
|
35986
|
-
//#region ../../packages/sdk/src/payroll/run-decoding.ts
|
|
35987
|
-
function toPayrollRun(wire) {
|
|
35988
|
-
return {
|
|
35989
|
-
id: toPayrollRunId(wire.id),
|
|
35990
|
-
status: wire.status,
|
|
35991
|
-
periodStart: wire.periodStart,
|
|
35992
|
-
periodEnd: wire.periodEnd,
|
|
35993
|
-
total: wire.total,
|
|
35994
|
-
recipientCount: wire.recipientCount
|
|
35995
|
-
};
|
|
35996
|
-
}
|
|
35997
|
-
function toPayrollRuns(wire) {
|
|
35998
|
-
return {
|
|
35999
|
-
...mapPage(wire, toPayrollRun),
|
|
36000
|
-
settledThisMonth: wire.settledThisMonth
|
|
36001
|
-
};
|
|
36002
|
-
}
|
|
36003
|
-
function toPayrollGroup(wire) {
|
|
36004
|
-
return {
|
|
36005
|
-
id: toPayrollGroupId(wire.id),
|
|
36006
|
-
name: wire.name,
|
|
36007
|
-
tone: wire.tone,
|
|
36008
|
-
members: wire.members.map((member) => ({
|
|
36009
|
-
partyId: member.partyId,
|
|
36010
|
-
amount: member.amount,
|
|
36011
|
-
currency: member.currency
|
|
36012
|
-
}))
|
|
36013
|
-
};
|
|
36014
|
-
}
|
|
36015
|
-
function validateRunItems(input) {
|
|
36016
|
-
for (const [index, item] of input.items.entries()) {
|
|
36017
|
-
if (Schema.decodeResult(PayrollRunItemInputSchema, { onExcessProperty: "error" })(item)._tag === "Failure") return Errors.invalidInput(`items.${index}`, "invalid Payroll item");
|
|
36018
|
-
try {
|
|
36019
|
-
const exact = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
36020
|
-
const net = BigInt(item.net);
|
|
36021
|
-
const gross = BigInt(item.gross);
|
|
36022
|
-
const adjustments = item.adjustments.reduce((sum, row) => sum + BigInt(row.amount), 0n);
|
|
36023
|
-
if (item.amount.asset !== input.asset || item.net !== exact.minorUnits || gross + adjustments !== net) return Errors.invalidInput(`items.${index}`, "invalid Payroll units");
|
|
36024
|
-
} catch {
|
|
36025
|
-
return Errors.invalidInput(`items.${index}`, "invalid Payroll units");
|
|
36026
|
-
}
|
|
36027
|
-
}
|
|
36028
|
-
return null;
|
|
36029
|
-
}
|
|
36030
|
-
const RunInputSchema = Schema.Struct({
|
|
36031
|
-
permissionId: AuthorizePayrollRunExecutionInputSchema.fields.permissionId,
|
|
36032
|
-
asset: AuthorizePayrollRunExecutionInputSchema.fields.asset,
|
|
36033
|
-
period: AuthorizePayrollRunExecutionInputSchema.fields.period,
|
|
36034
|
-
items: AuthorizePayrollRunExecutionInputSchema.fields.items,
|
|
36035
|
-
requestKey: Schema.optional(AuthorizePayrollRunExecutionInputSchema.fields.requestKey)
|
|
36036
|
-
});
|
|
36037
|
-
/** Decode caller input before session or signer work. Keep routing outside the input. */
|
|
36038
|
-
function decodePayrollRunInput(value) {
|
|
36039
|
-
try {
|
|
36040
|
-
const decoded = Schema.decodeUnknownSync(RunInputSchema, { onExcessProperty: "error" })(value);
|
|
36041
|
-
const input = {
|
|
36042
|
-
permissionId: decoded.permissionId,
|
|
36043
|
-
asset: decoded.asset,
|
|
36044
|
-
period: decoded.period,
|
|
36045
|
-
...decoded.requestKey === void 0 ? {} : { requestKey: decoded.requestKey },
|
|
36046
|
-
items: decoded.items.map((item) => ({
|
|
36047
|
-
amount: item.amount,
|
|
36048
|
-
gross: item.gross,
|
|
36049
|
-
net: item.net,
|
|
36050
|
-
adjustments: item.adjustments,
|
|
36051
|
-
partyId: toPartyId(item.partyId),
|
|
36052
|
-
to: item.to.kind === "party" ? {
|
|
36053
|
-
kind: "party",
|
|
36054
|
-
partyId: toPartyId(item.to.partyId)
|
|
36055
|
-
} : item.to.kind === "address" ? {
|
|
36056
|
-
kind: "address",
|
|
36057
|
-
address: toAddress(item.to.address)
|
|
36058
|
-
} : item.to
|
|
36059
|
-
}))
|
|
36060
|
-
};
|
|
36061
|
-
if (input.items.length === 0 || input.period.start > input.period.end) throw Errors.invalidInput("input", "Payroll requires items and an ordered period");
|
|
36062
|
-
const error = validateRunItems(input);
|
|
36063
|
-
if (error !== null) throw error;
|
|
36064
|
-
return input;
|
|
36065
|
-
} catch (cause) {
|
|
36066
|
-
throw cause instanceof CapxulError ? cause : Errors.invalidInput("input", "Invalid Payroll input");
|
|
36067
|
-
}
|
|
36068
|
-
}
|
|
36069
|
-
/** Read only the exact backend prepare receipt, never an arbitrary signer failure. */
|
|
36070
|
-
function payrollResolution(error, requestKey) {
|
|
36071
|
-
const details = error.details;
|
|
36072
|
-
if (error.code !== "WRONG_STATE" || details?.method !== runs.authorize.name || details.requestKey !== requestKey || typeof details.commandId !== "string" || typeof details.runId !== "string") return void 0;
|
|
36073
|
-
return details.payrollResolution === "failed" || details.payrollResolution === "settled" ? details.payrollResolution : void 0;
|
|
36074
|
-
}
|
|
36075
|
-
function validatePayrollRunLookup(orgId, runId) {
|
|
36076
|
-
return !Schema.is(PayrollRunIdSchema)(runId) || orgId.length === 0 ? {
|
|
36077
|
-
ok: false,
|
|
36078
|
-
error: Errors.invalidInput("runId", "Organization and run ID must be valid")
|
|
36079
|
-
} : {
|
|
36080
|
-
ok: true,
|
|
36081
|
-
value: void 0
|
|
36082
|
-
};
|
|
36083
|
-
}
|
|
36084
|
-
/** Strict saved detail decoder shared by the read and fresh stream. */
|
|
36085
|
-
function decodePayrollRunDetail(raw, orgId, runId) {
|
|
36086
|
-
const decoded = Schema.decodeUnknownResult(Schema.NullOr(PayrollRunDetailSchema), { onExcessProperty: "error" })(raw);
|
|
36087
|
-
if (decoded._tag === "Failure") return {
|
|
36088
|
-
ok: false,
|
|
36089
|
-
error: Errors.invalidInput("run", "Invalid Payroll run detail")
|
|
36090
|
-
};
|
|
36091
|
-
return checkPayrollRunDetail(decoded.success, orgId, runId);
|
|
36092
|
-
}
|
|
36093
|
-
//#endregion
|
|
36094
|
-
//#region ../../packages/sdk/src/payroll/run-subscription.ts
|
|
36095
|
-
function detailValue(result) {
|
|
36096
|
-
if (!result.ok) throw result.error;
|
|
36097
|
-
return result.value;
|
|
36098
|
-
}
|
|
36099
|
-
function subscribePayrollRun(deps, orgId, runId, listener, options) {
|
|
36100
|
-
const operation = CAPXUL_OPERATIONS.org.payroll.subscribeRun;
|
|
36101
|
-
const valid = deps.validate(orgId, runId);
|
|
36102
|
-
if (!valid.ok) return runCapxulEffect(Effect.fail(valid.error), observationOnlyControls(deps.invocationControls?.(options) ?? options), operation, deps.runPromise);
|
|
36103
|
-
const decode = (raw) => detailValue(deps.decode(raw, orgId, runId));
|
|
36104
|
-
return subscribeFreshQuery(deps, {
|
|
36105
|
-
orgId,
|
|
36106
|
-
runId
|
|
36107
|
-
}, listener, operation, {
|
|
36108
|
-
decode,
|
|
36109
|
-
validateCached: (raw) => {
|
|
36110
|
-
decode(raw);
|
|
36111
|
-
},
|
|
36112
|
-
invalidValue: (cause) => isCapxulError(cause) ? cause : Errors.invalidInput("run", "Invalid Payroll run detail"),
|
|
36113
|
-
invalidScope: () => Errors.invalidInput("run", "Payroll run subscription scope does not match"),
|
|
36114
|
-
lostValue: () => Errors.invalidInput("run", "Payroll run is no longer readable"),
|
|
36115
|
-
unavailable: () => Errors.notImplemented("payroll", "subscribeRun")
|
|
36116
|
-
}, options);
|
|
36117
|
-
}
|
|
36118
|
-
//#endregion
|
|
36119
|
-
//#region ../../packages/sdk/src/payroll/run-authorization.ts
|
|
36120
|
-
/**
|
|
36121
|
-
* Authorize one payroll run: a stable request key, the prepared batch checked
|
|
36122
|
-
* against the run the caller asked for, the signature, and the submission.
|
|
36123
|
-
*/
|
|
36124
|
-
async function authorizePayrollRun(scope, input, controls, onRequestKey, onResolved) {
|
|
36125
|
-
const { deps, orgId, requestKeyScope } = scope;
|
|
36126
|
-
const signal = controls?.signal;
|
|
36127
|
-
const execution = executionDependencies(deps);
|
|
36128
|
-
if (execution === null) return {
|
|
36129
|
-
ok: false,
|
|
36130
|
-
error: Errors.notImplemented("payroll", "executionComposition")
|
|
36131
|
-
};
|
|
36132
|
-
try {
|
|
36133
|
-
input = decodePayrollRunInput(input);
|
|
36134
|
-
} catch (cause) {
|
|
36135
|
-
return {
|
|
36136
|
-
ok: false,
|
|
36137
|
-
error: asCapxulError(cause)
|
|
36138
|
-
};
|
|
36139
|
-
}
|
|
36140
|
-
const { requestKey: provided, ...canonicalInput } = input;
|
|
36141
|
-
const actorId = onRequestKey === void 0 ? void 0 : execution.actor.authSession()?.authUserId;
|
|
36142
|
-
if (onRequestKey !== void 0 && actorId === void 0) return {
|
|
36143
|
-
ok: false,
|
|
36144
|
-
error: Errors.notAuthenticated()
|
|
36145
|
-
};
|
|
36146
|
-
const requestKey = await paymentRequestKeyLifecycle(`${requestKeyScope}:${AUTHORIZE_RUN}`, onRequestKey === void 0 ? {
|
|
36147
|
-
orgId,
|
|
36148
|
-
input
|
|
36149
|
-
} : {
|
|
36150
|
-
actorId,
|
|
36151
|
-
orgId,
|
|
36152
|
-
input: canonicalInput
|
|
36153
|
-
}, provided, onRequestKey === void 0 ? void 0 : { manageProvidedKey: true });
|
|
36154
|
-
try {
|
|
36155
|
-
await onRequestKey?.(requestKey.key);
|
|
36156
|
-
if (onRequestKey !== void 0 && execution.actor.authSession()?.authUserId !== actorId) {
|
|
36157
|
-
await requestKey.finish(false).catch(() => void 0);
|
|
36158
|
-
return {
|
|
36159
|
-
ok: false,
|
|
36160
|
-
error: Errors.notAuthenticated()
|
|
36161
|
-
};
|
|
36162
|
-
}
|
|
36163
|
-
} catch (cause) {
|
|
36164
|
-
await requestKey.finish(false).catch(() => void 0);
|
|
36165
|
-
return {
|
|
36166
|
-
ok: false,
|
|
36167
|
-
error: asCapxulError(cause)
|
|
36168
|
-
};
|
|
36169
|
-
}
|
|
36170
|
-
let authorized;
|
|
36171
|
-
let acceptedReplay;
|
|
36172
|
-
let preparedClosed = false;
|
|
36173
|
-
let terminalReplay;
|
|
36174
|
-
const submitted = await executePrepared(execution, async (signerAddress) => {
|
|
36175
|
-
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, runs.authorize, copyInvocationObservation(controls, {
|
|
36176
|
-
orgId,
|
|
36177
|
-
permissionId: input.permissionId,
|
|
36178
|
-
asset: input.asset,
|
|
36179
|
-
requestKey: requestKey.key,
|
|
36180
|
-
signerAddress,
|
|
36181
|
-
period: input.period,
|
|
36182
|
-
items: input.items
|
|
36183
|
-
}))).pipe(Effect.mapError((publicError) => ({ publicError }))), controls), deps.runPromise);
|
|
36184
|
-
if (!prepared.ok) {
|
|
36185
|
-
terminalReplay = payrollResolution(prepared.error, requestKey.key);
|
|
36186
|
-
return prepared;
|
|
36187
|
-
}
|
|
36188
|
-
authorized = prepared.value.run;
|
|
36189
|
-
acceptedReplay = prepared.value.replay.kind === "accepted" ? prepared.value.replay.submission : void 0;
|
|
36190
|
-
return {
|
|
36191
|
-
ok: true,
|
|
36192
|
-
value: prepared.value.execution
|
|
36193
|
-
};
|
|
36194
|
-
}, (request, evidence) => authorized === void 0 || authorized.periodStart !== input.period.start || authorized.periodEnd !== input.period.end ? Promise.resolve(false) : isRunBatch({
|
|
36195
|
-
orgId,
|
|
36196
|
-
permissionId: input.permissionId,
|
|
36197
|
-
requestKey: requestKey.key,
|
|
36198
|
-
runId: authorized.id,
|
|
36199
|
-
asset: input.asset,
|
|
36200
|
-
period: input.period,
|
|
36201
|
-
items: input.items
|
|
36202
|
-
})(request, evidence), true, () => preparedClosed = true, signal, controls, void 0, () => acceptedReplay);
|
|
36203
|
-
const resolution = preparedClosed ? "failed" : terminalReplay;
|
|
36204
|
-
if (resolution !== void 0) try {
|
|
36205
|
-
await onResolved?.(resolution);
|
|
36206
|
-
} catch {}
|
|
36207
|
-
try {
|
|
36208
|
-
await requestKey.finish(submitted.ok || resolution !== void 0);
|
|
36209
|
-
} catch {}
|
|
36210
|
-
if (!submitted.ok) return submitted;
|
|
36211
|
-
return authorized === void 0 ? {
|
|
36212
|
-
ok: false,
|
|
36213
|
-
error: Errors.unknown()
|
|
36214
|
-
} : {
|
|
36215
|
-
ok: true,
|
|
36216
|
-
value: toPayrollRun(authorized)
|
|
36217
|
-
};
|
|
36218
|
-
}
|
|
36219
|
-
const AUTHORIZE_RUN = runs.authorize.name;
|
|
36220
|
-
function executionDependencies(deps) {
|
|
36221
|
-
return deps.actor === void 0 || deps.chainId === void 0 || deps.signer === void 0 ? null : {
|
|
36222
|
-
actor: deps.actor,
|
|
36223
|
-
chainId: deps.chainId,
|
|
36224
|
-
convexCall: deps.convexCall,
|
|
36225
|
-
runPromise: deps.runPromise,
|
|
36226
|
-
signer: deps.signer,
|
|
36227
|
-
...deps.telemetry === void 0 ? {} : { telemetry: deps.telemetry }
|
|
36228
|
-
};
|
|
36229
|
-
}
|
|
36230
|
-
//#endregion
|
|
36231
|
-
//#region ../../packages/sdk/src/payroll/runs.ts
|
|
36232
|
-
function makePayrollMethods(deps, orgId) {
|
|
36233
|
-
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
36234
|
-
/** One observed call of one payroll row, its reply projected inside the call, under the row's name. */
|
|
36235
|
-
const call = (row, args, options, project) => {
|
|
36236
|
-
const controls = deps.invocationControls?.(options) ?? options;
|
|
36237
|
-
return runPortEffect(callOperation(deps.convexCall, row, copyInvocationObservation(controls, args)).pipe(Effect.map(project), Effect.mapError((publicError) => ({ publicError }))), controls, row.name, deps.runPromise);
|
|
36238
|
-
};
|
|
36239
|
-
return {
|
|
36240
|
-
subscribeRun: (runId, listener, options) => subscribePayrollRun({
|
|
36241
|
-
actor: deps.actor,
|
|
36242
|
-
convexCall: deps.convexCall,
|
|
36243
|
-
query: reference(runs.get),
|
|
36244
|
-
runPromise: deps.runPromise,
|
|
36245
|
-
invocationControls: deps.invocationControls,
|
|
36246
|
-
decode: decodePayrollRunDetail,
|
|
36247
|
-
validate: validatePayrollRunLookup
|
|
36248
|
-
}, orgId, runId, listener, options),
|
|
36249
|
-
getRun: (runId, options) => {
|
|
36250
|
-
const controls = deps.invocationControls?.(options) ?? options;
|
|
36251
|
-
const lifetime = deps.actor?.authLifetime();
|
|
36252
|
-
const operation = runs.get.name;
|
|
36253
|
-
return runCapxulEffect(Effect.gen(function* () {
|
|
36254
|
-
const lookup = validatePayrollRunLookup(orgId, runId);
|
|
36255
|
-
if (!lookup.ok) return yield* Effect.fail(lookup.error);
|
|
36256
|
-
if (lifetime === void 0 || lifetime.authUserId === null || deps.actor === void 0) return yield* Effect.fail(Errors.notAuthenticated());
|
|
36257
|
-
const current = () => deps.actor?.matchesAuthLifetime(lifetime, lifetime.authUserId) === true;
|
|
36258
|
-
if (!current()) return yield* Effect.fail(Errors.notAuthenticated());
|
|
36259
|
-
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
36260
|
-
const captured = carryInvocationParentSpan(controls, parent);
|
|
36261
|
-
const run = yield* awaitCapxulResult(() => runIfActive(controls?.signal, operation, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, runs.get, copyInvocationObservation(captured, {
|
|
36262
|
-
orgId,
|
|
36263
|
-
runId
|
|
36264
|
-
}))).pipe(Effect.mapError((publicError) => ({ publicError }))), captured), deps.runPromise));
|
|
36265
|
-
if (!current()) return yield* Effect.fail(Errors.cancelled({ operation }));
|
|
36266
|
-
const checked = checkPayrollRunDetail(run, orgId, runId);
|
|
36267
|
-
return yield* checked.ok ? Effect.succeed(checked.value) : Effect.fail(checked.error);
|
|
36268
|
-
}), observationOnlyControls(controls), operation, deps.runPromise);
|
|
36269
|
-
},
|
|
36270
|
-
runs: (options) => call(runs.list, { orgId }, options, toPayrollRuns),
|
|
36271
|
-
authorizeRun: (input, options) => {
|
|
36272
|
-
const controls = deps.invocationControls?.(options) ?? options;
|
|
36273
|
-
return runCapxulEffect(Effect.gen(function* () {
|
|
36274
|
-
if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: AUTHORIZE_RUN }));
|
|
36275
|
-
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
36276
|
-
return yield* awaitCapxulResult(() => authorizePayrollRun({
|
|
36277
|
-
deps,
|
|
36278
|
-
orgId,
|
|
36279
|
-
requestKeyScope
|
|
36280
|
-
}, input, carryInvocationParentSpan(controls, parent), options?.onRequestKey, options?.onResolved));
|
|
36281
|
-
}), observationOnlyControls(controls), AUTHORIZE_RUN, deps.runPromise);
|
|
36282
|
-
},
|
|
36283
|
-
terms: (options) => call(terms.list, { orgId }, options, (rates) => rates),
|
|
36284
|
-
groups: {
|
|
36285
|
-
list: (options) => call(groups$1.list, { orgId }, options, (saved) => mapPage(saved, toPayrollGroup)),
|
|
36286
|
-
save: (input, options) => call(groups$1.save, {
|
|
36287
|
-
orgId,
|
|
36288
|
-
...input.id === void 0 ? {} : { id: String(input.id) },
|
|
36289
|
-
name: input.name,
|
|
36290
|
-
tone: input.tone,
|
|
36291
|
-
members: input.members
|
|
36292
|
-
}, options, toPayrollGroup),
|
|
36293
|
-
remove: (id, options) => call(groups$1.remove, {
|
|
36294
|
-
orgId,
|
|
36295
|
-
id
|
|
36296
|
-
}, options, () => void 0)
|
|
36297
|
-
}
|
|
36298
|
-
};
|
|
36299
|
-
}
|
|
36300
|
-
const payrollUnavailable = () => Promise.resolve({
|
|
36301
|
-
ok: false,
|
|
36302
|
-
error: Errors.notImplemented("payroll", "executionComposition")
|
|
36303
|
-
});
|
|
36304
|
-
/** The bundle an unconfigured client exposes — every verb refuses, none throws. */
|
|
36305
|
-
function makeUnavailablePayrollMethods() {
|
|
36306
|
-
return {
|
|
36307
|
-
getRun: payrollUnavailable,
|
|
36308
|
-
subscribeRun: payrollUnavailable,
|
|
36309
|
-
runs: payrollUnavailable,
|
|
36310
|
-
authorizeRun: payrollUnavailable,
|
|
36311
|
-
terms: payrollUnavailable,
|
|
36312
|
-
groups: {
|
|
36313
|
-
list: payrollUnavailable,
|
|
36314
|
-
save: payrollUnavailable,
|
|
36315
|
-
remove: payrollUnavailable
|
|
36316
|
-
}
|
|
36317
|
-
};
|
|
36318
|
-
}
|
|
36319
|
-
//#endregion
|
|
36320
36451
|
//#region ../../node_modules/.pnpm/axios@1.17.0/node_modules/axios/lib/helpers/bind.js
|
|
36321
36452
|
/**
|
|
36322
36453
|
* Create a bound version of a function with a specified `this` context
|
|
@@ -70390,12 +70521,14 @@ const writeStderr = (text) => Effect.flatMap(Stdio.Stdio, (stdio) => Stream.run(
|
|
|
70390
70521
|
/** Wrap pending work only. Keep terminal prompts outside this scope. */
|
|
70391
70522
|
const withWaiting = (work, options) => Effect.scoped(Effect.gen(function* () {
|
|
70392
70523
|
const stdio = yield* Stdio.Stdio;
|
|
70524
|
+
const terminal = options.stderrTty === true && (yield* stdio.stdoutIsTerminal);
|
|
70525
|
+
if (options.mode === "human" && !terminal) return yield* work;
|
|
70393
70526
|
yield* writeStderr(options.mode === "json" ? `${JSON.stringify({
|
|
70394
70527
|
type: "cli.waiting",
|
|
70395
70528
|
label: options.label,
|
|
70396
70529
|
status: "waiting"
|
|
70397
70530
|
})}\n` : `Waiting: ${terminalText(options.label)}\n`);
|
|
70398
|
-
if (!(options.mode === "human" && options.tty && !options.ci
|
|
70531
|
+
if (!(options.mode === "human" && options.tty && !options.ci)) return yield* work;
|
|
70399
70532
|
const clear = "\r\x1B[2K";
|
|
70400
70533
|
const frames = [
|
|
70401
70534
|
"⠋",
|
|
@@ -70447,8 +70580,8 @@ const terminalText = (value) => value.replace(/[\p{Cc}\p{Cf}]/gu, (character) =>
|
|
|
70447
70580
|
const shellArgument = (value) => `'${value.replaceAll("'", "'\"'\"'")}'`;
|
|
70448
70581
|
//#endregion
|
|
70449
70582
|
//#region src/runtime/version.ts
|
|
70450
|
-
const cliVersion = "4.20.0-beta.
|
|
70451
|
-
const sdkVersion = "4.20.0-beta.
|
|
70583
|
+
const cliVersion = "4.20.0-beta.27";
|
|
70584
|
+
const sdkVersion = "4.20.0-beta.27";
|
|
70452
70585
|
const ReleaseVersion = Schema.String.check(Schema.isMaxLength(256), Schema.isPattern(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/u)).pipe(Schema.brand("CliReleaseVersion"));
|
|
70453
70586
|
const parts = (version) => {
|
|
70454
70587
|
const [core = "", ...prerelease] = version.split("+")[0].split("-");
|
|
@@ -71594,7 +71727,7 @@ const lifecycleResult = (lifecycle, email) => ({
|
|
|
71594
71727
|
const balanceLines$1 = (account) => [
|
|
71595
71728
|
`Account ${terminalText(account.id)}`,
|
|
71596
71729
|
...account.balances.length === 0 ? ["No asset balances returned."] : account.balances.flatMap((position) => [
|
|
71597
|
-
` Asset: ${terminalText(position.symbol)}
|
|
71730
|
+
` Asset: ${terminalText(position.symbol)} on ${networkName(requireAsset(position.asset).chainId)}`,
|
|
71598
71731
|
` Balance: ${terminalText(position.balance)}`,
|
|
71599
71732
|
` Available: ${terminalText(position.available)}`
|
|
71600
71733
|
]),
|
|
@@ -71610,7 +71743,7 @@ const depositLines = (instructions) => [
|
|
|
71610
71743
|
];
|
|
71611
71744
|
//#endregion
|
|
71612
71745
|
//#region src/commands/account/subcommands/show/execute.ts
|
|
71613
|
-
const execute$
|
|
71746
|
+
const execute$92 = (config, email) => Effect.gen(function* () {
|
|
71614
71747
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
71615
71748
|
const runtime = yield* CliRuntime;
|
|
71616
71749
|
return yield* withWaiting(Effect.promise(() => client.account.getLifecycle()).pipe(Effect.flatMap(resultValue), Effect.map((lifecycle) => lifecycleResult(lifecycle, session.email)), Effect.mapError((error) => accountReadFailure(error, session.email))), {
|
|
@@ -71620,7 +71753,7 @@ const execute$93 = (config, email) => Effect.gen(function* () {
|
|
|
71620
71753
|
});
|
|
71621
71754
|
//#endregion
|
|
71622
71755
|
//#region src/commands/account/subcommands/show/command.ts
|
|
71623
|
-
const command$80 = Command.make("show", { email: emailFlag$10 }, ({ email }) => dispatch$9("show", (config) => execute$
|
|
71756
|
+
const command$80 = Command.make("show", { email: emailFlag$10 }, ({ email }) => dispatch$9("show", (config) => execute$92(config, Option.getOrUndefined(email)))).pipe(annotate$8("show"), Command.withDescription("Read your Account lifecycle without starting setup"));
|
|
71624
71757
|
//#endregion
|
|
71625
71758
|
//#region src/auth/actor.ts
|
|
71626
71759
|
/** An Organization ID, as opposed to a handle. */
|
|
@@ -71683,7 +71816,7 @@ const actorScope = (actor) => actor.kind === "personal" ? {
|
|
|
71683
71816
|
//#region src/commands/org/subcommands/shared.ts
|
|
71684
71817
|
const emailFlag$9 = Flag.String("email").pipe(Flag.optional);
|
|
71685
71818
|
const scoped$1 = { email: emailFlag$9 };
|
|
71686
|
-
const confirmFlag$
|
|
71819
|
+
const confirmFlag$6 = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
71687
71820
|
const timeoutFlag$4 = Flag.Int("timeout-seconds").pipe(Flag.withDefault(120));
|
|
71688
71821
|
const metadata$18 = (name) => ({
|
|
71689
71822
|
name,
|
|
@@ -73259,7 +73392,7 @@ const readWriteTimeout = (value) => Schema.decodeEffect(Schema.Int.check(Schema.
|
|
|
73259
73392
|
})))(value).pipe(Effect.mapError(() => inputRequired("Provide --timeout-seconds as an integer from 1 to 3600.")));
|
|
73260
73393
|
//#endregion
|
|
73261
73394
|
//#region src/commands/account/subcommands/retry/execute.ts
|
|
73262
|
-
const execute$
|
|
73395
|
+
const execute$91 = (config, input) => Effect.gen(function* () {
|
|
73263
73396
|
const timeout = yield* readWriteTimeout(input.timeoutSeconds);
|
|
73264
73397
|
const interactive = yield* requireWriteConfirmation(input.confirm);
|
|
73265
73398
|
const opened = yield* openAuthenticatedSession(config, input.email);
|
|
@@ -73347,7 +73480,7 @@ const execute$92 = (config, input) => Effect.gen(function* () {
|
|
|
73347
73480
|
const profileFlag = (name, description) => Flag.String(name).pipe(Flag.withDescription(description), Flag.optional);
|
|
73348
73481
|
const command$79 = Command.make("retry", {
|
|
73349
73482
|
email: emailFlag$10,
|
|
73350
|
-
confirm: confirmFlag$
|
|
73483
|
+
confirm: confirmFlag$6,
|
|
73351
73484
|
timeoutSeconds: timeoutFlag$4,
|
|
73352
73485
|
otpStdin: Flag.Boolean("otp-stdin").pipe(Flag.withDefault(false), Flag.withDescription("Read the sign-in code from stdin when no session is saved")),
|
|
73353
73486
|
displayName: profileFlag("display-name", "Your display name, for a first setup"),
|
|
@@ -73357,7 +73490,7 @@ const command$79 = Command.make("retry", {
|
|
|
73357
73490
|
displayName: Option.getOrUndefined(displayName),
|
|
73358
73491
|
country: Option.getOrUndefined(country),
|
|
73359
73492
|
handle: Option.getOrUndefined(handle)
|
|
73360
|
-
}) : execute$
|
|
73493
|
+
}) : execute$91(config, {
|
|
73361
73494
|
kind: "retry",
|
|
73362
73495
|
email: Option.getOrUndefined(email),
|
|
73363
73496
|
confirm,
|
|
@@ -73377,7 +73510,7 @@ const account = Command.make("account").pipe(annotate$8("root"), Command.withDes
|
|
|
73377
73510
|
const emailFlag$8 = Flag.String("email").pipe(Flag.optional);
|
|
73378
73511
|
const fromFlag = Flag.Int("from").pipe(Flag.optional);
|
|
73379
73512
|
const toFlag = Flag.Int("to").pipe(Flag.optional);
|
|
73380
|
-
const confirmFlag$
|
|
73513
|
+
const confirmFlag$5 = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
73381
73514
|
const names$7 = {
|
|
73382
73515
|
root: "activity",
|
|
73383
73516
|
list: "activity.list",
|
|
@@ -73576,7 +73709,7 @@ const annotationPreview = (annotation, actor) => [
|
|
|
73576
73709
|
];
|
|
73577
73710
|
//#endregion
|
|
73578
73711
|
//#region src/commands/activity/subcommands/list/execute.ts
|
|
73579
|
-
const execute$
|
|
73712
|
+
const execute$90 = (config, input) => Effect.gen(function* () {
|
|
73580
73713
|
const actor = yield* actorFor(input.orgId);
|
|
73581
73714
|
const params = yield* pageParams(input);
|
|
73582
73715
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
@@ -73600,7 +73733,7 @@ const command$78 = Command.make("list", {
|
|
|
73600
73733
|
statuses: Flag.String("status").pipe(Flag.atLeast(0)),
|
|
73601
73734
|
from: fromFlag,
|
|
73602
73735
|
to: toFlag
|
|
73603
|
-
}, ({ email, limit, cursor, activityKind, direction, statuses, from, to }) => dispatch$7("list", (config, orgId) => execute$
|
|
73736
|
+
}, ({ email, limit, cursor, activityKind, direction, statuses, from, to }) => dispatch$7("list", (config, orgId) => execute$90(config, {
|
|
73604
73737
|
kind: "list",
|
|
73605
73738
|
email: Option.getOrUndefined(email),
|
|
73606
73739
|
orgId,
|
|
@@ -73765,7 +73898,7 @@ const documentReferenceLines = (payment) => {
|
|
|
73765
73898
|
};
|
|
73766
73899
|
//#endregion
|
|
73767
73900
|
//#region src/commands/activity/subcommands/get/execute.ts
|
|
73768
|
-
const execute$
|
|
73901
|
+
const execute$89 = (config, input) => Effect.gen(function* () {
|
|
73769
73902
|
const actor = yield* actorFor(input.orgId);
|
|
73770
73903
|
const reference = {
|
|
73771
73904
|
kind: yield* activityKind(input.activityKind),
|
|
@@ -73789,7 +73922,7 @@ const command$77 = Command.make("get", {
|
|
|
73789
73922
|
email: emailFlag$8,
|
|
73790
73923
|
activityKind: Flag.String("kind"),
|
|
73791
73924
|
id: Flag.String("id")
|
|
73792
|
-
}, ({ email, activityKind, id }) => dispatch$7("get", (config, orgId) => execute$
|
|
73925
|
+
}, ({ email, activityKind, id }) => dispatch$7("get", (config, orgId) => execute$89(config, {
|
|
73793
73926
|
kind: "get",
|
|
73794
73927
|
email: Option.getOrUndefined(email),
|
|
73795
73928
|
orgId,
|
|
@@ -73798,7 +73931,7 @@ const command$77 = Command.make("get", {
|
|
|
73798
73931
|
}))).pipe(annotate$7("get"), Command.withDescription("Read one exact Payment or Movement"));
|
|
73799
73932
|
//#endregion
|
|
73800
73933
|
//#region src/commands/activity/subcommands/summary/execute.ts
|
|
73801
|
-
const execute$
|
|
73934
|
+
const execute$88 = (config, input) => Effect.gen(function* () {
|
|
73802
73935
|
const actor = yield* actorFor(input.orgId);
|
|
73803
73936
|
const window = yield* summaryRange(input.from, input.to);
|
|
73804
73937
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
@@ -73817,7 +73950,7 @@ const command$76 = Command.make("summary", {
|
|
|
73817
73950
|
email: emailFlag$8,
|
|
73818
73951
|
from: fromFlag,
|
|
73819
73952
|
to: toFlag
|
|
73820
|
-
}, ({ email, from, to }) => dispatch$7("summary", (config, orgId) => execute$
|
|
73953
|
+
}, ({ email, from, to }) => dispatch$7("summary", (config, orgId) => execute$88(config, {
|
|
73821
73954
|
kind: "summary",
|
|
73822
73955
|
email: Option.getOrUndefined(email),
|
|
73823
73956
|
orgId,
|
|
@@ -73826,7 +73959,7 @@ const command$76 = Command.make("summary", {
|
|
|
73826
73959
|
}))).pipe(annotate$7("summary"), Command.withDescription("Summarize exact raw-unit activity totals"));
|
|
73827
73960
|
//#endregion
|
|
73828
73961
|
//#region src/commands/activity/subcommands/annotate/execute.ts
|
|
73829
|
-
const execute$
|
|
73962
|
+
const execute$87 = (config, input) => Effect.gen(function* () {
|
|
73830
73963
|
const actor = yield* actorFor(input.orgId);
|
|
73831
73964
|
const interactive = yield* requireWriteConfirmation(input.confirm);
|
|
73832
73965
|
const annotation = yield* readAnnotation(input.source);
|
|
@@ -73852,8 +73985,8 @@ const execute$88 = (config, input) => Effect.gen(function* () {
|
|
|
73852
73985
|
const command$75 = Command.make("annotate", {
|
|
73853
73986
|
email: emailFlag$8,
|
|
73854
73987
|
source: Flag.String("input").pipe(Flag.optional),
|
|
73855
|
-
confirm: confirmFlag$
|
|
73856
|
-
}, ({ email, source, confirm }) => dispatch$7("annotate", (config, orgId) => execute$
|
|
73988
|
+
confirm: confirmFlag$5
|
|
73989
|
+
}, ({ email, source, confirm }) => dispatch$7("annotate", (config, orgId) => execute$87(config, {
|
|
73857
73990
|
kind: "annotate",
|
|
73858
73991
|
email: Option.getOrUndefined(email),
|
|
73859
73992
|
orgId,
|
|
@@ -73870,7 +74003,7 @@ const activity = Command.make("activity").pipe(annotate$7("root"), Command.withD
|
|
|
73870
74003
|
]));
|
|
73871
74004
|
//#endregion
|
|
73872
74005
|
//#region src/commands/account/subcommands/deposit/execute.ts
|
|
73873
|
-
const execute$
|
|
74006
|
+
const execute$86 = (config, email) => Effect.gen(function* () {
|
|
73874
74007
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
73875
74008
|
const runtime = yield* CliRuntime;
|
|
73876
74009
|
return yield* withWaiting(Effect.promise((signal) => client.account.profile.depositInstructions({ signal })).pipe(Effect.flatMap(resultValue), Effect.map((depositInstructions) => ({
|
|
@@ -73893,14 +74026,14 @@ const perform$11 = (scoped, organizationId, organization) => Effect.gen(function
|
|
|
73893
74026
|
label: "Organization deposit instructions"
|
|
73894
74027
|
});
|
|
73895
74028
|
});
|
|
73896
|
-
const execute$
|
|
74029
|
+
const execute$85 = (config, input) => readOrganization(config, "deposit", input, {
|
|
73897
74030
|
kind: "scoped",
|
|
73898
74031
|
run: ({ scoped, organizationId, organization }) => perform$11(scoped(), organizationId, organization)
|
|
73899
74032
|
});
|
|
73900
74033
|
//#endregion
|
|
73901
74034
|
//#region src/commands/address/execute.ts
|
|
73902
74035
|
/** Where to send crypto to your Account, or to the Organization you act as. */
|
|
73903
|
-
const execute$
|
|
74036
|
+
const execute$84 = (config, email) => Effect.flatMap(selectActor(config), (actor) => actor.kind === "personal" ? execute$86(config, email) : execute$85(config, {
|
|
73904
74037
|
email,
|
|
73905
74038
|
orgs: [actor.id]
|
|
73906
74039
|
}));
|
|
@@ -73914,7 +74047,7 @@ const metadata$16 = {
|
|
|
73914
74047
|
const address = Command.make("address", { email: Flag.String("email").pipe(Flag.optional) }, ({ email }) => runCommand({
|
|
73915
74048
|
...metadata$16,
|
|
73916
74049
|
network: true
|
|
73917
|
-
}, (config) => execute$
|
|
74050
|
+
}, (config) => execute$84(config, Option.getOrUndefined(email)))).pipe(Command.annotate(CliCommandMetadata, metadata$16), Command.withDescription("where to send crypto to this account"), Command.withExamples([{ command: "capxul address" }]));
|
|
73918
74051
|
//#endregion
|
|
73919
74052
|
//#region src/commands/auth/subcommands/shared.ts
|
|
73920
74053
|
const emailFlag$7 = Flag.String("email").pipe(Flag.withDescription("Email address"), Flag.optional);
|
|
@@ -73960,7 +74093,7 @@ const sendCode = (config, email) => Effect.gen(function* () {
|
|
|
73960
74093
|
});
|
|
73961
74094
|
//#endregion
|
|
73962
74095
|
//#region src/commands/auth/subcommands/login/execute.ts
|
|
73963
|
-
const execute$
|
|
74096
|
+
const execute$83 = (config, suppliedEmail, otpStdin) => Effect.gen(function* () {
|
|
73964
74097
|
const email = yield* readEmail(suppliedEmail);
|
|
73965
74098
|
const runtime = yield* CliRuntime;
|
|
73966
74099
|
if (!otpStdin && (!runtime.tty || runtime.ci || runtime.mode === "json")) return yield* sendCode(config, email);
|
|
@@ -73983,14 +74116,14 @@ const execute$84 = (config, suppliedEmail, otpStdin) => Effect.gen(function* ()
|
|
|
73983
74116
|
const command$74 = Command.make("login", {
|
|
73984
74117
|
email: emailFlag$7,
|
|
73985
74118
|
otpStdin: otpStdinFlag
|
|
73986
|
-
}, ({ email, otpStdin }) => dispatch$6("login", (config) => execute$
|
|
74119
|
+
}, ({ email, otpStdin }) => dispatch$6("login", (config) => execute$83(config, Option.getOrUndefined(email), otpStdin))).pipe(annotate$6("login"), Command.withDescription("Sign in with your email and a one-time code"));
|
|
73987
74120
|
//#endregion
|
|
73988
74121
|
//#region src/commands/auth/subcommands/verify/execute.ts
|
|
73989
74122
|
/**
|
|
73990
74123
|
* Finish a sign-in that `auth login` started without a terminal. The email is
|
|
73991
74124
|
* the one that sign-in saved, unless `--email` names another pending one.
|
|
73992
74125
|
*/
|
|
73993
|
-
const execute$
|
|
74126
|
+
const execute$82 = (config, input) => Effect.gen(function* () {
|
|
73994
74127
|
const pending = (yield* readWhere(config)).origins?.[config.bootstrapBaseUrl]?.pending;
|
|
73995
74128
|
if (input.email === void 0 && pending === void 0) return yield* inputRequired("No sign-in is waiting for a code. Start one with: capxul auth login");
|
|
73996
74129
|
const email = yield* readEmail(input.email ?? pending);
|
|
@@ -74032,7 +74165,7 @@ const command$73 = Command.make("verify", {
|
|
|
74032
74165
|
code: Argument.String("code").pipe(Argument.withDescription("The six-digit code from your email (or use --otp-stdin)"), Argument.optional),
|
|
74033
74166
|
email: emailFlag$7,
|
|
74034
74167
|
otpStdin: otpStdinFlag
|
|
74035
|
-
}, ({ code, email, otpStdin }) => dispatch$6("verify", (config) => execute$
|
|
74168
|
+
}, ({ code, email, otpStdin }) => dispatch$6("verify", (config) => execute$82(config, {
|
|
74036
74169
|
...Option.isSome(email) ? { email: email.value } : {},
|
|
74037
74170
|
...Option.isSome(code) ? { code: code.value } : {},
|
|
74038
74171
|
otpStdin
|
|
@@ -74093,7 +74226,7 @@ const cleanupStoredNativeGrant = (config, email) => Effect.gen(function* () {
|
|
|
74093
74226
|
});
|
|
74094
74227
|
//#endregion
|
|
74095
74228
|
//#region src/commands/auth/subcommands/logout/execute.ts
|
|
74096
|
-
const execute$
|
|
74229
|
+
const execute$81 = (config, suppliedEmail) => Effect.gen(function* () {
|
|
74097
74230
|
const current = suppliedEmail === void 0 ? yield* readCurrentSession(config) : null;
|
|
74098
74231
|
if (suppliedEmail === void 0 && current === null) return {
|
|
74099
74232
|
data: {
|
|
@@ -74142,11 +74275,11 @@ const execute$82 = (config, suppliedEmail) => Effect.gen(function* () {
|
|
|
74142
74275
|
});
|
|
74143
74276
|
//#endregion
|
|
74144
74277
|
//#region src/commands/auth/subcommands/logout/command.ts
|
|
74145
|
-
const command$72 = Command.make("logout", { email: emailFlag$7 }, ({ email }) => dispatch$6("logout", (config) => execute$
|
|
74278
|
+
const command$72 = Command.make("logout", { email: emailFlag$7 }, ({ email }) => dispatch$6("logout", (config) => execute$81(config, Option.getOrUndefined(email)))).pipe(annotate$6("logout"), Command.withDescription("Sign out on this device"));
|
|
74146
74279
|
//#endregion
|
|
74147
74280
|
//#region src/commands/auth/subcommands/switch/execute.ts
|
|
74148
74281
|
/** Make another person already signed in on this machine the current one. */
|
|
74149
|
-
const execute$
|
|
74282
|
+
const execute$80 = (config, suppliedEmail) => Effect.gen(function* () {
|
|
74150
74283
|
const email = yield* readEmail(suppliedEmail);
|
|
74151
74284
|
const store = yield* openSessionRecord(config, email);
|
|
74152
74285
|
if (store.current().token === null) return yield* Effect.fail(authenticationFailure(Errors.notAuthenticated(), email));
|
|
@@ -74164,7 +74297,7 @@ const execute$81 = (config, suppliedEmail) => Effect.gen(function* () {
|
|
|
74164
74297
|
});
|
|
74165
74298
|
//#endregion
|
|
74166
74299
|
//#region src/commands/auth/subcommands/switch/command.ts
|
|
74167
|
-
const command$71 = Command.make("switch", { email: Argument.String("email").pipe(Argument.withDescription("The email of someone already signed in on this machine")) }, ({ email }) => dispatch$6("switch", (config) => execute$
|
|
74300
|
+
const command$71 = Command.make("switch", { email: Argument.String("email").pipe(Argument.withDescription("The email of someone already signed in on this machine")) }, ({ email }) => dispatch$6("switch", (config) => execute$80(config, email))).pipe(annotate$6("switch"), Command.withDescription("Switch to another person signed in on this machine"), Command.withExamples([{ command: "capxul auth switch ada@example.com" }]));
|
|
74168
74301
|
//#endregion
|
|
74169
74302
|
//#region src/commands/auth/command.ts
|
|
74170
74303
|
const auth = Command.make("auth").pipe(annotate$6("root"), Command.withDescription("sign in, switch person, sign out"), Command.withSubcommands([
|
|
@@ -74175,7 +74308,7 @@ const auth = Command.make("auth").pipe(annotate$6("root"), Command.withDescripti
|
|
|
74175
74308
|
]));
|
|
74176
74309
|
//#endregion
|
|
74177
74310
|
//#region src/commands/account/subcommands/balance/execute.ts
|
|
74178
|
-
const execute$
|
|
74311
|
+
const execute$79 = (config, email) => Effect.gen(function* () {
|
|
74179
74312
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
74180
74313
|
const runtime = yield* CliRuntime;
|
|
74181
74314
|
return yield* withWaiting(Effect.promise((signal) => client.accounts.read({ signal })).pipe(Effect.flatMap(resultValue), Effect.map((account) => ({
|
|
@@ -74198,14 +74331,14 @@ const perform$10 = (scoped, organizationId, organization) => Effect.gen(function
|
|
|
74198
74331
|
label: "Organization balance"
|
|
74199
74332
|
});
|
|
74200
74333
|
});
|
|
74201
|
-
const execute$
|
|
74334
|
+
const execute$78 = (config, input) => readOrganization(config, "balance", input, {
|
|
74202
74335
|
kind: "scoped",
|
|
74203
74336
|
run: ({ scoped, organizationId, organization }) => perform$10(scoped(), organizationId, organization)
|
|
74204
74337
|
});
|
|
74205
74338
|
//#endregion
|
|
74206
74339
|
//#region src/commands/balance/execute.ts
|
|
74207
74340
|
/** Your Account's balances, or the treasury of the Organization you act as. */
|
|
74208
|
-
const execute$
|
|
74341
|
+
const execute$77 = (config, email) => Effect.flatMap(selectActor(config), (actor) => actor.kind === "personal" ? execute$79(config, email) : execute$78(config, {
|
|
74209
74342
|
email,
|
|
74210
74343
|
orgs: [actor.id]
|
|
74211
74344
|
}));
|
|
@@ -74219,7 +74352,7 @@ const metadata$14 = {
|
|
|
74219
74352
|
const balance = Command.make("balance", { email: Flag.String("email").pipe(Flag.optional) }, ({ email }) => runCommand({
|
|
74220
74353
|
...metadata$14,
|
|
74221
74354
|
network: true
|
|
74222
|
-
}, (config) => execute$
|
|
74355
|
+
}, (config) => execute$77(config, Option.getOrUndefined(email)))).pipe(Command.annotate(CliCommandMetadata, metadata$14), Command.withDescription("balances for whoever you're acting as"), Command.withExamples([{ command: "capxul balance" }, {
|
|
74223
74356
|
command: "capxul balance --org acme",
|
|
74224
74357
|
description: "An Organization's treasury"
|
|
74225
74358
|
}]));
|
|
@@ -74248,22 +74381,22 @@ const renderReport$1 = (config, status) => ({
|
|
|
74248
74381
|
});
|
|
74249
74382
|
//#endregion
|
|
74250
74383
|
//#region src/commands/config/subcommands/off/execute.ts
|
|
74251
|
-
const execute$
|
|
74384
|
+
const execute$76 = (config) => setCollectionEnabled(config.settingsPath, false).pipe(Effect.andThen(collectionStatus(config)), Effect.map((status) => renderReport$1(config, status)));
|
|
74252
74385
|
//#endregion
|
|
74253
74386
|
//#region src/commands/config/subcommands/off/command.ts
|
|
74254
|
-
const command$70 = Command.make("off", {}, () => dispatch$5("off", execute$
|
|
74387
|
+
const command$70 = Command.make("off", {}, () => dispatch$5("off", execute$76)).pipe(annotate$5("off"), Command.withDescription("Turn off usage and diagnostics collection"));
|
|
74255
74388
|
//#endregion
|
|
74256
74389
|
//#region src/commands/config/subcommands/on/execute.ts
|
|
74257
|
-
const execute$
|
|
74390
|
+
const execute$75 = (config) => setCollectionEnabled(config.settingsPath, true).pipe(Effect.andThen(collectionStatus(config)), Effect.map((status) => renderReport$1(config, status)));
|
|
74258
74391
|
//#endregion
|
|
74259
74392
|
//#region src/commands/config/subcommands/on/command.ts
|
|
74260
|
-
const command$69 = Command.make("on", {}, () => dispatch$5("on", execute$
|
|
74393
|
+
const command$69 = Command.make("on", {}, () => dispatch$5("on", execute$75)).pipe(annotate$5("on"), Command.withDescription("Turn on usage and diagnostics collection"));
|
|
74261
74394
|
//#endregion
|
|
74262
74395
|
//#region src/commands/config/subcommands/status/execute.ts
|
|
74263
|
-
const execute$
|
|
74396
|
+
const execute$74 = (config) => collectionStatus(config).pipe(Effect.map((status) => renderReport$1(config, status)));
|
|
74264
74397
|
//#endregion
|
|
74265
74398
|
//#region src/commands/config/subcommands/status/command.ts
|
|
74266
|
-
const command$68 = Command.make("status", {}, () => dispatch$5("status", execute$
|
|
74399
|
+
const command$68 = Command.make("status", {}, () => dispatch$5("status", execute$74)).pipe(annotate$5("status"), Command.withDescription("Show whether this CLI collects usage and diagnostics"));
|
|
74267
74400
|
//#endregion
|
|
74268
74401
|
//#region src/commands/config/command.ts
|
|
74269
74402
|
const telemetry = Command.make("telemetry").pipe(Command.annotate(CliCommandMetadata, {
|
|
@@ -74287,7 +74420,7 @@ const includeHiddenFlag = Flag.Boolean("include-hidden").pipe(Flag.withDefault(f
|
|
|
74287
74420
|
const entryIdArgument = Argument.String("id").pipe(Argument.withDescription("The contact's PartyId"), Argument.optional);
|
|
74288
74421
|
const labelFlag = Flag.String("label");
|
|
74289
74422
|
const inputFlag = Flag.String("input").pipe(Flag.optional);
|
|
74290
|
-
const confirmFlag$
|
|
74423
|
+
const confirmFlag$4 = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
74291
74424
|
const names$6 = {
|
|
74292
74425
|
root: "contact",
|
|
74293
74426
|
list: "contact.list",
|
|
@@ -74536,7 +74669,7 @@ const perform$9 = (book, prepared, orgs, email) => Effect.gen(function* () {
|
|
|
74536
74669
|
]
|
|
74537
74670
|
};
|
|
74538
74671
|
});
|
|
74539
|
-
const execute$
|
|
74672
|
+
const execute$73 = (config, input) => Effect.gen(function* () {
|
|
74540
74673
|
const prepared = yield* prepare$4(input);
|
|
74541
74674
|
const { client, session } = yield* restoreAuthenticatedClient(config, input.email);
|
|
74542
74675
|
const book = yield* selectedBook(client, input.actor, input.orgs);
|
|
@@ -74547,14 +74680,14 @@ const execute$74 = (config, input) => Effect.gen(function* () {
|
|
|
74547
74680
|
const command$67 = (context) => Command.make("add", {
|
|
74548
74681
|
email: emailFlag$6,
|
|
74549
74682
|
input: inputFlag,
|
|
74550
|
-
confirm: confirmFlag$
|
|
74683
|
+
confirm: confirmFlag$4
|
|
74551
74684
|
}, ({ email, input, confirm }) => context.dispatch("add", (scope) => ({
|
|
74552
74685
|
kind: "add",
|
|
74553
74686
|
...scope,
|
|
74554
74687
|
email: Option.getOrUndefined(email),
|
|
74555
74688
|
source: Option.getOrUndefined(input),
|
|
74556
74689
|
confirm
|
|
74557
|
-
}), execute$
|
|
74690
|
+
}), execute$73)).pipe(context.annotate("add"), Command.withDescription("Add one contact from AddressBookAddInput JSON"));
|
|
74558
74691
|
//#endregion
|
|
74559
74692
|
//#region src/commands/contact/subcommands/get/execute.ts
|
|
74560
74693
|
const prepare$3 = (input) => optionalPartyId(input.entryId);
|
|
@@ -74566,7 +74699,7 @@ const perform$8 = (book, entryId, orgs) => Effect.gen(function* () {
|
|
|
74566
74699
|
lines: [actorLine(orgs), ...entry === null ? ["No contact found."] : contactLines(entry)]
|
|
74567
74700
|
};
|
|
74568
74701
|
});
|
|
74569
|
-
const execute$
|
|
74702
|
+
const execute$72 = (config, input) => Effect.gen(function* () {
|
|
74570
74703
|
const entryId = yield* prepare$3(input);
|
|
74571
74704
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
74572
74705
|
const book = yield* selectedBook(client, input.actor, input.orgs);
|
|
@@ -74582,7 +74715,7 @@ const command$66 = (context) => Command.make("get", {
|
|
|
74582
74715
|
...scope,
|
|
74583
74716
|
email: Option.getOrUndefined(email),
|
|
74584
74717
|
entryId: Option.getOrUndefined(entryId)
|
|
74585
|
-
}), execute$
|
|
74718
|
+
}), execute$72)).pipe(context.annotate("get"), Command.withDescription("Read one contact by stable PartyId"));
|
|
74586
74719
|
//#endregion
|
|
74587
74720
|
//#region src/commands/contact/internal/write.ts
|
|
74588
74721
|
/**
|
|
@@ -74653,20 +74786,20 @@ const visibilityVerbs = (kind) => {
|
|
|
74653
74786
|
};
|
|
74654
74787
|
//#endregion
|
|
74655
74788
|
//#region src/commands/contact/subcommands/hide/execute.ts
|
|
74656
|
-
const { prepare: prepare$2, perform: perform$7, execute: execute$
|
|
74789
|
+
const { prepare: prepare$2, perform: perform$7, execute: execute$71 } = visibilityVerbs("hide");
|
|
74657
74790
|
//#endregion
|
|
74658
74791
|
//#region src/commands/contact/subcommands/hide/command.ts
|
|
74659
74792
|
const command$65 = (context) => Command.make("hide", {
|
|
74660
74793
|
email: emailFlag$6,
|
|
74661
74794
|
entryId: entryIdArgument,
|
|
74662
|
-
confirm: confirmFlag$
|
|
74795
|
+
confirm: confirmFlag$4
|
|
74663
74796
|
}, ({ email, entryId, confirm }) => context.dispatch("hide", (scope) => ({
|
|
74664
74797
|
kind: "hide",
|
|
74665
74798
|
...scope,
|
|
74666
74799
|
email: Option.getOrUndefined(email),
|
|
74667
74800
|
entryId: Option.getOrUndefined(entryId),
|
|
74668
74801
|
confirm
|
|
74669
|
-
}), execute$
|
|
74802
|
+
}), execute$71)).pipe(context.annotate("hide"), Command.withDescription("Hide one contact"));
|
|
74670
74803
|
//#endregion
|
|
74671
74804
|
//#region src/commands/contact/subcommands/label/execute.ts
|
|
74672
74805
|
const prepare$1 = (input) => Effect.gen(function* () {
|
|
@@ -74695,7 +74828,7 @@ const perform$6 = (book, prepared, orgs, email) => Effect.gen(function* () {
|
|
|
74695
74828
|
]
|
|
74696
74829
|
};
|
|
74697
74830
|
});
|
|
74698
|
-
const execute$
|
|
74831
|
+
const execute$70 = (config, input) => Effect.gen(function* () {
|
|
74699
74832
|
const prepared = yield* prepare$1(input);
|
|
74700
74833
|
const { client, session } = yield* restoreAuthenticatedClient(config, input.email);
|
|
74701
74834
|
const book = yield* selectedBook(client, input.actor, input.orgs);
|
|
@@ -74707,7 +74840,7 @@ const command$64 = (context) => Command.make("label", {
|
|
|
74707
74840
|
email: emailFlag$6,
|
|
74708
74841
|
entryId: entryIdArgument,
|
|
74709
74842
|
label: labelFlag,
|
|
74710
|
-
confirm: confirmFlag$
|
|
74843
|
+
confirm: confirmFlag$4
|
|
74711
74844
|
}, ({ email, entryId, label, confirm }) => context.dispatch("label", (scope) => ({
|
|
74712
74845
|
kind: "label",
|
|
74713
74846
|
...scope,
|
|
@@ -74715,14 +74848,14 @@ const command$64 = (context) => Command.make("label", {
|
|
|
74715
74848
|
entryId: Option.getOrUndefined(entryId),
|
|
74716
74849
|
label,
|
|
74717
74850
|
confirm
|
|
74718
|
-
}), execute$
|
|
74851
|
+
}), execute$70)).pipe(context.annotate("label"), Command.withDescription("Change one contact label by stable PartyId"));
|
|
74719
74852
|
//#endregion
|
|
74720
74853
|
//#region src/commands/contact/subcommands/list/execute.ts
|
|
74721
74854
|
const perform$5 = (book, input, orgs) => contactWaiting(Effect.promise((signal) => book.list(input.includeHidden ? { includeHidden: true } : void 0, { signal })).pipe(Effect.flatMap(resultValue)), "Contact list").pipe(Effect.mapError((error) => normalizeContactScopeFailure(error, orgs)), Effect.map((page) => ({
|
|
74722
74855
|
data: page,
|
|
74723
74856
|
lines: [actorLine(orgs), ...page.items.length === 0 ? ["No contacts found."] : page.items.flatMap(contactLines)]
|
|
74724
74857
|
})));
|
|
74725
|
-
const execute$
|
|
74858
|
+
const execute$69 = (config, input) => Effect.gen(function* () {
|
|
74726
74859
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
74727
74860
|
const book = yield* selectedBook(client, input.actor, input.orgs);
|
|
74728
74861
|
return yield* perform$5(book, input, input.orgs);
|
|
@@ -74737,23 +74870,23 @@ const command$63 = (context) => Command.make("list", {
|
|
|
74737
74870
|
...scope,
|
|
74738
74871
|
email: Option.getOrUndefined(email),
|
|
74739
74872
|
includeHidden
|
|
74740
|
-
}), execute$
|
|
74873
|
+
}), execute$69)).pipe(context.annotate("list"), Command.withDescription("List contacts in the selected actor's address book"));
|
|
74741
74874
|
//#endregion
|
|
74742
74875
|
//#region src/commands/contact/subcommands/unhide/execute.ts
|
|
74743
|
-
const { prepare, perform: perform$4, execute: execute$
|
|
74876
|
+
const { prepare, perform: perform$4, execute: execute$68 } = visibilityVerbs("unhide");
|
|
74744
74877
|
//#endregion
|
|
74745
74878
|
//#region src/commands/contact/subcommands/unhide/command.ts
|
|
74746
74879
|
const command$62 = (context) => Command.make("unhide", {
|
|
74747
74880
|
email: emailFlag$6,
|
|
74748
74881
|
entryId: entryIdArgument,
|
|
74749
|
-
confirm: confirmFlag$
|
|
74882
|
+
confirm: confirmFlag$4
|
|
74750
74883
|
}, ({ email, entryId, confirm }) => context.dispatch("unhide", (scope) => ({
|
|
74751
74884
|
kind: "unhide",
|
|
74752
74885
|
...scope,
|
|
74753
74886
|
email: Option.getOrUndefined(email),
|
|
74754
74887
|
entryId: Option.getOrUndefined(entryId),
|
|
74755
74888
|
confirm
|
|
74756
|
-
}), execute$
|
|
74889
|
+
}), execute$68)).pipe(context.annotate("unhide"), Command.withDescription("Restore one contact"));
|
|
74757
74890
|
//#endregion
|
|
74758
74891
|
//#region src/commands/contact/command.ts
|
|
74759
74892
|
const makeContactCommand = () => {
|
|
@@ -74820,7 +74953,7 @@ const readSendWords = (to, amount) => Effect.gen(function* () {
|
|
|
74820
74953
|
});
|
|
74821
74954
|
//#endregion
|
|
74822
74955
|
//#region src/commands/dev/fund.ts
|
|
74823
|
-
const execute$
|
|
74956
|
+
const execute$67 = (config, input) => Effect.gen(function* () {
|
|
74824
74957
|
const runtime = yield* CliRuntime;
|
|
74825
74958
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
74826
74959
|
const account = yield* withWaiting(Effect.promise((signal) => client.accounts.read({ signal })).pipe(Effect.flatMap(resultValue)), {
|
|
@@ -74892,7 +75025,7 @@ const mint = (config, origin) => Effect.tryPromise({
|
|
|
74892
75025
|
outcome: "failed"
|
|
74893
75026
|
})
|
|
74894
75027
|
});
|
|
74895
|
-
const execute$
|
|
75028
|
+
const execute$66 = (config, input) => Effect.gen(function* () {
|
|
74896
75029
|
const origin = yield* readOrigin(input.origin);
|
|
74897
75030
|
const runtime = yield* CliRuntime;
|
|
74898
75031
|
const answer = yield* withWaiting(mint(config, origin), {
|
|
@@ -74939,7 +75072,7 @@ const keyCommand = Command.make("key", {
|
|
|
74939
75072
|
}, ({ origin, print }) => runCommand({
|
|
74940
75073
|
...metadata$11("dev.key"),
|
|
74941
75074
|
network: true
|
|
74942
|
-
}, (config) => execute$
|
|
75075
|
+
}, (config) => execute$66(config, {
|
|
74943
75076
|
origin,
|
|
74944
75077
|
write: !print
|
|
74945
75078
|
}))).pipe(Command.annotate(CliCommandMetadata, metadata$11("dev.key")), Command.withDescription("a sandbox publishable key for your app, in .env.local"));
|
|
@@ -74950,7 +75083,7 @@ const fundCommand = Command.make("fund", {
|
|
|
74950
75083
|
}, ({ amount, asset, email }) => runCommand({
|
|
74951
75084
|
...metadata$11("dev.fund"),
|
|
74952
75085
|
network: true
|
|
74953
|
-
}, (config) => execute$
|
|
75086
|
+
}, (config) => execute$67(config, {
|
|
74954
75087
|
amount,
|
|
74955
75088
|
asset,
|
|
74956
75089
|
email: Option.getOrUndefined(email)
|
|
@@ -75026,7 +75159,7 @@ const renderReport = (local, network) => ({
|
|
|
75026
75159
|
});
|
|
75027
75160
|
//#endregion
|
|
75028
75161
|
//#region src/commands/doctor/execute.ts
|
|
75029
|
-
const execute$
|
|
75162
|
+
const execute$65 = (config, input) => Effect.gen(function* () {
|
|
75030
75163
|
const local = yield* readLocalState(config);
|
|
75031
75164
|
if (!input.online) return renderReport(local, { status: "not_checked" });
|
|
75032
75165
|
const publishableKey = yield* requireApplicationKey(config);
|
|
@@ -75055,7 +75188,7 @@ const doctor = Command.make("doctor", {
|
|
|
75055
75188
|
}, ({ online, timeoutMs }) => runCommand({
|
|
75056
75189
|
...metadata$10,
|
|
75057
75190
|
network: online
|
|
75058
|
-
}, (config, observation, onFinalize) => execute$
|
|
75191
|
+
}, (config, observation, onFinalize) => execute$65(config, {
|
|
75059
75192
|
online,
|
|
75060
75193
|
timeoutMs,
|
|
75061
75194
|
...observation === void 0 ? {} : { observation },
|
|
@@ -75180,7 +75313,7 @@ const readHome = (client, orgId, scope) => Effect.promise((signal) => client.me.
|
|
|
75180
75313
|
balances: null,
|
|
75181
75314
|
needs: null
|
|
75182
75315
|
})));
|
|
75183
|
-
const execute$
|
|
75316
|
+
const execute$64 = (config) => Effect.gen(function* () {
|
|
75184
75317
|
const runtime = yield* CliRuntime;
|
|
75185
75318
|
const human = runtime.mode === "human";
|
|
75186
75319
|
const where = yield* currentWhere(config, runtime.args ?? [], "context");
|
|
@@ -75250,7 +75383,7 @@ const metadata$9 = {
|
|
|
75250
75383
|
const home = Command.make("home", {}, () => runCommand({
|
|
75251
75384
|
...metadata$9,
|
|
75252
75385
|
network: true
|
|
75253
|
-
}, execute$
|
|
75386
|
+
}, execute$64)).pipe(Command.annotate(CliCommandMetadata, metadata$9), Command.withDescription("home screen: where you are, what needs you"), Command.unlisted);
|
|
75254
75387
|
//#endregion
|
|
75255
75388
|
//#region src/commands/document/subcommands/shared.ts
|
|
75256
75389
|
const documentHashFlag = Flag.String("document-hash");
|
|
@@ -75293,7 +75426,7 @@ const readRef = (documentHash, contentHash) => Effect.gen(function* () {
|
|
|
75293
75426
|
const matchingRef = (expected, actual) => expected.documentHash === actual.documentHash.toLowerCase() && expected.contentHash === actual.contentHash.toLowerCase();
|
|
75294
75427
|
//#endregion
|
|
75295
75428
|
//#region src/commands/document/subcommands/get/execute.ts
|
|
75296
|
-
const execute$
|
|
75429
|
+
const execute$63 = (config, input) => Effect.gen(function* () {
|
|
75297
75430
|
const ref = yield* readRef(input.documentHash, input.contentHash);
|
|
75298
75431
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
75299
75432
|
const document = yield* Effect.promise((signal) => client.paymentDocuments.get(ref, { signal })).pipe(Effect.flatMap(resultValue));
|
|
@@ -75321,7 +75454,7 @@ const command$61 = Command.make("get", {
|
|
|
75321
75454
|
documentHash: documentHashFlag,
|
|
75322
75455
|
contentHash: contentHashFlag,
|
|
75323
75456
|
email: emailFlag$5
|
|
75324
|
-
}, ({ documentHash, contentHash, email }) => dispatch$4("get", (config) => execute$
|
|
75457
|
+
}, ({ documentHash, contentHash, email }) => dispatch$4("get", (config) => execute$63(config, {
|
|
75325
75458
|
kind: "get",
|
|
75326
75459
|
documentHash,
|
|
75327
75460
|
contentHash,
|
|
@@ -75329,7 +75462,7 @@ const command$61 = Command.make("get", {
|
|
|
75329
75462
|
}))).pipe(annotate$4("get"), Command.withDescription("Read exact document bytes and metadata"));
|
|
75330
75463
|
//#endregion
|
|
75331
75464
|
//#region src/commands/document/subcommands/verify/execute.ts
|
|
75332
|
-
const execute$
|
|
75465
|
+
const execute$62 = (config, input) => Effect.gen(function* () {
|
|
75333
75466
|
const ref = yield* readRef(input.documentHash, input.contentHash);
|
|
75334
75467
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
75335
75468
|
const verification = yield* Effect.promise((signal) => client.paymentDocuments.verify(ref, { signal })).pipe(Effect.flatMap(resultValue));
|
|
@@ -75350,7 +75483,7 @@ const command$60 = Command.make("verify", {
|
|
|
75350
75483
|
documentHash: documentHashFlag,
|
|
75351
75484
|
contentHash: contentHashFlag,
|
|
75352
75485
|
email: emailFlag$5
|
|
75353
|
-
}, ({ documentHash, contentHash, email }) => dispatch$4("verify", (config) => execute$
|
|
75486
|
+
}, ({ documentHash, contentHash, email }) => dispatch$4("verify", (config) => execute$62(config, {
|
|
75354
75487
|
kind: "verify",
|
|
75355
75488
|
documentHash,
|
|
75356
75489
|
contentHash,
|
|
@@ -75358,7 +75491,7 @@ const command$60 = Command.make("verify", {
|
|
|
75358
75491
|
}))).pipe(annotate$4("verify"), Command.withDescription("Check an authorized document"));
|
|
75359
75492
|
//#endregion
|
|
75360
75493
|
//#region src/commands/document/subcommands/render/execute.ts
|
|
75361
|
-
const execute$
|
|
75494
|
+
const execute$61 = (config, input) => Effect.gen(function* () {
|
|
75362
75495
|
const ref = yield* readRef(input.documentHash, input.contentHash);
|
|
75363
75496
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
75364
75497
|
const document = yield* Effect.promise((signal) => client.paymentDocuments.render(ref, { signal })).pipe(Effect.flatMap(resultValue));
|
|
@@ -75376,7 +75509,7 @@ const command$59 = Command.make("render", {
|
|
|
75376
75509
|
contentHash: contentHashFlag,
|
|
75377
75510
|
email: emailFlag$5,
|
|
75378
75511
|
outputDirectory: Flag.String("output-dir").pipe(Flag.optional)
|
|
75379
|
-
}, ({ documentHash, contentHash, email, outputDirectory }) => dispatch$4("render", (config) => execute$
|
|
75512
|
+
}, ({ documentHash, contentHash, email, outputDirectory }) => dispatch$4("render", (config) => execute$61(config, {
|
|
75380
75513
|
kind: "render",
|
|
75381
75514
|
documentHash,
|
|
75382
75515
|
contentHash,
|
|
@@ -75385,7 +75518,7 @@ const command$59 = Command.make("render", {
|
|
|
75385
75518
|
}))).pipe(annotate$4("render"), Command.withDescription("Save a verified document as PDF"));
|
|
75386
75519
|
//#endregion
|
|
75387
75520
|
//#region src/commands/document/subcommands/export/execute.ts
|
|
75388
|
-
const execute$
|
|
75521
|
+
const execute$60 = (config, input) => Effect.gen(function* () {
|
|
75389
75522
|
const ref = yield* readRef(input.documentHash, input.contentHash);
|
|
75390
75523
|
if (input.out.length === 0) return yield* inputFailure("Provide --out with a new file path.");
|
|
75391
75524
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
@@ -75419,7 +75552,7 @@ const command$58 = Command.make("export", {
|
|
|
75419
75552
|
contentHash: contentHashFlag,
|
|
75420
75553
|
email: emailFlag$5,
|
|
75421
75554
|
out: outFlag
|
|
75422
|
-
}, ({ documentHash, contentHash, email, out }) => dispatch$4("export", (config) => execute$
|
|
75555
|
+
}, ({ documentHash, contentHash, email, out }) => dispatch$4("export", (config) => execute$60(config, {
|
|
75423
75556
|
kind: "export",
|
|
75424
75557
|
documentHash,
|
|
75425
75558
|
contentHash,
|
|
@@ -75870,7 +76003,7 @@ const preparedLine = (mode, prepared) => mode === "json" ? `${JSON.stringify({
|
|
|
75870
76003
|
* is composed only after confirmation, and the durable identity reaches stderr
|
|
75871
76004
|
* before any digest is forwarded.
|
|
75872
76005
|
*/
|
|
75873
|
-
const execute$
|
|
76006
|
+
const execute$59 = (config, input) => Effect.gen(function* () {
|
|
75874
76007
|
const request = yield* buildInviteRequest(input);
|
|
75875
76008
|
const timeoutSeconds = yield* readWriteTimeout(input.timeoutSeconds);
|
|
75876
76009
|
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
@@ -75959,7 +76092,7 @@ const previewLines$1 = (preview, recipient) => [
|
|
|
75959
76092
|
const emailFlag$4 = Flag.String("email").pipe(Flag.optional);
|
|
75960
76093
|
const invitationIdArgument = Argument.String("id").pipe(Argument.withDescription("The invitation ID"), Argument.optional);
|
|
75961
76094
|
const timeoutFlag$3 = Flag.Int("timeout-seconds").pipe(Flag.withDefault(120));
|
|
75962
|
-
const confirmFlag$
|
|
76095
|
+
const confirmFlag$3 = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
75963
76096
|
const target = {
|
|
75964
76097
|
invitationId: invitationIdArgument,
|
|
75965
76098
|
email: emailFlag$4
|
|
@@ -75998,7 +76131,7 @@ const command$57 = Command.make("invite", {
|
|
|
75998
76131
|
email: emailFlag$4,
|
|
75999
76132
|
requestKey: Flag.String("request-key").pipe(Flag.optional),
|
|
76000
76133
|
preview: Flag.Boolean("preview").pipe(Flag.withDefault(false)),
|
|
76001
|
-
confirm: confirmFlag$
|
|
76134
|
+
confirm: confirmFlag$3,
|
|
76002
76135
|
timeoutSeconds: timeoutFlag$3
|
|
76003
76136
|
}, ({ email, toEmail, accountId, budgetIds, permissionIds, newBudgetName, asset, limit, unlimited, recipientAccounts, anyRecipient, actions, requestKey, preview, confirm, timeoutSeconds }) => Effect.gen(function* () {
|
|
76004
76137
|
const input = {
|
|
@@ -76047,7 +76180,7 @@ const command$57 = Command.make("invite", {
|
|
|
76047
76180
|
errors: missing.map((option) => new CliError.MissingOption({ option }))
|
|
76048
76181
|
});
|
|
76049
76182
|
}
|
|
76050
|
-
yield* dispatch$3("org.member.invite", "org", (config, orgs) => execute$
|
|
76183
|
+
yield* dispatch$3("org.member.invite", "org", (config, orgs) => execute$59(config, {
|
|
76051
76184
|
...input,
|
|
76052
76185
|
orgs
|
|
76053
76186
|
}));
|
|
@@ -76220,7 +76353,7 @@ const readOfferDigest = (value, flag) => Effect.gen(function* () {
|
|
|
76220
76353
|
* technical granter after the consent commits. Only the exact grantee can
|
|
76221
76354
|
* accept; Admin access to the offer does not grant consent authority.
|
|
76222
76355
|
*/
|
|
76223
|
-
const execute$
|
|
76356
|
+
const execute$58 = (config, input) => Effect.gen(function* () {
|
|
76224
76357
|
const timeoutSeconds = yield* readWriteTimeout(input.timeoutSeconds);
|
|
76225
76358
|
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
76226
76359
|
const runtime = yield* CliRuntime;
|
|
@@ -76265,9 +76398,9 @@ const command$56 = Command.make("accept", {
|
|
|
76265
76398
|
...target,
|
|
76266
76399
|
offerDigest: Flag.String("offer-digest").pipe(Flag.optional),
|
|
76267
76400
|
expectedOffer: Flag.String("expected-offer").pipe(Flag.optional),
|
|
76268
|
-
confirm: confirmFlag$
|
|
76401
|
+
confirm: confirmFlag$3,
|
|
76269
76402
|
timeoutSeconds: timeoutFlag$3
|
|
76270
|
-
}, ({ email, invitationId, offerDigest, expectedOffer, confirm, timeoutSeconds }) => dispatch$3("invite.accept", "own", (config, orgs) => execute$
|
|
76403
|
+
}, ({ email, invitationId, offerDigest, expectedOffer, confirm, timeoutSeconds }) => dispatch$3("invite.accept", "own", (config, orgs) => execute$58(config, {
|
|
76271
76404
|
email: Option.getOrUndefined(email),
|
|
76272
76405
|
orgs,
|
|
76273
76406
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76307,14 +76440,14 @@ const transitionInvitation = (action, question) => (config, input) => Effect.gen
|
|
|
76307
76440
|
});
|
|
76308
76441
|
//#endregion
|
|
76309
76442
|
//#region src/commands/org-invite/subcommands/cancel/execute.ts
|
|
76310
|
-
const execute$
|
|
76443
|
+
const execute$57 = transitionInvitation("cancel", "Cancel this invitation?");
|
|
76311
76444
|
//#endregion
|
|
76312
76445
|
//#region src/commands/org-invite/subcommands/cancel/command.ts
|
|
76313
76446
|
const command$55 = Command.make("cancel", {
|
|
76314
76447
|
...target,
|
|
76315
|
-
confirm: confirmFlag$
|
|
76448
|
+
confirm: confirmFlag$3,
|
|
76316
76449
|
timeoutSeconds: timeoutFlag$3
|
|
76317
|
-
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("org.invite.cancel", "org", (config, orgs) => execute$
|
|
76450
|
+
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("org.invite.cancel", "org", (config, orgs) => execute$57(config, {
|
|
76318
76451
|
email: Option.getOrUndefined(email),
|
|
76319
76452
|
orgs,
|
|
76320
76453
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76323,14 +76456,14 @@ const command$55 = Command.make("cancel", {
|
|
|
76323
76456
|
}))).pipe(annotate$3("org.invite.cancel"), Command.withDescription("Cancel a pending offer you administer; starts its cleanup"));
|
|
76324
76457
|
//#endregion
|
|
76325
76458
|
//#region src/commands/org-invite/subcommands/decline/execute.ts
|
|
76326
|
-
const execute$
|
|
76459
|
+
const execute$56 = transitionInvitation("decline", "Decline this invitation?");
|
|
76327
76460
|
//#endregion
|
|
76328
76461
|
//#region src/commands/org-invite/subcommands/decline/command.ts
|
|
76329
76462
|
const command$54 = Command.make("decline", {
|
|
76330
76463
|
...target,
|
|
76331
|
-
confirm: confirmFlag$
|
|
76464
|
+
confirm: confirmFlag$3,
|
|
76332
76465
|
timeoutSeconds: timeoutFlag$3
|
|
76333
|
-
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("invite.decline", "own", (config, orgs) => execute$
|
|
76466
|
+
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("invite.decline", "own", (config, orgs) => execute$56(config, {
|
|
76334
76467
|
email: Option.getOrUndefined(email),
|
|
76335
76468
|
orgs,
|
|
76336
76469
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76339,7 +76472,7 @@ const command$54 = Command.make("decline", {
|
|
|
76339
76472
|
}))).pipe(annotate$3("invite.decline"), Command.withDescription("Decline your own pending offer; starts its cleanup"));
|
|
76340
76473
|
//#endregion
|
|
76341
76474
|
//#region src/commands/org-invite/subcommands/get/execute.ts
|
|
76342
|
-
const execute$
|
|
76475
|
+
const execute$55 = (config, input) => Effect.gen(function* () {
|
|
76343
76476
|
const { timeoutSeconds, email, invitationId, organizationId: explicitOrg } = yield* readInvitationReadInput(input, "optional");
|
|
76344
76477
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
76345
76478
|
const invitation = yield* readInvitationWithin(client, explicitOrg === null ? resolveOwningOrganization(client, invitationId) : Effect.succeed(explicitOrg), invitationId, timeoutSeconds);
|
|
@@ -76359,7 +76492,7 @@ const make$2 = (side) => {
|
|
|
76359
76492
|
return Command.make("get", {
|
|
76360
76493
|
...target,
|
|
76361
76494
|
timeoutSeconds: timeoutFlag$3
|
|
76362
|
-
}, ({ email, invitationId, timeoutSeconds }) => dispatch$3(name, side, (config, orgs) => execute$
|
|
76495
|
+
}, ({ email, invitationId, timeoutSeconds }) => dispatch$3(name, side, (config, orgs) => execute$55(config, {
|
|
76363
76496
|
email: Option.getOrUndefined(email),
|
|
76364
76497
|
orgs,
|
|
76365
76498
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76370,7 +76503,7 @@ const command$53 = make$2("own");
|
|
|
76370
76503
|
const sent$2 = make$2("org");
|
|
76371
76504
|
//#endregion
|
|
76372
76505
|
//#region src/commands/org-invite/subcommands/list/execute.ts
|
|
76373
|
-
const execute$
|
|
76506
|
+
const execute$54 = (config, input) => Effect.gen(function* () {
|
|
76374
76507
|
const bounds = yield* readPageBounds(input);
|
|
76375
76508
|
const explicitOrg = yield* readExactOrg(input.orgs ?? [], "optional");
|
|
76376
76509
|
if (input.mine === true && explicitOrg !== null) return yield* inputRequired("Provide either --mine or --org; the Organization list is not filtered to you.");
|
|
@@ -76397,7 +76530,7 @@ const make$1 = (side) => {
|
|
|
76397
76530
|
limit: Flag.Int("limit").pipe(Flag.optional),
|
|
76398
76531
|
cursor: Flag.String("after").pipe(Flag.withDescription("the next page's cursor"), Flag.optional),
|
|
76399
76532
|
phases: Flag.String("phase").pipe(Flag.atLeast(0))
|
|
76400
|
-
}, ({ email, limit, cursor, phases }) => dispatch$3(name, side, (config, orgs) => side === "org" && orgs.length === 0 ? Effect.fail(inputRequired("Provide --org.")) : execute$
|
|
76533
|
+
}, ({ email, limit, cursor, phases }) => dispatch$3(name, side, (config, orgs) => side === "org" && orgs.length === 0 ? Effect.fail(inputRequired("Provide --org.")) : execute$54(config, {
|
|
76401
76534
|
email: Option.getOrUndefined(email),
|
|
76402
76535
|
orgs,
|
|
76403
76536
|
limit: Option.getOrUndefined(limit),
|
|
@@ -76411,14 +76544,14 @@ const command$52 = make$1("own");
|
|
|
76411
76544
|
const sent$1 = make$1("org");
|
|
76412
76545
|
//#endregion
|
|
76413
76546
|
//#region src/commands/org-invite/subcommands/resend/execute.ts
|
|
76414
|
-
const execute$
|
|
76547
|
+
const execute$53 = transitionInvitation("resend", "Resend this invitation?");
|
|
76415
76548
|
//#endregion
|
|
76416
76549
|
//#region src/commands/org-invite/subcommands/resend/command.ts
|
|
76417
76550
|
const command$51 = Command.make("resend", {
|
|
76418
76551
|
...target,
|
|
76419
|
-
confirm: confirmFlag$
|
|
76552
|
+
confirm: confirmFlag$3,
|
|
76420
76553
|
timeoutSeconds: timeoutFlag$3
|
|
76421
|
-
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("org.invite.resend", "org", (config, orgs) => execute$
|
|
76554
|
+
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("org.invite.resend", "org", (config, orgs) => execute$53(config, {
|
|
76422
76555
|
email: Option.getOrUndefined(email),
|
|
76423
76556
|
orgs,
|
|
76424
76557
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76427,15 +76560,15 @@ const command$51 = Command.make("resend", {
|
|
|
76427
76560
|
}))).pipe(annotate$3("org.invite.resend"), Command.withDescription("Retry delivery of a verified pending offer; never extends expiry"));
|
|
76428
76561
|
//#endregion
|
|
76429
76562
|
//#region src/commands/org-invite/subcommands/retry/execute.ts
|
|
76430
|
-
const execute$
|
|
76563
|
+
const execute$52 = transitionInvitation("retry", "Retry this invitation?");
|
|
76431
76564
|
//#endregion
|
|
76432
76565
|
//#region src/commands/org-invite/subcommands/retry/command.ts
|
|
76433
76566
|
/** The backend's own recovery action for an offer; its guidance names it, the help does not. */
|
|
76434
76567
|
const command$50 = Command.make("retry", {
|
|
76435
76568
|
...target,
|
|
76436
|
-
confirm: confirmFlag$
|
|
76569
|
+
confirm: confirmFlag$3,
|
|
76437
76570
|
timeoutSeconds: timeoutFlag$3
|
|
76438
|
-
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("org.invite.retry", "org", (config, orgs) => execute$
|
|
76571
|
+
}, ({ email, invitationId, confirm, timeoutSeconds }) => dispatch$3("org.invite.retry", "org", (config, orgs) => execute$52(config, {
|
|
76439
76572
|
email: Option.getOrUndefined(email),
|
|
76440
76573
|
orgs,
|
|
76441
76574
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76444,7 +76577,7 @@ const command$50 = Command.make("retry", {
|
|
|
76444
76577
|
}))).pipe(annotate$3("org.invite.retry"), Command.withDescription("Resume the current offer state; creates no new consent or grant"), Command.unlisted);
|
|
76445
76578
|
//#endregion
|
|
76446
76579
|
//#region src/commands/org-invite/subcommands/review/execute.ts
|
|
76447
|
-
const execute$
|
|
76580
|
+
const execute$51 = (config, input) => Effect.gen(function* () {
|
|
76448
76581
|
const { timeoutSeconds, email, invitationId, organizationId } = yield* readInvitationReadInput(input, "optional");
|
|
76449
76582
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
76450
76583
|
const invitation = yield* readInvitationWithin(client, organizationId === null ? resolveOwningOrganization(client, invitationId) : Effect.succeed(organizationId), invitationId, timeoutSeconds);
|
|
@@ -76459,7 +76592,7 @@ const execute$52 = (config, input) => Effect.gen(function* () {
|
|
|
76459
76592
|
const command$49 = Command.make("review", {
|
|
76460
76593
|
...target,
|
|
76461
76594
|
timeoutSeconds: timeoutFlag$3
|
|
76462
|
-
}, ({ email, invitationId, timeoutSeconds }) => dispatch$3("invite.review", "own", (config, orgs) => execute$
|
|
76595
|
+
}, ({ email, invitationId, timeoutSeconds }) => dispatch$3("invite.review", "own", (config, orgs) => execute$51(config, {
|
|
76463
76596
|
email: Option.getOrUndefined(email),
|
|
76464
76597
|
orgs,
|
|
76465
76598
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76467,7 +76600,7 @@ const command$49 = Command.make("review", {
|
|
|
76467
76600
|
}))).pipe(annotate$3("invite.review"), Command.withDescription("Review one exact current offer without writing or signing"), Command.unlisted);
|
|
76468
76601
|
//#endregion
|
|
76469
76602
|
//#region src/commands/org-invite/subcommands/wait/execute.ts
|
|
76470
|
-
const execute$
|
|
76603
|
+
const execute$50 = (config, input) => Effect.gen(function* () {
|
|
76471
76604
|
const { timeoutSeconds, email, invitationId, organizationId: explicitOrg } = yield* readInvitationReadInput(input, "optional");
|
|
76472
76605
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
76473
76606
|
let resolvedOrg = null;
|
|
@@ -76510,7 +76643,7 @@ const make = (side) => {
|
|
|
76510
76643
|
return Command.make("wait", {
|
|
76511
76644
|
...target,
|
|
76512
76645
|
timeoutSeconds: timeoutFlag$3
|
|
76513
|
-
}, ({ email, invitationId, timeoutSeconds }) => dispatch$3(name, side, (config, orgs) => execute$
|
|
76646
|
+
}, ({ email, invitationId, timeoutSeconds }) => dispatch$3(name, side, (config, orgs) => execute$50(config, {
|
|
76514
76647
|
email: Option.getOrUndefined(email),
|
|
76515
76648
|
orgs,
|
|
76516
76649
|
invitationId: Option.getOrUndefined(invitationId),
|
|
@@ -76568,7 +76701,7 @@ const makeContext$1 = () => ({
|
|
|
76568
76701
|
//#region src/commands/request/subcommands/shared.ts
|
|
76569
76702
|
const emailFlag$3 = Flag.String("email").pipe(Flag.optional);
|
|
76570
76703
|
const idArgument = Argument.String("id").pipe(Argument.withDescription("The request ID"));
|
|
76571
|
-
const confirmFlag$
|
|
76704
|
+
const confirmFlag$2 = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
76572
76705
|
const names$3 = {
|
|
76573
76706
|
"issued.root": "request",
|
|
76574
76707
|
"issued.issue": "request.issue",
|
|
@@ -76648,7 +76781,7 @@ const offerLines = (offer) => [
|
|
|
76648
76781
|
];
|
|
76649
76782
|
//#endregion
|
|
76650
76783
|
//#region src/commands/offer/subcommands/list/execute.ts
|
|
76651
|
-
const execute$
|
|
76784
|
+
const execute$49 = (config, input) => Effect.gen(function* () {
|
|
76652
76785
|
const orgId = yield* readScope(input);
|
|
76653
76786
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
76654
76787
|
const offers = (orgId === null ? client.account : client.org(orgId)).offers;
|
|
@@ -76668,7 +76801,7 @@ const command$47 = (context) => Command.make("list", { email: emailFlag$3 }, ({
|
|
|
76668
76801
|
kind: "list",
|
|
76669
76802
|
...scope,
|
|
76670
76803
|
email: Option.getOrUndefined(email)
|
|
76671
|
-
}), execute$
|
|
76804
|
+
}), execute$49)).pipe(context.annotate("list"), Command.withDescription("List fixed offers"));
|
|
76672
76805
|
//#endregion
|
|
76673
76806
|
//#region src/commands/offer/internal/input.ts
|
|
76674
76807
|
const exactText = (value, flag) => value.trim().length === 0 || new TextEncoder().encode(value).length > 128 || /[\p{Cc}\p{Cf}]/u.test(value) ? Effect.fail(inputRequired(`Provide a nonempty --${flag} of at most 128 bytes without control characters.`)) : Effect.succeed(value);
|
|
@@ -76697,7 +76830,7 @@ const readOfferInput = (source) => Effect.gen(function* () {
|
|
|
76697
76830
|
}).pipe(Effect.mapError((error) => error instanceof UpdateUnavailable ? inputRequired("Offer input exceeds 64 KiB.") : error));
|
|
76698
76831
|
//#endregion
|
|
76699
76832
|
//#region src/commands/offer/subcommands/get/execute.ts
|
|
76700
|
-
const execute$
|
|
76833
|
+
const execute$48 = (config, input) => Effect.gen(function* () {
|
|
76701
76834
|
const orgId = yield* readScope(input);
|
|
76702
76835
|
const id = yield* exactText(input.id, "offer-id");
|
|
76703
76836
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
@@ -76719,7 +76852,7 @@ const command$46 = (context) => Command.make("get", {
|
|
|
76719
76852
|
...scope,
|
|
76720
76853
|
email: Option.getOrUndefined(email),
|
|
76721
76854
|
id
|
|
76722
|
-
}), execute$
|
|
76855
|
+
}), execute$48)).pipe(context.annotate("get"), Command.withDescription("Get fixed offers"));
|
|
76723
76856
|
//#endregion
|
|
76724
76857
|
//#region src/commands/offer/internal/write.ts
|
|
76725
76858
|
/** An uncertain write returns scoped readback, never an automatic retry. */
|
|
@@ -76758,7 +76891,7 @@ const changeOffer = (config, email, target, change) => Effect.gen(function* () {
|
|
|
76758
76891
|
});
|
|
76759
76892
|
//#endregion
|
|
76760
76893
|
//#region src/commands/offer/subcommands/create/execute.ts
|
|
76761
|
-
const execute$
|
|
76894
|
+
const execute$47 = (config, input) => Effect.gen(function* () {
|
|
76762
76895
|
const orgId = yield* readScope(input);
|
|
76763
76896
|
const requestKey = yield* exactText(input.requestKey, "request-key");
|
|
76764
76897
|
const terms = yield* readOfferInput(input.source);
|
|
@@ -76789,7 +76922,7 @@ const command$45 = (context) => Command.make("create", {
|
|
|
76789
76922
|
email: emailFlag$3,
|
|
76790
76923
|
source: Flag.String("input"),
|
|
76791
76924
|
requestKey: Flag.String("request-key"),
|
|
76792
|
-
confirm: confirmFlag$
|
|
76925
|
+
confirm: confirmFlag$2
|
|
76793
76926
|
}, ({ email, source, requestKey, confirm }) => context.dispatch("create", (scope) => ({
|
|
76794
76927
|
kind: "create",
|
|
76795
76928
|
...scope,
|
|
@@ -76797,10 +76930,10 @@ const command$45 = (context) => Command.make("create", {
|
|
|
76797
76930
|
source,
|
|
76798
76931
|
requestKey,
|
|
76799
76932
|
confirm
|
|
76800
|
-
}), execute$
|
|
76933
|
+
}), execute$47)).pipe(context.annotate("create"), Command.withDescription("Create fixed offers"));
|
|
76801
76934
|
//#endregion
|
|
76802
76935
|
//#region src/commands/offer/subcommands/revise/execute.ts
|
|
76803
|
-
const execute$
|
|
76936
|
+
const execute$46 = (config, input) => Effect.gen(function* () {
|
|
76804
76937
|
const orgId = yield* readScope(input);
|
|
76805
76938
|
const id = yield* exactText(input.id, "offer-id");
|
|
76806
76939
|
const expectedRevision = yield* exactRevision(input.revision);
|
|
@@ -76828,7 +76961,7 @@ const command$44 = (context) => Command.make("revise", {
|
|
|
76828
76961
|
id: idArgument$1,
|
|
76829
76962
|
revision: revisionFlag,
|
|
76830
76963
|
source: Flag.String("input"),
|
|
76831
|
-
confirm: confirmFlag$
|
|
76964
|
+
confirm: confirmFlag$2
|
|
76832
76965
|
}, ({ email, id, revision, source, confirm }) => context.dispatch("revise", (scope) => ({
|
|
76833
76966
|
kind: "revise",
|
|
76834
76967
|
...scope,
|
|
@@ -76837,10 +76970,10 @@ const command$44 = (context) => Command.make("revise", {
|
|
|
76837
76970
|
revision,
|
|
76838
76971
|
source,
|
|
76839
76972
|
confirm
|
|
76840
|
-
}), execute$
|
|
76973
|
+
}), execute$46)).pipe(context.annotate("revise"), Command.withDescription("Revise fixed offers"));
|
|
76841
76974
|
//#endregion
|
|
76842
76975
|
//#region src/commands/offer/subcommands/deactivate/execute.ts
|
|
76843
|
-
const execute$
|
|
76976
|
+
const execute$45 = (config, input) => Effect.gen(function* () {
|
|
76844
76977
|
const orgId = yield* readScope(input);
|
|
76845
76978
|
const id = yield* exactText(input.id, "offer-id");
|
|
76846
76979
|
const expectedRevision = yield* exactRevision(input.revision);
|
|
@@ -76865,7 +76998,7 @@ const command$43 = (context) => Command.make("deactivate", {
|
|
|
76865
76998
|
email: emailFlag$3,
|
|
76866
76999
|
id: idArgument$1,
|
|
76867
77000
|
revision: revisionFlag,
|
|
76868
|
-
confirm: confirmFlag$
|
|
77001
|
+
confirm: confirmFlag$2
|
|
76869
77002
|
}, ({ email, id, revision, confirm }) => context.dispatch("deactivate", (scope) => ({
|
|
76870
77003
|
kind: "deactivate",
|
|
76871
77004
|
...scope,
|
|
@@ -76873,7 +77006,7 @@ const command$43 = (context) => Command.make("deactivate", {
|
|
|
76873
77006
|
id,
|
|
76874
77007
|
revision,
|
|
76875
77008
|
confirm
|
|
76876
|
-
}), execute$
|
|
77009
|
+
}), execute$45)).pipe(context.annotate("deactivate"), Command.withDescription("Deactivate fixed offers"));
|
|
76877
77010
|
//#endregion
|
|
76878
77011
|
//#region src/commands/offer/command.ts
|
|
76879
77012
|
const makeCommand = () => {
|
|
@@ -76896,7 +77029,7 @@ const accountIdFlag = Flag.String("account-id").pipe(Flag.optional);
|
|
|
76896
77029
|
const assignmentIdArgument = Argument.String("id").pipe(Argument.withDescription("The Permission assignment ID"), Argument.optional);
|
|
76897
77030
|
const expectedMemberEmailFlag = Flag.String("expected-member-email").pipe(Flag.optional);
|
|
76898
77031
|
const requestKeyFlag$2 = Flag.String("request-key").pipe(Flag.between(0, 1), Flag.map((values) => Option.fromUndefinedOr(values[0])));
|
|
76899
|
-
const confirmFlag$
|
|
77032
|
+
const confirmFlag$1 = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
76900
77033
|
const timeoutFlag$2 = Flag.Int("timeout-seconds").pipe(Flag.withDefault(120));
|
|
76901
77034
|
const names$2 = {
|
|
76902
77035
|
root: "org.permission",
|
|
@@ -77315,7 +77448,7 @@ const resolvePermissionScope = (config, email, explicit) => Effect.gen(function*
|
|
|
77315
77448
|
});
|
|
77316
77449
|
//#endregion
|
|
77317
77450
|
//#region src/commands/org/subcommands/permission/subcommands/list/execute.ts
|
|
77318
|
-
const execute$
|
|
77451
|
+
const execute$44 = (config, input) => Effect.gen(function* () {
|
|
77319
77452
|
const explicit = yield* explicitOrganization$1(input.orgs);
|
|
77320
77453
|
const { orgId, organization, permissions } = yield* resolvePermissionScope(config, input.email, explicit);
|
|
77321
77454
|
const runtime = yield* CliRuntime;
|
|
@@ -77330,7 +77463,7 @@ const execute$45 = (config, input) => Effect.gen(function* () {
|
|
|
77330
77463
|
});
|
|
77331
77464
|
//#endregion
|
|
77332
77465
|
//#region src/commands/org/subcommands/permission/subcommands/list/command.ts
|
|
77333
|
-
const command$42 = Command.make("list", { email: emailFlag$2 }, ({ email }) => dispatch$2("list", (config, orgs) => execute$
|
|
77466
|
+
const command$42 = Command.make("list", { email: emailFlag$2 }, ({ email }) => dispatch$2("list", (config, orgs) => execute$44(config, {
|
|
77334
77467
|
kind: "list",
|
|
77335
77468
|
orgs,
|
|
77336
77469
|
email: Option.getOrUndefined(email)
|
|
@@ -77348,7 +77481,7 @@ const notFound = () => new CliFailure({
|
|
|
77348
77481
|
exitCode: 2,
|
|
77349
77482
|
message: "The Permission was not found or is unavailable to this session. Check the Permission ID."
|
|
77350
77483
|
});
|
|
77351
|
-
const execute$
|
|
77484
|
+
const execute$43 = (config, input) => Effect.gen(function* () {
|
|
77352
77485
|
const explicit = yield* explicitOrganization$1(input.orgs);
|
|
77353
77486
|
const permissionId = yield* readPermissionId(input.permissionId);
|
|
77354
77487
|
const { orgId, permissions } = yield* resolvePermissionScope(config, input.email, explicit);
|
|
@@ -77374,7 +77507,7 @@ const execute$44 = (config, input) => Effect.gen(function* () {
|
|
|
77374
77507
|
const command$41 = Command.make("get", {
|
|
77375
77508
|
email: emailFlag$2,
|
|
77376
77509
|
permissionId: permissionIdArgument
|
|
77377
|
-
}, ({ email, permissionId }) => dispatch$2("get", (config, orgs) => execute$
|
|
77510
|
+
}, ({ email, permissionId }) => dispatch$2("get", (config, orgs) => execute$43(config, {
|
|
77378
77511
|
kind: "get",
|
|
77379
77512
|
orgs,
|
|
77380
77513
|
email: Option.getOrUndefined(email),
|
|
@@ -77589,7 +77722,7 @@ const writeValidatedPermission = (config, input, validated, submit) => Effect.ge
|
|
|
77589
77722
|
});
|
|
77590
77723
|
//#endregion
|
|
77591
77724
|
//#region src/commands/org/subcommands/permission/subcommands/create/execute.ts
|
|
77592
|
-
const execute$
|
|
77725
|
+
const execute$42 = (config, input) => Effect.gen(function* () {
|
|
77593
77726
|
const validated = yield* validateWriteInput(input);
|
|
77594
77727
|
return yield* writeValidatedPermission(config, input, validated, (methods, selection, key, signal, onPrepared) => {
|
|
77595
77728
|
if (selection.kind !== "create") throw new Error("Expected Permission creation preview");
|
|
@@ -77608,9 +77741,9 @@ const command$40 = Command.make("create", {
|
|
|
77608
77741
|
email: emailFlag$2,
|
|
77609
77742
|
input: sourceFlag$2,
|
|
77610
77743
|
requestKey: requestKeyFlag$2,
|
|
77611
|
-
confirm: confirmFlag$
|
|
77744
|
+
confirm: confirmFlag$1,
|
|
77612
77745
|
timeoutSeconds: timeoutFlag$2
|
|
77613
|
-
}, ({ email, input, requestKey, confirm, timeoutSeconds }) => dispatch$2("create", (config, orgs) => execute$
|
|
77746
|
+
}, ({ email, input, requestKey, confirm, timeoutSeconds }) => dispatch$2("create", (config, orgs) => execute$42(config, {
|
|
77614
77747
|
kind: "create",
|
|
77615
77748
|
orgs,
|
|
77616
77749
|
email: Option.getOrUndefined(email),
|
|
@@ -77621,7 +77754,7 @@ const command$40 = Command.make("create", {
|
|
|
77621
77754
|
}))).pipe(annotate$2("create"), Command.withDescription("Create a Permission from its complete policy"));
|
|
77622
77755
|
//#endregion
|
|
77623
77756
|
//#region src/commands/org/subcommands/permission/subcommands/change/execute.ts
|
|
77624
|
-
const execute$
|
|
77757
|
+
const execute$41 = (config, input) => Effect.gen(function* () {
|
|
77625
77758
|
const validated = yield* validateWriteInput(input);
|
|
77626
77759
|
return yield* writeValidatedPermission(config, input, validated, (methods, selection, key, signal, onPrepared) => {
|
|
77627
77760
|
if (selection.kind !== "change" || selection.permission === null) throw new Error("Expected an active Permission for change");
|
|
@@ -77642,9 +77775,9 @@ const command$39 = Command.make("change", {
|
|
|
77642
77775
|
permissionId: permissionIdArgument.pipe(Argument.optional),
|
|
77643
77776
|
input: sourceFlag$2,
|
|
77644
77777
|
requestKey: requestKeyFlag$2,
|
|
77645
|
-
confirm: confirmFlag$
|
|
77778
|
+
confirm: confirmFlag$1,
|
|
77646
77779
|
timeoutSeconds: timeoutFlag$2
|
|
77647
|
-
}, ({ email, permissionId, input, requestKey, confirm, timeoutSeconds }) => dispatch$2("change", (config, orgs) => execute$
|
|
77780
|
+
}, ({ email, permissionId, input, requestKey, confirm, timeoutSeconds }) => dispatch$2("change", (config, orgs) => execute$41(config, {
|
|
77648
77781
|
kind: "change",
|
|
77649
77782
|
orgs,
|
|
77650
77783
|
email: Option.getOrUndefined(email),
|
|
@@ -77656,7 +77789,7 @@ const command$39 = Command.make("change", {
|
|
|
77656
77789
|
}))).pipe(annotate$2("change"), Command.withDescription("Replace one active Permission's complete policy"));
|
|
77657
77790
|
//#endregion
|
|
77658
77791
|
//#region src/commands/org/subcommands/permission/subcommands/assign/execute.ts
|
|
77659
|
-
const execute$
|
|
77792
|
+
const execute$40 = (config, input) => Effect.gen(function* () {
|
|
77660
77793
|
const validated = yield* validateWriteInput(input);
|
|
77661
77794
|
return yield* writeValidatedPermission(config, input, validated, (methods, selection, key, signal, onPrepared) => {
|
|
77662
77795
|
if (selection.kind !== "assign") throw new Error("Expected Permission assignment preview");
|
|
@@ -77679,9 +77812,9 @@ const command$38 = Command.make("assign", {
|
|
|
77679
77812
|
accountId: accountIdFlag,
|
|
77680
77813
|
expectedMemberEmail: expectedMemberEmailFlag,
|
|
77681
77814
|
requestKey: requestKeyFlag$2,
|
|
77682
|
-
confirm: confirmFlag$
|
|
77815
|
+
confirm: confirmFlag$1,
|
|
77683
77816
|
timeoutSeconds: timeoutFlag$2
|
|
77684
|
-
}, ({ email, permissionId, accountId, expectedMemberEmail, requestKey, confirm, timeoutSeconds }) => dispatch$2("assign", (config, orgs) => execute$
|
|
77817
|
+
}, ({ email, permissionId, accountId, expectedMemberEmail, requestKey, confirm, timeoutSeconds }) => dispatch$2("assign", (config, orgs) => execute$40(config, {
|
|
77685
77818
|
kind: "assign",
|
|
77686
77819
|
orgs,
|
|
77687
77820
|
email: Option.getOrUndefined(email),
|
|
@@ -77694,7 +77827,7 @@ const command$38 = Command.make("assign", {
|
|
|
77694
77827
|
}))).pipe(annotate$2("assign"), Command.withDescription("Assign one active Permission to one exact Account"));
|
|
77695
77828
|
//#endregion
|
|
77696
77829
|
//#region src/commands/org/subcommands/permission/subcommands/revoke/execute.ts
|
|
77697
|
-
const execute$
|
|
77830
|
+
const execute$39 = (config, input) => Effect.gen(function* () {
|
|
77698
77831
|
const validated = yield* validateWriteInput(input);
|
|
77699
77832
|
return yield* writeValidatedPermission(config, input, validated, (methods, selection, key, signal, onPrepared) => {
|
|
77700
77833
|
if (selection.kind !== "revoke") throw new Error("Expected Permission revocation preview");
|
|
@@ -77713,9 +77846,9 @@ const command$37 = Command.make("revoke", {
|
|
|
77713
77846
|
email: emailFlag$2,
|
|
77714
77847
|
assignmentId: assignmentIdArgument,
|
|
77715
77848
|
requestKey: requestKeyFlag$2,
|
|
77716
|
-
confirm: confirmFlag$
|
|
77849
|
+
confirm: confirmFlag$1,
|
|
77717
77850
|
timeoutSeconds: timeoutFlag$2
|
|
77718
|
-
}, ({ email, assignmentId, requestKey, confirm, timeoutSeconds }) => dispatch$2("revoke", (config, orgs) => execute$
|
|
77851
|
+
}, ({ email, assignmentId, requestKey, confirm, timeoutSeconds }) => dispatch$2("revoke", (config, orgs) => execute$39(config, {
|
|
77719
77852
|
kind: "revoke",
|
|
77720
77853
|
orgs,
|
|
77721
77854
|
email: Option.getOrUndefined(email),
|
|
@@ -77726,7 +77859,7 @@ const command$37 = Command.make("revoke", {
|
|
|
77726
77859
|
}))).pipe(annotate$2("revoke"), Command.withDescription("Revoke one exact active Permission assignment"));
|
|
77727
77860
|
//#endregion
|
|
77728
77861
|
//#region src/commands/org/subcommands/permission/subcommands/replace/execute.ts
|
|
77729
|
-
const execute$
|
|
77862
|
+
const execute$38 = (config, input) => Effect.gen(function* () {
|
|
77730
77863
|
const validated = yield* validateWriteInput(input);
|
|
77731
77864
|
return yield* writeValidatedPermission(config, input, validated, (methods, selection, requestKey, signal, onPrepared) => {
|
|
77732
77865
|
if (selection.kind !== "replace") throw new Error("Expected Permission replacement preview");
|
|
@@ -77744,9 +77877,9 @@ const execute$39 = (config, input) => Effect.gen(function* () {
|
|
|
77744
77877
|
const command$36 = Command.make("replace", {
|
|
77745
77878
|
email: emailFlag$2,
|
|
77746
77879
|
requestKey: requestKeyFlag$2,
|
|
77747
|
-
confirm: confirmFlag$
|
|
77880
|
+
confirm: confirmFlag$1,
|
|
77748
77881
|
timeoutSeconds: timeoutFlag$2
|
|
77749
|
-
}, ({ email, requestKey, confirm, timeoutSeconds }) => dispatch$2("replace", (config, orgs) => execute$
|
|
77882
|
+
}, ({ email, requestKey, confirm, timeoutSeconds }) => dispatch$2("replace", (config, orgs) => execute$38(config, {
|
|
77750
77883
|
kind: "replace",
|
|
77751
77884
|
orgs,
|
|
77752
77885
|
email: Option.getOrUndefined(email),
|
|
@@ -77964,7 +78097,7 @@ const observeValidatedCommand = (config, input, validated, read) => Effect.gen(f
|
|
|
77964
78097
|
});
|
|
77965
78098
|
//#endregion
|
|
77966
78099
|
//#region src/commands/org/subcommands/permission/subcommands/command/subcommands/get/execute.ts
|
|
77967
|
-
const execute$
|
|
78100
|
+
const execute$37 = (config, input) => Effect.gen(function* () {
|
|
77968
78101
|
const validated = yield* validateObservationInput(input);
|
|
77969
78102
|
return yield* observeValidatedCommand(config, input, validated, (methods, _org, key) => Effect.promise((signal) => methods.getCommand(key, { signal })).pipe(Effect.flatMap(resultValue)));
|
|
77970
78103
|
});
|
|
@@ -77974,7 +78107,7 @@ const command$35 = Command.make("get", {
|
|
|
77974
78107
|
email: emailFlag$2,
|
|
77975
78108
|
requestKey: requestKeyFlag$2,
|
|
77976
78109
|
timeoutSeconds: timeoutFlag$2
|
|
77977
|
-
}, ({ email, requestKey, timeoutSeconds }) => dispatch$2("commandGet", (config, orgs) => execute$
|
|
78110
|
+
}, ({ email, requestKey, timeoutSeconds }) => dispatch$2("commandGet", (config, orgs) => execute$37(config, {
|
|
77978
78111
|
kind: "commandGet",
|
|
77979
78112
|
orgs,
|
|
77980
78113
|
email: Option.getOrUndefined(email),
|
|
@@ -77983,7 +78116,7 @@ const command$35 = Command.make("get", {
|
|
|
77983
78116
|
}))).pipe(annotate$2("commandGet"), Command.withDescription("Read one exact owned Permission command"));
|
|
77984
78117
|
//#endregion
|
|
77985
78118
|
//#region src/commands/org/subcommands/permission/subcommands/command/subcommands/wait/execute.ts
|
|
77986
|
-
const execute$
|
|
78119
|
+
const execute$36 = (config, input) => Effect.gen(function* () {
|
|
77987
78120
|
const validated = yield* validateObservationInput(input);
|
|
77988
78121
|
return yield* observeValidatedCommand(config, input, validated, (methods, orgId, key, seen) => observeCommand((listener, signal) => methods.subscribeCommand(key, listener, { signal }), orgId, key, seen));
|
|
77989
78122
|
});
|
|
@@ -77993,7 +78126,7 @@ const command$34 = Command.make("wait", {
|
|
|
77993
78126
|
email: emailFlag$2,
|
|
77994
78127
|
requestKey: requestKeyFlag$2,
|
|
77995
78128
|
timeoutSeconds: timeoutFlag$2
|
|
77996
|
-
}, ({ email, requestKey, timeoutSeconds }) => dispatch$2("commandWait", (config, orgs) => execute$
|
|
78129
|
+
}, ({ email, requestKey, timeoutSeconds }) => dispatch$2("commandWait", (config, orgs) => execute$36(config, {
|
|
77997
78130
|
kind: "commandWait",
|
|
77998
78131
|
orgs,
|
|
77999
78132
|
email: Option.getOrUndefined(email),
|
|
@@ -78023,7 +78156,7 @@ const groupIdArgument = Argument.String("id").pipe(Argument.withDescription("The
|
|
|
78023
78156
|
const runIdArgument = Argument.String("id").pipe(Argument.withDescription("The Payroll run ID"), Argument.optional, Argument.map(Option.toArray));
|
|
78024
78157
|
const requestKeyFlag$1 = Flag.String("request-key").pipe(Flag.atLeast(0));
|
|
78025
78158
|
const resumeFlag = Flag.String("resume").pipe(Flag.atLeast(0));
|
|
78026
|
-
const confirmFlag
|
|
78159
|
+
const confirmFlag = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
78027
78160
|
const timeoutFlag$1 = Flag.Int("timeout-seconds").pipe(Flag.withDefault(120));
|
|
78028
78161
|
const names$1 = {
|
|
78029
78162
|
root: "org.payroll",
|
|
@@ -78256,7 +78389,7 @@ const runLines$1 = (value) => [
|
|
|
78256
78389
|
];
|
|
78257
78390
|
//#endregion
|
|
78258
78391
|
//#region src/commands/org/subcommands/payroll/subcommands/groups/subcommands/list/execute.ts
|
|
78259
|
-
const execute$
|
|
78392
|
+
const execute$35 = (config, input) => Effect.gen(function* () {
|
|
78260
78393
|
const { client, organization, orgId, timeout } = yield* resolvePayrollContext(config, input);
|
|
78261
78394
|
const result = yield* boundedNetwork(Effect.promise((signal) => client.org(orgId).payroll.groups.list({ signal })).pipe(Effect.flatMap(resultValue)), timeout).pipe(Effect.mapError((error) => normalizeOrganizationReadFailure(error, orgId)));
|
|
78262
78395
|
return {
|
|
@@ -78269,7 +78402,7 @@ const execute$36 = (config, input) => Effect.gen(function* () {
|
|
|
78269
78402
|
const command$32 = Command.make("list", {
|
|
78270
78403
|
email: emailFlag$1,
|
|
78271
78404
|
timeout: timeoutFlag$1
|
|
78272
|
-
}, ({ email, timeout }) => dispatch$1("groups.list", (config, orgs) => execute$
|
|
78405
|
+
}, ({ email, timeout }) => dispatch$1("groups.list", (config, orgs) => execute$35(config, {
|
|
78273
78406
|
kind: "groups.list",
|
|
78274
78407
|
orgs,
|
|
78275
78408
|
email: Option.getOrUndefined(email),
|
|
@@ -78277,7 +78410,7 @@ const command$32 = Command.make("list", {
|
|
|
78277
78410
|
}))).pipe(annotate$1("groups.list"), Command.withDescription("List saved roster drafts in one Organization"));
|
|
78278
78411
|
//#endregion
|
|
78279
78412
|
//#region src/commands/org/subcommands/payroll/subcommands/groups/subcommands/save/execute.ts
|
|
78280
|
-
const execute$
|
|
78413
|
+
const execute$34 = (config, input) => Effect.gen(function* () {
|
|
78281
78414
|
const { client, session, stillAuthenticated, orgId, prepared, timeout } = yield* resolvePayrollContext(config, input);
|
|
78282
78415
|
if (prepared?.kind !== "groups.save") return yield* Effect.die("Expected Payroll group save");
|
|
78283
78416
|
const scoped = client.org(orgId);
|
|
@@ -78332,9 +78465,9 @@ const execute$35 = (config, input) => Effect.gen(function* () {
|
|
|
78332
78465
|
const command$31 = Command.make("save", {
|
|
78333
78466
|
email: emailFlag$1,
|
|
78334
78467
|
input: sourceFlag$1,
|
|
78335
|
-
confirm: confirmFlag
|
|
78468
|
+
confirm: confirmFlag,
|
|
78336
78469
|
timeout: timeoutFlag$1
|
|
78337
|
-
}, ({ email, input, confirm, timeout }) => dispatch$1("groups.save", (config, orgs) => execute$
|
|
78470
|
+
}, ({ email, input, confirm, timeout }) => dispatch$1("groups.save", (config, orgs) => execute$34(config, {
|
|
78338
78471
|
kind: "groups.save",
|
|
78339
78472
|
orgs,
|
|
78340
78473
|
email: Option.getOrUndefined(email),
|
|
@@ -78344,7 +78477,7 @@ const command$31 = Command.make("save", {
|
|
|
78344
78477
|
}))).pipe(annotate$1("groups.save"), Command.withDescription("Create or replace one complete Payroll roster draft"));
|
|
78345
78478
|
//#endregion
|
|
78346
78479
|
//#region src/commands/org/subcommands/payroll/subcommands/groups/subcommands/remove/execute.ts
|
|
78347
|
-
const execute$
|
|
78480
|
+
const execute$33 = (config, input) => Effect.gen(function* () {
|
|
78348
78481
|
const { client, session, stillAuthenticated, orgId, prepared, timeout } = yield* resolvePayrollContext(config, input);
|
|
78349
78482
|
if (prepared?.kind !== "groups.remove") return yield* Effect.die("Expected Payroll group remove");
|
|
78350
78483
|
const scoped = client.org(orgId);
|
|
@@ -78387,9 +78520,9 @@ const execute$34 = (config, input) => Effect.gen(function* () {
|
|
|
78387
78520
|
const command$30 = Command.make("remove", {
|
|
78388
78521
|
email: emailFlag$1,
|
|
78389
78522
|
groupId: groupIdArgument,
|
|
78390
|
-
confirm: confirmFlag
|
|
78523
|
+
confirm: confirmFlag,
|
|
78391
78524
|
timeout: timeoutFlag$1
|
|
78392
|
-
}, ({ email, groupId, confirm, timeout }) => dispatch$1("groups.remove", (config, orgs) => execute$
|
|
78525
|
+
}, ({ email, groupId, confirm, timeout }) => dispatch$1("groups.remove", (config, orgs) => execute$33(config, {
|
|
78393
78526
|
kind: "groups.remove",
|
|
78394
78527
|
orgs,
|
|
78395
78528
|
email: Option.getOrUndefined(email),
|
|
@@ -78406,7 +78539,7 @@ const groups = Command.make("groups").pipe(annotate$1("groups"), Command.withDes
|
|
|
78406
78539
|
]));
|
|
78407
78540
|
//#endregion
|
|
78408
78541
|
//#region src/commands/org/subcommands/payroll/subcommands/list/execute.ts
|
|
78409
|
-
const execute$
|
|
78542
|
+
const execute$32 = (config, input) => Effect.gen(function* () {
|
|
78410
78543
|
const { client, organization, orgId, timeout } = yield* resolvePayrollContext(config, input);
|
|
78411
78544
|
const result = yield* boundedNetwork(Effect.promise((signal) => client.org(orgId).payroll.runs({ signal })).pipe(Effect.flatMap(resultValue)), timeout).pipe(Effect.mapError((error) => normalizeOrganizationReadFailure(error, orgId)));
|
|
78412
78545
|
return {
|
|
@@ -78419,7 +78552,7 @@ const execute$33 = (config, input) => Effect.gen(function* () {
|
|
|
78419
78552
|
const command$29 = Command.make("list", {
|
|
78420
78553
|
email: emailFlag$1,
|
|
78421
78554
|
timeout: timeoutFlag$1
|
|
78422
|
-
}, ({ email, timeout }) => dispatch$1("list", (config, orgs) => execute$
|
|
78555
|
+
}, ({ email, timeout }) => dispatch$1("list", (config, orgs) => execute$32(config, {
|
|
78423
78556
|
kind: "list",
|
|
78424
78557
|
orgs,
|
|
78425
78558
|
email: Option.getOrUndefined(email),
|
|
@@ -78427,7 +78560,7 @@ const command$29 = Command.make("list", {
|
|
|
78427
78560
|
}))).pipe(annotate$1("list"), Command.withDescription("List Payroll runs and backend monthly totals"));
|
|
78428
78561
|
//#endregion
|
|
78429
78562
|
//#region src/commands/org/subcommands/payroll/subcommands/terms/execute.ts
|
|
78430
|
-
const execute$
|
|
78563
|
+
const execute$31 = (config, input) => Effect.gen(function* () {
|
|
78431
78564
|
const { client, organization, orgId, timeout } = yield* resolvePayrollContext(config, input);
|
|
78432
78565
|
const terms = yield* boundedNetwork(Effect.promise((signal) => client.org(orgId).payroll.terms({ signal })).pipe(Effect.flatMap(resultValue)), timeout).pipe(Effect.mapError((error) => normalizeOrganizationReadFailure(error, orgId)));
|
|
78433
78566
|
return {
|
|
@@ -78440,7 +78573,7 @@ const execute$32 = (config, input) => Effect.gen(function* () {
|
|
|
78440
78573
|
const command$28 = Command.make("terms", {
|
|
78441
78574
|
email: emailFlag$1,
|
|
78442
78575
|
timeout: timeoutFlag$1
|
|
78443
|
-
}, ({ email, timeout }) => dispatch$1("terms", (config, orgs) => execute$
|
|
78576
|
+
}, ({ email, timeout }) => dispatch$1("terms", (config, orgs) => execute$31(config, {
|
|
78444
78577
|
kind: "terms",
|
|
78445
78578
|
orgs,
|
|
78446
78579
|
email: Option.getOrUndefined(email),
|
|
@@ -78597,13 +78730,11 @@ const prepareRunInput = (input) => Effect.gen(function* () {
|
|
|
78597
78730
|
if (!interactive && orgId === null) return yield* inputRequired("Provide exact --org to run Payroll.");
|
|
78598
78731
|
if (!interactive && source === void 0 && resume === void 0) return yield* inputRequired("Provide --input FILE or --input -.");
|
|
78599
78732
|
if (!interactive && suppliedKey === void 0 && resumeKey === void 0) return yield* inputRequired("Provide --request-key for scripted Payroll.");
|
|
78600
|
-
yield* requireWriteConfirmation(input.confirm);
|
|
78601
78733
|
return {
|
|
78602
78734
|
timeout,
|
|
78603
78735
|
email,
|
|
78604
78736
|
orgId,
|
|
78605
78737
|
resume,
|
|
78606
|
-
interactive,
|
|
78607
78738
|
fresh: source === void 0 ? void 0 : yield* readRunInput(source),
|
|
78608
78739
|
key: resumeKey ?? suppliedKey ?? (yield* (yield* Crypto.Crypto).randomUUIDv4)
|
|
78609
78740
|
};
|
|
@@ -78712,204 +78843,6 @@ const guideRunInput = (budgets, groups, terms, contacts) => Effect.gen(function*
|
|
|
78712
78843
|
});
|
|
78713
78844
|
});
|
|
78714
78845
|
//#endregion
|
|
78715
|
-
//#region src/commands/org/subcommands/payroll/internal/run-lookup.ts
|
|
78716
|
-
const isPayrollRunId = (value) => /^payroll_run_[0-9a-f]{64}$/u.test(value);
|
|
78717
|
-
const exactRunId = (value) => isPayrollRunId(value) ? Effect.succeed(value) : Effect.fail(inputRequired("Provide the Payroll run ID: payroll_run_ followed by a 64-character digest."));
|
|
78718
|
-
const validateRunInput = (input) => Effect.gen(function* () {
|
|
78719
|
-
const timeout = yield* readWriteTimeout(input.timeoutSeconds);
|
|
78720
|
-
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
78721
|
-
if (input.orgs.length > 1) return yield* inputRequired("Provide one exact --org ID.");
|
|
78722
|
-
const orgId = yield* explicitOrganization(input.orgs);
|
|
78723
|
-
if (input.runIds.length > 1) return yield* inputRequired("Provide one exact Payroll run ID.");
|
|
78724
|
-
let runId = input.runIds[0];
|
|
78725
|
-
if (runId !== void 0) yield* exactRunId(runId);
|
|
78726
|
-
const runtime = yield* CliRuntime;
|
|
78727
|
-
if (!runtime.tty || runtime.ci || runtime.mode === "json") {
|
|
78728
|
-
if (orgId === null) return yield* inputRequired("Provide one exact --org ID.");
|
|
78729
|
-
if (runId === void 0) return yield* inputRequired("Provide the Payroll run ID.");
|
|
78730
|
-
}
|
|
78731
|
-
if (runId === void 0) runId = yield* Prompt.String({ message: "Payroll run ID" });
|
|
78732
|
-
return {
|
|
78733
|
-
orgId,
|
|
78734
|
-
runId: yield* exactRunId(runId),
|
|
78735
|
-
timeout,
|
|
78736
|
-
email
|
|
78737
|
-
};
|
|
78738
|
-
});
|
|
78739
|
-
const missingRun = () => new CliFailure({
|
|
78740
|
-
code: "INVALID_INPUT",
|
|
78741
|
-
outcome: "refused",
|
|
78742
|
-
exitCode: 2,
|
|
78743
|
-
message: "The Payroll run was not found or is unavailable to this session. Check --org and the Payroll run ID."
|
|
78744
|
-
});
|
|
78745
|
-
const matches = (detail, orgId, runId) => detail.orgId === orgId && detail.run.id === runId;
|
|
78746
|
-
const mismatch = () => Errors.invalidInput("runId", "Payroll run response scope does not match");
|
|
78747
|
-
const finishedRun = (detail) => detail.items.length > 0 && detail.items.every((item) => paymentPhase(item.payment.status).outcome === "good") || detail.items.some((item) => {
|
|
78748
|
-
const phase = paymentPhase(item.payment.status);
|
|
78749
|
-
return phase.terminal && phase.outcome !== "good" || phase.needsAction || item.payment.execution?.retryRequired === true;
|
|
78750
|
-
}) || [
|
|
78751
|
-
"failed",
|
|
78752
|
-
"mismatch",
|
|
78753
|
-
"unresolved"
|
|
78754
|
-
].includes(detail.command.verificationState) || detail.command.completionOutcome === "failed" || detail.command.terminalOutcome !== void 0 && detail.command.terminalOutcome !== "settled";
|
|
78755
|
-
//#endregion
|
|
78756
|
-
//#region src/commands/org/subcommands/payroll/internal/run-lines.ts
|
|
78757
|
-
const runRecovery = (orgId, runId, email, command) => {
|
|
78758
|
-
const args = [
|
|
78759
|
-
"capxul",
|
|
78760
|
-
"org",
|
|
78761
|
-
"payroll",
|
|
78762
|
-
"get",
|
|
78763
|
-
runId,
|
|
78764
|
-
"--org",
|
|
78765
|
-
orgId,
|
|
78766
|
-
...email === void 0 ? [] : ["--email", email]
|
|
78767
|
-
];
|
|
78768
|
-
return {
|
|
78769
|
-
lines: `${command === void 0 ? "" : `Request key: ${terminalText(command.requestKey)}\nCommand: ${terminalText(command.commandId)}\n`}Read: ${args.map(shellArgument).join(" ")}\nWait: ${[
|
|
78770
|
-
...args.slice(0, 3),
|
|
78771
|
-
"wait",
|
|
78772
|
-
...args.slice(4)
|
|
78773
|
-
].map(shellArgument).join(" ")}`,
|
|
78774
|
-
details: {
|
|
78775
|
-
organizationId: orgId,
|
|
78776
|
-
runId,
|
|
78777
|
-
...command === void 0 ? {} : {
|
|
78778
|
-
requestKey: command.requestKey,
|
|
78779
|
-
commandId: command.commandId
|
|
78780
|
-
},
|
|
78781
|
-
recovery: {
|
|
78782
|
-
kind: "read",
|
|
78783
|
-
argv: args
|
|
78784
|
-
}
|
|
78785
|
-
}
|
|
78786
|
-
};
|
|
78787
|
-
};
|
|
78788
|
-
const runDetailLines = (detail) => [
|
|
78789
|
-
`Payroll run ${terminalText(detail.run.id)}: recorded status ${detail.run.status}`,
|
|
78790
|
-
` Organization: ${terminalText(detail.orgId)}`,
|
|
78791
|
-
` Period: ${detail.run.periodStart} to ${detail.run.periodEnd}`,
|
|
78792
|
-
` Total: ${terminalText(formatAssetAmount(detail.run.total))}; recipients: ${detail.run.recipientCount}`,
|
|
78793
|
-
` Request key: ${terminalText(detail.command.requestKey)}`,
|
|
78794
|
-
` Command: ${terminalText(detail.command.commandId)}; state ${detail.command.state}; verification ${detail.command.verificationState}`,
|
|
78795
|
-
...detail.command.completionOutcome === void 0 ? [] : [` Recorded completion: ${detail.command.completionOutcome}`],
|
|
78796
|
-
...detail.command.terminalOutcome === void 0 ? [] : [` Recorded terminal outcome: ${detail.command.terminalOutcome}`],
|
|
78797
|
-
...detail.command.userOpHash === void 0 ? [] : [` Submitted user operation: ${terminalText(detail.command.userOpHash)}`],
|
|
78798
|
-
` Created: ${detail.createdAt}; updated: ${detail.updatedAt}${detail.settledAt === void 0 ? "" : `; recorded settled: ${detail.settledAt}`}`,
|
|
78799
|
-
"Original ordered Payments",
|
|
78800
|
-
...detail.items.flatMap((item) => [
|
|
78801
|
-
` Item ${item.itemIndex}: employee ${terminalText(item.employeeRef)}; engagement ${terminalText(item.engagementEdgeId)}`,
|
|
78802
|
-
` Gross: ${terminalText(item.gross)} raw units; net: ${terminalText(item.net)} raw units`,
|
|
78803
|
-
...item.adjustments.map((adjustment) => ` Adjustment: ${terminalText(adjustment.label)}; ${terminalText(adjustment.amount)} raw units`),
|
|
78804
|
-
` Quantity: ${terminalText(item.amount.value)}; asset: ${terminalText(item.amount.asset)}`,
|
|
78805
|
-
` Payment ${terminalText(item.payment.id)}: ${item.payment.status}`,
|
|
78806
|
-
` Counterparty: ${terminalText(item.payment.counterpartyLabel)}`,
|
|
78807
|
-
` Receipt: ${item.payment.receipt === null ? "none recorded" : `${terminalText(item.payment.receipt.transactionHash)} (chain ${item.payment.receipt.chainId})`}`,
|
|
78808
|
-
...item.payment.execution === void 0 ? [] : [` Execution: ${item.payment.execution.status}${item.payment.execution.retryRequired ? "; action required" : ""}`],
|
|
78809
|
-
...item.payment.recipient.kind === "party" ? [` Party: ${terminalText(item.payment.recipient.partyId)}; label: ${terminalText(item.payment.recipient.label)}`] : [],
|
|
78810
|
-
...item.payment.documentState === void 0 ? [] : [` Documents: ${item.payment.documentState}`],
|
|
78811
|
-
...item.payment.documents.map((document) => ` Document: ${terminalText(document.documentHash)}; content: ${terminalText(document.contentHash)}; kind: ${document.kind}`)
|
|
78812
|
-
])
|
|
78813
|
-
];
|
|
78814
|
-
//#endregion
|
|
78815
|
-
//#region src/commands/org/subcommands/payroll/internal/run-reads.ts
|
|
78816
|
-
const readValidatedRun = (config, input, validated, read) => Effect.gen(function* () {
|
|
78817
|
-
let orgId = validated.orgId;
|
|
78818
|
-
let email = validated.email;
|
|
78819
|
-
let command;
|
|
78820
|
-
const runtime = yield* CliRuntime;
|
|
78821
|
-
const known = () => orgId === null ? null : runRecovery(orgId, validated.runId, email, command);
|
|
78822
|
-
const observed = yield* Effect.gen(function* () {
|
|
78823
|
-
const restored = yield* restoreAuthenticatedClient(config, email, { requirement: "none" });
|
|
78824
|
-
email = restored.session.email;
|
|
78825
|
-
const organizations = yield* Effect.promise((signal) => restored.client.orgs({ signal })).pipe(Effect.flatMap(resultItems));
|
|
78826
|
-
orgId = (yield* selectOrganization(organizations, orgId)).id;
|
|
78827
|
-
if (!(yield* restored.stillAuthenticated)) return yield* Effect.fail(Errors.notAuthenticated());
|
|
78828
|
-
const reading = read(restored.client.org(orgId).payroll, orgId, validated.runId, (value) => {
|
|
78829
|
-
command = value.command;
|
|
78830
|
-
});
|
|
78831
|
-
const detail = yield* input.kind === "wait" ? withWaiting(reading, {
|
|
78832
|
-
...runtime,
|
|
78833
|
-
label: "Observe Payroll run state"
|
|
78834
|
-
}) : reading;
|
|
78835
|
-
if (detail === null) return yield* missingRun();
|
|
78836
|
-
if (!matches(detail, orgId, validated.runId)) return yield* Effect.fail(mismatch());
|
|
78837
|
-
if (!(yield* restored.stillAuthenticated)) return yield* Effect.fail(Errors.notAuthenticated());
|
|
78838
|
-
command = detail.command;
|
|
78839
|
-
return {
|
|
78840
|
-
detail,
|
|
78841
|
-
client: restored.client
|
|
78842
|
-
};
|
|
78843
|
-
}).pipe(Effect.mapError((error) => {
|
|
78844
|
-
const failure = classifyFailure(Cause.fail(orgId === null ? error : normalizeOrganizationReadFailure(error, orgId)), `org.payroll.${input.kind}`);
|
|
78845
|
-
const recovery = known();
|
|
78846
|
-
return new CliFailure({
|
|
78847
|
-
...failure,
|
|
78848
|
-
...recovery === null ? {} : {
|
|
78849
|
-
details: {
|
|
78850
|
-
...failure.details,
|
|
78851
|
-
...recovery.details
|
|
78852
|
-
},
|
|
78853
|
-
message: `${failure.message}\n${recovery.lines}`
|
|
78854
|
-
}
|
|
78855
|
-
});
|
|
78856
|
-
}), Effect.onInterrupt(() => {
|
|
78857
|
-
const recovery = known();
|
|
78858
|
-
return recovery === null ? Effect.void : writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
78859
|
-
type: "payroll.run.recovery",
|
|
78860
|
-
...recovery.details,
|
|
78861
|
-
message: recovery.lines
|
|
78862
|
-
})}\n` : `${recovery.lines}\n`).pipe(Effect.ignoreCause);
|
|
78863
|
-
}), Effect.timeoutOption(validated.timeout * 1e3));
|
|
78864
|
-
if (Option.isNone(observed)) {
|
|
78865
|
-
const recovery = known();
|
|
78866
|
-
return yield* new CliFailure({
|
|
78867
|
-
code: "CLI_DEADLINE",
|
|
78868
|
-
outcome: "failed",
|
|
78869
|
-
exitCode: 5,
|
|
78870
|
-
...recovery === null ? {} : { details: recovery.details },
|
|
78871
|
-
message: `The CLI stopped waiting. Payroll settlement is not confirmed.${recovery === null ? "" : `\n${recovery.lines}`}`
|
|
78872
|
-
});
|
|
78873
|
-
}
|
|
78874
|
-
const { detail } = observed.value;
|
|
78875
|
-
return {
|
|
78876
|
-
data: detail,
|
|
78877
|
-
lines: [...runDetailLines(detail), ...detail.items.flatMap((item) => documentReferenceLines(item.payment))]
|
|
78878
|
-
};
|
|
78879
|
-
});
|
|
78880
|
-
const saveRunDocuments = (config, client, detail) => Effect.forEach(detail.items, (item) => savePaymentDocuments(config, client, item.payment).pipe(Effect.map((output) => ({
|
|
78881
|
-
itemIndex: item.itemIndex,
|
|
78882
|
-
paymentId: item.payment.id,
|
|
78883
|
-
...output
|
|
78884
|
-
}))));
|
|
78885
|
-
//#endregion
|
|
78886
|
-
//#region src/commands/org/subcommands/payroll/internal/run-documents.ts
|
|
78887
|
-
/** Save the authorized run's documents; a document failure is reported beside the run, never instead of it. */
|
|
78888
|
-
const readRunDocumentOutputs = (input) => {
|
|
78889
|
-
const { config, scoped, client, orgId: selectedOrg, runId: completedRunId, key, within } = input;
|
|
78890
|
-
const preview = { client };
|
|
78891
|
-
return within(Effect.gen(function* () {
|
|
78892
|
-
const detail = yield* Effect.tryPromise({
|
|
78893
|
-
try: (signal) => scoped.payroll.getRun(completedRunId, { signal }),
|
|
78894
|
-
catch: (cause) => Errors.unknown(cause)
|
|
78895
|
-
}).pipe(Effect.flatMap(resultValue));
|
|
78896
|
-
if (detail === null || detail.orgId !== selectedOrg || detail.run.id !== completedRunId || detail.command.requestKey !== key) return yield* Effect.fail(Errors.invalidInput("runId", "The Payroll document read did not match this run."));
|
|
78897
|
-
return yield* saveRunDocuments(config, preview.client, detail);
|
|
78898
|
-
})).pipe(Effect.map((documentOutputs) => ({
|
|
78899
|
-
documentOutputs,
|
|
78900
|
-
documentOutputError: void 0
|
|
78901
|
-
})), Effect.catchCause((cause) => {
|
|
78902
|
-
const failure = classifyFailure(cause);
|
|
78903
|
-
return Effect.succeed({
|
|
78904
|
-
documentOutputs: [],
|
|
78905
|
-
documentOutputError: {
|
|
78906
|
-
code: failure.code,
|
|
78907
|
-
message: failure.message
|
|
78908
|
-
}
|
|
78909
|
-
});
|
|
78910
|
-
}));
|
|
78911
|
-
};
|
|
78912
|
-
//#endregion
|
|
78913
78846
|
//#region src/commands/org/subcommands/payroll/internal/run-preview.ts
|
|
78914
78847
|
/** The recovery a Payroll run prints: resume the saved input, or read and wait for the run. */
|
|
78915
78848
|
const runCommandRecovery = (input) => {
|
|
@@ -78931,11 +78864,10 @@ const runCommandRecovery = (input) => {
|
|
|
78931
78864
|
"run",
|
|
78932
78865
|
...common,
|
|
78933
78866
|
"--resume",
|
|
78934
|
-
key
|
|
78935
|
-
"--confirm"
|
|
78867
|
+
key
|
|
78936
78868
|
];
|
|
78937
78869
|
const flags = `--org ${shellArgument(orgId)} --email ${shellArgument(actorEmail)}`;
|
|
78938
|
-
const resumeLine = `capxul org payroll run ${flags} --resume ${shellArgument(key)}
|
|
78870
|
+
const resumeLine = `capxul org payroll run ${flags} --resume ${shellArgument(key)}`;
|
|
78939
78871
|
return {
|
|
78940
78872
|
details: {
|
|
78941
78873
|
organizationId: orgId,
|
|
@@ -79036,23 +78968,183 @@ const restoreTransactingActor = (config, opened, listOrganizations) => Effect.ge
|
|
|
79036
78968
|
};
|
|
79037
78969
|
});
|
|
79038
78970
|
//#endregion
|
|
78971
|
+
//#region src/platform/open-url.ts
|
|
78972
|
+
/** Open a link in the person's browser; false when this system has no opener or it fails. */
|
|
78973
|
+
const openUrl = (url) => Effect.promise(() => new Promise((resolve) => {
|
|
78974
|
+
const command = platform === "darwin" ? "open" : platform === "linux" ? "xdg-open" : null;
|
|
78975
|
+
if (command === null) return resolve(false);
|
|
78976
|
+
const child = spawn(command, [url], {
|
|
78977
|
+
detached: true,
|
|
78978
|
+
stdio: "ignore"
|
|
78979
|
+
});
|
|
78980
|
+
child.once("error", () => resolve(false));
|
|
78981
|
+
child.once("spawn", () => {
|
|
78982
|
+
child.unref();
|
|
78983
|
+
resolve(true);
|
|
78984
|
+
});
|
|
78985
|
+
}));
|
|
78986
|
+
//#endregion
|
|
78987
|
+
//#region src/commands/payment/internal/approval.ts
|
|
78988
|
+
const scoped = (scope) => scope.organizationId === void 0 ? [] : ["--org", scope.organizationId];
|
|
78989
|
+
/** The command that follows an approval to its end. */
|
|
78990
|
+
const waitArgv = (approvalId, scope = {}) => [
|
|
78991
|
+
"capxul",
|
|
78992
|
+
"payment",
|
|
78993
|
+
"wait",
|
|
78994
|
+
approvalId,
|
|
78995
|
+
...scoped(scope)
|
|
78996
|
+
];
|
|
78997
|
+
/** `--json`: the approval is open and nothing moves until a person approves it. */
|
|
78998
|
+
const awaitingApproval = (approval, scope = {}) => ({
|
|
78999
|
+
status: "awaiting_approval",
|
|
79000
|
+
approvalId: approval.approvalId,
|
|
79001
|
+
approvalUrl: approval.url,
|
|
79002
|
+
paymentIds: approval.operation.paymentIds,
|
|
79003
|
+
expiresAt: approval.expiresAt,
|
|
79004
|
+
next: { argv: [...waitArgv(approval.approvalId, scope), "--json"] }
|
|
79005
|
+
});
|
|
79006
|
+
/** What the person checks before they approve. Every operation is sponsored: no fee. */
|
|
79007
|
+
const previewLines = (approval, source) => {
|
|
79008
|
+
const { from, to, amount } = approval.summary;
|
|
79009
|
+
const payer = source.budget === void 0 ? from.label : `${from.label} · ${source.budget}`;
|
|
79010
|
+
const left = source.left === void 0 ? "" : ` · ${shownAmount(source.left)} left`;
|
|
79011
|
+
return [
|
|
79012
|
+
`From ${terminalText(payer)}${left}`,
|
|
79013
|
+
`To ${terminalText(to.label)}`,
|
|
79014
|
+
`Amount ${amount === null ? "nothing moves" : shownAmount(amount)}`,
|
|
79015
|
+
"Fee none"
|
|
79016
|
+
];
|
|
79017
|
+
};
|
|
79018
|
+
const rejected = (approval) => new CliFailure({
|
|
79019
|
+
code: "CANCELLED",
|
|
79020
|
+
message: "Not sent: it was rejected on the approval page.",
|
|
79021
|
+
exitCode: 130,
|
|
79022
|
+
outcome: "cancelled",
|
|
79023
|
+
details: { paymentIds: approval.operation.paymentIds }
|
|
79024
|
+
});
|
|
79025
|
+
const expired = (approval) => new CliFailure({
|
|
79026
|
+
code: "WRONG_STATE",
|
|
79027
|
+
message: "Not sent: the approval expired before anyone approved it.",
|
|
79028
|
+
exitCode: 2,
|
|
79029
|
+
outcome: "refused",
|
|
79030
|
+
details: {
|
|
79031
|
+
currentState: "expired",
|
|
79032
|
+
paymentIds: approval.operation.paymentIds
|
|
79033
|
+
}
|
|
79034
|
+
});
|
|
79035
|
+
const stillWaiting = (approvalId, scope) => new CliFailure({
|
|
79036
|
+
code: "CLI_DEADLINE",
|
|
79037
|
+
message: "Still waiting for the approval. Nothing is sent until a person approves it.",
|
|
79038
|
+
next: waitArgv(approvalId, scope),
|
|
79039
|
+
exitCode: 5,
|
|
79040
|
+
outcome: "failed"
|
|
79041
|
+
});
|
|
79042
|
+
/** The Payments that did not settle, as a failure that names how to read them. */
|
|
79043
|
+
const unsettled = (outcome, scope) => {
|
|
79044
|
+
const failed = outcome.payments.find((payment) => payment.status !== "settled");
|
|
79045
|
+
return failed === void 0 ? void 0 : new CliFailure({
|
|
79046
|
+
code: "TRANSACTION_FAILED",
|
|
79047
|
+
message: `The payment did not settle: it is ${failed.status}.`,
|
|
79048
|
+
next: [
|
|
79049
|
+
"capxul",
|
|
79050
|
+
"payment",
|
|
79051
|
+
"get",
|
|
79052
|
+
failed.id,
|
|
79053
|
+
...scoped(scope)
|
|
79054
|
+
],
|
|
79055
|
+
exitCode: 5,
|
|
79056
|
+
outcome: "failed",
|
|
79057
|
+
details: { paymentIds: outcome.payments.map((payment) => payment.id) }
|
|
79058
|
+
});
|
|
79059
|
+
};
|
|
79060
|
+
const read = (client, approvalId) => Effect.promise(() => client.approvals.get(approvalId)).pipe(Effect.flatMap(resultValue));
|
|
79061
|
+
/**
|
|
79062
|
+
* Follow an approval: `onSigned` once the person approves, then send it (the
|
|
79063
|
+
* page may already have) and wait for its Payments. A rejection is a
|
|
79064
|
+
* cancellation; an expired approval sent nothing.
|
|
79065
|
+
*/
|
|
79066
|
+
const followApproval = (client, approvalId, options) => Effect.gen(function* () {
|
|
79067
|
+
let approval = yield* read(client, approvalId);
|
|
79068
|
+
while (approval.state === "pending") {
|
|
79069
|
+
yield* Effect.sleep("2 seconds");
|
|
79070
|
+
approval = yield* read(client, approvalId);
|
|
79071
|
+
}
|
|
79072
|
+
if (approval.state === "rejected") return yield* rejected(approval);
|
|
79073
|
+
if (approval.state === "expired") return yield* expired(approval);
|
|
79074
|
+
yield* options.onSigned;
|
|
79075
|
+
const outcome = yield* Effect.promise((signal) => client.approvals.wait(approvalId, {
|
|
79076
|
+
signal,
|
|
79077
|
+
...options.organizationId === void 0 ? {} : { organizationId: options.organizationId }
|
|
79078
|
+
})).pipe(Effect.flatMap(resultValue));
|
|
79079
|
+
if (outcome.approval.state === "rejected") return yield* rejected(outcome.approval);
|
|
79080
|
+
if (outcome.approval.state === "expired") return yield* expired(outcome.approval);
|
|
79081
|
+
const failure = unsettled(outcome, options);
|
|
79082
|
+
if (failure !== void 0) return yield* failure;
|
|
79083
|
+
return outcome;
|
|
79084
|
+
}).pipe(Effect.timeoutOption(options.deadlineMs), Effect.flatMap(Option.match({
|
|
79085
|
+
onNone: () => Effect.fail(stillWaiting(approvalId, options)),
|
|
79086
|
+
onSome: Effect.succeed
|
|
79087
|
+
})));
|
|
79088
|
+
/** `Paid 50.00 USDC to Rex · 0x5b2e…91c4`, and where the receipt is. */
|
|
79089
|
+
const paidLines = (outcome, scope = {}) => outcome.payments.flatMap((payment) => {
|
|
79090
|
+
const hash = payment.receipt?.transactionHash;
|
|
79091
|
+
return [`Paid ${shownAmount(payment.amount)} to ${terminalText(payment.counterpartyLabel)}${hash === void 0 ? "" : ` · ${hash.slice(0, 6)}…${hash.slice(-4)}`}`, `receipt: ${terminalText([
|
|
79092
|
+
"capxul",
|
|
79093
|
+
"payment",
|
|
79094
|
+
"get",
|
|
79095
|
+
payment.id,
|
|
79096
|
+
...scoped(scope)
|
|
79097
|
+
].join(" "))}`];
|
|
79098
|
+
});
|
|
79099
|
+
/** A progress line for a person, on stderr. */
|
|
79100
|
+
const progress = (line) => writeStderr(`${line}\n`);
|
|
79101
|
+
/** After the approval lapses, the time a send and its settlement may still take. */
|
|
79102
|
+
const SETTLE_MS = 12e4;
|
|
79103
|
+
/**
|
|
79104
|
+
* Hand a prepared approval over. An agent gets the link and the wait command
|
|
79105
|
+
* back at once. A person sees the preview, the approval page opens, and the
|
|
79106
|
+
* CLI follows it until the payment is confirmed: the page is the one and only
|
|
79107
|
+
* confirmation.
|
|
79108
|
+
*/
|
|
79109
|
+
const handOver = (client, approval, options) => Effect.gen(function* () {
|
|
79110
|
+
const runtime = yield* CliRuntime;
|
|
79111
|
+
if (runtime.mode === "json") return {
|
|
79112
|
+
data: awaitingApproval(approval, options),
|
|
79113
|
+
lines: []
|
|
79114
|
+
};
|
|
79115
|
+
for (const line of previewLines(approval, options)) yield* progress(line);
|
|
79116
|
+
yield* progress("✓ Prepared");
|
|
79117
|
+
const opened = runtime.tty && !runtime.ci ? yield* openUrl(approval.url) : false;
|
|
79118
|
+
yield* progress(`… Approve in your browser${opened ? " (opened)" : ""}`);
|
|
79119
|
+
yield* progress(` ${approval.url}`);
|
|
79120
|
+
const now = yield* Clock.currentTimeMillis;
|
|
79121
|
+
const outcome = yield* followApproval(client, approval.approvalId, {
|
|
79122
|
+
organizationId: options.organizationId,
|
|
79123
|
+
deadlineMs: options.timeoutSeconds === void 0 ? Math.max(approval.expiresAt - now, 0) + SETTLE_MS : options.timeoutSeconds * 1e3,
|
|
79124
|
+
onSigned: progress("✓ Signed")
|
|
79125
|
+
}).pipe(Effect.onInterrupt(() => progress(`Nothing is sent until you approve. Follow it with: ${waitArgv(approval.approvalId, options).join(" ")}`).pipe(Effect.ignore)));
|
|
79126
|
+
yield* progress("✓ Confirmed");
|
|
79127
|
+
return {
|
|
79128
|
+
data: outcome,
|
|
79129
|
+
lines: paidLines(outcome, options)
|
|
79130
|
+
};
|
|
79131
|
+
});
|
|
79132
|
+
//#endregion
|
|
79039
79133
|
//#region src/commands/org/subcommands/payroll/subcommands/run/execute.ts
|
|
79040
79134
|
const operation = CAPXUL_OPERATIONS.payroll.runs.authorize;
|
|
79041
|
-
const execute$
|
|
79135
|
+
const execute$30 = (config, input) => Effect.gen(function* () {
|
|
79042
79136
|
const prepared = yield* prepareRunInput(input);
|
|
79043
|
-
const { timeout, email, resume,
|
|
79137
|
+
const { timeout, email, resume, fresh, key } = prepared;
|
|
79044
79138
|
let orgId = prepared.orgId;
|
|
79045
79139
|
const runtime = yield* CliRuntime;
|
|
79046
79140
|
let actorEmail = email;
|
|
79047
|
-
let runId;
|
|
79048
79141
|
let saved = false;
|
|
79049
|
-
let resolved;
|
|
79050
79142
|
const recovery = () => runCommandRecovery({
|
|
79051
79143
|
orgId,
|
|
79052
79144
|
actorEmail,
|
|
79053
79145
|
key,
|
|
79054
|
-
runId,
|
|
79055
|
-
canResume: saved
|
|
79146
|
+
runId: void 0,
|
|
79147
|
+
canResume: saved
|
|
79056
79148
|
});
|
|
79057
79149
|
const notice = (type) => {
|
|
79058
79150
|
const known = recovery();
|
|
@@ -79093,11 +79185,7 @@ const execute$31 = (config, input) => Effect.gen(function* () {
|
|
|
79093
79185
|
employees,
|
|
79094
79186
|
key
|
|
79095
79187
|
});
|
|
79096
|
-
|
|
79097
|
-
lines,
|
|
79098
|
-
question: "Authorize this complete Payroll run?"
|
|
79099
|
-
});
|
|
79100
|
-
else yield* writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
79188
|
+
yield* writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
79101
79189
|
type: "org.payroll.preview",
|
|
79102
79190
|
organizationId: selectedOrg,
|
|
79103
79191
|
requestKey: key,
|
|
@@ -79107,88 +79195,22 @@ const execute$31 = (config, input) => Effect.gen(function* () {
|
|
|
79107
79195
|
yield* notice("org.payroll.requestKey");
|
|
79108
79196
|
const draft = stored ?? (yield* saveCommandDraft(config, selector, requested, preview.stillAuthenticated));
|
|
79109
79197
|
saved = true;
|
|
79110
|
-
const
|
|
79111
|
-
const admitted = yield* parseRunInput(JSON.parse(frozen));
|
|
79198
|
+
const admitted = yield* parseRunInput(draft.input);
|
|
79112
79199
|
yield* notice("org.payroll.saved");
|
|
79113
|
-
const
|
|
79114
|
-
|
|
79115
|
-
|
|
79116
|
-
const signal = yield* Effect.abortSignal;
|
|
79117
|
-
let keyPersisted = false;
|
|
79118
|
-
let writeLifetime;
|
|
79119
|
-
const checkActor = Effect.gen(function* () {
|
|
79120
|
-
const cancelled = cancelledWrite(operation, signal);
|
|
79121
|
-
if (cancelled !== null) return yield* Effect.fail(cancelled);
|
|
79122
|
-
if (!(yield* preview.stillAuthenticated) || writeLifetime !== void 0 && !(yield* writeLifetime)) return yield* Effect.fail(Errors.cancelled({ operation }));
|
|
79123
|
-
});
|
|
79124
|
-
const checkDraft = Effect.gen(function* () {
|
|
79125
|
-
yield* checkActor;
|
|
79126
|
-
const current = yield* loadCommandDraft(config, selector, preview.stillAuthenticated);
|
|
79127
|
-
if (JSON.stringify(yield* parseRunInput(current.input)) !== frozen) return yield* Effect.fail(Errors.invalidInput("requestKey", "The saved Payroll input changed."));
|
|
79128
|
-
yield* checkActor;
|
|
79129
|
-
});
|
|
79130
|
-
yield* checkActor;
|
|
79131
|
-
const signer = yield* organizationWriteSigner(config, opened, run, async () => {
|
|
79132
|
-
await run(checkDraft);
|
|
79133
|
-
if (!keyPersisted || writeLifetime === void 0) throw Errors.invalidInput("requestKey", "The Payroll key was not durably confirmed.");
|
|
79134
|
-
});
|
|
79135
|
-
const write = yield* restoreWriteClient(config, opened, signer, preview.session, () => Errors.cancelled({ operation }));
|
|
79136
|
-
writeLifetime = write.stillAuthenticated;
|
|
79137
|
-
yield* checkActor;
|
|
79138
|
-
const result = yield* Effect.promise((operationSignal) => write.client.org(selectedOrg).payroll.authorizeRun({
|
|
79200
|
+
const approval = yield* within(withWaiting(Effect.promise((signal) => preview.client.approvals.prepare({
|
|
79201
|
+
organizationId: selectedOrg,
|
|
79202
|
+
payrollRun: {
|
|
79139
79203
|
...admitted,
|
|
79140
79204
|
requestKey: key
|
|
79141
|
-
}
|
|
79142
|
-
|
|
79143
|
-
|
|
79144
|
-
|
|
79145
|
-
|
|
79146
|
-
|
|
79147
|
-
|
|
79148
|
-
|
|
79149
|
-
await run(checkActor);
|
|
79150
|
-
keyPersisted = true;
|
|
79151
|
-
},
|
|
79152
|
-
onResolved: async (outcome) => {
|
|
79153
|
-
resolved = outcome;
|
|
79154
|
-
await run(writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
79155
|
-
type: "org.payroll.resolved",
|
|
79156
|
-
organizationId: selectedOrg,
|
|
79157
|
-
requestKey: key,
|
|
79158
|
-
resolution: outcome
|
|
79159
|
-
})}\n` : `Original Payroll command: ${outcome}. The current SDK result remains unchanged.\n`));
|
|
79160
|
-
}
|
|
79161
|
-
}));
|
|
79162
|
-
const details = result.ok ? void 0 : result.error.details;
|
|
79163
|
-
if (details?.method === operation && details.requestKey === key && typeof details.runId === "string" && isPayrollRunId(details.runId)) runId = details.runId;
|
|
79164
|
-
return yield* resultValue(result);
|
|
79165
|
-
}).pipe(Effect.scoped));
|
|
79166
|
-
if (!isPayrollRunId(completed.id)) return yield* Effect.fail(Errors.invalidInput("runId", "The Payroll result has an invalid run ID."));
|
|
79167
|
-
const completedRunId = completed.id;
|
|
79168
|
-
runId = completedRunId;
|
|
79169
|
-
const documents = yield* readRunDocumentOutputs({
|
|
79170
|
-
config,
|
|
79171
|
-
scoped,
|
|
79172
|
-
client: preview.client,
|
|
79173
|
-
orgId: selectedOrg,
|
|
79174
|
-
runId: completedRunId,
|
|
79175
|
-
key,
|
|
79176
|
-
within
|
|
79205
|
+
}
|
|
79206
|
+
}, { signal })).pipe(Effect.flatMap(resultValue)), {
|
|
79207
|
+
...runtime,
|
|
79208
|
+
label: "Preparing the payroll run"
|
|
79209
|
+
}));
|
|
79210
|
+
return yield* handOver(preview.client, approval, {
|
|
79211
|
+
organizationId: selectedOrg,
|
|
79212
|
+
budget: budget.label
|
|
79177
79213
|
});
|
|
79178
|
-
return {
|
|
79179
|
-
data: {
|
|
79180
|
-
run: completed,
|
|
79181
|
-
requestKey: key,
|
|
79182
|
-
...documents
|
|
79183
|
-
},
|
|
79184
|
-
lines: [
|
|
79185
|
-
`Run: ${terminalText(completedRunId)} (${terminalText(completed.status)})`,
|
|
79186
|
-
"Authorization or submission does not prove settlement.",
|
|
79187
|
-
...recovery().lines,
|
|
79188
|
-
...documents.documentOutputs.flatMap(documentOutputLines),
|
|
79189
|
-
...documents.documentOutputError === void 0 ? [] : [`Document output failed: ${terminalText(documents.documentOutputError.message)}`]
|
|
79190
|
-
]
|
|
79191
|
-
};
|
|
79192
79214
|
}).pipe(Effect.mapError((error) => {
|
|
79193
79215
|
const scoped = orgId === null ? error : normalizeOrganizationReadFailure(error, orgId);
|
|
79194
79216
|
const failure = classifyFailure(Cause.fail(scoped), operation);
|
|
@@ -79210,21 +79232,185 @@ const command$27 = Command.make("run", {
|
|
|
79210
79232
|
input: sourceFlag$1,
|
|
79211
79233
|
requestKey: requestKeyFlag$1,
|
|
79212
79234
|
resume: resumeFlag,
|
|
79213
|
-
confirm: confirmFlag$1,
|
|
79214
79235
|
timeout: timeoutFlag$1
|
|
79215
|
-
}, ({ email, input, requestKey, resume,
|
|
79236
|
+
}, ({ email, input, requestKey, resume, timeout }) => dispatch$1("run", (config, orgs) => execute$30(config, {
|
|
79216
79237
|
kind: "run",
|
|
79217
79238
|
orgs,
|
|
79218
79239
|
email: Option.getOrUndefined(email),
|
|
79219
79240
|
sources: input,
|
|
79220
79241
|
requestKeys: requestKey,
|
|
79221
79242
|
resumes: resume,
|
|
79222
|
-
confirm,
|
|
79223
79243
|
timeoutSeconds: timeout
|
|
79224
|
-
}))).pipe(annotate$1("run"), Command.withDescription("
|
|
79244
|
+
}))).pipe(annotate$1("run"), Command.withDescription("run payroll from a Budget; you approve it in the browser"));
|
|
79245
|
+
//#endregion
|
|
79246
|
+
//#region src/commands/org/subcommands/payroll/internal/run-lookup.ts
|
|
79247
|
+
const isPayrollRunId = (value) => /^payroll_run_[0-9a-f]{64}$/u.test(value);
|
|
79248
|
+
const exactRunId = (value) => isPayrollRunId(value) ? Effect.succeed(value) : Effect.fail(inputRequired("Provide the Payroll run ID: payroll_run_ followed by a 64-character digest."));
|
|
79249
|
+
const validateRunInput = (input) => Effect.gen(function* () {
|
|
79250
|
+
const timeout = yield* readWriteTimeout(input.timeoutSeconds);
|
|
79251
|
+
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
79252
|
+
if (input.orgs.length > 1) return yield* inputRequired("Provide one exact --org ID.");
|
|
79253
|
+
const orgId = yield* explicitOrganization(input.orgs);
|
|
79254
|
+
if (input.runIds.length > 1) return yield* inputRequired("Provide one exact Payroll run ID.");
|
|
79255
|
+
let runId = input.runIds[0];
|
|
79256
|
+
if (runId !== void 0) yield* exactRunId(runId);
|
|
79257
|
+
const runtime = yield* CliRuntime;
|
|
79258
|
+
if (!runtime.tty || runtime.ci || runtime.mode === "json") {
|
|
79259
|
+
if (orgId === null) return yield* inputRequired("Provide one exact --org ID.");
|
|
79260
|
+
if (runId === void 0) return yield* inputRequired("Provide the Payroll run ID.");
|
|
79261
|
+
}
|
|
79262
|
+
if (runId === void 0) runId = yield* Prompt.String({ message: "Payroll run ID" });
|
|
79263
|
+
return {
|
|
79264
|
+
orgId,
|
|
79265
|
+
runId: yield* exactRunId(runId),
|
|
79266
|
+
timeout,
|
|
79267
|
+
email
|
|
79268
|
+
};
|
|
79269
|
+
});
|
|
79270
|
+
const missingRun = () => new CliFailure({
|
|
79271
|
+
code: "INVALID_INPUT",
|
|
79272
|
+
outcome: "refused",
|
|
79273
|
+
exitCode: 2,
|
|
79274
|
+
message: "The Payroll run was not found or is unavailable to this session. Check --org and the Payroll run ID."
|
|
79275
|
+
});
|
|
79276
|
+
const matches = (detail, orgId, runId) => detail.orgId === orgId && detail.run.id === runId;
|
|
79277
|
+
const mismatch = () => Errors.invalidInput("runId", "Payroll run response scope does not match");
|
|
79278
|
+
const finishedRun = (detail) => detail.items.length > 0 && detail.items.every((item) => paymentPhase(item.payment.status).outcome === "good") || detail.items.some((item) => {
|
|
79279
|
+
const phase = paymentPhase(item.payment.status);
|
|
79280
|
+
return phase.terminal && phase.outcome !== "good" || phase.needsAction || item.payment.execution?.retryRequired === true;
|
|
79281
|
+
}) || [
|
|
79282
|
+
"failed",
|
|
79283
|
+
"mismatch",
|
|
79284
|
+
"unresolved"
|
|
79285
|
+
].includes(detail.command.verificationState) || detail.command.completionOutcome === "failed" || detail.command.terminalOutcome !== void 0 && detail.command.terminalOutcome !== "settled";
|
|
79286
|
+
//#endregion
|
|
79287
|
+
//#region src/commands/org/subcommands/payroll/internal/run-lines.ts
|
|
79288
|
+
const runRecovery = (orgId, runId, email, command) => {
|
|
79289
|
+
const args = [
|
|
79290
|
+
"capxul",
|
|
79291
|
+
"org",
|
|
79292
|
+
"payroll",
|
|
79293
|
+
"get",
|
|
79294
|
+
runId,
|
|
79295
|
+
"--org",
|
|
79296
|
+
orgId,
|
|
79297
|
+
...email === void 0 ? [] : ["--email", email]
|
|
79298
|
+
];
|
|
79299
|
+
return {
|
|
79300
|
+
lines: `${command === void 0 ? "" : `Request key: ${terminalText(command.requestKey)}\nCommand: ${terminalText(command.commandId)}\n`}Read: ${args.map(shellArgument).join(" ")}\nWait: ${[
|
|
79301
|
+
...args.slice(0, 3),
|
|
79302
|
+
"wait",
|
|
79303
|
+
...args.slice(4)
|
|
79304
|
+
].map(shellArgument).join(" ")}`,
|
|
79305
|
+
details: {
|
|
79306
|
+
organizationId: orgId,
|
|
79307
|
+
runId,
|
|
79308
|
+
...command === void 0 ? {} : {
|
|
79309
|
+
requestKey: command.requestKey,
|
|
79310
|
+
commandId: command.commandId
|
|
79311
|
+
},
|
|
79312
|
+
recovery: {
|
|
79313
|
+
kind: "read",
|
|
79314
|
+
argv: args
|
|
79315
|
+
}
|
|
79316
|
+
}
|
|
79317
|
+
};
|
|
79318
|
+
};
|
|
79319
|
+
const runDetailLines = (detail) => [
|
|
79320
|
+
`Payroll run ${terminalText(detail.run.id)}: recorded status ${detail.run.status}`,
|
|
79321
|
+
` Organization: ${terminalText(detail.orgId)}`,
|
|
79322
|
+
` Period: ${detail.run.periodStart} to ${detail.run.periodEnd}`,
|
|
79323
|
+
` Total: ${terminalText(formatAssetAmount(detail.run.total))}; recipients: ${detail.run.recipientCount}`,
|
|
79324
|
+
` Request key: ${terminalText(detail.command.requestKey)}`,
|
|
79325
|
+
` Command: ${terminalText(detail.command.commandId)}; state ${detail.command.state}; verification ${detail.command.verificationState}`,
|
|
79326
|
+
...detail.command.completionOutcome === void 0 ? [] : [` Recorded completion: ${detail.command.completionOutcome}`],
|
|
79327
|
+
...detail.command.terminalOutcome === void 0 ? [] : [` Recorded terminal outcome: ${detail.command.terminalOutcome}`],
|
|
79328
|
+
...detail.command.userOpHash === void 0 ? [] : [` Submitted user operation: ${terminalText(detail.command.userOpHash)}`],
|
|
79329
|
+
` Created: ${detail.createdAt}; updated: ${detail.updatedAt}${detail.settledAt === void 0 ? "" : `; recorded settled: ${detail.settledAt}`}`,
|
|
79330
|
+
"Original ordered Payments",
|
|
79331
|
+
...detail.items.flatMap((item) => [
|
|
79332
|
+
` Item ${item.itemIndex}: employee ${terminalText(item.employeeRef)}; engagement ${terminalText(item.engagementEdgeId)}`,
|
|
79333
|
+
` Gross: ${terminalText(item.gross)} raw units; net: ${terminalText(item.net)} raw units`,
|
|
79334
|
+
...item.adjustments.map((adjustment) => ` Adjustment: ${terminalText(adjustment.label)}; ${terminalText(adjustment.amount)} raw units`),
|
|
79335
|
+
` Quantity: ${terminalText(item.amount.value)}; asset: ${terminalText(item.amount.asset)}`,
|
|
79336
|
+
` Payment ${terminalText(item.payment.id)}: ${item.payment.status}`,
|
|
79337
|
+
` Counterparty: ${terminalText(item.payment.counterpartyLabel)}`,
|
|
79338
|
+
` Receipt: ${item.payment.receipt === null ? "none recorded" : `${terminalText(item.payment.receipt.transactionHash)} (chain ${item.payment.receipt.chainId})`}`,
|
|
79339
|
+
...item.payment.execution === void 0 ? [] : [` Execution: ${item.payment.execution.status}${item.payment.execution.retryRequired ? "; action required" : ""}`],
|
|
79340
|
+
...item.payment.recipient.kind === "party" ? [` Party: ${terminalText(item.payment.recipient.partyId)}; label: ${terminalText(item.payment.recipient.label)}`] : [],
|
|
79341
|
+
...item.payment.documentState === void 0 ? [] : [` Documents: ${item.payment.documentState}`],
|
|
79342
|
+
...item.payment.documents.map((document) => ` Document: ${terminalText(document.documentHash)}; content: ${terminalText(document.contentHash)}; kind: ${document.kind}`)
|
|
79343
|
+
])
|
|
79344
|
+
];
|
|
79345
|
+
//#endregion
|
|
79346
|
+
//#region src/commands/org/subcommands/payroll/internal/run-reads.ts
|
|
79347
|
+
const readValidatedRun = (config, input, validated, read) => Effect.gen(function* () {
|
|
79348
|
+
let orgId = validated.orgId;
|
|
79349
|
+
let email = validated.email;
|
|
79350
|
+
let command;
|
|
79351
|
+
const runtime = yield* CliRuntime;
|
|
79352
|
+
const known = () => orgId === null ? null : runRecovery(orgId, validated.runId, email, command);
|
|
79353
|
+
const observed = yield* Effect.gen(function* () {
|
|
79354
|
+
const restored = yield* restoreAuthenticatedClient(config, email, { requirement: "none" });
|
|
79355
|
+
email = restored.session.email;
|
|
79356
|
+
const organizations = yield* Effect.promise((signal) => restored.client.orgs({ signal })).pipe(Effect.flatMap(resultItems));
|
|
79357
|
+
orgId = (yield* selectOrganization(organizations, orgId)).id;
|
|
79358
|
+
if (!(yield* restored.stillAuthenticated)) return yield* Effect.fail(Errors.notAuthenticated());
|
|
79359
|
+
const reading = read(restored.client.org(orgId).payroll, orgId, validated.runId, (value) => {
|
|
79360
|
+
command = value.command;
|
|
79361
|
+
});
|
|
79362
|
+
const detail = yield* input.kind === "wait" ? withWaiting(reading, {
|
|
79363
|
+
...runtime,
|
|
79364
|
+
label: "Observe Payroll run state"
|
|
79365
|
+
}) : reading;
|
|
79366
|
+
if (detail === null) return yield* missingRun();
|
|
79367
|
+
if (!matches(detail, orgId, validated.runId)) return yield* Effect.fail(mismatch());
|
|
79368
|
+
if (!(yield* restored.stillAuthenticated)) return yield* Effect.fail(Errors.notAuthenticated());
|
|
79369
|
+
command = detail.command;
|
|
79370
|
+
return {
|
|
79371
|
+
detail,
|
|
79372
|
+
client: restored.client
|
|
79373
|
+
};
|
|
79374
|
+
}).pipe(Effect.mapError((error) => {
|
|
79375
|
+
const failure = classifyFailure(Cause.fail(orgId === null ? error : normalizeOrganizationReadFailure(error, orgId)), `org.payroll.${input.kind}`);
|
|
79376
|
+
const recovery = known();
|
|
79377
|
+
return new CliFailure({
|
|
79378
|
+
...failure,
|
|
79379
|
+
...recovery === null ? {} : {
|
|
79380
|
+
details: {
|
|
79381
|
+
...failure.details,
|
|
79382
|
+
...recovery.details
|
|
79383
|
+
},
|
|
79384
|
+
message: `${failure.message}\n${recovery.lines}`
|
|
79385
|
+
}
|
|
79386
|
+
});
|
|
79387
|
+
}), Effect.onInterrupt(() => {
|
|
79388
|
+
const recovery = known();
|
|
79389
|
+
return recovery === null ? Effect.void : writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
79390
|
+
type: "payroll.run.recovery",
|
|
79391
|
+
...recovery.details,
|
|
79392
|
+
message: recovery.lines
|
|
79393
|
+
})}\n` : `${recovery.lines}\n`).pipe(Effect.ignoreCause);
|
|
79394
|
+
}), Effect.timeoutOption(validated.timeout * 1e3));
|
|
79395
|
+
if (Option.isNone(observed)) {
|
|
79396
|
+
const recovery = known();
|
|
79397
|
+
return yield* new CliFailure({
|
|
79398
|
+
code: "CLI_DEADLINE",
|
|
79399
|
+
outcome: "failed",
|
|
79400
|
+
exitCode: 5,
|
|
79401
|
+
...recovery === null ? {} : { details: recovery.details },
|
|
79402
|
+
message: `The CLI stopped waiting. Payroll settlement is not confirmed.${recovery === null ? "" : `\n${recovery.lines}`}`
|
|
79403
|
+
});
|
|
79404
|
+
}
|
|
79405
|
+
const { detail } = observed.value;
|
|
79406
|
+
return {
|
|
79407
|
+
data: detail,
|
|
79408
|
+
lines: [...runDetailLines(detail), ...detail.items.flatMap((item) => documentReferenceLines(item.payment))]
|
|
79409
|
+
};
|
|
79410
|
+
});
|
|
79225
79411
|
//#endregion
|
|
79226
79412
|
//#region src/commands/org/subcommands/payroll/subcommands/get/execute.ts
|
|
79227
|
-
const execute$
|
|
79413
|
+
const execute$29 = (config, input) => Effect.gen(function* () {
|
|
79228
79414
|
const validated = yield* validateRunInput(input);
|
|
79229
79415
|
return yield* readValidatedRun(config, input, validated, (methods, _org, runId) => Effect.promise((signal) => methods.getRun(runId, { signal })).pipe(Effect.flatMap(resultValue)));
|
|
79230
79416
|
});
|
|
@@ -79234,7 +79420,7 @@ const command$26 = Command.make("get", {
|
|
|
79234
79420
|
runId: runIdArgument,
|
|
79235
79421
|
email: emailFlag$1,
|
|
79236
79422
|
timeout: timeoutFlag$1
|
|
79237
|
-
}, ({ runId, email, timeout }) => dispatch$1("get", (config, orgs) => execute$
|
|
79423
|
+
}, ({ runId, email, timeout }) => dispatch$1("get", (config, orgs) => execute$29(config, {
|
|
79238
79424
|
kind: "get",
|
|
79239
79425
|
orgs,
|
|
79240
79426
|
runIds: runId,
|
|
@@ -79306,7 +79492,7 @@ const observeRun = (register, orgId, runId, seen) => Effect.suspend(() => {
|
|
|
79306
79492
|
}).pipe(Effect.flatMap(resultValue));
|
|
79307
79493
|
//#endregion
|
|
79308
79494
|
//#region src/commands/org/subcommands/payroll/subcommands/wait/execute.ts
|
|
79309
|
-
const execute$
|
|
79495
|
+
const execute$28 = (config, input) => Effect.gen(function* () {
|
|
79310
79496
|
const validated = yield* validateRunInput(input);
|
|
79311
79497
|
return yield* readValidatedRun(config, input, validated, (methods, orgId, runId, seen) => observeRun((listener, signal) => methods.subscribeRun(runId, listener, { signal }), orgId, runId, seen));
|
|
79312
79498
|
});
|
|
@@ -79316,7 +79502,7 @@ const command$25 = Command.make("wait", {
|
|
|
79316
79502
|
runId: runIdArgument,
|
|
79317
79503
|
email: emailFlag$1,
|
|
79318
79504
|
timeout: timeoutFlag$1
|
|
79319
|
-
}, ({ runId, email, timeout }) => dispatch$1("wait", (config, orgs) => execute$
|
|
79505
|
+
}, ({ runId, email, timeout }) => dispatch$1("wait", (config, orgs) => execute$28(config, {
|
|
79320
79506
|
kind: "wait",
|
|
79321
79507
|
orgs,
|
|
79322
79508
|
runIds: runId,
|
|
@@ -79477,7 +79663,7 @@ const makeOrganizationProgress = (mode, run, persist) => {
|
|
|
79477
79663
|
* signature, and returns the typed wait failure, while the durable backend lane
|
|
79478
79664
|
* keeps running and stays resumable by the same create or by `org retry`.
|
|
79479
79665
|
*/
|
|
79480
|
-
const execute$
|
|
79666
|
+
const execute$27 = (config, input) => Effect.gen(function* () {
|
|
79481
79667
|
const operation = CAPXUL_OPERATIONS.org.create;
|
|
79482
79668
|
const draft = yield* readOrganizationDraft(input);
|
|
79483
79669
|
const timeout = yield* readWriteTimeout(input.timeoutSeconds);
|
|
@@ -79627,9 +79813,9 @@ const command$24 = Command.make("create", {
|
|
|
79627
79813
|
bio: Flag.String("bio").pipe(Flag.optional),
|
|
79628
79814
|
size: Flag.String("size").pipe(Flag.optional),
|
|
79629
79815
|
email: emailFlag$9,
|
|
79630
|
-
confirm: confirmFlag$
|
|
79816
|
+
confirm: confirmFlag$6,
|
|
79631
79817
|
timeoutSeconds: timeoutFlag$4
|
|
79632
|
-
}, ({ email, name, handle, country, bio, size, confirm, timeoutSeconds }) => dispatch$8(CAPXUL_OPERATIONS.org.create, (config) => execute$
|
|
79818
|
+
}, ({ email, name, handle, country, bio, size, confirm, timeoutSeconds }) => dispatch$8(CAPXUL_OPERATIONS.org.create, (config) => execute$27(config, {
|
|
79633
79819
|
email: Option.getOrUndefined(email),
|
|
79634
79820
|
name,
|
|
79635
79821
|
handle,
|
|
@@ -79649,7 +79835,7 @@ const perform$3 = (organizations, unfinishedSetups) => ({
|
|
|
79649
79835
|
},
|
|
79650
79836
|
lines: organizationListLines(organizations, unfinishedSetups)
|
|
79651
79837
|
});
|
|
79652
|
-
const execute$
|
|
79838
|
+
const execute$26 = (config, input) => readOrganization(config, "list", input, {
|
|
79653
79839
|
kind: "list",
|
|
79654
79840
|
listOrganizations: (client, signal) => client.orgs({ signal }),
|
|
79655
79841
|
readSetupPage: (client, pageInput, signal) => client.onboarding.listOrganizationSetups(pageInput, { signal }),
|
|
@@ -79657,7 +79843,7 @@ const execute$27 = (config, input) => readOrganization(config, "list", input, {
|
|
|
79657
79843
|
});
|
|
79658
79844
|
//#endregion
|
|
79659
79845
|
//#region src/commands/org/subcommands/list/command.ts
|
|
79660
|
-
const command$23 = Command.make("list", { email: emailFlag$9 }, ({ email }) => read$1(CAPXUL_OPERATIONS.org.list, { email }, execute$
|
|
79846
|
+
const command$23 = Command.make("list", { email: emailFlag$9 }, ({ email }) => read$1(CAPXUL_OPERATIONS.org.list, { email }, execute$26)).pipe(Command.annotate(CliCommandMetadata, metadata$18(CAPXUL_OPERATIONS.org.list)), Command.withDescription("List current Organization access"));
|
|
79661
79847
|
//#endregion
|
|
79662
79848
|
//#region src/commands/org/subcommands/me/execute.ts
|
|
79663
79849
|
const perform$2 = (scoped, organizationId, organization) => Effect.gen(function* () {
|
|
@@ -79670,13 +79856,13 @@ const perform$2 = (scoped, organizationId, organization) => Effect.gen(function*
|
|
|
79670
79856
|
label: "Organization membership"
|
|
79671
79857
|
});
|
|
79672
79858
|
});
|
|
79673
|
-
const execute$
|
|
79859
|
+
const execute$25 = (config, input) => readOrganization(config, "me", input, {
|
|
79674
79860
|
kind: "scoped",
|
|
79675
79861
|
run: ({ scoped, organizationId, organization }) => perform$2(scoped(), organizationId, organization)
|
|
79676
79862
|
});
|
|
79677
79863
|
//#endregion
|
|
79678
79864
|
//#region src/commands/org/subcommands/me/command.ts
|
|
79679
|
-
const command$22 = Command.make("me", scoped$1, ({ email }) => read$1(CAPXUL_OPERATIONS.org.me, { email }, execute$
|
|
79865
|
+
const command$22 = Command.make("me", scoped$1, ({ email }) => read$1(CAPXUL_OPERATIONS.org.me, { email }, execute$25)).pipe(Command.annotate(CliCommandMetadata, metadata$18(CAPXUL_OPERATIONS.org.me)), Command.withDescription("Read your standing in the Organization"));
|
|
79680
79866
|
//#endregion
|
|
79681
79867
|
//#region src/commands/org/subcommands/member/get/execute.ts
|
|
79682
79868
|
const perform$1 = (scoped, organizationId, organization, selectedAccountId) => Effect.gen(function* () {
|
|
@@ -79715,7 +79901,7 @@ const perform$1 = (scoped, organizationId, organization, selectedAccountId) => E
|
|
|
79715
79901
|
]
|
|
79716
79902
|
};
|
|
79717
79903
|
});
|
|
79718
|
-
const execute$
|
|
79904
|
+
const execute$24 = (config, input) => readOrganization(config, "member.get", input, {
|
|
79719
79905
|
kind: "scoped",
|
|
79720
79906
|
run: ({ scoped, organizationId, organization, accountId }) => perform$1(scoped(), organizationId, organization, accountId)
|
|
79721
79907
|
});
|
|
@@ -79724,7 +79910,7 @@ const execute$25 = (config, input) => readOrganization(config, "member.get", inp
|
|
|
79724
79910
|
const command$21 = Command.make("get", {
|
|
79725
79911
|
...scoped$1,
|
|
79726
79912
|
accountId: Argument.String("id").pipe(Argument.withDescription("The member's Account ID"), Argument.optional)
|
|
79727
|
-
}, ({ email, accountId }) => read$1("org.member.get", { email }, execute$
|
|
79913
|
+
}, ({ email, accountId }) => read$1("org.member.get", { email }, execute$24, Option.isSome(accountId) ? { accountId: accountId.value } : {})).pipe(Command.annotate(CliCommandMetadata, metadata$18("org.member.get")), Command.withDescription("Read one member by exact Account ID"));
|
|
79728
79914
|
//#endregion
|
|
79729
79915
|
//#region src/commands/org/internal/members.ts
|
|
79730
79916
|
const perform = (scoped, organizationId, organization) => Effect.gen(function* () {
|
|
@@ -79751,10 +79937,10 @@ const readOrganizationMembers = (config, command, input) => readOrganization(con
|
|
|
79751
79937
|
});
|
|
79752
79938
|
//#endregion
|
|
79753
79939
|
//#region src/commands/org/subcommands/member/list/execute.ts
|
|
79754
|
-
const execute$
|
|
79940
|
+
const execute$23 = (config, input) => readOrganizationMembers(config, "member.list", input);
|
|
79755
79941
|
//#endregion
|
|
79756
79942
|
//#region src/commands/org/subcommands/member/list/command.ts
|
|
79757
|
-
const command$20 = Command.make("list", scoped$1, ({ email }) => read$1("org.member.list", { email }, execute$
|
|
79943
|
+
const command$20 = Command.make("list", scoped$1, ({ email }) => read$1("org.member.list", { email }, execute$23)).pipe(Command.annotate(CliCommandMetadata, metadata$18("org.member.list")), Command.withDescription("List members, including pending members"));
|
|
79758
79944
|
//#endregion
|
|
79759
79945
|
//#region src/commands/org/subcommands/member/command.ts
|
|
79760
79946
|
const command$19 = Command.make("member").pipe(Command.annotate(CliCommandMetadata, metadata$18("org.member")), Command.withDescription("List, read, and invite Organization members"), Command.withSubcommands([
|
|
@@ -79770,7 +79956,7 @@ const command$19 = Command.make("member").pipe(Command.annotate(CliCommandMetada
|
|
|
79770
79956
|
* ever created. One deadline covers the retry call and its settlement, exactly as
|
|
79771
79957
|
* it does for create.
|
|
79772
79958
|
*/
|
|
79773
|
-
const execute$
|
|
79959
|
+
const execute$22 = (config, input) => Effect.gen(function* () {
|
|
79774
79960
|
const operation = CAPXUL_OPERATIONS.org.retry;
|
|
79775
79961
|
const timeout = yield* readWriteTimeout(input.timeoutSeconds);
|
|
79776
79962
|
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
@@ -79850,9 +80036,9 @@ const execute$23 = (config, input) => Effect.gen(function* () {
|
|
|
79850
80036
|
//#region src/commands/org/subcommands/retry/command.ts
|
|
79851
80037
|
const command$18 = Command.make("retry", {
|
|
79852
80038
|
email: emailFlag$9,
|
|
79853
|
-
confirm: confirmFlag$
|
|
80039
|
+
confirm: confirmFlag$6,
|
|
79854
80040
|
timeoutSeconds: timeoutFlag$4
|
|
79855
|
-
}, ({ email, confirm, timeoutSeconds }) => dispatch$8(CAPXUL_OPERATIONS.org.retry, (config, orgs) => execute$
|
|
80041
|
+
}, ({ email, confirm, timeoutSeconds }) => dispatch$8(CAPXUL_OPERATIONS.org.retry, (config, orgs) => execute$22(config, {
|
|
79856
80042
|
email: Option.getOrUndefined(email),
|
|
79857
80043
|
orgs,
|
|
79858
80044
|
confirm,
|
|
@@ -79882,7 +80068,7 @@ const settleOrganizationSetup = (read, input) => Effect.gen(function* () {
|
|
|
79882
80068
|
});
|
|
79883
80069
|
//#endregion
|
|
79884
80070
|
//#region src/commands/org/subcommands/show/execute.ts
|
|
79885
|
-
const execute$
|
|
80071
|
+
const execute$21 = (config, input) => readOrganization(config, "status", input, {
|
|
79886
80072
|
kind: "scoped",
|
|
79887
80073
|
run: ({ client, scoped, organizationId, organization, session, timeout }) => settleOrganizationSetup((observed) => Effect.gen(function* () {
|
|
79888
80074
|
const lifecycle = yield* Effect.promise((signal) => scoped().setup.get({ signal })).pipe(Effect.flatMap(resultValue));
|
|
@@ -79900,7 +80086,7 @@ const execute$22 = (config, input) => readOrganization(config, "status", input,
|
|
|
79900
80086
|
});
|
|
79901
80087
|
//#endregion
|
|
79902
80088
|
//#region src/commands/org/subcommands/show/command.ts
|
|
79903
|
-
const command$17 = Command.make("show", scoped$1, ({ email }) => read$1("org.show", { email }, execute$
|
|
80089
|
+
const command$17 = Command.make("show", scoped$1, ({ email }) => read$1("org.show", { email }, execute$21)).pipe(Command.annotate(CliCommandMetadata, metadata$18("org.show")), Command.withDescription("Read the exact Organization lifecycle"));
|
|
79904
80090
|
//#endregion
|
|
79905
80091
|
//#region src/commands/org/subcommands/wait/execute.ts
|
|
79906
80092
|
/** Follow the setup subscription to a settled state, printing each change once. */
|
|
@@ -79928,7 +80114,7 @@ const follow = (client, scoped, organizationId, email, observed) => Effect.gen(f
|
|
|
79928
80114
|
label: "Organization setup"
|
|
79929
80115
|
});
|
|
79930
80116
|
});
|
|
79931
|
-
const execute$
|
|
80117
|
+
const execute$20 = (config, input) => readOrganization(config, "wait", input, {
|
|
79932
80118
|
kind: "scoped",
|
|
79933
80119
|
run: ({ client, scoped, organizationId, organization, session, timeout }) => settleOrganizationSetup((observed) => follow(client, scoped(), organizationId, session.email, observed), {
|
|
79934
80120
|
organizationId,
|
|
@@ -79942,7 +80128,7 @@ const execute$21 = (config, input) => readOrganization(config, "wait", input, {
|
|
|
79942
80128
|
const command$16 = Command.make("wait", {
|
|
79943
80129
|
...scoped$1,
|
|
79944
80130
|
timeoutSeconds: timeoutFlag$4
|
|
79945
|
-
}, ({ email, timeoutSeconds }) => read$1("org.wait", { email }, execute$
|
|
80131
|
+
}, ({ email, timeoutSeconds }) => read$1("org.wait", { email }, execute$20, { timeoutSeconds })).pipe(Command.annotate(CliCommandMetadata, metadata$18("org.wait")), Command.withDescription("Poll the lifecycle until ready or failed; never retry setup"));
|
|
79946
80132
|
//#endregion
|
|
79947
80133
|
//#region src/commands/org/command.ts
|
|
79948
80134
|
/** Organization-only commands. They act as `--org`, `CAPXUL_ORG`, or the Organization `use org` saved. */
|
|
@@ -79965,7 +80151,6 @@ const paymentIdArgument = Argument.String("id").pipe(Argument.withDescription("T
|
|
|
79965
80151
|
const timeoutFlag = Flag.Int("timeout-seconds").pipe(Flag.withDefault(120));
|
|
79966
80152
|
const sourceFlag = Flag.String("input").pipe(Flag.withDescription("the SDK payment JSON, from a file or - for stdin"), Flag.optional);
|
|
79967
80153
|
const requestKeyFlag = Flag.String("request-key").pipe(Flag.withDescription("a key that makes repeating the same payment safe"), Flag.optional);
|
|
79968
|
-
const confirmFlag = Flag.Boolean("confirm").pipe(Flag.withDefault(false));
|
|
79969
80154
|
const names = {
|
|
79970
80155
|
root: "payment",
|
|
79971
80156
|
list: "payment.list",
|
|
@@ -80059,7 +80244,7 @@ const scopedFailure = (error, organizationId, kind) => {
|
|
|
80059
80244
|
};
|
|
80060
80245
|
//#endregion
|
|
80061
80246
|
//#region src/commands/org/subcommands/payment/subcommands/list/execute.ts
|
|
80062
|
-
const execute$
|
|
80247
|
+
const execute$19 = (config, input) => Effect.gen(function* () {
|
|
80063
80248
|
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
80064
80249
|
const organizationId = yield* readOrganizationId(input.orgs);
|
|
80065
80250
|
const named = flagValue((yield* CliRuntime).args ?? [], "org");
|
|
@@ -80074,7 +80259,7 @@ const execute$20 = (config, input) => Effect.gen(function* () {
|
|
|
80074
80259
|
});
|
|
80075
80260
|
//#endregion
|
|
80076
80261
|
//#region src/commands/payment/subcommands/list/execute.ts
|
|
80077
|
-
const execute$
|
|
80262
|
+
const execute$18 = (config, email) => Effect.gen(function* () {
|
|
80078
80263
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
80079
80264
|
const page = yield* Effect.promise((signal) => client.payments.list({ signal })).pipe(Effect.flatMap(resultValue), Effect.mapError((error) => isCapxulError(error) ? accountReadFailure(error, session.email) : error));
|
|
80080
80265
|
return {
|
|
@@ -80085,8 +80270,8 @@ const execute$19 = (config, email) => Effect.gen(function* () {
|
|
|
80085
80270
|
//#endregion
|
|
80086
80271
|
//#region src/commands/payment/subcommands/list/command.ts
|
|
80087
80272
|
const command$15 = Command.make("list", { email: emailFlag }, ({ email }) => dispatch("list", {
|
|
80088
|
-
personal: (config) => execute$
|
|
80089
|
-
organization: (config, orgId) => execute$
|
|
80273
|
+
personal: (config) => execute$18(config, Option.getOrUndefined(email)),
|
|
80274
|
+
organization: (config, orgId) => execute$19(config, {
|
|
80090
80275
|
kind: "list",
|
|
80091
80276
|
orgs: [orgId],
|
|
80092
80277
|
email: Option.getOrUndefined(email)
|
|
@@ -80094,7 +80279,7 @@ const command$15 = Command.make("list", { email: emailFlag }, ({ email }) => dis
|
|
|
80094
80279
|
})).pipe(annotate("list"), Command.withDescription("Payments sent and received"));
|
|
80095
80280
|
//#endregion
|
|
80096
80281
|
//#region src/commands/org/subcommands/payment/subcommands/get/execute.ts
|
|
80097
|
-
const execute$
|
|
80282
|
+
const execute$17 = (config, input) => Effect.gen(function* () {
|
|
80098
80283
|
const paymentId = yield* readPaymentId(input.paymentId);
|
|
80099
80284
|
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
80100
80285
|
const organizationId = yield* readOrganizationId(input.orgs);
|
|
@@ -80117,7 +80302,7 @@ const execute$18 = (config, input) => Effect.gen(function* () {
|
|
|
80117
80302
|
});
|
|
80118
80303
|
//#endregion
|
|
80119
80304
|
//#region src/commands/payment/subcommands/get/execute.ts
|
|
80120
|
-
const execute$
|
|
80305
|
+
const execute$16 = (config, paymentId, email) => Effect.gen(function* () {
|
|
80121
80306
|
const id = yield* readPaymentId(paymentId);
|
|
80122
80307
|
const { client, session } = yield* restoreAuthenticatedClient(config, email);
|
|
80123
80308
|
const payment = yield* Effect.promise((signal) => client.payments.get(id, { signal })).pipe(Effect.flatMap(resultValue), Effect.mapError((error) => isCapxulError(error) ? accountReadFailure(error, session.email) : error));
|
|
@@ -80139,8 +80324,8 @@ const command$14 = Command.make("get", {
|
|
|
80139
80324
|
paymentId: paymentIdArgument,
|
|
80140
80325
|
email: emailFlag
|
|
80141
80326
|
}, ({ paymentId, email }) => dispatch("get", {
|
|
80142
|
-
personal: (config) => execute$
|
|
80143
|
-
organization: (config, orgId) => execute$
|
|
80327
|
+
personal: (config) => execute$16(config, paymentId, Option.getOrUndefined(email)),
|
|
80328
|
+
organization: (config, orgId) => execute$17(config, {
|
|
80144
80329
|
kind: "get",
|
|
80145
80330
|
orgs: [orgId],
|
|
80146
80331
|
paymentId,
|
|
@@ -80286,7 +80471,7 @@ const waitForPayment = (config, input, register, organizationId) => Effect.gen(f
|
|
|
80286
80471
|
});
|
|
80287
80472
|
//#endregion
|
|
80288
80473
|
//#region src/commands/org/subcommands/payment/subcommands/wait/execute.ts
|
|
80289
|
-
const execute$
|
|
80474
|
+
const execute$15 = (config, input) => Effect.gen(function* () {
|
|
80290
80475
|
const paymentId = yield* readPaymentId(input.paymentId);
|
|
80291
80476
|
const timeoutSeconds = yield* readWriteTimeout(input.timeoutSeconds);
|
|
80292
80477
|
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
@@ -80299,168 +80484,6 @@ const execute$16 = (config, input) => Effect.gen(function* () {
|
|
|
80299
80484
|
}, (client, selectedPaymentId, listener, signal) => client.org(organizationId).payments.subscribe(selectedPaymentId, listener, { signal }), organizationId);
|
|
80300
80485
|
});
|
|
80301
80486
|
//#endregion
|
|
80302
|
-
//#region src/platform/open-url.ts
|
|
80303
|
-
/** Open a link in the person's browser; false when this system has no opener or it fails. */
|
|
80304
|
-
const openUrl = (url) => Effect.promise(() => new Promise((resolve) => {
|
|
80305
|
-
const command = platform === "darwin" ? "open" : platform === "linux" ? "xdg-open" : null;
|
|
80306
|
-
if (command === null) return resolve(false);
|
|
80307
|
-
const child = spawn(command, [url], {
|
|
80308
|
-
detached: true,
|
|
80309
|
-
stdio: "ignore"
|
|
80310
|
-
});
|
|
80311
|
-
child.once("error", () => resolve(false));
|
|
80312
|
-
child.once("spawn", () => {
|
|
80313
|
-
child.unref();
|
|
80314
|
-
resolve(true);
|
|
80315
|
-
});
|
|
80316
|
-
}));
|
|
80317
|
-
//#endregion
|
|
80318
|
-
//#region src/commands/payment/internal/approval.ts
|
|
80319
|
-
const scoped = (scope) => scope.organizationId === void 0 ? [] : ["--org", scope.organizationId];
|
|
80320
|
-
/** The command that follows an approval to its end. */
|
|
80321
|
-
const waitArgv = (approvalId, scope = {}) => [
|
|
80322
|
-
"capxul",
|
|
80323
|
-
"payment",
|
|
80324
|
-
"wait",
|
|
80325
|
-
approvalId,
|
|
80326
|
-
...scoped(scope)
|
|
80327
|
-
];
|
|
80328
|
-
/** `--json`: the approval is open and nothing moves until a person approves it. */
|
|
80329
|
-
const awaitingApproval = (approval, scope = {}) => ({
|
|
80330
|
-
status: "awaiting_approval",
|
|
80331
|
-
approvalId: approval.approvalId,
|
|
80332
|
-
approvalUrl: approval.url,
|
|
80333
|
-
paymentIds: approval.operation.paymentIds,
|
|
80334
|
-
expiresAt: approval.expiresAt,
|
|
80335
|
-
next: { argv: [...waitArgv(approval.approvalId, scope), "--json"] }
|
|
80336
|
-
});
|
|
80337
|
-
/** What the person checks before they approve. Every operation is sponsored: no fee. */
|
|
80338
|
-
const previewLines = (approval, source) => {
|
|
80339
|
-
const { from, to, amount } = approval.summary;
|
|
80340
|
-
const payer = source.budget === void 0 ? from.label : `${from.label} · ${source.budget}`;
|
|
80341
|
-
const left = source.left === void 0 ? "" : ` · ${shownAmount(source.left)} left`;
|
|
80342
|
-
return [
|
|
80343
|
-
`From ${terminalText(payer)}${left}`,
|
|
80344
|
-
`To ${terminalText(to.label)}`,
|
|
80345
|
-
`Amount ${amount === null ? "nothing moves" : shownAmount(amount)}`,
|
|
80346
|
-
"Fee none"
|
|
80347
|
-
];
|
|
80348
|
-
};
|
|
80349
|
-
const rejected = (approval) => new CliFailure({
|
|
80350
|
-
code: "CANCELLED",
|
|
80351
|
-
message: "Not sent: it was rejected on the approval page.",
|
|
80352
|
-
exitCode: 130,
|
|
80353
|
-
outcome: "cancelled",
|
|
80354
|
-
details: { paymentIds: approval.operation.paymentIds }
|
|
80355
|
-
});
|
|
80356
|
-
const expired = (approval) => new CliFailure({
|
|
80357
|
-
code: "WRONG_STATE",
|
|
80358
|
-
message: "Not sent: the approval expired before anyone approved it.",
|
|
80359
|
-
exitCode: 2,
|
|
80360
|
-
outcome: "refused",
|
|
80361
|
-
details: {
|
|
80362
|
-
currentState: "expired",
|
|
80363
|
-
paymentIds: approval.operation.paymentIds
|
|
80364
|
-
}
|
|
80365
|
-
});
|
|
80366
|
-
const stillWaiting = (approvalId, scope) => new CliFailure({
|
|
80367
|
-
code: "CLI_DEADLINE",
|
|
80368
|
-
message: "Still waiting for the approval. Nothing is sent until a person approves it.",
|
|
80369
|
-
next: waitArgv(approvalId, scope),
|
|
80370
|
-
exitCode: 5,
|
|
80371
|
-
outcome: "failed"
|
|
80372
|
-
});
|
|
80373
|
-
/** The Payments that did not settle, as a failure that names how to read them. */
|
|
80374
|
-
const unsettled = (outcome, scope) => {
|
|
80375
|
-
const failed = outcome.payments.find((payment) => payment.status !== "settled");
|
|
80376
|
-
return failed === void 0 ? void 0 : new CliFailure({
|
|
80377
|
-
code: "TRANSACTION_FAILED",
|
|
80378
|
-
message: `The payment did not settle: it is ${failed.status}.`,
|
|
80379
|
-
next: [
|
|
80380
|
-
"capxul",
|
|
80381
|
-
"payment",
|
|
80382
|
-
"get",
|
|
80383
|
-
failed.id,
|
|
80384
|
-
...scoped(scope)
|
|
80385
|
-
],
|
|
80386
|
-
exitCode: 5,
|
|
80387
|
-
outcome: "failed",
|
|
80388
|
-
details: { paymentIds: outcome.payments.map((payment) => payment.id) }
|
|
80389
|
-
});
|
|
80390
|
-
};
|
|
80391
|
-
const read = (client, approvalId) => Effect.promise(() => client.approvals.get(approvalId)).pipe(Effect.flatMap(resultValue));
|
|
80392
|
-
/**
|
|
80393
|
-
* Follow an approval: `onSigned` once the person approves, then send it (the
|
|
80394
|
-
* page may already have) and wait for its Payments. A rejection is a
|
|
80395
|
-
* cancellation; an expired approval sent nothing.
|
|
80396
|
-
*/
|
|
80397
|
-
const followApproval = (client, approvalId, options) => Effect.gen(function* () {
|
|
80398
|
-
let approval = yield* read(client, approvalId);
|
|
80399
|
-
while (approval.state === "pending") {
|
|
80400
|
-
yield* Effect.sleep("2 seconds");
|
|
80401
|
-
approval = yield* read(client, approvalId);
|
|
80402
|
-
}
|
|
80403
|
-
if (approval.state === "rejected") return yield* rejected(approval);
|
|
80404
|
-
if (approval.state === "expired") return yield* expired(approval);
|
|
80405
|
-
yield* options.onSigned;
|
|
80406
|
-
const outcome = yield* Effect.promise((signal) => client.approvals.wait(approvalId, {
|
|
80407
|
-
signal,
|
|
80408
|
-
...options.organizationId === void 0 ? {} : { organizationId: options.organizationId }
|
|
80409
|
-
})).pipe(Effect.flatMap(resultValue));
|
|
80410
|
-
if (outcome.approval.state === "rejected") return yield* rejected(outcome.approval);
|
|
80411
|
-
if (outcome.approval.state === "expired") return yield* expired(outcome.approval);
|
|
80412
|
-
const failure = unsettled(outcome, options);
|
|
80413
|
-
if (failure !== void 0) return yield* failure;
|
|
80414
|
-
return outcome;
|
|
80415
|
-
}).pipe(Effect.timeoutOption(options.deadlineMs), Effect.flatMap(Option.match({
|
|
80416
|
-
onNone: () => Effect.fail(stillWaiting(approvalId, options)),
|
|
80417
|
-
onSome: Effect.succeed
|
|
80418
|
-
})));
|
|
80419
|
-
/** `Paid 50.00 USDC to Rex · 0x5b2e…91c4`, and where the receipt is. */
|
|
80420
|
-
const paidLines = (outcome, scope = {}) => outcome.payments.flatMap((payment) => {
|
|
80421
|
-
const hash = payment.receipt?.transactionHash;
|
|
80422
|
-
return [`Paid ${shownAmount(payment.amount)} to ${terminalText(payment.counterpartyLabel)}${hash === void 0 ? "" : ` · ${hash.slice(0, 6)}…${hash.slice(-4)}`}`, `receipt: ${terminalText([
|
|
80423
|
-
"capxul",
|
|
80424
|
-
"payment",
|
|
80425
|
-
"get",
|
|
80426
|
-
payment.id,
|
|
80427
|
-
...scoped(scope)
|
|
80428
|
-
].join(" "))}`];
|
|
80429
|
-
});
|
|
80430
|
-
/** A progress line for a person, on stderr. */
|
|
80431
|
-
const progress = (line) => writeStderr(`${line}\n`);
|
|
80432
|
-
/** After the approval lapses, the time a send and its settlement may still take. */
|
|
80433
|
-
const SETTLE_MS = 12e4;
|
|
80434
|
-
/**
|
|
80435
|
-
* Hand a prepared approval over. An agent gets the link and the wait command
|
|
80436
|
-
* back at once. A person sees the preview, the approval page opens, and the
|
|
80437
|
-
* CLI follows it until the payment is confirmed: the page is the one and only
|
|
80438
|
-
* confirmation.
|
|
80439
|
-
*/
|
|
80440
|
-
const handOver = (client, approval, options) => Effect.gen(function* () {
|
|
80441
|
-
const runtime = yield* CliRuntime;
|
|
80442
|
-
if (runtime.mode === "json") return {
|
|
80443
|
-
data: awaitingApproval(approval, options),
|
|
80444
|
-
lines: []
|
|
80445
|
-
};
|
|
80446
|
-
for (const line of previewLines(approval, options)) yield* progress(line);
|
|
80447
|
-
yield* progress("✓ Prepared");
|
|
80448
|
-
const opened = runtime.tty && !runtime.ci ? yield* openUrl(approval.url) : false;
|
|
80449
|
-
yield* progress(`… Approve in your browser${opened ? " (opened)" : ""}`);
|
|
80450
|
-
yield* progress(` ${approval.url}`);
|
|
80451
|
-
const now = yield* Clock.currentTimeMillis;
|
|
80452
|
-
const outcome = yield* followApproval(client, approval.approvalId, {
|
|
80453
|
-
organizationId: options.organizationId,
|
|
80454
|
-
deadlineMs: options.timeoutSeconds === void 0 ? Math.max(approval.expiresAt - now, 0) + SETTLE_MS : options.timeoutSeconds * 1e3,
|
|
80455
|
-
onSigned: progress("✓ Signed")
|
|
80456
|
-
}).pipe(Effect.onInterrupt(() => progress(`Nothing is sent until you approve. Follow it with: ${waitArgv(approval.approvalId, options).join(" ")}`).pipe(Effect.ignore)));
|
|
80457
|
-
yield* progress("✓ Confirmed");
|
|
80458
|
-
return {
|
|
80459
|
-
data: outcome,
|
|
80460
|
-
lines: paidLines(outcome, options)
|
|
80461
|
-
};
|
|
80462
|
-
});
|
|
80463
|
-
//#endregion
|
|
80464
80487
|
//#region src/commands/payment/subcommands/wait/approval.ts
|
|
80465
80488
|
const APPROVAL_ID = /^approval_[0-9A-HJKMNP-TV-Z]{26}$/u;
|
|
80466
80489
|
/** An approval ID, as `payment send --json` returns it. */
|
|
@@ -80489,7 +80512,7 @@ const waitForApproval = (config, input) => Effect.gen(function* () {
|
|
|
80489
80512
|
});
|
|
80490
80513
|
//#endregion
|
|
80491
80514
|
//#region src/commands/payment/subcommands/wait/execute.ts
|
|
80492
|
-
const execute$
|
|
80515
|
+
const execute$14 = (config, input) => waitForPayment(config, input, (client, paymentId, listener, signal) => client.payments.subscribe(paymentId, listener, { signal }));
|
|
80493
80516
|
//#endregion
|
|
80494
80517
|
//#region src/commands/payment/subcommands/wait/command.ts
|
|
80495
80518
|
const command$13 = Command.make("wait", {
|
|
@@ -80501,7 +80524,7 @@ const command$13 = Command.make("wait", {
|
|
|
80501
80524
|
approvalId: paymentId,
|
|
80502
80525
|
email: Option.getOrUndefined(email),
|
|
80503
80526
|
timeoutSeconds
|
|
80504
|
-
}) : execute$
|
|
80527
|
+
}) : execute$14(config, {
|
|
80505
80528
|
kind: "wait",
|
|
80506
80529
|
paymentId,
|
|
80507
80530
|
email: Option.getOrUndefined(email),
|
|
@@ -80512,7 +80535,7 @@ const command$13 = Command.make("wait", {
|
|
|
80512
80535
|
email: Option.getOrUndefined(email),
|
|
80513
80536
|
timeoutSeconds,
|
|
80514
80537
|
organizationId: orgId
|
|
80515
|
-
}) : execute$
|
|
80538
|
+
}) : execute$15(config, {
|
|
80516
80539
|
kind: "wait",
|
|
80517
80540
|
orgs: [orgId],
|
|
80518
80541
|
paymentId,
|
|
@@ -80704,7 +80727,7 @@ const readWords = (input, holder) => Effect.gen(function* () {
|
|
|
80704
80727
|
amount
|
|
80705
80728
|
};
|
|
80706
80729
|
});
|
|
80707
|
-
const execute$
|
|
80730
|
+
const execute$13 = (config, input) => Effect.gen(function* () {
|
|
80708
80731
|
const flags = yield* readSendFlags(input);
|
|
80709
80732
|
const runtime = yield* CliRuntime;
|
|
80710
80733
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
@@ -80824,7 +80847,7 @@ const readOrganizationPaymentInput = (source) => Effect.gen(function* () {
|
|
|
80824
80847
|
}).pipe(Effect.mapError((error) => error instanceof UpdateUnavailable ? inputRequired("Organization Payment input exceeds 64 KiB.") : error));
|
|
80825
80848
|
//#endregion
|
|
80826
80849
|
//#region src/commands/org/subcommands/payment/subcommands/send/execute.ts
|
|
80827
|
-
const execute$
|
|
80850
|
+
const execute$12 = (config, orgId, input) => Effect.gen(function* () {
|
|
80828
80851
|
const flags = yield* readSendFlags(input);
|
|
80829
80852
|
const runtime = yield* CliRuntime;
|
|
80830
80853
|
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
@@ -80884,352 +80907,47 @@ const command$12 = Command.make("send", {
|
|
|
80884
80907
|
timeoutSeconds: Option.getOrUndefined(flags.timeoutSeconds)
|
|
80885
80908
|
};
|
|
80886
80909
|
return dispatch("send", {
|
|
80887
|
-
personal: (config) => execute$
|
|
80888
|
-
organization: (config, orgId) => execute$
|
|
80910
|
+
personal: (config) => execute$13(config, input),
|
|
80911
|
+
organization: (config, orgId) => execute$12(config, orgId, input)
|
|
80889
80912
|
});
|
|
80890
80913
|
}).pipe(annotate("send"), Command.withDescription("you approve it in the browser"));
|
|
80891
80914
|
//#endregion
|
|
80892
|
-
//#region src/commands/org/subcommands/payment/internal/retry-recovery.ts
|
|
80893
|
-
/** What an interrupted or failed retry prints: the selected and prepared Payments to read or wait for. */
|
|
80894
|
-
const retryRecovery = (input) => {
|
|
80895
|
-
const { organizationId, selectedPaymentId, recoveryEmail, previewIds, preparedIds, commandId } = input;
|
|
80896
|
-
const ids = [.../* @__PURE__ */ new Set([selectedPaymentId, ...preparedIds.length === 0 ? previewIds : preparedIds])];
|
|
80897
|
-
const argv = (id, verb) => [
|
|
80898
|
-
"capxul",
|
|
80899
|
-
"payment",
|
|
80900
|
-
verb,
|
|
80901
|
-
id,
|
|
80902
|
-
"--org",
|
|
80903
|
-
organizationId,
|
|
80904
|
-
...recoveryEmail === void 0 ? [] : ["--email", recoveryEmail]
|
|
80905
|
-
];
|
|
80906
|
-
return {
|
|
80907
|
-
details: {
|
|
80908
|
-
paymentId: selectedPaymentId,
|
|
80909
|
-
...organizationId === null ? {} : {
|
|
80910
|
-
organizationId,
|
|
80911
|
-
recovery: {
|
|
80912
|
-
kind: "read",
|
|
80913
|
-
argv: argv(selectedPaymentId, "get")
|
|
80914
|
-
}
|
|
80915
|
-
},
|
|
80916
|
-
...preparedIds.length === 0 ? {} : { paymentIds: preparedIds },
|
|
80917
|
-
...commandId === void 0 ? {} : { commandId }
|
|
80918
|
-
},
|
|
80919
|
-
lines: [
|
|
80920
|
-
...organizationId === null ? [] : [`Organization: ${terminalText(organizationId)}`],
|
|
80921
|
-
`Selected Payment: ${terminalText(selectedPaymentId)}`,
|
|
80922
|
-
...preparedIds.length > 0 ? [`Verified prepared Payment IDs: ${preparedIds.map(terminalText).join(", ")}`] : previewIds.length > 0 ? [`Preview Payment IDs for read guidance: ${previewIds.map(terminalText).join(", ")}`] : [],
|
|
80923
|
-
...organizationId === null ? [] : ids.flatMap((id) => [`Read: capxul payment get ${shellArgument(id)} --org ${shellArgument(organizationId)}${recoveryEmail === void 0 ? "" : ` --email ${shellArgument(recoveryEmail)}`}`, `Wait: capxul payment wait ${shellArgument(id)} --org ${shellArgument(organizationId)}${recoveryEmail === void 0 ? "" : ` --email ${shellArgument(recoveryEmail)}`}`])
|
|
80924
|
-
]
|
|
80925
|
-
};
|
|
80926
|
-
};
|
|
80927
|
-
//#endregion
|
|
80928
|
-
//#region src/commands/org/subcommands/payment/internal/retry-cohort.ts
|
|
80929
|
-
/** The preview is the selected Organization's complete outgoing cohort, with valid Payment IDs. */
|
|
80930
|
-
const requireRetryCohort = (cohort, selectedOrg, selectedPaymentId) => Effect.gen(function* () {
|
|
80931
|
-
if (cohort === null || cohort === void 0 || cohort.orgId !== selectedOrg || !cohort.paymentIds.includes(selectedPaymentId) || new Set(cohort.paymentIds).size !== cohort.paymentIds.length || cohort.payments.length !== cohort.paymentIds.length || cohort.payments.some((payment, index) => payment?.id !== cohort.paymentIds[index] || payment.direction !== "out")) return yield* Effect.fail(Errors.invalidInput("preview", "The Organization retry preview does not match the selected scope and complete outgoing cohort."));
|
|
80932
|
-
yield* Effect.forEach(cohort.paymentIds, readPaymentId).pipe(Effect.mapError(() => Errors.invalidInput("preview", "The retry preview contains an invalid Payment ID.")));
|
|
80933
|
-
});
|
|
80934
|
-
/** What the retry shows before it starts: the actor, the original command and every Payment. */
|
|
80935
|
-
const retryCohortLines = (session, selectedOrg, cohort) => {
|
|
80936
|
-
const preview = { session };
|
|
80937
|
-
return [
|
|
80938
|
-
`Acting as: ${terminalText(preview.session.email)} (${terminalText(preview.session.authUserId)})`,
|
|
80939
|
-
`Organization: ${terminalText(selectedOrg)}`,
|
|
80940
|
-
`Original command: ${terminalText(cohort.commandId)}`,
|
|
80941
|
-
`Stored Budget: ${cohort.permissionId === null ? "not recorded" : terminalText(cohort.permissionId)}`,
|
|
80942
|
-
...cohort.payments.flatMap((payment) => [
|
|
80943
|
-
...paymentLines(payment),
|
|
80944
|
-
` Recipient: ${terminalText(JSON.stringify(payment.recipient))}`,
|
|
80945
|
-
` AssetId: ${terminalText(payment.amount.asset)}`,
|
|
80946
|
-
` Quantity: ${terminalText(payment.amount.value)}`,
|
|
80947
|
-
` Timing: ${terminalText(JSON.stringify(payment.timing))}`
|
|
80948
|
-
])
|
|
80949
|
-
];
|
|
80950
|
-
};
|
|
80951
|
-
//#endregion
|
|
80952
|
-
//#region src/commands/org/subcommands/payment/subcommands/retry/execute.ts
|
|
80953
|
-
const execute$12 = (config, input) => Effect.gen(function* () {
|
|
80954
|
-
const timeout = yield* readWriteTimeout(input.timeoutSeconds);
|
|
80955
|
-
const email = input.email === void 0 ? void 0 : yield* readEmail(input.email);
|
|
80956
|
-
let organizationId = input.orgs.length === 0 ? null : yield* readOrganizationId(input.orgs);
|
|
80957
|
-
let paymentId = input.paymentId === void 0 ? void 0 : yield* readPaymentId(input.paymentId);
|
|
80958
|
-
const runtime = yield* CliRuntime;
|
|
80959
|
-
const human = runtime.tty && !runtime.ci && runtime.mode !== "json";
|
|
80960
|
-
if (!human && organizationId === null) return yield* inputRequired("Provide --org with one exact Organization ID.");
|
|
80961
|
-
if (!human && paymentId === void 0) return yield* inputRequired("Provide the exact Payment ID.");
|
|
80962
|
-
const interactive = yield* requireWriteConfirmation(input.confirm);
|
|
80963
|
-
if (paymentId === void 0) paymentId = yield* readPaymentId(yield* Prompt.String({ message: "Payment ID" }));
|
|
80964
|
-
const selectedPaymentId = paymentId;
|
|
80965
|
-
let recoveryEmail = email;
|
|
80966
|
-
let previewIds = [];
|
|
80967
|
-
let preparedIds = [];
|
|
80968
|
-
let commandId;
|
|
80969
|
-
let retryStarted = false;
|
|
80970
|
-
const sameIds = (ids) => ids.length === previewIds.length && ids.every((id, index) => id === previewIds[index]);
|
|
80971
|
-
const recovery = () => retryRecovery({
|
|
80972
|
-
organizationId,
|
|
80973
|
-
selectedPaymentId,
|
|
80974
|
-
recoveryEmail,
|
|
80975
|
-
previewIds,
|
|
80976
|
-
preparedIds,
|
|
80977
|
-
commandId
|
|
80978
|
-
});
|
|
80979
|
-
const recoveryNotice = () => {
|
|
80980
|
-
const known = recovery();
|
|
80981
|
-
return writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
80982
|
-
type: "org.payment.recovery",
|
|
80983
|
-
...known.details,
|
|
80984
|
-
...preparedIds.length === 0 ? { previewPaymentIds: previewIds } : {}
|
|
80985
|
-
})}\n` : `${known.lines.join("\n")}\n`).pipe(Effect.ignoreCause);
|
|
80986
|
-
};
|
|
80987
|
-
const within = (work) => work.pipe(Effect.timeoutOrElse({
|
|
80988
|
-
duration: timeout * 1e3,
|
|
80989
|
-
orElse: () => Effect.fail(new CliFailure({
|
|
80990
|
-
code: "CLI_DEADLINE",
|
|
80991
|
-
exitCode: 5,
|
|
80992
|
-
outcome: "failed",
|
|
80993
|
-
message: retryStarted ? "The CLI stopped waiting. The Payments may still settle." : "The retry preview or signer did not finish. No retry was started."
|
|
80994
|
-
}))
|
|
80995
|
-
}));
|
|
80996
|
-
return yield* Effect.gen(function* () {
|
|
80997
|
-
const opened = yield* openAuthenticatedSession(config, email);
|
|
80998
|
-
const preview = yield* within(restoreTransactingActor(config, opened, organizationId === null));
|
|
80999
|
-
recoveryEmail = preview.session.email;
|
|
81000
|
-
if (organizationId === null) {
|
|
81001
|
-
if (preview.organizations.length === 0) return yield* inputRequired("No current Organization is available. Provide an authorized --org.");
|
|
81002
|
-
organizationId = yield* Prompt.Select({
|
|
81003
|
-
message: "Organization",
|
|
81004
|
-
choices: preview.organizations.map((organization) => ({
|
|
81005
|
-
title: organizationLabel(organization),
|
|
81006
|
-
value: organization.id
|
|
81007
|
-
}))
|
|
81008
|
-
});
|
|
81009
|
-
}
|
|
81010
|
-
const selectedOrg = organizationId;
|
|
81011
|
-
const cohort = yield* within(Effect.promise((signal) => preview.client.org(selectedOrg).payments.previewRetry(selectedPaymentId, { signal })).pipe(Effect.flatMap(resultValue)));
|
|
81012
|
-
yield* requireRetryCohort(cohort, selectedOrg, selectedPaymentId);
|
|
81013
|
-
previewIds = [...cohort.paymentIds];
|
|
81014
|
-
commandId = cohort.commandId;
|
|
81015
|
-
const lines = retryCohortLines(preview.session, selectedOrg, cohort);
|
|
81016
|
-
if (interactive) yield* confirmWrite({
|
|
81017
|
-
lines,
|
|
81018
|
-
question: "Retry this complete original Payment cohort?"
|
|
81019
|
-
});
|
|
81020
|
-
else yield* writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
81021
|
-
type: "org.payment.preview",
|
|
81022
|
-
organizationId: selectedOrg,
|
|
81023
|
-
selectedPaymentId,
|
|
81024
|
-
commandId: cohort.commandId,
|
|
81025
|
-
permissionId: cohort.permissionId,
|
|
81026
|
-
previewPaymentIds: previewIds,
|
|
81027
|
-
payments: cohort.payments
|
|
81028
|
-
})}\n` : `${lines.join("\n")}\n`);
|
|
81029
|
-
const context = yield* Effect.context();
|
|
81030
|
-
const run = Effect.runPromiseWith(context);
|
|
81031
|
-
const operation = CAPXUL_OPERATIONS.organizationPayments.retry;
|
|
81032
|
-
const completed = yield* within(Effect.gen(function* () {
|
|
81033
|
-
const signal = yield* Effect.abortSignal;
|
|
81034
|
-
let writeLifetime;
|
|
81035
|
-
const checkActor = Effect.gen(function* () {
|
|
81036
|
-
const stopped = cancelledWrite(operation, signal);
|
|
81037
|
-
if (stopped !== null) return yield* Effect.fail(stopped);
|
|
81038
|
-
if (!(yield* preview.stillAuthenticated)) return yield* Effect.fail(Errors.cancelled({ operation }));
|
|
81039
|
-
});
|
|
81040
|
-
yield* checkActor;
|
|
81041
|
-
const signer = yield* organizationWriteSigner(config, opened, run, async () => {
|
|
81042
|
-
await run(checkActor);
|
|
81043
|
-
if (writeLifetime === void 0 || !await run(writeLifetime)) throw Errors.cancelled({ operation });
|
|
81044
|
-
if (!sameIds(preparedIds)) throw Errors.invalidInput("paymentIds", "The verified prepared retry cohort was not confirmed.");
|
|
81045
|
-
});
|
|
81046
|
-
const write = yield* restoreWriteClient(config, opened, signer, preview.session, () => Errors.cancelled({ operation }));
|
|
81047
|
-
writeLifetime = write.stillAuthenticated;
|
|
81048
|
-
yield* checkActor;
|
|
81049
|
-
const onPrepared = async ({ paymentIds }) => {
|
|
81050
|
-
const stopped = cancelledWrite(operation, signal);
|
|
81051
|
-
if (stopped !== null) throw stopped;
|
|
81052
|
-
preparedIds = [...paymentIds];
|
|
81053
|
-
if (!sameIds(preparedIds)) throw Errors.invalidInput("paymentIds", "The prepared retry Payments differ from the confirmed preview.");
|
|
81054
|
-
await run(writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
81055
|
-
type: "org.payment.prepared",
|
|
81056
|
-
...recovery().details
|
|
81057
|
-
})}\n` : `Verified prepared Payment IDs: ${preparedIds.map(terminalText).join(", ")}\n`));
|
|
81058
|
-
await run(checkActor);
|
|
81059
|
-
if (!await run(write.stillAuthenticated)) throw Errors.cancelled({ operation });
|
|
81060
|
-
};
|
|
81061
|
-
retryStarted = true;
|
|
81062
|
-
return yield* Effect.promise((operationSignal) => write.client.org(selectedOrg).payments.retry(selectedPaymentId, {
|
|
81063
|
-
signal: operationSignal,
|
|
81064
|
-
onPrepared
|
|
81065
|
-
})).pipe(Effect.flatMap(resultValue));
|
|
81066
|
-
}).pipe(Effect.scoped));
|
|
81067
|
-
const documentOutputs = yield* Effect.forEach(completed, (payment) => savePaymentDocuments(config, preview.client, payment).pipe(Effect.map((output) => ({
|
|
81068
|
-
paymentId: payment.id,
|
|
81069
|
-
...output
|
|
81070
|
-
}))));
|
|
81071
|
-
return {
|
|
81072
|
-
data: {
|
|
81073
|
-
payments: completed,
|
|
81074
|
-
documentOutputs
|
|
81075
|
-
},
|
|
81076
|
-
lines: [
|
|
81077
|
-
`Organization: ${terminalText(selectedOrg)}`,
|
|
81078
|
-
...completed.flatMap(paymentLines),
|
|
81079
|
-
...documentOutputs.flatMap(documentOutputLines)
|
|
81080
|
-
]
|
|
81081
|
-
};
|
|
81082
|
-
}).pipe(Effect.mapError((error) => {
|
|
81083
|
-
const account = isCapxulError(error) && recoveryEmail !== void 0 ? accountReadFailure(error, recoveryEmail) : error;
|
|
81084
|
-
const scoped = organizationId === null ? account : normalizeOrganizationReadFailure(account, organizationId);
|
|
81085
|
-
const failure = classifyFailure(Cause.fail(scoped), "org.payment.retry");
|
|
81086
|
-
const known = recovery();
|
|
81087
|
-
const message = isCapxulError(error) && error.code === "INVALID_INPUT" && (error.details?.field === "preview" || error.details?.field === "paymentIds") ? "The retry preview or Payment cohort does not match this command." : failure.message;
|
|
81088
|
-
return new CliFailure({
|
|
81089
|
-
...failure,
|
|
81090
|
-
details: {
|
|
81091
|
-
...failure.details,
|
|
81092
|
-
...known.details
|
|
81093
|
-
},
|
|
81094
|
-
message: `${message}\n${known.lines.join("\n")}`
|
|
81095
|
-
});
|
|
81096
|
-
}), Effect.onInterrupt(recoveryNotice));
|
|
81097
|
-
});
|
|
81098
|
-
//#endregion
|
|
81099
80915
|
//#region src/commands/payment/subcommands/retry/execute.ts
|
|
81100
|
-
const
|
|
81101
|
-
const waitLine = (id, email) => `capxul payment wait ${shellArgument(id)} --email ${shellArgument(email)}`;
|
|
81102
|
-
const execute$11 = (config, input) => Effect.gen(function* () {
|
|
80916
|
+
const execute$11 = (config, input, organizationId) => Effect.gen(function* () {
|
|
81103
80917
|
const id = yield* readPaymentId(input.paymentId);
|
|
81104
|
-
const
|
|
81105
|
-
const interactive = yield* requireWriteConfirmation(input.confirm);
|
|
81106
|
-
const opened = yield* openAuthenticatedSession(config, input.email);
|
|
81107
|
-
const previewRead = yield* Effect.gen(function* () {
|
|
81108
|
-
const restored = yield* restoreVerifiedClient(config, opened, { requirement: "none" });
|
|
81109
|
-
return {
|
|
81110
|
-
payment: yield* Effect.promise((signal) => restored.client.payments.get(id, { signal })).pipe(Effect.flatMap(resultValue)),
|
|
81111
|
-
session: restored.session,
|
|
81112
|
-
client: restored.client
|
|
81113
|
-
};
|
|
81114
|
-
}).pipe(Effect.timeoutOption(timeout * 1e3));
|
|
81115
|
-
if (Option.isNone(previewRead)) return yield* new CliFailure({
|
|
81116
|
-
code: "CLI_DEADLINE",
|
|
81117
|
-
outcome: "failed",
|
|
81118
|
-
exitCode: 5,
|
|
81119
|
-
message: `The Payment retry preview did not finish. No retry was started. Read: ${readLine(id, opened.email)}`
|
|
81120
|
-
});
|
|
81121
|
-
const { payment, session } = previewRead.value;
|
|
81122
|
-
if (payment === null) return yield* paymentNotFound();
|
|
81123
|
-
if (payment.id !== id) return yield* new CliFailure({
|
|
81124
|
-
code: "INVALID_INPUT",
|
|
81125
|
-
outcome: "refused",
|
|
81126
|
-
exitCode: 2,
|
|
81127
|
-
message: "The Payment response did not match the Payment ID."
|
|
81128
|
-
});
|
|
81129
|
-
if (interactive) yield* confirmWrite({
|
|
81130
|
-
lines: [`Acting as: ${terminalText(session.email)}`, ...paymentLines(payment)],
|
|
81131
|
-
question: "Retry this exact Payment?"
|
|
81132
|
-
});
|
|
80918
|
+
const timeoutSeconds = input.timeoutSeconds === void 0 ? void 0 : yield* readWriteTimeout(input.timeoutSeconds);
|
|
81133
80919
|
const runtime = yield* CliRuntime;
|
|
81134
|
-
yield*
|
|
81135
|
-
|
|
81136
|
-
|
|
81137
|
-
|
|
81138
|
-
|
|
81139
|
-
|
|
81140
|
-
|
|
81141
|
-
|
|
81142
|
-
|
|
81143
|
-
|
|
81144
|
-
|
|
81145
|
-
});
|
|
81146
|
-
const { client } = yield* restoreVerifiedClient(config, opened, {
|
|
81147
|
-
requirement: "deployed",
|
|
81148
|
-
openfortSignerFactory: signer
|
|
81149
|
-
});
|
|
81150
|
-
return yield* Effect.promise((operationSignal) => client.payments.retry(id, { signal: operationSignal })).pipe(Effect.flatMap(resultValue));
|
|
81151
|
-
}).pipe(Effect.scoped, Effect.timeoutOption(timeout * 1e3)).pipe(Effect.mapError((error) => {
|
|
81152
|
-
const account = isCapxulError(error) ? accountReadFailure(error, opened.email) : error;
|
|
81153
|
-
const classified = classifyFailure(Cause.fail(account), "payment.retry");
|
|
81154
|
-
return new CliFailure({
|
|
81155
|
-
code: classified.code,
|
|
81156
|
-
outcome: classified.outcome,
|
|
81157
|
-
exitCode: classified.exitCode,
|
|
81158
|
-
...classified.mode === void 0 ? {} : { mode: classified.mode },
|
|
81159
|
-
details: {
|
|
81160
|
-
...classified.details,
|
|
81161
|
-
paymentId: id,
|
|
81162
|
-
recovery: {
|
|
81163
|
-
kind: "read",
|
|
81164
|
-
argv: [
|
|
81165
|
-
"capxul",
|
|
81166
|
-
"payment",
|
|
81167
|
-
"get",
|
|
81168
|
-
id,
|
|
81169
|
-
"--email",
|
|
81170
|
-
opened.email
|
|
81171
|
-
]
|
|
81172
|
-
}
|
|
81173
|
-
},
|
|
81174
|
-
message: `${classified.message}\nRead: ${readLine(id, opened.email)}\nWait: ${waitLine(id, opened.email)}`
|
|
81175
|
-
});
|
|
81176
|
-
}));
|
|
81177
|
-
if (Option.isNone(result)) return yield* new CliFailure({
|
|
81178
|
-
code: "CLI_DEADLINE",
|
|
81179
|
-
outcome: "failed",
|
|
81180
|
-
exitCode: 5,
|
|
81181
|
-
details: {
|
|
81182
|
-
paymentId: id,
|
|
81183
|
-
recovery: {
|
|
81184
|
-
kind: "read",
|
|
81185
|
-
argv: [
|
|
81186
|
-
"capxul",
|
|
81187
|
-
"payment",
|
|
81188
|
-
"get",
|
|
81189
|
-
id,
|
|
81190
|
-
"--email",
|
|
81191
|
-
opened.email
|
|
81192
|
-
]
|
|
81193
|
-
}
|
|
81194
|
-
},
|
|
81195
|
-
message: `The CLI stopped waiting. The Payment may still settle.\nRead: ${readLine(id, opened.email)}\nWait: ${waitLine(id, opened.email)}`
|
|
80920
|
+
const { client } = yield* restoreAuthenticatedClient(config, input.email);
|
|
80921
|
+
const approval = yield* withWaiting(Effect.promise((signal) => client.approvals.prepare({
|
|
80922
|
+
retry: id,
|
|
80923
|
+
...organizationId === void 0 ? {} : { organizationId }
|
|
80924
|
+
}, { signal })).pipe(Effect.flatMap(resultValue)), {
|
|
80925
|
+
...runtime,
|
|
80926
|
+
label: "Preparing the retry"
|
|
80927
|
+
});
|
|
80928
|
+
return yield* handOver(client, approval, {
|
|
80929
|
+
organizationId,
|
|
80930
|
+
timeoutSeconds
|
|
81196
80931
|
});
|
|
81197
|
-
const documentOutputs = yield* Effect.forEach(result.value, (returnedPayment) => savePaymentDocuments(config, previewRead.value.client, returnedPayment).pipe(Effect.map((output) => ({
|
|
81198
|
-
paymentId: returnedPayment.id,
|
|
81199
|
-
...output
|
|
81200
|
-
}))));
|
|
81201
|
-
return {
|
|
81202
|
-
data: {
|
|
81203
|
-
payments: result.value,
|
|
81204
|
-
documentOutputs
|
|
81205
|
-
},
|
|
81206
|
-
lines: [...result.value.flatMap(paymentLines), ...documentOutputs.flatMap(documentOutputLines)]
|
|
81207
|
-
};
|
|
81208
80932
|
});
|
|
81209
80933
|
//#endregion
|
|
81210
80934
|
//#region src/commands/payment/subcommands/retry/command.ts
|
|
81211
80935
|
const command$11 = Command.make("retry", {
|
|
81212
80936
|
paymentId: paymentIdArgument,
|
|
81213
80937
|
email: emailFlag,
|
|
81214
|
-
|
|
81215
|
-
|
|
81216
|
-
|
|
81217
|
-
personal: (config) => execute$11(config, {
|
|
81218
|
-
kind: "retry",
|
|
81219
|
-
paymentId,
|
|
81220
|
-
email: Option.getOrUndefined(email),
|
|
81221
|
-
confirm,
|
|
81222
|
-
timeoutSeconds
|
|
81223
|
-
}),
|
|
81224
|
-
organization: (config, orgId) => execute$12(config, {
|
|
80938
|
+
timeoutSeconds: Flag.Int("timeout-seconds").pipe(Flag.withDescription("how long to follow it (default: until the approval lapses)"), Flag.optional)
|
|
80939
|
+
}, ({ paymentId, email, timeoutSeconds }) => {
|
|
80940
|
+
const input = {
|
|
81225
80941
|
kind: "retry",
|
|
81226
|
-
orgs: [orgId],
|
|
81227
80942
|
paymentId,
|
|
81228
80943
|
email: Option.getOrUndefined(email),
|
|
81229
|
-
|
|
81230
|
-
|
|
81231
|
-
|
|
81232
|
-
|
|
80944
|
+
timeoutSeconds: Option.getOrUndefined(timeoutSeconds)
|
|
80945
|
+
};
|
|
80946
|
+
return dispatch("retry", {
|
|
80947
|
+
personal: (config) => execute$11(config, input),
|
|
80948
|
+
organization: (config, orgId) => execute$11(config, input, orgId)
|
|
80949
|
+
});
|
|
80950
|
+
}).pipe(annotate("retry"), Command.withDescription("retry the exact Payment; you approve it in the browser"));
|
|
81233
80951
|
//#endregion
|
|
81234
80952
|
//#region src/commands/payment/command.ts
|
|
81235
80953
|
const payment = Command.make("payment").pipe(annotate("root"), Command.withDescription("send, read and follow Payments"), Command.withSubcommands([
|
|
@@ -81375,7 +81093,7 @@ const execute$8 = (config, input) => Effect.gen(function* () {
|
|
|
81375
81093
|
const command$8 = (context) => Command.make("cancel", {
|
|
81376
81094
|
email: emailFlag$3,
|
|
81377
81095
|
id: idArgument,
|
|
81378
|
-
confirm: confirmFlag$
|
|
81096
|
+
confirm: confirmFlag$2
|
|
81379
81097
|
}, ({ email, id, confirm }) => context.dispatch("cancel", (scope) => ({
|
|
81380
81098
|
kind: "cancel",
|
|
81381
81099
|
id,
|
|
@@ -81410,7 +81128,7 @@ const execute$7 = (config, input) => Effect.gen(function* () {
|
|
|
81410
81128
|
const command$7 = (context) => Command.make("decline", {
|
|
81411
81129
|
email: emailFlag$3,
|
|
81412
81130
|
id: idArgument,
|
|
81413
|
-
confirm: confirmFlag$
|
|
81131
|
+
confirm: confirmFlag$2
|
|
81414
81132
|
}, ({ email, id, confirm }) => context.dispatch("decline", (scope) => ({
|
|
81415
81133
|
kind: "decline",
|
|
81416
81134
|
id,
|
|
@@ -81529,7 +81247,7 @@ const execute$6 = (config, input) => Effect.gen(function* () {
|
|
|
81529
81247
|
const command$6 = (context) => Command.make("issue", {
|
|
81530
81248
|
email: emailFlag$3,
|
|
81531
81249
|
source: Flag.String("input"),
|
|
81532
|
-
confirm: confirmFlag$
|
|
81250
|
+
confirm: confirmFlag$2,
|
|
81533
81251
|
outputDirectory: Flag.String("output-dir").pipe(Flag.optional)
|
|
81534
81252
|
}, ({ email, source, confirm, outputDirectory }) => context.dispatch("issue", (scope) => ({
|
|
81535
81253
|
kind: "issue",
|
|
@@ -81546,38 +81264,46 @@ const command$5 = (args) => args.map(shellArgument).join(" ");
|
|
|
81546
81264
|
const execute$5 = (config, input) => Effect.gen(function* () {
|
|
81547
81265
|
const orgId = yield* readScope(input);
|
|
81548
81266
|
const id = yield* requestId(input.id);
|
|
81549
|
-
const
|
|
81267
|
+
const timeoutSeconds = input.timeoutSeconds === void 0 ? void 0 : yield* readWriteTimeout(input.timeoutSeconds);
|
|
81550
81268
|
if (input.direction !== "received") return yield* inputRequired("Use inbox pay for received Invoices.");
|
|
81551
81269
|
const permissionId = yield* readPaymentPermission(orgId, input.permissionId);
|
|
81552
|
-
const interactive = yield* requireWriteConfirmation(input.confirm);
|
|
81553
81270
|
const runtime = yield* CliRuntime;
|
|
81554
|
-
const
|
|
81555
|
-
const
|
|
81556
|
-
const
|
|
81557
|
-
const item = (yield* Effect.promise((signal) => actor.inbox.list({ signal })).pipe(Effect.flatMap(resultItems)
|
|
81271
|
+
const { client, session } = yield* restoreAuthenticatedClient(config, input.email);
|
|
81272
|
+
const actor = orgId === null ? client.account : client.org(orgId);
|
|
81273
|
+
const scoped = (work) => work.pipe(Effect.mapError((error) => orgId === null ? error : normalizeOrganizationReadFailure(error, orgId)));
|
|
81274
|
+
const item = (yield* withWaiting(scoped(Effect.promise((signal) => actor.inbox.list({ signal })).pipe(Effect.flatMap(resultItems))), {
|
|
81275
|
+
...runtime,
|
|
81276
|
+
label: "Reading the request"
|
|
81277
|
+
})).find((entry) => entry.id === id);
|
|
81558
81278
|
if (item === void 0) return yield* inputRequired("The Invoice is unavailable to this payer.");
|
|
81559
81279
|
const orgArgs = orgId === null ? [] : ["--org", orgId];
|
|
81560
|
-
const readArgs =
|
|
81280
|
+
const readArgs = [
|
|
81561
81281
|
"capxul",
|
|
81562
|
-
paymentId === void 0 ?
|
|
81563
|
-
|
|
81564
|
-
|
|
81282
|
+
...item.paymentId === void 0 ? [
|
|
81283
|
+
"inbox",
|
|
81284
|
+
"get",
|
|
81285
|
+
id
|
|
81286
|
+
] : [
|
|
81287
|
+
"payment",
|
|
81288
|
+
"get",
|
|
81289
|
+
item.paymentId
|
|
81290
|
+
],
|
|
81565
81291
|
...orgArgs,
|
|
81566
81292
|
"--email",
|
|
81567
|
-
|
|
81293
|
+
session.email
|
|
81568
81294
|
];
|
|
81569
81295
|
const resuming = input.resume === true && item.status === "approved" && item.paymentId !== void 0;
|
|
81570
81296
|
if (input.resume === true && !resuming || item.status !== "open" && !resuming) return yield* new CliFailure({
|
|
81571
81297
|
code: "WRONG_STATE",
|
|
81572
81298
|
outcome: "refused",
|
|
81573
81299
|
exitCode: 2,
|
|
81574
|
-
message: `The Invoice is ${terminalText(item.status)}. Read its current state:\n ${command$5(readArgs
|
|
81300
|
+
message: `The Invoice is ${terminalText(item.status)}. Read its current state:\n ${command$5(readArgs)}`,
|
|
81575
81301
|
details: { recovery: {
|
|
81576
81302
|
kind: "read",
|
|
81577
|
-
argv: readArgs
|
|
81303
|
+
argv: readArgs
|
|
81578
81304
|
} }
|
|
81579
81305
|
});
|
|
81580
|
-
const terms = yield* Effect.promise((signal) => actor.inbox.paymentTerms(id, { signal })).pipe(Effect.flatMap(resultValue)
|
|
81306
|
+
const terms = yield* scoped(Effect.promise((signal) => actor.inbox.paymentTerms(id, { signal })).pipe(Effect.flatMap(resultValue)));
|
|
81581
81307
|
if (terms.requestId !== id || terms.amount.asset !== item.amount.asset || terms.amount.value !== item.amount.value) return yield* inputRequired("The payment terms differ from the selected request. Read it again.");
|
|
81582
81308
|
const confirmation = {
|
|
81583
81309
|
...terms,
|
|
@@ -81589,113 +81315,35 @@ const execute$5 = (config, input) => Effect.gen(function* () {
|
|
|
81589
81315
|
permissionId
|
|
81590
81316
|
}
|
|
81591
81317
|
};
|
|
81592
|
-
|
|
81593
|
-
|
|
81594
|
-
|
|
81595
|
-
...requestLines(item, preview.session.email, orgId),
|
|
81596
|
-
`Recipient Safe: ${terminalText(terms.issuerSafe)}`,
|
|
81597
|
-
`Instruction: ${terminalText(terms.instruction.kind)}`,
|
|
81598
|
-
...permissionId === void 0 ? [] : [`Permission: ${terminalText(permissionId)}`]
|
|
81599
|
-
],
|
|
81600
|
-
question: "Pay this exact request now?"
|
|
81318
|
+
const approval = yield* withWaiting(scoped(Effect.promise((signal) => client.approvals.prepare({ request: confirmation }, { signal })).pipe(Effect.flatMap(resultValue))), {
|
|
81319
|
+
...runtime,
|
|
81320
|
+
label: "Preparing the payment"
|
|
81601
81321
|
});
|
|
81602
|
-
const
|
|
81603
|
-
|
|
81604
|
-
|
|
81605
|
-
|
|
81606
|
-
|
|
81607
|
-
const signal = yield* Effect.abortSignal;
|
|
81608
|
-
let writeLifetime;
|
|
81609
|
-
const checkActor = Effect.gen(function* () {
|
|
81610
|
-
const stopped = cancelledWrite(CAPXUL_OPERATIONS.inbox.fulfill, signal);
|
|
81611
|
-
if (stopped !== null) return yield* Effect.fail(stopped);
|
|
81612
|
-
if (!(yield* preview.stillAuthenticated) || writeLifetime !== void 0 && !(yield* writeLifetime)) return yield* Effect.fail(Errors.cancelled({ operation: CAPXUL_OPERATIONS.inbox.fulfill }));
|
|
81613
|
-
});
|
|
81614
|
-
yield* checkActor;
|
|
81615
|
-
const signer = yield* organizationWriteSigner(config, opened, run, async () => {
|
|
81616
|
-
await run(checkActor);
|
|
81617
|
-
if (writeLifetime === void 0 || preparedIds.length === 0) throw Errors.cancelled({ operation: CAPXUL_OPERATIONS.inbox.fulfill });
|
|
81618
|
-
});
|
|
81619
|
-
const write = yield* restoreWriteClient(config, opened, signer, preview.session, () => Errors.cancelled({ operation: CAPXUL_OPERATIONS.inbox.fulfill }));
|
|
81620
|
-
writeLifetime = write.stillAuthenticated;
|
|
81621
|
-
yield* checkActor;
|
|
81622
|
-
const payer = orgId === null ? write.client.account : write.client.org(orgId);
|
|
81623
|
-
return yield* Effect.promise((operationSignal) => payer.inbox.fulfill(confirmation, {
|
|
81624
|
-
signal: operationSignal,
|
|
81625
|
-
onPrepared: async ({ paymentIds }) => {
|
|
81626
|
-
if (expectedPaymentId !== void 0 && (paymentIds.length !== 1 || paymentIds[0] !== expectedPaymentId)) throw Errors.invalidInput("paymentIds", "Prepared Payment does not match the linked Invoice.");
|
|
81627
|
-
preparedIds = [...paymentIds];
|
|
81628
|
-
await run(checkActor);
|
|
81629
|
-
await run(writeStderr(runtime.mode === "json" ? `${JSON.stringify({
|
|
81630
|
-
type: "payment.prepared",
|
|
81631
|
-
paymentIds
|
|
81632
|
-
})}\n` : paymentIds.map((paymentId) => `Prepared Payment: ${terminalText(paymentId)}\n`).join("")));
|
|
81633
|
-
await run(checkActor);
|
|
81634
|
-
}
|
|
81635
|
-
})).pipe(Effect.flatMap(resultValue));
|
|
81636
|
-
}).pipe(Effect.scoped, Effect.timeoutOption(`${timeout} seconds`), Effect.catchCause((cause) => {
|
|
81637
|
-
const failure = classifyFailure(cause, orgId === null ? "inbox.pay" : "org.inbox.pay");
|
|
81638
|
-
const argv = readArgs(preparedIds[0]);
|
|
81639
|
-
return Effect.fail(new CliFailure({
|
|
81640
|
-
...failure,
|
|
81641
|
-
outcome: failure.outcome,
|
|
81642
|
-
message: `${failure.message}\nRead before another payment attempt:\n ${command$5(argv)}`,
|
|
81643
|
-
details: {
|
|
81644
|
-
...failure.details,
|
|
81645
|
-
...preparedIds.length === 0 ? {} : { paymentIds: preparedIds },
|
|
81646
|
-
recovery: {
|
|
81647
|
-
kind: "read",
|
|
81648
|
-
argv
|
|
81649
|
-
}
|
|
81650
|
-
}
|
|
81651
|
-
}));
|
|
81652
|
-
}));
|
|
81653
|
-
if (Option.isNone(result)) return yield* new CliFailure({
|
|
81654
|
-
code: "CLI_DEADLINE",
|
|
81655
|
-
outcome: "failed",
|
|
81656
|
-
exitCode: 5,
|
|
81657
|
-
message: `The CLI stopped waiting. The Payment may still settle.\n ${command$5(readArgs(preparedIds[0]))}`,
|
|
81658
|
-
details: {
|
|
81659
|
-
paymentIds: preparedIds,
|
|
81660
|
-
recovery: {
|
|
81661
|
-
kind: "read",
|
|
81662
|
-
argv: readArgs(preparedIds[0])
|
|
81663
|
-
}
|
|
81664
|
-
}
|
|
81322
|
+
const paymentIds = approval.operation.paymentIds;
|
|
81323
|
+
if (resuming && (paymentIds.length !== 1 || paymentIds[0] !== item.paymentId)) return yield* inputRequired("The prepared Payment does not match the linked Invoice.");
|
|
81324
|
+
return yield* handOver(client, approval, {
|
|
81325
|
+
organizationId: orgId ?? void 0,
|
|
81326
|
+
timeoutSeconds
|
|
81665
81327
|
});
|
|
81666
|
-
const documents = yield* Effect.forEach(result.value.payments, (payment) => savePaymentDocuments(config, preview.client, payment));
|
|
81667
|
-
const lines = ["Payment submission accepted. Read Payment state to check settlement."];
|
|
81668
|
-
for (const [index, payment] of result.value.payments.entries()) lines.push(`Payment ${terminalText(payment.id)}: ${terminalText(payment.status)}`, ` ${command$5(readArgs(payment.id))}`, ...documentOutputLines(documents[index]));
|
|
81669
|
-
return {
|
|
81670
|
-
data: {
|
|
81671
|
-
scope: scopeValue(orgId),
|
|
81672
|
-
requestId: id,
|
|
81673
|
-
submission: result.value,
|
|
81674
|
-
documents
|
|
81675
|
-
},
|
|
81676
|
-
lines
|
|
81677
|
-
};
|
|
81678
81328
|
});
|
|
81679
81329
|
//#endregion
|
|
81680
81330
|
//#region src/commands/request/subcommands/pay/command.ts
|
|
81681
81331
|
const command$4 = (context) => Command.make("pay", {
|
|
81682
81332
|
email: emailFlag$3,
|
|
81683
81333
|
id: idArgument,
|
|
81684
|
-
confirm: confirmFlag$3,
|
|
81685
81334
|
permissionId: Flag.String("permission-id").pipe(Flag.withDescription("The Permission an Organization pays under"), Flag.optional),
|
|
81686
|
-
timeoutSeconds: Flag.Int("timeout-seconds").pipe(Flag.
|
|
81687
|
-
resume: Flag.Boolean("resume").pipe(Flag.withDefault(false))
|
|
81688
|
-
}, ({ email, id,
|
|
81335
|
+
timeoutSeconds: Flag.Int("timeout-seconds").pipe(Flag.withDescription("how long to follow it (default: until the approval lapses)"), Flag.optional),
|
|
81336
|
+
resume: Flag.Boolean("resume").pipe(Flag.withDescription("open the approval again for a request whose Payment is prepared"), Flag.withDefault(false))
|
|
81337
|
+
}, ({ email, id, permissionId, timeoutSeconds, resume }) => context.dispatch("pay", (scope) => ({
|
|
81689
81338
|
kind: "pay",
|
|
81690
81339
|
...scope,
|
|
81691
81340
|
direction: context.direction,
|
|
81692
81341
|
id,
|
|
81693
|
-
|
|
81694
|
-
timeoutSeconds,
|
|
81342
|
+
timeoutSeconds: Option.getOrUndefined(timeoutSeconds),
|
|
81695
81343
|
resume,
|
|
81696
81344
|
email: Option.getOrUndefined(email),
|
|
81697
81345
|
permissionId: Option.getOrUndefined(permissionId)
|
|
81698
|
-
}), execute$5)).pipe(context.annotate("pay"), Command.withDescription("
|
|
81346
|
+
}), execute$5)).pipe(context.annotate("pay"), Command.withDescription("pay a received request; you approve it in the browser"));
|
|
81699
81347
|
//#endregion
|
|
81700
81348
|
//#region src/commands/request/command.ts
|
|
81701
81349
|
const issued = makeContext("issued");
|
|
@@ -81714,7 +81362,7 @@ const inbox = Command.make("inbox").pipe(received.annotate("root"), Command.with
|
|
|
81714
81362
|
]));
|
|
81715
81363
|
//#endregion
|
|
81716
81364
|
//#region src/commands/schema/internal/contract.ts
|
|
81717
|
-
/** Commands that move money. Each one hands over to the approval page
|
|
81365
|
+
/** Commands that move money. Each one hands over to the approval page. */
|
|
81718
81366
|
const MONEY = /* @__PURE__ */ new Set([
|
|
81719
81367
|
"payment.send",
|
|
81720
81368
|
"payment.retry",
|
|
@@ -81731,17 +81379,21 @@ const LOCAL = /* @__PURE__ */ new Set([
|
|
|
81731
81379
|
"config.telemetry.status",
|
|
81732
81380
|
"schema"
|
|
81733
81381
|
]);
|
|
81382
|
+
/** A money command's `data`: the approval link for an agent, the outcome for a person. */
|
|
81383
|
+
const APPROVAL = "--json: { status: 'awaiting_approval', approvalId, approvalUrl, paymentIds, expiresAt, next: { argv } }; a person: ApprovalOutcome { approval, payments }";
|
|
81734
81384
|
/** `data` of the commands an agent reaches for most; other lists are pages, others the SDK value. */
|
|
81735
81385
|
const OUTPUT = {
|
|
81736
81386
|
home: "{ where, signedIn, balances: Account | null, needsYou: NeedsYou[] | null, try }",
|
|
81737
81387
|
whoami: "Where: { user, actingAs, safe, env }",
|
|
81738
81388
|
balance: "Account: { id, balances: AccountPosition[], balance, available }",
|
|
81739
81389
|
address: "DepositInstructions",
|
|
81740
|
-
"payment.send":
|
|
81390
|
+
"payment.send": APPROVAL,
|
|
81741
81391
|
"payment.wait": "Payment, or for an approval ID: ApprovalOutcome { approval, payments }",
|
|
81742
81392
|
"payment.get": "Payment",
|
|
81743
81393
|
"payment.list": "Page<Payment>: { items, nextCursor }",
|
|
81744
|
-
"payment.retry":
|
|
81394
|
+
"payment.retry": APPROVAL,
|
|
81395
|
+
"inbox.pay": APPROVAL,
|
|
81396
|
+
"org.payroll.run": APPROVAL,
|
|
81745
81397
|
[CAPXUL_OPERATIONS.inbox.list]: "Page<InboxItem>",
|
|
81746
81398
|
"inbox.get": "InboxItem",
|
|
81747
81399
|
"request.list": "Page<ActorRequest>",
|
|
@@ -82836,4 +82488,4 @@ const runCli = (platform) => Effect.uninterruptibleMask((restore) => Effect.gen(
|
|
|
82836
82488
|
//#endregion
|
|
82837
82489
|
export { runCli };
|
|
82838
82490
|
|
|
82839
|
-
//# sourceMappingURL=entry-
|
|
82491
|
+
//# sourceMappingURL=entry-GLdITgH4.mjs.map
|