-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fec6723
commit e895b76
Showing
154 changed files
with
4,420 additions
and
2,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"eslint.validate": ["typescript"], | ||
"eslint.validate": [ | ||
"typescript" | ||
], | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit", | ||
"source.fixAll": "explicit" | ||
} | ||
} | ||
|
||
}, | ||
"cSpell.words": [ | ||
"fontsource", | ||
"LIGHTGRAY", | ||
"nadabot", | ||
"naxios", | ||
"Roboto", | ||
"SHADOWGRAY", | ||
"Snackbars", | ||
"Subtractor", | ||
"Unflag", | ||
"uuidv4", | ||
"wpdas", | ||
"zustand" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
assets/icons/nadabot-logo.tsx → common/assets/icons/nadabot-logo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
utils/getNearSocialProfileAvatarImage.ts → ...on/lib/getNearSocialProfileAvatarImage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
utils/insertIsHumanToProvider.ts → common/lib/insertIsHumanToProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Temporal } from "temporal-polyfill"; | ||
|
||
/** | ||
* Converts a value in milliseconds to the equivalent number of days. | ||
* | ||
* @param {number | string | null} value - The value to convert, | ||
* which can be a number of milliseconds, a string representing a number of milliseconds, or null. | ||
* | ||
* @return {number} The number of days equivalent to the input value. | ||
* @throws {TypeError} If the input value cannot be converted to a number of milliseconds. | ||
*/ | ||
export const millisecondsToDays = (value: number | string | null): number => { | ||
try { | ||
return Temporal.Duration.from({ | ||
milliseconds: typeof value === "string" ? parseInt(value) : value ?? 0, | ||
}).total("days"); | ||
} catch { | ||
const error = new TypeError(`Unable to convert \`${value}\` to days`); | ||
|
||
console.error(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
/** | ||
* Converts a value in days to the equivalent number of milliseconds. | ||
* | ||
* @param {number | string | null} value - The value to convert, | ||
* which can be a number of days, a string representing a number of days, or null. | ||
* | ||
* @return {number} The number of milliseconds equivalent to the input value. | ||
* @throws {TypeError} If the input value cannot be converted to a number of milliseconds. | ||
*/ | ||
export const daysToMilliseconds = (value: number | string | null): number => { | ||
try { | ||
return Temporal.Duration.from({ | ||
days: typeof value === "string" ? parseInt(value) : value ?? 0, | ||
}).total("milliseconds"); | ||
} catch { | ||
const error = new TypeError( | ||
`Unable to convert \`${value}\` to milliseconds`, | ||
); | ||
|
||
console.error(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const daysSinceTimestamp = (unixTimestampMs: number) => | ||
Temporal.Now.instant().since( | ||
Temporal.Instant.fromEpochMilliseconds(unixTimestampMs), | ||
).days; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
services/contracts/social/index.ts → common/services/contracts/social/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
common/services/contracts/sybil.nadabot/interfaces/groups.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { ProviderId } from "./providers"; | ||
|
||
export type GroupId = number; | ||
|
||
export enum RulePrimitiveType { | ||
Highest = "Highest", | ||
Lowest = "Lowest", | ||
} | ||
|
||
export enum RuleGenericType { | ||
Sum = "Sum", | ||
DiminishingReturns = "DiminishingReturns", | ||
IncreasingReturns = "IncreasingReturns", | ||
} | ||
|
||
export type RuleType = | ||
| keyof typeof RulePrimitiveType | ||
| keyof typeof RuleGenericType; | ||
|
||
export type Rule = | ||
| keyof typeof RulePrimitiveType | ||
| { | ||
/** Sum all scores with optional max value */ | ||
[RuleGenericType.Sum]: number | null | undefined; | ||
} | ||
| { | ||
/** Sum with diminishing returns, factor in percentage (e.g., 10 for 10% reduction each) */ | ||
[RuleGenericType.DiminishingReturns]: number; | ||
} | ||
| { | ||
/** Sum with increasing returns, factor in percentage (e.g., 10 for 10% increase each) */ | ||
[RuleGenericType.IncreasingReturns]: number; | ||
}; | ||
|
||
export type Group = { | ||
name: string; | ||
rule: Rule; | ||
}; | ||
|
||
export type GroupExternal = Group & { | ||
id: GroupId; | ||
providers: ProviderId[]; | ||
}; | ||
|
||
export interface GroupById { | ||
group_id: GroupId; | ||
} | ||
|
||
export interface CreateGroup extends Pick<GroupExternal, "rule" | "providers"> { | ||
group_name: GroupExternal["name"]; | ||
} | ||
|
||
export interface UpdateGroup | ||
extends GroupById, | ||
Partial<Pick<GroupExternal, "rule" | "providers">> { | ||
group_name?: GroupExternal["name"]; | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.