@dittolive/ditto 1.0.15-alpha1 → 1.0.18-alpha1
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 -165
- 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,86 +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
|
-
/**
|
|
584
|
-
* Returns the value of the receiver, lazily decoded from its CBOR
|
|
585
|
-
* representation if needed.
|
|
586
|
-
*/
|
|
587
|
-
get value(): any;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
declare class Counter {
|
|
591
|
-
/** The value of the counter. */
|
|
592
|
-
readonly value: number;
|
|
593
|
-
/** Whether the counter is set as a default value. */
|
|
594
|
-
readonly isDefault: boolean;
|
|
595
|
-
/**
|
|
596
|
-
* Creates a new counter with an initial value that can be used as part
|
|
597
|
-
* of a document's content.
|
|
598
|
-
*
|
|
599
|
-
* @param isDefault Represents whether or not the value should be set as a
|
|
600
|
-
* default value. Set this to `true` if you want to set a default value that
|
|
601
|
-
* you expect to be overwritten by other devices in the network. The default
|
|
602
|
-
* value is `false`.
|
|
603
|
-
*/
|
|
604
|
-
constructor(value: number, isDefault?: boolean);
|
|
605
|
-
/**
|
|
606
|
-
* Increments the counter by `amount`, which can be any valid number. Only
|
|
607
|
-
* valid within the closure of {@link Collection}'s {@link Collection.update | update()}
|
|
608
|
-
* method, otherwise an exception is thrown.
|
|
609
|
-
*/
|
|
610
|
-
increment(amount: number): void;
|
|
611
|
-
/** @internal */
|
|
612
|
-
static __newInternal(mutDoc: any, path: any, value: any): Counter;
|
|
613
|
-
private mutDoc;
|
|
614
|
-
private path;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
541
|
/**
|
|
618
542
|
* The types of an {@link UpdateResult}.
|
|
619
543
|
*/
|
|
@@ -622,7 +546,7 @@ declare class UpdateResult {
|
|
|
622
546
|
/** The update result's type. */
|
|
623
547
|
readonly type: UpdateResultType;
|
|
624
548
|
/** The ID of the document that was updated. */
|
|
625
|
-
readonly docID:
|
|
549
|
+
readonly docID: DocumentIDValue;
|
|
626
550
|
/** The path to the key in the document that was updated. */
|
|
627
551
|
readonly path: string;
|
|
628
552
|
/**
|
|
@@ -642,19 +566,19 @@ declare class UpdateResult {
|
|
|
642
566
|
/** The associated amount, only set if {@link type} is `incremented`. */
|
|
643
567
|
readonly amount?: number;
|
|
644
568
|
/** @internal */
|
|
645
|
-
static set(docID:
|
|
569
|
+
static set(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
646
570
|
/** @internal */
|
|
647
|
-
static replacedWithCounter(docID:
|
|
571
|
+
static replacedWithCounter(docID: DocumentIDValue, path: string): UpdateResult;
|
|
648
572
|
/** @internal */
|
|
649
|
-
static incremented(docID:
|
|
573
|
+
static incremented(docID: DocumentIDValue, path: string, amount: number): UpdateResult;
|
|
650
574
|
/** @internal */
|
|
651
|
-
static inserted(docID:
|
|
575
|
+
static inserted(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
652
576
|
/** @internal */
|
|
653
|
-
static removed(docID:
|
|
577
|
+
static removed(docID: DocumentIDValue, path: string): UpdateResult;
|
|
654
578
|
/** @internal */
|
|
655
|
-
static pushed(docID:
|
|
579
|
+
static pushed(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
656
580
|
/** @internal */
|
|
657
|
-
static popped(docID:
|
|
581
|
+
static popped(docID: DocumentIDValue, path: string, value?: any): UpdateResult;
|
|
658
582
|
/** @internal */
|
|
659
583
|
private constructor();
|
|
660
584
|
}
|
|
@@ -787,53 +711,8 @@ declare class MutableDocumentPath {
|
|
|
787
711
|
atIndex(index: number): MutableDocumentPath;
|
|
788
712
|
}
|
|
789
713
|
|
|
790
|
-
/**
|
|
791
|
-
|
|
792
|
-
* {@link Collection.fetchAttachment | fetchAttachment()} on a
|
|
793
|
-
* {@link Collection}.
|
|
794
|
-
*/
|
|
795
|
-
declare class AttachmentToken {
|
|
796
|
-
/** @internal */
|
|
797
|
-
readonly id: Uint8Array;
|
|
798
|
-
/** @internal */
|
|
799
|
-
readonly len: number;
|
|
800
|
-
/** @internal */
|
|
801
|
-
readonly metadata: {
|
|
802
|
-
[key: string]: string;
|
|
803
|
-
};
|
|
804
|
-
/** @internal */
|
|
805
|
-
constructor(jsObj: object);
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
/**
|
|
809
|
-
* Represents an attachment and can be used to insert the associated attachment
|
|
810
|
-
* into a document at a specific key.
|
|
811
|
-
*/
|
|
812
|
-
declare class Attachment {
|
|
813
|
-
/** @internal */
|
|
814
|
-
readonly ditto: Ditto;
|
|
815
|
-
/** @internal */
|
|
816
|
-
readonly token: AttachmentToken;
|
|
817
|
-
/** The attachment's metadata. */
|
|
818
|
-
get metadata(): {
|
|
819
|
-
[key: string]: string;
|
|
820
|
-
};
|
|
821
|
-
/**
|
|
822
|
-
* Returns the attachment's data.
|
|
823
|
-
*/
|
|
824
|
-
getData(): Promise<Uint8Array>;
|
|
825
|
-
/**
|
|
826
|
-
* Copies the attachment to the specified file path. Node-only,
|
|
827
|
-
* throws in the browser.
|
|
828
|
-
*
|
|
829
|
-
* @param path The path that the attachment should be copied to.
|
|
830
|
-
*/
|
|
831
|
-
copyToPath(path: string): Promise<void>;
|
|
832
|
-
/** @internal */
|
|
833
|
-
constructor(ditto: Ditto, token: AttachmentToken);
|
|
834
|
-
}
|
|
835
|
-
declare const attachmentBridge: Bridge<Attachment, "AttachmentHandle_t">;
|
|
836
|
-
|
|
714
|
+
/** Represents a unique identifier for a {@link Document}. */
|
|
715
|
+
declare type DocumentIDValue = any;
|
|
837
716
|
/**
|
|
838
717
|
* This is used whenever you can access the document content properties
|
|
839
718
|
* directly via the document.
|
|
@@ -848,15 +727,13 @@ declare type MutableDocumentLike = MutableDocument | DocumentValue | any;
|
|
|
848
727
|
* A document value is a JavaScript object containing values for keys that
|
|
849
728
|
* can be serialized via CBOR.
|
|
850
729
|
*/
|
|
851
|
-
declare type DocumentValue =
|
|
852
|
-
[key: string]: null | boolean | boolean[] | number | number[] | string | string[] | DocumentID | DocumentValue | DocumentValue[] | Counter | Attachment | AttachmentToken;
|
|
853
|
-
};
|
|
730
|
+
declare type DocumentValue = Record<string, any>;
|
|
854
731
|
/** A document belonging to a {@link Collection} with an inner value. */
|
|
855
732
|
declare class Document {
|
|
856
733
|
/**
|
|
857
734
|
* Returns the ID of the document.
|
|
858
735
|
*/
|
|
859
|
-
readonly _id:
|
|
736
|
+
readonly _id: DocumentIDValue;
|
|
860
737
|
/**
|
|
861
738
|
* Returns the content (aka value) of the document.
|
|
862
739
|
*/
|
|
@@ -872,11 +749,27 @@ declare class Document {
|
|
|
872
749
|
/**
|
|
873
750
|
* Returns the ID for a document.
|
|
874
751
|
*/
|
|
875
|
-
static id(document: DocumentLike):
|
|
752
|
+
static id(document: DocumentLike): DocumentIDValue;
|
|
876
753
|
/**
|
|
877
754
|
* Returns the content (aka inner value) of a document.
|
|
878
755
|
*/
|
|
879
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;
|
|
880
773
|
/**
|
|
881
774
|
* Returns the content (aka inner value) of a document at the given path.
|
|
882
775
|
*/
|
|
@@ -909,7 +802,7 @@ declare class MutableDocument {
|
|
|
909
802
|
/**
|
|
910
803
|
* Returns the ID of the document.
|
|
911
804
|
*/
|
|
912
|
-
readonly _id:
|
|
805
|
+
readonly _id: DocumentIDValue;
|
|
913
806
|
/**
|
|
914
807
|
* Returns the content (aka value) of the document. What you actually get is
|
|
915
808
|
* a proxy that you can freely manipulate and Ditto will register the changes,
|
|
@@ -940,7 +833,7 @@ declare class MutableDocument {
|
|
|
940
833
|
*/
|
|
941
834
|
readonly _incrementCounterAt: (mutableDocument: MutableDocumentLike, keyPath: string, amount: number, skipValidation?: boolean) => void;
|
|
942
835
|
/** Returns the ID for a mutable document. */
|
|
943
|
-
static id(mutableDocument: MutableDocumentLike):
|
|
836
|
+
static id(mutableDocument: MutableDocumentLike): DocumentIDValue;
|
|
944
837
|
/**
|
|
945
838
|
* Returns the content (aka inner value) of a mutable document.
|
|
946
839
|
*/
|
|
@@ -972,6 +865,53 @@ declare const documentBridge: Bridge<Document, "CDocument_t">;
|
|
|
972
865
|
/** @internal */
|
|
973
866
|
declare const mutableDocumentBridge: Bridge<MutableDocument, "CDocument_t">;
|
|
974
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
|
+
|
|
975
915
|
/**
|
|
976
916
|
* The types of attachment fetch events that can be delivered to an attachment
|
|
977
917
|
* fetcher's `callback`.
|
|
@@ -1105,7 +1045,7 @@ declare class Subscription {
|
|
|
1105
1045
|
}
|
|
1106
1046
|
|
|
1107
1047
|
/**
|
|
1108
|
-
* Maps a {@link
|
|
1048
|
+
* Maps a {@link DocumentIDValue} to an array of
|
|
1109
1049
|
* @link UpdateResult | update results}. This is the data structure you get
|
|
1110
1050
|
* when {@link PendingCursorOperation.update | updating} a set of documents
|
|
1111
1051
|
* with detailed info about the performed updates.
|
|
@@ -1115,14 +1055,14 @@ declare class UpdateResultsMap {
|
|
|
1115
1055
|
* Returns an array of {@link UpdateResult | update results} associated with
|
|
1116
1056
|
* the `documentID` or undefined if not found.
|
|
1117
1057
|
*/
|
|
1118
|
-
get(documentID:
|
|
1058
|
+
get(documentID: DocumentIDValue): UpdateResult[] | undefined;
|
|
1119
1059
|
/**
|
|
1120
|
-
* Returns all contained keys, i.e. {@link
|
|
1060
|
+
* Returns all contained keys, i.e. {@link DocumentIDValue | document IDs}
|
|
1121
1061
|
* contained in this map.
|
|
1122
1062
|
*/
|
|
1123
|
-
keys():
|
|
1063
|
+
keys(): DocumentIDValue[];
|
|
1124
1064
|
/** @internal */
|
|
1125
|
-
constructor(documentIDs:
|
|
1065
|
+
constructor(documentIDs: DocumentIDValue[], updateResultsByDocumentIDString: object);
|
|
1126
1066
|
private documentIDs;
|
|
1127
1067
|
private updateResultsByDocumentIDString;
|
|
1128
1068
|
}
|
|
@@ -1162,9 +1102,10 @@ declare class LiveQuery {
|
|
|
1162
1102
|
/** @internal */
|
|
1163
1103
|
readonly waitsForNextSignal: boolean;
|
|
1164
1104
|
/** @internal */
|
|
1165
|
-
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);
|
|
1166
1106
|
/** @internal */
|
|
1167
1107
|
signalNext(): Promise<void>;
|
|
1108
|
+
private orderBys;
|
|
1168
1109
|
private queryArgsCBOR;
|
|
1169
1110
|
private liveQueryID;
|
|
1170
1111
|
}
|
|
@@ -1474,7 +1415,7 @@ declare class PendingCursorOperation implements PromiseLike<DocumentLike[]> {
|
|
|
1474
1415
|
* @returns An array promise containing the IDs of the documents that were
|
|
1475
1416
|
* removed.
|
|
1476
1417
|
*/
|
|
1477
|
-
remove(): Promise<
|
|
1418
|
+
remove(): Promise<DocumentIDValue[]>;
|
|
1478
1419
|
/**
|
|
1479
1420
|
* Evicts all documents that match the query generated by the preceding
|
|
1480
1421
|
* function chaining.
|
|
@@ -1482,7 +1423,7 @@ declare class PendingCursorOperation implements PromiseLike<DocumentLike[]> {
|
|
|
1482
1423
|
* @return An array promise containing the IDs of the documents that were
|
|
1483
1424
|
* evicted.
|
|
1484
1425
|
*/
|
|
1485
|
-
evict(): Promise<
|
|
1426
|
+
evict(): Promise<DocumentIDValue[]>;
|
|
1486
1427
|
/**
|
|
1487
1428
|
* Executes the query generated by the preceding function chaining and return
|
|
1488
1429
|
* the list of matching documents.
|
|
@@ -1547,7 +1488,7 @@ declare type SingleObservationHandler = (document: DocumentLike | null, event: S
|
|
|
1547
1488
|
*/
|
|
1548
1489
|
declare class PendingIDSpecificOperation implements PromiseLike<DocumentLike | undefined> {
|
|
1549
1490
|
/** The ID of the document this operation operates on. */
|
|
1550
|
-
readonly documentID:
|
|
1491
|
+
readonly documentID: DocumentIDValue;
|
|
1551
1492
|
/** The collection the receiver is operating on. */
|
|
1552
1493
|
readonly collection: Collection;
|
|
1553
1494
|
/**
|
|
@@ -1688,9 +1629,10 @@ declare class PendingIDSpecificOperation implements PromiseLike<DocumentLike | u
|
|
|
1688
1629
|
*/
|
|
1689
1630
|
update(closure: (document: MutableDocumentLike) => void): Promise<UpdateResult[]>;
|
|
1690
1631
|
/** @internal */
|
|
1691
|
-
constructor(documentID:
|
|
1632
|
+
constructor(documentID: DocumentIDValue, collection: Collection);
|
|
1692
1633
|
/** @internal */
|
|
1693
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;
|
|
1694
1636
|
private get query();
|
|
1695
1637
|
private _observe;
|
|
1696
1638
|
}
|
|
@@ -1747,20 +1689,16 @@ declare class Collection {
|
|
|
1747
1689
|
* if you want to get updates about the document over time. It can also be
|
|
1748
1690
|
* used to update, remove or evict the document.
|
|
1749
1691
|
*
|
|
1750
|
-
* @param id The ID of the document to find.
|
|
1751
|
-
* {@link DocumentID} then Ditto will automatically create a {@link DocumentID}
|
|
1752
|
-
* instance from it.
|
|
1692
|
+
* @param id The ID of the document to find.
|
|
1753
1693
|
*/
|
|
1754
|
-
findByID(id:
|
|
1694
|
+
findByID(id: DocumentIDValue): PendingIDSpecificOperation;
|
|
1755
1695
|
/**
|
|
1756
1696
|
* Inserts a new document into the collection and returns its ID.
|
|
1757
1697
|
*
|
|
1758
1698
|
* @param value The content for the new document to insert.
|
|
1759
1699
|
*
|
|
1760
1700
|
* @param options.id The ID to use for the document. If `null` or `undefined`
|
|
1761
|
-
* then Ditto will automatically generate an ID.
|
|
1762
|
-
* {@link DocumentID} then Ditto will automatically create a
|
|
1763
|
-
* {@link DocumentID} instance from it.
|
|
1701
|
+
* then Ditto will automatically generate an ID.
|
|
1764
1702
|
*
|
|
1765
1703
|
* @param options.isDefault This option is now deprecated. You should instead
|
|
1766
1704
|
* specify a `writeStrategy` if you wish to insert data as default data. If
|
|
@@ -1773,7 +1711,7 @@ declare class Collection {
|
|
|
1773
1711
|
* @param options.writeStrategy Specifies the desired strategy for inserting a
|
|
1774
1712
|
* document. The default value is `'overwrite'`.
|
|
1775
1713
|
*/
|
|
1776
|
-
insert(value: DocumentValue, options?: InsertOptions): Promise<
|
|
1714
|
+
insert(value: DocumentValue, options?: InsertOptions): Promise<DocumentIDValue>;
|
|
1777
1715
|
/**
|
|
1778
1716
|
* Creates a new {@link Attachment} object, which can then be inserted into a
|
|
1779
1717
|
* document. Node only, throws when running in the web browser.
|
|
@@ -1791,8 +1729,7 @@ declare class Collection {
|
|
|
1791
1729
|
*
|
|
1792
1730
|
* ``` JavaScript
|
|
1793
1731
|
* const attachment = collection.newAttachment('/path/to/my/file.pdf')
|
|
1794
|
-
*
|
|
1795
|
-
* collection.insert({ _id: docID, attachment, other: 'some-string' })
|
|
1732
|
+
* collection.insert({ _id: '123', attachment, other: 'some-string' })
|
|
1796
1733
|
* }
|
|
1797
1734
|
* ```
|
|
1798
1735
|
*
|
|
@@ -2038,7 +1975,7 @@ declare class Store {
|
|
|
2038
1975
|
* Private method, used only by the Portal https://github.com/getditto/ditto/pull/3652
|
|
2039
1976
|
* @internal
|
|
2040
1977
|
*/
|
|
2041
|
-
registerLiveQueryWebhook(collectionName: string, query: string, url: string):
|
|
1978
|
+
registerLiveQueryWebhook(collectionName: string, query: string, url: string): DocumentIDValue;
|
|
2042
1979
|
}
|
|
2043
1980
|
|
|
2044
1981
|
/** @internal */
|
|
@@ -2279,6 +2216,33 @@ declare class Value {
|
|
|
2279
2216
|
constructor(value: unknown, options?: unknown);
|
|
2280
2217
|
}
|
|
2281
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
|
+
|
|
2282
2246
|
/** The log levels supported by Ditto. */
|
|
2283
2247
|
declare type LogLevel = 'Error' | 'Warning' | 'Info' | 'Debug' | 'Verbose';
|
|
2284
2248
|
/**
|
|
@@ -2445,5 +2409,5 @@ declare class Logger {
|
|
|
2445
2409
|
private constructor();
|
|
2446
2410
|
}
|
|
2447
2411
|
|
|
2448
|
-
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 };
|
|
2449
2413
|
//# sourceMappingURL=ditto.d.ts.map
|