From f94da7c86d8158c16efae39504a5bf98ed6f349f Mon Sep 17 00:00:00 2001 From: David Gee Date: Sun, 19 Mar 2017 20:56:32 -0500 Subject: [PATCH 1/4] Amend CallRoute signature to allow path/value pair based invalidation of routes --- falcor-router/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/falcor-router/index.d.ts b/falcor-router/index.d.ts index 659f45767f..22c7d6b91f 100644 --- a/falcor-router/index.d.ts +++ b/falcor-router/index.d.ts @@ -34,7 +34,7 @@ declare namespace FalcorRouter { type RoutePathSet = FalcorJsonGraph.PathSet; interface CallRoute extends Route { - call(callPath: RoutePathSet, args: Array): RouteResult | Promise; + call(callPath: RoutePathSet, args: Array): CallRouteResult | Promise; } interface GetRoute extends Route { @@ -47,6 +47,7 @@ declare namespace FalcorRouter { type RouteDefinition = GetRoute | SetRoute | CallRoute; type RouteResult = FalcorJsonGraph.PathValue | Array | FalcorJsonGraph.JSONEnvelope; + type CallRouteResult = FalcorJsonGraph.PathValue | FalcorJsonGraph.InvalidPath | Array | FalcorJsonGraph.JSONGraphEnvelope; interface RouterOptions { debug?: boolean; From 62057d84c87a4e4ea995321f8c94d02495eccbec Mon Sep 17 00:00:00 2001 From: David Gee Date: Mon, 20 Mar 2017 18:44:40 -0500 Subject: [PATCH 2/4] Add tests for new call route type definition --- falcor-router/falcor-router-tests.ts | 74 ++++++++++++++++++++++++++++ falcor-router/index.d.ts | 2 +- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/falcor-router/falcor-router-tests.ts b/falcor-router/falcor-router-tests.ts index 5f5bdca0e4..7358ab2e02 100644 --- a/falcor-router/falcor-router-tests.ts +++ b/falcor-router/falcor-router-tests.ts @@ -2,6 +2,7 @@ import falcor = require('falcor'); import Router = require('falcor-router'); +import falcorJsonGraph = require('falcor-json-graph'); new Router([]); new Router([], {}); @@ -100,3 +101,76 @@ new Router([{ } }]); +new Router([{ + route: 'todos.new', + call(callpath, args) { + return {path: 'json.todosById.1234.name', value: 'Buy cheese'}; + } +}]); + +new Router([{ + route: 'todos.new', + call(callpath, args) { + return falcorJsonGraph.pathInvalidation('json.todos.length'); + } +}]); + +new Router([{ + route: 'todos.new', + call(callpath, args) { + return [ + falcorJsonGraph.pathInvalidation('json.todos.length'), + {path: 'json.todosById.1234.name', value: 'Buy cheese'} + ] + } +}]); + +new Router([{ + route: 'todos.new', + call(callpath, args) { + return new Promise((resolve, reject): void => { + resolve([ + falcorJsonGraph.pathInvalidation('json.todos.length'), + {path: 'json.todosById.1234.name', value: 'Buy cheese'} + ]); + }); + } +}]); + +new Router([{ + route: 'todos.new', + call(callpath, args) { + return { + paths: [['json', 'todosById', '1234', 'name']], + jsonGraph: { + json: { + todosById: { + 1234: { + name: 'Buy cheese' + } + } + } + } + }; + } +}]); + +new Router([{ + route: 'todos.new', + call(callpath, args) { + return new Promise((resolve, reject): void => { + resolve({ + paths: [['json', 'todosById', '1234', 'name']], + jsonGraph: { + json: { + todosById: { + 1234: { + name: 'Buy cheese' + } + } + } + } + }); + }); + } +}]); diff --git a/falcor-router/index.d.ts b/falcor-router/index.d.ts index 22c7d6b91f..ca58618053 100644 --- a/falcor-router/index.d.ts +++ b/falcor-router/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for falcor-router 0.4.0 // Project: https://github.com/Netflix/falcor-router -// Definitions by: Quramy +// Definitions by: Quramy and cdhgee // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 8543638e66ddb2217c1e3079d3ad07c5068bf857 Mon Sep 17 00:00:00 2001 From: David Gee Date: Mon, 20 Mar 2017 18:48:05 -0500 Subject: [PATCH 3/4] Amend header in line with test requirements --- falcor-router/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/falcor-router/index.d.ts b/falcor-router/index.d.ts index ca58618053..e1d4cb7873 100644 --- a/falcor-router/index.d.ts +++ b/falcor-router/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for falcor-router 0.4.0 // Project: https://github.com/Netflix/falcor-router -// Definitions by: Quramy and cdhgee +// Definitions by: Quramy +// Definitions by: cdhgee // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 1d46d93298d20ae19ebb6df77c0fed66b9143718 Mon Sep 17 00:00:00 2001 From: David Gee Date: Mon, 20 Mar 2017 18:51:41 -0500 Subject: [PATCH 4/4] Amend header line --- falcor-router/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/falcor-router/index.d.ts b/falcor-router/index.d.ts index e1d4cb7873..daef26f379 100644 --- a/falcor-router/index.d.ts +++ b/falcor-router/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for falcor-router 0.4.0 // Project: https://github.com/Netflix/falcor-router -// Definitions by: Quramy -// Definitions by: cdhgee +// Definitions by: Quramy , cdhgee // Definitions: https://github.com/borisyankov/DefinitelyTyped ///