UNPKG

declarations

Version:

[![npm version](https://badge.fury.io/js/declarations.svg)](https://www.npmjs.com/package/declarations)

1,256 lines (1,171 loc) 340 kB
// Type definitions for Kii Cloud SDK v2.4.6 // Project: http://en.kii.com/ // Definitions by: Kii Consortium <http://jp.kii.com/consortium/> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace KiiCloud { enum KiiACLAction { KiiACLBucketActionCreateObjects, KiiACLBucketActionQueryObjects, KiiACLBucketActionDropBucket, KiiACLObjectActionRead, KiiACLObjectActionWrite, } export enum KiiSite { US, JP, CN, SG, CN3, EU } export enum KiiAnalyticsSite { US, JP, CN, SG, CN3, EU } enum KiiSocialNetworkName { FACEBOOK = 1, TWITTER = 2, QQ = 3, GOOGLEPLUS = 4, RENREN = 5 } type KiiSocialConnectOptions = { access_token: string, openID?: string } | { oauth_token: string, oauth_token_secret: string } interface KiiSocialAccountInfo { createdAt: number; provider: KiiSocialNetworkName; socialAccountId: string; } interface KiiThingFields { /** * thing identifier given by thing vendor. */ _vendorThingID: string; /** * thing password given by thing vendor. */ _password: string; /** * thing type given by thing vendor. */ _thingType?: string; /** * vendor identifier given by thing vendor. */ _vendor?: string; /** * firmware version given by thing vendor. */ _firmwareVersion?: string; /** * lot identifier given by thing vendor. */ _lot?: string; /** * product name given by thing vendor. */ _productName?: string; /** * arbitrary string field. */ _stringField1?: string; /** * arbitrary string field. */ _stringField2?: string; /** * arbitrary string field. */ _stringField3?: string; /** * arbitrary string field. */ _stringField4?: string; /** * arbitrary string field. */ _stringField5?: string; /** * arbitrary number field. */ _numberField1?: number; /** * arbitrary number field. */ _numberField2?: number; /** * arbitrary number field. */ _numberField3?: number; /** * arbitrary number field. */ _numberField4?: number; /** * arbitrary number field. */ _numberField5?: number; /** * custom fields. */ [name: string]: any; } type KiiACLSubject = KiiGroup | KiiUser | KiiAnyAuthenticatedUser | KiiAnonymousUser | KiiThing; interface APNSAlert { title: string; body: string; "title-loc-key": string; "title-loc-args": string[]; "action-loc-key": string; "loc-key": string; "loc-args": string[]; "launch-image": string; } interface identityData { emailAddress?: string; phoneNumber?: string; username?: string; } interface KiiAccessTokenObject { access_token: string; expires_at: Date; } interface KiiGcmInstallationResponse { installationID: string; } interface KiiMqttInstallationResponse { installationID: string; installationRegistrationID: string; } interface KiiMqttEndpoint { installationID: string; username: string; password: string; mqttTopic: string; host: string; "X-MQTT-TTL": number; portTCP: number; portSSL: number; portWS: number; portWSS: number; } /** * The main SDK class */ export class Kii { /** * Kii SDK Build Number * * @return current build number of the SDK */ static getBuildNumber(): string; /** * Kii SDK Version Number * * @return current version number of the SDK */ static getSDKVersion(): string; /** * Retrieve the current app ID * * @return The current app ID */ static getAppID(): string; /** * Retrieve the current app key * * @return The current app key */ static getAppKey(): string; /** * Set the access token lifetime in seconds. * * If you don't call this method or call it with 0, token won't be expired. * Call this method if you like the access token to be expired * after a certain period. Once called, token retrieved * by each future authentication will have the specified lifetime. * Note that, it will not update the lifetime of token received prior * calling this method. Once expired, you have to login again to renew the token. * * @param expiresIn The life time of access token in seconds. * * @throws If specified expiresIn is negative. * @throws If Kii has not been initialized * * @example * Kii.setAccessTokenExpiration(3600); */ static setAccessTokenExpiration(expiresIn: number): void; /** * Returns access token lifetime in seconds. * * If access token lifetime has not set explicitly by {@link Kii.setAccessTokenExpiration(expiresIn)}, returns 0. * * @return access token lifetime in seconds. * * @throws If Kii has not been initialized */ static getAccessTokenExpiration(): number; /** * Initialize the Kii SDK with a specific URL * * Should be the first Kii SDK action your application makes. * * @param appID The application ID found in your Kii developer console * @param appKey The application key found in your Kii developer console * @param site Can be one of the constants KiiSite.US, KiiSite.JP, KiiSite.CN or KiiSite.SG depending on your location. * @param analyticsOption An object used for initializing KiiAnalytics, If not provided or invalid object provided, KiiAnalytics won't be initialized. If provided, it can be empty object or with analyticsOption.deviceId.<br> If provided, but deviceId is not provided, SDK generates a new deviceId and use it when upload events. It can be retrieved by {@link KiiAnalytics.getDeviceId()}. It is recommended to retrieve the deviceId and store it to identify the device properly. * * @example * // Disable KiiAnalytics * Kii.initializeWithSite("my-app-id", "my-app-key", KiiSite.JP); * * // Enable KiiAnalytics with deviceId * var analyticsOption = { deviceId: "my-device-id" }; * Kii.initializeWithSite("my-app-id", "my-app-key", KiiSite.JP, analyticsOption); * * // Enable KiiAnalytics without deviceId * Kii.initializeWithSite("my-app-id", "my-app-key", KiiSite.JP, {}); */ static initializeWithSite(appID: string, appKey: string, site: KiiSite, analyticsOption?: any): void; /** * Initialize the Kii SDK * * Should be the first Kii SDK action your application makes. * Meanwhile, Kii Analytics is initialized. * * @param appID The application ID found in your Kii developer console * @param appKey The application key found in your Kii developer console * @param analyticsOption An object used for initializing KiiAnalytics, If not provided or invalid object provided, KiiAnalytics won't be initialized. If provided, it can be empty object or with analyticsOption.deviceId. <br> If provided, but deviceId is not provided, SDK generates a new deviceId and use it when upload events. It can be retrieved by {@link KiiAnalytics.getDeviceId()}. It is recommended to retrieve the deviceId and store it to identify the device properly. * * @example * // Disable KiiAnalytics * Kii.initialize("my-app-id", "my-app-key"); * * // Enable KiiAnalytics with deviceId * var analyticsOption = { deviceId: "my-device-id" }; * Kii.initialize("my-app-id", "my-app-key", analyticsOption); * * // Enable KiiAnalytics without deviceId * Kii.initialize("my-app-id", "my-app-key", {}); */ static initialize(appID: string, appKey: string, analyticsOption?: any): void; /** * Creates a reference to a bucket for this app * * <br><br>The bucket will be created/accessed within this app's scope * * @param bucketName The name of the bucket the app should create/access * * @return A working KiiBucket object * * @example * var bucket = Kii.bucketWithName("myBucket"); */ static bucketWithName(bucketName: string): KiiBucket; /** * Creates a reference to a encrypted bucket for this app * * <br><br>The bucket will be created/accessed within this app's scope * * @param bucketName The name of the bucket the app should create/access * * @return A working KiiEncryptedBucket object * * @example * var bucket = Kii.encryptedBucketWithName("myBucket"); */ static encryptedBucketWithName(bucketName: string): KiiBucket; /** * Creates a reference to a group with the given name * * @param groupName An application-specific group name * * @return A new KiiGroup reference * * @example * var group = new Kii.groupWithName("myGroup"); */ static groupWithName(groupName: string): KiiGroup; /** * Creates a reference to a group with the given name and a list of default members * * @param groupName An application-specific group name * @param members An array of KiiUser objects to add to the group * * @return A new KiiGroup reference * * @example * var group = new KiiGroup.groupWithName("myGroup", members); */ static groupWithNameAndMembers(groupName: string, members: KiiUser[]): KiiGroup; /** * Authenticate as app admin. * <br><br> * <b>This api call must not placed on code which can be accessed by browser. * This api is intended to be used by server side code like Node.js. * If you use this api in code accessible by browser, your application id and application secret could be stolen. * Attacker will be act as appadmin and all the data in your application will be suffered. * </b> * * @param clientId assigned to your application. * @param clientSecret assigned to your application. * @param callbacks The callback methods called when authentication succeeded/failed. * * @return return promise object. * <ul> * <li>fulfill callback function: function(adminContext). adminContext is a KiiAppAdminContext instance.</li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.message</li> * </ul> * </li> * </ul> * * @example * // example to use callbacks directly * Kii.authenticateAsAppAdmin("your client id", "your client secret", { * success: function(adminContext) { * // adminContext : KiiAppAdminContext instance * // Operate entities with adminContext. * }, * failure: function(error, statusCode) { * // Authentication failed. * } * ); * * // example to use Promise * Kii.authenticateAsAppAdmin("your client id", "your client secret").then( * function(adminContext) { // fulfill callback function * // adminContext : KiiAppAdminContext instance * // Operate entities with adminContext. * * }, * function(error) { // reject callback function * // Authentication failed. * var errorString = error.message; * } * ); */ static authenticateAsAppAdmin(clientId: string, clientSecret: string, callbacks?: { success(adminContext: KiiAppAdminContext): any; failure(error: string, statusCode: number): any; }): Promise<KiiAppAdminContext>; /** * Instantiate KiiServerCodeEntry with specified entry name. * * @param entryName Name of the entry. * * @return KiiServerCodeEntry instance. * * @throws Thrown when entryName is invalid in the following cases: * <li>not type of string </li> * <li>empty string </li> * <li>invalid string. Valid entryName pattern is "[a-zA-Z][_a-zA-Z0-9]*$".</li> * * @example * var entry = Kii.serverCodeEntry("main"); */ static serverCodeEntry(entryName: string): KiiServerCodeEntry; /** * Instantiate serverCodeEntryWithVersion with specified entry name and version. * * @param entryName Name of the entry. * @param version Version of the entry. * * @return KiiServerCodeEntry instance. * * @throws Thrown in the following cases: <br> * <li>entryName or version is not type of string </li> * <li>entryName or version is empty string </li> * <li>entryName is invalid string. Valid entryName pattern is "[a-zA-Z][_a-zA-Z0-9]*$".</li> * * @example * var entry = Kii.serverCodeEntryWithVersion("main", "gulsdf6ful8jvf8uq6fe7vjy6"); */ static serverCodeEntryWithVersion(entryName: string, version: string): KiiServerCodeEntry; /** * Instantiate topic belongs to application. * * @param topicName name of the topic. Must be a not empty string. * * @return topic instance. */ static topicWithName(topicName: string): KiiTopic; /** * Gets a list of topics in app scope * * @param callbacks An object with callback methods defined * @param paginationKey You can specify the pagination key with the nextPaginationKey passed by callbacks.success or fullfill callback of promise. If empty string or no string object is provided, this API regards no paginationKey specified. * * @return return promise object. * <ul> * <li>fulfill callback function: function(params). params is Array instance. * <ul> * <li>params[0] is array of KiiTopic instances.</li> * <li>params[1] is string of nextPaginationKey.</li> * </ul> * </li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.message</li> * </ul> * </li> * </ul> * * @example * // example to use callbacks directly * Kii.listTopics({ * success: function(topicList, nextPaginationKey) { * // do something with the result * for(var i=0; i&lt;topicList.length; i++){ * var topic = topicList[i]; * } * if (nextPaginationKey != null) { * Kii.listTopics({ * success: function(topicList, nextPaginationKey) {...}, * failure: function(anErrorString) {...} * }, nextPaginationKey); * } * }, * failure: function(anErrorString) { * // do something with the error response * } * }); * * // example to use promise * Kii.listTopics().then( * function(params) { * var topicList = params[0]; * var nextPaginationKey = params[1]; * // do something with the result * for(var i=0; i&lt;topicList.length; i++){ * var topic = topicList[i]; * } * if (nextPaginationKey != null) { * Kii.listTopics(null, nextPaginationKey).then( * function(params) {...}, * function(error) {...} * ); * } * }, * function(error) { * // do something with the error response * } * ); */ static listTopics(callbacks?: { success(topicList: KiiTopic[], nextPaginationKey: string): any; failure(anErrorString: string): any; }, paginationKey?: string): Promise<[KiiTopic[], string]>; /** * Authenticate as Thing. * <br><br> * <b>This api is intended to be used in a Thing device, where the user * credentials or app admin context is not configured. This Thing must be * already registered in Kii Cloud. * </b> * * @param vendorThingID vendorThingID of a registered Thing. * @param password password for the registered Thing. * @param callbacks The callback methods called when authentication succeeded/failed. * * @return return promise object. * <ul> * <li>fulfill callback function: function(thingAuthContext). thingAuthContext is a KiiThingContext instance.</li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.message</li> * </ul> * </li> * </ul> * * @example * // example to use callbacks directly * Kii.authenticateAsThing("vendor thing id", "password of this thing", { * success: function(thingAuthContext) { * // thingAuthContext : KiiThingContext instance * // Operate entities with thingAuthContext. * }, * failure: function(error) { * // Authentication failed. * } * ); * * // example to use Promise * Kii.authenticateAsThing("vendor thing id", "password of this thing").then( * function(thingAuthContext) { // fulfill callback function * // thingAuthContext : KiiThingContext instance * // Operate entities with thingAuthContext. * * }, * function(error) { // reject callback function * // Authentication failed. * var errorString = error.message; * } * ); */ static authenticateAsThing(vendorThingID: string, password: string, callbacks?: { success(thingAuthContext: KiiThingContext): any; failure(error: Error): any; }): Promise<KiiThingContext>; /** * Create a KiiThingContext reference * <br><br> * <b>This api is intended to be used in a Thing device, where the user * credentials or app admin context is not configured. This Thing must be * already registered in Kii Cloud. * </b> * * @param thingID thingID of a registered Thing. * @param token token for the registered Thing. * @param callbacks The callback methods called when creation succeeded/failed. * * @return return promise object. * <ul> * <li>fulfill callback function: function(thingContext). thingContext is a KiiThingContext instance.</li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.message</li> * </ul> * </li> * </ul> * * @example * // example to use callbacks directly * Kii.authenticateAsThingWithToken("thing_id", "thing_token", { * success: function(thingContext) { * // thingContext : KiiThingContext instance * // Operate entities with thingContext. * }, * failure: function(error) { * // Creation failed. * } * ); * * // example to use Promise * Kii.authenticateAsThingWithToken("thing_id", "thing_token").then( * function(thingContext) { // fulfill callback function * // thingContext : KiiThingContext instance * // Operate entities with thingContext. * * }, * function(error) { // reject callback function * // Creation failed. * var errorString = error.message; * } * ); */ static authenticateAsThingWithToken(thingID: string, token: string, callbacks?: { success(thingContext: KiiThingContext): any; failure(error: Error): any; }): Promise<KiiThingContext>; } /** * Represents a KiiACL object */ export class KiiACL { /** * Get the list of active ACLs associated with this object from the server * * @param callbacks An object with callback methods defined * * @return return promise object. * <ul> * <li>fulfill callback function: function(params). params is Array instance. * <ul> * <li>params[0] is the KiiACL instance which this method was called on.</li> * <li>params[1] is array of KiiACLEntry instances.</li> * </ul> * </li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.target is the KiiACL instance which this method was called on.</li> * <li>error.message</li> * </ul> * </li> * </ul> * * @example * // example to use callbacks directly * var acl = . . .; // a KiiACL object * acl.listACLEntries({ * success: function(theACL, theEntries) { * // do something * }, * * failure: function(theACL, anErrorString) { * // do something with the error response * } * }); * * // example to use Promise * var acl = . . .; // a KiiACL object * acl.listACLEntries().then( * function(params) { // fulfill callback function * var theACL = params[0]; * var theEntries = params[1]; * // do something * }, * function(error) { // reject callback function * var theACL = error.target; * var anErrorString = error.message; * // do something with the error response * }); */ listACLEntries(callbacks?: { success(theACL: KiiACL, theEntries: KiiACLEntry[]): any; failure(theACL: KiiACL, anErrorString: string): any; }): Promise<[KiiACL, KiiACLEntry[]]>; /** * Add a KiiACLEntry to the local object, if not already present. This does not explicitly grant any permissions, which should be done through the KiiACLEntry itself. This method simply adds the entry to the local ACL object so it can be saved to the server. * * @param entry The KiiACLEntry to add * * @throws If specified entry is not an instance of KiiACLEntry. * * @example * var aclEntry = . . .; // a KiiACLEntry object * var acl = . . .; // a KiiACL object * acl.putACLEntry(aclEntry); */ putACLEntry(entry: KiiACLEntry): void; /** * Remove a KiiACLEntry to the local object. This does not explicitly revoke any permissions, which should be done through the KiiACLEntry itself. This method simply removes the entry from the local ACL object and will not be saved to the server. * * @param entry The KiiACLEntry to remove * * @throws If specified entry is not an instance of KiiACLEntry. * * @example * var aclEntry = . . .; // a KiiACLEntry object * var acl = . . .; // a KiiACL object * acl.removeACLEntry(aclEntry); */ removeACLEntry(entry: KiiACLEntry): void; /** * Save the list of ACLEntry objects associated with this ACL object to the server * * @param callbacks An object with callback methods defined * * @return return promise object. * <ul> * <li>fulfill callback function: function(theSavedACL). theSavedACL is KiiACL instance.</li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.target is the KiiACL instance which this method was called on.</li> * <li>error.message</li> * </ul> * </li> * </ul> * * @example * // example to use callbacks directly * var acl = . . .; // a KiiACL object * acl.save({ * success: function(theSavedACL) { * // do something with the saved acl * }, * * failure: function(theACL, anErrorString) { * // do something with the error response * } * }); * * // example to use Promise * var acl = . . .; // a KiiACL object * acl.save().then( * function(theSavedACL) { // fulfill callback function * // do something with the saved acl * }, * function(error) { // reject callback function * var theACL = error.target; * var anErrorString = error.message; * // do something with the error response * }); */ save(callbacks?: { success(theSavedACL: KiiACL): any; failure(theACL: KiiACL, anErrorString: string): any; }): Promise<KiiACL>; } /** * Represents a KiiACLEntry object */ export class KiiACLEntry { /** * The action that is being permitted/restricted. Possible values: * <br><br> * KiiACLAction.KiiACLBucketActionCreateObjects,<br> * KiiACLAction.KiiACLBucketActionQueryObjects, <br> * KiiACLAction.KiiACLBucketActionDropBucket,<br> * KiiACLAction.KiiACLBucketActionReadObjects,<br> * KiiACLAction.KiiACLObjectActionRead,<br> * KiiACLAction.KiiACLObjectActionWrite,<br> * KiiACLAction.KiiACLSubscribeToTopic,<br> * KiiACLAction.KiiACLSendMessageToTopic * * @param value The action being permitted/restricted * * @throws If the value is not one of the permitted values */ setAction(value: KiiACLAction): void; /** * Get the action that is being permitted/restricted in this entry * * @return */ getAction(): KiiACLAction; /** * Set the subject to which the action/grant is being applied * * @param subject instance. * * @throws If the value is not one of the permitted values */ setSubject(subject: KiiACLSubject): void; /** * Get the subject that is being permitted/restricted in this entry * * @return */ getSubject<T extends KiiACLSubject>(): T; /** * Set whether or not the action is being permitted to the subject * * @param value true if the action is permitted, false otherwise * * @throws If the value is not a boolean type */ setGrant(value: boolean): void; /** * Get whether or not the action is being permitted to the subject * * @return */ getGrant(): boolean; /** * Create a KiiACLEntry object with a subject and action * * The entry will not be applied on the server until the KiiACL object is * explicitly saved. This method simply returns a working KiiACLEntry with * a specified subject and action. * * @param Subject to which the action/grant is being applied * @param action One of the specified KiiACLAction values the * permissions is being applied to * * @return A KiiACLEntry object with the specified attributes * * @throws If specified subject is invalid. * @throws If the specified action is invalid. */ static entryWithSubject(Subject: KiiACLSubject, action: KiiACLAction): KiiACLEntry; } /** * The main SDK class */ export class KiiAnalytics { /** * Retrieve the current app ID * * @return The current app ID */ static getAppID(): string; /** * Retrieve the current app key * * @return The current app key */ static getAppKey(): string; /** * Get the deviceId. If deviceId has not specified while initialization, it returns SDK generated deviceId.It is recommended to retrieve the deviceId and store it to identify the device properly. * * @return deviceId. */ static getDeviceId(): string; /** * Is the SDK printing logs to the console? * * @return True if printing logs, false otherwise */ static isLogging(): boolean; /** * Set the logging status of the SDK * * Helpful for development - we strongly advice you turn off logging for any production code. * * @param True if logs should be printed, false otherwise * * @example * KiiAnalytics.setLogging(true); */ static setLogging(True: boolean): void; /** * * * @deprecated Use {@link Kii.initializeWithSite} instead. Initialize the Kii SDK with a specific URL * * Should be the first Kii SDK action your application makes * * @param appID The application ID found in your Kii developer console * @param appKey The application key found in your Kii developer console * @param site Can be one of the constants KiiAnalyticsSite.US, KiiAnalyticsSite.JP, KiiAnalyticsSite.CN, KiiAnalyticsSite.CN3 or KiiAnalyticsSite.SG depending on your location. * @param deviceid If deviceId is not provided, SDK generates a new deviceId and use it when upload events.deviceId can be retrieved by {@link KiiAnalytics.getDeviceId()}.It is recommended to retrieve the deviceId and store it to identify the device properly. * * @example * // initialize without deviceId * Kii.initializeWithSite("my-app-id", "my-app-key", KiiAnalyticsSite.JP); * // initialize with deviceId * Kii.initializeWithSite("my-app-id", "my-app-key", KiiAnalyticsSite.JP, "my-device-id"); */ static initializeWithSite(appID: string, appKey: string, site: KiiAnalyticsSite, deviceid: string): void; /** * * * @deprecated Use {@link Kii.initialize} instead. Initialize the KiiAnalytics SDK * * Should be the first KiiAnalytics SDK action your application makes * * @param appID The application ID found in your Kii developer console * @param appKey The application key found in your Kii developer console * @param deviceid If deviceId is not provided, SDK generates a new deviceId and use it when upload events. deviceId can be retrieved by {@link KiiAnalytics.getDeviceId()}.It is recommended to retrieve the deviceId and store it to identify the device properly. * * @example * // initialize without deviceId * Kii.initializeWithSite("my-app-id", "my-app-key", KiiAnalyticsSite.JP); * // initialize with deviceId * Kii.initializeWithSite("my-app-id", "my-app-key", KiiAnalyticsSite.JP, "my-device-id"); */ static initialize(appID: string, appKey: string, deviceid: string): void; /** * Utilize the KiiAnalytics logger to track SDK-specific actions * * Helpful for development - we strongly advice you turn off logging for any production code. * * @param message The message to print to console.log in your browser * * @example * KiiAnalytics.logger("My message"); */ static logger(message: string): void; /** * Log a single event to be uploaded to KiiAnalytics * * Use this method if you'd like to track an event by name only. If you'd like to track other attributes/dimensions, please use KiiAnalytics.trackEventWithExtras(eventName, parameters) * * @param eventName A string representing the event name for later tracking * * @return return promise object. * <ul> * <li>fulfill callback function: function(). No parameters. </li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.message</li> * </ul> * </li> * </ul> */ static trackEvent(eventName: string): Promise<void>; /** * Log a single event to be uploaded to KiiAnalytics * * Use this method if you'd like to track an event by name and add extra information to the event. * * @param eventName A string representing the event name for later tracking * @param extras A dictionary of JSON-encodable key/value pairs to be attached to the event. * Key must follow the pattern "^[a-zA-Z][a-zA-Z0-9_]{0,63}$".Supported value type is string, number, boolean and array. * Empty string or empty array will be considered as invalid.Type of array elements must be string, number or boolean. * If any key/value pair is invalid, it will be ignored and not sent to the KiiCloud. * * @return return promise object. * <ul> * <li>fulfill callback function: function(). No parameters. </li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.message</li> * </ul> * </li> * </ul> */ static trackEventWithExtras(eventName: string, extras: any): Promise<void>; /** * Log a single event to be uploaded to KiiAnalytics * * Use this method if you'd like to track an event asynchronously by name and add extra information to the event. * * @param eventName A string representing the event name for later tracking * @param extras A dictionary of JSON-encodable key/value pairs to be attached to the event. * Key must follow the pattern "^[a-zA-Z][a-zA-Z0-9_]{0,63}$".Supported value type is string, number, boolean and array. * Empty string or empty array will be considered as invalid.Type of array elements must be string, number or boolean. * If any key/value pair is invalid, it will be ignored and not sent to the KiiCloud. * @param callbacks An object with callback methods defined * * @return return promise object. * <ul> * <li>fulfill callback function: function(). No parameters. </li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.message</li> * </ul> * </li> * </ul> */ static trackEventWithExtrasAndCallbacks(eventName: string, extras: any, callbacks?: { success(): any; failure(error: Error): any; }): Promise<void>; /** * * * @deprecated Set a custom API endpoint URL * * @param url A string containing the desired endpoint */ static setBaseURL(url: string): void; /** * * * @deprecated Use {@link Kii.getSDKVersion} instead. Kii Analytics SDK Version Number * * @return current version number of the SDK */ static getSDKVersion(): string; } /** * Represent an anonymous user for setting the ACL of an object. This will include anyone using the application but have not signed up or authenticated as registered user. * * When retrieving ACL from an object, test for this class to determine the subject type. */ export class KiiAnonymousUser { /** * Returns the ID of Anonymous user. */ getID(): string; } /** * Represent any authenticated user for setting the ACL of an object. This will include anyone using the application who has registered and authenticated in the current session. * * When retrieving ACL from an object, test for this class to determine the subject type. Example: */ export class KiiAnyAuthenticatedUser { /** * Returns the ID of AuthenticatedUser user. */ getID(): string; } /** * represents the app admin context * <br><br> * <B>This class must not referred from code accessible from browser. * This class is intended to be used by server side code like Node.js. * If you use this class in code accessible by browser, your application client id and client secret could be stolen. * Attacker will be act as application admin and all the data in your application will be suffered. * </B> * Application administrator context. Entities obtained from this class will be manipulated by application admin. */ export class KiiAppAdminContext { /** * Creates a reference to a bucket operated by app admin. * <br><br>The bucket will be created/accessed within this app's scope * * @param bucketName The name of the bucket the app should create/access * * @return A working KiiBucket object * * @example * Kii.authenticateAsAppAdmin("client-id", "client-secret", { * success: function(adminContext) { * var bucket = adminContext.bucketWithName("myBucket"); * // KiiBucket operation by app admin is available now. * }, * failure: function(errorString, errorCode) { * // auth failed. * } * }); */ bucketWithName(bucketName: string): KiiBucket; /** * Creates a reference to a encrypted bucket operated by app admin. * <br><br>The bucket will be created/accessed within this app's scope * * @param bucketName The name of the bucket the app should create/access * * @return A working KiiBucket object * * @example * Kii.authenticateAsAppAdmin("client-id", "client-secret", { * success: function(adminContext) { * var bucket = adminContext.encryptedBucketWithName("myBucket"); * // KiiBucket operation by app admin is available now. * }, * failure: function(errorString, errorCode) { * // auth failed. * } * }); */ encryptedBucketWithName(bucketName: string): KiiBucket; /** * Creates a reference to a group operated by app admin. * <br><br> * <b>Note:</b> * Returned instance from this API can not operate existing KiiGroup.<br> * If you want to operate existing KiiGroup, please use {@link KiiAppAdminContext#groupWithURI} or {@link KiiAppAdminContext#groupWithID}. * * @param group name. * * @return A working KiiGroup object * * @example * Kii.authenticateAsAppAdmin("client-id", "client-secret", { * success: function(adminContext) { * var group = adminContext.groupWithName("newGroup"); * // KiiGroup operation by app admin is available now. * }, * failure: function(errorString, errorCode) { * // auth failed. * } * }); */ groupWithName(group: string): KiiGroup; /** * Creates a reference to a user operated by app admin. * * @param user id. * * @return A working KiiUser object * * @example * Kii.authenticateAsAppAdmin("client-id", "client-secret", { * success: function(adminContext) { * var user = adminContext.userWithID("userid"); * // KiiUser operation by app admin is available now. * }, * failure: function(errorString, errorCode) { * // auth failed. * } * }); */ userWithID(user: string): KiiUser; /** * Creates a reference to an object operated by app admin using object`s URI. * * @param object URI. * * @return A working KiiObject instance * * @throws If the URI is null, empty or does not have correct format. */ objectWithURI(object: string): KiiObject; /** * Creates a reference to a group operated by app admin using group's ID. * <br><br> * <b>Note:</b> * Returned instance from this API can operate existing KiiGroup.<br> * If you want to create a new KiiGroup, please use {@link KiiAppAdminContext#groupWithName}. * * @param group ID. * * @return A working KiiGroup object * * @throws Thrown if passed groupID is null or empty. * * @example * Kii.authenticateAsAppAdmin("client-id", "client-secret", { * success: function(adminContext) { * var groupID = "0123456789abcdefghijklmno"; * var group = adminContext.groupWithID(groupID); * // KiiGroup operation by app admin is available now. * }, * failure: function(errorString, errorCode) { * // auth failed. * } * }); */ groupWithID(group: string): KiiGroup; /** * Register new group own by specified user on Kii Cloud with specified ID. * This method can be used only by app admin. * * <br><br>If the group that has specified id already exists, registration will be failed. * * @param groupID ID of the KiiGroup * @param groupName Name of the KiiGroup * @param user id of owner * @param members An array of KiiUser objects to add to the group * @param callbacks * * @return return promise object. * <ul> * <li>fulfill callback function: function(theSavedGroup). theSavedGroup is KiiGroup instance.</li> * <li>reject callback function: function(error). error is an Error instance. * <ul> * <li>error.target is the KiiGroup instance which this method was called on.</li> * <li>error.message</li> * <li>error.addMembersArray is array of KiiUser to be added as memebers of this group.</li> * <li>error.removeMembersArray is array of KiiUser to be removed from the memebers list of this group.</li> * </ul> * </li> * </ul> * * @example * // example to use callbacks directly * Kii.authenticateAsAppAdmin("client-id", "client-secret", { * success: function(adminContext) { * var members = []; * members.push(KiiUser.userWithID("Member User Id")); * adminContext.registerGroupWithOwnerAndID("Group ID", "Group Name", "Owner User ID", members, { * success: function(theSavedGroup) { * // do something with the saved group * }, * failure: function(theGroup, anErrorString, addMembersArray, removeMembersArray) { * // do something with the error response * } * }); * }, * failure: function(errorString, errorCode) { * // auth failed. * } * }); * // example to use Promise * Kii.authenticateAsAppAdmin("client-id", "client-secret").then( * function(adminContext) { * var members = []; * members.push(KiiUser.userWithID("Member User Id")); * return adminContext.registerGroupWithOwnerAndID("Group ID", "Group Name", "Owner User ID", members); * } * ).then( * function(group) { * // do something with the saved group * } * ); */ registerGroupWithOwnerAndID(groupID: string, groupName: string, user: string, members: KiiUser[], callbacks?: { success(adminContext: KiiAppAdminContext): any; failure(theGroup: KiiGroup, anErrorString: string, addMembersArray: KiiUser[], removeMembersArray: KiiUser[]): any; }): Promise<KiiAppAdminContext>; /** * Creates a reference to a group operated by app admin using group's URI. * <br><br> * <b>Note:</b> * Returned instance from this API can operate existing KiiGroup.<br> * If you want to create a new KiiGroup, please use {@link KiiAppAdminContext#groupWithName}. * * @param group URI. * * @return A working KiiGroup object * * @throws Thrown if the URI is null, empty or does not have correct format. * * @example * Kii.authenticateAsAppAdmin("client-id", "client-secret", { * success: function(adminContext) { * var groupUri = ...; // KiiGroup's URI * var group = adminContext.groupWithURI(groupUri); * // KiiGroup operation by app admin is available now. * }, * failure: function(errorString, errorCode) { * // auth failed. * } * }); */ groupWithURI(group: string): KiiGroup; /** * Find registered KiiUser with the email.<br> * If there are no user registers with the specified email or if there are but not verified email yet, * callbacks.failure or reject callback of promise will be called.<br> * If the email is null or empty, callbacks.failure or reject callback of promise will be callded. * <br><br> * <b>Note:</b> * <ul> * <li>If "Expose Full User Data To Others" is