@scaleway/regex 4.2.1 → 5.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.
package/.eslintignore ADDED
@@ -0,0 +1,4 @@
1
+ dist/
2
+ coverage/
3
+ node_modules
4
+ .reports/
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1943](https://github.com/scaleway/scaleway-lib/pull/1943) [`e726def`](https://github.com/scaleway/scaleway-lib/commit/e726def8e0cb4593f800f9acecca51b173ae907a) Thanks [@philibea](https://github.com/philibea)! - Migration from rollup to vite
8
+
9
+ ## 5.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [#1837](https://github.com/scaleway/scaleway-lib/pull/1837) [`5404963`](https://github.com/scaleway/scaleway-lib/commit/5404963ddd01fafe6ed9753d8324fb19849065ca) Thanks [@philibea](https://github.com/philibea)! - upgrade node version from 14 to 20
14
+
3
15
  ## 4.2.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,49 +1,47 @@
1
- declare const accessKeyRegex: RegExp;
2
- declare const alpha: RegExp;
3
- declare const alphaLowercase: RegExp;
4
- declare const alphanum: RegExp;
5
- declare const alphaDashes: RegExp;
6
- declare const alphanumDash: RegExp;
7
- declare const alphanumDashDots: RegExp;
8
- declare const alphanumDashDotsOrEmpty: RegExp;
9
- declare const alphanumDashDotsSpaces: RegExp;
10
- declare const alphanumDashLowercase: RegExp;
11
- declare const alphanumDashSpaces: RegExp;
12
- declare const alphanumDashOrEmpty: RegExp;
13
- declare const alphanumDashUnderscoreDots: RegExp;
14
- declare const alphanumDashUnderscore: RegExp;
15
- declare const alphanumDashUnderscoreDotsSpacesParenthesis: RegExp;
16
- declare const alphanumDashUnderscoreDotsSpaces: RegExp;
17
- declare const alphanumDashUnderscoreDollar: RegExp;
18
- declare const alphanumDots: RegExp;
19
- declare const alphanumLowercase: RegExp;
20
- declare const absoluteLinuxPath: RegExp;
21
- declare const ascii: RegExp;
22
- declare const backupKey: RegExp;
23
- declare const basicDomain: RegExp;
24
- declare const uppercaseBasicDomain: RegExp;
25
- declare const uppercaseBasicSubdomain: RegExp;
26
- declare const advancedDomainName: RegExp;
27
- declare const cron: RegExp;
28
- declare const digits: RegExp;
29
- declare const macAddress: RegExp;
30
- declare const email: RegExp;
31
- declare const fourDigitsCode: RegExp;
32
- declare const phone: RegExp;
33
- declare const spaces: RegExp;
34
- declare const sixDigitsCode: RegExp;
35
- declare const url: RegExp;
36
- declare const hexadecimal: RegExp;
37
- declare const s3BucketName: RegExp;
38
- declare const ip: RegExp;
39
- declare const ipv4: RegExp;
40
- declare const ipv6: RegExp;
41
- declare const ipCidr: RegExp;
42
- declare const ipv4Cidr: RegExp;
43
- declare const ipv6Cidr: RegExp;
44
- declare const reverseDNS: RegExp;
45
- declare const dashedIpv4: RegExp;
46
- declare const pathSegment: RegExp;
47
- declare const absolutePath: RegExp;
48
-
49
- export { absoluteLinuxPath, absolutePath, accessKeyRegex, advancedDomainName, alpha, alphaDashes, alphaLowercase, alphanum, alphanumDash, alphanumDashDots, alphanumDashDotsOrEmpty, alphanumDashDotsSpaces, alphanumDashLowercase, alphanumDashOrEmpty, alphanumDashSpaces, alphanumDashUnderscore, alphanumDashUnderscoreDollar, alphanumDashUnderscoreDots, alphanumDashUnderscoreDotsSpaces, alphanumDashUnderscoreDotsSpacesParenthesis, alphanumDots, alphanumLowercase, ascii, backupKey, basicDomain, cron, dashedIpv4, digits, email, fourDigitsCode, hexadecimal, ip, ipCidr, ipv4, ipv4Cidr, ipv6, ipv6Cidr, macAddress, pathSegment, phone, reverseDNS, s3BucketName, sixDigitsCode, spaces, uppercaseBasicDomain, uppercaseBasicSubdomain, url };
1
+ export declare const accessKeyRegex: RegExp;
2
+ export declare const alpha: RegExp;
3
+ export declare const alphaLowercase: RegExp;
4
+ export declare const alphanum: RegExp;
5
+ export declare const alphaDashes: RegExp;
6
+ export declare const alphanumDash: RegExp;
7
+ export declare const alphanumDashDots: RegExp;
8
+ export declare const alphanumDashDotsOrEmpty: RegExp;
9
+ export declare const alphanumDashDotsSpaces: RegExp;
10
+ export declare const alphanumDashLowercase: RegExp;
11
+ export declare const alphanumDashSpaces: RegExp;
12
+ export declare const alphanumDashOrEmpty: RegExp;
13
+ export declare const alphanumDashUnderscoreDots: RegExp;
14
+ export declare const alphanumDashUnderscore: RegExp;
15
+ export declare const alphanumDashUnderscoreDotsSpacesParenthesis: RegExp;
16
+ export declare const alphanumDashUnderscoreDotsSpaces: RegExp;
17
+ export declare const alphanumDashUnderscoreDollar: RegExp;
18
+ export declare const alphanumDots: RegExp;
19
+ export declare const alphanumLowercase: RegExp;
20
+ export declare const absoluteLinuxPath: RegExp;
21
+ export declare const ascii: RegExp;
22
+ export declare const backupKey: RegExp;
23
+ export declare const basicDomain: RegExp;
24
+ export declare const uppercaseBasicDomain: RegExp;
25
+ export declare const uppercaseBasicSubdomain: RegExp;
26
+ export declare const advancedDomainName: RegExp;
27
+ export declare const cron: RegExp;
28
+ export declare const digits: RegExp;
29
+ export declare const macAddress: RegExp;
30
+ export declare const email: RegExp;
31
+ export declare const fourDigitsCode: RegExp;
32
+ export declare const phone: RegExp;
33
+ export declare const spaces: RegExp;
34
+ export declare const sixDigitsCode: RegExp;
35
+ export declare const url: RegExp;
36
+ export declare const hexadecimal: RegExp;
37
+ export declare const s3BucketName: RegExp;
38
+ export declare const ip: RegExp;
39
+ export declare const ipv4: RegExp;
40
+ export declare const ipv6: RegExp;
41
+ export declare const ipCidr: RegExp;
42
+ export declare const ipv4Cidr: RegExp;
43
+ export declare const ipv6Cidr: RegExp;
44
+ export declare const reverseDNS: RegExp;
45
+ export declare const dashedIpv4: RegExp;
46
+ export declare const pathSegment: RegExp;
47
+ export declare const absolutePath: RegExp;
package/dist/index.js CHANGED
@@ -1,65 +1,61 @@
1
- const accessKeyRegex = /^SCW[A-Z0-9]{17}$/i;
2
- const alpha = /^[a-zA-Z]*$/;
3
- const alphaLowercase = /^[a-z]+$/;
4
- const alphanum = /^[a-zA-Z0-9]*$/;
5
- const alphaDashes = /^[a-zA-Z-]*$/;
6
- const alphanumDash = /^[a-zA-Z0-9-]*$/;
7
- const alphanumDashDots = /^[a-zA-Z0-9-.]*$/;
8
- const alphanumDashDotsOrEmpty = /^$|^[a-zA-Z0-9-.]*$/;
9
- const alphanumDashDotsSpaces = /^[a-zA-Z0-9-.\s]*$/;
10
- const alphanumDashLowercase = /^[a-z0-9-]+$/;
11
- const alphanumDashSpaces = /^[a-zA-Z0-9-\s]*$/;
12
- const alphanumDashOrEmpty = /^$|^[a-zA-Z0-9-]*$/;
13
- const alphanumDashUnderscoreDots = /^[a-zA-Z0-9-._]*$/;
14
- const alphanumDashUnderscore = /^[a-zA-Z0-9-_]*$/;
15
- const alphanumDashUnderscoreDotsSpacesParenthesis = /^[a-zA-Z0-9-_.()\s]*$/;
16
- const alphanumDashUnderscoreDotsSpaces = /^[a-zA-Z0-9-.\s_]*$/;
17
- const alphanumDashUnderscoreDollar = /^[a-zA-Z0-9_$-]*$/;
18
- const alphanumDots = /^[a-zA-Z0-9.]*$/;
19
- const alphanumLowercase = /^[a-z0-9]+$/;
20
- const absoluteLinuxPath = /(^\/$|^(\/[a-zA-Z0-9_]+)*$)/;
21
- const ascii = /^[\x00-\x7F]+$/;
22
- const backupKey = /^[A-Z0-9]{32}$/;
23
- const basicDomain = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+$/;
24
- const uppercaseBasicDomain = /^(?![-])+[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,63})+$/;
25
- const uppercaseBasicSubdomain = /^(?![-])+[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,63})+$/;
26
- const advancedDomainName = /^(?:(?:(?:[a-zA-Z0-9À-ÖØ-öø-ÿ](?:[a-zA-Z0-9À-ÖØ-öø-ÿ-]{0,61}[a-zA-Z0-9À-ÖØ-öø-ÿ])?)\.)+[a-zA-Z]{2,}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::[\d]{1,5})?$/;
27
- const cron = /^((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7})$/;
28
- const digits = /^[0-9]*$/;
29
- const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
30
- const email = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
31
- const fourDigitsCode = /^[0-9]{4}$/;
32
- const phone = /^\+[0-9]*/;
33
- const spaces = /^\s*$/;
34
- const sixDigitsCode = /^[0-9]{6}$/;
35
- const url = /^http(s)?:\/\/?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/;
36
- const hexadecimal = /^[0-9a-fA-F]+$/;
37
- const s3BucketName = /^[a-z0-9][-.a-z0-9]{1,61}[a-z0-9]$/;
38
- const v4 = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';
39
- const v6segment = '[a-fA-F\\d]{1,4}';
40
- const v6 = `
1
+ const o = /^SCW[A-Z0-9]{17}$/i, t = /^[a-zA-Z]*$/, e = /^[a-z]+$/, p = /^[a-zA-Z0-9]*$/, z = /^[a-zA-Z-]*$/, A = /^[a-zA-Z0-9-]*$/, h = /^[a-zA-Z0-9-.]*$/, d = /^$|^[a-zA-Z0-9-.]*$/, r = /^[a-zA-Z0-9-.\s]*$/, Z = /^[a-z0-9-]+$/, i = /^[a-zA-Z0-9-\s]*$/, m = /^$|^[a-zA-Z0-9-]*$/, l = /^[a-zA-Z0-9-._]*$/, D = /^[a-zA-Z0-9-_]*$/, u = /^[a-zA-Z0-9-_.()\s]*$/, g = /^[a-zA-Z0-9-.\s_]*$/, w = /^[a-zA-Z0-9_$-]*$/, x = /^[a-zA-Z0-9.]*$/, v = /^[a-z0-9]+$/, _ = /(^\/$|^(\/[a-zA-Z0-9_]+)*$)/, b = /^[\x00-\x7F]+$/, E = /^[A-Z0-9]{32}$/, S = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+$/, f = /^(?![-])+[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,63})+$/, F = /^(?![-])+[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,63})+$/, R = /^(?:(?:(?:[a-zA-Z0-9À-ÖØ-öø-ÿ](?:[a-zA-Z0-9À-ÖØ-öø-ÿ-]{0,61}[a-zA-Z0-9À-ÖØ-öø-ÿ])?)\.)+[a-zA-Z]{2,}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::[\d]{1,5})?$/, C = /^((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7})$/, U = /^[0-9]*$/, y = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/, L = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/, B = /^[0-9]{4}$/, N = /^\+[0-9]*/, P = /^\s*$/, k = /^[0-9]{6}$/, K = /^http(s)?:\/\/?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/, O = /^[0-9a-fA-F]+$/, I = /^[a-z0-9][-.a-z0-9]{1,61}[a-z0-9]$/, s = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}", a = "[a-fA-F\\d]{1,4}", n = `
41
2
  (?:
42
- (?:${v6segment}:){7}(?:${v6segment}|:)|
43
- (?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)|
44
- (?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)|
45
- (?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)|
46
- (?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)|
47
- (?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)|
48
- (?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)|
49
- (?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:))
3
+ (?:${a}:){7}(?:${a}|:)|
4
+ (?:${a}:){6}(?:${s}|:${a}|:)|
5
+ (?:${a}:){5}(?::${s}|(?::${a}){1,2}|:)|
6
+ (?:${a}:){4}(?:(?::${a}){0,1}:${s}|(?::${a}){1,3}|:)|
7
+ (?:${a}:){3}(?:(?::${a}){0,2}:${s}|(?::${a}){1,4}|:)|
8
+ (?:${a}:){2}(?:(?::${a}){0,3}:${s}|(?::${a}){1,5}|:)|
9
+ (?:${a}:){1}(?:(?::${a}){0,4}:${s}|(?::${a}){1,6}|:)|
10
+ (?::(?:(?::${a}){0,5}:${s}|(?::${a}){1,7}|:))
50
11
  )(?:%[0-9a-zA-Z]{1,})?
51
- `.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();
52
- const cidrv4 = `${v4}\\/(3[0-2]|[12]?[0-9])`;
53
- const cidrv6 = `${v6}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`;
54
- const ip = new RegExp(`^(?:${v4}|${v6})$`);
55
- const ipv4 = new RegExp(`^${v4}$`);
56
- const ipv6 = new RegExp(`^${v6}$`);
57
- const ipCidr = new RegExp(`(?:^${cidrv4}$)|(?:^${cidrv6}$)`);
58
- const ipv4Cidr = new RegExp(`^${cidrv4}$`);
59
- const ipv6Cidr = new RegExp(`^${cidrv6}$`);
60
- const reverseDNS = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+(\.)$/;
61
- const dashedIpv4 = /(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(-(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/;
62
- const pathSegment = /^[_a-zA-Z0-9]([-_.a-zA-Z0-9]*[_a-zA-Z0-9])?$/;
63
- const absolutePath = /^\/(([\w. -]*)[^\s?]\/?)+$/;
64
-
65
- export { absoluteLinuxPath, absolutePath, accessKeyRegex, advancedDomainName, alpha, alphaDashes, alphaLowercase, alphanum, alphanumDash, alphanumDashDots, alphanumDashDotsOrEmpty, alphanumDashDotsSpaces, alphanumDashLowercase, alphanumDashOrEmpty, alphanumDashSpaces, alphanumDashUnderscore, alphanumDashUnderscoreDollar, alphanumDashUnderscoreDots, alphanumDashUnderscoreDotsSpaces, alphanumDashUnderscoreDotsSpacesParenthesis, alphanumDots, alphanumLowercase, ascii, backupKey, basicDomain, cron, dashedIpv4, digits, email, fourDigitsCode, hexadecimal, ip, ipCidr, ipv4, ipv4Cidr, ipv6, ipv6Cidr, macAddress, pathSegment, phone, reverseDNS, s3BucketName, sixDigitsCode, spaces, uppercaseBasicDomain, uppercaseBasicSubdomain, url };
12
+ `.replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim(), $ = `${s}\\/(3[0-2]|[12]?[0-9])`, c = `${n}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`, W = new RegExp(`^(?:${s}|${n})$`), j = new RegExp(`^${s}$`), q = new RegExp(`^${n}$`), G = new RegExp(`(?:^${$}$)|(?:^${c}$)`), H = new RegExp(`^${$}$`), J = new RegExp(`^${c}$`), M = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+(\.)$/, Q = /(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(-(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/, T = /^[_a-zA-Z0-9]([-_.a-zA-Z0-9]*[_a-zA-Z0-9])?$/, V = /^\/(([\w. -]*)[^\s?]\/?)+$/;
13
+ export {
14
+ _ as absoluteLinuxPath,
15
+ V as absolutePath,
16
+ o as accessKeyRegex,
17
+ R as advancedDomainName,
18
+ t as alpha,
19
+ z as alphaDashes,
20
+ e as alphaLowercase,
21
+ p as alphanum,
22
+ A as alphanumDash,
23
+ h as alphanumDashDots,
24
+ d as alphanumDashDotsOrEmpty,
25
+ r as alphanumDashDotsSpaces,
26
+ Z as alphanumDashLowercase,
27
+ m as alphanumDashOrEmpty,
28
+ i as alphanumDashSpaces,
29
+ D as alphanumDashUnderscore,
30
+ w as alphanumDashUnderscoreDollar,
31
+ l as alphanumDashUnderscoreDots,
32
+ g as alphanumDashUnderscoreDotsSpaces,
33
+ u as alphanumDashUnderscoreDotsSpacesParenthesis,
34
+ x as alphanumDots,
35
+ v as alphanumLowercase,
36
+ b as ascii,
37
+ E as backupKey,
38
+ S as basicDomain,
39
+ C as cron,
40
+ Q as dashedIpv4,
41
+ U as digits,
42
+ L as email,
43
+ B as fourDigitsCode,
44
+ O as hexadecimal,
45
+ W as ip,
46
+ G as ipCidr,
47
+ j as ipv4,
48
+ H as ipv4Cidr,
49
+ q as ipv6,
50
+ J as ipv6Cidr,
51
+ y as macAddress,
52
+ T as pathSegment,
53
+ N as phone,
54
+ M as reverseDNS,
55
+ I as s3BucketName,
56
+ k as sixDigitsCode,
57
+ P as spaces,
58
+ f as uppercaseBasicDomain,
59
+ F as uppercaseBasicSubdomain,
60
+ K as url
61
+ };
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@scaleway/regex",
3
- "version": "4.2.1",
3
+ "version": "5.0.1",
4
4
  "description": "A small utility to use regex",
5
5
  "type": "module",
6
6
  "engines": {
7
- "node": ">=14.x"
7
+ "node": ">=20.x"
8
8
  },
9
9
  "sideEffects": false,
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
10
12
  "exports": {
11
- "types": "./dist/index.d.ts",
12
- "default": "./dist/index.js"
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "require": "./dist/index.cjs",
16
+ "default": "./dist/index.js"
17
+ }
13
18
  },
14
19
  "publishConfig": {
15
20
  "access": "public"
@@ -19,5 +24,12 @@
19
24
  "url": "https://github.com/scaleway/scaleway-lib",
20
25
  "directory": "packages/regex"
21
26
  },
22
- "license": "MIT"
27
+ "license": "MIT",
28
+ "scripts": {
29
+ "typecheck": "tsc --noEmit",
30
+ "type:generate": "tsc --declaration -p tsconfig.build.json",
31
+ "build": "vite build --config vite.config.ts && pnpm run type:generate",
32
+ "build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
33
+ "lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx ."
34
+ }
23
35
  }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": false,
5
+ "emitDeclarationOnly": true,
6
+ "rootDir": "src",
7
+ "outDir": "dist"
8
+ },
9
+ "exclude": [
10
+ "*.config.ts",
11
+ "*.setup.ts",
12
+ "**/__tests__",
13
+ "**/__mocks__",
14
+ "src/**/*.test.tsx"
15
+ ]
16
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["src/**/*.ts", "src/**/*.tsx", "*.config.ts"]
4
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ /* eslint-disable eslint-comments/disable-enable-pair */
2
+ /* eslint-disable import/no-relative-packages */
3
+ /* eslint-disable-next-line import/no-extraneous-dependencies */
4
+ import { defineConfig, mergeConfig } from 'vite'
5
+ import { defaultConfig } from '../../vite.config'
6
+
7
+ export default mergeConfig(defineConfig(defaultConfig), {
8
+ build: {
9
+ target: ['node20'],
10
+ },
11
+ })