@carrot-foundation/schemas 0.1.20 → 0.1.21

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 (36) hide show
  1. package/README.md +45 -0
  2. package/dist/index.cjs +1104 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +552 -0
  5. package/dist/index.d.ts +552 -2
  6. package/dist/index.js +1100 -1
  7. package/dist/index.js.map +1 -0
  8. package/package.json +6 -4
  9. package/dist/index.d.ts.map +0 -1
  10. package/dist/mass-id/index.d.ts +0 -3
  11. package/dist/mass-id/index.d.ts.map +0 -1
  12. package/dist/mass-id/index.js +0 -2
  13. package/dist/mass-id/mass-id.data.schema.d.ts +0 -256
  14. package/dist/mass-id/mass-id.data.schema.d.ts.map +0 -1
  15. package/dist/mass-id/mass-id.data.schema.js +0 -348
  16. package/dist/mass-id/mass-id.schema.d.ts +0 -297
  17. package/dist/mass-id/mass-id.schema.d.ts.map +0 -1
  18. package/dist/mass-id/mass-id.schema.js +0 -163
  19. package/dist/shared/base.schema.d.ts +0 -111
  20. package/dist/shared/base.schema.d.ts.map +0 -1
  21. package/dist/shared/base.schema.js +0 -127
  22. package/dist/shared/definitions.schema.d.ts +0 -96
  23. package/dist/shared/definitions.schema.d.ts.map +0 -1
  24. package/dist/shared/definitions.schema.js +0 -283
  25. package/dist/shared/entities/location.schema.d.ts +0 -55
  26. package/dist/shared/entities/location.schema.d.ts.map +0 -1
  27. package/dist/shared/entities/location.schema.js +0 -68
  28. package/dist/shared/entities/participant.schema.d.ts +0 -8
  29. package/dist/shared/entities/participant.schema.d.ts.map +0 -1
  30. package/dist/shared/entities/participant.schema.js +0 -24
  31. package/dist/shared/helpers.schema.d.ts +0 -4
  32. package/dist/shared/helpers.schema.d.ts.map +0 -1
  33. package/dist/shared/helpers.schema.js +0 -16
  34. package/dist/shared/nft.schema.d.ts +0 -116
  35. package/dist/shared/nft.schema.d.ts.map +0 -1
  36. package/dist/shared/nft.schema.js +0 -193
@@ -1,193 +0,0 @@
1
- import { z } from 'zod';
2
- import { BaseIpfsSchema } from './base.schema.js';
3
- import { EthereumAddressSchema, BlockchainChainIdSchema, TokenIdSchema, IpfsUriSchema, HexColorSchema, NonNegativeFloatSchema, RecordSchemaTypeSchema, } from './definitions.schema.js';
4
- import { uniqueBy } from './helpers.schema.js';
5
- const NftSchemaTypeSchema = RecordSchemaTypeSchema.extract([
6
- 'MassID',
7
- 'RecycledID',
8
- 'GasID',
9
- 'PurchaseID',
10
- ]).meta({
11
- title: 'NFT Schema Type',
12
- description: 'Type of schema for NFT records',
13
- });
14
- const BlockchainReferenceSchema = z
15
- .strictObject({
16
- smart_contract_address: EthereumAddressSchema.meta({
17
- title: 'Smart Contract Address',
18
- }),
19
- chain_id: BlockchainChainIdSchema.meta({
20
- title: 'Chain ID',
21
- description: 'Blockchain chain ID',
22
- }),
23
- network_name: z.string().min(5).max(100).meta({
24
- title: 'Network Name',
25
- description: 'Name of the blockchain network',
26
- }),
27
- token_id: TokenIdSchema.meta({
28
- title: 'Token ID',
29
- description: 'NFT token ID',
30
- }),
31
- })
32
- .meta({
33
- title: 'Blockchain Information',
34
- description: 'Blockchain-specific information for the NFT',
35
- });
36
- const ExternalLinkSchema = z
37
- .strictObject({
38
- label: z.string().min(1).max(50).meta({
39
- title: 'Link Label',
40
- description: 'Display name for the external link',
41
- }),
42
- url: z.url('Must be a valid URI').meta({
43
- title: 'Link URL',
44
- description: 'Direct URI to the linked resource',
45
- }),
46
- description: z.string().min(10).max(100).optional().meta({
47
- title: 'Link Description',
48
- description: 'Optional context about what the link provides',
49
- }),
50
- })
51
- .meta({
52
- title: 'External Link',
53
- description: 'External link with label and description',
54
- });
55
- const NftAttributeSchema = z
56
- .strictObject({
57
- trait_type: z.string().max(50).meta({
58
- title: 'Trait Type',
59
- description: 'Name of the trait or attribute',
60
- }),
61
- value: z.union([z.string(), z.number(), z.boolean()]).meta({
62
- title: 'Trait Value',
63
- description: 'Value of the trait - can be string, number, or boolean',
64
- }),
65
- display_type: z
66
- .enum(['number', 'date', 'boost_number', 'boost_percentage'])
67
- .optional()
68
- .meta({
69
- title: 'Display Type',
70
- description: 'How the trait should be displayed in marketplace UIs',
71
- }),
72
- max_value: NonNegativeFloatSchema.optional().meta({
73
- title: 'Max Value',
74
- description: 'Maximum possible value for numeric traits',
75
- }),
76
- })
77
- .meta({
78
- title: 'NFT Attribute',
79
- description: 'NFT attribute or trait with type and value',
80
- });
81
- export const NftIpfsSchema = BaseIpfsSchema.safeExtend({
82
- schema: BaseIpfsSchema.shape.schema.safeExtend({
83
- type: NftSchemaTypeSchema.meta({
84
- title: 'NFT Schema Type',
85
- description: 'Type/category of this NFT schema',
86
- }),
87
- }),
88
- blockchain: BlockchainReferenceSchema,
89
- name: z
90
- .string()
91
- .min(1)
92
- .max(100)
93
- .meta({
94
- title: 'NFT Name',
95
- description: 'Full display name for this NFT, including extra context',
96
- examples: [
97
- 'MassID #123 • Organic • 3.0t',
98
- 'RecycledID #456 • Plastic • 2.5t',
99
- 'GasID #789 • Methane • 1000 m³',
100
- ],
101
- }),
102
- short_name: z
103
- .string()
104
- .min(1)
105
- .max(50)
106
- .meta({
107
- title: 'Short Name',
108
- description: 'Compact name for UI summaries, tables, or tooltips',
109
- examples: ['MassID #123', 'RecycledID #456', 'GasID #789'],
110
- }),
111
- description: z
112
- .string()
113
- .min(10)
114
- .max(500)
115
- .meta({
116
- title: 'Description',
117
- description: "Human-readable summary of the NFT's role and context. Ideally, maximum 300 characters.",
118
- examples: [
119
- 'This MassID represents 3 metric tons of organic food waste from Enlatados Produção, tracked through complete chain of custody from generation to composting.',
120
- 'This RecycledID represents 2.5 metric tons of recycled plastic bottles processed by Green Solutions Ltd.',
121
- ],
122
- }),
123
- image: IpfsUriSchema.meta({
124
- title: 'Image URI',
125
- description: 'IPFS URI pointing to the preview image',
126
- }),
127
- background_color: HexColorSchema.optional().meta({
128
- title: 'Background Color',
129
- description: 'Hex color code for marketplace background display',
130
- }),
131
- animation_url: IpfsUriSchema.optional().meta({
132
- title: 'Animation URL',
133
- description: 'IPFS URI pointing to an animated or interactive media file',
134
- examples: [
135
- 'ipfs://QmAnimation123/mass-id-animation.mp4',
136
- 'ipfs://QmInteractive456/recycled-visualization.webm',
137
- ],
138
- }),
139
- external_links: uniqueBy(ExternalLinkSchema, (link) => link.url, 'External link URLs must be unique')
140
- .max(10)
141
- .optional()
142
- .meta({
143
- title: 'External Links',
144
- description: 'Optional list of public resource links with labels',
145
- examples: [
146
- [
147
- {
148
- label: 'Carrot Explorer',
149
- url: 'https://explore.carrot.eco/document/ad44dd3f-f176-4b98-bf78-5ee6e77d0530',
150
- description: 'Complete chain of custody and audit trail',
151
- },
152
- {
153
- label: 'Carrot White Paper',
154
- url: 'https://carrot.eco/whitepaper.pdf',
155
- description: 'Carrot Foundation technical and impact white paper',
156
- },
157
- ],
158
- ],
159
- }),
160
- attributes: uniqueBy(NftAttributeSchema, (attr) => attr.trait_type, 'Attribute trait_type values must be unique').meta({
161
- title: 'NFT Attributes',
162
- description: 'List of visual traits and filterable attributes compatible with NFT marketplaces',
163
- examples: [
164
- [
165
- {
166
- trait_type: 'Waste Type',
167
- value: 'Organic',
168
- },
169
- {
170
- trait_type: 'Waste Subtype',
171
- value: 'Food, Food Waste and Beverages',
172
- },
173
- {
174
- trait_type: 'Weight (kg)',
175
- value: 3000,
176
- display_type: 'number',
177
- },
178
- {
179
- trait_type: 'Origin Country',
180
- value: 'Brazil',
181
- },
182
- {
183
- trait_type: 'Pick-up Date',
184
- value: '2024-12-05',
185
- display_type: 'date',
186
- },
187
- ],
188
- ],
189
- }),
190
- }).meta({
191
- title: 'NFT IPFS Record',
192
- description: 'NFT-specific fields for Carrot IPFS records',
193
- });