@devdataphone/sdk 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +195 -0
  2. package/index.js +1 -1
  3. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # @devdataphone/sdk
2
+
3
+ Generate valid E.164 phone numbers for QA testing, database seeding, and mock data. Zero server-side retention.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@devdataphone/sdk.svg)](https://www.npmjs.com/package/@devdataphone/sdk)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ **🌐 Try it online: [DevDataPhone.com](https://devdataphone.com)** - Free online phone number generator with no signup required.
9
+
10
+ ## Features
11
+
12
+ - ✅ Generate valid E.164 format phone numbers
13
+ - ✅ Support for 10+ countries (US, UK, CN, IN, AU, CA, DE, FR, JP, BR)
14
+ - ✅ Validate phone numbers with detailed results
15
+ - ✅ Format numbers to national, international, or E.164
16
+ - ✅ Zero dependencies for core functionality
17
+ - ✅ TypeScript support included
18
+ - ✅ Works in Node.js 14+
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install @devdataphone/sdk
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```javascript
29
+ const { generate, validate, format } = require('@devdataphone/sdk');
30
+
31
+ // Generate 10 US phone numbers
32
+ const numbers = generate({ region: 'US', count: 10 });
33
+ console.log(numbers[0].number); // +14155550123
34
+
35
+ // Validate a phone number
36
+ const result = validate('+8613912345678');
37
+ console.log(result.valid); // true
38
+ console.log(result.country); // China
39
+ console.log(result.countryCode); // CN
40
+
41
+ // Format a phone number
42
+ console.log(format('+14155550100', 'national')); // (415) 555-0100
43
+ console.log(format('+14155550100', 'international')); // +1 415 555 0100
44
+ ```
45
+
46
+ ### ESM Import
47
+
48
+ ```javascript
49
+ import { generate, validate, format } from '@devdataphone/sdk';
50
+ ```
51
+
52
+ ## API Reference
53
+
54
+ ### generate(options)
55
+
56
+ Generate random phone numbers.
57
+
58
+ | Option | Type | Default | Description |
59
+ |--------|------|---------|-------------|
60
+ | `region` | string | `'US'` | Country code (US, UK, CN, IN, AU, CA, DE, FR, JP, BR) |
61
+ | `count` | number | `1` | Number of phone numbers (1-1000) |
62
+ | `format` | string | `'e164'` | Output format: `'e164'`, `'national'`, `'international'`, `'digits'` |
63
+
64
+ ```javascript
65
+ const numbers = generate({ region: 'UK', count: 5 });
66
+ // Returns: [{ number: '+447700900123', national: '07700 900123', ... }]
67
+ ```
68
+
69
+ ### generateOne(region, format)
70
+
71
+ Generate a single phone number string.
72
+
73
+ ```javascript
74
+ const number = generateOne('CN', 'national');
75
+ // Returns: '139 1234 5678'
76
+ ```
77
+
78
+ ### validate(input, options)
79
+
80
+ Validate a phone number with detailed results.
81
+
82
+ ```javascript
83
+ const result = validate('+14155550100');
84
+ // Returns: { valid: true, country: 'United States', countryCode: 'US', type: 'FIXED_LINE_OR_MOBILE', ... }
85
+ ```
86
+
87
+ ### isValid(input, defaultCountry)
88
+
89
+ Quick boolean validation check.
90
+
91
+ ```javascript
92
+ isValid('+14155550100'); // true
93
+ isValid('555-0100', 'US'); // true
94
+ isValid('invalid'); // false
95
+ ```
96
+
97
+ ### isE164(input)
98
+
99
+ Check if input is valid E.164 format.
100
+
101
+ ```javascript
102
+ isE164('+14155550100'); // true
103
+ isE164('(415) 555-0100'); // false
104
+ ```
105
+
106
+ ### format(input, style, options)
107
+
108
+ Format a phone number to different styles.
109
+
110
+ | Style | Example |
111
+ |-------|---------|
112
+ | `'e164'` | `+14155550100` |
113
+ | `'national'` | `(415) 555-0100` |
114
+ | `'international'` | `+1 415 555 0100` |
115
+ | `'rfc3966'` | `tel:+1-415-555-0100` |
116
+ | `'digits'` | `14155550100` |
117
+
118
+ ### Convenience Formatters
119
+
120
+ ```javascript
121
+ toE164('+1 (415) 555-0100'); // +14155550100
122
+ toNational('+14155550100'); // (415) 555-0100
123
+ toInternational('+14155550100'); // +1 415 555 0100
124
+ ```
125
+
126
+ ### Country Data
127
+
128
+ ```javascript
129
+ const { COUNTRIES, getCountry, getSupportedCountries, isSupported } = require('@devdataphone/sdk');
130
+
131
+ getSupportedCountries(); // ['US', 'UK', 'CN', 'IN', 'AU', 'CA', 'DE', 'FR', 'JP', 'BR']
132
+ isSupported('US'); // true
133
+ getCountry('US'); // { code: 'US', name: 'United States', dialCode: '+1', ... }
134
+ ```
135
+
136
+ ## Supported Countries
137
+
138
+ | Code | Country | Dial Code |
139
+ |------|---------|-----------|
140
+ | US | United States | +1 |
141
+ | UK | United Kingdom | +44 |
142
+ | CN | China | +86 |
143
+ | IN | India | +91 |
144
+ | AU | Australia | +61 |
145
+ | CA | Canada | +1 |
146
+ | DE | Germany | +49 |
147
+ | FR | France | +33 |
148
+ | JP | Japan | +81 |
149
+ | BR | Brazil | +55 |
150
+
151
+ ## Use Cases
152
+
153
+ - **QA Testing**: Generate realistic phone numbers for automated tests
154
+ - **Database Seeding**: Populate development databases with valid phone data
155
+ - **Mock Data**: Create demo data for UI development
156
+ - **Form Testing**: Test phone input validation without using real numbers
157
+
158
+ > 💡 Need a visual interface? Visit [DevDataPhone.com](https://devdataphone.com) for an instant online generator.
159
+
160
+ ## TypeScript
161
+
162
+ Full TypeScript definitions are included:
163
+
164
+ ```typescript
165
+ import { generate, validate, format, GenerateOptions, ValidationResult } from '@devdataphone/sdk';
166
+
167
+ const options: GenerateOptions = { region: 'US', count: 5 };
168
+ const numbers = generate(options);
169
+
170
+ const result: ValidationResult = validate('+14155550100');
171
+ ```
172
+
173
+ ## Optional: Enhanced Validation with libphonenumber-js
174
+
175
+ For enhanced validation accuracy, optionally install `libphonenumber-js`:
176
+
177
+ ```bash
178
+ npm install libphonenumber-js
179
+ ```
180
+
181
+ The SDK will automatically use it if available.
182
+
183
+ ## Related Resources
184
+
185
+ - 📖 [Why Mock Data Matters for Development](https://devdataphone.com/blog/why-mock-data-matters.html)
186
+ - 📖 [Stop Using Bad Regex for Phone Validation](https://devdataphone.com/blog/stop-using-bad-regex-for-phone-validation.html)
187
+ - 🛠️ [Online Phone Number Generator](https://devdataphone.com)
188
+
189
+ ## License
190
+
191
+ [MIT](https://opensource.org/licenses/MIT) © DevDataPhone
192
+
193
+ ---
194
+
195
+ **[DevDataPhone.com](https://devdataphone.com)** - Free Phone Number Generator for Developers
package/index.js CHANGED
@@ -30,7 +30,7 @@ const { COUNTRIES, US_AREA_CODES, CA_AREA_CODES, getCountry, getSupportedCountri
30
30
  * SDK Version
31
31
  * @type {string}
32
32
  */
33
- const VERSION = '1.0.0';
33
+ const VERSION = '1.0.1';
34
34
 
35
35
  /**
36
36
  * Generate random phone numbers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devdataphone/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Generate valid E.164 phone numbers for QA testing, database seeding, and mock data. Zero server-side retention.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -16,7 +16,8 @@
16
16
  "index.js",
17
17
  "index.mjs",
18
18
  "index.d.ts",
19
- "src/"
19
+ "src/",
20
+ "README.md"
20
21
  ],
21
22
  "scripts": {
22
23
  "test": "node test.js"