@goodpeanuts/dsh-sui 0.1.2-fix.2 → 0.1.2-fix.3
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/apps/cli/dist/packages/finance/src/transactions/contracts.mjs +3 -2
- package/apps/cli/dist/packages/finance/src/transactions/mutation.mjs +1 -1
- package/bundles/sui-ledger/dist/client.js +11 -7
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/contracts.mjs +3 -2
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/mutation.mjs +1 -1
- package/bundles/sui-ledger/dist/packages/finance-module/src/capabilities.mjs +5 -17
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ const explicitOffsetDateTime = string().min(1).refine((value) => {
|
|
|
6
6
|
return !Number.isNaN(Date.parse(value));
|
|
7
7
|
}, "occurredAt must be a valid date-time with an explicit timezone offset").refine(isSecondPrecisionInstant, "occurredAt must have whole-second precision; nonzero fractional seconds cannot be sent");
|
|
8
8
|
const remoteId = string().trim().min(1).max(128);
|
|
9
|
+
const amountCents = number().int().nonnegative().safe();
|
|
9
10
|
const createTransactionInputSchema = object({
|
|
10
11
|
occurredAt: explicitOffsetDateTime,
|
|
11
12
|
type: _enum([
|
|
@@ -13,7 +14,7 @@ const createTransactionInputSchema = object({
|
|
|
13
14
|
"income",
|
|
14
15
|
"transfer"
|
|
15
16
|
]),
|
|
16
|
-
amountCents
|
|
17
|
+
amountCents,
|
|
17
18
|
secondaryAmountCents: number().int().positive().safe().optional(),
|
|
18
19
|
accountId: remoteId,
|
|
19
20
|
destinationAccountId: remoteId.optional(),
|
|
@@ -64,7 +65,7 @@ const updateTransactionPatchSchema = object({
|
|
|
64
65
|
"income",
|
|
65
66
|
"transfer"
|
|
66
67
|
]).optional(),
|
|
67
|
-
amountCents:
|
|
68
|
+
amountCents: amountCents.optional(),
|
|
68
69
|
secondaryAmountCents: number().int().positive().safe().nullable().optional(),
|
|
69
70
|
accountId: remoteId.optional(),
|
|
70
71
|
destinationAccountId: remoteId.nullable().optional(),
|
|
@@ -554,7 +554,7 @@ function validateTransactionMetadata(input, metadata) {
|
|
|
554
554
|
if (input.projectId) requireRemoteId(metadata.projects, input.projectId, "projectId");
|
|
555
555
|
if (input.memberId) requireRemoteId(metadata.members, input.memberId, "memberId");
|
|
556
556
|
if (input.storeId) requireRemoteId(metadata.stores, input.storeId, "storeId");
|
|
557
|
-
if (!Number.isSafeInteger(input.amountCents) || input.amountCents
|
|
557
|
+
if (!Number.isSafeInteger(input.amountCents) || input.amountCents < 0) throw new FeideeError("amountCents must be a non-negative safe integer", "INVALID_ARGUMENT");
|
|
558
558
|
if (input.secondaryAmountCents !== void 0 && (!Number.isSafeInteger(input.secondaryAmountCents) || input.secondaryAmountCents <= 0)) throw new FeideeError("secondaryAmountCents must be a positive safe integer", "INVALID_ARGUMENT");
|
|
559
559
|
if (Number.isNaN(Date.parse(input.occurredAt))) throw new FeideeError("occurredAt is invalid", "INVALID_ARGUMENT");
|
|
560
560
|
}
|
|
@@ -6549,7 +6549,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6549
6549
|
}));
|
|
6550
6550
|
//#endregion
|
|
6551
6551
|
//#region ../../packages/finance/src/transactions/canary.ts
|
|
6552
|
-
var init_canary = __esmMin((() => {})), explicitOffsetDateTime, remoteId, writeFieldsSchema, updateTransactionPatchSchema;
|
|
6552
|
+
var init_canary = __esmMin((() => {})), explicitOffsetDateTime, remoteId, amountCents, writeFieldsSchema, updateTransactionPatchSchema;
|
|
6553
6553
|
var init_contracts = __esmMin((() => {
|
|
6554
6554
|
init_zod();
|
|
6555
6555
|
init_date_range();
|
|
@@ -6558,6 +6558,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6558
6558
|
return !Number.isNaN(Date.parse(value));
|
|
6559
6559
|
}, "occurredAt must be a valid date-time with an explicit timezone offset").refine(isSecondPrecisionInstant, "occurredAt must have whole-second precision; nonzero fractional seconds cannot be sent");
|
|
6560
6560
|
remoteId = string$1().trim().min(1).max(128);
|
|
6561
|
+
amountCents = number().int().nonnegative().safe();
|
|
6561
6562
|
writeFieldsSchema = object$1({
|
|
6562
6563
|
occurredAt: explicitOffsetDateTime,
|
|
6563
6564
|
type: _enum([
|
|
@@ -6565,7 +6566,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6565
6566
|
"income",
|
|
6566
6567
|
"transfer"
|
|
6567
6568
|
]),
|
|
6568
|
-
amountCents
|
|
6569
|
+
amountCents,
|
|
6569
6570
|
secondaryAmountCents: number().int().positive().safe().optional(),
|
|
6570
6571
|
accountId: remoteId,
|
|
6571
6572
|
destinationAccountId: remoteId.optional(),
|
|
@@ -6617,7 +6618,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6617
6618
|
"income",
|
|
6618
6619
|
"transfer"
|
|
6619
6620
|
]).optional(),
|
|
6620
|
-
amountCents:
|
|
6621
|
+
amountCents: amountCents.optional(),
|
|
6621
6622
|
secondaryAmountCents: number().int().positive().safe().nullable().optional(),
|
|
6622
6623
|
accountId: remoteId.optional(),
|
|
6623
6624
|
destinationAccountId: remoteId.nullable().optional(),
|
|
@@ -10217,7 +10218,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
10217
10218
|
}
|
|
10218
10219
|
function draftEditorIssues(value, references) {
|
|
10219
10220
|
return [
|
|
10220
|
-
...value.amount.trim() && (!Number.isFinite(Number(value.amount)) || Number(value.amount)
|
|
10221
|
+
...value.amount.trim() && (!Number.isFinite(Number(value.amount)) || Number(value.amount) < 0) ? ["请输入有效的非负金额。"] : [],
|
|
10221
10222
|
...value.secondaryAmount.trim() && (!Number.isFinite(Number(value.secondaryAmount)) || Number(value.secondaryAmount) <= 0) ? ["转入金额:请输入大于 0 的数字。"] : [],
|
|
10222
10223
|
...value.occurredAt && !editableTransactionTimeValid(value.occurredAt) ? ["时间:请输入有效的北京时间,精确到秒。"] : [],
|
|
10223
10224
|
...value.type === "transfer" && value.destinationAccountId && value.destinationAccountId === value.accountId ? ["转入账户:不能与转出账户相同。"] : [],
|
|
@@ -14230,9 +14231,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14230
14231
|
destinationAccountId: ""
|
|
14231
14232
|
};
|
|
14232
14233
|
}
|
|
14234
|
+
function editableAmountValid(input) {
|
|
14235
|
+
const amount = Number(input);
|
|
14236
|
+
return input.trim() !== "" && Number.isFinite(amount) && amount >= 0;
|
|
14237
|
+
}
|
|
14233
14238
|
function ProposalFeedback({ draft, categoryValid }) {
|
|
14234
14239
|
const issues = [
|
|
14235
|
-
...!
|
|
14240
|
+
...!editableAmountValid(draft.amount) ? ["请输入有效的非负金额。"] : [],
|
|
14236
14241
|
...!draft.occurredAt ? ["时间:请选择流水发生时间。"] : !editableTransactionTimeValid(draft.occurredAt) ? ["时间:请输入有效的北京时间,精确到秒,不含非零小数秒。"] : [],
|
|
14237
14242
|
...!draft.accountId.trim() ? ["账户:请选择收支账户。"] : [],
|
|
14238
14243
|
...draft.type === "transfer" && !draft.destinationAccountId.trim() ? ["转入账户:请选择收款账户。"] : [],
|
|
@@ -14246,8 +14251,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14246
14251
|
}) : null;
|
|
14247
14252
|
}
|
|
14248
14253
|
function editableProposalValid(draft) {
|
|
14249
|
-
|
|
14250
|
-
if (!editableTransactionTimeValid(draft.occurredAt) || !Number.isFinite(amount) || amount <= 0 || !draft.accountId.trim()) return false;
|
|
14254
|
+
if (!editableTransactionTimeValid(draft.occurredAt) || !editableAmountValid(draft.amount) || !draft.accountId.trim()) return false;
|
|
14251
14255
|
return draft.type === "transfer" ? Boolean(draft.destinationAccountId.trim() && draft.destinationAccountId !== draft.accountId) : Boolean(draft.categoryId.trim());
|
|
14252
14256
|
}
|
|
14253
14257
|
function isWorksetEnvelope(value) {
|
|
@@ -6,6 +6,7 @@ const explicitOffsetDateTime = string().min(1).refine((value) => {
|
|
|
6
6
|
return !Number.isNaN(Date.parse(value));
|
|
7
7
|
}, "occurredAt must be a valid date-time with an explicit timezone offset").refine(isSecondPrecisionInstant, "occurredAt must have whole-second precision; nonzero fractional seconds cannot be sent");
|
|
8
8
|
const remoteId = string().trim().min(1).max(128);
|
|
9
|
+
const amountCents = number().int().nonnegative().safe();
|
|
9
10
|
const createTransactionInputSchema = object({
|
|
10
11
|
occurredAt: explicitOffsetDateTime,
|
|
11
12
|
type: _enum([
|
|
@@ -13,7 +14,7 @@ const createTransactionInputSchema = object({
|
|
|
13
14
|
"income",
|
|
14
15
|
"transfer"
|
|
15
16
|
]),
|
|
16
|
-
amountCents
|
|
17
|
+
amountCents,
|
|
17
18
|
secondaryAmountCents: number().int().positive().safe().optional(),
|
|
18
19
|
accountId: remoteId,
|
|
19
20
|
destinationAccountId: remoteId.optional(),
|
|
@@ -64,7 +65,7 @@ const updateTransactionPatchSchema = object({
|
|
|
64
65
|
"income",
|
|
65
66
|
"transfer"
|
|
66
67
|
]).optional(),
|
|
67
|
-
amountCents:
|
|
68
|
+
amountCents: amountCents.optional(),
|
|
68
69
|
secondaryAmountCents: number().int().positive().safe().nullable().optional(),
|
|
69
70
|
accountId: remoteId.optional(),
|
|
70
71
|
destinationAccountId: remoteId.nullable().optional(),
|
|
@@ -554,7 +554,7 @@ function validateTransactionMetadata(input, metadata) {
|
|
|
554
554
|
if (input.projectId) requireRemoteId(metadata.projects, input.projectId, "projectId");
|
|
555
555
|
if (input.memberId) requireRemoteId(metadata.members, input.memberId, "memberId");
|
|
556
556
|
if (input.storeId) requireRemoteId(metadata.stores, input.storeId, "storeId");
|
|
557
|
-
if (!Number.isSafeInteger(input.amountCents) || input.amountCents
|
|
557
|
+
if (!Number.isSafeInteger(input.amountCents) || input.amountCents < 0) throw new FeideeError("amountCents must be a non-negative safe integer", "INVALID_ARGUMENT");
|
|
558
558
|
if (input.secondaryAmountCents !== void 0 && (!Number.isSafeInteger(input.secondaryAmountCents) || input.secondaryAmountCents <= 0)) throw new FeideeError("secondaryAmountCents must be a positive safe integer", "INVALID_ARGUMENT");
|
|
559
559
|
if (Number.isNaN(Date.parse(input.occurredAt))) throw new FeideeError("occurredAt is invalid", "INVALID_ARGUMENT");
|
|
560
560
|
}
|
|
@@ -711,7 +711,7 @@ function createFinanceTools(service, ledger, options = {}) {
|
|
|
711
711
|
endDate: dateSchema,
|
|
712
712
|
amountCents: {
|
|
713
713
|
type: "integer",
|
|
714
|
-
minimum:
|
|
714
|
+
minimum: 0
|
|
715
715
|
},
|
|
716
716
|
text: boundedTextSchema(2e3),
|
|
717
717
|
offset: {
|
|
@@ -1181,10 +1181,6 @@ const draftRevisionSetSchema = objectSchema([], {
|
|
|
1181
1181
|
"income",
|
|
1182
1182
|
"transfer"
|
|
1183
1183
|
] },
|
|
1184
|
-
amountCents: {
|
|
1185
|
-
type: "integer",
|
|
1186
|
-
minimum: 1
|
|
1187
|
-
},
|
|
1188
1184
|
currency: boundedTextSchema(16),
|
|
1189
1185
|
accountId: idSchema,
|
|
1190
1186
|
destinationAccountId: idSchema,
|
|
@@ -1229,7 +1225,7 @@ const financialDraftFieldsSchema = objectSchema([], Object.fromEntries(Object.en
|
|
|
1229
1225
|
type: "integer",
|
|
1230
1226
|
minimum: 0,
|
|
1231
1227
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
1232
|
-
description: "金额单位为分(整数),不是元;人民币 3.00 元 → 300,0.03 元 → 3。来源为元时用十进制运算统一换算,不按金额大小自动纠正。"
|
|
1228
|
+
description: "金额单位为分(整数),不是元;人民币 0 元 → 0,3.00 元 → 300,0.03 元 → 3。来源为元时用十进制运算统一换算,不按金额大小自动纠正。"
|
|
1233
1229
|
},
|
|
1234
1230
|
secondaryAmountCents: {
|
|
1235
1231
|
type: "integer",
|
|
@@ -1252,7 +1248,6 @@ const financialDraftFieldsSchema = objectSchema([], Object.fromEntries(Object.en
|
|
|
1252
1248
|
anyOf: [valueSchema, { type: "null" }]
|
|
1253
1249
|
}];
|
|
1254
1250
|
})));
|
|
1255
|
-
const positiveDraftAmountConstraint = { properties: { amountCents: { minimum: 1 } } };
|
|
1256
1251
|
const financialDraftSchema = {
|
|
1257
1252
|
...objectSchema(["operation"], {
|
|
1258
1253
|
operation: financialDraftOperationSchema,
|
|
@@ -1265,25 +1260,18 @@ const financialDraftSchema = {
|
|
|
1265
1260
|
oneOf: [
|
|
1266
1261
|
{ properties: {
|
|
1267
1262
|
operation: { const: "create" },
|
|
1268
|
-
remoteId: false
|
|
1269
|
-
fields: positiveDraftAmountConstraint
|
|
1263
|
+
remoteId: false
|
|
1270
1264
|
} },
|
|
1271
1265
|
{
|
|
1272
1266
|
required: ["remoteId", "fields"],
|
|
1273
1267
|
properties: {
|
|
1274
1268
|
operation: { const: "update" },
|
|
1275
|
-
fields: {
|
|
1276
|
-
...positiveDraftAmountConstraint,
|
|
1277
|
-
minProperties: 1
|
|
1278
|
-
}
|
|
1269
|
+
fields: { minProperties: 1 }
|
|
1279
1270
|
}
|
|
1280
1271
|
},
|
|
1281
1272
|
{
|
|
1282
1273
|
required: ["remoteId"],
|
|
1283
|
-
properties: {
|
|
1284
|
-
operation: { enum: ["delete", "matched"] },
|
|
1285
|
-
fields: positiveDraftAmountConstraint
|
|
1286
|
-
}
|
|
1274
|
+
properties: { operation: { enum: ["delete", "matched"] } }
|
|
1287
1275
|
}
|
|
1288
1276
|
]
|
|
1289
1277
|
};
|