@graphprotocol/grc-20 0.21.3 → 0.21.5
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/README.md +99 -5
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/convert-ids.d.ts +2 -0
- package/dist/convert-ids.d.ts.map +1 -0
- package/dist/convert-ids.js +42 -0
- package/dist/convert-ids.js.map +1 -0
- package/dist/protov2.d.ts +11 -0
- package/dist/protov2.d.ts.map +1 -0
- package/dist/protov2.js +11 -0
- package/dist/protov2.js.map +1 -0
- package/dist/src/core/blocks/image.d.ts +15 -0
- package/dist/src/core/blocks/image.d.ts.map +1 -0
- package/dist/src/core/blocks/image.js +15 -0
- package/dist/src/core/blocks/image.js.map +1 -0
- package/dist/src/core/idsv2/content.d.ts +59 -0
- package/dist/src/core/idsv2/content.d.ts.map +1 -0
- package/dist/src/core/idsv2/content.js +59 -0
- package/dist/src/core/idsv2/content.js.map +1 -0
- package/dist/src/core/idsv2/network.d.ts +5 -0
- package/dist/src/core/idsv2/network.d.ts.map +1 -0
- package/dist/src/core/idsv2/network.js +5 -0
- package/dist/src/core/idsv2/network.js.map +1 -0
- package/dist/src/core/idsv2/system.d.ts +222 -0
- package/dist/src/core/idsv2/system.d.ts.map +1 -0
- package/dist/src/core/idsv2/system.js +230 -0
- package/dist/src/core/idsv2/system.js.map +1 -0
- package/dist/src/core/image.d.ts +40 -0
- package/dist/src/core/image.d.ts.map +1 -0
- package/dist/src/core/image.js +76 -0
- package/dist/src/core/image.js.map +1 -0
- package/dist/src/core/image.test.d.ts +2 -0
- package/dist/src/core/image.test.d.ts.map +1 -0
- package/dist/src/core/image.test.js +52 -0
- package/dist/src/core/image.test.js.map +1 -0
- package/dist/src/core/relation.d.ts +88 -0
- package/dist/src/core/relation.d.ts.map +1 -0
- package/dist/src/core/relation.js +89 -0
- package/dist/src/core/relation.js.map +1 -0
- package/dist/src/core/relation.test.d.ts +2 -0
- package/dist/src/core/relation.test.d.ts.map +1 -0
- package/dist/src/core/relation.test.js +45 -0
- package/dist/src/core/relation.test.js.map +1 -0
- package/dist/src/core/triple.d.ts +50 -0
- package/dist/src/core/triple.d.ts.map +1 -0
- package/dist/src/core/triple.js +56 -0
- package/dist/src/core/triple.js.map +1 -0
- package/dist/src/core/triple.test.d.ts +2 -0
- package/dist/src/core/triple.test.d.ts.map +1 -0
- package/dist/src/core/triple.test.js +37 -0
- package/dist/src/core/triple.test.js.map +1 -0
- package/dist/src/graph/delete-entity.d.ts +14 -0
- package/dist/src/graph/delete-entity.d.ts.map +1 -0
- package/dist/src/graph/delete-entity.js +21 -0
- package/dist/src/graph/delete-entity.js.map +1 -0
- package/dist/src/graph/delete-entity.test.d.ts +2 -0
- package/dist/src/graph/delete-entity.test.d.ts.map +1 -0
- package/dist/src/graph/delete-entity.test.js +23 -0
- package/dist/src/graph/delete-entity.test.js.map +1 -0
- package/dist/src/graph/graph.test.d.ts +2 -0
- package/dist/src/graph/graph.test.d.ts.map +1 -0
- package/dist/src/graph/graph.test.js +46 -0
- package/dist/src/graph/graph.test.js.map +1 -0
- package/dist/src/graph/helpers/create-default-properties.d.ts +5 -0
- package/dist/src/graph/helpers/create-default-properties.d.ts.map +1 -0
- package/dist/src/graph/helpers/create-default-properties.js +44 -0
- package/dist/src/graph/helpers/create-default-properties.js.map +1 -0
- package/dist/src/graph/helpers/create-properties.d.ts +8 -0
- package/dist/src/graph/helpers/create-properties.d.ts.map +1 -0
- package/dist/src/graph/helpers/create-properties.js +53 -0
- package/dist/src/graph/helpers/create-properties.js.map +1 -0
- package/dist/src/graphv2/constants.d.ts +2 -0
- package/dist/src/graphv2/constants.d.ts.map +1 -0
- package/dist/src/graphv2/constants.js +2 -0
- package/dist/src/graphv2/constants.js.map +1 -0
- package/dist/src/graphv2/create-entity.d.ts +52 -0
- package/dist/src/graphv2/create-entity.d.ts.map +1 -0
- package/dist/src/graphv2/create-entity.js +140 -0
- package/dist/src/graphv2/create-entity.js.map +1 -0
- package/dist/src/graphv2/create-entity.test.d.ts +2 -0
- package/dist/src/graphv2/create-entity.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-entity.test.js +158 -0
- package/dist/src/graphv2/create-entity.test.js.map +1 -0
- package/dist/src/graphv2/create-image.d.ts +28 -0
- package/dist/src/graphv2/create-image.d.ts.map +1 -0
- package/dist/src/graphv2/create-image.js +71 -0
- package/dist/src/graphv2/create-image.js.map +1 -0
- package/dist/src/graphv2/create-image.test.d.ts +2 -0
- package/dist/src/graphv2/create-image.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-image.test.js +142 -0
- package/dist/src/graphv2/create-image.test.js.map +1 -0
- package/dist/src/graphv2/create-property.d.ts +22 -0
- package/dist/src/graphv2/create-property.d.ts.map +1 -0
- package/dist/src/graphv2/create-property.js +129 -0
- package/dist/src/graphv2/create-property.js.map +1 -0
- package/dist/src/graphv2/create-property.test.d.ts +2 -0
- package/dist/src/graphv2/create-property.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-property.test.js +82 -0
- package/dist/src/graphv2/create-property.test.js.map +1 -0
- package/dist/src/graphv2/create-relation.d.ts +33 -0
- package/dist/src/graphv2/create-relation.d.ts.map +1 -0
- package/dist/src/graphv2/create-relation.js +66 -0
- package/dist/src/graphv2/create-relation.js.map +1 -0
- package/dist/src/graphv2/create-relation.test.d.ts +2 -0
- package/dist/src/graphv2/create-relation.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-relation.test.js +208 -0
- package/dist/src/graphv2/create-relation.test.js.map +1 -0
- package/dist/src/graphv2/create-space.d.ts +13 -0
- package/dist/src/graphv2/create-space.d.ts.map +1 -0
- package/dist/src/graphv2/create-space.js +21 -0
- package/dist/src/graphv2/create-space.js.map +1 -0
- package/dist/src/graphv2/create-type.d.ts +22 -0
- package/dist/src/graphv2/create-type.d.ts.map +1 -0
- package/dist/src/graphv2/create-type.js +64 -0
- package/dist/src/graphv2/create-type.js.map +1 -0
- package/dist/src/graphv2/create-type.test.d.ts +2 -0
- package/dist/src/graphv2/create-type.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-type.test.js +109 -0
- package/dist/src/graphv2/create-type.test.js.map +1 -0
- package/dist/src/graphv2/delete-entity.d.ts +14 -0
- package/dist/src/graphv2/delete-entity.d.ts.map +1 -0
- package/dist/src/graphv2/delete-entity.js +21 -0
- package/dist/src/graphv2/delete-entity.js.map +1 -0
- package/dist/src/graphv2/delete-entity.test.d.ts +2 -0
- package/dist/src/graphv2/delete-entity.test.d.ts.map +1 -0
- package/dist/src/graphv2/delete-entity.test.js +24 -0
- package/dist/src/graphv2/delete-entity.test.js.map +1 -0
- package/dist/src/graphv2/delete-relation.d.ts +14 -0
- package/dist/src/graphv2/delete-relation.d.ts.map +1 -0
- package/dist/src/graphv2/delete-relation.js +21 -0
- package/dist/src/graphv2/delete-relation.js.map +1 -0
- package/dist/src/graphv2/delete-relation.test.d.ts +2 -0
- package/dist/src/graphv2/delete-relation.test.d.ts.map +1 -0
- package/dist/src/graphv2/delete-relation.test.js +24 -0
- package/dist/src/graphv2/delete-relation.test.js.map +1 -0
- package/dist/src/graphv2/index.d.ts +12 -0
- package/dist/src/graphv2/index.d.ts.map +1 -0
- package/dist/src/graphv2/index.js +12 -0
- package/dist/src/graphv2/index.js.map +1 -0
- package/dist/src/graphv2/remove-entity-properties.d.ts +25 -0
- package/dist/src/graphv2/remove-entity-properties.d.ts.map +1 -0
- package/dist/src/graphv2/remove-entity-properties.js +24 -0
- package/dist/src/graphv2/remove-entity-properties.js.map +1 -0
- package/dist/src/graphv2/unset-entity-values.d.ts +21 -0
- package/dist/src/graphv2/unset-entity-values.d.ts.map +1 -0
- package/dist/src/graphv2/unset-entity-values.js +26 -0
- package/dist/src/graphv2/unset-entity-values.js.map +1 -0
- package/dist/src/graphv2/unset-entity-values.test.d.ts +2 -0
- package/dist/src/graphv2/unset-entity-values.test.d.ts.map +1 -0
- package/dist/src/graphv2/unset-entity-values.test.js +40 -0
- package/dist/src/graphv2/unset-entity-values.test.js.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.d.ts +25 -0
- package/dist/src/graphv2/unset-relation-fields.d.ts.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.js +34 -0
- package/dist/src/graphv2/unset-relation-fields.js.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.test.d.ts +2 -0
- package/dist/src/graphv2/unset-relation-fields.test.d.ts.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.test.js +64 -0
- package/dist/src/graphv2/unset-relation-fields.test.js.map +1 -0
- package/dist/src/graphv2/update-entity.d.ts +28 -0
- package/dist/src/graphv2/update-entity.d.ts.map +1 -0
- package/dist/src/graphv2/update-entity.js +73 -0
- package/dist/src/graphv2/update-entity.js.map +1 -0
- package/dist/src/graphv2/update-entity.test.d.ts +2 -0
- package/dist/src/graphv2/update-entity.test.d.ts.map +1 -0
- package/dist/src/graphv2/update-entity.test.js +116 -0
- package/dist/src/graphv2/update-entity.test.js.map +1 -0
- package/dist/src/graphv2/update-relation.d.ts +21 -0
- package/dist/src/graphv2/update-relation.d.ts.map +1 -0
- package/dist/src/graphv2/update-relation.js +37 -0
- package/dist/src/graphv2/update-relation.js.map +1 -0
- package/dist/src/idv2.d.ts +27 -0
- package/dist/src/idv2.d.ts.map +1 -0
- package/dist/src/idv2.js +88 -0
- package/dist/src/idv2.js.map +1 -0
- package/dist/src/idv2.test.d.ts +2 -0
- package/dist/src/idv2.test.d.ts.map +1 -0
- package/dist/src/idv2.test.js +26 -0
- package/dist/src/idv2.test.js.map +1 -0
- package/dist/src/image.d.ts +8 -0
- package/dist/src/image.d.ts.map +1 -0
- package/dist/src/image.js +8 -0
- package/dist/src/image.js.map +1 -0
- package/dist/src/ipfsv2.d.ts +96 -0
- package/dist/src/ipfsv2.d.ts.map +1 -0
- package/dist/src/ipfsv2.js +163 -0
- package/dist/src/ipfsv2.js.map +1 -0
- package/dist/src/ipfsv2.test.d.ts +2 -0
- package/dist/src/ipfsv2.test.d.ts.map +1 -0
- package/dist/src/ipfsv2.test.js +22 -0
- package/dist/src/ipfsv2.test.js.map +1 -0
- package/dist/src/proto/edit.d.ts +3 -3
- package/dist/src/proto/edit.d.ts.map +1 -1
- package/dist/src/proto/edit.js +24 -30
- package/dist/src/proto/edit.js.map +1 -1
- package/dist/src/proto/edit.test.js +111 -163
- package/dist/src/proto/edit.test.js.map +1 -1
- package/dist/src/proto/editv2.d.ts +11 -0
- package/dist/src/proto/editv2.d.ts.map +1 -0
- package/dist/src/proto/editv2.js +81 -0
- package/dist/src/proto/editv2.js.map +1 -0
- package/dist/src/proto/editv2.test.d.ts +2 -0
- package/dist/src/proto/editv2.test.d.ts.map +1 -0
- package/dist/src/proto/editv2.test.js +211 -0
- package/dist/src/proto/editv2.test.js.map +1 -0
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.d.ts +410 -0
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.d.ts.map +1 -0
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.js +536 -0
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.js.map +1 -0
- package/dist/src/relation.d.ts +7 -0
- package/dist/src/relation.d.ts.map +1 -0
- package/dist/src/relation.js +7 -0
- package/dist/src/relation.js.map +1 -0
- package/dist/src/smart-wallet-2.test-invalid.d.ts +2 -0
- package/dist/src/smart-wallet-2.test-invalid.d.ts.map +1 -0
- package/dist/src/smart-wallet-2.test-invalid.js +49 -0
- package/dist/src/smart-wallet-2.test-invalid.js.map +1 -0
- package/dist/src/smart-wallet-2.test.d.ts +2 -0
- package/dist/src/smart-wallet-2.test.d.ts.map +1 -0
- package/dist/src/smart-wallet-2.test.js +49 -0
- package/dist/src/smart-wallet-2.test.js.map +1 -0
- package/dist/src/system-ids-v2.d.ts +7 -0
- package/dist/src/system-ids-v2.d.ts.map +1 -0
- package/dist/src/system-ids-v2.js +7 -0
- package/dist/src/system-ids-v2.js.map +1 -0
- package/dist/src/triple.d.ts +7 -0
- package/dist/src/triple.d.ts.map +1 -0
- package/dist/src/triple.js +7 -0
- package/dist/src/triple.js.map +1 -0
- package/dist/src/types-backup.d.ts +134 -0
- package/dist/src/types-backup.d.ts.map +1 -0
- package/dist/src/types-backup.js +13 -0
- package/dist/src/types-backup.js.map +1 -0
- package/dist/src/typesv2.d.ts +173 -0
- package/dist/src/typesv2.d.ts.map +1 -0
- package/dist/src/typesv2.js +8 -0
- package/dist/src/typesv2.js.map +1 -0
- package/package.json +1 -1
package/dist/src/proto/edit.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Id, generate, toBase64, toBytes } from
|
|
2
|
-
import { Edit, Entity as EntityProto, Op as OpBinary, Property, Relation as RelationProto, RelationUpdate, UnsetEntityValues, UnsetRelationFields, } from
|
|
1
|
+
import { Id, generate, toBase64, toBytes } from '../id.js';
|
|
2
|
+
import { Edit, Entity as EntityProto, Op as OpBinary, Property, Relation as RelationProto, RelationUpdate, UnsetEntityValues, UnsetRelationFields, } from './gen/src/proto/ipfs_pb.js';
|
|
3
3
|
function hexToBytes(hex) {
|
|
4
4
|
let hexString = hex;
|
|
5
|
-
if (hexString.startsWith(
|
|
5
|
+
if (hexString.startsWith('0x')) {
|
|
6
6
|
hexString = hexString.slice(2);
|
|
7
7
|
}
|
|
8
8
|
if (hex.length % 2 !== 0) {
|
|
9
|
-
throw new Error(
|
|
9
|
+
throw new Error('Invalid hex string: must have an even length');
|
|
10
10
|
}
|
|
11
11
|
const bytes = new Uint8Array(hex.length / 2);
|
|
12
12
|
for (let i = 0; i < hex.length; i += 2) {
|
|
@@ -14,7 +14,7 @@ function hexToBytes(hex) {
|
|
|
14
14
|
}
|
|
15
15
|
return bytes;
|
|
16
16
|
}
|
|
17
|
-
export function encode({ name, ops, author, language
|
|
17
|
+
export function encode({ name, ops, author, language }) {
|
|
18
18
|
return new Edit({
|
|
19
19
|
id: toBytes(generate()),
|
|
20
20
|
name,
|
|
@@ -54,7 +54,7 @@ function convertRelationIdsToBase64(relation) {
|
|
|
54
54
|
function convertUnsetEntityValuesToBase64(unsetEntityValues) {
|
|
55
55
|
return {
|
|
56
56
|
id: toBase64(unsetEntityValues.id),
|
|
57
|
-
properties: unsetEntityValues.properties.map(
|
|
57
|
+
properties: unsetEntityValues.properties.map(propertyId => toBase64(propertyId)),
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
function convertUpdateRelationToBase64(relation) {
|
|
@@ -108,26 +108,20 @@ function convertUnsetRelationFieldsToBase64(unsetRelationFields) {
|
|
|
108
108
|
function convertUpdateEntityToBase64(entity) {
|
|
109
109
|
return {
|
|
110
110
|
id: toBase64(entity.id).toString(),
|
|
111
|
-
values: entity.values.map(
|
|
111
|
+
values: entity.values.map(value => {
|
|
112
112
|
let options;
|
|
113
113
|
if (value.options) {
|
|
114
114
|
if (value.options.text) {
|
|
115
115
|
options = {
|
|
116
116
|
text: {
|
|
117
|
-
...(value.options.text.language
|
|
118
|
-
? {
|
|
119
|
-
language: toBase64(Id(value.options.text.language)).toString(),
|
|
120
|
-
}
|
|
121
|
-
: null),
|
|
117
|
+
...(value.options.text.language && { language: toBase64(Id(value.options.text.language)).toString() }),
|
|
122
118
|
},
|
|
123
119
|
};
|
|
124
120
|
}
|
|
125
121
|
else if (value.options.number) {
|
|
126
122
|
options = {
|
|
127
123
|
number: {
|
|
128
|
-
...(value.options.number.unit
|
|
129
|
-
? { unit: toBase64(Id(value.options.number.unit)).toString() }
|
|
130
|
-
: {}),
|
|
124
|
+
...(value.options.number.unit && { unit: value.options.number.unit }),
|
|
131
125
|
},
|
|
132
126
|
};
|
|
133
127
|
}
|
|
@@ -150,54 +144,54 @@ function convertPropertyToBase64(property) {
|
|
|
150
144
|
};
|
|
151
145
|
}
|
|
152
146
|
function opsToBinary(ops) {
|
|
153
|
-
return ops.map(
|
|
147
|
+
return ops.map(o => {
|
|
154
148
|
switch (o.type) {
|
|
155
|
-
case
|
|
149
|
+
case 'CREATE_RELATION':
|
|
156
150
|
return new OpBinary({
|
|
157
151
|
payload: {
|
|
158
|
-
case:
|
|
152
|
+
case: 'createRelation',
|
|
159
153
|
value: RelationProto.fromJson(convertRelationIdsToBase64(o.relation)),
|
|
160
154
|
},
|
|
161
155
|
});
|
|
162
|
-
case
|
|
156
|
+
case 'CREATE_PROPERTY':
|
|
163
157
|
return new OpBinary({
|
|
164
158
|
payload: {
|
|
165
|
-
case:
|
|
159
|
+
case: 'createProperty',
|
|
166
160
|
value: Property.fromJson(convertPropertyToBase64(o.property)),
|
|
167
161
|
},
|
|
168
162
|
});
|
|
169
|
-
case
|
|
163
|
+
case 'DELETE_RELATION':
|
|
170
164
|
return new OpBinary({
|
|
171
165
|
payload: {
|
|
172
|
-
case:
|
|
166
|
+
case: 'deleteRelation',
|
|
173
167
|
value: toBytes(o.id),
|
|
174
168
|
},
|
|
175
169
|
});
|
|
176
|
-
case
|
|
170
|
+
case 'UPDATE_ENTITY':
|
|
177
171
|
return new OpBinary({
|
|
178
172
|
payload: {
|
|
179
|
-
case:
|
|
173
|
+
case: 'updateEntity',
|
|
180
174
|
value: EntityProto.fromJson(convertUpdateEntityToBase64(o.entity)),
|
|
181
175
|
},
|
|
182
176
|
});
|
|
183
|
-
case
|
|
177
|
+
case 'UNSET_ENTITY_VALUES':
|
|
184
178
|
return new OpBinary({
|
|
185
179
|
payload: {
|
|
186
|
-
case:
|
|
180
|
+
case: 'unsetEntityValues',
|
|
187
181
|
value: UnsetEntityValues.fromJson(convertUnsetEntityValuesToBase64(o.unsetEntityValues)),
|
|
188
182
|
},
|
|
189
183
|
});
|
|
190
|
-
case
|
|
184
|
+
case 'UPDATE_RELATION':
|
|
191
185
|
return new OpBinary({
|
|
192
186
|
payload: {
|
|
193
|
-
case:
|
|
187
|
+
case: 'updateRelation',
|
|
194
188
|
value: RelationUpdate.fromJson(convertUpdateRelationToBase64(o.relation)),
|
|
195
189
|
},
|
|
196
190
|
});
|
|
197
|
-
case
|
|
191
|
+
case 'UNSET_RELATION_FIELDS':
|
|
198
192
|
return new OpBinary({
|
|
199
193
|
payload: {
|
|
200
|
-
case:
|
|
194
|
+
case: 'unsetRelationFields',
|
|
201
195
|
value: UnsetRelationFields.fromJson(convertUnsetRelationFieldsToBase64(o.unsetRelationFields)),
|
|
202
196
|
},
|
|
203
197
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/proto/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAW3D,OAAO,EACL,IAAI,EACJ,MAAM,IAAI,WAAW,EACrB,EAAE,IAAI,QAAQ,EACd,QAAQ,EACR,QAAQ,IAAI,aAAa,EACzB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AASpC,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,SAAS,GAAG,GAAG,CAAC;IACpB,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE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AAO,EAAE;wBACP,IAAI,EAAE,gBAAgB;wBACtB,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;qBAC1E;iBACF,CAAC,CAAC;YACL,KAAK,uBAAuB;gBAC1B,OAAO,IAAI,QAAQ,CAAC;oBAClB,OAAO,EAAE;wBACP,IAAI,EAAE,qBAAqB;wBAC3B,KAAK,EAAE,mBAAmB,CAAC,QAAQ,CAAC,kCAAkC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;qBAC/F;iBACF,CAAC,CAAC;QACP,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { describe, expect, it } from
|
|
2
|
-
import { Id, toBytes } from
|
|
3
|
-
import { encode } from
|
|
4
|
-
import { Edit } from
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { Id, toBytes } from '../id.js';
|
|
3
|
+
import { encode } from './edit.js';
|
|
4
|
+
import { Edit } from './gen/src/proto/ipfs_pb.js';
|
|
5
|
+
describe('Edit', () => {
|
|
6
|
+
it('encodes and decodes Edit with UPDATE_ENTITY ops correctly', () => {
|
|
7
7
|
const editBinary = encode({
|
|
8
|
-
name:
|
|
8
|
+
name: 'test',
|
|
9
9
|
ops: [
|
|
10
10
|
{
|
|
11
|
-
type:
|
|
11
|
+
type: 'UPDATE_ENTITY',
|
|
12
12
|
entity: {
|
|
13
|
-
id: Id(
|
|
13
|
+
id: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
14
14
|
values: [
|
|
15
15
|
{
|
|
16
|
-
property: Id(
|
|
17
|
-
value:
|
|
16
|
+
property: Id('d4bc2f20-5e2d-415e-971e-b0b9fbf6b6fc'),
|
|
17
|
+
value: 'test value',
|
|
18
18
|
options: {
|
|
19
19
|
text: {
|
|
20
|
-
language: Id(
|
|
20
|
+
language: Id('a6104fe0-d695-4f93-92fa-0a1afc552bc5'),
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
},
|
|
@@ -25,26 +25,26 @@ describe("Edit", () => {
|
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
|
-
author:
|
|
28
|
+
author: '0x000000000000000000000000000000000000',
|
|
29
29
|
});
|
|
30
30
|
const result = Edit.fromBinary(editBinary);
|
|
31
|
-
expect(result.name).toBe(
|
|
31
|
+
expect(result.name).toBe('test');
|
|
32
32
|
expect(result.ops.length).toBe(1);
|
|
33
33
|
const op = result.ops[0];
|
|
34
34
|
if (!op)
|
|
35
|
-
throw new Error(
|
|
36
|
-
expect(op.payload?.case).toBe(
|
|
35
|
+
throw new Error('Expected op to be defined');
|
|
36
|
+
expect(op.payload?.case).toBe('updateEntity');
|
|
37
37
|
expect(op.payload?.value).toEqual({
|
|
38
|
-
id: toBytes(Id(
|
|
38
|
+
id: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
39
39
|
values: [
|
|
40
40
|
{
|
|
41
|
-
property: toBytes(Id(
|
|
42
|
-
value:
|
|
41
|
+
property: toBytes(Id('d4bc2f20-5e2d-415e-971e-b0b9fbf6b6fc')),
|
|
42
|
+
value: 'test value',
|
|
43
43
|
options: {
|
|
44
44
|
value: {
|
|
45
|
-
case:
|
|
45
|
+
case: 'text',
|
|
46
46
|
value: {
|
|
47
|
-
language: toBytes(Id(
|
|
47
|
+
language: toBytes(Id('a6104fe0-d695-4f93-92fa-0a1afc552bc5')),
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
50
|
},
|
|
@@ -52,253 +52,201 @@ describe("Edit", () => {
|
|
|
52
52
|
],
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
|
-
it(
|
|
55
|
+
it('encodes and decodes an edit with a CREATE_PROPERTY ops with a point type correctly', () => {
|
|
56
56
|
const editBinary = encode({
|
|
57
|
-
name:
|
|
57
|
+
name: 'test',
|
|
58
58
|
ops: [
|
|
59
59
|
{
|
|
60
|
-
type:
|
|
61
|
-
entity: {
|
|
62
|
-
id: Id("3af3e22d-2169-4a07-8681-516710b7ecf1"),
|
|
63
|
-
values: [
|
|
64
|
-
{
|
|
65
|
-
property: Id("d4bc2f20-5e2d-415e-971e-b0b9fbf6b6fc"),
|
|
66
|
-
value: "test value",
|
|
67
|
-
options: {
|
|
68
|
-
number: {
|
|
69
|
-
unit: Id("a6104fe0-d695-4f93-92fa-0a1afc552bc5"),
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
author: "0x000000000000000000000000000000000000",
|
|
78
|
-
});
|
|
79
|
-
const result = Edit.fromBinary(editBinary);
|
|
80
|
-
expect(result.name).toBe("test");
|
|
81
|
-
expect(result.ops.length).toBe(1);
|
|
82
|
-
const op = result.ops[0];
|
|
83
|
-
if (!op)
|
|
84
|
-
throw new Error("Expected op to be defined");
|
|
85
|
-
expect(op.payload?.case).toBe("updateEntity");
|
|
86
|
-
expect(op.payload?.value).toEqual({
|
|
87
|
-
id: toBytes(Id("3af3e22d-2169-4a07-8681-516710b7ecf1")),
|
|
88
|
-
values: [
|
|
89
|
-
{
|
|
90
|
-
property: toBytes(Id("d4bc2f20-5e2d-415e-971e-b0b9fbf6b6fc")),
|
|
91
|
-
value: "test value",
|
|
92
|
-
options: {
|
|
93
|
-
value: {
|
|
94
|
-
case: "number",
|
|
95
|
-
value: {
|
|
96
|
-
unit: toBytes(Id("a6104fe0-d695-4f93-92fa-0a1afc552bc5")),
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
it("encodes and decodes an edit with a CREATE_PROPERTY ops with a point type correctly", () => {
|
|
105
|
-
const editBinary = encode({
|
|
106
|
-
name: "test",
|
|
107
|
-
ops: [
|
|
108
|
-
{
|
|
109
|
-
type: "CREATE_PROPERTY",
|
|
60
|
+
type: 'CREATE_PROPERTY',
|
|
110
61
|
property: {
|
|
111
|
-
id: Id(
|
|
112
|
-
dataType:
|
|
62
|
+
id: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
63
|
+
dataType: 'POINT',
|
|
113
64
|
},
|
|
114
65
|
},
|
|
115
66
|
],
|
|
116
|
-
author:
|
|
67
|
+
author: '0x000000000000000000000000000000000000',
|
|
117
68
|
});
|
|
118
69
|
const result = Edit.fromBinary(editBinary);
|
|
119
|
-
expect(result.name).toBe(
|
|
70
|
+
expect(result.name).toBe('test');
|
|
120
71
|
expect(result.ops.length).toBe(1);
|
|
121
72
|
const op = result.ops[0];
|
|
122
73
|
if (!op)
|
|
123
|
-
throw new Error(
|
|
124
|
-
expect(op.payload?.case).toBe(
|
|
74
|
+
throw new Error('Expected op to be defined');
|
|
75
|
+
expect(op.payload?.case).toBe('createProperty');
|
|
125
76
|
expect(op.payload?.value).toEqual({
|
|
126
|
-
id: toBytes(Id(
|
|
77
|
+
id: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
127
78
|
dataType: 4,
|
|
128
79
|
});
|
|
129
80
|
});
|
|
130
|
-
it(
|
|
81
|
+
it('encodes and decodes an edit with a CREATE_PROPERTY ops with a relation type correctly', () => {
|
|
131
82
|
const editBinary = encode({
|
|
132
|
-
name:
|
|
83
|
+
name: 'test',
|
|
133
84
|
ops: [
|
|
134
85
|
{
|
|
135
|
-
type:
|
|
86
|
+
type: 'CREATE_PROPERTY',
|
|
136
87
|
property: {
|
|
137
|
-
id: Id(
|
|
138
|
-
dataType:
|
|
88
|
+
id: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
89
|
+
dataType: 'RELATION',
|
|
139
90
|
},
|
|
140
91
|
},
|
|
141
92
|
],
|
|
142
|
-
author:
|
|
93
|
+
author: '0x000000000000000000000000000000000000',
|
|
143
94
|
});
|
|
144
95
|
const result = Edit.fromBinary(editBinary);
|
|
145
|
-
expect(result.name).toBe(
|
|
96
|
+
expect(result.name).toBe('test');
|
|
146
97
|
expect(result.ops.length).toBe(1);
|
|
147
98
|
const op = result.ops[0];
|
|
148
99
|
if (!op)
|
|
149
|
-
throw new Error(
|
|
150
|
-
expect(op.payload?.case).toBe(
|
|
100
|
+
throw new Error('Expected op to be defined');
|
|
101
|
+
expect(op.payload?.case).toBe('createProperty');
|
|
151
102
|
expect(op.payload?.value).toEqual({
|
|
152
|
-
id: toBytes(Id(
|
|
103
|
+
id: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
153
104
|
dataType: 5,
|
|
154
105
|
});
|
|
155
106
|
});
|
|
156
|
-
it(
|
|
107
|
+
it('encodes and decodes an edit with a CREATE_PROPERTY ops with a text type correctly', () => {
|
|
157
108
|
const editBinary = encode({
|
|
158
|
-
name:
|
|
109
|
+
name: 'test',
|
|
159
110
|
ops: [
|
|
160
111
|
{
|
|
161
|
-
type:
|
|
112
|
+
type: 'CREATE_PROPERTY',
|
|
162
113
|
property: {
|
|
163
|
-
id: Id(
|
|
164
|
-
dataType:
|
|
114
|
+
id: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
115
|
+
dataType: 'TEXT',
|
|
165
116
|
},
|
|
166
117
|
},
|
|
167
118
|
],
|
|
168
|
-
author:
|
|
119
|
+
author: '0x000000000000000000000000000000000000',
|
|
169
120
|
});
|
|
170
121
|
const result = Edit.fromBinary(editBinary);
|
|
171
|
-
expect(result.name).toBe(
|
|
122
|
+
expect(result.name).toBe('test');
|
|
172
123
|
expect(result.ops.length).toBe(1);
|
|
173
124
|
const op = result.ops[0];
|
|
174
125
|
if (!op)
|
|
175
|
-
throw new Error(
|
|
176
|
-
expect(op.payload?.case).toBe(
|
|
126
|
+
throw new Error('Expected op to be defined');
|
|
127
|
+
expect(op.payload?.case).toBe('createProperty');
|
|
177
128
|
expect(op.payload?.value).toEqual({
|
|
178
|
-
id: toBytes(Id(
|
|
129
|
+
id: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
179
130
|
dataType: 0,
|
|
180
131
|
});
|
|
181
132
|
});
|
|
182
|
-
it(
|
|
133
|
+
it('encodes and decodes Edit with CREATE_RELATION ops correctly', () => {
|
|
183
134
|
const editBinary = encode({
|
|
184
|
-
name:
|
|
135
|
+
name: 'test',
|
|
185
136
|
ops: [
|
|
186
137
|
{
|
|
187
|
-
type:
|
|
138
|
+
type: 'CREATE_RELATION',
|
|
188
139
|
relation: {
|
|
189
|
-
id: Id(
|
|
190
|
-
type: Id(
|
|
191
|
-
fromEntity: Id(
|
|
192
|
-
toEntity: Id(
|
|
193
|
-
entity: Id(
|
|
194
|
-
position:
|
|
140
|
+
id: Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7'),
|
|
141
|
+
type: Id('cf518eaf-ef74-4aad-bc87-fe09c2631fcd'),
|
|
142
|
+
fromEntity: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
143
|
+
toEntity: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
144
|
+
entity: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
145
|
+
position: 'test-position',
|
|
195
146
|
},
|
|
196
147
|
},
|
|
197
148
|
],
|
|
198
|
-
author:
|
|
149
|
+
author: '0x000000000000000000000000000000000000',
|
|
199
150
|
});
|
|
200
151
|
const result = Edit.fromBinary(editBinary);
|
|
201
|
-
expect(result.name).toBe(
|
|
152
|
+
expect(result.name).toBe('test');
|
|
202
153
|
expect(result.ops.length).toBe(1);
|
|
203
154
|
const op = result.ops[0];
|
|
204
155
|
if (!op)
|
|
205
|
-
throw new Error(
|
|
206
|
-
expect(op.payload?.case).toBe(
|
|
156
|
+
throw new Error('Expected op to be defined');
|
|
157
|
+
expect(op.payload?.case).toBe('createRelation');
|
|
207
158
|
expect(op.payload?.value).toEqual({
|
|
208
|
-
id: toBytes(Id(
|
|
209
|
-
type: toBytes(Id(
|
|
210
|
-
fromEntity: toBytes(Id(
|
|
211
|
-
toEntity: toBytes(Id(
|
|
212
|
-
entity: toBytes(Id(
|
|
213
|
-
position:
|
|
159
|
+
id: toBytes(Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7')),
|
|
160
|
+
type: toBytes(Id('cf518eaf-ef74-4aad-bc87-fe09c2631fcd')),
|
|
161
|
+
fromEntity: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
162
|
+
toEntity: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
163
|
+
entity: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
164
|
+
position: 'test-position',
|
|
214
165
|
});
|
|
215
166
|
});
|
|
216
|
-
it(
|
|
167
|
+
it('encodes and decodes Edit with DELETE_RELATION ops correctly', () => {
|
|
217
168
|
const editBinary = encode({
|
|
218
|
-
name:
|
|
169
|
+
name: 'test',
|
|
219
170
|
ops: [
|
|
220
171
|
{
|
|
221
|
-
type:
|
|
222
|
-
id: Id(
|
|
172
|
+
type: 'DELETE_RELATION',
|
|
173
|
+
id: Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7'),
|
|
223
174
|
},
|
|
224
175
|
],
|
|
225
|
-
author:
|
|
176
|
+
author: '0x000000000000000000000000000000000000',
|
|
226
177
|
});
|
|
227
178
|
const result = Edit.fromBinary(editBinary);
|
|
228
|
-
expect(result.name).toBe(
|
|
179
|
+
expect(result.name).toBe('test');
|
|
229
180
|
expect(result.ops.length).toBe(1);
|
|
230
181
|
const op = result.ops[0];
|
|
231
182
|
if (!op)
|
|
232
|
-
throw new Error(
|
|
233
|
-
expect(op.payload?.case).toBe(
|
|
234
|
-
expect(op.payload?.value).toEqual(toBytes(Id(
|
|
183
|
+
throw new Error('Expected op to be defined');
|
|
184
|
+
expect(op.payload?.case).toBe('deleteRelation');
|
|
185
|
+
expect(op.payload?.value).toEqual(toBytes(Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7')));
|
|
235
186
|
});
|
|
236
|
-
it(
|
|
187
|
+
it('encodes and decodes Edit with UPDATE_RELATION ops correctly', () => {
|
|
237
188
|
const editBinary = encode({
|
|
238
|
-
name:
|
|
189
|
+
name: 'test',
|
|
239
190
|
ops: [
|
|
240
191
|
{
|
|
241
|
-
type:
|
|
192
|
+
type: 'UPDATE_RELATION',
|
|
242
193
|
relation: {
|
|
243
|
-
id: Id(
|
|
244
|
-
position:
|
|
194
|
+
id: Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7'),
|
|
195
|
+
position: 'new-position',
|
|
245
196
|
},
|
|
246
197
|
},
|
|
247
198
|
],
|
|
248
|
-
author:
|
|
199
|
+
author: '0x000000000000000000000000000000000000',
|
|
249
200
|
});
|
|
250
201
|
const result = Edit.fromBinary(editBinary);
|
|
251
|
-
expect(result.name).toBe(
|
|
202
|
+
expect(result.name).toBe('test');
|
|
252
203
|
expect(result.ops.length).toBe(1);
|
|
253
204
|
const op = result.ops[0];
|
|
254
205
|
if (!op)
|
|
255
|
-
throw new Error(
|
|
256
|
-
expect(op.payload?.case).toBe(
|
|
206
|
+
throw new Error('Expected op to be defined');
|
|
207
|
+
expect(op.payload?.case).toBe('updateRelation');
|
|
257
208
|
expect(op.payload?.value).toEqual({
|
|
258
|
-
id: toBytes(Id(
|
|
259
|
-
position:
|
|
209
|
+
id: toBytes(Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7')),
|
|
210
|
+
position: 'new-position',
|
|
260
211
|
});
|
|
261
212
|
});
|
|
262
|
-
it(
|
|
213
|
+
it('encodes and decodes Edit with UNSET_ENTITY_VALUES ops correctly', () => {
|
|
263
214
|
const editBinary = encode({
|
|
264
|
-
name:
|
|
215
|
+
name: 'test',
|
|
265
216
|
ops: [
|
|
266
217
|
{
|
|
267
|
-
type:
|
|
218
|
+
type: 'UNSET_ENTITY_VALUES',
|
|
268
219
|
unsetEntityValues: {
|
|
269
|
-
id: Id(
|
|
270
|
-
properties: [
|
|
271
|
-
Id("d4bc2f20-5e2d-415e-971e-b0b9fbf6b6fc"),
|
|
272
|
-
Id("765564ca-c7e5-4c61-b1dc-c28ab77ec6b7"),
|
|
273
|
-
],
|
|
220
|
+
id: Id('3af3e22d-2169-4a07-8681-516710b7ecf1'),
|
|
221
|
+
properties: [Id('d4bc2f20-5e2d-415e-971e-b0b9fbf6b6fc'), Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7')],
|
|
274
222
|
},
|
|
275
223
|
},
|
|
276
224
|
],
|
|
277
|
-
author:
|
|
225
|
+
author: '0x000000000000000000000000000000000000',
|
|
278
226
|
});
|
|
279
227
|
const result = Edit.fromBinary(editBinary);
|
|
280
|
-
expect(result.name).toBe(
|
|
228
|
+
expect(result.name).toBe('test');
|
|
281
229
|
expect(result.ops.length).toBe(1);
|
|
282
230
|
const op = result.ops[0];
|
|
283
231
|
if (!op)
|
|
284
|
-
throw new Error(
|
|
285
|
-
expect(op.payload?.case).toBe(
|
|
232
|
+
throw new Error('Expected op to be defined');
|
|
233
|
+
expect(op.payload?.case).toBe('unsetEntityValues');
|
|
286
234
|
expect(op.payload?.value).toEqual({
|
|
287
|
-
id: toBytes(Id(
|
|
235
|
+
id: toBytes(Id('3af3e22d-2169-4a07-8681-516710b7ecf1')),
|
|
288
236
|
properties: [
|
|
289
|
-
toBytes(Id(
|
|
290
|
-
toBytes(Id(
|
|
237
|
+
toBytes(Id('d4bc2f20-5e2d-415e-971e-b0b9fbf6b6fc')),
|
|
238
|
+
toBytes(Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7')),
|
|
291
239
|
],
|
|
292
240
|
});
|
|
293
241
|
});
|
|
294
|
-
it(
|
|
242
|
+
it('encodes and decodes Edit with UNSET_RELATION_FIELDS ops correctly', () => {
|
|
295
243
|
const editBinary = encode({
|
|
296
|
-
name:
|
|
244
|
+
name: 'test',
|
|
297
245
|
ops: [
|
|
298
246
|
{
|
|
299
|
-
type:
|
|
247
|
+
type: 'UNSET_RELATION_FIELDS',
|
|
300
248
|
unsetRelationFields: {
|
|
301
|
-
id: Id(
|
|
249
|
+
id: Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7'),
|
|
302
250
|
fromSpace: true,
|
|
303
251
|
fromVersion: false,
|
|
304
252
|
toSpace: true,
|
|
@@ -308,17 +256,17 @@ describe("Edit", () => {
|
|
|
308
256
|
},
|
|
309
257
|
},
|
|
310
258
|
],
|
|
311
|
-
author:
|
|
259
|
+
author: '0x000000000000000000000000000000000000',
|
|
312
260
|
});
|
|
313
261
|
const result = Edit.fromBinary(editBinary);
|
|
314
|
-
expect(result.name).toBe(
|
|
262
|
+
expect(result.name).toBe('test');
|
|
315
263
|
expect(result.ops.length).toBe(1);
|
|
316
264
|
const op = result.ops[0];
|
|
317
265
|
if (!op)
|
|
318
|
-
throw new Error(
|
|
319
|
-
expect(op.payload?.case).toBe(
|
|
266
|
+
throw new Error('Expected op to be defined');
|
|
267
|
+
expect(op.payload?.case).toBe('unsetRelationFields');
|
|
320
268
|
expect(op.payload?.value).toEqual({
|
|
321
|
-
id: toBytes(Id(
|
|
269
|
+
id: toBytes(Id('765564ca-c7e5-4c61-b1dc-c28ab77ec6b7')),
|
|
322
270
|
fromSpace: true,
|
|
323
271
|
fromVersion: false,
|
|
324
272
|
toSpace: true,
|