cbl-ionic 0.2.4
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/CblIonic.podspec +18 -0
- package/LICENSE +201 -0
- package/README.md +19 -0
- package/android/build.gradle +69 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/cbl/js/kotiln/CollectionConfigDto.kt +5 -0
- package/android/src/main/java/cbl/js/kotiln/CollectionDocumentResult.kt +7 -0
- package/android/src/main/java/cbl/js/kotiln/CollectionDto.kt +9 -0
- package/android/src/main/java/cbl/js/kotiln/CollectionManager.kt +232 -0
- package/android/src/main/java/cbl/js/kotiln/ConfigDto.kt +5 -0
- package/android/src/main/java/cbl/js/kotiln/DatabaseManager.kt +183 -0
- package/android/src/main/java/cbl/js/kotiln/DocumentDto.kt +6 -0
- package/android/src/main/java/cbl/js/kotiln/FileSystemHelper.kt +18 -0
- package/android/src/main/java/cbl/js/kotiln/LoggingManager.kt +30 -0
- package/android/src/main/java/cbl/js/kotiln/ReplicatorManager.kt +123 -0
- package/android/src/main/java/cbl/js/kotiln/ScopeDto.kt +6 -0
- package/android/src/main/java/com/couchbase/ionic/CblIonicPluginPlugin.kt +1832 -0
- package/android/src/main/java/com/couchbase/ionic/IndexDto.kt +12 -0
- package/android/src/main/java/com/couchbase/ionic/IndexHelper.kt +30 -0
- package/android/src/main/java/com/couchbase/ionic/PluginHelper.kt +283 -0
- package/android/src/main/java/com/couchbase/ionic/QueryHelper.kt +62 -0
- package/android/src/main/java/com/couchbase/ionic/ReplicatorHelper.kt +174 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/esm/cblite-js/cblite/core-types.d.ts +634 -0
- package/dist/esm/cblite-js/cblite/core-types.js +2 -0
- package/dist/esm/cblite-js/cblite/core-types.js.map +1 -0
- package/dist/esm/cblite-js/cblite/index.d.ts +2 -0
- package/dist/esm/cblite-js/cblite/index.js +4 -0
- package/dist/esm/cblite-js/cblite/index.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/abstract-index.d.ts +14 -0
- package/dist/esm/cblite-js/cblite/src/abstract-index.js +12 -0
- package/dist/esm/cblite-js/cblite/src/abstract-index.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/authenticator.d.ts +6 -0
- package/dist/esm/cblite-js/cblite/src/authenticator.js +3 -0
- package/dist/esm/cblite-js/cblite/src/authenticator.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/basic-authenticator.d.ts +42 -0
- package/dist/esm/cblite-js/cblite/src/basic-authenticator.js +59 -0
- package/dist/esm/cblite-js/cblite/src/basic-authenticator.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/blob.d.ts +58 -0
- package/dist/esm/cblite-js/cblite/src/blob.js +86 -0
- package/dist/esm/cblite-js/cblite/src/blob.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/collation.d.ts +20 -0
- package/dist/esm/cblite-js/cblite/src/collation.js +64 -0
- package/dist/esm/cblite-js/cblite/src/collation.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/collection-config.d.ts +24 -0
- package/dist/esm/cblite-js/cblite/src/collection-config.js +30 -0
- package/dist/esm/cblite-js/cblite/src/collection-config.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/collection.d.ts +189 -0
- package/dist/esm/cblite-js/cblite/src/collection.js +354 -0
- package/dist/esm/cblite-js/cblite/src/collection.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/concurrency-control.d.ts +4 -0
- package/dist/esm/cblite-js/cblite/src/concurrency-control.js +8 -0
- package/dist/esm/cblite-js/cblite/src/concurrency-control.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/couchbase-lite-exception.d.ts +6 -0
- package/dist/esm/cblite-js/cblite/src/couchbase-lite-exception.js +15 -0
- package/dist/esm/cblite-js/cblite/src/couchbase-lite-exception.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/database-configuration.d.ts +52 -0
- package/dist/esm/cblite-js/cblite/src/database-configuration.js +75 -0
- package/dist/esm/cblite-js/cblite/src/database-configuration.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/database-logging.d.ts +13 -0
- package/dist/esm/cblite-js/cblite/src/database-logging.js +13 -0
- package/dist/esm/cblite-js/cblite/src/database-logging.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/database.d.ts +254 -0
- package/dist/esm/cblite-js/cblite/src/database.js +514 -0
- package/dist/esm/cblite-js/cblite/src/database.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/definitions.d.ts +7 -0
- package/dist/esm/cblite-js/cblite/src/definitions.js +2 -0
- package/dist/esm/cblite-js/cblite/src/definitions.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/document-replication.d.ts +13 -0
- package/dist/esm/cblite-js/cblite/src/document-replication.js +34 -0
- package/dist/esm/cblite-js/cblite/src/document-replication.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/document.d.ts +199 -0
- package/dist/esm/cblite-js/cblite/src/document.js +333 -0
- package/dist/esm/cblite-js/cblite/src/document.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/endpoint.d.ts +3 -0
- package/dist/esm/cblite-js/cblite/src/endpoint.js +2 -0
- package/dist/esm/cblite-js/cblite/src/endpoint.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/engine-locator.d.ts +42 -0
- package/dist/esm/cblite-js/cblite/src/engine-locator.js +50 -0
- package/dist/esm/cblite-js/cblite/src/engine-locator.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/expression.d.ts +134 -0
- package/dist/esm/cblite-js/cblite/src/expression.js +374 -0
- package/dist/esm/cblite-js/cblite/src/expression.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/file-system.d.ts +7 -0
- package/dist/esm/cblite-js/cblite/src/file-system.js +14 -0
- package/dist/esm/cblite-js/cblite/src/file-system.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/full-text-expression.d.ts +28 -0
- package/dist/esm/cblite-js/cblite/src/full-text-expression.js +38 -0
- package/dist/esm/cblite-js/cblite/src/full-text-expression.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/full-text-index.d.ts +47 -0
- package/dist/esm/cblite-js/cblite/src/full-text-index.js +77 -0
- package/dist/esm/cblite-js/cblite/src/full-text-index.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/index-builder.d.ts +20 -0
- package/dist/esm/cblite-js/cblite/src/index-builder.js +25 -0
- package/dist/esm/cblite-js/cblite/src/index-builder.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/index.d.ts +42 -0
- package/dist/esm/cblite-js/cblite/src/index.js +43 -0
- package/dist/esm/cblite-js/cblite/src/index.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/meta-expression.d.ts +10 -0
- package/dist/esm/cblite-js/cblite/src/meta-expression.js +30 -0
- package/dist/esm/cblite-js/cblite/src/meta-expression.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/meta.d.ts +7 -0
- package/dist/esm/cblite-js/cblite/src/meta.js +8 -0
- package/dist/esm/cblite-js/cblite/src/meta.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/mutable-document.d.ts +373 -0
- package/dist/esm/cblite-js/cblite/src/mutable-document.js +481 -0
- package/dist/esm/cblite-js/cblite/src/mutable-document.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/ordering.d.ts +14 -0
- package/dist/esm/cblite-js/cblite/src/ordering.js +31 -0
- package/dist/esm/cblite-js/cblite/src/ordering.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/parameter.d.ts +18 -0
- package/dist/esm/cblite-js/cblite/src/parameter.js +38 -0
- package/dist/esm/cblite-js/cblite/src/parameter.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/parameters.d.ts +17 -0
- package/dist/esm/cblite-js/cblite/src/parameters.js +61 -0
- package/dist/esm/cblite-js/cblite/src/parameters.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/query.d.ts +83 -0
- package/dist/esm/cblite-js/cblite/src/query.js +146 -0
- package/dist/esm/cblite-js/cblite/src/query.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/replicated-document.d.ts +25 -0
- package/dist/esm/cblite-js/cblite/src/replicated-document.js +51 -0
- package/dist/esm/cblite-js/cblite/src/replicated-document.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/replicator-activity-level.d.ts +7 -0
- package/dist/esm/cblite-js/cblite/src/replicator-activity-level.js +14 -0
- package/dist/esm/cblite-js/cblite/src/replicator-activity-level.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/replicator-change.d.ts +14 -0
- package/dist/esm/cblite-js/cblite/src/replicator-change.js +14 -0
- package/dist/esm/cblite-js/cblite/src/replicator-change.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/replicator-configuration.d.ts +341 -0
- package/dist/esm/cblite-js/cblite/src/replicator-configuration.js +516 -0
- package/dist/esm/cblite-js/cblite/src/replicator-configuration.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/replicator-progress.d.ts +9 -0
- package/dist/esm/cblite-js/cblite/src/replicator-progress.js +20 -0
- package/dist/esm/cblite-js/cblite/src/replicator-progress.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/replicator-status.d.ts +13 -0
- package/dist/esm/cblite-js/cblite/src/replicator-status.js +29 -0
- package/dist/esm/cblite-js/cblite/src/replicator-status.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/replicator.d.ts +108 -0
- package/dist/esm/cblite-js/cblite/src/replicator.js +224 -0
- package/dist/esm/cblite-js/cblite/src/replicator.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/result.d.ts +4 -0
- package/dist/esm/cblite-js/cblite/src/result.js +2 -0
- package/dist/esm/cblite-js/cblite/src/result.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/scope.d.ts +31 -0
- package/dist/esm/cblite-js/cblite/src/scope.js +34 -0
- package/dist/esm/cblite-js/cblite/src/scope.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/session-authenticator.d.ts +32 -0
- package/dist/esm/cblite-js/cblite/src/session-authenticator.js +52 -0
- package/dist/esm/cblite-js/cblite/src/session-authenticator.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/url-endpoint.d.ts +8 -0
- package/dist/esm/cblite-js/cblite/src/url-endpoint.js +12 -0
- package/dist/esm/cblite-js/cblite/src/url-endpoint.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/value-index.d.ts +32 -0
- package/dist/esm/cblite-js/cblite/src/value-index.js +54 -0
- package/dist/esm/cblite-js/cblite/src/value-index.js.map +1 -0
- package/dist/esm/cblite-js/cblite/src/variable-expression.d.ts +7 -0
- package/dist/esm/cblite-js/cblite/src/variable-expression.js +15 -0
- package/dist/esm/cblite-js/cblite/src/variable-expression.js.map +1 -0
- package/dist/esm/couchbase-lite/capacitor-engine.d.ts +124 -0
- package/dist/esm/couchbase-lite/capacitor-engine.js +303 -0
- package/dist/esm/couchbase-lite/capacitor-engine.js.map +1 -0
- package/dist/esm/definitions.d.ts +12 -0
- package/dist/esm/definitions.js +4 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/ionic-couchbase-lite.d.ts +3 -0
- package/dist/esm/ionic-couchbase-lite.js +4 -0
- package/dist/esm/ionic-couchbase-lite.js.map +1 -0
- package/dist/plugin.cjs.js +4400 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +4403 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CblIonicPlugin.swift +1583 -0
- package/ios/Plugin/CblIonicPluginPlugin.h +10 -0
- package/ios/Plugin/CblIonicPluginPlugin.m +86 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/cbl-js-swift/CollectionManager.swift +489 -0
- package/ios/Plugin/cbl-js-swift/DatabaseManager.swift +319 -0
- package/ios/Plugin/cbl-js-swift/FileSystemHelper.swift +22 -0
- package/ios/Plugin/cbl-js-swift/IndexHelper.swift +36 -0
- package/ios/Plugin/cbl-js-swift/LICENSE +201 -0
- package/ios/Plugin/cbl-js-swift/LoggingManager.swift +79 -0
- package/ios/Plugin/cbl-js-swift/MapHelper.swift +92 -0
- package/ios/Plugin/cbl-js-swift/QueryHelper.swift +74 -0
- package/ios/Plugin/cbl-js-swift/README.md +9 -0
- package/ios/Plugin/cbl-js-swift/ReplicatorHelper.swift +184 -0
- package/ios/Plugin/cbl-js-swift/ReplicatorManager.swift +157 -0
- package/package.json +86 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Dictionary } from './definitions';
|
|
2
|
+
import { Blob } from './blob';
|
|
3
|
+
import { Collection } from './collection';
|
|
4
|
+
export declare class Document {
|
|
5
|
+
protected id: string;
|
|
6
|
+
protected sequenceNo: number;
|
|
7
|
+
protected revisionID: string;
|
|
8
|
+
protected collection: Collection;
|
|
9
|
+
protected doc: Dictionary;
|
|
10
|
+
private _engine;
|
|
11
|
+
constructor(id?: string, sequenceNo?: number, revisionID?: string, collection?: Collection, data?: Dictionary);
|
|
12
|
+
/**
|
|
13
|
+
* The number of properties in the document.
|
|
14
|
+
*
|
|
15
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
16
|
+
*
|
|
17
|
+
* @function
|
|
18
|
+
*/
|
|
19
|
+
count(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the document data as a dictionary.
|
|
22
|
+
*
|
|
23
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
24
|
+
*
|
|
25
|
+
* @function
|
|
26
|
+
*/
|
|
27
|
+
getData(): Dictionary;
|
|
28
|
+
private _get;
|
|
29
|
+
/**
|
|
30
|
+
* Get a property’s value as a ArrayObject, which is a mapping object of an array value.
|
|
31
|
+
* Returns null if the property doesn’t exists, or its value is not an array.
|
|
32
|
+
*
|
|
33
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
34
|
+
*
|
|
35
|
+
* @function
|
|
36
|
+
*/
|
|
37
|
+
getArray(key: string): [] | null;
|
|
38
|
+
/**
|
|
39
|
+
* Returns metadata associated with the Blob. Use getBlobContent() to get the Blob’s data.
|
|
40
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
41
|
+
*
|
|
42
|
+
* @function
|
|
43
|
+
*/
|
|
44
|
+
getBlob(key: string): Blob | null;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated - use the Blob API getBytes() function instead
|
|
47
|
+
*
|
|
48
|
+
* Get a property’s value as a ArrayBuffer. Returns null if the property doesn’t exist,
|
|
49
|
+
* or its value is not a blob.
|
|
50
|
+
*
|
|
51
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
52
|
+
*
|
|
53
|
+
* @function
|
|
54
|
+
*/
|
|
55
|
+
getBlobContent(key: string): Promise<ArrayBuffer>;
|
|
56
|
+
/**
|
|
57
|
+
* Gets a property’s value as a boolean value. Returns true if the value exists,
|
|
58
|
+
* and is either true or a nonzero number.
|
|
59
|
+
*
|
|
60
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
61
|
+
*
|
|
62
|
+
* @function
|
|
63
|
+
*/
|
|
64
|
+
getBoolean(key: string): boolean | null;
|
|
65
|
+
/**
|
|
66
|
+
* The collection that the document belongs to.
|
|
67
|
+
*
|
|
68
|
+
* Throws an error if the database is closed.
|
|
69
|
+
*
|
|
70
|
+
* @function
|
|
71
|
+
*/
|
|
72
|
+
getCollection(): Collection | null;
|
|
73
|
+
/**
|
|
74
|
+
* Gets a property’s value as a Date value. JSON does not directly support dates, so
|
|
75
|
+
* the actual property value must be a string, which is then parsed according to the
|
|
76
|
+
* ISO-8601 date format (the default used in JSON.) Returns null if the value doesn’t
|
|
77
|
+
* exist, is not a string, or is not parseable as a date. NOTE: This is not a generic
|
|
78
|
+
* date parser! It only recognizes the ISO-8601 format, with milliseconds.
|
|
79
|
+
*
|
|
80
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
81
|
+
*
|
|
82
|
+
* @function
|
|
83
|
+
*/
|
|
84
|
+
getDate(key: string): Date | null;
|
|
85
|
+
/**
|
|
86
|
+
* Get a property’s value as a Dictionary, which is a mapping object of a dictionary
|
|
87
|
+
* value. Returns null if the property doesn’t exists, or its value is not a dictionary.
|
|
88
|
+
*
|
|
89
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
90
|
+
*
|
|
91
|
+
* @function
|
|
92
|
+
*/
|
|
93
|
+
getDictionary(key: string): Dictionary | null;
|
|
94
|
+
/**
|
|
95
|
+
* Gets a property’s value as a double value. Integers will be converted to double.
|
|
96
|
+
* The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t
|
|
97
|
+
* exist or does not have a numeric value.
|
|
98
|
+
*
|
|
99
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
100
|
+
*
|
|
101
|
+
* @function
|
|
102
|
+
*/
|
|
103
|
+
getDouble(key: string): number | null;
|
|
104
|
+
/**
|
|
105
|
+
* Gets a property’s value as a float value. Integers will be converted to float.
|
|
106
|
+
* The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t
|
|
107
|
+
* exist or does not have a numeric value.
|
|
108
|
+
*
|
|
109
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
110
|
+
*
|
|
111
|
+
* @function
|
|
112
|
+
*/
|
|
113
|
+
getFloat(key: string): number | null;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the document’s ID.
|
|
116
|
+
*
|
|
117
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
118
|
+
*
|
|
119
|
+
* @function
|
|
120
|
+
*/
|
|
121
|
+
getId(): string;
|
|
122
|
+
/**
|
|
123
|
+
* Gets a property’s value as an int value. Floating point values will be rounded.
|
|
124
|
+
* The value true is returned as 1, false as 0. Returns 0 if the property doesn’t
|
|
125
|
+
* exist or does not have a numeric value.
|
|
126
|
+
*
|
|
127
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
128
|
+
*
|
|
129
|
+
* @function
|
|
130
|
+
*/
|
|
131
|
+
getInt(key: string): number | null;
|
|
132
|
+
/**
|
|
133
|
+
* returns an array containing all keys, or an empty array if the document
|
|
134
|
+
* has no properties.
|
|
135
|
+
*
|
|
136
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
137
|
+
*
|
|
138
|
+
* @function
|
|
139
|
+
*/
|
|
140
|
+
getKeys(): string[];
|
|
141
|
+
/**
|
|
142
|
+
* Gets a property’s value as an number value. Floating point values will be rounded.
|
|
143
|
+
* The value true is returned as 1, false as 0. Returns 0 if the property doesn’t
|
|
144
|
+
* exist or does not have a numeric value.
|
|
145
|
+
*
|
|
146
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
147
|
+
*
|
|
148
|
+
* @function
|
|
149
|
+
*/
|
|
150
|
+
getLong(key: string): number | null;
|
|
151
|
+
/**
|
|
152
|
+
* The ID representing a document’s revision.
|
|
153
|
+
*
|
|
154
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
155
|
+
*
|
|
156
|
+
* @function
|
|
157
|
+
*/
|
|
158
|
+
getRevisionID(): string;
|
|
159
|
+
/**
|
|
160
|
+
* Sequence number of the document in the database. This indicates how recently the
|
|
161
|
+
* document has been changed: every time any document is updated, the database assigns it
|
|
162
|
+
* the next sequential sequence number. Thus, if a document’s sequence property changes
|
|
163
|
+
* that means it’s been changed (on-disk); and if one document’s sequence is greater than
|
|
164
|
+
* another’s, that means it was changed more recently.
|
|
165
|
+
*
|
|
166
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
167
|
+
*
|
|
168
|
+
* @function
|
|
169
|
+
*/
|
|
170
|
+
getSequence(): number;
|
|
171
|
+
/**
|
|
172
|
+
* Gets a property’s value as a string. Returns nil if the property doesn’t exist, i
|
|
173
|
+
* or its value is not a string.
|
|
174
|
+
*
|
|
175
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
176
|
+
*
|
|
177
|
+
* @function
|
|
178
|
+
*/
|
|
179
|
+
getString(key: string): string | null;
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated getValue is deprecated. Returns values as any.
|
|
182
|
+
*/
|
|
183
|
+
getValue(key: string): any;
|
|
184
|
+
/**
|
|
185
|
+
* Returns the document data as a dictionary.
|
|
186
|
+
*
|
|
187
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
188
|
+
*
|
|
189
|
+
* @function
|
|
190
|
+
*/
|
|
191
|
+
toDictionary(): Dictionary;
|
|
192
|
+
/**
|
|
193
|
+
* Converts the document content to a JSON string representation
|
|
194
|
+
* @returns {string} A JSON string
|
|
195
|
+
*
|
|
196
|
+
* @function
|
|
197
|
+
*/
|
|
198
|
+
toJsonString(): string;
|
|
199
|
+
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { Blob } from './blob';
|
|
2
|
+
import { EngineLocator } from './engine-locator';
|
|
3
|
+
export class Document {
|
|
4
|
+
constructor(id = null,
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
sequenceNo = null,
|
|
7
|
+
// eslint-disable-next-line
|
|
8
|
+
revisionID = null,
|
|
9
|
+
// eslint-disable-next-line
|
|
10
|
+
collection = null, data = {}) {
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.sequenceNo = sequenceNo;
|
|
13
|
+
this.revisionID = revisionID;
|
|
14
|
+
this.collection = collection;
|
|
15
|
+
this.doc = {};
|
|
16
|
+
this._engine = EngineLocator.getEngine(EngineLocator.key);
|
|
17
|
+
if (id === null) {
|
|
18
|
+
this.id = this._engine.getUUID();
|
|
19
|
+
}
|
|
20
|
+
this.doc = data;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The number of properties in the document.
|
|
24
|
+
*
|
|
25
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
26
|
+
*
|
|
27
|
+
* @function
|
|
28
|
+
*/
|
|
29
|
+
count() {
|
|
30
|
+
return Object.keys(this.doc).length;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the document data as a dictionary.
|
|
34
|
+
*
|
|
35
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
36
|
+
*
|
|
37
|
+
* @function
|
|
38
|
+
*/
|
|
39
|
+
getData() {
|
|
40
|
+
return this.doc;
|
|
41
|
+
}
|
|
42
|
+
_get(key) {
|
|
43
|
+
return this.doc[key];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a property’s value as a ArrayObject, which is a mapping object of an array value.
|
|
47
|
+
* Returns null if the property doesn’t exists, or its value is not an array.
|
|
48
|
+
*
|
|
49
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
50
|
+
*
|
|
51
|
+
* @function
|
|
52
|
+
*/
|
|
53
|
+
getArray(key) {
|
|
54
|
+
if (key in this.doc && Array.isArray(this.doc[key])) {
|
|
55
|
+
return this.doc[key];
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns metadata associated with the Blob. Use getBlobContent() to get the Blob’s data.
|
|
61
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
62
|
+
*
|
|
63
|
+
* @function
|
|
64
|
+
*/
|
|
65
|
+
getBlob(key) {
|
|
66
|
+
if (key in this.doc) {
|
|
67
|
+
const data = this._get(key);
|
|
68
|
+
if (data && typeof data === 'object' && 'content_type' in data) {
|
|
69
|
+
const b = new Blob(data.content_type, data.raw);
|
|
70
|
+
b.digest = data.digest;
|
|
71
|
+
b.length = data.length;
|
|
72
|
+
return b;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated - use the Blob API getBytes() function instead
|
|
79
|
+
*
|
|
80
|
+
* Get a property’s value as a ArrayBuffer. Returns null if the property doesn’t exist,
|
|
81
|
+
* or its value is not a blob.
|
|
82
|
+
*
|
|
83
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
84
|
+
*
|
|
85
|
+
* @function
|
|
86
|
+
*/
|
|
87
|
+
async getBlobContent(key) {
|
|
88
|
+
const data = await this._engine.collection_GetBlobContent({
|
|
89
|
+
documentId: this.getId(),
|
|
90
|
+
key: key,
|
|
91
|
+
collectionName: this.collection.name,
|
|
92
|
+
scopeName: this.collection.scope.name,
|
|
93
|
+
name: this.collection.scope.database.getName(),
|
|
94
|
+
});
|
|
95
|
+
return data.data;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets a property’s value as a boolean value. Returns true if the value exists,
|
|
99
|
+
* and is either true or a nonzero number.
|
|
100
|
+
*
|
|
101
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
102
|
+
*
|
|
103
|
+
* @function
|
|
104
|
+
*/
|
|
105
|
+
getBoolean(key) {
|
|
106
|
+
if (key in this.doc) {
|
|
107
|
+
const value = this.doc[key];
|
|
108
|
+
if (typeof value === 'boolean') {
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
if (value === 0 || value === '0.0') {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (value === null) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The collection that the document belongs to.
|
|
123
|
+
*
|
|
124
|
+
* Throws an error if the database is closed.
|
|
125
|
+
*
|
|
126
|
+
* @function
|
|
127
|
+
*/
|
|
128
|
+
getCollection() {
|
|
129
|
+
return this.collection;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Gets a property’s value as a Date value. JSON does not directly support dates, so
|
|
133
|
+
* the actual property value must be a string, which is then parsed according to the
|
|
134
|
+
* ISO-8601 date format (the default used in JSON.) Returns null if the value doesn’t
|
|
135
|
+
* exist, is not a string, or is not parseable as a date. NOTE: This is not a generic
|
|
136
|
+
* date parser! It only recognizes the ISO-8601 format, with milliseconds.
|
|
137
|
+
*
|
|
138
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
139
|
+
*
|
|
140
|
+
* @function
|
|
141
|
+
*/
|
|
142
|
+
getDate(key) {
|
|
143
|
+
if (key in this.doc) {
|
|
144
|
+
const value = this.doc[key];
|
|
145
|
+
if (typeof value === 'string') {
|
|
146
|
+
const date = new Date(value);
|
|
147
|
+
// Check if the date is valid (not "Invalid Date")
|
|
148
|
+
return !isNaN(date.getTime()) ? date : null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get a property’s value as a Dictionary, which is a mapping object of a dictionary
|
|
155
|
+
* value. Returns null if the property doesn’t exists, or its value is not a dictionary.
|
|
156
|
+
*
|
|
157
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
158
|
+
*
|
|
159
|
+
* @function
|
|
160
|
+
*/
|
|
161
|
+
getDictionary(key) {
|
|
162
|
+
if (key in this.doc) {
|
|
163
|
+
const value = this.doc[key];
|
|
164
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Gets a property’s value as a double value. Integers will be converted to double.
|
|
172
|
+
* The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t
|
|
173
|
+
* exist or does not have a numeric value.
|
|
174
|
+
*
|
|
175
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
176
|
+
*
|
|
177
|
+
* @function
|
|
178
|
+
*/
|
|
179
|
+
getDouble(key) {
|
|
180
|
+
if (key in this.doc) {
|
|
181
|
+
const value = this.doc[key];
|
|
182
|
+
if (typeof value === 'number') {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
if (typeof value === 'boolean') {
|
|
186
|
+
return value ? 1.0 : 0.0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return 0.0;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Gets a property’s value as a float value. Integers will be converted to float.
|
|
193
|
+
* The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t
|
|
194
|
+
* exist or does not have a numeric value.
|
|
195
|
+
*
|
|
196
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
197
|
+
*
|
|
198
|
+
* @function
|
|
199
|
+
*/
|
|
200
|
+
getFloat(key) {
|
|
201
|
+
if (key in this.doc) {
|
|
202
|
+
const value = this.doc[key];
|
|
203
|
+
if (typeof value === 'number') {
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
if (typeof value === 'boolean') {
|
|
207
|
+
return value ? 1.0 : 0.0;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return 0.0;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Returns the document’s ID.
|
|
214
|
+
*
|
|
215
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
216
|
+
*
|
|
217
|
+
* @function
|
|
218
|
+
*/
|
|
219
|
+
getId() {
|
|
220
|
+
return this.id;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Gets a property’s value as an int value. Floating point values will be rounded.
|
|
224
|
+
* The value true is returned as 1, false as 0. Returns 0 if the property doesn’t
|
|
225
|
+
* exist or does not have a numeric value.
|
|
226
|
+
*
|
|
227
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
228
|
+
*
|
|
229
|
+
* @function
|
|
230
|
+
*/
|
|
231
|
+
getInt(key) {
|
|
232
|
+
if (key in this.doc) {
|
|
233
|
+
const value = this.doc[key];
|
|
234
|
+
if (typeof value === 'number') {
|
|
235
|
+
return Math.floor(value);
|
|
236
|
+
}
|
|
237
|
+
if (typeof value === 'boolean') {
|
|
238
|
+
return value ? 1 : 0;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* returns an array containing all keys, or an empty array if the document
|
|
245
|
+
* has no properties.
|
|
246
|
+
*
|
|
247
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
248
|
+
*
|
|
249
|
+
* @function
|
|
250
|
+
*/
|
|
251
|
+
getKeys() {
|
|
252
|
+
return Object.keys(this.doc);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Gets a property’s value as an number value. Floating point values will be rounded.
|
|
256
|
+
* The value true is returned as 1, false as 0. Returns 0 if the property doesn’t
|
|
257
|
+
* exist or does not have a numeric value.
|
|
258
|
+
*
|
|
259
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
260
|
+
*
|
|
261
|
+
* @function
|
|
262
|
+
*/
|
|
263
|
+
getLong(key) {
|
|
264
|
+
return key in this.doc ? this.doc[key] : 0;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The ID representing a document’s revision.
|
|
268
|
+
*
|
|
269
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
270
|
+
*
|
|
271
|
+
* @function
|
|
272
|
+
*/
|
|
273
|
+
getRevisionID() {
|
|
274
|
+
return this.revisionID;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Sequence number of the document in the database. This indicates how recently the
|
|
278
|
+
* document has been changed: every time any document is updated, the database assigns it
|
|
279
|
+
* the next sequential sequence number. Thus, if a document’s sequence property changes
|
|
280
|
+
* that means it’s been changed (on-disk); and if one document’s sequence is greater than
|
|
281
|
+
* another’s, that means it was changed more recently.
|
|
282
|
+
*
|
|
283
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
284
|
+
*
|
|
285
|
+
* @function
|
|
286
|
+
*/
|
|
287
|
+
getSequence() {
|
|
288
|
+
return this.sequenceNo;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Gets a property’s value as a string. Returns nil if the property doesn’t exist, i
|
|
292
|
+
* or its value is not a string.
|
|
293
|
+
*
|
|
294
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
295
|
+
*
|
|
296
|
+
* @function
|
|
297
|
+
*/
|
|
298
|
+
getString(key) {
|
|
299
|
+
if (key in this.doc) {
|
|
300
|
+
const value = this.doc[key];
|
|
301
|
+
if (typeof value === 'string') {
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @deprecated getValue is deprecated. Returns values as any.
|
|
309
|
+
*/
|
|
310
|
+
getValue(key) {
|
|
311
|
+
return key in this.doc ? this.doc[key] : null;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Returns the document data as a dictionary.
|
|
315
|
+
*
|
|
316
|
+
* Throws an error if the collection is deleted or the database is closed.
|
|
317
|
+
*
|
|
318
|
+
* @function
|
|
319
|
+
*/
|
|
320
|
+
toDictionary() {
|
|
321
|
+
return this.doc;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Converts the document content to a JSON string representation
|
|
325
|
+
* @returns {string} A JSON string
|
|
326
|
+
*
|
|
327
|
+
* @function
|
|
328
|
+
*/
|
|
329
|
+
toJsonString() {
|
|
330
|
+
return JSON.stringify(this.doc);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,OAAO,QAAQ;IAInB,YACY,KAAa,IAAI;IAC3B,2BAA2B;IACjB,aAAqB,IAAI;IACnC,2BAA2B;IACjB,aAAqB,IAAI;IACnC,2BAA2B;IACjB,aAAyB,IAAI,EACvC,OAAmB,EAAE;QAPX,OAAE,GAAF,EAAE,CAAe;QAEjB,eAAU,GAAV,UAAU,CAAe;QAEzB,eAAU,GAAV,UAAU,CAAe;QAEzB,eAAU,GAAV,UAAU,CAAmB;QAV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AI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;;;OAUG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,GAAW;QAClB,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAEC;;;;;KAKC;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/endpoint.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ICoreEngine } from '../core-types';
|
|
2
|
+
export declare class EngineLocator {
|
|
3
|
+
private static instance;
|
|
4
|
+
static readonly key: string;
|
|
5
|
+
private static engines;
|
|
6
|
+
private constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Returns the singleton instance of EngineLocator
|
|
9
|
+
* @returns {EngineLocator} The singleton instance of the EngineLocator
|
|
10
|
+
* @example
|
|
11
|
+
* const locator = EngineLocator.getInstance();
|
|
12
|
+
* // Use the same instance throughout the application
|
|
13
|
+
* const sameLocator = EngineLocator.getInstance(); // Returns the same instance
|
|
14
|
+
*/
|
|
15
|
+
static getInstance(): EngineLocator;
|
|
16
|
+
/**
|
|
17
|
+
* Registers a core engine implementation with the EngineLocator
|
|
18
|
+
* @param {string} key - The unique identifier for the engine
|
|
19
|
+
* @param {ICoreEngine} service - The core engine implementation to register
|
|
20
|
+
* @example
|
|
21
|
+
* const engine = new MyCoreEngine();
|
|
22
|
+
* EngineLocator.registerEngine('myEngine', engine);
|
|
23
|
+
*
|
|
24
|
+
* // Later, retrieve the engine
|
|
25
|
+
* const sameEngine = EngineLocator.getEngine('myEngine');
|
|
26
|
+
*/
|
|
27
|
+
static registerEngine(key: string, service: ICoreEngine): void;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves a registered core engine implementation by its key
|
|
30
|
+
* @param {string} key - The unique identifier of the engine to retrieve
|
|
31
|
+
* @returns {ICoreEngine} The registered core engine implementation
|
|
32
|
+
* @example
|
|
33
|
+
* // First register an engine
|
|
34
|
+
* const engine = new MyCoreEngine();
|
|
35
|
+
* EngineLocator.registerEngine('myEngine', engine);
|
|
36
|
+
*
|
|
37
|
+
* // Then retrieve it
|
|
38
|
+
* const retrievedEngine = EngineLocator.getEngine('myEngine');
|
|
39
|
+
* // retrievedEngine === engine
|
|
40
|
+
*/
|
|
41
|
+
static getEngine(key: string): ICoreEngine;
|
|
42
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class EngineLocator {
|
|
2
|
+
constructor() { }
|
|
3
|
+
/**
|
|
4
|
+
* Returns the singleton instance of EngineLocator
|
|
5
|
+
* @returns {EngineLocator} The singleton instance of the EngineLocator
|
|
6
|
+
* @example
|
|
7
|
+
* const locator = EngineLocator.getInstance();
|
|
8
|
+
* // Use the same instance throughout the application
|
|
9
|
+
* const sameLocator = EngineLocator.getInstance(); // Returns the same instance
|
|
10
|
+
*/
|
|
11
|
+
static getInstance() {
|
|
12
|
+
if (!EngineLocator.instance) {
|
|
13
|
+
EngineLocator.instance = new EngineLocator();
|
|
14
|
+
}
|
|
15
|
+
return EngineLocator.instance;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Registers a core engine implementation with the EngineLocator
|
|
19
|
+
* @param {string} key - The unique identifier for the engine
|
|
20
|
+
* @param {ICoreEngine} service - The core engine implementation to register
|
|
21
|
+
* @example
|
|
22
|
+
* const engine = new MyCoreEngine();
|
|
23
|
+
* EngineLocator.registerEngine('myEngine', engine);
|
|
24
|
+
*
|
|
25
|
+
* // Later, retrieve the engine
|
|
26
|
+
* const sameEngine = EngineLocator.getEngine('myEngine');
|
|
27
|
+
*/
|
|
28
|
+
static registerEngine(key, service) {
|
|
29
|
+
EngineLocator.engines.set(key, service);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves a registered core engine implementation by its key
|
|
33
|
+
* @param {string} key - The unique identifier of the engine to retrieve
|
|
34
|
+
* @returns {ICoreEngine} The registered core engine implementation
|
|
35
|
+
* @example
|
|
36
|
+
* // First register an engine
|
|
37
|
+
* const engine = new MyCoreEngine();
|
|
38
|
+
* EngineLocator.registerEngine('myEngine', engine);
|
|
39
|
+
*
|
|
40
|
+
* // Then retrieve it
|
|
41
|
+
* const retrievedEngine = EngineLocator.getEngine('myEngine');
|
|
42
|
+
* // retrievedEngine === engine
|
|
43
|
+
*/
|
|
44
|
+
static getEngine(key) {
|
|
45
|
+
return EngineLocator.engines.get(key);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
EngineLocator.key = 'default';
|
|
49
|
+
EngineLocator.engines = new Map();
|
|
50
|
+
//# sourceMappingURL=engine-locator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-locator.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/engine-locator.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IAKxB,gBAAuB,CAAC;IAEvB;;;;;;;MAOE;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC5B,aAAa,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QAC/C,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAC;IAChC,CAAC;IAEA;;;;;;;;;;MAUE;IACH,MAAM,CAAC,cAAc,CAAC,GAAW,EAAE,OAAoB;QACrD,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAEC;;;;;;;;;;;;KAYC;IACH,MAAM,CAAC,SAAS,CAAC,GAAW;QAC1B,OAAO,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;;AAjDe,iBAAG,GAAW,SAAS,CAAC;AACzB,qBAAO,GAA6B,IAAI,GAAG,EAAE,CAAC"}
|