@carrot-foundation/schemas 0.1.6

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.
Files changed (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +45 -0
  3. package/dist/index.js +1 -0
  4. package/dist/mass-id/index.js +2 -0
  5. package/dist/mass-id/mass-id.data.schema.js +346 -0
  6. package/dist/mass-id/mass-id.schema.js +162 -0
  7. package/dist/shared/base.schema.js +127 -0
  8. package/dist/shared/definitions.schema.js +283 -0
  9. package/dist/shared/entities/location.schema.js +68 -0
  10. package/dist/shared/entities/participant.schema.js +24 -0
  11. package/dist/shared/helpers.schema.js +16 -0
  12. package/dist/shared/nft.schema.js +193 -0
  13. package/package.json +89 -0
  14. package/schemas/ipfs/collection/collection.example.json +25 -0
  15. package/schemas/ipfs/collection/collection.schema.json +47 -0
  16. package/schemas/ipfs/credit/credit.example.json +27 -0
  17. package/schemas/ipfs/credit/credit.schema.json +61 -0
  18. package/schemas/ipfs/gas-id/gas-id.attributes.schema.json +219 -0
  19. package/schemas/ipfs/gas-id/gas-id.data.schema.json +120 -0
  20. package/schemas/ipfs/gas-id/gas-id.example.json +245 -0
  21. package/schemas/ipfs/gas-id/gas-id.schema.json +29 -0
  22. package/schemas/ipfs/mass-id/mass-id.example.json +318 -0
  23. package/schemas/ipfs/mass-id/mass-id.schema.json +1325 -0
  24. package/schemas/ipfs/mass-id-audit/mass-id-audit.data.schema.json +130 -0
  25. package/schemas/ipfs/mass-id-audit/mass-id-audit.example.json +291 -0
  26. package/schemas/ipfs/mass-id-audit/mass-id-audit.schema.json +26 -0
  27. package/schemas/ipfs/methodology/methodology.data.schema.json +121 -0
  28. package/schemas/ipfs/methodology/methodology.example.json +222 -0
  29. package/schemas/ipfs/methodology/methodology.schema.json +26 -0
  30. package/schemas/ipfs/purchase-id/purchase-id.attributes.schema.json +91 -0
  31. package/schemas/ipfs/purchase-id/purchase-id.data.schema.json +337 -0
  32. package/schemas/ipfs/purchase-id/purchase-id.example.json +224 -0
  33. package/schemas/ipfs/purchase-id/purchase-id.schema.json +29 -0
  34. package/schemas/ipfs/recycled-id/recycled-id.attributes.schema.json +202 -0
  35. package/schemas/ipfs/recycled-id/recycled-id.data.schema.json +63 -0
  36. package/schemas/ipfs/recycled-id/recycled-id.example.json +213 -0
  37. package/schemas/ipfs/recycled-id/recycled-id.schema.json +29 -0
  38. package/schemas/ipfs/shared/base/base.schema.json +163 -0
  39. package/schemas/ipfs/shared/certificate/certificate.schema.json +145 -0
  40. package/schemas/ipfs/shared/definitions/definitions.schema.json +250 -0
  41. package/schemas/ipfs/shared/entities/location/location.schema.json +95 -0
  42. package/schemas/ipfs/shared/entities/participant/participant.schema.json +28 -0
  43. package/schemas/ipfs/shared/nft/nft.schema.json +182 -0
  44. package/schemas/ipfs/shared/references/audit-reference/audit-reference.schema.json +42 -0
  45. package/schemas/ipfs/shared/references/gas-id-reference/gas-id-reference.schema.json +27 -0
  46. package/schemas/ipfs/shared/references/mass-id-reference/mass-id-reference.schema.json +27 -0
  47. package/schemas/ipfs/shared/references/methodology-reference/methodology-reference.schema.json +34 -0
@@ -0,0 +1,145 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/carrot-foundation/schemas/refs/heads/main/schemas/ipfs/shared/certificate/certificate.schema.json",
4
+ "title": "Carrot Certificate Definitions",
5
+ "description": "Reusable certificate definitions for Carrot IPFS JSON schemas.",
6
+ "type": "object",
7
+ "$defs": {
8
+ "waste_classification": {
9
+ "type": "object",
10
+ "required": ["primary_type", "subtype", "net_weight_kg"],
11
+ "title": "Waste Classification",
12
+ "description": "Classification of the source waste (MassID)",
13
+ "properties": {
14
+ "primary_type": {
15
+ "$ref": "../definitions/definitions.schema.json#/$defs/waste_type",
16
+ "title": "Source Waste Primary Type",
17
+ "description": "Primary type of the source waste"
18
+ },
19
+ "subtype": {
20
+ "$ref": "../definitions/definitions.schema.json#/$defs/waste_subtype",
21
+ "title": "Source Waste Subtype",
22
+ "description": "Subtype of the source waste"
23
+ },
24
+ "net_weight_kg": {
25
+ "$ref": "../definitions/definitions.schema.json#/$defs/weight_kg",
26
+ "title": "Source Waste Net Weight",
27
+ "description": "Net weight of the source waste"
28
+ }
29
+ },
30
+ "additionalProperties": false
31
+ },
32
+ "accredited_participants": {
33
+ "type": "array",
34
+ "minItems": 1,
35
+ "title": "Accredited Participants",
36
+ "items": {
37
+ "type": "object",
38
+ "required": [
39
+ "participant_id",
40
+ "name",
41
+ "role",
42
+ "external_url",
43
+ "accreditation_id"
44
+ ],
45
+ "properties": {
46
+ "participant_id": {
47
+ "$ref": "../definitions/definitions.schema.json#/$defs/uuid",
48
+ "title": "Participant ID"
49
+ },
50
+ "name": {
51
+ "$ref": "../definitions/definitions.schema.json#/$defs/participant_name"
52
+ },
53
+ "role": {
54
+ "$ref": "../definitions/definitions.schema.json#/$defs/participant_role"
55
+ },
56
+ "accreditation_id": {
57
+ "$ref": "../definitions/definitions.schema.json#/$defs/uuid",
58
+ "title": "Accreditation ID"
59
+ },
60
+ "external_url": {
61
+ "$ref": "../definitions/definitions.schema.json#/$defs/external_url",
62
+ "title": "Participant Accreditation External URL"
63
+ }
64
+ },
65
+ "additionalProperties": false
66
+ }
67
+ },
68
+ "participant_rewards": {
69
+ "type": "object",
70
+ "required": ["distribution_basis", "reward_allocations"],
71
+ "title": "Participant Rewards",
72
+ "description": "Rewards distribution to participants",
73
+ "properties": {
74
+ "distribution_basis": {
75
+ "$ref": "../definitions/definitions.schema.json#/$defs/non_empty_string",
76
+ "maxLength": 200,
77
+ "title": "Distribution Basis",
78
+ "description": "Basis for the rewards distribution"
79
+ },
80
+ "reward_allocations": {
81
+ "type": "array",
82
+ "minItems": 1,
83
+ "title": "Reward Allocations",
84
+ "description": "Rewards percentage allocated to each participant",
85
+ "items": {
86
+ "type": "object",
87
+ "required": [
88
+ "participant_id",
89
+ "participant_name",
90
+ "role",
91
+ "reward_percentage",
92
+ "effective_percentage"
93
+ ],
94
+ "properties": {
95
+ "participant_id": {
96
+ "$ref": "../definitions/definitions.schema.json#/$defs/uuid",
97
+ "title": "Participant ID"
98
+ },
99
+ "participant_name": {
100
+ "$ref": "../definitions/definitions.schema.json#/$defs/participant_name"
101
+ },
102
+ "role": {
103
+ "$ref": "../definitions/definitions.schema.json#/$defs/participant_role"
104
+ },
105
+ "reward_percentage": {
106
+ "$ref": "../definitions/definitions.schema.json#/$defs/percentage",
107
+ "title": "Reward Percentage",
108
+ "description": "Reward percentage allocated to the participant"
109
+ },
110
+ "large_business_discount_applied": {
111
+ "type": "boolean",
112
+ "title": "Large Business Discount Applied",
113
+ "description": "Whether the large business discount was applied"
114
+ },
115
+ "effective_percentage": {
116
+ "$ref": "../definitions/definitions.schema.json#/$defs/percentage",
117
+ "title": "Effective Percentage",
118
+ "description": "Effective percentage of the reward"
119
+ }
120
+ },
121
+ "additionalProperties": false
122
+ }
123
+ },
124
+ "distribution_notes": {
125
+ "type": "object",
126
+ "properties": {
127
+ "large_business_discount_applied": {
128
+ "$ref": "../definitions/definitions.schema.json#/$defs/non_empty_string",
129
+ "description": "Description of the large business discount applied",
130
+ "example": "50% reduction applied to participants with >$4M annual revenue"
131
+ },
132
+ "redirected_rewards": {
133
+ "$ref": "../definitions/definitions.schema.json#/$defs/non_empty_string",
134
+ "description": "Description of the redirected rewards",
135
+ "example": "Discounted rewards from large businesses redirected to accredited NGOs"
136
+ }
137
+ },
138
+ "additionalProperties": false
139
+ }
140
+ },
141
+ "additionalProperties": false
142
+ }
143
+ },
144
+ "additionalProperties": false
145
+ }
@@ -0,0 +1,250 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/carrot-foundation/schemas/refs/heads/main/schemas/ipfs/shared/definitions/definitions.schema.json",
4
+ "title": "Carrot Shared Definitions",
5
+ "description": "Reusable atomic, domain, and composite definitions for Carrot IPFS JSON schemas.",
6
+ "type": "object",
7
+ "$defs": {
8
+ "uuid": {
9
+ "type": "string",
10
+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
11
+ "description": "UUID v4 string in canonical format.",
12
+ "example": "6f520d88-864d-432d-bf9f-5c3166c4818f"
13
+ },
14
+ "ethereum_address": {
15
+ "type": "string",
16
+ "pattern": "^0x[a-f0-9]{40}$",
17
+ "title": "Ethereum Address",
18
+ "description": "Ethereum address in lowercase hexadecimal format.",
19
+ "example": "0xabc123def456789abcdef123456789abcdef1234"
20
+ },
21
+ "iso_timestamp": {
22
+ "type": "string",
23
+ "format": "date-time",
24
+ "title": "ISO 8601 Timestamp",
25
+ "description": "ISO 8601 timestamp with timezone.",
26
+ "example": "2024-12-05T11:02:47.000Z"
27
+ },
28
+ "iso_date": {
29
+ "type": "string",
30
+ "format": "date",
31
+ "title": "ISO 8601 Date",
32
+ "description": "ISO 8601 date (YYYY-MM-DD).",
33
+ "example": "2024-02-10"
34
+ },
35
+ "iso_country_code": {
36
+ "type": "string",
37
+ "pattern": "^[A-Z]{2}$",
38
+ "title": "Country Code",
39
+ "description": "ISO 3166-1 alpha-2 country code.",
40
+ "example": "BR"
41
+ },
42
+ "iso_administrative_division_code": {
43
+ "type": "string",
44
+ "pattern": "^[A-Z]{2}-[A-Z0-9]{1,3}$",
45
+ "title": "Administrative Division Code",
46
+ "description": "ISO 3166-2 administrative division code.",
47
+ "example": "BR-AP"
48
+ },
49
+ "latitude": {
50
+ "type": "number",
51
+ "minimum": -90,
52
+ "maximum": 90,
53
+ "description": "Latitude in decimal degrees.",
54
+ "example": -23.39
55
+ },
56
+ "longitude": {
57
+ "type": "number",
58
+ "minimum": -180,
59
+ "maximum": 180,
60
+ "description": "Longitude in decimal degrees.",
61
+ "example": -51.13
62
+ },
63
+ "weight_kg": {
64
+ "type": "number",
65
+ "minimum": 0,
66
+ "title": "Weight in Kilograms",
67
+ "description": "Weight measurement in kilograms.",
68
+ "example": 1500.5
69
+ },
70
+ "name": {
71
+ "$ref": "#/$defs/non_empty_string",
72
+ "maxLength": 200
73
+ },
74
+ "slug": {
75
+ "$ref": "#/$defs/non_empty_string",
76
+ "pattern": "^[a-z0-9-]+$",
77
+ "maxLength": 100,
78
+ "title": "Slug",
79
+ "description": "URL-friendly identifier using lowercase letters, numbers, and hyphens only.",
80
+ "example": "bold-carbon-ch4"
81
+ },
82
+ "non_empty_string": {
83
+ "type": "string",
84
+ "minLength": 1
85
+ },
86
+ "waste_type": {
87
+ "$ref": "#/$defs/non_empty_string",
88
+ "title": "Waste Classification",
89
+ "description": "Primary waste material category following international standards.",
90
+ "example": "Organic"
91
+ },
92
+ "waste_subtype": {
93
+ "$ref": "#/$defs/non_empty_string",
94
+ "maxLength": 100,
95
+ "description": "Specific subcategory or detailed classification of the waste material.",
96
+ "example": "Food, Food Waste and Beverages"
97
+ },
98
+ "participant_role": {
99
+ "$ref": "#/$defs/non_empty_string",
100
+ "maxLength": 100,
101
+ "title": "Participant Role",
102
+ "description": "Role in the waste management supply chain.",
103
+ "example": "Transporter"
104
+ },
105
+ "participant_name": {
106
+ "$ref": "#/$defs/non_empty_string",
107
+ "maxLength": 100,
108
+ "title": "Participant Name",
109
+ "description": "Legal name of the participant.",
110
+ "example": "Eco Reciclagem"
111
+ },
112
+ "facility_type": {
113
+ "type": "string",
114
+ "enum": [
115
+ "Waste Generation",
116
+ "Collection Point",
117
+ "Transfer Station",
118
+ "Sorting Facility",
119
+ "Composting Facility",
120
+ "Recycling Facility",
121
+ "Processing Facility",
122
+ "Disposal Facility",
123
+ "Administrative Office"
124
+ ],
125
+ "title": "Facility Type",
126
+ "description": "Type of facility at a location.",
127
+ "example": "Recycling Facility"
128
+ },
129
+ "chain_id": {
130
+ "type": "integer",
131
+ "minimum": 1,
132
+ "title": "Blockchain network chain ID",
133
+ "description": "Blockchain network chain ID where the NFT is deployed.",
134
+ "example": 137
135
+ },
136
+ "percentage": {
137
+ "type": "number",
138
+ "minimum": 0,
139
+ "maximum": 100,
140
+ "title": "Percentage Value",
141
+ "description": "Percentage value between 0 and 100.",
142
+ "example": 25.5
143
+ },
144
+ "non_negative_integer": {
145
+ "type": "integer",
146
+ "minimum": 0,
147
+ "title": "Non-Negative Integer",
148
+ "description": "Non-negative integer value.",
149
+ "example": 100
150
+ },
151
+ "positive_integer": {
152
+ "type": "integer",
153
+ "minimum": 1,
154
+ "title": "Positive Integer",
155
+ "description": "Positive integer value.",
156
+ "example": 100
157
+ },
158
+ "non_negative_float": {
159
+ "type": "number",
160
+ "minimum": 0,
161
+ "title": "Non-Negative Float",
162
+ "description": "Non-negative float value.",
163
+ "example": 100.5
164
+ },
165
+ "hours": {
166
+ "type": "number",
167
+ "minimum": 0,
168
+ "multipleOf": 0.1,
169
+ "title": "Hours",
170
+ "description": "Time in hours.",
171
+ "example": 72.5
172
+ },
173
+ "ipfs_uri": {
174
+ "$ref": "#/$defs/non_empty_string",
175
+ "pattern": "^ipfs://[a-zA-Z0-9]+(/.*)?$",
176
+ "title": "IPFS URI",
177
+ "description": "IPFS URI pointing to content-addressed data using CID (Content Identifier). Format: ipfs://{CID}[/path]",
178
+ "examples": [
179
+ "ipfs://QmTy8w65yBXgyfG2ZBg5TrfB2hPjrDQH3RCQFJGkARStJb",
180
+ "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
181
+ "ipfs://QmHashExample/metadata.json"
182
+ ]
183
+ },
184
+ "semantic_version": {
185
+ "$ref": "#/$defs/non_empty_string",
186
+ "pattern": "^v?\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?(\\+[a-zA-Z0-9.-]+)?$",
187
+ "title": "Semantic Version",
188
+ "description": "Semantic version string (semver.org).",
189
+ "example": "v1.2.3"
190
+ },
191
+ "token_id": {
192
+ "$ref": "#/$defs/non_empty_string",
193
+ "pattern": "^[0-9]+$",
194
+ "title": "Token ID",
195
+ "description": "NFT token ID as numeric string (supports uint256).",
196
+ "example": "123"
197
+ },
198
+ "hex_color": {
199
+ "$ref": "#/$defs/non_empty_string",
200
+ "pattern": "^#[0-9A-F]{6}$",
201
+ "title": "Hex Color",
202
+ "description": "Hex color code with # prefix and uppercase.",
203
+ "example": "#FFFFFF"
204
+ },
205
+ "keccak256_hash": {
206
+ "$ref": "#/$defs/non_empty_string",
207
+ "pattern": "^0x[a-fA-F0-9]{64}$",
208
+ "title": "Keccak256 Hash",
209
+ "description": "Keccak256 hash as 32-byte hex string.",
210
+ "example": "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658"
211
+ },
212
+ "external_id": {
213
+ "$ref": "#/$defs/uuid",
214
+ "title": "External ID",
215
+ "description": "Off-chain reference ID (UUID from Carrot backend)."
216
+ },
217
+ "external_url": {
218
+ "$ref": "#/$defs/non_empty_string",
219
+ "format": "uri",
220
+ "title": "External URL",
221
+ "description": "External URL of the content.",
222
+ "example": "https://explore.carrot.eco/document/40e44dc8-75d4-4b6f-a5b2-420ab9482ee9"
223
+ },
224
+ "token_symbol": {
225
+ "$ref": "#/$defs/non_empty_string",
226
+ "maxLength": 10,
227
+ "pattern": "^[A-Z0-9-]+$",
228
+ "title": "Token Symbol",
229
+ "description": "ERC20 token symbol in uppercase letters and numbers only.",
230
+ "example": "C-CARB"
231
+ },
232
+ "relationship_type": {
233
+ "type": "string",
234
+ "enum": [
235
+ "collection",
236
+ "credit",
237
+ "gas-id",
238
+ "mass-id",
239
+ "mass-id-audit",
240
+ "methodology",
241
+ "purchase-id",
242
+ "recycled-id"
243
+ ],
244
+ "title": "Relationship Type",
245
+ "description": "Type of relationship between records.",
246
+ "example": "mass-id"
247
+ }
248
+ },
249
+ "additionalProperties": false
250
+ }
@@ -0,0 +1,95 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/carrot-foundation/schemas/refs/heads/main/schemas/ipfs/shared/entities/location/location.schema.json",
4
+ "title": "Geographic Location",
5
+ "description": "Geographic location with address and coordinate information.",
6
+ "type": "object",
7
+ "required": [
8
+ "id",
9
+ "municipality",
10
+ "administrative_division",
11
+ "administrative_division_code",
12
+ "country",
13
+ "country_code",
14
+ "responsible_participant_id",
15
+ "coordinates",
16
+ "facility_type"
17
+ ],
18
+ "properties": {
19
+ "id": {
20
+ "$ref": "../../definitions/definitions.schema.json#/$defs/uuid",
21
+ "title": "Location ID",
22
+ "description": "Unique identifier for the location."
23
+ },
24
+ "municipality": {
25
+ "$ref": "../../definitions/definitions.schema.json#/$defs/non_empty_string",
26
+ "maxLength": 50,
27
+ "description": "Municipality or city name.",
28
+ "example": "Macapá"
29
+ },
30
+ "administrative_division": {
31
+ "$ref": "../../definitions/definitions.schema.json#/$defs/non_empty_string",
32
+ "title": "Administrative Division",
33
+ "maxLength": 50,
34
+ "description": "State, province, or administrative region.",
35
+ "example": "Amapá"
36
+ },
37
+ "administrative_division_code": {
38
+ "$ref": "../../definitions/definitions.schema.json#/$defs/iso_administrative_division_code"
39
+ },
40
+ "country": {
41
+ "$ref": "../../definitions/definitions.schema.json#/$defs/non_empty_string",
42
+ "maxLength": 50,
43
+ "description": "Full country name in English.",
44
+ "example": "Brazil"
45
+ },
46
+ "country_code": {
47
+ "$ref": "../../definitions/definitions.schema.json#/$defs/iso_country_code"
48
+ },
49
+ "responsible_participant_id": {
50
+ "$ref": "../../definitions/definitions.schema.json#/$defs/uuid",
51
+ "title": "Responsible Participant ID",
52
+ "description": "ID of the participant responsible for this location."
53
+ },
54
+ "coordinates": {
55
+ "type": "object",
56
+ "title": "Location Coordinates",
57
+ "description": "GPS coordinates of the location.",
58
+ "required": ["latitude", "longitude", "precision_level"],
59
+ "properties": {
60
+ "latitude": {
61
+ "$ref": "../../definitions/definitions.schema.json#/$defs/latitude"
62
+ },
63
+ "longitude": {
64
+ "$ref": "../../definitions/definitions.schema.json#/$defs/longitude"
65
+ },
66
+ "precision_level": {
67
+ "type": "string",
68
+ "enum": ["exact", "neighborhood", "city", "region", "country"],
69
+ "title": "Coordinate Precision Level",
70
+ "description": "Level of coordinate precision.",
71
+ "example": "city"
72
+ }
73
+ },
74
+ "additionalProperties": false
75
+ },
76
+ "facility_type": {
77
+ "type": "string",
78
+ "enum": [
79
+ "Waste Generation",
80
+ "Collection Point",
81
+ "Transfer Station",
82
+ "Sorting Facility",
83
+ "Composting Facility",
84
+ "Recycling Facility",
85
+ "Processing Facility",
86
+ "Disposal Facility",
87
+ "Administrative Office"
88
+ ],
89
+ "title": "Facility Type",
90
+ "description": "Type of facility at a location.",
91
+ "example": "Recycling Facility"
92
+ }
93
+ },
94
+ "additionalProperties": false
95
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/carrot-foundation/schemas/refs/heads/main/schemas/ipfs/shared/entities/participant/participant.schema.json",
4
+ "title": "Participant",
5
+ "description": "A participant in the waste management supply chain.",
6
+ "type": "object",
7
+ "required": ["id", "name", "roles"],
8
+ "properties": {
9
+ "id": {
10
+ "$ref": "../../definitions/definitions.schema.json#/$defs/uuid",
11
+ "description": "Unique identifier for the participant."
12
+ },
13
+ "name": {
14
+ "$ref": "../../definitions/definitions.schema.json#/$defs/participant_name"
15
+ },
16
+ "roles": {
17
+ "type": "array",
18
+ "minItems": 1,
19
+ "uniqueItems": true,
20
+ "description": "Roles of the participant in the waste management supply chain.",
21
+ "items": {
22
+ "$ref": "../../definitions/definitions.schema.json#/$defs/participant_role"
23
+ },
24
+ "example": ["Waste Generator", "Transporter"]
25
+ }
26
+ },
27
+ "additionalProperties": false
28
+ }