stacks 0.47.4 → 0.48.2
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.
- package/buddy/art/social.png +0 -0
- package/buddy/package.json +1 -1
- package/buddy/src/commands/make.ts +27 -12
- package/buddy/src/commands/test.ts +40 -2
- package/core/actions/package.json +2 -2
- package/core/actions/src/helpers/utils.ts +29 -3
- package/core/actions/src/make.ts +37 -6
- package/core/actions/src/test-coverage.ts +1 -1
- package/core/actions/src/test-feature.ts +5 -0
- package/core/actions/src/test-unit.ts +5 -0
- package/core/ai/package.json +1 -1
- package/core/alias/package.json +1 -1
- package/core/arrays/package.json +1 -1
- package/core/auth/package.json +1 -1
- package/core/build/package.json +3 -3
- package/core/cache/package.json +3 -3
- package/core/chat/README.md +33 -40
- package/core/chat/package.json +1 -1
- package/core/cli/package.json +1 -1
- package/core/cloud/package.json +1 -1
- package/core/collections/package.json +1 -1
- package/core/config/package.json +1 -1
- package/core/dashboard/package.json +1 -1
- package/core/database/package.json +1 -1
- package/core/datetime/package.json +1 -1
- package/core/desktop/package.json +1 -1
- package/core/docs/node_modules/.bin/vitepress +2 -2
- package/core/docs/package.json +2 -2
- package/core/domains/package.json +1 -1
- package/core/drivers/package.json +1 -1
- package/core/email/README.md +101 -35
- package/core/email/package.json +1 -1
- package/core/error-handling/package.json +2 -2
- package/core/events/package.json +1 -1
- package/core/git/package.json +1 -1
- package/core/health/package.json +1 -1
- package/core/lint/node_modules/.bin/eslint +2 -2
- package/core/lint/package.json +3 -3
- package/core/logging/package.json +1 -1
- package/core/modules/package.json +1 -1
- package/core/notifications/README.md +7 -2
- package/core/notifications/package.json +1 -1
- package/core/notifications/src/index.ts +37 -9
- package/core/notifications/tests/chat/Slack.test.ts +5 -4
- package/core/notifications/tests/email/Mailgun.test.ts +4 -3
- package/core/notifications/tests/email/Sendgrid.test.ts +3 -3
- package/core/notifications/tests/sms/Twilio.test.ts +3 -3
- package/core/objects/package.json +1 -1
- package/core/path/package.json +1 -1
- package/core/path/src/index.ts +5 -0
- package/core/payments/package.json +1 -1
- package/core/push/README.md +24 -42
- package/core/push/package.json +1 -1
- package/core/realtime/package.json +1 -1
- package/core/router/package.json +1 -1
- package/core/search-engine/package.json +1 -1
- package/core/security/package.json +1 -1
- package/core/server/package.json +1 -1
- package/core/sms/README.md +82 -35
- package/core/sms/package.json +1 -1
- package/core/storage/package.json +1 -1
- package/core/storage/src/index.ts +13 -0
- package/core/strings/README.md +10 -2
- package/core/strings/package.json +4 -2
- package/core/strings/src/case.ts +14 -0
- package/core/strings/src/index.ts +4 -97
- package/core/strings/src/pluralize.ts +1 -0
- package/core/strings/src/utils.ts +80 -0
- package/core/strings/src/validation.ts +182 -0
- package/core/tables/README.md +109 -0
- package/core/tables/examples/vue/App.vue +12 -0
- package/core/tables/examples/vue/favicon.png +0 -0
- package/core/tables/examples/vue/index.html +20 -0
- package/core/tables/examples/web/favicon.png +0 -0
- package/core/tables/examples/web/index.html +13 -0
- package/core/tables/node_modules/.bin/mkdist +17 -0
- package/core/tables/node_modules/.bin/tsc +17 -0
- package/core/tables/node_modules/.bin/tsserver +17 -0
- package/core/tables/node_modules/.bin/unbuild +17 -0
- package/core/tables/package.json +97 -0
- package/core/tables/src/cli/index.ts +1 -0
- package/core/tables/src/components/Demo.vue +89 -0
- package/core/tables/src/components/README.md +111 -0
- package/core/tables/src/components/Table.vue +342 -0
- package/core/tables/src/components/TableBody.vue +33 -0
- package/core/tables/src/components/TableCellActionItems.vue +9 -0
- package/core/tables/src/components/TableFilters.vue +703 -0
- package/core/tables/src/components/TableHead.vue +87 -0
- package/core/tables/src/components/TablePagination.vue +146 -0
- package/core/tables/src/components/TableRow.vue +78 -0
- package/core/tables/src/components/TableSearch.vue +38 -0
- package/core/tables/src/components/Tooltip.vue +10 -0
- package/core/tables/src/config/tables.ts +1 -0
- package/core/tables/src/docs/index.md +0 -0
- package/core/tables/src/functions/README.md +8 -0
- package/core/tables/src/functions/dark.ts +3 -0
- package/core/tables/src/functions/index.ts +2 -0
- package/core/tables/src/functions/table.ts +180 -0
- package/core/tables/tests/example.test.ts +7 -0
- package/core/testing/node_modules/.bin/vitest +2 -2
- package/core/testing/package.json +9 -6
- package/core/types/node_modules/.bin/vitepress +2 -2
- package/core/types/package.json +4 -3
- package/core/types/src/cli.ts +10 -2
- package/core/types/src/hashing.ts +15 -0
- package/core/types/src/index.ts +2 -0
- package/core/types/src/notifications.ts +1 -0
- package/core/types/src/reactivity.ts +3 -0
- package/core/types/src/tables.ts +48 -0
- package/core/ui/node_modules/.bin/vue-tsc +2 -2
- package/core/ui/package.json +2 -2
- package/core/utils/package.json +1 -1
- package/core/x-ray/package.json +1 -1
- package/package.json +3 -2
- package/tsconfig.json +8 -0
- package/vitest.config.ts +2 -0
package/core/server/package.json
CHANGED
package/core/sms/README.md
CHANGED
|
@@ -1,60 +1,99 @@
|
|
|
1
|
-
# Stacks
|
|
1
|
+
# Stacks SMS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Stacks SMS is driver system for sending SMS messages.
|
|
4
4
|
|
|
5
5
|
## ☘️ Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 📦 Send SMS
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## 🤖 Usage
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```bash
|
|
12
|
+
pnpm i -D @stacksjs/sms
|
|
13
|
+
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
You may now use it in your project:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import * as sms from '@stacksjs/sms'
|
|
19
|
+
/* Then choose a driver. E.g for twilio */
|
|
20
|
+
const notification = sms.twilio
|
|
21
|
+
|
|
22
|
+
notification.send(SMSOptions)
|
|
23
|
+
|
|
24
|
+
interface SMSOptions {
|
|
25
|
+
to: string
|
|
26
|
+
content: string
|
|
27
|
+
from?: string
|
|
28
|
+
attachments?: AttachmentOptions[]
|
|
29
|
+
id?: string
|
|
30
|
+
}
|
|
31
|
+
```
|
|
14
32
|
|
|
15
|
-
|
|
33
|
+
### Drivers
|
|
34
|
+
|
|
35
|
+
Drivers are configured with the following environment variables:
|
|
36
|
+
|
|
37
|
+
#### Twilio
|
|
16
38
|
|
|
17
39
|
```bash
|
|
18
|
-
|
|
40
|
+
TWILIO_ACCOUNT_SID=ACtest
|
|
41
|
+
TWILIO_AUTH_TOKEN=testtoken
|
|
42
|
+
TWILIO_FROM_NUMBER=+112345
|
|
43
|
+
TWILIO_TO_NUMBER=+145678
|
|
19
44
|
```
|
|
20
45
|
|
|
21
|
-
|
|
46
|
+
#### Nexmo
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
VONAGE_API_KEY=VN123
|
|
50
|
+
VONAGE_API_SECRET=testkey
|
|
51
|
+
VONAGE_FROM_NUMBER=+112345
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Gupshup
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
GUPSHUP_USER_ID=GU123
|
|
58
|
+
GUPSHUP_PASSWORD=password
|
|
59
|
+
```
|
|
22
60
|
|
|
23
|
-
|
|
24
|
-
import notifications from '@stacksjs/notifications'
|
|
61
|
+
#### Plivo
|
|
25
62
|
|
|
26
|
-
|
|
63
|
+
```bash
|
|
64
|
+
PLIVO_ACCOUNT_ID=PA123
|
|
65
|
+
PLIVO_AUTH_TOKEN=testtoken
|
|
66
|
+
PLIVO_FROM_NUMBER=+112345
|
|
27
67
|
```
|
|
28
68
|
|
|
29
|
-
|
|
69
|
+
#### SMS77
|
|
30
70
|
|
|
31
|
-
|
|
71
|
+
```bash
|
|
72
|
+
SMS77_API_KEY=SA123
|
|
73
|
+
SMS77_FROM=from@example.com
|
|
74
|
+
```
|
|
32
75
|
|
|
33
|
-
|
|
34
|
-
- Mailgun
|
|
35
|
-
- Mailjet
|
|
36
|
-
- Netcore
|
|
37
|
-
- Nodemailer
|
|
38
|
-
- Post Mark
|
|
39
|
-
- Ses
|
|
40
|
-
- Mandrill
|
|
41
|
-
- EmailJS
|
|
76
|
+
#### SNS
|
|
42
77
|
|
|
43
|
-
|
|
78
|
+
```bash
|
|
79
|
+
SMS77_API_KEY=SA123
|
|
80
|
+
SMS77_FROM=from@example.com
|
|
81
|
+
```
|
|
44
82
|
|
|
45
|
-
|
|
46
|
-
- Nexmo
|
|
47
|
-
- Gupshup
|
|
48
|
-
- Plivo
|
|
49
|
-
- SMS77
|
|
50
|
-
- SNS
|
|
51
|
-
- Telnyx
|
|
52
|
-
- Termii
|
|
83
|
+
#### Telnyx
|
|
53
84
|
|
|
54
|
-
|
|
85
|
+
```bash
|
|
86
|
+
TELNYX_API_KEY=TA123
|
|
87
|
+
TELNYX_MESSAGE_PROFILE_ID=testprofileid
|
|
88
|
+
TELNYX_FROM=from@example.com
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Termii
|
|
55
92
|
|
|
56
|
-
|
|
57
|
-
|
|
93
|
+
```bash
|
|
94
|
+
TERMII_API_KEY=TermA123
|
|
95
|
+
TERMII_SENDER=from@example.com
|
|
96
|
+
```
|
|
58
97
|
|
|
59
98
|
Learn more in the docs.
|
|
60
99
|
|
|
@@ -82,6 +121,14 @@ For casual chit-chat with others using this package:
|
|
|
82
121
|
|
|
83
122
|
[Join the Stacks Discord Server](https://discord.ow3.org)
|
|
84
123
|
|
|
124
|
+
## 🙏🏼 Credits
|
|
125
|
+
|
|
126
|
+
Many thanks to the following core technologies & people who have contributed to this package:
|
|
127
|
+
|
|
128
|
+
- [Chris Breuer](https://github.com/chrisbbreuer)
|
|
129
|
+
- [Novu](https://novu.co/)
|
|
130
|
+
- [All Contributors](../../contributors)
|
|
131
|
+
|
|
85
132
|
## 📄 License
|
|
86
133
|
|
|
87
134
|
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
package/core/sms/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/sms",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.2",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks SMS integration. Painlessly create & manage your inboxes, templates, and send sms.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -87,6 +87,7 @@ export function isFolder(path: string): boolean {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
|
|
90
91
|
/**
|
|
91
92
|
* Determine whether a path is a file.
|
|
92
93
|
*/
|
|
@@ -169,6 +170,18 @@ export function doesFolderExist(path: string) {
|
|
|
169
170
|
return fs.existsSync(path)
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
export function createFolder(dir: string): Promise<void> {
|
|
174
|
+
return new Promise((resolve, reject) => {
|
|
175
|
+
fs.mkdirs(dir, (err: any) => {
|
|
176
|
+
if (err)
|
|
177
|
+
reject(err)
|
|
178
|
+
|
|
179
|
+
else
|
|
180
|
+
resolve()
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
172
185
|
export const filesystem = {
|
|
173
186
|
_dirname,
|
|
174
187
|
readJsonFile,
|
package/core/strings/README.md
CHANGED
|
@@ -17,9 +17,16 @@ Now, you can use it in your project:
|
|
|
17
17
|
|
|
18
18
|
```js
|
|
19
19
|
import {
|
|
20
|
-
|
|
20
|
+
// pluralize
|
|
21
|
+
addIrregularRule, addPluralRule, addSingularRule, addUncountableRule,
|
|
22
|
+
|
|
23
|
+
// case
|
|
24
|
+
camelCase, capitalCase, constantCase, dotCase,
|
|
21
25
|
headerCase, isPlural, isSingular, kebabCase, noCase, paramCase, pascalCase,
|
|
22
|
-
pathCase, plural, sentenceCase, singular, snakeCase
|
|
26
|
+
pathCase, plural, sentenceCase, singular, snakeCase,
|
|
27
|
+
|
|
28
|
+
// validation
|
|
29
|
+
isEmail, isStrongPassword, isAlphanumeric, validateUsername, isURL, isMobilePhone, isAlpha, isPostalCode, isDate, isNumeric, isBoolean, isHexColor, isHexadecimal, isBase64, isUUID, isJSON, isCreditCard, isISBN, isIP, isIPRange, isMACAddress, isLatLong, isLatitude, isLongitude, isCurrency, isDataURI, isMimeType, isJWT, isMongoId, isAscii, isBase32, isByteLength, isFQDN, isFullWidth, isHalfWidth, isHash, isHSL, isIBAN, isIdentityCard, isISIN, isISO8601, isISRC, isISSN, isISO31661Alpha2, isISO31661Alpha3
|
|
23
30
|
} from '@stacksjs/strings'
|
|
24
31
|
|
|
25
32
|
console.log(camelCase('hello world')) // helloWorld
|
|
@@ -58,6 +65,7 @@ Many thanks to the following core technologies & people who have contributed to
|
|
|
58
65
|
|
|
59
66
|
- [change-case](https://www.npmjs.com/package/change-case)
|
|
60
67
|
- [pluralize](https://www.npmjs.com/package/pluralize)
|
|
68
|
+
- [validation](https://www.npmjs.com/package/validation)
|
|
61
69
|
- [Chris Breuer](https://github.com/chrisbbreuer)
|
|
62
70
|
- [All Contributors](../../contributors)
|
|
63
71
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/strings",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.2",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks string utilities.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -57,8 +57,10 @@
|
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@stacksjs/alias": "workspace:*",
|
|
59
59
|
"@types/pluralize": "^0.0.29",
|
|
60
|
+
"@types/validator": "^13.7.10",
|
|
60
61
|
"change-case": "^4.1.2",
|
|
61
|
-
"pluralize": "^8.0.0"
|
|
62
|
+
"pluralize": "^8.0.0",
|
|
63
|
+
"validator": "^13.7.0"
|
|
62
64
|
},
|
|
63
65
|
"devDependencies": {
|
|
64
66
|
"@stacksjs/testing": "workspace:*",
|
|
@@ -1,97 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
capitalCase,
|
|
6
|
-
constantCase,
|
|
7
|
-
dotCase,
|
|
8
|
-
headerCase,
|
|
9
|
-
noCase,
|
|
10
|
-
paramCase,
|
|
11
|
-
paramCase as kebabCase,
|
|
12
|
-
pascalCase,
|
|
13
|
-
pathCase,
|
|
14
|
-
sentenceCase,
|
|
15
|
-
snakeCase,
|
|
16
|
-
} from 'change-case'
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Replace backslash to slash
|
|
20
|
-
*
|
|
21
|
-
* @category String
|
|
22
|
-
*/
|
|
23
|
-
export function slash(str: string) {
|
|
24
|
-
return str.replace(/\\/g, '/')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Ensure prefix of a string
|
|
29
|
-
*
|
|
30
|
-
* @category String
|
|
31
|
-
*/
|
|
32
|
-
export function ensurePrefix(prefix: string, str: string) {
|
|
33
|
-
if (!str.startsWith(prefix))
|
|
34
|
-
return prefix + str
|
|
35
|
-
return str
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Ensure suffix of a string
|
|
40
|
-
*
|
|
41
|
-
* @category String
|
|
42
|
-
*/
|
|
43
|
-
export function ensureSuffix(suffix: string, str: string) {
|
|
44
|
-
if (!str.endsWith(suffix))
|
|
45
|
-
return str + suffix
|
|
46
|
-
return str
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Dead simple template engine, just like Python's `.format()`
|
|
51
|
-
*
|
|
52
|
-
* @category String
|
|
53
|
-
* @example
|
|
54
|
-
* ```
|
|
55
|
-
* const result = template(
|
|
56
|
-
* 'Hello {0}! My name is {1}.',
|
|
57
|
-
* 'Buddy',
|
|
58
|
-
* 'Chris'
|
|
59
|
-
* ) // Hello Buddy! My name is Chris.
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export function template(str: string, ...args: any[]): string {
|
|
63
|
-
return str.replace(/{(\d+)}/g, (match, key) => {
|
|
64
|
-
const index = Number(key)
|
|
65
|
-
if (Number.isNaN(index))
|
|
66
|
-
return match
|
|
67
|
-
return args[index]
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// port from nanoid
|
|
72
|
-
// https://github.com/ai/nanoid
|
|
73
|
-
const urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
74
|
-
/**
|
|
75
|
-
* Generate a random string
|
|
76
|
-
* @category String
|
|
77
|
-
*/
|
|
78
|
-
export function randomStr(size = 16, dict = urlAlphabet) {
|
|
79
|
-
let id = ''
|
|
80
|
-
let i = size
|
|
81
|
-
const len = dict.length
|
|
82
|
-
while (i--)
|
|
83
|
-
id += dict[(Math.random() * len) | 0]
|
|
84
|
-
return id
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* First letter uppercase, other lowercase
|
|
89
|
-
* @category string
|
|
90
|
-
* @example
|
|
91
|
-
* ```
|
|
92
|
-
* capitalize('hello') => 'Hello'
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
export function capitalize(str: string): string {
|
|
96
|
-
return str[0].toUpperCase() + str.slice(1).toLowerCase()
|
|
97
|
-
}
|
|
1
|
+
export * from './case'
|
|
2
|
+
export * from './utils'
|
|
3
|
+
export * from './pluralize'
|
|
4
|
+
export * from './validation'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { plural, singular, isPlural, isSingular, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } from 'pluralize'
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace backslash to slash
|
|
3
|
+
*
|
|
4
|
+
* @category String
|
|
5
|
+
*/
|
|
6
|
+
export function slash(str: string) {
|
|
7
|
+
return str.replace(/\\/g, '/')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Ensure prefix of a string
|
|
12
|
+
*
|
|
13
|
+
* @category String
|
|
14
|
+
*/
|
|
15
|
+
export function ensurePrefix(prefix: string, str: string) {
|
|
16
|
+
if (!str.startsWith(prefix))
|
|
17
|
+
return prefix + str
|
|
18
|
+
return str
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Ensure suffix of a string
|
|
23
|
+
*
|
|
24
|
+
* @category String
|
|
25
|
+
*/
|
|
26
|
+
export function ensureSuffix(suffix: string, str: string) {
|
|
27
|
+
if (!str.endsWith(suffix))
|
|
28
|
+
return str + suffix
|
|
29
|
+
return str
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Dead simple template engine, just like Python's `.format()`
|
|
34
|
+
*
|
|
35
|
+
* @category String
|
|
36
|
+
* @example
|
|
37
|
+
* ```
|
|
38
|
+
* const result = template(
|
|
39
|
+
* 'Hello {0}! My name is {1}.',
|
|
40
|
+
* 'Buddy',
|
|
41
|
+
* 'Chris'
|
|
42
|
+
* ) // Hello Buddy! My name is Chris.
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function template(str: string, ...args: any[]): string {
|
|
46
|
+
return str.replace(/{(\d+)}/g, (match, key) => {
|
|
47
|
+
const index = Number(key)
|
|
48
|
+
if (Number.isNaN(index))
|
|
49
|
+
return match
|
|
50
|
+
return args[index]
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// port from nanoid
|
|
55
|
+
// https://github.com/ai/nanoid
|
|
56
|
+
const urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
57
|
+
/**
|
|
58
|
+
* Generate a random string
|
|
59
|
+
* @category String
|
|
60
|
+
*/
|
|
61
|
+
export function randomStr(size = 16, dict = urlAlphabet) {
|
|
62
|
+
let id = ''
|
|
63
|
+
let i = size
|
|
64
|
+
const len = dict.length
|
|
65
|
+
while (i--)
|
|
66
|
+
id += dict[(Math.random() * len) | 0]
|
|
67
|
+
return id
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* First letter uppercase, other lowercase
|
|
72
|
+
* @category string
|
|
73
|
+
* @example
|
|
74
|
+
* ```
|
|
75
|
+
* capitalize('hello') => 'Hello'
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export function capitalize(str: string): string {
|
|
79
|
+
return str[0].toUpperCase() + str.slice(1).toLowerCase()
|
|
80
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import validator from 'validator'
|
|
2
|
+
import type { HashAlgorithm } from '@stacksjs/types'
|
|
3
|
+
|
|
4
|
+
export function isEmail(email: string) {
|
|
5
|
+
return validator.isEmail(email)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isStrongPassword(password: string) {
|
|
9
|
+
return validator.isStrongPassword(password)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isAlphanumeric(username: string) {
|
|
13
|
+
return validator.isAlphanumeric(username)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function validateUsername(username: string) {
|
|
17
|
+
return isAlphanumeric(username)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isURL(url: string) {
|
|
21
|
+
return validator.isURL(url)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isMobilePhone(phoneNumber: string) {
|
|
25
|
+
return validator.isMobilePhone(phoneNumber)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isAlpha(name: string) {
|
|
29
|
+
return validator.isAlpha(name)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isPostalCode(zipCode: string) {
|
|
33
|
+
return validator.isPostalCode(zipCode, 'any')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isDate(date: string) {
|
|
37
|
+
return validator.isDate(date)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function isNumeric(number: string) {
|
|
41
|
+
return validator.isNumeric(number)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function isBoolean(boolean: string) {
|
|
45
|
+
return validator.isBoolean(boolean)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function isHexColor(color: string) {
|
|
49
|
+
return validator.isHexColor(color)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function isHexadecimal(hex: string) {
|
|
53
|
+
return validator.isHexadecimal(hex)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function isBase64(base64: string) {
|
|
57
|
+
return validator.isBase64(base64)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isUUID(uuid: string) {
|
|
61
|
+
return validator.isUUID(uuid)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function isJSON(json: string) {
|
|
65
|
+
return validator.isJSON(json)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function isCreditCard(creditCard: string) {
|
|
69
|
+
return validator.isCreditCard(creditCard)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function isISBN(isbn: string) {
|
|
73
|
+
return validator.isISBN(isbn)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function isIP(ip: string) {
|
|
77
|
+
return validator.isIP(ip)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function isIPRange(ip: string) {
|
|
81
|
+
return validator.isIPRange(ip)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function isMACAddress(macAddress: string) {
|
|
85
|
+
return validator.isMACAddress(macAddress)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function isLatLong(latitude: string) {
|
|
89
|
+
return validator.isLatLong(latitude)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function isLatitude(longitude: string) {
|
|
93
|
+
return validator.isLatLong(longitude)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function isLongitude(longitude: string) {
|
|
97
|
+
return validator.isLatLong(longitude)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function isCurrency(currency: string) {
|
|
101
|
+
return validator.isCurrency(currency)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function isDataURI(dataURI: string) {
|
|
105
|
+
return validator.isDataURI(dataURI)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function isMimeType(mimeType: string) {
|
|
109
|
+
return validator.isMimeType(mimeType)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function isJWT(jwt: string) {
|
|
113
|
+
return validator.isJWT(jwt)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function isMongoId(mongoId: string) {
|
|
117
|
+
return validator.isMongoId(mongoId)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function isAscii(ascii: string) {
|
|
121
|
+
return validator.isAscii(ascii)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function isBase32(base32: string) {
|
|
125
|
+
return validator.isBase32(base32)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function isByteLength(byteLength: string) {
|
|
129
|
+
return validator.isByteLength(byteLength)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function isFQDN(fqdn: string) {
|
|
133
|
+
return validator.isFQDN(fqdn)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function isFullWidth(fullWidth: string) {
|
|
137
|
+
return validator.isFullWidth(fullWidth)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function isHalfWidth(halfWidth: string) {
|
|
141
|
+
return validator.isHalfWidth(halfWidth)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function isHash(hash: string, algorithm: HashAlgorithm) {
|
|
145
|
+
return validator.isHash(hash, algorithm)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function isHSL(hsl: string) {
|
|
149
|
+
return validator.isHSL(hsl)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function isIBAN(iban: string) {
|
|
153
|
+
return validator.isIBAN(iban)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function isIdentityCard(identityCard: string) {
|
|
157
|
+
return validator.isIdentityCard(identityCard)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function isISIN(isin: string) {
|
|
161
|
+
return validator.isISIN(isin)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function isISO8601(iso8601: string) {
|
|
165
|
+
return validator.isISO8601(iso8601)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function isISRC(isrc: string) {
|
|
169
|
+
return validator.isISRC(isrc)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function isISSN(issn: string) {
|
|
173
|
+
return validator.isISSN(issn)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function isISO31661Alpha2(iso31661Alpha2: string) {
|
|
177
|
+
return validator.isISO31661Alpha2(iso31661Alpha2)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function isISO31661Alpha3(iso31661Alpha3: string) {
|
|
181
|
+
return validator.isISO31661Alpha3(iso31661Alpha3)
|
|
182
|
+
}
|