Skip to content

Commit 7a2eafd

Browse files
Jan LohageJan Lohage
authored andcommitted
add typings for dialablePhoneNumber hook, add libphonenumber-js as a dependency
1 parent a245b4d commit 7a2eafd

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"graphql": "^14.0.2",
8080
"http-shutdown": "^1.2.0",
8181
"istanbul": "^1.1.0-alpha.1",
82+
"libphonenumber-js": "^1.6.8",
8283
"mkdirp": "^0.5.1",
8384
"mocha": "^5.0.1",
8485
"mongodb": "^3.1.0-beta4",

types/index.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Hook, HookContext, Params, Query, Paginated, Application } from '@feathersjs/feathers';
44
import * as ajv from 'ajv';
55
import { GraphQLSchema, parse } from 'graphql';
6+
import * as libphonenumberjs from 'libphonenumber-js';
67

78
export type HookType = 'before' | 'after' | 'error';
89
export type MethodName = 'find' | 'create' | 'get' | 'update' | 'patch' | 'remove';
@@ -120,6 +121,18 @@ export function deleteByDot(object: any, path: string): void;
120121
*/
121122
export function dePopulate(): Hook;
122123

124+
// todo: dialablePhoneNumber docs
125+
/**
126+
* {@link https://feathers-plus.github.io/v1/feathers-hooks-common/index.html#DialablePhoneNumber}
127+
*/
128+
export function dialablePhoneNumber(
129+
libphonenumberJs: typeof libphonenumberjs,
130+
defaultCountry?: libphonenumberjs.CountryCode,
131+
phoneField?: string,
132+
dialableField?: string,
133+
countryField?: string
134+
): Hook;
135+
123136
/**
124137
* Prevents null from being used as an id in patch and remove service methods.
125138
* {@link https://feathers-plus.github.io/v1/feathers-hooks-common/index.html#DisableMultiItemChange}

types/tests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
debug,
1515
deleteByDot,
1616
dePopulate,
17+
dialablePhoneNumber,
1718
disableMultiItemChange,
1819
disableMultiItemCreate,
1920
disablePagination,
@@ -66,6 +67,7 @@ import {
6667
} from 'feathers-hooks-common';
6768
import ajv = require('ajv');
6869
import { parse } from 'graphql';
70+
import * as libphonenumberjs from 'libphonenumber-js';
6971

7072
const context1: HookContext = {
7173
type: 'before',
@@ -139,6 +141,9 @@ deleteByDot({}, 'abc.def');
139141
// $ExpectType Hook
140142
dePopulate();
141143

144+
// $ExpectType Hook
145+
dialablePhoneNumber(libphonenumberjs);
146+
142147
// $ExpectType Hook
143148
disableMultiItemChange();
144149

0 commit comments

Comments
 (0)