Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@paulbatum
Created October 7, 2012 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paulbatum/3849662 to your computer and use it in GitHub Desktop.
Save paulbatum/3849662 to your computer and use it in GitHub Desktop.
TypeScript declaration file for Windows Azure Mobile Services server scripts
// TypeScript declaration file for Windows Azure Mobile Services server scripts
// WORK IN PROGRESS
interface ZumoError {
}
interface StatusCodes {
OK: number;
NOT_FOUND: number;
}
interface Tables {
getTable(tableName: string): Table;
}
interface Table extends Query {
update(item: { }): void;
update(item: { }, options: {
success: () => void;
error?: (err: ZumoError) => void;
}): void;
insert(item: { }): void;
insert(item: { }, options: {
success: () => void;
error?: (err: ZumoError) => void;
}): void;
del(id: number): void;
del(item: { }): void;
del(item: { }, options: {
success: () => void;
error?: (err: ZumoError) => void;
}): void;
}
interface Query {
orderBy(column: string, ...more: string[]): Query;
orderByDescending(column: string, ...more: string[]): Query;
select(column: string, ...more: string[]): Query;
select(projection: () => any): Query;
skip(recordCount: number): Query;
take(recordCount: number): Query;
where(exampleObject: { }): Query;
where(predicate: () => bool): Query;
where(predicate: (arg1: any) => bool, arg1: any): Query;
where(predicate: (arg1: any, arg2: any) => bool, arg1: any, arg2: any): Query;
where(predicate: (arg1: any, arg2: any, arg3: any) => bool, arg1: any, arg2: any, arg3: any): Query;
where(predicate: (arg1: any, arg2: any, arg3: any, ...args: any[]) => bool, arg1: any, arg2: any, arg3: any, ...args: any[]): Query;
read(options: {
success: (results: any[]) => void;
error?: (err: ZumoError) => void;
}): void;
}
interface RequestBase {
respond(): void;
respond(status: number): void;
respond(status: number, response: any): void;
parameters: any;
}
interface Request extends RequestBase {
execute(): void;
execute(options: {
success: () => void;
error?: (err: ZumoError) => void;
}): void;
}
interface ReadRequest extends RequestBase {
execute(): void;
execute(options: {
success: (results: any[]) => void;
error?: (err: ZumoError) => void;
}): void;
}
interface User {
userId: string;
level: string;
}
// Globals
declare var statusCodes: StatusCodes;
declare var tables: Tables;
// Script templates
function read(query: any, user: User, request: ReadRequest) {
}
function insert(item: any, user: User, request: Request) {
}
function update(item: { id: number; }, user: User, request: Request) {
}
function del(id: number, user: User, request: Request) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment