From a85f6d5e69e85ef543f67fe6334963da12cb81a5 Mon Sep 17 00:00:00 2001 From: KevinJOH <13-11007@usb.ve> Date: Wed, 9 Oct 2024 22:56:03 -0400 Subject: [PATCH 1/7] traducir src-groups-join-a-ts --- src/groups/join.ts | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/groups/join.ts diff --git a/src/groups/join.ts b/src/groups/join.ts new file mode 100644 index 0000000000..9fa9469373 --- /dev/null +++ b/src/groups/join.ts @@ -0,0 +1,108 @@ +'use strict'; + +import * as winston from 'winston'; +import * as db from '../database'; +import * as user from '../user'; +import * as plugins from '../plugins'; +import * as cache from '../cache'; + +export default function (Groups: any) { + Groups.join = async function (groupNames: string | string[], uid: string): Promise { + if (!groupNames) { + throw new Error('[[error:invalid-data]]'); + } + if (Array.isArray(groupNames) && !groupNames.length) { + return; + } + if (!Array.isArray(groupNames)) { + groupNames = [groupNames]; + } + + if (!uid) { + throw new Error('[[error:invalid-uid]]'); + } + + const [isMembers, exists, isAdmin] = await Promise.all([ + Groups.isMemberOfGroups(uid, groupNames), + Groups.exists(groupNames), + user.isAdministrator(uid), + ]); + + const groupsToCreate = groupNames.filter((groupName, index) => groupName && !exists[index]); + const groupsToJoin = groupNames.filter((groupName, index) => !isMembers[index]); + + if (!groupsToJoin.length) { + return; + } + await createNonExistingGroups(groupsToCreate); + + const promises = [ + db.sortedSetsAdd(groupsToJoin.map(groupName => `group:${groupName}:members`), Date.now(), uid), + db.incrObjectField(groupsToJoin.map(groupName => `group:${groupName}`), 'memberCount'), + ]; + if (isAdmin) { + promises.push(db.setsAdd(groupsToJoin.map(groupName => `group:${groupName}:owners`), uid)); + } + + await Promise.all(promises); + + Groups.clearCache(uid, groupsToJoin); + cache.del(groupsToJoin.map(name => `group:${name}:members`)); + + const groupData = await Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); + const visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden); + + if (visibleGroups.length) { + await db.sortedSetAdd( + 'groups:visible:memberCount', + visibleGroups.map(groupData => groupData.memberCount), + visibleGroups.map(groupData => groupData.name) + ); + } + + await setGroupTitleIfNotSet(groupsToJoin, uid); + + plugins.hooks.fire('action:group.join', { + groupNames: groupsToJoin, + uid: uid, + }); + }; + + async function createNonExistingGroups(groupsToCreate: string[]): Promise { + if (!groupsToCreate.length) { + return; + } + + for (const groupName of groupsToCreate) { + try { + // eslint-disable-next-line no-await-in-loop + await Groups.create({ + name: groupName, + hidden: 1, + }); + } catch (err) { + if (err && err.message !== '[[error:group-already-exists]]') { + winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${err.stack}`); + throw err; + } + } + } + } + + async function setGroupTitleIfNotSet(groupNames: string[], uid: string): Promise { + const ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; + groupNames = groupNames.filter( + groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName) + ); + if (!groupNames.length) { + return; + } + + const currentTitle = await db.getObjectField(`user:${uid}`, 'groupTitle'); + if (currentTitle || currentTitle === '') { + return; + } + + await user.setUserField(uid, 'groupTitle', JSON.stringify(groupNames)); + } +} From 7d7e2f5f4171343d003d426c32c04a3a709964af Mon Sep 17 00:00:00 2001 From: KevinJOH <13-11007@usb.ve> Date: Thu, 10 Oct 2024 13:22:40 -0400 Subject: [PATCH 2/7] cambiar sintaxis de importacion --- src/groups/join.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/groups/join.ts b/src/groups/join.ts index 9fa9469373..b017746652 100644 --- a/src/groups/join.ts +++ b/src/groups/join.ts @@ -1,10 +1,10 @@ 'use strict'; import * as winston from 'winston'; -import * as db from '../database'; -import * as user from '../user'; -import * as plugins from '../plugins'; -import * as cache from '../cache'; +const db: any = require('../database'); +const user: any = require('../user'); +const plugins: any = require('../plugins'); +const cache: any = require('../cache'); export default function (Groups: any) { Groups.join = async function (groupNames: string | string[], uid: string): Promise { @@ -49,7 +49,7 @@ export default function (Groups: any) { Groups.clearCache(uid, groupsToJoin); cache.del(groupsToJoin.map(name => `group:${name}:members`)); - const groupData = await Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); + const groupData: { name: string, hidden: boolean, memberCount: number }[] = await Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); const visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden); if (visibleGroups.length) { @@ -81,8 +81,8 @@ export default function (Groups: any) { hidden: 1, }); } catch (err) { - if (err && err.message !== '[[error:group-already-exists]]') { - winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${err.stack}`); + if (err && (err as { message: string }).message !== '[[error:group-already-exists]]') { + winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${(err as { stack: string }).stack}`); throw err; } } From 5848c1eb511dd3116af9784b14df93fe363c5b3e Mon Sep 17 00:00:00 2001 From: KevinJOH <13-11007@usb.ve> Date: Sat, 12 Oct 2024 21:45:21 -0400 Subject: [PATCH 3/7] Agregar archivo js y corregir errores de sintaxis --- src/groups/join.js | 222 +++++++++++++++++++++++++-------------------- src/groups/join.ts | 200 ++++++++++++++++++++-------------------- 2 files changed, 226 insertions(+), 196 deletions(-) diff --git a/src/groups/join.js b/src/groups/join.js index 9fb02ec0bb..a1c038cc56 100644 --- a/src/groups/join.js +++ b/src/groups/join.js @@ -1,109 +1,139 @@ 'use strict'; -const winston = require('winston'); - +const __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + let desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function () { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +const __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) { + Object.defineProperty(o, 'default', { enumerable: true, value: v }); +}) : function (o, v) { + o.default = v; +}); +const __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + const result = {}; + if (mod != null) { + Object.keys(mod).forEach((k) => { + if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) { + __createBinding(result, mod, k); + } + }); + } + __setModuleDefault(result, mod); + return result; +}; +const __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P((resolve) => { resolve(value); }); } + const res = new (P || (P = Promise))((resolve, reject) => { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { + if (result.done) { + resolve(result.value); + } else { + adopt(result.value).then(fulfilled, rejected); + } + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + return res; +}; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.default = default_1; +const winston = __importStar(require('winston')); const db = require('../database'); const user = require('../user'); const plugins = require('../plugins'); const cache = require('../cache'); -module.exports = function (Groups) { - Groups.join = async function (groupNames, uid) { - if (!groupNames) { - throw new Error('[[error:invalid-data]]'); - } - if (Array.isArray(groupNames) && !groupNames.length) { - return; - } - if (!Array.isArray(groupNames)) { - groupNames = [groupNames]; - } - - if (!uid) { - throw new Error('[[error:invalid-uid]]'); - } - - const [isMembers, exists, isAdmin] = await Promise.all([ - Groups.isMemberOfGroups(uid, groupNames), - Groups.exists(groupNames), - user.isAdministrator(uid), - ]); - - const groupsToCreate = groupNames.filter((groupName, index) => groupName && !exists[index]); - const groupsToJoin = groupNames.filter((groupName, index) => !isMembers[index]); - - if (!groupsToJoin.length) { - return; - } - await createNonExistingGroups(groupsToCreate); - - const promises = [ - db.sortedSetsAdd(groupsToJoin.map(groupName => `group:${groupName}:members`), Date.now(), uid), - db.incrObjectField(groupsToJoin.map(groupName => `group:${groupName}`), 'memberCount'), - ]; - if (isAdmin) { - promises.push(db.setsAdd(groupsToJoin.map(groupName => `group:${groupName}:owners`), uid)); - } - - await Promise.all(promises); - - Groups.clearCache(uid, groupsToJoin); - cache.del(groupsToJoin.map(name => `group:${name}:members`)); - - const groupData = await Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); - const visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden); - - if (visibleGroups.length) { - await db.sortedSetAdd( - 'groups:visible:memberCount', - visibleGroups.map(groupData => groupData.memberCount), - visibleGroups.map(groupData => groupData.name) - ); - } - - await setGroupTitleIfNotSet(groupsToJoin, uid); - - plugins.hooks.fire('action:group.join', { - groupNames: groupsToJoin, - uid: uid, +function default_1(Groups) { + Groups.join = function (groupNames, uid) { + return __awaiter(this, undefined, undefined, function* () { + if (!groupNames) { + throw new Error('[[error:invalid-data]]'); + } + if (Array.isArray(groupNames) && !groupNames.length) { + return; + } + if (!Array.isArray(groupNames)) { + groupNames = [groupNames]; + } + if (!uid) { + throw new Error('[[error:invalid-uid]]'); + } + const [isMembers, exists, isAdmin] = yield Promise.all([ + Groups.isMemberOfGroups(uid, groupNames), + Groups.exists(groupNames), + user.isAdministrator(uid), + ]); + const groupsToCreate = groupNames.filter((groupName, index) => groupName && !exists[index]); + const groupsToJoin = groupNames.filter((groupName, index) => !isMembers[index]); + if (!groupsToJoin.length) { + return; + } + yield createNonExistingGroups(groupsToCreate); + const promises = [ + db.sortedSetsAdd(groupsToJoin.map(groupName => `group:${groupName}:members`), Date.now(), uid), + db.incrObjectField(groupsToJoin.map(groupName => `group:${groupName}`), 'memberCount'), + ]; + if (isAdmin) { + promises.push(db.setsAdd(groupsToJoin.map(groupName => `group:${groupName}:owners`), uid)); + } + yield Promise.all(promises); + Groups.clearCache(uid, groupsToJoin); + cache.del(groupsToJoin.map(name => `group:${name}:members`)); + const groupData = yield Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); + const visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden); + if (visibleGroups.length) { + yield db.sortedSetAdd('groups:visible:memberCount', visibleGroups.map(groupData => groupData.memberCount), visibleGroups.map(groupData => groupData.name)); + } + yield setGroupTitleIfNotSet(groupsToJoin, uid); + plugins.hooks.fire('action:group.join', { + groupNames: groupsToJoin, + uid: uid, + }); }); }; - - async function createNonExistingGroups(groupsToCreate) { - if (!groupsToCreate.length) { - return; - } - - for (const groupName of groupsToCreate) { - try { - // eslint-disable-next-line no-await-in-loop - await Groups.create({ - name: groupName, - hidden: 1, - }); - } catch (err) { - if (err && err.message !== '[[error:group-already-exists]]') { - winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${err.stack}`); - throw err; + function createNonExistingGroups(groupsToCreate) { + return __awaiter(this, undefined, undefined, function* () { + if (!groupsToCreate.length) { + return; + } + for (const groupName of groupsToCreate) { + try { + // eslint-disable-next-line no-await-in-loop + yield Groups.create({ + name: groupName, + hidden: 1, + }); + } catch (err) { + if (err && err.message !== '[[error:group-already-exists]]') { + winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${err.stack}`); + throw err; + } } } - } + }); } - - async function setGroupTitleIfNotSet(groupNames, uid) { - const ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; - groupNames = groupNames.filter( - groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName) - ); - if (!groupNames.length) { - return; - } - - const currentTitle = await db.getObjectField(`user:${uid}`, 'groupTitle'); - if (currentTitle || currentTitle === '') { - return; - } - - await user.setUserField(uid, 'groupTitle', JSON.stringify(groupNames)); + function setGroupTitleIfNotSet(groupNames, uid) { + return __awaiter(this, undefined, undefined, function* () { + const ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; + groupNames = groupNames.filter(groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName)); + if (!groupNames.length) { + return; + } + const currentTitle = yield db.getObjectField(`user:${uid}`, 'groupTitle'); + if (currentTitle || currentTitle === '') { + return; + } + yield user.setUserField(uid, 'groupTitle', JSON.stringify(groupNames)); + }); } -}; +} diff --git a/src/groups/join.ts b/src/groups/join.ts index b017746652..93bc5e01d7 100644 --- a/src/groups/join.ts +++ b/src/groups/join.ts @@ -6,103 +6,103 @@ const user: any = require('../user'); const plugins: any = require('../plugins'); const cache: any = require('../cache'); -export default function (Groups: any) { - Groups.join = async function (groupNames: string | string[], uid: string): Promise { - if (!groupNames) { - throw new Error('[[error:invalid-data]]'); - } - if (Array.isArray(groupNames) && !groupNames.length) { - return; - } - if (!Array.isArray(groupNames)) { - groupNames = [groupNames]; - } - - if (!uid) { - throw new Error('[[error:invalid-uid]]'); - } - - const [isMembers, exists, isAdmin] = await Promise.all([ - Groups.isMemberOfGroups(uid, groupNames), - Groups.exists(groupNames), - user.isAdministrator(uid), - ]); - - const groupsToCreate = groupNames.filter((groupName, index) => groupName && !exists[index]); - const groupsToJoin = groupNames.filter((groupName, index) => !isMembers[index]); - - if (!groupsToJoin.length) { - return; - } - await createNonExistingGroups(groupsToCreate); - - const promises = [ - db.sortedSetsAdd(groupsToJoin.map(groupName => `group:${groupName}:members`), Date.now(), uid), - db.incrObjectField(groupsToJoin.map(groupName => `group:${groupName}`), 'memberCount'), - ]; - if (isAdmin) { - promises.push(db.setsAdd(groupsToJoin.map(groupName => `group:${groupName}:owners`), uid)); - } - - await Promise.all(promises); - - Groups.clearCache(uid, groupsToJoin); - cache.del(groupsToJoin.map(name => `group:${name}:members`)); - - const groupData: { name: string, hidden: boolean, memberCount: number }[] = await Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); - const visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden); - - if (visibleGroups.length) { - await db.sortedSetAdd( - 'groups:visible:memberCount', - visibleGroups.map(groupData => groupData.memberCount), - visibleGroups.map(groupData => groupData.name) - ); - } - - await setGroupTitleIfNotSet(groupsToJoin, uid); - - plugins.hooks.fire('action:group.join', { - groupNames: groupsToJoin, - uid: uid, - }); - }; - - async function createNonExistingGroups(groupsToCreate: string[]): Promise { - if (!groupsToCreate.length) { - return; - } - - for (const groupName of groupsToCreate) { - try { - // eslint-disable-next-line no-await-in-loop - await Groups.create({ - name: groupName, - hidden: 1, - }); - } catch (err) { - if (err && (err as { message: string }).message !== '[[error:group-already-exists]]') { - winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${(err as { stack: string }).stack}`); - throw err; - } - } - } - } - - async function setGroupTitleIfNotSet(groupNames: string[], uid: string): Promise { - const ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; - groupNames = groupNames.filter( - groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName) - ); - if (!groupNames.length) { - return; - } - - const currentTitle = await db.getObjectField(`user:${uid}`, 'groupTitle'); - if (currentTitle || currentTitle === '') { - return; - } - - await user.setUserField(uid, 'groupTitle', JSON.stringify(groupNames)); - } -} +export default function (Groups:any) { + Groups.join = async function (groupNames: String[] | String, uid: String) { + if (!groupNames) { + throw new Error('[[error:invalid-data]]'); + } + if (Array.isArray(groupNames) && !groupNames.length) { + return; + } + if (!Array.isArray(groupNames)) { + groupNames = [groupNames]; + } + + if (!uid) { + throw new Error('[[error:invalid-uid]]'); + } + + const [isMembers, exists, isAdmin] = await Promise.all([ + Groups.isMemberOfGroups(uid, groupNames), + Groups.exists(groupNames), + user.isAdministrator(uid), + ]); + + const groupsToCreate = groupNames.filter((groupName, index) => groupName && !exists[index]); + const groupsToJoin = groupNames.filter((groupName, index) => !isMembers[index]); + + if (!groupsToJoin.length) { + return; + } + await createNonExistingGroups(groupsToCreate); + + const promises = [ + db.sortedSetsAdd(groupsToJoin.map(groupName => `group:${groupName}:members`), Date.now(), uid), + db.incrObjectField(groupsToJoin.map(groupName => `group:${groupName}`), 'memberCount'), + ]; + if (isAdmin) { + promises.push(db.setsAdd(groupsToJoin.map(groupName => `group:${groupName}:owners`), uid)); + } + + await Promise.all(promises); + + Groups.clearCache(uid, groupsToJoin); + cache.del(groupsToJoin.map(name => `group:${name}:members`)); + + const groupData = await Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); + const visibleGroups = groupData.filter((groupData: any) => groupData && !groupData.hidden); + + if (visibleGroups.length) { + await db.sortedSetAdd( + 'groups:visible:memberCount', + visibleGroups.map((groupData: any) => groupData.memberCount), + visibleGroups.map((groupData: any) => groupData.name) + ); + } + + await setGroupTitleIfNotSet(groupsToJoin, uid); + + plugins.hooks.fire('action:group.join', { + groupNames: groupsToJoin, + uid: uid, + }); + }; + + async function createNonExistingGroups(groupsToCreate: any) { + if (!groupsToCreate.length) { + return; + } + + for (const groupName of groupsToCreate) { + try { + // eslint-disable-next-line no-await-in-loop + await Groups.create({ + name: groupName, + hidden: 1, + }); + } catch (err) { + if (err && (err as {message: String}).message !== '[[error:group-already-exists]]') { + winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${(err as {stack:String}).stack}`); + throw err; + } + } + } + } + + async function setGroupTitleIfNotSet(groupNames: String [], uid: String) { + const ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; + groupNames = groupNames.filter( + groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName) + ); + if (!groupNames.length) { + return; + } + + const currentTitle = await db.getObjectField(`user:${uid}`, 'groupTitle'); + if (currentTitle || currentTitle === '') { + return; + } + + await user.setUserField(uid, 'groupTitle', JSON.stringify(groupNames)); + } +}; \ No newline at end of file From aaa4ddc59040a45eeee32df300a98af8b8d64062 Mon Sep 17 00:00:00 2001 From: KevinJOH <13-11007@usb.ve> Date: Mon, 14 Oct 2024 10:33:55 -0400 Subject: [PATCH 4/7] Actualizar sintaxis de importacion --- src/groups/join.js | 291 ++++++++++++++++++++++++++++----------------- src/groups/join.ts | 36 +++--- tsconfig.json | 119 ++++++++++++++++++ 3 files changed, 320 insertions(+), 126 deletions(-) create mode 100644 tsconfig.json diff --git a/src/groups/join.js b/src/groups/join.js index a1c038cc56..97f526e3a5 100644 --- a/src/groups/join.js +++ b/src/groups/join.js @@ -1,139 +1,206 @@ 'use strict'; -const __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - let desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function () { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -const __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) { - Object.defineProperty(o, 'default', { enumerable: true, value: v }); -}) : function (o, v) { - o.default = v; -}); -const __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - const result = {}; - if (mod != null) { - Object.keys(mod).forEach((k) => { - if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) { - __createBinding(result, mod, k); - } - }); - } - __setModuleDefault(result, mod); - return result; -}; const __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P((resolve) => { resolve(value); }); } const res = new (P || (P = Promise))((resolve, reject) => { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } - function step(result) { - if (result.done) { - resolve(result.value); - } else { - adopt(result.value).then(fulfilled, rejected); - } - } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); return res; }; +const __generator = (this && this.__generator) || function (thisArg, body) { + let f; let y; let t; let g; + let _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }; + return g = { next: verb(0), throw: verb(1), return: verb(2) }, typeof Symbol === 'function' && (g[Symbol.iterator] = function () { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (g && (g = 0, op[0] && (_ = 0)), _) { + try { + if (f = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; Object.defineProperty(exports, '__esModule', { value: true }); exports.default = default_1; -const winston = __importStar(require('winston')); -const db = require('../database'); -const user = require('../user'); -const plugins = require('../plugins'); -const cache = require('../cache'); +/* eslint-disable import/no-import-module-exports */ +const winston = require('winston'); +/* eslint-disable import/no-import-module-exports */ +const database_1 = require('../database'); +/* eslint-disable import/no-import-module-exports */ +const user_1 = require('../user'); +/* eslint-disable import/no-import-module-exports */ +const plugins_1 = require('../plugins'); +/* eslint-disable import/no-import-module-exports */ +const cache_1 = require('../cache'); function default_1(Groups) { Groups.join = function (groupNames, uid) { - return __awaiter(this, undefined, undefined, function* () { - if (!groupNames) { - throw new Error('[[error:invalid-data]]'); - } - if (Array.isArray(groupNames) && !groupNames.length) { - return; - } - if (!Array.isArray(groupNames)) { - groupNames = [groupNames]; - } - if (!uid) { - throw new Error('[[error:invalid-uid]]'); - } - const [isMembers, exists, isAdmin] = yield Promise.all([ - Groups.isMemberOfGroups(uid, groupNames), - Groups.exists(groupNames), - user.isAdministrator(uid), - ]); - const groupsToCreate = groupNames.filter((groupName, index) => groupName && !exists[index]); - const groupsToJoin = groupNames.filter((groupName, index) => !isMembers[index]); - if (!groupsToJoin.length) { - return; - } - yield createNonExistingGroups(groupsToCreate); - const promises = [ - db.sortedSetsAdd(groupsToJoin.map(groupName => `group:${groupName}:members`), Date.now(), uid), - db.incrObjectField(groupsToJoin.map(groupName => `group:${groupName}`), 'memberCount'), - ]; - if (isAdmin) { - promises.push(db.setsAdd(groupsToJoin.map(groupName => `group:${groupName}:owners`), uid)); - } - yield Promise.all(promises); - Groups.clearCache(uid, groupsToJoin); - cache.del(groupsToJoin.map(name => `group:${name}:members`)); - const groupData = yield Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); - const visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden); - if (visibleGroups.length) { - yield db.sortedSetAdd('groups:visible:memberCount', visibleGroups.map(groupData => groupData.memberCount), visibleGroups.map(groupData => groupData.name)); - } - yield setGroupTitleIfNotSet(groupsToJoin, uid); - plugins.hooks.fire('action:group.join', { - groupNames: groupsToJoin, - uid: uid, + return __awaiter(this, void 0, void 0, function () { + let _a; let isMembers; let exists; let isAdmin; let groupsToCreate; let groupsToJoin; let promises; let groupData; let + visibleGroups; + return __generator(this, (_b) => { + switch (_b.label) { + case 0: + if (!groupNames) { + throw new Error('[[error:invalid-data]]'); + } + if (Array.isArray(groupNames) && !groupNames.length) { + return [2]; + } + if (!Array.isArray(groupNames)) { + groupNames = [groupNames]; + } + if (!uid) { + throw new Error('[[error:invalid-uid]]'); + } + return [4 /* yield */, Promise.all([ + Groups.isMemberOfGroups(uid, groupNames), + Groups.exists(groupNames), + user_1.default.isAdministrator(uid), + ])]; + case 1: + _a = _b.sent(), isMembers = _a[0], exists = _a[1], isAdmin = _a[2]; + groupsToCreate = groupNames.filter((groupName, index) => groupName && !exists[index]); + groupsToJoin = groupNames.filter((groupName, index) => !isMembers[index]); + if (!groupsToJoin.length) { + return [2]; + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + return [4 /* yield */, createNonExistingGroups(groupsToCreate)]; + case 2: + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + _b.sent(); + promises = [ + database_1.default.sortedSetsAdd(groupsToJoin.map(groupName => 'group:'.concat(groupName, ':members')), Date.now(), uid), + database_1.default.incrObjectField(groupsToJoin.map(groupName => 'group:'.concat(groupName)), 'memberCount'), + ]; + if (isAdmin) { + promises.push(database_1.default.setsAdd(groupsToJoin.map(groupName => 'group:'.concat(groupName, ':owners')), uid)); + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + return [4 /* yield */, Promise.all(promises)]; + case 3: + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + _b.sent(); + Groups.clearCache(uid, groupsToJoin); + cache_1.default.del(groupsToJoin.map(name => 'group:'.concat(name, ':members'))); + return [4 /* yield */, Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount'])]; + case 4: + groupData = _b.sent(); + visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden); + if (!visibleGroups.length) return [3 /* break */, 6]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + return [4 /* yield */, database_1.default.sortedSetAdd('groups:visible:memberCount', visibleGroups.map(groupData => groupData.memberCount), visibleGroups.map(groupData => groupData.name))]; + case 5: + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + _b.sent(); + _b.label = 6; + case 6: + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + return [4 /* yield */, setGroupTitleIfNotSet(groupsToJoin, uid)]; + case 7: + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + _b.sent(); + plugins_1.default.hooks.fire('action:group.join', { + groupNames: groupsToJoin, + uid: uid, + }); + return [2]; + } }); }); }; function createNonExistingGroups(groupsToCreate) { - return __awaiter(this, undefined, undefined, function* () { - if (!groupsToCreate.length) { - return; - } - for (const groupName of groupsToCreate) { - try { - // eslint-disable-next-line no-await-in-loop - yield Groups.create({ - name: groupName, - hidden: 1, - }); - } catch (err) { - if (err && err.message !== '[[error:group-already-exists]]') { - winston.error(`[groups.join] Could not create new hidden group (${groupName})\n${err.stack}`); - throw err; - } + return __awaiter(this, void 0, void 0, function () { + let _i; let groupsToCreate_1; let groupName; let + err_1; + return __generator(this, (_a) => { + switch (_a.label) { + case 0: + if (!groupsToCreate.length) { + return [2]; + } + _i = 0, groupsToCreate_1 = groupsToCreate; + _a.label = 1; + case 1: + if (!(_i < groupsToCreate_1.length)) return [3 /* break */, 6]; + groupName = groupsToCreate_1[_i]; + _a.label = 2; + case 2: + _a.trys.push([2, 4, , 5]); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + // eslint-disable-next-line no-await-in-loop + return [4 /* yield */, Groups.create({ + name: groupName, + hidden: 1, + })]; + case 3: + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + // eslint-disable-next-line no-await-in-loop + _a.sent(); + return [3 /* break */, 5]; + case 4: + err_1 = _a.sent(); + if (err_1 && err_1.message !== '[[error:group-already-exists]]') { + winston.error('[groups.join] Could not create new hidden group ('.concat(groupName, ')\n').concat(err_1.stack)); + throw err_1; + } + return [3 /* break */, 5]; + case 5: + _i++; + return [3 /* break */, 1]; + case 6: return [2]; } - } + }); }); } function setGroupTitleIfNotSet(groupNames, uid) { - return __awaiter(this, undefined, undefined, function* () { - const ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; - groupNames = groupNames.filter(groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName)); - if (!groupNames.length) { - return; - } - const currentTitle = yield db.getObjectField(`user:${uid}`, 'groupTitle'); - if (currentTitle || currentTitle === '') { - return; - } - yield user.setUserField(uid, 'groupTitle', JSON.stringify(groupNames)); + return __awaiter(this, void 0, void 0, function () { + let ignore; let + currentTitle; + return __generator(this, (_a) => { + switch (_a.label) { + case 0: + ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; + groupNames = groupNames.filter(groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName)); + if (!groupNames.length) { + return [2]; + } + return [4 /* yield */, database_1.default.getObjectField('user:'.concat(uid), 'groupTitle')]; + case 1: + currentTitle = _a.sent(); + if (currentTitle || currentTitle === '') { + return [2]; + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + return [4 /* yield */, user_1.default.setUserField(uid, 'groupTitle', JSON.stringify(groupNames))]; + case 2: + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + _a.sent(); + return [2]; + } + }); }); } } + diff --git a/src/groups/join.ts b/src/groups/join.ts index 93bc5e01d7..55126f123b 100644 --- a/src/groups/join.ts +++ b/src/groups/join.ts @@ -1,13 +1,18 @@ 'use strict'; -import * as winston from 'winston'; -const db: any = require('../database'); -const user: any = require('../user'); -const plugins: any = require('../plugins'); -const cache: any = require('../cache'); +/* eslint-disable import/no-import-module-exports */ +import winston = require ('winston'); +/* eslint-disable import/no-import-module-exports */ +import db from '../database'; +/* eslint-disable import/no-import-module-exports */ +import user from '../user'; +/* eslint-disable import/no-import-module-exports */ +import plugins from '../plugins'; +/* eslint-disable import/no-import-module-exports */ +import cache from '../cache'; export default function (Groups:any) { - Groups.join = async function (groupNames: String[] | String, uid: String) { + Groups.join = async function (groupNames: String[] | String, uid: String): Promise { if (!groupNames) { throw new Error('[[error:invalid-data]]'); } @@ -21,7 +26,7 @@ export default function (Groups:any) { if (!uid) { throw new Error('[[error:invalid-uid]]'); } - + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call const [isMembers, exists, isAdmin] = await Promise.all([ Groups.isMemberOfGroups(uid, groupNames), Groups.exists(groupNames), @@ -34,6 +39,7 @@ export default function (Groups:any) { if (!groupsToJoin.length) { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call await createNonExistingGroups(groupsToCreate); const promises = [ @@ -43,23 +49,24 @@ export default function (Groups:any) { if (isAdmin) { promises.push(db.setsAdd(groupsToJoin.map(groupName => `group:${groupName}:owners`), uid)); } - + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call await Promise.all(promises); Groups.clearCache(uid, groupsToJoin); cache.del(groupsToJoin.map(name => `group:${name}:members`)); - + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call const groupData = await Groups.getGroupsFields(groupsToJoin, ['name', 'hidden', 'memberCount']); const visibleGroups = groupData.filter((groupData: any) => groupData && !groupData.hidden); if (visibleGroups.length) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call await db.sortedSetAdd( 'groups:visible:memberCount', visibleGroups.map((groupData: any) => groupData.memberCount), visibleGroups.map((groupData: any) => groupData.name) ); } - + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call await setGroupTitleIfNotSet(groupsToJoin, uid); plugins.hooks.fire('action:group.join', { @@ -68,13 +75,14 @@ export default function (Groups:any) { }); }; - async function createNonExistingGroups(groupsToCreate: any) { + async function createNonExistingGroups(groupsToCreate: any): Promise { if (!groupsToCreate.length) { return; } for (const groupName of groupsToCreate) { try { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call // eslint-disable-next-line no-await-in-loop await Groups.create({ name: groupName, @@ -89,7 +97,7 @@ export default function (Groups:any) { } } - async function setGroupTitleIfNotSet(groupNames: String [], uid: String) { + async function setGroupTitleIfNotSet(groupNames: String [], uid: String): Promise { const ignore = ['registered-users', 'verified-users', 'unverified-users', Groups.BANNED_USERS]; groupNames = groupNames.filter( groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName) @@ -97,12 +105,12 @@ export default function (Groups:any) { if (!groupNames.length) { return; } - + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call const currentTitle = await db.getObjectField(`user:${uid}`, 'groupTitle'); if (currentTitle || currentTitle === '') { return; } - + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call await user.setUserField(uid, 'groupTitle', JSON.stringify(groupNames)); } }; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..cc5a67fd9f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,119 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "ES2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "CommonJS", /* Specify what module code is generated. */ + "moduleResolution": "node", + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "include": [ + "public/src/**/*", + "src/**/*", + "test/**/*", + ], + "exclude":[ + "node_modules", + ] +} From 03f633584761dded1b5960c4a5a6b295fc1cac6d Mon Sep 17 00:00:00 2001 From: KevinJOH <13-11007@usb.ve> Date: Mon, 14 Oct 2024 10:47:33 -0400 Subject: [PATCH 5/7] Solucionar problemas de tsconfig --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index cc5a67fd9f..d4cbd3a3db 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - + "allowJs": false, /* Language and Environment */ "target": "ES2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ From 7f03ae938bb4b95f33d3318ffa0704eeea5db222 Mon Sep 17 00:00:00 2001 From: KevinJOH <13-11007@usb.ve> Date: Mon, 14 Oct 2024 10:53:04 -0400 Subject: [PATCH 6/7] Revertir cambios de tsconfig.json --- tsconfig.json | 134 ++++++-------------------------------------------- 1 file changed, 16 insertions(+), 118 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index d4cbd3a3db..eb281e4564 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,119 +1,17 @@ { - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - "allowJs": false, - /* Language and Environment */ - "target": "ES2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "CommonJS", /* Specify what module code is generated. */ - "moduleResolution": "node", - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - }, - "include": [ - "public/src/**/*", - "src/**/*", - "test/**/*", - ], - "exclude":[ - "node_modules", - ] -} + "compilerOptions": { + "allowJs": false, + "target": "es2017", + "module": "commonjs", + "moduleResolution": "node", + "esModuleInterop": true, + }, + "include": [ + "public/src/**/*", + "src/**/*", + "test/**/*", + ], + "exclude":[ + "node_modules", + ] + } \ No newline at end of file From 90028163d46502590aa9c362421cd17a68eb9856 Mon Sep 17 00:00:00 2001 From: KevinJOH <13-11007@usb.ve> Date: Mon, 14 Oct 2024 10:54:37 -0400 Subject: [PATCH 7/7] Revertir cambios de tsconfig --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index eb281e4564..4cd3b2f7a9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "allowJs": false, - "target": "es2017", + "target": "es6", "module": "commonjs", "moduleResolution": "node", "esModuleInterop": true,