Skip to content

Commit

Permalink
feat(types): support each core types
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Apr 15, 2018
1 parent bd758e8 commit eadc7a2
Show file tree
Hide file tree
Showing 22 changed files with 1,325 additions and 1,255 deletions.
89 changes: 80 additions & 9 deletions packages/@jxa/types/src/Application.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,94 @@
import { StandardAdditions } from "./core/StandardAdditions";
import { TextEdit } from "./core/TextEdit";
import { VoiceOver } from "./core/VoiceOver";
import { Terminal } from "./core/Terminal";
import { SystemEvents } from "./core/SystemEvents";
import { SpeechRecognitionServer } from "./core/SpeechRecognitionServer";
import { ScriptEditor } from "./core/ScriptEditor";
import { Calendar } from "./core/Calendar";
import { Contacts } from "./core/Contacts";
import { DatabaseEvents } from "./core/DatabaseEvents";
import { Finder } from "./core/Finder";
import { FontBook } from "./core/FontBook";
import { ImageEvents } from "./core/ImageEvents";
import { Keynote } from "./core/Keynote";
import { Mail } from "./core/Mail";
import { Messages } from "./core/Messages";
import { Notes } from "./core/Notes";
import { Numbers } from "./core/Numbers";
import { Pages } from "./core/Pages";
import { Photos } from "./core/Photos";
import { QuickTimePlayer } from "./core/QuickTimePlayer";
import { Reminders } from "./core/Reminders";
import { Safari } from "./core/Safari";
import { DVDPlayer } from "./core/DVDPlayer";
import { iTunes } from "./core/iTunes";

export = Application;
export as namespace Application;


/**
* bundle ID or name or path or remote machine
*/
declare function Application<T = any>(
name: string
): typeof Application & Application._StandardAdditions & Application.AnyValue;
declare function Application(name: string): typeof Application & Application._StandardAdditions & Application.AnyValue;
declare function Application(name: "Calendar"): typeof Application & Application._StandardAdditions & Application._Calendar;
declare function Application(name: "Contacts"): typeof Application & Application._StandardAdditions & Application._Contacts;
declare function Application(name: "Database Events"): typeof Application & Application._StandardAdditions & Application._DatabaseEvents;
declare function Application(name: "DVD Player"): typeof Application & Application._StandardAdditions & Application._DVDPlayer;
declare function Application(name: "Finder"): typeof Application & Application._StandardAdditions & Application._Finder;
declare function Application(name: "Font Book"): typeof Application & Application._StandardAdditions & Application._FontBook;
declare function Application(name: "Image Events"): typeof Application & Application._StandardAdditions & Application._ImageEvents;
declare function Application(name: "iTunes"): typeof Application & Application._StandardAdditions & Application._iTunes;
declare function Application(name: "Keynote"): typeof Application & Application._StandardAdditions & Application._Keynote;
declare function Application(name: "Mail"): typeof Application & Application._StandardAdditions & Application._Mail;
declare function Application(name: "Messages"): typeof Application & Application._StandardAdditions & Application._Messages;
declare function Application(name: "Notes"): typeof Application & Application._StandardAdditions & Application._Notes;
declare function Application(name: "Numbers"): typeof Application & Application._StandardAdditions & Application._Numbers;
declare function Application(name: "Pages"): typeof Application & Application._StandardAdditions & Application._Pages;
declare function Application(name: "Photos"): typeof Application & Application._StandardAdditions & Application._Photos;
declare function Application(name: "QuickTime Player"): typeof Application & Application._StandardAdditions & Application._QuickTimePlayer;
declare function Application(name: "Reminders"): typeof Application & Application._StandardAdditions & Application._Reminders;
declare function Application(name: "Safari"): typeof Application & Application._StandardAdditions & Application._Safari;
declare function Application(name: "Script Editor"): typeof Application & Application._StandardAdditions & Application._ScriptEditor;
declare function Application(name: "SpeechRecognitionServer"): typeof Application & Application._StandardAdditions & Application._SpeechRecognitionServer;
declare function Application(name: "System Events"): typeof Application & Application._StandardAdditions & Application._SystemEvents;
declare function Application(name: "Terminal"): typeof Application & Application._StandardAdditions & Application._Terminal;
declare function Application(name: "TextEdit"): typeof Application & Application._StandardAdditions & Application._TextEdit;
declare function Application(name: "VoiceOver"): typeof Application & Application._StandardAdditions & Application._VoiceOver;
/**
* process ID
*/
declare function Application<T = any>(
id: number
): typeof Application & Application._StandardAdditions & Application.AnyValue;
declare function Application(id: number): typeof Application & Application._StandardAdditions & Application.AnyValue;

declare namespace Application {
export interface _StandardAdditions extends StandardAdditions {}

// FIXME: very hack to avoid the Error
// Error:(10, 5) TS4023: Exported variable 'TextEdit' has or is using name 'TextEdit' from external module "...TextEdit" but cannot be named.
export interface _StandardAdditions extends StandardAdditions{}
export interface _Calendar extends Calendar{}
export interface _Contacts extends Contacts{}
export interface _DatabaseEvents extends DatabaseEvents{}
export interface _DVDPlayer extends DVDPlayer{}
export interface _Finder extends Finder{}
export interface _FontBook extends FontBook{}
export interface _ImageEvents extends ImageEvents{}
export interface _iTunes extends iTunes{}
export interface _Keynote extends Keynote{}
export interface _Mail extends Mail{}
export interface _Messages extends Messages{}
export interface _Notes extends Notes{}
export interface _Numbers extends Numbers{}
export interface _Pages extends Pages{}
export interface _Photos extends Photos{}
export interface _QuickTimePlayer extends QuickTimePlayer{}
export interface _Reminders extends Reminders{}
export interface _Safari extends Safari{}
export interface _ScriptEditor extends ScriptEditor{}
export interface _SpeechRecognitionServer extends SpeechRecognitionServer{}
export interface _SystemEvents extends SystemEvents{}
export interface _Terminal extends Terminal{}
export interface _VoiceOver extends VoiceOver{}
// Any Value
export interface AnyValue {
[index: string]: any;

Expand All @@ -28,7 +98,8 @@ declare namespace Application {
/**
* Return current app
*/
export function currentApplication(): typeof Application & Application._StandardAdditions & Application.AnyValue;
export function currentApplication<T = any>(): typeof Application &
Application._StandardAdditions & Application.AnyValue

/**
* It should be true if you use StandardAdditions
Expand Down
4 changes: 2 additions & 2 deletions packages/@jxa/types/src/core/DvdPlayer.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

export namespace DvdPlayer {
export namespace DVDPlayer {
// Records

// Function options
Expand All @@ -23,7 +23,7 @@ export namespace DvdPlayer {


}
export interface DvdPlayer {
export interface DVDPlayer {
// Functions

/**
Expand Down
20 changes: 10 additions & 10 deletions packages/@jxa/types/src/core/ITunes.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

export namespace ITunes {
export namespace iTunes {
// Records
/**
* This file was automatically generated by json-schema-to-typescript.
Expand Down Expand Up @@ -221,7 +221,7 @@ export namespace ITunes {


}
export interface ITunes {
export interface iTunes {
// Functions

/**
Expand All @@ -230,7 +230,7 @@ export interface ITunes {
* @param option
*
*/
print(directParameter?: any, option?: ITunes.PrintOptionalParameter): void;
print(directParameter?: any, option?: iTunes.PrintOptionalParameter): void;

/**
* Close an object
Expand All @@ -245,7 +245,7 @@ export interface ITunes {
* @param option
* @return the number of elements
*/
count(directParameter: any, option?: ITunes.CountOptionalParameter): number;
count(directParameter: any, option?: iTunes.CountOptionalParameter): number;

/**
* Delete an element from an object
Expand All @@ -260,7 +260,7 @@ export interface ITunes {
* @param option
* @return to the duplicated object(s)
*/
duplicate(directParameter: any, option?: ITunes.DuplicateOptionalParameter): any;
duplicate(directParameter: any, option?: iTunes.DuplicateOptionalParameter): any;

/**
* Verify if an object exists
Expand All @@ -275,15 +275,15 @@ export interface ITunes {
* @param option
* @return to the new object(s)
*/
make(option?: ITunes.MakeOptionalParameter): any;
make(option?: iTunes.MakeOptionalParameter): any;

/**
* Move playlist(s) to a new location
* @param directParameter the playlist(s) to move
* @param option
*
*/
move(directParameter: any, option?: ITunes.MoveOptionalParameter): void;
move(directParameter: any, option?: iTunes.MoveOptionalParameter): void;

/**
* Open the specified object(s)
Expand Down Expand Up @@ -319,7 +319,7 @@ export interface ITunes {
* @param option
* @return reference to added track(s)
*/
add(directParameter: {}, option?: ITunes.AddOptionalParameter): any;
add(directParameter: {}, option?: iTunes.AddOptionalParameter): any;

/**
* reposition to beginning of current track or go to previous track if already at start of current track
Expand Down Expand Up @@ -376,7 +376,7 @@ export interface ITunes {
* @param option
*
*/
play(directParameter?: any, option?: ITunes.PlayOptionalParameter): void;
play(directParameter?: any, option?: iTunes.PlayOptionalParameter): void;

/**
* toggle the playing/paused state of the current track
Expand Down Expand Up @@ -426,7 +426,7 @@ export interface ITunes {
* @param option
* @return reference to found track(s)
*/
search(directParameter: any, option?: ITunes.SearchOptionalParameter): any;
search(directParameter: any, option?: iTunes.SearchOptionalParameter): any;

/**
* select the specified object(s)
Expand Down
Loading

0 comments on commit eadc7a2

Please sign in to comment.