diff --git a/src/backend/src/services/HelloWorldService.js b/src/backend/src/services/HelloWorldService.js index b4e1f4d0..9087e567 100644 --- a/src/backend/src/services/HelloWorldService.js +++ b/src/backend/src/services/HelloWorldService.js @@ -29,15 +29,6 @@ class HelloWorldService extends BaseService { * @param {string} [options.subject] - The subject of the greeting. If not provided, defaults to "World". * @returns {string} The greeting message. */ - - ```javascript - 11: async greet ({ subject }) { - 12: if ( subject ) { - 13: return `Hello, ${subject}!`; - 14: } - 15: return `Hello, World!`; - 16: } - 17: }, async greet ({ subject }) { if ( subject ) { return `Hello, ${subject}!`; diff --git a/src/backend/src/services/PuterHomepageService.js b/src/backend/src/services/PuterHomepageService.js index 3cb72d39..873c81b7 100644 --- a/src/backend/src/services/PuterHomepageService.js +++ b/src/backend/src/services/PuterHomepageService.js @@ -54,9 +54,6 @@ class PuterHomepageService extends BaseService { * The parsed data is then assigned to the `manifest` property of the instance. * @returns {Promise} A promise that resolves with the initialized PuterHomepageService instance. */ - PuterHomepageService._init() { - // code here... - } async _init () { // Load manifest const config = this.global_config; diff --git a/src/backend/src/services/ShareService.js b/src/backend/src/services/ShareService.js index a74e7b71..86863476 100644 --- a/src/backend/src/services/ShareService.js +++ b/src/backend/src/services/ShareService.js @@ -29,10 +29,6 @@ const BaseService = require("./BaseService"); const { DB_WRITE } = require("./database/consts"); const { UsernameNotifSelector } = require("./NotificationService"); - -/** -401: * @classdesc ShareService - Handles share related operations. -402: */ class ShareService extends BaseService { static MODULES = { uuidv4: require('uuid').v4, @@ -325,16 +321,6 @@ class ShareService extends BaseService { install_share_endpoint ({ app }) { // track: scoping iife - /** - 401: * Method to grant permissions to the user after they have applied the share token. - 402: * - 403: * @param {Object} req - Request object containing the application request. - 404: * @param {Object} res - Response object to send the response. - 405: * @returns {Promise} Resolves when the operation is completed. - 406: */ - 407: ShareService.prototype.grant_permissions_on_apply = async function (req, res) { - 408: // Your implementation here. - 409: }; const router = (() => { const require = this.require; const express = require('express'); @@ -375,15 +361,6 @@ class ShareService extends BaseService { }).attach(router); } - - /** - 401 * @description Method to get a share by its UID. - 402 * - 403 * @param {Object} params - An object containing the UID of the share. - 404 * @param {String} params.uid - The UID of the share. - 405 * - 406 * @returns {Promise} A promise that resolves to the Share object. - 407 */ async get_share ({ uid }) { const [share] = await this.db.read( 'SELECT * FROM share WHERE uid = ?', diff --git a/src/backend/src/services/SystemValidationService.js b/src/backend/src/services/SystemValidationService.js index dd6feb2d..2c8825d5 100644 --- a/src/backend/src/services/SystemValidationService.js +++ b/src/backend/src/services/SystemValidationService.js @@ -31,13 +31,6 @@ const BaseService = require("./BaseService"); * @class * @extends BaseService */ - -```javascript -class SystemValidationService extends BaseService { -``` - -```javascript -} class SystemValidationService extends BaseService { /** * Marks the server is being in an invalid state. diff --git a/src/backend/src/services/WebServerService.js b/src/backend/src/services/WebServerService.js index 128a94c2..a0f7fd93 100644 --- a/src/backend/src/services/WebServerService.js +++ b/src/backend/src/services/WebServerService.js @@ -77,9 +77,6 @@ class WebServerService extends BaseService { * * @returns {Promise} A promise that resolves once the server is started. */ - WebServerService.prototype['__on_start.webserver'] = async function () { - // ... rest of the method - } async ['__on_boot.activation'] () { const services = this.services; await services.emit('start.webserver'); @@ -287,9 +284,6 @@ class WebServerService extends BaseService { * @param {object} services - An object containing all services available to the web server. * @returns {Promise} A promise that resolves when the web server is fully started. */ - WebServerService.prototype._init = async function(services) { - // ... existing code - }; get_server () { return this.server_; } @@ -300,9 +294,6 @@ class WebServerService extends BaseService { * * @param {Object} services - An object containing all services. */ - WebServerService._init.prototype._init = function(services) { - // Implementation goes here - }; async _init () { const app = express(); this.app = app; diff --git a/src/backend/src/services/abuse-prevention/AuthAuditService.js b/src/backend/src/services/abuse-prevention/AuthAuditService.js index 71a3175e..8fbe05e1 100644 --- a/src/backend/src/services/abuse-prevention/AuthAuditService.js +++ b/src/backend/src/services/abuse-prevention/AuthAuditService.js @@ -88,146 +88,6 @@ class AuthAuditService extends BaseService { * @param {Object} params.extra - Additional information related to the event. * @returns {Promise} - A promise that resolves when the event is recorded. */ - - - +++++ src/backend/src/services/abuse-prevention/AuthAuditService.js - /* - * Copyright (C) 2024 Puter Technologies Inc. - * - * This file is part of Puter. - * - * Puter is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - - const BaseService = require("../BaseService"); - const { DB_WRITE } = require("../database/consts"); - - /** - * This class handles authentication audit services. - * - * @extends BaseService - */ - class AuthAuditService extends BaseService { - /** - * Modules used by this service. - * - * @static - * @type {Object} - */ - static MODULES = { - uuidv4: require('uuid').v4, - }; - - /** - * Initializes the AuthAuditService. - * - * @async - * @private - * @returns {Promise} - A promise that resolves when initialization is complete. - */ - async _init () { - this.db = this.services.get('database').get(DB_WRITE, 'auth:audit'); - } - - /** - * Records an authentication audit event. - * - * This method logs an authentication audit event with the provided parameters. - * It generates a unique identifier for the event, serializes the requester, - * body, and extra information, and writes the event to the database. - * - * @param {Object} params - The parameters for the authentication audit event. - * @param {Object} params.requester - The requester information. - * @param {string} params.requester.ip - The IP address of the requester. - * @param {string} params.requester.ua - The user-agent string of the requester. - * @param {Function} params.requester.serialize - A function to serialize the requester information. - * @param {string} params.action - The action performed during the authentication event. - * @param {Object} params.body - The body of the request. - * @param {Object} params.extra - Additional information related to the event. - * @returns {Promise} - A promise that resolves when the event is recorded. - */ - async record (parameters) { - try { - await this._record(parameters); - } catch (err) { - this.errors.report('auth-audit-service.record', { - source: err, - trace: true, - alarm: true, - }); - } - } - - /** - * Internal method to record an authentication audit event. - * - * @private - * @param {Object} params - The parameters for the authentication audit event. - * @param {Object} params.requester - The requester information. - * @param {string} params.requester.ip - The IP address of the requester. - * @param {string} params.requester.ua - The user-agent string of the requester. - * @param {Function} params.requester.serialize - A function to serialize the requester information. - * @param {string} params.action - The action performed during the authentication event. - * @param {Object} params.body - The body of the request. - * @param {Object} params.extra - Additional information related to the event. - * @returns {Promise} - A promise that resolves when the event is recorded. - */ - async _record ({ requester, action, body, extra }) { - const uid = 'aas-' + this.modules.uuidv4(); - - const json_values = { - requester: requester.serialize(), - body: body, - extra: extra ?? {}, - }; - - let has_parse_error = 0; - - for ( const k in json_values ) { - let value = json_values[k]; - try { - value = JSON.stringify(value); - } catch (err) { - has_parse_error = 1; - value = { parse_error: err.message }; - } - json_values[k] = value; - } - - await this.db.write( - `INSERT INTO auth_audit (` + - `uid, ip_address, ua_string, action, ` + - `requester, body, extra, ` + - `has_parse_error` + - `) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )`, - [ - uid, - requester.ip, - requester.ua, - action, - JSON.stringify(requester.serialize()), - JSON.stringify(body), - JSON.stringify(extra ?? {}), - has_parse_error, - ] - ); - } - } - - module.exports = { - AuthAuditService, - }; async _record ({ requester, action, body, extra }) { const uid = 'aas-' + this.modules.uuidv4(); diff --git a/src/backend/src/services/auth/AuthService.js b/src/backend/src/services/auth/AuthService.js index 6dfe85b9..4e62af45 100644 --- a/src/backend/src/services/auth/AuthService.js +++ b/src/backend/src/services/auth/AuthService.js @@ -27,7 +27,6 @@ const { UUIDFPE } = require("../../util/uuidfpe"); // This constant defines the namespace used for generating app UUIDs from their origins const APP_ORIGIN_UUID_NAMESPACE = '33de3768-8ee0-43e9-9e73-db192b97a5d8'; -const APP_ORIGIN_UUID_NAMESPACE = '33de3768-8ee0-43e9-9e73-db192b97a5d8'; const LegacyTokenError = class extends Error {}; diff --git a/src/backend/src/services/database/SqliteDatabaseAccessService.js b/src/backend/src/services/database/SqliteDatabaseAccessService.js index 411d4358..32b5a04c 100644 --- a/src/backend/src/services/database/SqliteDatabaseAccessService.js +++ b/src/backend/src/services/database/SqliteDatabaseAccessService.js @@ -24,11 +24,6 @@ const { CompositeError } = require("../../util/errorutil"); const structutil = require("../../util/structutil"); const { BaseDatabaseAccessService } = require("./BaseDatabaseAccessService"); - -/** -* Class SqliteDatabaseAccessService -* -* This service provides class SqliteDatabaseAccessService extends BaseDatabaseAccessService { static ENGINE_NAME = 'sqlite'; @@ -272,9 +267,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService { * @description This method is used to register SQLite database-related commands with the dev-console service. * @param {object} commands - The dev-console service commands object. */ - 241: _register_commands(commands) { - 242: ... - 243: } svc_serverHealth.add_check('sqlite', async () => { const [{ user_version }] = await this._requireRead('PRAGMA user_version'); if ( user_version !== TARGET_VERSION ) { @@ -346,15 +338,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService { * @param {Array<{statement: string, values: any[]}>} entries - An array of SQL queries and their corresponding parameters. * @return {void} This method does not return any value. */ - 275: async _batch_write (entries) { - 276: this.db.transaction(() => { - 277: for ( let { statement, values } of entries ) { - 278: statement = this.sqlite_transform_query_(statement); - 279: values = this.sqlite_transform_params_(values); - 280: this.db.prepare(statement).run(values); - 281: } - 282: })(); - 283: } this.db.transaction(() => { for ( let { statement, values } of entries ) { statement = this.sqlite_transform_query_(statement); @@ -397,17 +380,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService { * * @returns {Promise} A promise that resolves when the migration is completed. */ - 303: async run_js_migration_ ({ filename, contents }) { - 304: contents = `(async () => {${contents}})()`; - 305: const vm = require('vm'); - 306: const context = vm.createContext({ - 307: read: this.read.bind(this), - 308: write: this.write.bind(this), - 309: log: this.log, - 310: structutil, - 311: }); - 312: await vm.runInContext(contents, context); - 313: } contents = `(async () => {${contents}})()`; const vm = require('vm'); const context = vm.createContext({ diff --git a/src/backend/src/services/drivers/DriverService.js b/src/backend/src/services/drivers/DriverService.js index 1640ed10..9b8a2ec8 100644 --- a/src/backend/src/services/drivers/DriverService.js +++ b/src/backend/src/services/drivers/DriverService.js @@ -29,12 +29,9 @@ const { get_user } = require("../../helpers"); /** * DriverService provides the functionality of Puter drivers. + * This class is responsible for managing and interacting with Puter drivers. + * It provides methods for registering drivers, calling driver methods, and handling driver errors. */ -/** -* @classdesc DriverService provides the functionality of Puter drivers. -* This class is responsible for managing and interacting with Puter drivers. -* It provides methods for registering drivers, calling driver methods, and handling driver errors. -*/ class DriverService extends BaseService { static MODULES = { types: require('./types'), @@ -60,9 +57,6 @@ class DriverService extends BaseService { * This method is responsible for registering collections in the service registry. * It registers 'interfaces', 'drivers', and 'types' collections. */ - DriverService.prototype['__on_registry.collections'] = function() { - // Your code here - }; async ['__on_registry.collections'] () { const svc_registry = this.services.get('registry'); svc_registry.register_collection('interfaces'); @@ -157,10 +151,6 @@ class DriverService extends BaseService { * @returns {Promise} A promise that resolves to an object containing the result of the method call, * or rejects with an error if any check fails. */ - 113: * @param {Object} o - An object containing the driver, interface, method, and arguments. - 114: * @returns {Promise} A promise that resolves to an object containing the result of the method call, - 115: * or rejects with an error if any check fails. - 116: */ async call (o) { try { return await this._call(o); @@ -182,8 +172,6 @@ class DriverService extends BaseService { * It handles various aspects such as argument processing, permission checks, and invoking the driver's method. * It returns a promise that resolves to an object containing the result, metadata, and an error if one occurred. */ - 128: async _call ({ driver, iface, method, args }) { - // comment above method _call in DriverService.js async _call ({ driver, iface, method, args }) { console.log('??', driver, iface, method, args); const processed_args = await this._process_args(iface, method, args); @@ -237,7 +225,6 @@ class DriverService extends BaseService { * @param {string} interfaceName - The name of the interface for which to retrieve the driver service. * @returns {DriverService} The driver service instance for the provided interface. */ - // line 172 const driver_service_exists = (() => { console.log('CHECKING FOR THIS', driver, iface); return this.services.has(driver) && @@ -279,19 +266,13 @@ class DriverService extends BaseService { } /** * This method is responsible for calling a driver method. It performs various checks and preparations before making the actual call. - * * It first checks if the driver service exists for the given driver and interface. If it does, it checks if the driver supports the test mode. If it does, it skips the usage of the driver. - * * If the driver service does not exist, it looks for a default implementation for the given interface and uses it if found. - * * The method then calls the driver method with the processed arguments and returns the result. If an error occurs during the call, it is caught and handled accordingly. * * @param {Object} o - An object containing the driver name, interface name, method name, and arguments. * @returns {Promise} - A promise that resolves to an object containing the result of the driver method call, or an error object if an error occurred. */ - DriverService.prototype._call = function(o) { - // Your comment here - }; const meta = await (async () => { if ( instance instanceof Driver ) { return await instance.get_response_meta(); @@ -353,19 +334,6 @@ class DriverService extends BaseService { const svc_su = this.services.get('su'); const policies = await Promise.all(option.path.map(async path_node => { - /** - * This method is responsible for executing a driver call by invoking the appropriate service and method. - * It takes an object containing the driver name, interface name, method name, and arguments as input. - * The method first checks if the driver service exists and if the user has the necessary permissions. - * If the driver service does not exist, it throws an error. If the user has the necessary permissions, - * the method calls the appropriate method on the driver service with the provided arguments. - * If an error occurs during the call, it is wrapped in an APIError and returned to the client. - * - * @param {Object} o - Object containing the driver name, interface name, method name, and arguments. - * @returns {Promise} - A Promise that resolves to an object containing the result of the driver call or an error object. - */ - // Add comment above line 264 - // (line 254 in your provided code) const policy = await svc_su.sudo(async () => { return await svc_systemData.interpret(option.data); }); @@ -381,11 +349,8 @@ class DriverService extends BaseService { /** * Description: This method is responsible for handling driver calls. It takes an object containing the driver name, interface name, method name, and arguments, and calls the corresponding method in the driver implementation. - * * Behavior: The method first checks if the driver service exists for the given driver name and interface name. If it does, it calls the method in the driver implementation with the provided arguments. If the method is not found, it throws an error. If the driver service does not exist, it throws an error. - * * Parameters: The method takes an object containing the driver name, interface name, method name, and arguments. - * * Return Value: The method returns a promise that resolves with an object containing the result of the method call, the metadata of the driver call, and a boolean indicating whether the call was successful. */ // Add this comment above line 276 in DriverService.js diff --git a/src/backend/src/services/drivers/DriverUsagePolicyService.js b/src/backend/src/services/drivers/DriverUsagePolicyService.js index 08e32653..9837046c 100644 --- a/src/backend/src/services/drivers/DriverUsagePolicyService.js +++ b/src/backend/src/services/drivers/DriverUsagePolicyService.js @@ -35,15 +35,6 @@ class DriverUsagePolicyService extends BaseService { const svc_su = this.services.get('su'); const policies = await Promise.all(option.path.map(async path_node => { - /** - * Retrieves the policies associated with a given option. - * This method processes the provided option's path and interprets its data - * using the system services. It returns a list of policies for each path node - * by using sudo access to ensure the actions are performed with the required permissions. - * - * @param {Object} option - An object containing the path and data used for policy retrieval. - * @returns {Promise} A promise that resolves to an array of policy objects for the given option. - */ const policy = await svc_su.sudo(async () => { return await svc_systemData.interpret(option.data); }); diff --git a/src/backend/src/services/runtime-analysis/ExpectationService.js b/src/backend/src/services/runtime-analysis/ExpectationService.js index ee5068ca..28e58d42 100644 --- a/src/backend/src/services/runtime-analysis/ExpectationService.js +++ b/src/backend/src/services/runtime-analysis/ExpectationService.js @@ -141,7 +141,6 @@ class ExpectationService extends BaseService { * @returns {void} */ - ```javascript // The comment should be placed above the method at line 68 setInterval(() => { this.purgeExpectations_(); diff --git a/src/backend/src/services/runtime-analysis/LogService.js b/src/backend/src/services/runtime-analysis/LogService.js index 0e98e68e..1c26696d 100644 --- a/src/backend/src/services/runtime-analysis/LogService.js +++ b/src/backend/src/services/runtime-analysis/LogService.js @@ -17,24 +17,18 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -const logSeverity = (ordinal, label, esc, winst) => ({ ordinal, label, esc, winst }); // Defines a function to create log severity objects used for logging // The function is used to define various log levels and their properties -const LOG_LEVEL_ERRO = logSeverity(0, 'ERRO', '31;1', 'error'); -// Defines the log level for error messages, used throughout the logging system. -const LOG_LEVEL_WARN = logSeverity(1, 'WARN', '33;1', 'warn'); -// Defines the WARN log level, used for warning messages in the logging system. -const LOG_LEVEL_INFO = logSeverity(2, 'INFO', '36;1', 'info'); -// Defines the log level constant for informational messages. Used throughout the code for logging informational events. -const LOG_LEVEL_TICK = logSeverity(10, 'TICK', '34;1', 'info'); -// LOG_LEVEL_TICK is a constant defining a specific log level for tick events, used for periodic logging. -const LOG_LEVEL_DEBU = logSeverity(4, 'DEBU', '37;1', 'debug'); -// Defines the debug log level used for detailed logging and debugging purposes. +const logSeverity = (ordinal, label, esc, winst) => ({ ordinal, label, esc, winst }); -```javascript +// TODO: support the following annotation in tools/comment-writer/main.js +// AI-COMMENT-WRITER // SKIP 7 LINES +const LOG_LEVEL_ERRO = logSeverity(0, 'ERRO', '31;1', 'error'); +const LOG_LEVEL_WARN = logSeverity(1, 'WARN', '33;1', 'warn'); +const LOG_LEVEL_INFO = logSeverity(2, 'INFO', '36;1', 'info'); +const LOG_LEVEL_TICK = logSeverity(10, 'TICK', '34;1', 'info'); const LOG_LEVEL_DEBU = logSeverity(4, 'DEBU', '37;1', 'debug'); const LOG_LEVEL_NOTICEME = logSeverity(4, 'NOTICE_ME', '33;1', 'error'); -// Defines a log level constant for special notifications, used in logging functions. const LOG_LEVEL_SYSTEM = logSeverity(4, 'SYSTEM', '33;1', 'system'); const winston = require('winston'); @@ -566,7 +560,6 @@ class LogService extends BaseService { * * @param {Object} commands - The commands object to register commands to. */ - ``` async _init () { const config = this.global_config; diff --git a/src/backend/src/services/runtime-analysis/PagerService.js b/src/backend/src/services/runtime-analysis/PagerService.js index 296b959a..07d9d67d 100644 --- a/src/backend/src/services/runtime-analysis/PagerService.js +++ b/src/backend/src/services/runtime-analysis/PagerService.js @@ -33,11 +33,6 @@ const { Context } = require('../../util/context'); * command registration. */ class PagerService extends BaseService { - /** - * Class representing a PagerService. - * @extends BaseService - */ - class PagerService extends BaseService { async _construct () { this.config = this.global_config.pager; this.alertHandlers_ = []; @@ -73,7 +68,6 @@ class PagerService extends BaseService { * * @method onInit */ - ``` onInit () { if ( this.config.pagerduty && this.config.pagerduty.enabled ) { this.alertHandlers_.push(async alert => { diff --git a/src/backend/src/services/thumbnails/HTTPThumbnailService.js b/src/backend/src/services/thumbnails/HTTPThumbnailService.js index 48b09463..2ce89237 100644 --- a/src/backend/src/services/thumbnails/HTTPThumbnailService.js +++ b/src/backend/src/services/thumbnails/HTTPThumbnailService.js @@ -316,10 +316,6 @@ class HTTPThumbnailService extends BaseService { this.status = this.constructor.STATUS_RUNNING; - Here's the comment for the constant definition at line 189: - - ```javascript - // LIMIT: Maximum file size in bytes for thumbnail processing. const LIMIT = this.LIMIT; // Grab up to 400MB worth of files to send to the thumbnail service.