@carrot-foundation/schemas 0.4.2 → 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 +26 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -43
- package/dist/index.d.ts +43 -43
- package/dist/index.js +26 -19
- 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 +2 -2
- package/schemas/ipfs/mass-id/mass-id.example.json +4 -4
- package/schemas/ipfs/mass-id/mass-id.schema.json +2 -2
- 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 +2 -2
- package/schemas/schema-hashes.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -29415,22 +29415,27 @@ var CreditRetirementReceiptSummarySchema = SummaryBaseSchema.safeExtend({
|
|
|
29415
29415
|
description: "Summary totals for the credit retirement including credit quantity, certificate count, and timestamp"
|
|
29416
29416
|
});
|
|
29417
29417
|
var ReceiptIdentitySchema = zod.z.strictObject({
|
|
29418
|
-
name: NonEmptyStringSchema.max(100).meta({
|
|
29418
|
+
name: NonEmptyStringSchema.max(100).optional().meta({
|
|
29419
29419
|
title: "Identity Name",
|
|
29420
29420
|
description: "Display name of the buyer or beneficiary on the receipt",
|
|
29421
29421
|
examples: ["EcoTech Solutions Inc.", "Climate Action Corp"]
|
|
29422
29422
|
}),
|
|
29423
|
-
external_id: ExternalIdSchema.meta({
|
|
29423
|
+
external_id: ExternalIdSchema.optional().meta({
|
|
29424
29424
|
title: "Identity External ID",
|
|
29425
29425
|
description: "Unique identifier for the buyer or beneficiary in the Carrot platform"
|
|
29426
29426
|
}),
|
|
29427
|
-
external_url: ExternalUrlSchema.meta({
|
|
29427
|
+
external_url: ExternalUrlSchema.optional().meta({
|
|
29428
29428
|
title: "Identity External URL",
|
|
29429
29429
|
description: "Link to the buyer or beneficiary profile page on the Carrot platform"
|
|
29430
29430
|
})
|
|
29431
|
-
}).
|
|
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({
|
|
29432
29437
|
title: "Identity",
|
|
29433
|
-
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."
|
|
29434
29439
|
});
|
|
29435
29440
|
function createReceiptCollectionSchema(params) {
|
|
29436
29441
|
const { meta } = params;
|
|
@@ -29486,7 +29491,7 @@ function buildSchemaUrl(schemaPath) {
|
|
|
29486
29491
|
return `${getSchemaBaseUrl()}/${cleanPath}`;
|
|
29487
29492
|
}
|
|
29488
29493
|
function getSchemaVersionOrDefault() {
|
|
29489
|
-
return "0.
|
|
29494
|
+
return "0.5.0";
|
|
29490
29495
|
}
|
|
29491
29496
|
|
|
29492
29497
|
// src/shared/schema-validation.ts
|
|
@@ -31479,11 +31484,11 @@ var CreditRetirementReceiptPurchaseReceiptAttributeSchema = NftAttributeSchema.s
|
|
|
31479
31484
|
});
|
|
31480
31485
|
var REQUIRED_CREDIT_RETIREMENT_RECEIPT_ATTRIBUTES = [
|
|
31481
31486
|
CreditRetirementReceiptTotalCreditsAttributeSchema,
|
|
31482
|
-
CreditRetirementReceiptBeneficiaryAttributeSchema,
|
|
31483
31487
|
CreditRetirementReceiptRetirementDateAttributeSchema,
|
|
31484
31488
|
CreditRetirementReceiptCertificatesAttributeSchema
|
|
31485
31489
|
];
|
|
31486
31490
|
var CONDITIONAL_CREDIT_RETIREMENT_RECEIPT_ATTRIBUTES = [
|
|
31491
|
+
CreditRetirementReceiptBeneficiaryAttributeSchema,
|
|
31487
31492
|
CreditRetirementReceiptCreditHolderAttributeSchema,
|
|
31488
31493
|
CreditRetirementReceiptPurchaseDateAttributeSchema,
|
|
31489
31494
|
CreditRetirementReceiptPurchaseReceiptAttributeSchema
|
|
@@ -31498,11 +31503,10 @@ var CreditRetirementReceiptAttributesSchema = createOrderedAttributesSchema({
|
|
|
31498
31503
|
...DYNAMIC_CREDIT_RETIREMENT_RECEIPT_ATTRIBUTES
|
|
31499
31504
|
],
|
|
31500
31505
|
title: "Credit Retirement Receipt NFT Attribute Array",
|
|
31501
|
-
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).",
|
|
31502
31507
|
uniqueBySelector: (attribute) => attribute.trait_type,
|
|
31503
31508
|
requiredTraitTypes: [
|
|
31504
31509
|
"Total Credits Retired",
|
|
31505
|
-
"Beneficiary",
|
|
31506
31510
|
"Retirement Date",
|
|
31507
31511
|
"Certificates Retired"
|
|
31508
31512
|
]
|
|
@@ -31513,7 +31517,7 @@ var CreditRetirementReceiptBeneficiarySchema = zod.z.strictObject({
|
|
|
31513
31517
|
title: "Retirement Beneficiary ID",
|
|
31514
31518
|
description: "UUID identifying the beneficiary of the retirement (bytes16 normalized to UUID)"
|
|
31515
31519
|
}),
|
|
31516
|
-
identity: CreditRetirementReceiptIdentitySchema
|
|
31520
|
+
identity: CreditRetirementReceiptIdentitySchema.optional()
|
|
31517
31521
|
}).meta({
|
|
31518
31522
|
title: "Beneficiary",
|
|
31519
31523
|
description: "Beneficiary receiving the retirement benefit"
|
|
@@ -31733,7 +31737,7 @@ var CreditRetirementReceiptDataSchema = zod.z.strictObject({
|
|
|
31733
31737
|
});
|
|
31734
31738
|
var CreditRetirementReceiptIpfsSchemaMeta = {
|
|
31735
31739
|
title: "CreditRetirementReceipt NFT IPFS Record",
|
|
31736
|
-
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",
|
|
31737
31741
|
$id: buildSchemaUrl(
|
|
31738
31742
|
"credit-retirement-receipt/credit-retirement-receipt.schema.json"
|
|
31739
31743
|
),
|
|
@@ -31803,14 +31807,17 @@ var CreditRetirementReceiptIpfsSchema = NftIpfsSchema.safeExtend({
|
|
|
31803
31807
|
missingMessage: 'Attribute "Certificates Retired" is required',
|
|
31804
31808
|
mismatchMessage: 'Attribute "Certificates Retired" must match data.summary.total_certificates'
|
|
31805
31809
|
});
|
|
31806
|
-
|
|
31807
|
-
|
|
31808
|
-
|
|
31809
|
-
|
|
31810
|
-
|
|
31811
|
-
|
|
31812
|
-
|
|
31813
|
-
|
|
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
|
+
}
|
|
31814
31821
|
const creditHolderName = data.credit_holder.identity?.name;
|
|
31815
31822
|
if (creditHolderName) {
|
|
31816
31823
|
validateAttributeValue({
|