@carrot-foundation/schemas 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +34 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -44
- package/dist/index.d.ts +46 -44
- package/dist/index.js +34 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/ipfs/collection/collection.example.json +3 -3
- package/schemas/ipfs/collection/collection.schema.json +2 -2
- package/schemas/ipfs/credit/credit.example.json +3 -3
- package/schemas/ipfs/credit/credit.schema.json +2 -2
- package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.example.json +4 -4
- package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.schema.json +11 -16
- package/schemas/ipfs/credit-retirement-receipt/credit-retirement-receipt.example.json +4 -4
- package/schemas/ipfs/credit-retirement-receipt/credit-retirement-receipt.schema.json +72 -83
- package/schemas/ipfs/gas-id/gas-id.example.json +4 -4
- package/schemas/ipfs/gas-id/gas-id.schema.json +5 -5
- package/schemas/ipfs/mass-id/mass-id.example.json +4 -4
- package/schemas/ipfs/mass-id/mass-id.schema.json +10 -10
- package/schemas/ipfs/mass-id-audit/mass-id-audit.example.json +3 -3
- package/schemas/ipfs/mass-id-audit/mass-id-audit.schema.json +2 -2
- package/schemas/ipfs/methodology/methodology.example.json +3 -3
- package/schemas/ipfs/methodology/methodology.schema.json +2 -2
- package/schemas/ipfs/recycled-id/recycled-id.example.json +4 -4
- package/schemas/ipfs/recycled-id/recycled-id.schema.json +6 -6
- package/schemas/schema-hashes.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -42,9 +42,14 @@ var NonNegativeFloatSchema = zod.z.number().min(0).meta({
|
|
|
42
42
|
description: "Floating-point number that is zero or positive",
|
|
43
43
|
examples: [0, 45.2, 72.5]
|
|
44
44
|
});
|
|
45
|
-
var
|
|
45
|
+
var PositiveFloatSchema = zod.z.number().gt(0).meta({
|
|
46
|
+
title: "Positive Float",
|
|
47
|
+
description: "Floating-point number greater than zero",
|
|
48
|
+
examples: [0.1, 45.2, 72.5]
|
|
49
|
+
});
|
|
50
|
+
var WeightKgSchema = PositiveFloatSchema.meta({
|
|
46
51
|
title: "Weight",
|
|
47
|
-
description: "Weight measurement in kilograms (kg)",
|
|
52
|
+
description: "Weight measurement in kilograms (kg), must be greater than zero",
|
|
48
53
|
examples: [500.35, 3e3]
|
|
49
54
|
});
|
|
50
55
|
var PercentageSchema = NonNegativeFloatSchema.max(100).meta({
|
|
@@ -29410,22 +29415,27 @@ var CreditRetirementReceiptSummarySchema = SummaryBaseSchema.safeExtend({
|
|
|
29410
29415
|
description: "Summary totals for the credit retirement including credit quantity, certificate count, and timestamp"
|
|
29411
29416
|
});
|
|
29412
29417
|
var ReceiptIdentitySchema = zod.z.strictObject({
|
|
29413
|
-
name: NonEmptyStringSchema.max(100).meta({
|
|
29418
|
+
name: NonEmptyStringSchema.max(100).optional().meta({
|
|
29414
29419
|
title: "Identity Name",
|
|
29415
29420
|
description: "Display name of the buyer or beneficiary on the receipt",
|
|
29416
29421
|
examples: ["EcoTech Solutions Inc.", "Climate Action Corp"]
|
|
29417
29422
|
}),
|
|
29418
|
-
external_id: ExternalIdSchema.meta({
|
|
29423
|
+
external_id: ExternalIdSchema.optional().meta({
|
|
29419
29424
|
title: "Identity External ID",
|
|
29420
29425
|
description: "Unique identifier for the buyer or beneficiary in the Carrot platform"
|
|
29421
29426
|
}),
|
|
29422
|
-
external_url: ExternalUrlSchema.meta({
|
|
29427
|
+
external_url: ExternalUrlSchema.optional().meta({
|
|
29423
29428
|
title: "Identity External URL",
|
|
29424
29429
|
description: "Link to the buyer or beneficiary profile page on the Carrot platform"
|
|
29425
29430
|
})
|
|
29426
|
-
}).
|
|
29431
|
+
}).refine(
|
|
29432
|
+
(value) => value.name !== void 0 || value.external_id !== void 0 || value.external_url !== void 0,
|
|
29433
|
+
{
|
|
29434
|
+
message: "identity must include at least one of: name, external_id, external_url"
|
|
29435
|
+
}
|
|
29436
|
+
).meta({
|
|
29427
29437
|
title: "Identity",
|
|
29428
|
-
description: "Identity information for the buyer or beneficiary associated with this receipt"
|
|
29438
|
+
description: "Identity information for the buyer or beneficiary associated with this receipt. All fields are optional, but at least one must be provided when the identity block is present."
|
|
29429
29439
|
});
|
|
29430
29440
|
function createReceiptCollectionSchema(params) {
|
|
29431
29441
|
const { meta } = params;
|
|
@@ -29481,7 +29491,7 @@ function buildSchemaUrl(schemaPath) {
|
|
|
29481
29491
|
return `${getSchemaBaseUrl()}/${cleanPath}`;
|
|
29482
29492
|
}
|
|
29483
29493
|
function getSchemaVersionOrDefault() {
|
|
29484
|
-
return "0.
|
|
29494
|
+
return "0.5.0";
|
|
29485
29495
|
}
|
|
29486
29496
|
|
|
29487
29497
|
// src/shared/schema-validation.ts
|
|
@@ -31474,11 +31484,11 @@ var CreditRetirementReceiptPurchaseReceiptAttributeSchema = NftAttributeSchema.s
|
|
|
31474
31484
|
});
|
|
31475
31485
|
var REQUIRED_CREDIT_RETIREMENT_RECEIPT_ATTRIBUTES = [
|
|
31476
31486
|
CreditRetirementReceiptTotalCreditsAttributeSchema,
|
|
31477
|
-
CreditRetirementReceiptBeneficiaryAttributeSchema,
|
|
31478
31487
|
CreditRetirementReceiptRetirementDateAttributeSchema,
|
|
31479
31488
|
CreditRetirementReceiptCertificatesAttributeSchema
|
|
31480
31489
|
];
|
|
31481
31490
|
var CONDITIONAL_CREDIT_RETIREMENT_RECEIPT_ATTRIBUTES = [
|
|
31491
|
+
CreditRetirementReceiptBeneficiaryAttributeSchema,
|
|
31482
31492
|
CreditRetirementReceiptCreditHolderAttributeSchema,
|
|
31483
31493
|
CreditRetirementReceiptPurchaseDateAttributeSchema,
|
|
31484
31494
|
CreditRetirementReceiptPurchaseReceiptAttributeSchema
|
|
@@ -31493,11 +31503,10 @@ var CreditRetirementReceiptAttributesSchema = createOrderedAttributesSchema({
|
|
|
31493
31503
|
...DYNAMIC_CREDIT_RETIREMENT_RECEIPT_ATTRIBUTES
|
|
31494
31504
|
],
|
|
31495
31505
|
title: "Credit Retirement Receipt NFT Attribute Array",
|
|
31496
|
-
description: "Attributes for credit retirement receipts including per-credit breakdowns, totals, beneficiary, credit holder, retirement date, certificate count, and optional purchase info. Fixed required attributes: Total Credits Retired,
|
|
31506
|
+
description: "Attributes for credit retirement receipts including per-credit breakdowns, totals, beneficiary, credit holder, retirement date, certificate count, and optional purchase info. Fixed required attributes: Total Credits Retired, Retirement Date, Certificates Retired. Conditional attributes: Beneficiary (required when beneficiary.identity.name is provided), Credit Holder (required when credit_holder.identity.name is provided), Purchase Date (optional, when purchase_receipt is present), Purchase Receipt (optional, when purchase_receipt is present). Dynamic attributes: Credit attributes (one per credit symbol in data.credits).",
|
|
31497
31507
|
uniqueBySelector: (attribute) => attribute.trait_type,
|
|
31498
31508
|
requiredTraitTypes: [
|
|
31499
31509
|
"Total Credits Retired",
|
|
31500
|
-
"Beneficiary",
|
|
31501
31510
|
"Retirement Date",
|
|
31502
31511
|
"Certificates Retired"
|
|
31503
31512
|
]
|
|
@@ -31508,7 +31517,7 @@ var CreditRetirementReceiptBeneficiarySchema = zod.z.strictObject({
|
|
|
31508
31517
|
title: "Retirement Beneficiary ID",
|
|
31509
31518
|
description: "UUID identifying the beneficiary of the retirement (bytes16 normalized to UUID)"
|
|
31510
31519
|
}),
|
|
31511
|
-
identity: CreditRetirementReceiptIdentitySchema
|
|
31520
|
+
identity: CreditRetirementReceiptIdentitySchema.optional()
|
|
31512
31521
|
}).meta({
|
|
31513
31522
|
title: "Beneficiary",
|
|
31514
31523
|
description: "Beneficiary receiving the retirement benefit"
|
|
@@ -31728,7 +31737,7 @@ var CreditRetirementReceiptDataSchema = zod.z.strictObject({
|
|
|
31728
31737
|
});
|
|
31729
31738
|
var CreditRetirementReceiptIpfsSchemaMeta = {
|
|
31730
31739
|
title: "CreditRetirementReceipt NFT IPFS Record",
|
|
31731
|
-
description: "Complete CreditRetirementReceipt NFT IPFS record including retirement summary, beneficiary and credit holder details, credit breakdowns, certificate allocations, and NFT display attributes",
|
|
31740
|
+
description: "Complete CreditRetirementReceipt NFT IPFS record including retirement summary, beneficiary and credit holder details (identity optional), credit breakdowns, certificate allocations, and NFT display attributes",
|
|
31732
31741
|
$id: buildSchemaUrl(
|
|
31733
31742
|
"credit-retirement-receipt/credit-retirement-receipt.schema.json"
|
|
31734
31743
|
),
|
|
@@ -31798,14 +31807,17 @@ var CreditRetirementReceiptIpfsSchema = NftIpfsSchema.safeExtend({
|
|
|
31798
31807
|
missingMessage: 'Attribute "Certificates Retired" is required',
|
|
31799
31808
|
mismatchMessage: 'Attribute "Certificates Retired" must match data.summary.total_certificates'
|
|
31800
31809
|
});
|
|
31801
|
-
|
|
31802
|
-
|
|
31803
|
-
|
|
31804
|
-
|
|
31805
|
-
|
|
31806
|
-
|
|
31807
|
-
|
|
31808
|
-
|
|
31810
|
+
const beneficiaryName = data.beneficiary.identity?.name;
|
|
31811
|
+
if (beneficiaryName) {
|
|
31812
|
+
validateAttributeValue({
|
|
31813
|
+
ctx,
|
|
31814
|
+
attributeByTraitType,
|
|
31815
|
+
traitType: "Beneficiary",
|
|
31816
|
+
expectedValue: String(beneficiaryName),
|
|
31817
|
+
missingMessage: 'Attribute "Beneficiary" is required when beneficiary.identity.name is provided',
|
|
31818
|
+
mismatchMessage: 'Attribute "Beneficiary" must match beneficiary.identity.name'
|
|
31819
|
+
});
|
|
31820
|
+
}
|
|
31809
31821
|
const creditHolderName = data.credit_holder.identity?.name;
|
|
31810
31822
|
if (creditHolderName) {
|
|
31811
31823
|
validateAttributeValue({
|
|
@@ -32198,6 +32210,7 @@ exports.ParticipantIdHashSchema = ParticipantIdHashSchema;
|
|
|
32198
32210
|
exports.ParticipantRoleSchema = ParticipantRoleSchema;
|
|
32199
32211
|
exports.ParticipantSchema = ParticipantSchema;
|
|
32200
32212
|
exports.PercentageSchema = PercentageSchema;
|
|
32213
|
+
exports.PositiveFloatSchema = PositiveFloatSchema;
|
|
32201
32214
|
exports.PositiveIntegerSchema = PositiveIntegerSchema;
|
|
32202
32215
|
exports.ReceiptIdentitySchema = ReceiptIdentitySchema;
|
|
32203
32216
|
exports.RecordEnvironmentSchema = RecordEnvironmentSchema;
|