@gadgetinc/ggt 0.4.7 → 0.4.8
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/README.md +1 -1
- package/bin/dev.js +2 -1
- package/bin/run.js +3 -1
- package/lib/commands/deploy.js +11 -15
- package/lib/commands/deploy.js.map +1 -1
- package/lib/commands/list.js +7 -11
- package/lib/commands/list.js.map +1 -1
- package/lib/commands/login.js +8 -12
- package/lib/commands/login.js.map +1 -1
- package/lib/commands/logout.js +3 -7
- package/lib/commands/logout.js.map +1 -1
- package/lib/commands/root.js +17 -44
- package/lib/commands/root.js.map +1 -1
- package/lib/commands/sync.js +8 -27
- package/lib/commands/sync.js.map +1 -1
- package/lib/commands/version.js +2 -6
- package/lib/commands/version.js.map +1 -1
- package/lib/commands/whoami.js +5 -9
- package/lib/commands/whoami.js.map +1 -1
- package/lib/ggt.js +40 -0
- package/lib/ggt.js.map +1 -0
- package/lib/services/app/app.js +8 -6
- package/lib/services/app/app.js.map +1 -1
- package/lib/services/app/edit/client.js +176 -0
- package/lib/services/app/edit/client.js.map +1 -0
- package/lib/services/app/edit/edit.js +155 -0
- package/lib/services/app/edit/edit.js.map +1 -0
- package/lib/services/app/edit/error.js +65 -0
- package/lib/services/app/edit/error.js.map +1 -0
- package/lib/services/app/edit/operation.js +87 -0
- package/lib/services/app/edit/operation.js.map +1 -0
- package/lib/services/command/arg.js +5 -5
- package/lib/services/command/arg.js.map +1 -1
- package/lib/services/command/command.js +21 -7
- package/lib/services/command/command.js.map +1 -1
- package/lib/services/command/context.js +108 -56
- package/lib/services/command/context.js.map +1 -1
- package/lib/services/filesync/changes.js +7 -9
- package/lib/services/filesync/changes.js.map +1 -1
- package/lib/services/filesync/conflicts.js +11 -9
- package/lib/services/filesync/conflicts.js.map +1 -1
- package/lib/services/filesync/directory.js +2 -2
- package/lib/services/filesync/directory.js.map +1 -1
- package/lib/services/filesync/filesync.js +70 -42
- package/lib/services/filesync/filesync.js.map +1 -1
- package/lib/services/filesync/hashes.js +18 -15
- package/lib/services/filesync/hashes.js.map +1 -1
- package/lib/services/http/auth.js +4 -4
- package/lib/services/http/auth.js.map +1 -1
- package/lib/services/http/http.js +43 -23
- package/lib/services/http/http.js.map +1 -1
- package/lib/services/output/log/logger.js +11 -6
- package/lib/services/output/log/logger.js.map +1 -1
- package/lib/services/output/log/printer.js.map +1 -1
- package/lib/services/output/log/structured.js +2 -2
- package/lib/services/output/log/structured.js.map +1 -1
- package/lib/services/output/notify.js +3 -7
- package/lib/services/output/notify.js.map +1 -1
- package/lib/services/output/prompt.js +11 -11
- package/lib/services/output/prompt.js.map +1 -1
- package/lib/services/output/report.js +51 -67
- package/lib/services/output/report.js.map +1 -1
- package/lib/services/output/update.js +9 -10
- package/lib/services/output/update.js.map +1 -1
- package/lib/services/user/user.js +19 -25
- package/lib/services/user/user.js.map +1 -1
- package/lib/services/util/collection.js +1 -1
- package/lib/services/util/collection.js.map +1 -1
- package/lib/services/util/function.js +29 -11
- package/lib/services/util/function.js.map +1 -1
- package/lib/services/util/number.js +3 -3
- package/lib/services/util/number.js.map +1 -1
- package/lib/services/util/object.js +4 -4
- package/lib/services/util/object.js.map +1 -1
- package/lib/services/util/paths.js +4 -4
- package/lib/services/util/paths.js.map +1 -1
- package/lib/services/util/types.js +3 -1
- package/lib/services/util/types.js.map +1 -1
- package/npm-shrinkwrap.json +579 -411
- package/package.json +15 -14
- package/lib/main.js +0 -8
- package/lib/main.js.map +0 -1
- package/lib/services/app/edit-graphql.js +0 -392
- package/lib/services/app/edit-graphql.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/user/user.ts"],"sourcesContent":["import assert from \"node:assert\";\nimport z from \"zod\";\nimport { login } from \"../../commands/login.js\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/services/user/user.ts"],"sourcesContent":["import assert from \"node:assert\";\nimport z from \"zod\";\nimport { login } from \"../../commands/login.js\";\nimport type { Context } from \"../command/context.js\";\nimport { config } from \"../config/config.js\";\nimport { loadCookie, swallowUnauthorized } from \"../http/auth.js\";\nimport { http } from \"../http/http.js\";\nimport { confirm } from \"../output/prompt.js\";\n\nconst User = z.object({\n id: z.union([z.string(), z.number()]).transform(Number),\n name: z.string().nullish(),\n email: z.string(),\n});\n\nexport type User = z.infer<typeof User>;\n\n/**\n * Retrieves the currently logged in user from Gadgets API.\n *\n * @returns A Promise that resolves to a User object representing the\n * current user, or undefined if the user is not authenticated.\n */\nexport const getUser = async (ctx: Context): Promise<User | undefined> => {\n if (ctx.user) {\n return ctx.user;\n }\n\n const cookie = loadCookie();\n if (!cookie) {\n return undefined;\n }\n\n try {\n const json = await http({\n context: { ctx },\n url: `https://${config.domains.services}/auth/api/current-user`,\n headers: { cookie },\n responseType: \"json\",\n resolveBodyOnly: true,\n });\n\n ctx.user = User.parse(json);\n ctx.log.info(\"loaded user\");\n\n return ctx.user;\n } catch (error) {\n swallowUnauthorized(ctx, error);\n return undefined;\n }\n};\n\n/**\n * Retrieves the current user or prompts the user to log in if not\n * already logged in.\n *\n * @param ctx - The current context.\n * @param message - The message to display when prompting the user to log in.\n * @returns A Promise that resolves to the current user.\n */\nexport const getUserOrLogin = async (\n ctx: Context,\n message = \"You must be logged in to use this command. Would you like to log in?\",\n): Promise<User> => {\n let user = await getUser(ctx);\n if (user) {\n return user;\n }\n\n ctx.log.info(\"prompting user to log in\");\n await confirm(ctx, { message });\n\n await login(ctx);\n\n user = await getUser(ctx);\n assert(user, \"missing user after successful login\");\n\n return user;\n};\n"],"names":["assert","z","login","config","loadCookie","swallowUnauthorized","http","confirm","User","object","id","union","string","number","transform","Number","name","nullish","email","getUser","ctx","user","cookie","undefined","json","context","url","domains","services","headers","responseType","resolveBodyOnly","parse","log","info","error","getUserOrLogin","message"],"mappings":"AAAA,OAAOA,YAAY,cAAc;AACjC,OAAOC,OAAO,MAAM;AACpB,SAASC,KAAK,QAAQ,0BAA0B;AAEhD,SAASC,MAAM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AAOqB,MAAM;IAEb,OAAOA;AACT,EAAE"}
|
|
@@ -12,7 +12,7 @@ import assert from "node:assert";
|
|
|
12
12
|
/**
|
|
13
13
|
* Returns a new array with all duplicate elements removed.
|
|
14
14
|
*
|
|
15
|
-
* @param array The array to remove duplicates from.
|
|
15
|
+
* @param array - The array to remove duplicates from.
|
|
16
16
|
* @returns A new array with all duplicate elements removed.
|
|
17
17
|
*/ export const uniq = (array)=>{
|
|
18
18
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/util/collection.ts"],"sourcesContent":["import levenshtein from \"fast-levenshtein\";\nimport assert from \"node:assert\";\n\n/**\n * Returns a new array with all falsy values removed. The values\n * `false`, `null`, `0`, `\"\"`, `undefined`, and `NaN` are falsy.\n *\n * @param array - The array to compact.\n * @returns A new array with all falsy values removed.\n */\nexport const compact = <T>(array: T[]): NonNullable<T>[] => {\n return array.filter((value): value is NonNullable<T> => Boolean(value));\n};\n\n/**\n * Returns a new array with all duplicate elements removed.\n *\n * @param array The array to remove duplicates from.\n * @returns A new array with all duplicate elements removed.\n */\nexport const uniq = <T>(array: T[]): T[] => {\n return [...new Set(array)];\n};\n\n/**\n * Sorts an array of strings based on their similarity to a given input\n * string. The closest match is returned as the first element, followed\n * by the sorted array.\n *\n * @param input - The input string to compare against.\n * @param options - The array of strings to be sorted.\n * @returns An array with the closest match as the first element,\n * followed by the sorted array.\n */\nexport const sortBySimilar = (input: string, options: readonly string[]): [closest: string, ...sorted: string[]] => {\n assert(options.length > 0, \"options must not be empty\");\n return [...options].sort((a, b) => levenshtein.get(a, input) - levenshtein.get(b, input)) as [string, ...string[]];\n};\n"],"names":["levenshtein","assert","compact","array","filter","value","Boolean","uniq","Set","sortBySimilar","input","options","length","sort","a","b","get"],"mappings":"AAAA,OAAOA,iBAAiB,mBAAmB;AAC3C,OAAOC,YAAY,cAAc;AAEjC;;;;;;CAMC,GACD,OAAO,MAAMC,UAAU,CAAIC;IACzB,OAAOA,MAAMC,MAAM,CAAC,CAACC,QAAmCC,QAAQD;AAClE,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAME,OAAO,CAAIJ;IACtB,OAAO;WAAI,IAAIK,IAAIL;KAAO;AAC5B,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,MAAMM,gBAAgB,CAACC,OAAeC;IAC3CV,OAAOU,QAAQC,MAAM,GAAG,GAAG;IAC3B,OAAO;WAAID;KAAQ,CAACE,IAAI,CAAC,CAACC,GAAGC,IAAMf,YAAYgB,GAAG,CAACF,GAAGJ,SAASV,YAAYgB,GAAG,CAACD,GAAGL;AACpF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/services/util/collection.ts"],"sourcesContent":["import levenshtein from \"fast-levenshtein\";\nimport assert from \"node:assert\";\n\n/**\n * Returns a new array with all falsy values removed. The values\n * `false`, `null`, `0`, `\"\"`, `undefined`, and `NaN` are falsy.\n *\n * @param array - The array to compact.\n * @returns A new array with all falsy values removed.\n */\nexport const compact = <T>(array: T[]): NonNullable<T>[] => {\n return array.filter((value): value is NonNullable<T> => Boolean(value));\n};\n\n/**\n * Returns a new array with all duplicate elements removed.\n *\n * @param array - The array to remove duplicates from.\n * @returns A new array with all duplicate elements removed.\n */\nexport const uniq = <T>(array: T[]): T[] => {\n return [...new Set(array)];\n};\n\n/**\n * Sorts an array of strings based on their similarity to a given input\n * string. The closest match is returned as the first element, followed\n * by the sorted array.\n *\n * @param input - The input string to compare against.\n * @param options - The array of strings to be sorted.\n * @returns An array with the closest match as the first element,\n * followed by the sorted array.\n */\nexport const sortBySimilar = (input: string, options: readonly string[]): [closest: string, ...sorted: string[]] => {\n assert(options.length > 0, \"options must not be empty\");\n return [...options].sort((a, b) => levenshtein.get(a, input) - levenshtein.get(b, input)) as [string, ...string[]];\n};\n"],"names":["levenshtein","assert","compact","array","filter","value","Boolean","uniq","Set","sortBySimilar","input","options","length","sort","a","b","get"],"mappings":"AAAA,OAAOA,iBAAiB,mBAAmB;AAC3C,OAAOC,YAAY,cAAc;AAEjC;;;;;;CAMC,GACD,OAAO,MAAMC,UAAU,CAAIC;IACzB,OAAOA,MAAMC,MAAM,CAAC,CAACC,QAAmCC,QAAQD;AAClE,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAME,OAAO,CAAIJ;IACtB,OAAO;WAAI,IAAIK,IAAIL;KAAO;AAC5B,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,MAAMM,gBAAgB,CAACC,OAAeC;IAC3CV,OAAOU,QAAQC,MAAM,GAAG,GAAG;IAC3B,OAAO;WAAID;KAAQ,CAACE,IAAI,CAAC,CAACC,GAAGC,IAAMf,YAAYgB,GAAG,CAACF,GAAGJ,SAASV,YAAYgB,GAAG,CAACD,GAAGL;AACpF,EAAE"}
|
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
import assert from "node:assert";
|
|
3
3
|
import { isFunction } from "./is.js";
|
|
4
4
|
const memoizedFns = new Set();
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A function that returns the first argument as a string.
|
|
7
|
+
*
|
|
8
|
+
* Used as the default key function for {@linkcode memo}.
|
|
9
|
+
*/ export const MemoFirstArg = (...args)=>String(args[0]);
|
|
10
|
+
/**
|
|
11
|
+
* A function that returns all arguments as a string.
|
|
12
|
+
*
|
|
13
|
+
* Useful for memoizing functions that accept a variable number of
|
|
14
|
+
* arguments.
|
|
15
|
+
*/ export const MemoAllArgs = (...args)=>args.map(String).join(":");
|
|
16
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
7
17
|
export function memo(fnOrKeyFn, fn) {
|
|
8
18
|
let keyFn;
|
|
9
19
|
if (fn) {
|
|
@@ -28,7 +38,9 @@ export function memo(fnOrKeyFn, fn) {
|
|
|
28
38
|
mimicFunction(memoized, fn);
|
|
29
39
|
return memoized;
|
|
30
40
|
}
|
|
31
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Clears the cache of all memoized functions.
|
|
43
|
+
*/ export const clearMemoized = ()=>{
|
|
32
44
|
for (const memoized of memoizedFns){
|
|
33
45
|
memoized.clear();
|
|
34
46
|
}
|
|
@@ -38,17 +50,17 @@ export const clearMemoized = ()=>{
|
|
|
38
50
|
* function until after `delayMS` milliseconds have elapsed since the
|
|
39
51
|
* last time it was invoked.
|
|
40
52
|
*
|
|
41
|
-
* @param delayMS The number of milliseconds to delay.
|
|
42
|
-
* @param
|
|
53
|
+
* @param delayMS - The number of milliseconds to delay.
|
|
54
|
+
* @param fn - The function to be debounced.
|
|
43
55
|
* @returns A debounced version of the provided function.
|
|
44
|
-
*/ export const debounce = (delayMS,
|
|
56
|
+
*/ export const debounce = (delayMS, fn)=>{
|
|
45
57
|
let timerId;
|
|
46
58
|
let upcomingCall;
|
|
47
59
|
const debounced = (...args)=>{
|
|
48
60
|
upcomingCall = ()=>{
|
|
49
61
|
upcomingCall = undefined;
|
|
50
62
|
timerId = undefined;
|
|
51
|
-
|
|
63
|
+
fn(...args);
|
|
52
64
|
};
|
|
53
65
|
clearTimeout(timerId);
|
|
54
66
|
timerId = setTimeout(upcomingCall, delayMS);
|
|
@@ -58,13 +70,14 @@ export const clearMemoized = ()=>{
|
|
|
58
70
|
upcomingCall();
|
|
59
71
|
}
|
|
60
72
|
};
|
|
73
|
+
mimicFunction(debounced, fn);
|
|
61
74
|
return debounced;
|
|
62
75
|
};
|
|
63
76
|
/**
|
|
64
77
|
* Wraps a value in a thunk (a function that returns a value). If the
|
|
65
78
|
* value is already a function, it is returned as is.
|
|
66
79
|
*
|
|
67
|
-
* @param val The value or function to wrap.
|
|
80
|
+
* @param val - The value or function to wrap.
|
|
68
81
|
* @returns A function that returns the value.
|
|
69
82
|
*/ export const thunk = (val)=>{
|
|
70
83
|
if (isFunction(val)) {
|
|
@@ -76,7 +89,7 @@ export const clearMemoized = ()=>{
|
|
|
76
89
|
* Unwraps a value from a thunk (a function that returns a value). If the
|
|
77
90
|
* value is not a function, it is returned as is.
|
|
78
91
|
*
|
|
79
|
-
* @param val The value or thunk to unwrap.
|
|
92
|
+
* @param val - The value or thunk to unwrap.
|
|
80
93
|
* @returns The unwrapped value.
|
|
81
94
|
*/ export const unthunk = (val)=>{
|
|
82
95
|
if (isFunction(val)) {
|
|
@@ -87,11 +100,16 @@ export const clearMemoized = ()=>{
|
|
|
87
100
|
/**
|
|
88
101
|
* A function that does nothing and returns nothing.
|
|
89
102
|
*/ // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
90
|
-
export const noop = ()=>{};
|
|
103
|
+
export const noop = (..._args)=>{};
|
|
91
104
|
/**
|
|
92
105
|
* A function that does nothing and returns `this`.
|
|
93
|
-
*/ export const noopThis = function() {
|
|
106
|
+
*/ export const noopThis = function(..._args) {
|
|
94
107
|
return this;
|
|
95
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* A function that does nothing and returns a function that does nothing.
|
|
111
|
+
*/ export const noopNoop = (..._args)=>{
|
|
112
|
+
return noop;
|
|
113
|
+
};
|
|
96
114
|
|
|
97
115
|
//# sourceMappingURL=function.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/util/function.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable func-style */\nimport mimicFunction from \"mimic-fn\";\nimport assert from \"node:assert\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/services/util/function.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable func-style */\nimport mimicFunction from \"mimic-fn\";\nimport assert from \"node:assert\";\nimport { isFunction } from \"./is.js\";\nimport { type AnyFunction } from \"./types.js\";\n\nconst memoizedFns = new Set<MemoizedFn>();\n\n/**\n * A function that has been wrapped by {@linkcode memo}.\n */\nexport type MemoizedFn<Fn extends AnyFunction = AnyFunction> = Fn & {\n /**\n * Clears the cache of the memoized function.\n */\n clear: () => void;\n};\n\n/**\n * A function that returns the first argument as a string.\n *\n * Used as the default key function for {@linkcode memo}.\n */\nexport const MemoFirstArg = (...args: any[]): string => String(args[0]);\n\n/**\n * A function that returns all arguments as a string.\n *\n * Useful for memoizing functions that accept a variable number of\n * arguments.\n */\nexport const MemoAllArgs = (...args: any[]): string => args.map(String).join(\":\");\n\n/**\n * Creates a memoized version of the provided function.\n *\n * The memoized function caches the results of previous calls and\n * returns the cached result when the first argument matches a previous\n * call. Subsequent arguments are ignored.\n *\n * @param fn - The function to memoize.\n * @see MemoFirstArg\n */\nexport function memo<Fn extends AnyFunction>(fn: Fn): MemoizedFn<Fn>;\n\n/**\n * Creates a memoized version of the provided function.\n *\n * The memoized function caches the results of previous calls and\n * returns the cached result when the key returned by `keyFn` matches\n * a previous call.\n *\n * @param keyFn - A function that returns a key for the arguments.\n * @param fn - The function to memoize.\n */\nexport function memo<Fn extends AnyFunction, KeyFn extends (...args: Parameters<Fn>) => string>(keyFn: KeyFn, fn: Fn): MemoizedFn<Fn>;\n\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function memo<Fn extends AnyFunction, KeyFn extends (...args: Parameters<Fn>) => string>(\n fnOrKeyFn: Fn | KeyFn,\n fn?: Fn,\n): MemoizedFn<Fn> {\n let keyFn: KeyFn;\n if (fn) {\n keyFn = fnOrKeyFn as KeyFn;\n } else {\n fn = fnOrKeyFn as Fn;\n keyFn = MemoFirstArg as unknown as KeyFn;\n }\n\n const cache = new Map<string, unknown>();\n\n const memoized = ((...args) => {\n const key = keyFn(...(args as Parameters<Fn>));\n if (cache.has(key)) {\n return cache.get(key);\n }\n\n assert(fn, \"fn shouldn't be undefined\");\n const result = fn(...args);\n cache.set(key, result);\n\n return result;\n }) as MemoizedFn<Fn>;\n\n memoized.clear = cache.clear.bind(cache);\n\n memoizedFns.add(memoized);\n\n mimicFunction(memoized, fn);\n\n return memoized;\n}\n\n/**\n * Clears the cache of all memoized functions.\n */\nexport const clearMemoized = (): void => {\n for (const memoized of memoizedFns) {\n memoized.clear();\n }\n};\n\n/**\n * A function that has been wrapped by {@linkcode debounce}.\n */\nexport type DebouncedFunc<Fn extends (...args: unknown[]) => void> = Fn & {\n /**\n * Invokes the function if it is waiting to stop being called.\n */\n flush: () => void;\n};\n\n/**\n * Creates a debounced function that delays invoking the provided\n * function until after `delayMS` milliseconds have elapsed since the\n * last time it was invoked.\n *\n * @param delayMS - The number of milliseconds to delay.\n * @param fn - The function to be debounced.\n * @returns A debounced version of the provided function.\n */\nexport const debounce = <F extends (...args: unknown[]) => void>(delayMS: number, fn: F): DebouncedFunc<F> => {\n let timerId: NodeJS.Timeout | undefined;\n let upcomingCall: (() => void) | undefined;\n\n const debounced = ((...args) => {\n upcomingCall = () => {\n upcomingCall = undefined;\n timerId = undefined;\n fn(...args);\n };\n\n clearTimeout(timerId);\n timerId = setTimeout(upcomingCall, delayMS);\n }) as DebouncedFunc<F>;\n\n debounced.flush = () => {\n if (upcomingCall) {\n upcomingCall();\n }\n };\n\n mimicFunction(debounced, fn);\n\n return debounced;\n};\n\n/**\n * Either a value or a function that returns a value.\n */\nexport type Thunk<T> = T | (() => T);\n\n/**\n * Wraps a value in a thunk (a function that returns a value). If the\n * value is already a function, it is returned as is.\n *\n * @param val - The value or function to wrap.\n * @returns A function that returns the value.\n */\nexport const thunk = <T>(val: T | (() => T)): (() => T) => {\n if (isFunction(val)) {\n return val;\n }\n return () => val;\n};\n\n/**\n * Unwraps a value from a thunk (a function that returns a value). If the\n * value is not a function, it is returned as is.\n *\n * @param val - The value or thunk to unwrap.\n * @returns The unwrapped value.\n */\nexport const unthunk = <T>(val: T | (() => T)): T => {\n if (isFunction(val)) {\n return val();\n }\n return val;\n};\n\n/**\n * A function that does nothing and returns nothing.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport const noop = (..._args: any[]): void => {};\n\n/**\n * A function that does nothing and returns `this`.\n */\nexport const noopThis = function <T>(this: T, ..._args: any[]): T {\n return this;\n};\n\n/**\n * A function that does nothing and returns a function that does nothing.\n */\nexport const noopNoop = (..._args: any[]): typeof noop => {\n return noop;\n};\n"],"names":["mimicFunction","assert","isFunction","memoizedFns","Set","MemoFirstArg","args","String","MemoAllArgs","map","join","memo","fnOrKeyFn","fn","keyFn","cache","Map","memoized","key","has","get","result","set","clear","bind","add","clearMemoized","debounce","delayMS","timerId","upcomingCall","debounced","undefined","clearTimeout","setTimeout","flush","thunk","val","unthunk","noop","_args","noopThis","noopNoop"],"mappings":"AAAA,qDAAqD,GACrD,6BAA6B,GAC7B,OAAOA,mBAAmB,WAAW;AACrC,OAAOC,YAAY,cAAc;AACjC,SAASC,UAAU,QAAQ,UAAU;AAGrC,MAAMC,cAAc,IAAIC;AAYxB;;;;CAIC,GACD,OAAO,MAAMC,eAAe,CAAC,GAAGC,OAAwBC,OAAOD,IAAI,CAAC,EAAE,EAAE;AAExE;;;;;CAKC,GACD,OAAO,MAAME,cAAc,CAAC,GAAGF,OAAwBA,KAAKG,GAAG,CAACF,QAAQG,IAAI,CAAC,KAAK;AA0BlF,+CAA+C;AAC/C,OAAO,SAASC,KACdC,SAAqB,EACrBC,EAAO;IAEP,IAAIC;IACJ,IAAID,IAAI;QACNC,QAAQF;IACV,OAAO;QACLC,KAAKD;QACLE,QAAQT;IACV;IAEA,MAAMU,QAAQ,IAAIC;IAElB,MAAMC,WAAY,CAAC,GAAGX;QACpB,MAAMY,MAAMJ,SAAUR;QACtB,IAAIS,MAAMI,GAAG,CAACD,MAAM;YAClB,OAAOH,MAAMK,GAAG,CAACF;QACnB;QAEAjB,OAAOY,IAAI;QACX,MAAMQ,SAASR,MAAMP;QACrBS,MAAMO,GAAG,CAACJ,KAAKG;QAEf,OAAOA;IACT;IAEAJ,SAASM,KAAK,GAAGR,MAAMQ,KAAK,CAACC,IAAI,CAACT;IAElCZ,YAAYsB,GAAG,CAACR;IAEhBjB,cAAciB,UAAUJ;IAExB,OAAOI;AACT;AAEA;;CAEC,GACD,OAAO,MAAMS,gBAAgB;IAC3B,KAAK,MAAMT,YAAYd,YAAa;QAClCc,SAASM,KAAK;IAChB;AACF,EAAE;AAYF;;;;;;;;CAQC,GACD,OAAO,MAAMI,WAAW,CAAyCC,SAAiBf;IAChF,IAAIgB;IACJ,IAAIC;IAEJ,MAAMC,YAAa,CAAC,GAAGzB;QACrBwB,eAAe;YACbA,eAAeE;YACfH,UAAUG;YACVnB,MAAMP;QACR;QAEA2B,aAAaJ;QACbA,UAAUK,WAAWJ,cAAcF;IACrC;IAEAG,UAAUI,KAAK,GAAG;QAChB,IAAIL,cAAc;YAChBA;QACF;IACF;IAEA9B,cAAc+B,WAAWlB;IAEzB,OAAOkB;AACT,EAAE;AAOF;;;;;;CAMC,GACD,OAAO,MAAMK,QAAQ,CAAIC;IACvB,IAAInC,WAAWmC,MAAM;QACnB,OAAOA;IACT;IACA,OAAO,IAAMA;AACf,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMC,UAAU,CAAID;IACzB,IAAInC,WAAWmC,MAAM;QACnB,OAAOA;IACT;IACA,OAAOA;AACT,EAAE;AAEF;;CAEC,GACD,gEAAgE;AAChE,OAAO,MAAME,OAAO,CAAC,GAAGC,SAAwB,EAAE;AAElD;;CAEC,GACD,OAAO,MAAMC,WAAW,SAAsB,GAAGD,KAAY;IAC3D,OAAO,IAAI;AACb,EAAE;AAEF;;CAEC,GACD,OAAO,MAAME,WAAW,CAAC,GAAGF;IAC1B,OAAOD;AACT,EAAE"}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* If the number is greater than the maximum value, the maximum value is returned.
|
|
17
17
|
* Otherwise, the number is returned as is.
|
|
18
18
|
*
|
|
19
|
-
* @param value The value to be clamped.
|
|
20
|
-
* @param min The minimum value of the range.
|
|
21
|
-
* @param max The maximum value of the range.
|
|
19
|
+
* @param value - The value to be clamped.
|
|
20
|
+
* @param min - The minimum value of the range.
|
|
21
|
+
* @param max - The maximum value of the range.
|
|
22
22
|
* @returns The clamped value.
|
|
23
23
|
*/ export const clamp = (value, min, max)=>{
|
|
24
24
|
return Math.max(min, Math.min(max, value));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/util/number.ts"],"sourcesContent":["/**\n * Parses a string value into a number. If the value is an invalid\n * number it returns {@linkcode defaultValue}.\n *\n * @param value - The string value to parse.\n * @returns The parsed number.\n */\nexport const parseNumber = (value: string | null | undefined, defaultValue = 0): number => {\n value ??= \"\";\n const parsed = Number.parseFloat(value);\n return Number.isNaN(parsed) ? defaultValue : parsed;\n};\n\n/**\n * Ensures that a number is within a given range.\n *\n * If the number is less than the minimum value, the minimum value is returned.\n * If the number is greater than the maximum value, the maximum value is returned.\n * Otherwise, the number is returned as is.\n *\n * @param value The value to be clamped.\n * @param min The minimum value of the range.\n * @param max The maximum value of the range.\n * @returns The clamped value.\n */\nexport const clamp = (value: number, min: number, max: number): number => {\n return Math.max(min, Math.min(max, value));\n};\n"],"names":["parseNumber","value","defaultValue","parsed","Number","parseFloat","isNaN","clamp","min","max","Math"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,cAAc,CAACC,OAAkCC,eAAe,CAAC;IAC5ED,UAAU;IACV,MAAME,SAASC,OAAOC,UAAU,CAACJ;IACjC,OAAOG,OAAOE,KAAK,CAACH,UAAUD,eAAeC;AAC/C,EAAE;AAEF;;;;;;;;;;;CAWC,GACD,OAAO,MAAMI,QAAQ,CAACN,OAAeO,KAAaC;IAChD,OAAOC,KAAKD,GAAG,CAACD,KAAKE,KAAKF,GAAG,CAACC,KAAKR;AACrC,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/services/util/number.ts"],"sourcesContent":["/**\n * Parses a string value into a number. If the value is an invalid\n * number it returns {@linkcode defaultValue}.\n *\n * @param value - The string value to parse.\n * @returns The parsed number.\n */\nexport const parseNumber = (value: string | null | undefined, defaultValue = 0): number => {\n value ??= \"\";\n const parsed = Number.parseFloat(value);\n return Number.isNaN(parsed) ? defaultValue : parsed;\n};\n\n/**\n * Ensures that a number is within a given range.\n *\n * If the number is less than the minimum value, the minimum value is returned.\n * If the number is greater than the maximum value, the maximum value is returned.\n * Otherwise, the number is returned as is.\n *\n * @param value - The value to be clamped.\n * @param min - The minimum value of the range.\n * @param max - The maximum value of the range.\n * @returns The clamped value.\n */\nexport const clamp = (value: number, min: number, max: number): number => {\n return Math.max(min, Math.min(max, value));\n};\n"],"names":["parseNumber","value","defaultValue","parsed","Number","parseFloat","isNaN","clamp","min","max","Math"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,cAAc,CAACC,OAAkCC,eAAe,CAAC;IAC5ED,UAAU;IACV,MAAME,SAASC,OAAOC,UAAU,CAACJ;IACjC,OAAOG,OAAOE,KAAK,CAACH,UAAUD,eAAeC;AAC/C,EAAE;AAEF;;;;;;;;;;;CAWC,GACD,OAAO,MAAMI,QAAQ,CAACN,OAAeO,KAAaC;IAChD,OAAOC,KAAKD,GAAG,CAACD,KAAKE,KAAKF,GAAG,CAACC,KAAKR;AACrC,EAAE"}
|
|
@@ -41,8 +41,8 @@ import { workspaceRoot } from "./paths.js";
|
|
|
41
41
|
/**
|
|
42
42
|
* Returns a new object with the specified keys omitted.
|
|
43
43
|
*
|
|
44
|
-
* @param record The input object.
|
|
45
|
-
* @param keys The keys to omit.
|
|
44
|
+
* @param record - The input object.
|
|
45
|
+
* @param keys - The keys to omit.
|
|
46
46
|
* @returns A new object with the specified keys omitted.
|
|
47
47
|
*/ export const omit = (record, keys)=>{
|
|
48
48
|
const result = {
|
|
@@ -58,8 +58,8 @@ import { workspaceRoot } from "./paths.js";
|
|
|
58
58
|
* Maps the values of an object to a new set of values using the
|
|
59
59
|
* provided function.
|
|
60
60
|
*
|
|
61
|
-
* @param obj The input object to map.
|
|
62
|
-
* @param fn The function to apply to each value in the input object.
|
|
61
|
+
* @param obj - The input object to map.
|
|
62
|
+
* @param fn - The function to apply to each value in the input object.
|
|
63
63
|
* @returns A new object with the same keys as the input object, but
|
|
64
64
|
* with the values mapped to new values using the provided function.
|
|
65
65
|
*/ export const mapValues = (obj, fn)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/util/object.ts"],"sourcesContent":["import cleanStack from \"clean-stack\";\nimport { RequestError } from \"got\";\nimport { inspect } from \"node:util\";\nimport { serializeError as baseSerializeError, type ErrorObject } from \"serialize-error\";\nimport type { Simplify } from \"type-fest\";\nimport { workspaceRoot } from \"./paths.js\";\n\n/**\n * Returns a new object with the properties of the input object merged\n * with the properties of the defaults object. If a property exists in\n * both objects, the property of the input object will be used.\n *\n * @param input - The input object to merge with the defaults object.\n * @param defaults - The defaults object to merge with the input object.\n * @returns A new object with the properties of the input object merged\n * with the properties of the defaults object.\n */\nexport const defaults = <Input extends Record<string, unknown>, Defaults extends Partial<Input>>(\n input: Input | null | undefined,\n defaults: Defaults,\n): Simplify<Defaults & Input> => {\n const result = { ...input };\n for (const [key, defaultValue] of Object.entries(defaults)) {\n if (!result[key]) {\n result[key] = defaultValue;\n }\n }\n return result as Simplify<Defaults & Input>;\n};\n\n/**\n * Creates a new object with only the specified properties of the\n * original object.\n *\n * @param object - The original object to pick properties from.\n * @param keys - The keys of the properties to pick.\n * @returns A new object with only the specified properties of the\n * original object.\n */\nexport const pick = <T extends Record<string, unknown>, K extends keyof T>(object: T, keys: readonly K[]): Pick<T, K> => {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n result[key] = object[key];\n }\n return result;\n};\n\n/**\n * Returns a new object with the specified keys omitted.\n *\n * @param record The input object.\n * @param keys The keys to omit.\n * @returns A new object with the specified keys omitted.\n */\nexport const omit = <T extends Record<string, unknown>, K extends keyof T>(record: T, keys: readonly K[]): Omit<T, K> => {\n const result = { ...record };\n for (const key of keys) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete result[key];\n }\n return result;\n};\n\n/**\n * Maps the values of an object to a new set of values using the\n * provided function.\n *\n * @param obj The input object to map.\n * @param fn The function to apply to each value in the input object.\n * @returns A new object with the same keys as the input object, but\n * with the values mapped to new values using the provided function.\n */\nexport const mapValues = <Key extends string | number | symbol, Value, MappedValue>(\n obj: Record<Key, Value>,\n fn: (value: Value) => MappedValue,\n): Record<Key, MappedValue> => {\n const result = {} as Record<Key, MappedValue>;\n for (const [key, value] of Object.entries(obj)) {\n result[key as Key] = fn(value as Value);\n }\n return result;\n};\n\n/**\n * Universal Error object to json blob serializer.\n *\n * Wraps `serialize-error` with some handy stuff, like special support\n * for Got HTTP errors\n */\nexport const serializeError = (error: unknown): ErrorObject => {\n if (Array.isArray(error) && error.length === 1) {\n error = error[0];\n }\n\n let serialized = baseSerializeError(Array.isArray(error) ? new AggregateError(error) : error);\n if (typeof serialized == \"string\") {\n serialized = { message: serialized };\n }\n\n if (serialized.stack) {\n serialized.stack = cleanStack(serialized.stack, { pretty: true, basePath: workspaceRoot }).replaceAll(/file:\\/\\/\\//g, \"\");\n }\n\n if (error instanceof RequestError) {\n serialized[\"timings\"] = undefined;\n serialized[\"options\"] = {\n method: error.options.method,\n url: error.options.url instanceof URL ? error.options.url.toJSON() : error.options.url,\n };\n serialized[\"responseBody\"] = inspect(error.response?.body);\n }\n\n return serialized;\n};\n"],"names":["cleanStack","RequestError","inspect","serializeError","baseSerializeError","workspaceRoot","defaults","input","result","key","defaultValue","Object","entries","pick","object","keys","omit","record","mapValues","obj","fn","value","error","Array","isArray","length","serialized","AggregateError","message","stack","pretty","basePath","replaceAll","undefined","method","options","url","URL","toJSON","response","body"],"mappings":"AAAA,OAAOA,gBAAgB,cAAc;AACrC,SAASC,YAAY,QAAQ,MAAM;AACnC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,kBAAkBC,kBAAkB,QAA0B,kBAAkB;AAEzF,SAASC,aAAa,QAAQ,aAAa;AAE3C;;;;;;;;;CASC,GACD,OAAO,MAAMC,WAAW,CACtBC,OACAD;IAEA,MAAME,SAAS;QAAE,GAAGD,KAAK;IAAC;IAC1B,KAAK,MAAM,CAACE,KAAKC,aAAa,IAAIC,OAAOC,OAAO,CAACN,UAAW;QAC1D,IAAI,CAACE,MAAM,CAACC,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AAGO;QACxBP,UAAU,CAAC,UAAU,GAAG;YACtBQ,QAAQZ,MAAMa,OAAO,CAACD,MAAM;YAC5BE,KAAKd,MAAMa,OAAO,CAACC,GAAG,YAAYC,MAAMf,MAAMa,OAAO,CAACC,GAAG,CAACE,MAAM,KAAKhB,MAAMa,OAAO,CAACC,GAAG;QACxF;QACAV,UAAU,CAAC,eAAe,GAAGxB,QAAQoB,MAAMiB,QAAQ,EAAEC;IACvD;IAEA,OAAOd;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/services/util/object.ts"],"sourcesContent":["import cleanStack from \"clean-stack\";\nimport { RequestError } from \"got\";\nimport { inspect } from \"node:util\";\nimport { serializeError as baseSerializeError, type ErrorObject } from \"serialize-error\";\nimport type { Simplify } from \"type-fest\";\nimport { workspaceRoot } from \"./paths.js\";\n\n/**\n * Returns a new object with the properties of the input object merged\n * with the properties of the defaults object. If a property exists in\n * both objects, the property of the input object will be used.\n *\n * @param input - The input object to merge with the defaults object.\n * @param defaults - The defaults object to merge with the input object.\n * @returns A new object with the properties of the input object merged\n * with the properties of the defaults object.\n */\nexport const defaults = <Input extends Record<string, unknown>, Defaults extends Partial<Input>>(\n input: Input | null | undefined,\n defaults: Defaults,\n): Simplify<Defaults & Input> => {\n const result = { ...input };\n for (const [key, defaultValue] of Object.entries(defaults)) {\n if (!result[key]) {\n result[key] = defaultValue;\n }\n }\n return result as Simplify<Defaults & Input>;\n};\n\n/**\n * Creates a new object with only the specified properties of the\n * original object.\n *\n * @param object - The original object to pick properties from.\n * @param keys - The keys of the properties to pick.\n * @returns A new object with only the specified properties of the\n * original object.\n */\nexport const pick = <T extends Record<string, unknown>, K extends keyof T>(object: T, keys: readonly K[]): Pick<T, K> => {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n result[key] = object[key];\n }\n return result;\n};\n\n/**\n * Returns a new object with the specified keys omitted.\n *\n * @param record - The input object.\n * @param keys - The keys to omit.\n * @returns A new object with the specified keys omitted.\n */\nexport const omit = <T extends Record<string, unknown>, K extends keyof T>(record: T, keys: readonly K[]): Omit<T, K> => {\n const result = { ...record };\n for (const key of keys) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete result[key];\n }\n return result;\n};\n\n/**\n * Maps the values of an object to a new set of values using the\n * provided function.\n *\n * @param obj - The input object to map.\n * @param fn - The function to apply to each value in the input object.\n * @returns A new object with the same keys as the input object, but\n * with the values mapped to new values using the provided function.\n */\nexport const mapValues = <Key extends string | number | symbol, Value, MappedValue>(\n obj: Record<Key, Value>,\n fn: (value: Value) => MappedValue,\n): Record<Key, MappedValue> => {\n const result = {} as Record<Key, MappedValue>;\n for (const [key, value] of Object.entries(obj)) {\n result[key as Key] = fn(value as Value);\n }\n return result;\n};\n\n/**\n * Universal Error object to json blob serializer.\n *\n * Wraps `serialize-error` with some handy stuff, like special support\n * for Got HTTP errors\n */\nexport const serializeError = (error: unknown): ErrorObject => {\n if (Array.isArray(error) && error.length === 1) {\n error = error[0];\n }\n\n let serialized = baseSerializeError(Array.isArray(error) ? new AggregateError(error) : error);\n if (typeof serialized == \"string\") {\n serialized = { message: serialized };\n }\n\n if (serialized.stack) {\n serialized.stack = cleanStack(serialized.stack, { pretty: true, basePath: workspaceRoot }).replaceAll(/file:\\/\\/\\//g, \"\");\n }\n\n if (error instanceof RequestError) {\n serialized[\"timings\"] = undefined;\n serialized[\"options\"] = {\n method: error.options.method,\n url: error.options.url instanceof URL ? error.options.url.toJSON() : error.options.url,\n };\n serialized[\"responseBody\"] = inspect(error.response?.body);\n }\n\n return serialized;\n};\n"],"names":["cleanStack","RequestError","inspect","serializeError","baseSerializeError","workspaceRoot","defaults","input","result","key","defaultValue","Object","entries","pick","object","keys","omit","record","mapValues","obj","fn","value","error","Array","isArray","length","serialized","AggregateError","message","stack","pretty","basePath","replaceAll","undefined","method","options","url","URL","toJSON","response","body"],"mappings":"AAAA,OAAOA,gBAAgB,cAAc;AACrC,SAASC,YAAY,QAAQ,MAAM;AACnC,SAAS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IK,eAAeL,SAASA;IACvF,IAAI,OAAOI,cAAc,UAAU;QACjCA,aAAa;YAAEE,SAASF;QAAW;IACrC;IAEA,IAAIA,WAAWG,KAAK,EAAE;QACpBH,WAAWG,KAAK,GAAG7B,WAAW0B,WAAWG,KAAK,EAAE;YAAEC,QAAQ;YAAMC,UAAU1B;QAAc,GAAG2B,UAAU,CAAC,gBAAgB;IACxH;IAEA,IAAIV,iBAAiBrB,cAAc;QACjCyB,UAAU,CAAC,UAAU,GAAGO;QACxBP,UAAU,CAAC,UAAU,GAAG;YACtBQ,QAAQZ,MAAMa,OAAO,CAACD,MAAM;YAC5BE,KAAKd,MAAMa,OAAO,CAACC,GAAG,YAAYC,MAAMf,MAAMa,OAAO,CAACC,GAAG,CAACE,MAAM,KAAKhB,MAAMa,OAAO,CAACC,GAAG;QACxF;QACAV,UAAU,CAAC,eAAe,GAAGxB,QAAQoB,MAAMiB,QAAQ,EAAEC;IACvD;IAEA,OAAOd;AACT,EAAE"}
|
|
@@ -3,18 +3,18 @@ import { fileURLToPath } from "node:url";
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns the filename of the current module.
|
|
5
5
|
*
|
|
6
|
-
* @returns
|
|
6
|
+
* @returns The filename of the current module.
|
|
7
7
|
*/ export const thisFilename = ()=>fileURLToPath(import.meta.url);
|
|
8
8
|
/**
|
|
9
9
|
* Returns the directory name of the current module.
|
|
10
10
|
*
|
|
11
|
-
* @returns
|
|
11
|
+
* @returns The directory name of the current module.
|
|
12
12
|
*/ export const thisDirname = ()=>path.dirname(thisFilename());
|
|
13
13
|
/**
|
|
14
14
|
* Returns a path relative to the current module.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns
|
|
16
|
+
* @param segments - The segments of the path.
|
|
17
|
+
* @returns The path relative to the current module.
|
|
18
18
|
*/ export const relativeToThisFile = (...segments)=>path.join(thisDirname(), ...segments);
|
|
19
19
|
/**
|
|
20
20
|
* The root directory of the ggt package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/util/paths.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Returns the filename of the current module.\n *\n * @returns
|
|
1
|
+
{"version":3,"sources":["../../../src/services/util/paths.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Returns the filename of the current module.\n *\n * @returns The filename of the current module.\n */\nexport const thisFilename = (): string => fileURLToPath(import.meta.url);\n\n/**\n * Returns the directory name of the current module.\n *\n * @returns The directory name of the current module.\n */\nexport const thisDirname = (): string => path.dirname(thisFilename());\n\n/**\n * Returns a path relative to the current module.\n *\n * @param segments - The segments of the path.\n * @returns The path relative to the current module.\n */\nexport const relativeToThisFile = (...segments: string[]): string => path.join(thisDirname(), ...segments);\n\n/**\n * The root directory of the ggt package.\n */\nexport const workspaceRoot = relativeToThisFile(\"../../../\");\n\n/**\n * Returns an absolute path within the ggt package.\n *\n * @param segments - The segments of the path to join.\n * @returns The absolute path to the file or directory.\n */\nexport const workspacePath = (...segments: string[]): string => path.join(workspaceRoot, ...segments);\n\n/**\n * Returns an absolute path within the `assets` directory of the ggt\n * package.\n *\n * @param segments - The segments of the path to join.\n * @returns The absolute path to the file or directory.\n */\nexport const assetsPath = (...segments: string[]): string => workspacePath(\"assets\", ...segments);\n"],"names":["path","fileURLToPath","thisFilename","url","thisDirname","dirname","relativeToThisFile","segments","join","workspaceRoot","workspacePath","assetsPath"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,SAASC,aAAa,QAAQ,WAAW;AAEzC;;;;CAIC,GACD,OAAO,MAAMC,eAAe,IAAcD,cAAc,YAAYE,GAAG,EAAE;AAEzE;;;;CAIC,GACD,OAAO,MAAMC,cAAc,IAAcJ,KAAKK,OAAO,CAACH,gBAAgB;AAEtE;;;;;CAKC,GACD,OAAO,MAAMI,qBAAqB,CAAC,GAAGC,WAA+BP,KAAKQ,IAAI,CAACJ,kBAAkBG,UAAU;AAE3G;;CAEC,GACD,OAAO,MAAME,gBAAgBH,mBAAmB,aAAa;AAE7D;;;;;CAKC,GACD,OAAO,MAAMI,gBAAgB,CAAC,GAAGH,WAA+BP,KAAKQ,IAAI,CAACC,kBAAkBF,UAAU;AAEtG;;;;;;CAMC,GACD,OAAO,MAAMI,aAAa,CAAC,GAAGJ,WAA+BG,cAAc,aAAaH,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/util/types.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/services/util/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Promisable, Simplify } from \"type-fest\";\n\n/**\n * Makes all properties of an object optional, except for the specified\n * properties.\n */\nexport type PartialExcept<T, K extends keyof T> = Simplify<Partial<T> & Pick<T, K>>;\n\n/**\n * Represents a function that can accept any number of arguments\n * and returns any value.\n */\nexport type AnyFunction = (...args: never[]) => unknown;\n\n/**\n * Represents void or Promise<void>.\n */\nexport type AnyVoid = Promisable<void>;\n\n/**\n * Returns all property names of an object whose values are functions.\n */\nexport type FunctionPropertyNames<T> = {\n [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n}[keyof T];\n\n/**\n * Returns the arguments of a function.\n */\nexport type ArgsType<T> = T extends (...args: infer A) => any ? A : never;\n"],"names":[],"mappings":"AAAA,qDAAqD,GA2BrD;;CAEC,GACD,WAA0E"}
|