diff --git a/types/feathersjs__authentication-client/feathersjs__authentication-client-tests.ts b/types/feathersjs__authentication-client/feathersjs__authentication-client-tests.ts new file mode 100644 index 0000000000..3d4eb36362 --- /dev/null +++ b/types/feathersjs__authentication-client/feathersjs__authentication-client-tests.ts @@ -0,0 +1,4 @@ +import feathersAuthClient from '@feathersjs/authentication-client'; + +// we can't really do much, because the augmentation of @feathersjs/feathers breaks importing it here. +const configureFn = feathersAuthClient({}); diff --git a/types/feathersjs__authentication-client/feathersjs__feathers.d.ts b/types/feathersjs__authentication-client/feathersjs__feathers.d.ts new file mode 100644 index 0000000000..9c0fa2e05e --- /dev/null +++ b/types/feathersjs__authentication-client/feathersjs__feathers.d.ts @@ -0,0 +1,14 @@ +declare module '@feathersjs/feathers' { + import { + FeathersAuthCredentials, + Passport + } from '@feathersjs/authentication-client'; + + interface Application { + authenticate(options?: FeathersAuthCredentials): Promise; + + logout(): Promise; + + passport: Passport; + } +} diff --git a/types/feathersjs__authentication-client/index.d.ts b/types/feathersjs__authentication-client/index.d.ts new file mode 100644 index 0000000000..a29039aab9 --- /dev/null +++ b/types/feathersjs__authentication-client/index.d.ts @@ -0,0 +1,64 @@ +// Type definitions for @feathersjs/authentication-client 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Abraao Alves , Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +import './feathersjs__feathers'; + +export default function feathersAuthClient(config?: FeathersAuthClientConfig): () => void; + +export interface FeathersAuthClientConfig { + storage?: Storage; + header?: string; + cookie?: string; + storageKey?: string; + jwtStrategy?: string; + path?: string; + entity?: string; + service?: string; +} + +export interface FeathersAuthCredentials { + strategy: string; + + [index: string]: any; +} + +export const defaults: { + header: string; + cookie: string; + storageKey: string; + jwtStrategy: string; + path: string; + entity: string; + service: string; + timeout: number; +}; + +export interface Passport { + setupSocketListeners(): void; + + connected(): Promise; + + authenticate(credentials?: FeathersAuthCredentials): any; + + authenticateSocket(credentials: FeathersAuthCredentials, socket: any, emit: any): any; + + logoutSocket(socket: any, emit: any): Promise; + + logout(): Promise; + + setJWT(data: any): Promise; + + getJWT(): Promise; + + verifyJWT(token: string): Promise; + + payloadIsValid(payload: string): boolean; + + getCookie(name: string): string; + + clearCookie(name: string): null; + + getStorage(storage: any): any; +} diff --git a/types/feathersjs__authentication-client/tsconfig.json b/types/feathersjs__authentication-client/tsconfig.json new file mode 100644 index 0000000000..62adef4864 --- /dev/null +++ b/types/feathersjs__authentication-client/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/authentication-client": ["feathersjs__authentication-client"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__authentication-client-tests.ts" + ] +} diff --git a/types/feathersjs__authentication-client/tslint.json b/types/feathersjs__authentication-client/tslint.json new file mode 100644 index 0000000000..a7da90ce21 --- /dev/null +++ b/types/feathersjs__authentication-client/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "strict-export-declare-modifiers": false +} diff --git a/types/feathersjs__authentication-jwt/feathersjs__authentication-jwt-tests.ts b/types/feathersjs__authentication-jwt/feathersjs__authentication-jwt-tests.ts new file mode 100644 index 0000000000..cdcefdcef7 --- /dev/null +++ b/types/feathersjs__authentication-jwt/feathersjs__authentication-jwt-tests.ts @@ -0,0 +1,4 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersAuthenticationJwt from '@feathersjs/authentication-jwt'; + +const app: Application<{}> = feathers().configure(feathersAuthenticationJwt()); diff --git a/types/feathersjs__authentication-jwt/index.d.ts b/types/feathersjs__authentication-jwt/index.d.ts new file mode 100644 index 0000000000..cc9e58be0d --- /dev/null +++ b/types/feathersjs__authentication-jwt/index.d.ts @@ -0,0 +1,68 @@ +// Type definitions for @feathersjs/authentication-jwt 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.2 + +import { Application } from '@feathersjs/feathers'; +import { Request } from 'express'; + +export default function feathersAuthenticationJwt(options?: FeathersAuthenticationJWTOptions): () => void; + +export interface FeathersAuthenticationJWTOptions { + /** + * the name to use when invoking the authentication Strategy + */ + name: string; + /** + * the entity that you pull from if an 'id' is present in the payload + */ + entity: string; + /** + * the service to look up the entity + */ + service: string; + /** + * whether the request object should be passed to `verify` + */ + passReqToCallback: boolean; + /** + * a passport-jwt option determining where to parse the JWT + */ + jwtFromRequest: JwtFromRequestFunction; + /** + * Your main secret provided to passport-jwt + */ + secretOrKey: string; + /** + * whether to use sessions, + */ + session: boolean; + /** + * A Verifier class. Defaults to the built-in one but can be a custom one. See below for details. + */ + Verifier: JWTVerifier; +} + +export class JWTVerifier { + constructor(app: Application, options: any); // the class constructor + + verify(req: Request, payload: any, done: (error: any, user?: any, info?: any) => void): void; +} + +export type JwtFromRequestFunction = (req: Request) => string; + +export const ExtractJWT: { + fromHeader(header_name: string): JwtFromRequestFunction; + fromBodyField(field_name: string): JwtFromRequestFunction; + fromUrlQueryParameter(param_name: string): JwtFromRequestFunction; + fromAuthHeaderWithScheme(auth_scheme: string): JwtFromRequestFunction; + fromAuthHeader(): JwtFromRequestFunction; + fromExtractors(extractors: JwtFromRequestFunction[]): JwtFromRequestFunction; + fromAuthHeaderAsBearerToken(): JwtFromRequestFunction; +}; + +export const defaults: { + name: string; + bodyKey: string; +}; diff --git a/types/feathersjs__authentication-jwt/tsconfig.json b/types/feathersjs__authentication-jwt/tsconfig.json new file mode 100644 index 0000000000..9845c047e6 --- /dev/null +++ b/types/feathersjs__authentication-jwt/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/authentication-jwt": ["feathersjs__authentication-jwt"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__authentication-jwt-tests.ts" + ] +} diff --git a/types/feathersjs__authentication-jwt/tslint.json b/types/feathersjs__authentication-jwt/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__authentication-jwt/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__authentication-local/feathersjs__authentication-local-tests.ts b/types/feathersjs__authentication-local/feathersjs__authentication-local-tests.ts new file mode 100644 index 0000000000..67a3db2c96 --- /dev/null +++ b/types/feathersjs__authentication-local/feathersjs__authentication-local-tests.ts @@ -0,0 +1,4 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersAuthenticationLocal from '@feathersjs/authentication-local'; + +const app: Application<{}> = feathers().configure(feathersAuthenticationLocal()); diff --git a/types/feathersjs__authentication-local/index.d.ts b/types/feathersjs__authentication-local/index.d.ts new file mode 100644 index 0000000000..8b6af17a33 --- /dev/null +++ b/types/feathersjs__authentication-local/index.d.ts @@ -0,0 +1,76 @@ +// Type definitions for @feathersjs/authentication-local 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.2 + +import { + Application, + Hook, + Paginated +} from '@feathersjs/feathers'; +import { Request } from 'express'; + +export default function feathersAuthenticationLocal(options?: FeathersAuthenticationLocalOptions): () => void; + +export interface FeathersAuthenticationLocalOptions { + /** + * the name to use when invoking the authentication Strategy + */ + name: string; + /** + * the entity that you're comparing username/password against + */ + entity: string; + /** + * the service to look up the entity + */ + service: string; + /** + * key name of username field on the request + */ + usernameField: string; + /** + * key name of password field on the request + */ + passwordField: string; + /** + * key name of the username field on the entity (defaults to `usernameField`) + */ + entityUsernameField: string; + /** + * key name of the password on the entity (defaults to `passwordField`) + */ + entityPasswordField: string; + /** + * whether the request object should be passed to `verify` + */ + passReqToCallback: boolean; + /** + * whether to use sessions, + */ + session: boolean; + /** + * A Verifier class. Defaults to the built-in one but can be a custom one. See below for details. + */ + Verifier: LocalVerifier; +} + +export class LocalVerifier { + constructor(app: Application, options: any); + + _comparePassword(entity: T, password: string): Promise; // compares password using bcrypt + _normalizeResult(results: T[] | Paginated): Promise; // normalizes result from service to account for pagination + verify(req: Request, username: string, password: string, done: (error: any, user?: any, options?: { message: string }) => void): void; +} + +export namespace hooks { + function hashPassword(options?: any): Hook; // todo: properly type options + function protect(...fields: string[]): Hook; +} + +export const defaults: { + name: string; + usernameField: string; + passwordField: string; +}; diff --git a/types/feathersjs__authentication-local/tsconfig.json b/types/feathersjs__authentication-local/tsconfig.json new file mode 100644 index 0000000000..1972b0a171 --- /dev/null +++ b/types/feathersjs__authentication-local/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/authentication-local": ["feathersjs__authentication-local"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__authentication-local-tests.ts" + ] +} diff --git a/types/feathersjs__authentication-local/tslint.json b/types/feathersjs__authentication-local/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__authentication-local/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__authentication-oauth1/feathersjs__authentication-oauth1-tests.ts b/types/feathersjs__authentication-oauth1/feathersjs__authentication-oauth1-tests.ts new file mode 100644 index 0000000000..78d1fb358f --- /dev/null +++ b/types/feathersjs__authentication-oauth1/feathersjs__authentication-oauth1-tests.ts @@ -0,0 +1,4 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersAuthenticationOAuth1 from '@feathersjs/authentication-oauth1'; + +const app: Application<{}> = feathers().configure(feathersAuthenticationOAuth1()); diff --git a/types/feathersjs__authentication-oauth1/index.d.ts b/types/feathersjs__authentication-oauth1/index.d.ts new file mode 100644 index 0000000000..54d4d2614a --- /dev/null +++ b/types/feathersjs__authentication-oauth1/index.d.ts @@ -0,0 +1,69 @@ +// Type definitions for @feathersjs/authentication-oauth1 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.2 + +import { + Application, + Paginated +} from '@feathersjs/feathers'; +import { Request } from 'express'; + +export default function feathersAuthenticationOAuth1(options?: FeathersAuthenticationOAuth1Options): () => void; + +export interface FeathersAuthenticationOAuth1Options { + /** + * The field to look up the entity by when logging in with the provider. Defaults to 'Id' (ie. 'twitterId'). + */ + idField: string; + /** + * The route to register the middleware + */ + path: string; + /** + * The route to register the callback handler + */ + callbackPath: string; + /** + * hostname[:port]/auth//callback', + */ + callbackURL: string; + /** + * the entity that you are looking up + */ + entity: string; + /** + * the service to look up the entity + */ + service: string; + /** + * whether the request object should be passed to `verify` + */ + passReqToCallback: boolean; + /** + * whether to use sessions, + */ + session: boolean; + /** + * Express middleware for handling the oauth callback. Defaults to the built in middleware. todo: needs a proper type + */ + handler: any; + /** + * The response formatter. Defaults the the built in feathers-rest formatter, which returns JSON. todo: needs a proper type + */ + formatter: any; + /** + * A Verifier class. Defaults to the built-in one but can be a custom one. See below for details. + */ + Verifier: OAuth1Verifier; +} + +export class OAuth1Verifier { + constructor(app: Application, options: any); + + _updateEntity(entity: any, data: { profile: any, accessToken: string, refreshToken: string }): Promise; // updates an existing entity + _createEntity(data: { profile: any, accessToken: string, refreshToken: string }): Promise; // creates an entity if they didn't exist already + _normalizeResult(results: T[] | Paginated): Promise; // normalizes result from service to account for pagination + verify(req: Request, accessToken: string, refreshToken: string, profile: any, done: (err: Error | null, user: object, info: object) => void): void; +} diff --git a/types/feathersjs__authentication-oauth1/tsconfig.json b/types/feathersjs__authentication-oauth1/tsconfig.json new file mode 100644 index 0000000000..0a57818109 --- /dev/null +++ b/types/feathersjs__authentication-oauth1/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/authentication-oauth1": ["feathersjs__authentication-oauth1"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__authentication-oauth1-tests.ts" + ] +} diff --git a/types/feathersjs__authentication-oauth1/tslint.json b/types/feathersjs__authentication-oauth1/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__authentication-oauth1/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__authentication-oauth2/feathersjs__authentication-oauth2-tests.ts b/types/feathersjs__authentication-oauth2/feathersjs__authentication-oauth2-tests.ts new file mode 100644 index 0000000000..f5ebaa4c1a --- /dev/null +++ b/types/feathersjs__authentication-oauth2/feathersjs__authentication-oauth2-tests.ts @@ -0,0 +1,4 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersAuthenticationOAuth2 from '@feathersjs/authentication-oauth2'; + +const app: Application<{}> = feathers().configure(feathersAuthenticationOAuth2()); diff --git a/types/feathersjs__authentication-oauth2/index.d.ts b/types/feathersjs__authentication-oauth2/index.d.ts new file mode 100644 index 0000000000..5ac6976dac --- /dev/null +++ b/types/feathersjs__authentication-oauth2/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for @feathersjs/authentication-oauth2 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.2 + +import { + Application, + Paginated +} from '@feathersjs/feathers'; +import { Request } from 'express'; + +export default function feathersAuthenticationOAuth2(options?: FeathersAuthenticationOAuth2Options): () => void; + +export interface FeathersAuthenticationOAuth2Options { + /** + * The field to look up the entity by when logging in with the provider. Defaults to 'Id' (ie. 'facebookId'). + */ + idField: string; + /** + * The route to register the middleware + */ + path: string; + /** + * The route to register the callback handler + */ + callbackPath: string; + /** + * The callback url. + */ + callbackURL: string; + successRedirect: string; + failureRedirect: string; + /** + * the entity that you are looking up + */ + entity: string; + /** + * the service to look up the entity + */ + service: string; + /** + * whether the request object should be passed to `verify` + */ + passReqToCallback: boolean; + /** + * whether to use sessions, + */ + session: boolean; + /** + * Express middleware for handling the oauth callback. Defaults to the built in middleware. todo: needs a proper type + */ + handler: any; + /** + * The response formatter. Defaults the the built in feathers-rest formatter, which returns JSON. todo: needs a proper type + */ + formatter: any; + /** + * A Verifier class. Defaults to the built-in one but can be a custom one. See below for details. + */ + Verifier: OAuth2Verifier; +} + +export class OAuth2Verifier { + constructor(app: Application, options: any) + + _updateEntity(entity: any, data: { profile: any, accessToken: string, refreshToken: string }): Promise; // updates an existing entity + _createEntity(data: { profile: any, accessToken: string, refreshToken: string }): Promise; // creates an entity if they didn't exist already + _normalizeResult(results: T[] | Paginated): Promise; // normalizes result from service to account for pagination + verify(req: Request, accessToken: string, refreshToken: string, profile: any, done: (err: Error | null, user: object, info: object) => void): void; +} diff --git a/types/feathersjs__authentication-oauth2/tsconfig.json b/types/feathersjs__authentication-oauth2/tsconfig.json new file mode 100644 index 0000000000..6c347cef78 --- /dev/null +++ b/types/feathersjs__authentication-oauth2/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/authentication-oauth2": ["feathersjs__authentication-oauth2"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__authentication-oauth2-tests.ts" + ] +} diff --git a/types/feathersjs__authentication-oauth2/tslint.json b/types/feathersjs__authentication-oauth2/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__authentication-oauth2/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__authentication/feathersjs__authentication-tests.ts b/types/feathersjs__authentication/feathersjs__authentication-tests.ts new file mode 100644 index 0000000000..59eb096902 --- /dev/null +++ b/types/feathersjs__authentication/feathersjs__authentication-tests.ts @@ -0,0 +1,4 @@ +import feathers from '@feathersjs/feathers'; +import feathersAuthentication from '@feathersjs/authentication'; + +feathers().configure(feathersAuthentication({})); diff --git a/types/feathersjs__authentication/index.d.ts b/types/feathersjs__authentication/index.d.ts new file mode 100644 index 0000000000..3a4722f12e --- /dev/null +++ b/types/feathersjs__authentication/index.d.ts @@ -0,0 +1,106 @@ +// Type definitions for @feathersjs/authentication 2.1 +// Project: http://feathersjs.com/ +// Definitions by: Abraao Alves , Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +import { Hook } from '@feathersjs/feathers'; + +export default function feathersAuthentication(config?: FeathersAuthenticationOptions): () => void; + +export const hooks: AuthHooks.Hooks; + +export interface FeathersAuthenticationOptions { + path?: string; + header?: string; + entity?: string; + service?: string; + passReqToCallback?: boolean; + session?: boolean; + cookie?: { + enabled?: boolean; + name?: string; + httpOnly?: boolean; + secure?: boolean; + }; + jwt?: { + /** + * By default is an access token + */ + header?: { + [key: string]: any + }; + + /** + * The resource server where the token is processed + */ + audience?: string; + + /** + * Typically the entity id associated with the JWT + */ + subject?: string; + + /** + * The issuing server, application or resource + */ + issuer?: string; + algorithm?: string; + expiresIn?: string; + }; +} + +export namespace AuthHooks { + interface HashPassOptions { + passwordField: string; + } + + interface RestrictOptions { + ownerField: string; + idField: string; + } + + interface Hooks { + authenticate(strategies: string[] | string): Hook; + + /** + * The `verifyToken` hook will attempt to verify a token. + * If the token is missing or is invalid it returns an error. + * If the token is valid it adds the decrypted payload to hook.params.payload which contains the user id. + * It is intended to be used as a before hook on any of the service methods. + * + */ + verifyToken(options?: any): Hook; + + /** + * The populateUser hook is for populating a user based on an id. + * It can be used on any service method as either a before or after hook. + * It is called internally after a token is created. + * + */ + populateUser(options?: any): Hook; + + /** + * The `restrictToAuthenticated` hook throws an error if there isn't a logged-in user by checking for the `hook.params.user` object. + * It can be used on any service method and is intended to be used as a before hook. + * It doesn't take any arguments. + * + */ + restrictToAuthenticated(): Hook; + + /** + * `restrictToOwner` is meant to be used as a before hook. + * It only allows the user to retrieve resources that are owned by them. + * It will return a *Forbidden* error without the proper permissions. + * It can be used on `get`, `create`, `update`, `patch` or `remove` methods. + * + */ + restrictToOwner(options?: RestrictOptions): Hook; + + /** + * The `hashPassword` hook will automatically hash the data coming in on the provided passwordField. + * It is intended to be used as a before hook on the user service for the create, update, or patch methods. + * + */ + hashPassword(options?: HashPassOptions): Hook; + } +} diff --git a/types/feathersjs__authentication/tsconfig.json b/types/feathersjs__authentication/tsconfig.json new file mode 100644 index 0000000000..8cb6f348ed --- /dev/null +++ b/types/feathersjs__authentication/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/authentication": ["feathersjs__authentication"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__authentication-tests.ts" + ] +} diff --git a/types/feathersjs__authentication/tslint.json b/types/feathersjs__authentication/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__authentication/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__configuration/feathersjs__configuration-tests.ts b/types/feathersjs__configuration/feathersjs__configuration-tests.ts new file mode 100644 index 0000000000..10e74958f1 --- /dev/null +++ b/types/feathersjs__configuration/feathersjs__configuration-tests.ts @@ -0,0 +1,4 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersConfiguration from '@feathersjs/configuration'; + +const app: Application<{}> = feathers().configure(feathersConfiguration()); diff --git a/types/feathersjs__configuration/index.d.ts b/types/feathersjs__configuration/index.d.ts new file mode 100644 index 0000000000..fe597c8360 --- /dev/null +++ b/types/feathersjs__configuration/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for @feathersjs/configuration 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +import { Application } from '@feathersjs/feathers'; + +export default function feathersConfiguration(): (app: Application) => Application; diff --git a/types/feathersjs__configuration/tsconfig.json b/types/feathersjs__configuration/tsconfig.json new file mode 100644 index 0000000000..4ff80d4bea --- /dev/null +++ b/types/feathersjs__configuration/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/configuration": ["feathersjs__configuration"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__configuration-tests.ts" + ] +} diff --git a/types/feathersjs__configuration/tslint.json b/types/feathersjs__configuration/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__configuration/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__errors/feathersjs__errors-tests.ts b/types/feathersjs__errors/feathersjs__errors-tests.ts new file mode 100644 index 0000000000..977040010a --- /dev/null +++ b/types/feathersjs__errors/feathersjs__errors-tests.ts @@ -0,0 +1,25 @@ +import { + BadGateway, + BadRequest, Conflict, FeathersError, Forbidden, GeneralError, LengthRequired, MethodNotAllowed, NotAcceptable, + NotAuthenticated, NotFound, NotImplemented, PaymentError, Timeout, TooManyRequests, Unavailable, Unprocessable +} from '@feathersjs/errors'; + +import * as errHandler from '@feathersjs/errors/handler'; +import * as notFound from '@feathersjs/errors/not-found'; + +const e0: FeathersError = new BadRequest('test'); +const e1: FeathersError = new NotAuthenticated('test'); +const e2: FeathersError = new PaymentError('test'); +const e3: FeathersError = new Forbidden('test'); +const e4: FeathersError = new NotFound('test'); +const e5: FeathersError = new MethodNotAllowed('test'); +const e6: FeathersError = new NotAcceptable('test'); +const e7: FeathersError = new Timeout('test'); +const e8: FeathersError = new Conflict('test'); +const e9: FeathersError = new LengthRequired('test'); +const e10: FeathersError = new Unprocessable('test'); +const e11: FeathersError = new TooManyRequests('test'); +const e12: FeathersError = new GeneralError('test'); +const e13: FeathersError = new NotImplemented('test'); +const e14: FeathersError = new BadGateway('test'); +const e15: FeathersError = new Unavailable('test'); diff --git a/types/feathersjs__errors/handler.d.ts b/types/feathersjs__errors/handler.d.ts new file mode 100644 index 0000000000..4525e39773 --- /dev/null +++ b/types/feathersjs__errors/handler.d.ts @@ -0,0 +1,7 @@ +import { ErrorRequestHandler } from 'express'; + +declare function handler(options?: any): ErrorRequestHandler; + +declare namespace handler {} + +export = handler; diff --git a/types/feathersjs__errors/index.d.ts b/types/feathersjs__errors/index.d.ts new file mode 100644 index 0000000000..9eacd9ce7e --- /dev/null +++ b/types/feathersjs__errors/index.d.ts @@ -0,0 +1,98 @@ +// Type definitions for @feathersjs/errors 3.2 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.2 + +export class FeathersError extends Error { + constructor(msg: string | Error, name: string, code: number, className: string, data: any) +} + +export class BadRequest extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class NotAuthenticated extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class PaymentError extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class Forbidden extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class NotFound extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class MethodNotAllowed extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class NotAcceptable extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class Timeout extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class Conflict extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class LengthRequired extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class Unprocessable extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class TooManyRequests extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class GeneralError extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class NotImplemented extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class BadGateway extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export class Unavailable extends FeathersError { + constructor(msg: string | Error, data?: any); +} + +export interface Errors { + FeathersError: FeathersError; + BadRequest: BadRequest; + NotAuthenticated: NotAuthenticated; + PaymentError: PaymentError; + Forbidden: Forbidden; + NotFound: NotFound; + MethodNotAllowed: MethodNotAllowed; + NotAcceptable: NotAcceptable; + Timeout: Timeout; + Conflict: Conflict; + LengthRequired: LengthRequired; + Unprocessable: Unprocessable; + TooManyRequests: TooManyRequests; + GeneralError: GeneralError; + NotImplemented: NotImplemented; + BadGateway: BadGateway; + Unavailable: Unavailable; +} + +export function convert(error: any): FeathersError; + +export const types: Errors; +export const errors: Errors; diff --git a/types/feathersjs__errors/not-found.d.ts b/types/feathersjs__errors/not-found.d.ts new file mode 100644 index 0000000000..453b3aded9 --- /dev/null +++ b/types/feathersjs__errors/not-found.d.ts @@ -0,0 +1,7 @@ +import { RequestHandler } from 'express'; + +declare function notFound(): RequestHandler; + +declare namespace notFound {} + +export = notFound; diff --git a/types/feathersjs__errors/tsconfig.json b/types/feathersjs__errors/tsconfig.json new file mode 100644 index 0000000000..f07ee484aa --- /dev/null +++ b/types/feathersjs__errors/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/errors": ["feathersjs__errors"], + "@feathersjs/errors/handler": ["feathersjs__errors/handler"], + "@feathersjs/errors/not-found": ["feathersjs__errors/not-found"] + } + }, + "files": [ + "index.d.ts", "feathersjs__errors-tests.ts", "handler.d.ts", "not-found.d.ts" + ] +} diff --git a/types/feathersjs__errors/tslint.json b/types/feathersjs__errors/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__errors/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__express/feathersjs__express-tests.ts b/types/feathersjs__express/feathersjs__express-tests.ts new file mode 100644 index 0000000000..d7f981eaa0 --- /dev/null +++ b/types/feathersjs__express/feathersjs__express-tests.ts @@ -0,0 +1,5 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersExpress from '@feathersjs/express'; +import { Application as ExpressApplication } from 'express'; + +const app: ExpressApplication & Application<{}> = feathersExpress(feathers()); diff --git a/types/feathersjs__express/index.d.ts b/types/feathersjs__express/index.d.ts new file mode 100644 index 0000000000..2bce8b54dd --- /dev/null +++ b/types/feathersjs__express/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @feathersjs/express 1.1 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript +// TypeScript Version: 2.2 + +import { Application as FeathersApplication } from '@feathersjs/feathers'; +import { Application as ExpressApplication } from 'express'; + +export default function feathersExpress(app: FeathersApplication): ExpressApplication & FeathersApplication; diff --git a/types/feathersjs__express/tsconfig.json b/types/feathersjs__express/tsconfig.json new file mode 100644 index 0000000000..8489861fc9 --- /dev/null +++ b/types/feathersjs__express/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/express": ["feathersjs__express"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__express-tests.ts" + ] +} diff --git a/types/feathersjs__express/tslint.json b/types/feathersjs__express/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__express/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__feathers/feathersjs__feathers-tests.ts b/types/feathersjs__feathers/feathersjs__feathers-tests.ts new file mode 100644 index 0000000000..a624187c68 --- /dev/null +++ b/types/feathersjs__feathers/feathersjs__feathers-tests.ts @@ -0,0 +1,16 @@ +import feathers, { Application } from '@feathersjs/feathers'; + +interface User { + id: number; + name: string; +} + +interface Services { + users: User; +} + +const app = feathers() as Application; + +app.service('users').get(0).then(u => { + const user: User = u; +}); diff --git a/types/feathersjs__feathers/index.d.ts b/types/feathersjs__feathers/index.d.ts new file mode 100644 index 0000000000..c10a173f06 --- /dev/null +++ b/types/feathersjs__feathers/index.d.ts @@ -0,0 +1,135 @@ +// Type definitions for @feathersjs/feathers 3.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage , Abraao Alves +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +// TypeScript Version: 2.2 + +/// + +import { EventEmitter } from 'events'; + +export default function feathers(): Application; + +export const version: string; + +export type Id = number | string; +export type NullableId = Id | null; + +export interface Query { + [key: string]: any; +} + +export interface PaginationOptions { + default: number; + max: number; +} + +export type ClientSideParams = Pick; +export type ServerSideParams = Params; + +export interface Params { + query?: Query; + paginate: false | Pick; + + [key: string]: any; // (JL) not sure if we want this +} + +export interface Paginated { + total: number; + limit: number; + skip: number; + data: T[]; +} + +export type Hook = (hook: HookContext) => (Promise> | undefined); + +export interface HookContext { + app?: Application; + data?: T; + error?: any; + id?: string | number; + method?: string; + params?: Params; + path?: string; + result?: T; + service: Service; + type: 'before' | 'after' | 'error'; +} + +export interface HookMap { + all: Hook | Hook[]; + find: Hook | Hook[]; + get: Hook | Hook[]; + create: Hook | Hook[]; + update: Hook | Hook[]; + patch: Hook | Hook[]; + remove: Hook | Hook[]; +} + +export interface HooksObject { + before: Partial; + after: Partial; + error: Partial; +} + +// todo: figure out what to do: These methods don't actually need to be implemented, so they can be undefined at runtime. Yet making them optional gets cumbersome in strict mode. +export interface ServiceMethods { + find(params?: Params): Promise>; + + get(id: Id, params?: Params): Promise; + + create(data: Partial | Array>, params?: Params): Promise; + + update(id: NullableId, data: T, params?: Params): Promise; + + patch(id: NullableId, data: Partial, params?: Params): Promise; + + remove(id: NullableId, params?: Params): Promise; +} + +export interface SetupMethod { + setup(app: Application, path: string): void; +} + +export interface ServiceOverloads { + create(data: Array>, params?: Params): Promise; + + create(data: Partial, params?: Params): Promise; + + patch(id: NullableId, data: Pick, params?: Params): Promise; +} + +export interface ServiceAddons extends EventEmitter { + hooks(hooks: Partial): this; +} + +export type Service = ServiceOverloads & ServiceAddons & ServiceMethods; + +export interface Application extends EventEmitter { + get(name: string): any; + + set(name: string, value: any): this; + + disable(name: string): this; + + disabled(name: string): boolean; + + enable(name: string): this; + + enabled(name: string): boolean; + + configure(callback: (this: this, app: this) => void): this; + + hooks(hooks: Partial): this; + + setup(server?: any): this; + + service(location: L): Service; + + service(location: string): Service; + + use(path: string, service: Partial & SetupMethod> | Application, options?: any): this; + + version: string; +} diff --git a/types/feathersjs__feathers/tsconfig.json b/types/feathersjs__feathers/tsconfig.json new file mode 100644 index 0000000000..b4eeb705cc --- /dev/null +++ b/types/feathersjs__feathers/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es2015" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__feathers-tests.ts" + ] +} diff --git a/types/feathersjs__feathers/tslint.json b/types/feathersjs__feathers/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__feathers/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__primus-client/feathersjs__primus-client-tests.ts b/types/feathersjs__primus-client/feathersjs__primus-client-tests.ts new file mode 100644 index 0000000000..66b2553c63 --- /dev/null +++ b/types/feathersjs__primus-client/feathersjs__primus-client-tests.ts @@ -0,0 +1,4 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersPrimusClient from '@feathersjs/primus-client'; + +const app: Application<{}> = feathers().configure(feathersPrimusClient({})); diff --git a/types/feathersjs__primus-client/index.d.ts b/types/feathersjs__primus-client/index.d.ts new file mode 100644 index 0000000000..4e51cd159c --- /dev/null +++ b/types/feathersjs__primus-client/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for @feathersjs/primus-client 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +// primus removed its typings from the repo https://github.com/primus/primus/pull/623, as of 01/2018 there are none on DT +export default function feathersPrimusClient(socket: any, options?: FeathersPrimusClientOptions): () => void; + +export interface FeathersPrimusClientOptions { + timeout?: number; +} diff --git a/types/feathersjs__primus-client/tsconfig.json b/types/feathersjs__primus-client/tsconfig.json new file mode 100644 index 0000000000..2c798b2f88 --- /dev/null +++ b/types/feathersjs__primus-client/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/primus-client": ["feathersjs__primus-client"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__primus-client-tests.ts" + ] +} diff --git a/types/feathersjs__primus-client/tslint.json b/types/feathersjs__primus-client/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__primus-client/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__primus/feathersjs__primus-tests.ts b/types/feathersjs__primus/feathersjs__primus-tests.ts new file mode 100644 index 0000000000..1b4202afc6 --- /dev/null +++ b/types/feathersjs__primus/feathersjs__primus-tests.ts @@ -0,0 +1,4 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersPrimus from '@feathersjs/primus'; + +const app: Application<{}> = feathers().configure(feathersPrimus({})); diff --git a/types/feathersjs__primus/index.d.ts b/types/feathersjs__primus/index.d.ts new file mode 100644 index 0000000000..9218a6a40e --- /dev/null +++ b/types/feathersjs__primus/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for @feathersjs/primus 3.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +// primus removed its typings from the repo https://github.com/primus/primus/pull/623, as of 01/2018 there are none on DT +export default function feathersPrimus(options: any, callback?: (primus: any) => void): () => void; diff --git a/types/feathersjs__primus/tsconfig.json b/types/feathersjs__primus/tsconfig.json new file mode 100644 index 0000000000..ca7b8a3077 --- /dev/null +++ b/types/feathersjs__primus/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/primus": ["feathersjs__primus"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__primus-tests.ts" + ] +} diff --git a/types/feathersjs__primus/tslint.json b/types/feathersjs__primus/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__primus/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__rest-client/feathersjs__rest-client-tests.ts b/types/feathersjs__rest-client/feathersjs__rest-client-tests.ts new file mode 100644 index 0000000000..2b7e49481e --- /dev/null +++ b/types/feathersjs__rest-client/feathersjs__rest-client-tests.ts @@ -0,0 +1 @@ +const dummy: any = null; diff --git a/types/feathersjs__rest-client/index.d.ts b/types/feathersjs__rest-client/index.d.ts new file mode 100644 index 0000000000..22e5f1084b --- /dev/null +++ b/types/feathersjs__rest-client/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for @feathersjs/rest-client 1.3 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +// todo: get rid of all the anys + +export default function feathersRestClient(base: string): Transport; + +export interface HandlerResult extends Function { + /** + * initialize service + */ + (): void; + + /** + * Transport Service + */ + Service: any; + + /** + * default Service + */ + service: any; +} + +export type Handler = (connection: any, options?: any) => () => HandlerResult; + +export interface Transport { + jquery: Handler; + superagent: Handler; + request: Handler; + fetch: Handler; + axios: Handler; + angular: Handler; + angularHttpClient: Handler; +} diff --git a/types/feathersjs__rest-client/tsconfig.json b/types/feathersjs__rest-client/tsconfig.json new file mode 100644 index 0000000000..f63a18a220 --- /dev/null +++ b/types/feathersjs__rest-client/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/rest-client": ["feathersjs__rest-client"] + } + }, + "files": [ + "index.d.ts", "feathersjs__rest-client-tests.ts" + ] +} diff --git a/types/feathersjs__rest-client/tslint.json b/types/feathersjs__rest-client/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__rest-client/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__socket-commons/feathers.d.ts b/types/feathersjs__socket-commons/feathers.d.ts new file mode 100644 index 0000000000..08438e4899 --- /dev/null +++ b/types/feathersjs__socket-commons/feathers.d.ts @@ -0,0 +1,18 @@ +declare module '@feathersjs/feathers' { + import { Channel } from '@feathersjs/socket-commons'; + import { HookContext } from '@feathersjs/feathers'; + + export interface ServiceAddons { + publish(callback: (data: T, hook: HookContext) => Channel): this + + publish(event: string, callback: (data: T, hook: HookContext) => Channel): this + } + + export interface Application { + channel(...names: string[]): Channel; + + publish(callback: (data: T, hook: HookContext) => Channel | Channel[]): Application; + + publish(event: string, callback: (data: T, hook: HookContext) => Channel | Channel[]): Application; + } +} diff --git a/types/feathersjs__socket-commons/feathersjs__socket-commons-tests.ts b/types/feathersjs__socket-commons/feathersjs__socket-commons-tests.ts new file mode 100644 index 0000000000..2b7e49481e --- /dev/null +++ b/types/feathersjs__socket-commons/feathersjs__socket-commons-tests.ts @@ -0,0 +1 @@ +const dummy: any = null; diff --git a/types/feathersjs__socket-commons/index.d.ts b/types/feathersjs__socket-commons/index.d.ts new file mode 100644 index 0000000000..38d46a0ec5 --- /dev/null +++ b/types/feathersjs__socket-commons/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for @feathersjs/socket-commons 3.1 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +import './socket-commons'; +import './feathers'; diff --git a/types/feathersjs__socket-commons/socket-commons.d.ts b/types/feathersjs__socket-commons/socket-commons.d.ts new file mode 100644 index 0000000000..2f32f24bd4 --- /dev/null +++ b/types/feathersjs__socket-commons/socket-commons.d.ts @@ -0,0 +1,13 @@ +declare module '@feathersjs/socket-commons' { + export type Connection = any; // todo: spec connection + + export interface Channel { + join(...connections: Connection[]): this; + + leave(...connections: Connection[]): this; + + filter(callback: (connection: Connection) => boolean): Channel; + + send(data: any): this; + } +} diff --git a/types/feathersjs__socket-commons/tsconfig.json b/types/feathersjs__socket-commons/tsconfig.json new file mode 100644 index 0000000000..6532818264 --- /dev/null +++ b/types/feathersjs__socket-commons/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/socket-commons": ["feathersjs__socket-commons"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__socket-commons-tests.ts" + ] +} diff --git a/types/feathersjs__socket-commons/tslint.json b/types/feathersjs__socket-commons/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__socket-commons/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__socketio-client/feathersjs__socketio-client-tests.ts b/types/feathersjs__socketio-client/feathersjs__socketio-client-tests.ts new file mode 100644 index 0000000000..80fa6cf4ba --- /dev/null +++ b/types/feathersjs__socketio-client/feathersjs__socketio-client-tests.ts @@ -0,0 +1,10 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersSocketIOClient from '@feathersjs/socketio-client'; + +import * as io from 'socket.io-client'; + +const socket = io(); +const app: Application<{}> = feathers(); + +app.configure(feathersSocketIOClient(socket)); +app.configure(feathersSocketIOClient(socket, { timeout: 1337 })); diff --git a/types/feathersjs__socketio-client/index.d.ts b/types/feathersjs__socketio-client/index.d.ts new file mode 100644 index 0000000000..f155bc50de --- /dev/null +++ b/types/feathersjs__socketio-client/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for @feathersjs/socketio-client 1.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +/// + +export default function feathersSocketIOClient(socket: SocketIOClient.Socket, options?: FeathersSocketIOClientOptions): () => void; + +export interface FeathersSocketIOClientOptions { + timeout?: number; +} diff --git a/types/feathersjs__socketio-client/tsconfig.json b/types/feathersjs__socketio-client/tsconfig.json new file mode 100644 index 0000000000..ffea4d4f91 --- /dev/null +++ b/types/feathersjs__socketio-client/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/socketio-client": ["feathersjs__socketio-client"], + "@feathersjs/feathers": ["feathersjs__feathers"] + + } + }, + "files": [ + "index.d.ts", "feathersjs__socketio-client-tests.ts" + ] +} diff --git a/types/feathersjs__socketio-client/tslint.json b/types/feathersjs__socketio-client/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__socketio-client/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/feathersjs__socketio/feathersjs__socketio-tests.ts b/types/feathersjs__socketio/feathersjs__socketio-tests.ts new file mode 100644 index 0000000000..5b997b25a4 --- /dev/null +++ b/types/feathersjs__socketio/feathersjs__socketio-tests.ts @@ -0,0 +1,10 @@ +import feathers, { Application } from '@feathersjs/feathers'; +import feathersSocketIO from '@feathersjs/socketio'; + +const app: Application<{}> = feathers(); + +app.configure(feathersSocketIO(1337, {})); +app.configure(feathersSocketIO(io => {})); +app.configure(feathersSocketIO({}, io => {})); +app.configure(feathersSocketIO(1337, io => {})); +app.configure(feathersSocketIO(1337, {}, io => {})); diff --git a/types/feathersjs__socketio/index.d.ts b/types/feathersjs__socketio/index.d.ts new file mode 100644 index 0000000000..3994f73537 --- /dev/null +++ b/types/feathersjs__socketio/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @feathersjs/socketio 3.0 +// Project: http://feathersjs.com/ +// Definitions by: Jan Lohage +// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript + +/// + +export default function feathersSocketIO(callback: (io: SocketIO.Server) => void): () => void; +export default function feathersSocketIO(options: number | SocketIO.ServerOptions, callback?: (io: SocketIO.Server) => void): () => void; +export default function feathersSocketIO(port: number, options?: SocketIO.ServerOptions, callback?: (io: SocketIO.Server) => void): () => void; diff --git a/types/feathersjs__socketio/tsconfig.json b/types/feathersjs__socketio/tsconfig.json new file mode 100644 index 0000000000..2b3cc51adc --- /dev/null +++ b/types/feathersjs__socketio/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@feathersjs/socketio": ["feathersjs__socketio"], + "@feathersjs/feathers": ["feathersjs__feathers"] + } + }, + "files": [ + "index.d.ts", "feathersjs__socketio-tests.ts" + ] +} diff --git a/types/feathersjs__socketio/tslint.json b/types/feathersjs__socketio/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/feathersjs__socketio/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}