<commit_before>import {Injectable} from "@angular/core";
import              "rxjs/Rx";
import {C8oBase} from "./c8oBase.service";
import {C8oUtils} from "./c8oUtils.service";
import {Http, Response} from "@angular/http";
import {C8oHttpInterface} from "./c8oHttpInterface.service";
import {C8oLogger} from "./c8oLogger.service";
import {C8oFullSync} from "./c8oFullSync.service";
import {C8oLogLevel} from "./c8oLogLevel.service";
import {C8oSettings} from "./c8oSettings.service";

import {C8oExceptionMessage} from "./Exception/c8oExceptionMessage.service";
import {C8oFullSyncCbl} from "./c8oFullSync.service";
import {C8oResponseListener, C8oResponseJsonListener} from "./c8oResponse.service";

import {C8oPromise} from "./c8oPromise.service";
import {C8oCallTask} from "./c8oCallTask.service";
import {C8oException} from "./Exception/c8oException.service";
import {C8oCouchBaseLiteException} from "./Exception/c8oCouchBaseLiteException.service";
import {C8oExceptionListener} from "./Exception/c8oExceptionListener.service";
import {Observable} from "rxjs";
import {C8oFullSyncChangeListener} from "./c8oFullSyncChangeListener.service";

/**
 * Allows to send requests to a Convertigo Server (or Studio), these requests are called c8o calls.<br/>
 * C8o calls are done thanks to a HTTP request or a CouchbaseLite usage.<br/>
 * An instance of C8o is connected to only one Convertigo and can't change it.<br/>
 * To use it, you have to first initialize the C8o instance with the Convertigo endpoint, then use call methods with Convertigo variables as parameter.
 */

@Injectable()
export class C8o extends C8oBase {
    // Log:
    // - VERBOSE (v): methods parameters,
    // - DEBUG (d): methods calls,
    // - INFO (i):
    // - WARN (w):
    // - ERROR (e):

    /*** Regular expression ***/

    /**
     * The regex used to handle the c8o requestable syntax ("&lt;project&gt;.&lt;sequence&gt;" or "&lt;project&gt;.&lt;connector&gt;.&lt;transaction&gt;")
     */
    private static RE_REQUESTABLE = /^([^.]*)\.(?:([^.]+)|(?:([^.]+)\.([^.]+)))$/;


    /**
     * The regex used to get the part of the endpoint before '/projects/...'
     */
    private static RE_ENDPOINT = /^(https?:\/\/([^:/]+)(:[0-9]+)?\/?.*?)\/projects\/([^\/]+)$/;

    /**
     *  Engine reserved parameters
     */
    static ENGINE_PARAMETER_PROJECT: string = "__project";
    static ENGINE_PARAMETER_SEQUENCE: string = "__sequence";
    static ENGINE_PARAMETER_CONNECTOR: string = "__connector";
    static ENGINE_PARAMETER_TRANSACTION: string = "__transaction";
    static ENGINE_PARAMETER_ENCODED: string = "__encoded";
    static ENGINE_PARAMETER_DEVICE_UUID: string = "__uuid";
    static ENGINE_PARAMETER_PROGRESS: string = "__progress";
    static ENGINE_PARAMETER_FROM_LIVE: string = "__fromLive";

    /**
     * FULLSYNC parameters
     */

    /**
     * Constant to use as a parameter for a Call of "fs://.post" and must be followed by a FS_POLICY_* constant.
     * <pre>{@code
     * c8o.callJson("fs://.post",
     *   C8o.FS_POLICY, C8o.FS_POLICY_MERGE,
     *   "docid", myid,
     *   "mykey", myvalue
     * ).sync();
     * }</pre>
     */
    static FS_POLICY: string = "_use_policy";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This is the default post policy that don't alter the document before the CouchbaseLite's insertion.
     */
    static FS_POLICY_NONE: string = "none";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This post policy remove the "_id" and "_rev" of the document before the CouchbaseLite's insertion.
     */
    static FS_POLICY_CREATE: string = "create";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This post policy inserts the document in CouchbaseLite even if a document with the same "_id" already exists.
     */
    static FS_POLICY_OVERRIDE: string = "override";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This post policy merge the document with an existing document with the same "_id" before the CouchbaseLite's insertion.
     */
    static FS_POLICY_MERGE: string = "merge";
    /**
     Use it with "fs://.post". Default value is ".".

     This key allow to override the sub key separator in case of document depth modification.
     */
    static FS_SUBKEY_SEPARATOR: string = "_use_subkey_separator";

    /**
     * Use it with "fs://" request as parameter to enable the live request feature.<br/>
     * Must be followed by a string parameter, the 'liveid' that can be use to cancel the live
     * request using c8o.cancelLive(liveid) method.<br/>
     * A live request automatically recall the then or thenUI handler when the database changed.
     */
    public static FS_LIVE:  string = "__live";

    /** Local cache keys **/
    static LOCAL_CACHE_DOCUMENT_KEY_RESPONSE: string = "response";
    static LOCAL_CACHE_DOCUMENT_KEY_RESPONSE_TYPE: string = "responseType";
    static LOCAL_CACHE_DOCUMENT_KEY_EXPIRATION_DATE: string = "expirationDate";

    static LOCAL_CACHE_DATABASE_NAME: string = "c8olocalcache";

    /** Response type **/
    static RESPONSE_TYPE_XML: string = "pxml";
    static RESPONSE_TYPE_JSON: string = "json";

    /* Static configuration */
    static deviceUUID: string = C8oUtils.getNewGUIDString();

    /**
     * Returns the current version of the SDK as "x.y.z".
     *
     * @return Current version of the SDK as "x.y.z".
     */
    static getSdkVersion(): string {
        return "2.1.1";
    }

    /** Network **/

    /**
     * The Convertigo endpoint, syntax: &lt;protocol&gt;://&lt;host&gt;:&lt;port&gt;/&lt;Convertigo web app path&gt;/projects/&lt;project name&gt; (Example: http://127.0.0.1:18080/convertigo/projects/MyProject)
     */
    private _endpoint: string;<commit_msg>update sdk version into C8o.service<commit_after>import {Injectable} from "@angular/core";
import              "rxjs/Rx";
import {C8oBase} from "./c8oBase.service";
import {C8oUtils} from "./c8oUtils.service";
import {Http, Response} from "@angular/http";
import {C8oHttpInterface} from "./c8oHttpInterface.service";
import {C8oLogger} from "./c8oLogger.service";
import {C8oFullSync} from "./c8oFullSync.service";
import {C8oLogLevel} from "./c8oLogLevel.service";
import {C8oSettings} from "./c8oSettings.service";

import {C8oExceptionMessage} from "./Exception/c8oExceptionMessage.service";
import {C8oFullSyncCbl} from "./c8oFullSync.service";
import {C8oResponseListener, C8oResponseJsonListener} from "./c8oResponse.service";

import {C8oPromise} from "./c8oPromise.service";
import {C8oCallTask} from "./c8oCallTask.service";
import {C8oException} from "./Exception/c8oException.service";
import {C8oCouchBaseLiteException} from "./Exception/c8oCouchBaseLiteException.service";
import {C8oExceptionListener} from "./Exception/c8oExceptionListener.service";
import {Observable} from "rxjs";
import {C8oFullSyncChangeListener} from "./c8oFullSyncChangeListener.service";

/**
 * Allows to send requests to a Convertigo Server (or Studio), these requests are called c8o calls.<br/>
 * C8o calls are done thanks to a HTTP request or a CouchbaseLite usage.<br/>
 * An instance of C8o is connected to only one Convertigo and can't change it.<br/>
 * To use it, you have to first initialize the C8o instance with the Convertigo endpoint, then use call methods with Convertigo variables as parameter.
 */

@Injectable()
export class C8o extends C8oBase {
    // Log:
    // - VERBOSE (v): methods parameters,
    // - DEBUG (d): methods calls,
    // - INFO (i):
    // - WARN (w):
    // - ERROR (e):

    /*** Regular expression ***/

    /**
     * The regex used to handle the c8o requestable syntax ("&lt;project&gt;.&lt;sequence&gt;" or "&lt;project&gt;.&lt;connector&gt;.&lt;transaction&gt;")
     */
    private static RE_REQUESTABLE = /^([^.]*)\.(?:([^.]+)|(?:([^.]+)\.([^.]+)))$/;


    /**
     * The regex used to get the part of the endpoint before '/projects/...'
     */
    private static RE_ENDPOINT = /^(https?:\/\/([^:/]+)(:[0-9]+)?\/?.*?)\/projects\/([^\/]+)$/;

    /**
     *  Engine reserved parameters
     */
    static ENGINE_PARAMETER_PROJECT: string = "__project";
    static ENGINE_PARAMETER_SEQUENCE: string = "__sequence";
    static ENGINE_PARAMETER_CONNECTOR: string = "__connector";
    static ENGINE_PARAMETER_TRANSACTION: string = "__transaction";
    static ENGINE_PARAMETER_ENCODED: string = "__encoded";
    static ENGINE_PARAMETER_DEVICE_UUID: string = "__uuid";
    static ENGINE_PARAMETER_PROGRESS: string = "__progress";
    static ENGINE_PARAMETER_FROM_LIVE: string = "__fromLive";

    /**
     * FULLSYNC parameters
     */

    /**
     * Constant to use as a parameter for a Call of "fs://.post" and must be followed by a FS_POLICY_* constant.
     * <pre>{@code
     * c8o.callJson("fs://.post",
     *   C8o.FS_POLICY, C8o.FS_POLICY_MERGE,
     *   "docid", myid,
     *   "mykey", myvalue
     * ).sync();
     * }</pre>
     */
    static FS_POLICY: string = "_use_policy";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This is the default post policy that don't alter the document before the CouchbaseLite's insertion.
     */
    static FS_POLICY_NONE: string = "none";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This post policy remove the "_id" and "_rev" of the document before the CouchbaseLite's insertion.
     */
    static FS_POLICY_CREATE: string = "create";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This post policy inserts the document in CouchbaseLite even if a document with the same "_id" already exists.
     */
    static FS_POLICY_OVERRIDE: string = "override";
    /**
     Use it with "fs://.post" and C8o.FS_POLICY.

     This post policy merge the document with an existing document with the same "_id" before the CouchbaseLite's insertion.
     */
    static FS_POLICY_MERGE: string = "merge";
    /**
     Use it with "fs://.post". Default value is ".".

     This key allow to override the sub key separator in case of document depth modification.
     */
    static FS_SUBKEY_SEPARATOR: string = "_use_subkey_separator";

    /**
     * Use it with "fs://" request as parameter to enable the live request feature.<br/>
     * Must be followed by a string parameter, the 'liveid' that can be use to cancel the live
     * request using c8o.cancelLive(liveid) method.<br/>
     * A live request automatically recall the then or thenUI handler when the database changed.
     */
    public static FS_LIVE:  string = "__live";

    /** Local cache keys **/
    static LOCAL_CACHE_DOCUMENT_KEY_RESPONSE: string = "response";
    static LOCAL_CACHE_DOCUMENT_KEY_RESPONSE_TYPE: string = "responseType";
    static LOCAL_CACHE_DOCUMENT_KEY_EXPIRATION_DATE: string = "expirationDate";

    static LOCAL_CACHE_DATABASE_NAME: string = "c8olocalcache";

    /** Response type **/
    static RESPONSE_TYPE_XML: string = "pxml";
    static RESPONSE_TYPE_JSON: string = "json";

    /* Static configuration */
    static deviceUUID: string = C8oUtils.getNewGUIDString();

    /**
     * Returns the current version of the SDK as "x.y.z".
     *
     * @return Current version of the SDK as "x.y.z".
     */
    static getSdkVersion(): string {
        return "2.1.30";
    }

    /** Network **/

    /**
     * The Convertigo endpoint, syntax: &lt;protocol&gt;://&lt;host&gt;:&lt;port&gt;/&lt;Convertigo web app path&gt;/projects/&lt;project name&gt; (Example: http://127.0.0.1:18080/convertigo/projects/MyProject)
     */
    private _endpoint: string;
{'fraction_non_alphanumeric': 0.13363975370739745, 'fraction_numerical': 0.011620848148469344, 'mean_word_length': 3.3223388305847075, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1321552', 'n_tokens_mistral': 3773, 'n_tokens_neox': 3702, 'n_words': 1059}