@graphprotocol/grc-20 0.31.0 → 0.32.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/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/examples/ranks/create-ordinal-rank.js +4 -4
- package/dist/examples/ranks/create-ordinal-rank.js.map +1 -1
- package/dist/examples/ranks/create-weighted-rank.js +4 -4
- package/dist/examples/ranks/create-weighted-rank.js.map +1 -1
- package/dist/proto.d.ts +4 -8
- package/dist/proto.d.ts.map +1 -1
- package/dist/proto.js +4 -8
- package/dist/proto.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/scripts/setup-rank-types.d.ts +2 -2
- package/dist/scripts/setup-rank-types.d.ts.map +1 -1
- package/dist/scripts/setup-rank-types.js.map +1 -1
- package/dist/src/codec/convert.d.ts +18 -0
- package/dist/src/codec/convert.d.ts.map +1 -0
- package/dist/src/codec/convert.js +188 -0
- package/dist/src/codec/convert.js.map +1 -0
- package/dist/src/core/account.d.ts +2 -2
- package/dist/src/core/account.d.ts.map +1 -1
- package/dist/src/core/account.js +2 -0
- package/dist/src/core/account.js.map +1 -1
- package/dist/src/core/account.test.js +69 -22
- package/dist/src/core/account.test.js.map +1 -1
- package/dist/src/core/blocks/data.d.ts +3 -3
- 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/data.test.js +74 -36
- package/dist/src/core/blocks/data.test.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 +3 -3
- 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/blocks/text.test.js +79 -15
- package/dist/src/core/blocks/text.test.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/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/encoding.test.d.ts +2 -0
- package/dist/src/encoding.test.d.ts.map +1 -0
- package/dist/src/encoding.test.js +644 -0
- package/dist/src/encoding.test.js.map +1 -0
- 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/full-flow-test.test.js +125 -37
- package/dist/src/full-flow-test.test.js.map +1 -1
- package/dist/src/graph/constants.d.ts +4 -0
- package/dist/src/graph/constants.d.ts.map +1 -1
- package/dist/src/graph/constants.js +14 -0
- package/dist/src/graph/constants.js.map +1 -1
- package/dist/src/graph/create-entity.d.ts +0 -1
- package/dist/src/graph/create-entity.d.ts.map +1 -1
- package/dist/src/graph/create-entity.js +155 -111
- package/dist/src/graph/create-entity.js.map +1 -1
- package/dist/src/graph/create-entity.test.js +339 -206
- package/dist/src/graph/create-entity.test.js.map +1 -1
- package/dist/src/graph/create-image.d.ts.map +1 -1
- package/dist/src/graph/create-image.js +15 -14
- package/dist/src/graph/create-image.js.map +1 -1
- package/dist/src/graph/create-image.test.js +109 -50
- package/dist/src/graph/create-image.test.js.map +1 -1
- package/dist/src/graph/create-property.d.ts.map +1 -1
- package/dist/src/graph/create-property.js +10 -19
- package/dist/src/graph/create-property.js.map +1 -1
- package/dist/src/graph/create-property.test.js +129 -19
- package/dist/src/graph/create-property.test.js.map +1 -1
- package/dist/src/graph/create-relation.d.ts +1 -3
- package/dist/src/graph/create-relation.d.ts.map +1 -1
- package/dist/src/graph/create-relation.js +21 -37
- package/dist/src/graph/create-relation.js.map +1 -1
- package/dist/src/graph/create-relation.test.js +186 -200
- package/dist/src/graph/create-relation.test.js.map +1 -1
- package/dist/src/graph/create-space.d.ts +4 -3
- 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/create-type.d.ts.map +1 -1
- package/dist/src/graph/create-type.js +16 -21
- package/dist/src/graph/create-type.js.map +1 -1
- package/dist/src/graph/create-type.test.js +76 -67
- package/dist/src/graph/create-type.test.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 +3 -6
- package/dist/src/graph/delete-relation.js.map +1 -1
- package/dist/src/graph/delete-relation.test.js +6 -8
- package/dist/src/graph/delete-relation.test.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 -4
- package/dist/src/graph/index.d.ts.map +1 -1
- package/dist/src/graph/index.js +1 -4
- package/dist/src/graph/index.js.map +1 -1
- package/dist/src/graph/update-entity.d.ts.map +1 -1
- package/dist/src/graph/update-entity.js +109 -57
- package/dist/src/graph/update-entity.js.map +1 -1
- package/dist/src/graph/update-entity.test.js +167 -40
- package/dist/src/graph/update-entity.test.js.map +1 -1
- package/dist/src/graph/update-relation.d.ts +1 -2
- package/dist/src/graph/update-relation.d.ts.map +1 -1
- package/dist/src/graph/update-relation.js +12 -16
- package/dist/src/graph/update-relation.js.map +1 -1
- package/dist/src/graph/update-relation.test.js +75 -109
- package/dist/src/graph/update-relation.test.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/id-utils.d.ts +6 -0
- package/dist/src/id-utils.d.ts.map +1 -1
- package/dist/src/id-utils.js +13 -0
- package/dist/src/id-utils.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 +7 -6
- package/dist/src/ipfs.d.ts.map +1 -1
- package/dist/src/ipfs.js +31 -11
- package/dist/src/ipfs.js.map +1 -1
- package/dist/src/ipfs.test.js +130 -17
- 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/proto/index.d.ts +7 -1
- package/dist/src/proto/index.d.ts.map +1 -1
- package/dist/src/proto/index.js +6 -1
- package/dist/src/proto/index.js.map +1 -1
- package/dist/src/ranks/create-rank.d.ts.map +1 -1
- package/dist/src/ranks/create-rank.js +54 -47
- package/dist/src/ranks/create-rank.js.map +1 -1
- package/dist/src/ranks/create-rank.test.js +181 -94
- package/dist/src/ranks/create-rank.test.js.map +1 -1
- 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 +52 -89
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.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 +2 -5
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with knowledge graph
|
|
3
|
+
* images in TypeScript.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.0.6
|
|
6
|
+
*/
|
|
7
|
+
import { type Id } from '../id.js';
|
|
8
|
+
import type { Op } from '../types.js';
|
|
9
|
+
type MakeImageReturnType = {
|
|
10
|
+
id: Id;
|
|
11
|
+
ops: Array<Op>;
|
|
12
|
+
};
|
|
13
|
+
type MakeImageParams = {
|
|
14
|
+
cid: string;
|
|
15
|
+
dimensions?: {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
id?: Id;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates an entity representing an Image.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const { id, ops } = Image.make({
|
|
27
|
+
* cid: 'https://example.com/image.png',
|
|
28
|
+
* dimensions: { width: 100, height: 100 },
|
|
29
|
+
* id: imageId, // optional and will be generated if not provided
|
|
30
|
+
* });
|
|
31
|
+
* console.log(id); // 'gw9uTVTnJdhtczyuzBkL3X'
|
|
32
|
+
* console.log(ops); // [...]
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @returns id – base58 encoded v4 uuid representing the image entity: {@link MakeImageReturnType}
|
|
36
|
+
* @returns ops – The ops for the Image entity: {@link MakeImageReturnType}
|
|
37
|
+
*/
|
|
38
|
+
export declare function make({ cid, dimensions, id }: MakeImageParams): MakeImageReturnType;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/core/image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,EAAY,MAAM,UAAU,CAAC;AAG7C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,KAAK,mBAAmB,GAAG;IACzB,EAAE,EAAE,EAAE,CAAC;IACP,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,EAAE,CAAC,EAAE,EAAE,CAAC;CACT,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,eAAe,GAAG,mBAAmB,CAkDlF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with knowledge graph
|
|
3
|
+
* images in TypeScript.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.0.6
|
|
6
|
+
*/
|
|
7
|
+
import { generate } from '../id.js';
|
|
8
|
+
import { Relation } from '../relation.js';
|
|
9
|
+
import { SystemIds } from '../system-ids.js';
|
|
10
|
+
/**
|
|
11
|
+
* Creates an entity representing an Image.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const { id, ops } = Image.make({
|
|
16
|
+
* cid: 'https://example.com/image.png',
|
|
17
|
+
* dimensions: { width: 100, height: 100 },
|
|
18
|
+
* id: imageId, // optional and will be generated if not provided
|
|
19
|
+
* });
|
|
20
|
+
* console.log(id); // 'gw9uTVTnJdhtczyuzBkL3X'
|
|
21
|
+
* console.log(ops); // [...]
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @returns id – base58 encoded v4 uuid representing the image entity: {@link MakeImageReturnType}
|
|
25
|
+
* @returns ops – The ops for the Image entity: {@link MakeImageReturnType}
|
|
26
|
+
*/
|
|
27
|
+
export function make({ cid, dimensions, id }) {
|
|
28
|
+
const entityId = id ?? generate();
|
|
29
|
+
const ops = [
|
|
30
|
+
Relation.make({
|
|
31
|
+
fromId: entityId,
|
|
32
|
+
toId: SystemIds.IMAGE_TYPE,
|
|
33
|
+
relationTypeId: SystemIds.TYPES_PROPERTY,
|
|
34
|
+
}),
|
|
35
|
+
{
|
|
36
|
+
type: 'SET_TRIPLE',
|
|
37
|
+
triple: {
|
|
38
|
+
entity: entityId,
|
|
39
|
+
attribute: SystemIds.IMAGE_URL_PROPERTY,
|
|
40
|
+
value: {
|
|
41
|
+
type: 'URL',
|
|
42
|
+
value: cid,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
if (dimensions) {
|
|
48
|
+
ops.push({
|
|
49
|
+
type: 'SET_TRIPLE',
|
|
50
|
+
triple: {
|
|
51
|
+
entity: entityId,
|
|
52
|
+
attribute: SystemIds.IMAGE_HEIGHT_PROPERTY,
|
|
53
|
+
value: {
|
|
54
|
+
type: 'NUMBER',
|
|
55
|
+
value: dimensions.height.toString(),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
ops.push({
|
|
60
|
+
type: 'SET_TRIPLE',
|
|
61
|
+
triple: {
|
|
62
|
+
entity: entityId,
|
|
63
|
+
attribute: SystemIds.IMAGE_WIDTH_PROPERTY,
|
|
64
|
+
value: {
|
|
65
|
+
type: 'NUMBER',
|
|
66
|
+
value: dimensions.width.toString(),
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
id: entityId,
|
|
73
|
+
ops,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/core/image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAiB7C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAmB;IAC3D,MAAM,QAAQ,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;IAClC,MAAM,GAAG,GAAc;QACrB,QAAQ,CAAC,IAAI,CAAC;YACZ,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,SAAS,CAAC,UAAU;YAC1B,cAAc,EAAE,SAAS,CAAC,cAAc;SACzC,CAAC;QACF;YACE,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE;gBACN,MAAM,EAAE,QAAQ;gBAChB,SAAS,EAAE,SAAS,CAAC,kBAAkB;gBACvC,KAAK,EAAE;oBACL,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,GAAG;iBACX;aACF;SACF;KACF,CAAC;IAEF,IAAI,UAAU,EAAE,CAAC;QACf,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE;gBACN,MAAM,EAAE,QAAQ;gBAChB,SAAS,EAAE,SAAS,CAAC,qBAAqB;gBAC1C,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;iBACpC;aACF;SACF,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE;gBACN,MAAM,EAAE,QAAQ;gBAChB,SAAS,EAAE,SAAS,CAAC,oBAAoB;gBACzC,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE;iBACnC;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,GAAG;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.test.d.ts","sourceRoot":"","sources":["../../../src/core/image.test.ts"],"names":[],"mappings":""}
|
|
@@ -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
|
+
//# sourceMappingURL=image.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.test.js","sourceRoot":"","sources":["../../../src/core/image.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation.js","sourceRoot":"","sources":["../../../src/core/relation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAmBzC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAC,IAA0B;IAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;IAElD,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE;YACR,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,IAAI,CAAC,cAAc;YACzB,UAAU,EAAE,IAAI,CAAC,MAAM;YACvB,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,KAAK,EAAE,IAAI,CAAC,QAAQ,IAAI,4BAA4B;SACrD;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,UAAkB;IACvC,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE;YACR,EAAE,EAAE,UAAU;SACf;KACF,CAAC;AACJ,CAAC;AAoBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,OAAO,CAAC,IAA2B;IACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAE3E,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE;YACN,SAAS,EAAE,SAAS,CAAC,cAAc;YACnC,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,KAAK,EAAE;gBACL,IAAI,EAAE,MAAM;gBACZ,KAAK,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"}
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.test.d.ts","sourceRoot":"","sources":["../../src/encoding.test.ts"],"names":[],"mappings":""}
|