Skip to content

Commit 71eaa82

Browse files
committed
refactor: enhance documentation for guides and improve visibility of features
1 parent 1a4107b commit 71eaa82

File tree

4 files changed

+198
-69
lines changed

4 files changed

+198
-69
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ Fork this repository and ensure you're working on the `main` branch:
150150

151151
- Add Arbitrum support
152152
- Adapt hardcoded address to feat with new contracts deployed on arbitrum
153+
- Add link to the new explorer feature Asset_Types in the guide =>
154+
`handle-schemas-dataset-types`
155+
- Move `manage-data/dataProtector/advanced/iApp` (Deserializer doc) in an other way to be more visible (may in build-iApp section)
153156
- complete `use-iapp` section
154157
- complete `explorer` section
155158
- complete `build-iapp` section

src/manage-data/guides/create-and-share-access.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,3 @@ steps:
229229
[schemas and dataset types](/manage-data/guides/handle-schemas-dataset-types)
230230
- **Monetize data**: Explore
231231
[data monetization strategies](/manage-data/guides/manage-data-monetization)
232-
233-
---
234-
235-
**TL;DR**: Protect data → Grant access to specific app + user → Data stays
236-
encrypted except inside authorized secure enclaves. You keep full control. 🔒

src/manage-data/guides/handle-schemas-dataset-types.md

Lines changed: 117 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ description:
66

77
# 🏷️ Handle Schemas and Dataset Types
88

9-
**Schemas are like TypeScript for your protected data.** They define the
10-
structure and types of your data automatically when you protect it, making it
11-
easy for iApps to know what they're working with.
9+
**Schemas are like content labels that describe what's inside your protected data.**
1210

13-
Think of schemas as **data labels** - they tell iApps "this protected data
11+
They define the structure and types of your data automatically when you protect
12+
it, making it easy for iApps to know what they're working with.
13+
14+
Think of schemas as **data fingerprints** - they tell iApps "this protected data
1415
contains an email address and a phone number" without revealing the actual
1516
values.
1617

@@ -20,12 +21,12 @@ When you protect data with DataProtector, the SDK automatically analyzes your
2021
JSON object and generates a schema. **No manual schema definition needed** -
2122
it's all handled for you.
2223

23-
```ts
24+
```ts twoslash
2425
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
2526

2627
const web3Provider = getWeb3Provider('PRIVATE_KEY');
2728
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
28-
29+
// ---cut---
2930
const protectedData = await dataProtectorCore.protectData({
3031
name: 'User Contact',
3132
data: {
@@ -38,20 +39,27 @@ const protectedData = await dataProtectorCore.protectData({
3839
},
3940
});
4041

41-
// The schema is automatically generated:
42-
console.log(protectedData.schema);
43-
/* Output:
42+
console.log('✅ Protected data created!');
43+
console.log('📍 Address:', protectedData.address);
44+
```
45+
46+
**🏷️ Generated Schema:**
47+
48+
```json
4449
{
45-
email: 'string',
46-
phoneNumber: 'string',
47-
preferences: {
48-
newsletter: 'bool',
49-
notifications: 'bool'
50+
"email": "string",
51+
"phoneNumber": "string",
52+
"preferences": {
53+
"newsletter": "bool",
54+
"notifications": "bool"
5055
}
5156
}
52-
*/
5357
```
5458

59+
::: info Schema Structure
60+
The schema automatically maps your data structure to types that iApps can understand and validate.
61+
:::
62+
5563
## Supported Data Types
5664

5765
The schema automatically detects these types:
@@ -65,16 +73,22 @@ The schema automatically detects these types:
6573
| `application/octet-stream` | Binary data | File contents |
6674
| `image/jpeg`, `image/png`, etc. | Media files | Images, videos |
6775

68-
::: tip Auto-Detection The SDK automatically detects file types based on
69-
content. No need to specify MIME types manually. :::
76+
::: tip Auto-Detection
77+
The SDK automatically detects file types based on
78+
content. No need to specify MIME types manually.
79+
:::
7080

7181
## Why Schemas Matter
7282

7383
### 🎯 **For iApp Development**
7484

7585
Schemas let your iApps validate and process data safely:
7686

77-
```js
87+
```ts twoslash
88+
import { IExecDataProtectorDeserializer } from '@iexec/dataprotector-deserializer';
89+
90+
const deserializer = new IExecDataProtectorDeserializer();
91+
// ---cut---
7892
// Inside your iApp
7993
const email = await deserializer.getValue('email', 'string');
8094
const preferences = await deserializer.getValue(
@@ -83,38 +97,64 @@ const preferences = await deserializer.getValue(
8397
);
8498
```
8599

100+
### 🛡️ **For Type Safety**
101+
102+
Prevents your iApps from processing incompatible data types.
103+
86104
### 🔍 **For Data Discovery**
87105

88106
Users can find relevant protected data without seeing the actual content:
89107

90-
```ts
91-
// Find all protected data with email addresses
92-
const query = { schema: { email: 'string' } };
93-
// Returns metadata only, no actual emails revealed
94-
```
95-
96-
### 🛡️ **For Type Safety**
108+
```ts twoslash
109+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
97110

98-
Prevents your iApps from processing incompatible data types.
111+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
112+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
113+
// ---cut---
114+
const listProtectedData = await dataProtectorCore.getProtectedData({
115+
requiredSchema: {
116+
email: 'string',
117+
},
118+
});
119+
```
99120

100121
## Real Examples
101122

102123
### Simple User Profile
103124

104-
```ts
125+
```ts twoslash
126+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
127+
128+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
129+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
130+
// ---cut---
105131
const userData = await dataProtectorCore.protectData({
106132
data: {
107133
108134
age: 25,
109135
isSubscribed: true,
110136
},
111137
});
112-
// Schema: { email: 'string', age: 'f64', isSubscribed: 'bool' }
138+
```
139+
140+
**🏷️ Generated Schema:**
141+
142+
```json
143+
{
144+
"email": "string",
145+
"age": "f64",
146+
"isSubscribed": "bool"
147+
}
113148
```
114149

115150
### Nested Contact Information
116151

117-
```ts
152+
```ts twoslash
153+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
154+
155+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
156+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
157+
// ---cut---
118158
const contactData = await dataProtectorCore.protectData({
119159
data: {
120160
personal: {
@@ -131,15 +171,43 @@ const contactData = await dataProtectorCore.protectData({
131171
},
132172
},
133173
});
134-
// Schema reflects the full nested structure
174+
```
175+
176+
**🏷️ Generated Schema:**
177+
178+
```json
179+
{
180+
"personal": {
181+
"firstName": "string",
182+
"lastName": "string"
183+
},
184+
"contact": {
185+
"email": "string",
186+
"phone": "string"
187+
},
188+
"preferences": {
189+
"marketing": "bool",
190+
"notifications": "bool"
191+
}
192+
}
135193
```
136194

137195
### File Data
138196

139-
```ts
140-
import { createArrayBufferFromFile } from '@iexec/dataprotector';
197+
```ts twoslash
198+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
199+
200+
// Mock function for the example
201+
function createArrayBufferFromFile(file: File): Promise<ArrayBuffer> {
202+
return Promise.resolve(new ArrayBuffer(0));
203+
}
204+
205+
// Get file from input element
206+
const file = new File([""], "example.jpg", { type: "image/jpeg" });
141207

142-
const file = document.getElementById('fileInput').files[0];
208+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
209+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
210+
// ---cut---
143211
const fileBuffer = await createArrayBufferFromFile(file);
144212

145213
const fileData = await dataProtectorCore.protectData({
@@ -149,20 +217,31 @@ const fileData = await dataProtectorCore.protectData({
149217
uploadDate: Date.now(),
150218
},
151219
});
152-
// Schema: { fileName: 'string', fileContent: 'image/jpeg', uploadDate: 'f64' }
220+
```
221+
222+
**🏷️ Schema for file upload:**
223+
224+
```json
225+
{
226+
"fileName": "string",
227+
"fileContent": "image/jpeg",
228+
"uploadDate": "f64"
229+
}
153230
```
154231

155232
## Using Schemas in iApps
156233

157234
Once you have protected data with a schema, you'll want to process it inside an
158235
iApp.
159236

160-
::: warning Type Matching **Your iApp and frontend must use the same field names
237+
::: warning Type Matching
238+
**Your iApp and frontend must use the same field names
161239
and types.** If they don't match, you'll get runtime errors when processing the
162-
data. :::
240+
data.
241+
:::
163242

164243
**Ready to build an iApp?** Check out our detailed
165-
[Inputs and Outputs guide](/build_iapp/guides/inputs-and-outputs) to learn how
244+
[Inputs and Outputs guide](/build-iapp/guides/inputs-and-outputs) to learn how
166245
to access schema fields inside your iApp using the deserializer.
167246

168247
## Next Steps
@@ -171,16 +250,10 @@ to access schema fields inside your iApp using the deserializer.
171250
explore next:
172251

173252
- **Build an iApp**: Check out the
174-
[iApp Generator guide](/build_iapp/iapp-generator) to create your first data
253+
[iApp Generator guide](/build-iapp/iapp-generator) to create your first data
175254
processor
176255
- **Process data**: Learn about
177256
[processProtectedData](/manage-data/dataProtector/dataProtectorCore/processProtectedData)
178257
for running computations
179258
- **See it in action**: Try our [Hello World tutorial](/overview/helloWorld) for
180259
a complete example
181-
182-
---
183-
184-
**TL;DR**: Schemas = auto-generated data labels. Frontend protects data → Schema
185-
describes structure → iApp uses schema to access fields safely. Match your field
186-
names and types between frontend and iApp! 🏷️

0 commit comments

Comments
 (0)