@dittolive/ditto 4.6.0 → 4.7.0-rc.3

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.
Files changed (69) hide show
  1. package/README.md +2 -2
  2. package/node/ditto.cjs.js +479 -128
  3. package/node/ditto.darwin-arm64.node +0 -0
  4. package/node/ditto.darwin-x64.node +0 -0
  5. package/node/ditto.linux-arm.node +0 -0
  6. package/node/ditto.linux-arm64.node +0 -0
  7. package/node/ditto.linux-x64.node +0 -0
  8. package/node/ditto.win32-x64.node +0 -0
  9. package/node/transports.darwin-arm64.node +0 -0
  10. package/node/transports.darwin-x64.node +0 -0
  11. package/package.json +1 -1
  12. package/react-native/android/.project +34 -0
  13. package/react-native/android/bin/.project +34 -0
  14. package/react-native/android/bin/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.class +0 -0
  15. package/react-native/android/bin/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.class +0 -0
  16. package/react-native/android/build/intermediates/cxx/abi_configuration_4i3a4k2a.json +14 -0
  17. package/react-native/android/build/intermediates/cxx/abi_configuration_4i3a4k2a.log +1 -0
  18. package/react-native/android/build/intermediates/cxx/abi_configuration_4i3a4k2a_key.json +23 -0
  19. package/react-native/android/build/intermediates/cxx/create_cxx_tasks_371_timing.txt +5 -0
  20. package/react-native/android/build/intermediates/cxx/ndk_locator_record_4q2c3f1f.json +11 -0
  21. package/react-native/android/build/intermediates/cxx/ndk_locator_record_4q2c3f1f.log +72 -0
  22. package/react-native/android/build/intermediates/cxx/ndk_locator_record_4q2c3f1f_key.json +10 -0
  23. package/react-native/android/build.gradle +1 -1
  24. package/react-native/android/cpp-adapter.cpp +39 -43
  25. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +1 -1
  26. package/react-native/cpp/include/Arc.hpp +18 -0
  27. package/react-native/cpp/include/ConnectionRequest.h +18 -0
  28. package/react-native/cpp/include/FFIUtils.h +2 -0
  29. package/react-native/cpp/include/Misc.h +1 -1
  30. package/react-native/cpp/include/Presence.h +4 -0
  31. package/react-native/cpp/include/Utils.h +14 -3
  32. package/react-native/cpp/src/Attachment.cpp +5 -6
  33. package/react-native/cpp/src/Authentication.cpp +1 -1
  34. package/react-native/cpp/src/Collection.cpp +2 -0
  35. package/react-native/cpp/src/ConnectionRequest.cpp +123 -0
  36. package/react-native/cpp/src/DQL.cpp +1 -1
  37. package/react-native/cpp/src/FFIUtils.cpp +58 -0
  38. package/react-native/cpp/src/Identity.cpp +2 -3
  39. package/react-native/cpp/src/LiveQuery.cpp +3 -3
  40. package/react-native/cpp/src/Misc.cpp +14 -23
  41. package/react-native/cpp/src/Presence.cpp +87 -0
  42. package/react-native/cpp/src/Utils.cpp +104 -99
  43. package/react-native/cpp/src/main.cpp +15 -2
  44. package/react-native/dittoffi/dittoffi.h +375 -252
  45. package/react-native/ios/DittoRNSDK.mm +3 -3
  46. package/react-native/src/ditto.rn.ts +12 -4
  47. package/react-native/src/index.ts +2 -2
  48. package/react-native/src/sources/bridge.ts +6 -2
  49. package/react-native/src/sources/connection-request.ts +139 -0
  50. package/react-native/src/sources/ditto.ts +31 -28
  51. package/react-native/src/sources/epilogue.ts +4 -2
  52. package/react-native/src/sources/error-codes.ts +37 -3
  53. package/react-native/src/sources/error.ts +30 -1
  54. package/react-native/src/sources/essentials.ts +6 -0
  55. package/react-native/src/sources/ffi-error.ts +20 -9
  56. package/react-native/src/sources/ffi.ts +206 -111
  57. package/react-native/src/sources/main.ts +1 -0
  58. package/react-native/src/sources/pending-collections-operation.ts +1 -1
  59. package/react-native/src/sources/presence.ts +189 -0
  60. package/react-native/src/sources/query-result-item.ts +4 -4
  61. package/react-native/src/sources/query-result.ts +6 -6
  62. package/react-native/src/sources/small-peer-info.ts +1 -12
  63. package/react-native/src/sources/store-observer.ts +6 -15
  64. package/react-native/src/sources/store.ts +5 -13
  65. package/react-native/src/sources/sync.ts +2 -3
  66. package/types/ditto.d.ts +265 -28
  67. package/web/ditto.es6.js +1 -1
  68. package/web/ditto.umd.js +1 -1
  69. package/web/ditto.wasm +0 -0
package/types/ditto.d.ts CHANGED
@@ -521,7 +521,7 @@ type Pointer<Type> = {
521
521
  /** @internal */
522
522
  declare const DittoCRDTTypeKey = "_ditto_internal_type_jkb12973t4b";
523
523
  /** @internal */
524
- type FFIDqlResponse = 'dittoffi_query_result_t';
524
+ type FFIQueryResult = 'dittoffi_query_result_t';
525
525
  /** @internal */
526
526
  type FFIWriteTransaction = 'CWriteTransaction_t';
527
527
  /** @internal */
@@ -2069,7 +2069,7 @@ declare class QueryResult {
2069
2069
  */
2070
2070
  mutatedDocumentIDs(): DocumentID[];
2071
2071
  /** @internal */
2072
- constructor(responsePointer: Pointer<FFIDqlResponse>);
2072
+ constructor(queryResultPointer: Pointer<FFIQueryResult>);
2073
2073
  }
2074
2074
 
2075
2075
  /**
@@ -2813,6 +2813,100 @@ declare class Store {
2813
2813
  registerLiveQueryWebhook(collectionName: string, query: string, url: string): Promise<DocumentID>;
2814
2814
  }
2815
2815
 
2816
+ /**
2817
+ * Indicates whether a connection request should be authorized.
2818
+ *
2819
+ * `allow` if the request should be authorized, `deny` otherwise.
2820
+ */
2821
+ type ConnectionRequestAuthorization = 'allow' | 'deny';
2822
+ /**
2823
+ * A handler for connection requests from other peers.
2824
+ *
2825
+ * Set a `ConnectionRequestHandler` on
2826
+ * {@link Presence.connectionRequestHandler | `ditto.presence.connectionRequestHandler`}
2827
+ * to allow or deny connection requests from other peers.
2828
+ *
2829
+ * @param connectionRequest - Contains information about the remote peer that
2830
+ * can be used to make an authorization decision.
2831
+ *
2832
+ * @returns `allow` if the request should be authorized, `deny` otherwise.
2833
+ *
2834
+ * @see
2835
+ * {@link Presence.connectionRequestHandler | `ditto.presence.connectionRequestHandler`}
2836
+ * for details on the connection request API.
2837
+ */
2838
+ type ConnectionRequestHandler = (connectionRequest: ConnectionRequest) => Promise<ConnectionRequestAuthorization>;
2839
+ /**
2840
+ * Contains information about a remote peer that has requested a connection.
2841
+ *
2842
+ * Connection requests and their authorization are scoped to a specific Ditto
2843
+ * peer and connection type.
2844
+ */
2845
+ declare class ConnectionRequest {
2846
+ /**
2847
+ * The unique peer key of the remote peer.
2848
+ *
2849
+ * @see field `peerKeyString` on {@link Peer} for more information on peer
2850
+ * keys.
2851
+ */
2852
+ get peerKeyString(): string;
2853
+ /**
2854
+ * Metadata associated with the remote peer.
2855
+ *
2856
+ * This is an empty object if the remote peer has not set any metadata.
2857
+ *
2858
+ * Set peer metadata for the local peer using {@link Presence.peerMetadata}
2859
+ * or {@link Presence.peerMetadataJSONString}.
2860
+ *
2861
+ * This is a convenience property that wraps
2862
+ * {@link peerMetadataJSONString | `peerMetadataJSONString()`}.
2863
+ */
2864
+ get peerMetadata(): Record<string, any>;
2865
+ /**
2866
+ * JSON-encoded metadata associated with the remote peer.
2867
+ *
2868
+ * This is a JSON string representing an empty dictionary if the remote peer
2869
+ * has not set any metadata.
2870
+ *
2871
+ * Set peer metadata for the local peer using {@link Presence.peerMetadata} or
2872
+ * {@link Presence.peerMetadataJSONString}.
2873
+ *
2874
+ * Uses UTF-8 encoding.
2875
+ */
2876
+ get peerMetadataJSONString(): string;
2877
+ /**
2878
+ * Metadata for the remote peer that is provided by the identity service.
2879
+ *
2880
+ * Use an authentication webhook to set this value. See Ditto's online
2881
+ * documentation for more information on how to configure an authentication
2882
+ * webhook.
2883
+ *
2884
+ * Convenience property that wraps {@link identityServiceMetadataJSONString}.
2885
+ */
2886
+ get identityServiceMetadata(): Record<string, any>;
2887
+ /**
2888
+ * JSON-encoded metadata for the remote peer that is provided by the
2889
+ * identity service.
2890
+ *
2891
+ * Use an authentication webhook to set this value. See Ditto's online
2892
+ * documentation for more information on how to configure an authentication
2893
+ * webhook.
2894
+ *
2895
+ * Uses UTF-8 encoding.
2896
+ */
2897
+ get identityServiceMetadataJSONString(): string;
2898
+ /**
2899
+ * The network transport of this connection request.
2900
+ *
2901
+ * Expect to receive separate connection requests for each network
2902
+ * transport that connects the local and remote peer.
2903
+ */
2904
+ get connectionType(): ConnectionType;
2905
+ /** @internal */
2906
+ toString(): string;
2907
+ private deref;
2908
+ }
2909
+
2816
2910
  /** Types of connections that can be established between two peers. */
2817
2911
  type ConnectionType = 'P2PWiFi' | 'WebSocket' | 'AccessPoint' | 'Bluetooth';
2818
2912
  /**
@@ -2874,8 +2968,36 @@ type Peer = {
2874
2968
  *
2875
2969
  * NOTE: This will be be empty when a peer is not updated to the latest
2876
2970
  * version of the SDK.
2971
+ *
2972
+ * @deprecated Use {@link peerKeyString} instead.
2877
2973
  */
2878
2974
  peerKey: Uint8Array;
2975
+ /**
2976
+ * The peer key is a unique identifier for a given peer, equal to or
2977
+ * derived from the cryptographic public key used to authenticate it.
2978
+ *
2979
+ * NOTE: This will be be empty when a peer is not updated to the latest
2980
+ * version of the SDK.
2981
+ */
2982
+ peerKeyString: string;
2983
+ /**
2984
+ * Metadata associated with the peer, empty dictionary by default.
2985
+ *
2986
+ * Use `ditto.presence.setPeerMetadata()` or
2987
+ * `ditto.presence.setPeerMetadataJSONData()` to set this value.
2988
+ *
2989
+ * @see {@link Presence.peerMetadata | `ditto.presence.peerMetadata`} for
2990
+ * details on usage of metadata.
2991
+ */
2992
+ peerMetadata: Record<string, any>;
2993
+ /**
2994
+ * Metadata associated with the peer by the identity service.
2995
+ *
2996
+ * Use an authentication webhook to set this value. See Ditto's online
2997
+ * documentation for more information on how to configure an authentication
2998
+ * webhook.
2999
+ */
3000
+ identityServiceMetadata: Record<string, any>;
2879
3001
  /**
2880
3002
  * The human-readable device name of the peer. This defaults to the hostname
2881
3003
  * but can be manually set by the application developer of the other peer.
@@ -2930,11 +3052,95 @@ type PresenceGraph = {
2930
3052
  declare class Presence {
2931
3053
  /** The Ditto instance this object belongs to. */
2932
3054
  readonly ditto: Ditto;
3055
+ /**
3056
+ * Set this handler to control which peers in a Ditto mesh can connect to the
3057
+ * current peer.
3058
+ *
3059
+ * Each peer in a Ditto mesh will attempt to connect to other peers that it
3060
+ * can reach. By default, the mesh will try and establish connections that
3061
+ * optimize for the best overall connectivity between peers. However, you can
3062
+ * set this handler to assert some control over which peers you connect to.
3063
+ *
3064
+ * If set, this handler is called for every incoming connection request from a
3065
+ * remote peer and is passed the other peer's `peerKey`, `peerMetadata`, and
3066
+ * `identityServiceMetadata`. The handler can then accept or reject the
3067
+ * request by returning an according {@link ConnectionRequestAuthorization}
3068
+ * value. When the connection request is rejected, the remote peer may retry
3069
+ * the connection request after a short delay.
3070
+ *
3071
+ * Connection request handlers must reliably respond to requests within a
3072
+ * short time. If a handler takes too long to respond or throws an exception,
3073
+ * the connection request will be denied. The response timeout is currently 10
3074
+ * seconds but may be subject to change in future releases.
3075
+ *
3076
+ * @see {@link peerMetadata | peerMetadata()}
3077
+ */
3078
+ get connectionRequestHandler(): ConnectionRequestHandler | null;
3079
+ /**
3080
+ * @throws TypeError: if the given handler is not a function.
3081
+ */
3082
+ set connectionRequestHandler(handler: ConnectionRequestHandler | null);
2933
3083
  /**
2934
3084
  * Returns the current presence graph capturing all known peers and
2935
3085
  * connections between them.
2936
3086
  */
2937
3087
  get graph(): PresenceGraph;
3088
+ /**
3089
+ * Metadata associated with the current peer. Other peers in the same mesh can
3090
+ * access this user-provided object of metadata via the presence {@link graph}
3091
+ * and when evaluating connection requests using
3092
+ * {@link connectionRequestHandler | connectionRequestHandler()}.
3093
+ *
3094
+ * Uses UTF-8 encoding.
3095
+ *
3096
+ * @see {@link peerMetadata | peerMetadata()} for a convenience property that
3097
+ * provides access to parsed metadata.
3098
+ */
3099
+ get peerMetadataJSONString(): string;
3100
+ /**
3101
+ * Set arbitrary metadata to be associated with the current peer.
3102
+ *
3103
+ * The metadata must not exceed 4 KB in size when JSON-encoded.
3104
+ *
3105
+ * @param {string} jsonString: JSON-encoded metadata.
3106
+ *
3107
+ * @throws {@link DittoError} `validation/invalid-json`: if `jsonString` does
3108
+ * not contain valid JSON.
3109
+ *
3110
+ * @throws {@link DittoError} `validation/not-an-object`: if `jsonString` does
3111
+ * not contain an object.
3112
+ *
3113
+ * @throws {@link DittoError} `validation/size-limit-exceeded`: if the size
3114
+ * limit for `jsonString` has been exceeded.
3115
+ *
3116
+ * @see {@link peerMetadataJSONString | peerMetadataJSONString()} for details
3117
+ * on usage of metadata.
3118
+ */
3119
+ setPeerMetadataJSONString(jsonString: string): Promise<void>;
3120
+ /**
3121
+ * This is a convenience property that wraps
3122
+ * {@link peerMetadataJSONString | peerMetadataJSONString()}.
3123
+ *
3124
+ * @see {@link peerMetadataJSONString | peerMetadataJSONString()} for details.
3125
+ */
3126
+ get peerMetadata(): Record<string, any>;
3127
+ /**
3128
+ * This is a convenience method that wraps
3129
+ * {@link setPeerMetadataJSONString | setPeerMetadataJSONString()}.
3130
+ *
3131
+ * @throws {@link DittoError} `validation/not-an-object`: if `peerMetadata` is
3132
+ * not an object.
3133
+ *
3134
+ * @throws {@link DittoError} `validation/not-json-compatible`: if
3135
+ * `peerMetadata` is not JSON serializable.
3136
+ *
3137
+ * @throws {@link DittoError} `validation/size-limit-exceeded`: if the size
3138
+ * limit for `peerMetadata` has been exceeded.
3139
+ *
3140
+ * @see {@link setPeerMetadataJSONString | setPeerMetadataJSONString()} for
3141
+ * details.
3142
+ */
3143
+ setPeerMetadata(peerMetadata: Record<string, any>): Promise<void>;
2938
3144
  /**
2939
3145
  * Request information about Ditto peers in range of this device.
2940
3146
  *
@@ -2949,6 +3155,7 @@ declare class Presence {
2949
3155
  /** @internal */
2950
3156
  close(): void;
2951
3157
  private observerManager;
3158
+ private _connectionRequestHandler;
2952
3159
  }
2953
3160
 
2954
3161
  /**
@@ -3293,7 +3500,7 @@ declare class SmallPeerInfo {
3293
3500
  *
3294
3501
  * - Must be a JSON object (not an array, string, number, etc.)
3295
3502
  * - The size when encoded as JSON must be less than 128 KB
3296
- * - May only be nested up to 2 levels deep
3503
+ * - May only be nested up to 64 levels deep
3297
3504
  *
3298
3505
  * @example <caption>Valid metadata</caption>
3299
3506
  * ditto.smallPeerInfo.metadata = {
@@ -3303,17 +3510,6 @@ declare class SmallPeerInfo {
3303
3510
  * }
3304
3511
  * }
3305
3512
  *
3306
- * @example <caption>Invalid metadata</caption>
3307
- * // This is invalid and results in an error.
3308
- * ditto.smallPeerInfo.metadata = {
3309
- * "foo": "bar",
3310
- * "nested": {
3311
- * "illegal": {
3312
- * "inner": "value"
3313
- * }
3314
- * }
3315
- * }
3316
- *
3317
3513
  * @throws when set to a value that violates any of the constraints listed
3318
3514
  * above.
3319
3515
  */
@@ -3382,15 +3578,19 @@ declare class Ditto {
3382
3578
  */
3383
3579
  static get VERSION(): string;
3384
3580
  /**
3385
- * Configure a custom identifier for the current device.
3581
+ * Configure a custom identifier for this peer.
3582
+ *
3583
+ * When using {@link Presence.observe | presence.observe()}, each remote peer
3584
+ * is represented by a short UTF-8 "device name". By default this will be a
3585
+ * truncated version of the device's hostname.
3386
3586
  *
3387
- * When using {@link Presence.observe | presence.observe()}, each remote peer is
3388
- * represented by a short UTF-8 "device name". By default this will be a
3389
- * truncated version of the device's hostname. It does not need to be unique
3390
- * among peers. Configure the device name before calling
3391
- * {@link startSync | startSync()}. If it is too long it may be truncated.
3587
+ * Changes to this property after {@link startSync | startSync()} was called
3588
+ * will only take effect after the next restart of sync. The value does not
3589
+ * need to be unique among peers. Device names longer than 24 bytes will be
3590
+ * truncated once {@link startSync | startSync()} is called.
3392
3591
  */
3393
- deviceName: string;
3592
+ get deviceName(): string;
3593
+ set deviceName(value: string);
3394
3594
  /** Returns a string identifying the version of the Ditto SDK. */
3395
3595
  get sdkVersion(): string;
3396
3596
  /**
@@ -3543,8 +3743,6 @@ declare class Ditto {
3543
3743
  *
3544
3744
  * @param licenseToken the license token to activate the `Ditto` instance
3545
3745
  * with. You can find yours on the [Ditto portal](https://portal.ditto.live).
3546
- *
3547
- * @throws {Error} if called in a React Native environment.
3548
3746
  */
3549
3747
  setOfflineOnlyLicenseToken(licenseToken: string): void;
3550
3748
  /**
@@ -3709,6 +3907,7 @@ declare class Ditto {
3709
3907
  private _isActivated;
3710
3908
  private _isSyncActive;
3711
3909
  private _isClosed;
3910
+ private _deviceName;
3712
3911
  /** Set of pending operations that need to complete before the Ditto instance can be closed in a safe manner. */
3713
3912
  private pendingOperations;
3714
3913
  private authClientValidityChanged;
@@ -3993,9 +4192,9 @@ type ErrorCode = keyof typeof ERROR_CODES;
3993
4192
  */
3994
4193
  declare const ERROR_CODES: {
3995
4194
  /** Internal error for unexpected system states */
3996
- readonly internal: "An unexpected internal error occured. Please get in touch with Ditto customer service to report this incident.";
3997
- /** Internal error with an unknown error cause **/
3998
- readonly 'internal/unknown-error': "An unexpected internal error occured. Please get in touch with Ditto customer service to report this incident.";
4195
+ readonly internal: "An unexpected internal error occurred. Please get in touch with Ditto customer service to report this incident.";
4196
+ /** Internal error with an unknown error cause */
4197
+ readonly 'internal/unknown-error': "An unexpected internal error occurred. Please get in touch with Ditto customer service to report this incident.";
3999
4198
  /** Error when using a feature not supported by the current environment */
4000
4199
  readonly 'sdk/unsupported': "The feature is not supported by the current environment.";
4001
4200
  /** Error for invalid DQL query arguments. */
@@ -4026,14 +4225,36 @@ declare const ERROR_CODES: {
4026
4225
  readonly 'store/failed-to-create-attachment': "The attachment could not be created.";
4027
4226
  /** An unclassified error while fetching an attachment. */
4028
4227
  readonly 'store/failed-to-fetch-attachment': "The attachment could not be fetched.";
4228
+ /** An error representing an invalid license token. */
4229
+ readonly 'activation/license-token-verification-failed': "Please provide a valid license token.";
4230
+ /** An error representing an expired license token. */
4231
+ readonly 'activation/license-token-expired': "The license token expired. Please renew it.";
4232
+ /** An error representing a token is in an unsupported future format. */
4233
+ readonly 'activation/license-token-unsupported-future-version': "The provided license token is in an unsupported future format.";
4234
+ /** The operation failed because it requires an activated Ditto instance. */
4235
+ readonly 'activation/not-activated': "The operation failed because the Ditto instance has not yet been activated.";
4236
+ /** A validation error where the maximum depth limit was exceeded. */
4237
+ readonly 'validation/depth-limit-exceeded': "The maximum depth limit has been exceeded.";
4238
+ /** A validation error where the value is not valid CBOR. */
4239
+ readonly 'validation/invalid-cbor': "The value provided is not valid CBOR.";
4240
+ /** A validation error where the value is not valid JSON. */
4241
+ readonly 'validation/invalid-json': "The value provided is not valid JSON.";
4242
+ /** A validation error where a value is required to be a JavaScript object */
4243
+ readonly 'validation/not-an-object': "The value provided is not of type object.";
4244
+ /** The value provided can not be serialized as JSON. */
4245
+ readonly 'validation/not-json-compatible': "Value is not serializable as JSON.";
4246
+ /** A validation error where a size limit was exceeded. */
4247
+ readonly 'validation/size-limit-exceeded': "The size limit has been exceeded.";
4029
4248
  };
4030
4249
 
4031
4250
  /**
4032
4251
  * Error codes for FFI result.
4033
4252
  *
4253
+ * This should include all variants of `FfiError` in `ffi/src/result/error.rs`.
4254
+ *
4034
4255
  * @internal
4035
4256
  */
4036
- type FFIResultErrorCode = 'StoreDocumentNotFound' | 'StoreDatabase' | 'StoreQuery' | 'Crdt' | 'JsFloatingStoreOperation' | 'DqlQueryCompilation' | 'DqlInvalidQueryArgs' | 'DqlUnsupported' | 'Base64Invalid';
4257
+ type FFIResultErrorCode = 'ActivationLicenseTokenExpired' | 'ActivationLicenseTokenInvalid' | 'ActivationLicenseUnsupportedFutureVersion' | 'ActivationNotActivated' | 'Base64Invalid' | 'Crdt' | 'DqlInvalidQueryArgs' | 'DqlQueryCompilation' | 'DqlUnsupported' | 'JsFloatingStoreOperation' | 'StoreDatabase' | 'StoreDocumentNotFound' | 'StoreQuery' | 'ValidationDepthLimitExceeded' | 'ValidationInvalidCbor' | 'ValidationInvalidJson' | 'ValidationNotAMap' | 'ValidationSizeLimitExceeded';
4037
4258
  /**
4038
4259
  * Represents an exception that occurred during a call into the Ditto FFI.
4039
4260
  *
@@ -4082,6 +4303,22 @@ type ErrorContext = Record<string, any>;
4082
4303
  *
4083
4304
  * Please reference {@link ERROR_CODES} for a comprehensive list of
4084
4305
  * possible error codes in this SDK version.
4306
+ *
4307
+ * @example
4308
+ * Handling a specific error code:
4309
+ * ```typescript
4310
+ * import { Attachment, DittoError } from '@dittolive/ditto'
4311
+ *
4312
+ * let attachment: Attachment
4313
+ * try {
4314
+ * attachment = await ditto.store.newAttachment(filePath)
4315
+ * } catch (error) {
4316
+ * if (error instanceof DittoError && error.code === 'store/attachment-file-not-found') {
4317
+ * // Handle a non-existing file
4318
+ * }
4319
+ * throw error // Rethrow any other error
4320
+ * }
4321
+ * ```
4085
4322
  */
4086
4323
  declare class DittoError extends Error {
4087
4324
  /**
@@ -4210,5 +4447,5 @@ declare class CBOR {
4210
4447
  static decode(data: Uint8Array, reviver?: (key: any, value: any) => any): any;
4211
4448
  }
4212
4449
 
4213
- export { type Address, Attachment, type AttachmentFetchEvent, type AttachmentFetchEventCompleted, type AttachmentFetchEventDeleted, type AttachmentFetchEventProgress, type AttachmentFetchEventType, AttachmentFetcher, type AttachmentMetadata, AttachmentToken, type AuthenticationHandler, type AuthenticationStatus, Authenticator, BasePendingCursorOperation, BasePendingIDSpecificOperation, CBOR, Collection, type CollectionInterface, CollectionsEvent, type CollectionsEventParams, type CollectionsObservationHandler, type ConditionSource, type Connection, type ConnectionType, Counter, type CustomLogCallback, type DQLQueryArgumentValue, type DQLQueryArguments, Ditto, DittoError, Document, DocumentID, type DocumentIDValue, DocumentPath, type DocumentValue, ERROR_CODES, type ErrorCode, type ErrorContext, type Identity, type IdentityManual, type IdentityOfflinePlayground, type IdentityOnlinePlayground, type IdentityOnlineWithAuthentication, type IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, type InitOptions, KeepAlive, LiveQuery, type LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, type LiveQueryEventUpdateParams, type LiveQueryMove, type LogLevel, Logger, MutableCounter, MutableDocument, MutableDocumentPath, MutableRegister, NotAvailableAuthenticator, Observer, type ObserverOptions, OnlineAuthenticator, type Peer, PendingCollectionsOperation, PendingCursorOperation, PendingIDSpecificOperation, Presence, type PresenceConnectionType, type PresenceGraph, type QueryArguments, type QueryObservationHandler, QueryResult, QueryResultItem, Register, type RemotePeer, SingleDocumentLiveQueryEvent, type SingleObservationHandler, SmallPeerInfo, type SmallPeerInfoSyncScope, type SortDirection, Store, type StoreObservationHandler, type StoreObservationHandlerWithSignalNext, StoreObserver, Subscription, Sync, type SyncParameters, type SyncState, SyncSubscription, type TransportCondition, TransportConfig, type TransportConfigConnect, type TransportConfigGlobal, type TransportConfigLan, type TransportConfigListen, type TransportConfigListenHTTP, type TransportConfigListenTCP, type TransportConfigPeerToPeer, type TypedAttachmentToken, type UntypedAttachmentToken, UpdateResult, type UpdateResultType, UpdateResultsMap, type UpsertOptions, type WebAssemblyModule, type WriteStrategy, WriteTransaction, WriteTransactionCollection, WriteTransactionPendingCursorOperation, WriteTransactionPendingIDSpecificOperation, type WriteTransactionResult, addressToString, checkAPIs, disableDeadlockTimeoutWhenDebugging, getBridgeLoad, init, mapFFIErrors, mapFFIErrorsAsync, transportConfigFromDeserializable, transportConfigToSerializable, validateAttachmentMetadata, validateDocumentIDCBOR, validateDocumentIDValue };
4450
+ export { type Address, Attachment, type AttachmentFetchEvent, type AttachmentFetchEventCompleted, type AttachmentFetchEventDeleted, type AttachmentFetchEventProgress, type AttachmentFetchEventType, AttachmentFetcher, type AttachmentMetadata, AttachmentToken, type AuthenticationHandler, type AuthenticationStatus, Authenticator, BasePendingCursorOperation, BasePendingIDSpecificOperation, CBOR, Collection, type CollectionInterface, CollectionsEvent, type CollectionsEventParams, type CollectionsObservationHandler, type ConditionSource, type Connection, ConnectionRequest, type ConnectionRequestAuthorization, type ConnectionRequestHandler, type ConnectionType, Counter, type CustomLogCallback, type DQLQueryArgumentValue, type DQLQueryArguments, Ditto, DittoError, Document, DocumentID, type DocumentIDValue, DocumentPath, type DocumentValue, ERROR_CODES, type ErrorCode, type ErrorContext, type Identity, type IdentityManual, type IdentityOfflinePlayground, type IdentityOnlinePlayground, type IdentityOnlineWithAuthentication, type IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, type InitOptions, KeepAlive, LiveQuery, type LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, type LiveQueryEventUpdateParams, type LiveQueryMove, type LogLevel, Logger, MutableCounter, MutableDocument, MutableDocumentPath, MutableRegister, NotAvailableAuthenticator, Observer, type ObserverOptions, OnlineAuthenticator, type Peer, PendingCollectionsOperation, PendingCursorOperation, PendingIDSpecificOperation, Presence, type PresenceConnectionType, type PresenceGraph, type QueryArguments, type QueryObservationHandler, QueryResult, QueryResultItem, Register, type RemotePeer, SingleDocumentLiveQueryEvent, type SingleObservationHandler, SmallPeerInfo, type SmallPeerInfoSyncScope, type SortDirection, Store, type StoreObservationHandler, type StoreObservationHandlerWithSignalNext, StoreObserver, Subscription, Sync, type SyncParameters, type SyncState, SyncSubscription, type TransportCondition, TransportConfig, type TransportConfigConnect, type TransportConfigGlobal, type TransportConfigLan, type TransportConfigListen, type TransportConfigListenHTTP, type TransportConfigListenTCP, type TransportConfigPeerToPeer, type TypedAttachmentToken, type UntypedAttachmentToken, UpdateResult, type UpdateResultType, UpdateResultsMap, type UpsertOptions, type WebAssemblyModule, type WriteStrategy, WriteTransaction, WriteTransactionCollection, WriteTransactionPendingCursorOperation, WriteTransactionPendingIDSpecificOperation, type WriteTransactionResult, addressToString, checkAPIs, disableDeadlockTimeoutWhenDebugging, getBridgeLoad, init, mapFFIErrors, mapFFIErrorsAsync, transportConfigFromDeserializable, transportConfigToSerializable, validateAttachmentMetadata, validateDocumentIDCBOR, validateDocumentIDValue };
4214
4451
  //# sourceMappingURL=ditto.d.ts.map