@graphprotocol/grc-20 0.22.0 → 0.23.0
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 +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CreateResult, DeleteRelationParams } from '../typesv2.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deletes a relation.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const { ops } = await deleteRelation({ id: relationId });
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @param params – {@link DeleteRelationParams}
|
|
11
|
+
* @returns The operations to delete the relation.
|
|
12
|
+
*/
|
|
13
|
+
export declare const deleteRelation: ({ id }: DeleteRelationParams) => CreateResult;
|
|
14
|
+
//# sourceMappingURL=delete-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../src/graphv2/delete-relation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAoB,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,oBAAoB,KAAG,YAQ7D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Id, assertValid, toBase64 } from '../idv2.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deletes a relation.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const { ops } = await deleteRelation({ id: relationId });
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @param params – {@link DeleteRelationParams}
|
|
11
|
+
* @returns The operations to delete the relation.
|
|
12
|
+
*/
|
|
13
|
+
export const deleteRelation = ({ id }) => {
|
|
14
|
+
assertValid(id, 'id is required');
|
|
15
|
+
const op = {
|
|
16
|
+
type: 'DELETE_RELATION',
|
|
17
|
+
id: toBase64(Id(id)),
|
|
18
|
+
};
|
|
19
|
+
return { id, ops: [op] };
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=delete-relation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.js","sourceRoot":"","sources":["../../../src/graphv2/delete-relation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,EAAE,EAAwB,EAAgB,EAAE;IAC3E,WAAW,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAClC,MAAM,EAAE,GAAqB;QAC3B,IAAI,EAAE,iBAAiB;QACvB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACrB,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.test.d.ts","sourceRoot":"","sources":["../../../src/graphv2/delete-relation.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { Id, toBase64 } from '../idv2.js';
|
|
3
|
+
import { deleteRelation } from './delete-relation.js';
|
|
4
|
+
describe('deleteRelation', () => {
|
|
5
|
+
it('should create a delete relation operation with valid ID', () => {
|
|
6
|
+
const id = Id('5cade575-7ecd-41ae-8348-1b22ffc2f94e');
|
|
7
|
+
const result = deleteRelation({ id });
|
|
8
|
+
expect(result).toEqual({
|
|
9
|
+
id,
|
|
10
|
+
ops: [
|
|
11
|
+
{
|
|
12
|
+
type: 'DELETE_RELATION',
|
|
13
|
+
id: toBase64(id),
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
it('should throw an error when ID validation fails', () => {
|
|
19
|
+
const id = 'invalid-id';
|
|
20
|
+
// @ts-expect-error - invalid id type
|
|
21
|
+
expect(() => deleteRelation({ id })).toThrow('Invalid id: "invalid-id"');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=delete-relation.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.test.js","sourceRoot":"","sources":["../../../src/graphv2/delete-relation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,EAAE,GAAG,EAAE,CAAC,sCAAsC,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAEtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,EAAE;YACF,GAAG,EAAE;gBACH;oBACE,IAAI,EAAE,iBAAiB;oBACvB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC;iBACjB;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,EAAE,GAAG,YAAY,CAAC;QAExB,qCAAqC;QACrC,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './create-entity.js';
|
|
2
|
+
export * from './create-image.js';
|
|
3
|
+
export * from './create-property.js';
|
|
4
|
+
export * from './create-relation.js';
|
|
5
|
+
export * from './create-space.js';
|
|
6
|
+
export * from './create-type.js';
|
|
7
|
+
export * from './delete-entity.js';
|
|
8
|
+
export * from './delete-relation.js';
|
|
9
|
+
export * from './unset-entity-values.js';
|
|
10
|
+
export * from './unset-relation-fields.js';
|
|
11
|
+
export * from './update-entity.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graphv2/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './create-entity.js';
|
|
2
|
+
export * from './create-image.js';
|
|
3
|
+
export * from './create-property.js';
|
|
4
|
+
export * from './create-relation.js';
|
|
5
|
+
export * from './create-space.js';
|
|
6
|
+
export * from './create-type.js';
|
|
7
|
+
export * from './delete-entity.js';
|
|
8
|
+
export * from './delete-relation.js';
|
|
9
|
+
export * from './unset-entity-values.js';
|
|
10
|
+
export * from './unset-relation-fields.js';
|
|
11
|
+
export * from './update-entity.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/graphv2/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Id } from '../idv2.js';
|
|
2
|
+
import type { UnsetPropertiesOp } from '../typesv2.js';
|
|
3
|
+
/**
|
|
4
|
+
* Removes properties from an entity.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const { ops } = await removeEntityProperties({
|
|
9
|
+
* id: entityId,
|
|
10
|
+
* properties: [propertyId1, propertyId2],
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param id - The id of the entity.
|
|
15
|
+
* @param properties - The property IDs to remove.
|
|
16
|
+
* @returns The operation to unset the properties.
|
|
17
|
+
*/
|
|
18
|
+
export declare const removeEntityProperties: ({ id, properties }: {
|
|
19
|
+
id: Id;
|
|
20
|
+
properties: Id[];
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
id: Id;
|
|
23
|
+
ops: UnsetPropertiesOp[];
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=remove-entity-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-entity-properties.d.ts","sourceRoot":"","sources":["../../../src/graphv2/remove-entity-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,GAAU,oBAAoB;IAAE,EAAE,EAAE,EAAE,CAAC;IAAC,UAAU,EAAE,EAAE,EAAE,CAAA;CAAE;;;EAQ5F,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes properties from an entity.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const { ops } = await removeEntityProperties({
|
|
7
|
+
* id: entityId,
|
|
8
|
+
* properties: [propertyId1, propertyId2],
|
|
9
|
+
* });
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param id - The id of the entity.
|
|
13
|
+
* @param properties - The property IDs to remove.
|
|
14
|
+
* @returns The operation to unset the properties.
|
|
15
|
+
*/
|
|
16
|
+
export const removeEntityProperties = async ({ id, properties }) => {
|
|
17
|
+
const op = {
|
|
18
|
+
type: 'UNSET_PROPERTIES',
|
|
19
|
+
entity: id,
|
|
20
|
+
properties,
|
|
21
|
+
};
|
|
22
|
+
return { id, ops: [op] };
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=remove-entity-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-entity-properties.js","sourceRoot":"","sources":["../../../src/graphv2/remove-entity-properties.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAgC,EAAE,EAAE;IAC/F,MAAM,EAAE,GAAsB;QAC5B,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,EAAE;QACV,UAAU;KACX,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Id } from '../idv2.js';
|
|
2
|
+
import type { UnsetEntityValuesOp, UnsetEntityValuesParams } from '../typesv2.js';
|
|
3
|
+
/**
|
|
4
|
+
* Unsets properties from an entity.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const { ops } = await unsetEntityValues({
|
|
9
|
+
* id: entityId,
|
|
10
|
+
* properties: [propertyId1, propertyId2],
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param params – {@link UnsetEntityValuesParams}
|
|
15
|
+
* @returns The operation to unset the properties.
|
|
16
|
+
*/
|
|
17
|
+
export declare const unsetEntityValues: ({ id, properties }: UnsetEntityValuesParams) => {
|
|
18
|
+
id: Id;
|
|
19
|
+
ops: UnsetEntityValuesOp[];
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=unset-entity-values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-entity-values.d.ts","sourceRoot":"","sources":["../../../src/graphv2/unset-entity-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAY,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAElF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,oBAAoB,uBAAuB;;;CAU5E,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Id, toBase64 } from '../idv2.js';
|
|
2
|
+
/**
|
|
3
|
+
* Unsets properties from an entity.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const { ops } = await unsetEntityValues({
|
|
8
|
+
* id: entityId,
|
|
9
|
+
* properties: [propertyId1, propertyId2],
|
|
10
|
+
* });
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param params – {@link UnsetEntityValuesParams}
|
|
14
|
+
* @returns The operation to unset the properties.
|
|
15
|
+
*/
|
|
16
|
+
export const unsetEntityValues = ({ id, properties }) => {
|
|
17
|
+
const op = {
|
|
18
|
+
type: 'UNSET_ENTITY_VALUES',
|
|
19
|
+
unsetEntityValues: {
|
|
20
|
+
id: toBase64(Id(id)),
|
|
21
|
+
properties: properties.map(propertyId => toBase64(Id(propertyId))),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
return { id, ops: [op] };
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=unset-entity-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-entity-values.js","sourceRoot":"","sources":["../../../src/graphv2/unset-entity-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAA2B,EAAE,EAAE;IAC/E,MAAM,EAAE,GAAwB;QAC9B,IAAI,EAAE,qBAAqB;QAC3B,iBAAiB,EAAE;YACjB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACpB,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;SACnE;KACF,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-entity-values.test.d.ts","sourceRoot":"","sources":["../../../src/graphv2/unset-entity-values.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { Id, toBase64 } from '../idv2.js';
|
|
3
|
+
import { unsetEntityValues } from './unset-entity-values.js';
|
|
4
|
+
describe('unsetEntityValues', () => {
|
|
5
|
+
it('should create an unset properties operation with valid ID and properties', () => {
|
|
6
|
+
const id = Id('5cade575-7ecd-41ae-8348-1b22ffc2f94e');
|
|
7
|
+
const properties = [Id('77e30275-8446-45ec-b3e8-99af0fcda375'), Id('3b7092c4-9035-479c-9cc9-aeb976b63c39')];
|
|
8
|
+
const result = unsetEntityValues({ id, properties });
|
|
9
|
+
expect(result).toEqual({
|
|
10
|
+
id,
|
|
11
|
+
ops: [
|
|
12
|
+
{
|
|
13
|
+
type: 'UNSET_ENTITY_VALUES',
|
|
14
|
+
unsetEntityValues: {
|
|
15
|
+
id: toBase64(id),
|
|
16
|
+
properties: properties.map(property => toBase64(property)),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
it('should handle empty properties array', () => {
|
|
23
|
+
const id = Id('5cade575-7ecd-41ae-8348-1b22ffc2f94e');
|
|
24
|
+
const properties = [];
|
|
25
|
+
const result = unsetEntityValues({ id, properties });
|
|
26
|
+
expect(result).toEqual({
|
|
27
|
+
id,
|
|
28
|
+
ops: [
|
|
29
|
+
{
|
|
30
|
+
type: 'UNSET_ENTITY_VALUES',
|
|
31
|
+
unsetEntityValues: {
|
|
32
|
+
id: toBase64(id),
|
|
33
|
+
properties: [],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=unset-entity-values.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-entity-values.test.js","sourceRoot":"","sources":["../../../src/graphv2/unset-entity-values.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF,MAAM,EAAE,GAAG,EAAE,CAAC,sCAAsC,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,CAAC,EAAE,CAAC,sCAAsC,CAAC,EAAE,EAAE,CAAC,sCAAsC,CAAC,CAAC,CAAC;QAC5G,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QAErD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,EAAE;YACF,GAAG,EAAE;gBACH;oBACE,IAAI,EAAE,qBAAqB;oBAC3B,iBAAiB,EAAE;wBACjB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC;wBAChB,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;qBAC3D;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,EAAE,GAAG,EAAE,CAAC,sCAAsC,CAAC,CAAC;QACtD,MAAM,UAAU,GAAS,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QAErD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,EAAE;YACF,GAAG,EAAE;gBACH;oBACE,IAAI,EAAE,qBAAqB;oBAC3B,iBAAiB,EAAE;wBACjB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC;wBAChB,UAAU,EAAE,EAAE;qBACf;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Id } from '../idv2.js';
|
|
2
|
+
import type { UnsetRelationFieldsOp, UnsetRelationParams } from '../typesv2.js';
|
|
3
|
+
/**
|
|
4
|
+
* Unsets fields from a relation.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const { ops } = await unsetRelationFields({
|
|
9
|
+
* id: relationId,
|
|
10
|
+
* fromVersion: true, // optional
|
|
11
|
+
* toSpace: true, // optional
|
|
12
|
+
* toVersion: true, // optional
|
|
13
|
+
* position: true, // optional
|
|
14
|
+
* verified: true, // optional
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param params – {@link UnsetRelationParams}
|
|
19
|
+
* @returns The operation to unset the relation.
|
|
20
|
+
*/
|
|
21
|
+
export declare const unsetRelationFields: ({ id, fromVersion, toSpace, toVersion, position, verified, }: UnsetRelationParams) => {
|
|
22
|
+
id: Id;
|
|
23
|
+
ops: UnsetRelationFieldsOp[];
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=unset-relation-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-relation-fields.d.ts","sourceRoot":"","sources":["../../../src/graphv2/unset-relation-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAY,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,GAAI,8DAOjC,mBAAmB;;;CAcrB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Id, toBase64 } from '../idv2.js';
|
|
2
|
+
/**
|
|
3
|
+
* Unsets fields from a relation.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const { ops } = await unsetRelationFields({
|
|
8
|
+
* id: relationId,
|
|
9
|
+
* fromVersion: true, // optional
|
|
10
|
+
* toSpace: true, // optional
|
|
11
|
+
* toVersion: true, // optional
|
|
12
|
+
* position: true, // optional
|
|
13
|
+
* verified: true, // optional
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param params – {@link UnsetRelationParams}
|
|
18
|
+
* @returns The operation to unset the relation.
|
|
19
|
+
*/
|
|
20
|
+
export const unsetRelationFields = ({ id, fromVersion, toSpace, toVersion, position, verified, }) => {
|
|
21
|
+
const op = {
|
|
22
|
+
type: 'UNSET_RELATION_FIELDS',
|
|
23
|
+
unsetRelationFields: {
|
|
24
|
+
id: toBase64(Id(id)),
|
|
25
|
+
fromVersion,
|
|
26
|
+
toSpace,
|
|
27
|
+
toVersion,
|
|
28
|
+
position,
|
|
29
|
+
verified,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return { id, ops: [op] };
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=unset-relation-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-relation-fields.js","sourceRoot":"","sources":["../../../src/graphv2/unset-relation-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,EAAE,EACF,WAAW,EACX,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,GACY,EAAE,EAAE;IACxB,MAAM,EAAE,GAA0B;QAChC,IAAI,EAAE,uBAAuB;QAC7B,mBAAmB,EAAE;YACnB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACpB,WAAW;YACX,OAAO;YACP,SAAS;YACT,QAAQ;YACR,QAAQ;SACT;KACF,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-relation-fields.test.d.ts","sourceRoot":"","sources":["../../../src/graphv2/unset-relation-fields.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { Id, toBase64 } from '../idv2.js';
|
|
3
|
+
import { unsetRelationFields } from './unset-relation-fields.js';
|
|
4
|
+
describe('unsetRelationFields', () => {
|
|
5
|
+
it('should create an unset relation operation with valid parameters', () => {
|
|
6
|
+
const id = Id('5cade575-7ecd-41ae-8348-1b22ffc2f94e');
|
|
7
|
+
const fromVersion = true;
|
|
8
|
+
const toSpace = true;
|
|
9
|
+
const toVersion = true;
|
|
10
|
+
const position = true;
|
|
11
|
+
const verified = true;
|
|
12
|
+
const result = unsetRelationFields({
|
|
13
|
+
id,
|
|
14
|
+
fromVersion,
|
|
15
|
+
toSpace,
|
|
16
|
+
toVersion,
|
|
17
|
+
position,
|
|
18
|
+
verified,
|
|
19
|
+
});
|
|
20
|
+
expect(result).toEqual({
|
|
21
|
+
id,
|
|
22
|
+
ops: [
|
|
23
|
+
{
|
|
24
|
+
type: 'UNSET_RELATION_FIELDS',
|
|
25
|
+
unsetRelationFields: {
|
|
26
|
+
id: toBase64(id),
|
|
27
|
+
fromVersion,
|
|
28
|
+
toSpace,
|
|
29
|
+
toVersion,
|
|
30
|
+
position,
|
|
31
|
+
verified,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
it('should handle optional parameters', () => {
|
|
38
|
+
const id = Id('5cade575-7ecd-41ae-8348-1b22ffc2f94e');
|
|
39
|
+
const toSpace = true;
|
|
40
|
+
const position = true;
|
|
41
|
+
const verified = true;
|
|
42
|
+
const result = unsetRelationFields({
|
|
43
|
+
id,
|
|
44
|
+
toSpace,
|
|
45
|
+
position,
|
|
46
|
+
verified,
|
|
47
|
+
});
|
|
48
|
+
expect(result).toEqual({
|
|
49
|
+
id,
|
|
50
|
+
ops: [
|
|
51
|
+
{
|
|
52
|
+
type: 'UNSET_RELATION_FIELDS',
|
|
53
|
+
unsetRelationFields: {
|
|
54
|
+
id: toBase64(id),
|
|
55
|
+
toSpace,
|
|
56
|
+
position,
|
|
57
|
+
verified,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=unset-relation-fields.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unset-relation-fields.test.js","sourceRoot":"","sources":["../../../src/graphv2/unset-relation-fields.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,EAAE,GAAG,EAAE,CAAC,sCAAsC,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,IAAI,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC;QAEtB,MAAM,MAAM,GAAG,mBAAmB,CAAC;YACjC,EAAE;YACF,WAAW;YACX,OAAO;YACP,SAAS;YACT,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,EAAE;YACF,GAAG,EAAE;gBACH;oBACE,IAAI,EAAE,uBAAuB;oBAC7B,mBAAmB,EAAE;wBACnB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC;wBAChB,WAAW;wBACX,OAAO;wBACP,SAAS;wBACT,QAAQ;wBACR,QAAQ;qBACT;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,EAAE,GAAG,EAAE,CAAC,sCAAsC,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC;QAEtB,MAAM,MAAM,GAAG,mBAAmB,CAAC;YACjC,EAAE;YACF,OAAO;YACP,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,EAAE;YACF,GAAG,EAAE;gBACH;oBACE,IAAI,EAAE,uBAAuB;oBAC7B,mBAAmB,EAAE;wBACnB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC;wBAChB,OAAO;wBACP,QAAQ;wBACR,QAAQ;qBACT;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CreateResult, UpdateEntityParams } from '../typesv2.js';
|
|
2
|
+
/**
|
|
3
|
+
* Updates an entity with the given name, description, cover and properties.
|
|
4
|
+
* All IDs passed to this function (cover, property IDs) are validated.
|
|
5
|
+
* If any invalid ID is provided, the function will throw an error.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { id, ops } = updateEntity({
|
|
10
|
+
* id: entityId,
|
|
11
|
+
* name: 'name of the entity',
|
|
12
|
+
* description: 'description of the entity',
|
|
13
|
+
* cover: imageEntityId,
|
|
14
|
+
* values: {
|
|
15
|
+
* // value property like text, number, url, time, point, checkbox
|
|
16
|
+
* [propertyId]: {
|
|
17
|
+
* type: 'TEXT', // TEXT | NUMBER | URL | TIME | POINT | CHECKBOX,
|
|
18
|
+
* value: 'value of the property',
|
|
19
|
+
* }
|
|
20
|
+
* },
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
* @param params – {@link UpdateEntityParams}
|
|
24
|
+
* @returns – {@link CreateResult}
|
|
25
|
+
* @throws Will throw an error if any provided ID is invalid
|
|
26
|
+
*/
|
|
27
|
+
export declare const updateEntity: ({ id, name, description, cover, values }: UpdateEntityParams) => CreateResult;
|
|
28
|
+
//# sourceMappingURL=update-entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-entity.d.ts","sourceRoot":"","sources":["../../../src/graphv2/update-entity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAsB,kBAAkB,EAAS,MAAM,eAAe,CAAC;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,GAAI,0CAA0C,kBAAkB,KAAG,YAgD3F,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { COVER_PROPERTY, DESCRIPTION_PROPERTY, NAME_PROPERTY } from '../core/idsv2/system.js';
|
|
2
|
+
import { Id, assertValid, generate, toBase64 } from '../idv2.js';
|
|
3
|
+
/**
|
|
4
|
+
* Updates an entity with the given name, description, cover and properties.
|
|
5
|
+
* All IDs passed to this function (cover, property IDs) are validated.
|
|
6
|
+
* If any invalid ID is provided, the function will throw an error.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const { id, ops } = updateEntity({
|
|
11
|
+
* id: entityId,
|
|
12
|
+
* name: 'name of the entity',
|
|
13
|
+
* description: 'description of the entity',
|
|
14
|
+
* cover: imageEntityId,
|
|
15
|
+
* values: {
|
|
16
|
+
* // value property like text, number, url, time, point, checkbox
|
|
17
|
+
* [propertyId]: {
|
|
18
|
+
* type: 'TEXT', // TEXT | NUMBER | URL | TIME | POINT | CHECKBOX,
|
|
19
|
+
* value: 'value of the property',
|
|
20
|
+
* }
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
* @param params – {@link UpdateEntityParams}
|
|
25
|
+
* @returns – {@link CreateResult}
|
|
26
|
+
* @throws Will throw an error if any provided ID is invalid
|
|
27
|
+
*/
|
|
28
|
+
export const updateEntity = ({ id, name, description, cover, values }) => {
|
|
29
|
+
assertValid(id, '`id` in `updateEntity`');
|
|
30
|
+
const ops = [];
|
|
31
|
+
const newValues = [];
|
|
32
|
+
if (name) {
|
|
33
|
+
newValues.push({
|
|
34
|
+
propertyId: toBase64(NAME_PROPERTY),
|
|
35
|
+
value: name,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (description) {
|
|
39
|
+
newValues.push({
|
|
40
|
+
propertyId: toBase64(DESCRIPTION_PROPERTY),
|
|
41
|
+
value: description,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
for (const [key, value] of Object.entries(values ?? {})) {
|
|
45
|
+
newValues.push({
|
|
46
|
+
propertyId: toBase64(Id(key)),
|
|
47
|
+
value: value.value,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const op = {
|
|
51
|
+
type: 'UPDATE_ENTITY',
|
|
52
|
+
entity: {
|
|
53
|
+
id: toBase64(Id(id)),
|
|
54
|
+
values: newValues,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
ops.push(op);
|
|
58
|
+
if (cover) {
|
|
59
|
+
assertValid(cover);
|
|
60
|
+
ops.push({
|
|
61
|
+
type: 'CREATE_RELATION',
|
|
62
|
+
relation: {
|
|
63
|
+
id: toBase64(generate()),
|
|
64
|
+
entity: toBase64(generate()),
|
|
65
|
+
fromEntity: toBase64(Id(id)),
|
|
66
|
+
toEntity: toBase64(Id(cover)),
|
|
67
|
+
type: toBase64(COVER_PROPERTY),
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return { id, ops };
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=update-entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-entity.js","sourceRoot":"","sources":["../../../src/graphv2/update-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC9F,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGjE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAsB,EAAgB,EAAE;IACzG,WAAW,CAAC,EAAE,EAAE,wBAAwB,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAc,EAAE,CAAC;IAE1B,MAAM,SAAS,GAAiB,EAAE,CAAC;IACnC,IAAI,IAAI,EAAE,CAAC;QACT,SAAS,CAAC,IAAI,CAAC;YACb,UAAU,EAAE,QAAQ,CAAC,aAAa,CAAC;YACnC,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;IACL,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,SAAS,CAAC,IAAI,CAAC;YACb,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAAC;YAC1C,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;QACxD,SAAS,CAAC,IAAI,CAAC;YACb,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YAC7B,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,EAAE,GAAmB;QACzB,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE;YACN,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACpB,MAAM,EAAE,SAAS;SAClB;KACF,CAAC;IACF,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEb,IAAI,KAAK,EAAE,CAAC;QACV,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACxB,MAAM,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBAC5B,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC5B,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAC7B,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC;aAC/B;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-entity.test.d.ts","sourceRoot":"","sources":["../../../src/graphv2/update-entity.test.ts"],"names":[],"mappings":""}
|