diff --git a/types/vcards-js/index.d.ts b/types/vcards-js/index.d.ts new file mode 100644 index 0000000000..d130090ba2 --- /dev/null +++ b/types/vcards-js/index.d.ts @@ -0,0 +1,257 @@ +// Type definitions for vcards-js 2.10 +// Project: https://github.com/enesser/vCards-JS +// Definitions by: Ben Allfree +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface vCard { + /** + * Specifies a value that represents a persistent, globally unique identifier associated with the vCard + */ + uid: string; + + /** + * Date of birth + */ + birthday: Date; + + /** + * Anniversary + */ + anniversary: Date; + + /** + * Cell phone number + */ + cellPhone: string; + + /** + * Other cell phone number or pager + */ + pagerPhone: string; + + /** + * The address for private electronic mail communication + */ + email: string; + + /** + * The address for work-related electronic mail communication + */ + workEmail: string; + + /** + * First name + */ + firstName: string; + + /** + * Formatted name string associated with the vCard object (will automatically populate if not set) + */ + formattedName: string; + + /** + * Gender. + */ + gender: 'M' | 'F'; + + /** + * Home mailing address + */ + homeAddress: Address; + + /** + * Home phone + */ + homePhone: string; + + /** + * Home facsimile + */ + homeFax: string; + + /** + * Last name + */ + lastName: string; + + /** + * Logo + */ + logo: Photo; + + /** + * Middle name + */ + middleName: string; + + /** + * Prefix for individual's name + */ + namePrefix: string; + + /** + * Suffix for individual's name + */ + nameSuffix: string; + + /** + * Nickname of individual + */ + nickname: string; + + /** + * Specifies supplemental information or a comment that is associated with the vCard + */ + note: string; + + /** + * The name and optionally the unit(s) of the organization associated with the vCard object + */ + organization: string; + + /** + * Whether or not this contact should be shown as a company + */ + isOrganization: boolean; + + /** + * Individual's photo + */ + photo: Photo; + + /** + * The role, occupation, or business category of the vCard object within an organization + */ + role: string; + + /** + * Social URLs attached to the vCard object (ex: Facebook, Twitter, LinkedIn) + */ + socialUrls: SocialUrls; + + /** + * A URL that can be used to get the latest version of this vCard + */ + source: string; + + /** + * Specifies the job title, functional position or function of the individual within an organization + */ + title: string; + + /** + * URL pointing to a website that represents the person in some way + */ + url: string; + + /** + * URL pointing to a website that represents the person's work in some way + */ + workUrl: string; + + /** + * Work mailing address + */ + workAddress: Address; + + /** + * Work phone + */ + workPhone: string; + + /** + * Work facsimile + */ + workFax: string; + + /** + * vCard version + */ + version: string; + + /** + * Get major version of the vCard format + */ + getMajorVersion: () => number; + + /** + * Get formatted vCard + * @return Formatted vCard in VCF format + */ + getFormattedString: () => string; + + /** + * Save formatted vCard to file + * @param filename - The file path + */ + saveToFile: (filename: string) => void; +} + +interface SocialUrls { + facebook: string; + linkedIn: string; + twitter: string; + flickr: string; +} + +interface Photo { + url: string; + mediaType: string; + base64: boolean; + + /** + * Attach a photo from a URL + * @param url URL where photo can be found + * @param mediaType Media type of photo (JPEG, PNG, GIF) + */ + attachFromUrl: (url: string, mediaType: string) => void; + + /** + * Embed a photo from a file using base-64 encoding (not implemented yet) + * @param fileLocation - filename + */ + embedFromFile: (fileLocation: string) => void; + + /** + * Embed a photo from a base-64 string + * @param base64String - the base64 string + * @param mediaType - the media type + */ + embedFromString: (base64String: string, mediaType: string) => void; +} + +interface Address { + /** + * Represents the actual text that should be put on the mailing label when delivering a physical package + */ + label: string; + + /** + * Street address + */ + street: string; + + /** + * City + */ + city: string; + + /** + * State or province + */ + stateProvince: string; + + /** + * Postal code + */ + postalCode: string; + + /** + * Country or region + */ + countryRegion: string; +} + +declare function vCardFactory(): vCard; + +export = vCardFactory; diff --git a/types/vcards-js/tsconfig.json b/types/vcards-js/tsconfig.json new file mode 100644 index 0000000000..38f97730ff --- /dev/null +++ b/types/vcards-js/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "esModuleInterop": true, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "vcards-js-tests.ts" + ] +} diff --git a/types/vcards-js/tslint.json b/types/vcards-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vcards-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vcards-js/vcards-js-tests.ts b/types/vcards-js/vcards-js-tests.ts new file mode 100644 index 0000000000..dbf1978807 --- /dev/null +++ b/types/vcards-js/vcards-js-tests.ts @@ -0,0 +1,10 @@ +import vCardsJS from 'vcards-js'; + +const vCard = vCardsJS(); + +vCard.firstName = 'Eric'; +vCard.middleName = 'J'; +vCard.lastName = 'Nesser'; +vCard.workPhone = '312-555-1212'; + +vCard.getFormattedString().length > 0;