forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kii-cloud-sdk.d.ts
7279 lines (6991 loc) · 297 KB
/
kii-cloud-sdk.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for Kii Cloud SDK v2.3.0
// Project: http://en.kii.com/
// Definitions by: Kii Consortium <http://jp.kii.com/consortium/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../es6-promise/es6-promise.d.ts' />
declare module KiiCloud {
enum KiiACLAction {
KiiACLBucketActionCreateObjects,
KiiACLBucketActionQueryObjects,
KiiACLBucketActionDropBucket,
KiiACLObjectActionRead,
KiiACLObjectActionWrite,
}
export enum KiiSite {
US,
JP,
CN,
SG,
CN3
}
export enum KiiAnalyticsSite {
US,
JP,
CN,
SG,
CN3
}
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;
/**
* 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;
}
/**
* 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<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<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]>;
}
/**
* 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.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.