chore: update typedefs and fix dbkv issue (#1840)

* chore: update typedefs

* fix:dbkv decr
This commit is contained in:
Daniel Salazar
2025-10-27 18:13:49 -07:00
committed by GitHub
parent cd5d0ca5dc
commit d1ae2bfe80
4 changed files with 49 additions and 83 deletions
+44 -78
View File
@@ -6,6 +6,47 @@ import { defineConfig } from 'eslint/config';
import globals from 'globals';
import controlStructureSpacing from './control-structure-spacing.js';
const rules = {
'no-unused-vars': ['error', {
'vars': 'all',
'args': 'after-used',
'caughtErrors': 'all',
'ignoreRestSiblings': false,
'ignoreUsingDeclarations': false,
'reportUsedIgnorePattern': false,
'argsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_',
}],
curly: ['error', 'multi-line'],
'@stylistic/curly-newline': ['error', 'always'],
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/indent': ['error', 4, {
CallExpression: {
arguments: 4,
},
}],
'@stylistic/indent-binary-ops': ['error', 4],
'@stylistic/array-bracket-newline': ['error', 'consistent'],
'@stylistic/semi': ['error', 'always'],
'@stylistic/quotes': ['error', 'single', { 'avoidEscape': true }],
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
'@stylistic/arrow-spacing': ['error', { before: true, after: true }],
'@stylistic/space-before-function-paren': ['error', { 'anonymous': 'never', 'named': 'never', 'asyncArrow': 'always', 'catch': 'always' }],
'@stylistic/key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }],
'@stylistic/keyword-spacing': ['error', { 'before': true, 'after': true }],
'@stylistic/no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
'@stylistic/comma-spacing': ['error', { 'before': false, 'after': true }],
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
'@stylistic/dot-location': ['error', 'property'],
'@stylistic/space-infix-ops': ['error'],
'no-undef': 'error',
'custom/control-structure-spacing': 'error',
'@stylistic/no-trailing-spaces': 'error',
};
export default defineConfig([
// TypeScript support block
{
@@ -39,47 +80,7 @@ export default defineConfig([
{
files: ['src/backend/**/*.{js,mjs,cjs,ts}'],
languageOptions: { globals: globals.node },
rules: {
'no-unused-vars': ['error', {
'vars': 'all',
'args': 'after-used',
'caughtErrors': 'all',
'ignoreRestSiblings': false,
'ignoreUsingDeclarations': false,
'reportUsedIgnorePattern': false,
'argsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_',
}],
curly: ['error', 'multi-line'],
'@stylistic/curly-newline': ['error', 'always'],
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/indent': ['error', 4, {
CallExpression: {
arguments: 4,
},
}],
'@stylistic/indent-binary-ops': ['error', 4],
'@stylistic/array-bracket-newline': ['error', 'consistent'],
'@stylistic/semi': ['error', 'always'],
'@stylistic/quotes': ['error', 'single', { 'avoidEscape': true }],
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
'@stylistic/arrow-spacing': ['error', { before: true, after: true }],
'@stylistic/space-before-function-paren': ['error', { 'anonymous': 'never', 'named': 'never', 'asyncArrow': 'always', 'catch': 'always' }],
'@stylistic/key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }],
'@stylistic/keyword-spacing': ['error', { 'before': true, 'after': true }],
'@stylistic/no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
'@stylistic/comma-spacing': ['error', { 'before': false, 'after': true }],
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
'@stylistic/dot-location': ['error', 'property'],
'@stylistic/space-infix-ops': ['error'],
'no-undef': 'error',
'custom/control-structure-spacing': 'error',
'@stylistic/no-trailing-spaces': 'error',
},
rules,
extends: ['js/recommended'],
plugins: {
js,
@@ -92,46 +93,11 @@ export default defineConfig([
globals: {
extension: 'readonly',
config: 'readonly',
global_config: 'readonly',
...globals.node,
},
},
rules: {
'no-unused-vars': ['error', {
'vars': 'all',
'args': 'after-used',
'caughtErrors': 'all',
'ignoreRestSiblings': false,
'ignoreUsingDeclarations': false,
'reportUsedIgnorePattern': false,
'argsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_',
}],
curly: ['error', 'multi-line'],
'@stylistic/curly-newline': ['error', 'always'],
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/indent': ['error', 4, { CallExpression: { arguments: 4 } }],
'@stylistic/indent-binary-ops': ['error', 4],
'@stylistic/array-bracket-newline': ['error', 'consistent'],
'@stylistic/semi': ['error', 'always'],
'@stylistic/quotes': ['error', 'single', { 'avoidEscape': true }],
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
'@stylistic/arrow-spacing': ['error', { before: true, after: true }],
'@stylistic/space-before-function-paren': ['error', { 'anonymous': 'never', 'named': 'never', 'asyncArrow': 'always', 'catch': 'always' }],
'@stylistic/key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }],
'@stylistic/keyword-spacing': ['error', { 'before': true, 'after': true }],
'@stylistic/no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
'@stylistic/comma-spacing': ['error', { 'before': false, 'after': true }],
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
'@stylistic/dot-location': ['error', 'property'],
'@stylistic/space-infix-ops': ['error'],
'no-undef': 'error',
'custom/control-structure-spacing': 'error',
'@stylistic/no-trailing-spaces': 'error',
},
rules,
extends: ['js/recommended'],
plugins: {
js,
+1 -1
View File
@@ -51,7 +51,7 @@ type StripPrefix<TPrefix extends string, T extends string> = T extends `${TPrefi
// TODO DS: define this globally in core to use it there too
interface ServiceNameMap {
'meteringService': Pick<MeteringServiceWrapper, 'meteringService'> & MeteringService // TODO DS: squash into a single class without wrapper
'puter-kv': DBKVStore
'puter-kvstore': DBKVStore
'su': SUService
}
interface Extension extends RouterMethods {
+2 -2
View File
@@ -1,8 +1,8 @@
import type { Actor } from "./auth/Actor";
import type { Actor } from './auth/Actor';
export class SUService {
_construct(): void;
get_system_actor(): Promise<any>;
get_system_actor(): Promise<Actor>;
sudo<T>(callback: () => Promise<T>): Promise<T>;
sudo<T>(actorOrCallback: Actor, callback: () => Promise<T>): Promise<T>;
}
@@ -309,8 +309,8 @@ export class DBKVStore {
return currVal as T extends { '': number } ? number : RecursiveRecord<number>;
}
async decr(...params: Parameters<typeof DBKVStore.prototype.incr>): ReturnType<typeof DBKVStore.prototype.incr> {
return await this.incr(...params);
async decr({ key, pathAndAmountMap }: Parameters<typeof DBKVStore.prototype.incr>[0]): ReturnType<typeof DBKVStore.prototype.incr> {
return await this.incr({ key, pathAndAmountMap: Object.fromEntries(Object.entries(pathAndAmountMap).map(([k, v]) => [k, -v])) });
}
async #expireat(key: string, timestamp: number){