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