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,108 @@
|
|
|
1
|
+
import { ReplicatorConfiguration } from './replicator-configuration';
|
|
2
|
+
import { ReplicatorChangeListener, ReplicatorDocumentChangeListener } from '../core-types';
|
|
3
|
+
import { ReplicatorStatus } from './replicator-status';
|
|
4
|
+
import { Collection } from './collection';
|
|
5
|
+
export declare class Replicator {
|
|
6
|
+
private _replicatorId;
|
|
7
|
+
private status;
|
|
8
|
+
private readonly _config;
|
|
9
|
+
private _engine;
|
|
10
|
+
private _statusChangeListener;
|
|
11
|
+
private _didStartStatusChangeListener;
|
|
12
|
+
private _documentChangeListener;
|
|
13
|
+
/**
|
|
14
|
+
* Initializes a replicator with the given configuration
|
|
15
|
+
*
|
|
16
|
+
* @param config
|
|
17
|
+
*/
|
|
18
|
+
private constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Adds a replicator change listener for listening to status updates
|
|
21
|
+
*
|
|
22
|
+
* @function
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
addChangeListener(listener: ReplicatorChangeListener): Promise<string>;
|
|
26
|
+
addDocumentChangeListener(listener: ReplicatorDocumentChangeListener): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new Replicator instance for database synchronization
|
|
29
|
+
* @param {ReplicatorConfiguration} config - The configuration for the replicator
|
|
30
|
+
* @returns {Promise<Replicator>} A Promise that resolves to a new Replicator instance
|
|
31
|
+
* @throws {Error} If the configuration is invalid or required parameters are missing
|
|
32
|
+
*/
|
|
33
|
+
static create(config: ReplicatorConfiguration): Promise<Replicator>;
|
|
34
|
+
/**
|
|
35
|
+
* Removes the replicator from the native engine and stops the replicator from running.
|
|
36
|
+
* This will remove all listeners from the replicator. As part of this, if you were to call
|
|
37
|
+
* start after this method, a new replicator would be created Natively and a new replicator
|
|
38
|
+
* id would be created.
|
|
39
|
+
*
|
|
40
|
+
* @function
|
|
41
|
+
*/
|
|
42
|
+
cleanup(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* returns the replicator id used to manage the replicator between the engine and the
|
|
45
|
+
* replicator native implementation. This value should get set when the replicator is
|
|
46
|
+
* created in the native engine via the start method.
|
|
47
|
+
*
|
|
48
|
+
* @function
|
|
49
|
+
*/
|
|
50
|
+
getId(): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* returns a copy of the replicators current configuration.
|
|
53
|
+
* @function
|
|
54
|
+
*/
|
|
55
|
+
getConfiguration(): ReplicatorConfiguration;
|
|
56
|
+
/**
|
|
57
|
+
* returns the replicators current status: its activity level and progress.
|
|
58
|
+
*
|
|
59
|
+
* @function
|
|
60
|
+
*/
|
|
61
|
+
getStatus(): Promise<ReplicatorStatus>;
|
|
62
|
+
/**
|
|
63
|
+
* Get pending document ids for the given collection. If the given collection is not part of the replication, an error will be thrown.
|
|
64
|
+
*
|
|
65
|
+
* @function
|
|
66
|
+
*/
|
|
67
|
+
getPendingDocumentIds(collection: Collection): Promise<{
|
|
68
|
+
pendingDocumentIds: string[];
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Check whether the document in the given collection is pending to push or not. If the given collection is not part of the replicator, an Exception will be thrown.
|
|
72
|
+
*
|
|
73
|
+
* @function
|
|
74
|
+
*/
|
|
75
|
+
isDocumentPending(documentId: string, collection: Collection): Promise<{
|
|
76
|
+
isPending: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
private notifyDocumentChange;
|
|
79
|
+
private notifyStatusChange;
|
|
80
|
+
/**
|
|
81
|
+
* Removes a change listener with the given listener token.
|
|
82
|
+
*
|
|
83
|
+
* @function
|
|
84
|
+
*/
|
|
85
|
+
removeChangeListener(token: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Starts the replicator with an option to reset the local checkpoint of the replicator. When the
|
|
88
|
+
* local checkpoint is reset, the replicator will sync all changes since the beginning of time from
|
|
89
|
+
* the remote database.
|
|
90
|
+
*
|
|
91
|
+
* This method returns immediately; the replicator runs asynchronously and will report its progress
|
|
92
|
+
* through the replicator change notification.
|
|
93
|
+
*
|
|
94
|
+
* @function
|
|
95
|
+
*
|
|
96
|
+
* @param {boolean} reset Resets the local checkpoint before starting the replicator.
|
|
97
|
+
*/
|
|
98
|
+
start(reset: boolean | undefined): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Stops a running replicator. This method returns immediately; when the replicator actually
|
|
101
|
+
* stops, the replicator will change its status's activity level to
|
|
102
|
+
* `ReplicatorActivityLevel.STOPPED` and the replicator change notification will be notified
|
|
103
|
+
* accordingly.
|
|
104
|
+
*
|
|
105
|
+
* @function
|
|
106
|
+
*/
|
|
107
|
+
stop(): Promise<void>;
|
|
108
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { EngineLocator } from './engine-locator';
|
|
2
|
+
import { ReplicatorStatus } from './replicator-status';
|
|
3
|
+
import { ReplicatorProgress } from './replicator-progress';
|
|
4
|
+
import { isDocumentReplicationRepresentation, } from './document-replication';
|
|
5
|
+
export class Replicator {
|
|
6
|
+
/**
|
|
7
|
+
* Initializes a replicator with the given configuration
|
|
8
|
+
*
|
|
9
|
+
* @param config
|
|
10
|
+
*/
|
|
11
|
+
constructor(replicatorId, config) {
|
|
12
|
+
this._replicatorId = undefined;
|
|
13
|
+
this._engine = EngineLocator.getEngine(EngineLocator.key);
|
|
14
|
+
this._didStartStatusChangeListener = false;
|
|
15
|
+
this._replicatorId = replicatorId;
|
|
16
|
+
this._config = config;
|
|
17
|
+
this._documentChangeListener = new Map();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Adds a replicator change listener for listening to status updates
|
|
21
|
+
*
|
|
22
|
+
* @function
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
async addChangeListener(listener) {
|
|
26
|
+
this._statusChangeListener = listener;
|
|
27
|
+
const token = this._engine.getUUID();
|
|
28
|
+
if (!this._didStartStatusChangeListener) {
|
|
29
|
+
await this._engine.replicator_AddChangeListener({
|
|
30
|
+
replicatorId: this._replicatorId,
|
|
31
|
+
changeListenerToken: token,
|
|
32
|
+
}, (data, err) => {
|
|
33
|
+
if (err) {
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
this.notifyStatusChange(data);
|
|
37
|
+
});
|
|
38
|
+
this._didStartStatusChangeListener = true;
|
|
39
|
+
return token;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error('Listener already started');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async addDocumentChangeListener(listener) {
|
|
46
|
+
const token = this._engine.getUUID();
|
|
47
|
+
this._documentChangeListener.set(token, listener);
|
|
48
|
+
await this._engine.replicator_AddDocumentChangeListener({
|
|
49
|
+
replicatorId: this._replicatorId,
|
|
50
|
+
changeListenerToken: token,
|
|
51
|
+
}, (data, err) => {
|
|
52
|
+
if (err) {
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
if (isDocumentReplicationRepresentation(data)) {
|
|
56
|
+
this.notifyDocumentChange(data, token);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
throw new Error('Invalid document replication change notification');
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return token;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new Replicator instance for database synchronization
|
|
66
|
+
* @param {ReplicatorConfiguration} config - The configuration for the replicator
|
|
67
|
+
* @returns {Promise<Replicator>} A Promise that resolves to a new Replicator instance
|
|
68
|
+
* @throws {Error} If the configuration is invalid or required parameters are missing
|
|
69
|
+
*/
|
|
70
|
+
static async create(config) {
|
|
71
|
+
if (config.getCollections().length === 0) {
|
|
72
|
+
throw new Error('No collections specified in the configuration');
|
|
73
|
+
}
|
|
74
|
+
const engine = EngineLocator.getEngine(EngineLocator.key);
|
|
75
|
+
const configJson = config.toJson();
|
|
76
|
+
const ret = await engine.replicator_Create({ config: configJson });
|
|
77
|
+
const replicator = new Replicator(ret.replicatorId, config);
|
|
78
|
+
return replicator;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Removes the replicator from the native engine and stops the replicator from running.
|
|
82
|
+
* This will remove all listeners from the replicator. As part of this, if you were to call
|
|
83
|
+
* start after this method, a new replicator would be created Natively and a new replicator
|
|
84
|
+
* id would be created.
|
|
85
|
+
*
|
|
86
|
+
* @function
|
|
87
|
+
*/
|
|
88
|
+
async cleanup() {
|
|
89
|
+
await this._engine.replicator_Cleanup({ replicatorId: this._replicatorId });
|
|
90
|
+
this._replicatorId = null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* returns the replicator id used to manage the replicator between the engine and the
|
|
94
|
+
* replicator native implementation. This value should get set when the replicator is
|
|
95
|
+
* created in the native engine via the start method.
|
|
96
|
+
*
|
|
97
|
+
* @function
|
|
98
|
+
*/
|
|
99
|
+
getId() {
|
|
100
|
+
return this._replicatorId;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* returns a copy of the replicators current configuration.
|
|
104
|
+
* @function
|
|
105
|
+
*/
|
|
106
|
+
getConfiguration() {
|
|
107
|
+
return this._config;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* returns the replicators current status: its activity level and progress.
|
|
111
|
+
*
|
|
112
|
+
* @function
|
|
113
|
+
*/
|
|
114
|
+
getStatus() {
|
|
115
|
+
return this._engine.replicator_GetStatus({
|
|
116
|
+
replicatorId: this._replicatorId,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get pending document ids for the given collection. If the given collection is not part of the replication, an error will be thrown.
|
|
121
|
+
*
|
|
122
|
+
* @function
|
|
123
|
+
*/
|
|
124
|
+
async getPendingDocumentIds(collection) {
|
|
125
|
+
const collections = this._config.getCollections();
|
|
126
|
+
if (!collections.includes(collection)) {
|
|
127
|
+
throw new Error('Collection not part of the replication');
|
|
128
|
+
}
|
|
129
|
+
return await this._engine.replicator_GetPendingDocumentIds({
|
|
130
|
+
replicatorId: this._replicatorId,
|
|
131
|
+
collectionName: collection.name,
|
|
132
|
+
scopeName: collection.scope.name,
|
|
133
|
+
name: collection.database.getName(),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Check whether the document in the given collection is pending to push or not. If the given collection is not part of the replicator, an Exception will be thrown.
|
|
138
|
+
*
|
|
139
|
+
* @function
|
|
140
|
+
*/
|
|
141
|
+
async isDocumentPending(documentId, collection) {
|
|
142
|
+
const collections = this._config.getCollections();
|
|
143
|
+
if (!collections.includes(collection)) {
|
|
144
|
+
throw new Error('Collection not part of the replication');
|
|
145
|
+
}
|
|
146
|
+
return await this._engine.replicator_IsDocumentPending({
|
|
147
|
+
replicatorId: this._replicatorId,
|
|
148
|
+
documentId: documentId,
|
|
149
|
+
collectionName: collection.name,
|
|
150
|
+
scopeName: collection.scope.name,
|
|
151
|
+
name: collection.database.getName(),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
notifyDocumentChange(data, token) {
|
|
155
|
+
const documents = data.documents.map((doc) => {
|
|
156
|
+
return {
|
|
157
|
+
scopeName: doc.scopeName,
|
|
158
|
+
collectionName: doc.collectionName,
|
|
159
|
+
id: doc.id,
|
|
160
|
+
flags: doc.flags,
|
|
161
|
+
error: doc.error,
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
const documentReplication = { isPush: data.isPush, documents: documents };
|
|
165
|
+
this._documentChangeListener.get(token)(documentReplication);
|
|
166
|
+
}
|
|
167
|
+
notifyStatusChange(data) {
|
|
168
|
+
let status;
|
|
169
|
+
const activityLevel = Number(data.activityLevel);
|
|
170
|
+
const replicatorProgress = new ReplicatorProgress(data.progress.completed, data.progress.total);
|
|
171
|
+
if (data.error && typeof data.error.message === 'string') {
|
|
172
|
+
status = new ReplicatorStatus(activityLevel, replicatorProgress, data.error.message);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
status = new ReplicatorStatus(activityLevel, replicatorProgress, undefined);
|
|
176
|
+
}
|
|
177
|
+
const statusChange = { status: status };
|
|
178
|
+
this._statusChangeListener(statusChange);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Removes a change listener with the given listener token.
|
|
182
|
+
*
|
|
183
|
+
* @function
|
|
184
|
+
*/
|
|
185
|
+
async removeChangeListener(token) {
|
|
186
|
+
await this._engine.replicator_RemoveChangeListener({
|
|
187
|
+
replicatorId: this._replicatorId,
|
|
188
|
+
changeListenerToken: token,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Starts the replicator with an option to reset the local checkpoint of the replicator. When the
|
|
193
|
+
* local checkpoint is reset, the replicator will sync all changes since the beginning of time from
|
|
194
|
+
* the remote database.
|
|
195
|
+
*
|
|
196
|
+
* This method returns immediately; the replicator runs asynchronously and will report its progress
|
|
197
|
+
* through the replicator change notification.
|
|
198
|
+
*
|
|
199
|
+
* @function
|
|
200
|
+
*
|
|
201
|
+
* @param {boolean} reset Resets the local checkpoint before starting the replicator.
|
|
202
|
+
*/
|
|
203
|
+
async start(reset) {
|
|
204
|
+
if (reset) {
|
|
205
|
+
await this._engine.replicator_ResetCheckpoint({
|
|
206
|
+
replicatorId: this._replicatorId,
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
await this._engine.replicator_Start({ replicatorId: this._replicatorId });
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Stops a running replicator. This method returns immediately; when the replicator actually
|
|
214
|
+
* stops, the replicator will change its status's activity level to
|
|
215
|
+
* `ReplicatorActivityLevel.STOPPED` and the replicator change notification will be notified
|
|
216
|
+
* accordingly.
|
|
217
|
+
*
|
|
218
|
+
* @function
|
|
219
|
+
*/
|
|
220
|
+
stop() {
|
|
221
|
+
return this._engine.replicator_Stop({ replicatorId: this._replicatorId });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=replicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replicator.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/replicator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAEL,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAGhC,MAAM,OAAO,UAAU;IAerB;;;;OAIG;IACH,YAAoB,YAAoB,EAAE,MAA+B;QAnBjE,kBAAa,GAAW,SAAS,CAAC;QAGlC,YAAO,GAAgB,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAIlE,kCAA6B,GAAY,KAAK,CAAC;QAarD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,uBAAuB,GAAG,IAAI,GAAG,EAGnC,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,iBAAiB,CAAC,QAAkC;QACxD,IAAI,CAAC,qBAAqB,GAAG,QAAQ,CAAC;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAC7C;gBACE,YAAY,EAAE,IAAI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AC5E,CAAC;IAED;;;;;;;OAOG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Collection } from './collection';
|
|
2
|
+
import { Database } from './database';
|
|
3
|
+
export declare class Scope {
|
|
4
|
+
private _engine;
|
|
5
|
+
/**
|
|
6
|
+
* Scope's name.
|
|
7
|
+
*
|
|
8
|
+
* @property
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Scope's Database.
|
|
13
|
+
*
|
|
14
|
+
* @property
|
|
15
|
+
*/
|
|
16
|
+
database: Database;
|
|
17
|
+
constructor(name: string | undefined, database: Database);
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves all collections within this scope
|
|
20
|
+
* @returns {Promise<Collection[]>} A Promise that resolves to an array of Collection instances
|
|
21
|
+
* @throws {Error} If the database is closed or there's an error accessing collections
|
|
22
|
+
*/
|
|
23
|
+
collections(): Promise<Collection[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves a specific collection within this scope by name
|
|
26
|
+
* @param {string} collectionName - The name of the collection to retrieve
|
|
27
|
+
* @returns {Promise<Collection | null>} A Promise that resolves to the Collection instance, or null if not found
|
|
28
|
+
* @throws {Error} If the database is closed or there's an error accessing the collection
|
|
29
|
+
*/
|
|
30
|
+
collection(collectionName: string): Promise<Collection | null>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EngineLocator } from './engine-locator';
|
|
2
|
+
export class Scope {
|
|
3
|
+
constructor(name, database) {
|
|
4
|
+
this._engine = EngineLocator.getEngine(EngineLocator.key);
|
|
5
|
+
this.name = name ?? '';
|
|
6
|
+
this.database = database;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves all collections within this scope
|
|
10
|
+
* @returns {Promise<Collection[]>} A Promise that resolves to an array of Collection instances
|
|
11
|
+
* @throws {Error} If the database is closed or there's an error accessing collections
|
|
12
|
+
*/
|
|
13
|
+
async collections() {
|
|
14
|
+
const results = await this._engine.collection_GetCollections({
|
|
15
|
+
name: this.database.getName(),
|
|
16
|
+
scopeName: this.name,
|
|
17
|
+
});
|
|
18
|
+
return results.collections;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves a specific collection within this scope by name
|
|
22
|
+
* @param {string} collectionName - The name of the collection to retrieve
|
|
23
|
+
* @returns {Promise<Collection | null>} A Promise that resolves to the Collection instance, or null if not found
|
|
24
|
+
* @throws {Error} If the database is closed or there's an error accessing the collection
|
|
25
|
+
*/
|
|
26
|
+
async collection(collectionName) {
|
|
27
|
+
return this._engine.collection_GetCollection({
|
|
28
|
+
name: this.database.getName(),
|
|
29
|
+
collectionName: collectionName,
|
|
30
|
+
scopeName: this.name,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/scope.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,MAAM,OAAO,KAAK;IAiBhB,YAAY,IAAwB,EAAE,QAAkB;QAhBhD,YAAO,GAAgB,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAiBxE,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEC;;;;KAIC;IACH,KAAK,CAAC,WAAW;QACf,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC;YAC3D,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YAC7B,SAAS,EAAE,IAAI,CAAC,IAAI;SACrB,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,WAAW,CAAC;IAC7B,CAAC;IAEC;;;;;KAKC;IACH,KAAK,CAAC,UAAU,CAAC,cAAsB;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC;YAC3C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YAC7B,cAAc,EAAE,cAAc;YAC9B,SAAS,EAAE,IAAI,CAAC,IAAI;SACrB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Dictionary } from './definitions';
|
|
2
|
+
import { Authenticator } from './authenticator';
|
|
3
|
+
export declare class SessionAuthenticator extends Authenticator {
|
|
4
|
+
private sessionID;
|
|
5
|
+
private cookieName;
|
|
6
|
+
private static DEFAULT_SYNC_GATEWAY_SESSION_ID_NAME;
|
|
7
|
+
constructor(sessionID: string, cookieName?: string);
|
|
8
|
+
/**
|
|
9
|
+
* Configures session-based authentication options for a replicator using cookies
|
|
10
|
+
* @param {Dictionary} options - The options to be modified
|
|
11
|
+
*/
|
|
12
|
+
authenticate(options: Dictionary): void;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the session ID used for authentication
|
|
15
|
+
* @returns {string} The current session ID
|
|
16
|
+
*/
|
|
17
|
+
getSessionID(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the name of the cookie used for session authentication
|
|
20
|
+
* @returns {string} The cookie name (defaults to 'SyncGatewaySession' if not specified)
|
|
21
|
+
*/
|
|
22
|
+
getCookieName(): string;
|
|
23
|
+
getType(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Converts the session authenticator configuration to a JSON-compatible object
|
|
26
|
+
* @returns {{ cookieName: string, sessionID: string }} An object containing the cookie name and session ID
|
|
27
|
+
*/
|
|
28
|
+
toJson(): {
|
|
29
|
+
cookieName: string;
|
|
30
|
+
sessionID: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ReplicatorConfiguration } from './replicator-configuration';
|
|
2
|
+
import { Authenticator } from './authenticator';
|
|
3
|
+
export class SessionAuthenticator extends Authenticator {
|
|
4
|
+
// eslint-disable-next-line
|
|
5
|
+
constructor(sessionID, cookieName = SessionAuthenticator.DEFAULT_SYNC_GATEWAY_SESSION_ID_NAME) {
|
|
6
|
+
super();
|
|
7
|
+
this.sessionID = sessionID;
|
|
8
|
+
this.cookieName = cookieName;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configures session-based authentication options for a replicator using cookies
|
|
12
|
+
* @param {Dictionary} options - The options to be modified
|
|
13
|
+
*/
|
|
14
|
+
authenticate(options) {
|
|
15
|
+
const current = options[ReplicatorConfiguration.CBLReplicatorOptionCookies] || '';
|
|
16
|
+
let cookieStr = current;
|
|
17
|
+
if (current.length) {
|
|
18
|
+
cookieStr += '; ';
|
|
19
|
+
}
|
|
20
|
+
cookieStr += `${this.cookieName}=${this.sessionID}`;
|
|
21
|
+
options[ReplicatorConfiguration.CBLReplicatorOptionCookies] = cookieStr;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the session ID used for authentication
|
|
25
|
+
* @returns {string} The current session ID
|
|
26
|
+
*/
|
|
27
|
+
getSessionID() {
|
|
28
|
+
return this.sessionID;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns the name of the cookie used for session authentication
|
|
32
|
+
* @returns {string} The cookie name (defaults to 'SyncGatewaySession' if not specified)
|
|
33
|
+
*/
|
|
34
|
+
getCookieName() {
|
|
35
|
+
return this.cookieName;
|
|
36
|
+
}
|
|
37
|
+
getType() {
|
|
38
|
+
return 'session';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Converts the session authenticator configuration to a JSON-compatible object
|
|
42
|
+
* @returns {{ cookieName: string, sessionID: string }} An object containing the cookie name and session ID
|
|
43
|
+
*/
|
|
44
|
+
toJson() {
|
|
45
|
+
return {
|
|
46
|
+
cookieName: this.cookieName,
|
|
47
|
+
sessionID: this.sessionID,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
SessionAuthenticator.DEFAULT_SYNC_GATEWAY_SESSION_ID_NAME = 'SyncGatewaySession';
|
|
52
|
+
//# sourceMappingURL=session-authenticator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-authenticator.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/session-authenticator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IAGlD,2BAA2B;IAC9B,YAAqB,SAAiB,EAAU,aAAqB,oBAAoB,CAAC,oCAAoC;QAC5H,KAAK,EAAE,CAAC;QADW,cAAS,GAAT,SAAS,CAAQ;QAAU,eAAU,GAAV,UAAU,CAAoE;IAE9H,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,OAAmB;QAC9B,MAAM,OAAO,GACX,OAAO,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC;QACpE,IAAI,SAAS,GAAG,OAAO,CAAC;QACxB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,SAAS,IAAI,IAAI,CAAC;QACpB,CAAC;QACD,SAAS,IAAI,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACpD,OAAO,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,GAAG,SAAS,CAAC;IAC1E,CAAC;IAEC;;;KAGC;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEC;;;KAGC;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,OAAO;QACL,OAAO,SAAS,CAAC;IACnB,CAAC;IAEA;;;MAGE;IACH,MAAM;QACJ,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;;AAnDc,yDAAoC,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-endpoint.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/url-endpoint.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAW;IAEvB,2BAA2B;IAC1B,YAAoB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEnC,MAAM;QACJ,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Expression } from './expression';
|
|
2
|
+
import { IndexType, AbstractIndex } from './abstract-index';
|
|
3
|
+
export declare class ValueIndex extends AbstractIndex {
|
|
4
|
+
private indexItems;
|
|
5
|
+
constructor(...indexItems: ValueIndexItem[]);
|
|
6
|
+
type(): IndexType;
|
|
7
|
+
language(): string;
|
|
8
|
+
ignoreAccents(): boolean;
|
|
9
|
+
items(): any[];
|
|
10
|
+
toJson(): {
|
|
11
|
+
type: string;
|
|
12
|
+
items: any[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class ValueIndexItem {
|
|
16
|
+
expr: Expression;
|
|
17
|
+
constructor(expr: Expression);
|
|
18
|
+
/**
|
|
19
|
+
* Creates a value index item with the given property.
|
|
20
|
+
*
|
|
21
|
+
* @param property the property name
|
|
22
|
+
* @return The value index item
|
|
23
|
+
*/
|
|
24
|
+
static property(property: string): ValueIndexItem;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a value index item with the given property.
|
|
27
|
+
*
|
|
28
|
+
* @param expression The expression to index. Typically a property expression.
|
|
29
|
+
* @return The value index item
|
|
30
|
+
*/
|
|
31
|
+
static expression(expression: Expression): ValueIndexItem;
|
|
32
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Expression } from './expression';
|
|
2
|
+
import { IndexType, AbstractIndex } from './abstract-index';
|
|
3
|
+
export class ValueIndex extends AbstractIndex {
|
|
4
|
+
constructor(...indexItems) {
|
|
5
|
+
super();
|
|
6
|
+
this.indexItems = indexItems;
|
|
7
|
+
}
|
|
8
|
+
type() {
|
|
9
|
+
return IndexType.Value;
|
|
10
|
+
}
|
|
11
|
+
language() {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
ignoreAccents() {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
items() {
|
|
18
|
+
const items = [];
|
|
19
|
+
for (let item of this.indexItems) {
|
|
20
|
+
items.push(item.expr.asJSON());
|
|
21
|
+
}
|
|
22
|
+
return items;
|
|
23
|
+
}
|
|
24
|
+
toJson() {
|
|
25
|
+
return {
|
|
26
|
+
type: 'value',
|
|
27
|
+
items: this.items(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class ValueIndexItem {
|
|
32
|
+
constructor(expr) {
|
|
33
|
+
this.expr = expr;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a value index item with the given property.
|
|
37
|
+
*
|
|
38
|
+
* @param property the property name
|
|
39
|
+
* @return The value index item
|
|
40
|
+
*/
|
|
41
|
+
static property(property) {
|
|
42
|
+
return new ValueIndexItem(Expression.property(property));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a value index item with the given property.
|
|
46
|
+
*
|
|
47
|
+
* @param expression The expression to index. Typically a property expression.
|
|
48
|
+
* @return The value index item
|
|
49
|
+
*/
|
|
50
|
+
static expression(expression) {
|
|
51
|
+
return new ValueIndexItem(expression);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=value-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-index.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/value-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,OAAO,UAAW,SAAQ,aAAa;IAG3C,YAAY,GAAG,UAA4B;QACzC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,IAAI;QACF,OAAO,SAAS,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK;QACH,MAAM,KAAK,GAAU,EAAE,CAAC;QACxB,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;SACpB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,cAAc;IACzB,YAAmB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEvC;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAgB;QACrC,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,UAAU,CAAC,UAAsB;QAC7C,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Expression } from './expression';
|
|
2
|
+
export class VariableExpression extends Expression {
|
|
3
|
+
// eslint-disable-next-line
|
|
4
|
+
constructor(name) {
|
|
5
|
+
super();
|
|
6
|
+
this.name = name;
|
|
7
|
+
}
|
|
8
|
+
getName() {
|
|
9
|
+
return this.name;
|
|
10
|
+
}
|
|
11
|
+
asJSON() {
|
|
12
|
+
return ['?' + this.name];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=variable-expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-expression.js","sourceRoot":"","sources":["../../../../../src/cblite-js/cblite/src/variable-expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAEhD,2BAA2B;IAC3B,YAAoB,IAAY;QAC9B,KAAK,EAAE,CAAC;QADU,SAAI,GAAJ,IAAI,CAAQ;IAEhC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,MAAM;QACX,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF"}
|