From 1ad718c4c95735d849ad22d4a9bd9c76b4845d07 Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Sat, 30 Jul 2016 00:07:09 +0300 Subject: [PATCH 01/80] Added gulp-help-doc definitions --- gulp-help-doc/gulp-help-doc-tests.ts | 24 ++++++++++++ gulp-help-doc/gulp-help-doc.d.ts | 57 ++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 gulp-help-doc/gulp-help-doc-tests.ts create mode 100644 gulp-help-doc/gulp-help-doc.d.ts diff --git a/gulp-help-doc/gulp-help-doc-tests.ts b/gulp-help-doc/gulp-help-doc-tests.ts new file mode 100644 index 0000000000..6e69a88e5b --- /dev/null +++ b/gulp-help-doc/gulp-help-doc-tests.ts @@ -0,0 +1,24 @@ +/// +/// +/// + +import gulp = require('gulp'); +import usage = require('gulp-help-doc'); + +/** + * Demo task + * + * @task {demo} + * @arg {env} environment + */ +gulp.task('demo', function() {}); + +var logger = { + output: '', + log: msg => logger.output += msg + '\n' +}; + +usage(gulp, { + logger: logger, + gulpfile: __filename +}).then(() => console.log(logger.output)); diff --git a/gulp-help-doc/gulp-help-doc.d.ts b/gulp-help-doc/gulp-help-doc.d.ts new file mode 100644 index 0000000000..de2983b878 --- /dev/null +++ b/gulp-help-doc/gulp-help-doc.d.ts @@ -0,0 +1,57 @@ +// Type definitions for gulp-help-doc +// Project: https://github.com/Mikhus/gulp-help-doc +// Definitions by: Mikhus +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "gulp-help-doc" { + + import gulp = require('gulp'); + import promise = require('es6-promise'); + + namespace usage { + + interface UsageOptions { + /** + * Defines max line width for the printed output lines + * (by default is 80 characters long) + */ + lineWidth?: number, + + /** + * Defines max width of the column width tasks or args names + * (by default is 20 characters long) + */ + keysColumnWidth?: number, + + /** + * Defines number of empty characters for left-padding of the output + */ + padding?: number, + + /** + * Printing engine (by default is console). Accepted any device + * which has log() function defined to do output. + */ + logger?: { log: Function }, + + /** + * Path to a gulpfile (default is gulpfile.js) + * Normally, there is no need to change this option. It may be used + * for some special cases, like mocking gulpfile for testing. + */ + gulpfile?: string + } + + interface Usage { + (gulp: gulp.Gulp, options?: UsageOptions): promise.Promise + } + + } + + var usage: usage.Usage; + + export = usage; +} From 830ccbe8372172aca14a08ae041c2d0adc3ef6ff Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Sat, 30 Jul 2016 00:14:48 +0300 Subject: [PATCH 02/80] Fixed declaration and tests --- gulp-help-doc/gulp-help-doc-tests.ts | 5 ++++- gulp-help-doc/gulp-help-doc.d.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gulp-help-doc/gulp-help-doc-tests.ts b/gulp-help-doc/gulp-help-doc-tests.ts index 6e69a88e5b..a3eca8ecae 100644 --- a/gulp-help-doc/gulp-help-doc-tests.ts +++ b/gulp-help-doc/gulp-help-doc-tests.ts @@ -13,7 +13,10 @@ import usage = require('gulp-help-doc'); */ gulp.task('demo', function() {}); -var logger = { +let logger: { + output: string, + log(msg: string) +} = { output: '', log: msg => logger.output += msg + '\n' }; diff --git a/gulp-help-doc/gulp-help-doc.d.ts b/gulp-help-doc/gulp-help-doc.d.ts index de2983b878..a6c1377b26 100644 --- a/gulp-help-doc/gulp-help-doc.d.ts +++ b/gulp-help-doc/gulp-help-doc.d.ts @@ -5,11 +5,12 @@ /// /// +/// declare module "gulp-help-doc" { import gulp = require('gulp'); - import promise = require('es6-promise'); + import Promise = require('es6-promise'); namespace usage { From fb2f5a4e232995bcc3bb70c5a4d44eb0d7d5822b Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Sat, 30 Jul 2016 00:18:47 +0300 Subject: [PATCH 03/80] Fixed declaration and tests --- gulp-help-doc/gulp-help-doc-tests.ts | 2 +- gulp-help-doc/gulp-help-doc.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gulp-help-doc/gulp-help-doc-tests.ts b/gulp-help-doc/gulp-help-doc-tests.ts index a3eca8ecae..f06c25e55c 100644 --- a/gulp-help-doc/gulp-help-doc-tests.ts +++ b/gulp-help-doc/gulp-help-doc-tests.ts @@ -15,7 +15,7 @@ gulp.task('demo', function() {}); let logger: { output: string, - log(msg: string) + log(msg: string): any } = { output: '', log: msg => logger.output += msg + '\n' diff --git a/gulp-help-doc/gulp-help-doc.d.ts b/gulp-help-doc/gulp-help-doc.d.ts index a6c1377b26..aa15e1cf17 100644 --- a/gulp-help-doc/gulp-help-doc.d.ts +++ b/gulp-help-doc/gulp-help-doc.d.ts @@ -10,7 +10,7 @@ declare module "gulp-help-doc" { import gulp = require('gulp'); - import Promise = require('es6-promise'); + import promise = require('es6-promise'); namespace usage { From 214f14e2b350c0a36d701a370f1231172299edee Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Sat, 30 Jul 2016 00:21:06 +0300 Subject: [PATCH 04/80] Definition fixed --- gulp-help-doc/gulp-help-doc.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gulp-help-doc/gulp-help-doc.d.ts b/gulp-help-doc/gulp-help-doc.d.ts index aa15e1cf17..31aa0d764a 100644 --- a/gulp-help-doc/gulp-help-doc.d.ts +++ b/gulp-help-doc/gulp-help-doc.d.ts @@ -5,12 +5,10 @@ /// /// -/// declare module "gulp-help-doc" { import gulp = require('gulp'); - import promise = require('es6-promise'); namespace usage { @@ -47,7 +45,7 @@ declare module "gulp-help-doc" { } interface Usage { - (gulp: gulp.Gulp, options?: UsageOptions): promise.Promise + (gulp: gulp.Gulp, options?: UsageOptions): Promise } } From 8a623bc76e2462bc7b50467cb346fa4343711fa0 Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Sat, 30 Jul 2016 00:26:00 +0300 Subject: [PATCH 05/80] Declaration fixed --- gulp-help-doc/gulp-help-doc.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulp-help-doc/gulp-help-doc.d.ts b/gulp-help-doc/gulp-help-doc.d.ts index 31aa0d764a..80d4922774 100644 --- a/gulp-help-doc/gulp-help-doc.d.ts +++ b/gulp-help-doc/gulp-help-doc.d.ts @@ -45,7 +45,7 @@ declare module "gulp-help-doc" { } interface Usage { - (gulp: gulp.Gulp, options?: UsageOptions): Promise + (gulp: gulp.Gulp, options?: UsageOptions): Promise } } From f0990e288ac73d593e982995947567aa2643b828 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lachance Date: Fri, 5 Aug 2016 12:40:35 -0400 Subject: [PATCH 06/80] + Add mapObject in the _ChainOfArrays interface since it works fine on runtime --- underscore/underscore-tests.ts | 11 +++++++++++ underscore/underscore.d.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 26718207d8..951c41bf9f 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -505,6 +505,17 @@ function chain_tests() { var firstVal: number = _.chain([1, 2, 3]) .first() .value(); + + interface NumberObject { + property: string; + value: number; + } + let numberObjects: NumberObject[] = [{property: 'odd', value: 1}, {property: 'even', value: 2}, {property: 'even', value: 0}]; + let evenNumbers: NumberObject[][] = _.chain(numberObjects) + .groupBy('property') + .mapObject((objects: any) => _.sortBy(objects, (object: NumberObject) => object.value)) + .values() + .value(); } var obj: { [k: string] : number } = { diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 708d7a34d6..cb5dfaa393 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -5924,6 +5924,7 @@ interface _ChainSingle { } interface _ChainOfArrays extends _Chain { flatten(shallow?: boolean): _Chain; + mapObject(fn: _.ListIterator): _ChainOfArrays; } declare var _: UnderscoreStatic; From a6b3f7257a56d0f708ef8d76218c0c9da2ffe37f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lachance Date: Fri, 5 Aug 2016 13:47:59 -0400 Subject: [PATCH 07/80] * Simplify with a more explicit example --- underscore/underscore-tests.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 951c41bf9f..fd335b7361 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -506,16 +506,11 @@ function chain_tests() { .first() .value(); - interface NumberObject { - property: string; - value: number; - } - let numberObjects: NumberObject[] = [{property: 'odd', value: 1}, {property: 'even', value: 2}, {property: 'even', value: 0}]; - let evenNumbers: NumberObject[][] = _.chain(numberObjects) + let numberObjects = [{property: 'odd', value: 1}, {property: 'even', value: 2}, {property: 'even', value: 0}]; + let evenAndOddGroupedNumbers = _.chain(numberObjects) .groupBy('property') - .mapObject((objects: any) => _.sortBy(objects, (object: NumberObject) => object.value)) - .values() - .value(); + .mapObject((objects: any) => _.pluck(objects, 'value')) + .value(); // { odd: [1], even: [0, 2] } } var obj: { [k: string] : number } = { From 0d001a04a13ddc7d14c4163fbdb0af44ccda31e0 Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Mon, 8 Aug 2016 10:44:38 -0500 Subject: [PATCH 08/80] Started preliminary work on Twilio Node API typedefs. --- twilio/twilio-tests.ts | 17 ++++ twilio/twilio.d.ts | 213 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 twilio/twilio-tests.ts create mode 100644 twilio/twilio.d.ts diff --git a/twilio/twilio-tests.ts b/twilio/twilio-tests.ts new file mode 100644 index 0000000000..9af07e7c27 --- /dev/null +++ b/twilio/twilio-tests.ts @@ -0,0 +1,17 @@ +/// + +var str: string; + +const client = new twilio.RestClient(str, str); +const account = client.accounts(str); + +account.messages.post({ + body: str, + from: str, + to: str +}); + +account.sms.messages(str).get(function(err, data) { + // Do nothing +}); + diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts new file mode 100644 index 0000000000..69331e86ca --- /dev/null +++ b/twilio/twilio.d.ts @@ -0,0 +1,213 @@ +/// +/// + + +/// index.js +export class twilio extends RestClient { + constructor(sid?: string, tkn?: string, options?: ClientOptions); +} + +export namespace twilio { + + // Composite Classes: + //============================== + // RestClient + // PricingClient + // MonitorClient + // TaskRouterClient + // IpMessagingClient + // LookupsClient + // TrunkingClient + + // Classes: + //============================== + // AccessToken + // Capability + // TaskRouterCapability + // TaskRouterWorkerCapability + // TaskRouterWorkspaceCapability + // TaskRouterTaskQueueCapability + // TwimlResponse + // webhook + + // Methods: + //=============================== + // validateRequest + // validateExpressRequest +} + + +/// ??? +declare interface GrantPayload {} + +declare interface Grant { + toPayload(): GrantPayload; +} + +declare interface RequestCallback { (err: any, data: any, response: ): void } + +/// AccessToken.js +declare interface IpMessagingGrantOptions { + serviceSid: string; + endpointId: string; + deploymentRoleSid: string; + pushCredentialSid: string; +} + +declare interface IpMessagingGrantPayload extends GrantPayload { + service_sid: string; + endpoint_id: string; + deployment_role_sid: string; + push_credential_sid: string; +} + +declare class IpMessagingGrant implements Grant { + serviceSid: string; + endpointId: string; + deploymentRoleSid: string; + pushCredentialSid: string; + key: string; + + constructor(options?: IpMessagingGrantOptions); + + toPayload(): IpMessagingGrantPayload; +} + +declare interface ConversationsGrantOptions { + configurationProfileSid: string; +} + +declare interface ConversationsGrantPayload extends GrantPayload { + configuration_profile_sid: string; +} + +declare class ConversationsGrant implements Grant { + configurationProfileSid: string; + + constructor(options?: ConversationsGrantOptions); + + toPayload(): ConversationsGrantPayload; +} + +declare interface AccessTokenOptions { + ttl: number; + identity: string; + nbf: number; +} + +declare class AccessToken { + accountSid: string; + keySid: string; + secret: string; + ttl: number; + identity: string; + nbf: number; + grants: Array; + + static IpMessagingGrant: IpMessagingGrant; + static ConversationGrant: ConversationsGrant; + static DEFAULT_ALGORITHM: string; + static ALGORITHMS: Array; + + constructor(accountSid: string, keySid: string, secret: string, opts?: AccessTokenOptions); + + addGrant(grant: Grant): void; + toJwt(algorithm: string): any; // TODO Find correct typedef +} + +/// Capability.js +declare class Capability { + accountSid: string; + authToken: string; + capabilities: Array; + clientName: string; + outgoingScopeParams: any; + scopeParams: any; + + constructor(sid?: string, tkn?: string); + + allowClientIncoming(clientName: string): Capability; + allowClientOutgoing(appSid: string, params?: any): Capability; + allowEventStream(filters?: any): Capability; + generate(timeout?: number): string; +} + +/// Client.js +declare interface ClientOptions { + host?: string; + apiVersion?: string; + timeout?: number; +} + +declare interface ClientRequestOptions { + url: string; + form?: any; +} + +declare class Client { + accountSid: string; + authToken: string; + host: string; + apiVersion: string; + timeout: number; + + constructor(sid?: string, tkn?: string, host?: string, api_version?: string, timeout?: number); + + getBaseUrl(): string; + request(options: ClientRequestOptions, callback: RequestCallback): Q.Promise; +} + +/// IpMessagingClient.js +declare class IpMessagingClient extends Client { + services: ServiceResource; + credentials: CredentialsResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); +} + +/// LookupsClient.js +declare class LookupsClient extends Client { + phoneNumbers: PhoneNumbersResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); +} + +/// MonitorClient.js +declare class MonitorClient extends Client implements EventResource, AlertResource { + events: EventResource; + alerts: AlertResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); +} + +/// PricingClient.js +declare class PricingClient extends Client { + voice: VoiceResource; + phoneNumbers: PhoneNumbersResource; + messaging: MessagingResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); +} + +/// RestClient.js +declare class RestClient extends Client implements AccountResource { + accounts: AccountResource; + + // Messaging shorthand + // TODO Pull in proper method signatures here! + sendSms(); + sendMms(); + sendMessage(); + listSms(); + listMessages(); + getSms(messageSid: string, callback: (/* ??? */) => void): void; + getMessage(messageSid: string, callback: (/* ??? */) => void): void; + + // Calls shorthand + // TODO Pull in proper method signatures here! + makeCall(); + listCalls(); + getCall(callSid: string, callback: (/* ??? */) => void): void; + + request(options: ClientRequestOptions, callback: RequestCallback): Q.Promise; +} \ No newline at end of file From d0b1b909633503f1d061bf78f1c0d08200777ce9 Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Mon, 8 Aug 2016 16:48:38 -0500 Subject: [PATCH 09/80] Fleshed out more of Twilio Node API. --- twilio/twilio.d.ts | 1025 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 887 insertions(+), 138 deletions(-) diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index 69331e86ca..d3a3bda26b 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -1,11 +1,15 @@ +/// /// /// +import * as Http from 'http'; /// index.js +/* export class twilio extends RestClient { constructor(sid?: string, tkn?: string, options?: ClientOptions); } +*/ export namespace twilio { @@ -27,187 +31,932 @@ export namespace twilio { // TaskRouterWorkerCapability // TaskRouterWorkspaceCapability // TaskRouterTaskQueueCapability - // TwimlResponse + // TwimlResponse (TODO main export is generator function) // webhook // Methods: //=============================== // validateRequest // validateExpressRequest -} -/// ??? -declare interface GrantPayload {} -declare interface Grant { - toPayload(): GrantPayload; -} + /// ??? + export interface GrantPayload {} -declare interface RequestCallback { (err: any, data: any, response: ): void } + export interface Grant { + toPayload(): GrantPayload; + } -/// AccessToken.js -declare interface IpMessagingGrantOptions { - serviceSid: string; - endpointId: string; - deploymentRoleSid: string; - pushCredentialSid: string; -} + export interface RequestCallback { (err: any, data: any, response: Http.ClientResponse): void; } + export interface BaseRequestCallback { (err: any, data: any): void; } -declare interface IpMessagingGrantPayload extends GrantPayload { - service_sid: string; - endpoint_id: string; - deployment_role_sid: string; - push_credential_sid: string; -} + export interface RestMethod { (args: any | BaseRequestCallback, callback?: RequestCallback): Q.Promise; } -declare class IpMessagingGrant implements Grant { - serviceSid: string; - endpointId: string; - deploymentRoleSid: string; - pushCredentialSid: string; - key: string; + /// AccessToken.js + export interface IpMessagingGrantOptions { + serviceSid: string; + endpointId: string; + deploymentRoleSid: string; + pushCredentialSid: string; + } - constructor(options?: IpMessagingGrantOptions); + export interface IpMessagingGrantPayload extends GrantPayload { + service_sid: string; + endpoint_id: string; + deployment_role_sid: string; + push_credential_sid: string; + } - toPayload(): IpMessagingGrantPayload; -} + export class IpMessagingGrant implements Grant { + serviceSid: string; + endpointId: string; + deploymentRoleSid: string; + pushCredentialSid: string; + key: string; -declare interface ConversationsGrantOptions { - configurationProfileSid: string; -} + constructor(options?: IpMessagingGrantOptions); -declare interface ConversationsGrantPayload extends GrantPayload { - configuration_profile_sid: string; -} + toPayload(): IpMessagingGrantPayload; + } -declare class ConversationsGrant implements Grant { - configurationProfileSid: string; + export interface ConversationsGrantOptions { + configurationProfileSid: string; + } - constructor(options?: ConversationsGrantOptions); + export interface ConversationsGrantPayload extends GrantPayload { + configuration_profile_sid: string; + } - toPayload(): ConversationsGrantPayload; -} + export class ConversationsGrant implements Grant { + configurationProfileSid: string; -declare interface AccessTokenOptions { - ttl: number; - identity: string; - nbf: number; -} + constructor(options?: ConversationsGrantOptions); -declare class AccessToken { - accountSid: string; - keySid: string; - secret: string; - ttl: number; - identity: string; - nbf: number; - grants: Array; + toPayload(): ConversationsGrantPayload; + } - static IpMessagingGrant: IpMessagingGrant; - static ConversationGrant: ConversationsGrant; - static DEFAULT_ALGORITHM: string; - static ALGORITHMS: Array; + export interface AccessTokenOptions { + ttl: number; + identity: string; + nbf: number; + } - constructor(accountSid: string, keySid: string, secret: string, opts?: AccessTokenOptions); + export class AccessToken { + accountSid: string; + keySid: string; + secret: string; + ttl: number; + identity: string; + nbf: number; + grants: Array; - addGrant(grant: Grant): void; - toJwt(algorithm: string): any; // TODO Find correct typedef -} + static IpMessagingGrant: IpMessagingGrant; + static ConversationGrant: ConversationsGrant; + static DEFAULT_ALGORITHM: string; + static ALGORITHMS: Array; -/// Capability.js -declare class Capability { - accountSid: string; - authToken: string; - capabilities: Array; - clientName: string; - outgoingScopeParams: any; - scopeParams: any; + constructor(accountSid: string, keySid: string, secret: string, opts?: AccessTokenOptions); + + addGrant(grant: Grant): void; + toJwt(algorithm: string): any; // TODO Find correct typedef + } + + /// Capability.js + export class Capability { + accountSid: string; + authToken: string; + capabilities: Array; + clientName: string; + outgoingScopeParams: any; + scopeParams: any; + + constructor(sid?: string, tkn?: string); + + allowClientIncoming(clientName: string): Capability; + allowClientOutgoing(appSid: string, params?: any): Capability; + allowEventStream(filters?: any): Capability; + generate(timeout?: number): string; + } + + /// Client.js + export interface ClientOptions { + host?: string; + apiVersion?: string; + timeout?: number; + } + + export interface ClientRequestOptions { + url: string; + form?: any; + } + + export class Client { + accountSid: string; + authToken: string; + host: string; + apiVersion: string; + timeout: number; + + constructor(sid?: string, tkn?: string, host?: string, api_version?: string, timeout?: number); + + getBaseUrl(): string; + request(options: ClientRequestOptions, callback?: RequestCallback): Q.Promise; + } + + /// IpMessagingClient.js + export class IpMessagingClient extends Client { + services: ServiceResource; + credentials: CredentialResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); + } + + /// LookupsClient.js + export class LookupsClient extends Client { + phoneNumbers: PhoneNumberResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); + } + + /// MonitorClient.js + export class MonitorClient extends Client implements EventResource, AlertResource { + events: EventResource; + alerts: AlertResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); + } + + /// PricingClient.js + export class PricingClient extends Client { + voice: VoiceResource; + phoneNumbers: PhoneNumberResource; + messaging: MessagingResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); + } + + /// RestClient.js + export class RestClient extends Client implements AccountResource { + accounts: AccountResource; + + // Imported from AccountResource + availablePhoneNumbers: AvailablePhoneNumberResource; + outgoingCallerIds: OutgoingCallerIdResource; + incomingPhoneNumbers: IncomingPhoneNumberResource; + messages: MessageResource; + sms: SMSIntermediary; + applications: ApplicationResource; + connectApps: ConnectAppResource; + authorizedConnectApps: AuthorizedConnectAppResource; + calls: CallResource; + conferences: ConferenceResource; + queues: QueueResource; + recordings: RecordingResource; + tokens: TokenResource; + transcriptions: TranscriptionResource; + notifications: NotificationResource; + usage: UsageIntermediary; + sip: SIPIntermediary; + addresses: AddressResource; + keys: KeyResource; + + // Mixed-in Methods + put: RestMethod; + post: RestMethod; + get: RestMethod; + update: RestMethod; + list: RestMethod; + + // Messaging shorthand + // TODO Pull in proper method signatures here! + sendSms(); + sendMms(); + sendMessage(); + listSms(); + listMessages(); + getSms(messageSid: string, callback?: RequestCallback): Q.Promise; + getMessage(messageSid: string, callback?: RequestCallback): Q.Promise; + + // Calls shorthand + // TODO Pull in proper method signatures here! + makeCall(); + listCalls(); + getCall(callSid: string, callback?: RequestCallback): Q.Promise; + + // Overrides Client.request(...) + request(options: ClientRequestOptions, callback?: RequestCallback): Q.Promise; + } + + /// TaskRouterCapability.js + export interface QueryFilter { + // TODO Populate me! + } + + export interface PostFilter { + // TODO Populate me! + } + + export interface Policy { + url: string; + method: string; + query_filter?: QueryFilter; + post_filter?: PostFilter; + allow: boolean; + } + + export class TaskRouterCapability { + accountSid: string; + authToken: string; + policies: Array; + workspaceSid: string; + channelId: string; + + private _baseUrl: string; + private _resourceUrl: string; + + constructor(accountSid: string, authToken: string, workspaceSid: string, channelId: string); + + protected _setupResource(): void; + private _validateJWT(): void; + private _generate(ttl: number, extraAttributes: any): string; + + allowFetchSubresources(): void; + allowUpdates(): void; + allowUpdatesSubresources(): void; + allowDelete(): void; + allowDeleteSubresources(): void; + allowWorkerActivityUpdates(): void; + allowWorkerFetchAttributes(): void; + allowTaskReservationUpdates(): void; + + addPolicy(url: string, method: string, allowed?: boolean, queryFilter?: QueryFilter, postFilter?: PostFilter): void; + allow(url: string, method: string, queryFilter?: QueryFilter, postFilter?: PostFilter): void; + deny(url: string, method: string, queryFilter?: QueryFilter, postFilter?: PostFilter): void; + generate(ttl: number): string; + } + + /// TaskRouterClient.js + export class TaskRouterClient extends Client implements WorkspaceResource { + workspaces: WorkspaceResource; + workspace: WorkspaceResource; + + constructor(sid?: string, tkn?: string, workspaceSid?: string, options?: ClientOptions); + } + + /// TaskRouterTaskQueueCapability.js + export class TaskRouterTaskQueueCapability extends TaskRouterCapability { + constructor(accountSid: string, authToken: string, workspaceSid: string, taskQueueSid: string); + + protected _setupResource(): void; + } + + /// TaskRouterWorkerCapability.js + export class TaskRouterWorkerCapability extends TaskRouterCapability { + reservationsUrl: string; + activityUrl: string; + workerReservationsUrl: string; + + constructor(accountSid: string, authToken: string, workspaceSid: string, workerSid: string); + + protected _setupResource(): void; + + allowActivityUpdates(): void; + allowReservationUpdates(): void; + } + + /// TaskRouterWorkspaceCapability.js + export class TaskRouterWorkspaceCapability extends TaskRouterCapability { + constructor(accountSid: string, authToken: string, workspaceSid: string); + + protected _setupResource(): void; + } + + /// TrunkingClient.js + export class TrunkingClient extends Client { + trunks: TrunkResource; + + constructor(sid?: string, tkn?: string, options?: ClientOptions); + } + + /// TwimlResponse.js + // ???? - Someone else should look at this thing to make sure it's correct + export interface NodeOptions { + name: string; + attributes?: any; + text?: string; + topLevel?: boolean; + legalNodes: Array; + } + + export class Node implements NodeOptions { + name: string; + attributes: any; + text: any; + topLevel: boolean; + legalNodes: Array; + + constructor(config?: NodeOptions); + + toString(): string; + } + + export function TwimlResponse(): Node; + + /// webhook.js + export interface webhookOptions { + validate?: boolean; + includeHelpers?: boolean; + host?: string; + protocol?: string; + } + + export interface WebhookExpressOptions { + // The full URL (with query string) you used to configure the webhook with Twilio - overrides host/protocol options + url?: string; + + // manually specify the host name used by Twilio in a number's webhook config + host?: string; + + // manually specify the protocol used by Twilio in a number's webhook config + protocol?: string; + } + + // For interop with node middleware chains + export interface MiddlewareFunction { (request: Http.ClientRequest, response: Http.ClientResponse, next: MiddlewareFunction): void; } + + export function webhook(options?: string | webhookOptions): MiddlewareFunction; + + export function validateRequest(authToken: string, twilioHeader: string, url: string, params?: any): boolean; + export function validateExpressRequest(request: Express.Request, authToken: string, options?: WebhookExpressOptions): boolean; + + /// resources/Accounts.js + export interface OutgoingCallerIdInstance { + get: RestMethod; + post: RestMethod; + put: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface OutgoingCallerIdResource { + (resourceSid: string): OutgoingCallerIdInstance; + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + export interface SMSMessageInstance { + get: RestMethod; + } + + export interface SMSMessageResource { + (resourceSid: string): SMSMessageInstance; + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + export interface SMSShortCodeInstance { + get: RestMethod; + post: RestMethod; + update: RestMethod; + } + + export interface SMSShortCodeResource { + get: RestMethod; + } + + export interface SMSIntermediary { + messages: SMSMessageResource; + shortCodes: SMSShortCodeResource; + } + + export interface ApplicationInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface ApplicationResource { + (resourceSid: string): ApplicationInstance; + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + export interface ConnectAppInstance { + get: RestMethod; + post: RestMethod; + update: RestMethod; + } + + export interface ConnectAppResource { + (resourceSid: string): ConnectAppInstance; + get: RestMethod; + } + + export interface AuthorizedConnectAppInstance { + get: RestMethod; + } + + export interface AuthorizedConnectAppResource { + (resourceSid: string): AuthorizedConnectAppInstance; + get: RestMethod; + } + + export interface TokenInstance {} + + export interface TokenResource { + (resourceSid: string): TokenInstance; + post: RestMethod; + create: RestMethod; + } + + export interface TranscriptionInstance { + get: RestMethod; + delete: RestMethod; + } + + export interface TranscriptionResource { + (resourceSid: string): TranscriptionInstance; + get: RestMethod; + } + + export interface NotificationInstance { + get: RestMethod; + delete: RestMethod; + } + + export interface NotificationResource { + (resourceSid: string): NotificationInstance; + get: RestMethod; + } + + export interface UsageTriggerInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface UsageTriggerResource { + (resourceSid: string): UsageTriggerInstance; + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + export interface UsageIntermediary { + records: UsageRecordResource; + triggers: UsageTriggerResource; + } + + export interface SIPIntermediary { + domains: SIPDomainResource; + ipAccessControlLists: SIPIPAccessControlListResource; + credentialLists: SIPCredentialListResource; + } + + export interface KeyInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface KeyResource { + (resourceSid: string): KeyInstance; + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + export interface AccountResource { + (accountSid: string): AccountResource; + + // Mixed-in resources + availablePhoneNumbers: AvailablePhoneNumberResource; + outgoingCallerIds: OutgoingCallerIdResource; + incomingPhoneNumbers: IncomingPhoneNumberResource; + messages: MessageResource; + sms: SMSIntermediary; + applications: ApplicationResource; + connectApps: ConnectAppResource; + authorizedConnectApps: AuthorizedConnectAppResource; + calls: CallResource; + conferences: ConferenceResource; + queues: QueueResource; + recordings: RecordingResource; + tokens: TokenResource; + transcriptions: TranscriptionResource; + notifications: NotificationResource; + usage: UsageIntermediary; + sip: SIPIntermediary; + addresses: AddressResource; + keys: KeyResource; + + // Mixed-in Methods + put: RestMethod; + post: RestMethod; + get: RestMethod; + update: RestMethod; + list: RestMethod; + } + + /// resources/Addresses.js + export interface DependentPhoneNumberResource { + get: RestMethod; + list: RestMethod; + } + + export interface AddressInstance { + // Mixins + dependentPhoneNumbers: DependentPhoneNumberResource; + + // Rest Methods + get: RestMethod; + post: RestMethod; + delete: RestMethod; + } + + export interface AddressResource { + (resourceSid: string): AddressInstance; + get: RestMethod; + list: RestMethod; + post: RestMethod; + create: RestMethod; + } + + /// resources/AvailablePhoneNumbers.js + export interface AvailablePhoneNumberResourceGroup { + get: RestMethod; + list: RestMethod; + search: RestMethod; + } - constructor(sid?: string, tkn?: string); + export interface AvailablePhoneNumberInstance { + local: AvailablePhoneNumberResourceGroup; + tollFree: AvailablePhoneNumberResourceGroup; + mobile: AvailablePhoneNumberResourceGroup; + } - allowClientIncoming(clientName: string): Capability; - allowClientOutgoing(appSid: string, params?: any): Capability; - allowEventStream(filters?: any): Capability; - generate(timeout?: number): string; -} + export interface AvailablePhoneNumberResource { + (isoCode: string): AvailablePhoneNumberInstance; + } -/// Client.js -declare interface ClientOptions { - host?: string; - apiVersion?: string; - timeout?: number; -} + /// resources/Calls.js + export interface CallRecordingResource { + get: RestMethod; + list: RestMethod; + } -declare interface ClientRequestOptions { - url: string; - form?: any; -} + export interface CallNotificationResource { + get: RestMethod; + list: RestMethod; + } -declare class Client { - accountSid: string; - authToken: string; - host: string; - apiVersion: string; - timeout: number; + export interface CallFeedbackResource { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + create: RestMethod; + } - constructor(sid?: string, tkn?: string, host?: string, api_version?: string, timeout?: number); + export interface CallInstance { + recordings: CallRecordingResource; + notifications: CallNotificationResource; + feedback: CallFeedbackResource; - getBaseUrl(): string; - request(options: ClientRequestOptions, callback: RequestCallback): Q.Promise; -} + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } -/// IpMessagingClient.js -declare class IpMessagingClient extends Client { - services: ServiceResource; - credentials: CredentialsResource; + export interface CallFeedbackSummaryInstance { + get: RestMethod; + delete: RestMethod; + } - constructor(sid?: string, tkn?: string, options?: ClientOptions); -} + export interface CallFeedbackSummaryResource { + (resourceSid: string): CallFeedbackSummaryInstance; + post: RestMethod; + create: RestMethod; + } -/// LookupsClient.js -declare class LookupsClient extends Client { - phoneNumbers: PhoneNumbersResource; + export interface CallResource { + (resourceSid: string): CallInstance; - constructor(sid?: string, tkn?: string, options?: ClientOptions); -} + get: RestMethod; + post: RestMethod; + create: RestMethod; -/// MonitorClient.js -declare class MonitorClient extends Client implements EventResource, AlertResource { - events: EventResource; - alerts: AlertResource; + feedbackSummary: CallFeedbackSummaryResource; + } - constructor(sid?: string, tkn?: string, options?: ClientOptions); -} + /// resources/Conferences.js + export interface ConferenceParticipantInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + kick: RestMethod; + } -/// PricingClient.js -declare class PricingClient extends Client { - voice: VoiceResource; - phoneNumbers: PhoneNumbersResource; - messaging: MessagingResource; + export interface ConferenceParticipantResource { + (resourceSid: string): ConferenceParticipantInstance; - constructor(sid?: string, tkn?: string, options?: ClientOptions); -} + get: RestMethod; + list: RestMethod; + } -/// RestClient.js -declare class RestClient extends Client implements AccountResource { - accounts: AccountResource; + export interface ConferenceInstance { + get: RestMethod; - // Messaging shorthand - // TODO Pull in proper method signatures here! - sendSms(); - sendMms(); - sendMessage(); - listSms(); - listMessages(); - getSms(messageSid: string, callback: (/* ??? */) => void): void; - getMessage(messageSid: string, callback: (/* ??? */) => void): void; + participants: ConferenceParticipantResource; + } - // Calls shorthand - // TODO Pull in proper method signatures here! - makeCall(); - listCalls(); - getCall(callSid: string, callback: (/* ??? */) => void): void; + export interface ConferenceResource { + (resourceSid: string): ConferenceInstance; - request(options: ClientRequestOptions, callback: RequestCallback): Q.Promise; + get: RestMethod; + list: RestMethod; + } + + /// resources/IncomingPhoneNumbers.js + export interface IncomingPhoneNumberResourceGroup { + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + export interface IncomingPhoneNumberInstance { + get: RestMethod; + post: RestMethod; + put: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface IncomingPhoneNumberResource { + (resourceSid: string): IncomingPhoneNumberInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + + local: IncomingPhoneNumberResourceGroup; + tollFree: IncomingPhoneNumberResourceGroup; + mobile: IncomingPhoneNumberResourceGroup; + } + + /// resources/Messages.js + export interface MessageMediaInstance { + get: RestMethod; + delete: RestMethod; + } + + export interface MessageMediaResource { + (resourceSid: string): MessageMediaInstance; + + get: RestMethod; + list: RestMethod; + } + + export interface MessageInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + + media: MessageMediaResource; + } + + export interface MessageResource { + (resourceSid: string): MessageInstance; + + get: RestMethod; + list: RestMethod; + post: RestMethod; + create: RestMethod; + } + + /// resources/Queues.js + export interface QueueMemberInstance { + get: RestMethod; + post: RestMethod; + update: RestMethod; + } + + export interface QueueMemberResource { + (resourceSid: string): QueueMemberInstance; + + get: RestMethod; + + front: QueueMemberInstance; + } + + export interface QueueInstance { + members: QueueMemberResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface QueueResource { + (resourceSid: string): QueueInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + /// resources/Recordings.js + export interface RecordingTranscriptionResource { + get: RestMethod; + list: RestMethod; + } + + export interface RecordingInstance { + get: RestMethod; + list: RestMethod; + delete: RestMethod; + + transcriptions: RecordingTranscriptionResource; + } + + export interface RecordingResource { + (resourceSid: string): RecordingInstance; + + get: RestMethod; + list: RestMethod; + } + + /// resources/UsageRecords.js + export interface UsageRecordInstance { + get: RestMethod; + } + + export interface UsageRecordRange { + get: RestMethod; + list: RestMethod; + } + + export interface UsageRecordResource { + (resourceSid: string): UsageRecordInstance; + + get: RestMethod; + + daily: UsageRecordRange; + monthly: UsageRecordRange; + yearly: UsageRecordRange; + allTime: UsageRecordRange; + today: UsageRecordRange; + yesterday: UsageRecordRange; + thisMonth: UsageRecordRange; + lastMonth: UsageRecordRange; + } + + /// resources/ip_messaging/Credentials.js + export interface CredentialInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface CredentialResource { + (resourceSid: string): CredentialInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + /// resources/ip_messaging/Services.js + export interface ServiceUserInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface ServiceUserResource { + (resourceSid: string): ServiceUserInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + export interface ServiceRoleInstance { + get: RestMethod; + } + + export interface ServiceRoleResource { + (resourceSid: string): ServiceRoleInstance; + + get: RestMethod; + list: RestMethod; + } + + export interface ServiceChannelMessageInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface ServiceChannelMessageResource { + (resourceSid: string): ServiceChannelMessageInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + export interface ServiceChannelMemberInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface ServiceChannelMemberResource { + (resourceSid: string): ServiceChannelMemberInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + export interface ServiceChannelInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + + messages: ServiceChannelMessageResource; + members: ServiceChannelMemberResource; + } + + export interface ServiceChannelResource { + (resourceSid: string): ServiceChannelInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + export interface ServiceInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + + users: ServiceUserResource; + roles: ServiceRoleResource; + channels: ServiceChannelResource; + } + + export interface ServiceResource { + (resourceSid: string): ServiceInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + /// resources/lookups/PhoneNumbers.js + export interface PhoneNumberInstance { + get: RestMethod; + } + + export interface PhoneNumberResource { + (resourceSid: string): PhoneNumberInstance; + } + + /// resources/monitor/Alerts.js + export interface AlertInstance { + get: RestMethod; + } + + export interface AlertResource { + (resourceSid: string): AlertInstance; + + get: RestMethod; + list: RestMethod; + } + + /// resources/monitor/Events.js + } \ No newline at end of file From b1af25b5d5fb030cbe2be30c26564b8d5998ae84 Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Mon, 8 Aug 2016 17:36:27 -0500 Subject: [PATCH 10/80] Added a few more files. --- twilio/twilio.d.ts | 223 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 220 insertions(+), 3 deletions(-) diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index d3a3bda26b..f901dae3ee 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -514,9 +514,9 @@ export namespace twilio { } export interface SIPIntermediary { - domains: SIPDomainResource; - ipAccessControlLists: SIPIPAccessControlListResource; - credentialLists: SIPCredentialListResource; + domains: DomainResource; + ipAccessControlLists: IPAccessControlListResource; + credentialLists: CredentialListResource; } export interface KeyInstance { @@ -958,5 +958,222 @@ export namespace twilio { } /// resources/monitor/Events.js + export interface EventInstance { + get: RestMethod; + } + + export interface EventResource { + (resourceSid: string): EventInstance; + + get: RestMethod; + list: RestMethod; + } + + /// resources/pricing/Messaging.js + export interface CountryInstance { + get: RestMethod; + } + + export interface CountryResource { + (resourceSid: string): CountryInstance; + + get: RestMethod; + list: RestMethod; + } + + export interface MessagingResource { + countries: CountryResource; + } + + /// resources/pricing/PhoneNumbers.js + export interface PhoneNumberResource { + countries: CountryResource; + } + + /// resources/pricing/Voice.js + export interface NumberInstance { + get: RestMethod; + } + + export interface NumberResource { + (resourceSid: string): NumberInstance; + + get: RestMethod; + list: RestMethod; + } + + export interface VoiceResource { + countries: CountryResource; + numbers: NumberResource; + } + + /// resources/sip/CredentialLists.js + export interface CredentialListInstance { + credentials: CredentialResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface CredentialListResource { + (resourceSid: string): CredentialListInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + /// resources/sip/Domains.js + export interface IPAccessControlListMappingInstance { + get: RestMethod; + delete: RestMethod; + } + + export interface IPAccessControlListMappingResource { + (resourceSid: string): IPAccessControlListMappingInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + export interface CredentialListMappingInstance { + get: RestMethod; + delete: RestMethod; + } + + export interface CredentialListMappingResource { + (resourceSid: string): CredentialListMappingInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + export interface DomainInstance { + ipAccessControlListMappings: IPAccessControlListMappingResource; + credentialListMappings: CredentialListMappingResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface DomainResource { + (resourceSid: string): DomainInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + /// resources/sip/IpAccessControlLists.js + export interface IPAddressInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface IPAddressResource { + (resourceSid: string): IPAddressInstance; + + get: RestMethod; + post: RestMethod; + list: RestMethod; + create: RestMethod; + } + + export interface IPAccessControlListInstance { + ipAddresses: IPAddressResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface IPAccessControlListResource { + (resourceSid: string): IPAccessControlListInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + /// resources/task_router/WorkflowBuilder.js + export interface WorkflowRuleTargetOptions { + queue: string; + expression?: string; + priority?: number; + timeout?: number; + } + + export class WorkflowRuleTarget { + queue: string; + expression: string; + priority: number; + timeout: number; + + constructor(options?: WorkflowRuleTargetOptions); + } + + export interface WorkflowRuleOptions { + expression: string; + targets: Array; + // Don't ask me why, but all of these are supported options. + friendly_name?: string; + friendlyName?: string; + filter_friendly_name?: string; + } + + export class WorkflowRule { + friendly_name: string; + expression: string; + targets: Array; + friendlyName: string; // Defined property mapped to friendly_name. + + constructor(options?: WorkflowRuleOptions); + } + + export interface TaskRoutingConfigurationOptions { + filters: Array; + default_filter?: WorkflowRuleOptions; + defaultFilter?: WorkflowRuleOptions; + } + + export class TaskRoutingConfiguration { + filters: Array; + default_filter: WorkflowRuleOptions; + defaultFilter: WorkflowRuleOptions; // Defined property mapped to default_filter. + + constructor(options?: TaskRoutingConfigurationOptions); + } + + export interface WorkflowConfigurationOptions { + task_routing?: TaskRoutingConfigurationOptions; + taskRouting?: TaskRoutingConfigurationOptions; + } + + export class WorkflowConfiguration { + task_routing: TaskRoutingConfiguration; + taskRouting: TaskRoutingConfiguration; // Defined property mapped to task_routing. + + constructor(options?: WorkflowConfigurationOptions); + + static fromJSON(json: string): WorkflowConfiguration; + toJSON(): string; + } + + /// resources/task_router/Workspaces.js + } \ No newline at end of file From 35e7542be42b28c32370d730fb29f3b8658cfb77 Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Mon, 8 Aug 2016 18:45:51 -0500 Subject: [PATCH 11/80] Tweaks to eliminate unnecessary cruft. --- twilio/twilio.d.ts | 246 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 219 insertions(+), 27 deletions(-) diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index f901dae3ee..f2600a2ed8 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -39,8 +39,6 @@ export namespace twilio { // validateRequest // validateExpressRequest - - /// ??? export interface GrantPayload {} @@ -180,7 +178,7 @@ export namespace twilio { } /// MonitorClient.js - export class MonitorClient extends Client implements EventResource, AlertResource { + export class MonitorClient extends Client { events: EventResource; alerts: AlertResource; @@ -197,7 +195,9 @@ export namespace twilio { } /// RestClient.js - export class RestClient extends Client implements AccountResource { + export class RestClient extends Client { + constructor(sid?: string, tkn?: string, options?: ClientOptions); + accounts: AccountResource; // Imported from AccountResource @@ -229,19 +229,17 @@ export namespace twilio { list: RestMethod; // Messaging shorthand - // TODO Pull in proper method signatures here! - sendSms(); - sendMms(); - sendMessage(); - listSms(); - listMessages(); + sendSms: RestMethod; + sendMms: RestMethod; + sendMessage: RestMethod; + listSms: RestMethod; + listMessages: RestMethod; getSms(messageSid: string, callback?: RequestCallback): Q.Promise; getMessage(messageSid: string, callback?: RequestCallback): Q.Promise; // Calls shorthand - // TODO Pull in proper method signatures here! - makeCall(); - listCalls(); + makeCall(): RestMethod; + listCalls(): RestMethod; getCall(callSid: string, callback?: RequestCallback): Q.Promise; // Overrides Client.request(...) @@ -249,19 +247,12 @@ export namespace twilio { } /// TaskRouterCapability.js - export interface QueryFilter { - // TODO Populate me! - } - - export interface PostFilter { - // TODO Populate me! - } export interface Policy { url: string; method: string; - query_filter?: QueryFilter; - post_filter?: PostFilter; + query_filter?: any; // Map, where FilterRequirement ::= Map + post_filter?: any; // Map, where FilterRequirement ::= Map allow: boolean; } @@ -290,14 +281,14 @@ export namespace twilio { allowWorkerFetchAttributes(): void; allowTaskReservationUpdates(): void; - addPolicy(url: string, method: string, allowed?: boolean, queryFilter?: QueryFilter, postFilter?: PostFilter): void; - allow(url: string, method: string, queryFilter?: QueryFilter, postFilter?: PostFilter): void; - deny(url: string, method: string, queryFilter?: QueryFilter, postFilter?: PostFilter): void; + addPolicy(url: string, method: string, allowed?: boolean, queryFilter?: any, postFilter?: any): void; + allow(url: string, method: string, queryFilter?: any, postFilter?: any): void; + deny(url: string, method: string, queryFilter?: any, postFilter?: any): void; generate(ttl: number): string; } /// TaskRouterClient.js - export class TaskRouterClient extends Client implements WorkspaceResource { + export class TaskRouterClient extends Client { workspaces: WorkspaceResource; workspace: WorkspaceResource; @@ -1174,6 +1165,207 @@ export namespace twilio { } /// resources/task_router/Workspaces.js - + export interface WorkspaceActivityInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface WorkspaceActivityResource { + (resourceSid: string): WorkspaceActivityInstance; + + get: RestMethod; + post: RestMethod; + list: RestMethod; + create: RestMethod; + } + + export interface WorkspaceEventInstance { + get: RestMethod; + } + + export interface WorkspaceEventResource { + (resourceSid: string): WorkspaceEventInstance; + + get: RestMethod; + list: RestMethod; + } + + export interface WorkspaceTaskReservationInstance { + get: RestMethod; + post: RestMethod; + update: RestMethod; + } + + export interface WorkspaceTaskReservationResource { + (resourceSid: string): WorkspaceTaskReservationInstance; + + get: RestMethod; + list: RestMethod; + } + + export interface WorkspaceTaskInstance { + reservations: WorkspaceTaskReservationResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface WorkspaceTaskResource { + (resourceSid: string): WorkspaceTaskInstance; + + get: RestMethod; + post: RestMethod; + list: RestMethod; + create: RestMethod; + } + + export interface WorkspaceInstanceStatisticResource { + get: RestMethod; + } + + export interface WorkspaceStatisticResource { + get: RestMethod; + list: RestMethod; + } + + export interface WorkspaceTaskQueueInstance { + statistics: WorkspaceInstanceStatisticResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface WorkspaceTaskQueueResource { + (resourceSid: string): WorkspaceTaskQueueInstance; + + statistics: WorkspaceStatisticResource; + + get: RestMethod; + post: RestMethod; + list: RestMethod; + create: RestMethod; + } + + export interface WorkspaceWorkerReservationInstance { + get: RestMethod; + post: RestMethod; + update: RestMethod; + } + + export interface WorkspaceWorkerReservationResource { + (resourceSid: string): WorkspaceWorkerReservationInstance; + + get: RestMethod; + list: RestMethod; + } + + export interface WorkspaceWorkerInstance { + statistics: WorkspaceInstanceStatisticResource; + reservations: WorkspaceWorkerReservationResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface WorkspaceWorkerResource { + (resourceSid: string): WorkspaceWorkerInstance; + + statistics: WorkspaceStatisticResource; + + get: RestMethod; + post: RestMethod; + list: RestMethod; + create: RestMethod; + } + + export interface WorkspaceWorkflowInstance { + statistics: WorkspaceInstanceStatisticResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface WorkspaceWorkflowResource { + (resourceSid: string): WorkspaceWorkflowInstance; + + statistics: WorkspaceStatisticResource; + + get: RestMethod; + post: RestMethod; + list: RestMethod; + create: RestMethod; + } + + export interface WorkspaceInstance { + activities: WorkspaceActivityResource; + events: WorkspaceEventResource; + tasks: WorkspaceTaskResource; + taskQueues: WorkspaceTaskQueueResource; + workers: WorkspaceWorkerResource; + workflows: WorkspaceWorkflowResource; + + statistics: WorkspaceInstanceStatisticResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface WorkspaceResource { + (resourceSid: string): WorkspaceInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + } + + /// resources/trunking/Trunks.js + export interface OriginationURLInstance { + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface OriginationURLResource { + (resourceSid: string): OriginationURLInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } + + export interface TrunkInstance { + ipAccessControlLists: IPAccessControlListResource; + credentialLists: CredentialListResource; + phoneNumbers: PhoneNumberResource; + originationUrls: OriginationURLResource; + + get: RestMethod; + post: RestMethod; + delete: RestMethod; + update: RestMethod; + } + + export interface TrunkResource { + (resourceSid: string): TrunkInstance; + + get: RestMethod; + post: RestMethod; + create: RestMethod; + list: RestMethod; + } } \ No newline at end of file From 0d0133104dff056cbba9a3677efbdd130175b3ab Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Mon, 8 Aug 2016 19:04:30 -0500 Subject: [PATCH 12/80] Tweaks to try and get this working. --- twilio/twilio-tests.ts | 2 ++ twilio/twilio.d.ts | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/twilio/twilio-tests.ts b/twilio/twilio-tests.ts index 9af07e7c27..f73fcc231b 100644 --- a/twilio/twilio-tests.ts +++ b/twilio/twilio-tests.ts @@ -1,5 +1,7 @@ /// +import twilio = require('twilio'); + var str: string; const client = new twilio.RestClient(str, str); diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index f2600a2ed8..e99e4c508f 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -1,17 +1,15 @@ +// Type definitions for twilio +// Project: https://github.com/twilio/twilio-node +// Definitions by: nickiannone +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + /// /// /// import * as Http from 'http'; -/// index.js -/* -export class twilio extends RestClient { - constructor(sid?: string, tkn?: string, options?: ClientOptions); -} -*/ - -export namespace twilio { +declare module twilio { // Composite Classes: //============================== @@ -352,7 +350,7 @@ export namespace twilio { toString(): string; } - export function TwimlResponse(): Node; + function TwimlResponse(): Node; /// webhook.js export interface webhookOptions { @@ -376,10 +374,10 @@ export namespace twilio { // For interop with node middleware chains export interface MiddlewareFunction { (request: Http.ClientRequest, response: Http.ClientResponse, next: MiddlewareFunction): void; } - export function webhook(options?: string | webhookOptions): MiddlewareFunction; + function webhook(options?: string | webhookOptions): MiddlewareFunction; - export function validateRequest(authToken: string, twilioHeader: string, url: string, params?: any): boolean; - export function validateExpressRequest(request: Express.Request, authToken: string, options?: WebhookExpressOptions): boolean; + function validateRequest(authToken: string, twilioHeader: string, url: string, params?: any): boolean; + function validateExpressRequest(request: Express.Request, authToken: string, options?: WebhookExpressOptions): boolean; /// resources/Accounts.js export interface OutgoingCallerIdInstance { From 215e13547ef0c5185b54c8c4f0f0310f2965479e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vlado=20Te=C5=A1anovi=C4=87?= Date: Tue, 9 Aug 2016 11:26:43 +0200 Subject: [PATCH 13/80] adding jsonschema --- jsonschema/jsonschema.d.ts | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 jsonschema/jsonschema.d.ts diff --git a/jsonschema/jsonschema.d.ts b/jsonschema/jsonschema.d.ts new file mode 100644 index 0000000000..2d52fb978e --- /dev/null +++ b/jsonschema/jsonschema.d.ts @@ -0,0 +1,114 @@ +// Type definitions for jsonschema +// Project: https://github.com/tdegrunt/jsonschema +// Definitions by: Vlado Tešanovic https://github.com/vladotesanovic +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare module "jsonschema" { + + export interface IJSONSchemaResult { + errors: Array; + instance: any; + arguments: Array<{}>; + propertyPath: string; + name: string; + schema: {}; + throwError: any; + disableFormat: boolean; + } + + export interface IJSONSchemaValidationError { + message: string; + property: string; + stack: string; + schema: {}; + name: string; + instance: any; + argument: {}; + } + + export interface IJSONSchemaOptions { + propertyName?: string; + base?: string; + } + + /** + * How to; + * + * const v: Validator = new Validator(); + * + * const schema: {} = { + * "type": "object", + * "properties": { + * "key": { + * "type": "string", + * "required": true + * }, + * "value": { + * "type": "string", + * "required": true + * } + * } + * }; + * + * const validationResults: { errors: Array } = + * v.validate({ key: "Name", value: "A10" }, {"type": "string"}); + * + */ + export class Validator { + + /** + * Creates a new Validator object + * @name Validator + * @constructor + */ + new(): this; + + /** + * Validates instance against the provided schema + * @param instance + * @param schema + * @param [options] + * @param [ctx] + * @return {Array} + */ + validate(instance: any, schema: {}, options?: IJSONSchemaOptions, ctx?: {}): IJSONSchemaResult; + + /** + * Adds a schema with a certain urn to the Validator instance. + * @param schema + * @param urn + * @return {Object} + */ + addSchema(schema: {}, urn: string): {}; + + /** + * Add Sub schema to existing one + * @param baseuri + * @param schema + */ + addSubSchema(baseuri: string, schema: {}): {} + + /** + * Sets all the schemas of the Validator instance. + * @param schemas + */ + setSchemas (schemas: Array<{}>): void; + + /** + * Returns the schema of a certain urn + * @param urn + */ + getSchema(urn: string): {}; + + /** + * Validates an instance against the schema (the actual work horse) + * @param instance + * @param schema + * @param options + * @param ctx + * @private + * @return {IJSONSchemaResult} + */ + validateSchema(instance: any, schema: {}, options?: {}, ctx?: {}): IJSONSchemaResult + } +} + From bc8fffa7503af4aefe9886f0757a9b50c6fab498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vlado=20Te=C5=A1anovi=C4=87?= Date: Tue, 9 Aug 2016 11:36:57 +0200 Subject: [PATCH 14/80] Tests added --- jsonschema/jsonschema-tests.ts | 6 ++++++ jsonschema/jsonschema.d.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 jsonschema/jsonschema-tests.ts diff --git a/jsonschema/jsonschema-tests.ts b/jsonschema/jsonschema-tests.ts new file mode 100644 index 0000000000..e8acc29886 --- /dev/null +++ b/jsonschema/jsonschema-tests.ts @@ -0,0 +1,6 @@ +/// +import { Validator, IJSONSchemaValidationError } from "jsonschema"; + +const v: Validator = new Validator(); + +const validationResults: { errors: Array } = v.validate("Smith", {"type": "string"}); diff --git a/jsonschema/jsonschema.d.ts b/jsonschema/jsonschema.d.ts index 2d52fb978e..9e32dbfded 100644 --- a/jsonschema/jsonschema.d.ts +++ b/jsonschema/jsonschema.d.ts @@ -1,6 +1,6 @@ // Type definitions for jsonschema // Project: https://github.com/tdegrunt/jsonschema -// Definitions by: Vlado Tešanovic https://github.com/vladotesanovic +// Definitions by: Vlado Tešanovic // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "jsonschema" { From 920cfea632211109539d81900d99b22e398db3f2 Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Tue, 9 Aug 2016 10:35:47 -0500 Subject: [PATCH 15/80] Fixed importing and added examples from twilio-node as tests. --- twilio/twilio-tests.ts | 234 +++++++++++++++++++++++++++++++++++++++-- twilio/twilio.d.ts | 43 +++++++- 2 files changed, 263 insertions(+), 14 deletions(-) diff --git a/twilio/twilio-tests.ts b/twilio/twilio-tests.ts index f73fcc231b..20e60242aa 100644 --- a/twilio/twilio-tests.ts +++ b/twilio/twilio-tests.ts @@ -1,19 +1,233 @@ -/// +import { twilio } from './twilio'; -import twilio = require('twilio'); +// Examples taken from https://twilio.github.io/twilio-node/ (v2.1.0) var str: string; -const client = new twilio.RestClient(str, str); -const account = client.accounts(str); +// Create a client: +var client = require('twilio')('ACCOUNT_SID', 'AUTH_TOKEN'); -account.messages.post({ - body: str, - from: str, - to: str +//Get a list of calls made by this account +// GET /2010-04-01/Accounts/ACCOUNT_SID/Calls +// alias for get is "list", if you prefer +client.calls.get(function(err, response) { + response.calls.forEach(function(call) { + console.log('Received call from: ' + call.from); + console.log('Call duration (in seconds): ' + call.duration); + }); }); -account.sms.messages(str).get(function(err, data) { - // Do nothing +//Get a list of calls made by this account, from this phone number +// GET /2010-04-01/Accounts/ACCOUNT_SID/Calls?From=+16513334455 +client.calls.get({ + from:'+16513334455' +}, function(err, response) { + response.calls.forEach(function(call) { + console.log('Received call from: ' + call.from); + console.log('This call\'s unique ID is: ' + call.sid); + }); }); +//Get data for a specific call +// GET /2010-04-01/Accounts/ACCOUNT_SID/Calls/abc123... +client.calls('abc123...').get(function(err, call) { + console.log('This call\'s unique ID is: ' + call.sid); + console.log('This call was created at: ' + call.dateCreated); +}); + +//Get data for a specific call, for a specific account +// GET /2010-04-01/Accounts/AC.../Calls/abc123... +client.accounts('AC...').calls('abc123...').get(function(err, response) { + response.calls.forEach(function(call) { + console.log('Received call from: ' + call.from); + console.log('This call\'s unique ID is: ' + call.sid); + }); +}); + +// Create (send) an SMS message +// POST /2010-04-01/Accounts/ACCOUNT_SID/SMS/Messages +// "create" and "update" aliases are in place where appropriate on PUT and POST requests +client.sms.messages.post({ + to:'+16515559999', + from:'+14503334455', + body:'word to your mother.' +}, function(err, text) { + console.log('You sent: '+ text.body); + console.log('Current status of this text message is: '+ text.status); +}); + +// Delete a TwiML application +// DELETE /2010-04-01/Accounts/ACCOUNT_SID/Applications/APP... +client.applications('APP...').delete(function(err, response, nodeResponse) { + //DELETE requests do not return data - if there was no error, it worked. + err ? console.log('There was an error') : console.log('it worked!'); +}); + +var client = require('twilio')('ACCOUNT_SID', 'AUTH_TOKEN'), + SOME_SUBACCOUNT_SID = 'AC...'; + +//Send a text message, associated with the given subaccount +client.accounts(SOME_SUBACCOUNT_SID).sms.messages.create({ + to:'+16512223333', + from:'+14505556677', + body:'word to your subaccount mother.' +}, function(err, text) { + console.log('You sent: '+ text.body); + console.log('Current status of this text message is: '+ text.status); +}); + +//This REST call using the master/default account for the client... +client.makeCall({ + to:'+16512223333', + from:'+14505556677', + url:'http://example.com/someTwiml.php' +}, function(err, call) { + console.log('This call\'s unique ID is: ' + call.sid); + console.log('This call was created at: ' + call.dateCreated); +}); + +//...is the same as... +client.accounts(str).calls.create({ + to:'+16512223333', + from:'+14505556677', + url:'http://example.com/someTwiml.php' +}, function(err, call) { + console.log('This call\'s unique ID is: ' + call.sid); + console.log('This call was created at: ' + call.dateCreated); +}); + +var restClient = new twilio.RestClient('ACCOUNT_SID', 'AUTH_TOKEN'); + +// A simple example of making a phone call using promises +var promise = restClient.makeCall({ + to:'+16515556667777', // a number to call + from:'+16518889999', // a Twilio number you own + url:'https://demo.twilio.com/welcome/voice' // A URL containing TwiML instructions for the call +}); + +// You can assign functions to be called, at any time, after the request to +// Twilio has been completed. The first function is called when the request +// succeeds, the second if there was an error. +promise.then(function(call) { + console.log('Call success! Call SID: '+call.sid); +}, function(error) { + console.error('Call failed! Reason: '+error.message); +}); + +// Let's look at an example where we're making multiple requests to Twilio, like +// buying a new phone number. This is where promises can become very useful: + +// First, search for available phone numbers +restClient.availablePhoneNumbers('US').local.get({ + areaCode:'651' +}).then(function(searchResults) { + + // handle the case where there are no numbers found + if (searchResults.availablePhoneNumbers.length < 1) { + throw { message:'No numbers found with that area code' }; + } + + // Okay, so there are some available numbers. Now, let's buy the first one + // in the list. Return the promise created by the next call to Twilio: + return restClient.incomingPhoneNumbers.create({ + phoneNumber:searchResults.availablePhoneNumbers[0].phoneNumber, + voiceUrl:'https://demo.twilio.com/welcome/voice', + smsUrl:'https://demo.twilio.com/welcome/sms/reply' + }); + +}).then(function(number) { + + // We bought the number! Everything worked! + console.log('Your new number: '+number.phoneNumber); + +}).fail(function(error) { + + // This callback will be invoked on any error returned in the + // process. + console.log('Number purchase failed! Reason: '+error.message); + +}).fin(function() { + + // You can use this optional callback like a "finally" block + // It will always execute last. Perform any cleanup necessary here. + +}); + +client.request({ + url:'/Accounts', + method:'GET' +}, function (error, responseData) { + //work with response data +}); + +/// TwiML +var resp = new twilio.TwimlResponse(); + +resp.say('Welcome to Twilio!'); +resp.say('Please let us know if we can help during your development.', { + voice:'woman', + language:'en-gb' +}); + +console.log(resp.toString()); + +resp.say('Welcome to Twilio!') + .pause({ length:3 }) + .say('Please let us know if we can help during your development.', { + voice:'woman', + language:'en-gb' + }) + .play('http://www.example.com/some_sound.mp3'); + +resp.say('Welcome to Acme Customer Service!') + .gather({ + action:'http://www.example.com/callFinished.php', + finishOnKey:'*' + }, function() { + this.say('Press 1 for customer service') + .say('Press 2 for British customer service', { language:'en-gb' }); + }); + +resp.say('Welcome to Acme Customer Service!') + .gather({ + action:'http://www.example.com/callFinished.php', + finishOnKey:'*' + }, function(node) { //note the use of the "node" variable in the anonymous function + + //Now you can use this reference as well, if using "this" wrankles you + node.say('Press 1 for customer service') + .say('Press 2 for British customer service', { language:'en-gb' }); + + }); + +resp.say('Your conference call is starting.', + { + voice:'woman', + language:'en-gb' + }) + .dial({ + action:'http://example.com/something.php' + }, function(node) { + node.conference('waitingRoom', { + beep:'false' + }); + }); + +/// Capabilities +var capability = new twilio.Capability(str, str); +capability.allowClientIncoming('jenny'); +var token = capability.generate(); + +capability.allowClientOutgoing('AP123'); +var token = capability.generate(); + +capability.allowClientOutgoing('AP123'); +var token = capability.generate(120); + +/// Utilities +twilio.validateRequest(token, str, 'http://example.herokuapp.com', { query: 'val' }); +twilio.validateExpressRequest({}, 'YOUR_TWILIO_AUTH_TOKEN'); +twilio.validateExpressRequest({}, 'YOUR_TWILIO_AUTH_TOKEN', {}); +twilio.webhook({ validate: false }); + + diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index e99e4c508f..cc74cecef5 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -9,7 +9,11 @@ import * as Http from 'http'; -declare module twilio { +export interface twilio { + (sid?: string, tkn?: string, options?: twilio.ClientOptions): twilio.RestClient; +} + +export module twilio { // Composite Classes: //============================== @@ -236,8 +240,8 @@ declare module twilio { getMessage(messageSid: string, callback?: RequestCallback): Q.Promise; // Calls shorthand - makeCall(): RestMethod; - listCalls(): RestMethod; + makeCall: RestMethod; + listCalls: RestMethod; getCall(callSid: string, callback?: RequestCallback): Q.Promise; // Overrides Client.request(...) @@ -338,6 +342,10 @@ declare module twilio { legalNodes: Array; } + export interface TwimlMethod { (arg1: any | string | TwimlCallback, arg2?: any | string | TwimlCallback): Node } + + export interface TwimlCallback { (node?: Node): void; } + export class Node implements NodeOptions { name: string; attributes: any; @@ -347,10 +355,37 @@ declare module twilio { constructor(config?: NodeOptions); + // TwiML Verbs/Nouns: + gather: TwimlMethod; + say: TwimlMethod; + play: TwimlMethod; + pause: TwimlMethod; + + dial: TwimlMethod; + number: TwimlMethod; + client: TwimlMethod; + conference: TwimlMethod; + queue: TwimlMethod; + sip: TwimlMethod; + + message: TwimlMethod; + media: TwimlMethod; + body: TwimlMethod; + + enqueue: TwimlMethod; + task: TwimlMethod; + + record: TwimlMethod; + sms: TwimlMethod; + hangup: TwimlMethod; + redirect: TwimlMethod; + reject: TwimlMethod; + leave: TwimlMethod; + toString(): string; } - function TwimlResponse(): Node; + export class TwimlResponse extends Node {} /// webhook.js export interface webhookOptions { From 95c58d3e815fd2dba4d1cf6804fd68f7a4c404f3 Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Tue, 9 Aug 2016 10:52:08 -0500 Subject: [PATCH 16/80] Forgot a few export statements. --- twilio/twilio.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index cc74cecef5..035710cd1b 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -409,10 +409,10 @@ export module twilio { // For interop with node middleware chains export interface MiddlewareFunction { (request: Http.ClientRequest, response: Http.ClientResponse, next: MiddlewareFunction): void; } - function webhook(options?: string | webhookOptions): MiddlewareFunction; + export function webhook(options?: string | webhookOptions): MiddlewareFunction; - function validateRequest(authToken: string, twilioHeader: string, url: string, params?: any): boolean; - function validateExpressRequest(request: Express.Request, authToken: string, options?: WebhookExpressOptions): boolean; + export function validateRequest(authToken: string, twilioHeader: string, url: string, params?: any): boolean; + export function validateExpressRequest(request: Express.Request, authToken: string, options?: WebhookExpressOptions): boolean; /// resources/Accounts.js export interface OutgoingCallerIdInstance { From 4fadd40471a5c20fbdf72bf526b1d7466c7cd2da Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Tue, 9 Aug 2016 10:55:35 -0500 Subject: [PATCH 17/80] Added imports. --- twilio/twilio.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index 035710cd1b..8de55d6f83 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -7,8 +7,11 @@ /// /// +import * as express from 'express'; import * as Http from 'http'; +import q = require('q'); + export interface twilio { (sid?: string, tkn?: string, options?: twilio.ClientOptions): twilio.RestClient; } From ebe80b9f21e6229c73ac40d93b8bfef90b17afee Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Tue, 9 Aug 2016 11:22:17 -0500 Subject: [PATCH 18/80] Fixed Q import (hopefully?) and cleaned up implicit types in test --- twilio/twilio-tests.ts | 45 +++++++++++++++++++++--------------------- twilio/twilio.d.ts | 3 ++- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/twilio/twilio-tests.ts b/twilio/twilio-tests.ts index 20e60242aa..0c9013ede7 100644 --- a/twilio/twilio-tests.ts +++ b/twilio/twilio-tests.ts @@ -5,13 +5,13 @@ import { twilio } from './twilio'; var str: string; // Create a client: -var client = require('twilio')('ACCOUNT_SID', 'AUTH_TOKEN'); +var client: twilio.RestClient = (require('twilio') as twilio)('ACCOUNT_SID', 'AUTH_TOKEN'); //Get a list of calls made by this account // GET /2010-04-01/Accounts/ACCOUNT_SID/Calls // alias for get is "list", if you prefer -client.calls.get(function(err, response) { - response.calls.forEach(function(call) { +client.calls.get(function(err: any, response: any) { + response.calls.forEach(function(call: any) { console.log('Received call from: ' + call.from); console.log('Call duration (in seconds): ' + call.duration); }); @@ -21,8 +21,8 @@ client.calls.get(function(err, response) { // GET /2010-04-01/Accounts/ACCOUNT_SID/Calls?From=+16513334455 client.calls.get({ from:'+16513334455' -}, function(err, response) { - response.calls.forEach(function(call) { +}, function(err: any, response: any) { + response.calls.forEach(function(call: any) { console.log('Received call from: ' + call.from); console.log('This call\'s unique ID is: ' + call.sid); }); @@ -30,15 +30,15 @@ client.calls.get({ //Get data for a specific call // GET /2010-04-01/Accounts/ACCOUNT_SID/Calls/abc123... -client.calls('abc123...').get(function(err, call) { +client.calls('abc123...').get(function(err: any, call: any) { console.log('This call\'s unique ID is: ' + call.sid); console.log('This call was created at: ' + call.dateCreated); }); //Get data for a specific call, for a specific account // GET /2010-04-01/Accounts/AC.../Calls/abc123... -client.accounts('AC...').calls('abc123...').get(function(err, response) { - response.calls.forEach(function(call) { +client.accounts('AC...').calls('abc123...').get(function(err: any, response: any) { + response.calls.forEach(function(call: any) { console.log('Received call from: ' + call.from); console.log('This call\'s unique ID is: ' + call.sid); }); @@ -51,27 +51,26 @@ client.sms.messages.post({ to:'+16515559999', from:'+14503334455', body:'word to your mother.' -}, function(err, text) { +}, function(err: any, text: any) { console.log('You sent: '+ text.body); console.log('Current status of this text message is: '+ text.status); }); // Delete a TwiML application // DELETE /2010-04-01/Accounts/ACCOUNT_SID/Applications/APP... -client.applications('APP...').delete(function(err, response, nodeResponse) { +client.applications('APP...').delete(function(err: any, response: any, nodeResponse: any) { //DELETE requests do not return data - if there was no error, it worked. err ? console.log('There was an error') : console.log('it worked!'); }); -var client = require('twilio')('ACCOUNT_SID', 'AUTH_TOKEN'), - SOME_SUBACCOUNT_SID = 'AC...'; +var SOME_SUBACCOUNT_SID = 'AC...'; //Send a text message, associated with the given subaccount client.accounts(SOME_SUBACCOUNT_SID).sms.messages.create({ to:'+16512223333', from:'+14505556677', body:'word to your subaccount mother.' -}, function(err, text) { +}, function(err: any, text: any) { console.log('You sent: '+ text.body); console.log('Current status of this text message is: '+ text.status); }); @@ -81,7 +80,7 @@ client.makeCall({ to:'+16512223333', from:'+14505556677', url:'http://example.com/someTwiml.php' -}, function(err, call) { +}, function(err: any, call: any) { console.log('This call\'s unique ID is: ' + call.sid); console.log('This call was created at: ' + call.dateCreated); }); @@ -91,7 +90,7 @@ client.accounts(str).calls.create({ to:'+16512223333', from:'+14505556677', url:'http://example.com/someTwiml.php' -}, function(err, call) { +}, function(err: any, call: any) { console.log('This call\'s unique ID is: ' + call.sid); console.log('This call was created at: ' + call.dateCreated); }); @@ -108,9 +107,9 @@ var promise = restClient.makeCall({ // You can assign functions to be called, at any time, after the request to // Twilio has been completed. The first function is called when the request // succeeds, the second if there was an error. -promise.then(function(call) { +promise.then(function(call: any) { console.log('Call success! Call SID: '+call.sid); -}, function(error) { +}, function(error: any) { console.error('Call failed! Reason: '+error.message); }); @@ -120,7 +119,7 @@ promise.then(function(call) { // First, search for available phone numbers restClient.availablePhoneNumbers('US').local.get({ areaCode:'651' -}).then(function(searchResults) { +}).then(function(searchResults: any) { // handle the case where there are no numbers found if (searchResults.availablePhoneNumbers.length < 1) { @@ -135,12 +134,12 @@ restClient.availablePhoneNumbers('US').local.get({ smsUrl:'https://demo.twilio.com/welcome/sms/reply' }); -}).then(function(number) { +}).then(function(number: any) { // We bought the number! Everything worked! console.log('Your new number: '+number.phoneNumber); -}).fail(function(error) { +}).fail(function(error: any) { // This callback will be invoked on any error returned in the // process. @@ -156,7 +155,7 @@ restClient.availablePhoneNumbers('US').local.get({ client.request({ url:'/Accounts', method:'GET' -}, function (error, responseData) { +}, function (error: any, responseData: any) { //work with response data }); @@ -192,7 +191,7 @@ resp.say('Welcome to Acme Customer Service!') .gather({ action:'http://www.example.com/callFinished.php', finishOnKey:'*' - }, function(node) { //note the use of the "node" variable in the anonymous function + }, function(node: twilio.Node) { //note the use of the "node" variable in the anonymous function //Now you can use this reference as well, if using "this" wrankles you node.say('Press 1 for customer service') @@ -207,7 +206,7 @@ resp.say('Your conference call is starting.', }) .dial({ action:'http://example.com/something.php' - }, function(node) { + }, function(node: twilio.Node) { node.conference('waitingRoom', { beep:'false' }); diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index 8de55d6f83..e7b28d7636 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -5,7 +5,7 @@ /// /// -/// +/// import * as express from 'express'; import * as Http from 'http'; @@ -151,6 +151,7 @@ export module twilio { export interface ClientRequestOptions { url: string; + method?: string; form?: any; } From 73f02e190b0647ba30353afdf07f6ee9443fbb80 Mon Sep 17 00:00:00 2001 From: rundef Date: Wed, 10 Aug 2016 09:12:15 -0400 Subject: [PATCH 19/80] [sequelize] import lodash dependency --- sequelize/sequelize.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 4cf94ce77d..e7433b826c 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -10,6 +10,7 @@ /// declare module "sequelize" { + import * as _ from "lodash"; namespace sequelize { From 04a5bdef672a7d5b35dec420c256d5e04659a6ea Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Wed, 10 Aug 2016 16:20:48 +0200 Subject: [PATCH 20/80] Typings for epub --- epub/epub-tests.ts | 9 +++++++ epub/epub.d.ts | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 epub/epub-tests.ts create mode 100644 epub/epub.d.ts diff --git a/epub/epub-tests.ts b/epub/epub-tests.ts new file mode 100644 index 0000000000..6e61a26634 --- /dev/null +++ b/epub/epub-tests.ts @@ -0,0 +1,9 @@ +/// +import EPub = require("epub"); + +var epub = new EPub("./file.epub"); +epub.on("end", function(){ + epub.getChapter("chapter_id", function(err: Error, text: string) {}); +}); + +epub.parse(); diff --git a/epub/epub.d.ts b/epub/epub.d.ts new file mode 100644 index 0000000000..7c813e003d --- /dev/null +++ b/epub/epub.d.ts @@ -0,0 +1,66 @@ +// Type definitions for epub +// Project: https://github.com/julien-c/epub +// Definitions by: Julien Chaumond +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +/** + * new EPub(fname[, imageroot][, linkroot]) + * - fname (String): filename for the ebook + * - imageroot (String): URL prefix for images + * - linkroot (String): URL prefix for links + * + * Creates an Event Emitter type object for parsing epub files + * + * var epub = new EPub("book.epub"); + * epub.on("end", function () { + * console.log(epub.spine); + * }); + * epub.on("error", function (error) { ... }); + * epub.parse(); + * + * Image and link URL format is: + * + * imageroot + img_id + img_zip_path + * + * So an image "logo.jpg" which resides in "OPT/" in the zip archive + * and is listed in the manifest with id "logo_img" will have the + * following url (providing that imageroot is "/images/"): + * + * /images/logo_img/OPT/logo.jpg + **/ +declare module "epub" { + + import {EventEmitter} from "events"; + + interface TocElement { + level: number; + order: number; + title: string; + id: string; + href?: string; + } + + class EPub extends EventEmitter { + constructor(epubfile: string, imagewebroot?: string, chapterwebroot?: string); + + metadata: Object; + manifest: Object; + spine: Object; + flow: Array; + toc: Array; + + parse(): void; + + getChapter(chapterId: string, callback: (error: Error, text: string) => void): void; + + getChapterRaw(chapterId: string, callback: (error: Error, text: string) => void): void; + + getImage(id: string, callback: (error: Error, data: Buffer, mimeType: string) => void): void; + + getFile(id: string, callback: (error: Error, data: Buffer, mimeType: string) => void): void; + } + + export = EPub; +} From 2a2017e7485e69c902ae90d115ce377b12f6fc6b Mon Sep 17 00:00:00 2001 From: Kostya Esmukov Date: Wed, 10 Aug 2016 20:00:22 +0300 Subject: [PATCH 21/80] Updated react-i18next typings for the 1.7.0 version --- react-i18next/react-i18next-tests.tsx | 26 ++++++++++++++++++++------ react-i18next/react-i18next.d.ts | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/react-i18next/react-i18next-tests.tsx b/react-i18next/react-i18next-tests.tsx index d9faea8ac2..dd013002d4 100644 --- a/react-i18next/react-i18next-tests.tsx +++ b/react-i18next/react-i18next-tests.tsx @@ -7,7 +7,7 @@ import * as ReactDOM from 'react-dom'; import * as React from 'react'; import * as i18n from 'i18next'; -import { translate, I18nextProvider, Interpolate, InjectedTranslateProps } from 'react-i18next'; +import { translate, I18nextProvider, Interpolate, InjectedTranslateProps, TranslationFunction } from 'react-i18next'; i18n @@ -26,18 +26,19 @@ i18n }); -interface InnerAnotherComponentProps extends InjectedTranslateProps { +interface InnerAnotherComponentProps { + _?: TranslationFunction; } class InnerAnotherComponent extends React.Component { render() { - const { t } = this.props; + const { _ } = this.props; - return

{t('content.text', { /* options t options */ })}

; + return

{_('content.text', { /* options t options */ })}

; } } -const AnotherComponent = translate('view', { wait: true })(InnerAnotherComponent); +const AnotherComponent = translate('view', { wait: true, translateFuncName: '_' })(InnerAnotherComponent); @@ -69,7 +70,20 @@ class TranslatableView extends React.Component {

{t('common:appName')}

- + + {t('nav:link1')} ) diff --git a/react-i18next/react-i18next.d.ts b/react-i18next/react-i18next.d.ts index 0720e6e4ed..8993ab61cb 100644 --- a/react-i18next/react-i18next.d.ts +++ b/react-i18next/react-i18next.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-i18next 1.6.3 +// Type definitions for react-i18next 1.7.0 // Project: https://github.com/i18next/react-i18next // Definitions by: Kostya Esmukov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,11 +11,16 @@ declare namespace ReactI18next { import React = __React; + export type TranslationFunction = I18next.TranslationFunction; + // Extend your component's Prop interface with this one to get access to `this.props.t` // + // Please note that if you use the `translateFuncName` option, you should create + // your own interface just like this one, but with your name of the translation function. + // // interface MyComponentProps extends ReactI18next.InjectedTranslateProps {} export interface InjectedTranslateProps { - t?: I18next.TranslationFunction; + t?: TranslationFunction; } interface I18nextProviderProps { @@ -35,7 +40,10 @@ declare namespace ReactI18next { regexp?: RegExp; options?: I18next.TranslationOptions; - [regexKey: string]: InterpolateValue | RegExp | I18next.TranslationOptions; + useDangerouslySetInnerHTML?: boolean; + dangerouslySetInnerHTMLPartElement?: string; + + [regexKey: string]: InterpolateValue | RegExp | I18next.TranslationOptions | boolean; } export class Interpolate extends React.Component { } @@ -43,6 +51,7 @@ declare namespace ReactI18next { interface TranslateOptions { withRef?: boolean; wait?: boolean; + translateFuncName?: string; } export function translate(namespaces?: string[] | string, options?: TranslateOptions): (WrappedComponent: C) => C; From 1317f2fdf4be30668fc4b37c0bc4e2a2daa74bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Werlang?= Date: Wed, 10 Aug 2016 15:31:42 -0300 Subject: [PATCH 22/80] rename drop to tether-drop to adhere to npm registry --- drop/drop-tests.ts => tether-drop/tether-drop-tests.ts | 4 +++- drop/drop.d.ts => tether-drop/tether-drop.d.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) rename drop/drop-tests.ts => tether-drop/tether-drop-tests.ts (93%) rename drop/drop.d.ts => tether-drop/tether-drop.d.ts (98%) diff --git a/drop/drop-tests.ts b/tether-drop/tether-drop-tests.ts similarity index 93% rename from drop/drop-tests.ts rename to tether-drop/tether-drop-tests.ts index 0da04e9445..f67f746a7c 100644 --- a/drop/drop-tests.ts +++ b/tether-drop/tether-drop-tests.ts @@ -1,5 +1,7 @@ /// -/// +/// + +import 'tether-drop'; var yellowBox = document.querySelector(".yellow"); var greenBox = document.querySelector(".green"); diff --git a/drop/drop.d.ts b/tether-drop/tether-drop.d.ts similarity index 98% rename from drop/drop.d.ts rename to tether-drop/tether-drop.d.ts index 87ae4425b9..19c48ec7a1 100644 --- a/drop/drop.d.ts +++ b/tether-drop/tether-drop.d.ts @@ -56,6 +56,6 @@ declare namespace Drop { } } -declare module "drop" { +declare module "tether-drop" { export = Drop; } From 493d44982e5a935e29c79ac933761001211c9ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn?= Date: Wed, 10 Aug 2016 21:18:28 +0200 Subject: [PATCH 23/80] Add default export to angular-ui-router. --- angular-ui-router/angular-ui-router-tests.ts | 9 +++++---- angular-ui-router/angular-ui-router.d.ts | 10 ++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/angular-ui-router/angular-ui-router-tests.ts b/angular-ui-router/angular-ui-router-tests.ts index 9c5db1754a..a588faa448 100644 --- a/angular-ui-router/angular-ui-router-tests.ts +++ b/angular-ui-router/angular-ui-router-tests.ts @@ -1,6 +1,7 @@ /// -var myApp = angular.module('testModule'); +import uiRouterModule from "angular-ui-router"; +var myApp = angular.module("testModule", [uiRouterModule]); interface MyAppScope extends ng.IScope { items: string[]; @@ -141,7 +142,7 @@ class UrlLocatorTestService implements IUrlLocatorTestService { private $state: ng.ui.IStateService ) { $rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event)); - $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => + $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => this.onStateNotFound(event, unfoundState, fromState, fromParams)); } @@ -164,14 +165,14 @@ class UrlLocatorTestService implements IUrlLocatorTestService { }); } } - + private onStateNotFound(event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) { var unfoundTo: string = unfoundState.to; var unfoundToParams: {} = unfoundState.toParams; - var unfoundOptions: ng.ui.IStateOptions = unfoundState.options + var unfoundOptions: ng.ui.IStateOptions = unfoundState.options } private stateServiceTest() { diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index 0f0ac8caa3..7e4f097c8c 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -7,13 +7,7 @@ // Support for AMD require and CommonJS declare module 'angular-ui-router' { - // Since angular-ui-router adds providers for a bunch of - // injectable dependencies, it doesn't really return any - // actual data except the plain string 'ui.router'. - // - // As such, I don't think anybody will ever use the actual - // default value of the module. So I've only included the - // the types. (@xogeny) + export default "ui.router"; export type IState = angular.ui.IState; export type IStateProvider = angular.ui.IStateProvider; export type IUrlMatcher = angular.ui.IUrlMatcher; @@ -109,7 +103,7 @@ declare namespace angular.ui { toParams: {}, options: IStateOptions } - + interface IStateProvider extends angular.IServiceProvider { state(name:string, config:IState): IStateProvider; state(config:IState): IStateProvider; From 3fa40795278939a0cb5937a25b5cd0c743ec1d0a Mon Sep 17 00:00:00 2001 From: Emm Date: Wed, 10 Aug 2016 21:06:52 +0200 Subject: [PATCH 24/80] Add useNullOrDefault config option to knex.js. --- knex/knex-tests.ts | 6 ++++++ knex/knex.d.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index 04ba8409ee..f4bbf01b42 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -78,6 +78,12 @@ var knex = Knex({ client: 'pg' }); +// useNullAsDefault +var knex = Knex({ + client: 'sqlite', + useNullAsDefault: true, +}); + knex('books').insert({title: 'Test'}).returning('*').toString(); // Migrations diff --git a/knex/knex.d.ts b/knex/knex.d.ts index a8501f2e51..2cb8280ea1 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -454,6 +454,7 @@ declare module "knex" { pool?: PoolConfig; migrations?: MigratorConfig; acquireConnectionTimeout?: number; + useNullAsDefault?: boolean; } interface ConnectionConfig { From e0e0f509d58c23cb230b9c6f6b353decde463ce8 Mon Sep 17 00:00:00 2001 From: Emm Date: Wed, 10 Aug 2016 21:09:52 +0200 Subject: [PATCH 25/80] Add search path config option to knex.js. --- knex/knex-tests.ts | 6 ++++++ knex/knex.d.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index f4bbf01b42..3a00c32551 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -78,6 +78,12 @@ var knex = Knex({ client: 'pg' }); +// searchPath +var knex = Knex({ + client: 'pg', + searchPath: 'public', +}); + // useNullAsDefault var knex = Knex({ client: 'sqlite', diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 2cb8280ea1..64d530ed49 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -455,6 +455,7 @@ declare module "knex" { migrations?: MigratorConfig; acquireConnectionTimeout?: number; useNullAsDefault?: boolean; + searchPath?: string; } interface ConnectionConfig { From 11271655921d31fc8edecd17343c2bd2c11080e1 Mon Sep 17 00:00:00 2001 From: Yeiniel Suarez Sosa Date: Wed, 10 Aug 2016 15:09:28 -0500 Subject: [PATCH 26/80] Fixed return type for Client.stream() of cassandra-driver. --- cassandra-driver/cassandra-driver.d.ts | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cassandra-driver/cassandra-driver.d.ts b/cassandra-driver/cassandra-driver.d.ts index ac68985c31..9a4184b62e 100644 --- a/cassandra-driver/cassandra-driver.d.ts +++ b/cassandra-driver/cassandra-driver.d.ts @@ -16,10 +16,10 @@ declare module "cassandra-driver" { namespace policies { namespace addressResolution { - var EC2MultiRegionTranslator: EC2MultiRegionTranslatorStatic; + var EC2MultiRegionTranslator: EC2MultiRegionTranslatorStatic; interface AddressTranslator { - translate(address: string, port: number, callback: Callback): void; + translate(address: string, port: number, callback: Callback): void; } interface EC2MultiRegionTranslatorStatic { @@ -141,7 +141,7 @@ declare module "cassandra-driver" { var Tuple: TupleStatic; var Uuid: UuidStatic; - enum consistencies { + enum consistencies { any = 0, one, two, @@ -154,7 +154,7 @@ declare module "cassandra-driver" { localSerial, localOne } - + enum dataTypes { custom = 0, ascii, @@ -204,7 +204,7 @@ declare module "cassandra-driver" { fromString(value: string): BigDecimal; fromNumber(value: number): BigDecimal; } - + interface BigDecimal { equals(other: BigDecimal): boolean; inspect(): string; @@ -239,7 +239,7 @@ declare module "cassandra-driver" { interface IntegerStatic { new(bits: Array, sign: number): Integer; - + fromInt(value: number): Integer; fromNumber(value: number): Integer; fromBits(bits: Array): Integer; @@ -295,7 +295,7 @@ declare module "cassandra-driver" { fromString(value: string): LocalDate; fromBuffer(buffer: Buffer): LocalDate; } - + interface LocalDate { _value: number; year: number; @@ -384,7 +384,7 @@ declare module "cassandra-driver" { interface TimeUuidStatic { new (value?: Date, ticks?: number, nodeId?: string|Buffer, clockId?: string|Buffer): TimeUuid; - + fromDate(date: Date, ticks?: number, nodeId?: string|Buffer, clockId?: string|Buffer): TimeUuid; fromString(value: string): TimeUuid; min(date: Date, ticks?: number): TimeUuid; @@ -408,7 +408,7 @@ declare module "cassandra-driver" { interface Tuple { elements: Array; length: number; - + get(index: number): any; toString(): string; toJSON(): string; @@ -513,7 +513,7 @@ declare module "cassandra-driver" { execute(query: string, params?: any, options?: QueryOptions, callback?: ResultCallback): void; getReplicas(keyspace: string, token: Buffer): Array; // TODO: Should this be a more explicit return? shutdown(callback?: Callback): void; - stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): void; + stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): NodeJS.ReadableStream; } interface HostStatic { @@ -549,7 +549,7 @@ declare module "cassandra-driver" { } interface EncoderStatic { - new(protocolVersion: number, options: ClientOptions) : Encoder; + new(protocolVersion: number, options: ClientOptions) : Encoder; } interface Encoder { @@ -590,29 +590,29 @@ declare module "cassandra-driver" { } class ArgumentError extends DriverError { - constructor(message: string); + constructor(message: string); } class AuthenticationError extends DriverError { - constructor(message: string); + constructor(message: string); } class DriverInternalError extends DriverError { - constructor(message: string); + constructor(message: string); } class NoHostAvailableError extends DriverError { - constructor(innerErrors: any, message?: string); + constructor(innerErrors: any, message?: string); } class NotSupportedError extends DriverError { - constructor(message: string); + constructor(message: string); } class OperationTimedOutError extends DriverError {} class ResponseError extends DriverError { - constructor(code: number, message: string); + constructor(code: number, message: string); } } @@ -688,7 +688,7 @@ declare module "cassandra-driver" { interface IndexStatic { new (name: string, target: string, kind: IndexType, options: Object): Index; - + fromRows(indexRows: Array): Array; fromColumnRows(columnRows: Array, columnsByName: { [key:string]: ColumnInfo }): Array; } From 09a869c9aff51cd88250ad09b2a1b7b3cdb034d0 Mon Sep 17 00:00:00 2001 From: Jed Borovik Date: Wed, 10 Aug 2016 19:22:56 -0400 Subject: [PATCH 27/80] Change react-modal from export default to export = --- react-modal/react-modal-tests.tsx | 4 ++-- react-modal/react-modal.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/react-modal/react-modal-tests.tsx b/react-modal/react-modal-tests.tsx index 9a9814930d..40fc2a637e 100644 --- a/react-modal/react-modal-tests.tsx +++ b/react-modal/react-modal-tests.tsx @@ -2,7 +2,7 @@ /// import * as React from "react"; -import ReactModal from 'react-modal'; +import * as ReactModal from 'react-modal'; class ExampleOfUsingReactModal extends React.Component<{}, {}> { render() { @@ -46,4 +46,4 @@ class ExampleOfUsingReactModal extends React.Component<{}, {}> { ); } -}; \ No newline at end of file +}; diff --git a/react-modal/react-modal.d.ts b/react-modal/react-modal.d.ts index 2f2d0403d2..2aac95eacb 100644 --- a/react-modal/react-modal.d.ts +++ b/react-modal/react-modal.d.ts @@ -24,5 +24,5 @@ declare module "react-modal" { shouldCloseOnOverlayClick?: boolean } let ReactModal: __React.ClassicComponentClass; - export default ReactModal; + export = ReactModal; } From ff84f05542264c0ffbbcbdb90e9555269d9fcc47 Mon Sep 17 00:00:00 2001 From: Seth Westphal Date: Wed, 10 Aug 2016 19:58:41 -0500 Subject: [PATCH 28/80] Fix ExpressionAttributeNames. --- aws-sdk/aws-sdk.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-sdk/aws-sdk.d.ts b/aws-sdk/aws-sdk.d.ts index cadb392863..cb35f34e97 100644 --- a/aws-sdk/aws-sdk.d.ts +++ b/aws-sdk/aws-sdk.d.ts @@ -329,7 +329,7 @@ declare module "aws-sdk" { interface _DDBDC_Generic { TableName: string; - ExpressionAttributeNames?: string[]; + ExpressionAttributeNames?: { [someKey: string]: string }; ReturnConsumedCapacity?: "INDEXES" | "TOTAL" | "NONE"; } From 0bc3512b989c065e94baf2df9771392bb79f0cfb Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Thu, 11 Aug 2016 14:59:46 +1000 Subject: [PATCH 29/80] Add leaflet-geocoder-mapzen type declarations and tests for the basic usage of leaflet-geocoder-mapzen. Does not include the advanced usage patterns: https://github.com/mapzen/leaflet-geocoder/#advanced-usage --- .../leaflet-geocoder-mapzen-tests.ts | 10 + .../leaflet-geocoder-mapzen.d.ts | 177 ++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts create mode 100644 leaflet-geocoder-mapzen/leaflet-geocoder-mapzen.d.ts diff --git a/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts b/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts new file mode 100644 index 0000000000..c6519ab371 --- /dev/null +++ b/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts @@ -0,0 +1,10 @@ +/// +/// + +var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + osmAttrib = '© OpenStreetMap contributors', + osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), + map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }); + +// Add geocoding plugin +L.control.geocoder('search-MKZrG6M').addTo(map); diff --git a/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen.d.ts b/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen.d.ts new file mode 100644 index 0000000000..8809472e43 --- /dev/null +++ b/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen.d.ts @@ -0,0 +1,177 @@ +// Type definitions for leaflet-geocoder-mapzen v1.6.3 +// Project: https://github.com/mapzen/leaflet-geocoder +// Definitions by: Leonard Lausen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +/// + +declare namespace L { + namespace Control { + export interface GeocoderStatic extends ClassStatic { + /** + * Creates a geocoder control. + */ + new (options?: GeocoderOptions): Geocoder; + } + + export interface Geocoder extends L.Control { + } + + export interface GeocoderOptions { + /** + * Host endpoint for a Pelias-compatible search API. + * + * Default value: 'https://search.mapzen.com/v1'. + */ + url?: string; + + /** + * If true, search is bounded by the current map view. + * You may also provide a custom bounding box in form of a LatLngBounds object. + * Note: bounds is not supported by autocomplete. + * + * Default value: false. + */ + bounds?: LatLngBounds | boolean; + + /** + * If true, search and autocomplete prioritizes results near the center + * of the current view. + * You may also provide a custom LatLng value + * (in any of the accepted Leaflet formats) to act as the center bias. + * + * Default value: 'true'. + */ + focus?: LatLng | boolean; + + /** + * Filters results by layers (documentation). + * If left blank, results will come from all available layers. + * + * Default value: null. + */ + layers?: string | any[] ; + + /** + * An object of key-value pairs which will be serialized + * into query parameters that will be passed to the API. + * This allows custom queries that are not already supported + * by the convenience options listed above. + * For a full list of supported parameters, + * please read the Mapzen Search documentation. + * + * IMPORTANT: some parameters only work with the /search endpoint, + * and do not apply to /autocomplete requests! + * All supplied parameters are passed through; + * this library doesn't know which are valid parameters and which are not. + * In the event that other options conflict with parameters passed through params, + * the params option takes precedence. + * + * Default value: null. + */ + params?: Object; + + /** + * The position of the control (one of the map corners). + * Can be 'topleft', 'topright', 'bottomleft', or 'bottomright'. + * + * Default value: 'topleft'. + */ + position?: PositionString; + + /** + * Attribution text to include. + * Set to blank or null to disable. + * + * Default value: 'Geocoding by Mapzen' + */ + attribution?: string; + + /** + * Placeholder text to display in the search input box. + * Set to blank or null to disable. + * + * Default value: 'Search' + */ + placeholder?: string; + + /** + * Tooltip text to display on the search icon. Set to blank or null to disable. + * + * Default value: 'Search' + */ + title?: string; + + /** + * If true, highlighting a search result pans the map to that location. + * + * Default value: true + */ + panToPoint?: boolean; + + /** + * If true, an icon is used to indicate a polygonal result, + * matching any non-"venue" or non-"address" layer type. + * If false, no icon is displayed. + * For custom icons, pass a string containing a path to the image. + * + * Default value: true + */ + polygonIcon?: boolean | string; + + /** + * If true, search results drops Leaflet's default blue markers onto the map. + * You may customize this marker's appearance and + * behavior using Leaflet marker options. + * + * Default value: true + */ + markers?: MarkerOptions | boolean; + + /** + * If true, the input box will expand to take up the full width of the map container. + * If an integer breakpoint is provided, + * the full width applies only if the map container width is below this breakpoint. + * + * Default value: 650 + */ + fullWidth?: number | boolean; + + /** + * If true, the search input is always expanded. + * It does not collapse into a button-only state. + * + * Default value: false + */ + expanded?: boolean; + + /** + * If true, suggested results are fetched on each keystroke. + * If false, this is disabled and users must obtain results + * by pressing the Enter key after typing in their query. + * + * Default value: true + */ + autocomplete?: boolean; + + /** + * If true, selected results will make a request to the service /place endpoint. + * If false, this is disabled. + * The geocoder does not handle responses to /place, + * you will need to do handle it yourself in the results event listener (see below). + * + * Default value: false + */ + place?: boolean; + } + } + + export namespace control { + + /** + * Creates a geocoder control. + */ + export function geocoder(api_key: string, options?: Control.GeocoderOptions): L.Control.Geocoder; + } +} From 247c4be0b7939a5558f9ff485f9a8abe6085b9d0 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Thu, 11 Aug 2016 09:54:15 +0100 Subject: [PATCH 30/80] superagent typings: make buffer parameter optional --- superagent/superagent.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index f7ab4c88c9..1d89adeb6b 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -85,7 +85,7 @@ declare module "superagent" { accept(type: string): this; attach(field: string, file: string, filename?: string): this; auth(user: string, name: string): this; - buffer(val: boolean): this; + buffer(val?: boolean): this; clearTimeout(): this; end(callback?: CallbackHandler): this; field(name: string, val: string): this; From 1dd3713216e9a9d2a9917294e167d61bdec531a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=81rlis=20Ga=C5=86=C4=A3is?= Date: Thu, 11 Aug 2016 14:10:56 +0300 Subject: [PATCH 31/80] Added `opts` parameter to sheet_to_json method. --- xlsx/xlsx.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xlsx/xlsx.d.ts b/xlsx/xlsx.d.ts index b761387681..766be99457 100644 --- a/xlsx/xlsx.d.ts +++ b/xlsx/xlsx.d.ts @@ -128,7 +128,11 @@ declare module 'xlsx' { } export interface IUtils { - sheet_to_json(worksheet:IWorkSheet):T[]; + sheet_to_json(worksheet:IWorkSheet, opts?: { + raw?: boolean; + range?: any; + header?: "A"|number|string[]; + }):T[]; sheet_to_csv(worksheet:IWorkSheet):any; sheet_to_formulae(worksheet:IWorkSheet):any; } From d16e4caf673c5b60f033fd5a4b0797de7924d56a Mon Sep 17 00:00:00 2001 From: viskin Date: Thu, 11 Aug 2016 14:40:11 +0300 Subject: [PATCH 32/80] added marker-animate-unobtrusive library --- .../marker-animate-unobtrusive-amd-tests.ts | 5 ++ .../marker-animate-unobtrusive-tests.ts | 50 +++++++++++++ .../marker-animate-unobtrusive.d.ts | 72 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts create mode 100644 marker-animate-unobtrusive/marker-animate-unobtrusive-tests.ts create mode 100644 marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts diff --git a/marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts b/marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts new file mode 100644 index 0000000000..f86619fc90 --- /dev/null +++ b/marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts @@ -0,0 +1,5 @@ +import SlidingMarker = require('SlidingMarker'); +import MarkerWithGhost = require('MarkerWithGhost'); + +SlidingMarker.initializeGlobally(); +MarkerWithGhost.initializeGlobally(); diff --git a/marker-animate-unobtrusive/marker-animate-unobtrusive-tests.ts b/marker-animate-unobtrusive/marker-animate-unobtrusive-tests.ts new file mode 100644 index 0000000000..73ad4da4b5 --- /dev/null +++ b/marker-animate-unobtrusive/marker-animate-unobtrusive-tests.ts @@ -0,0 +1,50 @@ +/// +/// + +function test_init() { + SlidingMarker.initializeGlobally(); + MarkerWithGhost.initializeGlobally(); +} + +function test_options() { + var options: SlidingMarkerOptions = { + position: new google.maps.LatLng(0, 0), + easing: "easeInOutSine", + duration: 1000, + animateFunctionAdapter: (marker, destPoint, easing, duration) => {} + }; + var m = new SlidingMarker(options); + var g = new MarkerWithGhost(options); +} + +function test_sliding_marker() { + let googleMarker: google.maps.Marker; + let p: google.maps.LatLng; + let d: number; + let e:jQuery.easing.IEasingType; + + var m = new SlidingMarker(); + googleMarker = m; + + p = m.getPosition(); + m.setDuration(d); + d = m.getDuration(); + m.setEasing(e); + e = m.getEasing(); + p = m.getAnimationPosition(); + m.setPositionNotAnimated(p); +} + +function test_marker_with_ghost() { + let p: google.maps.LatLng; + let d: number; + let e:jQuery.easing.IEasingType; + let slidingMarker: SlidingMarker; + + var g = new MarkerWithGhost(); + slidingMarker = g; + + g.setGhostPosition(p); + p = g.getGhostPosition(); + p = g.getGhostAnimationPosition(); +} diff --git a/marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts b/marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts new file mode 100644 index 0000000000..515791052b --- /dev/null +++ b/marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts @@ -0,0 +1,72 @@ +// Type definitions for marker-animate-unobtrusive 0.2.8 +// Project: https://github.com/terikon/marker-animate-unobtrusive +// Definitions by: Roman Viskin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace jQuery.easing { + type IEasingType = + 'swing' | + 'easeInQuad' | + 'easeOutQuad' | + 'easeInOutQuad' | + 'easeInCubic' | + 'easeOutCubic' | + 'easeInOutCubic' | + 'easeInQuart' | + 'easeOutQuart' | + 'easeInOutQuart' | + 'easeInQuint' | + 'easeOutQuint' | + 'easeInOutQuint' | + 'easeInSine' | + 'easeOutSine' | + 'easeInOutSine' | + 'easeInExpo' | + 'easeOutExpo' | + 'easeInOutExpo' | + 'easeInCirc' | + 'easeOutCirc' | + 'easeInOutCirc' | + 'easeInElastic' | + 'easeOutElastic' | + 'easeInOutElastic' | + 'easeInBack' | + 'easeOutBack' | + 'easeInOutBack' | + 'easeInBounce' | + 'easeOutBounce' | + 'easeInOutBounce'; +} + +interface SlidingMarkerOptions extends google.maps.MarkerOptions { + easing?: jQuery.easing.IEasingType, + duration?: number, + animateFunctionAdapter?: (marker: google.maps.Marker, destPoint: google.maps.LatLng, easing: 'linear' | jQuery.easing.IEasingType, duration: number) => void +} + +declare class SlidingMarker extends google.maps.Marker { + static initializeGlobally(): void; + constructor(opts?: SlidingMarkerOptions); + setDuration(duration: number); + getDuration(): number; + setEasing(easing: jQuery.easing.IEasingType); + getEasing(): jQuery.easing.IEasingType; + getAnimationPosition(): google.maps.LatLng; + setPositionNotAnimated(position: google.maps.LatLng | google.maps.LatLngLiteral): void; +} + +declare class MarkerWithGhost extends SlidingMarker { + setGhostPosition(ghostPosition: google.maps.LatLng | google.maps.LatLngLiteral); + getGhostPosition(): google.maps.LatLng; + getGhostAnimationPosition(): google.maps.LatLng; +} + +declare module "SlidingMarker" { + export = SlidingMarker; +} + +declare module "MarkerWithGhost" { + export = MarkerWithGhost; +} From 0479daf2d17921abfbc9dd080d5e90565b4a57f5 Mon Sep 17 00:00:00 2001 From: viskin Date: Thu, 11 Aug 2016 14:45:01 +0300 Subject: [PATCH 33/80] fixed implicit "any" --- marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts b/marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts index 515791052b..61a4a680df 100644 --- a/marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts +++ b/marker-animate-unobtrusive/marker-animate-unobtrusive.d.ts @@ -49,16 +49,16 @@ interface SlidingMarkerOptions extends google.maps.MarkerOptions { declare class SlidingMarker extends google.maps.Marker { static initializeGlobally(): void; constructor(opts?: SlidingMarkerOptions); - setDuration(duration: number); + setDuration(duration: number): void; getDuration(): number; - setEasing(easing: jQuery.easing.IEasingType); + setEasing(easing: jQuery.easing.IEasingType): void; getEasing(): jQuery.easing.IEasingType; getAnimationPosition(): google.maps.LatLng; setPositionNotAnimated(position: google.maps.LatLng | google.maps.LatLngLiteral): void; } declare class MarkerWithGhost extends SlidingMarker { - setGhostPosition(ghostPosition: google.maps.LatLng | google.maps.LatLngLiteral); + setGhostPosition(ghostPosition: google.maps.LatLng | google.maps.LatLngLiteral): void; getGhostPosition(): google.maps.LatLng; getGhostAnimationPosition(): google.maps.LatLng; } From 54a597604443b54609baf2bf006ba0733e7539e4 Mon Sep 17 00:00:00 2001 From: viskin Date: Thu, 11 Aug 2016 14:53:11 +0300 Subject: [PATCH 34/80] Fixed missing references in test --- .../marker-animate-unobtrusive-amd-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts b/marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts index f86619fc90..544c95af5a 100644 --- a/marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts +++ b/marker-animate-unobtrusive/marker-animate-unobtrusive-amd-tests.ts @@ -1,3 +1,6 @@ +/// +/// + import SlidingMarker = require('SlidingMarker'); import MarkerWithGhost = require('MarkerWithGhost'); From 147f25f0b684675ca9b3cdecc9be0b3ace3e9187 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 7 Aug 2016 22:50:15 +0200 Subject: [PATCH 35/80] Update to Electron 1.3.3 --- github-electron/github-electron-main-tests.ts | 12 ++ github-electron/github-electron.d.ts | 111 ++++++++++++++++-- 2 files changed, 111 insertions(+), 12 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 0392702e6a..bebf0b99c8 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -985,3 +985,15 @@ app.on('ready', function () { console.log(webContents.getAllWebContents()); console.log(webContents.getFocusedWebContents()); + +var win = new BrowserWindow({ + webPreferences: { + offscreen: true + } +}); + +win.webContents.on('paint', (event, dirty, image) => { + console.log(dirty, image.getBitmap()); +}); + +win.loadURL('http://github.com'); diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 0961eb03cf..7b246966ab 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v1.3.2 +// Type definitions for Electron v1.3.3 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -299,13 +299,13 @@ declare namespace Electron { * Note: This is only implemented on macOS and Windows. * On macOS, you can only register protocols that have been added to your app's info.plist. */ - setAsDefaultProtocolClient(protocol: string): void; + setAsDefaultProtocolClient(protocol: string): boolean; /** * Removes the current executable as the default handler for a protocol (aka URI scheme). * * Note: This is only implemented on macOS and Windows. */ - removeAsDefaultProtocolClient(protocol: string): void; + removeAsDefaultProtocolClient(protocol: string): boolean; /** * @returns Whether the current executable is the default handler for a protocol (aka URI scheme). * @@ -317,7 +317,7 @@ declare namespace Electron { * * Note: This API is only available on Windows. */ - setUserTasks(tasks: Task[]): void; + setUserTasks(tasks: Task[]): boolean; /** * This method makes your application a Single Instance Application instead of allowing * multiple instances of your app to run, this will ensure that only a single instance @@ -349,6 +349,8 @@ declare namespace Electron { getCurrentActivityType(): string; /** * Changes the Application User Model ID to id. + * + * Note: This is only implemented on Windows. */ setAppUserModelId(id: string): void; /** @@ -807,6 +809,10 @@ declare namespace Electron { * @returns Whether the window is focused. */ isFocused(): boolean; + /** + * @returns Whether the window is destroyed. + */ + isDestroyed(): boolean; /** * Shows and gives focus to the window. */ @@ -877,6 +883,14 @@ declare namespace Electron { * @returns The window's width, height, x and y values. */ getBounds(): Rectangle; + /** + * Resizes and moves the window's client area (e.g. the web page) to width, height, x, y. + */ + setContentBounds(options: Rectangle, animate?: boolean): void; + /** + * @returns The window's client area (e.g. the web page) width, height, x and y values. + */ + getContentBounds(): Rectangle; /** * Resizes the window to width and height. */ @@ -1101,7 +1115,13 @@ declare namespace Electron { * @param progress Valid range is [0, 1.0]. If < 0, the progress bar is removed. * If greater than 0, it becomes indeterminate. */ - setProgressBar(progress: number): void; + setProgressBar(progress: number, options?: { + /** + * Mode for the progress bar. + * Note: This is only implemented on Windows. + */ + mode: 'none' | 'normal' | 'indeterminate' | 'error' | 'paused' + }): void; /** * Sets a 16px overlay onto the current Taskbar icon, usually used to convey * some sort of application status or to passively notify the user. @@ -1136,7 +1156,12 @@ declare namespace Electron { * * Note: This API is available only on Windows. */ - setThumbnailClip(region: Rectangle): void; + setThumbnailClip(region: Rectangle): boolean; + /** + * Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar. + * Note: This API is available only on Windows. + */ + setThumbnailToolTip(toolTip: string): boolean; /** * Same as webContents.showDefinitionForSelection(). * Note: This API is available only on macOS. @@ -1379,9 +1404,14 @@ declare namespace Electron { defaultEncoding?: string; /** * Whether to throttle animations and timers when the page becomes background. - * Default: true + * Default: true. */ backgroundThrottling?: boolean; + /** + * Whether to enable offscreen rendering for the browser window. + * Default: false. + */ + offscreen?: boolean; } interface BrowserWindowOptions { @@ -2266,8 +2296,8 @@ declare namespace Electron { } type MenuItemType = 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'; - type MenuItemRole = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteandmatchstyle' | 'selectall' | 'delete' | 'minimize' | 'close' | 'quit' | 'togglefullscreen'; - type MenuItemRoleMac = 'about' | 'hide' | 'hideothers' | 'unhide' | 'front' | 'zoom' | 'window' | 'help' | 'services'; + type MenuItemRole = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteandmatchstyle' | 'selectall' | 'delete' | 'minimize' | 'close' | 'quit' | 'togglefullscreen' | 'resetzoom' | 'zoomin' | 'zoomout'; + type MenuItemRoleMac = 'about' | 'hide' | 'hideothers' | 'unhide' | 'startspeaking' | 'stopspeaking' | 'front' | 'zoom' | 'window' | 'help' | 'services'; interface MenuItemOptions { /** @@ -2458,9 +2488,17 @@ declare namespace Electron { */ toJPEG(quality: number): Buffer; /** - * @returns Buffer that contains the image's raw pixel data. + * @returns Buffer that contains a copy of the image's raw bitmap pixel data. */ toBitmap(): Buffer; + /** + * @returns Buffer that contains the image's raw bitmap pixel data. + * + * The difference between getBitmap() and toBitmap() is, getBitmap() does not copy the bitmap data, + * so you have to use the returned Buffer immediately in current event loop tick, + * otherwise the data might be changed or destroyed. + */ + getBitmap(): Buffer; /** * @returns string The data URL of the image. */ @@ -3336,6 +3374,26 @@ declare namespace Electron { * Note: This is only implemented on macOS. */ isDarkMode(): boolean; + /** + * @returns If the Swipe between pages setting is on. + * + * Note: This is only implemented on macOS. + */ + isSwipeTrackingFromScrollEventsEnabled(): boolean; + /** + * Posts event as native notifications of macOS. + * The userInfo contains the user information dictionary sent along with the notification. + * + * Note: This is only implemented on macOS. + */ + postNotification(event: string, userInfo: Object): void; + /** + * Posts event as native notifications of macOS. + * The userInfo contains the user information dictionary sent along with the notification. + * + * Note: This is only implemented on macOS. + */ + postLocalNotification(event: string, userInfo: Object): void; /** * Subscribes to native notifications of macOS, callback will be called when the corresponding event happens. * The id of the subscriber is returned, which can be used to unsubscribe the event. @@ -3722,9 +3780,9 @@ declare namespace Electron { */ on(event: 'select-bluetooth-device', listener: (event: Event, deviceList: BluetoothDevice[], callback: (deviceId: string) => void) => void): this; /** - * Emitted when a page's view is repainted. + * Emitted when a new frame is generated. Only the dirty area is passed in the buffer. */ - on(event: 'view-painted', listener: Function): this; + on(event: 'paint', listener: (event: Event, dirtyRect: Rectangle, image: NativeImage) => void): this; on(event: string, listener: Function): this; /** * Loads the url in the window. @@ -4023,6 +4081,31 @@ declare namespace Electron { * Note: This API is available only on macOS. */ showDefinitionForSelection(): void; + /** + * @returns Whether offscreen rendering is enabled. + */ + isOffscreen(): boolean; + /** + * If offscreen rendering is enabled and not painting, start painting. + */ + startPainting(): void; + /** + * If offscreen rendering is enabled and painting, stop painting. + */ + stopPainting(): void; + /** + * If offscreen rendering is enabled returns whether it is currently painting. + */ + isPainting(): boolean; + /** + * If offscreen rendering is enabled sets the frame rate to the specified number. + * Only values between 1 and 60 are accepted. + */ + setFrameRate(fps: number): void; + /** + * If offscreen rendering is enabled returns the current frame rate. + */ + getFrameRate(): number; /** * Sets the item as dragging item for current drag-drop operation. */ @@ -4679,6 +4762,10 @@ declare namespace Electron { * @returns The title of guest page. */ getTitle(): string; + /** + * @returns Whether the web page is destroyed. + */ + isDestroyed(): boolean; /** * @returns Whether guest page is still loading resources. */ From 8a2c4d2aceadb8f2545c3464ef447efad428f6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vlado=20Te=C5=A1anovi=C4=87?= Date: Thu, 11 Aug 2016 15:58:47 +0200 Subject: [PATCH 36/80] removed private function --- jsonschema/jsonschema.d.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/jsonschema/jsonschema.d.ts b/jsonschema/jsonschema.d.ts index 9e32dbfded..1c2f0f915e 100644 --- a/jsonschema/jsonschema.d.ts +++ b/jsonschema/jsonschema.d.ts @@ -98,17 +98,6 @@ declare module "jsonschema" { * @param urn */ getSchema(urn: string): {}; - - /** - * Validates an instance against the schema (the actual work horse) - * @param instance - * @param schema - * @param options - * @param ctx - * @private - * @return {IJSONSchemaResult} - */ - validateSchema(instance: any, schema: {}, options?: {}, ctx?: {}): IJSONSchemaResult } } From e611d74ee8345ddf400cd7fe353e9ff7991bf31a Mon Sep 17 00:00:00 2001 From: rbanderton Date: Thu, 11 Aug 2016 09:40:20 -0500 Subject: [PATCH 37/80] Added point.r function option Per https://github.com/c3js/c3/issues/179 supplying a function to `point.r` is supported. --- c3/c3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c3/c3.d.ts b/c3/c3.d.ts index f5159090d2..2838ba2675 100644 --- a/c3/c3.d.ts +++ b/c3/c3.d.ts @@ -747,7 +747,7 @@ declare namespace c3 { /** * The radius size of each point. */ - r?: number; + r?: number | ((d: any) => number); focus?: { expand: { From 935e0c7a782959f990479f7bc2ded1259a1fcbde Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 11 Aug 2016 18:34:05 +0100 Subject: [PATCH 38/80] Create inversify-inject-decorators.d.ts --- .../inversify-inject-decorators.d.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 inversify-inject-decorators/inversify-inject-decorators.d.ts diff --git a/inversify-inject-decorators/inversify-inject-decorators.d.ts b/inversify-inject-decorators/inversify-inject-decorators.d.ts new file mode 100644 index 0000000000..da567815e9 --- /dev/null +++ b/inversify-inject-decorators/inversify-inject-decorators.d.ts @@ -0,0 +1,32 @@ +// Type definitions for inversify-inject-decorators 1.0.0-beta.1 +// Project: https://github.com/inversify/inversify-inject-decorators +// Definitions by: inversify +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace inversifyInjectDecorators { + + interface InjectDecorators { + + lazyInject: (serviceIdentifier: (string|Symbol|inversify.interfaces.Newable)) => + (proto: any, key: string) => void; + + lazyInjectNamed: (serviceIdentifier: (string|Symbol|inversify.interfaces.Newable), named: string) => + (proto: any, key: string) => void; + + lazyInjectTagged: (serviceIdentifier: (string|Symbol|inversify.interfaces.Newable), key: string, value: any) => + (proto: any, propertyName: string) => void; + + lazyMultiInject: (serviceIdentifier: (string|Symbol|inversify.interfaces.Newable)) => + (proto: any, key: string) => void; + + } + + export default function getDecorators(kernel: inversify.interfaces.Kernel): InjectDecorators; + +} + +declare module "inversify-inject-decorators" { + export = inversifyInjectDecorators; +} From 4ee6064b2a017bff9d522e30c4b33b9f02d9fa8c Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 11 Aug 2016 18:34:56 +0100 Subject: [PATCH 39/80] Create inversify-inject-decorators-tests.ts --- .../inversify-inject-decorators-tests.ts | 214 ++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 inversify-inject-decorators/inversify-inject-decorators-tests.ts diff --git a/inversify-inject-decorators/inversify-inject-decorators-tests.ts b/inversify-inject-decorators/inversify-inject-decorators-tests.ts new file mode 100644 index 0000000000..468bbaf763 --- /dev/null +++ b/inversify-inject-decorators/inversify-inject-decorators-tests.ts @@ -0,0 +1,214 @@ +/// +/// + +import getDecorators from "inversify-inject-decorators"; +import { Kernel, injectable, tagged, named } from "inversify"; + +module lazyInject { + + let kernel = new Kernel(); + let { lazyInject } = getDecorators(kernel); + let TYPES = { Weapon: "Weapon" }; + + interface Weapon { + name: string; + durability: number; + use(): void; + } + + @injectable() + class Sword implements Weapon { + public name: string; + public durability: number; + public constructor() { + this.durability = 100; + this.name = "Sword"; + } + public use() { + this.durability = this.durability - 10; + } + } + + class Warrior { + @lazyInject(TYPES.Weapon) + public weapon: Weapon; + } + + kernel.bind(TYPES.Weapon).to(Sword); + + let warrior = new Warrior(); + console.log(warrior.weapon instanceof Sword); // true + +} + +module lazyInjectNamed { + + let kernel = new Kernel(); + let { lazyInjectNamed } = getDecorators(kernel); + let TYPES = { Weapon: "Weapon" }; + + interface Weapon { + name: string; + durability: number; + use(): void; + } + + @injectable() + class Sword implements Weapon { + public name: string; + public durability: number; + public constructor() { + this.durability = 100; + this.name = "Sword"; + } + public use() { + this.durability = this.durability - 10; + } + } + + @injectable() + class Shuriken implements Weapon { + public name: string; + public durability: number; + public constructor() { + this.durability = 100; + this.name = "Shuriken"; + } + public use() { + this.durability = this.durability - 10; + } + } + + class Warrior { + + @lazyInjectNamed(TYPES.Weapon, "not-throwwable") + @named("not-throwwable") + public primaryWeapon: Weapon; + + @lazyInjectNamed(TYPES.Weapon, "throwwable") + @named("throwwable") + public secondaryWeapon: Weapon; + + } + + kernel.bind(TYPES.Weapon).to(Sword).whenTargetNamed("not-throwwable"); + kernel.bind(TYPES.Weapon).to(Shuriken).whenTargetNamed("throwwable"); + + let warrior = new Warrior(); + console.log(warrior.primaryWeapon instanceof Sword); // true + console.log(warrior.primaryWeapon instanceof Shuriken); // true + +} + +module lazyInjectTagged { + + let kernel = new Kernel(); + let { lazyInjectTagged } = getDecorators(kernel); + let TYPES = { Weapon: "Weapon" }; + + interface Weapon { + name: string; + durability: number; + use(): void; + } + + @injectable() + class Sword implements Weapon { + public name: string; + public durability: number; + public constructor() { + this.durability = 100; + this.name = "Sword"; + } + public use() { + this.durability = this.durability - 10; + } + } + + @injectable() + class Shuriken implements Weapon { + public name: string; + public durability: number; + public constructor() { + this.durability = 100; + this.name = "Shuriken"; + } + public use() { + this.durability = this.durability - 10; + } + } + + class Warrior { + + @lazyInjectTagged(TYPES.Weapon, "throwwable", false) + @tagged("throwwable", false) + public primaryWeapon: Weapon; + + @lazyInjectTagged(TYPES.Weapon, "throwwable", true) + @tagged("throwwable", true) + public secondaryWeapon: Weapon; + + } + + kernel.bind(TYPES.Weapon).to(Sword).whenTargetTagged("throwwable", false); + kernel.bind(TYPES.Weapon).to(Shuriken).whenTargetTagged("throwwable", true); + + let warrior = new Warrior(); + console.log(warrior.primaryWeapon instanceof Sword); // true + console.log(warrior.primaryWeapon instanceof Shuriken); // true + +} + +module lazyMultiInject { + + let kernel = new Kernel(); + let { lazyMultiInject } = getDecorators(kernel); + let TYPES = { Weapon: "Weapon" }; + + interface Weapon { + name: string; + durability: number; + use(): void; + } + + @injectable() + class Sword implements Weapon { + public name: string; + public durability: number; + public constructor() { + this.durability = 100; + this.name = "Sword"; + } + public use() { + this.durability = this.durability - 10; + } + } + + @injectable() + class Shuriken implements Weapon { + public name: string; + public durability: number; + public constructor() { + this.durability = 100; + this.name = "Shuriken"; + } + public use() { + this.durability = this.durability - 10; + } + } + + class Warrior { + + @lazyMultiInject(TYPES.Weapon) + public weapons: Weapon[]; + + } + + kernel.bind(TYPES.Weapon).to(Sword); + kernel.bind(TYPES.Weapon).to(Shuriken); + + let warrior = new Warrior(); + console.log(warrior.weapons[0] instanceof Sword); // true + console.log(warrior.weapons[1] instanceof Shuriken); // true + +} From c27a53475311ffc7fa463f4124c7f11237a0997b Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 11 Aug 2016 18:47:12 +0100 Subject: [PATCH 40/80] Update inversify-inject-decorators.d.ts --- inversify-inject-decorators/inversify-inject-decorators.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inversify-inject-decorators/inversify-inject-decorators.d.ts b/inversify-inject-decorators/inversify-inject-decorators.d.ts index da567815e9..032ed40cdd 100644 --- a/inversify-inject-decorators/inversify-inject-decorators.d.ts +++ b/inversify-inject-decorators/inversify-inject-decorators.d.ts @@ -23,10 +23,10 @@ declare namespace inversifyInjectDecorators { } - export default function getDecorators(kernel: inversify.interfaces.Kernel): InjectDecorators; + export function getDecorators(kernel: inversify.interfaces.Kernel): InjectDecorators; } declare module "inversify-inject-decorators" { - export = inversifyInjectDecorators; + export default inversifyInjectDecorators.getDecorators; } From 8e3619521cbc2833679ee0cd7196b10d91a95666 Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Thu, 11 Aug 2016 19:20:48 +0300 Subject: [PATCH 41/80] Fixed XLSX typings --- xlsx/xlsx.d.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xlsx/xlsx.d.ts b/xlsx/xlsx.d.ts index 766be99457..68f89b545a 100644 --- a/xlsx/xlsx.d.ts +++ b/xlsx/xlsx.d.ts @@ -7,6 +7,7 @@ declare module 'xlsx' { export function readFile(filename:string, opts?:IParsingOptions):IWorkBook; export function read(data:any, opts?:IParsingOptions):IWorkBook; + export function write(data:any, opts?:IParsingOptions): any; export var utils:IUtils; export interface IProperties { @@ -41,6 +42,7 @@ declare module 'xlsx' { bookSheets?:boolean; bookVBA?:boolean; password?:string; + bookType?:string; /** * Possible options: 'binary', 'base64', 'buffer', 'file' @@ -127,14 +129,21 @@ declare module 'xlsx' { s?: string; } + export interface ICell { + c: number; + r: number; + } + export interface IUtils { sheet_to_json(worksheet:IWorkSheet, opts?: { raw?: boolean; range?: any; header?: "A"|number|string[]; }):T[]; - sheet_to_csv(worksheet:IWorkSheet):any; - sheet_to_formulae(worksheet:IWorkSheet):any; + sheet_to_csv(worksheet: IWorkSheet):any; + sheet_to_formulae(worksheet: IWorkSheet):any; + encode_cell(cell: ICell): any; + encode_range(s: ICell, e: ICell): any; } } From 479d12f779a8486edd58d451d7ca2a8728baf3dc Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Thu, 11 Aug 2016 14:56:46 -0500 Subject: [PATCH 42/80] Cleaned up resource interfaces. --- twilio/twilio.d.ts | 863 +++++++++------------------------------------ 1 file changed, 165 insertions(+), 698 deletions(-) diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index e7b28d7636..0b4de0c36d 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -44,7 +44,7 @@ export module twilio { // validateRequest // validateExpressRequest - /// ??? + /// Random stuff export interface GrantPayload {} export interface Grant { @@ -56,6 +56,39 @@ export module twilio { export interface RestMethod { (args: any | BaseRequestCallback, callback?: RequestCallback): Q.Promise; } + /// Resource stock interfaces + export interface BaseMappedResource { + (resourceSid: string): T; + } + + export interface Resource { + get: RestMethod; + } + + export interface DeletableResource extends Resource { + delete: RestMethod; + } + + export interface ListableResource extends Resource { + list: RestMethod; + } + + export interface MappedResource extends Resource, BaseMappedResource {} + + export interface PostableResource extends Resource { + post: RestMethod; + } + + export interface InstanceResource extends PostableResource, DeletableResource { + update: RestMethod; + } + + export interface CreatableMappedResource extends MappedResource, PostableResource { + create: RestMethod; + } + + export interface ListMappedResource extends CreatableMappedResource, ListableResource {} + /// AccessToken.js export interface IpMessagingGrantOptions { serviceSid: string; @@ -193,9 +226,9 @@ export module twilio { /// PricingClient.js export class PricingClient extends Client { - voice: VoiceResource; - phoneNumbers: PhoneNumberResource; - messaging: MessagingResource; + voice: PricingVoiceResource; + phoneNumbers: PricingPhoneNumberResource; + messaging: PricingMessagingResource; constructor(sid?: string, tkn?: string, options?: ClientOptions); } @@ -419,122 +452,49 @@ export module twilio { export function validateExpressRequest(request: Express.Request, authToken: string, options?: WebhookExpressOptions): boolean; /// resources/Accounts.js - export interface OutgoingCallerIdInstance { - get: RestMethod; - post: RestMethod; + export interface OutgoingCallerIdInstance extends InstanceResource { put: RestMethod; - delete: RestMethod; + } + export type OutgoingCallerIdResource = CreatableMappedResource; + + export type SMSMessageInstance = Resource; + export type SMSMessageResource = CreatableMappedResource; + + export interface SMSShortCodeInstance extends PostableResource { update: RestMethod; } - - export interface OutgoingCallerIdResource { - (resourceSid: string): OutgoingCallerIdInstance; - get: RestMethod; - post: RestMethod; - create: RestMethod; - } - - export interface SMSMessageInstance { - get: RestMethod; - } - - export interface SMSMessageResource { - (resourceSid: string): SMSMessageInstance; - get: RestMethod; - post: RestMethod; - create: RestMethod; - } - - export interface SMSShortCodeInstance { - get: RestMethod; - post: RestMethod; - update: RestMethod; - } - - export interface SMSShortCodeResource { - get: RestMethod; - } + export type SMSShortCodeResource = MappedResource; export interface SMSIntermediary { messages: SMSMessageResource; shortCodes: SMSShortCodeResource; } - export interface ApplicationInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; + export type ApplicationInstance = InstanceResource; + export type ApplicationResource = CreatableMappedResource; + + export interface ConnectAppInstance extends PostableResource { update: RestMethod; } + export type ConnectAppResource = MappedResource; - export interface ApplicationResource { - (resourceSid: string): ApplicationInstance; - get: RestMethod; - post: RestMethod; - create: RestMethod; - } - - export interface ConnectAppInstance { - get: RestMethod; - post: RestMethod; - update: RestMethod; - } - - export interface ConnectAppResource { - (resourceSid: string): ConnectAppInstance; - get: RestMethod; - } - - export interface AuthorizedConnectAppInstance { - get: RestMethod; - } - - export interface AuthorizedConnectAppResource { - (resourceSid: string): AuthorizedConnectAppInstance; - get: RestMethod; - } + export type AuthorizedConnectAppInstance = Resource; + export type AuthorizedConnectAppResource = MappedResource; export interface TokenInstance {} - - export interface TokenResource { - (resourceSid: string): TokenInstance; + export interface TokenResource extends BaseMappedResource { post: RestMethod; create: RestMethod; } - export interface TranscriptionInstance { - get: RestMethod; - delete: RestMethod; - } + export type TranscriptionInstance = DeletableResource; + export type TranscriptionResource = MappedResource; - export interface TranscriptionResource { - (resourceSid: string): TranscriptionInstance; - get: RestMethod; - } + export type NotificationInstance = DeletableResource; + export type NotificationResource = MappedResource; - export interface NotificationInstance { - get: RestMethod; - delete: RestMethod; - } - - export interface NotificationResource { - (resourceSid: string): NotificationInstance; - get: RestMethod; - } - - export interface UsageTriggerInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface UsageTriggerResource { - (resourceSid: string): UsageTriggerInstance; - get: RestMethod; - post: RestMethod; - create: RestMethod; - } + export type UsageTriggerInstance = InstanceResource; + export type UsageTriggerResource = CreatableMappedResource; export interface UsageIntermediary { records: UsageRecordResource; @@ -547,22 +507,12 @@ export module twilio { credentialLists: CredentialListResource; } - export interface KeyInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; + export type KeyInstance = InstanceResource; + export type KeyResource = CreatableMappedResource; + + export interface AccountInstance extends PostableResource { update: RestMethod; - } - - export interface KeyResource { - (resourceSid: string): KeyInstance; - get: RestMethod; - post: RestMethod; - create: RestMethod; - } - - export interface AccountResource { - (accountSid: string): AccountResource; + put: RestMethod; // Mixed-in resources availablePhoneNumbers: AvailablePhoneNumberResource; @@ -584,260 +534,108 @@ export module twilio { sip: SIPIntermediary; addresses: AddressResource; keys: KeyResource; - - // Mixed-in Methods - put: RestMethod; - post: RestMethod; - get: RestMethod; - update: RestMethod; - list: RestMethod; } + export interface AccountResource extends AccountInstance, ListMappedResource {} + /// resources/Addresses.js - export interface DependentPhoneNumberResource { - get: RestMethod; - list: RestMethod; - } + export type DependentPhoneNumberResource = ListableResource; - export interface AddressInstance { + export interface AddressInstance extends PostableResource, DeletableResource { // Mixins dependentPhoneNumbers: DependentPhoneNumberResource; - - // Rest Methods - get: RestMethod; - post: RestMethod; - delete: RestMethod; - } - - export interface AddressResource { - (resourceSid: string): AddressInstance; - get: RestMethod; - list: RestMethod; - post: RestMethod; - create: RestMethod; } + export type AddressResource = ListMappedResource; /// resources/AvailablePhoneNumbers.js - export interface AvailablePhoneNumberResourceGroup { - get: RestMethod; - list: RestMethod; + export interface AvailablePhoneNumberResourceGroup extends ListableResource { search: RestMethod; } - export interface AvailablePhoneNumberInstance { local: AvailablePhoneNumberResourceGroup; tollFree: AvailablePhoneNumberResourceGroup; mobile: AvailablePhoneNumberResourceGroup; } - - export interface AvailablePhoneNumberResource { - (isoCode: string): AvailablePhoneNumberInstance; - } + export type AvailablePhoneNumberResource = BaseMappedResource; /// resources/Calls.js - export interface CallRecordingResource { - get: RestMethod; - list: RestMethod; - } - - export interface CallNotificationResource { - get: RestMethod; - list: RestMethod; - } - - export interface CallFeedbackResource { - get: RestMethod; - post: RestMethod; - delete: RestMethod; + export type CallRecordingResource = ListableResource; + export type CallNotificationResource = ListableResource; + export interface CallFeedbackResource extends PostableResource, DeletableResource { create: RestMethod; } - export interface CallInstance { + export interface CallInstance extends InstanceResource { recordings: CallRecordingResource; notifications: CallNotificationResource; feedback: CallFeedbackResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; } - export interface CallFeedbackSummaryInstance { - get: RestMethod; - delete: RestMethod; - } - - export interface CallFeedbackSummaryResource { - (resourceSid: string): CallFeedbackSummaryInstance; + export type CallFeedbackSummaryInstance = DeletableResource; + export interface CallFeedbackSummaryResource extends BaseMappedResource { post: RestMethod; create: RestMethod; } - - export interface CallResource { - (resourceSid: string): CallInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - + export interface CallResource extends CreatableMappedResource { feedbackSummary: CallFeedbackSummaryResource; } /// resources/Conferences.js - export interface ConferenceParticipantInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; + export interface ConferenceParticipantInstance extends InstanceResource { kick: RestMethod; } - - export interface ConferenceParticipantResource { - (resourceSid: string): ConferenceParticipantInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface ConferenceInstance { - get: RestMethod; - + export interface ConferenceParticipantResource extends MappedResource, ListableResource {} + export interface ConferenceInstance extends Resource { participants: ConferenceParticipantResource; } - - export interface ConferenceResource { - (resourceSid: string): ConferenceInstance; - - get: RestMethod; - list: RestMethod; - } + export interface ConferenceResource extends MappedResource, ListableResource {} /// resources/IncomingPhoneNumbers.js - export interface IncomingPhoneNumberResourceGroup { - get: RestMethod; - post: RestMethod; + export interface IncomingPhoneNumberResourceGroup extends PostableResource { create: RestMethod; } - - export interface IncomingPhoneNumberInstance { - get: RestMethod; - post: RestMethod; + export interface IncomingPhoneNumberInstance extends InstanceResource { put: RestMethod; - delete: RestMethod; - update: RestMethod; } - - export interface IncomingPhoneNumberResource { - (resourceSid: string): IncomingPhoneNumberInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - + export interface IncomingPhoneNumberResource extends CreatableMappedResource { local: IncomingPhoneNumberResourceGroup; tollFree: IncomingPhoneNumberResourceGroup; mobile: IncomingPhoneNumberResourceGroup; } /// resources/Messages.js - export interface MessageMediaInstance { - get: RestMethod; - delete: RestMethod; - } - - export interface MessageMediaResource { - (resourceSid: string): MessageMediaInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface MessageInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - + export type MessageMediaInstance = DeletableResource; + export interface MessageMediaResource extends MappedResource, ListableResource {} + export interface MessageInstance extends PostableResource, DeletableResource { media: MessageMediaResource; } - - export interface MessageResource { - (resourceSid: string): MessageInstance; - - get: RestMethod; - list: RestMethod; - post: RestMethod; - create: RestMethod; - } + export type MessageResource = ListMappedResource; /// resources/Queues.js - export interface QueueMemberInstance { - get: RestMethod; - post: RestMethod; + export interface QueueMemberInstance extends PostableResource { update: RestMethod; } - - export interface QueueMemberResource { - (resourceSid: string): QueueMemberInstance; - - get: RestMethod; - + export interface QueueMemberResource extends MappedResource { front: QueueMemberInstance; } - export interface QueueInstance { + export interface QueueInstance extends InstanceResource { members: QueueMemberResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface QueueResource { - (resourceSid: string): QueueInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; } + export type QueueResource = CreatableMappedResource; /// resources/Recordings.js - export interface RecordingTranscriptionResource { - get: RestMethod; - list: RestMethod; - } - - export interface RecordingInstance { - get: RestMethod; - list: RestMethod; - delete: RestMethod; - + export type RecordingTranscriptionResource = ListableResource; + export interface RecordingInstance extends ListableResource, DeletableResource { transcriptions: RecordingTranscriptionResource; } - - export interface RecordingResource { - (resourceSid: string): RecordingInstance; - - get: RestMethod; - list: RestMethod; - } + export interface RecordingResource extends MappedResource, ListableResource {} /// resources/UsageRecords.js - export interface UsageRecordInstance { - get: RestMethod; - } - - export interface UsageRecordRange { - get: RestMethod; - list: RestMethod; - } - - export interface UsageRecordResource { - (resourceSid: string): UsageRecordInstance; - - get: RestMethod; + export type UsageRecordInstance = Resource; + export type UsageRecordRange = ListableResource; + export interface UsageRecordResource extends MappedResource { daily: UsageRecordRange; monthly: UsageRecordRange; yearly: UsageRecordRange; @@ -849,293 +647,95 @@ export module twilio { } /// resources/ip_messaging/Credentials.js - export interface CredentialInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface CredentialResource { - (resourceSid: string): CredentialInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } + export type CredentialInstance = InstanceResource; + export type CredentialResource = ListMappedResource; /// resources/ip_messaging/Services.js - export interface ServiceUserInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } + export type ServiceUserInstance = InstanceResource; + export type ServiceUserResource = ListMappedResource; + export type ServiceRoleInstance = Resource; + export interface ServiceRoleResource extends MappedResource, ListableResource {} - export interface ServiceUserResource { - (resourceSid: string): ServiceUserInstance; + export type ServiceChannelMessageInstance = InstanceResource; + export type ServiceChannelMessageResource = ListMappedResource; - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } - - export interface ServiceRoleInstance { - get: RestMethod; - } - - export interface ServiceRoleResource { - (resourceSid: string): ServiceRoleInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface ServiceChannelMessageInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface ServiceChannelMessageResource { - (resourceSid: string): ServiceChannelMessageInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } - - export interface ServiceChannelMemberInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface ServiceChannelMemberResource { - (resourceSid: string): ServiceChannelMemberInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } - - export interface ServiceChannelInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; + export type ServiceChannelMemberInstance = InstanceResource; + export type ServiceChannelMemberResource = ListMappedResource; + export interface ServiceChannelInstance extends InstanceResource { messages: ServiceChannelMessageResource; members: ServiceChannelMemberResource; } + export type ServiceChannelResource = ListMappedResource; - export interface ServiceChannelResource { - (resourceSid: string): ServiceChannelInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } - - export interface ServiceInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - + export interface ServiceInstance extends InstanceResource { users: ServiceUserResource; roles: ServiceRoleResource; channels: ServiceChannelResource; } - - export interface ServiceResource { - (resourceSid: string): ServiceInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } + export type ServiceResource = ListMappedResource; /// resources/lookups/PhoneNumbers.js - export interface PhoneNumberInstance { - get: RestMethod; - } - - export interface PhoneNumberResource { - (resourceSid: string): PhoneNumberInstance; - } + export type PhoneNumberInstance = Resource; + export type PhoneNumberResource = BaseMappedResource; /// resources/monitor/Alerts.js - export interface AlertInstance { - get: RestMethod; - } - - export interface AlertResource { - (resourceSid: string): AlertInstance; - - get: RestMethod; - list: RestMethod; - } + export type AlertInstance = Resource; + export interface AlertResource extends MappedResource, ListableResource {} /// resources/monitor/Events.js - export interface EventInstance { - get: RestMethod; - } - - export interface EventResource { - (resourceSid: string): EventInstance; - - get: RestMethod; - list: RestMethod; - } + export type EventInstance = Resource; + export interface EventResource extends MappedResource, ListableResource {} /// resources/pricing/Messaging.js - export interface CountryInstance { - get: RestMethod; - } + export type CountryInstance = Resource; + export interface CountryResource extends MappedResource, ListableResource {} - export interface CountryResource { - (resourceSid: string): CountryInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface MessagingResource { + export interface PricingMessagingResource { countries: CountryResource; } /// resources/pricing/PhoneNumbers.js - export interface PhoneNumberResource { + export interface PricingPhoneNumberResource { countries: CountryResource; } /// resources/pricing/Voice.js - export interface NumberInstance { - get: RestMethod; - } + export type NumberInstance = Resource; + export interface NumberResource extends MappedResource, ListableResource {} - export interface NumberResource { - (resourceSid: string): NumberInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface VoiceResource { + export interface PricingVoiceResource { countries: CountryResource; numbers: NumberResource; } /// resources/sip/CredentialLists.js - export interface CredentialListInstance { + export interface CredentialListInstance extends InstanceResource { credentials: CredentialResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface CredentialListResource { - (resourceSid: string): CredentialListInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; } + export type CredentialListResource = ListMappedResource; /// resources/sip/Domains.js - export interface IPAccessControlListMappingInstance { - get: RestMethod; - delete: RestMethod; - } + export type IPAccessControlListMappingInstance = DeletableResource; + export type IPAccessControlListMappingResource = ListMappedResource; - export interface IPAccessControlListMappingResource { - (resourceSid: string): IPAccessControlListMappingInstance; + export type CredentialListMappingInstance = DeletableResource; + export type CredentialListMappingResource = ListMappedResource; - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } - - export interface CredentialListMappingInstance { - get: RestMethod; - delete: RestMethod; - } - - export interface CredentialListMappingResource { - (resourceSid: string): CredentialListMappingInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } - - export interface DomainInstance { + export interface DomainInstance extends InstanceResource { ipAccessControlListMappings: IPAccessControlListMappingResource; credentialListMappings: CredentialListMappingResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface DomainResource { - (resourceSid: string): DomainInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; } + export type DomainResource = ListMappedResource; /// resources/sip/IpAccessControlLists.js - export interface IPAddressInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } + export type IPAddressInstance = InstanceResource; + export type IPAddressResource = ListMappedResource; - export interface IPAddressResource { - (resourceSid: string): IPAddressInstance; - - get: RestMethod; - post: RestMethod; - list: RestMethod; - create: RestMethod; - } - - export interface IPAccessControlListInstance { + export interface IPAccessControlListInstance extends InstanceResource { ipAddresses: IPAddressResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface IPAccessControlListResource { - (resourceSid: string): IPAccessControlListInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; } + export type IPAccessControlListResource = ListMappedResource; /// resources/task_router/WorkflowBuilder.js export interface WorkflowRuleTargetOptions { @@ -1202,148 +802,53 @@ export module twilio { } /// resources/task_router/Workspaces.js - export interface WorkspaceActivityInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; + export type WorkspaceActivityInstance = InstanceResource; + export type WorkspaceActivityResource = ListMappedResource; + + export type WorkspaceEventInstance = Resource; + export interface WorkspaceEventResource extends MappedResource, ListableResource {} + + export interface WorkspaceTaskReservationInstance extends PostableResource { update: RestMethod; } + export interface WorkspaceTaskReservationResource extends MappedResource, ListableResource {} - export interface WorkspaceActivityResource { - (resourceSid: string): WorkspaceActivityInstance; - - get: RestMethod; - post: RestMethod; - list: RestMethod; - create: RestMethod; - } - - export interface WorkspaceEventInstance { - get: RestMethod; - } - - export interface WorkspaceEventResource { - (resourceSid: string): WorkspaceEventInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface WorkspaceTaskReservationInstance { - get: RestMethod; - post: RestMethod; - update: RestMethod; - } - - export interface WorkspaceTaskReservationResource { - (resourceSid: string): WorkspaceTaskReservationInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface WorkspaceTaskInstance { + export interface WorkspaceTaskInstance extends InstanceResource { reservations: WorkspaceTaskReservationResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; } + export type WorkspaceTaskResource = ListMappedResource; - export interface WorkspaceTaskResource { - (resourceSid: string): WorkspaceTaskInstance; + export type WorkspaceInstanceStatisticResource = Resource; + export type WorkspaceStatisticResource = ListableResource; - get: RestMethod; - post: RestMethod; - list: RestMethod; - create: RestMethod; - } - - export interface WorkspaceInstanceStatisticResource { - get: RestMethod; - } - - export interface WorkspaceStatisticResource { - get: RestMethod; - list: RestMethod; - } - - export interface WorkspaceTaskQueueInstance { + export interface WorkspaceTaskQueueInstance extends InstanceResource { statistics: WorkspaceInstanceStatisticResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; } - - export interface WorkspaceTaskQueueResource { - (resourceSid: string): WorkspaceTaskQueueInstance; - + export interface WorkspaceTaskQueueResource extends ListMappedResource { statistics: WorkspaceStatisticResource; - - get: RestMethod; - post: RestMethod; - list: RestMethod; - create: RestMethod; } - export interface WorkspaceWorkerReservationInstance { - get: RestMethod; - post: RestMethod; + export interface WorkspaceWorkerReservationInstance extends PostableResource { update: RestMethod; } + export interface WorkspaceWorkerReservationResource extends MappedResource, ListableResource {} - export interface WorkspaceWorkerReservationResource { - (resourceSid: string): WorkspaceWorkerReservationInstance; - - get: RestMethod; - list: RestMethod; - } - - export interface WorkspaceWorkerInstance { + export interface WorkspaceWorkerInstance extends InstanceResource { statistics: WorkspaceInstanceStatisticResource; reservations: WorkspaceWorkerReservationResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; } - - export interface WorkspaceWorkerResource { - (resourceSid: string): WorkspaceWorkerInstance; - + export interface WorkspaceWorkerResource extends ListMappedResource { statistics: WorkspaceStatisticResource; - - get: RestMethod; - post: RestMethod; - list: RestMethod; - create: RestMethod; } - export interface WorkspaceWorkflowInstance { + export interface WorkspaceWorkflowInstance extends InstanceResource { statistics: WorkspaceInstanceStatisticResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; } - - export interface WorkspaceWorkflowResource { - (resourceSid: string): WorkspaceWorkflowInstance; - + export interface WorkspaceWorkflowResource extends ListMappedResource { statistics: WorkspaceStatisticResource; - - get: RestMethod; - post: RestMethod; - list: RestMethod; - create: RestMethod; } - export interface WorkspaceInstance { + export interface WorkspaceInstance extends InstanceResource { activities: WorkspaceActivityResource; events: WorkspaceEventResource; tasks: WorkspaceTaskResource; @@ -1352,57 +857,19 @@ export module twilio { workflows: WorkspaceWorkflowResource; statistics: WorkspaceInstanceStatisticResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface WorkspaceResource { - (resourceSid: string): WorkspaceInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; } + export type WorkspaceResource = CreatableMappedResource; /// resources/trunking/Trunks.js - export interface OriginationURLInstance { - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } + export type OriginationURLInstance = InstanceResource; + export type OriginationURLResource = ListMappedResource; - export interface OriginationURLResource { - (resourceSid: string): OriginationURLInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; - } - - export interface TrunkInstance { + export interface TrunkInstance extends InstanceResource { ipAccessControlLists: IPAccessControlListResource; credentialLists: CredentialListResource; phoneNumbers: PhoneNumberResource; originationUrls: OriginationURLResource; - - get: RestMethod; - post: RestMethod; - delete: RestMethod; - update: RestMethod; - } - - export interface TrunkResource { - (resourceSid: string): TrunkInstance; - - get: RestMethod; - post: RestMethod; - create: RestMethod; - list: RestMethod; } + export type TrunkResource = ListMappedResource; } \ No newline at end of file From b860065390ce0fd739fcc662db0f9446b6a035b3 Mon Sep 17 00:00:00 2001 From: Nicholas Iannone Date: Thu, 11 Aug 2016 15:09:20 -0500 Subject: [PATCH 43/80] Swapped type definition for interface definition for backwards compatibility. --- twilio/twilio.d.ts | 130 ++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/twilio/twilio.d.ts b/twilio/twilio.d.ts index 0b4de0c36d..93630f0da2 100644 --- a/twilio/twilio.d.ts +++ b/twilio/twilio.d.ts @@ -455,31 +455,31 @@ export module twilio { export interface OutgoingCallerIdInstance extends InstanceResource { put: RestMethod; } - export type OutgoingCallerIdResource = CreatableMappedResource; + export interface OutgoingCallerIdResource extends CreatableMappedResource {} - export type SMSMessageInstance = Resource; - export type SMSMessageResource = CreatableMappedResource; + export interface SMSMessageInstance extends Resource {} + export interface SMSMessageResource extends CreatableMappedResource {} export interface SMSShortCodeInstance extends PostableResource { update: RestMethod; } - export type SMSShortCodeResource = MappedResource; + export interface SMSShortCodeResource extends MappedResource {} export interface SMSIntermediary { messages: SMSMessageResource; shortCodes: SMSShortCodeResource; } - export type ApplicationInstance = InstanceResource; - export type ApplicationResource = CreatableMappedResource; + export interface ApplicationInstance extends InstanceResource {} + export interface ApplicationResource extends CreatableMappedResource {} export interface ConnectAppInstance extends PostableResource { update: RestMethod; } - export type ConnectAppResource = MappedResource; + export interface ConnectAppResource extends MappedResource {} - export type AuthorizedConnectAppInstance = Resource; - export type AuthorizedConnectAppResource = MappedResource; + export interface AuthorizedConnectAppInstance extends Resource {} + export interface AuthorizedConnectAppResource extends MappedResource {} export interface TokenInstance {} export interface TokenResource extends BaseMappedResource { @@ -487,14 +487,14 @@ export module twilio { create: RestMethod; } - export type TranscriptionInstance = DeletableResource; - export type TranscriptionResource = MappedResource; + export interface TranscriptionInstance extends DeletableResource {} + export interface TranscriptionResource extends MappedResource {} - export type NotificationInstance = DeletableResource; - export type NotificationResource = MappedResource; + export interface NotificationInstance extends DeletableResource {} + export interface NotificationResource extends MappedResource {} - export type UsageTriggerInstance = InstanceResource; - export type UsageTriggerResource = CreatableMappedResource; + export interface UsageTriggerInstance extends InstanceResource {} + export interface UsageTriggerResource extends CreatableMappedResource {} export interface UsageIntermediary { records: UsageRecordResource; @@ -507,8 +507,8 @@ export module twilio { credentialLists: CredentialListResource; } - export type KeyInstance = InstanceResource; - export type KeyResource = CreatableMappedResource; + export interface KeyInstance extends InstanceResource {} + export interface KeyResource extends CreatableMappedResource {} export interface AccountInstance extends PostableResource { update: RestMethod; @@ -539,13 +539,13 @@ export module twilio { export interface AccountResource extends AccountInstance, ListMappedResource {} /// resources/Addresses.js - export type DependentPhoneNumberResource = ListableResource; + export interface DependentPhoneNumberResource extends ListableResource {} export interface AddressInstance extends PostableResource, DeletableResource { // Mixins dependentPhoneNumbers: DependentPhoneNumberResource; } - export type AddressResource = ListMappedResource; + export interface AddressResource extends ListMappedResource {} /// resources/AvailablePhoneNumbers.js export interface AvailablePhoneNumberResourceGroup extends ListableResource { @@ -556,11 +556,11 @@ export module twilio { tollFree: AvailablePhoneNumberResourceGroup; mobile: AvailablePhoneNumberResourceGroup; } - export type AvailablePhoneNumberResource = BaseMappedResource; + export interface AvailablePhoneNumberResource extends BaseMappedResource {} /// resources/Calls.js - export type CallRecordingResource = ListableResource; - export type CallNotificationResource = ListableResource; + export interface CallRecordingResource extends ListableResource {} + export interface CallNotificationResource extends ListableResource {} export interface CallFeedbackResource extends PostableResource, DeletableResource { create: RestMethod; } @@ -571,7 +571,7 @@ export module twilio { feedback: CallFeedbackResource; } - export type CallFeedbackSummaryInstance = DeletableResource; + export interface CallFeedbackSummaryInstance extends DeletableResource {} export interface CallFeedbackSummaryResource extends BaseMappedResource { post: RestMethod; create: RestMethod; @@ -604,12 +604,12 @@ export module twilio { } /// resources/Messages.js - export type MessageMediaInstance = DeletableResource; + export interface MessageMediaInstance extends DeletableResource {} export interface MessageMediaResource extends MappedResource, ListableResource {} export interface MessageInstance extends PostableResource, DeletableResource { media: MessageMediaResource; } - export type MessageResource = ListMappedResource; + export interface MessageResource extends ListMappedResource {} /// resources/Queues.js export interface QueueMemberInstance extends PostableResource { @@ -622,18 +622,18 @@ export module twilio { export interface QueueInstance extends InstanceResource { members: QueueMemberResource; } - export type QueueResource = CreatableMappedResource; + export interface QueueResource extends CreatableMappedResource {} /// resources/Recordings.js - export type RecordingTranscriptionResource = ListableResource; + export interface RecordingTranscriptionResource extends ListableResource {} export interface RecordingInstance extends ListableResource, DeletableResource { transcriptions: RecordingTranscriptionResource; } export interface RecordingResource extends MappedResource, ListableResource {} /// resources/UsageRecords.js - export type UsageRecordInstance = Resource; - export type UsageRecordRange = ListableResource; + export interface UsageRecordInstance extends Resource {} + export interface UsageRecordRange extends ListableResource {} export interface UsageRecordResource extends MappedResource { daily: UsageRecordRange; @@ -647,48 +647,48 @@ export module twilio { } /// resources/ip_messaging/Credentials.js - export type CredentialInstance = InstanceResource; - export type CredentialResource = ListMappedResource; + export interface CredentialInstance extends InstanceResource {} + export interface CredentialResource extends ListMappedResource {} /// resources/ip_messaging/Services.js - export type ServiceUserInstance = InstanceResource; - export type ServiceUserResource = ListMappedResource; - export type ServiceRoleInstance = Resource; + export interface ServiceUserInstance extends InstanceResource {} + export interface ServiceUserResource extends ListMappedResource {} + export interface ServiceRoleInstance extends Resource {} export interface ServiceRoleResource extends MappedResource, ListableResource {} - export type ServiceChannelMessageInstance = InstanceResource; - export type ServiceChannelMessageResource = ListMappedResource; + export interface ServiceChannelMessageInstance extends InstanceResource {} + export interface ServiceChannelMessageResource extends ListMappedResource {} - export type ServiceChannelMemberInstance = InstanceResource; - export type ServiceChannelMemberResource = ListMappedResource; + export interface ServiceChannelMemberInstance extends InstanceResource {} + export interface ServiceChannelMemberResource extends ListMappedResource {} export interface ServiceChannelInstance extends InstanceResource { messages: ServiceChannelMessageResource; members: ServiceChannelMemberResource; } - export type ServiceChannelResource = ListMappedResource; + export interface ServiceChannelResource extends ListMappedResource {} export interface ServiceInstance extends InstanceResource { users: ServiceUserResource; roles: ServiceRoleResource; channels: ServiceChannelResource; } - export type ServiceResource = ListMappedResource; + export interface ServiceResource extends ListMappedResource {} /// resources/lookups/PhoneNumbers.js - export type PhoneNumberInstance = Resource; - export type PhoneNumberResource = BaseMappedResource; + export interface PhoneNumberInstance extends Resource {} + export interface PhoneNumberResource extends BaseMappedResource {} /// resources/monitor/Alerts.js - export type AlertInstance = Resource; + export interface AlertInstance extends Resource {} export interface AlertResource extends MappedResource, ListableResource {} /// resources/monitor/Events.js - export type EventInstance = Resource; + export interface EventInstance extends Resource {} export interface EventResource extends MappedResource, ListableResource {} /// resources/pricing/Messaging.js - export type CountryInstance = Resource; + export interface CountryInstance extends Resource {} export interface CountryResource extends MappedResource, ListableResource {} export interface PricingMessagingResource { @@ -701,7 +701,7 @@ export module twilio { } /// resources/pricing/Voice.js - export type NumberInstance = Resource; + export interface NumberInstance extends Resource {} export interface NumberResource extends MappedResource, ListableResource {} export interface PricingVoiceResource { @@ -713,29 +713,29 @@ export module twilio { export interface CredentialListInstance extends InstanceResource { credentials: CredentialResource; } - export type CredentialListResource = ListMappedResource; + export interface CredentialListResource extends ListMappedResource {} /// resources/sip/Domains.js - export type IPAccessControlListMappingInstance = DeletableResource; - export type IPAccessControlListMappingResource = ListMappedResource; + export interface IPAccessControlListMappingInstance extends DeletableResource {} + export interface IPAccessControlListMappingResource extends ListMappedResource {} - export type CredentialListMappingInstance = DeletableResource; - export type CredentialListMappingResource = ListMappedResource; + export interface CredentialListMappingInstance extends DeletableResource {} + export interface CredentialListMappingResource extends ListMappedResource {} export interface DomainInstance extends InstanceResource { ipAccessControlListMappings: IPAccessControlListMappingResource; credentialListMappings: CredentialListMappingResource; } - export type DomainResource = ListMappedResource; + export interface DomainResource extends ListMappedResource {} /// resources/sip/IpAccessControlLists.js - export type IPAddressInstance = InstanceResource; - export type IPAddressResource = ListMappedResource; + export interface IPAddressInstance extends InstanceResource {} + export interface IPAddressResource extends ListMappedResource {} export interface IPAccessControlListInstance extends InstanceResource { ipAddresses: IPAddressResource; } - export type IPAccessControlListResource = ListMappedResource; + export interface IPAccessControlListResource extends ListMappedResource {} /// resources/task_router/WorkflowBuilder.js export interface WorkflowRuleTargetOptions { @@ -802,10 +802,10 @@ export module twilio { } /// resources/task_router/Workspaces.js - export type WorkspaceActivityInstance = InstanceResource; - export type WorkspaceActivityResource = ListMappedResource; + export interface WorkspaceActivityInstance extends InstanceResource {} + export interface WorkspaceActivityResource extends ListMappedResource {} - export type WorkspaceEventInstance = Resource; + export interface WorkspaceEventInstance extends Resource {} export interface WorkspaceEventResource extends MappedResource, ListableResource {} export interface WorkspaceTaskReservationInstance extends PostableResource { @@ -816,10 +816,10 @@ export module twilio { export interface WorkspaceTaskInstance extends InstanceResource { reservations: WorkspaceTaskReservationResource; } - export type WorkspaceTaskResource = ListMappedResource; + export interface WorkspaceTaskResource extends ListMappedResource {} - export type WorkspaceInstanceStatisticResource = Resource; - export type WorkspaceStatisticResource = ListableResource; + export interface WorkspaceInstanceStatisticResource extends Resource {} + export interface WorkspaceStatisticResource extends ListableResource {} export interface WorkspaceTaskQueueInstance extends InstanceResource { statistics: WorkspaceInstanceStatisticResource; @@ -858,11 +858,11 @@ export module twilio { statistics: WorkspaceInstanceStatisticResource; } - export type WorkspaceResource = CreatableMappedResource; + export interface WorkspaceResource extends CreatableMappedResource {} /// resources/trunking/Trunks.js - export type OriginationURLInstance = InstanceResource; - export type OriginationURLResource = ListMappedResource; + export interface OriginationURLInstance extends InstanceResource {} + export interface OriginationURLResource extends ListMappedResource {} export interface TrunkInstance extends InstanceResource { ipAccessControlLists: IPAccessControlListResource; @@ -870,6 +870,6 @@ export module twilio { phoneNumbers: PhoneNumberResource; originationUrls: OriginationURLResource; } - export type TrunkResource = ListMappedResource; + export interface TrunkResource extends ListMappedResource {} } \ No newline at end of file From da354071c00aba723e72b1b0ce6b948f54f1ccb1 Mon Sep 17 00:00:00 2001 From: Ahmet Kiyak Date: Thu, 11 Aug 2016 23:30:59 +0200 Subject: [PATCH 44/80] Update stripe.d.ts Pass expiration date as single string https://stripe.com/docs/stripe.js#passing-exp-dates --- stripe/stripe.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 659c75bf3e..8a03ee3f33 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -17,8 +17,9 @@ interface StripeStatic { interface StripeTokenData { number: string; - exp_month: number; - exp_year: number; + exp_month?: number; + exp_year?: number; + exp?: string; cvc?: string; name?: string; address_line1?: string; From c3049e250452c5d00f6c4e58e3f64fd81f646968 Mon Sep 17 00:00:00 2001 From: microshine Date: Fri, 12 Aug 2016 00:41:00 +0300 Subject: [PATCH 45/80] Fix type error --- pkcs11js/pkcs11js.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkcs11js/pkcs11js.d.ts b/pkcs11js/pkcs11js.d.ts index c340ca2112..dcbdb401cb 100644 --- a/pkcs11js/pkcs11js.d.ts +++ b/pkcs11js/pkcs11js.d.ts @@ -210,7 +210,7 @@ declare module "pkcs11js" { * @param {Handle} slot ID of token's slot * @returns {Handle[]} Gets mech. array */ - C_GetMechanismList(slot: Handle): Handle[]; + C_GetMechanismList(slot: Handle): number[]; /** * Obtains information about a particular mechanism possibly supported by a token * @@ -218,7 +218,7 @@ declare module "pkcs11js" { * @param {Handle} mech Type of mechanism * @returns {MechanismInfo} Receives mechanism info */ - C_GetMechanismInfo(slot: Handle, mech: Handle): MechanismInfo; + C_GetMechanismInfo(slot: Handle, mech: number): MechanismInfo; /* Session management */ From 4f5debab4b1d135bd75d5cd2e4c7b8721d42c5cf Mon Sep 17 00:00:00 2001 From: microshine Date: Fri, 12 Aug 2016 00:43:48 +0300 Subject: [PATCH 46/80] Update types --- graphene-pk11/graphene-pk11.d.ts | 3745 +++++++++++++----------------- 1 file changed, 1636 insertions(+), 2109 deletions(-) diff --git a/graphene-pk11/graphene-pk11.d.ts b/graphene-pk11/graphene-pk11.d.ts index 4453a921f1..2ebec894dd 100644 --- a/graphene-pk11/graphene-pk11.d.ts +++ b/graphene-pk11/graphene-pk11.d.ts @@ -1,1230 +1,276 @@ -// Type definitions for graphene-pk11 v2.0.0 +// Type definitions for graphene-pk11 v2.0.2 // Project: https://github.com/PeculiarVentures/graphene // Definitions by: Stepan Miroshin // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// /** * A simple layer for interacting with PKCS #11 / PKCS11 / CryptoKI for Node - * v2.0.0 + * v2.0.2 */ -declare module "graphene-pk11" { - type Callback = (err: Error, rv: number) => void; - type CK_PTR = Buffer; +declare module "types/graphene-pk11" { + import * as graphene from "graphene-pk11"; + import * as pkcs11 from "pkcs11js"; - class Pkcs11 { - lib: any; - /** - * load a library with PKCS11 interface - * @param {string} libFile path to PKCS11 library - */ - constructor(libFile: string); - protected callFunction(funcName: string, args: any[]): number; - /** - * C_Initialize initializes the Cryptoki library. - * @param pInitArgs if this is not NULL_PTR, it gets - * cast to CK_C_INITIALIZE_ARGS_PTR - * and dereferenced - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Initialize(pInitArgs?: CK_PTR): number; - C_Initialize(pInitArgs: CK_PTR, cllback: Callback): void; - /** - * C_Finalize indicates that an application is done with the Cryptoki library. - * @param pReserved reserved. Should be NULL_PTR - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Finalize(pReserved?: CK_PTR): number; - C_Finalize(pReserved: CK_PTR, callback: Callback): void; - /** - * C_GetInfo returns general information about Cryptoki. - * @param pInfo location that receives information - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetInfo(pInfo: CK_PTR): number; - C_GetInfo(pInfo: CK_PTR, callback: Callback): void; - /** - * C_GetSlotList obtains a list of slots in the system. - * @param {boolean} tokenPresent only slots with tokens? - * @param pSlotList receives array of slot IDs - * @param pulCount receives number of slots - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetSlotList(tokenPresent: boolean, pSlotList: CK_PTR, pulCount: CK_PTR): number; - C_GetSlotList(tokenPresent: boolean, pSlotList: CK_PTR, pulCount: CK_PTR, callback: Callback): void; - /** - * C_GetSlotInfo obtains information about a particular slot in - * the system. - * @param {number} slotID the ID of the slot - * @param {Buffer} pInfo receives the slot information - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetSlotInfo(slotID: number, pInfo: CK_PTR): number; - C_GetSlotInfo(slotID: number, pInfo: CK_PTR, callback: Callback): void; - /** - * C_GetTokenInfo obtains information about a particular token - * in the system. - * @param {number} slotID ID of the token's slot - * @param {Buffer} pInfo receives the token information - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetTokenInfo(slotID: number, pInfo: Buffer): number; - C_GetTokenInfo(slotID: number, pInfo: Buffer, callback: Callback): void; - /** - * C_GetMechanismList obtains a list of mechanism types - * supported by a token. - * @param {number} slotID ID of the token's slot - * @param {number} pMechanismList gets mech. array - * @param {number} pulCount gets # of mechs - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetMechanismList(slotID: number, pMechanismList: Buffer, pulCount: Buffer): number; - C_GetMechanismList(slotID: number, pMechanismList: Buffer, pulCount: Buffer, callback: Callback): void; - /** C_GetMechanismInfo obtains information about a particular - * mechanism possibly supported by a token. - * @param {number} slotID ID of the token's slot - * @param {number} type type of mechanism - * @param {Buffer} pInfo receives mechanism info - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetMechanismInfo(slotID: number, type: number, pInfo: Buffer): number; - C_GetMechanismInfo(slotID: number, type: number, pInfo: Buffer, callback: Callback): void; - /** - * C_InitToken initializes a token. - * @param {number} slotID ID of the token's slot - * @param {Buffer} pPin the SO's initial PIN - * @param {number} ulPinLen length in bytes of the PIN - * @param {number} pLabel 32-byte token label (blank padded) - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_InitToken(slotID: number, pPin: Buffer, ulPinLen: number, pLabel: Buffer): number; - C_InitToken(slotID: number, pPin: Buffer, ulPinLen: number, pLabel: Buffer, callback: Callback): void; - /** - * C_InitPIN initializes the normal user's PIN. - * @param {number} hSession the session's handle - * @param {Buffer} pPin the normal user's PIN - * @param {number} ulPinLen length in bytes of the PIN - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_InitPIN(hSession: number, pPin: Buffer, ulPinLen: number): number; - C_InitPIN(hSession: number, pPin: Buffer, ulPinLen: number, callback: Callback): void; - /** - * C_SetPIN modifies the PIN of the user who is logged in. - * @param {number} hSession the session's handle - * @param {Buffer} pOldPin the old PIN - * @param {number} ulOldLen length of the old PIN - * @param {Buffer} pNewPin the new PIN - * @param {number} ulNewLen length of the new PIN - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SetPIN(hSession: any, pOldPin: Buffer, ulOldLen: number, pNewPin: Buffer, ulNewLen: number): number; - C_SetPIN(hSession: any, pOldPin: Buffer, ulOldLen: number, pNewPin: Buffer, ulNewLen: number, callback: Callback): void; - /** - * C_OpenSession opens a session between an application and a - * token. - * @param {number} slotID ID of the token's slot - * @param {number} flags from CK_SESSION_INFO - * @param {Buffer} pApplication passed to callback - * @param {Buffer} Notify callback function - * @param {Buffer} phSession gets session handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_OpenSession(slotID: number, flags: number, pApplication?: Buffer, notify?: Buffer, phSession?: Buffer): number; - C_OpenSession(slotID: number, flags: number, pApplication: Buffer, notify: Buffer, phSession: Buffer, callback: Callback): void; - /** - * C_CloseSession closes a session between an application and a token. - * @param {number} hSession the session's handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_CloseSession(hSession: number): number; - C_CloseSession(hSession: number, callback: Callback): void; - /** - * C_CloseAllSessions closes all sessions with a token. - * @param {number} slotID ID of the token's slot - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_CloseAllSessions(slotID: number): number; - C_CloseAllSessions(slotID: number, callback: Callback): void; - /** - * C_GetSessionInfo obtains information about the session. - * @param {number} hSession the session's handle - * @param {Buffer} pInfo receives session info - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetSessionInfo(hSession: number, pInfo: Buffer): number; - C_GetSessionInfo(hSession: number, pInfo: Buffer, callback: Callback): void; - /** - * C_GetOperationState obtains the state of the cryptographic operation in a session. - * @param {number} hSession the session's handle - * @param {Buffer} pOperationState gets state - * @param {Buffer} pulOperationStateLen gets state length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetOperationState(hSession: number, pOperationState: Buffer, pulOperationStateLen: Buffer): number; - C_GetOperationState(hSession: number, pOperationState: Buffer, pulOperationStateLen: Buffer, callback: Callback): void; - /** - * C_SetOperationState restores the state of the cryptographic operation in a session. - * @param {number} hSession the session's handle - * @param {Buffer} pOperationState holds state - * @param {number} ulOperationStateLen holds holds state length - * @param {number} hEncryptionKey en/decryption key - * @param {number} hAuthenticationKey sign/verify key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SetOperationState(hSession: number, pOperationState: Buffer, ulOperationStateLen: number, hEncryptionKey: number, hAuthenticationKey: number): number; - C_SetOperationState(hSession: number, pOperationState: Buffer, ulOperationStateLen: number, hEncryptionKey: number, hAuthenticationKey: number, callback: Callback): void; - /** - * C_Login logs a user into a token. - * @param {number} hSession the session's handle - * @param {number} userType the user type - * @param {Buffer} pPin the user's PIN - * @param {number} ulPinLen the length of the PIN - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Login(hSession: number, userType: number, pPin: Buffer, ulPinLen: number): number; - C_Login(hSession: number, userType: number, pPin: Buffer, ulPinLen: number, callback: Callback): void; - /** - * C_Logout logs a user out from a token. - * @param {number} hSession the session's handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Logout(hSession: number): number; - C_Logout(hSession: number, callback: Callback): void; - /** - * C_CreateObject creates a new object. - * @param {number} hSession the session's handle - * @param {Buffer} pTemplate the object's template - * @param {number} ulCount attributes in template - * @param {Buffer} phObject gets new object's handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_CreateObject(hSession: number, pTemplate: Buffer, ulCount: number, phObject: Buffer): number; - C_CreateObject(hSession: number, pTemplate: Buffer, ulCount: number, phObject: Buffer, callback: Callback): void; - /** - * C_CopyObject copies an object, creating a new object for the copy. - * @param {number} hSession the session's handle - * @param {number} hObject the object's handle - * @param {Buffer} pTemplate template for new object - * @param {number} ulCount attributes in template - * @param {Buffer} phNewObject receives handle of copy - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_CopyObject(hSession: number, hObject: number, pTemplate: Buffer, ulCount: number, phNewObject: Buffer): number; - C_CopyObject(hSession: number, hObject: number, pTemplate: Buffer, ulCount: number, phNewObject: Buffer, callback: Callback): void; - /** - * C_DestroyObject destroys an object. - * @param {number} hSession the session's handle - * @param {number} hObject the object's handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DestroyObject(hSession: number, hObject: number): number; - C_DestroyObject(hSession: number, hObject: number, callback: Callback): void; - /** - * C_GetObjectSize gets the size of an object in bytes. - * @param {number} hSession the session's handle - * @param {number} hObject the object's handle - * @param {Buffer} pulSize receives size of object - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetObjectSize(hSession: number, hObject: number, pulSize: Buffer): number; - C_GetObjectSize(hSession: number, hObject: number, pulSize: Buffer, callback: Callback): void; - /** - * C_GetAttributeValue obtains the value of one or more object attributes. - * @param {number} hSession the session's handle - * @param {number} hObject the object's handle - * @param {Buffer} pTemplate specifies attrs; gets vals - * @param {number} ulCount attributes in template - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetAttributeValue(hSession: number, hObject: number, pTemplate: Buffer, ulCount: number): number; - C_GetAttributeValue(hSession: number, hObject: number, pTemplate: Buffer, ulCount: number, callback: Callback): void; - /** - * C_SetAttributeValue modifies the value of one or more object attributes - * @param {number} hSession the session's handle - * @param {number} hObject the object's handle - * @param {Buffer} pTemplate specifies attrs and values - * @param {number} ulCount attributes in template - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SetAttributeValue(hSession: number, hObject: number, pTemplate: Buffer, ulCount: number): number; - C_SetAttributeValue(hSession: number, hObject: number, pTemplate: Buffer, ulCount: number, callback: Callback): void; - /** - * C_FindObjectsInit initializes a search for token and session - * objects that match a template. - * @param {number} hSession the session's handle - * @param {Buffer} pTemplate attribute values to match - * @param {number} ulCount attrs in search template - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_FindObjectsInit(hSession: number, pTemplate: Buffer, ulCount: number): number; - C_FindObjectsInit(hSession: number, pTemplate: Buffer, ulCount: number, callback: Callback): void; - /** - * C_FindObjects continues a search for token and session - * objects that match a template, obtaining additional object - * handles. - * @param {number} hSession the session's handle - * @param {Buffer} phObject gets obj. handles - * @param {number} ulMaxObjectCount max handles to get - * @param {Buffer} pulObjectCount actual # returned - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_FindObjects(hSession: number, phObject: Buffer, ulMaxObjectCount: number, pulObjectCount: Buffer): number; - C_FindObjects(hSession: number, phObject: Buffer, ulMaxObjectCount: number, pulObjectCount: Buffer, callback: Callback): void; - /** - * C_FindObjectsFinal finishes a search for token and session objects. - * @param {number} hSession the session's handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_FindObjectsFinal(hSession: number): number; - C_FindObjectsFinal(hSession: number, callback: Callback): void; - /** - * C_EncryptInit initializes an encryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the encryption mechanism - * @param {number} hKey handle of encryption key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_EncryptInit(hSession: number, pMechanism: Buffer, hKey: number): number; - C_EncryptInit(hSession: number, pMechanism: Buffer, hKey: number, callback: Callback): void; - /** - * C_Encrypt encrypts single-part data. - * @param {number} hSession the session's handle - * @param {Buffer} pData the plaintext data - * @param {number} ulDataLen bytes of plaintext - * @param {Buffer} pEncryptedData gets ciphertext - * @param {Buffer} pulEncryptedDataLen gets c-text size - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Encrypt(hSession: number, pData: Buffer, ulDataLen: number, pEncryptedData: Buffer, pulEncryptedDataLen: Buffer): number; - C_Encrypt(hSession: number, pData: Buffer, ulDataLen: number, pEncryptedData: Buffer, pulEncryptedDataLen: Buffer, callback: Callback): void; - /** - * C_EncryptUpdate continues a multiple-part encryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pPart the plaintext data - * @param {number} ulPartLen plaintext data len - * @param {Buffer} pEncryptedPart gets ciphertext - * @param {Buffer} pulEncryptedPartLen gets c-text size - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_EncryptUpdate(hSession: number, pPart: Buffer, ulPartLen: number, pEncryptedPart: Buffer, pulEncryptedPartLen: Buffer): number; - C_EncryptUpdate(hSession: number, pPart: Buffer, ulPartLen: number, pEncryptedPart: Buffer, pulEncryptedPartLen: Buffer, callback: Callback): void; - /** - * C_EncryptFinal finishes a multiple-part encryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pLastEncryptedPart last c-text - * @param {Buffer} pulLastEncryptedPartLen gets last size - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_EncryptFinal(hSession: number, pLastEncryptedPart: Buffer, pulLastEncryptedPartLen: Buffer): number; - C_EncryptFinal(hSession: number, pLastEncryptedPart: Buffer, pulLastEncryptedPartLen: Buffer, callback: Callback): void; - /** - * C_DecryptInit initializes a decryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the decryption mechanism - * @param {number} hKey handle of decryption key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DecryptInit(hSession: number, pMechanism: Buffer, hKey: number): any; - C_DecryptInit(hSession: number, pMechanism: Buffer, hKey: number, callback: Callback): void; - /** - * C_Decrypt decrypts encrypted data in a single part. - * @param {number} hSession the session's handle - * @param {Buffer} pEncryptedData ciphertext - * @param {number} ulEncryptedDataLen ciphertext length - * @param {Buffer} pData gets plaintext - * @param {number} pulDataLen gets p-text size - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Decrypt(hSession: number, pEncryptedData: Buffer, ulEncryptedDataLen: number, pData: Buffer, pulDataLen: Buffer): number; - C_Decrypt(hSession: number, pEncryptedData: Buffer, ulEncryptedDataLen: number, pData: Buffer, pulDataLen: Buffer, callback: Callback): void; - /** - * C_DecryptUpdate continues a multiple-part decryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pEncryptedPart encrypted data - * @param {number} ulEncryptedPartLen input length - * @param {Buffer} pPart gets plaintext - * @param {Buffer} pulPartLen p-text size - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DecryptUpdate(hSession: number, pEncryptedPart: Buffer, ulEncryptedPartLen: number, pPart: Buffer, pulPartLen: Buffer): number; - C_DecryptUpdate(hSession: number, pEncryptedPart: Buffer, ulEncryptedPartLen: number, pPart: Buffer, pulPartLen: Buffer, callback: Callback): void; - /** - * C_DecryptFinal finishes a multiple-part decryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pLastPart gets plaintext - * @param {Buffer} pulLastPartLen p-text size - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DecryptFinal(hSession: number, pLastPart: Buffer, pulLastPartLen: Buffer): number; - C_DecryptFinal(hSession: number, pLastPart: Buffer, pulLastPartLen: Buffer, callback: Callback): void; - /** - * C_DigestInit initializes a message-digesting operation. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the digesting mechanism - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DigestInit(hSession: number, pMechanism: Buffer): number; - C_DigestInit(hSession: number, pMechanism: Buffer, callback: Callback): void; - /** - * C_Digest digests data in a single part. - * @param {number} hSession the session's handle - * @param {Buffer} pData data to be digested - * @param {number} ulDataLen bytes of data to digest - * @param {Buffer} pDigest gets the message digest - * @param {Buffer} pulDigestLen gets digest length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Digest(hSession: number, pData: Buffer, ulDataLen: number, pDigest: Buffer, pulDigestLen: Buffer): number; - C_Digest(hSession: number, pData: Buffer, ulDataLen: number, pDigest: Buffer, pulDigestLen: Buffer, callback: Callback): void; - /** - * C_DigestUpdate continues a multiple-part message-digesting operation. - * @param {number} hSession the session's handle - * @param {Buffer} pPart data to be digested - * @param {number} ulPartLen bytes of data to be digested - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DigestUpdate(hSession: number, pPart: Buffer, ulPartLen: number): number; - C_DigestUpdate(hSession: number, pPart: Buffer, ulPartLen: number, callback: Callback): void; - /** - * C_DigestKey continues a multi-part message-digesting operation, - * by digesting the value of a secret key as part of - * the data already digested. - * @param {number} hSession the session's handle - * @param {number} hKey secret key to digest - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DigestKey(hSession: number, hKey: number): number; - C_DigestKey(hSession: number, hKey: number, callback: Callback): void; - /** - * C_DigestFinal finishes a multiple-part message-digesting - * operation. - * @param {number} hSession the session's handle - * @param {Buffer} pDigest gets the message digest - * @param {Buffer} pulDigestLen gets byte count of digest - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DigestFinal(hSession: number, pDigest: Buffer, pulDigestLen: Buffer): number; - C_DigestFinal(hSession: number, pDigest: Buffer, pulDigestLen: Buffer, callback: Callback): void; - /** - * C_SignInit initializes a signature (private key encryption) - * operation, where the signature is (will be) an appendix to - * the data, and plaintext cannot be recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the signature mechanism - * @param {number} hKey handle of signature key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SignInit(hSession: number, pMechanism: Buffer, hKey: number): number; - C_SignInit(hSession: number, pMechanism: Buffer, hKey: number, callback: Callback): void; - /** - * C_Sign signs (encrypts with private key) data in a single - * part, where the signature is (will be) an appendix to the - * data, and plaintext cannot be recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pData the data to sign - * @param {number} ulDataLen count of bytes to sign - * @param {Buffer} pSignature gets the signature - * @param {Buffer} pulSignatureLen gets signature length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Sign(hSession: number, pData: Buffer, ulDataLen: number, pSignature: Buffer, pulSignatureLen: Buffer): number; - C_Sign(hSession: number, pData: Buffer, ulDataLen: number, pSignature: Buffer, pulSignatureLen: Buffer, callback: Callback): void; - /** - * C_SignUpdate continues a multiple-part signature operation, - * where the signature is (will be) an appendix to the data, - * and plaintext cannot be recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pPart the data to sign - * @param {number} ulPartLen count of bytes to sign - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SignUpdate(hSession: number, pPart: Buffer, ulPartLen: Buffer): number; - C_SignUpdate(hSession: number, pPart: Buffer, ulPartLen: Buffer, callback: Callback): void; - /** - * C_SignFinal finishes a multiple-part signature operation, - * returning the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pSignature gets the signature - * @param {Buffer} pulSignatureLen gets signature length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SignFinal(hSession: number, pSignature: Buffer, pulSignatureLen: Buffer): number; - C_SignFinal(hSession: number, pSignature: Buffer, pulSignatureLen: Buffer, callback: Callback): void; - /** - * C_SignRecoverInit initializes a signature operation, where - * the data can be recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the signature mechanism - * @param {number} hKey handle of the signature key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SignRecoverInit(hSession: number, pMechanism: Buffer, hKey: number): number; - C_SignRecoverInit(hSession: number, pMechanism: Buffer, hKey: number, callback: Callback): void; - /** - * C_SignRecover signs data in a single operation, where the - * data can be recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pData the data to sign - * @param {number} ulDataLen count of bytes to sign - * @param {Buffer} pSignature gets the signature - * @param {Buffer} pulSignatureLen gets signature length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SignRecover(hSession: number, pData: Buffer, ulDataLen: number, pSignature: Buffer, pulSignatureLen: Buffer): number; - C_SignRecover(hSession: number, pData: Buffer, ulDataLen: number, pSignature: Buffer, pulSignatureLen: Buffer, callback: Callback): void; - /** - * C_VerifyInit initializes a verification operation, where the - * signature is an appendix to the data, and plaintext cannot - * cannot be recovered from the signature (e.g. DSA). - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the verification mechanism - * @param {number} hKey verification key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_VerifyInit(hSession: number, pMechanism: Buffer, hKey: number): number; - C_VerifyInit(hSession: number, pMechanism: Buffer, hKey: number, callback: Callback): void; - /** - * C_Verify verifies a signature in a single-part operation, - * where the signature is an appendix to the data, and plaintext - * cannot be recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pData signed data - * @param {number} ulDataLen length of signed data - * @param {Buffer} pSignature signature - * @param {number} ulSignatureLen signature length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_Verify(hSession: number, pData: Buffer, ulDataLen: number, pSignature: Buffer, ulSignatureLen: Buffer): number; - C_Verify(hSession: number, pData: Buffer, ulDataLen: number, pSignature: Buffer, ulSignatureLen: Buffer, callback: Callback): void; - /** - * C_VerifyUpdate continues a multiple-part verification - * operation, where the signature is an appendix to the data, - * and plaintext cannot be recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pPart signed data - * @param {number} ulPartLen length of signed data - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_VerifyUpdate(hSession: number, pPart: Buffer, ulPartLen: number): number; - C_VerifyUpdate(hSession: number, pPart: Buffer, ulPartLen: number, callback: Callback): void; - /** - * C_VerifyFinal finishes a multiple-part verification - * operation, checking the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pSignature signature to verify - * @param {number} ulSignatureLen signature length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_VerifyFinal(hSession: number, pSignature: Buffer, ulSignatureLen: number): number; - C_VerifyFinal(hSession: number, pSignature: Buffer, ulSignatureLen: number, callback: Callback): void; - /** - * C_VerifyRecoverInit initializes a signature verification - * operation, where the data is recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the verification mechanism - * @param {number} hKey verification key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_VerifyRecoverInit(hSession: number, pMechanism: Buffer, hKey: number): number; - C_VerifyRecoverInit(hSession: number, pMechanism: Buffer, hKey: number, callback: Callback): void; - /** - * C_VerifyRecover verifies a signature in a single-part - * operation, where the data is recovered from the signature. - * @param {number} hSession the session's handle - * @param {Buffer} pSignature signature to verify - * @param {number} ulSignatureLen signature length - * @param {Buffer} pData gets signed data - * @param {Buffer} pulDataLen gets signed data len - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_VerifyRecover(hSession: number, pSignature: Buffer, ulSignatureLen: number, pData: Buffer, pulDataLen: Buffer): number; - C_VerifyRecover(hSession: number, pSignature: Buffer, ulSignatureLen: number, pData: Buffer, pulDataLen: Buffer, callback: Callback): void; - /** - * C_DigestEncryptUpdate continues a multiple-part digesting - * and encryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pPart the plaintext data - * @param {number} ulPartLen plaintext length - * @param {Buffer} pEncryptedPart gets ciphertext - * @param {Buffer} pulEncryptedPartLen gets c-text length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DigestEncryptUpdate(hSession: number, pPart: Buffer, ulPartLen: number, pEncryptedPart: Buffer, pulEncryptedPartLen: Buffer): number; - C_DigestEncryptUpdate(hSession: number, pPart: Buffer, ulPartLen: number, pEncryptedPart: Buffer, pulEncryptedPartLen: Buffer, callback: Callback): void; - /** - * C_DecryptDigestUpdate continues a multiple-part decryption and - * digesting operation. - * @param {number} hSession the session's handle - * @param {Buffer} pEncryptedPart ciphertext - * @param {number} ulEncryptedPartLen ciphertext length - * @param {Buffer} pPart gets plaintext - * @param {Buffer} pulPartLen gets plaintext len - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DecryptDigestUpdate(hSession: number, pEncryptedPart: Buffer, ulEncryptedPartLen: number, pPart: Buffer, pulPartLen: Buffer): number; - C_DecryptDigestUpdate(hSession: number, pEncryptedPart: Buffer, ulEncryptedPartLen: number, pPart: Buffer, pulPartLen: Buffer, callback: Callback): void; - /** - * C_SignEncryptUpdate continues a multiple-part signing and - * encryption operation. - * @param {number} hSession the session's handle - * @param {Buffer} pPart the plaintext data - * @param {number} ulPartLen plaintext length - * @param {Buffer} pEncryptedPart gets ciphertext - * @param {Buffer} pulEncryptedPartLen gets c-text length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SignEncryptUpdate(hSession: number, pPart: Buffer, ulPartLen: number, pEncryptedPart: Buffer, pulEncryptedPartLen: Buffer): number; - C_SignEncryptUpdate(hSession: number, pPart: Buffer, ulPartLen: number, pEncryptedPart: Buffer, pulEncryptedPartLen: Buffer, callback: Callback): void; - /** - * C_DecryptVerifyUpdate continues a multiple-part decryption and - * verify operation. - * @param {number} hSession the session's handle - * @param {Buffer} pEncryptedPart ciphertext - * @param {number} ulEncryptedPartLen ciphertext length - * @param {Buffer} pPart gets plaintext - * @param {Buffer} pulPartLen gets p-text length - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DecryptVerifyUpdate(hSession: number, pEncryptedPart: Buffer, ulEncryptedPartLen: number, pPart: Buffer, pulPartLen: Buffer): number; - C_DecryptVerifyUpdate(hSession: number, pEncryptedPart: Buffer, ulEncryptedPartLen: number, pPart: Buffer, pulPartLen: Buffer, callback: Callback): void; - /** - * C_GenerateKey generates a secret key, creating a new key object. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism key generation mech. - * @param {Buffer} pTemplate template for new key - * @param {number} ulCount # of attrs in template - * @param {Buffer} phKey gets handle of new key - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GenerateKey(hSession: number, pMechanism: Buffer, pTemplate: Buffer, ulCount: number, phKey: Buffer): number; - C_GenerateKey(hSession: number, pMechanism: Buffer, pTemplate: Buffer, ulCount: number, phKey: Buffer, callback: Callback): any; - /** - * C_GenerateKeyPair generates a public-key/private-key pair, - * creating new key objects. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism key-gen mech. - * @param {Buffer} pPublicKeyTemplate template for public key - * @param {number} ulPublicKeyAttributeCount public attrs - * @param {Buffer} pPrivateKeyTemplate template for private key - * @param {number} ulPrivateKeyAttributeCount private attrs - * @param {Buffer} phPublicKey gets public key handle - * @param {Buffer} phPrivateKey gets private key handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GenerateKeyPair(hSession: number, pMechanism: Buffer, pPublicKeyTemplate: Buffer, ulPublicKeyAttributeCount: number, pPrivateKeyTemplate: Buffer, ulPrivateKeyAttributeCount: number, phPublicKey: Buffer, phPrivateKey: Buffer): number; - C_GenerateKeyPair(hSession: number, pMechanism: Buffer, pPublicKeyTemplate: Buffer, ulPublicKeyAttributeCount: number, pPrivateKeyTemplate: Buffer, ulPrivateKeyAttributeCount: number, phPublicKey: Buffer, phPrivateKey: Buffer, callback: Callback): void; - /** - * C_WrapKey wraps (i.e., encrypts) a key. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism the wrapping mechanism - * @param {number} hWrappingKey wrapping key - * @param {number} hKey key to be wrapped - * @param {Buffer} pWrappedKey gets wrapped key - * @param {Buffer} pulWrappedKeyLen gets wrapped key size - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_WrapKey(hSession: number, pMechanism: Buffer, hWrappingKey: number, hKey: number, pWrappedKey: Buffer, pulWrappedKeyLen: Buffer): number; - C_WrapKey(hSession: number, pMechanism: Buffer, hWrappingKey: number, hKey: number, pWrappedKey: Buffer, pulWrappedKeyLen: Buffer, callback: Callback): void; - /** - * C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new - * key object. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism unwrapping mech. - * @param {Buffer} pWrappedKey the wrapped key - * @param {number} ulWrappedKeyLen wrapped key len - * @param {Buffer} pTemplate new key template - * @param {number} ulAttributeCount template length - * @param {Buffer} pTemplate new key template - * @param {number} ulAttributeCount template length - * @param {Buffer} phKey gets new handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_UnwrapKey(hSession: number, pMechanism: Buffer, hUnwrappingKey: number, pWrappedKey: Buffer, ulWrappedKeyLen: number, pTemplate: Buffer, ulAttributeCount: number, phKey: Buffer): number; - C_UnwrapKey(hSession: number, pMechanism: Buffer, hUnwrappingKey: number, pWrappedKey: Buffer, ulWrappedKeyLen: number, pTemplate: Buffer, ulAttributeCount: number, phKey: Buffer, callback: Callback): void; - /** - * C_DeriveKey derives a key from a base key, creating a new key object. - * @param {number} hSession the session's handle - * @param {Buffer} pMechanism key deriv. mech. - * @param {number} hBaseKey base key - * @param {Buffer} pTemplate new key template - * @param {number} ulAttributeCount template length - * @param {Buffer} phKey gets new handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_DeriveKey(hSession: number, pMechanism: Buffer, hBaseKey: number, pTemplate: Buffer, ulAttributeCount: number, phKey: Buffer): number; - C_DeriveKey(hSession: number, pMechanism: Buffer, hBaseKey: number, pTemplate: Buffer, ulAttributeCount: number, phKey: Buffer, callback: Callback): void; - /** - * C_SeedRandom mixes additional seed material into the token's - * random number generator. - * @param {number} hSession the session's handle - * @param {Buffer} pSeed the seed material - * @param {number} ulSeedLen length of seed material - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_SeedRandom(hSession: number, pSeed: Buffer, ulSeedLen: number): number; - C_SeedRandom(hSession: number, pSeed: Buffer, ulSeedLen: number, callback: Callback): void; - /** - * C_GenerateRandom generates random data. - * @param {number} hSession the session's handle - * @param {Buffer} pRandomData receives the random data - * @param {number} ulRandomLen # of bytes to generate - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GenerateRandom(hSession: number, pRandomData: Buffer, ulRandomLen: number): number; - C_GenerateRandom(hSession: number, pRandomData: Buffer, ulRandomLen: number, callback: Callback): void; - /** - * C_GetFunctionStatus is a legacy function; it obtains an - * updated status of a function running in parallel with an - * application. - * @param {number} hSession the session's handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_GetFunctionStatus(hSession: number): number; - C_GetFunctionStatus(hSession: number, callback: Callback): void; - /** - * C_CancelFunction is a legacy function; it cancels a function - * running in parallel. - * @param {number} hSession the session's handle - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_CancelFunction(hSession: number): number; - C_CancelFunction(hSession: number, callback: Callback): void; - /** - * C_WaitForSlotEvent waits for a slot event (token insertion, - * removal, etc.) to occur. - * @param {number} flags blocking/nonblocking flag - * @param {Buffer} pSlot location that receives the slot ID - * @param {Buffer} pRserved reserved. Should be NULL_PTR - * @param {Callback} callback callback function with PKCS11 result value - * @returns void PKCS11 result value - */ - C_WaitForSlotEvent(flags: number, pSlot: Buffer, pRserved: Buffer): number; - C_WaitForSlotEvent(flags: number, pSlot: Buffer, pRserved: Buffer, callback: Callback): number; + // ========== Core ========== + + /** + * Handle + */ + type Handle = Buffer; + /** + * BaseObject + * + * @interface BaseObject + */ + interface BaseObject { + } + /** + * HandleObject + * + * @interface HandleObject + * @extends {BaseObject} + */ + interface HandleObject extends BaseObject { + /** + * handle to pkcs11 object + */ + handle: Handle; } - enum KeyType { - RSA, - DSA, - DH, - ECDSA, - EC, - X9_42_DH, - KEA, - GENERIC_SECRET, - RC2, - RC4, - DES, - DES2, - DES3, - CAST, - CAST3, - CAST5, - CAST128, - RC5, - IDEA, - SKIPJACK, - BATON, - JUNIPER, - CDMF, - AES, - GOSTR3410, - GOSTR3411, - GOST28147, - BLOWFISH, - TWOFISH, - SECURID, - HOTP, - ACTI, - CAMELLIA, - ARIA, - } - enum KeyGenMechanism { - AES, - RSA, - RSA_X9_31, - DSA, - DH_PKCS, - DH_X9_42, - GOSTR3410, - GOST28147, - RC2, - RC4, - DES, - DES2, - SECURID, - ACTI, - CAST, - CAST3, - CAST5, - CAST128, - RC5, - IDEA, - GENERIC_SECRET, - SSL3_PRE_MASTER, - CAMELLIA, - ARIA, - SKIPJACK, - KEA, - BATON, - ECDSA, - EC, - JUNIPER, - TWOFISH, - } + /** + * Collection + * + * @interface Collection + * @extends {BaseObject} + * @template T + */ + interface Collection extends BaseObject { - enum MechanismEnum { - RSA_PKCS_KEY_PAIR_GEN, - RSA_PKCS, - RSA_9796, - RSA_X_509, - MD2_RSA_PKCS, - MD5_RSA_PKCS, - SHA1_RSA_PKCS, - RIPEMD128_RSA_PKCS, - RIPEMD160_RSA_PKCS, - RSA_PKCS_OAEP, - RSA_X9_31_KEY_PAIR_GEN, - RSA_X9_31, - SHA1_RSA_X9_31, - RSA_PKCS_PSS, - SHA1_RSA_PKCS_PSS, - DSA_KEY_PAIR_GEN, - DSA, - DSA_SHA1, - DH_PKCS_KEY_PAIR_GEN, - DH_PKCS_DERIVE, - X9_42_DH_KEY_PAIR_GEN, - X9_42_DH_DERIVE, - X9_42_DH_HYBRID_DERIVE, - X9_42_MQV_DERIVE, - SHA256_RSA_PKCS, - SHA384_RSA_PKCS, - SHA512_RSA_PKCS, - SHA256_RSA_PKCS_PSS, - SHA384_RSA_PKCS_PSS, - SHA512_RSA_PKCS_PSS, - SHA224_RSA_PKCS, - SHA224_RSA_PKCS_PSS, - RC2_KEY_GEN, - RC2_ECB, - RC2_CBC, - RC2_MAC, - RC2_MAC_GENERAL, - RC2_CBC_PAD, - RC4_KEY_GEN, - RC4, - DES_KEY_GEN, - DES_ECB, - DES_CBC, - DES_MAC, - DES_MAC_GENERAL, - DES_CBC_PAD, - DES2_KEY_GEN, - DES3_KEY_GEN, - DES3_ECB, - DES3_CBC, - DES3_MAC, - DES3_MAC_GENERAL, - DES3_CBC_PAD, - CDMF_KEY_GEN, - CDMF_ECB, - CDMF_CBC, - CDMF_MAC, - CDMF_MAC_GENERAL, - CDMF_CBC_PAD, - DES_OFB64, - DES_OFB8, - DES_CFB64, - DES_CFB8, - MD2, - MD2_HMAC, - MD2_HMAC_GENERAL, - MD5, - MD5_HMAC, - MD5_HMAC_GENERAL, - SHA1, - SHA, - SHA_1, - SHA_1_HMAC, - SHA_1_HMAC_GENERAL, - RIPEMD128, - RIPEMD128_HMAC, - RIPEMD128_HMAC_GENERAL, - RIPEMD160, - RIPEMD160_HMAC, - RIPEMD160_HMAC_GENERAL, - SHA256, - SHA256_HMAC, - SHA256_HMAC_GENERAL, - SHA224, - SHA224_HMAC, - SHA224_HMAC_GENERAL, - SHA384, - SHA384_HMAC, - SHA384_HMAC_GENERAL, - SHA512, - SHA512_HMAC, - SHA512_HMAC_GENERAL, - SECURID_KEY_GEN, - SECURID, - HOTP_KEY_GEN, - HOTP, - ACTI, - ACTI_KEY_GEN, - CAST_KEY_GEN, - CAST_ECB, - CAST_CBC, - CAST_MAC, - CAST_MAC_GENERAL, - CAST_CBC_PAD, - CAST3_KEY_GEN, - CAST3_ECB, - CAST3_CBC, - CAST3_MAC, - CAST3_MAC_GENERAL, - CAST3_CBC_PAD, - CAST5_KEY_GEN, - CAST128_KEY_GEN, - CAST5_ECB, - CAST128_ECB, - CAST5_CBC, - CAST128_CBC, - CAST5_MAC, - CAST128_MAC, - CAST5_MAC_GENERAL, - CAST128_MAC_GENERAL, - CAST5_CBC_PAD, - CAST128_CBC_PAD, - RC5_KEY_GEN, - RC5_ECB, - RC5_CBC, - RC5_MAC, - RC5_MAC_GENERAL, - RC5_CBC_PAD, - IDEA_KEY_GEN, - IDEA_ECB, - IDEA_CBC, - IDEA_MAC, - IDEA_MAC_GENERAL, - IDEA_CBC_PAD, - GENERIC_SECRET_KEY_GEN, - CONCATENATE_BASE_AND_KEY, - CONCATENATE_BASE_AND_DATA, - CONCATENATE_DATA_AND_BASE, - XOR_BASE_AND_DATA, - EXTRACT_KEY_FROM_KEY, - SSL3_PRE_MASTER_KEY_GEN, - SSL3_MASTER_KEY_DERIVE, - SSL3_KEY_AND_MAC_DERIVE, - SSL3_MASTER_KEY_DERIVE_DH, - TLS_PRE_MASTER_KEY_GEN, - TLS_MASTER_KEY_DERIVE, - TLS_KEY_AND_MAC_DERIVE, - TLS_MASTER_KEY_DERIVE_DH, - TLS_PRF, - SSL3_MD5_MAC, - SSL3_SHA1_MAC, - MD5_KEY_DERIVATION, - MD2_KEY_DERIVATION, - SHA1_KEY_DERIVATION, - SHA256_KEY_DERIVATION, - SHA384_KEY_DERIVATION, - SHA512_KEY_DERIVATION, - SHA224_KEY_DERIVATION, - PBE_MD2_DES_CBC, - PBE_MD5_DES_CBC, - PBE_MD5_CAST_CBC, - PBE_MD5_CAST3_CBC, - PBE_MD5_CAST5_CBC, - PBE_MD5_CAST128_CBC, - PBE_SHA1_CAST5_CBC, - PBE_SHA1_CAST128_CBC, - PBE_SHA1_RC4_128, - PBE_SHA1_RC4_40, - PBE_SHA1_DES3_EDE_CBC, - PBE_SHA1_DES2_EDE_CBC, - PBE_SHA1_RC2_128_CBC, - PBE_SHA1_RC2_40_CBC, - PKCS5_PBKD2, - PBA_SHA1_WITH_SHA1_HMAC, - WTLS_PRE_MASTER_KEY_GEN, - WTLS_MASTER_KEY_DERIVE, - WTLS_MASTER_KEY_DERIVE_DH_ECC, - WTLS_PRF, - WTLS_SERVER_KEY_AND_MAC_DERIVE, - WTLS_CLIENT_KEY_AND_MAC_DERIVE, - KEY_WRAP_LYNKS, - KEY_WRAP_SET_OAEP, - CMS_SIG, - KIP_DERIVE, - KIP_WRAP, - KIP_MAC, - CAMELLIA_KEY_GEN, - CAMELLIA_ECB, - CAMELLIA_CBC, - CAMELLIA_MAC, - CAMELLIA_MAC_GENERAL, - CAMELLIA_CBC_PAD, - CAMELLIA_ECB_ENCRYPT_DATA, - CAMELLIA_CBC_ENCRYPT_DATA, - CAMELLIA_CTR, - ARIA_KEY_GEN, - ARIA_ECB, - ARIA_CBC, - ARIA_MAC, - ARIA_MAC_GENERAL, - ARIA_CBC_PAD, - ARIA_ECB_ENCRYPT_DATA, - ARIA_CBC_ENCRYPT_DATA, - SKIPJACK_KEY_GEN, - SKIPJACK_ECB64, - SKIPJACK_CBC64, - SKIPJACK_OFB64, - SKIPJACK_CFB64, - SKIPJACK_CFB32, - SKIPJACK_CFB16, - SKIPJACK_CFB8, - SKIPJACK_WRAP, - SKIPJACK_PRIVATE_WRAP, - SKIPJACK_RELAYX, - KEA_KEY_PAIR_GEN, - KEA_KEY_DERIVE, - FORTEZZA_TIMESTAMP, - BATON_KEY_GEN, - BATON_ECB128, - BATON_ECB96, - BATON_CBC128, - BATON_COUNTER, - BATON_SHUFFLE, - BATON_WRAP, - ECDSA_KEY_PAIR_GEN, - EC_KEY_PAIR_GEN, - ECDSA, - ECDSA_SHA1, - ECDSA_SHA224, - ECDSA_SHA256, - ECDSA_SHA384, - ECDSA_SHA512, - ECDH1_DERIVE, - ECDH1_COFACTOR_DERIVE, - ECMQV_DERIVE, - JUNIPER_KEY_GEN, - JUNIPER_ECB128, - JUNIPER_CBC128, - JUNIPER_COUNTER, - JUNIPER_SHUFFLE, - JUNIPER_WRAP, - FASTHASH, - AES_KEY_GEN, - AES_ECB, - AES_CBC, - AES_MAC, - AES_MAC_GENERAL, - AES_CBC_PAD, - AES_CTR, - AES_CMAC, - AES_CMAC_GENERAL, - BLOWFISH_KEY_GEN, - BLOWFISH_CBC, - TWOFISH_KEY_GEN, - TWOFISH_CBC, - AES_GCM, - AES_CCM, - AES_KEY_WRAP, - AES_KEY_WRAP_PAD, - DES_ECB_ENCRYPT_DATA, - DES_CBC_ENCRYPT_DATA, - DES3_ECB_ENCRYPT_DATA, - DES3_CBC_ENCRYPT_DATA, - AES_ECB_ENCRYPT_DATA, - AES_CBC_ENCRYPT_DATA, - GOSTR3410_KEY_PAIR_GEN, - GOSTR3410, - GOSTR3410_WITH_GOSTR3411, - GOSTR3410_KEY_WRAP, - GOSTR3410_DERIVE, - GOSTR3411, - GOSTR3411_HMAC, - GOST28147_KEY_GEN, - GOST28147_ECB, - GOST28147, - GOST28147_MAC, - GOST28147_KEY_WRAP, - DSA_PARAMETER_GEN, - DH_PKCS_PARAMETER_GEN, - X9_42_DH_PARAMETER_GEN, - VENDOR_DEFINED, - } + /** + * returns length of collection + */ + length: number; - interface IParams { - toCKI(): Buffer; - } - - interface IAlgorithm { - name: string; - params: Buffer | IParams; - } - - type MechanismType = MechanismEnum | KeyGenMechanism | IAlgorithm | string; - - enum MechanismFlag { - /** - * `True` if the mechanism is performed by the device; `false` if the mechanism is performed in software - */ - HW, - /** - * `True` if the mechanism can be used with encrypt function - */ - ENCRYPT, - /** - * `True` if the mechanism can be used with decrypt function - */ - DECRYPT, - /** - * `True` if the mechanism can be used with digest function - */ - DIGEST, - /** - * `True` if the mechanism can be used with sign function - */ - SIGN, - /** - * `True` if the mechanism can be used with sign recover function - */ - SIGN_RECOVER, - /** - * `True` if the mechanism can be used with verify function - */ - VERIFY, - /** - * `True` if the mechanism can be used with verify recover function - */ - VERIFY_RECOVER, - /** - * `True` if the mechanism can be used with geberate function - */ - GENERATE, - /** - * `True` if the mechanism can be used with generate key pair function - */ - GENERATE_KEY_PAIR, - /** - * `True` if the mechanism can be used with wrap function - */ - WRAP, - /** - * `True` if the mechanism can be used with unwrap function - */ - UNWRAP, - /** - * `True` if the mechanism can be used with derive function - */ - DERIVE, - } - class Mechanism extends HandleObject { - protected slotHandle: number; - /** - * the minimum size of the key for the mechanism - * _whether this is measured in bits or in bytes is mechanism-dependent_ - */ - minKeySize: number; - /** - * the maximum size of the key for the mechanism - * _whether this is measured in bits or in bytes is mechanism-dependent_ - */ - maxKeySize: number; - /** - * bit flag specifying mechanism capabilities - */ - flags: number; - /** - * returns string name from MechanismEnum - */ - name: string; - constructor(handle: number, slotHandle: number, lib: Pkcs11); - protected getInfo(): void; - static create(alg: MechanismType): Buffer; - static vendor(jsonFile: string): any; - static vendor(name: string, value: number): any; - } - - class MechanismCollection extends Collection { - protected slotHandle: number; - constructor(items: Array, slotHandle: number, lib: Pkcs11, classType?: typeof Mechanism); /** * returns item from collection by index * @param {number} index of element in collection `[0..n]` */ - items(index: number): Mechanism; + items(index: number): T; + + } + type SessionObjectCollection = Collection + type MechanismCollection = Collection; + type SlotCollection = Collection; + + // ========== PKCS11 Objects ========== + + /** + * Certificate objects (object class CKO_CERTIFICATE) hold public-key or attribute certificates + */ + interface Certificate extends Storage { + /** + * Type of certificate + */ + type: graphene.CertificateType; + /** + * The certificate can be trusted for the application that it was created. + */ + trusted: boolean; + /** + * Categorization of the certificate + */ + category: graphene.CertificateCategory; + /** + * Checksum + */ + checkValue: Buffer; + /** + * Start date for the certificate (default empty) + */ + startDate: Date; + /** + * End date for the certificate (default empty) + */ + endDate: Date; + } + + /** + * X.509 certificate objects (certificate type `CKC_X_509`) hold X.509 public key certificates + */ + interface X509Certificate extends Certificate { + /** + * DER-encoding of the certificate subject name + * - Must be specified when the object is created. + * - Must be non-empty if `CKA_URL` is empty. + */ + subject: Buffer; + /** + * Key identifier for public/private key pair (default empty) + */ + id: Buffer; + /** + * DER-encoding of the certificate issuer name (default empty) + */ + issuer: Buffer; + /** + * HEX-encoding of the certificate serial number (default empty) + */ + serialNumber: string; + /** + * BER-encoding of the certificate + * - Must be specified when the object is created. + * - Must be non-empty if `CKA_URL` is empty. + */ + value: Buffer; + /** + * If not empty this attribute gives the URL where the complete certificate + * can be obtained (default empty) + * - Must be non-empty if `CKA_VALUE` is empty + */ + url: string; + /** + * SHA-1 hash of the subject public key (default empty) + * - Can only be empty if `CKA_URL` is empty. + */ + subjetcKeyIdentifier: Buffer; + /** + * SHA-1 hash of the issuer public key (default empty) + * - Can only be empty if `CKA_URL` is empty. + */ + authorityKeyIdentifier: Buffer; + /** + * Java MIDP security domain + */ + java: graphene.JavaMIDP; + } + + /** + * WTLS certificate objects (certificate type `CKC_WTLS`) hold WTLS public key certificates + */ + interface WtlsCertificate extends Certificate { + /** + * WTLS-encoding (Identifier type) of the certificate subject + * - Must be specified when the object is created. + * - Can only be empty if `CKA_VALUE` is empty. + */ + subject: Buffer; + /** + * WTLS-encoding (Identifier type) of the certificate issuer (default empty) + */ + issuer: Buffer; + /** + * Key identifier for public/private key pair (default empty) + */ + id: Buffer; + /** + * WTLS-encoding of the certificate + * - Must be specified when the object is created. + * - Must be non-empty if `CKA_URL` is empty. + */ + value: Buffer; + /** + * If not empty this attribute gives the URL where the complete certificate + * can be obtained (default empty) + * - Must be non-empty if `CKA_VALUE` is empty + */ + url: string; + /** + * DER-encoding of the certificate serial number (default empty) + */ + serialNumber: Buffer; + /** + * SHA-1 hash of the subject public key (default empty) + * - Can only be empty if `CKA_URL` is empty. + */ + subjetcKeyIdentifier: Buffer; + /** + * SHA-1 hash of the issuer public key (default empty) + * - Can only be empty if `CKA_URL` is empty. + */ + authorityKeyIdentifier: Buffer; + } + + /** + * X.509 attribute certificate objects (certificate type `CKC_X_509_ATTR_CERT`) hold X.509 attribute certificates + */ + interface AttributeCertificate extends Certificate { + /** + * DER-encoding of the attribute certificate's subject field. + * This is distinct from the `CKA_SUBJECT` attribute contained in `CKC_X_509` certificates + * because the `ASN.1` syntax and encoding are different. + * - Must be specified when the object is created + */ + owner: Buffer; + /** + * DER-encoding of the attribute certificate's issuer field. + * This is distinct from the `CKA_ISSUER` attribute contained in `CKC_X_509` certificates + * because the ASN.1 syntax and encoding are different. (default empty) + */ + issuer: Buffer; + /** + * DER-encoding of the certificate serial number (default empty) + */ + serialNumber: Buffer; + /** + * BER-encoding of a sequence of object identifier values corresponding + * to the attribute types contained in the certificate. + * When present, this field offers an opportunity for applications + * to search for a particular attribute certificate without fetching + * and parsing the certificate itself. (default empty) + */ + types: Buffer; + /** + * BER-encoding of the certificate + * - Must be specified when the object is created. + */ + value: Buffer; + } + + interface DomainParameters extends Storage { + /** + * Type of key the domain parameters can be used to generate. + */ + keyType: graphene.KeyType; + /** + * `CK_TRUE` only if domain parameters were either * generated locally (i.e., on the token) + * with a `C_GenerateKey` * created with a `C_CopyObject` call as a copy of domain parameters + * which had its `CKA_LOCAL` attribute set to `CK_TRUE` + */ + local: boolean; + } + + /** + * Data objects (object class `CKO_DATA`) hold information defined by an application. + * Other than providing access to it, Cryptoki does not attach any special meaning to a data object + * + * @ + * @class Data + * @extends {Storage} + */ + interface Data extends Storage { + /** + * Description of the application that manages the object (default empty) + * + * @type {string} + */ + application: string; + /** + * DER-encoding of the object identifier indicating the data object type (default empty) + * + * @type {Buffer} + */ + objectId: Buffer; + /** + * Value of the object (default empty) + * + * @type {Buffer} + */ + value: Buffer; } /** @@ -1232,13 +278,13 @@ declare module "graphene-pk11" { * - defines the object class `CKO_PUBLIC_KEY`, `CKO_PRIVATE_KEY` and `CKO_SECRET_KEY` for type `CK_OBJECT_CLASS` * as used in the `CKA_CLASS` attribute of objects */ - class Key extends Storage { + interface Key extends Storage { /** * Type of key * - Must be specified when object is created with `C_CreateObject` * - Must be specified when object is unwrapped with `C_UnwrapKey` */ - type: KeyType; + type: graphene.KeyType; /** * Key identifier for key (default empty) * - May be modified after object is created with a `C_SetAttributeValue` call, @@ -1288,41 +334,737 @@ declare module "graphene-pk11" { * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. * - Must not be specified when object is unwrapped with `C_UnwrapKey`. */ - mechanism: KeyGenMechanism; + mechanism: graphene.KeyGenMechanism; allowedMechanisms: void; } - - class DomainParameters extends Storage { + /** + * Private key objects (object class `CKO_PRIVATE_KEY`) hold private keys + */ + interface PrivateKey extends Key { /** - * Type of key the domain parameters can be used to generate. + * DER-encoding of the key subject name (default empty) + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. */ - keyType: KeyType; + subject: Buffer; /** - * `CK_TRUE` only if domain parameters were either * generated locally (i.e., on the token) - * with a `C_GenerateKey` * created with a `C_CopyObject` call as a copy of domain parameters - * which had its `CKA_LOCAL` attribute set to `CK_TRUE` + * `CK_TRUE` if key is sensitive + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Attribute cannot be changed once set to CK_TRUE. It becomes a read only attribute. + * - Default value is token-specific, and may depend on the values of other attributes. */ - local: boolean; + sensitive: boolean; + /** + * `CK_TRUE` if key supports decryption + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + decrypt: boolean; + /** + * `CK_TRUE` if key supports signatures where the signature is an appendix to the data + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + sign: boolean; + /** + * `CK_TRUE` if key supports signatures where the data can be recovered from the signature + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + signRecover: boolean; + /** + * `CK_TRUE` if key supports unwrapping (i.e., can be used to unwrap other keys) + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + unwrap: boolean; + /** + * `CK_TRUE` if key is extractable and can be wrapped + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Attribute cannot be changed once set to `CK_FALSE`. It becomes a read only attribute. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + extractable: boolean; + /** + * `CK_TRUE` if key has always had the `CKA_SENSITIVE` attribute set to `CK_TRUE` + * - Must not be specified when object is created with `C_CreateObject`. + * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. + * - Must not be specified when object is unwrapped with `C_UnwrapKey`. + */ + alwaysSensitive: boolean; + /** + * `CK_TRUE` if key has never had the `CKA_EXTRACTABLE` attribute set to `CK_TRUE` + * - Must not be specified when object is created with `C_CreateObject`. + * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. + * - Must not be specified when object is unwrapped with `C_UnwrapKey`. + */ + neverExtractable: boolean; + /** + * `CK_TRUE` if the key can only be wrapped with a wrapping key + * that has `CKA_TRUSTED` set to `CK_TRUE`. Default is `CK_FALSE`. + * - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute. + */ + wrapTrusted: boolean; + /** + * For wrapping keys. The attribute template to apply to any keys unwrapped + * using this wrapping key. Any user supplied template is applied after this template + * as if the object has already been created. + */ + template: void; + alwaysAuthenticate: boolean; } /** - * Data objects (object class `CKO_DATA`) hold information defined by an application. - * Other than providing access to it, Cryptoki does not attach any special meaning to a data object + * Public key objects (object class CKO_PUBLIC_KEY) hold public keys */ - class Data extends Storage { + interface PublicKey extends Key { /** - * Description of the application that manages the object (default empty) + * DER-encoding of the key subject name (default empty) + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. */ - application: string; + subject: Buffer; /** - * DER-encoding of the object identifier indicating the data object type (default empty) + * `CK_TRUE` if key supports encryption + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. */ - objectId: Buffer; + encrypt: boolean; /** - * Value of the object (default empty) + * `CK_TRUE` if key supports verification where the signature is an appendix to the data + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. */ + verify: boolean; + /** + * `CK_TRUE` if key supports verification where the data is recovered from the signature + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + verifyRecover: boolean; + /** + * `CK_TRUE` if key supports wrapping (i.e., can be used to wrap other keys) + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + wrap: boolean; + /** + * The key can be trusted for the application that it was created. + * - The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`. + * - Can only be set to CK_TRUE by the SO user. + */ + trusted: boolean; + /** + * For wrapping keys. The attribute template to match against any keys wrapped using this wrapping key. + * Keys that do not match cannot be wrapped. + */ + template: void; + } + + /** + * Secret key objects (object class `CKO_SECRET_KEY`) hold secret keys. + */ + interface SecretKey extends Key { + /** + * `CK_TRUE` if key is sensitive + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute. + */ + sensitive: boolean; + /** + * `CK_TRUE` if key supports encryption + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + encrypt: boolean; + /** + * `CK_TRUE` if key supports decryption + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + decrypt: boolean; + /** + * `CK_TRUE` if key supports verification (i.e., of authentication codes) where the signature is an appendix to the data + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + verify: boolean; + /** + * `CK_TRUE` if key supports signatures (i.e., authentication codes) where the signature is an appendix to the data + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + sign: boolean; + /** + * `CK_TRUE` if key supports wrapping (i.e., can be used to wrap other keys) + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + wrap: boolean; + /** + * `CK_TRUE` if key supports unwrapping (i.e., can be used to unwrap other keys) + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + unwrap: boolean; + /** + * `CK_TRUE` if key is extractable and can be wrapped + * - May be modified after object is created with a `C_SetAttributeValue` call, + * or in the process of copying object with a `C_CopyObject` call. + * However, it is possible that a particular token may not permit modification of the attribute + * during the course of a `C_CopyObject` call. + * - Attribute cannot be changed once set to `CK_FALSE`. It becomes a read only attribute. + * - Default value is token-specific, and may depend on the values of other attributes. + */ + extractable: boolean; + /** + * `CK_TRUE` if key has always had the `CKA_SENSITIVE` attribute set to `CK_TRUE` + * - Must not be specified when object is created with `C_CreateObject`. + * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. + * - Must not be specified when object is unwrapped with `C_UnwrapKey`. + */ + alwaysSensitive: boolean; + /** + * `CK_TRUE` if key has never had the `CKA_EXTRACTABLE` attribute set to `CK_TRUE` + * - Must not be specified when object is created with `C_CreateObject`. + * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. + * - Must not be specified when object is unwrapped with `C_UnwrapKey`. + */ + neverExtractable: boolean; + /** + * Key checksum + */ + checkValue: Buffer; + /** + * `CK_TRUE` if the key can only be wrapped with a wrapping key + * that has `CKA_TRUSTED` set to `CK_TRUE`. Default is `CK_FALSE`. + * - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute. + */ + wrapTrusted: boolean; + /** + * The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`. + * - Can only be set to CK_TRUE by the SO user. + */ + trusted: boolean; + /** + * For wrapping keys. + * The attribute template to match against any keys wrapped using this wrapping key. + * Keys that do not match cannot be wrapped. + */ + wrapTemplate: void; + /** + * For wrapping keys. + * The attribute template to apply to any keys unwrapped using this wrapping key. + * Any user supplied template is applied after this template as if the object has already been created. + */ + unwrapTemplate: void; + } + + interface Storage extends SessionObject { + /** + * `true` if object is a token object; + * `false` if object is a session object. Default is `false`. + */ + token: boolean; + /** + * `true` if object is a private object; + * `false` if object is a public object. + * Default value is token-specific, and may depend on the values of other attributes of the object. + */ + private: boolean; + /** + * `true` if object can be modified. Default is `false` + */ + modifiable: boolean; + /** + * Description of the object (default empty) + */ + label: string; + } + + interface SessionObject extends HandleObject { + /** + * Session + */ + session: Session; + /** + * gets the size of an object in bytes + * + * @readonly + * @type {number} + */ + size: number; + /** + * copies an object, creating a new object for the copy + * + * @param {ITemplate} template template for the new object + * @returns {SessionObject} + */ + copy(template: ITemplate): SessionObject; + /** + * destroys an object + */ + destroy(): void; + getAttribute(attr: string): ITemplate; + getAttribute(attrs: ITemplate): ITemplate; + setAttribute(attrs: string, value: any): void; + setAttribute(attrs: ITemplate): void; + class: graphene.ObjectClass; + toType(): T; + } + + // ========== Crypto ========== + + /** + * Type CryptoData + */ + type CryptoData = string | Buffer; + + interface INamedCurve { + name: string; + oid: string; value: Buffer; + size: number; + } + + /** + * Cipher + * + * @interface Cipher + * @extends {BaseObject} + */ + interface Cipher extends BaseObject { + update(data: CryptoData): Buffer; + final(): Buffer; + once(data: CryptoData, enc: Buffer): Buffer; + once(data: CryptoData, enc: Buffer, cb: (error: Error, data: Buffer) => void): void; + } + + /** + * Decipher + * + * @interface Decipher + * @extends {BaseObject} + */ + interface Decipher extends BaseObject { + update(data: Buffer): Buffer; + final(): Buffer; + once(data: Buffer, dec: Buffer): Buffer; + once(data: Buffer, dec: Buffer, cb: (error: Error, data: Buffer) => void): void; + } + + /** + * Digest + * + * @interface Digest + * @extends {BaseObject} + */ + interface Digest extends BaseObject { + update(data: CryptoData): void; + final(): Buffer; + once(data: CryptoData): Buffer; + once(data: CryptoData, cb: (error: Error, data: Buffer) => void): void; + } + + /** + * Sign + * + * @interface Sign + * @extends {BaseObject} + */ + interface Sign extends BaseObject { + update(data: CryptoData): void; + final(): Buffer; + once(data: CryptoData): Buffer; + once(data: CryptoData, cb: (error: Error, data: Buffer) => void): void; + } + + /** + * Verify + * + * @interface Verify + * @extends {BaseObject} + */ + interface Verify extends BaseObject { + update(data: CryptoData): void; + final(signature: Buffer): boolean; + once(data: CryptoData, signature: Buffer): boolean; + once(data: CryptoData, signature: Buffer, cb: (error: Error, valid: boolean) => void): void; + } + + interface IAlgorithm { + name: string; + params: Buffer | IParams; + } + + type MechanismType = graphene.MechanismEnum | graphene.KeyGenMechanism | IAlgorithm | string; + + interface Mechanism extends BaseObject { + /** + * the minimum size of the key for the mechanism + * _whether this is measured in bits or in bytes is mechanism-dependent_ + */ + minKeySize: number; + /** + * the maximum size of the key for the mechanism + * _whether this is measured in bits or in bytes is mechanism-dependent_ + */ + maxKeySize: number; + /** + * bit flag specifying mechanism capabilities + */ + flags: number; + /** + * returns string name from MechanismEnum + */ + name: string; + } + + interface IParams { + toCKI(): any; + } + + interface IKeyPair { + privateKey: PrivateKey; + publicKey: PublicKey; + } + + /** + * provides information about a session + * + * @ + * @class Session + * @extends {HandleObject} + */ + interface Session extends HandleObject { + constructor(handle: Handle, slot: Slot, lib: pkcs11.PKCS11); + /** + * Slot + * + * @type {Slot} + */ + slot: Slot; + /** + * the state of the session + * + * @type {number} + */ + state: number; + /** + * bit flags that define the type of session + * + * @type {number} + */ + flags: number; + /** + * an error code defined by the cryptographic device. Used for errors not covered by Cryptoki + * + * @type {number} + */ + deviceError: number; + /** + * closes a session between an application and a token + */ + close(): void; + /** + * initializes the normal user's PIN + * @param {string} pin the normal user's PIN + */ + initPin(pin: string): void; + /** + * modifies the PIN of the user who is logged in + * @param {string} oldPin + * @param {string} newPin + */ + setPin(oldPin: string, newPin: string): void; + /** + * obtains a copy of the cryptographic operations state of a session, encoded as a string of bytes + */ + getOperationState(): Buffer; + /** + * restores the cryptographic operations state of a session + * from a string of bytes obtained with getOperationState + * @param {Buffer} state the saved state + * @param {number} encryptionKey holds key which will be used for an ongoing encryption + * or decryption operation in the restored session + * (or 0 if no encryption or decryption key is needed, + * either because no such operation is ongoing in the stored session + * or because all the necessary key information is present in the saved state) + * @param {number} authenticationKey holds a handle to the key which will be used for an ongoing signature, + * MACing, or verification operation in the restored session + * (or 0 if no such key is needed, either because no such operation is ongoing in the stored session + * or because all the necessary key information is present in the saved state) + */ + setOperationState(state: Buffer, encryptionKey?: number, authenticationKey?: number): void; + /** + * logs a user into a token + * @param {string} pin the user's PIN. + * - This standard allows PIN values to contain any valid `UTF8` character, + * but the token may impose subset restrictions + * @param {} userType the user type. Default is `USER` + */ + login(pin: string, userType?: graphene.UserType): void; + /** + * logs a user out from a token + */ + logout(): void; + /** + * creates a new object + * - Only session objects can be created during a read-only session. + * - Only public objects can be created unless the normal user is logged in. + * @param {ITemplate} template the object's template + * @returns {SessionObject} + */ + create(template: ITemplate): SessionObject; + /** + * Copies an object, creating a new object for the copy + * @param {SessionObject} object the copied object + * @param {ITemplate} template template for new object + * @returns {SessionObject} + */ + copy(object: SessionObject, template: ITemplate): SessionObject; + /** + * removes all session objects matched to template + * - if template is null, removes all session objects + * - returns a number of destroied session objects + * @param {ITemplate} template template + */ + destroy(template: ITemplate): number; + /** + * @param {SessionObject} object + */ + destroy(object: SessionObject): number; + destroy(): number; + /** + * removes all session objects + * - returns a number of destroied session objects + */ + clear(): number; + /** + * returns a collection of session objects mached to template + * @param template template + * @param callback optional callback function wich is called for each founded object + * - if callback function returns false, it breaks find function. + */ + find(callback?: (obj: SessionObject) => any): SessionObjectCollection; + find(template: ITemplate, callback?: (obj: SessionObject, index: number) => any): SessionObjectCollection; + /** + * Returns object from session by handle + * @param {number} handle handle of object + * @returns T + */ + getObject(handle: Handle): T; + /** + * generates a secret key or set of domain parameters, creating a new object. + * @param mechanism generation mechanism + * @param template template for the new key or set of domain parameters + */ + generateKey(mechanism: MechanismType, template?: ITemplate): SecretKey; + generateKey(mechanism: MechanismType, template: ITemplate, callback: (err: Error, key: SecretKey) => void): void; + generateKeyPair(mechanism: MechanismType, publicTemplate: ITemplate, privateTemplate: ITemplate): IKeyPair; + generateKeyPair(mechanism: MechanismType, publicTemplate: ITemplate, privateTemplate: ITemplate, callback: (err: Error, keys: IKeyPair) => void): void; + createSign(alg: MechanismType, key: Key): Sign; + createVerify(alg: MechanismType, key: Key): Verify; + createCipher(alg: MechanismType, key: Key): Cipher; + createDecipher(alg: MechanismType, key: Key, blockSize?: number): Decipher; + createDigest(alg: MechanismType): Digest; + wrapKey(alg: MechanismType, wrappingKey: Key, key: Key): Buffer; + wrapKey(alg: MechanismType, wrappingKey: Key, key: Key, callback: (err: Error, wkey: Buffer) => void): void; + unwrapKey(alg: MechanismType, unwrappingKey: Key, wrappedKey: Buffer, template: ITemplate): Key; + unwrapKey(alg: MechanismType, unwrappingKey: Key, wrappedKey: Buffer, template: ITemplate, callback: (err: Error, key: Key) => void): void; + /** + * derives a key from a base key, creating a new key object + * @param {MechanismType} alg key deriv. mech + * @param {Key} baseKey base key + * @param {ITemplate} template new key template + */ + deriveKey(alg: MechanismType, baseKey: Key, template: ITemplate): SecretKey; + deriveKey(alg: MechanismType, baseKey: Key, template: ITemplate, callback: (err: Error, key: Key) => void): void; + /** + * generates random data + * @param {number} size \# of bytes to generate + */ + generateRandom(size: number): Buffer; + } + + interface Slot extends HandleObject { + slotDescription: string; + manufacturerID: string; + flags: number; + hardwareVersion: pkcs11.Version; + firmwareVersion: pkcs11.Version; + module: graphene.Module; + /** + * Returns information about token + * + * @returns {Token} + */ + getToken(): Token; + /** + * returns list of `MechanismInfo` + * + * @returns {MechanismCollection} + */ + getMechanisms(): MechanismCollection; + /** + * initializes a token + * + * @param {string} pin the SO's initial PIN + * @returns {string} + */ + initToken(pin: string): string; + /** + * opens a session between an application and a token in a particular slot + * + * @param {SessionFlag} [flags=session.SessionFlag.SERIAL_SESSION] indicates the type of session + * @returns {Session} + */ + open(flags?: graphene.SessionFlag): Session; + /** + * closes all sessions an application has with a token + */ + closeAll(): void; + } + + interface Token extends HandleObject { + /** + * application-defined label, assigned during token initialization. + * - Must be padded with the blank character (' '). + * - Should __not__ be null-terminated. + */ + label: string; + /** + * ID of the device manufacturer. + * - Must be padded with the blank character (' '). + * - Should __not__ be null-terminated. + */ + manufacturerID: string; + /** + * model of the device. + * - Must be padded with the blank character (' '). + * - Should __not__ be null-terminated. + */ + model: string; + /** + * character-string serial number of the device. + * - Must be padded with the blank character (' '). + * - Should __not__ be null-terminated. + */ + serialNumber: string; + /** + * bit flags indicating capabilities and status of the device + */ + flags: number; + /** + * maximum number of sessions that can be opened with the token at one time by a single application + */ + maxSessionCount: number; + /** + * number of sessions that this application currently has open with the token + */ + sessionCount: number; + /** + * maximum number of read/write sessions that can be opened + * with the token at one time by a single application + */ + maxRwSessionCount: number; + /** + * number of read/write sessions that this application currently has open with the token + */ + rwSessionCount: number; + /** + * maximum length in bytes of the PIN + */ + maxPinLen: number; + /** + * minimum length in bytes of the PIN + */ + minPinLen: number; + /** + * the total amount of memory on the token in bytes in which public objects may be stored + */ + totalPublicMemory: number; + /** + * the amount of free (unused) memory on the token in bytes for public objects + */ + freePublicMemory: number; + /** + * the total amount of memory on the token in bytes in which private objects may be stored + */ + totalPrivateMemory: number; + /** + * the amount of free (unused) memory on the token in bytes for private objects + */ + freePrivateMemory: number; + /** + * version number of hardware + */ + hardwareVersion: pkcs11.Version; + /** + * version number of firmware + */ + firmwareVersion: pkcs11.Version; + /** + * current time as a character-string of length 16, + * represented in the format YYYYMMDDhhmmssxx + */ + utcTime: Date; } interface ITemplate { @@ -1638,7 +1380,7 @@ declare module "graphene-pk11" { /** * CKA_OTP_USER_IDENTIFIER */ - OtpUserId?: any; + otpUserId?: any; /** * CKA_OTP_SERVICE_IDENTIFIER */ @@ -1724,41 +1466,211 @@ declare module "graphene-pk11" { */ allowedMechanisms?: any; } - class Attribute { - protected $value: Buffer; - type: number; - name: string; - convertType: string; - length: number; - value: any; - constructor(type: number, value?: any); - constructor(type: string, value?: any); - get(): any; - set(template: any): void; - } - class Template { - protected attrs: Attribute[]; - length: number; - constructor(template: string); - constructor(template: ITemplate); - set(v: any): Template; - ref(): Buffer; - serialize(): any; + +} + +declare module "graphene-pk11" { + import * as graphene from "types/graphene-pk11"; + import * as pkcs11 from "pkcs11js"; + + // ========== Parameters ========== + + // ========== AES ========== + + /** + * Parameter AES CBC + * + * @class AesCbcParams + * @implements {graphene.IParams} + * @implements {pkcs11.AesCBC} + */ + class AesCbcParams implements graphene.IParams, pkcs11.AesCBC { + /** + * initialization vector + * - must have a fixed size of 16 bytes + */ + iv: Buffer; + /** + * the data + */ + data: Buffer; + type: MechParams; + constructor(iv: Buffer, data?: Buffer); + toCKI(): Buffer; } - class BaseObject { - protected lib: Pkcs11; - constructor(lib?: Pkcs11); - } - class HandleObject extends BaseObject { + /** + * Parameter AES CCM + * + * @class AesCcmParams + * @implements {graphene.IParams} + */ + class AesCcmParams implements graphene.IParams { /** - * handle to pkcs11 object + * length of the data where 0 <= dataLength < 2^8L */ - handle: number; - constructor(handle: number, lib: Pkcs11); - protected getInfo(): void; + dataLength: number; + /** + * the nonce + */ + nonce: Buffer; + /** + * the additional authentication data + * - This data is authenticated but not encrypted + */ + aad: Buffer; + /** + * length of authentication tag (output following cipher text) in bits. + * - Can be any value between 0 and 128 + */ + macLength: number; + type: MechParams; + constructor(dataLength: number, nonce: Buffer, aad?: Buffer, macLength?: number); + toCKI(): pkcs11.AesCCM; } + /** + * Parameter AES GCM + * + * @class AesGcmParams + * @implements {graphene.IParams} + */ + class AesGcmParams implements graphene.IParams { + /** + * initialization vector + * - The length of the initialization vector can be any number between 1 and 256. + * 96-bit (12 byte) IV values can be processed more efficiently, + * so that length is recommended for situations in which efficiency is critical. + */ + iv: Buffer; + /** + * pointer to additional authentication data. + * This data is authenticated but not encrypted. + */ + aad: Buffer; + /** + * length of authentication tag (output following cipher text) in bits. + * Can be any value between 0 and 128. Default 128 + */ + tagBits: number; + type: MechParams; + constructor(iv: Buffer, aad?: Buffer, tagBits?: number); + toCKI(): pkcs11.AesGCM; + } + + // ========== EC ========== + + /** + * Parameter EC DH + * + * @class EcdhParams + * @implements {graphene.IParams} + * @implements {pkcs11.ECDH1} + */ + class EcdhParams implements graphene.IParams, pkcs11.ECDH1 { + /** + * key derivation function used on the shared secret value + */ + kdf: EcKdf; + /** + * some data shared between the two parties + */ + sharedData: Buffer; + /** + * other party's EC public key value + */ + publicData: Buffer; + type: MechParams; + /** + * Creates an instance of EcdhParams. + * + * @param {EcKdf} kdf key derivation function used on the shared secret value + * @param {Buffer} [sharedData=null] some data shared between the two parties + * @param {Buffer} [publicData=null] other party's EC public key value + */ + constructor(kdf: EcKdf, sharedData?: Buffer, publicData?: Buffer); + toCKI(): pkcs11.ECDH1; + } + + class NamedCurve { + static getByName(name: string): graphene.INamedCurve; + static getByOid(oid: string): graphene.INamedCurve; + } + + /** + * EcKdf is used to indicate the Key Derivation Function (KDF) + * applied to derive keying data from a shared secret. + * The key derivation function will be used by the EC key agreement schemes. + */ + enum EcKdf { + NULL, + SHA1, + SHA224, + SHA256, + SHA384, + SHA512, + } + + // ========== RSA ========== + + /** + * Parameter RSA OAEP + * + * @class RsaOaepParams + * @implements {graphene.IParams} + */ + class RsaOaepParams implements graphene.IParams { + hashAlgorithm: MechanismEnum; + mgf: RsaMgf; + source: number; + sourceData: Buffer; + type: MechParams; + constructor(hashAlg?: MechanismEnum, mgf?: RsaMgf, sourceData?: Buffer); + toCKI(): pkcs11.RsaOAEP; + } + + /** + * Parameter RSA PSS + * + * @class RsaPssParams + * @implements {graphene.IParams} + */ + class RsaPssParams implements graphene.IParams { + /** + * hash algorithm used in the PSS encoding; + * - if the signature mechanism does not include message hashing, + * then this value must be the mechanism used by the application to generate + * the message hash; + * - if the signature mechanism includes hashing, + * then this value must match the hash algorithm indicated + * by the signature mechanism + */ + hashAlgorithm: MechanismEnum; + /** + * mask generation function to use on the encoded block + */ + mgf: RsaMgf; + /** + * length, in bytes, of the salt value used in the PSS encoding; + * - typical values are the length of the message hash and zero + */ + saltLength: number; + type: MechParams; + constructor(hashAlg?: MechanismEnum, mgf?: RsaMgf, saltLen?: number); + toCKI(): pkcs11.RsaPSS; + } + + enum RsaMgf { + MGF1_SHA1, + MGF1_SHA224, + MGF1_SHA256, + MGF1_SHA384, + MGF1_SHA512, + } + + + // ========== Enums ========== + enum ObjectClass { DATA, CERTIFICATE, @@ -1771,327 +1683,467 @@ declare module "graphene-pk11" { OTP_KEY, } - class SessionObject extends HandleObject { - /** - * Session - */ - session: Session; - /** - * gets the size of an object in bytes - */ - size: number; - constructor(object: SessionObject); - constructor(handle: number, session: Session, lib: Pkcs11); - /** - * copies an object, creating a new object for the copy - * @param {ITemplate} template template for the new object - */ - copy(template: ITemplate): SessionObject; - /** - * destroys an object - */ - destroy(): void; - getAttribute(attr: string): ITemplate; - getAttribute(attrs: ITemplate): ITemplate; - setAttribute(attrs: string, value: any): any; - setAttribute(attrs: ITemplate): any; - protected get(name: string): any; - protected set(name: string, value: any): void; - class: ObjectClass; - toType(): T; + class Mechanism { + static vendor(jsonFile: string): void; + static vendor(name: string, value: number): void; } - class SessionObjectCollection extends Collection { - session: Session; - items(index: number): SessionObject; - constructor(items: Array, session: Session, lib: Pkcs11, classType?: any); + enum CertificateType { + X_509, + X_509_ATTR_CERT, + WTLS, } - /** - * Private key objects (object class `CKO_PRIVATE_KEY`) hold private keys - */ - class PrivateKey extends Key { - /** - * DER-encoding of the key subject name (default empty) - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - */ - subject: Buffer; - /** - * `CK_TRUE` if key is sensitive - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Attribute cannot be changed once set to CK_TRUE. It becomes a read only attribute. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - sensitive: boolean; - /** - * `CK_TRUE` if key supports decryption - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - decrypt: boolean; - /** - * `CK_TRUE` if key supports signatures where the signature is an appendix to the data - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - sign: boolean; - /** - * `CK_TRUE` if key supports signatures where the data can be recovered from the signature - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - signRecover: boolean; - /** - * `CK_TRUE` if key supports unwrapping (i.e., can be used to unwrap other keys) - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - unwrap: boolean; - /** - * `CK_TRUE` if key is extractable and can be wrapped - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Attribute cannot be changed once set to `CK_FALSE`. It becomes a read only attribute. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - extractable: boolean; - /** - * `CK_TRUE` if key has always had the `CKA_SENSITIVE` attribute set to `CK_TRUE` - * - Must not be specified when object is created with `C_CreateObject`. - * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. - * - Must not be specified when object is unwrapped with `C_UnwrapKey`. - */ - alwaysSensitive: boolean; - /** - * `CK_TRUE` if key has never had the `CKA_EXTRACTABLE` attribute set to `CK_TRUE` - * - Must not be specified when object is created with `C_CreateObject`. - * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. - * - Must not be specified when object is unwrapped with `C_UnwrapKey`. - */ - neverExtractable: boolean; - /** - * `CK_TRUE` if the key can only be wrapped with a wrapping key - * that has `CKA_TRUSTED` set to `CK_TRUE`. Default is `CK_FALSE`. - * - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute. - */ - wrapTrusted: boolean; - /** - * For wrapping keys. The attribute template to apply to any keys unwrapped - * using this wrapping key. Any user supplied template is applied after this template - * as if the object has already been created. - */ - template: void; - alwaysAuthenticate: boolean; + enum CertificateCategory { + Unspecified = 0, + TokenUser = 1, + Authority = 2, + OtherEntity = 3, } - /** - * Public key objects (object class CKO_PUBLIC_KEY) hold public keys - */ - class PublicKey extends Key { - /** - * DER-encoding of the key subject name (default empty) - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - */ - subject: Buffer; - /** - * `CK_TRUE` if key supports encryption - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - encrypt: boolean; - /** - * `CK_TRUE` if key supports verification where the signature is an appendix to the data - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - verify: boolean; - /** - * `CK_TRUE` if key supports verification where the data is recovered from the signature - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - verifyRecover: boolean; - /** - * `CK_TRUE` if key supports wrapping (i.e., can be used to wrap other keys) - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - wrap: boolean; - /** - * The key can be trusted for the application that it was created. - * - The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`. - * - Can only be set to CK_TRUE by the SO user. - */ - trusted: boolean; - /** - * For wrapping keys. The attribute template to match against any keys wrapped using this wrapping key. - * Keys that do not match cannot be wrapped. - */ - template: void; + enum KeyType { + RSA, + DSA, + DH, + ECDSA, + EC, + X9_42_DH, + KEA, + GENERIC_SECRET, + RC2, + RC4, + DES, + DES2, + DES3, + CAST, + CAST3, + CAST5, + CAST128, + RC5, + IDEA, + SKIPJACK, + BATON, + JUNIPER, + CDMF, + AES, + GOSTR3410, + GOSTR3411, + GOST28147, + BLOWFISH, + TWOFISH, + SECURID, + HOTP, + ACTI, + CAMELLIA, + ARIA, } - /** - * Secret key objects (object class `CKO_SECRET_KEY`) hold secret keys. - */ - class SecretKey extends Key { - /** - * `CK_TRUE` if key is sensitive - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute. - */ - sensitive: boolean; - /** - * `CK_TRUE` if key supports encryption - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - encrypt: boolean; - /** - * `CK_TRUE` if key supports decryption - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - decrypt: boolean; - /** - * `CK_TRUE` if key supports verification (i.e., of authentication codes) where the signature is an appendix to the data - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - verify: boolean; - /** - * `CK_TRUE` if key supports signatures (i.e., authentication codes) where the signature is an appendix to the data - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - sign: boolean; - /** - * `CK_TRUE` if key supports wrapping (i.e., can be used to wrap other keys) - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - wrap: boolean; - /** - * `CK_TRUE` if key supports unwrapping (i.e., can be used to unwrap other keys) - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - unwrap: boolean; - /** - * `CK_TRUE` if key is extractable and can be wrapped - * - May be modified after object is created with a `C_SetAttributeValue` call, - * or in the process of copying object with a `C_CopyObject` call. - * However, it is possible that a particular token may not permit modification of the attribute - * during the course of a `C_CopyObject` call. - * - Attribute cannot be changed once set to `CK_FALSE`. It becomes a read only attribute. - * - Default value is token-specific, and may depend on the values of other attributes. - */ - extractable: boolean; - /** - * `CK_TRUE` if key has always had the `CKA_SENSITIVE` attribute set to `CK_TRUE` - * - Must not be specified when object is created with `C_CreateObject`. - * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. - * - Must not be specified when object is unwrapped with `C_UnwrapKey`. - */ - alwaysSensitive: boolean; - /** - * `CK_TRUE` if key has never had the `CKA_EXTRACTABLE` attribute set to `CK_TRUE` - * - Must not be specified when object is created with `C_CreateObject`. - * - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`. - * - Must not be specified when object is unwrapped with `C_UnwrapKey`. - */ - neverExtractable: boolean; - /** - * Key checksum - */ - checkValue: Buffer; - /** - * `CK_TRUE` if the key can only be wrapped with a wrapping key - * that has `CKA_TRUSTED` set to `CK_TRUE`. Default is `CK_FALSE`. - * - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute. - */ - wrapTrusted: boolean; - /** - * The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`. - * - Can only be set to CK_TRUE by the SO user. - */ - trusted: boolean; - /** - * For wrapping keys. - * The attribute template to match against any keys wrapped using this wrapping key. - * Keys that do not match cannot be wrapped. - */ - wrapTemplate: void; - /** - * For wrapping keys. - * The attribute template to apply to any keys unwrapped using this wrapping key. - * Any user supplied template is applied after this template as if the object has already been created. - */ - unwrapTemplate: void; + enum KeyGenMechanism { + AES, + RSA, + RSA_X9_31, + DSA, + DH_PKCS, + DH_X9_42, + GOSTR3410, + GOST28147, + RC2, + RC4, + DES, + DES2, + SECURID, + ACTI, + CAST, + CAST3, + CAST5, + CAST128, + RC5, + IDEA, + GENERIC_SECRET, + SSL3_PRE_MASTER, + CAMELLIA, + ARIA, + SKIPJACK, + KEA, + BATON, + ECDSA, + EC, + JUNIPER, + TWOFISH, } + enum MechanismFlag { + /** + * `True` if the mechanism is performed by the device; `false` if the mechanism is performed in software + */ + HW, + /** + * `True` if the mechanism can be used with encrypt function + */ + ENCRYPT, + /** + * `True` if the mechanism can be used with decrypt function + */ + DECRYPT, + /** + * `True` if the mechanism can be used with digest function + */ + DIGEST, + /** + * `True` if the mechanism can be used with sign function + */ + SIGN, + /** + * `True` if the mechanism can be used with sign recover function + */ + SIGN_RECOVER, + /** + * `True` if the mechanism can be used with verify function + */ + VERIFY, + /** + * `True` if the mechanism can be used with verify recover function + */ + VERIFY_RECOVER, + /** + * `True` if the mechanism can be used with geberate function + */ + GENERATE, + /** + * `True` if the mechanism can be used with generate key pair function + */ + GENERATE_KEY_PAIR, + /** + * `True` if the mechanism can be used with wrap function + */ + WRAP, + /** + * `True` if the mechanism can be used with unwrap function + */ + UNWRAP, + /** + * `True` if the mechanism can be used with derive function + */ + DERIVE, + } - interface ISlotInfo { - slotDescription: string; - manufacturerID: string; - flags: number; - hardwareVersion: IVersion; - firmwareVersion: IVersion; + enum MechanismEnum { + RSA_PKCS_KEY_PAIR_GEN, + RSA_PKCS, + RSA_9796, + RSA_X_509, + MD2_RSA_PKCS, + MD5_RSA_PKCS, + SHA1_RSA_PKCS, + RIPEMD128_RSA_PKCS, + RIPEMD160_RSA_PKCS, + RSA_PKCS_OAEP, + RSA_X9_31_KEY_PAIR_GEN, + RSA_X9_31, + SHA1_RSA_X9_31, + RSA_PKCS_PSS, + SHA1_RSA_PKCS_PSS, + DSA_KEY_PAIR_GEN, + DSA, + DSA_SHA1, + DSA_SHA224, + DSA_SHA256, + DSA_SHA384, + DSA_SHA512, + DH_PKCS_KEY_PAIR_GEN, + DH_PKCS_DERIVE, + X9_42_DH_KEY_PAIR_GEN, + X9_42_DH_DERIVE, + X9_42_DH_HYBRID_DERIVE, + X9_42_MQV_DERIVE, + SHA256_RSA_PKCS, + SHA384_RSA_PKCS, + SHA512_RSA_PKCS, + SHA256_RSA_PKCS_PSS, + SHA384_RSA_PKCS_PSS, + SHA512_RSA_PKCS_PSS, + SHA224_RSA_PKCS, + SHA224_RSA_PKCS_PSS, + RC2_KEY_GEN, + RC2_ECB, + RC2_CBC, + RC2_MAC, + RC2_MAC_GENERAL, + RC2_CBC_PAD, + RC4_KEY_GEN, + RC4, + DES_KEY_GEN, + DES_ECB, + DES_CBC, + DES_MAC, + DES_MAC_GENERAL, + DES_CBC_PAD, + DES2_KEY_GEN, + DES3_KEY_GEN, + DES3_ECB, + DES3_CBC, + DES3_MAC, + DES3_MAC_GENERAL, + DES3_CBC_PAD, + CDMF_KEY_GEN, + CDMF_ECB, + CDMF_CBC, + CDMF_MAC, + CDMF_MAC_GENERAL, + CDMF_CBC_PAD, + DES_OFB64, + DES_OFB8, + DES_CFB64, + DES_CFB8, + MD2, + MD2_HMAC, + MD2_HMAC_GENERAL, + MD5, + MD5_HMAC, + MD5_HMAC_GENERAL, + SHA1, + SHA, + SHA_1, + SHA_1_HMAC, + SHA_1_HMAC_GENERAL, + RIPEMD128, + RIPEMD128_HMAC, + RIPEMD128_HMAC_GENERAL, + RIPEMD160, + RIPEMD160_HMAC, + RIPEMD160_HMAC_GENERAL, + SHA256, + SHA256_HMAC, + SHA256_HMAC_GENERAL, + SHA224, + SHA224_HMAC, + SHA224_HMAC_GENERAL, + SHA384, + SHA384_HMAC, + SHA384_HMAC_GENERAL, + SHA512, + SHA512_HMAC, + SHA512_HMAC_GENERAL, + SECURID_KEY_GEN, + SECURID, + HOTP_KEY_GEN, + HOTP, + ACTI, + ACTI_KEY_GEN, + CAST_KEY_GEN, + CAST_ECB, + CAST_CBC, + CAST_MAC, + CAST_MAC_GENERAL, + CAST_CBC_PAD, + CAST3_KEY_GEN, + CAST3_ECB, + CAST3_CBC, + CAST3_MAC, + CAST3_MAC_GENERAL, + CAST3_CBC_PAD, + CAST5_KEY_GEN, + CAST128_KEY_GEN, + CAST5_ECB, + CAST128_ECB, + CAST5_CBC, + CAST128_CBC, + CAST5_MAC, + CAST128_MAC, + CAST5_MAC_GENERAL, + CAST128_MAC_GENERAL, + CAST5_CBC_PAD, + CAST128_CBC_PAD, + RC5_KEY_GEN, + RC5_ECB, + RC5_CBC, + RC5_MAC, + RC5_MAC_GENERAL, + RC5_CBC_PAD, + IDEA_KEY_GEN, + IDEA_ECB, + IDEA_CBC, + IDEA_MAC, + IDEA_MAC_GENERAL, + IDEA_CBC_PAD, + GENERIC_SECRET_KEY_GEN, + CONCATENATE_BASE_AND_KEY, + CONCATENATE_BASE_AND_DATA, + CONCATENATE_DATA_AND_BASE, + XOR_BASE_AND_DATA, + EXTRACT_KEY_FROM_KEY, + SSL3_PRE_MASTER_KEY_GEN, + SSL3_MASTER_KEY_DERIVE, + SSL3_KEY_AND_MAC_DERIVE, + SSL3_MASTER_KEY_DERIVE_DH, + TLS_PRE_MASTER_KEY_GEN, + TLS_MASTER_KEY_DERIVE, + TLS_KEY_AND_MAC_DERIVE, + TLS_MASTER_KEY_DERIVE_DH, + TLS_PRF, + SSL3_MD5_MAC, + SSL3_SHA1_MAC, + MD5_KEY_DERIVATION, + MD2_KEY_DERIVATION, + SHA1_KEY_DERIVATION, + SHA256_KEY_DERIVATION, + SHA384_KEY_DERIVATION, + SHA512_KEY_DERIVATION, + SHA224_KEY_DERIVATION, + PBE_MD2_DES_CBC, + PBE_MD5_DES_CBC, + PBE_MD5_CAST_CBC, + PBE_MD5_CAST3_CBC, + PBE_MD5_CAST5_CBC, + PBE_MD5_CAST128_CBC, + PBE_SHA1_CAST5_CBC, + PBE_SHA1_CAST128_CBC, + PBE_SHA1_RC4_128, + PBE_SHA1_RC4_40, + PBE_SHA1_DES3_EDE_CBC, + PBE_SHA1_DES2_EDE_CBC, + PBE_SHA1_RC2_128_CBC, + PBE_SHA1_RC2_40_CBC, + PKCS5_PBKD2, + PBA_SHA1_WITH_SHA1_HMAC, + WTLS_PRE_MASTER_KEY_GEN, + WTLS_MASTER_KEY_DERIVE, + WTLS_MASTER_KEY_DERIVE_DH_ECC, + WTLS_PRF, + WTLS_SERVER_KEY_AND_MAC_DERIVE, + WTLS_CLIENT_KEY_AND_MAC_DERIVE, + KEY_WRAP_LYNKS, + KEY_WRAP_SET_OAEP, + CAMELLIA_KEY_GEN, + CAMELLIA_ECB, + CAMELLIA_CBC, + CAMELLIA_MAC, + CAMELLIA_MAC_GENERAL, + CAMELLIA_CBC_PAD, + CAMELLIA_ECB_ENCRYPT_DATA, + CAMELLIA_CBC_ENCRYPT_DATA, + CAMELLIA_CTR, + ARIA_KEY_GEN, + ARIA_ECB, + ARIA_CBC, + ARIA_MAC, + ARIA_MAC_GENERAL, + ARIA_CBC_PAD, + ARIA_ECB_ENCRYPT_DATA, + ARIA_CBC_ENCRYPT_DATA, + SKIPJACK_KEY_GEN, + SKIPJACK_ECB64, + SKIPJACK_CBC64, + SKIPJACK_OFB64, + SKIPJACK_CFB64, + SKIPJACK_CFB32, + SKIPJACK_CFB16, + SKIPJACK_CFB8, + SKIPJACK_WRAP, + SKIPJACK_PRIVATE_WRAP, + SKIPJACK_RELAYX, + KEA_KEY_PAIR_GEN, + KEA_KEY_DERIVE, + FORTEZZA_TIMESTAMP, + BATON_KEY_GEN, + BATON_ECB128, + BATON_ECB96, + BATON_CBC128, + BATON_COUNTER, + BATON_SHUFFLE, + BATON_WRAP, + ECDSA_KEY_PAIR_GEN, + EC_KEY_PAIR_GEN, + ECDSA, + ECDSA_SHA1, + ECDSA_SHA224, + ECDSA_SHA256, + ECDSA_SHA384, + ECDSA_SHA512, + ECDH1_DERIVE, + ECDH1_COFACTOR_DERIVE, + ECMQV_DERIVE, + JUNIPER_KEY_GEN, + JUNIPER_ECB128, + JUNIPER_CBC128, + JUNIPER_COUNTER, + JUNIPER_SHUFFLE, + JUNIPER_WRAP, + FASTHASH, + AES_KEY_GEN, + AES_ECB, + AES_CBC, + AES_MAC, + AES_MAC_GENERAL, + AES_CBC_PAD, + AES_CTR, + AES_CMAC, + AES_CMAC_GENERAL, + BLOWFISH_KEY_GEN, + BLOWFISH_CBC, + TWOFISH_KEY_GEN, + TWOFISH_CBC, + AES_GCM, + AES_CCM, + AES_KEY_WRAP, + AES_KEY_WRAP_PAD, + DES_ECB_ENCRYPT_DATA, + DES_CBC_ENCRYPT_DATA, + DES3_ECB_ENCRYPT_DATA, + DES3_CBC_ENCRYPT_DATA, + AES_ECB_ENCRYPT_DATA, + AES_CBC_ENCRYPT_DATA, + GOSTR3410_KEY_PAIR_GEN, + GOSTR3410, + GOSTR3410_WITH_GOSTR3411, + GOSTR3410_KEY_WRAP, + GOSTR3410_DERIVE, + GOSTR3411, + GOSTR3411_HMAC, + GOST28147_KEY_GEN, + GOST28147_ECB, + GOST28147, + GOST28147_MAC, + GOST28147_KEY_WRAP, + DSA_PARAMETER_GEN, + DH_PKCS_PARAMETER_GEN, + X9_42_DH_PARAMETER_GEN, + VENDOR_DEFINED, + } + + enum MechParams { + AesCBC = 1, + AesCCM = 2, + AesGCM = 3, + RsaOAEP = 4, + RsaPSS = 5, + EcDH = 6, + } + + enum SessionFlag { + /** + * `True` if the session is read/write; `false` if the session is read-only + */ + RW_SESSION, + /** + * This flag is provided for backward compatibility, and should always be set to `true` + */ + SERIAL_SESSION + } + + enum UserType { + /** + * Security Officer + */ + SO, + /** + * User + */ + USER, + /** + * Context specific + */ + CONTEXT_SPECIFIC } enum SlotFlag { @@ -2106,205 +2158,7 @@ declare module "graphene-pk11" { /** * True if the slot is a hardware slot, as opposed to a software slot implementing a "soft token" */ - HW_SLOT, - } - - interface IVersion { - major: number; - minor: number; - } - interface IModuleInfo { - cryptokiVersion: IVersion; - manufacturerID: string; - flags: number; - libraryDescription: string; - libraryVersion: IVersion; - } - - class Collection { - protected items_: Array; - protected classType: any; - protected lib: Pkcs11; - constructor(items: Array, lib: Pkcs11, classType: any); - /** - * returns length of collection - */ - length: number; - /** - * returns item from collection by index - * @param {number} index of element in collection `[0..n]` - */ - items(index: number): T; - } - - enum SessionOpenFlag { - /** - * session is r/w - */ - RW_SESSION, - /** - * no parallel - */ - SERIAL_SESSION, - } - enum SessionFlag { - /** - * `True` if the session is read/write; `false` if the session is read-only - */ - RW_SESSION, - /** - * This flag is provided for backward compatibility, and should always be set to `true` - */ - SERIAL_SESSION, - } - enum UserType { - /** - * Security Officer - */ - SO, - /** - * User - */ - USER, - /** - * Context specific - */ - CONTEXT_SPECIFIC, - } - interface IKeyPair { - privateKey: PrivateKey; - publicKey: PublicKey; - } - /** - * provides information about a session - */ - class Session extends HandleObject { - constructor(handle: number, slot: Slot, lib: Pkcs11); - slot: Slot; - /** - * the state of the session - */ - state: number; - /** - * bit flags that define the type of session - */ - flags: number; - /** - * an error code defined by the cryptographic device. Used for errors not covered by Cryptoki - */ - deviceError: number; - protected getInfo(): void; - /** - * closes a session between an application and a token - */ - close(): void; - /** - * initializes the normal user's PIN - * @param {string} pin the normal user's PIN - */ - initPin(pin: string): void; - /** - * modifies the PIN of the user who is logged in - * @param {string} oldPin - * @param {string} newPin - */ - setPin(oldPin: string, newPin: string): void; - /** - * obtains a copy of the cryptographic operations state of a session, encoded as a string of bytes - */ - getOperationState(): Buffer; - /** - * restores the cryptographic operations state of a session - * from a string of bytes obtained with getOperationState - * @param {Buffer} state the saved state - * @param {number} encryptionKey holds key which will be used for an ongoing encryption - * or decryption operation in the restored session - * (or 0 if no encryption or decryption key is needed, - * either because no such operation is ongoing in the stored session - * or because all the necessary key information is present in the saved state) - * @param {number} authenticationKey holds a handle to the key which will be used for an ongoing signature, - * MACing, or verification operation in the restored session - * (or 0 if no such key is needed, either because no such operation is ongoing in the stored session - * or because all the necessary key information is present in the saved state) - */ - setOperationState(state: Buffer, encryptionKey?: number, authenticationKey?: number): void; - /** - * logs a user into a token - * @param {string} pin the user's PIN. - * - This standard allows PIN values to contain any valid `UTF8` character, - * but the token may impose subset restrictions - * @param {} userType the user type. Default is `USER` - */ - login(pin: string, userType?: UserType): void; - /** - * logs a user out from a token - */ - logout(): void; - /** - * creates a new object - * - Only session objects can be created during a read-only session. - * - Only public objects can be created unless the normal user is logged in. - * @param {ITemplate} template the object's template - */ - create(template: ITemplate): SessionObject; - /** - * removes all session objects matched to template - * - if template is null, removes all session objects - * - returns a number of destroied session objects - * @param {ITemplate} template template - */ - destroy(template: ITemplate): number; - /** - * @param {SessionObject} object - */ - destroy(object: SessionObject): number; - destroy(): number; - /** - * removes all session objects - * - returns a number of destroied session objects - */ - clear(): number; - /** - * returns a collection of session objects mached to template - * @param template template - * @param callback optional callback function wich is called for each founded object - * - if callback function returns false, it breaks find function. - */ - find(callback?: (obj: SessionObject) => void): SessionObjectCollection; - find(template: ITemplate, callback?: (obj: SessionObject) => void): SessionObjectCollection; - /** - * Returns object from session by handle - * @param {number} handle handle of object - * @returns T - */ - getObject(handle: number): T; - /** - * generates a secret key or set of domain parameters, creating a new object. - * @param mechanism generation mechanism - * @param template template for the new key or set of domain parameters - */ - generateKey(mechanism: MechanismType, template?: ITemplate): SecretKey; - generateKey(mechanism: MechanismType, template: ITemplate, callback: (err: Error, key: SecretKey) => void): void; - generateKeyPair(mechanism: MechanismType, publicTemplate: ITemplate, privateTemplate: ITemplate): IKeyPair; - createSign(alg: MechanismType, key: Key): Sign; - createVerify(alg: MechanismType, key: Key): Verify; - createCipher(alg: MechanismType, key: Key): Cipher; - createDecipher(alg: MechanismType, key: Key): Decipher; - createDigest(alg: MechanismType): Digest; - wrapKey(alg: MechanismType, wrappingKey: Key, key: Key): Buffer; - unwrapKey(alg: MechanismType, unwrappingKey: Key, wrappedKey: Buffer, template: ITemplate): Key; - /** - * derives a key from a base key, creating a new key object - * @param {MechanismType} alg key deriv. mech - * @param {Key} baseKey base key - * @param {ITemplate} template new key template - */ - deriveKey(alg: MechanismType, baseKey: Key, template: ITemplate): SecretKey; - /** - * generates random data - * @param {number} size \# of bytes to generate - */ - generateRandom(size: number): Buffer; + HW_SLOT } enum TokenFlag { @@ -2325,139 +2179,25 @@ declare module "graphene-pk11" { SO_PIN_COUNT_LOW, SO_PIN_FINAL_TRY, SO_PIN_LOCKED, - SO_PIN_TO_BE_CHANGED, - } - class Token extends HandleObject { - /** - * application-defined label, assigned during token initialization. - * - Must be padded with the blank character (' '). - * - Should __not__ be null-terminated. - */ - label: string; - /** - * ID of the device manufacturer. - * - Must be padded with the blank character (' '). - * - Should __not__ be null-terminated. - */ - manufacturerID: string; - /** - * model of the device. - * - Must be padded with the blank character (' '). - * - Should __not__ be null-terminated. - */ - model: string; - /** - * character-string serial number of the device. - * - Must be padded with the blank character (' '). - * - Should __not__ be null-terminated. - */ - serialNumber: string; - /** - * bit flags indicating capabilities and status of the device - */ - flags: number; - /** - * maximum number of sessions that can be opened with the token at one time by a single application - */ - maxSessionCount: number; - /** - * number of sessions that this application currently has open with the token - */ - sessionCount: number; - /** - * maximum number of read/write sessions that can be opened - * with the token at one time by a single application - */ - maxRwSessionCount: number; - /** - * number of read/write sessions that this application currently has open with the token - */ - rwSessionCount: number; - /** - * maximum length in bytes of the PIN - */ - maxPinLen: number; - /** - * minimum length in bytes of the PIN - */ - minPinLen: number; - /** - * the total amount of memory on the token in bytes in which public objects may be stored - */ - totalPublicMemory: number; - /** - * the amount of free (unused) memory on the token in bytes for public objects - */ - freePublicMemory: number; - /** - * the total amount of memory on the token in bytes in which private objects may be stored - */ - totalPrivateMemory: number; - /** - * the amount of free (unused) memory on the token in bytes for private objects - */ - freePrivateMemory: number; - /** - * version number of hardware - */ - hardwareVersion: IVersion; - /** - * version number of firmware - */ - firmwareVersion: IVersion; - /** - * current time as a character-string of length 16, - * represented in the format YYYYMMDDhhmmssxx - */ - utcTime: Date; - constructor(handle: number, lib: Pkcs11); - protected getInfo(): void; + SO_PIN_TO_BE_CHANGED } - class Slot extends HandleObject implements ISlotInfo { - slotDescription: string; - manufacturerID: string; - flags: number; - hardwareVersion: IVersion; - firmwareVersion: IVersion; - module: Module; - constructor(handle: number, module: Module, lib: Pkcs11); - protected getInfo(): void; - getToken(): Token; - /** - * returns list of `MechanismInfo` - */ - getMechanisms(): MechanismCollection; - /** - * initializes a token - * @param {string} pin the SO's initial PIN - * @param {string} label label of the token - */ - initToken(pin: string, label: string): void; - /** - * opens a session between an application and a token in a particular slot - * @parsm flags indicates the type of session - */ - open(flags?: number): Session; - /** - * closes all sessions an application has with a token - */ - closeAll(): void; + enum JavaMIDP { + Unspecified, + Manufacturer, + Operator, + ThirdParty } - class SlotCollection extends Collection { - module: Module; - items(index: number): Slot; - constructor(items: Array, module: Module, lib: Pkcs11, classType?: any); - } + // ========== Module ========== - class Module extends BaseObject implements IModuleInfo { + class Module implements graphene.BaseObject { libFile: string; libName: string; /** * Cryptoki interface version */ - cryptokiVersion: IVersion; + cryptokiVersion: pkcs11.Version; /** * blank padded manufacturer ID */ @@ -2473,9 +2213,10 @@ declare module "graphene-pk11" { /** * version of library */ - libraryVersion: IVersion; - constructor(lib: Pkcs11); - protected getInfo(): void; + libraryVersion: pkcs11.Version; + + constructor(lib: pkcs11.PKCS11); + /** * initializes the Cryptoki library */ @@ -2489,231 +2230,17 @@ declare module "graphene-pk11" { * @param {number} index index of an element in collection * @param {number} tokenPresent only slots with tokens. Default `True` */ - getSlots(index: number, tokenPresent?: boolean): Slot; + getSlots(index: number, tokenPresent?: boolean): graphene.Slot; /** * @param {number} tokenPresent only slots with tokens. Default `True` */ - getSlots(tokenPresent?: boolean): SlotCollection; + getSlots(tokenPresent?: boolean): graphene.SlotCollection; /** * loads pkcs11 lib + * @param libFile path to PKCS11 library + * @param libName name of PKCS11 library */ static load(libFile: string, libName?: string): Module; } - class Cipher { - session: Session; - lib: Pkcs11; - constructor(session: Session, alg: MechanismType, key: Key, lib: Pkcs11); - protected init(alg: MechanismType, key: Key): void; - update(text: string): Buffer; - update(data: Buffer): Buffer; - final(): Buffer; - } - - class Decipher { - session: Session; - lib: Pkcs11; - constructor(session: Session, alg: MechanismType, key: Key, lib: Pkcs11); - protected init(alg: MechanismType, key: Key): void; - update(text: string): Buffer; - update(data: Buffer): Buffer; - final(): Buffer; - } - - class Digest { - session: Session; - lib: Pkcs11; - constructor(session: Session, alg: MechanismType, lib: Pkcs11); - protected init(alg: MechanismType): void; - update(text: string): void; - update(data: Buffer): void; - final(): Buffer; - } - - class Sign { - session: Session; - lib: Pkcs11; - constructor(session: Session, alg: MechanismType, key: Key, lib: Pkcs11); - protected init(alg: MechanismType, key: Key): void; - update(text: string): void; - update(data: Buffer): void; - final(): Buffer; - } - - class Verify { - session: Session; - lib: Pkcs11; - constructor(session: Session, alg: MechanismType, key: Key, lib: Pkcs11); - protected init(alg: MechanismType, key: Key): void; - update(text: string): void; - update(data: Buffer): void; - final(signature: Buffer): boolean; - } - - /** - * - * EC - * - */ - - /** - * EcKdf is used to indicate the Key Derivation Function (KDF) - * applied to derive keying data from a shared secret. - * The key derivation function will be used by the EC key agreement schemes. - */ - enum EcKdf { - NULL, - SHA1, - SHA224, - SHA256, - SHA384, - SHA512, - } - - class EcdhParams implements IParams { - /** - * key derivation function used on the shared secret value - */ - kdf: EcKdf; - /** - * some data shared between the two parties - */ - sharedData: Buffer; - /** - * other party's EC public key value - */ - publicData: Buffer; - /** - * @param {EcKdf} kdf key derivation function used on the shared secret value - * @param {Buffer=null} sharedData some data shared between the two parties - * @param {Buffer=null} publicData other party's EC public key value - */ - constructor(kdf: EcKdf, sharedData?: Buffer, publicData?: Buffer); - toCKI(): Buffer; - } - - export interface INamedCurve { - name: string; - oid: string; - value: Buffer; - size: number; - } - - class NamedCurve { - static getByName(name: string): INamedCurve; - static getByOid(oid: string): INamedCurve; - } - - /** - * - * AES - * - */ - - class AesCbcParams implements IParams { - /** - * initialization vector - * - must have a fixed size of 16 bytes - */ - iv: Buffer; - /** - * the data - */ - data: Buffer; - constructor(iv: Buffer, data: Buffer); - toCKI(): Buffer; - } - - class AesCcmParams implements IParams { - /** - * length of the data where 0 <= dataLength < 2^8L - */ - dataLength: number; - /** - * the nonce - */ - nonce: Buffer; - /** - * the additional authentication data - * - This data is authenticated but not encrypted - */ - aad: Buffer; - /** - * length of authentication tag (output following cipher text) in bits. - * - Can be any value between 0 and 128 - */ - macLength: number; - constructor(dataLength: number, nonce: Buffer, aad?: Buffer, macLength?: number); - toCKI(): Buffer; - } - - class AesGcmParams implements IParams { - /** - * initialization vector - * - The length of the initialization vector can be any number between 1 and 256. - * 96-bit (12 byte) IV values can be processed more efficiently, - * so that length is recommended for situations in which efficiency is critical. - */ - iv: Buffer; - /** - * pointer to additional authentication data. - * This data is authenticated but not encrypted. - */ - aad: Buffer; - /** - * length of authentication tag (output following cipher text) in bits. - * Can be any value between 0 and 128. Default 128 - */ - tagBits: number; - constructor(iv: Buffer, aad?: Buffer, tagBits?: number); - toCKI(): Buffer; - } - - /** - * - * RSA - * - */ - - enum RsaMgf { - MGF1_SHA1, - MGF1_SHA224, - MGF1_SHA256, - MGF1_SHA384, - MGF1_SHA512, - } - - class RsaOaepParams implements IParams { - hashAlgorithm: MechanismEnum; - mgf: RsaMgf; - source: number; - sourceData: Buffer; - constructor(hashAlg?: MechanismEnum, mgf?: RsaMgf, sourceData?: Buffer); - toCKI(): Buffer; - } - - class RsaPssParams implements IParams { - /** - * hash algorithm used in the PSS encoding; - * - if the signature mechanism does not include message hashing, - * then this value must be the mechanism used by the application to generate - * the message hash; - * - if the signature mechanism includes hashing, - * then this value must match the hash algorithm indicated - * by the signature mechanism - */ - hashAlgorithm: MechanismEnum; - /** - * mask generation function to use on the encoded block - */ - mgf: RsaMgf; - /** - * length, in bytes, of the salt value used in the PSS encoding; - * - typical values are the length of the message hash and zero - */ - saltLength: number; - constructor(hashAlg?: MechanismEnum, mgf?: RsaMgf, saltLen?: number); - toCKI(): Buffer; - } - } \ No newline at end of file From c66c9bc8537ddae07c7a38c8149ab08ec11be4d9 Mon Sep 17 00:00:00 2001 From: microshine Date: Fri, 12 Aug 2016 00:55:47 +0300 Subject: [PATCH 47/80] Fix error --- graphene-pk11/graphene-pk11.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/graphene-pk11/graphene-pk11.d.ts b/graphene-pk11/graphene-pk11.d.ts index 2ebec894dd..bc6e178ae6 100644 --- a/graphene-pk11/graphene-pk11.d.ts +++ b/graphene-pk11/graphene-pk11.d.ts @@ -793,7 +793,6 @@ declare module "types/graphene-pk11" { * @extends {HandleObject} */ interface Session extends HandleObject { - constructor(handle: Handle, slot: Slot, lib: pkcs11.PKCS11); /** * Slot * From f4efd4d3629874cbf4461a41ad5e5d39860c1112 Mon Sep 17 00:00:00 2001 From: Hedley Luna Date: Fri, 12 Aug 2016 05:35:16 -0300 Subject: [PATCH 48/80] Adding the sorter function to the options. This function is called when append is called (#10576) --- select2/select2-tests.ts | 8 ++++++++ select2/select2.d.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/select2/select2-tests.ts b/select2/select2-tests.ts index 5712fc2d3e..545deedd83 100644 --- a/select2/select2-tests.ts +++ b/select2/select2-tests.ts @@ -34,6 +34,7 @@ $("#e5").select2({ } } }); + $("#e19").select2({ maximumSelectionSize: 3 }); $("#e10").select2({ data: [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }] @@ -121,6 +122,13 @@ $("#e7").select2({ dropdownCssClass: "bigdrop" }); +function sort(elements) { + return elements.sort(); +} +$("#e20").select2({ + sorter: sort +}); + $("#e8").select2(); $("#e8_get").click(function () { alert("Selected value is: " + $("#e8").select2("val")); }); $("#e8_set").click(function () { $("#e8").select2("val", "CA"); }); diff --git a/select2/select2.d.ts b/select2/select2.d.ts index c1d119df1e..1741395620 100644 --- a/select2/select2.d.ts +++ b/select2/select2.d.ts @@ -80,6 +80,7 @@ interface Select2Options { templateResult?: (object: Select2SelectionObject) => any; language?: string | string[] | {}; selectOnClose?: boolean; + sorter?: (data: any[]) => any[]; } interface Select2JQueryEventObject extends JQueryEventObject { From 0cba063650e6cd578c6db1e987a37f0da2bbd886 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Fri, 12 Aug 2016 17:35:48 +0900 Subject: [PATCH 49/80] TypeScript-STL v1.0 & Samchon-Framework v2.0 Beta (#10577) * Sleep * TypeScript-STL & Samchon Framework * TypeScript-STL & Samchon Framework --- samchon-framework/samchon-framework.d.ts | 4554 +++++++++++++++++----- typescript-stl/typescript-stl-tests.ts | 2 +- typescript-stl/typescript-stl.d.ts | 1357 +++---- 3 files changed, 4371 insertions(+), 1542 deletions(-) diff --git a/samchon-framework/samchon-framework.d.ts b/samchon-framework/samchon-framework.d.ts index c81a9d1e5b..a6d03758dd 100644 --- a/samchon-framework/samchon-framework.d.ts +++ b/samchon-framework/samchon-framework.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Samchon Framework v1.2.0 +// Type definitions for Samchon Framework v2.0.0-beta.1 // Project: https://github.com/samchon/framework // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,28 +11,59 @@ declare module "samchon-framework" } /** - * Samchon Framework, A SDN framework. + *

Samchon-Framework

* + *

+ *

+ * + *

Samchon, a SDN (Software Defined Network) framework.

+ * + *

With Samchon Framework, you can implement distributed processing system within framework of OOD like + * handling S/W objects (classes). You can realize cloud and distributed system very easily with provided + * system templates and even integration with C++ is possible.

+ * + *

The goal, ultimate utilization model of Samchon Framework is, building cloud system with NodeJS and + * takING heavy works to C++ distributed systems with provided modules (those are system templates).

+ * + * @git https://github.com/samchon/framework * @author Jeongho Nam */ declare namespace samchon { -} -declare namespace samchon.library { -} -declare namespace samchon.collection { -} -declare namespace samchon.protocol { -} -declare namespace samchon.protocol.service { -} -declare namespace samchon.protocol.master { -} -declare namespace samchon.protocol.slave { + /** + *

Running on Node.

+ * + *

Test whether the JavaScript is running on Node.

+ * + * @references http://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser + */ + function is_node(): boolean; } declare namespace samchon.collection { /** * A {@link Vector} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
    • {@link push_back}
    • + *
    • {@link unshift}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link pop_back}
    • + *
    • {@link shift}
    • + *
    • {@link pop}
    • + *
    • {@link splice}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link sort}
    • + *
  • + *
+ * * @author Jeongho Nam */ class ArrayCollection extends std.Vector implements ICollection { @@ -80,38 +111,46 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.VectorIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.VectorIterator, last: std.VectorIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ @@ -132,12 +171,9 @@ declare namespace samchon.collection { } declare namespace samchon.library { /** - * An event class. - * - *
    - *
  • Comments from - https://developer.mozilla.org/en-US/docs/Web/API/Event/
  • - *
+ * A basic event class of Samchon Framework. * + * @reference https://developer.mozilla.org/en-US/docs/Web/API/Event * @author Jeongho Nam */ class BasicEvent implements Event { @@ -231,51 +267,78 @@ declare namespace samchon.library { } declare namespace samchon.collection { /** - * Type of function pointer for {@link CollectionEvent CollectionEvents}. + * Type of function pointer for listener of {@link CollectionEvent CollectionEvents}. */ interface CollectionEventListener extends EventListener { (event: CollectionEvent): void; } +} +declare namespace samchon.collection { /** - * + * @author Jeongho Nam */ class CollectionEvent extends library.BasicEvent { - static INSERT: string; - static ERASE: string; /** - * + * @hidden */ private first_; /** - * + * @hidden */ private last_; /** + * Initialization Constructor. * - * - * @param type + * @param type Type of collection event. * @param first * @param last */ constructor(type: string, first: std.Iterator, last: std.Iterator); + constructor(type: "insert", first: std.Iterator, last: std.Iterator); + constructor(type: "erase", first: std.Iterator, last: std.Iterator); + constructor(type: "refresh", first: std.Iterator, last: std.Iterator); /** - * + * Get associative container. */ container: ICollection; /** - * + * Get range of the first. */ first: std.Iterator; /** - * + * Get range of the last. */ last: std.Iterator; } } +declare namespace samchon.collection.CollectionEvent { + const INSERT: string; + const ERASE: string; + const REFRESH: string; +} declare namespace samchon.collection { /** * A {@link Deque} who can detect element I/O events. * + *

Below are list of methods who are dispatching {@link CollectionEvent}:

+ * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
    • {@link push_front}
    • + *
    • {@link push_back}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link pop_front}
    • + *
    • {@link pop_back}
    • + *
  • + *
+ * * @author Jeongho Nam */ class DequeCollection extends std.Deque implements ICollection { @@ -323,44 +386,72 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.DequeIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.DequeIterator, last: std.DequeIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashMap} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
    • {@link set}
    • + *
    • {@link insert_or_assign}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link extract}
    • + *
  • + *
  • refresh typed events:
      + *
    • {@link set}
    • + *
    • {@link insert_or_assign}
    • + *
  • + *
+ * * @author Jeongho Nam */ class HashMapCollection extends std.HashMap implements ICollection> { @@ -384,42 +475,65 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; } +} +declare namespace samchon.collection { /** * A {@link HashMultiMap} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
  • + *
+ * * @author Jeongho Nam */ class HashMultiMapCollection extends std.HashMap implements ICollection> { @@ -443,47 +557,143 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link HashMultiSet} who can detect element I/O events. + * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
  • + *
+ * + * @author Jeongho Nam + */ + class HashMultiSetCollection extends std.HashMultiSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + hasEventListener(type: string): boolean; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.SetIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashSet} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link extract}
    • + *
  • + *
+ * * @author Jeongho Nam */ - class HashSetCollection extends std.TreeSet implements ICollection { + class HashSetCollection extends std.HashSet implements ICollection { /** * A chain object taking responsibility of dispatching events. */ @@ -507,216 +717,175 @@ declare namespace samchon.collection { /** * @inheritdoc */ - addEventListener(type: string, listener: EventListener): void; + refresh(): void; /** * @inheritdoc */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; + refresh(it: std.SetIterator): void; /** * @inheritdoc */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } - class HashMultiSetCollection extends std.TreeMultiSet implements ICollection { - /** - * A chain object taking responsibility of dispatching events. - */ - private event_dispatcher_; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; + refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * An interface for {@link IContainer containers} who can detect element I/O events. * + *

Below are list of methods who are dispatching {@link CollectionEvent}:

+ * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
  • + * * @author Jeongho Nam */ interface ICollection extends std.base.IContainer, library.IEventDispatcher { + /** + *

    Dispatch a {@link CollectionEvent} with refresh typed.

    + * + *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever + * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be + * detected. There's no way to detect those events automatically by {@link IContainer}.

    + * + *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to + * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified + * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with + * refresh typed will be dispatched.

    + * + *

    If you don't specify any iterator, then the range of the refresh event will be all elements in this + * {@link ICollection collection}; {@link begin begin()} to {@link end end()}.

    + */ + refresh(): void; + /** + *

    Dispatch a {@link CollectionEvent} with refresh typed.

    + * + *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever + * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be + * detected. There's no way to detect those events automatically by {@link IContainer}.

    + * + *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to + * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified + * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with + * refresh typed will be dispatched.

    + * + * @param it An iterator targeting the content changed element. + */ + refresh(it: std.Iterator): void; + /** + *

    Dispatch a {@link CollectionEvent} with refresh typed.

    + * + *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever + * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be + * detected. There's no way to detect those events automatically by {@link IContainer}.

    + * + *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to + * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified + * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with + * refresh typed will be dispatched.

    + * + * @param first An Iterator to the initial position in a sequence of the content changed elmeents. + * @param last An {@link Iterator} to the final position in a sequence of the content changed elements. The range + * used is [first, last), which contains all the elements between first and + * last, including the element pointed by first but not the element pointed by + * last. + */ + refresh(first: std.Iterator, last: std.Iterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - *

    Registers an event listener object with an EventDispatcher object so that the listener - * receives notification of an event. You can register event listeners on all nodes in the display - * list for a specific type of event, phase, and priority. - * - *

    After you successfully register an event listener, you cannot change its priority through - * additional calls to addEventListener(). To change a listener's priority, you must first call - * removeEventListener(). Then you can register the listener again with the new priority level.

    - * - *

    Keep in mind that after the listener is registered, subsequent calls to addEventListener() - * with a different type or useCapture value result in the creation of a separate listener - * registration. For example, if you first register a listener with useCapture set to true, - * it listens only during the capture phase. If you call addEventListener() again using the same - * listener object, but with useCapture set to false, you have two separate listeners: one that - * listens during the capture phase and another that listens during the target and bubbling phases.

    - * - *

    You cannot register an event listener for only the target phase or the bubbling phase. - * Those phases are coupled during registration because bubbling applies only to the ancestors of - * the target node.

    - * - *

    If you no longer need an event listener, remove it by calling removeEventListener(), or - * memory problems could result. Event listeners are not automatically removed from memory because - * the garbage collector does not remove the listener as long as the dispatching object exists - * (unless the useWeakReference parameter is set to true).

    - * - *

    Copying an EventDispatcher instance does not copy the event listeners attached to it. (If - * your newly created node needs an event listener, you must attach the listener after creating - * the node.) However, if you move an EventDispatcher instance, the event listeners attached to - * it move along with it.

    - * - *

    If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered - * during a later phase in the event flow, such as the bubbling phase.

    - * - *

    If an event listener is removed from a node while an event is being processed on the node, - * it is still triggered by the current actions. After it is removed, the event listener is never - * invoked again (unless it is registered again for future processing).

    - * - * @param event The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener function that processes the event. - * This function must accept an Event object as its only parameter and must return - * nothing. - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - *

    Registers an event listener object with an EventDispatcher object so that the listener - * receives notification of an event. You can register event listeners on all nodes in the display - * list for a specific type of event, phase, and priority. - * - *

    After you successfully register an event listener, you cannot change its priority through - * additional calls to addEventListener(). To change a listener's priority, you must first call - * removeEventListener(). Then you can register the listener again with the new priority level.

    - * - *

    Keep in mind that after the listener is registered, subsequent calls to addEventListener() - * with a different type or useCapture value result in the creation of a separate listener - * registration. For example, if you first register a listener with useCapture set to true, - * it listens only during the capture phase. If you call addEventListener() again using the same - * listener object, but with useCapture set to false, you have two separate listeners: one that - * listens during the capture phase and another that listens during the target and bubbling phases.

    - * - *

    You cannot register an event listener for only the target phase or the bubbling phase. - * Those phases are coupled during registration because bubbling applies only to the ancestors of - * the target node.

    - * - *

    If you no longer need an event listener, remove it by calling removeEventListener(), or - * memory problems could result. Event listeners are not automatically removed from memory because - * the garbage collector does not remove the listener as long as the dispatching object exists - * (unless the useWeakReference parameter is set to true).

    - * - *

    Copying an EventDispatcher instance does not copy the event listeners attached to it. (If - * your newly created node needs an event listener, you must attach the listener after creating - * the node.) However, if you move an EventDispatcher instance, the event listeners attached to - * it move along with it.

    - * - *

    If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered - * during a later phase in the event flow, such as the bubbling phase.

    - * - *

    If an event listener is removed from a node while an event is being processed on the node, - * it is still triggered by the current actions. After it is removed, the event listener is never - * invoked again (unless it is registered again for future processing).

    - * - * @param event The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener function that processes the event. - * This function must accept an Event object as its only parameter and must return - * nothing. - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered - * with the EventDispatcher object, a call to this method has no effect. - * - * @param type The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener object to remove. - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered - * with the EventDispatcher object, a call to this method has no effect. - * - * @param type The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener object to remove. - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link List} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
      • {@link push_front}
      • + *
      • {@link push_back}
      • + *
      • {@link merge}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link pop_front}
      • + *
      • {@link pop_back}
      • + *
      • {@link unique}
      • + *
      • {@link remove}
      • + *
      • {@link remove_if}
      • + *
      • {@link splice}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link sort}
      • + *
    • + *
    + * * @author Jeongho Nam */ class ListCollection extends std.List implements ICollection { @@ -772,47 +941,75 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.ListIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.ListIterator, last: std.ListIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link TreeMap} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
      • {@link set}
      • + *
      • {@link insert_or_assign}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link extract}
      • + *
    • + *
    • refresh typed events:
        + *
      • {@link set}
      • + *
      • {@link insert_or_assign}
      • + *
    • + *
    + * * @author Jeongho Nam */ - class TreeMapCollection extends std.HashMap implements ICollection> { + class TreeMapCollection extends std.TreeMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ @@ -833,45 +1030,68 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; } +} +declare namespace samchon.collection { /** * A {@link TreeMultiMap} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
    • + *
    + * * @author Jeongho Nam */ - class TreeMultiMapCollection extends std.HashMap implements ICollection> { + class TreeMultiMapCollection extends std.TreeMultiMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ @@ -892,95 +1112,65 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; } } declare namespace samchon.collection { - /** - * A {@link TreeMap} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class TreeSetCollection extends std.TreeSet implements ICollection { - /** - * A chain object taking responsibility of dispatching events. - */ - private event_dispatcher_; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } /** * A {@link TreeMultiSet} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
    • + *
    + * * @author Jeongho Nam */ class TreeMultiSetCollection extends std.TreeMultiSet implements ICollection { @@ -1004,38 +1194,121 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.SetIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link TreeMap} who can detect element I/O events. + * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link extract}
      • + *
    • + *
    + * + * @author Jeongho Nam + */ + class TreeSetCollection extends std.TreeSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + hasEventListener(type: string): boolean; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.SetIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.library { @@ -1373,7 +1646,7 @@ declare namespace samchon.library { * * @author Jeongho Nam */ - class XMLList extends std.Vector { + class XMLList extends std.Deque { getTag(): string; /** *

    Convert XMLList to string.

    @@ -1390,6 +1663,30 @@ declare namespace samchon.library { } } declare namespace samchon.collection { + /** + * An {@link XMLList} who can detect element I/O events. + * + *

    Below are list of methods who are dispatching {@link CollectionEvent}:

    + * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
      • {@link push_front}
      • + *
      • {@link push_back}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link pop_front}
      • + *
      • {@link pop_back}
      • + *
    • + *
    + * + * @author Jeongho Nam + */ class XMLListCollection extends library.XMLList implements ICollection { /** * A chain object taking responsibility of dispatching events. @@ -1406,11 +1703,11 @@ declare namespace samchon.collection { /** * @hidden */ - protected insert_by_repeating_val(position: std.VectorIterator, n: number, val: library.XML): std.VectorIterator; + protected insert_by_repeating_val(position: std.DequeIterator, n: number, val: library.XML): std.DequeIterator; /** * @hidden */ - protected insert_by_range>(position: std.VectorIterator, begin: InputIterator, end: InputIterator): std.VectorIterator; + protected insert_by_range>(position: std.DequeIterator, begin: InputIterator, end: InputIterator): std.DequeIterator; /** * @inheritdoc */ @@ -1418,7 +1715,7 @@ declare namespace samchon.collection { /** * @hidden */ - protected erase_by_range(first: std.VectorIterator, last: std.VectorIterator): std.VectorIterator; + protected erase_by_range(first: std.DequeIterator, last: std.DequeIterator): std.DequeIterator; /** * @hidden */ @@ -1435,71 +1732,57 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.DequeIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.DequeIterator, last: std.DequeIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - unshift(...items: U[]): number; - /** - * @inheritdoc - */ - pop(): library.XML; - /** - * @inheritdoc - */ - splice(start: number): library.XML[]; - /** - * @inheritdoc - */ - splice(start: number, deleteCount: number, ...items: library.XML[]): library.XML[]; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } -declare namespace samchon.example { - function test_file_reference(): void; -} -declare namespace samchon.example { - function test_web_client(): void; -} declare namespace samchon.library { /** *

    Case generator.

    * - *

    CaseGenerator is an abstract case generator using like a matrix.

    + *

    {@link CaseGenerator} is an abstract case generator being used like a matrix.

    *
      - *
    • nTTr(n^r) -> CombinedPermutationGenerator
    • - *
    • nPr -> PermutationGenerator
    • - *
    • n! -> FactorialGenerator
    • + *
    • n��r(n^r) -> {@link CombinedPermutationGenerator}
    • + *
    • nPr -> {@link PermutationGenerator}
    • + *
    • n! -> {@link FactorialGenerator}
    • *
    * * @author Jeongho Nam @@ -1544,13 +1827,13 @@ declare namespace samchon.library { * @param index Index number * @return The row of the index'th in combined permuation case */ - abstract at(index: number): Array; + abstract at(index: number): number[]; } /** *

    A combined-permutation case generator.

    - *

    nTTr

    * - * @inheritdoc + *

    n��r

    + * * @author Jeongho Nam */ class CombinedPermutationGenerator extends CaseGenerator { @@ -1565,14 +1848,14 @@ declare namespace samchon.library { * @param r Size of elements of each case. */ constructor(n: number, r: number); - at(index: number): Array; + at(index: number): number[]; } /** *

    A permutation case generator.

    - *

    nPr

    + * + *

    nPr

    * * @author Jeongho Nam - * @inheritdoc */ class PermuationGenerator extends CaseGenerator { /** @@ -1585,8 +1868,15 @@ declare namespace samchon.library { /** * @inheritdoc */ - at(index: number): Array; + at(index: number): number[]; } + /** + *

    Factorial case generator.

    + * + *

    n! = nPn

    + * + * @author Jeongho Nam + */ class FactorialGenerator extends PermuationGenerator { /** * Construct from factorial size N. @@ -1602,8 +1892,8 @@ declare namespace samchon.library { * whether specific types of event listeners are registered, and dispatches events.

    * *

    Event targets are an important part of the Flash�� Player and Adobe AIR event model. The event - * target serves as the focal point for how events flow through the display list hierarchy. When an - * event such as a mouse click or a keypress occurs, an event object is dispatched into the event flow + * target serves as the local point for how events flow through the display list hierarchy. When an + * event such as a mouse click or a key press occurs, an event object is dispatched into the event flow * from the root of the display list. The event object makes a round-trip journey to the event target, * which is conceptually divided into three phases: the capture phase includes the journey from the * root to the last node before the event target's node; the target phase includes only the event @@ -1728,6 +2018,7 @@ declare namespace samchon.library { * @param listener The listener function that processes the event. * This function must accept an Event object as its only parameter and must return * nothing. + * @param thisArg The object to be used as the this object. */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; /** @@ -1744,6 +2035,7 @@ declare namespace samchon.library { * * @param type The type of event. * @param listener The listener object to remove. + * @param thisArg The object to be used as the this object. */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; } @@ -1795,11 +2087,11 @@ declare namespace samchon.library { /** * The origin object who issuing events. */ - protected target: IEventDispatcher; + protected event_dispatcher_: IEventDispatcher; /** * Container of listeners. */ - protected listeners: std.HashMap>>; + protected event_listeners_: std.HashMap>>; /** * Default Constructor. */ @@ -1807,9 +2099,9 @@ declare namespace samchon.library { /** * Construct from the origin event dispatcher. * - * @param target The origin object who issuing events. + * @param dispatcher The origin object who issuing events. */ - constructor(target: IEventDispatcher); + constructor(dispatcher: IEventDispatcher); /** * @inheritdoc */ @@ -2011,6 +2303,31 @@ declare namespace samchon.library { * @param fileName File name to be saved. */ save(data: string, fileName: string): void; + /** + *

    Save a file to local filesystem.

    + * + *

    {@link FileReference.save} implemented the save function by downloading a file from a hidden anchor tag. + * However, the plan, future's {@link FileReference} will follow such rule:

    + * + *

    Opens a dialog box that lets the user save a file to the local filesystem.

    + * + *

    The {@link save save()} method first opens an browser-system dialog box that asks the user to enter a + * filename and select a location on the local computer to save the file. When the user selects a location and + * confirms the save operation (for example, by clicking Save), the save process begins. Listeners receive events + * to indicate the progress, success, or failure of the save operation. To ascertain the status of the dialog box + * and the save operation after calling {@link save save()}, your code must listen for events such as cancel, + * open, progress, and complete.

    + * + *

    When the file is saved successfully, the properties of the {@link FileReference} object are populated with + * the properties of the local file. The complete event is dispatched if the save is successful.

    + * + *

    Only one {@link browse browse()} or {@link save()} session can be performed at a time (because only one + * dialog box can be invoked at a time).

    + * + * @param data The data to be saved. The data can be in one of several formats, and will be treated appropriately. + * @param fileName File name to be saved. + */ + static save(data: string, fileName: string): void; } /** *

    The {@link FileReferenceList} class provides a means to let users select one or more files for @@ -2081,10 +2398,251 @@ declare namespace samchon.library { browse(...typeFilter: string[]): void; } } +declare namespace samchon.library { + /** + *

    A genetic algorithm class.

    + * + * @details + *

    In the field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the + * process of natural selection. This heuristic (also sometimes called a metaheuristic) is routinely used to generate + * useful solutions to optimization and search problems.

    + * + *

    Genetic algorithms belong to the larger class of evolutionary algorithms (EA), which generate solutions to + * optimization problems using techniques inspired by natural evolution, such as inheritance, {@link mutate mutation}, + * {@link selection}, and {@link crossover}.

    + * + * @reference https://en.wikipedia.org/wiki/Genetic_algorithm + * @author Jeongho Nam + */ + class GeneticAlgorithm { + /** + * Whether each element (Gene) is unique in their GeneArray. + */ + private unique; + /** + * Rate of mutation. + * + * The {@link mutation_rate} determines the percentage of occurence of mutation in GeneArray. + * + *
      + *
    • When {@link mutation_rate} is too high, it is hard to ancitipate studying on genetic algorithm.
    • + *
    • + * When {@link mutation_rate} is too low and initial set of genes (GeneArray) is far away from optimal, the + * evolution tends to wandering outside of he optimal. + *
    • + *
    + */ + private mutation_rate; + /** + * Number of tournaments in selection. + */ + private tournament; + /** + * Initialization Constructor. + * + * @param unique Whether each Gene is unique in their GeneArray. + * @param mutation_rate Rate of mutation. + * @param tournament Number of tournaments in selection. + */ + constructor(unique?: boolean, mutation_rate?: number, tournament?: number); + /** + *

    Evolove GeneArray.

    + * + *

    Convenient method accessing to {@link evolvePopulation evolvePopulation()}.

    + * + * @param individual An initial set of genes; sequence listing. + * @param population Size of population in a generation. + * @param generation Size of generation in evolution. + * @param compare A comparison function returns whether left gene is more optimal. + * + * @return An evolved GeneArray, optimally. + * + * @see {@link GAPopulation.compare} + */ + evolveGeneArray>(individual: GeneArray, population: number, generation: number, compare?: (left: T, right: T) => boolean): GeneArray; + /** + * Evolve population, a mass of GeneArraies. + * + * @param population An initial population. + * @param compare A comparison function returns whether left gene is more optimal. + * + * @return An evolved population. + * + * @see {@link GAPopulation.compare} + */ + evolvePopulation>(population: GAPopulation, compare?: (left: T, right: T) => boolean): GAPopulation; + /** + *

    Select the best GeneArray in population from tournament.

    + * + *

    {@link selection Selection} is the stage of a genetic algorithm in which individual genomes are chosen + * from a population for later breeding (using {@linlk crossover} operator). A generic {@link selection} + * procedure may be implemented as follows:

    + * + *
      + *
    1. + * The fitness function is evaluated for each individual, providing fitness values, which are then + * normalized. ization means dividing the fitness value of each individual by the sum of all fitness + * values, so that the sum of all resulting fitness values equals 1. + *
    2. + *
    3. The population is sorted by descending fitness values.
    4. + *
    5. + * Accumulated normalized fitness values are computed (the accumulated fitness value of an individual is the + * sum of its own fitness value plus the fitness values of all the previous individuals). The accumulated + * fitness of the last individual should be 1 (otherwise something went wrong in the normalization step). + *
    6. + *
    7. A random number R between 0 and 1 is chosen.
    8. + *
    9. The selected individual is the first one whose accumulated normalized value is greater than R.
    10. + *
    + * + * @param population The target of tournament. + * @return The best genes derived by the tournament. + * + * @reference https://en.wikipedia.org/wiki/Selection_(genetic_algorithm) + */ + private selection(population); + /** + *

    Create a new GeneArray by crossing over two GeneArray(s).

    + * + *

    {@link crossover} is a genetic operator used to vary the programming of a chromosome or chromosomes from + * one generation to the next. It is analogous to reproduction and biological crossover, upon which genetic + * algorithms are based.

    + * + *

    {@link crossover Cross over} is a process of taking more than one parent solutions and producing a child + * solution from them. There are methods for selection of the chromosomes.

    + * + * @param parent1 A parent sequence listing + * @param parent2 A parent sequence listing + * + * @reference https://en.wikipedia.org/wiki/Crossover_(genetic_algorithm) + */ + private crossover(parent1, parent2); + /** + *

    Cause a mutation on the GeneArray.

    + * + *

    {@link mutate Mutation} is a genetic operator used to maintain genetic diversity from one generation of a + * population of genetic algorithm chromosomes to the next. It is analogous to biological mutation.

    + * + *

    {@link mutate Mutation} alters one or more gene values in a chromosome from its initial state. In + * {@link mutate mutation}, the solution may change entirely from the previous solution. Hence GA can come to + * better solution by using {@link mutate mutation}.

    + * + *

    {@link mutate Mutation} occurs during evolution according to a user-definable mutation probability. This + * probability should be set low. If it is set too high, the search will turn into a primitive random search.

    + * + *

    Note

    + *

    Muttion is pursuing diversity. Mutation is useful for avoiding the following problem.

    + * + *

    When initial set of genes(GeneArray) is far away from optimail, without mutation (only with selection and + * crossover), the genetic algorithm has a tend to wandering outside of the optimal.

    + * + *

    Genes in the GeneArray will be swapped following percentage of the {@link mutation_rate}.

    + * + * @param individual A container of genes to mutate + * + * @reference https://en.wikipedia.org/wiki/Mutation_(genetic_algorithm) + * @see {@link mutation_rate} + */ + private mutate(individual); + } + /** + *

    A population in a generation.

    + * + *

    {@link GAPopulation} is a class representing population of candidate genes (sequence listing) having an array + * of GeneArray as a member. {@link GAPopulation} also manages initial set of genes and handles fitting test direclty + * by the method {@link fitTest fitTest()}.

    + * + *

    The success of evolution of genetic algorithm is depend on the {@link GAPopulation}'s initial set and fitting + * test. (GeneArray and {@link compare}.)

    + * + *

    Warning

    + *

    Be careful for the mistakes of direction or position of the {@link compare}.

    + *

    Most of logical errors failed to access optimal solution are occured from those mistakes.

    + * + * @param Type of gene elements. + * @param An array containing genes as elments; sequnce listing. + * + * @author Jeongho Nam + */ + class GAPopulation> { + /** + * Genes representing the population. + */ + private children; + /** + *

    A comparison function returns whether left gene is more optimal, greater.

    + * + *

    Default value of this {@link compare} is {@link std.greater}. It means to compare two array + * (GeneArray must be a type of {@link std.base.IArrayContainer}). Thus, you've to keep follwing rule.

    + * + *
      + *
    • GeneArray is implemented from {@link std.base.IArrayContainer}.
    • + *
        + *
      • {@link std.Vector}
      • + *
      • {@link std.Deque}
      • + *
      + *
    • GeneArray has custom public less(obj: T): boolean; function.
    • + *
    + * + *

    If you don't want to follow the rule or want a custom comparison function, you have to realize a + * comparison function.

    + */ + private compare; + /** + *

    Private constructor with population.

    + * + *

    Private constructor of GAPopulation does not create {@link children}. (candidate genes) but only assigns + * null repeatedly following the population size.

    + * + *

    This private constructor is designed only for {@link GeneticAlgorithm}. Don't create {@link GAPopulation} + * with this constructor, by yourself.

    + * + * @param size Size of the population. + */ + constructor(size: number); + /** + *

    Construct from a {@link GeneArray} and size of the population.

    + * + *

    This public constructor creates GeneArray(s) as population (size) having shuffled genes which are + * came from the initial set of genes (geneArray). It uses {@link std.greater} as default comparison function. + *

    + * + * @param geneArray An initial sequence listing. + * @param size The size of population to have as children. + */ + constructor(geneArray: GeneArray, size: number); + /** + *

    Constructor from a GeneArray, size of the poluation and custom comparison function.

    + * + *

    This public constructor creates GeneArray(s) as population (size) having shuffled genes which are + * came from the initial set of genes (geneArray). The compare is used for comparison function. + *

    + * + * @param geneArray An initial sequence listing. + * @param size The size of population to have as children. + * @param compare A comparison function returns whether left gene is more optimal. + */ + constructor(geneArray: GeneArray, size: number, compare: (left: GeneArray, right: GeneArray) => boolean); + /** + * Test fitness of each GeneArray in the {@link population}. + * + * @return The best GeneArray in the {@link population}. + */ + fitTest(): GeneArray; + /** + * @hidden + */ + private clone(obj); + } +} declare namespace samchon.library { /** *

    A utility class supporting static methods of string.

    * + *

    The {@link StringUtil} utility class is an all-static class with methods for working with string objects within + * Samchon Framework. You do not create instances of {@link StringUtil}; instead you call methods such as the + * StringUtil.substitute() method.

    + * + * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/StringUtil.html * @author Jeongho Nam */ class StringUtil { @@ -2105,11 +2663,11 @@ declare namespace samchon.library { *
  • If start and end are all omitted, returns str, itself.
  • *
* - * @param str Target string to be applied between - * @param start A string for separating substring at the front - * @param end A string for separating substring at the end + * @param str Target string to be applied between. + * @param start A string for separating substring at the front. + * @param end A string for separating substring at the end. * - * @return substring by specified terms + * @return substring by specified terms. */ static between(str: string, start?: string, end?: string): string; /** @@ -2124,12 +2682,12 @@ declare namespace samchon.library { *
  • If startStr and endStar are all omitted, returns str.
  • * * - * @param str Target string to split by between + * @param str Target string to split by between. * @param start A string for separating substring at the front. - * If omitted, it's same with split(end) not having last item + * If omitted, it's same with split(end) not having last item. * @param end A string for separating substring at the end. - * If omitted, it's same with split(start) not having first item - * @return An array of substrings + * If omitted, it's same with split(start) not having first item. + * @return An array of substrings. */ static betweens(str: string, start?: string, end?: string): Array; /** @@ -2195,20 +2753,74 @@ declare namespace samchon.library { * @return A string specified words are replaced */ static replaceAll(str: string, ...pairs: std.Pair[]): string; - /** - *

    Get a tabbed string by specified size.

    - */ - static tab(size: number): string; - /** - *

    Get a tabbed HTLM string by specified size.

    - */ - static htmlTab(size: number): string; /** * Replace all HTML spaces to a literal space. * * @param str Target string to replace. */ static removeHTMLSpaces(str: string): string; + /** + *

    Repeat a string.

    + * + *

    Returns a string consisting of a specified string concatenated with itself a specified number of times.

    + * + * @param str The string to be repeated. + * @param n The repeat count. + * + * @return The repeated string. + */ + static repeat(str: string, n: number): string; + /** + *

    Number to formatted string with "," sign.

    + * + *

    Returns a string converted from the number rounded off from specified precision with "," symbols.

    + * + * @param val A number wants to convert to string. + * @param precision Target precision of round off. + * + * @return A string who represents the number with roundoff and "," symbols. + */ + static numberFormat(val: number, precision?: number): string; + static percentFormat(val: number, precision?: number): string; + } +} +declare namespace samchon.library { + /** + *

    URLVariables class is for representing variables of HTTP.

    + * + *

    URLVariables class allows you to transfer variables between an application and server. + * When transfering, URLVariables will be converted to a URI string.

    + * + *
      + *
    • URI: Uniform Resource Identifier
    • + *
    + * + * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html + * @author Migrated by Jeongho Nam + */ + class URLVariables extends std.HashMap { + /** + * Default Constructor. + */ + constructor(); + /** + *

    Construct from a URL-encoded string.

    + * + *

    The {@link decode decode()} method is automatically called to convert the string to properties of the {@link URLVariables} object.

    + * + * @param str A URL-encoded string containing name/value pairs. + */ + constructor(str: string); + /** + * Converts the variable string to properties of the specified URLVariables object. + * + * @param str A URL-encoded query string containing name/value pairs. + */ + decode(str: string): void; + /** + * Returns a string containing all enumerable variables, in the MIME content encoding application/x-www-form-urlencoded. + */ + toString(): string; } } declare namespace samchon.protocol { @@ -2247,20 +2859,31 @@ declare namespace samchon.protocol { * * @param xml An xml used to contruct data of entity. */ - construct(xml: library.XML): any; + construct(xml: library.XML): void; /** *

    Get a key that can identify the Entity uniquely.

    * - *

    If identifier of the Entity is not atomic value, returns a string or paired object + *

    If identifier of the Entity is not atomic value, returns a paired or tuple object * that can represents the composite identifier.

    + * + * + * class Point extends Entity + * { + * private x: number; + * private y: number; + * + * public key(): std.Pair + * { + * return std.make_pair(this.x, this.y); + * } + * } + * */ key(): any; /** *

    A tag name when represented by XML.

    * - *
      - *
    • - *
    + * */ TAG(): string; /** @@ -2345,6 +2968,593 @@ declare namespace samchon.protocol { toXML(): library.XML; } } +declare namespace samchon.protocol { + /** + *

    An interface taking full charge of network communication.

    + * + *

    {@link ICommunicator} is an interface for communicator classes who take full charge of network communication + * with external system, without reference to whether the external system is a server or a client.

    + * + *

    Whenever a replied message comes from the external system, the message will be converted to an + * {@link Invoke} class and will be shifted to the {@link WebCommunicator.listener listener}'s + * {@link IProtocol.replyData replyData()} method.

    + * + * + interface ICommmunicator + { + private socket: SomeSocketClass; + + // LISTENER LISTENS INVOKE MESSAGE BY IT'S IProtocol.replyData() METHOD + protected listener: IProtocol; + + // YOU CAN DETECT DISCONNECTION BY ENROLLING FUNCTION POINTER TO HERE. + public onClose: Function; + + public sendData(invoke: Invoke): void + { + this.socket.write(invoke); + } + public replyData(invoke: Invoke): void + { + // WHENEVER COMMUNICATOR GETS MESSAGE, THEN SHIFT IT TO LISTENER'S replyData() METHOD. + this.listener.replyData(invoke); + } + } + * + * + *

    + * + *

    + * + * + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    + * + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    + * + *
      + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} + *
    + * + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    + * + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    + * + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link IClientDriver}, {@link IServerConnector} + * @handbook Basic Components - ICommunicator + * @author Jeongho Nam + */ + interface ICommunicator extends IProtocol { + /** + * Callback function for connection closed. + */ + onClose: Function; + /** + * Close connection. + */ + close(): any; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol { + abstract class CommunicatorBase implements ICommunicator { + /** + * @hidden + */ + protected listener: IProtocol; + /** + * @inheritdoc + */ + onClose: Function; + /** + * @hidden + */ + private binary_invoke; + /** + * @hidden + */ + private binary_parameters; + /** + * @hidden + */ + private unhandled_invokes; + /** + * Default Constructor. + */ + constructor(); + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + abstract close(): void; + protected is_binary_invoke(): boolean; + abstract sendData(invoke: Invoke): void; + replyData(invoke: Invoke): void; + protected handle_string(str: string): void; + protected handle_binary(binary: Uint8Array): void; + } +} +declare namespace samchon.protocol { + class Communicator extends CommunicatorBase { + /** + * @hidden + */ + protected socket: socket.socket; + /** + * @hidden + */ + private header_bytes; + /** + * @hidden + */ + private data; + /** + * @hidden + */ + private data_index; + /** + * @hidden + */ + private listening; + /** + * @inheritdoc + */ + close(): void; + /** + * @hidden + */ + protected start_listen(): void; + /** + * @hidden + */ + private handle_error(); + /** + * @hidden + */ + private handle_close(); + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + /** + * @hidden + */ + private listen_piece(piece); + /** + * @hidden + */ + private listen_header(piece, piece_index); + /** + * @hidden + */ + private listen_data(piece, piece_index); + } +} +declare namespace samchon.protocol { + /** + *

    Base class for web-communicator, {@link WebClientDriver} and {@link WebServerConnector}.

    + * + *

    This class {@link WebCommunicatorBase} subrogates network communication for web-communicator classes, + * {@link WebClinetDriver} and {@link WebServerConnector}. The web-communicator and this class + * {@link WebCommunicatorBase} share same interface {@link IProtocol} and have a chain of responsibily + * relationship.

    + * + *

    When an {@link Invoke} message was delivered from the connected remote system, then this class calls + * web-communicator's {@link WebServerConnector.replyData replyData()} method. Also, when called web-communicator's + * {@link WebClientDriver.sendData sendData()}, then {@link sendData sendData()} of this class will be caleed.

    + * + *
      + *
    • this.replyData() -> communicator.replyData()
    • + *
    • communicator.sendData() -> this.sendData()
    • + *
    + * + * @author Jeongho Nam + */ + class WebCommunicator extends CommunicatorBase { + /** + * Connection driver, a socket for web-socket. + */ + protected connection: websocket.connection; + /** + * Close the connection. + */ + close(): void; + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + /** + *

    Handle raw-data received from the remote system.

    + * + *

    Queries raw-data received from the remote system. When the raw-data represents an formal {@link Invoke} + * message, then it will be sent to the {@link replyData}.

    + * + * @param message A raw-data received from the remote system. + */ + protected handle_message(message: websocket.IMessage): void; + protected handle_close(): void; + } +} +declare namespace samchon.protocol { + class SharedWorkerCommunicator extends CommunicatorBase { + protected port: MessagePort; + close(): void; + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + protected handle_message(event: MessageEvent): void; + } +} +declare namespace samchon.protocol { + /** + *

    An interface for communicator with connected client.

    + * + *

    {@link IClientDriver} is a type of {@link ICommunicator}, specified for communication with connected client + * in a server. It takes full charge of network communication with the connected client.

    + * + *

    {@link IClientDriver} is created in {@link IServer} and delivered via + * {@link IServer.addClient IServer.addClient()}. Those are derived types from this {@link IClientDriver}, being + * created by matched {@link IServer} object.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Derived Type Created By
    {@link ClientDrvier} {@link Server}
    {@link WebClientDrvier} {@link WebServer}
    {@link SharedWorkerClientDrvier} {@link SharedWorkerServer}
    + * + *

    + * + *

    + * + *

    When you've got an {@link IClientDriver} object from the {@link IServer.addClient IServer.addClient()}, then + * specify {@link CommunicatorBase.listener listener} with {@link IClient.listen IClient.listen()}. Below codes are + * an example specifying and managing the {@link CommunicatorBase.listener listener} objects.

    + * + * + /// + /// + + // IMPORTS + import std = require("typescript-stl"); + import samchon = require("samchon-framework"); + + // SHORTCUTS + import library = samchon.library; + import protocol = samchon.protocol; + + class CalculatorServer extends protocol.Server + { + private clients: std.HashSet; + + // WHEN A CLIENT HAS CONNECTED + public addClient(driver: IClientDriver): void + { + let client: CalculatorClient = new CalculatorClient(this, driver); + this.clients.insert(client); + } + } + + class CalculatorClient extends protocol.IProtocol + { + // PARENT SERVER INSTANCE + private server: CalculatorServer; + + // COMMUNICATOR, SENDS AND RECEIVES NETWORK MESSAGE WITH CONNECTED CLIENT + private driver: protocol.IClientDriver; + + ///// + // CONSTRUCTORS + ///// + public constructor(server: CalculatorServer, driver: protocol.IClientDriver) + { + this.server = server; + this.driver = driver; + + // START LISTENING AND RESPOND CLOSING EVENT + this.driver.listen(this); // INVOKE MESSAGE WILL COME TO HERE + this.driver.onClose = this.destructor.bind(this); // DISCONNECTED HANDLER + } + public destructor(): void + { + // WHEN DISCONNECTED, THEN ERASE THIS OBJECT FROM CalculatorServer.clients. + this.server["clients"].erase(this); + } + + ///// + // INVOKE MESSAGE CHAIN + ///// + public sendData(invoke: protocol.Invoke): void + { + // CALL ICommunicator.sendData(), WHO PHYSICALLY SEND NETWORK MESSAGE + this.driver.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + // FIND MATCHED MEMBER FUNCTION NAMED EQUAL TO THE invoke.getListener() + invoke.apply(this); + } + } + * + * + * + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    + * + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    + * + *
      + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} + *
    + * + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    + * + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    + * + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link IServer} + * @handbook Basic Components - IClientDriver + * @author Jeongho Nam + */ + interface IClientDriver extends ICommunicator { + /** + *

    Listen message from the newly connected client.

    + * + *

    Starts listening message from the newly connected client. Replied message from the connected client will + * be converted to {@link Invoke} classes and shifted to the listener's + * {@link IProtocol.replyData replyData()} method.

    + * + * @param listener A listener object to listen replied message from newly connected client in + * {@link IProtocol.replyData replyData()} as an {@link Invoke} message. + */ + listen(listener: IProtocol): void; + } +} +declare namespace samchon.protocol { + class ClientDriver extends Communicator implements IClientDriver { + constructor(socket: socket.socket); + /** + * @inheritdoc + */ + listen(listener: IProtocol): void; + } +} +declare namespace samchon.protocol { + class WebClientDriver extends WebCommunicator implements IClientDriver { + /** + * Requested path. + */ + private path; + /** + * Session ID, an identifier of the remote client. + */ + private session_id; + private listening; + /** + * Initialization Constructor. + * + * @param connection Connection driver, a socket for web-socket. + * @param path Requested path. + * @param session_id Session ID, an identifier of the remote client. + */ + constructor(connection: websocket.connection, path: string, session_id: string); + /** + * @inheritdoc + */ + listen(listener: IProtocol): void; + /** + * Get requested path. + */ + getPath(): string; + /** + * Get session ID, an identifier of the remote client. + */ + getSessionID(): string; + } +} +declare namespace samchon.protocol { + class SharedWorkerClientDriver extends SharedWorkerCommunicator implements IClientDriver { + private listening; + constructor(port: MessagePort); + /** + * @inheritdoc + */ + listen(listener: IProtocol): void; + } +} +declare namespace samchon.protocol { + abstract class DedicatedWorker implements IProtocol { + private communicator_; + /** + * Default Constructor. + */ + constructor(); + abstract replyData(invoke: protocol.Invoke): void; + sendData(invoke: Invoke): void; + } +} +declare namespace samchon.protocol { + class DedicatedWorkerConnector extends CommunicatorBase implements IServerConnector { + private worker; + /** + * @inheritdoc + */ + onConnect: Function; + /** + * @inheritdoc + */ + onClose: Function; + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + connect(jsFile: string): void; + /** + * @inheritdoc + */ + close(): void; + sendData(invoke: Invoke): void; + replyData(invoke: Invoke): void; + private handle_message(event); + } +} declare namespace samchon.protocol { interface IEntityGroup extends IEntity, std.base.IContainer { /** @@ -2368,7 +3578,6 @@ declare namespace samchon.protocol { * * @return A new child Entity belongs to EntityArray. */ - createChild(xml: library.XML): T; /** *

    Get iterator to element.

    * @@ -2444,9 +3653,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2488,9 +3703,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2532,9 +3753,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2583,9 +3810,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2627,9 +3860,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2671,9 +3910,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2709,203 +3954,238 @@ declare namespace samchon.protocol { } declare namespace samchon.protocol { /** - *

    A network driver for an external system.

    + *

    An interface for {@link Invoke} message chain.

    * - *

    ExternalSystem is a boundary class interacting with an external system by network communication. - * Also, ExternalSystem is an abstract class that a network role, which one is server and which one is - * client, is not determined yet.

    + *

    {@link IProtocol} is an interface for {@link Invoke} message, which is standard message of network I/O in + * Samchon Framework, chain. The {@link IProtocol} interface is used to network drivers and some classes + * which are in a relationship of Chain of Responsibility Pattern with those network drivers.

    * - *

    The ExternalSystem has ExternalSystemRole(s) groupped methods, handling Invoke message - * interacting with the external system, by subject or unit of a moudle. The ExternalSystemRole is - * categorized in a 'control'.

    + *

    Implements {@link IProtocol} if the class sends and handles {@link Invoke} message. Looking around source + * codes of Samchon Framework, especially System Templates, you can find out that all the classes and + * modules handling {@link Invoke} messages are always implementing this {@link IProtocol} . Yes, {@link IProtocol}, + * this is the main role you've to follow in this Samchon Framework.

    * - *

    Note

    - *

    The ExternalSystem class takes a role of interaction with external system in network level. - * However, within a framework of Samchon Framework, a boundary class like the ExternalSystem is - * not such important. You can find some evidence in a relationship between ExternalSystemArray, - * ExternalSystem and ExternalSystemRole.

    + *

    + * + *

    * - *

    Of course, the ExternalSystemRole is belonged to an ExternalSystem. However, if you - * access an ExternalSystemRole from an ExternalSystemArray directly, not passing by a belonged - * ExternalSystem, and send an Invoke message even you're not knowing which ExternalSystem is - * related in, it's called "Proxy pattern". * - *

    Like the explanation of "Proxy pattern", you can utilize an ExternalSystemRole as a proxy - * of an ExternalSystem. With the pattern, you can only concentrate on ExternalSystemRole itself, - * what to do with Invoke message, irrespective of the ExternalSystemRole is belonged to which - * ExternalSystem.

    - * - * @author Jeongho Nam - */ - abstract class ExternalSystem extends EntityArray implements IProtocol { - /** - *

    A driver for interacting with (real, physical) external system.

    - */ - protected driver: ServerConnector; - /** - *

    A name can identify an external system.

    - * - *

    The name must be unique in ExternalSystemArray.

    - */ - protected name: string; - /** - *

    An ip address of an external system.

    - */ - protected ip: string; - /** - *

    A port number of an external system.

    - */ - protected port: number; - /** - *

    Default Constructor.

    - */ - constructor(); - /** - *

    Start interaction.

    - *

    An abstract method starting interaction with an external system.

    - * - *

    If an external systems are a server, starts connection and listening Inovoke message, - * else clients, just starts listening only. You also can addict your own procudures of starting - * the driver, but if you directly override method of abstract ExternalSystem, be careful about - * virtual inheritance.

    - */ - start(): void; - key(): any; - /** - *

    Get name.

    - */ - getName(): string; - /** - *

    Get ip address of the external system.

    - */ - getIP(): string; - /** - *

    Get port number of the external system.

    - */ - getPort(): number; - sendData(invoke: Invoke): void; - replyData(invoke: Invoke): void; - TAG(): string; - CHILD_TAG(): string; - } -} -declare namespace samchon.protocol { - /** - *

    An array of ExternalSystem(s).

    - * - *

    ExternalSystemArray is an abstract class containing and managing external system drivers.

    - * - *

    Also, ExternalSystemArray can access to ExternalSystemRole(s) directly. With the method, you - * can use an ExternalSystemRole as "logical proxy" of an ExternalSystem. Of course, the - * ExternalSystemRole is belonged to an ExternalSystem. However, if you access an ExternalSystemRole - * from an ExternalSystemArray directly, not passing by a belonged ExternalSystem, and send an Invoke - * message even you're not knowing which ExternalSystem is related in, the ExternalSystemRole acted - * a role of proxy.

    - * - *

    It's called as "Proxy pattern". With the pattern, you can only concentrate on - * ExternalSystemRole itself, what to do with Invoke message, irrespective of the ExternalSystemRole - * is belonged to which ExternalSystem.

    + *

    Utilization Case

    + *

    Below pseudo code and class diagram represents {@link service Service Module}, who can build a cloud server. + * All the classes in the pseudo code are implementing the {@link IProtocol} because all of them are handling + * {@link Invoke} message.

    * *
      - *
    • ExternalSystemArray::getRole("something")->sendData(invoke);
    • + *
    • Server: Represents a server literally
    • + *
    • User: Represents an user being identified by its session id. User contains multiple Client objects.
    • + *
        + *
      • In browser, an user can open multiple windows. + *
          + *
        • User: A browser (like IE, Chrome and Safari). + *
        • Client: An internet browser window + *
        + *
      • + *
      + *
    • Client: Represents a browser window and it takes role of network communication with it.
    • + *
    • Service: Represents a service, domain logic.
    • *
    * - * @author Jeongho Nam - */ - abstract class ExternalSystemArray extends EntityArray implements IProtocol { - /** - * Default Constructor. - */ - constructor(); - /** - *

    Start interaction.

    - *

    An abstract method starting interaction with external systems.

    - * - *

    If external systems are servers, starts connection to them, else clients, opens a server - * and accepts the external systems. You can addict your own procudures of starting drivers, but - * if you directly override method of abstract ExternalSystemArray, be careful about virtual - * inheritance.

    - */ - start(): void; - /** - *

    Test whether has a role.

    - * - * @param name Name of an ExternalSystemRole. - * @return Whether has or not. - */ - hasRole(key: string): boolean; - /** - *

    Get a role.

    - * - * @param name Name of an ExternalSystemRole - * @return A shared pointer of specialized role - */ - getRole(key: string): ExternalSystemRole; - sendData(invoke: Invoke): void; - replyData(invoke: Invoke): void; - TAG(): string; - CHILD_TAG(): string; + *

    + * + *

    + * + * + /// + /// + + // IMPORTS + import std = require("typescript-stl"); + import samchon = require("samchon-framework"); + + // SHORTCUTS + import library = samchon.library; + import collection = samchon.collection; + import protocol = samchon.protocol; + + namespace service + { + export class Server extends protocol.WebServer implements IProtocol + { + // SERVER HAS MULTIPLE USER OBJECTS + private session_map: std.HashMap; + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE TO ALL USER OBJECTS + for (let it = this.session_map.begin(); !it.equal_to(this.session_map.end()); it = it.next()) + it.second.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INVOKE MESSAGE BY ITSELF + } + } + + export class User extends + collection.HashMapCollection // USER HAS MULTIPLE CLIENT OBJECTS + implements IProtocol + { + private server: Server; // USER REFRES SERVER + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE TO ALL CLIENT OBJECTS + for (let it = this.begin(); !it.equal_to(this.end()); it = it.next()) + it.second.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INOVKE MESSAGE BY ITSELF + this.server.replyData(invoke); // OR VIA SERVER + } + } + + export class Client implements IProtocol + { + private user: User; // CLIENT REFERS USER + private service: Service; // CLIENT HAS A SERVICE OBJECT + + private driver: WebClientDriver; + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE VIA driver: WebClientDriver + this.driver.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INOVKE MEESAGE BY ITSELF + this.user.replyData(invoke); // OR VIA USER + + if (this.service != null) // OR VIA SERVICE + this.service.replyData(invoke); + } + } + + export class Service implements IProtocol + { + private client: Client; // SERVICE REFRES CLIENT + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE VIA CLIENT + return this.client.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INVOKE MESSAGE BY ITSELF + } + } } -} -declare namespace samchon.protocol { - /** - *

    A role belongs to an external system.

    + *
    * - *

    ExternalSystemRole is a 'control' class groupping methods, handling Invoke messages - * interacting with an external system that the ExternalSystemRole is belonged to, by a subject or - * unit of a module.

    * - *

    ExternalSystemRole can be a "logical proxy" for an ExternalSystem which is containing the - * ExternalSystemRole. Of course, the ExternalSystemRole is belonged to an ExternalSystem. However, - * if you access an ExternalSystemRole from an ExternalSystemArray directly, not passing by a - * belonged ExternalSystem, and send an Invoke message even you're not knowing which ExternalSystem - * is related in, the ExternalSystemRole acted a role of proxy.

    + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    * - *

    It's called as "Proxy pattern". With the pattern, you can only concentrate on - * ExternalSystemRole itself, what to do with Invoke message, irrespective of the ExternalSystemRole - * is belonged to which ExternalSystem.

    + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    * - * @author Jeongho Nam - */ - class ExternalSystemRole extends Entity implements IProtocol { - /** - *

    A driver of external system containing the ExternalSystemRole.

    - */ - protected system: ExternalSystem; - /** - *

    A name representing the role.

    - */ - protected name: string; - protected sendListeners: std.HashSet; - /** - *

    Construct from external system driver.

    - * - * @param system A driver of external system the ExternalSystemRole is belonged to. - */ - constructor(system: ExternalSystem); - construct(xml: library.XML): void; - getName(): string; - hasSendListener(key: string): boolean; - sendData(invoke: Invoke): void; - replyData(invoke: Invoke): void; - TAG(): string; - toXML(): library.XML; - } -} -declare namespace samchon.protocol { - /** - *

    An interface for Invoke message chain.

    + *
      + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} + *
    * - *

    IProtocol is an interface for Invoke message, which is standard message of network I/O - * in Samchon Framework, chain. The IProtocol interface is used to network drivers and some - * classes which are in a relationship of chain of responsibility with those network drivers.

    + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    * - *

    In Samchon Framework, server side, IProtocol is one of the basic 3 + 1 components that - * can make any type of network system in Samchon Framework with IServer and IClient. Following - * the "chain of responsibility" pa1ttern, looking around classes in Samchon Framework, you - * can see all related classes with network I/O are implemented from the IProtocol.

    + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    * - * @see Invoke + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link Invoke} + * @handbook Basic Components - IProtocol * @author Jeongho Nam */ interface IProtocol { @@ -2920,7 +4200,7 @@ declare namespace samchon.protocol { *

    Handling replied message.

    *

    Handles replied message or shifts the responsibility to chain.

    * - * @param invoke Replied invoke message + * @param invoke An {@link Invoke} message has received. */ sendData(invoke: Invoke): void; } @@ -2928,7 +4208,8 @@ declare namespace samchon.protocol { declare namespace samchon.protocol { /** *

    Standard message of network I/O.

    - *

    Invoke is a class used in network I/O in protocol package of Samchon Framework.

    + * + *

    {@link Invoke} is a class used in network I/O in protocol package of Samchon Framework.

    * *

    The Invoke message has an XML structure like the result screen of provided example in below. * We can enjoy lots of benefits by the normalized and standardized message structure used in @@ -2940,8 +4221,8 @@ declare namespace samchon.protocol { * like a object (class) in OOD. And those relationships can be easily designed by using design * pattern.

    * - *

    In Samchon Framework, you can make any type of network system with basic 3 + 1 componenets - * (IProtocol, IServer and IClient + ServerConnector), by implemens or inherits them, like designing + *

    In Samchon Framework, you can make any type of network system with basic componenets + * (IProtocol, IServer and ICommunicator) by implemens or inherits them, like designing * classes of S/W architecture.

    * * @see IProtocol @@ -2952,6 +4233,10 @@ declare namespace samchon.protocol { *

    Listener, represent function's name.

    */ protected listener: string; + /** + * Default Constructor. + */ + constructor(); constructor(listener: string); /** * Copy Constructor. @@ -2959,13 +4244,17 @@ declare namespace samchon.protocol { * @param invoke */ constructor(invoke: Invoke); - constructor(xml: library.XML); - constructor(listener: string, begin: std.VectorIterator, end: std.VectorIterator); - constructor(listener: string, ...parameters: any[]); + /** + * Construct from listener and parametric values. + * + * @param listener + * @param parameters + */ + constructor(listener: string, ...parameters: Array); /** * @inheritdoc */ - createChild(xml: library.XML): InvokeParameter; + protected createChild(xml: library.XML): InvokeParameter; /** * Get listener. */ @@ -2990,93 +4279,10 @@ declare namespace samchon.protocol { CHILD_TAG(): string; } } -declare namespace samchon.protocol { - /** - *

    A history of an Invoke message.

    - * - *

    InvokeHistory is a class for reporting history log of an Invoke message with elapsed time - * from a slave to its master.

    - * - *

    With the elapsed time, consumed time for a process of handling the Invoke message, - * InvokeHistory is reported to the master. The master utilizies the elapsed time to estimating - * performances of each slave system. With the estimated performan index, master retrives the - * optimal solution of distributing processes.

    - * - * @author Jeongho Nam - */ - class InvokeHistory extends Entity { - /** - *

    An identifier.

    - */ - protected uid: number; - /** - *

    A listener of the Invoke message.

    - * - *

    InvokeHistory does not archive entire data of an Invoke message. InvokeHistory only - * archives its listener. The first, formal reason is to save space, avoid wasting spaces.

    - * - *

    The second, complicate reason is on an aspect of which systems are using the - * InvokeHistory class. InvokeHistory is designed to let slave reports to master elapsed time - * of a process used to handling the Invoke message. If you want to archive entire history log - * of Invoke messages, then the subject should be master, not the slave using InvokeHistory - * classes.

    - */ - protected listener: string; - /** - *

    Start time of the history.

    - * - *

    Means start time of a process handling the Invoke message. The start time not only - * has ordinary arguments represented Datetime (year to seconds), but also has very precise - * values under seconds, which is expressed as nano seconds (10^-9).

    - * - *

    The precise start time will be used to calculate elapsed time with end time.

    - */ - protected startTime: Date; - /** - *

    End time of the history.

    - * - * @details - *

    Means end time of a process handling the Invoke message. The end time not only - * has ordinary arguments represented Datetime (year to seconds), but also has very precise - * values under seconds, which is expressed as nano seconds (10^-9).

    - * - *

    The precise end time will be used to calculate elapsed time with start time.

    - */ - protected endTime: Date; - /** - *

    Construct from an Invoke message.

    - * - *

    InvokeHistory does not archive entire Invoke message, only archives its listener.

    - * - * @param invoke A message to archive its history log - */ - constructor(invoke: Invoke); - /** - *

    Notify end of the process.

    - * - *

    Notifies end of a process handling the matched Invoke message to InvokeHistory.

    - *

    InvokeHistory archives the end datetime and calculates elapsed time as nanoseconds.

    - */ - notifyEnd(): void; - TAG(): string; - toXML(): library.XML; - /** - *

    Get an Invoke message.

    - * - *

    Returns an Invoke message to report to a master that how much time was elapsed on a - * process handling the Invoke message. In master, those reports are used to estimate - * performance of each slave system.

    - * - * @return An Invoke message to report master. - */ - toInvoke(): Invoke; - } -} declare namespace samchon.protocol { /** * A parameter belongs to an Invoke. * - * @see Invoke * @author Jeongho Nam */ class InvokeParameter extends Entity { @@ -3093,31 +4299,33 @@ declare namespace samchon.protocol { /** *

    Value of the parameter.

    */ - protected value: any; + protected value: string | number | library.XML | Uint8Array; /** * Default Constructor. */ constructor(); + constructor(val: number); + constructor(val: string); + constructor(val: library.XML); + constructor(val: Uint8Array); /** - * Initialization Constructor without type specification. + * Construct from variable name and number value. * * @param name * @param val */ - constructor(name: string, val: any); - /** - * Initialization Constructor. - * - * @param name - * @param type - * @param val - */ - constructor(name: string, type: string, val: any); + constructor(name: string, val: number); + constructor(name: string, val: string); + constructor(name: string, val: library.XML); + constructor(name: string, val: Uint8Array); /** * @inheritdoc */ construct(xml: library.XML): void; - setValue(value: any): void; + setValue(value: number): any; + setValue(value: string): any; + setValue(value: library.XML): any; + setValue(value: Uint8Array): any; /** * @inheritdoc */ @@ -3145,193 +4353,1781 @@ declare namespace samchon.protocol { } } declare namespace samchon.protocol { - /** - *

    A server connector for a physical client.

    - * - *

    ServerConnector is a class for a physical client connecting a server. If you want to connect - * to a server, then implements this ServerConnector and just override some methods like - * getIP(), getPort() and replyData(). That's all.

    - * - *

    In Samchon Framework, package protocol, There are basic 3 + 1 components that can make any - * type of network system in Samchon Framework. The basic 3 components are IProtocol, IServer and - * IClient. The last, surplus one is the ServerConnector. Looking around classes in - * Samchon Framework, especially module master and slave which are designed for realizing - * distributed processing systems and parallel processing systems, physical client classes are all - * derived from this ServerConnector.

    - * - * - * - * @author Jeongho Nam - */ - class ServerConnector implements IProtocol { + class InvokeHistory extends Entity { /** - *

    A parent object who listens and sends Invoke message.

    * - *
      - *
    • ServerConnector.replyData(Invoke) -> parent.replyData(Invoke)
    • - *
    */ - private parent; + private uid; /** - *

    A socket for network I/O.

    + * @see {@link Invoke.listener} */ - private socket; - private binary_invoke; + private listener; /** - *

    An open-event listener.

    - */ - onopen: Function; - /** - *

    Constructor with parent.

    - */ - constructor(parent: IProtocol); - /** - *

    Connects to a cloud server with specified host and port.

    * - *

    If the connection fails immediately, either an event is dispatched or an exception is thrown: - * an error event is dispatched if a host was specified, and an exception is thrown if no host - * was specified. Otherwise, the status of the connection is reported by an event. - * If the socket is already connected, the existing connection is closed first.

    + */ + private startTime; + /** * - * @param ip - * The name or IP address of the host to connect to. - * If no host is specified, the host that is contacted is the host where the calling - * file resides. If you do not specify a host, use an event listener to determine whether - * the connection was successful. - * @param port - * The port number to connect to. - * - * @throws IOError - * No host was specified and the connection failed. - * @throws SecurityError - * This error occurs in SWF content for the following reasons: - * Local untrusted SWF files may not communicate with the Internet. You can work around - * this limitation by reclassifying the file as local-with-networking or as trusted. */ - connect(ip: string, port: number, path?: string): void; + private endTime; /** - *

    Send data to the server.

    + * Default Constructor. */ - sendData(invoke: Invoke): void; - /** - *

    Shift responsiblity of handling message to parent.

    - */ - replyData(invoke: Invoke): void; - private handleConnect(event); - /** - *

    Handling replied message.

    - */ - private handleReply(event); + constructor(); + constructor(invoke: Invoke); + construct(xml: library.XML): void; + notifyEnd(): void; + key(): number; + getUID(): number; + getListener(): string; + getStartTime(): Date; + getEndTime(): Date; + computeElapsedTime(): number; + TAG(): string; + toXML(): library.XML; + toInvoke(): Invoke; } } -declare namespace samchon.protocol.service { +declare namespace samchon.protocol { /** - *

    An application, the top class in JS-UI.

    + *

    An interface for a physical server.

    + * + *

    {@link IServer} provides methods for opening a server. Extends one of them who are derived from this + * {@link IServer} and open the server with method {@link open IServer.open()}. Override + * {@link addClient IServer.addClient()} who accepts a newly connected client with {@link IClientDriver}. + * If you're embarrased because your class already extended another one, then use {@link IServerBase}.

    * - *

    The Application is separated to three part, TopMenu, Movie and ServerConnector.

    *
      - *
    • TopMenu: Menu on the top. It's not an essential component.
    • - *
    • Movie: Correspond with Service in Server. Movie has domain UI components(Movie) for the matched Service.
    • - *
    • ServerConnector: The socket connecting to the Server.
    • + *
    • {@link Server}
    • + *
    • {@link WebServer}
    • + *
    • {@link SharedWorkerServer}
    • *
    * - *

    The Application and its UI-layout is not fixed, essential component for Samchon Framework in Flex, - * so it's okay to do not use the provided Application and make your custom Application. - * But the custom Application, your own, has to contain the Movie and keep the construction routine.

    + *

    + * + *

    * - *

    + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    + * + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    * - *

    THE CONSTRUCTION ROUTINE

    *
      - *
    • Socket Connection
    • - *
        - *
      • Connect to the CPP-Server
      • - *
      - *
    • Fetch authority
    • - *
        - *
      • Send a request to fetching authority
      • - *
      • The window can be navigated to other page by the authority
      • - *
      - *
    • Construct Movie
    • - *
        - *
      • Determine a Movie by URLVariables::movie and construct it
      • - *
      - *
    • All the routines are done
    • + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} *
    * + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    + * + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    + * + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link IClientDriver} + * @handbook Basic Components - IServer * @author Jeongho Nam */ - class Application implements IProtocol { - /** - *

    Invoke Socket.

    - */ - protected socket: ServerConnector; - /** - *

    A movie.

    - */ - protected movie: Movie; - /** - *

    Construct from arguments.

    - * - * @param movie A movie represents a service. - * @param ip An ip address of cloud server to connect. - * @param port A port number of cloud server to connect. - */ - constructor(movie: Movie, ip: string, port: number); - private handleConnect(event); - /** - *

    Handle replied message or shift the responsibility.

    - */ - replyData(invoke: Invoke): void; - /** - *

    Send a data to server.

    - */ - sendData(invoke: Invoke): void; + interface IServer { + open(port: number): void; + close(): void; + addClient(clientDriver: IClientDriver): void; } } -declare namespace samchon.protocol.service { - /** - * A movie belonged to an Application. - */ - class Movie implements IProtocol { +declare namespace samchon.protocol { + abstract class Server implements IServer { + private server; /** - *

    An application the movie is belonged to + * @inheritdoc */ - protected application: Application; + abstract addClient(driver: ClientDriver): void; /** - * Handle replied data. + * @inheritdoc */ - replyData(invoke: Invoke): void; + open(port: number): void; /** - * Send data to server. + * @inheritdoc */ - sendData(invoke: Invoke): void; + close(): void; + private handle_connect(socket); } } -declare namespace samchon.protocol.service { -} -declare namespace samchon.protocol.slave { - /** - * @brief A slave system. - * - * @details - *

    SlaveSystem, literally, means a slave system belongs to a maste system.

    - * - *

    The SlaveSystem class is used in opposite side system of master::DistributedSystem - * and master::ParallelSystem and reports elapsed time of each commmand (by Invoke message) - * for estimation of its performance.

    - * - * @inheritdoc - * @author Jeongho Nam - */ - abstract class SlaveSystem extends ExternalSystem { +declare namespace samchon.protocol { + abstract class WebServer implements IServer { /** - *

    Default Constructor.

    + * A server handler. + */ + private http_server; + /** + * Sequence number for issuing session id. + */ + private sequence; + /** + * @hidden + */ + private my_port; + /** + * Default Constructor. */ constructor(); /** * @inheritdoc */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + /** + * @inheritdoc + */ + abstract addClient(driver: WebClientDriver): void; + /** + *

    Handle request from a client system.

    + * + *

    This method {@link handle_request} will be called when a client is connected. It will call an abstract + * method method {@link addClient addClient()} who handles an accepted client. If the newly connected client + * doesn't have its own session id, then a new session id will be issued.

    + * + * @param request Requested header. + */ + private handle_request(request); + /** + *

    Get session id from a newly connected.

    + * + *

    Queries ordinary session id from cookies of a newly connected client. If the client has not, a new + * session id will be issued.

    + * + * @param cookies Cookies from the remote client. + */ + private get_session_id(cookies); + /** + * Issue a new session id. + */ + private issue_session_id(); + } +} +declare namespace samchon.protocol { + abstract class SharedWorkerServer implements IServer { + /** + * @inheritdoc + */ + abstract addClient(driver: SharedWorkerClientDriver): void; + /** + * @inheritdoc + */ + open(): void; + /** + * @inheritdoc + */ + close(): void; + private handle_connect(event); + } +} +declare namespace samchon.protocol { + /** + *

    An interface for substitute server classes.

    + * + *

    {@link IServerBase} is an interface for substitue server classes who subrogate server's role.

    + * + *

    The easiest way to defining a server class is to extending one of them, who are derived from the + * {@link IServer}.

    + * + *
      + *
    • {@link Server}
    • + *
    • {@link WebServer}
    • + *
    • {@link SharedWorkerServer}
    • + *
    + * + *

    However, it is impossible (that is, if the class is already extending another class), you can instead implement + * the {@link IServer} interface, create an {@link IServerBase} member, and write simple hooks to route calls into the + * aggregated {@link IServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: IServerBase = new WebServerBase(this); + + public addClient(driver: IClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @see {@link IServer} + * @handbook Basic Components - IServerBase + * @author Jeongho Nam + */ + interface IServerBase extends IServer { + } +} +declare namespace samchon.protocol { + /** + *

    A substitute {@link Server}.

    + * + *

    {@link ServerBase} is a substitute class who subrogates {@link Server}'s responsibility.

    + * + *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending + * {@link Server}. However, it is impossible (that is, if the class is already extending another class), you can + * instead implement the {@link IServer} interface, create a {@link ServerBase} member, and write simple hooks + * to route calls into the aggregated {@link ServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: ServerBase = new ServerBase(this); + + public addClient(driver: ClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @author Jeongho Nam + */ + class ServerBase extends Server implements IServerBase { + private target; + constructor(target: IServer); + addClient(driver: IClientDriver): void; + } +} +declare namespace samchon.protocol { + /** + *

    A substitute {@link WebServer}.

    + * + *

    {@link WebServerBase} is a substitute class who subrogates {@link WebServer}'s responsibility.

    + * + *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending + * {@link WebServer}. However, it is impossible (that is, if the class is already extending another class), you can + * instead implement the {@link IServer} interface, create a {@link WebServerBase} member, and write simple hooks to + * route calls into the aggregated {@link WebServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: WebServerBase = new WebServerBase(this); + + public addClient(driver: WebClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @author Jeongho Nam + */ + class WebServerBase extends WebServer implements IServerBase { + private target; + constructor(target: IServer); + addClient(driver: IClientDriver): void; + } +} +declare namespace samchon.protocol { + /** + *

    A substitute {@link SharedWorkerServer}.

    + * + *

    {@link SharedWorkerServerBase} is a substitute class who subrogates {@link SharedWorkerServer}'s + * responsibility.

    + * + *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending + * {@link SharedWorkerServer}. However, it is impossible (that is, if the class is already extending another class), + * you can instead implement the {@link IServer} interface, create a {@link SharedWorkerServerBase} member, and write + * simple hooks to route calls into the aggregated {@link SharedWorkerServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: SharedWorkerServerBase = new SharedWorkerServerBase(this); + + public addClient(driver: SharedWorkerClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @author Jeongho Nam + */ + class SharedWorkerServerBase extends SharedWorkerServer implements IServerBase { + private target; + constructor(target: IServer); + addClient(driver: IClientDriver): void; + } +} +declare namespace samchon.protocol { + /** + *

    An interface for server connector.

    + * + *

    {@link IServerConnector} is an interface for server connector classes who ca connect to an external server + * as a client.

    + * + *

    Of course, {@link IServerConnector} is extended from the {@link ICommunicator}, thus, it also takes full + * charge of network communication and delivers replied message to {@link WebCommunicator.listener listener}'s + * {@link IProtocol.replyData replyData()} method.

    + * + * @handbook Basic Components - IServerConnector + * @author Jeongho Nam + */ + interface IServerConnector extends ICommunicator { + /** + * Callback function for connection completed. + */ + onConnect: Function; + /** + *

    Connect to a server.

    + * + *

    Connects to a server with specified host address and port number. After the connection has + * succeeded, callback function {@link onConnect} is called. Listening data from the connected server also begins. + * Replied messages from the connected server will be converted to {@link Invoke} classes and will be shifted to + * the {@link WebCommunicator.listener listener}'s {@link IProtocol.replyData replyData()} method.

    + * + *

    If the connection fails immediately, either an event is dispatched or an exception is thrown: an error + * event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, + * the status of the connection is reported by an event. If the socket is already connected, the existing + * connection is closed first.

    + * + * @param ip The name or IP address of the host to connect to. + * If no host is specified, the host that is contacted is the host where the calling file resides. + * If you do not specify a host, use an event listener to determine whether the connection was + * successful. + * @param port The port number to connect to. + */ + connect(ip: string, port: number): void; + } +} +declare namespace samchon.protocol { + class ServerConnector extends Communicator implements IServerConnector { + /** + * @inheritdoc + */ + onConnect: Function; + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + connect(ip: string, port: number): void; + private handle_connect(...arg); + } +} +declare namespace samchon.protocol { + /** + *

    A server connector for web-socket protocol.

    + * + * @author Jeongho Nam + */ + class WebServerConnector extends WebCommunicator implements IServerConnector { + /** + *

    A socket for network I/O.

    + * + *

    Note that, {@link socket} is only used in web-browser environment.

    + */ + private browser_socket; + /** + *

    A driver for server connection.

    + * + *

    Note that, {@link node_client} is only used in NodeJS environment.

    + */ + private node_client; + /** + * @inheritdoc + */ + onConnect: Function; + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + connect(ip: string, port: number, path?: string): void; + /** + * @inheritdoc + */ + close(): void; + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + private handle_browser_connect(event); + private handle_browser_message(event); + private handle_node_connect(connection); + } +} +declare namespace samchon.protocol { + class SharedWorkerServerConnector extends SharedWorkerCommunicator implements IServerConnector { + /** + * @inheritdoc + */ + onConnect: Function; + constructor(listener: IProtocol); + connect(jsFile: string): void; + } +} +declare namespace samchon.protocol { + namespace socket { + type socket = any; + type server = any; + type http_server = any; + } + namespace websocket { + type connection = any; + type request = any; + type IMessage = any; + type ICookie = any; + type client = any; + } +} +declare namespace samchon.protocol.external { + /** + *

    An external system driver.

    + * + *

    The {@link ExternalSystem} class represents an external system, connected and interact with this system. + * {@link ExternalSystem} takes full charge of network communication with external system have connected. + * Replied {@link Invoke messages} from the external system is shifted to and processed in, children elements of this + * class, {@link ExternalSystemRole} objects.

    + * + *

    + * + *

    + * + *

    Bridge & Proxy Pattern

    + *

    The {@link ExternalSystem} class can be a bridge for logical proxy. In framework within user, + * which {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Bridge Pattern and Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalSystem extends EntityDequeCollection implements IProtocol { + /** + * A network communicator with external system. + */ + /** + * A network communicator with external system. + */ + protected communicator: ICommunicator; + /** + * The name represents external system have connected. + */ + protected name: string; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from an IClientDriver object. + * + * @param driver + */ + constructor(driver: IClientDriver); + /** + * Default Destructor. + */ + destructor(): void; + /** + * Identifier of {@link ExternalSystem} is its {@link name}. + */ + key(): string; + /** + * Get {@link name}. + */ + getName(): string; + close(): void; + /** + * Send {@link Invoke} message to external system. + * + * @param invoke An {@link Invoke} message to send. + */ + sendData(invoke: Invoke): void; + /** + * Handle an {@Invoke} message have received. + * + * @param invoke An {@link Invoke} message have received. + */ + replyData(invoke: Invoke): void; + /** + * Tag name of the {@link ExternalSytem} in {@link XML}. + * + * @return system. + */ + TAG(): string; + /** + * Tag name of {@link ExternalSystemRole children elements} belonged to the {@link ExternalSytem} in {@link XML}. + * + * @return role. + */ + CHILD_TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + /** + * @hidden + */ + private communicator_; + /** + * @hidden + */ + private external_system_array_; + /** + * @hidden + */ + private erasing_; + /** + * @hidden + */ + private external_system_array; + /** + * @hidden + */ + private handle_close(); + } +} +declare namespace samchon.protocol.parallel { + /** + *

    An external parallel system driver.

    + * + * + * + * @author Jeongho Nam + */ + abstract class ParallelSystem extends external.ExternalSystem { + /** + * A manager containing this {@link ParallelSystem} object. + */ + private systemArray; + /** + * A list of {@link Invoke} messages on process. + * + * @see {@link performance} + */ + private progress_list; + /** + * A list of {@link Invoke} messages had processed. + * + * @see {@link performance} + */ + private history_list; + /** + *

    Performance index.

    + * + *

    A performance index that indicates how much fast the connected parallel system is.

    + * + *

    If this {@link ParallelSystem parallel system} hasn't any {@link Invoke} message + * {@link history_list had handled}, then the {@link performance performance index} will be 1, which means + * default and average value between all {@link ParallelSystem} instances (belonged to a same + * {@link ParallelSystemArray} object).

    + * + *

    You can specify this {@link performance} by yourself, but notice that, if the + * {@link performance performance index} is higher then other {@link ParallelSystem} objects, then this + * {@link ParallelSystem parallel system} will ordered to handle more processes than other {@link ParallelSystem} + * objects. Otherwise, the {@link performance performance index) is lower than others, of course, less processes + * will be delivered.

    + * + *

    This {@link performance index} is always re-calculated whenever {@link ParallelSystemArray} calls one of + * them below.

    + * + *
      + *
    • {@link ParallelSystemArray.sendSegmentData ParallelSystemArray.sendSegmentData()}
    • + *
    • {@link ParallelSystemArray.sendPieceData ParallelSystemArray.sendPieceData()}
    • + *
    + * + *

    If this class is a type of {@link DistributedSystem}, a derived class from the {@link ParallelSystem}, + * then {@link DistributedSystemRole.sendData DistributedSystem.sendData()} also cause the re-calculation.

    + * + * @see {@link progress_list}, {@link history_list} + */ + protected performance: number; + /** + * Construct from a {@link ParallelSystemArray}. + * + * @param systemArray A manager containing this {@link ParallelSystem} object. + * @param communicator A communicator who takes full charge of network communication with the external + * parallel system. + */ + constructor(systemArray: ParallelSystemArray, communicator?: ICommunicator); + /** + * Get manager of this object, {@link systemArray}. + * + * @return A manager containing this {@link ParallelSystem} object. + */ + getSystemArray(): ParallelSystemArray; + /** + * Get {@link performant performance index}. + * + * A performance index that indicates how much fast the connected parallel system is. + */ + getPerformance(): number; + /** + * Send an {@link Invoke} message with index of segmentation. + * + * @param invoke An invoke message requesting parallel process. + * @param first Initial piece's index in a section. + * @param last Final piece's index in a section. The ranged used is [first, last), which contains + * all the pieces' indices between first and last, including the piece pointed by index + * first, but not the piece pointed by the index last. + * + * @see {@link ParallelSystemArray.sendPieceData} + */ + private send_piece_data(invoke, first, last); + /** + * + * + * @param xml + * + * @see {@link ParallelSystemArray.notify_end} + */ + private report_invoke_history(xml); + } +} +declare namespace samchon.protocol.distributed { + abstract class DistributedSystem extends parallel.ParallelSystem { + } +} +declare namespace samchon.protocol.external { + /** + *

    An array and manager of {@link ExternalSystem external systems}.

    + * + *

    {@link ExternalSystemArray} is an abstract class contains and manages external system drivers, + * {@link ExternalSystem} objects. You can specify this {@link ExternalSystemArray} to be a server accepting + * {@link ExternalSystem external clients} or a client connecting to {@link IExternalServer external servers}. Even + * both of them is also possible.

    + * + *
      + *
    • A server accepting external clients: {@link IExternalClientArray}
    • + *
    • A client connecting to external servers: {@link IExternalServerArray}
    • + *
    • + * Accepts external clients & Connects to external servers at the same time: + * {@link IExternalServerClientArray} + *
    • + *
    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalSystemArray extends EntityArrayCollection implements IProtocol { + /** + * Default Constructor. + */ + constructor(); + /** + * @hidden + */ + private handle_system_insert(event); + /** + * @hidden + */ + private handle_system_erase(event); + /** + * @hidden + */ + protected handle_system_close(system: ExternalSystem): void; + /** + * Test whether this system array has the role. + * + * @param name Name, identifier of target {@link ExternalSystemRole role}. + * + * @return Whether the role has or not. + */ + hasRole(name: string): boolean; + /** + * Get a role. + * + * @param name Name, identifier of target {@link ExternalSystemRole role}. + * + * @return The specified role. + */ + getRole(name: string): ExternalSystemRole; + /** + *

    Send an {@link Invoke} message.

    + * + * @param invoke An {@link Invoke} message to send. + */ + sendData(invoke: Invoke): void; + /** + *

    Handle an {@Invoke} message have received.

    + * + * @param invoke An {@link Invoke} message have received. + */ + replyData(invoke: Invoke): void; + /** + * Tag name of the {@link ExternalSytemArray} in {@link XML}. + * + * @return systemArray. + */ + TAG(): string; + /** + * Tag name of {@link ExternalSystem children elements} belonged to the {@link ExternalSytemArray} in {@link XML}. + * + * @return system. + */ + CHILD_TAG(): string; + } +} +declare namespace samchon.protocol.parallel { + /** + *

    A manager containing {@link ParallelSystem} objects.

    + * + * + * + * @author Jeongho Nam + */ + abstract class ParallelSystemArray extends external.ExternalSystemArray { + /** + * @see {@link ParallelSystem.progress_list}, {@link ParallelSystem.history_list} + */ + private history_sequence; + /** + * Default Constructor. + */ + constructor(); + /** + * + * @param invoke An invoke message requesting parallel process. + * @param size Number of pieces. + */ + sendSegmentData(invoke: Invoke, size: number): void; + /** + * + * + * @param invoke An invoke message requesting parallel process. + * @param first Initial piece's index in a section. + * @param last Final piece's index in a section. The ranged used is [first, last), which contains + * all the pieces' indices between first and last, including the piece pointed by index + * first, but not the piece pointed by the index last. + */ + sendPieceData(invoke: Invoke, first: number, last: number): void; + /** + * + * @param history + * + * @return Whether the processes with same uid are all fininsed. + * + * @see {@link ParallelSystem.report_invoke_history}, {@link normalize_performance} + */ + protected notify_end(history: PRInvokeHistory): boolean; + /** + * @see {@link ParallelSystem.performance} + */ + private normalize_performance(); + } +} +declare namespace samchon.protocol.distributed { + abstract class DistributedSystemArray extends parallel.ParallelSystemArray { + protected roles: std.HashMap; + } +} +declare namespace samchon.protocol.external { + /** + *

    A role of an external system.

    + * + *

    The {@link ExternalSystemRole} class represents a role, what to do in an {@link ExternalSystem}. + * Extends this class and writes some methods related to the role.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemRole} class can be an logical proxy. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalSystemRole extends Entity implements IProtocol { + /** + * An {@link ExternalSystem external system} containing this {@link ExternalSystemRole role}. + */ + private system; + /** + *

    A name, represents and identifies this {@link ExternalSystemRole role}.

    + * + *

    This {@link name} is an identifier represents this {@link ExternalSystemRole role}. This {@link name} is + * used in {@link ExternalSystemArray.getRole} and {@link ExternalSystem.get}, as a key elements. Thus, this + * {@link name} should be unique in an {@link ExternalSystemArray}. + */ + private name; + /** + * Constructor from a system. + * + * @param system An external system containing this role. + */ + constructor(system: ExternalSystem); + /** + * Identifier of {@link ExternalSystemRole} is its {@link name}. + */ + key(): string; + /** + * Get external system, this role is belonged to. + */ + getSystem(): ExternalSystem; + /** + * Get name, who represents and identifies this role. + */ + getName(): string; + /** + * Send an {@link Invoke} message to the external system via {@link system}. + * + * @param invoke An {@link Invoke} message to send to the external system. + */ + sendData(invoke: Invoke): void; + /** + *

    Handle replied {@link Invoke message} from the {@link system external system} belonged to.

    + * + *

    This {@link replyData replyData()} will call a member method named following {@link Invoke.listener}. + * in the invoke.

    + * + * @param invoke An {@link Invoke} message received from the {@link system external system}. + */ + replyData(invoke: Invoke): void; + /** + * Tag name of the {@link ExternalSytemRole} in {@link XML}. + * + * @return role. + */ + TAG(): string; + } +} +declare namespace samchon.protocol.distributed { + abstract class DistributedSystemRole extends external.ExternalSystemRole { + private systems; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an {@link ExternalSystemArray} accepts {@link ExternalSystem external clients} as a + * {@link IServer server}.

    + * + *

    The easiest way to defining an {@link ExternalSystemArray} who opens server and accepts + * {@link ExternalSystem external clients} is to extending one of below, who are derived from this interface + * {@link IExternalClientArray}. However, if you can't specify an {@link ExternalSystemArray} to be whether server or + * client, then make a class (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make + * a new class (now, I name it BaseClientArray) extending BaseSystemArray and implementing this + * interface {@link IExternalClientArray}. Define the BaseClientArray following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalClientArray extends ExternalSystemArray, IServer { + } + /** + *

    An {@link ExternalSystemArray} acceepts {@link ExternalSystem external clients} as a {@link IServer server}.

    + * + *

    {@link ExternalServerArray} is an abstract class contains, manages and accepts external server drivers, + * {@link IExternalServer} objects, as a {@link IServer server}.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalClientArray extends ExternalSystemArray implements IExternalClientArray { + /** + * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. + */ + private server_base; + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method creating {@link IServerBase} object.

    + * + *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, + * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who + * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    + * + *

    Creates and returns one of them:

    + *
      + *
    • {@link ServerBase}
    • + *
    • {@link WebServerBase}
    • + *
    • {@link SharedWorkerServerBase}
    • + *
    + * + * @return A new {@link IServerBase} object. + */ + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + /** + * This method is deprecated. Don't use and override this. + * + * @return null. + */ + protected createChild(xml: library.XML): ExternalSystem; + /** + * Factory method creating {@link ExternalSystem} object. + * + * @param driver A communicator with connected client. + * @return A newly created {@link ExternalSystem} object. + */ + protected abstract createExternalClient(driver: IClientDriver): ExternalSystem; + /** + * @inheritdoc + */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an external server driver.

    + * + *

    The easiest way to defining an external server driver is to extending one of below, who are derived from this + * interface {@link IExternalServer}. However, if you've to interact with an external system who can be both server + * and client, then make a class (let's name it as BaseSystem) extending {@link ExternalSystem} and make a + * new class (now, I name it BaseServer) extending BaseSystem and implementing this interface + * {@link IExternalServer}. Define the BaseServer following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalServer extends ExternalSystem { + /** + * Connect to the external system. + */ + connect(): void; + /** + * Get ip address. + */ + getIP(): string; + /** + * Get port number. + */ + getPort(): number; + } + /** + *

    An external server driver.

    + * + *

    The {@link ExternalServer} class represents an external server, connected and interact with this system. + * {@link ExternalServer} takes full charge of network communication with external server have connected. + * Replied {@link Invoke messages} from the external system is shifted to and processed in, children elements of this + * class, {@link ExternalSystemRole} objects.

    + * + *

    + * + *

    + * + *

    Bridge & Proxy Pattern

    + *

    The {@link ExternalSystem} class can be a bridge for logical proxy. In framework within user, + * which {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Bridge Pattern and Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalServer extends ExternalSystem implements IExternalServer { + /** + * IP address of target external system to connect. + */ + protected ip: string; + /** + * Port number of target external system to connect. + */ + protected port: number; + /** + * Default Constructor. + */ + constructor(); + /** + * Factory method creating server connector. + */ + protected abstract createServerConnector(): IServerConnector; + /** + * @inheritdoc + */ + connect(): void; + /** + * @inheritdoc + */ + getIP(): string; + /** + * @inheritdoc + */ + getPort(): number; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an {@link ExternalSystemArray} connects to {@link IExternalServer external servers} as a + * client.

    + * + *

    The easiest way to defining an {@link ExternalSystemArray} who connects to + * {@link IExternalServer external servers} is to extending one of below, who are derived from this interface + * {@link IExternalServerArray}. However, if you can't specify an {@link ExternalSystemArray} to be whether server or + * client, then make a class (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make + * a new class (now, I name it BaseServerArray) extending BaseSystemArray and implementing this + * interface {@link IExternalServerArray}. Define the BaseServerArray following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalServerArray extends ExternalSystemArray { + /** + *

    Connect to {@link IExternalServer external servers}.

    + * + *

    This method calls children elements' method {@link IExternalServer.connect} gradually.

    + */ + connect(): void; + } + /** + *

    An {@link ExternalSystemArray} connecting to {@link IExternalServer external servers} as a client.

    + * + *

    {@link ExternalServerArray} is an abstract class contains, manages and connects to external server drivers, + * {@link IExternalServer} objects, as a client.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalServerArray extends ExternalSystemArray { + /** + * Default Constructor. + */ + constructor(); + /** + * @inheritdoc + */ + connect(): void; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an {@link ExternalSystemArray} accepts {@link ExternalSystem external clients} as a + * {@link IServer server} and connects to {@link IExternalServer} as client, at the same time.

    + * + *

    The easiest way to defining an {@link IExternalServerClientArray} who opens server, accepts + * {@link ExternalSystem external clients} and connects to {@link IExternalServer external servers} is to extending + * one of below, who are derived from this interface {@link IExternalServerClientArray}. However, if you can't + * specify an {@link ExternalSystemArray} to be whether server or client or even can both them, then make a class + * (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make a new class (now, I name + * it BaseServerClientArray) extending BaseSystemArray and implementing this interface + * {@link IExternalServerClientArray}. Define the BaseServerClientArray following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalServerClientArray extends IExternalServerArray, IExternalClientArray { + } + /** + *

    An {@link ExternalSystemArray} connecting to {@link IExternalServer external servers} as a client and + * accepts {@link ExternalSystem external clients} as a {@link IServer server}.

    + * + *

    {@link ExternalServerArray} is an abstract class contains, manages and connects to external server drivers, + * {@link IExternalServer} objects and accepts external client drivers {@link ExternalSyste} obejcts as a + * client and a {@link IServer server} at the same time.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalServerClientArray extends ExternalClientArray implements IExternalServerClientArray { + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method of a child Entity.

    + * + *

    This method is migrated to {@link createExternalServer createExternalServer()}. Override the + * {@link createExternalServer createExternalServer()}.

    + * + * @param xml An {@link XML} object represents child element, so that can identify the type of child to create. + * + * @return A new child Entity via {@link createExternalServer createExternalServer()}. + */ + protected createChild(xml: library.XML): ExternalSystem; + /** + * Factory method creating an {@link IExternalServer} object. + * + * @param xml An {@link XML} object represents child element, so that can identify the type of child to create. + * + * @return A newly created {@link IExternalServer} object. + */ + protected abstract createExternalServer(xml: library.XML): IExternalServer; + /** + * @inheritdoc + */ + connect(): void; + } +} +declare namespace samchon.protocol.slave { + abstract class SlaveSystem extends external.ExternalSystem { + /** + * Default Constructor. + */ + constructor(); replyData(invoke: Invoke): void; } } +declare namespace samchon.protocol.external { + abstract class MediatorSystem extends slave.SlaveSystem { + private system_array; + private progress_list; + constructor(systemArray: ExternalSystemArray); + abstract start(): void; + /** + * @hidden + */ + protected createChild(xml: library.XML): ExternalSystemRole; + private notify_end(uid); + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol.external { + class MediatorServer extends MediatorSystem implements IServer { + private server_base; + private port; + constructor(systemArray: ExternalSystemArray, port: number); + protected createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + start(): void; + open(port: number): void; + close(): void; + } + class MediatorWebServer extends MediatorServer { + protected createServerBase(): IServerBase; + } + class MediatorSharedWorkerServer extends MediatorServer { + protected createServerBase(): IServerBase; + } +} +declare namespace samchon.protocol.external { + class MediatorClient extends MediatorSystem implements IExternalServer { + protected ip: string; + protected port: number; + constructor(systemArray: ExternalSystemArray, ip: string, port: number); + protected createServerConnector(): IServerConnector; + getIP(): string; + getPort(): number; + start(): void; + connect(): void; + } + class MediatorWebClient extends MediatorClient { + /** + * @inheritdoc + */ + protected createServerConnector(): IServerConnector; + } + class MediatorSharedWorkerClient extends MediatorClient { + /** + * @inheritdoc + */ + protected createServerConnector(): IServerConnector; + } +} +declare namespace samchon.protocol.parallel { + class PRInvokeHistory extends InvokeHistory { + /** + * Index number of initial piece. + */ + private first; + /** + * Index number of final piece. + */ + private last; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from an Invoke message. + * + * @param invoke + */ + constructor(invoke: Invoke); + getFirst(): number; + getLast(): number; + /** + * Compute number of allocated pieces. + */ + computeSize(): number; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelClientArray extends ParallelSystemArray implements external.IExternalClientArray { + /** + * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. + */ + private server_base; + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method creating {@link IServerBase} object.

    + * + *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, + * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who + * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    + * + *

    Creates and returns one of them:

    + *
      + *
    • {@link ServerBase}
    • + *
    • {@link WebServerBase}
    • + *
    • {@link SharedWorkerServerBase}
    • + *
    + * + * @return A new {@link IServerBase} object. + */ + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalClient(driver: IClientDriver): ParallelSystem; + /** + * @inheritdoc + */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelSystemArrayMediator extends ParallelSystemArray { + protected mediator: external.MediatorSystem; + /** + * Default Constructor. + */ + constructor(); + protected abstract createMediator(): external.MediatorSystem; + protected start_mediator(): void; + sendData(invoke: protocol.Invoke): void; + sendPieceData(invoke: protocol.Invoke, first: number, last: number): void; + protected notify_end(history: PRInvokeHistory): boolean; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelClientArrayMediator extends ParallelSystemArrayMediator implements external.IExternalClientArray { + /** + * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. + */ + private server_base; + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method creating {@link IServerBase} object.

    + * + *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, + * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who + * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    + * + *

    Creates and returns one of them:

    + *
      + *
    • {@link ServerBase}
    • + *
    • {@link WebServerBase}
    • + *
    • {@link SharedWorkerServerBase}
    • + *
    + * + * @return A new {@link IServerBase} object. + */ + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalClient(driver: IClientDriver): ParallelSystem; + /** + * @inheritdoc + */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + } +} +declare namespace samchon.protocol.parallel { + interface IParallelServer extends ParallelSystem, external.IExternalServer { + } + abstract class ParallelServer extends ParallelSystem implements IParallelServer { + protected ip: string; + protected port: number; + constructor(systemArray: ParallelSystemArray); + protected abstract createServerConnector(): IServerConnector; + connect(): void; + getIP(): string; + getPort(): number; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerArray extends ParallelSystemArray implements external.IExternalServerArray { + constructor(); + connect(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerArrayMediator extends ParallelSystemArrayMediator implements external.IExternalServerArray { + constructor(); + connect(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerClientArray extends ParallelClientArray implements external.IExternalServerClientArray { + /** + * Default Constructor. + */ + constructor(); + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalServer(xml: library.XML): IParallelServer; + connect(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerClientArrayMediator extends ParallelClientArrayMediator implements external.IExternalServerClientArray { + /** + * Default Constructor. + */ + constructor(); + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalServer(xml: library.XML): IParallelServer; + /** + * @inheritdoc + */ + connect(): void; + } +} +declare namespace samchon.protocol.service { + abstract class Client implements protocol.IProtocol { + private user; + private service; + private driver; + private no; + /** + * Construct from an User and WebClientDriver. + */ + constructor(user: User, driver: WebClientDriver); + protected abstract createService(path: string): Service; + close(): void; + getUser(): User; + getService(): Service; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + protected changeService(path: string): void; + } +} +declare namespace samchon.protocol.service { + abstract class Server extends protocol.WebServer implements IProtocol { + private session_map; + private account_map; + /** + * Default Constructor. + */ + constructor(); + /** + * Factory method creating {@link User} object. + * + * @return A newly created {@link User} object. + */ + protected abstract createUser(): User; + has(account: string): boolean; + get(account: string): User; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + addClient(driver: WebClientDriver): void; + private erase_user(user); + } +} +declare namespace samchon.protocol.service { + abstract class Service implements protocol.IProtocol { + private client; + private path; + /** + * Default Constructor. + */ + constructor(client: Client, path: string); + destructor(): void; + /** + * Get client. + */ + getClient(): Client; + /** + * Get path. + */ + getPath(): string; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol.service { + abstract class User extends collection.HashMapCollection implements protocol.IProtocol { + private server; + private session_id; + private sequence; + private account_id; + private authority; + /** + * Construct from a Server. + */ + constructor(server: Server); + protected abstract createClient(driver: WebClientDriver): Client; + private handle_erase_client(event); + getServer(): Server; + getAccountID(): string; + getAuthority(): number; + setAccount(id: string, authority: number): void; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol.slave { + abstract class SlaveClient extends SlaveSystem { + constructor(); + protected abstract createServerConnector(): IServerConnector; + connect(ip: string, port: number): void; + } +} +declare namespace samchon.protocol.slave { + abstract class SlaveServer extends SlaveSystem implements IServer { + private server_base; + constructor(); + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + open(port: number): void; + close(): void; + } +} diff --git a/typescript-stl/typescript-stl-tests.ts b/typescript-stl/typescript-stl-tests.ts index cc684cde7e..d83a9ffc5a 100644 --- a/typescript-stl/typescript-stl-tests.ts +++ b/typescript-stl/typescript-stl-tests.ts @@ -1,4 +1,4 @@ /// import std = require("typescript-stl"); -std.example.test_all(); \ No newline at end of file +console.log(std); \ No newline at end of file diff --git a/typescript-stl/typescript-stl.d.ts b/typescript-stl/typescript-stl.d.ts index a0f92b88b6..5a83a405cd 100644 --- a/typescript-stl/typescript-stl.d.ts +++ b/typescript-stl/typescript-stl.d.ts @@ -1,4 +1,4 @@ -// Type definitions for TypeScript-STL v1.0.0-rc.3 +// Type definitions for TypeScript-STL v1.0.0 // Project: https://github.com/samchon/typescript-stl // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -117,13 +117,6 @@ declare namespace std { */ declare namespace std.base { } -/** - * Examples for supporting developers who use STL library. - * - * @author Jeongho Nam - */ -declare namespace std.example { -} declare namespace std { /** *

    Apply function to range.

    @@ -2751,8 +2744,8 @@ declare namespace std.base { /** *

    An abstract container.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -2872,8 +2865,8 @@ declare namespace std { *

    There is not a single type of {@link Iterator bidirectional iterator}: {@link IContainer Each container} * may define its own specific iterator type able to iterate through it and access its elements.

    * - *

    - * + *

    + * *

    * * @reference http://www.cplusplus.com/reference/iterator/BidirectionalIterator @@ -2958,18 +2951,45 @@ declare namespace std { * first element in a range is reversed, the reversed iterator points to the element before the first element (this * would be the past-the-end element of the reversed range).

    * - *

    - * + *

    + * *

    * * @reference http://www.cplusplus.com/reference/iterator/reverse_iterator * @author Jeongho Nam */ abstract class ReverseIterator, This extends ReverseIterator> extends Iterator { + /** + * @hidden + */ protected base_: Base; + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: Base); + /** + *

    Return base iterator.

    + * + *

    Return a reference of the base iteraotr.

    + * + *

    The base iterator is an iterator of the same type as the one used to construct the {@link ReverseIterator}, + * but pointing to the element next to the one the {@link ReverseIterator} is currently pointing to + * (a {@link ReverseIterator} has always an offset of -1 with respect to its base iterator). + * + * @return A reference of the base iterator, which iterates in the opposite direction. + */ base(): Base; + /** + * @hidden + */ protected abstract create_neighbor(): This; + /** + *

    Get value of the iterator is pointing.

    + * + * @return A value of the reverse iterator. + */ value: T; /** * @inheritdoc @@ -3194,8 +3214,8 @@ declare namespace std { * the end, {@link Deque Deques} perform worse and have less consistent iterators and references than * {@link List Lists}.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -3217,66 +3237,27 @@ declare namespace std { */ class Deque extends base.Container implements base.IArrayContainer, base.IDequeContainer { /** - *

    Row size of the {@link matrix_ matrix} which contains elements.

    - * - *

    Note that the {@link ROW} affects on time complexity of accessing and inserting element. - * Accessing element is {@link ROW} times slower than ordinary {@link Vector} and inserting element - * in middle position is {@link ROW} times faster than ordinary {@link Vector}.

    - * - *

    When the {@link ROW} returns 8, time complexity of accessing element is O(8) and inserting - * element in middle position is O(N/8). ({@link Vector}'s time complexity of accessement is O(1) - * and inserting element is O(N)).

    + * @hidden */ private static ROW; /** - *

    Minimum {@link capacity}.

    - * - *

    Although a {@link Deque} has few elements, even no element is belonged to, the {@link Deque} - * keeps the minimum {@link capacity} at least.

    + * @hidden */ private static MIN_CAPACITY; /** - *

    A matrix containing elements.

    - * - *

    This {@link matrix_} is the biggest difference one between {@link Vector} and {@link Deque}. - * Its number of rows follows {@link ROW} and number of columns follows {@link get_col_size} which - * returns divide of {@link capacity} and {@link ROW}.

    - * - * By separating segment of elements (segment: row, elements in a segment: col), {@link Deque} takes - * advantage of time complexity on inserting element in middle position. {@link Deque} is {@link ROW} - * times faster than {@link Vector} when inserting elements in middle position.

    - * - *

    However, separating segment of elements from matrix, {@link Deque} also takes disadvantage of - * time complexity on accessing element. {@link Deque} is {@link ROW} times slower than {@link Vector} - * when accessing element.

    + * @hidden */ private matrix_; /** - * Number of elements in the {@link Deque}. + * @hidden */ private size_; /** - *

    Size of allocated storage capacity.

    - * - *

    The {@link capacity_ capacity} is size of the storage space currently allocated for the - * {@link Deque container}, expressed in terms of elements.

    - * - *

    This {@link capacity_ capacity} is not necessarily equal to the {@link Deque container} - * {@link size}. It can be equal or greater, with the extra space allowing to accommodate for growth - * without the need to reallocate on each insertion.

    - * - *

    Notice that this {@link capacity_ capacity} does not suppose a limit on the {@link size} of - * the {@link Deque container}. When this {@link capacity} is exhausted and more is needed, it is - * automatically expanded by the {@link Deque container} (reallocating it storage space). - * The theoretical limit on the {@link size} of a {@link Deque container} is given by member - * {@link max_size}.

    - * - *

    The {@link capacity_ capacity} of a {@link Deque container} can be explicitly altered by - * calling member {@link Deque.reserve}.

    + * @hidden */ private capacity_; /** - * Get column size; {@link capacity_ capacity} / {@link ROW row}. + * @hidden */ private get_col_size(); /** @@ -3480,8 +3461,8 @@ declare namespace std { /** *

    An iterator of {@link Deque}.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -3509,6 +3490,11 @@ declare namespace std { /** * @inheritdoc */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ value: T; /** * @inheritdoc @@ -3552,8 +3538,8 @@ declare namespace std { /** *

    A reverse-iterator of Deque.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -3561,13 +3547,20 @@ declare namespace std { * @author Jeongho Nam */ class DequeReverseIterator extends ReverseIterator, DequeReverseIterator> implements base.IArrayIterator { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: DequeIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): DequeReverseIterator; /** - * Set value. + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; /** @@ -3629,8 +3622,8 @@ declare namespace std { *

    All objects thrown by components of the standard library are derived from this class. * Therefore, all standard exceptions can be caught by catching this type by reference.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/exception/exception * @author Jeongho Nam @@ -3678,8 +3671,8 @@ declare namespace std { * *

    It is used as a base class for several logical error exceptions.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/logic_error * @author Jeongho Nam @@ -3704,8 +3697,8 @@ declare namespace std { *

    No component of the standard library throws exceptions of this type. It is designed as a standard * exception to be thrown by programs.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/domain_error * @author Jeongho Nam @@ -3726,8 +3719,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal invalid arguments.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/invalid_argument * @author Jeongho Nam @@ -3748,8 +3741,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library, * such as vector and string also throw exceptions of this type to signal errors resizing.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/length_error * @author Jeongho Nam @@ -3771,8 +3764,8 @@ declare namespace std { * such as vector, deque, string and bitset also throw exceptions of this type to signal arguments * out of range.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/out_of_range * @author Jeongho Nam @@ -3793,8 +3786,8 @@ declare namespace std { * *

    It is used as a base class for several runtime error exceptions.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/runtime_error * @author Jeongho Nam @@ -3815,8 +3808,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal range errors.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/overflow_error * @author Jeongho Nam @@ -3837,8 +3830,8 @@ declare namespace std { *

    No component of the standard library throws exceptions of this type. It is designed as a standard * exception to be thrown by programs.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/underflow_error * @author Jeongho Nam @@ -3860,8 +3853,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal range errors.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/range_error * @author Jeongho Nam @@ -4422,8 +4415,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -4820,8 +4813,8 @@ declare namespace std { /** *

    An iterator of {@link MapContainer map container}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ @@ -4891,13 +4884,21 @@ declare namespace std { /** *

    A reverse-iterator of {@link MapContainer map container}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ class MapReverseIterator extends ReverseIterator, MapIterator, MapReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: MapIterator); + /** + * @hidden + */ protected create_neighbor(): MapReverseIterator; /** * Get first, key element. @@ -4931,8 +4932,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -5198,8 +5199,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -5311,8 +5312,8 @@ declare namespace std { *

    {@link HashMap} containers are faster than {@link TreeMap} containers to access individual elements by their * key, although they are generally less efficient for range iteration through a subset of their elements.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -5342,6 +5343,9 @@ declare namespace std { * @author Jeongho Nam */ class HashMap extends base.UniqueMap implements base.IHashMap { + /** + * @hidden + */ private hash_buckets_; /** * @hidden @@ -5473,8 +5477,8 @@ declare namespace std { *

    Elements with equivalent keys are grouped together in the same bucket and in such a way that * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -5505,7 +5509,7 @@ declare namespace std { */ class HashMultiMap extends base.MultiMap { /** - * + * @hidden */ private hash_buckets_; /** @@ -5633,8 +5637,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -5910,8 +5914,8 @@ declare namespace std { /** *

    An iterator of a Set.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ @@ -5969,146 +5973,26 @@ declare namespace std { /** *

    A reverse-iterator of Set.

    * - *

    - *

    + *

    + *

    * * @param Type of the elements. * * @author Jeongho Nam */ class SetReverseIterator extends ReverseIterator, SetReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: SetIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): SetReverseIterator; } } -declare namespace std.base { - /** - *

    An abstract set.

    - * - *

    {@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of - * individual elements based on their value.

    - * - *

    In an {@link SetContainer}, the value of an element is at the same time its key, used to uniquely - * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be modified - * once in the container - they can be inserted and removed, though.

    - * - *

    {@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    - * - *

    - *

    - * - *

    Container properties

    - *
    - *
    Associative
    - *
    - * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
    - * - *
    Set
    - *
    The value of an element is also the key used to identify it.
    - * - *
    Unique keys
    - *
    No two elements in the container can have equivalent keys.
    - *
    - * - * @param Type of the elements. Each element in a {@link SetContainer} container is also identified - * by this value (each value is itself also the element's key). - * - * @author Jeongho Nam - */ - abstract class UniqueSet extends SetContainer { - /** - * @inheritdoc - */ - count(key: T): number; - /** - *

    Extract an element.

    - * - *

    Extracts the element pointed to by val and erases it from the {@link UniqueSet}.

    - * - * @param val Value to be extracted. - * - * @return A value. - */ - extract(val: T): T; - /** - *

    Extract an element.

    - * - *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    - * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: SetIterator): SetIterator; - /** - *

    Extract an element.

    - * - *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    - * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: SetReverseIterator): SetReverseIterator; - /** - * @hidden - */ - private extract_by_key(val); - /** - * @hidden - */ - private extract_by_iterator(it); - /** - * @hidden - */ - private extract_by_reverse_iterator(it); - /** - *

    Insert an element.

    - * - *

    Extends the container by inserting new elements, effectively increasing the container {@link size} by - * the number of element inserted (zero or one).

    - * - *

    Because elements in a {@link UniqueSet UniqueSets} are unique, the insertion operation checks whether - * each inserted element is equivalent to an element already in the container, and if so, the element is not - * inserted, returning an iterator to this existing element (if the function returns a value).

    - * - *

    For a similar container allowing for duplicate elements, see {@link MultiSet}.

    - * - * @param key Value to be inserted as an element. - * - * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly - * inserted element or to the equivalent element already in the {@link UniqueSet}. The - * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or - * false if an equivalent element already existed. - */ - insert(val: T): Pair, boolean>; - /** - * @inheritdoc - */ - insert(hint: SetIterator, val: T): SetIterator; - /** - * @inheritdoc - */ - insert(hint: SetReverseIterator, val: T): SetReverseIterator; - /** - * @inheritdoc - */ - insert>(begin: InputIterator, end: InputIterator): void; - /** - * @inheritdoc - */ - swap(obj: UniqueSet): void; - } -} declare namespace std.base { /** *

    An abstract set.

    @@ -6124,8 +6008,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -6177,163 +6061,6 @@ declare namespace std.base { swap(obj: MultiSet): void; } } -declare namespace std.HashSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

    Hashed, unordered set.

    - * - *

    {@link HashSet}s are containers that store unique elements in no particular order, and which - * allow for fast retrieval of individual elements based on their value.

    - * - *

    In an {@link HashSet}, the value of an element is at the same time its key, that - * identifies it uniquely. Keys are immutable, therefore, the elements in an {@link HashSet} cannot be - * modified once in the container - they can be inserted and removed, though.

    - * - *

    Internally, the elements in the {@link HashSet} are not sorted in any particular order, but - * organized into buckets depending on their hash values to allow for fast access to individual elements - * directly by their values (with a constant average time complexity on average).

    - * - *

    {@link HashSet} containers are faster than {@link TreeSet} containers to access individual - * elements by their key, although they are generally less efficient for range iteration through a - * subset of their elements.

    - * - *

    - *

    - * - *

    Container properties

    - *
    - *
    Associative
    - *
    Elements in associative containers are referenced by their key and not by their absolute - * position in the container.
    - * - *
    Hashed
    - *
    Hashed containers organize their elements using hash tables that allow for fast access to elements - * by their key.
    - * - *
    Set
    - *
    The value of an element is also the key used to identify it.
    - * - *
    Unique keys
    - *
    No two elements in the container can have equivalent keys.
    - *
    - * - * @param Type of the elements. - * Each element in an {@link HashSet} is also uniquely identified by this value. - * - * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set - * @author Jeongho Nam - */ - class HashSet extends base.UniqueSet { - private hash_buckets_; - /** - * @hidden - */ - protected init(): void; - /** - * @hidden - */ - protected construct_from_array(items: Array): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: T): SetIterator; - /** - * @inheritdoc - */ - begin(): SetIterator; - /** - * @inheritdoc - */ - begin(index: number): SetIterator; - /** - * @inheritdoc - */ - end(): SetIterator; - /** - * @inheritdoc - */ - end(index: number): SetIterator; - /** - * @inheritdoc - */ - rbegin(): SetReverseIterator; - /** - * @inheritdoc - */ - rbegin(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - rend(): SetReverseIterator; - /** - * @inheritdoc - */ - rend(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - bucket_count(): number; - /** - * @inheritdoc - */ - bucket_size(n: number): number; - /** - * @inheritdoc - */ - max_load_factor(): number; - /** - * @inheritdoc - */ - max_load_factor(z: number): void; - /** - * @inheritdoc - */ - bucket(key: T): number; - /** - * @inheritdoc - */ - reserve(n: number): void; - /** - * @inheritdoc - */ - rehash(n: number): void; - /** - * @hidden - */ - protected insert_by_val(val: T): any; - /** - * @hidden - */ - protected insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - swap(obj: base.UniqueSet): void; - /** - * @hidden - */ - private swap_tree_set(obj); - } -} declare namespace std.HashMultiSet { type iterator = std.SetIterator; type reverse_iterator = std.SetReverseIterator; @@ -6357,8 +6084,8 @@ declare namespace std { *

    Elements with equivalent values are grouped together in the same bucket and in such a way that an * iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -6384,6 +6111,9 @@ declare namespace std { * @author Jeongho Nam */ class HashMultiSet extends base.MultiSet { + /** + * @hidden + */ private hash_buckets_; /** * @hidden @@ -6495,6 +6225,291 @@ declare namespace std { private swap_tree_set(obj); } } +declare namespace std.base { + /** + *

    An abstract set.

    + * + *

    {@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of + * individual elements based on their value.

    + * + *

    In an {@link SetContainer}, the value of an element is at the same time its key, used to uniquely + * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be modified + * once in the container - they can be inserted and removed, though.

    + * + *

    {@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    + * + *

    + *

    + * + *

    Container properties

    + *
    + *
    Associative
    + *
    + * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
    + * + *
    Set
    + *
    The value of an element is also the key used to identify it.
    + * + *
    Unique keys
    + *
    No two elements in the container can have equivalent keys.
    + *
    + * + * @param Type of the elements. Each element in a {@link SetContainer} container is also identified + * by this value (each value is itself also the element's key). + * + * @author Jeongho Nam + */ + abstract class UniqueSet extends SetContainer { + /** + * @inheritdoc + */ + count(key: T): number; + /** + *

    Extract an element.

    + * + *

    Extracts the element pointed to by val and erases it from the {@link UniqueSet}.

    + * + * @param val Value to be extracted. + * + * @return A value. + */ + extract(val: T): T; + /** + *

    Extract an element.

    + * + *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    + * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetIterator): SetIterator; + /** + *

    Extract an element.

    + * + *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    + * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetReverseIterator): SetReverseIterator; + /** + * @hidden + */ + private extract_by_key(val); + /** + * @hidden + */ + private extract_by_iterator(it); + /** + * @hidden + */ + private extract_by_reverse_iterator(it); + /** + *

    Insert an element.

    + * + *

    Extends the container by inserting new elements, effectively increasing the container {@link size} by + * the number of element inserted (zero or one).

    + * + *

    Because elements in a {@link UniqueSet UniqueSets} are unique, the insertion operation checks whether + * each inserted element is equivalent to an element already in the container, and if so, the element is not + * inserted, returning an iterator to this existing element (if the function returns a value).

    + * + *

    For a similar container allowing for duplicate elements, see {@link MultiSet}.

    + * + * @param key Value to be inserted as an element. + * + * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly + * inserted element or to the equivalent element already in the {@link UniqueSet}. The + * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or + * false if an equivalent element already existed. + */ + insert(val: T): Pair, boolean>; + /** + * @inheritdoc + */ + insert(hint: SetIterator, val: T): SetIterator; + /** + * @inheritdoc + */ + insert(hint: SetReverseIterator, val: T): SetReverseIterator; + /** + * @inheritdoc + */ + insert>(begin: InputIterator, end: InputIterator): void; + /** + * @inheritdoc + */ + swap(obj: UniqueSet): void; + } +} +declare namespace std.HashSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

    Hashed, unordered set.

    + * + *

    {@link HashSet}s are containers that store unique elements in no particular order, and which + * allow for fast retrieval of individual elements based on their value.

    + * + *

    In an {@link HashSet}, the value of an element is at the same time its key, that + * identifies it uniquely. Keys are immutable, therefore, the elements in an {@link HashSet} cannot be + * modified once in the container - they can be inserted and removed, though.

    + * + *

    Internally, the elements in the {@link HashSet} are not sorted in any particular order, but + * organized into buckets depending on their hash values to allow for fast access to individual elements + * directly by their values (with a constant average time complexity on average).

    + * + *

    {@link HashSet} containers are faster than {@link TreeSet} containers to access individual + * elements by their key, although they are generally less efficient for range iteration through a + * subset of their elements.

    + * + *

    + *

    + * + *

    Container properties

    + *
    + *
    Associative
    + *
    Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
    + * + *
    Hashed
    + *
    Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their key.
    + * + *
    Set
    + *
    The value of an element is also the key used to identify it.
    + * + *
    Unique keys
    + *
    No two elements in the container can have equivalent keys.
    + *
    + * + * @param Type of the elements. + * Each element in an {@link HashSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set + * @author Jeongho Nam + */ + class HashSet extends base.UniqueSet { + /** + * @hidden + */ + private hash_buckets_; + /** + * @hidden + */ + protected init(): void; + /** + * @hidden + */ + protected construct_from_array(items: Array): void; + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: T): SetIterator; + /** + * @inheritdoc + */ + begin(): SetIterator; + /** + * @inheritdoc + */ + begin(index: number): SetIterator; + /** + * @inheritdoc + */ + end(): SetIterator; + /** + * @inheritdoc + */ + end(index: number): SetIterator; + /** + * @inheritdoc + */ + rbegin(): SetReverseIterator; + /** + * @inheritdoc + */ + rbegin(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + rend(): SetReverseIterator; + /** + * @inheritdoc + */ + rend(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + bucket_count(): number; + /** + * @inheritdoc + */ + bucket_size(n: number): number; + /** + * @inheritdoc + */ + max_load_factor(): number; + /** + * @inheritdoc + */ + max_load_factor(z: number): void; + /** + * @inheritdoc + */ + bucket(key: T): number; + /** + * @inheritdoc + */ + reserve(n: number): void; + /** + * @inheritdoc + */ + rehash(n: number): void; + /** + * @hidden + */ + protected insert_by_val(val: T): any; + /** + * @hidden + */ + protected insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + swap(obj: base.UniqueSet): void; + /** + * @hidden + */ + private swap_tree_set(obj); + } +} declare namespace std.List { type iterator = std.ListIterator; type reverse_iterator = std.ListReverseIterator; @@ -6523,8 +6538,8 @@ declare namespace std { * distance between these. They also consume some extra memory to keep the linking information associated to each * element (which may be an important factor for large lists of small-sized elements).

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -6546,15 +6561,15 @@ declare namespace std { */ class List extends base.Container implements base.IDequeContainer { /** - * An iterator of beginning. + * @hidden */ protected begin_: ListIterator; /** - * An iterator of end. + * @hidden */ protected end_: ListIterator; /** - * Number of elements in the {@link List}. + * @hidden */ protected size_: number; /** @@ -7096,8 +7111,8 @@ declare namespace std { /** *

    An iterator, node of a List.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -7143,6 +7158,11 @@ declare namespace std { /** * @inheritdoc */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ value: T; /** * @inheritdoc @@ -7158,8 +7178,8 @@ declare namespace std { /** *

    A reverse-iterator of List.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -7167,13 +7187,20 @@ declare namespace std { * @author Jeongho Nam */ class ListReverseIterator extends ReverseIterator, ListReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: ListIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): ListReverseIterator; /** - * @inheritdoc + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; } @@ -7208,8 +7235,8 @@ declare namespace std { * By default, if no container class is specified for a particular {@link Queue} class instantiation, the standard * container {@link List} is used.

    * - *

    - * + *

    + * *

    * * @param Type of elements. @@ -7540,8 +7567,8 @@ declare namespace std { * By default, if no container class is specified for a particular {@link Stack} class instantiation, the standard * container {@link List} is used.

    * - *

    - * + *

    + * *

    * * @param Type of elements. @@ -7651,18 +7678,18 @@ declare namespace std.base { * so that they can be interpreted when needed as more abstract (and portable) * {@link ErrorCondition error conditions}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ abstract class ErrorInstance { /** - * A reference to an {@link ErrorCategory} object. + * @hidden */ protected category_: ErrorCategory; /** - * A numerical value identifying an error instance. + * @hidden */ protected value_: number; /** @@ -7761,15 +7788,15 @@ declare namespace std { *

    The class inherits from {@link RuntimeError}, to which it adds an {@link ErrorCode} as * member code (and defines a specialized what member).

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/system_error * @author Jeongho Nam */ class SystemError extends RuntimeError { /** - * Error code. + * @hidden */ protected code_: ErrorCode; /** @@ -7827,8 +7854,8 @@ declare namespace std { * passed by reference. As such, only one object of each of these types shall exist, each uniquely identifying its own * category: all error codes and conditions of a same category shall return a reference to same object.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/error_category * @author Jeongho Nam @@ -7955,8 +7982,8 @@ declare namespace std { *

    The {@link ErrorCategory categories} associated with the {@link ErrorCondition} and the * {@link ErrorCode} define the equivalences between them.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/error_condition * @author Jeongho Nam @@ -7988,8 +8015,8 @@ declare namespace std { *

    Objects of this class associate such numerical codes to {@link ErrorCategory error categories}, so that they * can be interpreted when needed as more abstract (and portable) {@link ErrorCondition error conditions}.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/error_code * @author Jeongho Nam @@ -8034,8 +8061,8 @@ declare namespace std { * *

    {@link TreeMap}s are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -8063,7 +8090,7 @@ declare namespace std { */ class TreeMap extends base.UniqueMap implements base.ITreeMap { /** - * RB-Tree+ object for implemeting the {@link TreeMap}. + * @hidden */ private tree_; /** @@ -8216,8 +8243,8 @@ declare namespace std { * *

    {@link TreeMultiMap TreeMultiMaps} are typically implemented as binary search trees.

    * - *

    < - * img src="http://samchon.github.io/typescript-stl/api/assets/images/design/map_containers.png" style="max-width: 100%" />

    + *

    < + * img src="http://samchon.github.io/typescript-stl/images/design/class_diagram/map_containers.png" style="max-width: 100%" />

    * *

    Container properties

    *
    @@ -8250,6 +8277,9 @@ declare namespace std { * @author Jeongho Nam */ class TreeMultiMap extends base.MultiMap implements base.ITreeMap { + /** + * @hidden + */ private tree_; /** * Default Constructor. @@ -8377,169 +8407,6 @@ declare namespace std { private swap_tree_multimap(obj); } } -declare namespace std.TreeSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

    Tree-structured set, std::set of STL.

    - * - *

    {@link TreeSet}s are containers that store unique elements following a specific order.

    - * - *

    In a {@link TreeSet}, the value of an element also identifies it (the value is itself the - * key, of type T), and each value must be unique. The value of the elements in a - * {@link TreeSet} cannot be modified once in the container (the elements are always const), but they - * can be inserted or removed from the

    - * - *

    Internally, the elements in a {@link TreeSet} are always sorted following a specific strict weak - * ordering criterion indicated by its internal comparison method (of {@link less}).

    - * - *

    {@link TreeSet} containers are generally slower than {@link HashSet} containers to access - * individual elements by their key, but they allow the direct iteration on subsets based on their - * order.

    - * - *

    {@link TreeSet}s are typically implemented as binary search trees.

    - * - *

    - *

    - * - *

    Container properties

    - *
    - *
    Associative
    - *
    - * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
    - * - *
    Ordered
    - *
    - * The elements in the container follow a strict order at all times. All inserted elements are - * given a position in this order. - *
    - * - *
    Set
    - *
    The value of an element is also the key used to identify it.
    - * - *
    Unique keys
    - *
    No two elements in the container can have equivalent keys.
    - *
    - * - * @param Type of the elements. - * Each element in an {@link TreeSet} is also uniquely identified by this value. - * - * @reference http://www.cplusplus.com/reference/set/set - * @author Jeongho Nam - */ - class TreeSet extends base.UniqueSet implements base.ITreeSet { - /** - * RB-Tree+ object for implemeting the {@link TreeSet}. - */ - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (x: T, y: T) => boolean); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - */ - constructor(array: Array); - /** - * Contruct from elements with compare. - * - * @param array Elements to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array, compare: (x: T, y: T) => boolean); - /** - * Copy Constructor. - */ - constructor(container: base.IContainer); - /** - * Copy Constructor with compare. - * - * @param container A container to be copied. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: base.IContainer, compare: (x: T, y: T) => boolean); - /** - * Range Constructor. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * Range Constructor with compare. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * @param compare A binary predicate determines order of elements. - */ - constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(val: T): SetIterator; - /** - * @inheritdoc - */ - key_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - value_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - lower_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - upper_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - equal_range(val: T): Pair, SetIterator>; - /** - * @hidden - */ - protected insert_by_val(val: T): any; - protected insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - swap(obj: base.UniqueSet): void; - /** - * @hidden - */ - private swap_tree_set(obj); - } -} declare namespace std.TreeMultiSet { type iterator = std.SetIterator; type reverse_iterator = std.SetReverseIterator; @@ -8565,8 +8432,8 @@ declare namespace std { * *

    {@link TreeMultiSet TreeMultiSets} are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -8597,7 +8464,7 @@ declare namespace std { */ class TreeMultiSet extends base.MultiSet implements base.ITreeSet { /** - * RB-Tree+ object for implemeting the {@link TreeMultiSet}. + * @hidden */ private tree_; /** @@ -8711,6 +8578,169 @@ declare namespace std { private swap_tree_set(obj); } } +declare namespace std.TreeSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

    Tree-structured set, std::set of STL.

    + * + *

    {@link TreeSet}s are containers that store unique elements following a specific order.

    + * + *

    In a {@link TreeSet}, the value of an element also identifies it (the value is itself the + * key, of type T), and each value must be unique. The value of the elements in a + * {@link TreeSet} cannot be modified once in the container (the elements are always const), but they + * can be inserted or removed from the

    + * + *

    Internally, the elements in a {@link TreeSet} are always sorted following a specific strict weak + * ordering criterion indicated by its internal comparison method (of {@link less}).

    + * + *

    {@link TreeSet} containers are generally slower than {@link HashSet} containers to access + * individual elements by their key, but they allow the direct iteration on subsets based on their + * order.

    + * + *

    {@link TreeSet}s are typically implemented as binary search trees.

    + * + *

    + *

    + * + *

    Container properties

    + *
    + *
    Associative
    + *
    + * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
    + * + *
    Ordered
    + *
    + * The elements in the container follow a strict order at all times. All inserted elements are + * given a position in this order. + *
    + * + *
    Set
    + *
    The value of an element is also the key used to identify it.
    + * + *
    Unique keys
    + *
    No two elements in the container can have equivalent keys.
    + *
    + * + * @param Type of the elements. + * Each element in an {@link TreeSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/set/set + * @author Jeongho Nam + */ + class TreeSet extends base.UniqueSet implements base.ITreeSet { + /** + * @hidden + */ + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (x: T, y: T) => boolean); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + */ + constructor(array: Array); + /** + * Contruct from elements with compare. + * + * @param array Elements to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array, compare: (x: T, y: T) => boolean); + /** + * Copy Constructor. + */ + constructor(container: base.IContainer); + /** + * Copy Constructor with compare. + * + * @param container A container to be copied. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: base.IContainer, compare: (x: T, y: T) => boolean); + /** + * Range Constructor. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * Range Constructor with compare. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * @param compare A binary predicate determines order of elements. + */ + constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(val: T): SetIterator; + /** + * @inheritdoc + */ + key_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + lower_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + upper_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + equal_range(val: T): Pair, SetIterator>; + /** + * @hidden + */ + protected insert_by_val(val: T): any; + protected insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + swap(obj: base.UniqueSet): void; + /** + * @hidden + */ + private swap_tree_set(obj); + } +} declare namespace std { /** *

    Running on Node.

    @@ -8818,8 +8848,8 @@ declare namespace std { * end, they perform worse than the others, and have less consistent iterators and references than {@link List}s. *

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -9200,8 +9230,8 @@ declare namespace std { /** *

    An iterator of Vector.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -9232,7 +9262,9 @@ declare namespace std { * @inheritdoc */ /** - * Set value. + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; /** @@ -9277,8 +9309,8 @@ declare namespace std { /** *

    A reverse-iterator of Vector.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -9286,13 +9318,20 @@ declare namespace std { * @author Jeongho Nam */ class VectorReverseIterator extends ReverseIterator, VectorReverseIterator> implements base.IArrayIterator { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: VectorIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): VectorReverseIterator; /** - * Set value. + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; /** @@ -9353,7 +9392,13 @@ declare namespace std.base { * @author Jeongho Nam */ class HashBuckets { + /** + * @hidden + */ private buckets_; + /** + * @hidden + */ private item_size_; /** * Default Constructor. @@ -9400,8 +9445,8 @@ declare namespace std.base { *

    Elements with equivalent keys are grouped together in the same bucket and in such a way that * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -9696,8 +9741,8 @@ declare namespace std.base { /** *

    Hash buckets storing {@link MapIterator MapIterators}.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -9727,8 +9772,8 @@ declare namespace std.base { * elements by their key, although they are generally less efficient for range iteration through a * subset of their elements.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -9951,8 +9996,8 @@ declare namespace std.base { /** *

    Hash buckets storing {@link SetIterator SetIterators}.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -9993,8 +10038,8 @@ declare namespace std.base { * beginning or the end, {@link IArray} objects perform worse and have less consistent iterators and references * than {@link List Lists}

    . * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -10107,8 +10152,8 @@ declare namespace std.base { *

    There is not a single type of {@link IArrayIterator random-access iterator}: Each container may define its * own specific iterator type able to iterate through it and access its elements.

    * - *

    - * + *

    + * *

    * * @reference http://www.cplusplus.com/reference/iterator/RandomAccessIterator @@ -10138,8 +10183,8 @@ declare namespace std.base { *

    {@link IContainer} is an interface designed for sequence containers. Sequence containers of STL * (Standard Template Library) are based on the {@link IContainer}.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -10330,8 +10375,8 @@ declare namespace std.base { /** *

    An interface for deque

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -10360,8 +10405,8 @@ declare namespace std.base { /** *

    An interface for linear containers.

    * - *

    - * + *

    + * *

    * * @author Jeonngho Nam @@ -10522,7 +10567,7 @@ declare namespace std.base { * * * - *

    * *

    These constraints enforce a critical property of red-black trees: the path from the root to the farthest @@ -10717,7 +10762,7 @@ declare namespace std.base { * the only loop, and any rotations occur after this loop, this proves that a constant number of rotations * occur.

    * - *

    * * @param N A node to be inserted or swapped. @@ -10751,7 +10796,7 @@ declare namespace std.base { * node are black) is still violated, but now we can resolve this by * continuing to case 5.

    * - *

    * * @param N A node to be inserted or swapped. @@ -10782,7 +10827,7 @@ declare namespace std.base { * through {@link XTreeNode.parent P}. In each case, this is the only * black node of the three.

    * - *

    * * @param N A node to be inserted or swapped. @@ -10936,7 +10981,7 @@ declare namespace std.base { /** *

    {@link XTreeNode.sibling S} is red.

    * - *

    * *

    In this case we reverse the colors of {@link XTreeNode.parent P} and @@ -10958,7 +11003,7 @@ declare namespace std.base { *

    {@link XTreeNode.parent P}, {@link XTreeNode.sibling S}, and {@link XTreeNode.sibling * S}'s children are black.

    * - *

    * *

    In this case, we simply repaint {@link XTreeNode.sibling S} red. The @@ -10982,7 +11027,7 @@ declare namespace std.base { *

    {@link XTreeNode.sibling S} and {@link XTreeNode.sibling S}'s children are * black, but {@link XTreeNode.parent P} is red.

    * - *

    * *

    In this case, we simply exchange the colors of {@link XTreeNode.sibling S} and @@ -10999,7 +11044,7 @@ declare namespace std.base { * left child is red, {@link XTreeNode.sibling S}'s right child is * black, and N is the left child of its parent.

    * - *

    * *

    In this case we rotate right at {@link XTreeNode.sibling S}, so that @@ -11038,7 +11083,7 @@ declare namespace std.base { *

    Thus, the paths passing through N pass through one additional * black node.

    * - *

    * *

    Meanwhile, if a path does not go through N, then there are two possibilities:

    @@ -11122,8 +11167,8 @@ declare namespace std.base { * *

    {@link ITreeMap TreeMultiMaps} are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -11257,13 +11302,19 @@ declare namespace std.base { /** *

    A red-black tree storing {@link MapIterator MapIterators}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ class PairTree extends XTree> { + /** + * @hidden + */ private map_; + /** + * @hidden + */ private compare_; /** * Default Constructor. @@ -11409,8 +11460,8 @@ declare namespace std.base { * *

    {@link ITreeSet TreeMultiSets} are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -11551,13 +11602,19 @@ declare namespace std.base { /** *

    A red-black Tree storing {@link SetIterator SetIterators}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ class AtomicTree extends XTree> { + /** + * @hidden + */ private set_; + /** + * @hidden + */ private compare_; /** * Default Constructor. @@ -11738,27 +11795,3 @@ declare namespace std.base { uncle: XTreeNode; } } -declare namespace std.example { - function test_all(): void; -} -declare namespace std.example { - function test_bind(): void; -} -declare namespace std.example { - function test_deque(): void; -} -declare namespace std.example { - function test_for_each(): void; -} -declare namespace std.example { - function test_hash_map(): void; -} -declare namespace std.example { - function test_list(): void; -} -declare namespace std.example { - function sorting(): void; -} -declare namespace std.example { - function tree_set(): void; -} From 1003a9ce5250b8fe374cca07c21a19ea474622b2 Mon Sep 17 00:00:00 2001 From: jcbmln Date: Fri, 12 Aug 2016 03:36:34 -0500 Subject: [PATCH 50/80] Add type definition for koa-hbs (#10579) --- koa-hbs/koa-hbs-tests.ts | 21 +++++++++++++++ koa-hbs/koa-hbs.d.ts | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 koa-hbs/koa-hbs-tests.ts create mode 100644 koa-hbs/koa-hbs.d.ts diff --git a/koa-hbs/koa-hbs-tests.ts b/koa-hbs/koa-hbs-tests.ts new file mode 100644 index 0000000000..373c3ab8b9 --- /dev/null +++ b/koa-hbs/koa-hbs-tests.ts @@ -0,0 +1,21 @@ +/// +/// + +import * as Hbs from 'koa-hbs'; +import * as Koa from 'koa'; +import * as Path from 'path'; + +const app = new Koa(); +const hbs = new Hbs(); + +app.use(hbs.middleware({ + viewPath: Path.join(__dirname, './views') +})); + +app.use(function *(next: any) { + yield this.render('index', { + title: 'Hello World!' + }); +}); + +app.listen(3000); diff --git a/koa-hbs/koa-hbs.d.ts b/koa-hbs/koa-hbs.d.ts new file mode 100644 index 0000000000..cd8fc9c5b4 --- /dev/null +++ b/koa-hbs/koa-hbs.d.ts @@ -0,0 +1,55 @@ +// Type definitions for koa-favicon v2.x +// Project: https://github.com/gilt/koa-hbs +// Definitions by: Jacob Malone +// Definitions: https://github.com/jcbmln/DefinitelyTyped + +/* =================== USAGE =================== + + import * as Hbs from "koa-hbs"; + import * as Koa from "koa"; + + var hbs = new Hbs(); + var app = new Koa(); + + app.use(hbs.middleware({ + viewPath: __dirname + '/views' + })); + + app.use(function *() { + yield this.render('main', { + title: 'koa-hbs' + }); + }); + + =============================================== */ + +/// + +declare module "koa-hbs" { + + import * as Koa from "koa"; + + namespace Hbs { + export interface Middleware { + viewPath: Array | string, + handlebars?: Function, + templateOptions?: {}, + extname?: string, + partialsPath?: Array | string, + defaultLayout?: string, + layoutsPath?: string, + contentHelperName?: string, + blockHelperName?: string, + disableCache?: boolean + } + } + + class Hbs { + constructor(); + + middleware(opts: Hbs.Middleware): any; + } + + namespace Hbs {} + export = Hbs; +} From e4d53c60ada4ca2ba38c8271b81caa9379761cff Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 11:55:28 +0200 Subject: [PATCH 51/80] #10342 Added hideNoData/showNoData to highcharts --- highcharts/highcharts.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index 4ea165814f..451e3d248b 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -5754,6 +5754,17 @@ interface HighchartsChartObject { * @since 1.2.0 */ hideLoading(): void; + /** + * Returns true if there are data points within the plot area now + * @return {boolean} If chart has any data. + * @since 3.0.8 + */ + hasData(): boolean; + /** + * Hide the 'No data to display' message added by the no-data-to-display plugin. + * @since 3.0.8 + */ + hideNoData(): void; /** * The options structure for the chart. * @since 1.2.0 @@ -5802,6 +5813,12 @@ interface HighchartsChartObject { * @since 2.1.0 */ setTitle(title: HighchartsTitleOptions, subtitle?: HighchartsSubtitleOptions, redraw?: boolean): void; + /** + * Display a no-data message. + * @param {String} message An optional message to show in place of the default one + * @since 3.0.8 + */ + showNoData(message?: string): void; /** * Dim the chart's plot area and show a loading label text. Options for the loading screen are defined at * options.loading. A custom text can be given as a parameter for loading. From 4a76c899385aefbd0f629dad03f463d7c8b433d1 Mon Sep 17 00:00:00 2001 From: Brian Surowiec Date: Fri, 12 Aug 2016 07:26:42 -0400 Subject: [PATCH 52/80] Rename bootstrap-datepicker to match npm package Fixes #10572 --- .../bootstrap-datepicker-tests.ts | 2 +- .../bootstrap-datepicker.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename bootstrap.datepicker/bootstrap.datepicker-tests.ts => bootstrap-datepicker/bootstrap-datepicker-tests.ts (98%) rename bootstrap.datepicker/bootstrap.datepicker.d.ts => bootstrap-datepicker/bootstrap-datepicker.d.ts (98%) diff --git a/bootstrap.datepicker/bootstrap.datepicker-tests.ts b/bootstrap-datepicker/bootstrap-datepicker-tests.ts similarity index 98% rename from bootstrap.datepicker/bootstrap.datepicker-tests.ts rename to bootstrap-datepicker/bootstrap-datepicker-tests.ts index b275ee25a8..d290a5b8fa 100644 --- a/bootstrap.datepicker/bootstrap.datepicker-tests.ts +++ b/bootstrap-datepicker/bootstrap-datepicker-tests.ts @@ -1,4 +1,4 @@ -/// +/// function tests_simple() { $('#datepicker').datepicker(); diff --git a/bootstrap.datepicker/bootstrap.datepicker.d.ts b/bootstrap-datepicker/bootstrap-datepicker.d.ts similarity index 98% rename from bootstrap.datepicker/bootstrap.datepicker.d.ts rename to bootstrap-datepicker/bootstrap-datepicker.d.ts index f60a0ffed6..1a2bb2124b 100644 --- a/bootstrap.datepicker/bootstrap.datepicker.d.ts +++ b/bootstrap-datepicker/bootstrap-datepicker.d.ts @@ -1,4 +1,4 @@ -// Type definitions for bootstrap.datepicker +// Type definitions for bootstrap-datepicker // Project: https://github.com/eternicode/bootstrap-datepicker // Definitions by: Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 123ff34937aabde67b4a3e7845a011497e193845 Mon Sep 17 00:00:00 2001 From: Teun Zengerink Date: Fri, 12 Aug 2016 14:13:19 +0200 Subject: [PATCH 53/80] Add width to IDialogOptions --- ng-dialog/ng-dialog.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ng-dialog/ng-dialog.d.ts b/ng-dialog/ng-dialog.d.ts index 42d7821d4a..931dbab188 100644 --- a/ng-dialog/ng-dialog.d.ts +++ b/ng-dialog/ng-dialog.d.ts @@ -222,6 +222,11 @@ declare namespace angular.dialog { * If specified, the first matching element is used. */ ariaDescribedBySelector?: string; + + /** + * Specifies the width of the dialog content element. Default value is null (unspecified) + */ + width?: string|number; } /** From 508e5b07915f9e97c602a48262f4f5b9e381cbb0 Mon Sep 17 00:00:00 2001 From: Teun Zengerink Date: Fri, 12 Aug 2016 14:14:21 +0200 Subject: [PATCH 54/80] Add draw to Pikaday --- pikaday/pikaday.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pikaday/pikaday.d.ts b/pikaday/pikaday.d.ts index 913ea69613..efa000fad9 100644 --- a/pikaday/pikaday.d.ts +++ b/pikaday/pikaday.d.ts @@ -102,6 +102,11 @@ declare class Pikaday { */ setEndRange(date: Date): void; + /** + * Update the HTML. + */ + draw(force: boolean): void; + /** * Returns true if the picker is visible. */ @@ -249,7 +254,7 @@ declare namespace Pikaday { * Render the month after the year in the title. Default: false. */ showMonthAfterYear?: boolean; - + /** * Render days of the calendar grid that fall in the next or previous months to the current month instead of rendering an empty table cell. Default: false. */ From 0957d02747f89a0c3d21710ff2e8a3f04f097c10 Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Fri, 12 Aug 2016 15:30:00 +0300 Subject: [PATCH 55/80] domurl type defs added --- domurl/domurl-tests.ts | 80 ++++++++++++++++++++++++++++++++++++++++++ domurl/domurl.d.ts | 30 ++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 domurl/domurl-tests.ts create mode 100644 domurl/domurl.d.ts diff --git a/domurl/domurl-tests.ts b/domurl/domurl-tests.ts new file mode 100644 index 0000000000..20070b0395 --- /dev/null +++ b/domurl/domurl-tests.ts @@ -0,0 +1,80 @@ +/// + +interface UModel extends QueryString { + a: any; + b: string; +} + +interface U2Model extends QueryString { + a: any; +} + +interface U3Model extends QueryString { + foo: string; +} + +var u = new Url(); // current document URL will be used +// or we can instantiate as +var u2 = new Url("http://example.com/some/path?a=b&c=d#someAnchor"); +// it should support relative URLs also +var u3 = new Url("/my/site/doc/path?foo=bar#baz"); + +// get the value of some query string parameter +alert(u2.query.a); +// or +alert(u3.query["foo"]); + +// Manipulating query string parameters +u.query.a = [1, 2, 3]; // adds/replaces in query string params a=1&a=2&a=3 +u.query.b = 'woohoo'; // adds/replaces in query string param b=woohoo + +if (u.query.a instanceof Array) { // the way to add a parameter + u.query.a.push(4); // now it's "a=1&a=2&a=3&a=4&b=woohoo" +} + +else { // if not an array but scalar value here is a way how to convert to array + u.query.a = [u.query.a]; + u.query.a.push(8) +} + + +// The way to remove the parameter: +delete u.query.a; +// or: +delete u.query["a"]; + +// If you need to remove all query string params: +u.query.clear(); +alert(u); + +// Lookup URL parts: +alert( + 'protocol = ' + u.protocol + '\n' + + 'user = ' + u.user + '\n' + + 'pass = ' + u.pass + '\n' + + 'host = ' + u.host + '\n' + + 'port = ' + u.port + '\n' + + 'path = ' + u.path + '\n' + + 'query = ' + u.query + '\n' + + 'hash = ' + u.hash +); + +// Manipulating URL parts +u.path = '/some/new/path'; // the way to change URL path +u.protocol = 'https'; // the way to force https protocol on the source URL + +// inject into string +var str = 'My Cool Link'; + +// or use in DOM context +var a = document.createElement('a'); +a.href = u.toString(); +a.innerHTML = 'test'; +document.body.appendChild(a); + +// Stringify +var su1 = u + ''; +var su2 = String(u); +var su3 = u.toString(); +// NOTE, that usually it will be done automatically, so only in special +// cases direct stringify is required diff --git a/domurl/domurl.d.ts b/domurl/domurl.d.ts new file mode 100644 index 0000000000..ad1051d7fb --- /dev/null +++ b/domurl/domurl.d.ts @@ -0,0 +1,30 @@ +// Type definitions for domurl +// Project: https://github.com/Mikhus/domurl +// Definitions by: Mykhailo Stadnyk +// Definitions: https://github.com/Mikhus/DefinitelyTyped + +interface QueryString { + (qs?: string); + toString(): string; +} + +declare class Url { + constructor(url?: string); + query: T; + protocol: string; + user: string; + pass: string; + host: string; + port: string; + path: string; + hash: string; + href: string; + toString(): string; + encode(s: string): string; + decode(s: string): string; + isAbsolute(): boolean; + paths(paths?: [string]): [string]; + isEmptyQuery(): boolean; + queryLength(): number; + clearQuery(): Url; +} From 75f71e27750bd0daa5b2d7b423d1a8fe1cc4b6c0 Mon Sep 17 00:00:00 2001 From: Maksym Butsykin Date: Fri, 12 Aug 2016 15:33:43 +0300 Subject: [PATCH 56/80] Add type definition for angular-es --- angular-es/angular-es-tests.ts | 157 +++++++++++++++++++++++++++++ angular-es/angular-es.d.ts | 179 +++++++++++++++++++++++++++++++++ 2 files changed, 336 insertions(+) create mode 100644 angular-es/angular-es-tests.ts create mode 100644 angular-es/angular-es.d.ts diff --git a/angular-es/angular-es-tests.ts b/angular-es/angular-es-tests.ts new file mode 100644 index 0000000000..9565c3ef70 --- /dev/null +++ b/angular-es/angular-es-tests.ts @@ -0,0 +1,157 @@ +/// + +// +// @Component +// +import { Component } from 'angular-es'; +@Component({ + selector: '', + template: '' +}) +class MyComponentController { + +} + +// +// @Config +// +import { Config } from 'angular-es'; + +@Config +class MyConfig { + +} + +// +// @Constant +// +import { Constant } from 'angular-es'; + +@Constant('MyConstant') +class MyConstant { + foo = 'foo'; + bar = 'bar'; +} + +// +// @Controller +// +import { Controller } from 'angular-es'; + +@Controller('MyController') +class MyController { + +} + +// +// @Decorator +// +import { Decorator } from 'angular-es'; + +@Decorator('MyServiceDecorator') +class MyServiceDecorator { + +} + +// +// @Directive +// +import { Directive } from 'angular-es'; + +@Directive('MyDirective') +class MyDirective { + +} + +// +// @Factory +// +import { Factory } from 'angular-es'; + +@Factory('MyFactory') +class MyFactory { +} + +// +// @Filter +// +import { Filter } from 'angular-es'; + +@Filter('MyFilter') +class MyFilter { +} + +// +// @Inject +// +import { Inject } from 'angular-es'; + +@Inject('fooBar') +class MyService { + + @Inject('bazBar') + myMethod(bazBar) { + } + + constructor(fooBar) { + } +} + +// +// @InjectAsProperty +// +import { InjectAsProperty } from 'angular-es'; + +@InjectAsProperty('fooBar') +class MyService { + fooBar; + + myMethod() { + this.fooBar !== undefined; + } +} + +// +// @Module +// +import { Module, Service } from 'angular-es'; + +@Module('my.module') +@Service('MyService') +class MyService { +} + +// +// @Provider +// +import { Provider } from 'angular-es'; + +@Provider('MyProvider') +class MyProvider { +} + +// +// @Run +// +import { Run } from 'angular-es'; + +@Run +class MyRunBlock { +} + +// +// @Service +// +import { Service } from 'angular-es'; + +@Service('MyService') +class MyService { +} +// +// @Value +// +import { Value } from 'angular-es'; + +@Value('MyValue') +class MyValue { +} diff --git a/angular-es/angular-es.d.ts b/angular-es/angular-es.d.ts new file mode 100644 index 0000000000..dbe1c7afdd --- /dev/null +++ b/angular-es/angular-es.d.ts @@ -0,0 +1,179 @@ +// Type definitions for angular-es v0.0.3 +// Project: https://github.com/mbutsykin/angular-es +// Definitions by: mbutsykin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'angular-es' { + + /** + * Decorated target + */ + interface ngESDecorator { + target: Object|Function, + ngName?: string, + ngArguments?: Array, + ngType?: string, + injectAsProperty?: Array; + } + + /** + * Component interface + * @see https://docs.angularjs.org/guide/component + */ + interface iComponent { + template: string, + selector: string, + controllerAs?: string, + require?: string, + templateUrl?: string, + transclude?: string, + bindings?: Object + } + + /** + * Register component + * + * @param {Object} component - component config + * + * @returns {ngESDecorator} - decorated class + */ + var Component: (component: iComponent) => ngESDecorator; + + /** + * Register config block + */ + var Config: () => ngESDecorator; + + /** + * Register constant + * + * @param {string} name - constant name + * + * @returns {ngESDecorator} - decorated class + */ + var Constant: (name: string) => ngESDecorator; + + /** + * Register controller + * + * @param {string} name - controller name + * + * @returns {ngESDecorator} - decorated class + */ + var Controller: (name: string) => ngESDecorator; + + /** + * Register decorator + * + * @param {string} name - provider name to decorate + * + * @returns {ngESDecorator} - decorated class + */ + var Decorator: (name: string) => ngESDecorator; + + /** + * Register directive + * + * @param {string} name - directive selector, can be in hyphen-case + * + * @returns {ngESDecorator} - decorated class + */ + var Directive: (name: string) => ngESDecorator; + + /** + * Register factory + * + * @param {string} name - factory name + * + * @returns {ngESDecorator} - decorated class + */ + var Factory: (name: string) => ngESDecorator; + + /** + * Register filter + * + * @param {string} name - filter name + * + * @returns {ngESDecorator} - decorated class + */ + var Filter: (name: string) => ngESDecorator; + + /** + * Add $inject property to target + * + * @param {Array} dependencies - dependencies to inject + * + * @returns {ngESDecorator} - decorated class + */ + var Inject: (...dependencies: Array) => ngESDecorator; + + /** + * Inject dependencies as properties to target + * + * @param {Array} dependencies - dependencies to inject + * + * @returns {ngESDecorator} - decorated class + */ + var InjectAsProperty: (...dependencies: Array) => ngESDecorator; + + /** + * Attach target to the specified module + * + * @param {string} name - module name + * + * @returns {ngESDecorator} - decorated class + */ + var Module: (name: string) => ngESDecorator; + + /** + * Register provider + * + * @param {string} name - provider name + * + * @returns {ngESDecorator} - decorated class + */ + var Provider: (name: string) => ngESDecorator; + + /** + * Register run block + * + * @returns {ngESDecorator} - decorated class + */ + var Run: () => ngESDecorator; + + /** + * Register service + * + * @param {string} name - service name + * + * @returns {ngESDecorator} - decorated class + */ + var Service: (name: string) => ngESDecorator; + + /** + * Register value + * + * @param {string} name - value name + * + * @returns {ngESDecorator} - decorated class + */ + var Value: (name: string) => ngESDecorator; + + export { + Component, + Config, + Constant, + Controller, + Decorator, + Directive, + Factory, + Filter, + Inject, + InjectAsProperty + Module, + Provider, + Run, + Service, + Value, + } +} From fb27145ccd04b3947163cdfef4253eb92444e858 Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Fri, 12 Aug 2016 15:36:54 +0300 Subject: [PATCH 57/80] Fixing defs and tests --- domurl/domurl-tests.ts | 3 +-- domurl/domurl.d.ts | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/domurl/domurl-tests.ts b/domurl/domurl-tests.ts index 20070b0395..fd4895ed5f 100644 --- a/domurl/domurl-tests.ts +++ b/domurl/domurl-tests.ts @@ -44,8 +44,7 @@ delete u.query.a; delete u.query["a"]; // If you need to remove all query string params: -u.query.clear(); -alert(u); +alert(u.clearQuaery()); // Lookup URL parts: alert( diff --git a/domurl/domurl.d.ts b/domurl/domurl.d.ts index ad1051d7fb..f659ca1843 100644 --- a/domurl/domurl.d.ts +++ b/domurl/domurl.d.ts @@ -1,10 +1,10 @@ // Type definitions for domurl // Project: https://github.com/Mikhus/domurl -// Definitions by: Mykhailo Stadnyk +// Definitions by: Mikhus // Definitions: https://github.com/Mikhus/DefinitelyTyped -interface QueryString { - (qs?: string); +declare class QueryString { + constructor(qs?: string); toString(): string; } From 2f0120be92881eaac339d1dcebb928d88c072592 Mon Sep 17 00:00:00 2001 From: york yao Date: Fri, 12 Aug 2016 20:40:18 +0800 Subject: [PATCH 58/80] add types of devtools-detect --- devtools-detect/devtools-detect-tests.ts | 12 ++++++++++++ devtools-detect/devtools-detect.d.ts | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 devtools-detect/devtools-detect-tests.ts create mode 100644 devtools-detect/devtools-detect.d.ts diff --git a/devtools-detect/devtools-detect-tests.ts b/devtools-detect/devtools-detect-tests.ts new file mode 100644 index 0000000000..9cd1d2f7a7 --- /dev/null +++ b/devtools-detect/devtools-detect-tests.ts @@ -0,0 +1,12 @@ +/// + +// check if it's open +console.log('is DevTools open?', window.devtools.open); +// check it's orientation, null if not open +console.log('and DevTools orientation?', window.devtools.orientation); + +// get notified when it's opened/closed or orientation changes +window.addEventListener('devtoolschange', function (e) { + console.log('is DevTools open?', e.detail.open); + console.log('and DevTools orientation?', e.detail.orientation); +}); diff --git a/devtools-detect/devtools-detect.d.ts b/devtools-detect/devtools-detect.d.ts new file mode 100644 index 0000000000..c66d63f0fa --- /dev/null +++ b/devtools-detect/devtools-detect.d.ts @@ -0,0 +1,16 @@ +// Type definitions for ajv +// Project: https://github.com/sindresorhus/devtools-detect +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type DevTools = { + open: boolean; + orientation: "vertical" | "horizontal"; +} +interface DevToolsEvent extends Event { + detail: DevTools; +} +interface Window { + devtools: DevTools; + addEventListener(type: "devtoolschange", listener: (ev: DevToolsEvent) => any, useCapture?: boolean): void; +} From 3728283b922d017408477dd35eb6a63b66f542b1 Mon Sep 17 00:00:00 2001 From: Maksym Butsykin Date: Fri, 12 Aug 2016 15:41:15 +0300 Subject: [PATCH 59/80] Add type definition for angular-es --- angular-es/angular-es.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-es/angular-es.d.ts b/angular-es/angular-es.d.ts index dbe1c7afdd..2ecf628655 100644 --- a/angular-es/angular-es.d.ts +++ b/angular-es/angular-es.d.ts @@ -169,7 +169,7 @@ declare module 'angular-es' { Factory, Filter, Inject, - InjectAsProperty + InjectAsProperty, Module, Provider, Run, From fcf8e2aedb578db684f6aa3831656d310f05b145 Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Fri, 12 Aug 2016 15:44:32 +0300 Subject: [PATCH 60/80] Fixed defs and tests --- domurl/domurl-tests.ts | 2 +- domurl/domurl.d.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/domurl/domurl-tests.ts b/domurl/domurl-tests.ts index fd4895ed5f..0b83b1c491 100644 --- a/domurl/domurl-tests.ts +++ b/domurl/domurl-tests.ts @@ -44,7 +44,7 @@ delete u.query.a; delete u.query["a"]; // If you need to remove all query string params: -alert(u.clearQuaery()); +alert(u.clearQuery()); // Lookup URL parts: alert( diff --git a/domurl/domurl.d.ts b/domurl/domurl.d.ts index f659ca1843..8c418c75cc 100644 --- a/domurl/domurl.d.ts +++ b/domurl/domurl.d.ts @@ -5,7 +5,7 @@ declare class QueryString { constructor(qs?: string); - toString(): string; + toString: () => string; } declare class Url { @@ -19,12 +19,12 @@ declare class Url { path: string; hash: string; href: string; - toString(): string; - encode(s: string): string; - decode(s: string): string; - isAbsolute(): boolean; - paths(paths?: [string]): [string]; - isEmptyQuery(): boolean; - queryLength(): number; - clearQuery(): Url; + toString: () => string; + encode: (s: string) => string; + decode: (s: string) => string; + isAbsolute: () => boolean; + paths: (paths?: [string]) => [string]; + isEmptyQuery: () => boolean; + queryLength: () => number; + clearQuery: () => Url; } From 81508371bd1173fb110086f1de433291e7cda3bb Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Fri, 12 Aug 2016 15:46:44 +0300 Subject: [PATCH 61/80] tests slightly improved --- domurl/domurl-tests.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/domurl/domurl-tests.ts b/domurl/domurl-tests.ts index 0b83b1c491..825dcdd7d0 100644 --- a/domurl/domurl-tests.ts +++ b/domurl/domurl-tests.ts @@ -20,9 +20,9 @@ var u2 = new Url("http://example.com/some/path?a=b&c=d#someAnchor"); var u3 = new Url("/my/site/doc/path?foo=bar#baz"); // get the value of some query string parameter -alert(u2.query.a); +console.log(u2.query.a); // or -alert(u3.query["foo"]); +console.log(u3.query["foo"]); // Manipulating query string parameters u.query.a = [1, 2, 3]; // adds/replaces in query string params a=1&a=2&a=3 @@ -44,10 +44,12 @@ delete u.query.a; delete u.query["a"]; // If you need to remove all query string params: -alert(u.clearQuery()); +console.log(u.clearQuery()); +console.log(u.queryLength()); +console.log(u.isEmptyQuery()); // Lookup URL parts: -alert( +console.log( 'protocol = ' + u.protocol + '\n' + 'user = ' + u.user + '\n' + 'pass = ' + u.pass + '\n' + From 98d68b5fa6592ac4307c48de24c7b21a79a88a63 Mon Sep 17 00:00:00 2001 From: Maksym Butsykin Date: Fri, 12 Aug 2016 15:53:02 +0300 Subject: [PATCH 62/80] Add type definition for angular-es --- angular-es/angular-es.d.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/angular-es/angular-es.d.ts b/angular-es/angular-es.d.ts index 2ecf628655..cce597eb1d 100644 --- a/angular-es/angular-es.d.ts +++ b/angular-es/angular-es.d.ts @@ -5,15 +5,23 @@ declare module 'angular-es' { + interface ClassDecorator { + (target: TFunction): TFunction|void; + } + + interface MethodDecorator { + (target: Object, propertyKey: string|symbol, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor|void; + } + /** * Decorated target */ - interface ngESDecorator { - target: Object|Function, - ngName?: string, - ngArguments?: Array, - ngType?: string, - injectAsProperty?: Array; + interface ngESDecorator extends ClassDecorator, MethodDecorator { + (target: Object|Function, + ngName?: string, + ngArguments?: Array, + ngType?: string, + injectAsProperty?: Array); } /** From e4d396d1b0192eb0777edd990de6ed9057c1ef51 Mon Sep 17 00:00:00 2001 From: Maksym Butsykin Date: Fri, 12 Aug 2016 16:01:44 +0300 Subject: [PATCH 63/80] Add type definition for angular-es --- angular-es/angular-es-tests.ts | 20 ++++++++++---------- angular-es/angular-es.d.ts | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/angular-es/angular-es-tests.ts b/angular-es/angular-es-tests.ts index 9565c3ef70..2e44d5d0a8 100644 --- a/angular-es/angular-es-tests.ts +++ b/angular-es/angular-es-tests.ts @@ -17,7 +17,7 @@ class MyComponentController { // import { Config } from 'angular-es'; -@Config +@Config() class MyConfig { } @@ -87,13 +87,13 @@ class MyFilter { import { Inject } from 'angular-es'; @Inject('fooBar') -class MyService { +class MyFooService { @Inject('bazBar') - myMethod(bazBar) { + myMethod(bazBar: Object) { } - constructor(fooBar) { + constructor(fooBar: Object) { } } @@ -103,8 +103,8 @@ class MyService { import { InjectAsProperty } from 'angular-es'; @InjectAsProperty('fooBar') -class MyService { - fooBar; +class MyFooBarService { + fooBar: Object; myMethod() { this.fooBar !== undefined; @@ -114,11 +114,11 @@ class MyService { // // @Module // -import { Module, Service } from 'angular-es'; +import { Module } from 'angular-es'; @Module('my.module') -@Service('MyService') -class MyService { +@Service('MyModuleService') +class MyModuleService { } // @@ -135,7 +135,7 @@ class MyProvider { // import { Run } from 'angular-es'; -@Run +@Run() class MyRunBlock { } diff --git a/angular-es/angular-es.d.ts b/angular-es/angular-es.d.ts index cce597eb1d..10979ae15c 100644 --- a/angular-es/angular-es.d.ts +++ b/angular-es/angular-es.d.ts @@ -21,7 +21,7 @@ declare module 'angular-es' { ngName?: string, ngArguments?: Array, ngType?: string, - injectAsProperty?: Array); + injectAsProperty?: Array): void; } /** From e8eed9cade9a0ce76fd99b66054af072f69d27a0 Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 15:52:38 +0200 Subject: [PATCH 64/80] #10342 Added hideNoData/showNoData to highcharts --- ...highcharts-modules-no-data-to-display.d.ts | 22 +++++++++++++++++++ highcharts/highcharts.d.ts | 17 -------------- 2 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 highcharts/highcharts-modules-no-data-to-display.d.ts diff --git a/highcharts/highcharts-modules-no-data-to-display.d.ts b/highcharts/highcharts-modules-no-data-to-display.d.ts new file mode 100644 index 0000000000..6b8ed03e15 --- /dev/null +++ b/highcharts/highcharts-modules-no-data-to-display.d.ts @@ -0,0 +1,22 @@ +/// +interface HighchartsChartObject { + /** + * Returns true if there are data points within the plot area now + * @return {boolean} If chart has any data. + * @since 3.0.8 + */ + hasData(): boolean; + + /** + * Hide the 'No data to display' message added by the no-data-to-display plugin. + * @since 3.0.8 + */ + hideNoData(): void; + + /** + * Display a no-data message. + * @param {String} message An optional message to show in place of the default one + * @since 3.0.8 + */ + showNoData(message?: string): void; +} diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index 451e3d248b..4ea165814f 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -5754,17 +5754,6 @@ interface HighchartsChartObject { * @since 1.2.0 */ hideLoading(): void; - /** - * Returns true if there are data points within the plot area now - * @return {boolean} If chart has any data. - * @since 3.0.8 - */ - hasData(): boolean; - /** - * Hide the 'No data to display' message added by the no-data-to-display plugin. - * @since 3.0.8 - */ - hideNoData(): void; /** * The options structure for the chart. * @since 1.2.0 @@ -5813,12 +5802,6 @@ interface HighchartsChartObject { * @since 2.1.0 */ setTitle(title: HighchartsTitleOptions, subtitle?: HighchartsSubtitleOptions, redraw?: boolean): void; - /** - * Display a no-data message. - * @param {String} message An optional message to show in place of the default one - * @since 3.0.8 - */ - showNoData(message?: string): void; /** * Dim the chart's plot area and show a loading label text. Options for the loading screen are defined at * options.loading. A custom text can be given as a parameter for loading. From bba9c487953d957dc3d4a5c3b9d32bd67c5716c6 Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 16:05:23 +0200 Subject: [PATCH 65/80] #10342 Added hideNoData/showNoData to highcharts --- .../highcharts-modules-no-data-to-display-tests.ts | 9 +++++++++ highcharts/highcharts-modules-no-data-to-display.d.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 highcharts/highcharts-modules-no-data-to-display-tests.ts diff --git a/highcharts/highcharts-modules-no-data-to-display-tests.ts b/highcharts/highcharts-modules-no-data-to-display-tests.ts new file mode 100644 index 0000000000..9b1d69b8da --- /dev/null +++ b/highcharts/highcharts-modules-no-data-to-display-tests.ts @@ -0,0 +1,9 @@ +/// +/// + +function test_NoDataToDisplay() { + var chart = $("#container").highcharts(); + var chartHasData = chart.hasData(); + chart.hideNoData(); + chart.showNoData("Custom no data message"); +} diff --git a/highcharts/highcharts-modules-no-data-to-display.d.ts b/highcharts/highcharts-modules-no-data-to-display.d.ts index 6b8ed03e15..c1429efe78 100644 --- a/highcharts/highcharts-modules-no-data-to-display.d.ts +++ b/highcharts/highcharts-modules-no-data-to-display.d.ts @@ -1,4 +1,4 @@ -/// +// interface HighchartsChartObject { /** * Returns true if there are data points within the plot area now From 6dcc2fe492f45659b4b7d5bda73530c982715c38 Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 16:07:23 +0200 Subject: [PATCH 66/80] #10342 Added hideNoData/showNoData to highcharts --- highcharts/highcharts-modules-no-data-to-display.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/highcharts/highcharts-modules-no-data-to-display.d.ts b/highcharts/highcharts-modules-no-data-to-display.d.ts index c1429efe78..120acede4c 100644 --- a/highcharts/highcharts-modules-no-data-to-display.d.ts +++ b/highcharts/highcharts-modules-no-data-to-display.d.ts @@ -1,3 +1,7 @@ +// Type definitions for Highcharts No Data to Display +// Project: http://www.highcharts.com/ +// Definitions by: Andrey Zolotin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // interface HighchartsChartObject { /** From 1234549417e07d3fb1dbb6a269bd2c2e3ff83bb6 Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 16:11:16 +0200 Subject: [PATCH 67/80] #10342 Added hideNoData/showNoData to highcharts --- highcharts/highcharts-modules-no-data-to-display.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highcharts/highcharts-modules-no-data-to-display.d.ts b/highcharts/highcharts-modules-no-data-to-display.d.ts index 120acede4c..d1910675cd 100644 --- a/highcharts/highcharts-modules-no-data-to-display.d.ts +++ b/highcharts/highcharts-modules-no-data-to-display.d.ts @@ -2,7 +2,7 @@ // Project: http://www.highcharts.com/ // Definitions by: Andrey Zolotin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// +// interface HighchartsChartObject { /** * Returns true if there are data points within the plot area now From 7fe81784e0d55f8d8080c7fbb75cfdbb4af6e161 Mon Sep 17 00:00:00 2001 From: Roman Reshetnikov Date: Fri, 12 Aug 2016 17:26:20 +0300 Subject: [PATCH 68/80] DevExpress ASP.NET 16.1.5 --- devexpress-web/devexpress-web.d.ts | 847 +++++++++++++++++++---------- 1 file changed, 549 insertions(+), 298 deletions(-) diff --git a/devexpress-web/devexpress-web.d.ts b/devexpress-web/devexpress-web.d.ts index 6671a45ec4..c2e0014f85 100644 --- a/devexpress-web/devexpress-web.d.ts +++ b/devexpress-web/devexpress-web.d.ts @@ -250,6 +250,9 @@ interface ASPxClientDashboardItemWidgetCreatedEventHandler { */ (source: S, e: ASPxClientDashboardItemWidgetEventArgs): void; } +/** + * References a method that will handle the ItemWidgetUpdating event. + */ interface ASPxClientDashboardItemWidgetUpdatingEventHandler { /** * References a method that will handle the ItemWidgetUpdating event. @@ -258,6 +261,9 @@ interface ASPxClientDashboardItemWidgetUpdatingEventHandler { */ (source: S, e: ASPxClientDashboardItemWidgetEventArgs): void; } +/** + * References a method that will handle the ItemWidgetUpdated event. + */ interface ASPxClientDashboardItemWidgetUpdatedEventHandler { /** * References a method that will handle the ItemWidgetUpdated event. @@ -616,6 +622,11 @@ interface ASPxClientDashboardDesigner extends ASPxClientControl { * Occurs after a dashboard displayed in the ASPxClientDashboardDesigner is changed. */ DashboardChanged: ASPxClientEvent>; + /** + * For internal use. + */ + CustomizeMenuItems: ASPxClientEvent>; + BeforeRender: ASPxClientEvent>; /** * Switches the ASPxClientDashboardDesigner to the viewer mode. */ @@ -650,6 +661,9 @@ interface ASPxClientDashboardDesigner extends ASPxClientControl { */ SaveDashboard(): void; } +/** + * References a method that will handle the DashboardStateChanged event. + */ interface ASPxClientDashboardStateChangedEventHandler { /** * References a method that will handle the DashboardStateChanged event. @@ -668,6 +682,9 @@ interface ASPxClientDashboardStateChangedEventArgs extends ASPxClientEventArgs { */ DashboardState: string; } +/** + * References a method that will handle the DashboardChanged event. + */ interface ASPxClientDashboardChangedEventHandler { /** * References a method that will handle the DashboardChanged event. @@ -691,6 +708,26 @@ interface ASPxClientDashboardChangedEventArgs extends ASPxClientEventArgs { */ DashboardName: string; } +interface ASPxClientDashboardDesignerCustomizeMenuItemsEventHandler { + (source: S, e: ASPxClientDashboardDesignerCustomizeMenuItemsEventArgs): void; +} +interface ASPxClientDashboardDesignerMenuItem { + id: string; + title: string; + template: string; + selected: boolean; + disabled: boolean; + hasSeparator: boolean; + click: Function; + hotKey: number; +} +interface ASPxClientDashboardDesignerCustomizeMenuItemsEventArgs extends ASPxClientEventArgs { + Items: ASPxClientDashboardDesignerMenuItem[]; + FindById(itemId: string): ASPxClientDashboardDesignerMenuItem; +} +interface ASPxClientDashboardDesignerBeforeRenderEventHandler { + (source: S, e: ASPxClientEventArgs): void; +} /** * A client-side equivalent of the ASPxDashboardViewer control. */ @@ -1332,6 +1369,9 @@ interface ASPxClientDashboardActionAvailabilityChangedEventArgs extends ASPxClie */ ItemActions: ASPxClientDashboardItemAction[]; } +/** + * References a method that will handle the DataLoadingError event. + */ interface ASPxClientDashboardDataLoadingErrorEventHandler { /** * References a method that will handle the DataLoadingError event. @@ -1630,11 +1670,11 @@ interface ASPxClientBinaryImage extends ASPxClientEdit { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param parameter A string value that contains any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * Represents the client-side equivalent of the ASPxButton control. @@ -2482,8 +2522,8 @@ interface ASPxClientListEdit extends ASPxClientEdit { */ interface ASPxClientListEditItem { /** - * Gets a value that indicates whether a list box item is selected. - * Value: true if a list box item is selected; otherwise, false. + * Gets a value that indicates whether a list edit item is selected. + * Value: true if a list edit item is selected; otherwise, false. */ selected: boolean; /** @@ -3367,11 +3407,11 @@ interface ASPxClientGaugeControl extends ASPxClientControl { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * Represents the client ASPxGridView. @@ -6159,7 +6199,7 @@ interface ASPxClientVerticalGrid extends ASPxClientGridBase { */ RowSorting: ASPxClientEvent>; /** - * Fires on the client side before the expansion state of a row is changed via end-user interaction. + * Fires on the client side before the expansion state of a row is changed by end-user interaction. */ RowExpandedChanging: ASPxClientEvent>; /** @@ -7406,6 +7446,27 @@ interface ASPxClientHtmlEditorInsertYouTubeVideoCommandArguments extends ASPxCli */ interface ASPxClientHtmlEditorChangeYouTubeVideoCommandArguments extends ASPxClientHtmlEditorInsertYouTubeVideoCommandArguments { } +/** + * A method that will handle the DialogInitialized client event. + */ +interface ASPxClientHtmlEditorDialogInitializedEventHandler { + /** + * A method that will handle the client DialogInitialized event. + * @param source An object representing the event's source. + * @param e An ASPxClientHtmlEditorDialogInitializedEventArgs object that contains event data. + */ + (source: S, e: ASPxClientHtmlEditorDialogInitializedEventArgs): void; +} +/** + * Provides data for the DialogInitialized client event. + */ +interface ASPxClientHtmlEditorDialogInitializedEventArgs extends ASPxClientEventArgs { + /** + * Gets the name of the dialog that has been initialized. + * Value: A string value that is the name of the initialized dialog. + */ + dialogName: string; +} /** * A method that will handle the CommandExecuting event. */ @@ -7634,6 +7695,10 @@ interface ASPxClientHtmlEditorBeforePasteEventArgs extends ASPxClientEventArgs { * Represents a client-side equivalent of the ASPxHtmlEditor control. */ interface ASPxClientHtmlEditor extends ASPxClientControl { + /** + * Occurs on the client side after a dialog has been initialized. + */ + DialogInitialized: ASPxClientEvent>; /** * Occurs before a default or custom command has been executed and allows you to cancel the action. */ @@ -7797,7 +7862,7 @@ interface ASPxClientHtmlEditor extends ASPxClientControl { */ SetToolbarDropDownItemPickerValue(commandName: string, value: string): void; /** - * Specifies the visibility of a ribbon context tab ?ategory specified by its name. + * Specifies the visibility of a ribbon context tab category specified by its name. * @param categoryName A Name property value of the required category. * @param active true to make a category visible; false to make it hidden. */ @@ -7958,11 +8023,11 @@ interface ASPxClientPivotGrid extends ASPxClientControl { */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; } /** * A method that will handle the CellDblClick event. @@ -8239,11 +8304,11 @@ interface ASPxClientRichEdit extends ASPxClientControl { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; /** * Indicates whether any unsaved changes are contained in the current document. */ @@ -9122,11 +9187,7 @@ interface RichEditCommands { * Value: A object that provides methods for executing the command and checking its state. */ toggleTableCellBottomBorder: ToggleTableCellBottomBorderCommand; - /** - * Gets a command to toggle left borders for selected cells on/off. - * Value: A object that provides methods for executing the command and checking its state. - */ - toggleTableCellsLeftBorder: ToggleTableCellsLeftBorderCommand; + toggleTableCellLeftBorder: ToggleTableCellLeftBorderCommand; /** * Gets a command to remove the borders of the selected table cells. * Value: A object that provides methods for executing the command and checking its state. @@ -9202,6 +9263,7 @@ interface RichEditCommands { * Value: A object that provides methods for executing the command and checking its state. */ replaceNext: ReplaceNextCommand; + openSpellingDialog: OpenSpellingDialogCommand; } /** * Serves as a base for objects that implement different client command functionalities. @@ -10814,10 +10876,10 @@ interface OpenPageMarginsDialogCommand extends CommandWithSimpleStateBase { */ interface ChangePageOrientationCommand extends CommandBase { /** - * Executes the ChangePageOrientationCommand command by applying the specified setting. May result in taking no action if the command's state does not allow command execution. Use the object's getState method to check the command state. - * @param isPortrait true to apply portrait page orientation, false to apply landscape page orientation. + * + * @param isPortrait */ - execute(isPortrait: boolean): boolean; + execute(isPortrait: any): boolean; /** * Gets information about the command state. */ @@ -11428,6 +11490,9 @@ declare enum ParagraphFirstLineIndent { Indented=1, Hanging=2 } +interface OpenSpellingDialogCommand extends CommandWithSimpleStateBase { + execute(): boolean; +} /** * A command to invoke the Insert Table dialog. */ @@ -11519,7 +11584,7 @@ interface ChangeTableColumnPreferredWidthCommand extends CommandBase { interface ChangeTableCellFormattingCommand extends CommandBase { /** * Executes the ChangeTableCellFormattingCommand command by applying the specified setting. May result in taking no action if the command's state does not allow command execution. Use the object's getState method to check the command state. - * @param settings A TableFormattingSettings object specifying ?ell formatting of the selected table elements. + * @param settings A TableFormattingSettings object specifying cell formatting of the selected table elements. */ execute(settings: TableCellFormattingSettings): boolean; /** @@ -11656,7 +11721,7 @@ interface SplitTableCellsDialogCommand extends CommandWithSimpleStateBase { /** * A command to split the selected table cells based on the specified options. */ -interface SplitTableCellsCommand extends CommandBase { +interface SplitTableCellsCommand extends CommandWithSimpleStateBase { /** * Executes the SplitTableCellsCommand command by applying the specified settings. May result in taking no action if the command's state does not allow command execution. Use the object's getState method to check the command state. * @param rowCount An integer value specifying number of rows in the splitted table cells. @@ -11664,10 +11729,6 @@ interface SplitTableCellsCommand extends CommandBase { * @param mergeBeforeSplit true to merge the selected cells before splitting; otherwise, false. */ execute(rowCount: number, columnCount: number, mergeBeforeSplit: boolean): boolean; - /** - * Gets information about the command state. - */ - getState(): SimpleCommandState; } /** * A command to insert table cells with a vertical shift into the selected table. @@ -11829,13 +11890,7 @@ interface ToggleTableCellBottomBorderCommand extends CommandWithBooleanStateBase */ execute(): boolean; } -/** - * A command to toggle left borders for selected cells on/off. - */ -interface ToggleTableCellsLeftBorderCommand extends CommandWithBooleanStateBase { - /** - * Executes the ToggleTableCellsLeftBorderCommand command by imitating the corresponding end-user action made in the RichEdit's UI. May result in taking no action if the command's state does not allow command execution. Use the object's getState method to check the command state. - */ +interface ToggleTableCellLeftBorderCommand extends CommandWithBooleanStateBase { execute(): boolean; } /** @@ -12202,10 +12257,6 @@ interface TableHeightUnit { * Value: An integer value specifying the table height. */ value: number; - /** - * Gets or sets the unit type for the table height. - * Value: One of the values. - */ type: any; } declare enum TableHeightUnitType { @@ -12816,18 +12867,42 @@ interface ASPxClientAppointment { * A client point object. */ interface ASPxClientPoint { + /** + * Gets the point's X-coordinate. + */ GetX(): number; + /** + * Gets the point's Y-coordinate. + */ GetY(): number; } /** * A client rectangle object. */ interface ASPxClientRect { + /** + * Gets the X-coordinate of the rectangle's left edge. + */ GetLeft(): number; + /** + * Gets the X-coordinate of the rectangle's right edge. + */ GetRight(): number; + /** + * Gets the Y-coordinate of the rectangle's top edge. + */ GetTop(): number; + /** + * Gets the Y-coordinate of the rectangle's bottom edge. + */ GetBottom(): number; + /** + * Gets the rectangle's width. + */ GetWidth(): number; + /** + * Gets the rectangle's height. + */ GetHeight(): number; } /** @@ -13078,10 +13153,13 @@ interface ASPxClientWeekOfMonth { * Represents a client-side equivalent of the WeekDaysCheckEdit control. */ interface ASPxClientWeekDaysCheckEdit extends ASPxClientControl { + /** + * Gets the selection state of the week day check boxes. + */ GetValue(): ASPxClientWeekDays; /** - * - * @param value + * Gets the selection state of the week day check boxes. + * @param value An ASPxClientWeekDays object specifying the selection state of the week day check boxes. */ SetValue(value: ASPxClientWeekDays): void; } @@ -13089,22 +13167,31 @@ interface ASPxClientWeekDaysCheckEdit extends ASPxClientControl { * Represents a client-side equivalent of the RecurrenceRangeControl. */ interface ASPxClientRecurrenceRangeControl extends ASPxClientControl { + /** + * Gets the type of the recurrence range. + */ GetRange(): ASPxClientRecurrenceRange; + /** + * Gets how many times the appointment occurs. + */ GetOccurrenceCount(): number; + /** + * Gets the recurrence end date. + */ GetEndDate(): Date; /** - * - * @param range + * Sets the type of the recurrence range. + * @param range An ASPxClientRecurrenceRangeenumeration value that specifies the recurrence range type. */ SetRange(range: ASPxClientRecurrenceRange): void; /** - * - * @param occurrenceCount + * Sets how many times the appointment occurs. + * @param occurrenceCount An integer value that specifies how many times the appointment occurs. */ SetOccurrenceCount(occurrenceCount: number): void; /** - * - * @param date + * Sets the recurrence end date. + * @param date A JavaScript Date object that specifies the end date for the recurrence. */ SetEndDate(date: Date): void; } @@ -13112,10 +13199,13 @@ interface ASPxClientRecurrenceRangeControl extends ASPxClientControl { * A base for client equivalents of recurrence controls available in the XtraScheduler library. */ interface ASPxClientRecurrenceControlBase extends ASPxClientControl { + /** + * Returns an object providing access to the ASPxClientRecurrenceControlBase control's editor values. + */ CreateValueAccessor(): DefaultRecurrenceRuleValuesAccessor; /** - * - * @param recurrenceInfo + * Updates values of editors displayed by the ASPxClientRecurrenceControlBase control. + * @param recurrenceInfo An ASPxClientRecurrenceInfo object containing new editor values. */ Update(recurrenceInfo: ASPxClientRecurrenceInfo): void; } @@ -13123,10 +13213,13 @@ interface ASPxClientRecurrenceControlBase extends ASPxClientControl { * Represents a client-side equivalent of the DailyRecurrenceControl - a control for specifying the daily recurrence. */ interface ASPxClientDailyRecurrenceControl extends ASPxClientRecurrenceControlBase { + /** + * Returns an object providing access to the ASPxClientDailyRecurrenceControl's editor values. + */ CreateValueAccessor(): DefaultRecurrenceRuleValuesAccessor; /** - * - * @param recurrenceInfo + * Updates values of editors displayed by the ASPxClientDailyRecurrenceControl. + * @param recurrenceInfo An ASPxClientRecurrenceInfo object containing new editor values. */ Update(recurrenceInfo: ASPxClientRecurrenceInfo): void; } @@ -13134,10 +13227,13 @@ interface ASPxClientDailyRecurrenceControl extends ASPxClientRecurrenceControlBa * Represents a client-side equivalent of the WeeklyRecurrenceControl. */ interface ASPxClientWeeklyRecurrenceControl extends ASPxClientRecurrenceControlBase { + /** + * Returns an object providing access to the ASPxClientWeeklyRecurrenceControl's editor values. + */ CreateValueAccessor(): DefaultRecurrenceRuleValuesAccessor; /** - * - * @param recurrenceInfo + * Updates values of editors displayed by the ASPxClientWeeklyRecurrenceControl. + * @param recurrenceInfo An ASPxClientRecurrenceInfo object containing new editor values. */ Update(recurrenceInfo: ASPxClientRecurrenceInfo): void; } @@ -13145,10 +13241,13 @@ interface ASPxClientWeeklyRecurrenceControl extends ASPxClientRecurrenceControlB * Represents a client-side equivalent of the MonthlyRecurrenceControl. */ interface ASPxClientMonthlyRecurrenceControl extends ASPxClientRecurrenceControlBase { + /** + * Returns an object providing access to the ASPxClientMonthlyRecurrenceControl's editor values. + */ CreateValueAccessor(): DefaultRecurrenceRuleValuesAccessor; /** - * - * @param recurrenceInfo + * Updates values of editors displayed by the ASPxClientMonthlyRecurrenceControll. + * @param recurrenceInfo An ASPxClientRecurrenceInfo object containing new editor values. */ Update(recurrenceInfo: ASPxClientRecurrenceInfo): void; } @@ -13156,55 +13255,139 @@ interface ASPxClientMonthlyRecurrenceControl extends ASPxClientRecurrenceControl * Represents a client-side equivalent of the YearlyRecurrenceControl. */ interface ASPxClientYearlyRecurrenceControl extends ASPxClientRecurrenceControlBase { + /** + * Returns an object providing access to the ASPxClientYearlyRecurrenceControl's editor values. + */ CreateValueAccessor(): DefaultRecurrenceRuleValuesAccessor; /** - * - * @param recurrenceInfo + * Updates values of editors displayed by the ASPxClientYearlyRecurrenceControl. + * @param recurrenceInfo An ASPxClientRecurrenceInfo object containing new editor values. */ Update(recurrenceInfo: ASPxClientRecurrenceInfo): void; } +/** + * An object providing access to an ASPxClientRecurrenceControlBase control's editor values. + */ interface DefaultRecurrenceRuleValuesAccessor { + /** + * Get the frequency with which the appointment occurs with respect to the appointment's recurrence type. + */ GetPeriodicity(): number; + /** + * Gets the number of the month's day in which the appointment is scheduled. + */ GetDayNumber(): number; + /** + * Gets or sets the month's number. + */ GetMonth(): number; + /** + * Gets the days of the week to which a weekly recurrent appointment is scheduled. + */ GetWeekDays(): ASPxClientWeekDays; + /** + * Gets the number of the week in a month when an appointment is scheduled. + */ GetWeekOfMonth(): ASPxClientWeekOfMonth; } +/** + * An object providing access to an ASPxClientDailyRecurrenceControl's editor values. + */ interface DailyRecurrenceValuesAccessor extends DefaultRecurrenceRuleValuesAccessor { + /** + * Gets the number of days between appointment occurrences. + */ GetPeriodicity(): number; + /** + * Gets the days of the week to which a daily recurrent appointment is scheduled. + */ GetWeekDays(): ASPxClientWeekDays; } +/** + * An object providing access to an ASPxClientWeeklyRecurrenceControl's editor values. + */ interface WeeklyRecurrenceValuesAccessor extends DefaultRecurrenceRuleValuesAccessor { + /** + * Gets the number of weeks between appointment occurrences. + */ GetPeriodicity(): number; + /** + * Gets the days of the week to which a weekly recurrent appointment is scheduled. + */ GetWeekDays(): ASPxClientWeekDays; } +/** + * An object providing access to an ASPxClientMonthlyRecurrenceControl's editor values. + */ interface MonthlyRecurrenceValuesAccessor extends DefaultRecurrenceRuleValuesAccessor { + /** + * Gets the number of the month's day in which the appointment is scheduled. + */ GetDayNumber(): number; + /** + * Gets the number of months between appointment occurrences. + */ GetPeriodicity(): number; + /** + * Gets the days of the week to which a monthly recurrent appointment is scheduled. + */ GetWeekDays(): ASPxClientWeekDays; + /** + * Gets the number of the week in a month when an appointment is scheduled. + */ GetWeekOfMonth(): ASPxClientWeekOfMonth; } +/** + * An object providing access to an ASPxClientYearlyRecurrenceControl's editor values. + */ interface YearlyRecurrenceValuesAccessor extends DefaultRecurrenceRuleValuesAccessor { + /** + * Gets the number of the month's day in which the appointment is scheduled. + */ GetDayNumber(): number; + /** + * Gets or sets the month's number. + */ GetMonth(): number; + /** + * Gets the days of the week to which a yearly recurrent appointment is scheduled. + */ GetWeekDays(): ASPxClientWeekDays; + /** + * Gets or sets the number of a week in a month when an appointment is scheduled. + */ GetWeekOfMonth(): ASPxClientWeekOfMonth; } +/** + * Provides base functionality for ASPxClientScheduler's forms. + */ interface ASPxClientFormBase { + /** + * Occurs when the form has been closed. + */ FormClosed: ASPxClientEvent>; + /** + * Closes the form. + */ Close(): void; /** - * - * @param element - * @param isVisible + * Sets the visibility state of the specified form element. + * @param element An object specifying the element whose visibility state should be changed. + * @param isVisible true to display the element; false to hide the element. */ SetVisibleCore(element: Object, isVisible: boolean): void; } +/** + * Represents a client-side equivalent of the RecurrenceTypeEdit. + */ interface ASPxClientRecurrenceTypeEdit extends ASPxClientRadioButtonList { + /** + * Gets the selected recurrence type. + */ GetRecurrenceType(): ASPxClientRecurrenceType; /** - * - * @param recurrenceType + * Sets the selected recurrence type. + * @param recurrenceType An ASPxClientRecurrenceType enumeration value. */ SetRecurrenceType(recurrenceType: ASPxClientRecurrenceType): void; } @@ -13227,10 +13410,13 @@ interface AppointmentPropertyNames { * Represents the client-side equivalent of the TimeInterval class. */ interface ASPxClientTimeInterval { + /** + * Gets a value indicating if the time interval is All-Day. + */ GetAllDay(): boolean; /** - * - * @param allDayValue + * Sets a value specifying if the time interval is All-Day. + * @param allDayValue true, if this is an all-day time interval; otherwise, false. */ SetAllDay(allDayValue: boolean): void; /** @@ -13908,23 +14094,44 @@ interface ASPxClientAppointmentResizeEventArgs extends ASPxClientEventArgs { */ operation: ASPxClientAppointmentOperation; } +/** + * Contains information about a client tooltip. + */ interface ASPxClientSchedulerToolTipData { + /** + * Returns the client appointment for which the tooltip is displayed. + */ GetAppointment(): ASPxClientAppointment; + /** + * Returns the client time interval for which the tooltip is displayed. + */ GetInterval(): ASPxClientTimeInterval; + /** + * Returns the resources associated with the appointment for which the tooltip is displayed. + */ GetResources(): Object[]; } +/** + * A client-side equivalent of the ASPxSchedulerToolTipBase control. + */ interface ASPxClientToolTipBase { + /** + * Returns the value that indicates whether or not the tooltip can be displayed. + */ CanShowToolTip(): boolean; /** - * - * @param toolTipData + * Ends updating the tooltip content. + * @param toolTipData An ASPxClientSchedulerToolTipData object providing data required to update the tooltip content. */ FinalizeUpdate(toolTipData: ASPxClientSchedulerToolTipData): void; /** - * - * @param toolTipData + * Updates the tooltip content. + * @param toolTipData An ASPxClientSchedulerToolTipData object providing data required to update the tooltip content. */ Update(toolTipData: ASPxClientSchedulerToolTipData): void; + /** + * Closes the tooltip. + */ Close(): void; /** * @@ -13932,18 +14139,18 @@ interface ASPxClientToolTipBase { */ CalculatePosition(bounds: Object): ASPxClientPoint; /** - * - * @param eventObject + * Displays the Appointment Menu in the position of the tooltip. + * @param eventObject An object containing information about the event on which the menu is displayed. */ ShowAppointmentMenu(eventObject: Object): void; /** - * - * @param eventObject + * Displays the View Menu in the position of the tooltip. + * @param eventObject An object containing information about the event on which the menu is displayed. */ ShowViewMenu(eventObject: Object): void; /** - * - * @param interval + * Returns the string representation of the specified interval. + * @param interval An ASPxClientTimeInterval object to convert. */ ConvertIntervalToString(interval: ASPxClientTimeInterval): string; } @@ -14222,11 +14429,11 @@ interface ASPxClientSpreadsheet extends ASPxClientControl { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side DocumentCallback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side DocumentCallback event. @@ -14373,6 +14580,7 @@ interface ASPxClientTreeList extends ASPxClientControl { * Sets input focus to the ASPxTreeList. */ Focus(): void; + GetPopupEditForm(): ASPxClientPopupControl; /** * Returns the focused node's key value. */ @@ -14430,11 +14638,11 @@ interface ASPxClientTreeList extends ASPxClientControl { */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side CustomDataCallback event passing it the specified argument. * @param arg A string value that represents any information that needs to be sent to the server-side CustomDataCallback event. @@ -15011,22 +15219,22 @@ interface MVCxClientCallbackPanel extends ASPxClientCallbackPanel { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the Callback Panel by processing the passed information on the server, in an Action specified by the Callback Panel's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the CardView extension. @@ -15042,11 +15250,11 @@ interface MVCxClientCardView extends ASPxClientCardView { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the CardView by processing the passed information on the server, in an Action specified via the CardView's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CardView's CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback with a parameter to process the passed information on the server, in an Action specified via the CardView's CustomDataActionRouteValues property, and then process the returned result in the specified client function. This method does not update the CardView. * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomDataActionRouteValues property. @@ -15079,22 +15287,22 @@ interface MVCxClientChart extends ASPxClientWebChartControl { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update a Chart by processing the passed information on the server, in an Action specified via the Chart's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side event, passing it the specified argument. * @param args A string value that represents any information that needs to be sent to the server-side event. */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the ComboBox and ComboBoxFor extensions. @@ -15110,11 +15318,11 @@ interface MVCxClientComboBox extends ASPxClientComboBox { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the ComboBox by processing the passed information on the server, in an Action specified by the ComboBox's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. @@ -15135,22 +15343,22 @@ interface MVCxClientDataView extends ASPxClientDataView { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the DataView by processing the passed information on the server, in an Action specified via the DataView's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side CustomCallback event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the DateEdit extension. @@ -15167,22 +15375,22 @@ interface MVCxClientDockManager extends ASPxClientDockManager { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the DockManager by processing the passed information on the server, in an Action specified by the DockManager's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that contains any information that needs to be sent to the server-side Callback event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that contains any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the DockPanel extension. @@ -15198,11 +15406,11 @@ interface MVCxClientDockPanel extends ASPxClientDockPanel { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the DockPanel by processing the passed information on the server, in an Action specified by the DockPanel's DockPanelSettings.CallbackRouteValues) property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side WindowCallback event, passing the specified argument to it. * @param parameter A string value that is any information that needs to be sent to the server-side WindowCallback event. @@ -15223,22 +15431,22 @@ interface MVCxClientFileManager extends ASPxClientFileManager { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the FileManager by processing the passed information on the server, in an Action specified via the extension's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the file manager's CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. * @param args A string value that specifies any information that needs to be sent to the server-side CustomCallback event. */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that specifies any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the GridView extension. @@ -15254,11 +15462,11 @@ interface MVCxClientGridView extends ASPxClientGridView { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the GridView by processing the passed information on the server, in an Action specified via the grid's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the grid's CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback with a parameter to process the passed information on the server, in an Action specified via the GridView's CustomDataActionRouteValues property, and then process the returned result in the specified client function. This method does not update the GridView. * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomDataActionRouteValues property. @@ -15317,22 +15525,22 @@ interface MVCxClientImageGallery extends ASPxClientImageGallery { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the ImageGallery by processing the passed information on the server, in an Action specified via the ImageGallery's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side CustomCallback event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the ListBox and ListBoxFor extensions. @@ -15348,11 +15556,11 @@ interface MVCxClientListBox extends ASPxClientListBox { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the ListBox by processing the passed information on the server, in an Action specified by the ListBox's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server, and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. @@ -15382,11 +15590,11 @@ interface MVCxClientPivotGrid extends ASPxClientPivotGrid { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the PivotGrid by processing the passed information on the server, in an Action specified via the grid's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the grid's CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Passes PivotGrid callback parameters to the specified object. * @param obj An object that receives PivotGrid callback parameters. @@ -15398,11 +15606,11 @@ interface MVCxClientPivotGrid extends ASPxClientPivotGrid { */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the PopupControl extension. @@ -15418,11 +15626,11 @@ interface MVCxClientPopupControl extends ASPxClientPopupControl { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the PopupControl by processing the passed information on the server, in an Action specified via the PopupControl's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback with a parameters to update the popup window by processing the related popup window and the passed information on the server, in an Action specified by the PopupControl's CallbackRouteValues property. * @param window A ASPxClientPopupWindow object identifying the processed popup window. @@ -15436,12 +15644,12 @@ interface MVCxClientPopupControl extends ASPxClientPopupControl { */ PerformWindowCallback(window: ASPxClientPopupWindow, parameter: string): void; /** - * Sends a callback to the server and generates the server-side WindowCallback event, passing it the related popup window object and the specified argument. - * @param window An ASPxClientPopupWindow object identifying the processed popup window. - * @param parameter A string value specifying any information that needs to be sent to the server-side WindowCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param window + * @param parameter + * @param onSuccess */ - PerformWindowCallback(window: ASPxClientPopupWindow, parameter: string, onSuccess: Function): void; + PerformWindowCallback(window: ASPxClientPopupWindow, parameter: string, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side WindowCallback event, passing the specified argument to it. * @param parameter A string value that is any information that needs to be sent to the server-side WindowCallback event. @@ -15513,22 +15721,22 @@ interface MVCxClientReportDesigner extends ASPxClientReportDesigner { */ PerformCallback(arg: Object): void; /** - * Sends a callback to the server with the specified argument. - * @param arg A Object value, specifying the callback argument. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param arg + * @param onSuccess */ - PerformCallback(arg: Object, onSuccess: Function): void; + PerformCallback(arg: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server with the specified argument. * @param arg A String value, specifying the callback argument. */ PerformCallback(arg: string): void; /** - * Sends a callback to the server with the specified argument. - * @param arg A String value, specifying the callback argument. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param arg + * @param onSuccess */ - PerformCallback(arg: string, onSuccess: Function): void; + PerformCallback(arg: string, onSuccess: (arg1: string) => void): void; } /** * A method that will handle the SaveCommandExecuted event. @@ -15565,22 +15773,22 @@ interface MVCxClientRichEdit extends ASPxClientRichEdit { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the RichEdit by processing the passed information on the server, in an Action specified via the CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the RoundPanel extension. @@ -15596,22 +15804,22 @@ interface MVCxClientRoundPanel extends ASPxClientRoundPanel { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the Round Panel by processing the passed information on the server, in an Action specified by the Round Panel's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side ContentCallback event, passing it the specified argument. * @param parameter A string value that is any information that needs to be sent to the server-side ContentCallback event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side ContentCallback event, passing it the specified argument. - * @param parameter A string value that is any information that needs to be sent to the server-side ContentCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the Scheduler extension. @@ -15628,11 +15836,11 @@ interface MVCxClientScheduler extends ASPxClientScheduler { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the Scheduler by processing the passed information on the server, in an Action specified via the Scheduler's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument * @param parameter A string value that represents any information that needs to be sent to the server-side CustomCallback event. @@ -15682,22 +15890,22 @@ interface MVCxClientSpreadsheet extends ASPxClientSpreadsheet { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the Spreadsheet by processing the passed information on the server, in an Action specified via the CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the PageControl extension. @@ -15713,22 +15921,22 @@ interface MVCxClientPageControl extends ASPxClientPageControl { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the PageControl by processing the passed information on the server, in an Action specified by the PageControl's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A client-side counterpart of the TokenBox and TokenBoxFor extensions. @@ -15744,11 +15952,11 @@ interface MVCxClientTokenBox extends ASPxClientTokenBox { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the TokenBox by processing the passed information on the server, in an Action specified by the TokenBox's CallbackRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified by the CallbackRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. @@ -15769,11 +15977,11 @@ interface MVCxClientTreeList extends ASPxClientTreeList { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the TreeList by processing the passed information on the server, in an Action specified via the TreeList's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback with a parameter to process the passed information on the server, in an Action specified via the TreeList's CustomDataCallback event. This method does not update the TreeList. * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomDataActionRouteValues property. @@ -15785,11 +15993,11 @@ interface MVCxClientTreeList extends ASPxClientTreeList { */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; /** * Sends a callback to the server and generates the server-side CustomDataCallback event passing it the specified argument. * @param arg A string value that represents any information that needs to be sent to the server-side CustomDataCallback event. @@ -15887,11 +16095,11 @@ interface MVCxClientVerticalGrid extends ASPxClientVerticalGrid { */ PerformCallback(data: Object): void; /** - * Sends a callback with a parameter to update the VerticalGrid by processing the passed information on the server in an Action specified via the grid's CustomActionRouteValues property. - * @param data An object containing any information that needs to be passed to a handling Action specified via the grid's CustomActionRouteValues property. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param data + * @param onSuccess */ - PerformCallback(data: Object, onSuccess: Function): void; + PerformCallback(data: Object, onSuccess: (arg1: string) => void): void; /** * Sends a callback with a parameter to process the passed information on the server, in an Action specified via the VerticalGrid's CustomDataActionRouteValues property, and then process the returned result in the specified client function. This method does not update the VerticalGrid. * @param data An object containing any information that needs to be passed to a handling Action specified via the CustomDataActionRouteValues property. @@ -16013,11 +16221,11 @@ interface ASPxClientCallback extends ASPxClientControl { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A method that will handle the client events related to completion of callback server-side processing. @@ -16072,11 +16280,11 @@ interface ASPxClientCallbackPanel extends ASPxClientControl { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; /** * Returns the text displayed within the control's loading panel. */ @@ -16460,6 +16668,12 @@ interface ASPxClientControlsInitializedEventArgs extends ASPxClientEventArgs { */ isCallback: boolean; } +interface ASPxClientControlPredicate { + (control: Object): boolean; +} +interface ASPxClientControlAction { + (control: Object): void; +} /** * A collection object used on the client side to maintain particular client control objects */ @@ -16498,6 +16712,21 @@ interface ASPxClientControlCollection { * @param name A string value that is the hierarchically-qualified identifier of the required DevExpress control. */ GetByName(name: string): Object; + /** + * + * @param predicate + */ + GetControlsByPredicate(predicate: ASPxClientControlPredicate): Object[]; + /** + * + * @param type + */ + GetControlsByType(type: Object): Object[]; + /** + * + * @param action + */ + ForEachControl(action: ASPxClientControlAction): void; } /** * Represents a client-side equivalent of the ASPxDataView object. @@ -16559,11 +16788,11 @@ interface ASPxClientDataView extends ASPxClientControl { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * A JavaScript function which returns a value specifying whether an object meets the criteria defined within the method specified by this delegate. @@ -16629,11 +16858,11 @@ interface ASPxClientDockManager extends ASPxClientControl { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that contains any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; /** * Returns a zone specified by its unique identifier (zoneUID). * @param zoneUID A string value specifying the unique identifier of the zone. @@ -17375,11 +17604,11 @@ interface ASPxClientFileManager extends ASPxClientControl { */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that specifies any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; } /** * A JavaScript function which receives callback data obtained via a call to the client SetCurrentFolderPath method. @@ -17448,6 +17677,7 @@ interface ASPxClientFileManagerFile extends ASPxClientFileManagerItem { * A client-side equivalent of the FileManagerFolder object. */ interface ASPxClientFileManagerFolder extends ASPxClientFileManagerItem { + isParentFolder: boolean; } /** * A JavaScript function which receives callback data obtained by a call to the client GetAllItems method. @@ -18659,6 +18889,7 @@ interface ASPxClientMenuBase extends ASPxClientControl { * Represents a client collection that maintains client menu objects. */ interface ASPxClientMenuCollection extends ASPxClientControlCollection { + RecalculateAll(): void; /** * Hides all menus maitained by the collection. */ @@ -19358,12 +19589,12 @@ interface ASPxClientPopupControl extends ASPxClientPopupControlBase { */ PerformWindowCallback(window: ASPxClientPopupWindow, parameter: string): void; /** - * Sends a callback to the server and generates the server-side WindowCallback event, passing it the related popup window object and the specified argument. - * @param window An ASPxClientPopupWindow object identifying the processed popup window. - * @param parameter A string value specifying any information that needs to be sent to the server-side WindowCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param window + * @param parameter + * @param onSuccess */ - PerformWindowCallback(window: ASPxClientPopupWindow, parameter: string, onSuccess: Function): void; + PerformWindowCallback(window: ASPxClientPopupWindow, parameter: string, onSuccess: (arg1: string) => void): void; /** * Specifies the default popup window's size. * @param width An integer value that specifies the default popup window's width. @@ -20006,7 +20237,7 @@ interface ASPxClientRibbon extends ASPxClientControl { */ GetMinimized(): boolean; /** - * Specifies the visibility of a context tab ?ategory specified by its name. + * Specifies the visibility of a context tab category specified by its name. * @param categoryName A Name property value of the required category. * @param visible true to make a category visible; false to make it hidden. */ @@ -20248,11 +20479,11 @@ interface ASPxClientRoundPanel extends ASPxClientPanelBase { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side ContentCallback event, passing it the specified argument. - * @param parameter A string value that is any information that needs to be sent to the server-side ContentCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; /** * Returns the text displayed within the panel's header. */ @@ -20623,11 +20854,11 @@ interface ASPxClientPageControl extends ASPxClientTabControlBase { */ PerformCallback(parameter: string): void; /** - * Sends a callback to the server and generates the server-side Callback event, passing it the specified argument. - * @param parameter A string value that represents any information that needs to be sent to the server-side Callback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param parameter + * @param onSuccess */ - PerformCallback(parameter: string, onSuccess: Function): void; + PerformCallback(parameter: string, onSuccess: (arg1: string) => void): void; } /** * Represents a client-side equivalent of a tab control's TabPage object. @@ -21481,11 +21712,15 @@ interface ASPxClientChartDesigner extends ASPxClientControl { */ PerformCallback(arg: string): void; /** - * Sends a callback to the server and generates the server-side event, passing it the specified argument. - * @param arg A string value that represents any information that needs to be sent to the server-side event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param arg + * @param onSuccess + */ + PerformCallback(arg: string, onSuccess: (arg1: string) => void): void; + /** + * Updates the localization settings of the ASPxClientChartDesigner properties. + * @param localization A dictionary containing the property names, along with their localized equivalents. */ - PerformCallback(arg: string, onSuccess: Function): void; UpdateLocalization(localization: { [key: string]: string; }): void; /** * Returns the model of the Client Chart Designer. @@ -21636,11 +21871,11 @@ interface ASPxClientWebChartControl extends ASPxClientControl { */ PerformCallback(args: string): void; /** - * Sends a callback to the server and generates the server-side CustomCallback event, passing it the specified argument. - * @param args A string value that represents any information that needs to be sent to the server-side CustomCallback event. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param args + * @param onSuccess */ - PerformCallback(args: string, onSuccess: Function): void; + PerformCallback(args: string, onSuccess: (arg1: string) => void): void; /** * Prints the current chart on the client side. */ @@ -23640,11 +23875,15 @@ interface ASPxClientQueryBuilder extends ASPxClientControl { */ PerformCallback(arg: string): void; /** - * Sends a callback to the server with the specified argument. - * @param arg A String value, specifying the callback argument. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param arg + * @param onSuccess + */ + PerformCallback(arg: string, onSuccess: (arg1: string) => void): void; + /** + * Updates the localization settings of the ASPxClientQueryBuilder properties. + * @param localization A dictionary containing the property names, along with their localized equivalents. */ - PerformCallback(arg: string, onSuccess: Function): void; UpdateLocalization(localization: { [key: string]: string; }): void; /** * Returns the object model of a Query Builder. @@ -23797,11 +24036,15 @@ interface ASPxClientReportDesigner extends ASPxClientControl { */ PerformCallback(arg: string): void; /** - * Sends a callback to the server with the specified argument. - * @param arg A String value, specifying the callback argument. - * @param onSuccess A delegate method that will be called if the callback is successful. + * + * @param arg + * @param onSuccess + */ + PerformCallback(arg: string, onSuccess: (arg1: string) => void): void; + /** + * Updates the localization settings of the ASPxClientReportDesigner properties. + * @param localization A dictionary containing the property names, along with their localized equivalents. */ - PerformCallback(arg: string, onSuccess: Function): void; UpdateLocalization(localization: { [key: string]: string; }): void; /** * Returns the object model of a Web Report Designer. @@ -24013,6 +24256,10 @@ interface ASPxClientReportViewer extends ASPxClientControl { * Occurs on the client side when another report page is loaded into this ASPxClientReportViewer instance. */ PageLoad: ASPxClientEvent>; + /** + * Submits the values of the specified parameters. + * @param parameters A dictionary containing the parameter names, along with their Object values. + */ SubmitParameters(parameters: { [key: string]: Object; }): void; /** * Prints a report shown in the ReportViewer. @@ -24260,6 +24507,10 @@ interface ASPxClientWebDocumentViewer extends ASPxClientControl { * @param format A String value, specifying the export format. The following formats are currently supported: 'csv', 'html', 'image', 'mht', 'pdf', 'rtf', 'txt', 'xls', and 'xlsx'. */ ExportTo(format: string): void; + /** + * Updates the localization settings of the ASPxClientWebDocumentViewer properties. + * @param localization A dictionary containing the property names, along with their localized equivalents. + */ UpdateLocalization(localization: { [key: string]: string; }): void; } /** @@ -25661,30 +25912,30 @@ interface ASPxClientRichEditStatic extends ASPxClientControlStatic { } interface ASPxSchedulerDateTimeHelperStatic { /** - * - * @param date + * Returns the date part of the specified DateTime value. + * @param date A DateTime object from which to extract the date. */ TruncToDate(date: Date): Date; /** - * - * @param date + * Returns the day time part of the specified DateTime value. + * @param date A DateTime object from which to extract the day time. */ ToDayTime(date: Date): any; /** - * - * @param date + * Adds the specified number of days to a DateTime object and returns the result. + * @param date A DateTime object to which to add days. */ AddDays(date: Date): Date; /** - * - * @param date - * @param timeSpan + * Adds the specified timespan to a DateTime object and returns the result. + * @param date A DateTime object to which to add a timespan. + * @param timeSpan A TimeSpan object specifying the timespan to add. */ AddTimeSpan(date: Date, timeSpan: any): Date; /** - * - * @param date - * @param spanInMs + * Rounds a DateTime value up to the nearest interval. + * @param date A DateTime object containing a value to round. + * @param spanInMs A TimeSpan object specifying an interval to which to round. */ CeilDateTime(date: Date, spanInMs: any): Date; } @@ -25706,9 +25957,9 @@ interface ASPxClientRecurrenceTypeEditStatic extends ASPxClientRadioButtonListSt } interface ASPxClientTimeIntervalStatic { /** - * - * @param start - * @param end + * Gets the duration of a time interval between two points in time. + * @param start A DateTime object specifying the starting point of the time interval. + * @param end A DateTime object specifying the ending point of the time interval. */ CalculateDuration(start: Date, end: Date): number; } From 1b240acf4a60d678527b4b1099c23ddb255a9752 Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 16:45:11 +0200 Subject: [PATCH 69/80] #10342 Added hideNoData/showNoData to highcharts --- highcharts/highcharts-modules-no-data-to-display-tests.ts | 2 +- highcharts/highcharts-modules-no-data-to-display.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/highcharts/highcharts-modules-no-data-to-display-tests.ts b/highcharts/highcharts-modules-no-data-to-display-tests.ts index 9b1d69b8da..454b50f067 100644 --- a/highcharts/highcharts-modules-no-data-to-display-tests.ts +++ b/highcharts/highcharts-modules-no-data-to-display-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// function test_NoDataToDisplay() { diff --git a/highcharts/highcharts-modules-no-data-to-display.d.ts b/highcharts/highcharts-modules-no-data-to-display.d.ts index d1910675cd..120acede4c 100644 --- a/highcharts/highcharts-modules-no-data-to-display.d.ts +++ b/highcharts/highcharts-modules-no-data-to-display.d.ts @@ -2,7 +2,7 @@ // Project: http://www.highcharts.com/ // Definitions by: Andrey Zolotin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// +// interface HighchartsChartObject { /** * Returns true if there are data points within the plot area now From 26a7266dbb029fe0abab4070fe973838d162f937 Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 16:48:36 +0200 Subject: [PATCH 70/80] #10342 Added hideNoData/showNoData to highcharts --- highcharts/highcharts-modules-no-data-to-display-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/highcharts/highcharts-modules-no-data-to-display-tests.ts b/highcharts/highcharts-modules-no-data-to-display-tests.ts index 454b50f067..5a6ed0b59c 100644 --- a/highcharts/highcharts-modules-no-data-to-display-tests.ts +++ b/highcharts/highcharts-modules-no-data-to-display-tests.ts @@ -1,5 +1,6 @@ /// /// +// function test_NoDataToDisplay() { var chart = $("#container").highcharts(); From c19594e5e5437039b1530114d82a7b022773c01a Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 16:55:09 +0200 Subject: [PATCH 71/80] #10342 Added hideNoData/showNoData to highcharts --- highcharts/highcharts-modules-no-data-to-display-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highcharts/highcharts-modules-no-data-to-display-tests.ts b/highcharts/highcharts-modules-no-data-to-display-tests.ts index 5a6ed0b59c..806b7c3dd8 100644 --- a/highcharts/highcharts-modules-no-data-to-display-tests.ts +++ b/highcharts/highcharts-modules-no-data-to-display-tests.ts @@ -1,6 +1,6 @@ /// -/// // +/// function test_NoDataToDisplay() { var chart = $("#container").highcharts(); From c6b2d3b16c76a52fbff392520d46427f882dad53 Mon Sep 17 00:00:00 2001 From: "Zolotin, Andrey (GGA)" Date: Fri, 12 Aug 2016 16:55:48 +0200 Subject: [PATCH 72/80] #10342 Added hideNoData/showNoData to highcharts --- highcharts/highcharts-modules-no-data-to-display-tests.ts | 2 +- highcharts/highcharts-modules-no-data-to-display.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/highcharts/highcharts-modules-no-data-to-display-tests.ts b/highcharts/highcharts-modules-no-data-to-display-tests.ts index 806b7c3dd8..64b50f831f 100644 --- a/highcharts/highcharts-modules-no-data-to-display-tests.ts +++ b/highcharts/highcharts-modules-no-data-to-display-tests.ts @@ -1,5 +1,5 @@ /// -// +/// /// function test_NoDataToDisplay() { diff --git a/highcharts/highcharts-modules-no-data-to-display.d.ts b/highcharts/highcharts-modules-no-data-to-display.d.ts index 120acede4c..ab5fdd1d0d 100644 --- a/highcharts/highcharts-modules-no-data-to-display.d.ts +++ b/highcharts/highcharts-modules-no-data-to-display.d.ts @@ -2,7 +2,7 @@ // Project: http://www.highcharts.com/ // Definitions by: Andrey Zolotin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// +/// interface HighchartsChartObject { /** * Returns true if there are data points within the plot area now From 876e78d5f5084d396e3b1c3eb11c73367655039e Mon Sep 17 00:00:00 2001 From: Jon Perl Date: Fri, 12 Aug 2016 11:14:35 -0400 Subject: [PATCH 73/80] Add missing jsonb column type to knex TableBuilder --- knex/knex.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 64d530ed49..bd02069da1 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -370,6 +370,7 @@ declare module "knex" { enum(columnName: string, values: Value[]): ColumnBuilder; enu(columnName: string, values: Value[]): ColumnBuilder; json(columnName: string): ColumnBuilder; + jsonb(columnName: string): ColumnBuilder; uuid(columnName: string): ColumnBuilder; comment(val: string): TableBuilder; specificType(columnName: string, type: string): ColumnBuilder; From db5cd794084553b74b6beb32c446e0574004269d Mon Sep 17 00:00:00 2001 From: Finn Poppinga Date: Fri, 12 Aug 2016 17:19:54 +0200 Subject: [PATCH 74/80] add missing methods of QueryIterator interface --- documentdb/documentdb.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/documentdb/documentdb.d.ts b/documentdb/documentdb.d.ts index 1d901179a6..c4aefe470f 100644 --- a/documentdb/documentdb.d.ts +++ b/documentdb/documentdb.d.ts @@ -93,7 +93,12 @@ declare module 'documentdb' { /** Represents the result returned from a query. */ interface QueryIterator { - + current(): TResultRow; + executeNext(callback: (error: QueryError, result: TResultRow[]) => void): void; + forEach(iteratorFunction : (error: QueryError, element: TResultRow) => void): void; + hasMoreResults(): boolean; + nextItem(callback: (error : QueryError, item : TResultRow) => void): void; + reset() : void; toArray(callback: (error: QueryError, result: TResultRow[]) => void): void; } From 601a2d4ae2854bc62809d0e6312746b758fffc21 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 12 Aug 2016 17:50:16 +0100 Subject: [PATCH 75/80] Knex: add missing transaction.raw --- knex/knex.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index bd02069da1..4ef5ef5a8c 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -330,6 +330,7 @@ declare module "knex" { interface Transaction extends QueryBuilder { commit: any; rollback: any; + raw: Raw; } // @@ -370,7 +371,6 @@ declare module "knex" { enum(columnName: string, values: Value[]): ColumnBuilder; enu(columnName: string, values: Value[]): ColumnBuilder; json(columnName: string): ColumnBuilder; - jsonb(columnName: string): ColumnBuilder; uuid(columnName: string): ColumnBuilder; comment(val: string): TableBuilder; specificType(columnName: string, type: string): ColumnBuilder; From eb1ed6bb545c8c18fc620fec04f2ba3b3e79b581 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 12 Aug 2016 17:51:56 +0100 Subject: [PATCH 76/80] Add test --- knex/knex-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index 3a00c32551..e894a6be47 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -380,6 +380,8 @@ knex.transaction(function(trx) { // Using trx as a transaction object: knex.transaction(function(trx) { + + trx.raw('') var info: any; var books: any[] = [ From 73748184ab2c45bbc67babed52d9d197241d384d Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 12 Aug 2016 17:52:39 +0100 Subject: [PATCH 77/80] Restore --- knex/knex.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 4ef5ef5a8c..27996ccbca 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -370,6 +370,7 @@ declare module "knex" { binary(columnName: string): ColumnBuilder; enum(columnName: string, values: Value[]): ColumnBuilder; enu(columnName: string, values: Value[]): ColumnBuilder; + jsonb(columnName: string): ColumnBuilder; json(columnName: string): ColumnBuilder; uuid(columnName: string): ColumnBuilder; comment(val: string): TableBuilder; From 793ec09a5f53fbc83f3b2fd07b29b39ff44c9946 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 12 Aug 2016 17:53:07 +0100 Subject: [PATCH 78/80] Order --- knex/knex.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 27996ccbca..68e8248c1e 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -370,8 +370,8 @@ declare module "knex" { binary(columnName: string): ColumnBuilder; enum(columnName: string, values: Value[]): ColumnBuilder; enu(columnName: string, values: Value[]): ColumnBuilder; - jsonb(columnName: string): ColumnBuilder; json(columnName: string): ColumnBuilder; + jsonb(columnName: string): ColumnBuilder; uuid(columnName: string): ColumnBuilder; comment(val: string): TableBuilder; specificType(columnName: string, type: string): ColumnBuilder; From b4f1909a44c251f20c4f17d49705a90ed69476ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chabbey=20Fran=C3=A7ois?= Date: Fri, 12 Aug 2016 10:06:28 -0700 Subject: [PATCH 79/80] Update lru-cache to v4.1.0 lru-cache accepts any type for the key. --- lru-cache/lru-cache.d.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lru-cache/lru-cache.d.ts b/lru-cache/lru-cache.d.ts index 25b9b8cf52..7bca656bd8 100644 --- a/lru-cache/lru-cache.d.ts +++ b/lru-cache/lru-cache.d.ts @@ -1,4 +1,4 @@ -// Type definitions for lru-cache v2.5.0 +// Type definitions for lru-cache v4.0.1 // Project: https://github.com/isaacs/node-lru-cache // Definitions by: Bart van der Schoor // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -12,20 +12,22 @@ declare module 'lru-cache' { max?: number; maxAge?: number; length?: (value: T) => number; - dispose?: (key: string, value: T) => void; + dispose?: (key: any, value: T) => void; stale?: boolean; } interface Cache { - set(key: string, value: T): void; - get(key: string): T; - peek(key: string): T; - has(key: string): boolean - del(key: string): void; + set(key: any, value: T): void; + get(key: any): T; + peek(key: any): T; + has(key: any): boolean + del(key: any): void; reset(): void; - forEach(iter: (value: T, key: string, cache: Cache) => void, thisp?: any): void; - - keys(): string[]; + prune(): void; + forEach(iter: (value: T, key: any, cache: Cache) => void, thisp?: any): void; + itemCount: number; + length: number + keys(): any[]; values(): T[]; } } From 5458c8e4dc7239a5733a3d939e9983d846876b74 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 12 Aug 2016 18:09:15 +0100 Subject: [PATCH 80/80] Fix --- knex/knex.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 68e8248c1e..75c9f67a43 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -330,7 +330,7 @@ declare module "knex" { interface Transaction extends QueryBuilder { commit: any; rollback: any; - raw: Raw; + raw: Knex.RawBuilder; } //