forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asana.d.ts
2476 lines (2253 loc) · 98 KB
/
asana.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 node-asana 0.14.0
// Project: https://github.com/Asana/node-asana
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../bluebird/bluebird.d.ts" />
/// <reference path="../request/request.d.ts" />
declare module "asana" {
import * as Promise from 'bluebird';
namespace asana {
var Client: ClientStatic;
interface ClientStatic {
/**
* Constructs a Client with instances of all the resources using the dispatcher.
* It also keeps a reference to the dispatcher so that way the end user can have
* access to it.
* @class
* @classdesc A wrapper for the Asana API which is authenticated for one user
* @param {Dispatcher} dispatcher The request dispatcher to use
* @param {Object} options Options to configure the client
* @param {String} [clientId] ID of the client, required for Oauth
* @param {String} [clientSecret] Secret key, for some Oauth flows
* @param {String} [redirectUri] Default redirect URI for this client
* @param {String} [asanaBaseUrl] Base URL for Asana, for debugging
*/
(dispatcher: Dispatcher, options?: ClientOptions): asana.Client;
/**
* Creates a new client.
* @param {Object} options Options for specifying the client, see constructor.
*/
create(options?: ClientOptions): Client;
}
/** Options to configure the client */
interface ClientOptions extends DispatcherOptions {
clientId?: string|number;
clientSecret?: string;
redirectUri?: string;
asanaBaseUrl?: string;
}
interface Client {
/**
* Ensures the client is authorized to make requests. Kicks off the
* configured Oauth flow, if any.
*
* @returns {Promise<Client>} A promise that resolves to this client when
* authorization is complete.
*/
authorize(): Promise<Client>;
/**
* Configure the Client to use a user's API Key and then authenticate
* through HTTP Basic Authentication. This should only be done for testing,
* as requests using Oauth can provide more security, higher rate limits, and
* more features.
* @param {String} apiKey The Asana Api Key of the user
* @return {Client} this
* @param apiKey
* @return
*/
useBasicAuth(apiKey: string): this;
/**
* Configure the client to authenticate using a Personal Access Token.
* @param {String} accessToken The Personal Access Token to use for
* authenticating requests.
* @return {Client} this
* @param accessToken
* @return
*/
useAccessToken(accessToken: string): this;
/**
* Configure the client to authenticate via Oauth. Credentials can be
* supplied, or they can be obtained by running an Oauth flow.
* @param {Object} options Options for Oauth. Includes any options for
* the selected flow.
* @option {Function} [flowType] Type of OauthFlow to use to obtain user
* authorization. Defaults to autodetect based on environment.
* @option {Object} [credentials] Credentials to use; no flow required to
* obtain authorization. This object should at a minimum contain an
* `access_token` string field.
* @return {Client} this
* @param options
* @return
*/
useOauth(options?: auth.OauthAuthenticatorOptions): this;
/**
* The internal dispatcher. This is mostly used by the resources but provided
* for custom requests to the API or API features that have not yet been added
* to the client.
* @type {Dispatcher}
*/
dispatcher: Dispatcher;
/**
* An instance of the Attachments resource.
* @type {Attachments}
*/
attachments: resources.Attachments;
/**
* An instance of the Events resource.
* @type {Events}
*/
events: resources.Events;
/**
* An instance of the Projects resource.
* @type {Projects}
*/
projects: resources.Projects;
/**
* An instance of the Stories resource.
* @type {Stories}
*/
stories: resources.Stories;
/**
* An instance of the Tags resource.
* @type {Tags}
*/
tags: resources.Tags;
/**
* An instance of the Tasks resource.
* @type {Tasks}
*/
tasks: resources.Tasks;
/**
* An instance of the Teams resource.
* @type {Teams}
*/
teams: resources.Teams;
/**
* An instance of the Users resource.
* @type {Users}
*/
users: resources.Users;
/**
* An instance of the Workspaces resource.
* @type {Workspaces}
*/
workspaces: resources.Workspaces;
/**
* Store off Oauth info.
*/
app: auth.App;
}
var Dispatcher: DispatcherStatic;
interface DispatcherStatic {
/**
* Creates a dispatcher which will act as a basic wrapper for making HTTP
* requests to the API, and handle authentication.
* @class
* @classdesc A HTTP wrapper for the Asana API
* @param {Object} options for default behavior of the Dispatcher
* @option {Authenticator} [authenticator] Object to use for authentication.
* Can also be set later with `setAuthenticator`.
* @option {String} [retryOnRateLimit] Automatically handle `RateLimitEnforced`
* errors by sleeping and retrying after the waiting period.
* @option {Function} [handleUnauthorized] Automatically handle
* `NoAuthorization` with the callback. If the callback returns `true`
* (or a promise resolving to `true), will retry the request.
* @option {String} [asanaBaseUrl] Base URL for Asana, for debugging
* @option {Number} [requestTimeout] Timeout (in milliseconds) to wait for the
* request to finish.
*/
new (options?: DispatcherOptions): Dispatcher;
/**
* Default handler for requests that are considered unauthorized.
* Requests that the authenticator try to refresh its credentials if
* possible.
* @return {Promise<boolean>} True iff refresh was successful, false if not.
* @return
*/
maybeReauthorize(): Promise<boolean>;
/**
* The relative API path for the current version of the Asana API.
* @type {String}
*/
API_PATH : string;
}
interface DispatcherOptions {
authenticator?: auth.Authenticator;
retryOnRateLimit?: boolean;
handleUnauthorized?: () => boolean|Promise<boolean>;
requestTimeout?: string;
}
interface Dispatcher {
/**
* Creates an Asana API Url by concatenating the ROOT_URL with path provided.
* @param {String} path The path
* @return {String} The url
* @param path
* @return
*/
url(path: string): string;
/**
* Configure the authentication mechanism to use.
* @returns {Dispatcher} this
* @param authenticator
* @return
*/
setAuthenticator(authenticator: auth.Authenticator): this;
/**
* Ensure the dispatcher is authorized to make requests. Call this before
* making any API requests.
*
* @returns {Promise} Resolves when the dispatcher is authorized, rejected if
* there was a problem authorizing.
* @return
*/
authorize(): Promise<void>;
/**
* Dispatches a request to the Asana API. The request parameters are passed to
* the request module.
* @param {Object} params The params for request
* @param {Object} [dispatchOptions] Options for handling request/response
* @return {Promise} The response for the request
* @param params
* @param dispatchOptions?
* @return
*/
dispatch(params: any, dispatchOptions?: any): Promise<any>;
/**
* Dispatches a GET request to the Asana API.
* @param {String} path The path of the API
* @param {Object} [query] The query params
* @param {Object} [dispatchOptions] Options for handling the request and
* response. See `dispatch`.
* @return {Promise} The response for the request
* @param path
* @param query?
* @param dispatchOptions?
* @return
*/
get(path: string, query?: any, dispatchOptions?: any): Promise<any>;
/**
* Dispatches a POST request to the Asana API.
* @param {String} path The path of the API
* @param {Object} data The data to be sent
* @param {Object} [dispatchOptions] Options for handling the request and
* response. See `dispatch`.
* @return {Promise} The response for the request
* @param path
* @param data
* @param dispatchOptions?
* @return
*/
post(path: string, data: any, dispatchOptions?: any): Promise<any>;
/**
* Dispatches a PUT request to the Asana API.
* @param {String} path The path of the API
* @param {Object} data The data to be sent
* @param {Object} [dispatchOptions] Options for handling the request and
* response. See `dispatch`.
* @return {Promise} The response for the request
* @param path
* @param data
* @param dispatchOptions?
* @return
*/
put(path: string, data: any, dispatchOptions?: any): Promise<any>;
/**
* Dispatches a DELETE request to the Asana API.
* @param {String} path The path of the API
* @param {Object} [dispatchOptions] Options for handling the request and
* response. See `dispatch`.
* @return {Promise} The response for the request
* @param path
* @param dispatchOptions?
* @return
*/
delete(path: string, dispatchOptions?: any): Promise<any>;
/**
* The base URL for Asana
* @type {String}
*/
asanaBaseUrl : string;
/**
* Whether requests should be automatically retried if rate limited.
* @type {Boolean}
*/
retryOnRateLimit : boolean;
/**
* Handler for unauthorized requests which may seek reauthorization.
* Default behavior is available if configured with an Oauth authenticator
* that has a refresh token, and will refresh the current access token.
* @type {Function}
*/
handleUnauthorized : () => boolean|Promise<boolean>;
/**
* The amount of time in milliseconds to wait for a request to finish.
* @type {Number}
*/
requestTimeout : number;
}
namespace auth {
var BasicAuthenticator: BasicAuthenticatorStatic;
interface BasicAuthenticatorStatic {
/**
* @param apiKey
*/
new (apiKey: string): BasicAuthenticator;
}
interface BasicAuthenticator extends Authenticator {
/**
* @param {Object} request The request to modify, for the `request` library.
* @return {Object} The `request` parameter, modified to include authentication
* information using the stored credentials.
* @param request
* @return
*/
authenticateRequest(request: BasicAuthenticatorRequest): BasicAuthenticatorRequest;
}
interface BasicAuthenticatorRequest {
auth : {
username : string;
password : string;
}
}
var OauthAuthenticator: OauthAuthenticatorStatic;
interface OauthAuthenticatorStatic {
/**
* Creates an authenticator that uses Oauth for authentication.
*
* @param {Object} options Configure the authenticator; must specify one
* of `flow` or `credentials`.
* @option {App} app The app being authenticated for.
* @option {OauthFlow} [flow] The flow to use to get credentials
* when needed.
* @option {String|Object} [credentials] Initial credentials to use. This can
* be either the object returned from an access token request (which
* contains the token and some other metadata) or just the `access_token`
* field.
* @constructor
*/
new (options: OauthAuthenticatorOptions): OauthAuthenticator;
}
interface OauthAuthenticatorOptions {
flowType?: auth.FlowType;
credentials?: Credentials|string;
}
interface Credentials {
access_token?: string;
refresh_token?: string;
}
interface OauthAuthenticator extends Authenticator {
/**
* @param {Object} request The request to modify, for the `request` library.
* @return {Object} The `request` parameter, modified to include authentication
* information using the stored credentials.
* @param request
* @return
*/
authenticateRequest(request: OauthAuthenticatorRequest): OauthAuthenticatorRequest;
}
interface OauthAuthenticatorRequest {
/**
* When browserify-d, the `auth` component of the `request` library
* doesn't work so well, so we just manually set the bearer token instead.
*/
headers : {
Authorization : string;
}
}
/**
* A layer to abstract the differences between using different types of
* authentication (Oauth vs. Basic). The Authenticator is responsible for
* establishing credentials and applying them to outgoing requests.
* @constructor
*/
interface Authenticator {
/**
* Establishes credentials.
*
* @return {Promise} Resolves when initial credentials have been
* completed and `authenticateRequest` calls can expect to succeed.
* @return
*/
establishCredentials(): Promise<void>;
/**
* Attempts to refresh credentials, if possible, given the current credentials.
*
* @return {Promise} Resolves to `true` if credentials have been successfully
* established and `authenticateRequests` can expect to succeed, else
* resolves to `false`.
* @return
*/
refreshCredentials(): Promise<boolean>;
}
var App: AppStatic;
interface AppStatic {
/**
* An abstraction around an App used with Asana.
*
* @options {Object} Options to construct the app
* @option {String} clientId The ID of the app
* @option {String} [clientSecret] The secret key, if available here
* @option {String} [redirectUri] The default redirect URI
* @option {String} [scope] Scope to use, supports `default` and `scim`
* @option {String} [asanaBaseUrl] Base URL to use for Asana, for debugging
* @constructor
*/
new (options: AppOptions): App;
}
interface AppOptions extends AsanaAuthorizeUrlOptions {
clientId?: string|number;
clientSecret?: string;
scope?: string;
}
interface App {
/**
* @param {Object} options Overrides to the app's defaults
* @option {String} asanaBaseUrl
* @option {String} redirectUri
* @returns {String} The URL used to authorize a user for the app.
* @param options
* @return
*/
asanaAuthorizeUrl(options?: AsanaAuthorizeUrlOptions): string;
/**
* @param {Object} options Overrides to the app's defaults
* @option {String} asanaBaseUrl
* @option {String} redirectUri
* @returns {String} The URL used to acquire an access token.
* @param options
* @return
*/
asanaTokenUrl(options?: AsanaAuthorizeUrlOptions): string;
/**
* @param {String} code An authorization code obtained via `asanaAuthorizeUrl`.
* @param {Object} options Overrides to the app's defaults
* @option {String} asanaBaseUrl
* @option {String} redirectUri
* @return {Promise<Object>} The token, which will include the `access_token`
* used for API access, as well as a `refresh_token` which can be stored
* to get a new access token without going through the flow again.
* @param code
* @param options
* @return
*/
accessTokenFromCode(code: string, options?: AsanaAuthorizeUrlOptions): Promise<Credentials>;
/**
* @param {String} refreshToken A refresh token obtained via Oauth.
* @param {Object} options Overrides to the app's defaults
* @option {String} asanaBaseUrl
* @option {String} redirectUri
* @return {Promise<Object>} The token, which will include the `access_token`
* used for API access.
* @param refreshToken
* @param options
* @return
*/
accessTokenFromRefreshToken(refreshToken: string, options: AsanaAuthorizeUrlOptions): Promise<Credentials>;
scope : string;
asanaBaseUrl : string;
}
interface AsanaAuthorizeUrlOptions {
redirectUri?: string;
asanaBaseUrl?: string;
}
var OauthError: OauthErrorStatic;
interface OauthErrorStatic {
/**
* @param options {Object} A data blob parsed from a query string or JSON
* response from the Asana API
* @option {String} error The string code identifying the error.
* @option {String} [error_uri] A link to help and information about the error.
* @option {String} [error_description] A description of the error.
* @constructor
*/
new (options: OauthErrorOptions): OauthError;
}
interface OauthErrorOptions {
error?: string;
error_uri?: string;
error_description?: string;
}
interface OauthError extends Error {
}
/**
* Auto-detects the type of Oauth flow to use that's appropriate to the
* environment.
*
* @returns {Function|null} The type of Oauth flow to use, or null if no
* appropriate type could be determined.
* @param env
* @return
*/
function autoDetect(env: any): Function;
var RedirectFlow: RedirectFlowStatic;
interface RedirectFlowStatic extends FlowType {
/**
* An Oauth flow that runs in the browser and requests user authorization by
* redirecting to an authorization page on Asana, and redirecting back with
* the credentials.
* @param {Object} options See `BaseBrowserFlow` for options.
* @constructor
*/
new (options: any): RedirectFlow;
}
interface RedirectFlow extends BaseBrowserFlow {
}
var PopupFlow: PopupFlowStatic;
interface PopupFlowStatic extends FlowType {
/**
* An Oauth flow that runs in the browser and requests user authorization by
* popping up a window and prompting the user.
* @param {Object} options See `BaseBrowserFlow` for options.
* @constructor
*/
new (options: any): PopupFlow;
}
interface PopupFlow extends BaseBrowserFlow {
/**
* @param popupWidth
* @param popupHeight
*/
_popupParams(popupWidth: number, popupHeight: number): void;
runReceiver(): void;
}
var NativeFlow: NativeFlowStatic;
interface NativeFlowStatic extends FlowType {
/**
* An Oauth flow that can be run from the console or an app that does
* not have the ability to open and manage a browser on its own.
* @param {Object} options
* @option {App} app App to authenticate for
* @option {String function(String)} [instructions] Function returning the
* instructions to output to the user. Passed the authorize url.
* @option {String function()} [prompt] String to output immediately before
* waiting for a line from stdin.
* @constructor
*/
new (options: any): NativeFlow;
}
interface NativeFlow extends Flow {
/**
* Run the Oauth flow, prompting the user to go to the authorization URL
* and enter the code it displays when finished.
*
* @return {Promise<Object>} The access token object, which will include
* `access_token` and `refresh_token`.
*/
run(): void;
/**
* @param {String} code An authorization code obtained via `asanaAuthorizeUrl`.
* @return {Promise<Object>} The token, which will include the `access_token`
* used for API access, as well as a `refresh_token` which can be stored
* to get a new access token without going through the flow again.
* @param code
*/
accessToken(code: string): void;
/**
* @return {Promise} The access token, which will include a refresh token
* that can be stored in the future to create a client without going
* through the Oauth flow.
* @param url
* @return
*/
promptForCode(url: string): any;
}
var ChromeExtensionFlow: ChromeExtensionFlowStatic;
interface ChromeExtensionFlowStatic extends FlowType {
/**
* An Oauth flow that runs in a Chrome browser extension and requests user
* authorization by opening a temporary tab to prompt the user.
* @param {Object} options See `BaseBrowserFlow` for options, plus the below:
* @options {String} [receiverPath] Full path and filename from the base
* directory of the extension to the receiver page. This is an HTML file
* that has been made web-accessible, and that calls the receiver method
* `Asana.auth.ChromeExtensionFlow.runReceiver();`.
* @constructor
*/
new (options: any): ChromeExtensionFlow;
}
interface ChromeExtensionFlow extends BaseBrowserFlow {
/**
* Runs the receiver code to send the Oauth result to the requesting tab.
*/
runReceiver(): void;
}
var BaseBrowserFlow: BaseBrowserFlowStatic;
interface BaseBrowserFlowStatic extends FlowType {
/**
* A base class for any flow that runs in the browser. All subclasses use the
* "implicit grant" flow to authenticate via the browser.
* @param {Object} options
* @option {App} app The app this flow is for
* @option {String} [redirectUri] The URL that Asana should redirect to once
* user authorization is complete. Defaults to the URL configured in
* the app, and if none then the current page URL.
* @constructor
*/
new (options: any): BaseBrowserFlow;
}
interface BaseBrowserFlow extends Flow {
/**
* @param {String} authUrl The URL the user should be navigated to in order
* to authorize the app.
* @param {String} state The unique state generated for this auth request.
* @return {Promise} Resolved when authorization has successfully started,
* i.e. the user has been navigated to a page requesting authorization.
* @param authUrl
* @param state
* @return
*/
startAuthorization(authUrl: string, state: string): any;
/**
* @return {Promise<Object>} Credentials returned from Oauth.
* @param state
*/
finishAuthorization(state: string): void;
/**
* @return {String} The URL to redirect to that will receive the
* @return
*/
receiverUrl(): string;
/**
* @return {String} The URL to redirect to that will receive the
* @return
*/
asanaBaseUrl(): string;
/**
* @returns {String} Generate a new unique state parameter for a request.
* @return
*/
getStateParam(): string;
}
interface FlowType {
new (options: any): Flow;
}
interface Flow {
/**
* @returns {String} The URL used to authorize the user for the app.
* @return
*/
authorizeUrl(): string;
/**
* Run the appropriate parts of the Oauth flow, attempting to establish user
* authorization.
* @returns {Promise<Object>} A promise that resolves to the Oauth credentials.
*/
run(): void;
}
}
namespace errors {
class AsanaError extends Error {
/**
* @param message
* @return
*/
constructor(message: any);
code: number;
value: any;
}
class Forbidden extends AsanaError {
/**
* @param value
* @return
*/
constructor(value: any);
}
class InvalidRequest extends AsanaError {
/**
* @param value
* @return
*/
constructor(value: any);
}
class NoAuthorization extends AsanaError {
/**
* @param value
* @return
*/
constructor(value: any);
}
class NotFound extends AsanaError {
/**
* @param value
* @return
*/
constructor(value: any);
}
class RateLimitEnforced extends AsanaError {
/**
* @param value
* @return
*/
constructor(value: any);
}
class ServerError extends AsanaError {
/**
* @param value
* @return
*/
constructor(value: any);
}
}
namespace resources {
interface AttachmentsStatic {
/**
* @param dispatcher
*/
new (dispatcher: Dispatcher): Attachments;
}
namespace Attachments {
interface Type extends Resource {
created_at: string;
permanent_url: string;
download_url: string;
view_url: string;
host: string;
parent: Resource;
}
}
var Attachments: AttachmentsStatic;
/**
* An _attachment_ object represents any file attached to a task in Asana,
* whether it's an uploaded file or one associated via a third-party service
* such as Dropbox or Google Drive.
* @class
* @param {Dispatcher} dispatcher The API dispatcher
*/
interface Attachments extends Resource {
/**
* * Returns the full record for a single attachment.
* * @param {Number} attachment Globally unique identifier for the attachment.
* * @param {Object} [params] Parameters for the request
* * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
* * @return {Promise} The requested resource
* @param attachment
* @param params?
* @param dispatchOptions?
* @return
*/
findById(attachment: number, params?: Params, dispatchOptions?: any): Promise<Attachments.Type>;
/**
* * Returns the compact records for all attachments on the task.
* * @param {Number} task Globally unique identifier for the task.
* * @param {Object} [params] Parameters for the request
* * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
* * @return {Promise} The response from the API
* @param task
* @param params?
* @param dispatchOptions?
* @return
*/
findByTask(task: number, params?: PaginationParams, dispatchOptions?: any): Promise<ResourceList<Attachments.Type>>;
}
interface EventsStatic {
/**
* @param dispatcher
* @return
*/
new (dispatcher: Dispatcher): Events;
}
var Events: EventsStatic;
/**
* An _event_ is an object representing a change to a resource that was observed
* by an event subscription.
*
* In general, requesting events on a resource is faster and subject to higher
* rate limits than requesting the resource itself. Additionally, change events
* bubble up - listening to events on a project would include when stories are
* added to tasks in the project, even on subtasks.
*
* Establish an initial sync token by making a request with no sync token.
* The response will be a `412` error - the same as if the sync token had
* expired.
*
* Subsequent requests should always provide the sync token from the immediately
* preceding call.
*
* Sync tokens may not be valid if you attempt to go 'backward' in the history
* by requesting previous tokens, though re-requesting the current sync token
* is generally safe, and will always return the same results.
*
* When you receive a `412 Precondition Failed` error, it means that the
* sync token is either invalid or expired. If you are attempting to keep a set
* of data in sync, this signals you may need to re-crawl the data.
*
* Sync tokens always expire after 24 hours, but may expire sooner, depending on
* load on the service.
* @class
* @param {Dispatcher} dispatcher The API dispatcher
*/
interface Events extends Resource { }
interface ProjectsStatic {
/**
* @param dispatcher
*/
new (dispatcher: Dispatcher): Projects;
}
namespace Projects {
interface Type extends Resource {
created_at: string;
modified_at: string;
due_date: string;
current_status: Status;
public: boolean;
archived: boolean;
notes: string;
color: string;
workspace: Resource;
team: Resource;
members: Resource[];
followers: Resource[];
}
interface CreateParams {
name?: string;
team?: number;
public?: boolean;
due_date: string;
notes?: string;
color?: string;
}
interface FollowersParams {
followers: (number|string)[];
}
interface MembersParams {
members: (number|string)[];
}
interface Status {
color: string;
text: string;
html_text: string;
modified_at: string;
author: Resource;
}
interface FindAllParams extends PaginationParams {
team?: number;
archived?: boolean;
}
interface FindByParams extends PaginationParams {
archived?: boolean;
}
}
var Projects: ProjectsStatic;
/**
* A _project_ represents a prioritized list of tasks in Asana. It exists in a
* single workspace or organization and is accessible to a subset of users in
* that workspace or organization, depending on its permissions.
*
* Projects in organizations are shared with a single team. You cannot currently
* change the team of a project via the API. Non-organization workspaces do not
* have teams and so you should not specify the team of project in a
* regular workspace.
* @class
* @param {Dispatcher} dispatcher The API dispatcher
*/
interface Projects extends Resource {
/**
* * Creates a new project in a workspace or team.
* *
* * Every project is required to be created in a specific workspace or
* * organization, and this cannot be changed once set. Note that you can use
* * the `workspace` parameter regardless of whether or not it is an
* * organization.
* *
* * If the workspace for your project _is_ an organization, you must also
* * supply a `team` to share the project with.
* *
* * Returns the full record of the newly created project.
* * @param {Object} data Data for the request
* * @param {String} data.workspace The workspace or organization to create the project in.
* * @param {String} [data.team] If creating in an organization, the specific team to create the
* * project in.
* * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
* * @return {Promise} The response from the API
* @param data
* @param dispatchOptions?
* @return
*/
create(data: Projects.CreateParams & { workspace: number }, dispatchOptions?: any): Promise<Projects.Type>;
/**
* * If the workspace for your project _is_ an organization, you must also
* * supply a `team` to share the project with.
* *
* * Returns the full record of the newly created project.
* * @param {Number} workspace The workspace or organization to create the project in.
* * @param {Object} data Data for the request
* * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
* * @return {Promise} The response from the API
* @param workspace
* @param data
* @param dispatchOptions?
* @return
*/
createInWorkspace(workspace: number, data: Projects.CreateParams, dispatchOptions?: any): Promise<Projects.Type>;
/**
* * Creates a project shared with the given team.
* *
* * Returns the full record of the newly created project.
* * @param {Number} team The team to create the project in.
* * @param {Object} data Data for the request
* * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
* * @return {Promise} The response from the API
* @param team
* @param data