@20syldev/api 4.8.0 → 5.0.0

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 (126) hide show
  1. package/README.md +93 -55
  2. package/dist/config/versions.js +16 -0
  3. package/dist/config/versions.js.map +1 -1
  4. package/dist/constants.js +5 -0
  5. package/dist/constants.js.map +1 -1
  6. package/dist/modules/v5/chart.js +379 -0
  7. package/dist/modules/v5/chart.js.map +1 -0
  8. package/dist/modules/v5/evaluate.js +281 -0
  9. package/dist/modules/v5/evaluate.js.map +1 -0
  10. package/dist/modules/v5/matrix.js +238 -0
  11. package/dist/modules/v5/matrix.js.map +1 -0
  12. package/dist/modules/v5.js +5 -0
  13. package/dist/modules/v5.js.map +1 -0
  14. package/dist/routes/get.js +191 -162
  15. package/dist/routes/get.js.map +1 -1
  16. package/dist/routes/post.js +69 -0
  17. package/dist/routes/post.js.map +1 -1
  18. package/package.json +4 -2
  19. package/recap.md +98 -0
  20. package/.github/FUNDING.yml +0 -1
  21. package/.prettierrc +0 -7
  22. package/eslint.config.js +0 -24
  23. package/robots.txt +0 -74
  24. package/src/app.ts +0 -53
  25. package/src/config/env.ts +0 -87
  26. package/src/config/plans.ts +0 -61
  27. package/src/config/versions.ts +0 -121
  28. package/src/constants.ts +0 -61
  29. package/src/favicon.ico +0 -0
  30. package/src/middleware/cors.ts +0 -23
  31. package/src/middleware/error.ts +0 -16
  32. package/src/middleware/json.ts +0 -9
  33. package/src/middleware/logger.ts +0 -32
  34. package/src/middleware/ratelimit.ts +0 -89
  35. package/src/middleware/version.ts +0 -40
  36. package/src/modules/v3/algorithms.js +0 -218
  37. package/src/modules/v3/captcha.js +0 -60
  38. package/src/modules/v3/chat.js +0 -111
  39. package/src/modules/v3/color.js +0 -60
  40. package/src/modules/v3/convert.js +0 -39
  41. package/src/modules/v3/domain.js +0 -86
  42. package/src/modules/v3/hash.js +0 -16
  43. package/src/modules/v3/hyperplanning.js +0 -56
  44. package/src/modules/v3/levenshtein.js +0 -46
  45. package/src/modules/v3/personal.js +0 -139
  46. package/src/modules/v3/qrcode.js +0 -20
  47. package/src/modules/v3/tic_tac_toe.js +0 -242
  48. package/src/modules/v3/time.js +0 -98
  49. package/src/modules/v3/token.js +0 -54
  50. package/src/modules/v3/username.js +0 -94
  51. package/src/modules/v3/utils.js +0 -77
  52. package/src/modules/v3.js +0 -15
  53. package/src/modules/v4/address.ts +0 -412
  54. package/src/modules/v4/agent.ts +0 -104
  55. package/src/modules/v4/algorithms.ts +0 -276
  56. package/src/modules/v4/captcha.ts +0 -114
  57. package/src/modules/v4/chat.ts +0 -130
  58. package/src/modules/v4/color.ts +0 -75
  59. package/src/modules/v4/convert.ts +0 -127
  60. package/src/modules/v4/cron.ts +0 -221
  61. package/src/modules/v4/dice.ts +0 -46
  62. package/src/modules/v4/domain.ts +0 -86
  63. package/src/modules/v4/encode.ts +0 -241
  64. package/src/modules/v4/geo.ts +0 -64
  65. package/src/modules/v4/hash.ts +0 -32
  66. package/src/modules/v4/hyperplanning.ts +0 -93
  67. package/src/modules/v4/ip.ts +0 -134
  68. package/src/modules/v4/levenshtein.ts +0 -46
  69. package/src/modules/v4/palette.ts +0 -71
  70. package/src/modules/v4/password.ts +0 -379
  71. package/src/modules/v4/personal.ts +0 -140
  72. package/src/modules/v4/placeholder.ts +0 -197
  73. package/src/modules/v4/qrcode.ts +0 -121
  74. package/src/modules/v4/regex.ts +0 -67
  75. package/src/modules/v4/statistics.ts +0 -62
  76. package/src/modules/v4/text.ts +0 -330
  77. package/src/modules/v4/tic_tac_toe.ts +0 -264
  78. package/src/modules/v4/time.ts +0 -149
  79. package/src/modules/v4/token.ts +0 -53
  80. package/src/modules/v4/username.ts +0 -94
  81. package/src/modules/v4/validate.ts +0 -76
  82. package/src/modules/v4.ts +0 -29
  83. package/src/routes/delete.ts +0 -72
  84. package/src/routes/get.ts +0 -856
  85. package/src/routes/index.ts +0 -59
  86. package/src/routes/patch.ts +0 -45
  87. package/src/routes/post.ts +0 -209
  88. package/src/storage/index.ts +0 -16
  89. package/src/types/express.d.ts +0 -17
  90. package/src/types/storage.ts +0 -48
  91. package/src/utils/colors.ts +0 -91
  92. package/src/utils/helpers.ts +0 -90
  93. package/src/utils/response.ts +0 -28
  94. package/tests/integration/api.test.ts +0 -772
  95. package/tests/tsconfig.json +0 -3
  96. package/tests/unit/address.test.ts +0 -84
  97. package/tests/unit/agent.test.ts +0 -113
  98. package/tests/unit/algorithms.test.ts +0 -121
  99. package/tests/unit/captcha.test.ts +0 -62
  100. package/tests/unit/chat.test.ts +0 -54
  101. package/tests/unit/color.test.ts +0 -54
  102. package/tests/unit/convert.test.ts +0 -68
  103. package/tests/unit/cron.test.ts +0 -110
  104. package/tests/unit/dice.test.ts +0 -58
  105. package/tests/unit/domain.test.ts +0 -48
  106. package/tests/unit/encode.test.ts +0 -109
  107. package/tests/unit/geo.test.ts +0 -46
  108. package/tests/unit/hash.test.ts +0 -45
  109. package/tests/unit/hyperplanning.test.ts +0 -97
  110. package/tests/unit/ip.test.ts +0 -140
  111. package/tests/unit/levenshtein.test.ts +0 -35
  112. package/tests/unit/palette.test.ts +0 -54
  113. package/tests/unit/password.test.ts +0 -86
  114. package/tests/unit/personal.test.ts +0 -66
  115. package/tests/unit/placeholder.test.ts +0 -58
  116. package/tests/unit/qrcode.test.ts +0 -83
  117. package/tests/unit/regex.test.ts +0 -95
  118. package/tests/unit/statistics.test.ts +0 -58
  119. package/tests/unit/text.test.ts +0 -108
  120. package/tests/unit/tic_tac_toe.test.ts +0 -56
  121. package/tests/unit/time.test.ts +0 -115
  122. package/tests/unit/token.test.ts +0 -62
  123. package/tests/unit/username.test.ts +0 -35
  124. package/tests/unit/validate.test.ts +0 -72
  125. package/tsconfig.json +0 -17
  126. package/tsconfig.test.json +0 -9
@@ -1,115 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import time from '../../src/modules/v4/time.js';
5
-
6
- describe('time', () => {
7
- test('live returns full set of formats', () => {
8
- const result = time('live');
9
- const fields = [
10
- 'iso',
11
- 'utc',
12
- 'timestamp',
13
- 'locale',
14
- 'date',
15
- 'time',
16
- 'year',
17
- 'month',
18
- 'day',
19
- 'hour',
20
- 'minute',
21
- 'second',
22
- 'ms',
23
- 'dayOfWeek',
24
- 'dayOfYear',
25
- 'weekNumber',
26
- 'timezone',
27
- 'timezoneOffset',
28
- ];
29
- for (const f of fields) {
30
- assert.ok(f in result, `missing field: ${f}`);
31
- }
32
- });
33
-
34
- test('iso is parseable', () => {
35
- const result = time('live');
36
- assert.ok(!isNaN(Date.parse(result.iso as string)));
37
- });
38
-
39
- test('format=year returns only date', () => {
40
- const result = time('live', undefined, undefined, 'year');
41
- assert.ok('date' in result);
42
- assert.equal(typeof result.date, 'number');
43
- });
44
-
45
- test('random within range', () => {
46
- const result = time('random', '2020-01-01', '2020-12-31');
47
- const ts = result.timestamp as number;
48
- assert.ok(ts >= new Date('2020-01-01').getTime());
49
- assert.ok(ts <= new Date('2020-12-31').getTime());
50
- });
51
-
52
- test('throws on invalid type', () => {
53
- assert.throws(() => time('foo'), /valid type/);
54
- });
55
-
56
- test('throws on invalid format', () => {
57
- assert.throws(() => time('live', undefined, undefined, 'fakeformat'), /valid format/);
58
- });
59
-
60
- test('throws on invalid timezone', () => {
61
- assert.throws(() => time('live', undefined, undefined, undefined, 'Mars/Olympus'), /valid timezone/);
62
- });
63
-
64
- test('Europe/Paris timezone', () => {
65
- const result = time('live', undefined, undefined, undefined, 'Europe/Paris');
66
- assert.equal(result.timezone, 'Europe/Paris');
67
- });
68
-
69
- describe('countdown', () => {
70
- test('future date returns direction future', () => {
71
- const future = new Date(Date.now() + 7 * 24 * 3600 * 1000).toISOString();
72
- const r = time('countdown', undefined, undefined, undefined, undefined, future);
73
- assert.equal(r.direction, 'future');
74
- });
75
-
76
- test('past date returns direction past', () => {
77
- const past = new Date(Date.now() - 7 * 24 * 3600 * 1000).toISOString();
78
- const r = time('countdown', undefined, undefined, undefined, undefined, past);
79
- assert.equal(r.direction, 'past');
80
- });
81
-
82
- test('remaining breakdown is correct', () => {
83
- const target = new Date(Date.now() + 2 * 86400 * 1000 + 3 * 3600 * 1000).toISOString();
84
- const r = time('countdown', undefined, undefined, undefined, undefined, target);
85
- const rem = r.remaining as { days: number; hours: number };
86
- assert.equal(rem.days, 2);
87
- assert.equal(rem.hours, 3);
88
- });
89
-
90
- test('human skips zero units', () => {
91
- const target = new Date(Date.now() + 3 * 86400 * 1000).toISOString();
92
- const r = time('countdown', undefined, undefined, undefined, undefined, target);
93
- assert.ok(!(r.human as string).includes('hour'));
94
- assert.ok(!(r.human as string).includes('minute'));
95
- });
96
-
97
- test('throws on missing target', () => {
98
- assert.throws(() => time('countdown'), /target date/);
99
- });
100
-
101
- test('throws on invalid target', () => {
102
- assert.throws(
103
- () => time('countdown', undefined, undefined, undefined, undefined, 'not-a-date'),
104
- /valid target date/,
105
- );
106
- });
107
-
108
- test('throws if target is more than 100 years away', () => {
109
- assert.throws(
110
- () => time('countdown', undefined, undefined, undefined, undefined, '2200-01-01'),
111
- /100 years/,
112
- );
113
- });
114
- });
115
- });
@@ -1,62 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import token from '../../src/modules/v4/token.js';
5
-
6
- describe('token', () => {
7
- test('alpha length', () => {
8
- const t = token(24, 'alpha');
9
- assert.equal(t.length, 24);
10
- assert.match(t, /^[a-zA-Z]+$/);
11
- });
12
-
13
- test('alphanum length', () => {
14
- const t = token(32, 'alphanum');
15
- assert.equal(t.length, 32);
16
- assert.match(t, /^[a-zA-Z0-9]+$/);
17
- });
18
-
19
- test('hex contains only hex chars', () => {
20
- const t = token(16, 'hex');
21
- assert.equal(t.length, 16);
22
- assert.match(t, /^[0-9a-f]+$/);
23
- });
24
-
25
- test('num contains only digits', () => {
26
- const t = token(20, 'num');
27
- assert.match(t, /^\d+$/);
28
- });
29
-
30
- test('urlsafe chars only', () => {
31
- const t = token(40, 'urlsafe');
32
- assert.match(t, /^[a-zA-Z0-9_-]+$/);
33
- });
34
-
35
- test('uuid type produces hex', () => {
36
- const t = token(32, 'uuid');
37
- assert.equal(t.length, 32);
38
- });
39
-
40
- test('default type alphanum', () => {
41
- const t = token(20);
42
- assert.match(t, /^[a-zA-Z0-9]+$/);
43
- });
44
-
45
- test('throws below minimum length', () => {
46
- assert.throws(() => token(5, 'alpha'), /greater than or equal to 12/);
47
- });
48
-
49
- test('throws above maximum length', () => {
50
- assert.throws(() => token(5000, 'alpha'), /4096/);
51
- });
52
-
53
- test('throws on invalid type', () => {
54
- assert.throws(() => token(20, 'martian'), /Invalid token type/);
55
- });
56
-
57
- test('two tokens are different (entropy check)', () => {
58
- const a = token(32, 'alphanum');
59
- const b = token(32, 'alphanum');
60
- assert.notEqual(a, b);
61
- });
62
- });
@@ -1,35 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import username from '../../src/modules/v4/username.js';
5
-
6
- describe('username', () => {
7
- test('returns expected fields', () => {
8
- const result = username();
9
- assert.ok('username' in result);
10
- assert.ok('number' in result);
11
- assert.ok('adjective' in result);
12
- assert.ok('animal' in result);
13
- assert.ok('job' in result);
14
- });
15
-
16
- test('username is a non-empty string', () => {
17
- const result = username();
18
- assert.equal(typeof result.username, 'string');
19
- assert.ok((result.username as string).length > 0);
20
- });
21
-
22
- test('number is between 0 and 99', () => {
23
- const result = username();
24
- const n = result.number as number;
25
- assert.ok(n >= 0 && n <= 99);
26
- });
27
-
28
- test('produces varied usernames', () => {
29
- const seen = new Set<string>();
30
- for (let i = 0; i < 10; i++) {
31
- seen.add(username().username as string);
32
- }
33
- assert.ok(seen.size > 1);
34
- });
35
- });
@@ -1,72 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import { email, iban, luhn } from '../../src/modules/v4/validate.js';
5
-
6
- describe('validate', () => {
7
- describe('luhn', () => {
8
- test('valid Visa test card', () => {
9
- const result = luhn('4111111111111111');
10
- assert.equal(result.valid, true);
11
- });
12
-
13
- test('invalid card number', () => {
14
- const result = luhn('4111111111111112');
15
- assert.equal(result.valid, false);
16
- });
17
-
18
- test('strips spaces and dashes', () => {
19
- const result = luhn('4111-1111 1111-1111');
20
- assert.equal(result.valid, true);
21
- assert.equal(result.value, '4111111111111111');
22
- });
23
-
24
- test('throws on non-digit', () => {
25
- assert.throws(() => luhn('4111ABC11111111'), /only digits/);
26
- });
27
-
28
- test('throws on too short', () => {
29
- assert.throws(() => luhn('411111'), /between 12 and 19/);
30
- });
31
- });
32
-
33
- describe('iban', () => {
34
- test('valid French IBAN', () => {
35
- const result = iban('FR1420041010050500013M02606');
36
- assert.equal(result.valid, true);
37
- assert.equal(result.country, 'FR');
38
- });
39
-
40
- test('invalid checksum', () => {
41
- const result = iban('FR1420041010050500013M02607');
42
- assert.equal(result.valid, false);
43
- });
44
-
45
- test('strips spaces', () => {
46
- const result = iban('FR14 2004 1010 0505 0001 3M02 606');
47
- assert.equal(result.valid, true);
48
- });
49
-
50
- test('throws on bad format', () => {
51
- assert.throws(() => iban('1234'), /Invalid IBAN format/);
52
- });
53
- });
54
-
55
- describe('email', () => {
56
- test('valid email', () => {
57
- assert.equal(email('hello@example.com').valid, true);
58
- });
59
-
60
- test('rejects missing domain', () => {
61
- assert.equal(email('hello@').valid, false);
62
- });
63
-
64
- test('rejects missing @', () => {
65
- assert.equal(email('helloexample.com').valid, false);
66
- });
67
-
68
- test('rejects spaces', () => {
69
- assert.equal(email('hello world@example.com').valid, false);
70
- });
71
- });
72
- });
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "allowJs": true,
7
- "strict": true,
8
- "noUncheckedIndexedAccess": true,
9
- "outDir": "dist",
10
- "rootDir": "src",
11
- "declaration": false,
12
- "sourceMap": true,
13
- "esModuleInterop": true,
14
- "skipLibCheck": true
15
- },
16
- "include": ["src"]
17
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": ".",
5
- "noEmit": true,
6
- "types": ["node"]
7
- },
8
- "include": ["src", "tests"]
9
- }