@dittolive/ditto 1.0.15 → 1.0.18-alpha2
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 +2 -2
- package/index.html +3 -4
- package/node/ditto.cjs.js +1 -1
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +1 -1
- package/playground.cjs +3 -4
- package/types/ditto.d.ts +129 -166
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
package/types/ditto.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ declare type Pointer<Type> = {
|
|
|
23
23
|
};
|
|
24
24
|
/** @internal */
|
|
25
25
|
declare type AuthClientType = 'CAuthClient_t';
|
|
26
|
+
declare type OrderBy = {
|
|
27
|
+
query: string;
|
|
28
|
+
direction: 'Ascending' | 'Descending';
|
|
29
|
+
};
|
|
26
30
|
/** Various options to pass the web assembly module to Ditto. */
|
|
27
31
|
declare type WebAssemblyModule = RequestInfo | URL | Response | BufferSource | WebAssembly.Module | string | null;
|
|
28
32
|
|
|
@@ -243,7 +247,7 @@ interface IdentityOnlinePlayground {
|
|
|
243
247
|
* found at https://portal.ditto.live.
|
|
244
248
|
*/
|
|
245
249
|
appID: string;
|
|
246
|
-
/** If true, auto-configure sync with Ditto Cloud. */
|
|
250
|
+
/** If true, auto-configure sync with Ditto Cloud. Default is `true`. */
|
|
247
251
|
enableDittoCloudSync?: boolean;
|
|
248
252
|
}
|
|
249
253
|
/**
|
|
@@ -534,87 +538,6 @@ declare class Bridge<JSClass extends object, FFIType> {
|
|
|
534
538
|
private finalize;
|
|
535
539
|
}
|
|
536
540
|
|
|
537
|
-
/** Represents a unique identifier for a {@link Document}. */
|
|
538
|
-
declare class DocumentID {
|
|
539
|
-
/**
|
|
540
|
-
* Creates a new `DocumentID`.
|
|
541
|
-
*
|
|
542
|
-
* A document ID can be created from any of the following:
|
|
543
|
-
*
|
|
544
|
-
* - `string`
|
|
545
|
-
* - `number` (integer)
|
|
546
|
-
* - `boolean`
|
|
547
|
-
* - `null`
|
|
548
|
-
* - raw data in the form of a JS [Typed Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays)
|
|
549
|
-
* - `Array` (containing any of the items in this list)
|
|
550
|
-
* - Map (a raw JS `object`, where the keys must be strings and the values
|
|
551
|
-
* can be made up of any of the items in this list)
|
|
552
|
-
*
|
|
553
|
-
* Note that you cannot use floats or other custom types to create a document
|
|
554
|
-
* ID.
|
|
555
|
-
*
|
|
556
|
-
* Document IDs are also limited in size, based on their serialized
|
|
557
|
-
* representation, to 256 bytes. You will receive an error if you try to
|
|
558
|
-
* create a document ID that exceeds the size limit.
|
|
559
|
-
*
|
|
560
|
-
* @param value The value that represents the document identifier.
|
|
561
|
-
* @param skipCBOREncoding If `true, skips CBOR encoding and assumes
|
|
562
|
-
* the passed in `value` is already CBOR encoded. You shouldn't need to ever
|
|
563
|
-
* pass this parameter, it's only used internally for certain edge cases.
|
|
564
|
-
*/
|
|
565
|
-
constructor(value: any, skipCBOREncoding?: boolean);
|
|
566
|
-
/**
|
|
567
|
-
* Returns `true` if passed in `documentID` is equal to the receiver,
|
|
568
|
-
* otherwise returns `false`.
|
|
569
|
-
*/
|
|
570
|
-
equals(documentID: DocumentID): boolean;
|
|
571
|
-
/**
|
|
572
|
-
* Returns a string representation of the receiver.
|
|
573
|
-
*
|
|
574
|
-
* The returned string can be used directly in queries that you use with
|
|
575
|
-
* other Ditto functions. For example you could create a query that was like
|
|
576
|
-
* this:
|
|
577
|
-
*
|
|
578
|
-
* ``` TypeScript
|
|
579
|
-
* collection.find(`_id == ${documentID.toString()}`)
|
|
580
|
-
* ```
|
|
581
|
-
*/
|
|
582
|
-
toString(): string;
|
|
583
|
-
toBase64String(): string;
|
|
584
|
-
/**
|
|
585
|
-
* Returns the value of the receiver, lazily decoded from its CBOR
|
|
586
|
-
* representation if needed.
|
|
587
|
-
*/
|
|
588
|
-
get value(): any;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
declare class Counter {
|
|
592
|
-
/** The value of the counter. */
|
|
593
|
-
readonly value: number;
|
|
594
|
-
/** Whether the counter is set as a default value. */
|
|
595
|
-
readonly isDefault: boolean;
|
|
596
|
-
/**
|
|
597
|
-
* Creates a new counter with an initial value that can be used as part
|
|
598
|
-
* of a document's content.
|
|
599
|
-
*
|
|
600
|
-
* @param isDefault Represents whether or not the value should be set as a
|
|
601
|
-
* default value. Set this to `true` if you want to set a default value that
|
|
602
|
-
* you expect to be overwritten by other devices in the network. The default
|
|
603
|
-
* value is `false`.
|
|
604
|
-
*/
|
|
605
|
-
constructor(value: number, isDefault?: boolean);
|
|
606
|
-
/**
|
|
607
|
-
* Increments the counter by `amount`, which can be any valid number. Only
|
|
608
|
-
* valid within the closure of {@link Collection}'s {@link Collection.update | update()}
|
|
609
|
-
* method, otherwise an exception is thrown.
|
|
610
|
-
*/
|
|
611
|
-
increment(amount: number): void;
|
|
612
|
-
/** @internal */
|
|
613
|
-
static __newInternal(mutDoc: any, path: any, value: any): Counter;
|
|
614
|
-
private mutDoc;
|
|
615
|
-
private path;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
541
|
/**
|
|
619
542
|
* The types of an {@link UpdateResult}.
|
|
620
543
|
*/
|
|
@@ -623,7 +546,7 @@ declare class UpdateResult {
|
|
|
623
546
|
/** The update result's type. */
|
|
624
547
|
readonly type: UpdateResultType;
|
|
625
548
|
/** The ID of the document that was updated. */
|
|
626
|
-
readonly docID:
|
|
549
|
+
readonly docID: DocumentIDValue;
|
|
627
550
|
/** The path to the key in the document that was updated. */
|
|
628
551
|
readonly path: string;
|
|
629
552
|
/**
|
|
@@ -643,19 +566,19 @@ declare class UpdateResult {
|
|
|
643
566
|
/** The associated amount, only set if {@link type} is `incremented`. */
|
|
644
567
|
readonly amount?: number;
|
|
645
568
|
/** @internal */
|
|
646
|
-
static set(docID:
|
|
569
|
+
static set(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
647
570
|
/** @internal */
|
|
648
|
-
static replacedWithCounter(docID:
|
|
571
|
+
static replacedWithCounter(docID: DocumentIDValue, path: string): UpdateResult;
|
|
649
572
|
/** @internal */
|
|
650
|
-
static incremented(docID:
|
|
573
|
+
static incremented(docID: DocumentIDValue, path: string, amount: number): UpdateResult;
|
|
651
574
|
/** @internal */
|
|
652
|
-
static inserted(docID:
|
|
575
|
+
static inserted(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
653
576
|
/** @internal */
|
|
654
|
-
static removed(docID:
|
|
577
|
+
static removed(docID: DocumentIDValue, path: string): UpdateResult;
|
|
655
578
|
/** @internal */
|
|
656
|
-
static pushed(docID:
|
|
579
|
+
static pushed(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
657
580
|
/** @internal */
|
|
658
|
-
static popped(docID:
|
|
581
|
+
static popped(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
659
582
|
/** @internal */
|
|
660
583
|
private constructor();
|
|
661
584
|
}
|
|
@@ -788,53 +711,8 @@ declare class MutableDocumentPath {
|
|
|
788
711
|
atIndex(index: number): MutableDocumentPath;
|
|
789
712
|
}
|
|
790
713
|
|
|
791
|
-
/**
|
|
792
|
-
|
|
793
|
-
* {@link Collection.fetchAttachment | fetchAttachment()} on a
|
|
794
|
-
* {@link Collection}.
|
|
795
|
-
*/
|
|
796
|
-
declare class AttachmentToken {
|
|
797
|
-
/** @internal */
|
|
798
|
-
readonly id: Uint8Array;
|
|
799
|
-
/** @internal */
|
|
800
|
-
readonly len: number;
|
|
801
|
-
/** @internal */
|
|
802
|
-
readonly metadata: {
|
|
803
|
-
[key: string]: string;
|
|
804
|
-
};
|
|
805
|
-
/** @internal */
|
|
806
|
-
constructor(jsObj: object);
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* Represents an attachment and can be used to insert the associated attachment
|
|
811
|
-
* into a document at a specific key.
|
|
812
|
-
*/
|
|
813
|
-
declare class Attachment {
|
|
814
|
-
/** @internal */
|
|
815
|
-
readonly ditto: Ditto;
|
|
816
|
-
/** @internal */
|
|
817
|
-
readonly token: AttachmentToken;
|
|
818
|
-
/** The attachment's metadata. */
|
|
819
|
-
get metadata(): {
|
|
820
|
-
[key: string]: string;
|
|
821
|
-
};
|
|
822
|
-
/**
|
|
823
|
-
* Returns the attachment's data.
|
|
824
|
-
*/
|
|
825
|
-
getData(): Promise<Uint8Array>;
|
|
826
|
-
/**
|
|
827
|
-
* Copies the attachment to the specified file path. Node-only,
|
|
828
|
-
* throws in the browser.
|
|
829
|
-
*
|
|
830
|
-
* @param path The path that the attachment should be copied to.
|
|
831
|
-
*/
|
|
832
|
-
copyToPath(path: string): Promise<void>;
|
|
833
|
-
/** @internal */
|
|
834
|
-
constructor(ditto: Ditto, token: AttachmentToken);
|
|
835
|
-
}
|
|
836
|
-
declare const attachmentBridge: Bridge<Attachment, "AttachmentHandle_t">;
|
|
837
|
-
|
|
714
|
+
/** Represents a unique identifier for a {@link Document}. */
|
|
715
|
+
declare type DocumentIDValue = any;
|
|
838
716
|
/**
|
|
839
717
|
* This is used whenever you can access the document content properties
|
|
840
718
|
* directly via the document.
|
|
@@ -849,15 +727,13 @@ declare type MutableDocumentLike = MutableDocument | DocumentValue | any;
|
|
|
849
727
|
* A document value is a JavaScript object containing values for keys that
|
|
850
728
|
* can be serialized via CBOR.
|
|
851
729
|
*/
|
|
852
|
-
declare type DocumentValue =
|
|
853
|
-
[key: string]: null | boolean | boolean[] | number | number[] | string | string[] | DocumentID | DocumentValue | DocumentValue[] | Counter | Attachment | AttachmentToken;
|
|
854
|
-
};
|
|
730
|
+
declare type DocumentValue = Record<string, any>;
|
|
855
731
|
/** A document belonging to a {@link Collection} with an inner value. */
|
|
856
732
|
declare class Document {
|
|
857
733
|
/**
|
|
858
734
|
* Returns the ID of the document.
|
|
859
735
|
*/
|
|
860
|
-
readonly _id:
|
|
736
|
+
readonly _id: DocumentIDValue;
|
|
861
737
|
/**
|
|
862
738
|
* Returns the content (aka value) of the document.
|
|
863
739
|
*/
|
|
@@ -873,11 +749,27 @@ declare class Document {
|
|
|
873
749
|
/**
|
|
874
750
|
* Returns the ID for a document.
|
|
875
751
|
*/
|
|
876
|
-
static id(document: DocumentLike):
|
|
752
|
+
static id(document: DocumentLike): DocumentIDValue;
|
|
877
753
|
/**
|
|
878
754
|
* Returns the content (aka inner value) of a document.
|
|
879
755
|
*/
|
|
880
756
|
static value(document: DocumentLike): DocumentValue;
|
|
757
|
+
/**
|
|
758
|
+
* Returns a string representation of the passed in document ID value.
|
|
759
|
+
*
|
|
760
|
+
* The returned string can be used directly in queries that you use with
|
|
761
|
+
* other Ditto functions. For example you could create a query that was like
|
|
762
|
+
* this:
|
|
763
|
+
*
|
|
764
|
+
* ``` TypeScript
|
|
765
|
+
* collection.find(`_id == ${Document.stringForID(documentID)}`)
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
static stringForID(documentID: DocumentIDValue): string;
|
|
769
|
+
/**
|
|
770
|
+
* Returns a byte representation of the document ID value as base64 string.
|
|
771
|
+
*/
|
|
772
|
+
static base64StringForID(documentID: DocumentIDValue): string;
|
|
881
773
|
/**
|
|
882
774
|
* Returns the content (aka inner value) of a document at the given path.
|
|
883
775
|
*/
|
|
@@ -910,7 +802,7 @@ declare class MutableDocument {
|
|
|
910
802
|
/**
|
|
911
803
|
* Returns the ID of the document.
|
|
912
804
|
*/
|
|
913
|
-
readonly _id:
|
|
805
|
+
readonly _id: DocumentIDValue;
|
|
914
806
|
/**
|
|
915
807
|
* Returns the content (aka value) of the document. What you actually get is
|
|
916
808
|
* a proxy that you can freely manipulate and Ditto will register the changes,
|
|
@@ -941,7 +833,7 @@ declare class MutableDocument {
|
|
|
941
833
|
*/
|
|
942
834
|
readonly _incrementCounterAt: (mutableDocument: MutableDocumentLike, keyPath: string, amount: number, skipValidation?: boolean) => void;
|
|
943
835
|
/** Returns the ID for a mutable document. */
|
|
944
|
-
static id(mutableDocument: MutableDocumentLike):
|
|
836
|
+
static id(mutableDocument: MutableDocumentLike): DocumentIDValue;
|
|
945
837
|
/**
|
|
946
838
|
* Returns the content (aka inner value) of a mutable document.
|
|
947
839
|
*/
|
|
@@ -973,6 +865,53 @@ declare const documentBridge: Bridge<Document, "CDocument_t">;
|
|
|
973
865
|
/** @internal */
|
|
974
866
|
declare const mutableDocumentBridge: Bridge<MutableDocument, "CDocument_t">;
|
|
975
867
|
|
|
868
|
+
/**
|
|
869
|
+
* Serves as a token for a specific attachment that you can pass to a call to
|
|
870
|
+
* {@link Collection.fetchAttachment | fetchAttachment()} on a
|
|
871
|
+
* {@link Collection}.
|
|
872
|
+
*/
|
|
873
|
+
declare class AttachmentToken {
|
|
874
|
+
/** @internal */
|
|
875
|
+
readonly id: Uint8Array;
|
|
876
|
+
/** @internal */
|
|
877
|
+
readonly len: number;
|
|
878
|
+
/** @internal */
|
|
879
|
+
readonly metadata: {
|
|
880
|
+
[key: string]: string;
|
|
881
|
+
};
|
|
882
|
+
/** @internal */
|
|
883
|
+
constructor(jsObj: object);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Represents an attachment and can be used to insert the associated attachment
|
|
888
|
+
* into a document at a specific key.
|
|
889
|
+
*/
|
|
890
|
+
declare class Attachment {
|
|
891
|
+
/** @internal */
|
|
892
|
+
readonly ditto: Ditto;
|
|
893
|
+
/** @internal */
|
|
894
|
+
readonly token: AttachmentToken;
|
|
895
|
+
/** The attachment's metadata. */
|
|
896
|
+
get metadata(): {
|
|
897
|
+
[key: string]: string;
|
|
898
|
+
};
|
|
899
|
+
/**
|
|
900
|
+
* Returns the attachment's data.
|
|
901
|
+
*/
|
|
902
|
+
getData(): Promise<Uint8Array>;
|
|
903
|
+
/**
|
|
904
|
+
* Copies the attachment to the specified file path. Node-only,
|
|
905
|
+
* throws in the browser.
|
|
906
|
+
*
|
|
907
|
+
* @param path The path that the attachment should be copied to.
|
|
908
|
+
*/
|
|
909
|
+
copyToPath(path: string): Promise<void>;
|
|
910
|
+
/** @internal */
|
|
911
|
+
constructor(ditto: Ditto, token: AttachmentToken);
|
|
912
|
+
}
|
|
913
|
+
declare const attachmentBridge: Bridge<Attachment, "AttachmentHandle_t">;
|
|
914
|
+
|
|
976
915
|
/**
|
|
977
916
|
* The types of attachment fetch events that can be delivered to an attachment
|
|
978
917
|
* fetcher's `callback`.
|
|
@@ -1106,7 +1045,7 @@ declare class Subscription {
|
|
|
1106
1045
|
}
|
|
1107
1046
|
|
|
1108
1047
|
/**
|
|
1109
|
-
* Maps a {@link
|
|
1048
|
+
* Maps a {@link DocumentIDValue} to an array of
|
|
1110
1049
|
* @link UpdateResult | update results}. This is the data structure you get
|
|
1111
1050
|
* when {@link PendingCursorOperation.update | updating} a set of documents
|
|
1112
1051
|
* with detailed info about the performed updates.
|
|
@@ -1116,14 +1055,14 @@ declare class UpdateResultsMap {
|
|
|
1116
1055
|
* Returns an array of {@link UpdateResult | update results} associated with
|
|
1117
1056
|
* the `documentID` or undefined if not found.
|
|
1118
1057
|
*/
|
|
1119
|
-
get(documentID:
|
|
1058
|
+
get(documentID: DocumentIDValue): UpdateResult[] | undefined;
|
|
1120
1059
|
/**
|
|
1121
|
-
* Returns all contained keys, i.e. {@link
|
|
1060
|
+
* Returns all contained keys, i.e. {@link DocumentIDValue | document IDs}
|
|
1122
1061
|
* contained in this map.
|
|
1123
1062
|
*/
|
|
1124
|
-
keys():
|
|
1063
|
+
keys(): DocumentIDValue[];
|
|
1125
1064
|
/** @internal */
|
|
1126
|
-
constructor(documentIDs:
|
|
1065
|
+
constructor(documentIDs: DocumentIDValue[], updateResultsByDocumentIDString: object);
|
|
1127
1066
|
private documentIDs;
|
|
1128
1067
|
private updateResultsByDocumentIDString;
|
|
1129
1068
|
}
|
|
@@ -1163,9 +1102,10 @@ declare class LiveQuery {
|
|
|
1163
1102
|
/** @internal */
|
|
1164
1103
|
readonly waitsForNextSignal: boolean;
|
|
1165
1104
|
/** @internal */
|
|
1166
|
-
constructor(query: string, queryArgs: QueryArguments | null, queryArgsCBOR: Uint8Array | null, limit: number, offset: number, collection: Collection, subscription: Subscription | null, waitsForNextSignal: boolean, handler: QueryObservationHandler);
|
|
1105
|
+
constructor(query: string, queryArgs: QueryArguments | null, queryArgsCBOR: Uint8Array | null, orderBys: OrderBy[], limit: number, offset: number, collection: Collection, subscription: Subscription | null, waitsForNextSignal: boolean, handler: QueryObservationHandler);
|
|
1167
1106
|
/** @internal */
|
|
1168
1107
|
signalNext(): Promise<void>;
|
|
1108
|
+
private orderBys;
|
|
1169
1109
|
private queryArgsCBOR;
|
|
1170
1110
|
private liveQueryID;
|
|
1171
1111
|
}
|
|
@@ -1475,7 +1415,7 @@ declare class PendingCursorOperation implements PromiseLike<DocumentLike[]> {
|
|
|
1475
1415
|
* @returns An array promise containing the IDs of the documents that were
|
|
1476
1416
|
* removed.
|
|
1477
1417
|
*/
|
|
1478
|
-
remove(): Promise<
|
|
1418
|
+
remove(): Promise<DocumentIDValue[]>;
|
|
1479
1419
|
/**
|
|
1480
1420
|
* Evicts all documents that match the query generated by the preceding
|
|
1481
1421
|
* function chaining.
|
|
@@ -1483,7 +1423,7 @@ declare class PendingCursorOperation implements PromiseLike<DocumentLike[]> {
|
|
|
1483
1423
|
* @return An array promise containing the IDs of the documents that were
|
|
1484
1424
|
* evicted.
|
|
1485
1425
|
*/
|
|
1486
|
-
evict(): Promise<
|
|
1426
|
+
evict(): Promise<DocumentIDValue[]>;
|
|
1487
1427
|
/**
|
|
1488
1428
|
* Executes the query generated by the preceding function chaining and return
|
|
1489
1429
|
* the list of matching documents.
|
|
@@ -1548,7 +1488,7 @@ declare type SingleObservationHandler = (document: DocumentLike | null, event: S
|
|
|
1548
1488
|
*/
|
|
1549
1489
|
declare class PendingIDSpecificOperation implements PromiseLike<DocumentLike | undefined> {
|
|
1550
1490
|
/** The ID of the document this operation operates on. */
|
|
1551
|
-
readonly documentID:
|
|
1491
|
+
readonly documentID: DocumentIDValue;
|
|
1552
1492
|
/** The collection the receiver is operating on. */
|
|
1553
1493
|
readonly collection: Collection;
|
|
1554
1494
|
/**
|
|
@@ -1689,9 +1629,10 @@ declare class PendingIDSpecificOperation implements PromiseLike<DocumentLike | u
|
|
|
1689
1629
|
*/
|
|
1690
1630
|
update(closure: (document: MutableDocumentLike) => void): Promise<UpdateResult[]>;
|
|
1691
1631
|
/** @internal */
|
|
1692
|
-
constructor(documentID:
|
|
1632
|
+
constructor(documentID: DocumentIDValue, collection: Collection);
|
|
1693
1633
|
/** @internal */
|
|
1694
1634
|
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
|
|
1635
|
+
private documentIDCBOR;
|
|
1695
1636
|
private get query();
|
|
1696
1637
|
private _observe;
|
|
1697
1638
|
}
|
|
@@ -1748,20 +1689,16 @@ declare class Collection {
|
|
|
1748
1689
|
* if you want to get updates about the document over time. It can also be
|
|
1749
1690
|
* used to update, remove or evict the document.
|
|
1750
1691
|
*
|
|
1751
|
-
* @param id The ID of the document to find.
|
|
1752
|
-
* {@link DocumentID} then Ditto will automatically create a {@link DocumentID}
|
|
1753
|
-
* instance from it.
|
|
1692
|
+
* @param id The ID of the document to find.
|
|
1754
1693
|
*/
|
|
1755
|
-
findByID(id:
|
|
1694
|
+
findByID(id: DocumentIDValue): PendingIDSpecificOperation;
|
|
1756
1695
|
/**
|
|
1757
1696
|
* Inserts a new document into the collection and returns its ID.
|
|
1758
1697
|
*
|
|
1759
1698
|
* @param value The content for the new document to insert.
|
|
1760
1699
|
*
|
|
1761
1700
|
* @param options.id The ID to use for the document. If `null` or `undefined`
|
|
1762
|
-
* then Ditto will automatically generate an ID.
|
|
1763
|
-
* {@link DocumentID} then Ditto will automatically create a
|
|
1764
|
-
* {@link DocumentID} instance from it.
|
|
1701
|
+
* then Ditto will automatically generate an ID.
|
|
1765
1702
|
*
|
|
1766
1703
|
* @param options.isDefault This option is now deprecated. You should instead
|
|
1767
1704
|
* specify a `writeStrategy` if you wish to insert data as default data. If
|
|
@@ -1774,7 +1711,7 @@ declare class Collection {
|
|
|
1774
1711
|
* @param options.writeStrategy Specifies the desired strategy for inserting a
|
|
1775
1712
|
* document. The default value is `'overwrite'`.
|
|
1776
1713
|
*/
|
|
1777
|
-
insert(value: DocumentValue, options?: InsertOptions): Promise<
|
|
1714
|
+
insert(value: DocumentValue, options?: InsertOptions): Promise<DocumentIDValue>;
|
|
1778
1715
|
/**
|
|
1779
1716
|
* Creates a new {@link Attachment} object, which can then be inserted into a
|
|
1780
1717
|
* document. Node only, throws when running in the web browser.
|
|
@@ -1792,8 +1729,7 @@ declare class Collection {
|
|
|
1792
1729
|
*
|
|
1793
1730
|
* ``` JavaScript
|
|
1794
1731
|
* const attachment = collection.newAttachment('/path/to/my/file.pdf')
|
|
1795
|
-
*
|
|
1796
|
-
* collection.insert({ _id: docID, attachment, other: 'some-string' })
|
|
1732
|
+
* collection.insert({ _id: '123', attachment, other: 'some-string' })
|
|
1797
1733
|
* }
|
|
1798
1734
|
* ```
|
|
1799
1735
|
*
|
|
@@ -2039,7 +1975,7 @@ declare class Store {
|
|
|
2039
1975
|
* Private method, used only by the Portal https://github.com/getditto/ditto/pull/3652
|
|
2040
1976
|
* @internal
|
|
2041
1977
|
*/
|
|
2042
|
-
registerLiveQueryWebhook(collectionName: string, query: string, url: string):
|
|
1978
|
+
registerLiveQueryWebhook(collectionName: string, query: string, url: string): DocumentIDValue;
|
|
2043
1979
|
}
|
|
2044
1980
|
|
|
2045
1981
|
/** @internal */
|
|
@@ -2280,6 +2216,33 @@ declare class Value {
|
|
|
2280
2216
|
constructor(value: unknown, options?: unknown);
|
|
2281
2217
|
}
|
|
2282
2218
|
|
|
2219
|
+
declare class Counter {
|
|
2220
|
+
/** The value of the counter. */
|
|
2221
|
+
readonly value: number;
|
|
2222
|
+
/** Whether the counter is set as a default value. */
|
|
2223
|
+
readonly isDefault: boolean;
|
|
2224
|
+
/**
|
|
2225
|
+
* Creates a new counter with an initial value that can be used as part
|
|
2226
|
+
* of a document's content.
|
|
2227
|
+
*
|
|
2228
|
+
* @param isDefault Represents whether or not the value should be set as a
|
|
2229
|
+
* default value. Set this to `true` if you want to set a default value that
|
|
2230
|
+
* you expect to be overwritten by other devices in the network. The default
|
|
2231
|
+
* value is `false`.
|
|
2232
|
+
*/
|
|
2233
|
+
constructor(value: number, isDefault?: boolean);
|
|
2234
|
+
/**
|
|
2235
|
+
* Increments the counter by `amount`, which can be any valid number. Only
|
|
2236
|
+
* valid within the closure of {@link Collection}'s {@link Collection.update | update()}
|
|
2237
|
+
* method, otherwise an exception is thrown.
|
|
2238
|
+
*/
|
|
2239
|
+
increment(amount: number): void;
|
|
2240
|
+
/** @internal */
|
|
2241
|
+
static __newInternal(mutDoc: any, path: any, value: any): Counter;
|
|
2242
|
+
private mutDoc;
|
|
2243
|
+
private path;
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2283
2246
|
/** The log levels supported by Ditto. */
|
|
2284
2247
|
declare type LogLevel = 'Error' | 'Warning' | 'Info' | 'Debug' | 'Verbose';
|
|
2285
2248
|
/**
|
|
@@ -2446,5 +2409,5 @@ declare class Logger {
|
|
|
2446
2409
|
private constructor();
|
|
2447
2410
|
}
|
|
2448
2411
|
|
|
2449
|
-
export { Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, Authenticator, Collection, ConditionSource, Counter, CustomLogCallback, Ditto, Document,
|
|
2412
|
+
export { Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, Authenticator, Collection, CollectionsEvent, CollectionsEventParams, ConditionSource, Counter, CustomLogCallback, Ditto, Document, DocumentIDValue, DocumentLike, DocumentPath, DocumentValue, Identity, IdentityDevelopment, IdentityManual, IdentityOfflinePlayground, IdentityOnline, IdentityOnlinePlayground, IdentityOnlineWithAuthentication, IdentityProduction, IdentitySharedKey, InitOptions, InsertOptions, LiveQuery, LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, LiveQueryEventUpdateParams, LiveQueryMove, LogLevel, Logger, MutableDocument, MutableDocumentLike, MutableDocumentPath, NotAvailableAuthenticator, Observer, OnlineWithAuthenticationAuthenticator, PendingCursorOperation, PendingIDSpecificOperation, PresenceConnectionType, QueryArguments, QueryObservationHandler, RemotePeer, SingleDocumentLiveQueryEvent, SingleObservationHandler, SortDirection, Store, Subscription, SubscriptionContextInfo, TransportCondition, TransportConfig, TransportConfigConnect, TransportConfigGlobal, TransportConfigLan, TransportConfigListen, TransportConfigListenHTTP, TransportConfigListenTCP, TransportConfigPeerToPeer, UpdateResult, UpdateResultType, UpdateResultsMap, Value, WebAssemblyModule, WriteStrategy, __log, attachmentBridge, dittoBridge, documentBridge, init, mutableDocumentBridge };
|
|
2450
2413
|
//# sourceMappingURL=ditto.d.ts.map
|