mirror of
https://github.com/Rolands-Laucis/Socio.git
synced 2026-05-15 14:15:57 -06:00
went back to old tsconfig
This commit is contained in:
parent
7be4043e45
commit
17b9d45a3c
12 changed files with 56 additions and 49 deletions
|
|
@ -1,8 +1,8 @@
|
|||
//If God did not exist, it would be necessary to invent Him. /Voltaire/
|
||||
|
||||
import { E } from "./logging";
|
||||
import { SocioClient, SocioClientOptions } from './core-client';
|
||||
import { CoreMessageKind } from './utils';
|
||||
import { E } from "./logging.js";
|
||||
import { SocioClient, SocioClientOptions } from './core-client.js';
|
||||
import { CoreMessageKind } from './utils.js';
|
||||
|
||||
//types
|
||||
type AdminClientOptions = { url:string, client_secret: string, socio_client_opts: SocioClientOptions }
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
//If God did not exist, it would be necessary to invent Him. /Voltaire/
|
||||
|
||||
import { LogHandler, E } from "./logging";
|
||||
import { LogHandler, E } from "./logging.js";
|
||||
import { WebSocket as nodeWebSocket } from "ws";
|
||||
import { yaml_parse, yaml_stringify } from './utils';
|
||||
import { yaml_parse, yaml_stringify } from './utils.js';
|
||||
|
||||
//types
|
||||
import type { id, PropValue, LoggingOpts } from './types.d.ts';
|
||||
import { ClientMessageKind } from './core-client';
|
||||
import { ClientMessageKind } from './core-client.js';
|
||||
type MessageDataObj = { id: id, status?: string, result?: string | object | boolean | PropValue, data?: object };
|
||||
type AdminClientOptions = { url: string, client_secret: string } & LoggingOpts;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
//types
|
||||
import type { ClientID, S_SERV_data, ServerMessageDataObj } from "./types.d.ts";
|
||||
import type { SocioSession } from "./core-session";
|
||||
import { E, log } from "./logging";
|
||||
import type { SocioSession } from "./core-session.js";
|
||||
import { E, log } from "./logging.js";
|
||||
export type User = { client_id: ClientID, username?: string };
|
||||
export type ChatRoomMessage = { user: User, ts: number, text:string};
|
||||
type ServerInterfaceFunction = (client_ids: string[], data: object) => void;
|
||||
|
|
@ -43,7 +43,7 @@ export class ServerChatRoom{
|
|||
const new_message = { user: { client_id }, ts: (new Date()).getTime(), text };
|
||||
this.#messages.add(new_message);
|
||||
if(this.#messages.size > this.history_length)
|
||||
this.#messages.delete(this.#messages.values().next().value); //remove the first message, if over history limit
|
||||
this.#messages.delete(this.#messages.values().next().value as ChatRoomMessage); //remove the first message, if over history limit
|
||||
|
||||
//send new message to clients
|
||||
const clients = [...this.#users.values()].map(c => c.client_id); //could filter out the current client as well, but that actually complicates things more than solves
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import pako from 'pako'; //https://github.com/nodeca/pako
|
||||
import * as diff_lib from 'recursive-diff'; //https://www.npmjs.com/package/recursive-diff
|
||||
|
||||
import { LogHandler, E, err, log, info, done } from './logging';
|
||||
import { yaml_parse, yaml_stringify, clamp, CoreMessageKind } from './utils';
|
||||
import { LogHandler, E, err, log, info, done } from './logging.js';
|
||||
import { yaml_parse, yaml_stringify, clamp, CoreMessageKind } from './utils.js';
|
||||
|
||||
//types
|
||||
import type { id, PropKey, PropValue, PropOpts, Bit, ClientLifecycleHooks, ClientID, SocioFiles, LoggingOpts, ClientSubscribeOpts, data_result_block } from './types.d.ts';
|
||||
|
|
@ -16,7 +16,7 @@ import type { data_base, C_RES_data, C_CON_data, C_UPD_data, C_AUTH_data, C_GET_
|
|||
import type { S_SUB_data, S_UNSUB_data, S_SQL_data, S_AUTH_data, S_GET_PERM_data, S_PROP_SUB_data, S_PROP_UNSUB_data, S_PROP_GET_data, S_PROP_SET_data, S_PROP_REG_data, S_RECON_GET_data, S_RECON_USE_data, S_UP_FILES_data, S_GET_FILES_data } from './types.d.ts';
|
||||
import type { ClientMessageDataObj } from './types.d.ts';
|
||||
|
||||
import type { RateLimit } from './ratelimit';
|
||||
import type { RateLimit } from './ratelimit.js';
|
||||
type SubscribeCallbackObjectSuccess = ((res: object | object[]) => void) | null;
|
||||
type SubscribeCallbackObject = { success: SubscribeCallbackObjectSuccess, error?: Function};
|
||||
type QueryObject = ClientSubscribeOpts & { onUpdate: SubscribeCallbackObject };
|
||||
|
|
@ -499,18 +499,27 @@ export class SocioClient extends LogHandler {
|
|||
// async Prop(prop_name: PropKey){
|
||||
// const client_this = this; //use for inside the Proxy scope
|
||||
// const prop_proxy = new Proxy(await this.GetProp(prop_name), {
|
||||
// async get(p: PropValue, property) {
|
||||
// const res = await client_this.GetProp.bind(client_this)(prop_name);
|
||||
// return res?.result?.success === 1 ? res?.result?.res[property] : p[property];
|
||||
// get(p: PropValue, property) {
|
||||
// return p[property];
|
||||
// // const res = await client_this.GetProp.bind(client_this)(prop_name);
|
||||
// // return res?.result?.success === 1 ? res?.result?.res[property] : p[property];
|
||||
// },
|
||||
// // @ts-expect-error
|
||||
// async set(p: PropValue, property, new_val) { //ive run tests in other projects and the async set does work fine. TS doesnt want to allow it for some reason
|
||||
// p[property] = new_val;
|
||||
// return (await client_this.SetProp.bind(client_this)(prop_name, p))?.result?.success === 1;
|
||||
// //ive run tests in other projects and the async set does work fine. TS doesnt want to allow it for some reason
|
||||
// set(p: PropValue, property, new_val) {
|
||||
// //the sub will run this too, which means the value would've already been set
|
||||
// if (p[property] !== new_val){
|
||||
// p[property] = new_val;
|
||||
// client_this.SetProp.bind(client_this)(prop_name, p);
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// // return (await client_this.SetProp.bind(client_this)(prop_name, p))?.result?.success === 1;
|
||||
// }
|
||||
// });
|
||||
|
||||
// this.SubscribeProp(prop_name, (new_val) => { prop_proxy[]})
|
||||
// this.SubscribeProp(prop_name, (new_val) => {
|
||||
// for(const [key, val] of Object.entries(new_val)) prop_proxy[key] = val; //set each key, bcs cant just assign the new obj, bcs then it wouldnt be a proxy anymore
|
||||
// });
|
||||
// return prop_proxy;
|
||||
// }
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ import { WebSocketServer } from 'ws'; //https://github.com/websockets/ws https:/
|
|||
import * as diff_lib from 'recursive-diff'; //https://www.npmjs.com/package/recursive-diff
|
||||
|
||||
//mine
|
||||
import { QueryIsSelect, ParseQueryTables, ParseQueryVerb } from './sql-parsing';
|
||||
import { SocioStringParse, GetAllMethodNamesOf, yaml_parse } from './utils';
|
||||
import { E, LogHandler, err, log, info, done } from './logging';
|
||||
import { UUID, type SocioSecurity } from './secure';
|
||||
import { SocioSession, type SubObj } from './core-session';
|
||||
import { RateLimiter } from './ratelimit';
|
||||
import { CoreMessageKind } from './utils';
|
||||
import { QueryIsSelect, ParseQueryTables, ParseQueryVerb } from './sql-parsing.js';
|
||||
import { SocioStringParse, GetAllMethodNamesOf, yaml_parse } from './utils.js';
|
||||
import { E, LogHandler, err, log, info, done } from './logging.js';
|
||||
import { UUID, type SocioSecurity } from './secure.js';
|
||||
import { SocioSession, type SubObj } from './core-session.js';
|
||||
import { RateLimiter } from './ratelimit.js';
|
||||
import { CoreMessageKind } from './utils.js';
|
||||
|
||||
//types
|
||||
import type { ServerOptions, WebSocket, AddressInfo } from 'ws';
|
||||
|
|
@ -25,9 +25,9 @@ import type { data_base, S_SUB_data, ServerMessageDataObj, S_UNSUB_data, S_SQL_d
|
|||
import type { C_RES_data, C_CON_data, C_UPD_data, C_AUTH_data, C_GET_PERM_data, C_PROP_UPD_data, C_RECON_Data, C_RECV_FILES_Data } from './types.d.ts'; //types over network for the data object
|
||||
|
||||
import type { id, PropKey, PropValue, PropAssigner, PropOpts, ClientID, FS_Util_Response, ServerLifecycleHooks, LoggingOpts, Bit, SessionOpts } from './types.d.ts';
|
||||
import { ClientMessageKind } from './core-client';
|
||||
import type { RateLimit } from './ratelimit';
|
||||
import type { SocioStringObj } from './sql-parsing';
|
||||
import { ClientMessageKind } from './core-client.js';
|
||||
import type { RateLimit } from './ratelimit.js';
|
||||
import type { SocioStringObj } from './sql-parsing.js';
|
||||
export type QueryFuncParams = { id?: id, sql: string, params?: any };
|
||||
export type QueryFunction = (client: SocioSession, id: id, sql: string, params?: any) => Promise<object>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
//Homo vitae commodatus non donatus est. - Man's life is lent, not given. /Syrus/
|
||||
|
||||
import { LogHandler, E, log, info, done } from './logging';
|
||||
import { RateLimiter } from './ratelimit';
|
||||
import { yaml_stringify, FastHash } from './utils';
|
||||
import { ClientMessageKind } from './core-client';
|
||||
import { LogHandler, E, log, info, done } from './logging.js';
|
||||
import { RateLimiter } from './ratelimit.js';
|
||||
import { yaml_stringify, FastHash } from './utils.js';
|
||||
import { ClientMessageKind } from './core-client.js';
|
||||
|
||||
//types
|
||||
import type { WebSocket } from 'ws'; //https://github.com/websockets/ws https://github.com/websockets/ws/blob/master/doc/ws.md
|
||||
import type { id, Bit, LoggingOpts, SessionOpts, Auth_Hook } from './types.d.ts';
|
||||
import type { RateLimit } from './ratelimit';
|
||||
import type { RateLimit } from './ratelimit.js';
|
||||
|
||||
export type SubObj = {
|
||||
tables: string[],
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ export function SaveFilesToDiskPath(string_array_path: string[], files: SocioFil
|
|||
if (!string_array_path || !files) return rej({ result: 0, error: 'function arguments are falsy' });
|
||||
for (const [filename, file_data] of files.entries()) {
|
||||
const file_path = os_path.join(...string_array_path, filename);
|
||||
//@ts-expect-error
|
||||
const bin = pako.inflate(Buffer.from(file_data.bin, 'base64')); //file_data.bin should be a base64 encoded string, so make a buffer from it and decompress with pako
|
||||
const bin = pako.inflate(Buffer.from(file_data.bin, 'base64').buffer as ArrayBuffer); //file_data.bin should be a base64 encoded string, so make a buffer from it and decompress with pako
|
||||
fs.writeFileSync(file_path, bin, { flag: 'w' });
|
||||
}
|
||||
res({ result: 1 });
|
||||
|
|
@ -28,8 +27,7 @@ export function ReadFilesFromDisk(file_paths: string[]): Promise<FS_Util_Respons
|
|||
for (const path of file_paths) {
|
||||
const filename = os_path.basename(path);
|
||||
const file = fs.readFileSync(path);
|
||||
//@ts-expect-error
|
||||
files.set(filename, { meta: { size: file.byteLength }, bin: Buffer.from(pako.deflate(file)).toString('base64')}); //compress the file binary and conver to base64 string
|
||||
files.set(filename, { meta: { size: file.byteLength }, bin: Buffer.from(pako.deflate(file.buffer as ArrayBuffer)).toString('base64')}); //compress the file binary and conver to base64 string
|
||||
}
|
||||
res({ result: 1, files });
|
||||
} catch (e: any) { rej({ result: 0, error: e }); }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//You can always count on Americans to do the right thing - after they've tried everything else. /Winston Churchill/
|
||||
|
||||
import { E, LogHandler } from "./logging";
|
||||
import { E, LogHandler } from "./logging.js";
|
||||
|
||||
type RateLimitTimeUnit = { ms?: number, seconds?: number, minutes?: number } //can specify any combination of these
|
||||
export type RateLimit = { n: number } & RateLimitTimeUnit;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
import MagicString from 'magic-string'; //https://github.com/Rich-Harris/magic-string
|
||||
import { randomUUID, createCipheriv, createDecipheriv, getCiphers, randomBytes, createHash, type CipherGCMTypes } from 'crypto'; //https://nodejs.org/api/crypto.html
|
||||
import { socio_string_regex } from './sql-parsing';
|
||||
import { LogHandler, E, log, info, done } from './logging';
|
||||
import { socio_string_regex } from './sql-parsing.js';
|
||||
import { LogHandler, E, log, info, done } from './logging.js';
|
||||
import { extname } from 'path';
|
||||
|
||||
//types
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// To err is human; to persist in it - diabolial. /Lucius Annaeus Seneca/
|
||||
import { soft_error } from './logging';
|
||||
import { soft_error } from './logging.js';
|
||||
|
||||
export type SocioStringObj = { str: string, markers: string[] };
|
||||
//socio template literal tag. Dummy function, that doesnt ever get used. See Socio <= 1.3.4 on github for a working implementation of this function.
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
// "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. */
|
||||
"moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
// "module": "NodeNext", /* Specify what module code is generated. */
|
||||
"module": "commonjs",
|
||||
"module": "NodeNext", /* Specify what module code is generated. */
|
||||
// "module": "commonjs",
|
||||
"rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
|
|
@ -88,8 +88,8 @@
|
|||
// "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. */
|
||||
// "noUnusedLocals": false, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": false, /* 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. */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//I ask not for a lighter burden, but for broader shoulders. -Atlas, when asking Zeus for sympathy.
|
||||
|
||||
import type { QueryMarker } from "./types.d.ts";
|
||||
import type { SocioStringObj } from "./sql-parsing";
|
||||
import type { SocioStringObj } from "./sql-parsing.js";
|
||||
|
||||
export enum CoreMessageKind {
|
||||
SUB, UNSUB, SQL, PING, AUTH, GET_PERM, PROP_SUB, PROP_UNSUB, PROP_GET, PROP_SET, PROP_REG, SERV, ADMIN, RECON, UP_FILES, GET_FILES
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue