@graphprotocol/grc-20 0.22.0 → 0.23.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/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/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- 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/account.js +1 -1
- package/dist/src/core/account.js.map +1 -1
- package/dist/src/core/blocks/data.d.ts.map +1 -1
- package/dist/src/core/blocks/data.js +2 -1
- package/dist/src/core/blocks/data.js.map +1 -1
- 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/blocks/text.d.ts.map +1 -1
- package/dist/src/core/blocks/text.js +2 -1
- package/dist/src/core/blocks/text.js.map +1 -1
- 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/create-entity.d.ts +7 -6
- package/dist/src/graph/create-entity.d.ts.map +1 -1
- package/dist/src/graph/create-entity.js +13 -7
- package/dist/src/graph/create-entity.js.map +1 -1
- package/dist/src/graph/create-image.d.ts.map +1 -1
- package/dist/src/graph/create-image.js +2 -1
- package/dist/src/graph/create-image.js.map +1 -1
- package/dist/src/graph/create-property.d.ts +8 -6
- package/dist/src/graph/create-property.d.ts.map +1 -1
- package/dist/src/graph/create-property.js +11 -8
- package/dist/src/graph/create-property.js.map +1 -1
- package/dist/src/graph/create-relation.d.ts +25 -14
- package/dist/src/graph/create-relation.d.ts.map +1 -1
- package/dist/src/graph/create-relation.js +57 -17
- package/dist/src/graph/create-relation.js.map +1 -1
- package/dist/src/graph/create-relation.test.js +165 -0
- package/dist/src/graph/create-relation.test.js.map +1 -1
- package/dist/src/graph/create-space.d.ts +16 -2
- package/dist/src/graph/create-space.d.ts.map +1 -1
- package/dist/src/graph/create-space.js +14 -0
- package/dist/src/graph/create-space.js.map +1 -1
- package/dist/src/graph/create-type.d.ts +1 -1
- package/dist/src/graph/create-type.d.ts.map +1 -1
- package/dist/src/graph/create-type.js +4 -3
- package/dist/src/graph/create-type.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/delete-relation.d.ts.map +1 -1
- package/dist/src/graph/delete-relation.js +2 -1
- package/dist/src/graph/delete-relation.js.map +1 -1
- 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 -0
- package/dist/src/graph/index.d.ts.map +1 -1
- package/dist/src/graph/index.js +1 -0
- package/dist/src/graph/index.js.map +1 -1
- package/dist/src/graph/unset-entity-values.d.ts.map +1 -1
- package/dist/src/graph/unset-entity-values.js +2 -1
- package/dist/src/graph/unset-entity-values.js.map +1 -1
- package/dist/src/graph/unset-relation-fields.d.ts +2 -1
- package/dist/src/graph/unset-relation-fields.d.ts.map +1 -1
- package/dist/src/graph/unset-relation-fields.js +5 -2
- package/dist/src/graph/unset-relation-fields.js.map +1 -1
- package/dist/src/graph/unset-relation-fields.test.js +6 -0
- package/dist/src/graph/unset-relation-fields.test.js.map +1 -1
- package/dist/src/graph/update-entity.d.ts +1 -2
- package/dist/src/graph/update-entity.d.ts.map +1 -1
- package/dist/src/graph/update-entity.js +4 -18
- package/dist/src/graph/update-entity.js.map +1 -1
- package/dist/src/graph/update-entity.test.js +1 -30
- package/dist/src/graph/update-entity.test.js.map +1 -1
- package/dist/src/graph/update-relation.d.ts +6 -5
- package/dist/src/graph/update-relation.d.ts.map +1 -1
- package/dist/src/graph/update-relation.js +8 -6
- package/dist/src/graph/update-relation.js.map +1 -1
- package/dist/src/graph/update-relation.test.d.ts +2 -0
- package/dist/src/graph/update-relation.test.d.ts.map +1 -0
- package/dist/src/graph/update-relation.test.js +264 -0
- package/dist/src/graph/update-relation.test.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/id-utils.d.ts +30 -0
- package/dist/src/id-utils.d.ts.map +1 -0
- package/dist/src/id-utils.js +86 -0
- package/dist/src/id-utils.js.map +1 -0
- package/dist/src/id-utils.test.d.ts +2 -0
- package/dist/src/id-utils.test.d.ts.map +1 -0
- package/dist/src/id-utils.test.js +17 -0
- package/dist/src/id-utils.test.js.map +1 -0
- package/dist/src/id.d.ts +0 -22
- package/dist/src/id.d.ts.map +1 -1
- package/dist/src/id.js +1 -82
- package/dist/src/id.js.map +1 -1
- package/dist/src/id.test.js +1 -14
- package/dist/src/id.test.js.map +1 -1
- 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 +1 -1
- package/dist/src/ipfs.d.ts.map +1 -1
- package/dist/src/ipfs.js +1 -1
- package/dist/src/ipfs.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/edit.d.ts +1 -1
- package/dist/src/proto/edit.d.ts.map +1 -1
- package/dist/src/proto/edit.js +2 -1
- package/dist/src/proto/edit.js.map +1 -1
- package/dist/src/proto/edit.test.js +2 -1
- 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/types.d.ts +1 -1
- 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/package.json +2 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect, it } from 'vitest';
|
|
2
|
+
import { INITIAL_RELATION_INDEX_VALUE } from '~/constants.js';
|
|
3
|
+
import { SystemIds } from '../system-ids.js';
|
|
4
|
+
import { make } from './image.js';
|
|
5
|
+
it('should generate ops for an image entity', () => {
|
|
6
|
+
const { id, ops } = make({ cid: 'https://example.com/image.png' });
|
|
7
|
+
// We check each field individually since we don't know the id of the relation
|
|
8
|
+
expect(typeof id).toBe('string');
|
|
9
|
+
expect(ops.length).toBe(2);
|
|
10
|
+
if (ops[0]?.type === 'CREATE_RELATION') {
|
|
11
|
+
expect(ops[0].relation.type).toBe(SystemIds.TYPES_PROPERTY);
|
|
12
|
+
expect(ops[0].relation.fromEntity).toBe(id);
|
|
13
|
+
expect(ops[0].relation.toEntity).toBe(SystemIds.IMAGE_TYPE);
|
|
14
|
+
expect(ops[0].relation.index).toBe(INITIAL_RELATION_INDEX_VALUE);
|
|
15
|
+
}
|
|
16
|
+
if (ops[1]?.type === 'SET_TRIPLE') {
|
|
17
|
+
expect(ops[1].triple.attribute).toBe(SystemIds.IMAGE_URL_PROPERTY);
|
|
18
|
+
expect(ops[1].triple.entity).toBe(id);
|
|
19
|
+
expect(ops[1].triple.value.type).toBe('URL');
|
|
20
|
+
expect(ops[1].triple.value.value).toBe('https://example.com/image.png');
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
it('should generate ops for an image entity with dimensions', () => {
|
|
24
|
+
const { id, ops } = make({ cid: 'https://example.com/image.png', dimensions: { width: 200, height: 100 } });
|
|
25
|
+
expect(typeof id).toBe('string');
|
|
26
|
+
expect(ops.length).toBe(4);
|
|
27
|
+
if (ops[0]?.type === 'CREATE_RELATION') {
|
|
28
|
+
expect(ops[0].relation.type).toBe(SystemIds.TYPES_PROPERTY);
|
|
29
|
+
expect(ops[0].relation.fromEntity).toBe(id);
|
|
30
|
+
expect(ops[0].relation.toEntity).toBe(SystemIds.IMAGE_TYPE);
|
|
31
|
+
expect(ops[0].relation.index).toBe(INITIAL_RELATION_INDEX_VALUE);
|
|
32
|
+
}
|
|
33
|
+
if (ops[1]?.type === 'SET_TRIPLE') {
|
|
34
|
+
expect(ops[1].triple.attribute).toBe(SystemIds.IMAGE_URL_PROPERTY);
|
|
35
|
+
expect(ops[1].triple.entity).toBe(id);
|
|
36
|
+
expect(ops[1].triple.value.type).toBe('URL');
|
|
37
|
+
expect(ops[1].triple.value.value).toBe('https://example.com/image.png');
|
|
38
|
+
}
|
|
39
|
+
if (ops[2]?.type === 'SET_TRIPLE') {
|
|
40
|
+
expect(ops[2].triple.attribute).toBe(SystemIds.IMAGE_HEIGHT_PROPERTY);
|
|
41
|
+
expect(ops[2].triple.entity).toBe(id);
|
|
42
|
+
expect(ops[2].triple.value.type).toBe('NUMBER');
|
|
43
|
+
expect(ops[2].triple.value.value).toBe('100');
|
|
44
|
+
}
|
|
45
|
+
if (ops[3]?.type === 'SET_TRIPLE') {
|
|
46
|
+
expect(ops[3].triple.attribute).toBe(SystemIds.IMAGE_WIDTH_PROPERTY);
|
|
47
|
+
expect(ops[3].triple.entity).toBe(id);
|
|
48
|
+
expect(ops[3].triple.value.type).toBe('NUMBER');
|
|
49
|
+
expect(ops[3].triple.value.value).toBe('200');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+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AQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;QAClC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;QACrE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with Relations in TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.0.6
|
|
5
|
+
*/
|
|
6
|
+
import { SystemIds } from '../system-ids.js';
|
|
7
|
+
import type { CreateRelationOp, DeleteRelationOp } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Arguments for creating a new Relation.
|
|
10
|
+
*
|
|
11
|
+
* @param relationId - optional base58 encoded v4 uuid
|
|
12
|
+
* @param fromId - base58 encoded v4 uuid
|
|
13
|
+
* @param toId - base58 encoded v4 uuid
|
|
14
|
+
* @param relationTypeId - base58 encoded v4 uuid
|
|
15
|
+
* @param position - optional fractional index using position-strings
|
|
16
|
+
*/
|
|
17
|
+
type CreateRelationParams = {
|
|
18
|
+
relationId?: string;
|
|
19
|
+
fromId: string;
|
|
20
|
+
toId: string;
|
|
21
|
+
relationTypeId: string;
|
|
22
|
+
position?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Generates ops for a new Relation.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const ops = Relation.make({
|
|
30
|
+
* fromId: 'from-id',
|
|
31
|
+
* toId: 'to-id',
|
|
32
|
+
* relationTypeId: 'relation-type-id',
|
|
33
|
+
* // optional
|
|
34
|
+
* relationId: 'relation-id',
|
|
35
|
+
* position: 'position-string',
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param args {@link CreateRelationParams}
|
|
40
|
+
* @returns – {@link CreateRelationOp}
|
|
41
|
+
*/
|
|
42
|
+
export declare function make(args: CreateRelationParams): CreateRelationOp;
|
|
43
|
+
/**
|
|
44
|
+
* Generates ops for deleting a Relation.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const op = Relation.remove('relation-id');
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param relationId – base58 encoded v4 uuid representing the relation's entity id
|
|
52
|
+
* @returns – {@link DeleteRelationOp}
|
|
53
|
+
*/
|
|
54
|
+
export declare function remove(relationId: string): DeleteRelationOp;
|
|
55
|
+
type ReorderRelationParams = {
|
|
56
|
+
relationId: string;
|
|
57
|
+
beforeIndex?: string;
|
|
58
|
+
afterIndex?: string;
|
|
59
|
+
};
|
|
60
|
+
type ReorderRelationOp = {
|
|
61
|
+
type: 'SET_TRIPLE';
|
|
62
|
+
triple: {
|
|
63
|
+
attribute: typeof SystemIds.RELATION_INDEX;
|
|
64
|
+
entity: string;
|
|
65
|
+
value: {
|
|
66
|
+
type: 'TEXT';
|
|
67
|
+
value: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Generates op for reordering a Relation using position-strings
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const op = Relation.reorder({
|
|
77
|
+
* relationId: 'relation-id',
|
|
78
|
+
* beforeIndex: 'before-position',
|
|
79
|
+
* afterIndex: 'after-position',
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param args {@link ReorderRelationParams}
|
|
84
|
+
* @returns – {@link ReorderRelationOp}
|
|
85
|
+
*/
|
|
86
|
+
export declare function reorder(args: ReorderRelationParams): ReorderRelationOp;
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../../../src/core/relation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGtE;;;;;;;;GAQG;AACH,KAAK,oBAAoB,GAAG;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,oBAAoB,GAAG,gBAAgB,CAajE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAO3D;AAED,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE;QACN,SAAS,EAAE,OAAO,SAAS,CAAC,cAAc,CAAC;QAC3C,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE;YACL,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;SACf,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,qBAAqB,GAAG,iBAAiB,CActE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with Relations in TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.0.6
|
|
5
|
+
*/
|
|
6
|
+
import { INITIAL_RELATION_INDEX_VALUE } from '../../constants.js';
|
|
7
|
+
import { generate } from '../id.js';
|
|
8
|
+
import { SystemIds } from '../system-ids.js';
|
|
9
|
+
import { Position } from './position.js';
|
|
10
|
+
/**
|
|
11
|
+
* Generates ops for a new Relation.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const ops = Relation.make({
|
|
16
|
+
* fromId: 'from-id',
|
|
17
|
+
* toId: 'to-id',
|
|
18
|
+
* relationTypeId: 'relation-type-id',
|
|
19
|
+
* // optional
|
|
20
|
+
* relationId: 'relation-id',
|
|
21
|
+
* position: 'position-string',
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param args {@link CreateRelationParams}
|
|
26
|
+
* @returns – {@link CreateRelationOp}
|
|
27
|
+
*/
|
|
28
|
+
export function make(args) {
|
|
29
|
+
const newEntityId = args.relationId ?? generate();
|
|
30
|
+
return {
|
|
31
|
+
type: 'CREATE_RELATION',
|
|
32
|
+
relation: {
|
|
33
|
+
id: newEntityId,
|
|
34
|
+
type: args.relationTypeId,
|
|
35
|
+
fromEntity: args.fromId,
|
|
36
|
+
toEntity: args.toId,
|
|
37
|
+
index: args.position ?? INITIAL_RELATION_INDEX_VALUE,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generates ops for deleting a Relation.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const op = Relation.remove('relation-id');
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param relationId – base58 encoded v4 uuid representing the relation's entity id
|
|
50
|
+
* @returns – {@link DeleteRelationOp}
|
|
51
|
+
*/
|
|
52
|
+
export function remove(relationId) {
|
|
53
|
+
return {
|
|
54
|
+
type: 'DELETE_RELATION',
|
|
55
|
+
relation: {
|
|
56
|
+
id: relationId,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates op for reordering a Relation using position-strings
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const op = Relation.reorder({
|
|
66
|
+
* relationId: 'relation-id',
|
|
67
|
+
* beforeIndex: 'before-position',
|
|
68
|
+
* afterIndex: 'after-position',
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param args {@link ReorderRelationParams}
|
|
73
|
+
* @returns – {@link ReorderRelationOp}
|
|
74
|
+
*/
|
|
75
|
+
export function reorder(args) {
|
|
76
|
+
const newIndex = Position.createBetween(args.beforeIndex, args.afterIndex);
|
|
77
|
+
return {
|
|
78
|
+
type: 'SET_TRIPLE',
|
|
79
|
+
triple: {
|
|
80
|
+
attribute: SystemIds.RELATION_INDEX,
|
|
81
|
+
entity: args.relationId,
|
|
82
|
+
value: {
|
|
83
|
+
type: 'TEXT',
|
|
84
|
+
value: newIndex,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=relation.js.map
|
|
@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AK,EAAE,QAAQ;aAChB;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation.test.d.ts","sourceRoot":"","sources":["../../../src/core/relation.test.ts"],"names":[],"mappings":""}
|
|
@@ -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"}
|
|
@@ -20,7 +20,7 @@ import type { CreateResult, EntityParams } from '../types.js';
|
|
|
20
20
|
* ],
|
|
21
21
|
* relations: {
|
|
22
22
|
* [relationPropertyId]: {
|
|
23
|
-
*
|
|
23
|
+
* toEntity: 'id of the entity',
|
|
24
24
|
* id: 'id of the relation', // optional
|
|
25
25
|
* toSpace: 'id of the to space', // optional
|
|
26
26
|
* fromSpace: 'id of the from space', // optional
|
|
@@ -32,16 +32,17 @@ import type { CreateResult, EntityParams } from '../types.js';
|
|
|
32
32
|
* entityName: 'name of the relation entity', // optional
|
|
33
33
|
* entityDescription: 'description of the relation entity', // optional
|
|
34
34
|
* entityCover: 'id of the cover', // optional
|
|
35
|
-
* entityValues:
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* entityRelations: {
|
|
35
|
+
* entityValues: [ // optional values for the relation entity
|
|
36
|
+
* { property: propertyId, value: 'value of the property' },
|
|
37
|
+
* ],
|
|
38
|
+
* entityRelations: { // same structure as `relations` and can be nested
|
|
39
39
|
* [relationPropertyId]: {
|
|
40
|
-
*
|
|
40
|
+
* toEntity: 'id of the entity',
|
|
41
41
|
* id: 'id of the relation', // optional
|
|
42
42
|
* position: positionString, // optional
|
|
43
43
|
* },
|
|
44
44
|
* },
|
|
45
|
+
* entityTypes: [typeEntityId1, typeEntityId2], // optional
|
|
45
46
|
* },
|
|
46
47
|
* },
|
|
47
48
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-entity.d.ts","sourceRoot":"","sources":["../../../src/graph/create-entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-entity.d.ts","sourceRoot":"","sources":["../../../src/graph/create-entity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC;AAGvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,YAAY,GAAI,yEAQ1B,YAAY,KAAG,YAuKjB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { COVER_PROPERTY, DESCRIPTION_PROPERTY, NAME_PROPERTY, TYPES_PROPERTY } from '../core/ids/system.js';
|
|
2
|
-
import {
|
|
2
|
+
import { assertValid, generate } from '../id-utils.js';
|
|
3
|
+
import { Id } from '../id.js';
|
|
3
4
|
import { createRelation } from './create-relation.js';
|
|
4
5
|
/**
|
|
5
6
|
* Creates an entity with the given name, description, cover, properties, and types.
|
|
@@ -22,7 +23,7 @@ import { createRelation } from './create-relation.js';
|
|
|
22
23
|
* ],
|
|
23
24
|
* relations: {
|
|
24
25
|
* [relationPropertyId]: {
|
|
25
|
-
*
|
|
26
|
+
* toEntity: 'id of the entity',
|
|
26
27
|
* id: 'id of the relation', // optional
|
|
27
28
|
* toSpace: 'id of the to space', // optional
|
|
28
29
|
* fromSpace: 'id of the from space', // optional
|
|
@@ -34,16 +35,17 @@ import { createRelation } from './create-relation.js';
|
|
|
34
35
|
* entityName: 'name of the relation entity', // optional
|
|
35
36
|
* entityDescription: 'description of the relation entity', // optional
|
|
36
37
|
* entityCover: 'id of the cover', // optional
|
|
37
|
-
* entityValues:
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* entityRelations: {
|
|
38
|
+
* entityValues: [ // optional values for the relation entity
|
|
39
|
+
* { property: propertyId, value: 'value of the property' },
|
|
40
|
+
* ],
|
|
41
|
+
* entityRelations: { // same structure as `relations` and can be nested
|
|
41
42
|
* [relationPropertyId]: {
|
|
42
|
-
*
|
|
43
|
+
* toEntity: 'id of the entity',
|
|
43
44
|
* id: 'id of the relation', // optional
|
|
44
45
|
* position: positionString, // optional
|
|
45
46
|
* },
|
|
46
47
|
* },
|
|
48
|
+
* entityTypes: [typeEntityId1, typeEntityId2], // optional
|
|
47
49
|
* },
|
|
48
50
|
* },
|
|
49
51
|
* });
|
|
@@ -205,7 +207,11 @@ export const createEntity = ({ id: providedId, name, description, cover, values,
|
|
|
205
207
|
toEntity: relation.toEntity,
|
|
206
208
|
type: Id(typeId),
|
|
207
209
|
position: relation.position,
|
|
210
|
+
fromSpace: relation.fromSpace,
|
|
208
211
|
toSpace: relation.toSpace,
|
|
212
|
+
fromVersion: relation.fromVersion,
|
|
213
|
+
toVersion: relation.toVersion,
|
|
214
|
+
verified: relation.verified,
|
|
209
215
|
entityId: relationEntityId,
|
|
210
216
|
entityName: relation.entityName,
|
|
211
217
|
entityDescription: relation.entityDescription,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-entity.js","sourceRoot":"","sources":["../../../src/graph/create-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5G,OAAO,EAAE,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"create-entity.js","sourceRoot":"","sources":["../../../src/graph/create-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5G,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ph/create-image.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-image.d.ts","sourceRoot":"","sources":["../../../src/graph/create-image.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAGpF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,WAAW,GAAU,kDAK/B,iBAAiB,KAAG,OAAO,CAAC,YAAY,CA8C1C,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IMAGE_HEIGHT_PROPERTY, IMAGE_TYPE, IMAGE_URL_PROPERTY, IMAGE_WIDTH_PROPERTY, TYPES_PROPERTY, } from '../core/ids/system.js';
|
|
2
|
-
import { Id
|
|
2
|
+
import { Id } from '../id.js';
|
|
3
|
+
import { assertValid, generate } from '../id-utils.js';
|
|
3
4
|
import { uploadImage } from '../ipfs.js';
|
|
4
5
|
import { createEntity } from './create-entity.js';
|
|
5
6
|
/**
|
|
@@ -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,WAAW,EAAE,QAAQ,EAAE,MAAM,
|
|
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,C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,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO;QACL,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QACV,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import type { CreatePropertyParams, CreateResult } from "../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Creates a property with the given name, description, cover, and
|
|
4
|
-
* All IDs passed to this function (cover, relation value types) are validated.
|
|
3
|
+
* Creates a property with the given name, description, cover, and dataType.
|
|
4
|
+
* All IDs passed to this function (cover, relation value types, properties) are validated.
|
|
5
5
|
* If any invalid ID is provided, the function will throw an error.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* const { id, ops } = createProperty({
|
|
10
|
-
* name: 'name of the property',
|
|
11
|
-
* type: 'TEXT'
|
|
12
|
-
* description: 'description of the property',
|
|
13
|
-
* cover: imageEntityId,
|
|
14
10
|
* id: propertyId, // optional and will be generated if not provided
|
|
11
|
+
* dataType: 'TEXT',
|
|
12
|
+
* name: 'name of the property', // optional
|
|
13
|
+
* description: 'description of the property', // optional
|
|
14
|
+
* cover: imageEntityId, // optional
|
|
15
|
+
* properties: [propertyId1, propertyId2], // optional
|
|
16
|
+
* relationValueTypes: [relationValueTypeId1, relationValueTypeId2], // optional
|
|
15
17
|
* });
|
|
16
18
|
* ```
|
|
17
19
|
* @param params – {@link CreatePropertyParams}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-property.d.ts","sourceRoot":"","sources":["../../../src/graph/create-property.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-property.d.ts","sourceRoot":"","sources":["../../../src/graph/create-property.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAM,MAAM,aAAa,CAAC;AAI1E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,oBAAoB,KAAG,YA0E7D,CAAA"}
|