Upstream sync

This commit is contained in:
Hinell
2017-01-15 01:35:37 +03:00
12 changed files with 427 additions and 5 deletions
+11 -2
View File
@@ -901,8 +901,17 @@ declare namespace angular {
*/
interface ILocationService {
absUrl(): string;
/**
* Returns the hash fragment
*/
hash(): string;
hash(newHash: string): ILocationService;
/**
* Changes the hash fragment and returns `$location`
*/
hash(newHash: string|null): ILocationService;
host(): string;
/**
@@ -942,7 +951,7 @@ declare namespace angular {
* @param search New search params
* @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted. If paramValue is an array, it will override the property of the search component of $location specified via the first argument. If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign.
*/
search(search: string, paramValue: string|number|string[]|boolean): ILocationService;
search(search: string, paramValue: string|number|null|string[]|boolean): ILocationService;
state(): any;
state(state: any): ILocationService;
@@ -0,0 +1,13 @@
import login = require("connect-ensure-login");
login.ensureLoggedIn();
login.ensureLoggedIn("/login");
login.ensureLoggedIn({
redirectTo: "/login",
});
login.ensureLoggedOut();
login.ensureLoggedOut("/");
login.ensureLoggedOut({
redirectTo: "/",
});
+73
View File
@@ -0,0 +1,73 @@
// Type definitions for connect-ensure-login 0.1
// Project: https://github.com/jaredhanson/connect-ensure-login
// Definitions by: Pavel Puchkov <https://github.com/0x6368656174>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { RequestHandler } from "express";
interface LoggedInOptions {
/**
* URL to redirect to for login, defaults to _/login_
*/
redirectTo?: string;
/**
* set redirectTo in session, defaults to _true_
*/
setRedirectTo?: boolean;
}
interface LoggedOutOptions {
/**
* URL to redirect to in logged in, defaults to _/_
*/
redirectTo?: string;
}
/**
* Ensure that a user is logged in before proceeding to next route middleware.
*
* This middleware ensures that a user is logged in. If a request is received
* that is unauthenticated, the request will be redirected to a login page (by
* default to `/login`).
*
* Additionally, `returnTo` will be be set in the session to the URL of the
* current request. After authentication, this value can be used to redirect
* the user to the page that was originally requested.
*
* Examples:
*
* app.get('/profile',
* ensureLoggedIn(),
* function(req, res) { ... });
*
* app.get('/profile',
* ensureLoggedIn('/signin'),
* function(req, res) { ... });
*
* app.get('/profile',
* ensureLoggedIn({ redirectTo: '/session/new', setReturnTo: false }),
* function(req, res) { ... });
*/
export declare function ensureLoggedIn(options?: LoggedInOptions | string): RequestHandler;
/**
* Ensure that no user is logged in before proceeding to next route middleware.
*
* This middleware ensures that no user is logged in. If a request is received
* that is authenticated, the request will be redirected to another page (by
* default to `/`).
*
* Examples:
*
* app.get('/login',
* ensureLoggedOut(),
* function(req, res) { ... });
*
* app.get('/login',
* ensureLoggedOut('/home'),
* function(req, res) { ... });
*
* app.get('/login',
* ensureLoggedOut({ redirectTo: '/home' }),
* function(req, res) { ... });
*/
export declare function ensureLoggedOut(options?: LoggedOutOptions | string): RequestHandler;
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"connect-ensure-login-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "../tslint.json"
}
+118
View File
@@ -0,0 +1,118 @@
import {
Mgrs,
Utm,
Dms,
Vector3d,
OsGridRef,
LatLonEllipsoidal as LatLon } from 'geodesy';
/**
* Mgrs
*/
const mgrs = new Mgrs(31, 'U', 'D', 'Q', 48251, 11932);
const bandMgrs = mgrs.band;
const datumMgrs = mgrs.datum;
const e100kMgrs = mgrs.e100k;
const e100kLettersMgrs = mgrs.e100kLetters;
const eastingMgrs = mgrs.easting;
const latBandsMgrs = mgrs.latBands;
const n100kMgrs = mgrs.n100k;
const n100kLettersMgrs = mgrs.n100kLetters;
const northingMgrs = mgrs.northing;
const zoneMgrs = mgrs.zone;
mgrs.toString();
mgrs.toUtm();
// Static Functions
Mgrs.parse('31U DQ 48251 11932');
/**
* Utm
*/
const utm = new Utm(31, 'N', 448251, 5411932);
const convergenceUtm = utm.convergence;
const datumUtm = utm.datum;
const eastingUtm = utm.easting;
const hemisphereUtm = utm.hemisphere;
const northingUtm = utm.northing;
const scaleUtm = utm.scale;
utm.toLatLonE();
utm.toMgrs();
utm.toString();
// Static Functions
Utm.parse('31 N 448251 5411932');
/**
* Dms
*/
Dms.separator = '\u202f';
// Static Functions
Dms.parseDMS('51° 28′ 40.12″ N');
Dms.toDMS(45);
Dms.toDMS(45, 'dm');
Dms.toDMS(45, 'd', 2);
Dms.toDMS(45, 'dms', 4);
Dms.toLat(45);
Dms.toLat(45, 'dm');
Dms.toLat(45, 'd', 2);
Dms.toLat(45, 'dms', 4);
Dms.toLon(45);
Dms.toLon(45, 'dm');
Dms.toLon(45, 'd', 2);
Dms.toLon(45, 'dms', 4);
Dms.toBrng(90);
Dms.toBrng(90, 'dm');
Dms.toBrng(90, 'd', 2);
Dms.toBrng(90, 'dms', 4);
Dms.compassPoint(180);
Dms.compassPoint(180, 1);
Dms.compassPoint(180, 2);
Dms.compassPoint(180, 3);
/**
* Vector3d
*/
const v1 = new Vector3d(4, 23, 13);
const v2 = new Vector3d(5, 42, 33);
const v3 = new Vector3d(8, 12, 43);
v1.cross(v2).dot(v3);
/**
* LatLon
*/
const latlon = new LatLon(52.65798, 1.71605);
const latlonWGS84 = new LatLon(51.4778, -0.0016, LatLon.datum.WGS84);
const pWGS84 = new LatLon(51.4778, -0.0016, LatLon.datum.WGS84);
const pOSGB = pWGS84.convertDatum(LatLon.datum.OSGB36);
latlon.toUtm();
latlon.toCartesian();
latlon.toString();
latlon.toString('dm');
latlon.toString('d', 0);
const mgrsGrid = new LatLon(45.4215296, -75.697193).toUtm().toMgrs();
mgrsGrid.toString(6);
/**
* OsGridRef
*/
const gridref = new OsGridRef(651409, 313177);
const osgrid = new OsGridRef(651409.903, 313177.270);
new OsGridRef(651409, 313177).toString();
// Static Functions
OsGridRef.latLonToOsGrid(latlon);
OsGridRef.osGridToLatLon(gridref);
OsGridRef.osGridToLatLon(gridref, LatLon.datum.OSGB36);
OsGridRef.parse('TG 51409 13177');
+149
View File
@@ -0,0 +1,149 @@
// Type definitions for geodesy 1.1
// Project: https://github.com/chrisveness/geodesy
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type format = 'd' | 'dm' | 'dms';
export type datum = 'ED50'| 'Irl1975'| 'NAD27'| 'NAD83'| 'NTF'| 'OSGB36'| 'Potsdam'| 'TokyoJapan'| 'WGS72'| 'WGS84';
export type hemisphere = 'N' | 'S';
export type ellipsoid = 'WGS84' | 'Airy1830' | 'AiryModified' | 'Bessel1841' | 'Clarke1866' | 'Clarke1880IGN' | 'GRS80' | 'Intl1924' | 'WGS72';
export type transform = [number, number, number, number, number, number, number];
export type LatLon = LatLonEllipsoidal;
export interface Datum {
ellipsoid: Ellipsoid;
transform: [number, number, number, number, number, number, number];
}
export interface Datums {
ED50: Datum;
Irl1975: Datum;
NAD27: Datum;
NAD83: Datum;
NTF: Datum;
OSGB36: Datum;
Potsdam: Datum;
TokyoJapan: Datum;
WGS72: Datum;
WGS84: Datum;
}
export interface Ellipsoid {
a: number;
b: number;
f: number;
}
export interface Ellipsoids {
WGS84: Ellipsoid;
GRS80: Ellipsoid;
Airy1830: Ellipsoid;
AiryModified: Ellipsoid;
Intl1924: Ellipsoid;
Bessel1841: Ellipsoid;
}
export declare class Mgrs {
zone: number;
band: string;
e100k: string;
n100k: string;
easting: number;
northing: number;
datum: datum;
latBands: string;
e100kLetters: string;
n100kLetters: string;
constructor(
zone: number,
band: string,
e100k: string,
n100k: string,
easting: number,
northing: number,
datum?: datum
)
static parse(mgrsGridRef: string): Mgrs;
toUtm(): Utm;
toString(digits?: 2 | 4 | 6 | 8 | 10): string;
}
export declare class Utm {
zone: number;
hemisphere: hemisphere;
easting: number;
northing: number;
datum: Datum;
convergence: number;
scale: number;
constructor(
zone: number,
hemisphere: hemisphere,
easting: number,
northing: number,
datum?: datum,
convergence?: number,
scale?: number
);
static parse(utmCoord: string, datum?: datum): Utm;
toLatLonE(): LatLon;
toMgrs(): Mgrs;
toString(digits?: number): string;
}
export declare namespace Dms {
export let separator: string;
}
export declare class Dms {
static parseDMS(dmsStr: string): number;
static toDMS(deg: number, format?: format, dp?: 0 | 2 | 4): string;
static toLat(deg: number, format?: format, dp?: 0 | 2 | 4): string;
static toLon(deg: number, format?: format, dp?: 0 | 2 | 4): string;
static toBrng(deg: number, format?: format, dp?: 0 | 2 | 4): string;
static compassPoint(bearing: number, precision?: 1 | 2 | 3): string;
}
export declare class Vector3d {
x: number;
y: number;
z: number;
constructor(x: number, y: number, z: number);
plus(v: Vector3d): Vector3d;
minus(v: Vector3d): Vector3d;
times(x: number): Vector3d;
dividedBy(x: number): Vector3d;
dot(v: Vector3d): number;
cross(v: Vector3d): Vector3d;
negate(): Vector3d;
length(): number;
unit(): Vector3d;
angleTo(v: Vector3d, n?: Vector3d): number;
rotateAround(axis: Vector3d, theta: number): Vector3d;
toString(precision?: number): string;
toLatLonE(datum: Datum): LatLon;
applyTransform(t: number[]): Vector3d;
}
export declare class OsGridRef {
easting: number;
northing: number;
constructor(easting: number, northing: number);
static latLonToOsGrid(p: LatLon): OsGridRef;
static osGridToLatLon(gridref: OsGridRef, datum?: Datum): LatLon;
static parse(gridref: string): OsGridRef;
toString(digits?: number): string;
}
export declare class LatLonEllipsoidal {
lat: number;
lon: number;
datum: Datum;
constructor(lat: number, lon: number, datum?: Datum);
toUtm(): Utm;
convertDatum(toDatum: Datum): LatLon;
toCartesian(): Vector3d;
toString(format?: format, dp?: 0 | 2 | 4): string;
static datum: Datums;
static ellipsoid: Ellipsoids;
}
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"geodesy-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+7 -1
View File
@@ -309,10 +309,16 @@ declare module "mongoose" {
(...hookArgs:any[]): any;
}
interface CappedOptions {
size: number;
max?: number;
autoIndexId?: boolean;
}
export interface SchemaOption {
autoIndex?: boolean;
bufferCommands?: boolean;
capped?: boolean;
capped?: boolean | number | CappedOptions;
collection?: string;
id?: boolean;
_id?: boolean;
+7 -2
View File
@@ -1,6 +1,6 @@
// Type definitions for Passport 0.3
// Project: http://passportjs.org
// Definitions by: Horiuchi_H <https://github.com/horiuchi/>
// Definitions by: Horiuchi_H <https://github.com/horiuchi/>, Eric Naeseth <https://github.com/enaeseth>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Express {
@@ -60,6 +60,11 @@ declare module 'passport' {
transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
}
interface PassportStatic extends Passport {
Passport: {new(): Passport};
Authenticator: {new(): Passport};
}
interface Strategy {
name?: string;
authenticate(req: express.Request, options?: any): void;
@@ -91,7 +96,7 @@ declare module 'passport' {
}
}
const passport: passport.Passport;
const passport: passport.PassportStatic;
export = passport;
}
+5
View File
@@ -108,3 +108,8 @@ function ensureAuthenticated(req: express.Request, res: express.Response, next:
}
}
const passportInstance: passport.Passport = new passport.Passport()
passportInstance.use(new TestStrategy())
const authenticator: passport.Passport = new passport.Authenticator()
authenticator.use(new TestStrategy())