@dolthub/web-utils 0.1.10 → 0.2.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 (98) hide show
  1. package/README.md +12 -0
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/esm/index.js +1 -1
  5. package/dist/esm/index.js.map +1 -1
  6. package/package.json +22 -15
  7. package/dist/cjs/types/Maybe.d.ts +0 -2
  8. package/dist/cjs/types/__tests__/compareArray.test.d.ts +0 -1
  9. package/dist/cjs/types/__tests__/dateConversions.test.d.ts +0 -1
  10. package/dist/cjs/types/__tests__/dedupe.test.d.ts +0 -1
  11. package/dist/cjs/types/__tests__/enumKeys.test.d.ts +0 -1
  12. package/dist/cjs/types/__tests__/excerpt.test.d.ts +0 -1
  13. package/dist/cjs/types/__tests__/helpers/mutationExamples.d.ts +0 -1
  14. package/dist/cjs/types/__tests__/initialUppercase.test.d.ts +0 -1
  15. package/dist/cjs/types/__tests__/loremer.test.d.ts +0 -1
  16. package/dist/cjs/types/__tests__/nTimes.test.d.ts +0 -1
  17. package/dist/cjs/types/__tests__/null.test.d.ts +0 -1
  18. package/dist/cjs/types/__tests__/numberFormat.test.d.ts +0 -1
  19. package/dist/cjs/types/__tests__/parseSqlQuery.test.d.ts +0 -1
  20. package/dist/cjs/types/__tests__/pluralize.test.d.ts +0 -1
  21. package/dist/cjs/types/__tests__/prettyJSON.test.d.ts +0 -1
  22. package/dist/cjs/types/__tests__/randomArrayItem.test.d.ts +0 -1
  23. package/dist/cjs/types/__tests__/safeJSONParse.test.d.ts +0 -1
  24. package/dist/cjs/types/__tests__/sprintf.test.d.ts +0 -1
  25. package/dist/cjs/types/__tests__/toOrdinal.test.d.ts +0 -1
  26. package/dist/cjs/types/__tests__/urlUtils.test.d.ts +0 -1
  27. package/dist/cjs/types/__tests__/validators.test.d.ts +0 -1
  28. package/dist/cjs/types/compareArray.d.ts +0 -1
  29. package/dist/cjs/types/dateConversions.d.ts +0 -13
  30. package/dist/cjs/types/dedupe.d.ts +0 -1
  31. package/dist/cjs/types/enumKeys.d.ts +0 -21
  32. package/dist/cjs/types/excerpt.d.ts +0 -1
  33. package/dist/cjs/types/fakeEscapePress.d.ts +0 -1
  34. package/dist/cjs/types/index.d.ts +0 -24
  35. package/dist/cjs/types/initialUppercase.d.ts +0 -1
  36. package/dist/cjs/types/keycodes.d.ts +0 -101
  37. package/dist/cjs/types/loremer/index.d.ts +0 -37
  38. package/dist/cjs/types/loremer/words.d.ts +0 -2
  39. package/dist/cjs/types/nTimes.d.ts +0 -2
  40. package/dist/cjs/types/null.d.ts +0 -4
  41. package/dist/cjs/types/numberFormat.d.ts +0 -3
  42. package/dist/cjs/types/parseSqlQuery.d.ts +0 -29
  43. package/dist/cjs/types/pluralize.d.ts +0 -1
  44. package/dist/cjs/types/prettyJSON.d.ts +0 -2
  45. package/dist/cjs/types/randomArrayItem.d.ts +0 -1
  46. package/dist/cjs/types/randomNum.d.ts +0 -1
  47. package/dist/cjs/types/safeJSONParse.d.ts +0 -1
  48. package/dist/cjs/types/sprintf.d.ts +0 -1
  49. package/dist/cjs/types/toOrdinal.d.ts +0 -1
  50. package/dist/cjs/types/tuplify.d.ts +0 -1
  51. package/dist/cjs/types/urlUtils.d.ts +0 -203
  52. package/dist/cjs/types/validators.d.ts +0 -9
  53. package/dist/esm/types/Maybe.d.ts +0 -2
  54. package/dist/esm/types/__tests__/compareArray.test.d.ts +0 -1
  55. package/dist/esm/types/__tests__/dateConversions.test.d.ts +0 -1
  56. package/dist/esm/types/__tests__/dedupe.test.d.ts +0 -1
  57. package/dist/esm/types/__tests__/enumKeys.test.d.ts +0 -1
  58. package/dist/esm/types/__tests__/excerpt.test.d.ts +0 -1
  59. package/dist/esm/types/__tests__/helpers/mutationExamples.d.ts +0 -1
  60. package/dist/esm/types/__tests__/initialUppercase.test.d.ts +0 -1
  61. package/dist/esm/types/__tests__/loremer.test.d.ts +0 -1
  62. package/dist/esm/types/__tests__/nTimes.test.d.ts +0 -1
  63. package/dist/esm/types/__tests__/null.test.d.ts +0 -1
  64. package/dist/esm/types/__tests__/numberFormat.test.d.ts +0 -1
  65. package/dist/esm/types/__tests__/parseSqlQuery.test.d.ts +0 -1
  66. package/dist/esm/types/__tests__/pluralize.test.d.ts +0 -1
  67. package/dist/esm/types/__tests__/prettyJSON.test.d.ts +0 -1
  68. package/dist/esm/types/__tests__/randomArrayItem.test.d.ts +0 -1
  69. package/dist/esm/types/__tests__/safeJSONParse.test.d.ts +0 -1
  70. package/dist/esm/types/__tests__/sprintf.test.d.ts +0 -1
  71. package/dist/esm/types/__tests__/toOrdinal.test.d.ts +0 -1
  72. package/dist/esm/types/__tests__/urlUtils.test.d.ts +0 -1
  73. package/dist/esm/types/__tests__/validators.test.d.ts +0 -1
  74. package/dist/esm/types/compareArray.d.ts +0 -1
  75. package/dist/esm/types/dateConversions.d.ts +0 -13
  76. package/dist/esm/types/dedupe.d.ts +0 -1
  77. package/dist/esm/types/enumKeys.d.ts +0 -21
  78. package/dist/esm/types/excerpt.d.ts +0 -1
  79. package/dist/esm/types/fakeEscapePress.d.ts +0 -1
  80. package/dist/esm/types/index.d.ts +0 -24
  81. package/dist/esm/types/initialUppercase.d.ts +0 -1
  82. package/dist/esm/types/keycodes.d.ts +0 -101
  83. package/dist/esm/types/loremer/index.d.ts +0 -37
  84. package/dist/esm/types/loremer/words.d.ts +0 -2
  85. package/dist/esm/types/nTimes.d.ts +0 -2
  86. package/dist/esm/types/null.d.ts +0 -4
  87. package/dist/esm/types/numberFormat.d.ts +0 -3
  88. package/dist/esm/types/parseSqlQuery.d.ts +0 -29
  89. package/dist/esm/types/pluralize.d.ts +0 -1
  90. package/dist/esm/types/prettyJSON.d.ts +0 -2
  91. package/dist/esm/types/randomArrayItem.d.ts +0 -1
  92. package/dist/esm/types/randomNum.d.ts +0 -1
  93. package/dist/esm/types/safeJSONParse.d.ts +0 -1
  94. package/dist/esm/types/sprintf.d.ts +0 -1
  95. package/dist/esm/types/toOrdinal.d.ts +0 -1
  96. package/dist/esm/types/tuplify.d.ts +0 -1
  97. package/dist/esm/types/urlUtils.d.ts +0 -203
  98. package/dist/esm/types/validators.d.ts +0 -9
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dolthub/web-utils",
3
3
  "author": "DoltHub",
4
4
  "description": "A collection of utilities for building web applications",
5
- "version": "0.1.10",
5
+ "version": "0.2.0",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -14,7 +14,6 @@
14
14
  "utils",
15
15
  "frontend"
16
16
  ],
17
- "packageManager": "yarn@4.0.2",
18
17
  "scripts": {
19
18
  "clean": "rm -rf dist && rm -rf .rollup.cache && rm -rf types && rm -rf tsconfig.tsbuildinfo && rm -rf .eslintcache",
20
19
  "compile": "tsc -b",
@@ -29,26 +28,27 @@
29
28
  "yalc:push": "yarn dbuild && yalc push"
30
29
  },
31
30
  "devDependencies": {
32
- "@babel/core": "^7.27.7",
33
- "@babel/preset-env": "^7.27.2",
34
- "@babel/preset-typescript": "^7.27.1",
31
+ "@babel/core": "^7.28.3",
32
+ "@babel/preset-env": "^7.28.6",
33
+ "@babel/preset-typescript": "^7.28.5",
35
34
  "@rollup/plugin-commonjs": "^28.0.6",
36
- "@rollup/plugin-node-resolve": "^16.0.1",
35
+ "@rollup/plugin-node-resolve": "^16.0.3",
37
36
  "@rollup/plugin-typescript": "^11.1.5",
38
- "@types/eslint": "^8",
37
+ "@types/eslint": "^9",
39
38
  "@types/jest": "^29.5.14",
40
39
  "@types/rollup-plugin-peer-deps-external": "^2",
41
- "@typescript-eslint/eslint-plugin": "^7.1.0",
42
- "@typescript-eslint/parser": "^7.16.0",
43
- "babel-jest": "^30.0.2",
44
- "eslint": "^8.57.0",
40
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
41
+ "@typescript-eslint/parser": "^8.45.0",
42
+ "babel-jest": "^30.2.0",
43
+ "eslint": "^9.39.2",
45
44
  "jest": "^29.7.0",
45
+ "node-sql-parser": "^5.4.0",
46
46
  "prettier": "^3.6.2",
47
- "rollup": "^4.46.2",
48
- "rollup-plugin-dts": "^6.2.1",
47
+ "rollup": "^4.59.0",
48
+ "rollup-plugin-dts": "^6.3.0",
49
49
  "rollup-plugin-peer-deps-external": "^2.2.4",
50
50
  "rollup-plugin-terser": "^7.0.2",
51
- "typescript": "^5.9.2",
51
+ "typescript": "^5.9.3",
52
52
  "yalc": "^1.0.0-pre.53"
53
53
  },
54
54
  "repository": {
@@ -58,8 +58,15 @@
58
58
  "bugs": {
59
59
  "url": "https://github.com/dolthub/react-library/issues"
60
60
  },
61
+ "peerDependencies": {
62
+ "node-sql-parser": "^5.4.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "node-sql-parser": {
66
+ "optional": false
67
+ }
68
+ },
61
69
  "dependencies": {
62
- "node-sql-parser": "^5.3.10",
63
70
  "timeago.js": "^4.0.2"
64
71
  }
65
72
  }
@@ -1,2 +0,0 @@
1
- type Maybe<T> = T | undefined | null;
2
- export default Maybe;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const mutationExamples: string[];
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export default function compareArray(arr1: string[], arr2: string[]): boolean;
@@ -1,13 +0,0 @@
1
- export declare const oneHour: number;
2
- export declare function getUTCDateAndTimeString(date: Date): string;
3
- export declare function getDateString(date: Date): string;
4
- export declare function getUTCDateString(date: Date): string;
5
- export declare function getUTCTimeString(date: Date): string;
6
- export declare function getNow(): Date;
7
- export declare function getDateMinusHours(date: Date, hours: number): Date;
8
- export declare function getUTCNowDateString(): string;
9
- export declare function getLongDateTimeString(d: Date): string;
10
- export declare function getTimeWithSeconds(date: Date): string;
11
- export declare function getTimeAgoString(oldDateTime: number): string;
12
- export declare function areTimeAgosEqual(a: Date, b: Date): boolean;
13
- export declare function convertToUTCDate(d: Date): Date;
@@ -1 +0,0 @@
1
- export default function dedupe<T>(arr: T[]): T[];
@@ -1,21 +0,0 @@
1
- /**
2
- * enumKeys takes an enum and returns an array of strongly typed keys. Useful to iterate over string enums.
3
- * @param obj The enum
4
- * @returns An array of strong typed keys
5
- * @example
6
- *
7
- * enum MyEnum {
8
- * Key1 = "value1",
9
- * Key2 = "value2",
10
- * Key3 = "value3"
11
- * }
12
- *
13
- * // ks's type is ("Key1" || "Key2" || "Key3")[]
14
- * const ks = enumKeys(MyEnum);
15
- *
16
- * // keys' type is MyEnum[]
17
- * // Unfortunately, we can't do this inside enumKeys because there is no generic type constraint for enums.
18
- * const keys = ks.map(k => MyEnum[k])
19
- */
20
- declare function enumKeys<O extends object, K extends keyof O = keyof O>(obj: O): K[];
21
- export default enumKeys;
@@ -1 +0,0 @@
1
- export default function excerpt(str: string, len?: number): string;
@@ -1 +0,0 @@
1
- export default function fakeEscapePress(): void;
@@ -1,24 +0,0 @@
1
- export { default as Maybe } from "./Maybe";
2
- export { default as compareArray } from "./compareArray";
3
- export { areTimeAgosEqual, convertToUTCDate, getDateMinusHours, getDateString, getLongDateTimeString, getNow, getTimeAgoString, getTimeWithSeconds, getUTCDateAndTimeString, getUTCDateString, getUTCNowDateString, getUTCTimeString, oneHour, } from "./dateConversions";
4
- export { default as dedupe } from "./dedupe";
5
- export { default as enumKeys } from "./enumKeys";
6
- export { default as excerpt } from "./excerpt";
7
- export { default as fakeEscapePress } from "./fakeEscapePress";
8
- export { default as initialUppercase } from "./initialUppercase";
9
- export { KeyCodes } from "./keycodes";
10
- export { loremer } from "./loremer";
11
- export { default as nTimes, nTimesWithIndex } from "./nTimes";
12
- export { NULL_VALUE, getDisplayValue, getDisplayValueForApi, isNullValue, } from "./null";
13
- export { formatNumber, formatToRoundedUsd, formatToUsd } from "./numberFormat";
14
- export { convertToSqlWithNewColNames, convertToSqlWithNewCols, convertToSqlWithNewCondition, convertToSqlWithOrderBy, getColumns, getTableName, isMultipleQueries, isMutation, makeQueryExecutable, parseSelectQuery, queryHasOrderBy, removeColumnFromQuery, requireTableNameForSelect, } from "./parseSqlQuery";
15
- export { default as pluralize } from "./pluralize";
16
- export { default as prettyJSON, prettyJSONText } from "./prettyJSON";
17
- export { default as randomArrayItem } from "./randomArrayItem";
18
- export { default as randomNum } from "./randomNum";
19
- export { default as safeJSONParse } from "./safeJSONParse";
20
- export { sprintf } from "./sprintf";
21
- export { default as toOrdinal } from "./toOrdinal";
22
- export { default as tuplify } from "./tuplify";
23
- export { Route } from "./urlUtils";
24
- export { emailValidator, usernameValidator } from "./validators";
@@ -1 +0,0 @@
1
- export default function initialUppercase(s: string): string;
@@ -1,101 +0,0 @@
1
- export declare enum KeyCodes {
2
- BACKSPACE = 8,
3
- TAB = 9,
4
- ENTER = 13,
5
- SHIFT = 16,
6
- CTRL = 17,
7
- ALT = 18,
8
- PAUSE = 19,
9
- CAPS_LOCK = 20,
10
- ESCAPE = 27,
11
- SPACE = 32,
12
- PAGE_UP = 33,
13
- PAGE_DOWN = 34,
14
- END = 35,
15
- HOME = 36,
16
- LEFT_ARROW = 37,
17
- UP_ARROW = 38,
18
- RIGHT_ARROW = 39,
19
- DOWN_ARROW = 40,
20
- INSERT = 45,
21
- DELETE = 46,
22
- KEY_0 = 48,
23
- KEY_1 = 49,
24
- KEY_2 = 50,
25
- KEY_3 = 51,
26
- KEY_4 = 52,
27
- KEY_5 = 53,
28
- KEY_6 = 54,
29
- KEY_7 = 55,
30
- KEY_8 = 56,
31
- KEY_9 = 57,
32
- KEY_A = 65,
33
- KEY_B = 66,
34
- KEY_C = 67,
35
- KEY_D = 68,
36
- KEY_E = 69,
37
- KEY_F = 70,
38
- KEY_G = 71,
39
- KEY_H = 72,
40
- KEY_I = 73,
41
- KEY_J = 74,
42
- KEY_K = 75,
43
- KEY_L = 76,
44
- KEY_M = 77,
45
- KEY_N = 78,
46
- KEY_O = 79,
47
- KEY_P = 80,
48
- KEY_Q = 81,
49
- KEY_R = 82,
50
- KEY_S = 83,
51
- KEY_T = 84,
52
- KEY_U = 85,
53
- KEY_V = 86,
54
- KEY_W = 87,
55
- KEY_X = 88,
56
- KEY_Y = 89,
57
- KEY_Z = 90,
58
- LEFT_META = 91,
59
- RIGHT_META = 92,
60
- SELECT = 93,
61
- NUMPAD_0 = 96,
62
- NUMPAD_1 = 97,
63
- NUMPAD_2 = 98,
64
- NUMPAD_3 = 99,
65
- NUMPAD_4 = 100,
66
- NUMPAD_5 = 101,
67
- NUMPAD_6 = 102,
68
- NUMPAD_7 = 103,
69
- NUMPAD_8 = 104,
70
- NUMPAD_9 = 105,
71
- MULTIPLY = 106,
72
- ADD = 107,
73
- SUBTRACT = 109,
74
- DECIMAL = 110,
75
- DIVIDE = 111,
76
- F1 = 112,
77
- F2 = 113,
78
- F3 = 114,
79
- F4 = 115,
80
- F5 = 116,
81
- F6 = 117,
82
- F7 = 118,
83
- F8 = 119,
84
- F9 = 120,
85
- F10 = 121,
86
- F11 = 122,
87
- F12 = 123,
88
- NUM_LOCK = 144,
89
- SCROLL_LOCK = 145,
90
- SEMICOLON = 186,
91
- EQUALS = 187,
92
- COMMA = 188,
93
- DASH = 189,
94
- PERIOD = 190,
95
- FORWARD_SLASH = 191,
96
- GRAVE_ACCENT = 192,
97
- OPEN_BRACKET = 219,
98
- BACK_SLASH = 220,
99
- CLOSE_BRACKET = 221,
100
- SINGLE_QUOTE = 222
101
- }
@@ -1,37 +0,0 @@
1
- type LoremerOptions = {
2
- words: string[] | string;
3
- };
4
- export default function Loremer(opts: LoremerOptions): {
5
- word: ({ trueSingleWord, minLength, maxLength, matchRegex, }?: {
6
- trueSingleWord?: boolean;
7
- matchRegex?: RegExp;
8
- minLength?: number;
9
- maxLength?: number;
10
- }) => string;
11
- words: (n: number) => string[];
12
- resourceNameSegment: () => string;
13
- sentence: (options?: {
14
- max?: number;
15
- min?: number;
16
- }) => string;
17
- sentences: (n: number) => string[];
18
- paragraph: () => string;
19
- };
20
- export declare function parseWords(words: string): string[];
21
- export declare const loremer: {
22
- word: ({ trueSingleWord, minLength, maxLength, matchRegex, }?: {
23
- trueSingleWord?: boolean;
24
- matchRegex?: RegExp;
25
- minLength?: number;
26
- maxLength?: number;
27
- }) => string;
28
- words: (n: number) => string[];
29
- resourceNameSegment: () => string;
30
- sentence: (options?: {
31
- max?: number;
32
- min?: number;
33
- }) => string;
34
- sentences: (n: number) => string[];
35
- paragraph: () => string;
36
- };
37
- export {};
@@ -1,2 +0,0 @@
1
- declare const _default: () => string[];
2
- export default _default;
@@ -1,2 +0,0 @@
1
- export default function nTimes<T>(n: number, operation: (...args: any[]) => T, args?: Parameters<typeof operation>): T[];
2
- export declare function nTimesWithIndex<T>(n: number, operation: (n: number) => T): T[];
@@ -1,4 +0,0 @@
1
- export declare const NULL_VALUE = "\uF5F2\uEB94NULL\uF5A8\uE6FF";
2
- export declare function isNullValue(dv: string): boolean;
3
- export declare function getDisplayValue(dv: string): string;
4
- export declare function getDisplayValueForApi(dv: string): string | null;
@@ -1,3 +0,0 @@
1
- export declare function formatNumber(num: number): string;
2
- export declare function formatToUsd(num: number): string;
3
- export declare function formatToRoundedUsd(num: number): string;
@@ -1,29 +0,0 @@
1
- import { ColumnRef, Select } from "node-sql-parser";
2
- import Maybe from "./Maybe";
3
- export type TableColumn = {
4
- name: string;
5
- sourceTable?: Maybe<string>;
6
- };
7
- export declare function parseSelectQuery(q: string): Select | null;
8
- export declare function getTableNames(q: string): string[] | undefined;
9
- export declare function requireTableNameForSelect(q: string): string[];
10
- export declare function getTableName(q?: string): Maybe<string>;
11
- export declare function fallbackGetTableNamesForSelect(query: string): string[];
12
- type Column = {
13
- expr: ColumnRef;
14
- as: string | null;
15
- };
16
- type Columns = any[] | "*" | Column[];
17
- export declare function getColumns(q: string): Columns | undefined;
18
- export declare function convertToSql(select: Select): string;
19
- export declare function convertToSqlWithNewColNames(q: string, cols: string[] | "*", tableName: string): string;
20
- export declare function convertToSqlWithNewCols(q: string, cols: TableColumn[] | "*", tableNames?: string[]): string;
21
- export declare function convertToSqlWithNewCondition(query: string, column: string, value: string): string;
22
- export declare function convertToSqlWithOrderBy(query: string, column: string, type?: "ASC" | "DESC"): string;
23
- export declare function queryHasOrderBy(query: string, column: string, type?: "ASC" | "DESC"): boolean;
24
- export declare function getQueryType(q: string): string | undefined;
25
- export declare function isMutation(q?: string): boolean;
26
- export declare function removeColumnFromQuery(q: string, colNameToRemove: string, cols: TableColumn[]): string;
27
- export declare function makeQueryExecutable(q: string): string;
28
- export declare function isMultipleQueries(queryString: string): boolean;
29
- export {};
@@ -1 +0,0 @@
1
- export default function pluralize(num: number, str: string): string;
@@ -1,2 +0,0 @@
1
- export default function prettyJSON(data: any): string;
2
- export declare function prettyJSONText(text: string): string;
@@ -1 +0,0 @@
1
- export default function randomArrayItem<T>(arr: T[]): T;
@@ -1 +0,0 @@
1
- export default function randomNum(min: number, max: number): number;
@@ -1 +0,0 @@
1
- export default function safeJSONParse(text: string): any;
@@ -1 +0,0 @@
1
- export declare const sprintf: (str: string, ...argv: any[]) => string;
@@ -1 +0,0 @@
1
- export default function toOrdinal(n: number): string;
@@ -1 +0,0 @@
1
- export default function tuplify<T extends any[]>(...elements: T): T;
@@ -1,203 +0,0 @@
1
- import { ParsedUrlQueryInput } from "querystring";
2
- import { UrlObject } from "url";
3
- type Url = string | UrlObject;
4
- export type LinkObject = {
5
- href: Url;
6
- as?: Url;
7
- };
8
- /**
9
- * __Route__
10
- *
11
- * `Route` class that handles adding static and dynamic route segments to
12
- * existing routes. `Route` can be initialized with a "href" string or
13
- * `UrlObject` and optional "as" string or `UrlObject`.
14
- *
15
- * @example
16
- * const routeA = new Route("/repositories");
17
- * routeA.hrefPathname() // "/repositories"
18
- * routeA.addDynamic("ownerName", "my-owner")
19
- * routeA.hrefPathname() // "repositories/[ownerName]"
20
- * routeA.asPathname() // "repositories/my-owner"
21
- *
22
- * const routeB = new Route(
23
- * { pathname: "/repositories/[ownerName]", query: { refName: "main" } },
24
- * { pathname: "/repositories/my-owner", query: { refName: "main" } },
25
- * )
26
- * routeB.hrefPathname() // "/repositories/[ownerName]"
27
- * routeB.asPathname() // "repositories/my-owner"
28
- * routeB.getQuery() // { refName: "main" }
29
- */
30
- export declare class Route {
31
- href: Url;
32
- as: Url;
33
- constructor(href: Url, as?: Url);
34
- /**
35
- * __hrefPathname__
36
- *
37
- * Gets pathname string from href string or `UrlObject`.
38
- *
39
- * @param addFrag Optional route fragment string to add to `href` pathname
40
- *
41
- * @returns `href` pathname string, with added route fragment if provided
42
- *
43
- * @example
44
- * const routeA = new Route("/repositories");
45
- * routeA.hrefPathname() // "/repositories"
46
- * routeA.hrefPathname("[ownerName]") // "repositories/[ownerName]"
47
- *
48
- * const routeB = new Route({ pathname: "/repositories" })
49
- * routeB.hrefPathname() // "/repositories"
50
- * routeB.hrefPathname("[ownerName]") // "repositories/[ownerName]"
51
- */
52
- hrefPathname(addFrag?: string): string;
53
- /**
54
- * __asPathname__
55
- *
56
- * Gets pathname string from as string or `UrlObject`.
57
- *
58
- * @param addFrag Optional route fragment string to add to `as` pathname
59
- *
60
- * @returns `as` pathname string, with added route fragment if provided
61
- *
62
- * @example
63
- * const routeA = new Route("/repositories");
64
- * routeA.asPathname() // "/repositories"
65
- * routeA.asPathname("my-username") // "repositories/my-username"
66
- *
67
- * const routeB = new Route(
68
- * { pathname: "/repositories/[ownerName]" },
69
- * { pathname: "/repositories/my-username" },
70
- * );
71
- * routeB.asPathname() // "/repositories/my-username"
72
- * routeB.asPathname("data") // "repositories/my-username/data"
73
- */
74
- asPathname(addFrag?: string): string;
75
- /**
76
- * __getQuery__
77
- *
78
- * Gets query object from the href `UrlObject`.
79
- *
80
- * @returns query object
81
- *
82
- * @example
83
- * const route = new Route("/repositories");
84
- * route.withQuery({ refName: "main" })
85
- * route.getQuery() // { refName: "main" }
86
- */
87
- getQuery(): string | ParsedUrlQueryInput | undefined | null;
88
- /**
89
- * __getHash__
90
- *
91
- * Gets hash string from the href `UrlObject`.
92
- *
93
- * @returns hash string
94
- *
95
- * @example
96
- * const route = new Route("/repositories");
97
- * route.withHash("commitA")
98
- * route.getHash() // "commitA"
99
- */
100
- getHash(): string;
101
- /**
102
- * __addStatic__
103
- *
104
- * Adds static route fragment string to a `Route`. Static route fragments look like:
105
- * ```ts
106
- * { href: "/repositories", as: "/repositories" }
107
- * ```
108
- * As opposed to dynamic route fragments which look like:
109
- * ```ts
110
- * { href: "/[ownerName]", as: "/owner-value" }
111
- * ```
112
- *
113
- * @param pathFrag Route fragment string to add to the url. "/" is automatically prepended.
114
- *
115
- * @returns new instance of `Route`
116
- *
117
- * @example
118
- * const route = new Route("/repositories");
119
- * route.addStatic("data")
120
- * route.hrefPathname() // "/repositories/data"
121
- * route.asPathname() // "/repositories/data"
122
- */
123
- addStatic(pathFrag: string): Route;
124
- /**
125
- * __maybeAddStatic__
126
- *
127
- * Maybe adds static route fragment string to a `Route`.
128
- *
129
- * @see this.addStatic
130
- *
131
- * @param pathFrag Optional route fragment string to add to the url. "/" is automatically prepended.
132
- *
133
- * @example
134
- * const route = new Route("/repositories");
135
- * route.maybeAddStatic("data")
136
- * route.hrefPathname() // "/repositories/data"
137
- * route.maybeAddStatic()
138
- * route.hrefPathname() // "/repositories"
139
- */
140
- maybeAddStatic(pathFrag?: string): Route;
141
- /**
142
- * __addDynamic__
143
- *
144
- * Adds dynamic route fragment string to a Route.
145
- * Dynamic route fragments look like:
146
- * ```ts
147
- * { href: "/[ownerName]", as: "/owner-value" }
148
- * ```
149
- * As opposed to static route fragments which look like:
150
- *
151
- * ```ts
152
- * { href: "/repositories", as: "/repositories" }
153
- * ```
154
- *
155
- * @param param String fragment to add to the href path. This value will be wrapped in square brackets. "/" is automatically prepended.
156
- * @param as Value of the `param` to be added to the `as` path. "/" is automatically prepended.
157
- * @param encode Default false. If true, encodes a `as` param value string as a valid component of a Uniform Resource Identifier (URI).
158
- *
159
- * @returns new instance of `Route`
160
- *
161
- * @example
162
- * const route = new Route("/repositories");
163
- * route.addDynamic("ownerName", "my-owner-name")
164
- * route.hrefPathname() // "/repositories/[ownerName]"
165
- * route.asPathname() // "/repositories/my-owner-name"
166
- */
167
- addDynamic(param: string, as: string, encode?: boolean): Route;
168
- /**
169
- * __withQuery__
170
- *
171
- * Adds query object to a `Route`. Looks like "?refName=main&active=Tables"
172
- * when url is formatted.
173
- *
174
- * @param q Record with fields that will be added to the query string.
175
- *
176
- * @returns new instance of `Route`
177
- *
178
- * @example
179
- * const route = new Route("/repositories/[ownerName]", "/repositories/my-owner");
180
- * route.withQuery({ refName: "main", active: undefined })
181
- * route.hrefPathname() // { pathname: "/repositories/[ownerName]", query: { refName: "main" } }
182
- * route.asPathname() // { pathname: "/repositories/my-owner", query: { refName: "main" } }
183
- */
184
- withQuery(q: Record<string, string | undefined | null>): Route;
185
- /**
186
- * __withHash__
187
- *
188
- * Adds hash string to a `Route`. Looks like "#hash-value" when url is formatted.
189
- *
190
- * @param hash Optional hash string
191
- *
192
- * @returns new instance of Route
193
- *
194
- * @example
195
- * const route = new Route("/repositories/[ownerName]", "/repositories/my-owner");
196
- * route.withHash({ commitId: "commitA" })
197
- * route.hrefPathname() // { pathname: "/repositories/[ownerName]", hash: { commitId: "commitA" } }
198
- * route.asPathname() // { pathname: "/repositories/my-owner", hash: { commitId: "commitA" } }
199
- */
200
- withHash(hash?: string): Route;
201
- }
202
- export declare function queryHandler(q: Record<string, string | undefined | null>): string | null | ParsedUrlQueryInput | undefined;
203
- export {};
@@ -1,9 +0,0 @@
1
- export declare function emailValidator(s: string): {
2
- isValid: boolean;
3
- errorMsg: string;
4
- };
5
- export declare function usernameValidator(s: string): {
6
- isValid: boolean;
7
- errorMsg: string;
8
- detailedErrorMsg: string;
9
- };
@@ -1,2 +0,0 @@
1
- type Maybe<T> = T | undefined | null;
2
- export default Maybe;