@carrot-foundation/schemas 0.1.39 → 0.1.40
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 +491 -375
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +285 -319
- package/dist/index.d.ts +285 -319
- package/dist/index.js +491 -375
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/ipfs/collection/collection.schema.json +2 -2
- package/schemas/ipfs/credit/credit.schema.json +2 -2
- package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.schema.json +11 -20
- package/schemas/ipfs/credit-retirement-receipt/credit-retirement-receipt.schema.json +11 -20
- package/schemas/ipfs/gas-id/gas-id.example.json +1 -2
- package/schemas/ipfs/gas-id/gas-id.schema.json +3 -20
- package/schemas/ipfs/mass-id/mass-id.example.json +87 -187
- package/schemas/ipfs/mass-id/mass-id.schema.json +658 -484
- package/schemas/ipfs/mass-id-audit/mass-id-audit.schema.json +2 -2
- package/schemas/ipfs/methodology/methodology.schema.json +2 -2
- package/schemas/ipfs/recycled-id/recycled-id.example.json +1 -2
- package/schemas/ipfs/recycled-id/recycled-id.schema.json +3 -20
package/dist/index.cjs
CHANGED
|
@@ -25,9 +25,7 @@ var EthereumAddressSchema = zod.z.string().regex(
|
|
|
25
25
|
"0xabcdef1234567890abcdef1234567890abcdef12"
|
|
26
26
|
]
|
|
27
27
|
});
|
|
28
|
-
var IsoTimestampSchema = zod.z.iso.datetime({
|
|
29
|
-
message: "Must be a valid ISO 8601 timestamp with timezone"
|
|
30
|
-
}).meta({
|
|
28
|
+
var IsoTimestampSchema = zod.z.iso.datetime().meta({
|
|
31
29
|
title: "ISO Timestamp",
|
|
32
30
|
description: "ISO 8601 formatted timestamp with timezone information",
|
|
33
31
|
examples: ["2024-12-05T11:02:47.000Z", "2025-02-22T10:35:12.000Z"]
|
|
@@ -141,29 +139,15 @@ var ParticipantNameSchema = NonEmptyStringSchema.max(100).meta({
|
|
|
141
139
|
description: "Name of a participant in the waste management system",
|
|
142
140
|
examples: ["Enlatados Produ\xE7\xE3o", "Eco Reciclagem", "Green Tech Corp"]
|
|
143
141
|
});
|
|
144
|
-
var FacilityTypeSchema = zod.z.enum([
|
|
145
|
-
"Collection Point",
|
|
146
|
-
"Recycling Facility",
|
|
147
|
-
"Administrative Office",
|
|
148
|
-
"Other"
|
|
149
|
-
]).meta({
|
|
150
|
-
title: "Facility Type",
|
|
151
|
-
description: "Type of facility in the waste management chain",
|
|
152
|
-
examples: [
|
|
153
|
-
"Collection Point",
|
|
154
|
-
"Recycling Facility",
|
|
155
|
-
"Administrative Office"
|
|
156
|
-
]
|
|
157
|
-
});
|
|
158
142
|
var BlockchainChainIdSchema = zod.z.number().int().min(1).meta({
|
|
159
143
|
title: "Chain ID",
|
|
160
144
|
description: "Blockchain network identifier",
|
|
161
|
-
examples: [
|
|
145
|
+
examples: [137, 80002]
|
|
162
146
|
});
|
|
163
147
|
var BlockchainNetworkNameSchema = NonEmptyStringSchema.max(100).meta({
|
|
164
148
|
title: "Blockchain Network Name",
|
|
165
149
|
description: "Name of the blockchain network",
|
|
166
|
-
examples: ["Polygon", "
|
|
150
|
+
examples: ["Polygon", "Amoy"]
|
|
167
151
|
});
|
|
168
152
|
var SmartContractAddressSchema = EthereumAddressSchema.meta({
|
|
169
153
|
title: "Smart Contract Address",
|
|
@@ -394,8 +378,7 @@ var LocationSchema = zod.z.strictObject({
|
|
|
394
378
|
title: "Responsible Participant ID Hash",
|
|
395
379
|
description: "Anonymized ID of the participant responsible for this location"
|
|
396
380
|
}),
|
|
397
|
-
coordinates: CoordinatesSchema
|
|
398
|
-
facility_type: FacilityTypeSchema.optional()
|
|
381
|
+
coordinates: CoordinatesSchema
|
|
399
382
|
}).meta({
|
|
400
383
|
title: "Location",
|
|
401
384
|
description: "Geographic location with address and coordinate information"
|
|
@@ -918,7 +901,7 @@ function buildSchemaUrl(schemaPath) {
|
|
|
918
901
|
return `${getSchemaBaseUrl()}/${cleanPath}`;
|
|
919
902
|
}
|
|
920
903
|
function getSchemaVersionOrDefault() {
|
|
921
|
-
return "0.1.
|
|
904
|
+
return "0.1.40";
|
|
922
905
|
}
|
|
923
906
|
var MethodologyAttributeSchema = NftAttributeSchema.safeExtend({
|
|
924
907
|
trait_type: zod.z.literal("Methodology"),
|
|
@@ -1418,6 +1401,294 @@ function validateAttributesForItems(params) {
|
|
|
1418
1401
|
}
|
|
1419
1402
|
});
|
|
1420
1403
|
}
|
|
1404
|
+
var IbamaWasteClassificationSchema = zod.z.string().regex(/^\d{2} \d{2} \d{2}\*?$/, "Invalid Ibama code format").meta({
|
|
1405
|
+
title: "Ibama Classification Code",
|
|
1406
|
+
description: "Ibama waste classification code in the format NN NN NN with required spaces and optional trailing *",
|
|
1407
|
+
examples: ["20 01 01", "20 01 01*", "04 02 20"]
|
|
1408
|
+
});
|
|
1409
|
+
var MassIDLocalClassificationSchema = zod.z.strictObject({
|
|
1410
|
+
code: IbamaWasteClassificationSchema,
|
|
1411
|
+
system: zod.z.literal("Ibama").meta({
|
|
1412
|
+
title: "Classification System",
|
|
1413
|
+
description: "Authority or standard providing the classification code",
|
|
1414
|
+
examples: ["Ibama"]
|
|
1415
|
+
})
|
|
1416
|
+
}).meta({
|
|
1417
|
+
title: "Local Classification",
|
|
1418
|
+
description: "Regulatory classification reference for the waste material",
|
|
1419
|
+
examples: [{ code: "04 02 20", system: "Ibama" }]
|
|
1420
|
+
});
|
|
1421
|
+
var MassIDWastePropertiesSchema = zod.z.strictObject({
|
|
1422
|
+
type: WasteTypeSchema.meta({
|
|
1423
|
+
title: "Waste Type",
|
|
1424
|
+
description: "Waste material category",
|
|
1425
|
+
examples: ["Organic"]
|
|
1426
|
+
}),
|
|
1427
|
+
subtype: WasteSubtypeSchema.meta({
|
|
1428
|
+
title: "Waste Subtype",
|
|
1429
|
+
description: "Specific subcategory of waste material",
|
|
1430
|
+
examples: ["Food, Food Waste and Beverages"]
|
|
1431
|
+
}),
|
|
1432
|
+
local_classification: MassIDLocalClassificationSchema.optional(),
|
|
1433
|
+
net_weight: WeightKgSchema.meta({
|
|
1434
|
+
title: "Net Weight (kg)",
|
|
1435
|
+
description: "Net weight of the waste batch in kilograms (kg)",
|
|
1436
|
+
examples: [3e3]
|
|
1437
|
+
})
|
|
1438
|
+
}).meta({
|
|
1439
|
+
title: "Waste Properties",
|
|
1440
|
+
description: "Standardized waste material properties and regulatory information"
|
|
1441
|
+
});
|
|
1442
|
+
var MassIDAttachmentTypeSchema = zod.z.enum(["Recycling Manifest", "Transport Manifest"]).meta({
|
|
1443
|
+
title: "Attachment Type",
|
|
1444
|
+
description: "Type of supporting attachment linked to a MassID event",
|
|
1445
|
+
examples: ["Recycling Manifest", "Transport Manifest"]
|
|
1446
|
+
});
|
|
1447
|
+
var MassIDAttachmentSchema = zod.z.strictObject({
|
|
1448
|
+
type: MassIDAttachmentTypeSchema,
|
|
1449
|
+
document_number: NonEmptyStringSchema.max(50).optional().meta({
|
|
1450
|
+
title: "Document Number",
|
|
1451
|
+
description: "Official document number if applicable",
|
|
1452
|
+
examples: ["2353", "12345"]
|
|
1453
|
+
}),
|
|
1454
|
+
issued_at: IsoTimestampSchema.optional().meta({
|
|
1455
|
+
title: "Issued At",
|
|
1456
|
+
description: "ISO 8601 timestamp when the attachment was issued"
|
|
1457
|
+
}),
|
|
1458
|
+
event_id: UuidSchema.meta({
|
|
1459
|
+
title: "Event ID",
|
|
1460
|
+
description: "Identifier of the event this attachment belongs to"
|
|
1461
|
+
})
|
|
1462
|
+
}).meta({
|
|
1463
|
+
title: "MassID Attachment",
|
|
1464
|
+
description: "Attachment associated with a specific MassID event, linked by event_id"
|
|
1465
|
+
});
|
|
1466
|
+
var MassIDBaseEventSchema = zod.z.strictObject({
|
|
1467
|
+
event_id: UuidSchema.meta({
|
|
1468
|
+
title: "Event ID",
|
|
1469
|
+
description: "Unique event identifier"
|
|
1470
|
+
}),
|
|
1471
|
+
description: NonEmptyStringSchema.max(200).optional().meta({
|
|
1472
|
+
title: "Event Description",
|
|
1473
|
+
description: "Detailed description of what happened during this event",
|
|
1474
|
+
examples: [
|
|
1475
|
+
"Waste collected from residential area using collection truck",
|
|
1476
|
+
"Material sorted into recyclable and non-recyclable fractions",
|
|
1477
|
+
"Waste transferred to authorized recycling facility"
|
|
1478
|
+
]
|
|
1479
|
+
}),
|
|
1480
|
+
timestamp: IsoTimestampSchema.meta({
|
|
1481
|
+
title: "Event Timestamp",
|
|
1482
|
+
description: "ISO 8601 timestamp when the event occurred"
|
|
1483
|
+
}),
|
|
1484
|
+
participant_id_hash: Sha256HashSchema.meta({
|
|
1485
|
+
title: "Participant ID Hash",
|
|
1486
|
+
description: "Reference to participant in the participants array"
|
|
1487
|
+
}),
|
|
1488
|
+
location_id_hash: Sha256HashSchema.meta({
|
|
1489
|
+
title: "Location ID Hash",
|
|
1490
|
+
description: "Reference to location in the locations array"
|
|
1491
|
+
}),
|
|
1492
|
+
weight: WeightKgSchema.optional().meta({
|
|
1493
|
+
title: "Event Weight (kg)",
|
|
1494
|
+
description: "Mass weight after this event in kilograms (kg)"
|
|
1495
|
+
})
|
|
1496
|
+
}).meta({
|
|
1497
|
+
title: "MassID Base Event",
|
|
1498
|
+
description: "Base MassID event definition shared across event types"
|
|
1499
|
+
});
|
|
1500
|
+
var buildMassIDEventSchema = (eventName, description) => MassIDBaseEventSchema.safeExtend({
|
|
1501
|
+
event_name: zod.z.literal(eventName).meta({
|
|
1502
|
+
title: "Event Name",
|
|
1503
|
+
description: `${eventName} event discriminator`,
|
|
1504
|
+
examples: [eventName]
|
|
1505
|
+
})
|
|
1506
|
+
}).meta({
|
|
1507
|
+
title: `${eventName} Event`,
|
|
1508
|
+
description
|
|
1509
|
+
});
|
|
1510
|
+
var PickUpEventSchema = buildMassIDEventSchema(
|
|
1511
|
+
"Pick-up",
|
|
1512
|
+
"Waste picked up from the origin location"
|
|
1513
|
+
).safeExtend({
|
|
1514
|
+
data: zod.z.strictObject({
|
|
1515
|
+
vehicle_type: NonEmptyStringSchema.max(50).optional().meta({
|
|
1516
|
+
title: "Vehicle Type",
|
|
1517
|
+
description: "Type of vehicle used for pick-up operations",
|
|
1518
|
+
examples: ["Truck", "Van", "Compactor"]
|
|
1519
|
+
})
|
|
1520
|
+
}).optional().meta({
|
|
1521
|
+
title: "Pick-up Event Data",
|
|
1522
|
+
description: "Vehicle information associated with the pick-up event"
|
|
1523
|
+
})
|
|
1524
|
+
});
|
|
1525
|
+
var WeighingEventSchema = buildMassIDEventSchema(
|
|
1526
|
+
"Weighing",
|
|
1527
|
+
"Waste weighed at a facility"
|
|
1528
|
+
).safeExtend({
|
|
1529
|
+
data: zod.z.strictObject({
|
|
1530
|
+
weighing_capture_method: NonEmptyStringSchema.max(100).optional().meta({
|
|
1531
|
+
title: "Weighing Capture Method",
|
|
1532
|
+
description: "Method used to capture the weight measurement",
|
|
1533
|
+
examples: [
|
|
1534
|
+
"Digital scale integration",
|
|
1535
|
+
"Manual entry",
|
|
1536
|
+
"Automated capture via IoT scale"
|
|
1537
|
+
]
|
|
1538
|
+
}),
|
|
1539
|
+
scale_type: NonEmptyStringSchema.max(50).optional().meta({
|
|
1540
|
+
title: "Scale Type",
|
|
1541
|
+
description: "Type of scale used to weigh the load",
|
|
1542
|
+
examples: ["Weighbridge (Truck Scale)", "Axle scale"]
|
|
1543
|
+
}),
|
|
1544
|
+
container_type: NonEmptyStringSchema.max(50).optional().meta({
|
|
1545
|
+
title: "Container Type",
|
|
1546
|
+
description: "Type of container holding the waste during weighing",
|
|
1547
|
+
examples: ["Roll-off container", "Front loader bin"]
|
|
1548
|
+
}),
|
|
1549
|
+
vehicle_type: NonEmptyStringSchema.max(50).optional().meta({
|
|
1550
|
+
title: "Vehicle Type",
|
|
1551
|
+
description: "Type of vehicle used during weighing",
|
|
1552
|
+
examples: ["Truck", "Trailer"]
|
|
1553
|
+
}),
|
|
1554
|
+
container_capacity: WeightKgSchema.optional().meta({
|
|
1555
|
+
title: "Container Capacity (kg)",
|
|
1556
|
+
description: "Maximum container capacity in kilograms",
|
|
1557
|
+
examples: [12e3]
|
|
1558
|
+
}),
|
|
1559
|
+
gross_weight: WeightKgSchema.optional().meta({
|
|
1560
|
+
title: "Gross Weight (kg)",
|
|
1561
|
+
description: "Total weight including vehicle/container before tare",
|
|
1562
|
+
examples: [9500]
|
|
1563
|
+
}),
|
|
1564
|
+
tare: WeightKgSchema.optional().meta({
|
|
1565
|
+
title: "Tare Weight (kg)",
|
|
1566
|
+
description: "Weight of the empty vehicle or container",
|
|
1567
|
+
examples: [3500]
|
|
1568
|
+
})
|
|
1569
|
+
}).optional().meta({
|
|
1570
|
+
title: "Weighing Event Data",
|
|
1571
|
+
description: "Weighing operational details including capture method, equipment, and weights"
|
|
1572
|
+
})
|
|
1573
|
+
});
|
|
1574
|
+
var DropOffEventSchema = buildMassIDEventSchema(
|
|
1575
|
+
"Drop-off",
|
|
1576
|
+
"Waste delivered to a destination location"
|
|
1577
|
+
);
|
|
1578
|
+
var SortingEventSchema = buildMassIDEventSchema(
|
|
1579
|
+
"Sorting",
|
|
1580
|
+
"Sorting or segregation of waste materials"
|
|
1581
|
+
).safeExtend({
|
|
1582
|
+
data: zod.z.strictObject({
|
|
1583
|
+
initial_weight: WeightKgSchema.optional().meta({
|
|
1584
|
+
title: "Initial Weight (kg)",
|
|
1585
|
+
description: "Weight of the material entering the sorting process in kilograms",
|
|
1586
|
+
examples: [5e3]
|
|
1587
|
+
}),
|
|
1588
|
+
deducted_weight: WeightKgSchema.optional().meta({
|
|
1589
|
+
title: "Deducted Weight (kg)",
|
|
1590
|
+
description: "Weight removed during sorting (e.g., contaminants or moisture) in kilograms",
|
|
1591
|
+
examples: [250]
|
|
1592
|
+
})
|
|
1593
|
+
}).optional().meta({
|
|
1594
|
+
title: "Sorting Event Data",
|
|
1595
|
+
description: "Weights associated with sorting, including initial and deducted amounts"
|
|
1596
|
+
})
|
|
1597
|
+
});
|
|
1598
|
+
var RecyclingEventSchema = buildMassIDEventSchema(
|
|
1599
|
+
"Recycling",
|
|
1600
|
+
"Waste processed or recycled at the destination"
|
|
1601
|
+
);
|
|
1602
|
+
var MassIDEventSchema = zod.z.discriminatedUnion("event_name", [
|
|
1603
|
+
PickUpEventSchema,
|
|
1604
|
+
WeighingEventSchema,
|
|
1605
|
+
DropOffEventSchema,
|
|
1606
|
+
SortingEventSchema,
|
|
1607
|
+
RecyclingEventSchema
|
|
1608
|
+
]).meta({
|
|
1609
|
+
title: "MassID Event",
|
|
1610
|
+
description: "Lifecycle event describing custody, processing, documentation, or recycling steps"
|
|
1611
|
+
});
|
|
1612
|
+
var MassIDEventsSchema = zod.z.array(MassIDEventSchema).min(1).superRefine((events, ctx) => {
|
|
1613
|
+
events.forEach((event, index) => {
|
|
1614
|
+
if (index === 0) {
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
const previousEvent = events[index - 1];
|
|
1618
|
+
if (event.timestamp < previousEvent.timestamp) {
|
|
1619
|
+
ctx.addIssue({
|
|
1620
|
+
code: "custom",
|
|
1621
|
+
path: [index, "timestamp"],
|
|
1622
|
+
message: "Events must be ordered by timestamp"
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
}).meta({
|
|
1627
|
+
title: "MassID Events",
|
|
1628
|
+
description: "Chronological sequence of custody transfer, processing, and recycling events"
|
|
1629
|
+
});
|
|
1630
|
+
var MassIDDataSchema = zod.z.strictObject({
|
|
1631
|
+
waste_properties: MassIDWastePropertiesSchema,
|
|
1632
|
+
locations: uniqueBy(
|
|
1633
|
+
LocationSchema,
|
|
1634
|
+
(loc) => loc.id_hash,
|
|
1635
|
+
"Location ID hashes must be unique"
|
|
1636
|
+
).min(1).meta({
|
|
1637
|
+
title: "Locations",
|
|
1638
|
+
description: "All locations referenced in this MassID, indexed by ID"
|
|
1639
|
+
}),
|
|
1640
|
+
participants: uniqueBy(
|
|
1641
|
+
ParticipantSchema,
|
|
1642
|
+
(participant) => participant.id_hash,
|
|
1643
|
+
"Participant ID hashes must be unique"
|
|
1644
|
+
).min(1).meta({
|
|
1645
|
+
title: "Participants",
|
|
1646
|
+
description: "All participants referenced in this MassID, indexed by ID"
|
|
1647
|
+
}),
|
|
1648
|
+
events: MassIDEventsSchema,
|
|
1649
|
+
attachments: zod.z.array(MassIDAttachmentSchema).optional().meta({
|
|
1650
|
+
title: "Attachments",
|
|
1651
|
+
description: "Supporting documents associated with events, linked by event_id"
|
|
1652
|
+
})
|
|
1653
|
+
}).refine((data) => {
|
|
1654
|
+
const participantIdSet = new Set(
|
|
1655
|
+
data.participants.map((participant) => participant.id_hash)
|
|
1656
|
+
);
|
|
1657
|
+
const eventParticipantIds = data.events.map(
|
|
1658
|
+
(event) => event.participant_id_hash
|
|
1659
|
+
);
|
|
1660
|
+
const allEventParticipantsExist = eventParticipantIds.every(
|
|
1661
|
+
(participantId) => participantIdSet.has(participantId)
|
|
1662
|
+
);
|
|
1663
|
+
return allEventParticipantsExist;
|
|
1664
|
+
}, "All participant ID hashes in events must exist in participants array").refine((data) => {
|
|
1665
|
+
const locationIdSet = new Set(
|
|
1666
|
+
data.locations.map((location) => location.id_hash)
|
|
1667
|
+
);
|
|
1668
|
+
const eventLocationIds = data.events.map((event) => event.location_id_hash);
|
|
1669
|
+
const allEventLocationsExist = eventLocationIds.every(
|
|
1670
|
+
(locationId) => locationIdSet.has(locationId)
|
|
1671
|
+
);
|
|
1672
|
+
return allEventLocationsExist;
|
|
1673
|
+
}, "All location ID hashes in events must exist in locations array").refine((data) => {
|
|
1674
|
+
if (!data.attachments || data.attachments.length === 0) {
|
|
1675
|
+
return true;
|
|
1676
|
+
}
|
|
1677
|
+
const eventIdSet = new Set(data.events.map((event) => event.event_id));
|
|
1678
|
+
return data.attachments.every(
|
|
1679
|
+
(attachment) => eventIdSet.has(attachment.event_id)
|
|
1680
|
+
);
|
|
1681
|
+
}, "All attachments must reference an existing event by event_id").refine((data) => {
|
|
1682
|
+
const participantIdSet = new Set(
|
|
1683
|
+
data.participants.map((participant) => participant.id_hash)
|
|
1684
|
+
);
|
|
1685
|
+
return data.locations.every(
|
|
1686
|
+
(location) => participantIdSet.has(location.responsible_participant_id_hash)
|
|
1687
|
+
);
|
|
1688
|
+
}, "All responsible participant ID hashes in locations must exist in participants array").meta({
|
|
1689
|
+
title: "MassID Data",
|
|
1690
|
+
description: "MassID data containing waste tracking events and supporting information"
|
|
1691
|
+
});
|
|
1421
1692
|
|
|
1422
1693
|
// src/mass-id/mass-id.attributes.ts
|
|
1423
1694
|
var MassIDAttributeWasteTypeSchema = NftAttributeSchema.safeExtend({
|
|
@@ -1425,22 +1696,22 @@ var MassIDAttributeWasteTypeSchema = NftAttributeSchema.safeExtend({
|
|
|
1425
1696
|
value: WasteTypeSchema
|
|
1426
1697
|
}).meta({
|
|
1427
1698
|
title: "Waste Type Attribute",
|
|
1428
|
-
description: "
|
|
1699
|
+
description: "Primary waste material category (e.g., Organic, Paper, Glass, Metal)"
|
|
1429
1700
|
});
|
|
1430
1701
|
var MassIDAttributeWasteSubtypeSchema = NftAttributeSchema.safeExtend({
|
|
1431
1702
|
trait_type: zod.z.literal("Waste Subtype"),
|
|
1432
1703
|
value: WasteSubtypeSchema
|
|
1433
1704
|
}).meta({
|
|
1434
1705
|
title: "Waste Subtype Attribute",
|
|
1435
|
-
description: "
|
|
1706
|
+
description: "Regulatory or operational waste subtype (e.g., Food, Food Waste and Beverages)"
|
|
1436
1707
|
});
|
|
1437
1708
|
var MassIDAttributeWeightSchema = NftAttributeSchema.safeExtend({
|
|
1438
1709
|
trait_type: zod.z.literal("Weight (kg)"),
|
|
1439
1710
|
value: WeightKgSchema,
|
|
1440
1711
|
display_type: zod.z.literal("number")
|
|
1441
1712
|
}).meta({
|
|
1442
|
-
title: "Weight Attribute",
|
|
1443
|
-
description: "
|
|
1713
|
+
title: "Weight Attribute (kg)",
|
|
1714
|
+
description: "Net batch weight in kilograms (kg) for this MassID"
|
|
1444
1715
|
});
|
|
1445
1716
|
var MassIDAttributeOriginCountrySchema = OriginCountryAttributeSchema.safeExtend({
|
|
1446
1717
|
value: CountryNameSchema
|
|
@@ -1453,84 +1724,70 @@ var MassIDAttributeOriginDivisionSchema = NftAttributeSchema.safeExtend({
|
|
|
1453
1724
|
value: AdministrativeDivisionSchema
|
|
1454
1725
|
}).meta({
|
|
1455
1726
|
title: "Origin Administrative Division Attribute",
|
|
1456
|
-
description: "
|
|
1727
|
+
description: "State/province where the waste was generated (ISO 3166-2 preferred)"
|
|
1457
1728
|
});
|
|
1458
|
-
var
|
|
1459
|
-
trait_type: zod.z.literal("Vehicle Type"),
|
|
1729
|
+
var MassIDAttributePickUpVehicleTypeSchema = NftAttributeSchema.safeExtend({
|
|
1730
|
+
trait_type: zod.z.literal("Pick-up Vehicle Type"),
|
|
1460
1731
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1461
|
-
title: "Vehicle Type",
|
|
1462
|
-
description: "Type of vehicle used for waste
|
|
1463
|
-
examples: ["
|
|
1732
|
+
title: "Pick-up Vehicle Type",
|
|
1733
|
+
description: "Type of vehicle used for waste pick-up operations",
|
|
1734
|
+
examples: ["Truck", "Box Truck", "Flatbed Truck", "Roll-off Truck"]
|
|
1464
1735
|
})
|
|
1465
1736
|
}).meta({
|
|
1466
|
-
title: "Vehicle Type Attribute",
|
|
1467
|
-
description: "Vehicle type
|
|
1737
|
+
title: "Pick-up Vehicle Type Attribute",
|
|
1738
|
+
description: "Vehicle type used during pick-up"
|
|
1468
1739
|
});
|
|
1469
1740
|
var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.safeExtend({
|
|
1470
1741
|
trait_type: zod.z.literal("Recycling Method"),
|
|
1471
1742
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1472
1743
|
title: "Recycling Method",
|
|
1473
1744
|
description: "Method used for recycling or processing the waste",
|
|
1474
|
-
examples: [
|
|
1475
|
-
"Composting",
|
|
1476
|
-
"Mechanical Recycling",
|
|
1477
|
-
"Incineration with Energy Recovery"
|
|
1478
|
-
]
|
|
1745
|
+
examples: ["Composting", "Mechanical Recycling", "Anaerobic Digestion"]
|
|
1479
1746
|
})
|
|
1480
1747
|
}).meta({
|
|
1481
1748
|
title: "Recycling Method Attribute",
|
|
1482
|
-
description: "
|
|
1483
|
-
});
|
|
1484
|
-
var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.safeExtend({
|
|
1485
|
-
trait_type: zod.z.literal("Processing Time (hours)"),
|
|
1486
|
-
value: HoursSchema,
|
|
1487
|
-
trait_description: NonEmptyStringSchema.max(200).optional().meta({
|
|
1488
|
-
title: "Processing Time Description",
|
|
1489
|
-
description: "Custom description for the processing time"
|
|
1490
|
-
})
|
|
1491
|
-
}).meta({
|
|
1492
|
-
title: "Processing Time Attribute",
|
|
1493
|
-
description: "Processing time attribute with optional trait description"
|
|
1749
|
+
description: "Process applied to this mass (e.g., composting, mechanical recycling)"
|
|
1494
1750
|
});
|
|
1495
1751
|
var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.safeExtend({
|
|
1496
1752
|
trait_type: zod.z.literal("Local Waste Classification ID"),
|
|
1497
|
-
value:
|
|
1498
|
-
title: "Local Waste Classification ID",
|
|
1499
|
-
description: "Local or regional waste classification identifier",
|
|
1500
|
-
examples: ["04 02 20", "IBAMA-A001", "EWC-150101"]
|
|
1501
|
-
})
|
|
1753
|
+
value: IbamaWasteClassificationSchema
|
|
1502
1754
|
}).meta({
|
|
1503
1755
|
title: "Local Waste Classification ID Attribute",
|
|
1504
|
-
description: "
|
|
1756
|
+
description: "Regulatory waste classification code (e.g., Ibama format NN NN NN[*])",
|
|
1757
|
+
examples: ["20 01 01", "20 01 01*", "04 02 20"]
|
|
1505
1758
|
});
|
|
1506
1759
|
var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.safeExtend({
|
|
1507
|
-
trait_type: zod.z.literal("Recycling Manifest
|
|
1760
|
+
trait_type: zod.z.literal("Recycling Manifest Number"),
|
|
1508
1761
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1509
|
-
title: "Recycling Manifest
|
|
1510
|
-
description: "
|
|
1511
|
-
examples: ["
|
|
1762
|
+
title: "Recycling Manifest Number",
|
|
1763
|
+
description: "Official recycling manifest identifier",
|
|
1764
|
+
examples: ["2353", "REC-MANIFEST-789", "RC12345"]
|
|
1512
1765
|
})
|
|
1513
1766
|
}).meta({
|
|
1514
|
-
title: "Recycling Manifest
|
|
1515
|
-
description: "
|
|
1767
|
+
title: "Recycling Manifest Number Attribute",
|
|
1768
|
+
description: "Official recycling manifest number issued by recycling authority (optional)"
|
|
1516
1769
|
});
|
|
1517
1770
|
var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.safeExtend({
|
|
1518
|
-
trait_type: zod.z.literal("Transport Manifest
|
|
1771
|
+
trait_type: zod.z.literal("Transport Manifest Number"),
|
|
1519
1772
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1520
|
-
title: "Transport Manifest
|
|
1521
|
-
description: "
|
|
1522
|
-
examples: ["
|
|
1773
|
+
title: "Transport Manifest Number",
|
|
1774
|
+
description: "Official transport manifest identifier",
|
|
1775
|
+
examples: ["4126", "TRN-67890", "TRANS-MANIFEST-456"]
|
|
1523
1776
|
})
|
|
1524
1777
|
}).meta({
|
|
1525
|
-
title: "Transport Manifest
|
|
1526
|
-
description: "
|
|
1778
|
+
title: "Transport Manifest Number Attribute",
|
|
1779
|
+
description: "Official transport manifest number issued by logistics/transport authority (optional)"
|
|
1527
1780
|
});
|
|
1528
1781
|
var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.safeExtend({
|
|
1529
1782
|
trait_type: zod.z.literal("Weighing Capture Method"),
|
|
1530
1783
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1531
1784
|
title: "Weighing Capture Method",
|
|
1532
1785
|
description: "Method used to capture weight data",
|
|
1533
|
-
examples: [
|
|
1786
|
+
examples: [
|
|
1787
|
+
"Digital scale integration",
|
|
1788
|
+
"Manual entry",
|
|
1789
|
+
"Automated capture via IoT scale"
|
|
1790
|
+
]
|
|
1534
1791
|
})
|
|
1535
1792
|
}).meta({
|
|
1536
1793
|
title: "Weighing Capture Method Attribute",
|
|
@@ -1543,8 +1800,8 @@ var MassIDAttributeScaleTypeSchema = NftAttributeSchema.safeExtend({
|
|
|
1543
1800
|
description: "Type of scale used for weighing",
|
|
1544
1801
|
examples: [
|
|
1545
1802
|
"Weighbridge (Truck Scale)",
|
|
1803
|
+
"Axle scale",
|
|
1546
1804
|
"Floor Scale",
|
|
1547
|
-
"Bench Scale",
|
|
1548
1805
|
"Crane Scale"
|
|
1549
1806
|
]
|
|
1550
1807
|
})
|
|
@@ -1552,35 +1809,36 @@ var MassIDAttributeScaleTypeSchema = NftAttributeSchema.safeExtend({
|
|
|
1552
1809
|
title: "Scale Type Attribute",
|
|
1553
1810
|
description: "Scale type attribute (optional)"
|
|
1554
1811
|
});
|
|
1555
|
-
var MassIDAttributeContainerTypeSchema = NftAttributeSchema.safeExtend({
|
|
1556
|
-
trait_type: zod.z.literal("Container Type"),
|
|
1557
|
-
value: NonEmptyStringSchema.max(100).meta({
|
|
1558
|
-
title: "Container Type",
|
|
1559
|
-
description: "Type of container used for waste storage or transport",
|
|
1560
|
-
examples: ["Truck", "Dumpster", "Roll-off Container", "Compactor", "Bin"]
|
|
1561
|
-
})
|
|
1562
|
-
}).meta({
|
|
1563
|
-
title: "Container Type Attribute",
|
|
1564
|
-
description: "Container type attribute (optional)"
|
|
1565
|
-
});
|
|
1566
1812
|
var MassIDAttributePickUpDateSchema = NftAttributeSchema.safeExtend({
|
|
1567
1813
|
trait_type: zod.z.literal("Pick-up Date"),
|
|
1568
1814
|
value: UnixTimestampSchema.meta({
|
|
1569
1815
|
title: "Pick-up Date",
|
|
1570
1816
|
description: "Unix timestamp in milliseconds when the waste was picked up from the source",
|
|
1571
|
-
examples: [
|
|
1817
|
+
examples: [1733396567e3]
|
|
1572
1818
|
}),
|
|
1573
1819
|
display_type: zod.z.literal("date")
|
|
1574
1820
|
}).meta({
|
|
1575
1821
|
title: "Pick-up Date Attribute",
|
|
1576
1822
|
description: "Pick-up date attribute with Unix timestamp"
|
|
1577
1823
|
});
|
|
1824
|
+
var MassIDAttributeDropOffDateSchema = NftAttributeSchema.safeExtend({
|
|
1825
|
+
trait_type: zod.z.literal("Drop-off Date"),
|
|
1826
|
+
value: UnixTimestampSchema.meta({
|
|
1827
|
+
title: "Drop-off Date",
|
|
1828
|
+
description: "Unix timestamp in milliseconds when the waste was dropped off at the destination",
|
|
1829
|
+
examples: [1733407367e3]
|
|
1830
|
+
}),
|
|
1831
|
+
display_type: zod.z.literal("date")
|
|
1832
|
+
}).meta({
|
|
1833
|
+
title: "Drop-off Date Attribute",
|
|
1834
|
+
description: "Drop-off date attribute with Unix timestamp"
|
|
1835
|
+
});
|
|
1578
1836
|
var MassIDAttributeRecyclingDateSchema = NftAttributeSchema.safeExtend({
|
|
1579
1837
|
trait_type: zod.z.literal("Recycling Date"),
|
|
1580
1838
|
value: UnixTimestampSchema.meta({
|
|
1581
1839
|
title: "Recycling Date",
|
|
1582
1840
|
description: "Unix timestamp in milliseconds when the waste was recycled/processed",
|
|
1583
|
-
examples: [
|
|
1841
|
+
examples: [1733657567e3]
|
|
1584
1842
|
}),
|
|
1585
1843
|
display_type: zod.z.literal("date")
|
|
1586
1844
|
}).meta({
|
|
@@ -1595,308 +1853,24 @@ var MassIDAttributesSchema = uniqueBy(
|
|
|
1595
1853
|
MassIDAttributeOriginCountrySchema,
|
|
1596
1854
|
MassIDAttributeOriginMunicipalitySchema,
|
|
1597
1855
|
MassIDAttributeOriginDivisionSchema,
|
|
1598
|
-
|
|
1856
|
+
MassIDAttributePickUpVehicleTypeSchema,
|
|
1599
1857
|
MassIDAttributeRecyclingMethodSchema,
|
|
1600
|
-
MassIDAttributeProcessingTimeSchema,
|
|
1601
1858
|
MassIDAttributeLocalWasteClassificationIdSchema,
|
|
1602
1859
|
MassIDAttributeRecyclingManifestCodeSchema,
|
|
1603
1860
|
MassIDAttributeTransportManifestCodeSchema,
|
|
1604
1861
|
MassIDAttributeWeighingCaptureMethodSchema,
|
|
1605
1862
|
MassIDAttributeScaleTypeSchema,
|
|
1606
|
-
MassIDAttributeContainerTypeSchema,
|
|
1607
1863
|
MassIDAttributePickUpDateSchema,
|
|
1864
|
+
MassIDAttributeDropOffDateSchema,
|
|
1608
1865
|
MassIDAttributeRecyclingDateSchema
|
|
1609
1866
|
]),
|
|
1610
1867
|
(attr) => attr.trait_type
|
|
1611
|
-
).min(
|
|
1868
|
+
).min(11).max(16).meta({
|
|
1612
1869
|
title: "MassID Attributes",
|
|
1613
|
-
description: "MassID NFT attributes array
|
|
1614
|
-
});
|
|
1615
|
-
var MassIDLocalClassificationSchema = zod.z.strictObject({
|
|
1616
|
-
code: NonEmptyStringSchema.max(20).meta({
|
|
1617
|
-
title: "Classification Code",
|
|
1618
|
-
description: "Local waste classification code",
|
|
1619
|
-
examples: ["20 01 01", "D001", "EWC-150101", "IBAMA-A001"]
|
|
1620
|
-
}),
|
|
1621
|
-
description: NonEmptyStringSchema.max(200).meta({
|
|
1622
|
-
title: "Classification Description",
|
|
1623
|
-
description: "Local waste classification description",
|
|
1624
|
-
examples: [
|
|
1625
|
-
"Paper and cardboard packaging",
|
|
1626
|
-
"Ignitable waste",
|
|
1627
|
-
"Paper and cardboard packaging waste",
|
|
1628
|
-
"Municipal solid waste - organic fraction"
|
|
1629
|
-
]
|
|
1630
|
-
}),
|
|
1631
|
-
system: zod.z.enum(["IBAMA"]).meta({
|
|
1632
|
-
title: "Classification System",
|
|
1633
|
-
description: "Classification system name - currently supports IBAMA (Instituto Brasileiro do Meio Ambiente e dos Recursos Naturais Renov\xE1veis)",
|
|
1634
|
-
examples: ["IBAMA"]
|
|
1635
|
-
})
|
|
1636
|
-
}).meta({
|
|
1637
|
-
title: "Local Classification",
|
|
1638
|
-
description: "Local or regional waste classification codes and descriptions"
|
|
1639
|
-
});
|
|
1640
|
-
var MassIDMeasurementUnitSchema = zod.z.enum(["kg", "ton"]).meta({
|
|
1641
|
-
title: "Measurement Unit",
|
|
1642
|
-
description: "Unit of measurement for the waste quantity",
|
|
1643
|
-
examples: ["kg", "ton"]
|
|
1644
|
-
});
|
|
1645
|
-
var MassIDWastePropertiesSchema = zod.z.strictObject({
|
|
1646
|
-
type: WasteTypeSchema.meta({
|
|
1647
|
-
title: "Waste Type",
|
|
1648
|
-
description: "Waste material category"
|
|
1649
|
-
}),
|
|
1650
|
-
subtype: WasteSubtypeSchema.meta({
|
|
1651
|
-
title: "Waste Subtype",
|
|
1652
|
-
description: "Specific subcategory of waste material"
|
|
1653
|
-
}),
|
|
1654
|
-
local_classification: MassIDLocalClassificationSchema.optional(),
|
|
1655
|
-
measurement_unit: MassIDMeasurementUnitSchema,
|
|
1656
|
-
net_weight: NonNegativeFloatSchema.meta({
|
|
1657
|
-
title: "Net Weight",
|
|
1658
|
-
description: "Net weight of the waste batch in the specified measurement unit"
|
|
1659
|
-
})
|
|
1660
|
-
}).meta({
|
|
1661
|
-
title: "Waste Properties",
|
|
1662
|
-
description: "Standardized waste material properties and regulatory information"
|
|
1663
|
-
});
|
|
1664
|
-
var EventAttributeFormatSchema = zod.z.enum(["KILOGRAM", "DATE", "CURRENCY", "PERCENTAGE", "COORDINATE"]).meta({
|
|
1665
|
-
title: "Event Attribute Format",
|
|
1666
|
-
description: "Data format hint for proper display",
|
|
1667
|
-
examples: ["KILOGRAM", "DATE", "PERCENTAGE"]
|
|
1668
|
-
});
|
|
1669
|
-
var EventAttributeSchema = zod.z.strictObject({
|
|
1670
|
-
name: NonEmptyStringSchema.max(100).meta({
|
|
1671
|
-
title: "Attribute Name",
|
|
1672
|
-
description: "Event attribute name",
|
|
1673
|
-
examples: [
|
|
1674
|
-
"temperature",
|
|
1675
|
-
"humidity",
|
|
1676
|
-
"contamination_percentage",
|
|
1677
|
-
"quality_grade",
|
|
1678
|
-
"batch_number",
|
|
1679
|
-
"operator_id",
|
|
1680
|
-
"equipment_used",
|
|
1681
|
-
"processing_cost"
|
|
1682
|
-
]
|
|
1683
|
-
}),
|
|
1684
|
-
value: zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]).optional().meta({
|
|
1685
|
-
title: "Attribute Value",
|
|
1686
|
-
description: "Event attribute value",
|
|
1687
|
-
examples: [
|
|
1688
|
-
25.5,
|
|
1689
|
-
"Grade A",
|
|
1690
|
-
true,
|
|
1691
|
-
"BATCH-2024-001",
|
|
1692
|
-
12.75,
|
|
1693
|
-
"Shredder-X200",
|
|
1694
|
-
false,
|
|
1695
|
-
"OP-456"
|
|
1696
|
-
]
|
|
1697
|
-
}),
|
|
1698
|
-
preserved_sensitivity: zod.z.boolean().optional().meta({
|
|
1699
|
-
title: "Preserved Sensitivity",
|
|
1700
|
-
description: "Indicates if the attribute contains sensitive information that was preserved"
|
|
1701
|
-
}),
|
|
1702
|
-
format: EventAttributeFormatSchema.optional()
|
|
1703
|
-
}).meta({
|
|
1704
|
-
title: "Event Attribute",
|
|
1705
|
-
description: "Additional attribute specific to an event"
|
|
1706
|
-
});
|
|
1707
|
-
var EventAttachmentSchema = zod.z.strictObject({
|
|
1708
|
-
type: NonEmptyStringSchema.max(50).meta({
|
|
1709
|
-
title: "Attachment Type",
|
|
1710
|
-
description: "Type of supporting attachment",
|
|
1711
|
-
examples: [
|
|
1712
|
-
"Waste Transfer Note",
|
|
1713
|
-
"Certificate of Disposal",
|
|
1714
|
-
"Certificate of Final Destination",
|
|
1715
|
-
"Quality Assessment Report",
|
|
1716
|
-
"Transport Manifest",
|
|
1717
|
-
"Processing Receipt",
|
|
1718
|
-
"Environmental Permit",
|
|
1719
|
-
"Invoice"
|
|
1720
|
-
]
|
|
1721
|
-
}),
|
|
1722
|
-
document_number: NonEmptyStringSchema.max(50).optional().meta({
|
|
1723
|
-
title: "Document Number",
|
|
1724
|
-
description: "Official document number if applicable",
|
|
1725
|
-
examples: [
|
|
1726
|
-
"WTN-2024-001234",
|
|
1727
|
-
"CD-ENV-456789",
|
|
1728
|
-
"INV-2024-QTR1-789",
|
|
1729
|
-
"PERMIT-EPA-2024-001",
|
|
1730
|
-
"MANIFEST-DOT-567890"
|
|
1731
|
-
]
|
|
1732
|
-
}),
|
|
1733
|
-
reference: NonEmptyStringSchema.meta({
|
|
1734
|
-
title: "Attachment Reference",
|
|
1735
|
-
description: "Reference to attachment (IPFS hash, file name, or external URL)",
|
|
1736
|
-
examples: [
|
|
1737
|
-
"QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o",
|
|
1738
|
-
"waste_transfer_note_2024_001.pdf",
|
|
1739
|
-
"https://docs.example.com/certificates/disposal_cert_456.pdf",
|
|
1740
|
-
"bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
|
|
1741
|
-
"processing_receipt_20240315.jpg"
|
|
1742
|
-
]
|
|
1743
|
-
}),
|
|
1744
|
-
issue_timestamp: UnixTimestampSchema.optional().meta({
|
|
1745
|
-
title: "Issue Timestamp",
|
|
1746
|
-
description: "Unix timestamp in milliseconds when the attachment was issued",
|
|
1747
|
-
examples: [17105184e5, 17040672e5, 17152704e5]
|
|
1748
|
-
}),
|
|
1749
|
-
issuer: NonEmptyStringSchema.max(100).optional().meta({
|
|
1750
|
-
title: "Attachment Issuer",
|
|
1751
|
-
description: "Entity that issued the attachment",
|
|
1752
|
-
examples: [
|
|
1753
|
-
"Environmental Protection Agency",
|
|
1754
|
-
"Waste Management Solutions Ltd",
|
|
1755
|
-
"Green Recycling Corp",
|
|
1756
|
-
"City Waste Authority",
|
|
1757
|
-
"EcoProcess Industries",
|
|
1758
|
-
"Regional Environmental Office"
|
|
1759
|
-
]
|
|
1760
|
-
})
|
|
1761
|
-
}).meta({
|
|
1762
|
-
title: "Event Attachment",
|
|
1763
|
-
description: "Supporting event attachment"
|
|
1764
|
-
});
|
|
1765
|
-
var MassIDChainOfCustodyEventSchema = zod.z.strictObject({
|
|
1766
|
-
event_id: UuidSchema.meta({
|
|
1767
|
-
title: "Event ID",
|
|
1768
|
-
description: "Unique event identifier"
|
|
1769
|
-
}),
|
|
1770
|
-
event_name: NonEmptyStringSchema.max(50).meta({
|
|
1771
|
-
title: "Event Name",
|
|
1772
|
-
description: "Name of custody or processing event",
|
|
1773
|
-
examples: ["Sorting", "Processing", "Recycling", "Weighing"]
|
|
1774
|
-
}),
|
|
1775
|
-
description: NonEmptyStringSchema.max(200).optional().meta({
|
|
1776
|
-
title: "Event Description",
|
|
1777
|
-
description: "Detailed description of what happened during this event",
|
|
1778
|
-
examples: [
|
|
1779
|
-
"Waste collected from residential area using collection truck",
|
|
1780
|
-
"Material sorted into recyclable and non-recyclable fractions",
|
|
1781
|
-
"Plastic waste processed through shredding and washing",
|
|
1782
|
-
"Waste transferred to authorized recycling facility",
|
|
1783
|
-
"Final disposal at licensed landfill site",
|
|
1784
|
-
"Quality inspection and contamination assessment completed"
|
|
1785
|
-
]
|
|
1786
|
-
}),
|
|
1787
|
-
timestamp: UnixTimestampSchema.meta({
|
|
1788
|
-
title: "Event Timestamp",
|
|
1789
|
-
description: "Unix timestamp in milliseconds when the event occurred",
|
|
1790
|
-
examples: [17105184e5, 17040672e5, 17152704e5]
|
|
1791
|
-
}),
|
|
1792
|
-
participant_id_hash: Sha256HashSchema.meta({
|
|
1793
|
-
title: "Participant ID Hash",
|
|
1794
|
-
description: "Reference to participant in the participants array"
|
|
1795
|
-
}),
|
|
1796
|
-
location_id_hash: Sha256HashSchema.meta({
|
|
1797
|
-
title: "Location ID Hash",
|
|
1798
|
-
description: "Reference to location in the locations array"
|
|
1799
|
-
}),
|
|
1800
|
-
weight: NonNegativeFloatSchema.optional().meta({
|
|
1801
|
-
title: "Event Weight",
|
|
1802
|
-
description: "Mass weight after this event"
|
|
1803
|
-
}),
|
|
1804
|
-
attributes: zod.z.array(EventAttributeSchema).optional().meta({
|
|
1805
|
-
title: "Event Attributes",
|
|
1806
|
-
description: "Additional attributes specific to this event"
|
|
1807
|
-
}),
|
|
1808
|
-
attachments: zod.z.array(EventAttachmentSchema).optional().meta({
|
|
1809
|
-
title: "Event Attachments",
|
|
1810
|
-
description: "Associated attachments for this event"
|
|
1811
|
-
})
|
|
1812
|
-
}).meta({
|
|
1813
|
-
title: "Chain of Custody Event",
|
|
1814
|
-
description: "Chain of custody event"
|
|
1815
|
-
});
|
|
1816
|
-
var MassIDChainOfCustodySchema = zod.z.strictObject({
|
|
1817
|
-
events: zod.z.array(MassIDChainOfCustodyEventSchema).min(1).meta({
|
|
1818
|
-
title: "Custody Events",
|
|
1819
|
-
description: "Chronological sequence of custody transfer and processing events"
|
|
1820
|
-
}),
|
|
1821
|
-
total_duration_minutes: MinutesSchema.meta({
|
|
1822
|
-
title: "Total Duration (minutes)",
|
|
1823
|
-
description: "Total time from first to last event in minutes"
|
|
1824
|
-
})
|
|
1825
|
-
}).meta({
|
|
1826
|
-
title: "Chain of Custody",
|
|
1827
|
-
description: "Complete chain of custody tracking from waste generation to final processing"
|
|
1828
|
-
});
|
|
1829
|
-
var MassIDGeographicDataSchema = zod.z.strictObject({
|
|
1830
|
-
from_location_id_hash: Sha256HashSchema.meta({
|
|
1831
|
-
title: "From Location ID Hash",
|
|
1832
|
-
description: "Reference hash of the location where the waste started movement"
|
|
1833
|
-
}),
|
|
1834
|
-
to_location_id_hash: Sha256HashSchema.meta({
|
|
1835
|
-
title: "To Location ID Hash",
|
|
1836
|
-
description: "Reference hash of the location where the waste ended movement"
|
|
1837
|
-
}),
|
|
1838
|
-
first_reported_timestamp: UnixTimestampSchema.meta({
|
|
1839
|
-
title: "First Reported Timestamp",
|
|
1840
|
-
description: "Unix timestamp in milliseconds when the waste was first reported/collected at the origin location",
|
|
1841
|
-
examples: [17105184e5, 17040672e5, 17152704e5]
|
|
1842
|
-
}),
|
|
1843
|
-
last_reported_timestamp: UnixTimestampSchema.meta({
|
|
1844
|
-
title: "Last Reported Timestamp",
|
|
1845
|
-
description: "Unix timestamp in milliseconds when the waste was last reported/processed at the destination location",
|
|
1846
|
-
examples: [17106048e5, 17041536e5, 17153568e5]
|
|
1847
|
-
})
|
|
1848
|
-
}).refine((data) => {
|
|
1849
|
-
return data.first_reported_timestamp <= data.last_reported_timestamp;
|
|
1850
|
-
}, "first_reported_timestamp must be before or equal to last_reported_timestamp").meta({
|
|
1851
|
-
title: "Geographic Data",
|
|
1852
|
-
description: "Simplified geographic information tracking waste movement from origin to destination with temporal bounds"
|
|
1853
|
-
});
|
|
1854
|
-
var MassIDDataSchema = zod.z.strictObject({
|
|
1855
|
-
waste_properties: MassIDWastePropertiesSchema,
|
|
1856
|
-
locations: uniqueBy(
|
|
1857
|
-
LocationSchema,
|
|
1858
|
-
(loc) => loc.id_hash,
|
|
1859
|
-
"Location ID hashes must be unique"
|
|
1860
|
-
).min(1).meta({
|
|
1861
|
-
title: "Locations",
|
|
1862
|
-
description: "All locations referenced in this MassID, indexed by ID"
|
|
1863
|
-
}),
|
|
1864
|
-
participants: uniqueBy(
|
|
1865
|
-
ParticipantSchema,
|
|
1866
|
-
(p) => p.id_hash,
|
|
1867
|
-
"Participant ID hashes must be unique"
|
|
1868
|
-
).min(1).meta({
|
|
1869
|
-
title: "Participants",
|
|
1870
|
-
description: "All participants referenced in this MassID, indexed by ID"
|
|
1871
|
-
}),
|
|
1872
|
-
chain_of_custody: MassIDChainOfCustodySchema,
|
|
1873
|
-
geographic_data: MassIDGeographicDataSchema
|
|
1874
|
-
}).refine((data) => {
|
|
1875
|
-
const participantIdSet = new Set(
|
|
1876
|
-
data.participants.map((participant) => participant.id_hash)
|
|
1877
|
-
);
|
|
1878
|
-
const eventParticipantIds = data.chain_of_custody.events.map(
|
|
1879
|
-
(event) => event.participant_id_hash
|
|
1880
|
-
);
|
|
1881
|
-
const allEventParticipantsExist = eventParticipantIds.every(
|
|
1882
|
-
(participantId) => participantIdSet.has(participantId)
|
|
1883
|
-
);
|
|
1884
|
-
return allEventParticipantsExist;
|
|
1885
|
-
}, "All participant ID hashes in chain of custody events must exist in participants array").refine((data) => {
|
|
1886
|
-
const locationIdSet = new Set(
|
|
1887
|
-
data.locations.map((location) => location.id_hash)
|
|
1888
|
-
);
|
|
1889
|
-
const eventLocationIds = data.chain_of_custody.events.map(
|
|
1890
|
-
(event) => event.location_id_hash
|
|
1891
|
-
);
|
|
1892
|
-
const allEventLocationsExist = eventLocationIds.every(
|
|
1893
|
-
(locationId) => locationIdSet.has(locationId)
|
|
1894
|
-
);
|
|
1895
|
-
return allEventLocationsExist;
|
|
1896
|
-
}, "All location ID hashes in chain of custody events must exist in locations array").meta({
|
|
1897
|
-
title: "MassID Data",
|
|
1898
|
-
description: "MassID data containing waste tracking and chain of custody information"
|
|
1870
|
+
description: "MassID NFT attributes array. Provide the canonical set covering waste (type, subtype, net weight), origin (country, municipality, administrative division), logistics (vehicle, manifests, weighing method/scale), and lifecycle timestamps (pick-up, drop-off, recycling). Length is validated; specific composition is producer-controlled."
|
|
1899
1871
|
});
|
|
1872
|
+
var isPickUpEvent = (event) => event.event_name === "Pick-up";
|
|
1873
|
+
var isWeighingEvent = (event) => event.event_name === "Weighing";
|
|
1900
1874
|
var MassIDIpfsSchemaMeta = {
|
|
1901
1875
|
title: "MassID NFT IPFS Record",
|
|
1902
1876
|
description: "Complete MassID NFT IPFS record including fixed attributes and detailed waste tracking data",
|
|
@@ -1912,6 +1886,148 @@ var MassIDIpfsSchema = NftIpfsSchema.safeExtend({
|
|
|
1912
1886
|
}),
|
|
1913
1887
|
attributes: MassIDAttributesSchema,
|
|
1914
1888
|
data: MassIDDataSchema
|
|
1889
|
+
}).superRefine((record, ctx) => {
|
|
1890
|
+
const { data, attributes } = record;
|
|
1891
|
+
const findAttribute = (traitType) => {
|
|
1892
|
+
const index = attributes.findIndex(
|
|
1893
|
+
(attribute) => attribute.trait_type === traitType
|
|
1894
|
+
);
|
|
1895
|
+
return {
|
|
1896
|
+
attribute: index >= 0 ? attributes[index] : void 0,
|
|
1897
|
+
index
|
|
1898
|
+
};
|
|
1899
|
+
};
|
|
1900
|
+
const assertAttributeMatches = (traitType, expectedValue, sourceDescription) => {
|
|
1901
|
+
const { attribute, index } = findAttribute(traitType);
|
|
1902
|
+
if (expectedValue === void 0 || expectedValue === null) {
|
|
1903
|
+
if (attribute) {
|
|
1904
|
+
ctx.addIssue({
|
|
1905
|
+
code: "custom",
|
|
1906
|
+
path: ["attributes", index],
|
|
1907
|
+
message: `${traitType} attribute must be omitted when ${sourceDescription} is not provided`
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
if (!attribute) {
|
|
1913
|
+
ctx.addIssue({
|
|
1914
|
+
code: "custom",
|
|
1915
|
+
path: ["attributes"],
|
|
1916
|
+
message: `${traitType} attribute must be present and match ${sourceDescription}`
|
|
1917
|
+
});
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
if (attribute.value !== expectedValue) {
|
|
1921
|
+
ctx.addIssue({
|
|
1922
|
+
code: "custom",
|
|
1923
|
+
path: ["attributes", index, "value"],
|
|
1924
|
+
message: `${traitType} attribute must equal ${sourceDescription}`
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
const assertTimestampAttributeMatches = (traitType, isoTimestamp, sourceDescription) => {
|
|
1929
|
+
if (!isoTimestamp) {
|
|
1930
|
+
assertAttributeMatches(traitType, void 0, sourceDescription);
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
const timestamp = Date.parse(isoTimestamp);
|
|
1934
|
+
if (Number.isNaN(timestamp)) {
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
assertAttributeMatches(traitType, timestamp, sourceDescription);
|
|
1938
|
+
};
|
|
1939
|
+
assertAttributeMatches(
|
|
1940
|
+
"Waste Type",
|
|
1941
|
+
data.waste_properties.type,
|
|
1942
|
+
"waste_properties.type"
|
|
1943
|
+
);
|
|
1944
|
+
assertAttributeMatches(
|
|
1945
|
+
"Waste Subtype",
|
|
1946
|
+
data.waste_properties.subtype,
|
|
1947
|
+
"waste_properties.subtype"
|
|
1948
|
+
);
|
|
1949
|
+
assertAttributeMatches(
|
|
1950
|
+
"Weight (kg)",
|
|
1951
|
+
data.waste_properties.net_weight,
|
|
1952
|
+
"waste_properties.net_weight"
|
|
1953
|
+
);
|
|
1954
|
+
assertAttributeMatches(
|
|
1955
|
+
"Local Waste Classification ID",
|
|
1956
|
+
data.waste_properties.local_classification?.code,
|
|
1957
|
+
"waste_properties.local_classification.code"
|
|
1958
|
+
);
|
|
1959
|
+
const pickUpEvent = data.events.find(isPickUpEvent);
|
|
1960
|
+
const pickUpLocation = pickUpEvent ? data.locations.find(
|
|
1961
|
+
(location) => location.id_hash === pickUpEvent.location_id_hash
|
|
1962
|
+
) : void 0;
|
|
1963
|
+
assertAttributeMatches(
|
|
1964
|
+
"Origin Country",
|
|
1965
|
+
pickUpLocation?.country,
|
|
1966
|
+
"Pick-up event location.country"
|
|
1967
|
+
);
|
|
1968
|
+
assertAttributeMatches(
|
|
1969
|
+
"Origin Municipality",
|
|
1970
|
+
pickUpLocation?.municipality,
|
|
1971
|
+
"Pick-up event location.municipality"
|
|
1972
|
+
);
|
|
1973
|
+
assertAttributeMatches(
|
|
1974
|
+
"Origin Administrative Division",
|
|
1975
|
+
pickUpLocation?.administrative_division,
|
|
1976
|
+
"Pick-up event location.administrative_division"
|
|
1977
|
+
);
|
|
1978
|
+
assertTimestampAttributeMatches(
|
|
1979
|
+
"Pick-up Date",
|
|
1980
|
+
pickUpEvent?.timestamp,
|
|
1981
|
+
"Pick-up event timestamp"
|
|
1982
|
+
);
|
|
1983
|
+
assertAttributeMatches(
|
|
1984
|
+
"Pick-up Vehicle Type",
|
|
1985
|
+
pickUpEvent?.data?.vehicle_type,
|
|
1986
|
+
"Pick-up event vehicle_type"
|
|
1987
|
+
);
|
|
1988
|
+
const dropOffEvent = data.events.find(
|
|
1989
|
+
(event) => event.event_name === "Drop-off"
|
|
1990
|
+
);
|
|
1991
|
+
assertTimestampAttributeMatches(
|
|
1992
|
+
"Drop-off Date",
|
|
1993
|
+
dropOffEvent?.timestamp,
|
|
1994
|
+
"Drop-off event timestamp"
|
|
1995
|
+
);
|
|
1996
|
+
const recyclingEvent = data.events.find(
|
|
1997
|
+
(event) => event.event_name === "Recycling"
|
|
1998
|
+
);
|
|
1999
|
+
assertTimestampAttributeMatches(
|
|
2000
|
+
"Recycling Date",
|
|
2001
|
+
recyclingEvent?.timestamp,
|
|
2002
|
+
"Recycling event timestamp"
|
|
2003
|
+
);
|
|
2004
|
+
const weighingEvent = data.events.find(isWeighingEvent);
|
|
2005
|
+
assertAttributeMatches(
|
|
2006
|
+
"Weighing Capture Method",
|
|
2007
|
+
weighingEvent?.data?.weighing_capture_method,
|
|
2008
|
+
"Weighing event weighing_capture_method"
|
|
2009
|
+
);
|
|
2010
|
+
assertAttributeMatches(
|
|
2011
|
+
"Scale Type",
|
|
2012
|
+
weighingEvent?.data?.scale_type,
|
|
2013
|
+
"Weighing event scale_type"
|
|
2014
|
+
);
|
|
2015
|
+
const recyclingManifest = data.attachments?.find(
|
|
2016
|
+
(attachment) => attachment.type === "Recycling Manifest" && attachment.document_number
|
|
2017
|
+
);
|
|
2018
|
+
assertAttributeMatches(
|
|
2019
|
+
"Recycling Manifest Number",
|
|
2020
|
+
recyclingManifest?.document_number,
|
|
2021
|
+
"Recycling Manifest attachment document_number"
|
|
2022
|
+
);
|
|
2023
|
+
const transportManifest = data.attachments?.find(
|
|
2024
|
+
(attachment) => attachment.type === "Transport Manifest" && attachment.document_number
|
|
2025
|
+
);
|
|
2026
|
+
assertAttributeMatches(
|
|
2027
|
+
"Transport Manifest Number",
|
|
2028
|
+
transportManifest?.document_number,
|
|
2029
|
+
"Transport Manifest attachment document_number"
|
|
2030
|
+
);
|
|
1915
2031
|
}).meta(MassIDIpfsSchemaMeta);
|
|
1916
2032
|
var GasIDAttributeMethodologySchema = MethodologyAttributeSchema;
|
|
1917
2033
|
var GasIDAttributeGasTypeSchema = NftAttributeSchema.safeExtend({
|
|
@@ -3431,7 +3547,6 @@ exports.EPSILON = EPSILON;
|
|
|
3431
3547
|
exports.EthereumAddressSchema = EthereumAddressSchema;
|
|
3432
3548
|
exports.ExternalIdSchema = ExternalIdSchema;
|
|
3433
3549
|
exports.ExternalUrlSchema = ExternalUrlSchema;
|
|
3434
|
-
exports.FacilityTypeSchema = FacilityTypeSchema;
|
|
3435
3550
|
exports.GasIDAttributesSchema = GasIDAttributesSchema;
|
|
3436
3551
|
exports.GasIDDataSchema = GasIDDataSchema;
|
|
3437
3552
|
exports.GasIDIpfsSchema = GasIDIpfsSchema;
|
|
@@ -3439,6 +3554,7 @@ exports.GasIDIpfsSchemaMeta = GasIDIpfsSchemaMeta;
|
|
|
3439
3554
|
exports.GasIDReferenceSchema = GasIDReferenceSchema;
|
|
3440
3555
|
exports.HexColorSchema = HexColorSchema;
|
|
3441
3556
|
exports.HoursSchema = HoursSchema;
|
|
3557
|
+
exports.IbamaWasteClassificationSchema = IbamaWasteClassificationSchema;
|
|
3442
3558
|
exports.IpfsUriSchema = IpfsUriSchema;
|
|
3443
3559
|
exports.IsoAdministrativeDivisionCodeSchema = IsoAdministrativeDivisionCodeSchema;
|
|
3444
3560
|
exports.IsoCountryCodeSchema = IsoCountryCodeSchema;
|