@graphprotocol/grc-20 0.31.0 → 0.31.1
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 +4 -0
- 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/encoding.d.ts +2 -1
- package/dist/src/encoding.d.ts.map +1 -1
- package/dist/src/encoding.js +2 -2
- package/dist/src/encoding.js.map +1 -1
- package/dist/src/encodings/get-register-space-calldata.d.ts +32 -0
- package/dist/src/encodings/get-register-space-calldata.d.ts.map +1 -0
- package/dist/src/encodings/get-register-space-calldata.js +39 -0
- package/dist/src/encodings/get-register-space-calldata.js.map +1 -0
- package/dist/src/encodings/get-register-space-calldata.test.d.ts +2 -0
- package/dist/src/encodings/get-register-space-calldata.test.d.ts.map +1 -0
- package/dist/src/encodings/get-register-space-calldata.test.js +15 -0
- package/dist/src/encodings/get-register-space-calldata.test.js.map +1 -0
- package/dist/src/graph/constants.d.ts +3 -0
- package/dist/src/graph/constants.d.ts.map +1 -1
- package/dist/src/graph/constants.js +10 -0
- package/dist/src/graph/constants.js.map +1 -1
- package/dist/src/graph/create-image.js +1 -1
- package/dist/src/graph/create-image.js.map +1 -1
- package/dist/src/graph/create-space.d.ts +2 -1
- package/dist/src/graph/create-space.d.ts.map +1 -1
- package/dist/src/graph/create-space.js +2 -2
- package/dist/src/graph/create-space.js.map +1 -1
- 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/graph/index.d.ts +1 -1
- package/dist/src/graph/index.d.ts.map +1 -1
- package/dist/src/graph/index.js +1 -1
- package/dist/src/graph/index.js.map +1 -1
- 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/ipfs.d.ts +4 -3
- package/dist/src/ipfs.d.ts.map +1 -1
- package/dist/src/ipfs.js +4 -4
- package/dist/src/ipfs.js.map +1 -1
- package/dist/src/ipfs.test.js +1 -1
- package/dist/src/ipfs.test.js.map +1 -1
- 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/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/types.d.ts +2 -2
- package/dist/src/types.d.ts.map +1 -1
- 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/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { expect, it } from 'vitest';
|
|
2
|
+
import { RELATION_INDEX } from './ids/system.js';
|
|
3
|
+
import { Position, PositionRange } from './position.js';
|
|
4
|
+
import { make, remove, reorder } from './relation.js';
|
|
5
|
+
it('should generate CreateRelationOp for CREATE_RELATION', () => {
|
|
6
|
+
const op = make({
|
|
7
|
+
relationId: 'test-relation-id',
|
|
8
|
+
fromId: 'test-entity-id',
|
|
9
|
+
relationTypeId: 'test-relation-type-id',
|
|
10
|
+
toId: 'test-entity-id',
|
|
11
|
+
position: 'test-position',
|
|
12
|
+
});
|
|
13
|
+
expect(op).toEqual({
|
|
14
|
+
type: 'CREATE_RELATION',
|
|
15
|
+
relation: {
|
|
16
|
+
id: 'test-relation-id',
|
|
17
|
+
type: 'test-relation-type-id',
|
|
18
|
+
fromEntity: 'test-entity-id',
|
|
19
|
+
toEntity: 'test-entity-id',
|
|
20
|
+
index: 'test-position',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
it('should generate DeleteRelationOp for DELETE_RELATION', () => {
|
|
25
|
+
const op = remove('test-relation-id');
|
|
26
|
+
expect(op).toEqual({
|
|
27
|
+
type: 'DELETE_RELATION',
|
|
28
|
+
relation: {
|
|
29
|
+
id: 'test-relation-id',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
it('should generate Op that places the fractional indexer between the two provided values', () => {
|
|
34
|
+
const op = reorder({
|
|
35
|
+
relationId: 'test-relation-id',
|
|
36
|
+
beforeIndex: PositionRange.FIRST,
|
|
37
|
+
afterIndex: PositionRange.LAST,
|
|
38
|
+
});
|
|
39
|
+
expect(op.type).toBe('SET_TRIPLE');
|
|
40
|
+
expect(op.triple.attribute).toBe(RELATION_INDEX);
|
|
41
|
+
expect(op.triple.entity).toBe('test-relation-id');
|
|
42
|
+
expect(op.triple.value.type).toBe('TEXT');
|
|
43
|
+
// @TODO how do we test that the resulting value is in-between the two indexes?
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=relation.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation.test.js","sourceRoot":"","sources":["../../../src/core/relation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEtD,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;IAC9D,MAAM,EAAE,GAAG,IAAI,CAAC;QACd,UAAU,EAAE,kBAAkB;QAC9B,MAAM,EAAE,gBAAgB;QACxB,cAAc,EAAE,uBAAuB;QACvC,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;QACjB,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE;YACR,EAAE,EAAE,kBAAkB;YACtB,IAAI,EAAE,uBAAuB;YAC7B,UAAU,EAAE,gBAAgB;YAC5B,QAAQ,EAAE,gBAAgB;YAC1B,KAAK,EAAE,eAAe;SACvB;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;IAC9D,MAAM,EAAE,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAEtC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;QACjB,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE;YACR,EAAE,EAAE,kBAAkB;SACvB;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,uFAAuF,EAAE,GAAG,EAAE;IAC/F,MAAM,EAAE,GAAG,OAAO,CAAC;QACjB,UAAU,EAAE,kBAAkB;QAC9B,WAAW,EAAE,aAAa,CAAC,KAAK;QAChC,UAAU,EAAE,aAAa,CAAC,IAAI;KAC/B,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACjD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,+EAA+E;AACjF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with Triples in TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.0.6
|
|
5
|
+
*/
|
|
6
|
+
import type { DeleteTripleOp, SetTripleOp, Value } from '../types.js';
|
|
7
|
+
type CreateTripleParams = {
|
|
8
|
+
attributeId: string;
|
|
9
|
+
entityId: string;
|
|
10
|
+
value: Value;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Generates op for creating a new Triple.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const op = Triple.make({
|
|
18
|
+
* attributeId: 'attribute-id',
|
|
19
|
+
* entityId: 'entity-id',
|
|
20
|
+
* value: {
|
|
21
|
+
* type: 'TEXT',
|
|
22
|
+
* value: 'value',
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
* @param args – {@link CreateTripleParams}
|
|
27
|
+
* @returns – {@link SetTripleOp}
|
|
28
|
+
*/
|
|
29
|
+
export declare function make(args: CreateTripleParams): SetTripleOp;
|
|
30
|
+
type DeleteTripleParams = {
|
|
31
|
+
attributeId: string;
|
|
32
|
+
entityId: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Generates op for deleting a Triple.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const op = Triple.remove({
|
|
40
|
+
* attributeId: 'attribute-id',
|
|
41
|
+
* entityId: 'entity-id',
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param args – {@link DeleteTripleParams}
|
|
46
|
+
* @returns – {@link DeleteTripleOp}
|
|
47
|
+
*/
|
|
48
|
+
export declare function remove(args: DeleteTripleParams): DeleteTripleOp;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=triple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triple.d.ts","sourceRoot":"","sources":["../../../src/core/triple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEtE,KAAK,kBAAkB,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,kBAAkB,GAAG,WAAW,CAS1D;AAED,KAAK,kBAAkB,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,cAAc,CAQ/D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with Triples in TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.0.6
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Generates op for creating a new Triple.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const op = Triple.make({
|
|
12
|
+
* attributeId: 'attribute-id',
|
|
13
|
+
* entityId: 'entity-id',
|
|
14
|
+
* value: {
|
|
15
|
+
* type: 'TEXT',
|
|
16
|
+
* value: 'value',
|
|
17
|
+
* },
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
* @param args – {@link CreateTripleParams}
|
|
21
|
+
* @returns – {@link SetTripleOp}
|
|
22
|
+
*/
|
|
23
|
+
export function make(args) {
|
|
24
|
+
return {
|
|
25
|
+
type: 'SET_TRIPLE',
|
|
26
|
+
triple: {
|
|
27
|
+
attribute: args.attributeId,
|
|
28
|
+
entity: args.entityId,
|
|
29
|
+
value: args.value,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generates op for deleting a Triple.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const op = Triple.remove({
|
|
39
|
+
* attributeId: 'attribute-id',
|
|
40
|
+
* entityId: 'entity-id',
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param args – {@link DeleteTripleParams}
|
|
45
|
+
* @returns – {@link DeleteTripleOp}
|
|
46
|
+
*/
|
|
47
|
+
export function remove(args) {
|
|
48
|
+
return {
|
|
49
|
+
type: 'DELETE_TRIPLE',
|
|
50
|
+
triple: {
|
|
51
|
+
attribute: args.attributeId,
|
|
52
|
+
entity: args.entityId,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=triple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triple.js","sourceRoot":"","sources":["../../../src/core/triple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,IAAI,CAAC,IAAwB;IAC3C,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE;YACN,SAAS,EAAE,IAAI,CAAC,WAAW;YAC3B,MAAM,EAAE,IAAI,CAAC,QAAQ;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB;KACF,CAAC;AACJ,CAAC;AAOD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAAC,IAAwB;IAC7C,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE;YACN,SAAS,EAAE,IAAI,CAAC,WAAW;YAC3B,MAAM,EAAE,IAAI,CAAC,QAAQ;SACtB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triple.test.d.ts","sourceRoot":"","sources":["../../../src/core/triple.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { expect, it } from 'vitest';
|
|
2
|
+
import { make, remove } from './triple.js';
|
|
3
|
+
it('should generate SetTripleOp for SET_TRIPLE', () => {
|
|
4
|
+
const op = make({
|
|
5
|
+
attributeId: 'test-attribute-id',
|
|
6
|
+
entityId: 'test-entity-id',
|
|
7
|
+
value: {
|
|
8
|
+
type: 'TEXT',
|
|
9
|
+
value: 'test value',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
expect(op).toEqual({
|
|
13
|
+
type: 'SET_TRIPLE',
|
|
14
|
+
triple: {
|
|
15
|
+
attribute: 'test-attribute-id',
|
|
16
|
+
entity: 'test-entity-id',
|
|
17
|
+
value: {
|
|
18
|
+
type: 'TEXT',
|
|
19
|
+
value: 'test value',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
it('should generate DeleteTripleOp for DELETE_TRIPLE', () => {
|
|
25
|
+
const op = remove({
|
|
26
|
+
attributeId: 'test-attribute-id',
|
|
27
|
+
entityId: 'test-entity-id',
|
|
28
|
+
});
|
|
29
|
+
expect(op).toEqual({
|
|
30
|
+
type: 'DELETE_TRIPLE',
|
|
31
|
+
triple: {
|
|
32
|
+
attribute: 'test-attribute-id',
|
|
33
|
+
entity: 'test-entity-id',
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=triple.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triple.test.js","sourceRoot":"","sources":["../../../src/core/triple.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE3C,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACpD,MAAM,EAAE,GAAG,IAAI,CAAC;QACd,WAAW,EAAE,mBAAmB;QAChC,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,YAAY;SACpB;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;QACjB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE;YACN,SAAS,EAAE,mBAAmB;YAC9B,MAAM,EAAE,gBAAgB;YACxB,KAAK,EAAE;gBACL,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,YAAY;aACpB;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAC1D,MAAM,EAAE,GAAG,MAAM,CAAC;QAChB,WAAW,EAAE,mBAAmB;QAChC,QAAQ,EAAE,gBAAgB;KAC3B,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;QACjB,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE;YACN,SAAS,EAAE,mBAAmB;YAC9B,MAAM,EAAE,gBAAgB;SACzB;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/src/encoding.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type Network } from './graph/constants.js';
|
|
1
2
|
type GetEditCalldataParams = {
|
|
2
3
|
spaceId: string;
|
|
3
4
|
cid: string;
|
|
4
|
-
network?:
|
|
5
|
+
network?: Network;
|
|
5
6
|
};
|
|
6
7
|
export declare function getEditCalldata(params: GetEditCalldataParams): Promise<{
|
|
7
8
|
to: `0x${string}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAMlE,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAsB,eAAe,CAAC,MAAM,EAAE,qBAAqB;QAe/C,KAAK,MAAM,EAAE;UACT,KAAK,MAAM,EAAE;GAapC"}
|
package/dist/src/encoding.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Micro } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { getApiOrigin } from './graph/constants.js';
|
|
3
3
|
class GetEditCalldataError extends Error {
|
|
4
4
|
_tag = 'GetEditCalldataError';
|
|
5
5
|
}
|
|
6
6
|
export async function getEditCalldata(params) {
|
|
7
7
|
const getCalldata = Micro.gen(function* () {
|
|
8
8
|
const result = yield* Micro.tryPromise({
|
|
9
|
-
try: () => fetch(`${params.network
|
|
9
|
+
try: () => fetch(`${getApiOrigin(params.network)}/space/${params.spaceId}/edit/calldata`, {
|
|
10
10
|
method: 'POST',
|
|
11
11
|
body: JSON.stringify({ cid: params.cid }),
|
|
12
12
|
}),
|
package/dist/src/encoding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAgB,MAAM,sBAAsB,CAAC;AAElE,MAAM,oBAAqB,SAAQ,KAAK;IAC7B,IAAI,GAAG,sBAAsB,CAAC;CACxC;AAQD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAA6B;IACjE,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QACrC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;YACrC,GAAG,EAAE,GAAG,EAAE,CACR,KAAK,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,MAAM,CAAC,OAAO,gBAAgB,EAAE;gBAC7E,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;aAC1C,CAAC;YACJ,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,oBAAoB,CAAC,0CAA0C,MAAM,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;SAC/G,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;YACvC,GAAG,EAAE,KAAK,IAAI,EAAE;gBACd,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBACzC,OAAO;oBACL,EAAE,EAAE,EAAmB;oBACvB,IAAI,EAAE,IAAqB;iBAC5B,CAAC;YACJ,CAAC;YACD,KAAK,EAAE,KAAK,CAAC,EAAE,CACb,IAAI,oBAAoB,CACtB,qEAAqE,MAAM,CAAC,OAAO,KAAK,KAAK,EAAE,CAChG;SACJ,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the calldata for registering a space ID.
|
|
3
|
+
*
|
|
4
|
+
* This function encodes the `registerSpaceId` function call for the Space Registry contract.
|
|
5
|
+
* It is called by a space contract to register itself with the Space Registry.
|
|
6
|
+
* The space ID is deterministically derived from the caller's address and nonce.
|
|
7
|
+
*
|
|
8
|
+
* @returns Encoded calldata for the transaction
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { getRegisterSpaceCalldata, TESTNET } from '@graphprotocol/grc-20';
|
|
13
|
+
* import { createWalletClient, http } from 'viem';
|
|
14
|
+
*
|
|
15
|
+
* const calldata = getRegisterSpaceCalldata();
|
|
16
|
+
*
|
|
17
|
+
* // Using viem
|
|
18
|
+
* const hash = await walletClient.sendTransaction({
|
|
19
|
+
* to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
20
|
+
* data: calldata,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Using wagmi
|
|
24
|
+
* const { sendTransaction } = useSendTransaction();
|
|
25
|
+
* sendTransaction({
|
|
26
|
+
* to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
27
|
+
* data: calldata,
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getRegisterSpaceCalldata(): `0x${string}`;
|
|
32
|
+
//# sourceMappingURL=get-register-space-calldata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-register-space-calldata.d.ts","sourceRoot":"","sources":["../../../src/encodings/get-register-space-calldata.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,wBAAwB,IAAI,KAAK,MAAM,EAAE,CAKxD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { encodeFunctionData } from 'viem';
|
|
2
|
+
import { SpaceRegistryAbi } from '../abis/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get the calldata for registering a space ID.
|
|
5
|
+
*
|
|
6
|
+
* This function encodes the `registerSpaceId` function call for the Space Registry contract.
|
|
7
|
+
* It is called by a space contract to register itself with the Space Registry.
|
|
8
|
+
* The space ID is deterministically derived from the caller's address and nonce.
|
|
9
|
+
*
|
|
10
|
+
* @returns Encoded calldata for the transaction
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { getRegisterSpaceCalldata, TESTNET } from '@graphprotocol/grc-20';
|
|
15
|
+
* import { createWalletClient, http } from 'viem';
|
|
16
|
+
*
|
|
17
|
+
* const calldata = getRegisterSpaceCalldata();
|
|
18
|
+
*
|
|
19
|
+
* // Using viem
|
|
20
|
+
* const hash = await walletClient.sendTransaction({
|
|
21
|
+
* to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
22
|
+
* data: calldata,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Using wagmi
|
|
26
|
+
* const { sendTransaction } = useSendTransaction();
|
|
27
|
+
* sendTransaction({
|
|
28
|
+
* to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
29
|
+
* data: calldata,
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function getRegisterSpaceCalldata() {
|
|
34
|
+
return encodeFunctionData({
|
|
35
|
+
abi: SpaceRegistryAbi,
|
|
36
|
+
functionName: 'registerSpaceId',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=get-register-space-calldata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-register-space-calldata.js","sourceRoot":"","sources":["../../../src/encodings/get-register-space-calldata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,kBAAkB,CAAC;QACxB,GAAG,EAAE,gBAAgB;QACrB,YAAY,EAAE,iBAAiB;KAChC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-register-space-calldata.test.d.ts","sourceRoot":"","sources":["../../../src/encodings/get-register-space-calldata.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getRegisterSpaceCalldata } from './get-register-space-calldata.js';
|
|
3
|
+
describe('getRegisterSpaceCalldata', () => {
|
|
4
|
+
it('should generate valid calldata', () => {
|
|
5
|
+
const calldata = getRegisterSpaceCalldata();
|
|
6
|
+
expect(calldata).toBeTypeOf('string');
|
|
7
|
+
expect(calldata.startsWith('0x')).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
it('should return consistent calldata', () => {
|
|
10
|
+
const calldata1 = getRegisterSpaceCalldata();
|
|
11
|
+
const calldata2 = getRegisterSpaceCalldata();
|
|
12
|
+
expect(calldata1).toBe(calldata2);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=get-register-space-calldata.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-register-space-calldata.test.js","sourceRoot":"","sources":["../../../src/encodings/get-register-space-calldata.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;QAC5C,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,SAAS,GAAG,wBAAwB,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAG,wBAAwB,EAAE,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const MAINNET_API_ORIGIN = "https://hypergraph-v2.up.railway.app";
|
|
2
2
|
export declare const TESTNET_API_ORIGIN = "https://api-testnet.geobrowser.io";
|
|
3
|
+
export declare const TESTNET_V2_API_ORIGIN = "https://testnet-api.geobrowser.io";
|
|
4
|
+
export type Network = 'TESTNET' | 'TESTNET_V2' | 'MAINNET';
|
|
5
|
+
export declare function getApiOrigin(network?: Network): string;
|
|
3
6
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/graph/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,kBAAkB,sCAAsC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/graph/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,kBAAkB,sCAAsC,CAAC;AACtE,eAAO,MAAM,qBAAqB,sCAAsC,CAAC;AAEzE,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAE3D,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAQtD"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
export const MAINNET_API_ORIGIN = 'https://hypergraph-v2.up.railway.app';
|
|
2
2
|
export const TESTNET_API_ORIGIN = 'https://api-testnet.geobrowser.io';
|
|
3
|
+
export const TESTNET_V2_API_ORIGIN = 'https://testnet-api.geobrowser.io';
|
|
4
|
+
export function getApiOrigin(network) {
|
|
5
|
+
if (network === 'TESTNET') {
|
|
6
|
+
return TESTNET_API_ORIGIN;
|
|
7
|
+
}
|
|
8
|
+
if (network === 'TESTNET_V2') {
|
|
9
|
+
return TESTNET_V2_API_ORIGIN;
|
|
10
|
+
}
|
|
11
|
+
return MAINNET_API_ORIGIN;
|
|
12
|
+
}
|
|
3
13
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/graph/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/graph/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,mCAAmC,CAAC;AAIzE,MAAM,UAAU,YAAY,CAAC,OAAiB;IAC5C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QAC7B,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -32,7 +32,7 @@ export const createImage = async ({ name, description, id: providedId, network,
|
|
|
32
32
|
if (providedId)
|
|
33
33
|
assertValid(providedId, '`id` in `createImage`');
|
|
34
34
|
const id = providedId ?? generate();
|
|
35
|
-
const { cid, dimensions } = await uploadImage(params, network, network === 'TESTNET');
|
|
35
|
+
const { cid, dimensions } = await uploadImage(params, network, network === 'TESTNET' || network === 'TESTNET_V2');
|
|
36
36
|
const values = [];
|
|
37
37
|
values.push({
|
|
38
38
|
property: IMAGE_URL_PROPERTY,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-image.js","sourceRoot":"","sources":["../../../src/graph/create-image.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,EAChC,IAAI,EACJ,WAAW,EACX,EAAE,EAAE,UAAU,EACd,OAAO,EACP,GAAG,MAAM,EACS,EAA8B,EAAE;IAClD,IAAI,UAAU;QAAE,WAAW,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAC;IAEjE,MAAM,EAAE,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC;IACpC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"create-image.js","sourceRoot":"","sources":["../../../src/graph/create-image.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,EAChC,IAAI,EACJ,WAAW,EACX,EAAE,EAAE,UAAU,EACd,OAAO,EACP,GAAG,MAAM,EACS,EAA8B,EAAE;IAClD,IAAI,UAAU;QAAE,WAAW,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAC;IAEjE,MAAM,EAAE,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC;IACpC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC;IAElH,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,MAAM,CAAC,IAAI,CAAC;QACV,QAAQ,EAAE,kBAAkB;QAC5B,KAAK,EAAE,GAAG;KACX,CAAC,CAAC;IACH,IAAI,UAAU,EAAE,MAAM,EAAE,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC;YACV,QAAQ,EAAE,qBAAqB;YAC/B,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,UAAU,EAAE,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC;YACV,QAAQ,EAAE,oBAAoB;YAC9B,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE;SACnC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC;QAC3B,EAAE;QACF,IAAI;QACJ,WAAW;QACX,MAAM;KACP,CAAC,CAAC;IAEH,GAAG,CAAC,IAAI,CAAC;QACP,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE;YACR,EAAE,EAAE,QAAQ,EAAE;YACd,MAAM,EAAE,QAAQ,EAAE;YAClB,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;YAClB,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO;QACL,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QACV,GAAG;QACH,UAAU;QACV,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Id } from '../id.js';
|
|
2
2
|
import type { Op } from '../types.js';
|
|
3
|
+
import { type Network } from './constants.js';
|
|
3
4
|
type CreateSpaceParams = {
|
|
4
5
|
editorAddress: string;
|
|
5
6
|
name: string;
|
|
6
|
-
network?:
|
|
7
|
+
network?: Network;
|
|
7
8
|
ops?: Op[];
|
|
8
9
|
spaceEntityId?: string;
|
|
9
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-space.d.ts","sourceRoot":"","sources":["../../../src/graph/create-space.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"create-space.d.ts","sourceRoot":"","sources":["../../../src/graph/create-space.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE5D,KAAK,iBAAiB,GAAG;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CACxC,CAAC;AAkBF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,iBAAiB;;EAqD1D,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IdUtils } from '../../index.js';
|
|
2
2
|
import { Id } from '../id.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getApiOrigin } from './constants.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a space with the given name and editor address.
|
|
6
6
|
*
|
|
@@ -20,7 +20,7 @@ import { MAINNET_API_ORIGIN, TESTNET_API_ORIGIN } from './constants.js';
|
|
|
20
20
|
*/
|
|
21
21
|
export const createSpace = async (params) => {
|
|
22
22
|
const governanceType = params.governanceType ?? 'PERSONAL';
|
|
23
|
-
const apiHost = params.network
|
|
23
|
+
const apiHost = getApiOrigin(params.network);
|
|
24
24
|
const formData = new FormData();
|
|
25
25
|
formData.append('name', params.name);
|
|
26
26
|
formData.append('editorAddress', params.editorAddress);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-space.js","sourceRoot":"","sources":["../../../src/graph/create-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-space.js","sourceRoot":"","sources":["../../../src/graph/create-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAgC5D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,MAAyB,EAAE,EAAE;IAC7D,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,UAAU,CAAC;IAC3D,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE7C,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IACvD,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QACzB,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,GAAG,GAAG,GAAG,OAAO,SAAS,CAAC;IAE9B,MAAM,YAAY,GAChB,cAAc,KAAK,UAAU;QAC3B,CAAC,CAAC;YACE,SAAS,EAAE,MAAM,CAAC,IAAI;YACtB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,oBAAoB,EAAE,MAAM,CAAC,aAAa;SAC3C;QACH,CAAC,CAAC;YACE,SAAS,EAAE,MAAM,CAAC,IAAI;YACtB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,sBAAsB,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;SAC/C,CAAC;IAER,IAAI,cAAc,KAAK,UAAU,EAAE,CAAC;QAClC,GAAG,GAAG,GAAG,GAAG,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;QAChC,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IACxB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC9B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;QAClC,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/E,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;AACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CreateResult, DeleteEntityParams } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deletes an entity from a space.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const { ops } = await deleteEntity({ id: entityId });
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @param params – {@link DeleteEntityParams}
|
|
11
|
+
* @returns The operations to delete the entity.
|
|
12
|
+
*/
|
|
13
|
+
export declare const deleteEntity: ({ id }: DeleteEntityParams) => CreateResult;
|
|
14
|
+
//# sourceMappingURL=delete-entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-entity.d.ts","sourceRoot":"","sources":["../../../src/graph/delete-entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAkB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,kBAAkB,KAAG,YAQzD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Id, assertValid } from '../id.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deletes an entity from a space.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const { ops } = await deleteEntity({ id: entityId });
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @param params – {@link DeleteEntityParams}
|
|
11
|
+
* @returns The operations to delete the entity.
|
|
12
|
+
*/
|
|
13
|
+
export const deleteEntity = ({ id }) => {
|
|
14
|
+
assertValid(id, '`id` in `deleteEntity`');
|
|
15
|
+
const op = {
|
|
16
|
+
type: 'DELETE_ENTITY',
|
|
17
|
+
id: Id(id),
|
|
18
|
+
};
|
|
19
|
+
return { id: Id(id), ops: [op] };
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=delete-entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-entity.js","sourceRoot":"","sources":["../../../src/graph/delete-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG3C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,EAAsB,EAAgB,EAAE;IACvE,WAAW,CAAC,EAAE,EAAE,wBAAwB,CAAC,CAAC;IAC1C,MAAM,EAAE,GAAmB;QACzB,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;KACX,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-entity.test.d.ts","sourceRoot":"","sources":["../../../src/graph/delete-entity.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { Id } from '../id.js';
|
|
3
|
+
import { deleteEntity } from './delete-entity.js';
|
|
4
|
+
describe('deleteEntity', () => {
|
|
5
|
+
it('should create a delete entity operation with valid ID', () => {
|
|
6
|
+
const id = Id('5cade575-7ecd-41ae-8348-1b22ffc2f94e');
|
|
7
|
+
const result = deleteEntity({ id });
|
|
8
|
+
expect(result).toEqual({
|
|
9
|
+
id,
|
|
10
|
+
ops: [
|
|
11
|
+
{
|
|
12
|
+
type: 'DELETE_ENTITY',
|
|
13
|
+
id: id,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
it('should throw an error when ID validation fails', () => {
|
|
19
|
+
const id = 'invalid-id';
|
|
20
|
+
expect(() => deleteEntity({ id })).toThrow('Invalid id: "invalid-id"');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=delete-entity.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-entity.test.js","sourceRoot":"","sources":["../../../src/graph/delete-entity.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,EAAE,GAAG,EAAE,CAAC,sCAAsC,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAEpC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,EAAE;YACF,GAAG,EAAE;gBACH;oBACE,IAAI,EAAE,eAAe;oBACrB,EAAE,EAAE,EAAE;iBACP;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,EAAE,GAAG,YAAY,CAAC;QAExB,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.test.d.ts","sourceRoot":"","sources":["../../../src/graph/graph.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createEntity } from './create-entity.js';
|
|
3
|
+
import { createProperty } from './create-property.js';
|
|
4
|
+
import { createType } from './create-type.js';
|
|
5
|
+
describe('Graph', () => {
|
|
6
|
+
it('creates types, entities and relations', async () => {
|
|
7
|
+
const ops = [];
|
|
8
|
+
// create age property
|
|
9
|
+
const { id: agePropertyId, ops: createAgePropertyOps } = createProperty({
|
|
10
|
+
type: 'NUMBER',
|
|
11
|
+
name: 'Age',
|
|
12
|
+
});
|
|
13
|
+
ops.push(...createAgePropertyOps);
|
|
14
|
+
// create likes property
|
|
15
|
+
const { id: likesPropertyId, ops: createLikesPropertyOps } = createProperty({
|
|
16
|
+
type: 'RELATION',
|
|
17
|
+
name: 'Likes',
|
|
18
|
+
});
|
|
19
|
+
ops.push(...createLikesPropertyOps);
|
|
20
|
+
// create person type
|
|
21
|
+
const { id: personTypeId, ops: createPersonTypeOps } = createType({
|
|
22
|
+
name: 'Person',
|
|
23
|
+
properties: [agePropertyId],
|
|
24
|
+
});
|
|
25
|
+
ops.push(...createPersonTypeOps);
|
|
26
|
+
// create restaurant entity
|
|
27
|
+
const { id: restaurantId, ops: createRestaurantOps } = createEntity({
|
|
28
|
+
name: 'Restaurant',
|
|
29
|
+
types: [personTypeId],
|
|
30
|
+
});
|
|
31
|
+
ops.push(...createRestaurantOps);
|
|
32
|
+
// create person entity
|
|
33
|
+
const { id: personId, ops: createPersonOps } = createEntity({
|
|
34
|
+
name: 'Jane Doe',
|
|
35
|
+
types: [personTypeId],
|
|
36
|
+
properties: {
|
|
37
|
+
[likesPropertyId]: {
|
|
38
|
+
to: restaurantId,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
ops.push(...createPersonOps);
|
|
43
|
+
expect(ops.length).toBe(16);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=graph.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.test.js","sourceRoot":"","sources":["../../../src/graph/graph.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,GAAG,GAAc,EAAE,CAAC;QAE1B,sBAAsB;QACtB,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,oBAAoB,EAAE,GAAG,cAAc,CAAC;YACtE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAC;QAElC,wBAAwB;QACxB,MAAM,EAAE,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,sBAAsB,EAAE,GAAG,cAAc,CAAC;YAC1E,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC,CAAC;QAEpC,qBAAqB;QACrB,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,UAAU,CAAC;YAChE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,CAAC,aAAa,CAAC;SAC5B,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC;QAEjC,2BAA2B;QAC3B,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,YAAY,CAAC;YAClE,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,CAAC,YAAY,CAAC;SACtB,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC;QAEjC,uBAAuB;QACvB,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC;YAC1D,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,CAAC,YAAY,CAAC;YACrB,UAAU,EAAE;gBACV,CAAC,eAAe,CAAC,EAAE;oBACjB,EAAE,EAAE,YAAY;iBACjB;aACF;SACF,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;QAE7B,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-default-properties.d.ts","sourceRoot":"","sources":["../../../../src/graph/helpers/create-default-properties.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAI,QAAQ,iBAAiB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,SA0CvF,CAAC"}
|