@privateaim/kit 0.4.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 (55) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +202 -0
  3. package/dist/constants.d.ts +6 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/domains/index.d.ts +2 -0
  6. package/dist/domains/index.d.ts.map +1 -0
  7. package/dist/domains/permission/constants.d.ts +88 -0
  8. package/dist/domains/permission/constants.d.ts.map +1 -0
  9. package/dist/domains/permission/index.d.ts +2 -0
  10. package/dist/domains/permission/index.d.ts.map +1 -0
  11. package/dist/index.cjs +243 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.ts +4 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.mjs +225 -0
  16. package/dist/index.mjs.map +1 -0
  17. package/dist/utils/boolean.d.ts +4 -0
  18. package/dist/utils/boolean.d.ts.map +1 -0
  19. package/dist/utils/error.d.ts +2 -0
  20. package/dist/utils/error.d.ts.map +1 -0
  21. package/dist/utils/has-own-property.d.ts +3 -0
  22. package/dist/utils/has-own-property.d.ts.map +1 -0
  23. package/dist/utils/hex-checker.d.ts +3 -0
  24. package/dist/utils/hex-checker.d.ts.map +1 -0
  25. package/dist/utils/hostname.d.ts +2 -0
  26. package/dist/utils/hostname.d.ts.map +1 -0
  27. package/dist/utils/index.d.ts +10 -0
  28. package/dist/utils/index.d.ts.map +1 -0
  29. package/dist/utils/nanoid.d.ts +4 -0
  30. package/dist/utils/nanoid.d.ts.map +1 -0
  31. package/dist/utils/object-properties.d.ts +3 -0
  32. package/dist/utils/object-properties.d.ts.map +1 -0
  33. package/dist/utils/proxy-connection-string.d.ts +12 -0
  34. package/dist/utils/proxy-connection-string.d.ts.map +1 -0
  35. package/dist/utils/regex-patterns.d.ts +3 -0
  36. package/dist/utils/regex-patterns.d.ts.map +1 -0
  37. package/package.json +41 -0
  38. package/rollup.config.mjs +19 -0
  39. package/src/constants.ts +12 -0
  40. package/src/domains/index.ts +8 -0
  41. package/src/domains/permission/constants.ts +46 -0
  42. package/src/domains/permission/index.ts +8 -0
  43. package/src/index.ts +10 -0
  44. package/src/utils/boolean.ts +18 -0
  45. package/src/utils/error.ts +12 -0
  46. package/src/utils/has-own-property.ts +19 -0
  47. package/src/utils/hex-checker.ts +22 -0
  48. package/src/utils/hostname.ts +18 -0
  49. package/src/utils/index.ts +16 -0
  50. package/src/utils/nanoid.ts +23 -0
  51. package/src/utils/object-properties.ts +31 -0
  52. package/src/utils/proxy-connection-string.ts +64 -0
  53. package/src/utils/regex-patterns.ts +9 -0
  54. package/tsconfig.build.json +11 -0
  55. package/tsconfig.json +3 -0
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2021-2024.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */
7
+
8
+ import { customAlphabet } from 'nanoid';
9
+
10
+ export function createNanoID(alphabet?: string) : string;
11
+ export function createNanoID(len?: number) : string;
12
+ export function createNanoID(alphabet?: string, len?: number) : string;
13
+ export function createNanoID(alphabetOrLen?: string | number, len?: number) : string {
14
+ if (typeof alphabetOrLen === 'string') {
15
+ return customAlphabet(alphabetOrLen, len || 21)();
16
+ }
17
+
18
+ if (typeof alphabetOrLen === 'number') {
19
+ return customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', alphabetOrLen)();
20
+ }
21
+
22
+ return customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', len || 21)();
23
+ }
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (c) 2021-2024.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */
7
+
8
+ export function nullifyEmptyObjectProperties<T extends Record<string, any>>(data: T) : T {
9
+ const keys : (keyof T)[] = Object.keys(data);
10
+
11
+ for (let i = 0; i < keys.length; i++) {
12
+ const key = keys[i];
13
+ if (data[key] === '') {
14
+ data[key] = null as T[keyof T];
15
+ }
16
+ }
17
+
18
+ return data as T;
19
+ }
20
+
21
+ export function deleteUndefinedObjectProperties<T extends Record<string, any>>(data: T) : T {
22
+ const keys : string[] = Object.keys(data);
23
+
24
+ for (let i = 0; i < keys.length; i++) {
25
+ if (typeof data[keys[i]] === 'undefined') {
26
+ delete data[keys[i]];
27
+ }
28
+ }
29
+
30
+ return data;
31
+ }
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright (c) 2021-2024.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */
7
+
8
+ export type ProxyConnectionConfig = {
9
+ protocol: 'http' | 'https',
10
+ host: string,
11
+ port: number,
12
+ auth: {
13
+ username: string,
14
+ password: string,
15
+ }
16
+ };
17
+
18
+ export function parseProxyConnectionString(connectionStr: string) : ProxyConnectionConfig | undefined {
19
+ const match = connectionStr
20
+ .match(/(?:(https|http):\/\/)(?:(\w+)(?::(\w+))?@)?(?:([^:]+))(?::(\d{1,5}))?$/);
21
+
22
+ if (!match) {
23
+ return undefined;
24
+ }
25
+
26
+ return {
27
+ protocol: match[1] as 'http' | 'https',
28
+ host: match[4],
29
+ port: parseInt(match[5], 10),
30
+ auth: {
31
+ username: match[2],
32
+ password: match[3],
33
+ },
34
+ };
35
+ }
36
+
37
+ export function detectProxyConnectionConfig() : ProxyConnectionConfig | undefined {
38
+ const envKeys = [
39
+ 'https_proxy',
40
+ 'HTTPS_PROXY',
41
+ 'http_proxy',
42
+ 'HTTP_PROXY',
43
+ ];
44
+
45
+ let result : string | undefined;
46
+
47
+ for (let i = 0; i < envKeys.length; i++) {
48
+ const envKey = envKeys[i];
49
+ const envVal = process.env[envKey];
50
+
51
+ if (
52
+ envVal !== undefined &&
53
+ envVal !== null
54
+ ) {
55
+ result = result || envVal;
56
+ }
57
+ }
58
+
59
+ if (!result) {
60
+ return undefined;
61
+ }
62
+
63
+ return parseProxyConnectionString(result);
64
+ }
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2023-2024.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */
7
+
8
+ export const alphaNumHyphenUnderscoreRegex = /^[a-z0-9-_]*$/;
9
+ export const registryRobotSecretRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/;
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.build.json",
3
+
4
+ "compilerOptions": {
5
+ "outDir": "./dist"
6
+ },
7
+
8
+ "include": [
9
+ "src/**/*.ts"
10
+ ]
11
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../tsconfig.json"
3
+ }