Prettier u15

This commit is contained in:
Rory&
2025-12-17 09:58:25 +01:00
parent 9bf4e59301
commit 11973397c8
24 changed files with 548 additions and 547 deletions

View File

@@ -12,9 +12,9 @@
"build": "npm run build:src && npm run generate:schema && npm run generate:openapi",
"build:src": "tsc -b -v",
"build:watch": "tsc -w -b .",
"clean": "rm -rf dist/",
"clean": "rm -rf dist/",
"test": "node scripts/test.js",
"test:node": "node --test --enable-source-maps dist/**/*.test.js",
"test:node": "node --test --enable-source-maps dist/**/*.test.js",
"lint": "eslint .",
"setup": "npm run build && npm run generate:schema",
"sync:db": "npm run build && node scripts/syncronise.js",
@@ -22,7 +22,7 @@
"generate:schema": "node scripts/schema.js",
"generate:migration": "node --enable-source-maps -r dotenv/config -r module-alias/register node_modules/typeorm/cli.js migration:generate -d dist/util/util/Database.js",
"generate:openapi": "node scripts/openapi.js",
"generate:docs:envconfig": "node --enable-source-maps dist/renderEnvConfigSchema.js",
"generate:docs:envconfig": "node --enable-source-maps dist/renderEnvConfigSchema.js",
"add:license": "node scripts/license.js",
"migrate-from-staging": "node --enable-source-maps -r dotenv/config -r module-alias/register scripts/stagingMigration/index.js",
"node:tests": "npm run build:src && node --enable-source-maps -r dotenv/config -r module-alias/register --test --experimental-test-coverage dist/**/*.test.js",
@@ -133,4 +133,4 @@
"node-mailjet": "^6.0.11",
"nodemailer": "^7.0.11"
}
}
}

View File

@@ -1,15 +1,15 @@
{
"gateway": {
"endpointPublic": "ws://localhost:3001"
},
"cdn": {
"endpointPrivate": "http://localhost:3001",
"endpointPublic": "http://localhost:3001"
},
"api": {
"endpointPublic": "http://localhost:3001/api/v9/"
},
"rabbitmq": {
"host": null
}
}
"gateway": {
"endpointPublic": "ws://localhost:3001"
},
"cdn": {
"endpointPrivate": "http://localhost:3001",
"endpointPublic": "http://localhost:3001"
},
"api": {
"endpointPublic": "http://localhost:3001/api/v9/"
},
"rabbitmq": {
"host": null
}
}

View File

@@ -1,15 +1,15 @@
{
"api": {
"endpointPublic": "http://localhost:3001/api/v9/"
},
"cdn": {
"endpointPublic": "http://localhost:3003",
"endpointPrivate": "http://localhost:3003"
},
"gateway": {
"endpointPublic": "ws://localhost:3002"
},
"rabbitmq": {
"host": "amqp://guest:guest@localhost/"
}
}
"api": {
"endpointPublic": "http://localhost:3001/api/v9/"
},
"cdn": {
"endpointPublic": "http://localhost:3003",
"endpointPrivate": "http://localhost:3003"
},
"gateway": {
"endpointPublic": "ws://localhost:3002"
},
"rabbitmq": {
"host": "amqp://guest:guest@localhost/"
}
}

View File

@@ -114,12 +114,12 @@ const excludedLambdas = [
}
},
(n, s) => {
if (s.properties && Object.keys(s.properties).every(x=> x[0] === x[0].toUpperCase())) {
if (s.properties && Object.keys(s.properties).every((x) => x[0] === x[0].toUpperCase())) {
console.log(`\r${redBright("[WARN]")} Omitting schema ${n} as all its properties have uppercase characters.`);
exclusionList.auto.push({ value: n, reason: "Schema with only uppercase properties" });
return true;
}
}
},
// (n, s) => {
// if (JSON.stringify(s).length <= 300) {
// console.log({n, s});

View File

@@ -1,415 +1,409 @@
{
"include": [
"MessageInteractionSchema"
],
"includeRe": [
"^MessageComponentType\\..*"
],
"manual": [
"DefaultSchema",
"Schema",
"EntitySchema",
"ReadableStream<any>",
"SomeJSONSchema",
"UncheckedPartialSchema",
"PartialSchema",
"UncheckedPropertiesSchema",
"PropertiesSchema",
"AsyncSchema",
"AnySchema",
"SMTPConnection.CustomAuthenticationResponse",
"TransportMakeRequestResponse",
"StaticSchema",
"CSVImportResponse",
"NewMultipleMembersResponse",
"EventsResponse",
"NotificationAPIResponse",
"MetricsAPIResponse",
"ValidationResponse",
"MultipleValidationJobsListResponse",
"UpdateRouteResponse",
"MessagesSendAPIResponse",
"APIWebhook",
"WebhookResponse",
"WebhookValidationResponse",
"MessageResponse",
"ConnectionSettingsResponse",
"UpdatedDKIMSelectorResponse",
"UpdatedWebPrefixResponse",
"APIResponse",
"APIErrorOptions",
"APIErrorType",
"ListTagsForResourceResponse",
"GetContactResponse",
"LibraryResponse",
"LibraryLocalResponse",
"SchemaTraits",
"TraitsSchema",
"AbuseIpDbCheckResponse",
"IpDataIpLookupResponse"
],
"manualRe": [
".*\\.Response$",
"^(Http2Server|Server|Express|(Resolved|)Http|Client|_|)Response$",
".*\\..*",
"^Axios.*",
"^Internal",
"^Record<",
"^Omit<",
"^ListContact(s|Lists)Response$",
"^APIKeyConfiguration\\..*",
"^AccountSetting\\..*",
"^BulkContactManagement\\..*",
"^Campaign.*",
"^Contact.*",
"^DNS\\..*",
"^Delete.*",
"^Destroy.*",
"^Template\\..*",
"^Webhook\\..*",
"^(BigDecimal|BigInteger|Blob|Boolean|Document|Error|LazyRequest|List|Map|Normalized|Numeric|StreamingBlob|TimestampDateTime|TimestampHttpDate|TimestampEpochSeconds|Simple)Schema",
"^((Create|Update)Contact(|List))Response$",
"^(T|Unt)agResourceResponse$",
"^Put",
"^Inbox",
"^Seed",
"^DomainTag",
"^IpPool",
"DomainTemplate",
"^\\$",
"^Suppression",
"^Mail(|ing)List",
"DomainTracking",
"UpdatedDomain",
"ConfigurationSet",
"ContactList",
"^IPR",
"^Job"
],
"manualWarn": [],
"manualWarnRe": [
".*<.*>$"
],
"auto": [
{
"value": "StringSchema",
"reason": "AWS Smithy schema"
},
{
"value": "TimestampDefaultSchema",
"reason": "AWS Smithy schema"
},
{
"value": "StaticSimpleSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticListSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticMapSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticStructureSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticErrorSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticOperationSchema",
"reason": "Self-reference only schema"
},
{
"value": "UnitSchema",
"reason": "AWS Smithy schema"
},
{
"value": "MemberSchema",
"reason": "Self-reference only schema"
},
{
"value": "StructureSchema",
"reason": "Self-reference only schema"
},
{
"value": "OperationSchema",
"reason": "Self-reference only schema"
},
{
"value": "BatchGetMetricDataResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CancelExportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateCustomVerificationEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateDedicatedIpPoolResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateDeliverabilityTestReportResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateEmailIdentityResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateEmailIdentityPolicyResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateExportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateImportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateMultiRegionEndpointResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateTenantResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateTenantResourceAssociationResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetAccountResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetBlacklistReportsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetCustomVerificationEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDedicatedIpResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDedicatedIpPoolResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDedicatedIpsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDeliverabilityDashboardOptionsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDeliverabilityTestReportResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDomainDeliverabilityCampaignResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDomainStatisticsReportResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetEmailIdentityResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetEmailIdentityPoliciesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetExportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetImportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetMessageInsightsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetMultiRegionEndpointResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetReputationEntityResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetSuppressedDestinationResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetTenantResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListCustomVerificationEmailTemplatesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListDedicatedIpPoolsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListDeliverabilityTestReportsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListDomainDeliverabilityCampaignsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListEmailIdentitiesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListEmailTemplatesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListExportJobsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListImportJobsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListMultiRegionEndpointsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListRecommendationsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListReputationEntitiesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListResourceTenantsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListSuppressedDestinationsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListTenantResourcesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListTenantsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "SendBulkEmailResponse",
"reason": "HTML paragraph in description"
},
{
"value": "SendCustomVerificationEmailResponse",
"reason": "HTML paragraph in description"
},
{
"value": "SendEmailResponse",
"reason": "HTML paragraph in description"
},
{
"value": "TestRenderEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateCustomVerificationEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateEmailIdentityPolicyResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateReputationEntityCustomerManagedStatusResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateReputationEntityPolicyResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdatedDKIMAuthorityResponse",
"reason": "Uses import()"
},
{
"value": "ListRecipientResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "TemplateResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "TemplateDetailContentResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "EventCallbackUrlResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "ParseRouteResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "SenderResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "MetaSenderResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "ApiKeyResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "MyProfileResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "UserResponse",
"reason": "Schema with only uppercase properties"
}
]
}
"include": ["MessageInteractionSchema"],
"includeRe": ["^MessageComponentType\\..*"],
"manual": [
"DefaultSchema",
"Schema",
"EntitySchema",
"ReadableStream<any>",
"SomeJSONSchema",
"UncheckedPartialSchema",
"PartialSchema",
"UncheckedPropertiesSchema",
"PropertiesSchema",
"AsyncSchema",
"AnySchema",
"SMTPConnection.CustomAuthenticationResponse",
"TransportMakeRequestResponse",
"StaticSchema",
"CSVImportResponse",
"NewMultipleMembersResponse",
"EventsResponse",
"NotificationAPIResponse",
"MetricsAPIResponse",
"ValidationResponse",
"MultipleValidationJobsListResponse",
"UpdateRouteResponse",
"MessagesSendAPIResponse",
"APIWebhook",
"WebhookResponse",
"WebhookValidationResponse",
"MessageResponse",
"ConnectionSettingsResponse",
"UpdatedDKIMSelectorResponse",
"UpdatedWebPrefixResponse",
"APIResponse",
"APIErrorOptions",
"APIErrorType",
"ListTagsForResourceResponse",
"GetContactResponse",
"LibraryResponse",
"LibraryLocalResponse",
"SchemaTraits",
"TraitsSchema",
"AbuseIpDbCheckResponse",
"IpDataIpLookupResponse"
],
"manualRe": [
".*\\.Response$",
"^(Http2Server|Server|Express|(Resolved|)Http|Client|_|)Response$",
".*\\..*",
"^Axios.*",
"^Internal",
"^Record<",
"^Omit<",
"^ListContact(s|Lists)Response$",
"^APIKeyConfiguration\\..*",
"^AccountSetting\\..*",
"^BulkContactManagement\\..*",
"^Campaign.*",
"^Contact.*",
"^DNS\\..*",
"^Delete.*",
"^Destroy.*",
"^Template\\..*",
"^Webhook\\..*",
"^(BigDecimal|BigInteger|Blob|Boolean|Document|Error|LazyRequest|List|Map|Normalized|Numeric|StreamingBlob|TimestampDateTime|TimestampHttpDate|TimestampEpochSeconds|Simple)Schema",
"^((Create|Update)Contact(|List))Response$",
"^(T|Unt)agResourceResponse$",
"^Put",
"^Inbox",
"^Seed",
"^DomainTag",
"^IpPool",
"DomainTemplate",
"^\\$",
"^Suppression",
"^Mail(|ing)List",
"DomainTracking",
"UpdatedDomain",
"ConfigurationSet",
"ContactList",
"^IPR",
"^Job"
],
"manualWarn": [],
"manualWarnRe": [".*<.*>$"],
"auto": [
{
"value": "StringSchema",
"reason": "AWS Smithy schema"
},
{
"value": "TimestampDefaultSchema",
"reason": "AWS Smithy schema"
},
{
"value": "StaticSimpleSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticListSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticMapSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticStructureSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticErrorSchema",
"reason": "Self-reference only schema"
},
{
"value": "StaticOperationSchema",
"reason": "Self-reference only schema"
},
{
"value": "UnitSchema",
"reason": "AWS Smithy schema"
},
{
"value": "MemberSchema",
"reason": "Self-reference only schema"
},
{
"value": "StructureSchema",
"reason": "Self-reference only schema"
},
{
"value": "OperationSchema",
"reason": "Self-reference only schema"
},
{
"value": "BatchGetMetricDataResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CancelExportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateCustomVerificationEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateDedicatedIpPoolResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateDeliverabilityTestReportResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateEmailIdentityResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateEmailIdentityPolicyResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateExportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateImportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateMultiRegionEndpointResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateTenantResponse",
"reason": "HTML paragraph in description"
},
{
"value": "CreateTenantResourceAssociationResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetAccountResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetBlacklistReportsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetCustomVerificationEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDedicatedIpResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDedicatedIpPoolResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDedicatedIpsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDeliverabilityDashboardOptionsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDeliverabilityTestReportResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDomainDeliverabilityCampaignResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetDomainStatisticsReportResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetEmailIdentityResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetEmailIdentityPoliciesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetExportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetImportJobResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetMessageInsightsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetMultiRegionEndpointResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetReputationEntityResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetSuppressedDestinationResponse",
"reason": "HTML paragraph in description"
},
{
"value": "GetTenantResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListCustomVerificationEmailTemplatesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListDedicatedIpPoolsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListDeliverabilityTestReportsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListDomainDeliverabilityCampaignsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListEmailIdentitiesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListEmailTemplatesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListExportJobsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListImportJobsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListMultiRegionEndpointsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListRecommendationsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListReputationEntitiesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListResourceTenantsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListSuppressedDestinationsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListTenantResourcesResponse",
"reason": "HTML paragraph in description"
},
{
"value": "ListTenantsResponse",
"reason": "HTML paragraph in description"
},
{
"value": "SendBulkEmailResponse",
"reason": "HTML paragraph in description"
},
{
"value": "SendCustomVerificationEmailResponse",
"reason": "HTML paragraph in description"
},
{
"value": "SendEmailResponse",
"reason": "HTML paragraph in description"
},
{
"value": "TestRenderEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateCustomVerificationEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateEmailIdentityPolicyResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateEmailTemplateResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateReputationEntityCustomerManagedStatusResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdateReputationEntityPolicyResponse",
"reason": "HTML paragraph in description"
},
{
"value": "UpdatedDKIMAuthorityResponse",
"reason": "Uses import()"
},
{
"value": "ListRecipientResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "TemplateResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "TemplateDetailContentResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "EventCallbackUrlResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "ParseRouteResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "SenderResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "MetaSenderResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "ApiKeyResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "MyProfileResponse",
"reason": "Schema with only uppercase properties"
},
{
"value": "UserResponse",
"reason": "Schema with only uppercase properties"
}
]
}

View File

@@ -19,7 +19,8 @@
import { handleMessage, postHandleMessage, route } from "@spacebar/api";
import {
Attachment,
AutomodExecutor, AutomodInvocation,
AutomodExecutor,
AutomodInvocation,
AutomodRule,
AutomodTriggerTypes,
Channel,
@@ -443,13 +444,15 @@ router.post(
// @ts-ignore
message.member.roles = message.member.roles.filter((x) => x.id != x.guild_id).map((x) => x.id);
const automodResult = await AutomodExecutor.executeInvocation(new AutomodInvocation({
eventType: AutomodRuleEventType.MESSAGE_SEND,
guildId: message.guild_id,
payload: message
}));
const automodResult = await AutomodExecutor.executeInvocation(
new AutomodInvocation({
eventType: AutomodRuleEventType.MESSAGE_SEND,
guildId: message.guild_id,
payload: message,
}),
);
if(automodResult.blocked) {
if (automodResult.blocked) {
throw new HTTPError("Unhandled error sending message", 403);
}
}

View File

@@ -137,8 +137,7 @@ async function patchUserSettings(userId: string, updatedSettings: PreloadedUserS
};
}
if (EnvConfig.get().logging.logProtoUpdates.includes("SETTINGS"))
console.log(`Updating user settings for user ${userId} with atomic=${atomic}:`, updatedSettings);
if (EnvConfig.get().logging.logProtoUpdates.includes("SETTINGS")) console.log(`Updating user settings for user ${userId} with atomic=${atomic}:`, updatedSettings);
if (!atomic) {
settings = PreloadedUserSettings.fromJson(

View File

@@ -137,8 +137,7 @@ async function patchUserSettings(userId: string, updatedSettings: FrecencyUserSe
};
}
if (EnvConfig.get().logging.logProtoUpdates.includes("FRECENCY"))
console.log(`Updating frecency settings for user ${userId} with atomic=${atomic}:`, updatedSettings);
if (EnvConfig.get().logging.logProtoUpdates.includes("FRECENCY")) console.log(`Updating frecency settings for user ${userId} with atomic=${atomic}:`, updatedSettings);
if (!atomic) {
settings = FrecencyUserSettings.fromJson(

View File

@@ -33,7 +33,7 @@ export interface Storage {
let storage: Storage;
if (EnvConfig.get().cdn.storageProvider === "file" || !EnvConfig.get().cdn.storageProvider ) {
if (EnvConfig.get().cdn.storageProvider === "file" || !EnvConfig.get().cdn.storageProvider) {
let location = EnvConfig.get().cdn.storageLocation;
if (location) {
location = path.resolve(location);

View File

@@ -79,18 +79,11 @@ export async function Connection(this: WS.Server, socket: WebSocket, request: In
console.log(`[Gateway] New connection from ${ipAddress}, total ${this.clients.size}`);
if (EnvConfig.get().logging.gatewayLogging.logHttp)
[
"close",
"error",
"upgrade",
"open",
"ping",
"pong",
"unexpected-response",
...(EnvConfig.get().logging.gatewayLogging.logHttpMessages ? ["message"] : []),
].forEach((x) => {
socket.on(x, (y) => console.log(x, y));
});
["close", "error", "upgrade", "open", "ping", "pong", "unexpected-response", ...(EnvConfig.get().logging.gatewayLogging.logHttpMessages ? ["message"] : [])].forEach(
(x) => {
socket.on(x, (y) => console.log(x, y));
},
);
const { searchParams } = new URL(`http://localhost${request.url}`);
// @ts-ignore

View File

@@ -728,5 +728,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
const setupListenerTime = Date.now();
console.log(`[Gateway] IDENTIFY ${this.user_id} in ${totalSw.elapsed().totalMilliseconds}ms`, EnvConfig.get().logging.gatewayLogging.logTraces ? JSON.stringify(d._trace, null, 2) : "");
console.log(
`[Gateway] IDENTIFY ${this.user_id} in ${totalSw.elapsed().totalMilliseconds}ms`,
EnvConfig.get().logging.gatewayLogging.logTraces ? JSON.stringify(d._trace, null, 2) : "",
);
}

View File

@@ -12,16 +12,16 @@ const schema = EnvConfig.schema();
const keyMap = [
{
name: "Name",
selector: (v: {key: string}) => v.key
selector: (v: { key: string }) => v.key,
},
{
name: "Value",
selector: (v: {type: string}) => v.type
selector: (v: { type: string }) => v.type,
},
{
name: "Description",
selector: (v: {description: string}) => v.description
}
selector: (v: { description: string }) => v.description,
},
];
// --- separators
const startOfLine = dim("| "); // <tr>
@@ -32,7 +32,7 @@ const headSeparator = dim("-");
const pad = true;
// --- do not touch
const colWidths: {[key: string]: number} = {};
const colWidths: { [key: string]: number } = {};
console.log(bgRedBright("Calculating column widths"));
for (const key of keyMap) {
@@ -72,4 +72,4 @@ for (const entry of schema) {
process.stdout.write(cell);
}
process.stdout.write(endOfLine);
}
}

View File

@@ -55,7 +55,9 @@ export class AutomodExecutor {
result = await this.executeMemberInvocation();
} else throw new Error("Unsupported automod invocation type");
console.log(`[Automod] Executed automod invocation of type ${invocation.eventType} in ${Date.now() - startTime}ms with ${matchingRules.length} matching rules. Result: ${result.blocked ? "blocked" : "allowed"}`);
console.log(
`[Automod] Executed automod invocation of type ${invocation.eventType} in ${Date.now() - startTime}ms with ${matchingRules.length} matching rules. Result: ${result.blocked ? "blocked" : "allowed"}`,
);
return result;
}

View File

@@ -19,7 +19,6 @@ export async function internalExecuteMessageAutomod(context: AutomodMessageInvoc
}
let triggered = false;
// if (rule.trigger_type == AutomodRuleTriggerType.KEYWORD)
}
return result;

View File

@@ -1 +1 @@
export * from './AutomodExecutor';
export * from "./AutomodExecutor";

View File

@@ -20,21 +20,24 @@ import { arrayOrderBy } from "@spacebar/util";
export class ConfigurationEnvConfiguration {
static get schema() {
return arrayOrderBy([
{ key: "CONFIG_PATH", type: "string", description: "Path to a JSON file containing configuration data" },
{ key: "CONFIG_WRITEBACK", type: "boolean", description: "Whether to write back configuration changes to the specified JSON file" },
{
key: "CONFIG_MODE",
type: "string",
description:
"How to treat the JSON config.<br/>" +
"<ul>" +
"<li>**`override`**: Apply overrides without saving</li>" +
"<li>**`overwrite`**: Apply overrides, saving changes to the database</li>" +
"<li>**`single`**: Ignore database config outright</li>" +
"</ul>",
},
], (e) => e.key);
return arrayOrderBy(
[
{ key: "CONFIG_PATH", type: "string", description: "Path to a JSON file containing configuration data" },
{ key: "CONFIG_WRITEBACK", type: "boolean", description: "Whether to write back configuration changes to the specified JSON file" },
{
key: "CONFIG_MODE",
type: "string",
description:
"How to treat the JSON config.<br/>" +
"<ul>" +
"<li>**`override`**: Apply overrides without saving</li>" +
"<li>**`overwrite`**: Apply overrides, saving changes to the database</li>" +
"<li>**`single`**: Ignore database config outright</li>" +
"</ul>",
},
],
(e) => e.key,
);
}
get enabled(): boolean {

View File

@@ -27,7 +27,8 @@ export class DatabaseEnvConfiguration {
{
key: "DB_UNSAFE_SCHEMA_SYNC",
type: "boolean",
description: "If true, the database schema will be forcibly synchronised. This is unsafe for production environments. **We claim no responsibility for data loss!**",
description:
"If true, the database schema will be forcibly synchronised. This is unsafe for production environments. **We claim no responsibility for data loss!**",
},
{
key: "DB_DISABLE_JOINS",
@@ -37,7 +38,7 @@ export class DatabaseEnvConfiguration {
];
}
get url(): (string | undefined) {
get url(): string | undefined {
return process.env.DATABASE;
}

View File

@@ -30,23 +30,34 @@ interface GatewayLoggingConfigValue {
export class LogEnvConfiguration {
static get schema() {
return arrayOrderBy([
{ key: "LOG_CDN_SIGNATURES", type: "boolean", description: "Log CDN attachment signature checks - very noisy!" },
{ key: "LOG_DATABASE_QUERIES", type: "boolean", description: "Enable logging of database queries." },
{ key: "LOG_GATEWAY_EVENTS", type: "boolean", description: "Comma-separated list of flags. Any of: `TRACES`, `USER_ID`, `SESSION_ID`, `PAYLOAD`, `HTTP`, `HTTP_MESSAGES`." },
{ key: "LOG_WEBRTC_EVENTS", type: "boolean", description: "Comma-separated list of flags. Any of: `TRACES`, `USER_ID`, `SESSION_ID`, `PAYLOAD`, `HTTP`, `HTTP_MESSAGES`." },
{ key: "DUMP_GATEWAY_EVENT_PATH", type: "string", description: "Path to dump gateway events." },
{ key: "DUMP_WEBRTC_EVENT_PATH", type: "string", description: "Path to dump gateway events." },
{ key: "LOG_PROTO_UPDATES", type: "boolean or string", description: "`true`, or a list of proto schemas to log (`SETTINGS`, `FRECENCY`)" },
{
key: "LOG_REQUESTS",
type: "string",
description: "Comma-separated list of requests to log by status code. Negated with a leading `-`. Example: `-204` (log everything except 204 No Content)",
},
{ key: "LOG_AUTHENTICATION", type: "boolean", description: "Log authentication debug messages - very noisy!" },
{ key: "LOG_VALIDATION_ERRORS", type: "boolean", description: "Enable logging of validation errors." },
{ key: "LOG_IMPORT_ERRORS", type: "boolean", description: "Enable logging of import errors." },
], (e) => e.key);
return arrayOrderBy(
[
{ key: "LOG_CDN_SIGNATURES", type: "boolean", description: "Log CDN attachment signature checks - very noisy!" },
{ key: "LOG_DATABASE_QUERIES", type: "boolean", description: "Enable logging of database queries." },
{
key: "LOG_GATEWAY_EVENTS",
type: "boolean",
description: "Comma-separated list of flags. Any of: `TRACES`, `USER_ID`, `SESSION_ID`, `PAYLOAD`, `HTTP`, `HTTP_MESSAGES`.",
},
{
key: "LOG_WEBRTC_EVENTS",
type: "boolean",
description: "Comma-separated list of flags. Any of: `TRACES`, `USER_ID`, `SESSION_ID`, `PAYLOAD`, `HTTP`, `HTTP_MESSAGES`.",
},
{ key: "DUMP_GATEWAY_EVENT_PATH", type: "string", description: "Path to dump gateway events." },
{ key: "DUMP_WEBRTC_EVENT_PATH", type: "string", description: "Path to dump gateway events." },
{ key: "LOG_PROTO_UPDATES", type: "boolean or string", description: "`true`, or a list of proto schemas to log (`SETTINGS`, `FRECENCY`)" },
{
key: "LOG_REQUESTS",
type: "string",
description: "Comma-separated list of requests to log by status code. Negated with a leading `-`. Example: `-204` (log everything except 204 No Content)",
},
{ key: "LOG_AUTHENTICATION", type: "boolean", description: "Log authentication debug messages - very noisy!" },
{ key: "LOG_VALIDATION_ERRORS", type: "boolean", description: "Enable logging of validation errors." },
{ key: "LOG_IMPORT_ERRORS", type: "boolean", description: "Enable logging of import errors." },
],
(e) => e.key,
);
}
get gatewayLogging(): GatewayLoggingConfigValue {
@@ -96,9 +107,7 @@ export class LogEnvConfiguration {
logTraces: envVal?.includes("TRACES") || logDeprecated("LOG_WEBRTC_TRACES", "LOG_WEBRTC_EVENTS=TRACES") === "true",
logUserId: envVal?.includes("USER_ID") ?? false,
logSessionId: envVal?.includes("SESSION_ID") ?? false,
logPayload:
envVal?.includes("PAYLOAD") ||
logDeprecated("WRTC_WS_VERBOSE", "LOG_WEBRTC_EVENTS=PAYLOAD") === "true",
logPayload: envVal?.includes("PAYLOAD") || logDeprecated("WRTC_WS_VERBOSE", "LOG_WEBRTC_EVENTS=PAYLOAD") === "true",
logHttp: envVal?.includes("HTTP") ?? false,
logHttpMessages: envVal?.includes("HTTP_MESSAGES") ?? false,
};
@@ -111,7 +120,7 @@ export class LogEnvConfiguration {
}
get dumpGatewayEventPath(): string | undefined {
if(process.env.DUMP_GATEWAY_EVENT_PATH !== undefined) return process.env.DUMP_GATEWAY_EVENT_PATH;
if (process.env.DUMP_GATEWAY_EVENT_PATH !== undefined) return process.env.DUMP_GATEWAY_EVENT_PATH;
if (process.env.WS_DUMP !== undefined) {
console.warn("[EnvConfig] WS_DUMP is deprecated. Please use DUMP_GATEWAY_EVENT_PATH=./dump instead.");
return process.env.WS_DUMP ? "dump" : undefined;
@@ -119,7 +128,7 @@ export class LogEnvConfiguration {
}
get dumpWebrtcEventPath(): string | undefined {
if(process.env.DUMP_WEBRTC_EVENT_PATH !== undefined) return process.env.DUMP_WEBRTC_EVENT_PATH;
if (process.env.DUMP_WEBRTC_EVENT_PATH !== undefined) return process.env.DUMP_WEBRTC_EVENT_PATH;
if (process.env.WRTC_DUMP !== undefined) {
console.warn("[EnvConfig] WRTC_DUMP is deprecated. Please use DUMP_WEBRTC_EVENT_PATH=./dump_wrtc instead.");
return process.env.WRTC_DUMP ? "dump_wrtc" : undefined;

View File

@@ -20,12 +20,19 @@ import { arrayOrderBy } from "@spacebar/util";
export class WebRtcEnvConfiguration {
static get schema() {
return arrayOrderBy([
{ key: "WRTC_PUBLIC_IP", type: "string", description: "Public IP of the server running the media server" },
{ key: "WRTC_PORT_MIN", type: "number", description: "Minimum port for WebRTC media server" },
{ key: "WRTC_PORT_MAX", type: "number", description: "Maximum port for WebRTC media server" },
{ key: "WRTC_LIBRARY", type: "string", description: "WebRTC library to use. One of `@spacebarchat/medooze-webrtc` (voice+video) or `@spacebarchat/mediasoup-webrtc` (voice only)" },
], (e) => e.key);
return arrayOrderBy(
[
{ key: "WRTC_PUBLIC_IP", type: "string", description: "Public IP of the server running the media server" },
{ key: "WRTC_PORT_MIN", type: "number", description: "Minimum port for WebRTC media server" },
{ key: "WRTC_PORT_MAX", type: "number", description: "Maximum port for WebRTC media server" },
{
key: "WRTC_LIBRARY",
type: "string",
description: "WebRTC library to use. One of `@spacebarchat/medooze-webrtc` (voice+video) or `@spacebarchat/mediasoup-webrtc` (voice only)",
},
],
(e) => e.key,
);
}
get publicIp(): string {

View File

@@ -28,4 +28,4 @@ export * from "./imports";
export * from "./config";
export * from "./connections";
export * from "./Signing";
export * from "./automod";
export * from "./automod";

View File

@@ -49,7 +49,7 @@ export type UserTokenData = {
};
function logAuth(text: string) {
if(!EnvConfig.get().logging.logAuthentication) return;
if (!EnvConfig.get().logging.logAuthentication) return;
console.log(`[AUTH] ${text}`);
}

View File

@@ -32,7 +32,6 @@ export function arrayPartition<T>(array: T[], filter: (elem: T) => boolean): [T[
return [pass, fail];
}
export function arrayRemove<T>(array: T[], item: T): void {
const index = array.indexOf(item);
if (index > -1) {
@@ -62,4 +61,4 @@ export function arrayOrderByDescending<T>(array: T[], keySelector: (elem: T) =>
if (keyA < keyB) return 1;
return 0;
});
}
}

View File

@@ -36,18 +36,11 @@ export async function Connection(this: WS.Server, socket: WebRtcWebSocket, reque
console.log("[WebRTC] new connection", request.url);
if (EnvConfig.get().logging.gatewayLogging.logHttp) {
[
"close",
"error",
"upgrade",
"open",
"ping",
"pong",
"unexpected-response",
...(EnvConfig.get().logging.gatewayLogging.logHttpMessages ? ["message"] : []),
].forEach((x) => {
socket.on(x, (y) => console.log("[WebRTC]", x, y));
});
["close", "error", "upgrade", "open", "ping", "pong", "unexpected-response", ...(EnvConfig.get().logging.gatewayLogging.logHttpMessages ? ["message"] : [])].forEach(
(x) => {
socket.on(x, (y) => console.log("[WebRTC]", x, y));
},
);
}
const { searchParams } = new URL(`http://localhost${request.url}`);

View File

@@ -24,10 +24,7 @@ export async function Send(socket: WebRtcWebSocket, data: VoicePayload) {
await fs.mkdir(path.join(dumpPath!, id), {
recursive: true,
});
await fs.writeFile(
path.join(dumpPath!, id, `${Date.now()}.out.json`),
JSON.stringify(data, null, 2),
);
await fs.writeFile(path.join(dumpPath!, id, `${Date.now()}.out.json`), JSON.stringify(data, null, 2));
}
let buffer: Buffer | string;