diff --git a/notNeededPackages.json b/notNeededPackages.json index 2bd15edb68..cf16f8732e 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -468,6 +468,12 @@ "sourceRepoURL": "https://github.com/js-data/js-data", "asOfVersion": "3.0.0" }, + { + "libraryName": "JSData Http Adapter", + "typingsPackageName": "js-data-http", + "sourceRepoURL": "https://github.com/js-data/js-data-http", + "asOfVersion": "3.0.0" + }, { "libraryName": "JSNLog", "typingsPackageName": "jsnlog", diff --git a/types/js-data-http/index.d.ts b/types/js-data-http/index.d.ts deleted file mode 100644 index 62a2c1e25b..0000000000 --- a/types/js-data-http/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Type definitions for JSData Http Adapter 1.2 -// Project: https://github.com/js-data/js-data-http 2.2 -// Definitions by: Stefan Steinhart -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -import * as JSData from 'js-data'; - -declare module 'js-data' { - interface DSHttpAdapterOptions { - serialize?(resourceName: string, data: any): any; - deserialize?(resourceName: string, data: any): any; - queryTransform?(resourceName: string, params: DSFilterParams): any; - httpConfig?: any; - forceTrailingSlash?: boolean; - log?: boolean | ((message?: any, ...optionalParams: any[]) => void); - error?: boolean | ((message?: any, ...optionalParams: any[]) => void); - basePath?: string; - verbsUseBasePath?: string; - } - - interface DSHttpAdapterPromiseResolveType { - data: any; - headers: any; - status: number; - config: any; - } - - interface DSHttpAdapter extends IDSAdapter { - new(options?: DSHttpAdapterOptions): DSHttpAdapter; - - defaults: DSHttpAdapterOptions; - http: any; - - // DSHttpAdapter uses axios so options are axios config objects. - HTTP(options?: Object): JSDataPromise; - DEL(url: string, data?: Object, options?: Object): JSDataPromise; - GET(url: string, data?: Object, options?: Object): JSDataPromise; - POST(url: string, data?: Object, options?: Object): JSDataPromise; - PUT(url: string, data?: Object, options?: Object): JSDataPromise; - } -} - -declare var DSHttpAdapter: JSData.DSHttpAdapter; -export = DSHttpAdapter; -export as namespace DSHttpAdapter; diff --git a/types/js-data-http/js-data-http-tests.ts b/types/js-data-http/js-data-http-tests.ts deleted file mode 100644 index 082d34a71f..0000000000 --- a/types/js-data-http/js-data-http-tests.ts +++ /dev/null @@ -1,173 +0,0 @@ -import * as JSData from 'js-data'; -import DSHttpAdapter = require("js-data-http"); - -declare var axios: any; - -const adapter = new DSHttpAdapter(); -const store = new JSData.DS(); -store.registerAdapter('http', adapter, { default: true }); - -adapter.defaults.basePath = '/api'; -adapter.http = axios; - -const ADocument: JSData.DSResourceDefinition = store.defineResource('document'); - -ADocument.inject({ id: 5, author: 'John' }); - -// bypass the data store -adapter.update(ADocument, 5, { author: 'Johnny' }).then((document: any) => { - document; // { id: 5, author: 'Johnny' } - - // The updated document has NOT been injected into the data store because we bypassed the data store - ADocument.get(document.id); // { id: 5, author: 'John' } -}); - -// Normally you would just go through the data store -ADocument.update(5, { author: 'Johnny' }).then((document: any) => { - document; // { id: 5, author: 'Johnny' } - - // the updated document has been injected into the data store - ADocument.get(document.id); // { id: 5, author: 'Johnny' } -}); - -ADocument.inject({ id: 5, author: 'John' }); -ADocument.inject({ id: 6, author: 'John' }); - -// bypass the data store -adapter.updateAll(ADocument, { author: 'Johnny' }, { author: 'John' }).then(documents => { - documents[0]; // { id: 5, author: 'Johnny' } - - // The updated documents have NOT been injected into the data store because we bypassed the data store - ADocument.filter({ author: 'John' }); // [{...}, {...}] - ADocument.filter({ author: 'Johnny' }); // [] -}); - -// Normally you would just go through the data store -ADocument.updateAll({ author: 'Johnny' }, { author: 'John' }).then(documents => { - documents[0]; // { id: 5, author: 'Johnny' } - - // the updated documents have been injected into the data store - ADocument.filter({ author: 'John' }); // [] - ADocument.filter({ author: 'Johnny' }); // [{...}, {...}] -}); - -adapter.PUT('/user/1', { name: 'Johnny' }).then(data => { - data.data; // { id: 1, name: 'Johnny', ... } - data.headers; // {...} - data.status; // 200 - data.config; // {...} -}); - -adapter.POST('/user/1', { name: 'John' }).then(data => { - data.data; // { id: 1, name: 'John', ... } - data.headers; // {...} - data.status; // 200 - data.config; // {...} -}); - -adapter.HTTP({ url: '/user/1', method: 'put', data: { name: 'Johnny' }}).then(data => { - data.data; // { id: 1, name: 'Johnny', ... } - data.headers; // {...} - data.status; // 200 - data.config; // {...} -}); - -adapter.GET('/user/1').then(data => { - data.data; // { id: 1, ... } - data.headers; // {...} - data.status; // 200 - data.config; // {...} -}); - -const User: JSData.DSResourceDefinition = store.defineResource('user'); - -let params: any = { - age: { - '>': 30 - } -}; - -// bypass the data store -adapter.findAll(User, params).then(users => { - // users[0].age; 55 // etc., etc. - - // the users have NOT been injected into the data store because we bypassed the data store - User.filter(params); // [] -}); - -// normally you would go through the data store -User.findAll(params).then(users => { - // users[0].age; 55 // etc., etc. - - // the users have been injected into the data store - User.filter(params); // [{...}, {...}, ...] -}); - -// bypass the data store -adapter.find(ADocument, 5).then((document: any) => { - document; // { id: 5, author: 'John Anderson' } - - // the document has NOT been injected into the data store because we bypassed the data store - ADocument.get(document.id); // undefined -}); - -// Normally you would just go through the data store -ADocument.find(5).then((document: any) => { - document; // { id: 5, author: 'John Anderson' } - - // the document has been injected into the data store - ADocument.get(document.id); // { id: 5, author: 'John Anderson' } -}); - -params = { - author: 'John' -}; - -// bypass the data store -adapter.destroyAll(ADocument, params).then(() => { - // the documents have NOT been ejected from the data store because we bypassed the data store - ADocument.filter(params); // [{...}, {...}, ...] -}); - -// normally you would go through the data store -ADocument.destroyAll(params).then(() => { - // the documents have been ejected from the data store - ADocument.filter(params); // [] -}); - -ADocument.inject({ id: 5, author: 'John' }); - -// bypass the data store -adapter.destroy(ADocument, 5).then(() => { - // the document is still in the data store because we bypassed the data store - // ADocument.get(document.id); // { id: 5, author: 'John' } -}); - -// Normally you would just go through the data store -ADocument.destroy(5).then(() => { - // the document has been ejected from the data store - // ADocument.get(document.id); // undefined -}); - -adapter.DEL('/user/1').then(data => { - data.data; // 1 - data.headers; // {...} - data.status; // 204 - data.config; // {...} -}); - -// bypass the data store -adapter.create(ADocument, { author: 'John' }).then((document: any) => { - document; // { id: 5, author: 'John' } - - // The new document has NOT been injected into the data store because we bypassed the data store - ADocument.get(document.id); // undefined -}); - -// Normally you would just go through the data store -ADocument.create({ author: 'John' }).then((document: any) => { - document; // { id: 5, author: 'John' } - - // the new document has been injected into the data store - ADocument.get(document.id); // { id: 5, author: 'John' } -}); diff --git a/types/js-data-http/package.json b/types/js-data-http/package.json deleted file mode 100644 index f932c0aa52..0000000000 --- a/types/js-data-http/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "@types/js-data": "^2.8.31" - } -} diff --git a/types/js-data-http/tsconfig.json b/types/js-data-http/tsconfig.json deleted file mode 100644 index 2dcba49575..0000000000 --- a/types/js-data-http/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "js-data-http-tests.ts" - ] -} \ No newline at end of file diff --git a/types/js-data-http/tslint.json b/types/js-data-http/tslint.json deleted file mode 100644 index 38c1ea8606..0000000000 --- a/types/js-data-http/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "ban-types": false, - "no-misused-new": false - } -}