@carrot-foundation/schemas 0.4.2 → 0.5.1

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 CHANGED
@@ -28610,7 +28610,7 @@ var NftIpfsSchema = BaseIpfsSchema.safeExtend({
28610
28610
  "External link URLs must be unique"
28611
28611
  ).optional().meta({
28612
28612
  title: "External Links",
28613
- description: "Optional list of public resource links with labels"
28613
+ description: "Supplementary reference links (label, URL, optional description) displayed on the NFT page"
28614
28614
  }),
28615
28615
  attributes: uniqueBy(
28616
28616
  NftAttributeSchema,
@@ -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
- description: "Unique identifier for the buyer or beneficiary in the Carrot platform"
29425
+ description: "Unique identifier of the associated entity 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
- }).meta({
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.4.2";
29494
+ return "0.5.1";
29490
29495
  }
29491
29496
 
29492
29497
  // src/shared/schema-validation.ts
@@ -30060,7 +30065,7 @@ var MassIDWastePropertiesSchema = zod.z.strictObject({
30060
30065
  local_classification: MassIDLocalClassificationSchema.optional(),
30061
30066
  weight_kg: WeightKgSchema.meta({
30062
30067
  title: "Net Weight",
30063
- description: "Net weight of the waste batch in kilograms (kg)",
30068
+ description: "Weight in kilograms of the entire waste batch tracked through the chain of custody",
30064
30069
  examples: [3e3]
30065
30070
  })
30066
30071
  }).meta({
@@ -30103,7 +30108,7 @@ var MassIDBaseEventSchema = zod.z.strictObject({
30103
30108
  participant_id_hash: ParticipantIdHashSchema,
30104
30109
  location_id_hash: Sha256HashSchema.meta({
30105
30110
  title: "Location ID Hash",
30106
- description: "Reference to location in the locations array"
30111
+ description: "Hash reference to the geographic location where this event occurred; matches an entry in `data.locations`"
30107
30112
  })
30108
30113
  }).meta({
30109
30114
  title: "MassID Base Event",
@@ -31037,7 +31042,7 @@ var CreditPurchaseReceiptBuyerAttributeSchema = NftAttributeSchema.omit({
31037
31042
  var CreditPurchaseReceiptRetirementDateAttributeSchema = createDateAttributeSchema({
31038
31043
  traitType: "Retirement Date",
31039
31044
  title: "Retirement Date",
31040
- description: "Unix timestamp in milliseconds when credits were retired (if retirement occurred)"
31045
+ description: "Unix timestamp in milliseconds when credits were retired; present in the attributes array only when the purchase has been retired (data.retirement_receipt is set)"
31041
31046
  });
31042
31047
  var CreditPurchaseReceiptRetirementReceiptAttributeSchema = NftAttributeSchema.safeExtend({
31043
31048
  trait_type: zod.z.literal("Retirement Receipt"),
@@ -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, Beneficiary, Retirement Date, Certificates Retired. Conditional attributes: 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).",
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
  ]
@@ -31511,9 +31515,9 @@ var CreditRetirementReceiptIdentitySchema = ReceiptIdentitySchema;
31511
31515
  var CreditRetirementReceiptBeneficiarySchema = zod.z.strictObject({
31512
31516
  beneficiary_id: ExternalIdSchema.meta({
31513
31517
  title: "Retirement Beneficiary ID",
31514
- description: "UUID identifying the beneficiary of the retirement (bytes16 normalized to UUID)"
31518
+ description: "UUID identifying the beneficiary of the retirement within the Carrot platform"
31515
31519
  }),
31516
- identity: CreditRetirementReceiptIdentitySchema
31520
+ identity: CreditRetirementReceiptIdentitySchema.optional()
31517
31521
  }).meta({
31518
31522
  title: "Beneficiary",
31519
31523
  description: "Beneficiary receiving the retirement benefit"
@@ -31521,7 +31525,7 @@ var CreditRetirementReceiptBeneficiarySchema = zod.z.strictObject({
31521
31525
  var CreditRetirementReceiptCreditHolderSchema = zod.z.strictObject({
31522
31526
  wallet_address: EthereumAddressSchema.meta({
31523
31527
  title: "Credit Holder Wallet Address",
31524
- description: "Ethereum address of the credit holder surrendering credits"
31528
+ description: "Ethereum address of the wallet that held and surrendered the credits"
31525
31529
  }),
31526
31530
  identity: CreditRetirementReceiptIdentitySchema.optional()
31527
31531
  }).meta({
@@ -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
- validateAttributeValue({
31807
- ctx,
31808
- attributeByTraitType,
31809
- traitType: "Beneficiary",
31810
- expectedValue: String(data.beneficiary.identity.name),
31811
- missingMessage: 'Attribute "Beneficiary" is required',
31812
- mismatchMessage: 'Attribute "Beneficiary" must match beneficiary.identity.name'
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({