mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
w: upgrade deps
This commit is contained in:
1 parent
47499bdcd6
commit
0824487342
19 files changed
+132
-88
No files matched your search
@@ -94,9 +94,14 @@ bus.on('app/started', () => {
|
||||
});
|
||||
|
||||
class ApiHandler extends Handler {
|
||||
async query(q: string, variables: any) {
|
||||
// FIXME validation for fields like ObjectID doesn't work.
|
||||
return graphql(schema, q, root, this, variables);
|
||||
query(q: string, variables: any) {
|
||||
return graphql({
|
||||
schema,
|
||||
source: q,
|
||||
rootValue: root,
|
||||
contextValue: this,
|
||||
variableValues: variables,
|
||||
});
|
||||
}
|
||||
|
||||
async get() {
|
||||
|
||||
@@ -105,14 +105,9 @@ class DomainUserHandler extends ManageHandler {
|
||||
rudocs[ud.role || 'default'].push(ud);
|
||||
}
|
||||
const rolesSelect = roles.map((role) => [role._id, role._id]);
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
['domain', null],
|
||||
['domain_user', null],
|
||||
];
|
||||
this.response.template = 'domain_user.html';
|
||||
this.response.body = {
|
||||
roles, rolesSelect, rudocs, udict, path, domain: this.domain,
|
||||
roles, rolesSelect, rudocs, udict, domain: this.domain,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -134,14 +129,9 @@ class DomainUserHandler extends ManageHandler {
|
||||
class DomainPermissionHandler extends ManageHandler {
|
||||
async get({ domainId }) {
|
||||
const roles = await domain.getRoles(domainId);
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
['domain', null],
|
||||
['domain_permission', null],
|
||||
];
|
||||
this.response.template = 'domain_permission.html';
|
||||
this.response.body = {
|
||||
roles, PERMS_BY_FAMILY, domain: this.domain, path, log2,
|
||||
roles, PERMS_BY_FAMILY, domain: this.domain, log2,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -179,10 +169,8 @@ class DomainRoleHandler extends ManageHandler {
|
||||
|
||||
@param('roles', Types.Array)
|
||||
async postDelete(domainId: string, roles: string[]) {
|
||||
for (const role of roles) {
|
||||
if (['root', 'default', 'guest'].includes(role)) {
|
||||
throw new ValidationError('role');
|
||||
}
|
||||
if (Set.intersection(new Set(roles), new Set(['root', 'default', 'guest'])).size > 0) {
|
||||
throw new ValidationError('role', null, 'You cannot delete root, default or guest roles');
|
||||
}
|
||||
await domain.deleteRoles(domainId, roles);
|
||||
this.back();
|
||||
|
||||
@@ -24,16 +24,12 @@ async function getStatus() {
|
||||
|
||||
class StatusHandler extends Handler {
|
||||
async get() {
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
['status', null],
|
||||
];
|
||||
const stats = await getStatus();
|
||||
for (const stat of stats) {
|
||||
if (!stat.battery.hasBattery) stat.battery = 'No battery';
|
||||
else stat.battery = `${stat.battery.type} ${stat.battery.model} ${stat.battery.percent}%${stat.battery.isCharging ? ' Charging' : ''}`;
|
||||
}
|
||||
this.response.body = { stats, path };
|
||||
this.response.body = { stats };
|
||||
this.response.template = 'status.html';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type fs from 'fs';
|
||||
import type * as Koa from 'koa';
|
||||
import type { Dictionary, NumericDictionary } from 'lodash';
|
||||
import type { ItemBucketMetadata } from 'minio';
|
||||
import type { Cursor, ObjectID } from 'mongodb';
|
||||
@@ -682,10 +681,3 @@ declare global {
|
||||
var Hydro: HydroGlobal; // eslint-disable-line
|
||||
var addons: string[]; // eslint-disable-line
|
||||
}
|
||||
|
||||
declare module 'koa' {
|
||||
interface Request extends Koa.BaseRequest {
|
||||
body?: any;
|
||||
files?: import('formidable').Files;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,6 @@ class DomainModel {
|
||||
@ArgMethod
|
||||
static async getList(domainIds: string[]) {
|
||||
const r: Record<string, DomainDoc | null> = {};
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const tasks = [];
|
||||
for (const domainId of domainIds) tasks.push(DomainModel.get(domainId).then((ddoc) => { r[domainId] = ddoc; }));
|
||||
await Promise.all(tasks);
|
||||
@@ -146,12 +145,11 @@ class DomainModel {
|
||||
}
|
||||
}
|
||||
if (count) {
|
||||
for (const role of roles) {
|
||||
if (!['default', 'guest'].includes(role._id)) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
role.count = await DomainModel.countUser(ddoc._id, role._id);
|
||||
}
|
||||
}
|
||||
await Promise.all(roles.map(async (role) => {
|
||||
if (['default', 'guest'].includes(role._id)) return role;
|
||||
role.count = await DomainModel.countUser(ddoc._id, role._id);
|
||||
return role;
|
||||
}));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ export type NumberKeys<O> = {
|
||||
export type ArrayKeys<O, P = any> = {
|
||||
[K in keyof O]: P[] extends O[K] ? K : never
|
||||
}[keyof O];
|
||||
export type NestKeys<O, T = any, S = any[]> = O extends object ? O extends S ? never : {
|
||||
[K in keyof O]: (O[K] extends T ? K : never) | `${K & string}.${NestKeys<O[K], T, S | O>}`
|
||||
}[keyof O] & string : never;
|
||||
export type Value<O, V = ''> = {
|
||||
[K in keyof O]: V
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user