@fern-api/ui-core-utils 0.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.
- package/dist/ObjectPropertiesVisitor.d.ts +5 -0
- package/dist/ObjectPropertiesVisitor.d.ts.map +1 -0
- package/dist/ObjectPropertiesVisitor.js +6 -0
- package/dist/__test__/combineURLs.test.d.ts +2 -0
- package/dist/__test__/combineURLs.test.d.ts.map +1 -0
- package/dist/__test__/combineURLs.test.js +20 -0
- package/dist/__test__/unknownToString.test.d.ts +2 -0
- package/dist/__test__/unknownToString.test.d.ts.map +1 -0
- package/dist/__test__/unknownToString.test.js +31 -0
- package/dist/__test__/withDefaultProtocol.test.d.ts +2 -0
- package/dist/__test__/withDefaultProtocol.test.d.ts.map +1 -0
- package/dist/__test__/withDefaultProtocol.test.js +61 -0
- package/dist/addPrefixToString.d.ts +10 -0
- package/dist/addPrefixToString.d.ts.map +1 -0
- package/dist/addPrefixToString.js +5 -0
- package/dist/assertNever.d.ts +4 -0
- package/dist/assertNever.d.ts.map +1 -0
- package/dist/assertNever.js +6 -0
- package/dist/assertVoidNoThrow.d.ts +2 -0
- package/dist/assertVoidNoThrow.d.ts.map +1 -0
- package/dist/assertVoidNoThrow.js +2 -0
- package/dist/combineURLs.d.ts +12 -0
- package/dist/combineURLs.d.ts.map +1 -0
- package/dist/combineURLs.js +13 -0
- package/dist/delay/delay.d.ts +2 -0
- package/dist/delay/delay.d.ts.map +1 -0
- package/dist/delay/delay.js +3 -0
- package/dist/delay/withMinimumTime.d.ts +11 -0
- package/dist/delay/withMinimumTime.d.ts.map +1 -0
- package/dist/delay/withMinimumTime.js +22 -0
- package/dist/empty.d.ts +3 -0
- package/dist/empty.d.ts.map +1 -0
- package/dist/empty.js +2 -0
- package/dist/identity.d.ts +3 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +4 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/isNonNullish.d.ts +3 -0
- package/dist/isNonNullish.d.ts.map +1 -0
- package/dist/isNonNullish.js +8 -0
- package/dist/objects/entries.d.ts +3 -0
- package/dist/objects/entries.d.ts.map +1 -0
- package/dist/objects/entries.js +3 -0
- package/dist/objects/isPlainObject.d.ts +3 -0
- package/dist/objects/isPlainObject.d.ts.map +1 -0
- package/dist/objects/isPlainObject.js +18 -0
- package/dist/objects/keys.d.ts +2 -0
- package/dist/objects/keys.d.ts.map +1 -0
- package/dist/objects/keys.js +3 -0
- package/dist/objects/values.d.ts +3 -0
- package/dist/objects/values.d.ts.map +1 -0
- package/dist/objects/values.js +3 -0
- package/dist/platform.d.ts +3 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +14 -0
- package/dist/specialTokens.d.ts +2 -0
- package/dist/specialTokens.d.ts.map +1 -0
- package/dist/specialTokens.js +345 -0
- package/dist/titleCase.d.ts +3 -0
- package/dist/titleCase.d.ts.map +1 -0
- package/dist/titleCase.js +15 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/unknownToString.d.ts +6 -0
- package/dist/unknownToString.d.ts.map +1 -0
- package/dist/unknownToString.js +10 -0
- package/dist/visitDiscriminatedUnion.d.ts +13 -0
- package/dist/visitDiscriminatedUnion.d.ts.map +1 -0
- package/dist/visitDiscriminatedUnion.js +18 -0
- package/dist/withDefaultProtocol.d.ts +9 -0
- package/dist/withDefaultProtocol.d.ts.map +1 -0
- package/dist/withDefaultProtocol.js +15 -0
- package/package.json +77 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type ObjectPropertiesVisitor<T, R> = {
|
|
2
|
+
[K in keyof T]-?: (value: T[K]) => R;
|
|
3
|
+
};
|
|
4
|
+
export declare function visitObject<T extends Record<string, unknown>>(object: T, visitor: ObjectPropertiesVisitor<T, void | Promise<void>>): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=ObjectPropertiesVisitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectPropertiesVisitor.d.ts","sourceRoot":"","sources":["../src/ObjectPropertiesVisitor.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI;KACvC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;CACvC,CAAC;AAEF,wBAAsB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,uBAAuB,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAC1D,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineURLs.test.d.ts","sourceRoot":"","sources":["../../src/__test__/combineURLs.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { combineURLs } from "../combineURLs";
|
|
3
|
+
// Test cases from [Axios](https://github.com/axios/axios/blob/fe7d09bb08fa1c0e414956b7fc760c80459b0a43/test/specs/helpers/combineURLs.spec.js)
|
|
4
|
+
describe("helpers::combineURLs", function () {
|
|
5
|
+
it("should combine URLs", function () {
|
|
6
|
+
expect(combineURLs("https://api.github.com", "/users")).toBe("https://api.github.com/users");
|
|
7
|
+
});
|
|
8
|
+
it("should remove duplicate slashes", function () {
|
|
9
|
+
expect(combineURLs("https://api.github.com/", "/users")).toBe("https://api.github.com/users");
|
|
10
|
+
});
|
|
11
|
+
it("should insert missing slash", function () {
|
|
12
|
+
expect(combineURLs("https://api.github.com", "users")).toBe("https://api.github.com/users");
|
|
13
|
+
});
|
|
14
|
+
it("should not insert slash when relative url missing/empty", function () {
|
|
15
|
+
expect(combineURLs("https://api.github.com/users", "")).toBe("https://api.github.com/users");
|
|
16
|
+
});
|
|
17
|
+
it("should allow a single slash for relative url", function () {
|
|
18
|
+
expect(combineURLs("https://api.github.com/users", "/")).toBe("https://api.github.com/users/");
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknownToString.test.d.ts","sourceRoot":"","sources":["../../src/__test__/unknownToString.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { unknownToString } from "../unknownToString";
|
|
2
|
+
describe("unknownToString", () => {
|
|
3
|
+
it("should preserve strings", () => {
|
|
4
|
+
expect(unknownToString("foo")).toBe("foo");
|
|
5
|
+
});
|
|
6
|
+
it("should convert booleans to strings", () => {
|
|
7
|
+
expect(unknownToString(true)).toBe("true");
|
|
8
|
+
expect(unknownToString(false)).toBe("false");
|
|
9
|
+
});
|
|
10
|
+
it("should convert numbers to strings", () => {
|
|
11
|
+
expect(unknownToString(42)).toBe("42");
|
|
12
|
+
expect(unknownToString(3.14)).toBe("3.14");
|
|
13
|
+
expect(unknownToString(1_000_000_000_000_000_000)).toBe("1000000000000000000");
|
|
14
|
+
});
|
|
15
|
+
it("should convert nulls", () => {
|
|
16
|
+
expect(unknownToString(null)).toBe("");
|
|
17
|
+
expect(unknownToString(undefined)).toBe("");
|
|
18
|
+
expect(unknownToString(null, { renderNull: true })).toBe("null");
|
|
19
|
+
expect(unknownToString(undefined, { renderNull: true })).toBe("null");
|
|
20
|
+
});
|
|
21
|
+
it("should convert objects to JSON strings", () => {
|
|
22
|
+
expect(unknownToString({ foo: "bar" })).toBe('{"foo":"bar"}');
|
|
23
|
+
});
|
|
24
|
+
it("should convert arrays to JSON strings", () => {
|
|
25
|
+
expect(unknownToString([1, 2, 3])).toBe("[1,2,3]");
|
|
26
|
+
});
|
|
27
|
+
it("should not render functions", () => {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
29
|
+
expect(unknownToString(() => { })).toBe("");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withDefaultProtocol.test.d.ts","sourceRoot":"","sources":["../../src/__test__/withDefaultProtocol.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { withDefaultProtocol } from "../withDefaultProtocol";
|
|
3
|
+
describe("withDefaultProtocol", () => {
|
|
4
|
+
it("adds https:// to a domain without protocol", () => {
|
|
5
|
+
expect(withDefaultProtocol("example.com")).toBe("https://example.com");
|
|
6
|
+
});
|
|
7
|
+
it("does not modify a URL that already has https://", () => {
|
|
8
|
+
expect(withDefaultProtocol("https://example.com")).toBe("https://example.com");
|
|
9
|
+
});
|
|
10
|
+
it("does not modify a URL that already has http://", () => {
|
|
11
|
+
expect(withDefaultProtocol("http://example.com")).toBe("http://example.com");
|
|
12
|
+
});
|
|
13
|
+
it("does not modify URLs with other protocols", () => {
|
|
14
|
+
expect(withDefaultProtocol("ftp://example.com")).toBe("ftp://example.com");
|
|
15
|
+
});
|
|
16
|
+
it("handles mixed case protocols", () => {
|
|
17
|
+
expect(withDefaultProtocol("HtTp://example.com")).toBe("HtTp://example.com");
|
|
18
|
+
});
|
|
19
|
+
it("handles an empty string", () => {
|
|
20
|
+
expect(withDefaultProtocol("")).toBe("https://");
|
|
21
|
+
});
|
|
22
|
+
it("handles IP addresses", () => {
|
|
23
|
+
expect(withDefaultProtocol("192.168.1.1")).toBe("https://192.168.1.1");
|
|
24
|
+
});
|
|
25
|
+
it("handles URLs with ports", () => {
|
|
26
|
+
expect(withDefaultProtocol("example.com:8080")).toBe("https://example.com:8080");
|
|
27
|
+
});
|
|
28
|
+
it("handles URLs with authentication", () => {
|
|
29
|
+
expect(withDefaultProtocol("user:pass@example.com")).toBe("https://user:pass@example.com");
|
|
30
|
+
});
|
|
31
|
+
it("handles URLs with www", () => {
|
|
32
|
+
expect(withDefaultProtocol("www.example.com")).toBe("https://www.example.com");
|
|
33
|
+
});
|
|
34
|
+
it("handles URLs with subdomains", () => {
|
|
35
|
+
expect(withDefaultProtocol("subdomain.example.com")).toBe("https://subdomain.example.com");
|
|
36
|
+
});
|
|
37
|
+
it("handles URLs with paths", () => {
|
|
38
|
+
expect(withDefaultProtocol("example.com/path/to/resource")).toBe("https://example.com/path/to/resource");
|
|
39
|
+
});
|
|
40
|
+
it("handles URLs with query parameters", () => {
|
|
41
|
+
expect(withDefaultProtocol("example.com?param1=value1¶m2=value2")).toBe("https://example.com?param1=value1¶m2=value2");
|
|
42
|
+
});
|
|
43
|
+
it("handles double slashes in the path", () => {
|
|
44
|
+
expect(withDefaultProtocol("example.com//path//to//resource")).toBe("https://example.com//path//to//resource");
|
|
45
|
+
});
|
|
46
|
+
it("handles URLs with :// in the path", () => {
|
|
47
|
+
expect(withDefaultProtocol("example.com/path/to/resource/with/colon://in/path")).toBe("https://example.com/path/to/resource/with/colon://in/path");
|
|
48
|
+
});
|
|
49
|
+
it("handles URLs with :// in query parameters", () => {
|
|
50
|
+
expect(withDefaultProtocol("example.com?param1=value1¶m2=colon://in/value")).toBe("https://example.com?param1=value1¶m2=colon://in/value");
|
|
51
|
+
});
|
|
52
|
+
it("handles URLs with :// in fragment", () => {
|
|
53
|
+
expect(withDefaultProtocol("example.com/path#fragment://with/colon")).toBe("https://example.com/path#fragment://with/colon");
|
|
54
|
+
});
|
|
55
|
+
it("handles URLs with :// as part of a file name", () => {
|
|
56
|
+
expect(withDefaultProtocol("example.com/file:with/colon.txt")).toBe("https://example.com/file:with/colon.txt");
|
|
57
|
+
});
|
|
58
|
+
it("handles URLs with :// in a path segment", () => {
|
|
59
|
+
expect(withDefaultProtocol("example.com/path/segment:with/colon")).toBe("https://example.com/path/segment:with/colon");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function addPrefixToString({ prefix, content, includePrefixOnAllLines, }: {
|
|
2
|
+
prefix: string;
|
|
3
|
+
content: string;
|
|
4
|
+
/**
|
|
5
|
+
* if true, the prefix is included on all lines.
|
|
6
|
+
* if false, all lines after the first are indented by the length of the prefix
|
|
7
|
+
*/
|
|
8
|
+
includePrefixOnAllLines?: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
//# sourceMappingURL=addPrefixToString.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addPrefixToString.d.ts","sourceRoot":"","sources":["../src/addPrefixToString.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,EAC9B,MAAM,EACN,OAAO,EACP,uBAA+B,GAClC,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,MAAM,CAGT"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import stripAnsi from "strip-ansi";
|
|
2
|
+
export function addPrefixToString({ prefix, content, includePrefixOnAllLines = false, }) {
|
|
3
|
+
const prefixLength = stripAnsi(prefix).length;
|
|
4
|
+
return `${prefix}${content.replaceAll("\n", `\n${includePrefixOnAllLines ? prefix : " ".repeat(prefixLength)}`)}`;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertNever.d.ts","sourceRoot":"","sources":["../src/assertNever.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE3C;AAGD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAG;AAErD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertVoidNoThrow.d.ts","sourceRoot":"","sources":["../src/assertVoidNoThrow.ts"],"names":[],"mappings":"AACA,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,IAAI,GAAG,IAAI,CAAG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new URL by combining the specified URLs
|
|
3
|
+
*
|
|
4
|
+
* From [Axios' combineURLs](https://github.com/axios/axios/blob/c8b7be59cba56e8fd09dc667de246117987d7517/lib/helpers/combineURLs.js)
|
|
5
|
+
*
|
|
6
|
+
* @param baseURL The base URL
|
|
7
|
+
* @param relativeURL The relative URL
|
|
8
|
+
*
|
|
9
|
+
* @returns The combined URL
|
|
10
|
+
*/
|
|
11
|
+
export declare function combineURLs(baseURL: string, relativeURL: string): string;
|
|
12
|
+
//# sourceMappingURL=combineURLs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineURLs.d.ts","sourceRoot":"","sources":["../src/combineURLs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAExE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new URL by combining the specified URLs
|
|
3
|
+
*
|
|
4
|
+
* From [Axios' combineURLs](https://github.com/axios/axios/blob/c8b7be59cba56e8fd09dc667de246117987d7517/lib/helpers/combineURLs.js)
|
|
5
|
+
*
|
|
6
|
+
* @param baseURL The base URL
|
|
7
|
+
* @param relativeURL The relative URL
|
|
8
|
+
*
|
|
9
|
+
* @returns The combined URL
|
|
10
|
+
*/
|
|
11
|
+
export function combineURLs(baseURL, relativeURL) {
|
|
12
|
+
return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../src/delay/delay.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* if the promise resolves:
|
|
3
|
+
* - if alwaysDelay=true, this doesn't resolve until after ms
|
|
4
|
+
* - if alwaysDelay=false, this resolves immediately
|
|
5
|
+
* if the promise rejects, this doesn't reject until after ms
|
|
6
|
+
* (timer starts when withMinimumTime() is invoked)
|
|
7
|
+
*/
|
|
8
|
+
export declare function withMinimumTime<T>(promise: Promise<T>, ms: number, { alwaysDelay }?: {
|
|
9
|
+
alwaysDelay?: boolean;
|
|
10
|
+
}): Promise<T>;
|
|
11
|
+
//# sourceMappingURL=withMinimumTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withMinimumTime.d.ts","sourceRoot":"","sources":["../../src/delay/withMinimumTime.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACnC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,MAAM,EACV,EAAE,WAAmB,EAAE,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,OAAO,CAAC,CAAC,CAAC,CAaZ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { delay } from "./delay";
|
|
2
|
+
/**
|
|
3
|
+
* if the promise resolves:
|
|
4
|
+
* - if alwaysDelay=true, this doesn't resolve until after ms
|
|
5
|
+
* - if alwaysDelay=false, this resolves immediately
|
|
6
|
+
* if the promise rejects, this doesn't reject until after ms
|
|
7
|
+
* (timer starts when withMinimumTime() is invoked)
|
|
8
|
+
*/
|
|
9
|
+
export async function withMinimumTime(promise, ms, { alwaysDelay = false } = {}) {
|
|
10
|
+
const delayPromise = delay(ms);
|
|
11
|
+
try {
|
|
12
|
+
const result = await promise;
|
|
13
|
+
if (alwaysDelay) {
|
|
14
|
+
await delayPromise;
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
await delayPromise;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/empty.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../src/empty.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,kBAAoB,CAAC;AAC7C,eAAO,MAAM,YAAY,cAAoB,CAAC"}
|
package/dist/empty.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvC;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/identity.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { visitObject, type ObjectPropertiesVisitor } from "./ObjectPropertiesVisitor";
|
|
2
|
+
export { addPrefixToString } from "./addPrefixToString";
|
|
3
|
+
export { assertNever, assertNeverNoThrow } from "./assertNever";
|
|
4
|
+
export { assertVoidNoThrow } from "./assertVoidNoThrow";
|
|
5
|
+
export { combineURLs } from "./combineURLs";
|
|
6
|
+
export { delay } from "./delay/delay";
|
|
7
|
+
export { withMinimumTime } from "./delay/withMinimumTime";
|
|
8
|
+
export { EMPTY_ARRAY, EMPTY_OBJECT } from "./empty";
|
|
9
|
+
export { identity } from "./identity";
|
|
10
|
+
export { assertNonNullish, isNonNullish } from "./isNonNullish";
|
|
11
|
+
export { entries, type Entries } from "./objects/entries";
|
|
12
|
+
export { isPlainObject } from "./objects/isPlainObject";
|
|
13
|
+
export { keys } from "./objects/keys";
|
|
14
|
+
export { values, type Values } from "./objects/values";
|
|
15
|
+
export { PLATFORM, type Platform } from "./platform";
|
|
16
|
+
export { titleCase } from "./titleCase";
|
|
17
|
+
export type { Digit, Letter, LowercaseLetter, UppercaseLetter } from "./types";
|
|
18
|
+
export { unknownToString } from "./unknownToString";
|
|
19
|
+
export { visitDiscriminatedUnion } from "./visitDiscriminatedUnion";
|
|
20
|
+
export { withDefaultProtocol } from "./withDefaultProtocol";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { visitObject } from "./ObjectPropertiesVisitor";
|
|
2
|
+
export { addPrefixToString } from "./addPrefixToString";
|
|
3
|
+
export { assertNever, assertNeverNoThrow } from "./assertNever";
|
|
4
|
+
export { assertVoidNoThrow } from "./assertVoidNoThrow";
|
|
5
|
+
export { combineURLs } from "./combineURLs";
|
|
6
|
+
export { delay } from "./delay/delay";
|
|
7
|
+
export { withMinimumTime } from "./delay/withMinimumTime";
|
|
8
|
+
export { EMPTY_ARRAY, EMPTY_OBJECT } from "./empty";
|
|
9
|
+
export { identity } from "./identity";
|
|
10
|
+
export { assertNonNullish, isNonNullish } from "./isNonNullish";
|
|
11
|
+
export { entries } from "./objects/entries";
|
|
12
|
+
export { isPlainObject } from "./objects/isPlainObject";
|
|
13
|
+
export { keys } from "./objects/keys";
|
|
14
|
+
export { values } from "./objects/values";
|
|
15
|
+
export { PLATFORM } from "./platform";
|
|
16
|
+
export { titleCase } from "./titleCase";
|
|
17
|
+
export { unknownToString } from "./unknownToString";
|
|
18
|
+
export { visitDiscriminatedUnion } from "./visitDiscriminatedUnion";
|
|
19
|
+
export { withDefaultProtocol } from "./withDefaultProtocol";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNonNullish.d.ts","sourceRoot":"","sources":["../src/isNonNullish.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,IAAI,CAAC,CAE/D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAI7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/objects/entries.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AAEjD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEhF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainObject.d.ts","sourceRoot":"","sources":["../../src/objects/isPlainObject.ts"],"names":[],"mappings":"AACA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAY9E;AAMD,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// https://github.com/lodash/lodash/blob/master/isPlainObject.js
|
|
2
|
+
export function isPlainObject(value) {
|
|
3
|
+
if (!isObjectLike(value) || String(value) !== "[object Object]") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
if (Object.getPrototypeOf(value) == null) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
let proto = value;
|
|
10
|
+
while (Object.getPrototypeOf(proto) != null) {
|
|
11
|
+
proto = Object.getPrototypeOf(proto);
|
|
12
|
+
}
|
|
13
|
+
return Object.getPrototypeOf(value) === proto;
|
|
14
|
+
}
|
|
15
|
+
function isObjectLike(value) {
|
|
16
|
+
return typeof value === "object" && value != null;
|
|
17
|
+
}
|
|
18
|
+
export default isPlainObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/objects/keys.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAE9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/objects/values.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnC,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAEhF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC;AAEnD,eAAO,MAAM,QAAQ,UAWjB,CAAC"}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UAParser } from "ua-parser-js";
|
|
2
|
+
const uaParser = new UAParser();
|
|
3
|
+
export const PLATFORM = (function getPlatform() {
|
|
4
|
+
const { name } = uaParser.getOS();
|
|
5
|
+
if (typeof name === "string") {
|
|
6
|
+
if (name.startsWith("Mac OS")) {
|
|
7
|
+
return "mac";
|
|
8
|
+
}
|
|
9
|
+
if (name.startsWith("Windows")) {
|
|
10
|
+
return "windows";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return "other";
|
|
14
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specialTokens.d.ts","sourceRoot":"","sources":["../src/specialTokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,UAwW1B,CAAC"}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
export const SPECIAL_TOKENS = [
|
|
2
|
+
// privacy
|
|
3
|
+
"PII",
|
|
4
|
+
"PHI",
|
|
5
|
+
"PCI",
|
|
6
|
+
"GDPR",
|
|
7
|
+
"CCPA",
|
|
8
|
+
"HIPAA",
|
|
9
|
+
"COPPA",
|
|
10
|
+
"FERPA",
|
|
11
|
+
"GLBA",
|
|
12
|
+
"SOX",
|
|
13
|
+
"FISMA",
|
|
14
|
+
"NIST",
|
|
15
|
+
"CIS",
|
|
16
|
+
"ISO",
|
|
17
|
+
"IEC",
|
|
18
|
+
"ITAR",
|
|
19
|
+
"EAR",
|
|
20
|
+
"CMMC",
|
|
21
|
+
"CUI",
|
|
22
|
+
"CDI",
|
|
23
|
+
"FTC",
|
|
24
|
+
"FCC",
|
|
25
|
+
"SEC",
|
|
26
|
+
"FINRA",
|
|
27
|
+
// security
|
|
28
|
+
"XSS",
|
|
29
|
+
"CSRF",
|
|
30
|
+
"SSRF",
|
|
31
|
+
"XSRF",
|
|
32
|
+
"TLS",
|
|
33
|
+
"SSL",
|
|
34
|
+
"SSH",
|
|
35
|
+
"API",
|
|
36
|
+
"OAuth",
|
|
37
|
+
"OAuth1",
|
|
38
|
+
"OAuth1.0",
|
|
39
|
+
"OAuth2",
|
|
40
|
+
"OAuth2.0",
|
|
41
|
+
"SAML",
|
|
42
|
+
"OpenID",
|
|
43
|
+
"OpenID Connect",
|
|
44
|
+
"CAPTCHA",
|
|
45
|
+
"reCAPTCHA",
|
|
46
|
+
"2FA",
|
|
47
|
+
"MFA",
|
|
48
|
+
"OTP",
|
|
49
|
+
"TOTP",
|
|
50
|
+
"HOTP",
|
|
51
|
+
"U2F",
|
|
52
|
+
"FIDO",
|
|
53
|
+
"FIDO2",
|
|
54
|
+
"PKI",
|
|
55
|
+
"HMAC",
|
|
56
|
+
"AES",
|
|
57
|
+
"RSA",
|
|
58
|
+
"SHA",
|
|
59
|
+
"MD5",
|
|
60
|
+
"BCrypt",
|
|
61
|
+
"PBKDF2",
|
|
62
|
+
"Argon2",
|
|
63
|
+
"SCrypt",
|
|
64
|
+
"JWT",
|
|
65
|
+
"JWE",
|
|
66
|
+
"JWS",
|
|
67
|
+
"JWK",
|
|
68
|
+
"JWA",
|
|
69
|
+
"JOSE",
|
|
70
|
+
// shopping
|
|
71
|
+
"SKU",
|
|
72
|
+
"SKUs",
|
|
73
|
+
"UPC",
|
|
74
|
+
"EAN",
|
|
75
|
+
"ISBN",
|
|
76
|
+
"ASIN",
|
|
77
|
+
"MPN",
|
|
78
|
+
"MSRP",
|
|
79
|
+
"MAP",
|
|
80
|
+
"RRP",
|
|
81
|
+
"MSRP",
|
|
82
|
+
// time
|
|
83
|
+
"AM",
|
|
84
|
+
"PM",
|
|
85
|
+
"UTC",
|
|
86
|
+
"GMT",
|
|
87
|
+
"PST",
|
|
88
|
+
"PDT",
|
|
89
|
+
"EST",
|
|
90
|
+
"EDT",
|
|
91
|
+
"CST",
|
|
92
|
+
"CDT",
|
|
93
|
+
"MST",
|
|
94
|
+
"MDT",
|
|
95
|
+
// geography
|
|
96
|
+
"USA",
|
|
97
|
+
"UK",
|
|
98
|
+
"EU",
|
|
99
|
+
"UAE",
|
|
100
|
+
"APAC",
|
|
101
|
+
"EMEA",
|
|
102
|
+
"LATAM",
|
|
103
|
+
"ANZ",
|
|
104
|
+
"SEA",
|
|
105
|
+
"MEA",
|
|
106
|
+
"MENA",
|
|
107
|
+
"NATO",
|
|
108
|
+
"NA",
|
|
109
|
+
"SA",
|
|
110
|
+
"CA",
|
|
111
|
+
"EU",
|
|
112
|
+
"AU",
|
|
113
|
+
"NZ",
|
|
114
|
+
"JP",
|
|
115
|
+
"KR",
|
|
116
|
+
"CN",
|
|
117
|
+
"HK",
|
|
118
|
+
"TW",
|
|
119
|
+
"SG",
|
|
120
|
+
"MY",
|
|
121
|
+
"TH",
|
|
122
|
+
"ID",
|
|
123
|
+
"PH",
|
|
124
|
+
"VN",
|
|
125
|
+
"IN",
|
|
126
|
+
"PK",
|
|
127
|
+
"BD",
|
|
128
|
+
"LK",
|
|
129
|
+
"NP",
|
|
130
|
+
"MM",
|
|
131
|
+
"KH",
|
|
132
|
+
"LA",
|
|
133
|
+
"MM",
|
|
134
|
+
"BT",
|
|
135
|
+
"MV",
|
|
136
|
+
// finance
|
|
137
|
+
"USD",
|
|
138
|
+
"EUR",
|
|
139
|
+
"GBP",
|
|
140
|
+
"JPY",
|
|
141
|
+
"CNY",
|
|
142
|
+
"RUB",
|
|
143
|
+
"INR",
|
|
144
|
+
"AUD",
|
|
145
|
+
"CAD",
|
|
146
|
+
"CHF",
|
|
147
|
+
"SGD",
|
|
148
|
+
"MYR",
|
|
149
|
+
"THB",
|
|
150
|
+
"IDR",
|
|
151
|
+
"KRW",
|
|
152
|
+
"PHP",
|
|
153
|
+
"VND",
|
|
154
|
+
"HKD",
|
|
155
|
+
"TWD",
|
|
156
|
+
"MXN",
|
|
157
|
+
"BRL",
|
|
158
|
+
"ARS",
|
|
159
|
+
"CLP",
|
|
160
|
+
"COP",
|
|
161
|
+
"PEN",
|
|
162
|
+
"ZAR",
|
|
163
|
+
"NGN",
|
|
164
|
+
"EGP",
|
|
165
|
+
"AED",
|
|
166
|
+
"SAR",
|
|
167
|
+
"ILS",
|
|
168
|
+
"TRY",
|
|
169
|
+
"SEK",
|
|
170
|
+
"NOK",
|
|
171
|
+
"DKK",
|
|
172
|
+
"ISK",
|
|
173
|
+
"HUF",
|
|
174
|
+
"PLN",
|
|
175
|
+
"CZK",
|
|
176
|
+
"RON",
|
|
177
|
+
"BGN",
|
|
178
|
+
// programming
|
|
179
|
+
"API",
|
|
180
|
+
"APIs",
|
|
181
|
+
"SDK",
|
|
182
|
+
"SDKs",
|
|
183
|
+
"AI",
|
|
184
|
+
"OCR",
|
|
185
|
+
"REST",
|
|
186
|
+
"SOAP",
|
|
187
|
+
"JSON",
|
|
188
|
+
"XML",
|
|
189
|
+
"HTTP",
|
|
190
|
+
"HTTPS",
|
|
191
|
+
"URI",
|
|
192
|
+
"URL",
|
|
193
|
+
"CRUD",
|
|
194
|
+
"RESTful",
|
|
195
|
+
"KYB",
|
|
196
|
+
"KYC",
|
|
197
|
+
"AML",
|
|
198
|
+
"HTML",
|
|
199
|
+
"CSS",
|
|
200
|
+
"JS",
|
|
201
|
+
"SQL",
|
|
202
|
+
"DB",
|
|
203
|
+
"UI",
|
|
204
|
+
"UX",
|
|
205
|
+
"SaaS",
|
|
206
|
+
"PaaS",
|
|
207
|
+
"IaaS",
|
|
208
|
+
"IP",
|
|
209
|
+
"TCP",
|
|
210
|
+
"UDP",
|
|
211
|
+
"DNS",
|
|
212
|
+
"FTP",
|
|
213
|
+
"SMTP",
|
|
214
|
+
"IMAP",
|
|
215
|
+
"POP3",
|
|
216
|
+
"CSV",
|
|
217
|
+
"MVC",
|
|
218
|
+
"MVP",
|
|
219
|
+
"MVVM",
|
|
220
|
+
"DOM",
|
|
221
|
+
"SPA",
|
|
222
|
+
"SSR",
|
|
223
|
+
"CSR",
|
|
224
|
+
"DDoS",
|
|
225
|
+
"CDN",
|
|
226
|
+
"IoT",
|
|
227
|
+
"ML",
|
|
228
|
+
"DL",
|
|
229
|
+
"NLP",
|
|
230
|
+
"CLI",
|
|
231
|
+
"GUI",
|
|
232
|
+
"BI",
|
|
233
|
+
"ETL",
|
|
234
|
+
"RDBMS",
|
|
235
|
+
"NoSQL",
|
|
236
|
+
"IDE",
|
|
237
|
+
"CMS",
|
|
238
|
+
"CCPA",
|
|
239
|
+
"POSIX",
|
|
240
|
+
"ABI",
|
|
241
|
+
"API",
|
|
242
|
+
"AST",
|
|
243
|
+
"COBOL",
|
|
244
|
+
"DDL",
|
|
245
|
+
"DML",
|
|
246
|
+
// AI-related
|
|
247
|
+
"NN", // Neural Network
|
|
248
|
+
"CNN", // Convolutional Neural Network
|
|
249
|
+
"RNN", // Recurrent Neural Network
|
|
250
|
+
"LSTM", // Long Short Term Memory
|
|
251
|
+
"GRU", // Gated Recurrent Unit
|
|
252
|
+
"ANN", // Artificial Neural Network
|
|
253
|
+
"GAN", // Generative Adversarial Network
|
|
254
|
+
"RL", // Reinforcement Learning
|
|
255
|
+
"DL", // Deep Learning
|
|
256
|
+
"ML", // Machine Learning
|
|
257
|
+
"NLP", // Natural Language Processing
|
|
258
|
+
"NLG", // Natural Language Generation
|
|
259
|
+
"NLU", // Natural Language Understanding
|
|
260
|
+
"BERT", // Bidirectional Encoder Representations from Transformers
|
|
261
|
+
"GPT", // Generative Pre-training Transformer
|
|
262
|
+
"SVM", // Support Vector Machine
|
|
263
|
+
"PCA", // Principal Component Analysis
|
|
264
|
+
"AI", // Artificial Intelligence
|
|
265
|
+
"CV", // Computer Vision
|
|
266
|
+
"TF", // TensorFlow
|
|
267
|
+
"TTS", // Text-to-Speech
|
|
268
|
+
"ASR", // Automatic Speech Recognition
|
|
269
|
+
"HMM", // Hidden Markov Model
|
|
270
|
+
"DNN", // Deep Neural Network
|
|
271
|
+
"MLP", // Multi-Layer Perceptron
|
|
272
|
+
"RBM", // Restricted Boltzmann Machine
|
|
273
|
+
"CRF", // Conditional Random Field
|
|
274
|
+
// Media
|
|
275
|
+
"PDF",
|
|
276
|
+
"PDFs",
|
|
277
|
+
"RTF",
|
|
278
|
+
"TXT",
|
|
279
|
+
"XLS",
|
|
280
|
+
"XLSX",
|
|
281
|
+
"PPT",
|
|
282
|
+
// Image
|
|
283
|
+
"JPG",
|
|
284
|
+
"JPEG",
|
|
285
|
+
"PNG",
|
|
286
|
+
"GIF",
|
|
287
|
+
"GIFs",
|
|
288
|
+
"SVG",
|
|
289
|
+
"TIFF",
|
|
290
|
+
"BMP",
|
|
291
|
+
"ICO",
|
|
292
|
+
"PSD",
|
|
293
|
+
"WebP",
|
|
294
|
+
"AVIF",
|
|
295
|
+
"HEIF",
|
|
296
|
+
"HEIC",
|
|
297
|
+
"EPS",
|
|
298
|
+
// Audio
|
|
299
|
+
"MP3",
|
|
300
|
+
"WAV",
|
|
301
|
+
"AIFF",
|
|
302
|
+
"FLAC",
|
|
303
|
+
"WMA",
|
|
304
|
+
"AAC",
|
|
305
|
+
"OGG",
|
|
306
|
+
// Video
|
|
307
|
+
"AVI",
|
|
308
|
+
"WMV",
|
|
309
|
+
"MOV",
|
|
310
|
+
"M4V",
|
|
311
|
+
"MP4",
|
|
312
|
+
"MPG",
|
|
313
|
+
"MPEG",
|
|
314
|
+
"FLV",
|
|
315
|
+
"SWF",
|
|
316
|
+
"MKV",
|
|
317
|
+
"WebM",
|
|
318
|
+
// Cloud Computing
|
|
319
|
+
"GCP", // Google Cloud Platform
|
|
320
|
+
"AWS", // Amazon Web Services
|
|
321
|
+
"VM", // Virtual Machines
|
|
322
|
+
"VPC", // Virtual Private Cloud
|
|
323
|
+
"S3", // AWS Simple Storage Service
|
|
324
|
+
"EC2", // AWS Elastic Compute Cloud
|
|
325
|
+
// Data Storage and Databases
|
|
326
|
+
"DynamoDB",
|
|
327
|
+
"CosmosDB",
|
|
328
|
+
"BigQuery",
|
|
329
|
+
"CI/CD",
|
|
330
|
+
// Security and Compliance
|
|
331
|
+
"SOC1", // Service Organization Control 1
|
|
332
|
+
"SOC2", // Service Organization Control 2
|
|
333
|
+
"SOC3", // Service Organization Control 3
|
|
334
|
+
"PCI DSS", // Payment Card Industry Data Security Standard
|
|
335
|
+
"WAF", // Web Application Firewall
|
|
336
|
+
"IAM", // Identity and Access Management
|
|
337
|
+
// Networking
|
|
338
|
+
"SDN", // Software-Defined Networking
|
|
339
|
+
"MPLS", // Multi-Protocol Label Switching
|
|
340
|
+
"BGP", // Border Gateway Protocol
|
|
341
|
+
// Frameworks and Libraries
|
|
342
|
+
"Vue.js",
|
|
343
|
+
"Node.js",
|
|
344
|
+
".NET",
|
|
345
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"titleCase.d.ts","sourceRoot":"","sources":["../src/titleCase.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAe9C;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import title from "title";
|
|
2
|
+
import { SPECIAL_TOKENS } from "./specialTokens";
|
|
3
|
+
export function titleCase(name) {
|
|
4
|
+
// regex match pascalCase or CamelCase and add spaces between words
|
|
5
|
+
name = name.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
6
|
+
// regex match snake_case and replace "_" with " "
|
|
7
|
+
name = name.replace(/_/g, " ");
|
|
8
|
+
// regex match kebab-case and replace "-" with " "
|
|
9
|
+
name = name.replace(/-/g, " ");
|
|
10
|
+
const titleCased = title(name, { special: SPECIAL_TOKENS });
|
|
11
|
+
// regex match "V 2", "V 4", etc. and replace it with "V2", "V4", etc.
|
|
12
|
+
const versionedTitle = titleCased.replace(/V\s(\d)/g, "V$1");
|
|
13
|
+
return versionedTitle;
|
|
14
|
+
}
|
|
15
|
+
export default titleCase;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type LowercaseLetter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
2
|
+
export type UppercaseLetter = Uppercase<LowercaseLetter>;
|
|
3
|
+
export type Letter = LowercaseLetter | UppercaseLetter;
|
|
4
|
+
export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
5
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACrB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAEV,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;AAEzD,MAAM,MAAM,MAAM,GAAG,eAAe,GAAG,eAAe,CAAC;AAEvD,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknownToString.d.ts","sourceRoot":"","sources":["../src/unknownToString.ts"],"names":[],"mappings":"AAAA,UAAU,IAAI;IACV,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,UAAkB,EAAE,GAAE,IAAS,GAAG,MAAM,CAOzF;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function unknownToString(value, { renderNull = false } = {}) {
|
|
2
|
+
if (value == null || typeof value === "function") {
|
|
3
|
+
return renderNull ? "null" : "";
|
|
4
|
+
}
|
|
5
|
+
else if (typeof value === "string") {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
return JSON.stringify(value);
|
|
9
|
+
}
|
|
10
|
+
export default unknownToString;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type DiscriminatedUnionVisitor<T extends Record<Discriminant, string>, U, Discriminant extends string> = {
|
|
2
|
+
[D in T[Discriminant]]: (value: Extract<T, Record<Discriminant, D>>) => U;
|
|
3
|
+
} & {
|
|
4
|
+
_other?: (value: Record<Discriminant, string>) => U;
|
|
5
|
+
};
|
|
6
|
+
export declare function visitDiscriminatedUnion<T extends Record<"type", string>>(item: T): {
|
|
7
|
+
_visit: <U>(visitor: DiscriminatedUnionVisitor<T, U, "type">) => U;
|
|
8
|
+
};
|
|
9
|
+
export declare function visitDiscriminatedUnion<T extends Record<Discriminant, string>, Discriminant extends string>(item: T, discriminant: Discriminant): {
|
|
10
|
+
_visit: <U>(visitor: DiscriminatedUnionVisitor<T, U, Discriminant>) => U;
|
|
11
|
+
};
|
|
12
|
+
export default visitDiscriminatedUnion;
|
|
13
|
+
//# sourceMappingURL=visitDiscriminatedUnion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitDiscriminatedUnion.d.ts","sourceRoot":"","sources":["../src/visitDiscriminatedUnion.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,YAAY,SAAS,MAAM,IAAI;KAC3G,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;CAC5E,GAAG;IACA,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CACvD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpE,IAAI,EAAE,CAAC,GACR;IAAE,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC;AAC1E,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,YAAY,SAAS,MAAM,EACvG,IAAI,EAAE,CAAC,EACP,YAAY,EAAE,YAAY,GAC3B;IAAE,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC;AAoBhF,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assertNever } from "./assertNever";
|
|
2
|
+
export function visitDiscriminatedUnion(item, discriminant = "type") {
|
|
3
|
+
return {
|
|
4
|
+
_visit: (visitor) => {
|
|
5
|
+
const visit = visitor[item[discriminant]];
|
|
6
|
+
if (visit != null) {
|
|
7
|
+
return visit(item);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
if (visitor._other == null) {
|
|
11
|
+
assertNever(item);
|
|
12
|
+
}
|
|
13
|
+
return visitor._other(item);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export default visitDiscriminatedUnion;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefixes the given endpoint with the `defaultProtocol` if one isn't defined already.
|
|
3
|
+
*
|
|
4
|
+
* @param endpoint
|
|
5
|
+
* @param defaultProtocol defaults to "https://"
|
|
6
|
+
* @returns the endpoint, which will always have a protocol
|
|
7
|
+
*/
|
|
8
|
+
export declare function withDefaultProtocol(endpoint: string, defaultProtocol?: string): string;
|
|
9
|
+
//# sourceMappingURL=withDefaultProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withDefaultProtocol.d.ts","sourceRoot":"","sources":["../src/withDefaultProtocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,SAAa,GAAG,MAAM,CAS1F"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefixes the given endpoint with the `defaultProtocol` if one isn't defined already.
|
|
3
|
+
*
|
|
4
|
+
* @param endpoint
|
|
5
|
+
* @param defaultProtocol defaults to "https://"
|
|
6
|
+
* @returns the endpoint, which will always have a protocol
|
|
7
|
+
*/
|
|
8
|
+
export function withDefaultProtocol(endpoint, defaultProtocol = "https://") {
|
|
9
|
+
// matches any protocol scheme at the beginning of the string (e.g., "http://", "https://", "ftp://")
|
|
10
|
+
const protocolRegex = /^[a-z]+:\/\//i;
|
|
11
|
+
if (!protocolRegex.test(endpoint)) {
|
|
12
|
+
return `${defaultProtocol}${endpoint}`;
|
|
13
|
+
}
|
|
14
|
+
return endpoint;
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fern-api/ui-core-utils",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/fern-api/fern-platform.git",
|
|
7
|
+
"directory": "packages/commons/core-utils"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"source": "src/index.ts",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./assertNever": {
|
|
17
|
+
"types": "./src/assertNever.ts",
|
|
18
|
+
"default": "./dist/assertNever.js"
|
|
19
|
+
},
|
|
20
|
+
"./titleCase": {
|
|
21
|
+
"types": "./src/titleCase.ts",
|
|
22
|
+
"default": "./dist/titleCase.js"
|
|
23
|
+
},
|
|
24
|
+
"./unknownToString": {
|
|
25
|
+
"types": "./src/unknownToString.ts",
|
|
26
|
+
"default": "./dist/unknownToString.js"
|
|
27
|
+
},
|
|
28
|
+
"./visitDiscriminatedUnion": {
|
|
29
|
+
"types": "./src/visitDiscriminatedUnion.ts",
|
|
30
|
+
"default": "./dist/visitDiscriminatedUnion.js"
|
|
31
|
+
},
|
|
32
|
+
"./isPlainObject": {
|
|
33
|
+
"types": "./src/objects/isPlainObject.ts",
|
|
34
|
+
"default": "./dist/objects/isPlainObject.js"
|
|
35
|
+
},
|
|
36
|
+
"./identity": {
|
|
37
|
+
"types": "./src/identity.ts",
|
|
38
|
+
"default": "./dist/identity.js"
|
|
39
|
+
},
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./src/index.ts",
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"sideEffects": false,
|
|
46
|
+
"scripts": {
|
|
47
|
+
"clean": "rm -rf ./lib && tsc --build --clean",
|
|
48
|
+
"compile": "tsc --build",
|
|
49
|
+
"test": "vitest --run --passWithNoTests --globals",
|
|
50
|
+
"lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../../.eslintignore",
|
|
51
|
+
"lint:eslint:fix": "pnpm lint:eslint --fix",
|
|
52
|
+
"lint:style": "stylelint 'src/**/*.scss' --allow-empty-input --max-warnings 0",
|
|
53
|
+
"lint:style:fix": "pnpm lint:style --fix",
|
|
54
|
+
"format": "prettier --write --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
|
|
55
|
+
"format:check": "prettier --check --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
|
|
56
|
+
"organize-imports": "organize-imports-cli tsconfig.json",
|
|
57
|
+
"depcheck": "depcheck"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"strip-ansi": "^7.1.0",
|
|
61
|
+
"title": "^3.5.3",
|
|
62
|
+
"ua-parser-js": "^1.0.35"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@fern-platform/configs": "workspace:*",
|
|
66
|
+
"@types/node": "^18.7.18",
|
|
67
|
+
"@types/title": "^3.4.3",
|
|
68
|
+
"@types/ua-parser-js": "^0.7.39",
|
|
69
|
+
"depcheck": "^1.4.3",
|
|
70
|
+
"eslint": "^8.56.0",
|
|
71
|
+
"vitest": "^1.5.0",
|
|
72
|
+
"organize-imports-cli": "^0.10.0",
|
|
73
|
+
"prettier": "^3.3.2",
|
|
74
|
+
"stylelint": "^16.1.0",
|
|
75
|
+
"typescript": "5.4.3"
|
|
76
|
+
}
|
|
77
|
+
}
|