From 6fde16275a38d5203702d57c928545178450eb92 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Tue, 22 Sep 2015 15:58:27 -0300 Subject: [PATCH 1/5] Add Stamplay js Sdk definitions --- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 35 +++++++++++++++++++++ stamplay-js-sdk/stamplay-js-sdk.d.ts | 40 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 stamplay-js-sdk/stamplay-js-sdk-tests.ts create mode 100644 stamplay-js-sdk/stamplay-js-sdk.d.ts diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts new file mode 100644 index 000000000..f17da5c13 --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -0,0 +1,35 @@ +/// + +var userFn = Stamplay.User(); +var user = new userFn.Model; + +var tags = new Stamplay.Cobject('tag').Collection; + +// Signing up +var registrationData = { + email : 'user@provider.com', + password: 'mySecret' + }; + +user.signup(registrationData).then(function(){ + user.set('phoneNumber', '020 123 4567' ); + return user.save(); + }).then(function(){ + var number = user.get('phoneNumber'); + console.log(number); // number value is 020 123 4567 + }); + + +// Action +var fooMod = new Stamplay.Cobject('foo').Model; +fooMod.fetch(5).then( + function(){ + return fooMod.upVote() + } +).then( + function(){ + //success callback + }, function( err ){ + //error callback + } +) diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts new file mode 100644 index 000000000..50817ee2d --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -0,0 +1,40 @@ +// Type definitions for stamplay-js-sdk 1.2.9 +// Project: https://github.com/Stamplay/stamplay-js-sdk and https://stamplay.com/docs/jssdk#api-ref-model +// Definitions by: Riderman de Sousa Barbosa +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Stamplay { + + export interface IStamplayModel { + signup({}) : PromisesAPlus.Thenable + new() : IStamplayModel + get(property : string) + set(property : string, value: any) + unset(property : string) + fetch(id : any) + destroy() : PromisesAPlus.Thenable + save({}?) : PromisesAPlus.Thenable + } + + export interface IStamplayAction { + new() : IStamplayModel + upVote() : PromisesAPlus.Thenable + } + + export interface IStamplayUser { + Model : IStamplayModel + } + + export interface StamplayStatic { + User() : IStamplayUser + Cobject(collection : string) : void + } +} + +declare var Stamplay: Stamplay.StamplayStatic; + +declare module "Stamplay" { + export = Stamplay; +} From bd7be4ea62b08a1df4c4d0933329c03828df7235 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Wed, 23 Sep 2015 07:44:16 -0300 Subject: [PATCH 2/5] Fix TS errors for stamplay-js-sdk --- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 9 +++++---- stamplay-js-sdk/stamplay-js-sdk.d.ts | 8 ++++---- stamplay-js-sdk/tsconfig.json | 6 ++++++ 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 stamplay-js-sdk/tsconfig.json diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts index f17da5c13..644d2c5b9 100644 --- a/stamplay-js-sdk/stamplay-js-sdk-tests.ts +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -2,8 +2,8 @@ var userFn = Stamplay.User(); var user = new userFn.Model; - -var tags = new Stamplay.Cobject('tag').Collection; +var colTags = new Stamplay.Cobject('tag'); +var tags = colTags.Collection; // Signing up var registrationData = { @@ -21,7 +21,8 @@ user.signup(registrationData).then(function(){ // Action -var fooMod = new Stamplay.Cobject('foo').Model; +var colFoo = new Stamplay.Cobject('foo'); +var fooMod = colFoo.Model; fooMod.fetch(5).then( function(){ return fooMod.upVote() @@ -29,7 +30,7 @@ fooMod.fetch(5).then( ).then( function(){ //success callback - }, function( err ){ + }, function( err : any ){ //error callback } ) diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts index 50817ee2d..3cd9f3843 100644 --- a/stamplay-js-sdk/stamplay-js-sdk.d.ts +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -10,10 +10,10 @@ declare module Stamplay { export interface IStamplayModel { signup({}) : PromisesAPlus.Thenable new() : IStamplayModel - get(property : string) - set(property : string, value: any) - unset(property : string) - fetch(id : any) + get(property : string) : any + set(property : string, value: any) : void + unset(property : string) : void + fetch(id : any) : PromisesAPlus.Thenable destroy() : PromisesAPlus.Thenable save({}?) : PromisesAPlus.Thenable } diff --git a/stamplay-js-sdk/tsconfig.json b/stamplay-js-sdk/tsconfig.json new file mode 100644 index 000000000..8d5b43ce4 --- /dev/null +++ b/stamplay-js-sdk/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "ES5", + "module": "amd" + } +} From c2c6dfa673ce234c7427ce7f53034f4ca1b99665 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Wed, 23 Sep 2015 07:51:23 -0300 Subject: [PATCH 3/5] Change object user to object model --- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 8 ++++---- stamplay-js-sdk/stamplay-js-sdk.d.ts | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts index 644d2c5b9..bfc229d49 100644 --- a/stamplay-js-sdk/stamplay-js-sdk-tests.ts +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -2,8 +2,8 @@ var userFn = Stamplay.User(); var user = new userFn.Model; -var colTags = new Stamplay.Cobject('tag'); -var tags = colTags.Collection; +var colTags = Stamplay.Cobject('tag'); +var tags = new colTags.Collection(); // Signing up var registrationData = { @@ -21,8 +21,8 @@ user.signup(registrationData).then(function(){ // Action -var colFoo = new Stamplay.Cobject('foo'); -var fooMod = colFoo.Model; +var colFoo = Stamplay.Cobject('foo'); +var fooMod = new colFoo.Model(); fooMod.fetch(5).then( function(){ return fooMod.upVote() diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts index 3cd9f3843..2eb62206b 100644 --- a/stamplay-js-sdk/stamplay-js-sdk.d.ts +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -16,20 +16,18 @@ declare module Stamplay { fetch(id : any) : PromisesAPlus.Thenable destroy() : PromisesAPlus.Thenable save({}?) : PromisesAPlus.Thenable + upVote() : PromisesAPlus.Thenable } - export interface IStamplayAction { - new() : IStamplayModel - upVote() : PromisesAPlus.Thenable - } - - export interface IStamplayUser { + export interface IStamplayObject { Model : IStamplayModel + Collection : any + } export interface StamplayStatic { - User() : IStamplayUser - Cobject(collection : string) : void + User() : IStamplayObject + Cobject(object : string) : IStamplayObject } } From 1942dfab9229362cf9fd69a48814a59def7c1daf Mon Sep 17 00:00:00 2001 From: ridermansb Date: Wed, 23 Sep 2015 07:52:56 -0300 Subject: [PATCH 4/5] Fix linebreak --- stamplay-js-sdk/stamplay-js-sdk.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts index 2eb62206b..154dc414e 100644 --- a/stamplay-js-sdk/stamplay-js-sdk.d.ts +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -1,5 +1,5 @@ // Type definitions for stamplay-js-sdk 1.2.9 -// Project: https://github.com/Stamplay/stamplay-js-sdk and https://stamplay.com/docs/jssdk#api-ref-model +// Project: https://github.com/Stamplay/stamplay-js-sdk // Definitions by: Riderman de Sousa Barbosa // Definitions: https://github.com/borisyankov/DefinitelyTyped From 369a31db8892db37c8d2e913adef42e867c74113 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Thu, 1 Oct 2015 14:47:26 -0300 Subject: [PATCH 5/5] Remove tsconfig file --- stamplay-js-sdk/tsconfig.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 stamplay-js-sdk/tsconfig.json diff --git a/stamplay-js-sdk/tsconfig.json b/stamplay-js-sdk/tsconfig.json deleted file mode 100644 index 8d5b43ce4..000000000 --- a/stamplay-js-sdk/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "target": "ES5", - "module": "amd" - } -}