chore: prettier update

This commit is contained in:
Ben Allfree 2023-09-10 16:33:38 -07:00
parent f0f7dee969
commit 4e22e62706
74 changed files with 535 additions and 489 deletions

View File

@ -1,3 +1,5 @@
.svelte-kit
dist
mount
mount
.data
attic

View File

@ -32,18 +32,19 @@
"semi": false,
"useTabs": false,
"singleQuote": true,
"trailingComma": "all",
"plugins": [
"./node_modules/prettier-plugin-organize-imports",
"./node_modules/prettier-plugin-svelte"
"./node_modules/prettier-plugin-organize-imports/index.js",
"./node_modules/prettier-plugin-svelte/plugin.js"
]
},
"devDependencies": {
"chokidar-cli": "^3.0.0",
"concurrently": "^7.4.0",
"patch-package": "^6.5.0",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.1.1",
"prettier-plugin-svelte": "^2.7.0",
"concurrently": "^8.2.1",
"patch-package": "^8.0.0",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-svelte": "^3.0.3",
"tslib": "^2.6.2",
"typescript": "^5.0"
},

View File

@ -18,7 +18,7 @@ export const addDevCommand = (program: Command) => {
.description('Build the JS bundle')
.option(
'--src <path>',
`Path to source (default: <project>/src/index.{ts|js})`
`Path to source (default: <project>/src/index.{ts|js})`,
)
.option('--dist <path>', `Path to dist (default: <project>/dist/index.js)`)
.action(async (options) => {

View File

@ -22,7 +22,7 @@ export const addDevCommand = (program: Command) => {
.description('Watch for source code changes in development mode')
.option(
'--src <path>',
`Path to source (default: <project>/src/index.{ts|js})`
`Path to source (default: <project>/src/index.{ts|js})`,
)
.option('--dist <path>', `Path to dist (default: <project>/dist/index.js)`)
.option('--host', 'PocketBase host', DEFAULT_PB_DEV_URL)

View File

@ -70,7 +70,7 @@ export const addPublishCommand = (program: Command) => {
.description('Publish JS bundle to PBScript-enabled PocketBase instance')
.option(
'--dist <src>',
`Path to dist bundle (default: <project>/dist/index.js)`
`Path to dist bundle (default: <project>/dist/index.js)`,
)
.option('--host <host>', `PocketBase host (default: ${DEFAULT_PB_DEV_URL})`)
.action(async (options) => {

View File

@ -6,7 +6,7 @@ export type FieldStruct<TRec extends Pb_Any_Record_Db> = Partial<{
}>
export const buildQueryFilter = <TRec extends Pb_Any_Record_Db>(
fields: FieldStruct<TRec>
fields: FieldStruct<TRec>,
): Pb_QueryParams => {
const filter = map(fields, (v, k) => `${k.toString()} = "${v}"`).join(' and ')
return { filter }

View File

@ -5,14 +5,14 @@ import {
Pb_Any_Record_Db,
Pb_Untrusted_Db,
} from '../schema/base'
import { buildQueryFilter, FieldStruct } from './buildQueryFilter'
import { FieldStruct, buildQueryFilter } from './buildQueryFilter'
export const getOne = async <
TRec extends Pb_Any_Record_Db,
TFields extends FieldStruct<TRec> = FieldStruct<TRec>
TFields extends FieldStruct<TRec> = FieldStruct<TRec>,
>(
collectionName: Pb_Any_Collection_Name,
fields: TFields
fields: TFields,
) => {
const queryParams = buildQueryFilter(fields)
const recs = await client.records.getList(collectionName, 1, 2, queryParams)

View File

@ -6,14 +6,14 @@ export const mergeDeep = <TObject>(dst: any, src: TObject) => {
if (dst[k] === undefined) dst[k] = {}
if (!isObject(dst[k])) {
throw new Error(
`${k.toString()} is an object in default, but not in target`
`${k.toString()} is an object in default, but not in target`,
)
}
dst[k] = mergeDeep(dst[k], v)
} else {
if (isObject(dst[k])) {
throw new Error(
`${k.toString()} is an object in target, but not in default`
`${k.toString()} is an object in target, but not in default`,
)
}
// The magic: if the target has no value for this field, use the

View File

@ -2,7 +2,7 @@ import { UnsubFunc } from 'store/backend/types'
import { client } from '../client'
export const onAuthStateChanged = (
cb: (user: typeof client.authStore.model) => void
cb: (user: typeof client.authStore.model) => void,
): UnsubFunc => {
setTimeout(() => cb(client.authStore.model), 0)
return client.authStore.onChange(() => {

View File

@ -8,14 +8,14 @@ import {
Pb_Untrusted_Db,
Pb_UserFields,
} from '../schema/base'
import { buildQueryFilter, FieldStruct } from './buildQueryFilter'
import { FieldStruct, buildQueryFilter } from './buildQueryFilter'
import { mergeDeep } from './mergeDeep'
export const upsert = async <TRow extends Pb_Any_Record_Db>(
collectionName: Pb_Any_Collection_Name,
filterFields: FieldStruct<TRow>,
mutate: (draft: Draft<Pb_UserFields<TRow>>) => void,
defaultRec: Pb_UserFields<TRow>
defaultRec: Pb_UserFields<TRow>,
) => {
const queryParams = buildQueryFilter(filterFields)
const recs = await client.records.getList(collectionName, 1, 2, queryParams)
@ -42,7 +42,7 @@ export const upsert = async <TRow extends Pb_Any_Record_Db>(
}
return carry
},
{} as Partial<Pb_UserFields<TRow>>
{} as Partial<Pb_UserFields<TRow>>,
)
client.records.update(collectionName, id, final)
}

View File

@ -50,7 +50,7 @@ export class CustomAuthStore extends BaseAuthStore {
}
exportToCookie(
options?: SerializeOptions | undefined,
key?: string | undefined
key?: string | undefined,
): string {
throw new Error(`Unsupported exportToCookie()`)
}

View File

@ -1,6 +1,6 @@
export function assertExists<TType>(
v: TType,
message = `Value does not exist`
message = `Value does not exist`,
): asserts v is NonNullable<TType> {
if (typeof v === 'undefined') {
throw new Error(message)

View File

@ -20,11 +20,11 @@ export type ConnectionConfig = {
export const ensureAdminClient = async (
slug: string,
config: ConnectionConfig
config: ConnectionConfig,
) => {
const saver = mkProjectSaver<ConnectionConfig>(slug)
const client = pbClient(config, (session) =>
saver((config) => ({ ...config, session }))
saver((config) => ({ ...config, session })),
)
const _isAdmin = await isAdmin(client)
if (_isAdmin) {
@ -34,7 +34,7 @@ export const ensureAdminClient = async (
const { host } = config
console.log(
`You must be logged in to ${host}/_ as a PocketBase admin to continue.`
`You must be logged in to ${host}/_ as a PocketBase admin to continue.`,
)
while (true) {
@ -55,7 +55,7 @@ export const ensureAdminClient = async (
value.length > 0 ? true : `Enter a password`,
},
],
{ onCancel: () => die(`Exited.`) }
{ onCancel: () => die(`Exited.`) },
)
const { username, password } = response
try {

View File

@ -9,13 +9,13 @@ import { ConnectionConfig } from './ensureAdminClient'
export const pbClient = (
config: ConnectionConfig,
saver: SessionStateSaver
saver: SessionStateSaver,
) => {
const { host, session } = config
const client = new PocketBase(
host,
'en-US',
new CustomAuthStore(session, saver)
new CustomAuthStore(session, saver),
)
return client
}
@ -31,7 +31,7 @@ export const isAdmin = async (client: pocketbaseEs) => {
export const adminPbClient = async (
config: ConnectionConfig,
saver: SessionStateSaver
saver: SessionStateSaver,
) => {
const client = pbClient(config, saver)
if (!client.authStore.isValid) {

View File

@ -38,10 +38,10 @@ export const createCleanupManager = (slug?: string) => {
(c, v) => {
return c.then(() => v())
},
Promise.resolve()
Promise.resolve(),
).catch((e) => {
error(
`Cleanup functions are failing. This should never happen, check all cleanup functions to make sure they are trapping their exceptions.`
`Cleanup functions are failing. This should never happen, check all cleanup functions to make sure they are trapping their exceptions.`,
)
throw e
})

View File

@ -58,7 +58,7 @@ export const createLogger = (config: Partial<Config>) => {
return JSON.stringify(arg)
}
return arg
})
}),
)
}
@ -89,7 +89,7 @@ export const createLogger = (config: Partial<Config>) => {
;[..._buf.slice(_curIdx, MAX_BUF), ..._buf.slice(0, _curIdx)].forEach(
(args) => {
console.error(...args)
}
},
)
console.error(`========== ERROR TRACEBACK END ==============`)
}

View File

@ -1,6 +1,6 @@
export function assertExists<TType>(
v: TType,
message = `Value does not exist`
message = `Value does not exist`,
): asserts v is NonNullable<TType> {
if (typeof v === 'undefined') {
throw new Error(message)
@ -9,7 +9,7 @@ export function assertExists<TType>(
export function assertTruthy<TType>(
v: unknown,
message = `Value should be truthy`
message = `Value should be truthy`,
): asserts v is NonNullable<TType> {
if (!v) {
throw new Error(message)

View File

@ -5,10 +5,10 @@ import { SetReturnType } from 'type-fest'
const limiters: { [lane: string]: Bottleneck } = {}
export const serialAsyncExecutionGuard = <
T extends (...args: any[]) => Promise<any>
T extends (...args: any[]) => Promise<any>,
>(
cb: T,
lane?: SetReturnType<T, string>
lane?: SetReturnType<T, string>,
): T => {
const uuid = uniqueId()
const _lane = lane || (() => uuid)
@ -27,10 +27,10 @@ export const serialAsyncExecutionGuard = <
const singletons: { [_: string]: Promise<any> } = {}
export const singletonAsyncExecutionGuard = <
T extends (...args: any[]) => Promise<any>
T extends (...args: any[]) => Promise<any>,
>(
cb: T,
key: SetReturnType<T, string>
key: SetReturnType<T, string>,
): T => {
const uuid = uniqueId()
const keyFactory = key || (() => uuid)

View File

@ -3,15 +3,15 @@ import { values } from '@s-libs/micro-dash'
export type Unsubscribe = () => void
export type EventSubscriber<TPayload> = (
cb: EventHandler<TPayload>
cb: EventHandler<TPayload>,
) => Unsubscribe
export type EventEmitter<TPayload> = (
payload: TPayload,
stopOnHandled?: boolean
stopOnHandled?: boolean,
) => Promise<boolean>
export type EventHandler<TPayload> = (
payload: TPayload,
isHandled: boolean
isHandled: boolean,
) => boolean | void | Promise<boolean | void>
/**
@ -20,7 +20,7 @@ export type EventHandler<TPayload> = (
* @returns void
*/
export const createEvent = <TPayload>(
defaultHandler?: EventHandler<TPayload>
defaultHandler?: EventHandler<TPayload>,
): [EventSubscriber<TPayload>, EventEmitter<TPayload>] => {
let i = 0
const callbacks: any = {}

View File

@ -1,11 +1,11 @@
export * from './CleanupManager'
export * from './Logger'
export * from './TimerManager'
export * from './assert'
export * from './asyncExecutionGuard'
export * from './CleanupManager'
export * from './events'
export * from './Logger'
export * from './mkSingleton'
export * from './newId'
export * from './pocketbase-client-helpers'
export * from './safeCatch'
export * from './schema'
export * from './TimerManager'

View File

@ -10,9 +10,9 @@ export type SingletonBaseConfig = {
export const mkSingleton = <
TConfig,
TApi extends SingletonApi | Promise<SingletonApi>
TApi extends SingletonApi | Promise<SingletonApi>,
>(
factory: (config: TConfig) => TApi
factory: (config: TConfig) => TApi,
) => {
let _service: TApi | undefined = undefined
return (config?: TConfig) => {

View File

@ -6,11 +6,11 @@ import { logger } from '../Logger'
import { newId } from '../newId'
import { safeCatch } from '../safeCatch'
import {
RPC_COLLECTION,
RpcCommands,
RpcFields,
RpcRecord_Create,
RpcStatus,
RPC_COLLECTION,
} from '../schema'
import type { WatchHelper } from './WatchHelper'
@ -30,7 +30,7 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
const mkRpc = <TPayload extends JsonObject, TResult extends JsonObject>(
cmd: RpcCommands,
schema: JSONSchemaType<TPayload>
schema: JSONSchemaType<TPayload>,
) => {
type ConcreteRpcRecord = RpcFields<TPayload, TResult>
const validator = new Ajv().compile(schema)
@ -39,7 +39,7 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
logger(),
async (
payload: TPayload,
cb?: (data: RecordSubscription<ConcreteRpcRecord>) => void
cb?: (data: RecordSubscription<ConcreteRpcRecord>) => void,
) => {
const _rpcLogger = _logger.create(cmd)
const { dbg, error } = _rpcLogger
@ -82,7 +82,7 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
reject(new ClientResponseError(data.record.result))
}
},
{ initialFetch: false, pollIntervalMs: 100 }
{ initialFetch: false, pollIntervalMs: 100 },
)
dbg(`Creating ${rpcIn.id}`)
const newRpc = await client.collection(RPC_COLLECTION).create(rpcIn)
@ -92,7 +92,7 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
reject(e)
})
})
}
},
)
}

View File

@ -1,9 +1,9 @@
import type pocketbaseEs from 'pocketbase'
import type { RecordSubscription, UnsubscribeFunc } from 'pocketbase'
import { logger } from '../Logger'
import { UnixTimestampMs, createTimerManager } from '../TimerManager'
import { safeCatch } from '../safeCatch'
import { BaseFields, RecordId } from '../schema'
import { createTimerManager, UnixTimestampMs } from '../TimerManager'
export type WatchHelperConfig = {
client: pocketbaseEs
@ -23,7 +23,7 @@ export const createWatchHelper = (config: WatchHelperConfig) => {
collectionName: string,
id: RecordId,
cb: (data: RecordSubscription<TRec>, unsub: UnsubscribeFunc) => void,
options?: Partial<WatchConfig>
options?: Partial<WatchConfig>,
): Promise<UnsubscribeFunc> => {
const { dbg } = logger().create(`watchById:${collectionName}:${id}`)
const config: WatchConfig = {
@ -89,7 +89,7 @@ export const createWatchHelper = (config: WatchHelperConfig) => {
idName: keyof TRec,
idValue: RecordId,
cb: (data: RecordSubscription<TRec>) => void,
initialFetch = true
initialFetch = true,
): Promise<UnsubscribeFunc> => {
let hasUpdate: { [_: RecordId]: boolean } = {}
const unsub = client
@ -112,7 +112,7 @@ export const createWatchHelper = (config: WatchHelperConfig) => {
})
}
return unsub
}
},
)
return { watchById, watchAllById }

View File

@ -9,7 +9,7 @@ export const safeCatch = <TIn extends any[], TOut>(
name: string,
logger: Logger,
cb: (...args: TIn) => Promise<TOut>,
timeoutMs = SAFECATCH_TTL_MS
timeoutMs = SAFECATCH_TTL_MS,
): ((...args: TIn) => Promise<TOut>) => {
return async (...args: TIn) => {
const uuid = `${name}:${nanoid()}`
@ -29,17 +29,17 @@ export const safeCatch = <TIn extends any[], TOut>(
if (e instanceof ClientResponseError) {
if (e.status === 400) {
dbg(
`PocketBase API error: It looks like you don't have permission to make this request. Raw error: ${e}. Payload: ${payload}`
`PocketBase API error: It looks like you don't have permission to make this request. Raw error: ${e}. Payload: ${payload}`,
)
} else if (e.status === 0) {
dbg(
`Client request aborted (possible duplicate request or real error). Raw error: ${e}. Payload: ${payload}`
`Client request aborted (possible duplicate request or real error). Raw error: ${e}. Payload: ${payload}`,
)
} else if (e.status === 404) {
dbg(`Record not found. Raw error: ${e}. Payload: ${payload}`)
} else {
dbg(
`Unknown PocketBase API error. Raw error: ${e}. Payload: ${payload}`
`Unknown PocketBase API error. Raw error: ${e}. Payload: ${payload}`,
)
}
} else {

View File

@ -34,7 +34,7 @@ export type RpcPayloadBase = JsonObject
export type RpcFields<
TPayload extends RpcPayloadBase,
TRes extends JsonObject
TRes extends JsonObject,
> = BaseFields & {
userId: UserId
cmd: string

View File

@ -3,7 +3,7 @@ export * from './Instance'
export * from './InstanceLog'
export * from './Invocation'
export * from './Rpc'
export * from './types'
export * from './User'
export * from './types'
export * from './util'
// gen:export

View File

@ -25,7 +25,7 @@ export const DAEMON_PB_MIGRATIONS_DIR = (() => {
const v = env('DAEMON_PB_MIGRATIONS_DIR')
if (!v) {
throw new Error(
`DAEMON_PB_MIGRATIONS_DIR (${v}) environment variable must be specified`
`DAEMON_PB_MIGRATIONS_DIR (${v}) environment variable must be specified`,
)
}
if (!existsSync(v)) {
@ -38,7 +38,7 @@ export const DAEMON_PB_DATA_DIR = (() => {
const v = env('DAEMON_PB_DATA_DIR')
if (!v) {
throw new Error(
`DAEMON_PB_DATA_DIR (${v}) environment variable must be specified`
`DAEMON_PB_DATA_DIR (${v}) environment variable must be specified`,
)
}
if (!existsSync(v)) {
@ -56,12 +56,12 @@ export const DAEMON_MAX_PORTS = envi(`DAEMON_MAX_PORTS`, 500)
export const DAEMON_PB_BACKUP_SLEEP = envi(`DAEMON_PB_BACKUP_SLEEP`, 100)
export const DAEMON_PB_BACKUP_PAGE_COUNT = envi(
`DAEMON_PB_BACKUP_PAGE_COUNT`,
5
5,
)
export const PH_BIN_CACHE = env(
`PH_BIN_CACHE`,
join(__dirname, `../../../.pbincache`)
join(__dirname, `../../../.pbincache`),
)
export const PH_FTP_PORT = envi('PH_FTP_PORT', 21)

View File

@ -79,7 +79,7 @@ global.EventSource = require('eventsource')
error(`migrate had an unexpected stop. Check it out`)
},
},
{ logger }
{ logger },
)
).exited
info(`Migrating done`)
@ -96,7 +96,7 @@ global.EventSource = require('eventsource')
error(`migrate had an unexpected stop. Check it out`)
},
},
{ logger }
{ logger },
)
/**

View File

@ -20,15 +20,15 @@ export const centralDbService = mkSingleton(
const target = coreInternalUrl
dbg(
`Forwarding proxy request for ${req.url} to central instance ${target}`
`Forwarding proxy request for ${req.url} to central instance ${target}`,
)
proxy.web(req, res, { target })
},
`CentralDbService`
`CentralDbService`,
)
return {
shutdown() {},
}
}
},
)

View File

@ -7,7 +7,7 @@ import {
SSL_KEY,
} from '$constants'
import { clientService, createPbClient } from '$services'
import { mkSingleton, SingletonBaseConfig } from '@pockethost/common'
import { SingletonBaseConfig, mkSingleton } from '@pockethost/common'
import { readFileSync } from 'fs'
import { FtpSrv } from 'ftp-srv'
import { PhFs } from './PhFs'
@ -77,7 +77,7 @@ export const ftpService = mkSingleton((config: FtpConfig) => {
reject(new Error(`Invalid username or password`))
return
}
}
},
)
ftpServer.listen().then(() => {

View File

@ -3,24 +3,24 @@ import { assert } from '$util'
import { InstanceFields, Logger } from '@pockethost/common'
import { compact, map } from '@s-libs/micro-dash'
import {
Mode,
constants,
createReadStream,
createWriteStream,
existsSync,
mkdirSync,
Mode,
} from 'fs'
import { FileStat, FileSystem, FtpConnection } from 'ftp-srv'
import { customAlphabet } from 'nanoid'
import { isAbsolute, join, normalize, resolve, sep } from 'path'
import { PocketbaseClientApi } from '../clientService/PbClient'
import * as fsAsync from './fs-async'
import {
FolderNames,
INSTANCE_ROOT_FOLDER_NAMES,
isInstanceRootFolder,
MAINTENANCE_ONLY_FOLDER_NAMES,
isInstanceRootFolder,
} from './FtpService'
import * as fsAsync from './fs-async'
const nanoid = customAlphabet(`abcdefghijklmnop`)
@ -51,7 +51,7 @@ export class PhFs implements FileSystem {
constructor(
connection: FtpConnection,
client: PocketbaseClientApi,
logger: Logger
logger: Logger,
) {
const cwd = `/`
const root = DAEMON_PB_DATA_DIR
@ -109,12 +109,12 @@ export class PhFs implements FileSystem {
dbg({ rootFolderName, instance })
if (
MAINTENANCE_ONLY_FOLDER_NAMES.includes(
rootFolderName as FolderNames
rootFolderName as FolderNames,
) &&
!instance.maintenance
) {
throw new Error(
`Instance must be in maintenance mode to access ${rootFolderName}`
`Instance must be in maintenance mode to access ${rootFolderName}`,
)
}
fsPathParts.push(rootFolderName)
@ -122,7 +122,7 @@ export class PhFs implements FileSystem {
const rootFolderFsPath = resolve(
join(...fsPathParts)
.replace(UNIX_SEP_REGEX, sep)
.replace(WIN_SEP_REGEX, sep)
.replace(WIN_SEP_REGEX, sep),
)
if (!existsSync(rootFolderFsPath)) {
mkdirSync(rootFolderFsPath)
@ -137,7 +137,7 @@ export class PhFs implements FileSystem {
const fsPath = resolve(
join(...fsPathParts)
.replace(UNIX_SEP_REGEX, sep)
.replace(WIN_SEP_REGEX, sep)
.replace(WIN_SEP_REGEX, sep),
)
// Create FTP client path using unix separator
@ -210,7 +210,7 @@ export class PhFs implements FileSystem {
*/
if (!instance) {
throw new Error(
`Something as gone wrong. An instance without a subdomain is not possible.`
`Something as gone wrong. An instance without a subdomain is not possible.`,
)
}
@ -247,7 +247,7 @@ export class PhFs implements FileSystem {
})
})
.catch(() => null)
})
}),
)
})
.then(compact)
@ -322,7 +322,7 @@ export class PhFs implements FileSystem {
async write(
fileName: string,
options?: { append?: boolean | undefined; start?: any } | undefined
options?: { append?: boolean | undefined; start?: any } | undefined,
) {
const { dbg, error } = this.log
.create(`write`)
@ -366,7 +366,7 @@ export class PhFs implements FileSystem {
async read(
fileName: string,
options: { start?: any } | undefined
options: { start?: any } | undefined,
): Promise<any> {
const { dbg, error } = this.log
.create(`read`)
@ -374,9 +374,8 @@ export class PhFs implements FileSystem {
.breadcrumb(fileName)
dbg(`read`)
const { fsPath, clientPath, pathFromRootFolder } = await this._resolvePath(
fileName
)
const { fsPath, clientPath, pathFromRootFolder } =
await this._resolvePath(fileName)
const { start } = options || {}
@ -433,9 +432,8 @@ export class PhFs implements FileSystem {
.breadcrumb(path)
dbg(`mkdir`)
const { fsPath, clientPath, pathFromRootFolder } = await this._resolvePath(
path
)
const { fsPath, clientPath, pathFromRootFolder } =
await this._resolvePath(path)
/*
Disallow making directories if not inside root folder
@ -485,7 +483,7 @@ export class PhFs implements FileSystem {
Promise.all([
this.restartInstanceGuard(fromRootFolderName, instance),
this.restartInstanceGuard(toRootFolderName, instance),
])
]),
)
}
@ -497,9 +495,8 @@ export class PhFs implements FileSystem {
.breadcrumb(mode.toString())
dbg(`chmod`)
const { fsPath, clientPath, pathFromRootFolder } = await this._resolvePath(
path
)
const { fsPath, clientPath, pathFromRootFolder } =
await this._resolvePath(path)
/*
Disallow making directories if not inside root folder
@ -517,7 +514,7 @@ export class PhFs implements FileSystem {
async restartInstanceGuard(
rootFolderName: FolderNames | undefined,
instance: InstanceFields
instance: InstanceFields,
) {
// Not needed?
// const { dbg, error } = this.log

View File

@ -10,4 +10,4 @@ const mkdir = promisify(fs.mkdir)
const rename = promisify(fs.rename)
const chmod = promisify(fs.chmod)
export { stat, readdir, access, unlink, rmdir, mkdir, rename, chmod }
export { access, chmod, mkdir, readdir, rename, rmdir, stat, unlink }

View File

@ -2,11 +2,11 @@ import { SqliteChangeEvent, sqliteService } from '$services'
import {
InstanceLogFields,
InstanceLogFields_Create,
RecordId,
StreamNames,
newId,
pocketNow,
RecordId,
safeCatch,
StreamNames,
} from '@pockethost/common'
import knex from 'knex'
import { AsyncReturnType } from 'type-fest'
@ -15,7 +15,7 @@ import { DaemonContext } from './DaemonContext'
export type SqliteLogger = AsyncReturnType<typeof createSqliteLogger>
export const createSqliteLogger = async (
logDbPath: string,
context: DaemonContext
context: DaemonContext,
) => {
const { parentLogger } = context
const _dbLogger = parentLogger.create(`${logDbPath}`)
@ -46,7 +46,7 @@ export const createSqliteLogger = async (
const sql = conn('logs').insert(_in).toString()
trace(`Writing log ${JSON.stringify(_in)} ${sql}`)
await db.exec(sql)
}
},
)
const subscribe = (cb: (e: SqliteChangeEvent<InstanceLogFields>) => void) => {
@ -66,7 +66,7 @@ export const createSqliteLogger = async (
const fetch = async (limit: number = 100) => {
return db.all<InstanceLogFields[]>(
`select * from logs order by created desc limit ${limit}`
`select * from logs order by created desc limit ${limit}`,
)
}

View File

@ -17,7 +17,7 @@ const instances: {
export const createInstanceLogger = async (
instanceId: InstanceId,
context: DaemonContext
context: DaemonContext,
) => {
const { parentLogger } = context
const _instanceLogger = parentLogger.create(`InstanceLogger`)
@ -31,7 +31,7 @@ export const createInstanceLogger = async (
DAEMON_PB_DATA_DIR,
instanceId,
'pb_data',
'instance_logs.db'
'instance_logs.db',
)
dbg(`logs path`, logDbPath)
@ -69,5 +69,5 @@ export const instanceLoggerService = mkSingleton(
dbg(`Shutting down`)
},
}
}
},
)

View File

@ -43,7 +43,7 @@ export const createDenoProcess = async (config: DenoProcessConfig) => {
const denoWrite = (
message: string,
stream: StreamNames = StreamNames.Info
stream: StreamNames = StreamNames.Info,
) => {
dbg(`[${instance.id}:${path}:${stream}] ${message}`)
return denoLogger.write(message, stream)
@ -76,12 +76,12 @@ export const createDenoProcess = async (config: DenoProcessConfig) => {
if (code) {
await denoWrite(
`Unexpected 'deno' exit code: ${code}.`,
StreamNames.Error
StreamNames.Error,
)
} else {
await denoWrite(
`Worker has exited with code ${code}`,
StreamNames.System
StreamNames.System,
)
}
resolve()

View File

@ -8,18 +8,18 @@ import {
import { clientService, proxyService } from '$services'
import { mkInternalUrl, now } from '$util'
import {
assertTruthy,
CLEANUP_PRIORITY_LAST,
createCleanupManager,
createTimerManager,
InstanceFields,
InstanceId,
InstanceStatus,
SingletonBaseConfig,
StreamNames,
assertTruthy,
createCleanupManager,
createTimerManager,
mkSingleton,
safeCatch,
serialAsyncExecutionGuard,
SingletonBaseConfig,
StreamNames,
} from '@pockethost/common'
import { map, values } from '@s-libs/micro-dash'
import Bottleneck from 'bottleneck'
@ -30,7 +30,7 @@ import { AsyncReturnType } from 'type-fest'
import { instanceLoggerService } from '../InstanceLoggerService'
import { pocketbaseService } from '../PocketBaseService'
import { createDenoProcess } from './Deno/DenoProcess'
import { portManager, PortManagerConfig } from './PortManager'
import { PortManagerConfig, portManager } from './PortManager'
enum InstanceApiStatus {
Starting = 'starting',
@ -116,13 +116,13 @@ export const instanceService = mkSingleton(
const { id, subdomain, version } = instance
const systemInstanceLogger = instanceServiceLogger.create(
`${subdomain}:${id}:${version}`
`${subdomain}:${id}:${version}`,
)
const { dbg, warn, error, info } = systemInstanceLogger
if (instanceApis[id]) {
throw new Error(
`Attempted to create an instance API when one is already available for ${id}`
`Attempted to create an instance API when one is already available for ${id}`,
)
}
@ -159,7 +159,7 @@ export const instanceService = mkSingleton(
internalUrl: () => {
if (status !== InstanceApiStatus.Healthy) {
throw new Error(
`Attempt to access instance URL when instance is not in a healthy state.`
`Attempt to access instance URL when instance is not in a healthy state.`,
)
}
return internalUrl
@ -167,7 +167,7 @@ export const instanceService = mkSingleton(
startRequest: () => {
if (status !== InstanceApiStatus.Healthy) {
throw new Error(
`Attempt to start an instance request when instance is not in a healthy state.`
`Attempt to start an instance request when instance is not in a healthy state.`,
)
}
return startRequest()
@ -198,7 +198,7 @@ export const instanceService = mkSingleton(
const healthyGuard = () => {
if (status !== InstanceApiStatus.ShuttingDown) return
throw new Error(
`HealthyGuard detected instance is shutting down. Aborting further initialization.`
`HealthyGuard detected instance is shutting down. Aborting further initialization.`,
)
}
@ -207,7 +207,7 @@ export const instanceService = mkSingleton(
*/
const clientLimiter = new Bottleneck({ maxConcurrent: 1 })
const updateInstanceStatus = clientLimiter.wrap(
client.updateInstanceStatus
client.updateInstanceStatus,
)
const updateInstance = clientLimiter.wrap(client.updateInstance)
const createInvocation = clientLimiter.wrap(client.createInvocation)
@ -240,15 +240,15 @@ export const instanceService = mkSingleton(
instance.id,
{
parentLogger: systemInstanceLogger,
}
},
)
const writeUserLog = serialAsyncExecutionGuard(
userInstanceLogger.write,
() => `${instance.id}:userLog`
() => `${instance.id}:userLog`,
)
shutdownManager.add(() =>
writeUserLog(`Shutting down instance`).catch(error)
writeUserLog(`Shutting down instance`).catch(error),
)
/*
@ -277,7 +277,7 @@ export const instanceService = mkSingleton(
version,
onUnexpectedStop: (code, stdout, stderr) => {
warn(
`PocketBase processes exited unexpectedly with ${code}. Putting in maintenance mode.`
`PocketBase processes exited unexpectedly with ${code}. Putting in maintenance mode.`,
)
warn(stdout)
warn(stderr)
@ -287,24 +287,24 @@ export const instanceService = mkSingleton(
})
await writeUserLog(
`Putting instance in maintenance mode because it shut down with return code ${code}. `,
StreamNames.Error
StreamNames.Error,
)
await Promise.all(
stdout.map((data) =>
writeUserLog(data, StreamNames.Error).catch(error)
)
writeUserLog(data, StreamNames.Error).catch(error),
),
)
await Promise.all(
stderr.map((data) =>
writeUserLog(data, StreamNames.Error).catch(error)
)
writeUserLog(data, StreamNames.Error).catch(error),
),
)
})
setImmediate(() => {
_safeShutdown(
new Error(
`PocketBase processes exited unexpectedly with ${code}. Putting in maintenance mode.`
)
`PocketBase processes exited unexpectedly with ${code}. Putting in maintenance mode.`,
),
).catch(error)
})
},
@ -313,7 +313,7 @@ export const instanceService = mkSingleton(
} catch (e) {
warn(`Error spawning: ${e}`)
throw new Error(
`Could not launch PocketBase ${instance.version}. It may be time to upgrade.`
`Could not launch PocketBase ${instance.version}. It may be time to upgrade.`,
)
}
})()
@ -345,7 +345,7 @@ export const instanceService = mkSingleton(
DAEMON_PB_DATA_DIR,
instance.id,
`worker`,
`index.ts`
`index.ts`,
)
dbg(`Checking ${workerPath} for a worker entry point`)
if (existsSync(workerPath)) {
@ -405,7 +405,7 @@ export const instanceService = mkSingleton(
}
return true
}),
RECHECK_TTL
RECHECK_TTL,
)
}
@ -418,7 +418,7 @@ export const instanceService = mkSingleton(
warn(`_pingInvocation failed with ${e}`)
return true
}),
1000
1000,
)
}
@ -442,7 +442,7 @@ export const instanceService = mkSingleton(
.catch((e: ClientResponseError) => {
if (e.status !== 404) {
throw new Error(
`Unexpected response ${JSON.stringify(e)} from mothership`
`Unexpected response ${JSON.stringify(e)} from mothership`,
)
}
return []
@ -454,9 +454,8 @@ export const instanceService = mkSingleton(
}
{
dbg(`Trying to get instance by subdomain: ${idOrSubdomain}`)
const [instance, owner] = await client.getInstanceBySubdomain(
idOrSubdomain
)
const [instance, owner] =
await client.getInstanceBySubdomain(idOrSubdomain)
if (instance && owner) {
dbg(`${idOrSubdomain} is a subdomain`)
return { instance, owner }
@ -477,14 +476,14 @@ export const instanceService = mkSingleton(
if (instanceIdOrSubdomain === PUBLIC_APP_DB) return
const { instance, owner } = await getInstanceByIdOrSubdomain(
instanceIdOrSubdomain
instanceIdOrSubdomain,
)
if (!owner) {
throw new Error(`Instance owner is invalid`)
}
if (!instance) {
throw new Error(
`Subdomain ${instanceIdOrSubdomain} does not resolve to an instance`
`Subdomain ${instanceIdOrSubdomain} does not resolve to an instance`,
)
}
@ -494,7 +493,7 @@ export const instanceService = mkSingleton(
dbg(`Checking for maintenance mode`)
if (instance.maintenance) {
throw new Error(
`This instance is in Maintenance Mode. See https://pockethost.gitbook.io/manual/daily-usage/maintenance for more information.`
`This instance is in Maintenance Mode. See https://pockethost.gitbook.io/manual/daily-usage/maintenance for more information.`,
)
}
@ -504,7 +503,7 @@ export const instanceService = mkSingleton(
dbg(`Checking for verified account`)
if (!owner?.verified) {
throw new Error(
`Log in at ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DOMAIN} to verify your account.`
`Log in at ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DOMAIN} to verify your account.`,
)
}
@ -518,12 +517,12 @@ export const instanceService = mkSingleton(
dbg(
`Forwarding proxy request for ${
req.url
} to instance ${api.internalUrl()}`
} to instance ${api.internalUrl()}`,
)
proxy.web(req, res, { target: api.internalUrl() })
},
`InstanceService`
`InstanceService`,
)
const { getNextPort } = await portManager({ maxPorts })
@ -537,5 +536,5 @@ export const instanceService = mkSingleton(
const getInstanceApiIfExistsById = (id: InstanceId) => instanceApis[id]
return { shutdown, getInstanceApiIfExistsById }
}
},
)

View File

@ -37,8 +37,8 @@ export const portManager = mkSingleton(async (cfg: PortManagerConfig) => {
const removed = remove(exclude, (v) => v === newPort)
dbg(
`Removed ${removed.join(',')} from excluded ports: ${exclude.join(
','
)}`
',',
)}`,
)
},
]

View File

@ -2,8 +2,8 @@ import { DAEMON_PB_DATA_DIR, DAEMON_PB_MIGRATIONS_DIR } from '$constants'
import { mkInternalAddress, mkInternalUrl, tryFetch } from '$util'
import { createCleanupManager, createTimerManager } from '@pockethost/common'
import {
mkSingleton,
SingletonBaseConfig,
mkSingleton,
} from '@pockethost/common/src/mkSingleton'
import { spawn } from 'child_process'
import { existsSync } from 'fs'
@ -23,7 +23,7 @@ export type SpawnConfig = {
onUnexpectedStop: (
code: number | null,
stdout: string[],
stderr: string[]
stderr: string[],
) => void
}
export type PocketbaseServiceApi = AsyncReturnType<
@ -49,7 +49,7 @@ function pidIsRunning(pid: number) {
}
export const createPocketbaseService = async (
config: PocketbaseServiceConfig
config: PocketbaseServiceConfig,
) => {
const { logger } = config
const _serviceLogger = logger.create('PocketbaseService')
@ -77,7 +77,7 @@ export const createPocketbaseService = async (
const bin = realVersion.binPath
if (!existsSync(bin)) {
throw new Error(
`PocketBase binary (${bin}) not found. Contact pockethost.io.`
`PocketBase binary (${bin}) not found. Contact pockethost.io.`,
)
}
@ -93,7 +93,7 @@ export const createPocketbaseService = async (
args.push(
isMothership
? DAEMON_PB_MIGRATIONS_DIR
: `${DAEMON_PB_DATA_DIR}/${slug}/pb_migrations`
: `${DAEMON_PB_DATA_DIR}/${slug}/pb_migrations`,
)
}
if (command === 'serve') {
@ -157,7 +157,7 @@ export const createPocketbaseService = async (
const { pid } = ls
if (!pid) {
throw new Error(
`Attempt to kill a PocketBase process that was never running.`
`Attempt to kill a PocketBase process that was never running.`,
)
}
const p = new Promise<boolean>((resolve, reject) => {

View File

@ -22,7 +22,7 @@ export type ProxyMiddleware = (
proxy: Server
host: string
},
logger: Logger
logger: Logger,
) => void | Promise<void>
export type ProxyServiceConfig = SingletonBaseConfig & {
@ -44,7 +44,7 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
dbg(`Incoming request ${req.method} ${req.headers.host}/${req.url}`)
if (!req.headers.host?.endsWith(PUBLIC_APP_DOMAIN)) {
warn(
`Request for ${req.headers.host} rejected because host does not end in ${PUBLIC_APP_DOMAIN}`
`Request for ${req.headers.host} rejected because host does not end in ${PUBLIC_APP_DOMAIN}`,
)
res.writeHead(502, {
'Content-Type': `text/plain`,
@ -54,7 +54,7 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
}
{
const { warn } = _proxyLogger.create(
`${req.method} ${req.headers.host}/${req.url}`
`${req.method} ${req.headers.host}/${req.url}`,
)
try {
for (let i = 0; i < middleware.length; i++) {
@ -94,7 +94,7 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
subdomainFilter: string | ((subdomain: string) => boolean),
urlFilters: string | string[],
handler: ProxyMiddleware,
handlerName: string
handlerName: string,
) => {
const _handlerLogger = _proxyLogger.create(`${handlerName}`)
const { dbg, trace } = _handlerLogger
@ -149,7 +149,7 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
req,
res,
{ host, subdomain, coreInternalUrl, proxy },
_requestLogger
_requestLogger,
)
})
}

View File

@ -59,7 +59,7 @@ export const realtimeLog = mkSingleton(async (config: RealtimeLogConfig) => {
res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS')
res.setHeader(
'Access-Control-Allow-Headers',
'authorization,content-type,cache-control'
'authorization,content-type,cache-control',
)
res.setHeader('Access-Control-Max-Age', 86400)
res.statusCode = 204
@ -106,7 +106,7 @@ export const realtimeLog = mkSingleton(async (config: RealtimeLogConfig) => {
.getOne<InstanceFields>(instanceId)
if (!instance) {
throw new Error(
`instanceId ${instanceId} not found for user ${user.id}`
`instanceId ${instanceId} not found for user ${user.id}`,
)
}
dbg(`Instance is `, instance)
@ -142,14 +142,14 @@ export const realtimeLog = mkSingleton(async (config: RealtimeLogConfig) => {
const evt = mkEvent(`log`, record)
trace(
`Dispatching SSE log event from ${instance.subdomain} (${instance.id})`,
evt
evt,
)
limiter.schedule(() => write(evt)).catch(error)
})
req.on('close', () => {
limiter.stop()
dbg(
`SSE request for ${instance.subdomain} (${instance.id}) closed. Unsubscribing.`
`SSE request for ${instance.subdomain} (${instance.id}) closed. Unsubscribing.`,
)
unsub()
})
@ -172,7 +172,7 @@ export const realtimeLog = mkSingleton(async (config: RealtimeLogConfig) => {
const evt = mkEvent(`log`, rec)
trace(
`Dispatching SSE initial log event from ${instance.subdomain} (${instance.id})`,
evt
evt,
)
return write(evt)
})
@ -186,7 +186,7 @@ export const realtimeLog = mkSingleton(async (config: RealtimeLogConfig) => {
.catch(error)
}
},
`RealtimeLogService`
`RealtimeLogService`,
)
return {

View File

@ -1,12 +1,12 @@
import { clientService } from '$services'
import {
assertTruthy,
mkSingleton,
RPC_COMMANDS,
RpcCommands,
RpcFields,
RpcStatus,
RPC_COMMANDS,
SingletonBaseConfig,
assertTruthy,
mkSingleton,
} from '@pockethost/common'
import { isObject } from '@s-libs/micro-dash'
import Ajv, { JSONSchemaType, ValidateFunction } from 'ajv'
@ -22,12 +22,12 @@ export type KnexApi = ReturnType<typeof knexFactory>
export type CommandModuleInitializer = (
register: RpcServiceApi['registerCommand'],
client: pocketbaseEs,
knex: KnexApi
knex: KnexApi,
) => void
export type RpcRunner<
TPayload extends JsonObject,
TResult extends JsonObject
TResult extends JsonObject,
> = (job: RpcFields<TPayload, TResult>) => Promise<TResult>
export type RpcServiceConfig = SingletonBaseConfig & {}
@ -58,8 +58,8 @@ export const rpcService = mkSingleton(async (config: RpcServiceConfig) => {
if (!RPC_COMMANDS.find((c) => c === cmd)) {
throw new Error(
`RPC command '${cmd}' is invalid. It must be one of: ${RPC_COMMANDS.join(
'|'
)}.`
'|',
)}.`,
)
}
return cmd as RpcCommands
@ -76,7 +76,7 @@ export const rpcService = mkSingleton(async (config: RpcServiceConfig) => {
const { validate, run } = handler
if (!validate(payload)) {
throw new Error(
`Payload for ${cmd} fails validation: ${JSON.stringify(payload)}`
`Payload for ${cmd} fails validation: ${JSON.stringify(payload)}`,
)
}
dbg(`Running RPC ${rpc.id}`, rpc)
@ -115,11 +115,11 @@ export const rpcService = mkSingleton(async (config: RpcServiceConfig) => {
const registerCommand = <
TPayload extends JsonObject,
TResult extends JsonObject
TResult extends JsonObject,
>(
commandName: RpcCommands,
schema: JSONSchemaType<TPayload>,
runner: RpcRunner<TPayload, TResult>
runner: RpcRunner<TPayload, TResult>,
) => {
if (jobHandlers[commandName]) {
throw new Error(`${commandName} job handler already registered.`)

View File

@ -20,9 +20,9 @@ import {
type SetInstanceMaintenanceResult,
} from '@pockethost/common'
import { valid, validRange } from 'semver'
import { clientService } from '../clientService/clientService'
import { instanceService } from '../InstanceService/InstanceService'
import { updaterService } from '../UpdaterService/UpdaterService'
import { clientService } from '../clientService/clientService'
import { rpcService } from './RpcService'
export const registerRpcCommands = async (logger: Logger) => {
@ -48,7 +48,7 @@ export const registerRpcCommands = async (logger: Logger) => {
maintenance: false,
})
return { instance }
}
},
)
registerCommand<SaveVersionPayload, SaveVersionResult>(
@ -65,7 +65,7 @@ export const registerRpcCommands = async (logger: Logger) => {
}
await client.updateInstance(instanceId, { version })
return { status: 'ok' }
}
},
)
registerCommand<SaveSecretsPayload, SaveSecretsResult>(
@ -76,7 +76,7 @@ export const registerRpcCommands = async (logger: Logger) => {
const { instanceId, secrets } = payload
await client.updateInstance(instanceId, { secrets })
return { status: 'ok' }
}
},
)
registerCommand<RenameInstancePayload, RenameInstanceResult>(
@ -90,7 +90,7 @@ export const registerRpcCommands = async (logger: Logger) => {
await client.updateInstance(instanceId, { subdomain })
dbg(`Instance updated successfully `)
return {}
}
},
)
registerCommand<SetInstanceMaintenancePayload, SetInstanceMaintenanceResult>(
@ -112,7 +112,7 @@ export const registerRpcCommands = async (logger: Logger) => {
}
}
return {}
}
},
)
// gen:command

View File

@ -5,13 +5,13 @@ import {
serialAsyncExecutionGuard,
SingletonBaseConfig,
} from '@pockethost/common'
import { Database as SqliteDatabase, open } from 'sqlite'
import { open, Database as SqliteDatabase } from 'sqlite'
import { Database } from 'sqlite3'
import { JsonObject } from 'type-fest'
export type SqliteUnsubscribe = () => void
export type SqliteChangeHandler<TRecord extends JsonObject> = (
e: SqliteChangeEvent<TRecord>
e: SqliteChangeEvent<TRecord>,
) => void
export type SqliteEventType = 'update' | 'insert' | 'delete'
export type SqliteChangeEvent<TRecord extends JsonObject> = {
@ -25,7 +25,7 @@ export type SqliteServiceApi = {
migrate: SqliteDatabase['migrate']
exec: SqliteDatabase['exec']
subscribe: <TRecord extends JsonObject>(
cb: SqliteChangeHandler<TRecord>
cb: SqliteChangeHandler<TRecord>,
) => SqliteUnsubscribe
}
export type SqliteServiceConfig = SingletonBaseConfig & {}
@ -43,7 +43,7 @@ export const sqliteService = mkSingleton((config: SqliteServiceConfig) => {
This function
*/
const _unsafe_getDatabase = async (
filename: string
filename: string,
): Promise<SqliteServiceApi> => {
const _dbLogger = logger.create(`SqliteService`)
_dbLogger.breadcrumb(filename)
@ -62,7 +62,7 @@ export const sqliteService = mkSingleton((config: SqliteServiceConfig) => {
eventType: SqliteEventType,
database: string,
table: string,
rowId: number
rowId: number,
) => {
trace(`Got a raw change event`, {
eventType,
@ -73,7 +73,7 @@ export const sqliteService = mkSingleton((config: SqliteServiceConfig) => {
if (eventType === 'delete') return // Not supported
const record = await db.get(
`select * from ${table} where rowid = '${rowId}'`
`select * from ${table} where rowid = '${rowId}'`,
)
const e: SqliteChangeEvent<any> = {
table,
@ -81,7 +81,7 @@ export const sqliteService = mkSingleton((config: SqliteServiceConfig) => {
record,
}
fireChange(e)
}
},
)
cm.add(() => {
@ -110,7 +110,7 @@ export const sqliteService = mkSingleton((config: SqliteServiceConfig) => {
}
const getDatabase = serialAsyncExecutionGuard(
_unsafe_getDatabase,
(fileName) => fileName
(fileName) => fileName,
)
const shutdown = async () => {

View File

@ -1,9 +1,9 @@
import { downloadAndExtract, smartFetch } from '$util'
import {
SingletonBaseConfig,
createCleanupManager,
createTimerManager,
mkSingleton,
SingletonBaseConfig,
} from '@pockethost/common'
import { keys } from '@s-libs/micro-dash'
import { chmodSync, existsSync } from 'fs'
@ -49,7 +49,7 @@ export const updaterService = mkSingleton(
const check = async () => {
const releases = await smartFetch<Releases>(
`https://api.github.com/repos/pocketbase/pocketbase/releases?per_page=100`,
join(cachePath, `releases.json`)
join(cachePath, `releases.json`),
)
// dbg({ releases })
@ -77,7 +77,7 @@ export const updaterService = mkSingleton(
await Promise.all(promises)
if (keys(binPaths).length === 0) {
throw new Error(
`No version found, probably mismatched architecture and OS (${osName}/${cpuArchitecture})`
`No version found, probably mismatched architecture and OS (${osName}/${cpuArchitecture})`,
)
}
maxVersion = `~${rsort(keys(binPaths))[0]}`
@ -94,7 +94,7 @@ export const updaterService = mkSingleton(
const version = maxSatisfying(keys(binPaths), semVer)
if (!version)
throw new Error(
`No version satisfies ${semVer} (${keys(binPaths).join(', ')})`
`No version satisfies ${semVer} (${keys(binPaths).join(', ')})`,
)
const binPath = binPaths[version]
if (!binPath) throw new Error(`binPath for ${version} not found`)
@ -109,5 +109,5 @@ export const updaterService = mkSingleton(
getVersion,
shutdown: async () => {},
}
}
},
)

View File

@ -1,12 +1,12 @@
import {
assertExists,
INSTANCE_COLLECTION,
InstanceFields,
InstanceFields_Create,
InstanceId,
InstanceStatus,
INSTANCE_COLLECTION,
safeCatch,
UserFields,
assertExists,
safeCatch,
} from '@pockethost/common'
import { reduce } from '@s-libs/micro-dash'
import Bottleneck from 'bottleneck'
@ -25,7 +25,7 @@ export const createInstanceMixin = (context: MixinContext) => {
const resetInstances = safeCatch(`resetRpcs`, logger, async () =>
rawDb(INSTANCE_COLLECTION).update<InstanceFields>({
status: InstanceStatus.Idle,
})
}),
)
const createInstance = safeCatch(
@ -35,7 +35,7 @@ export const createInstanceMixin = (context: MixinContext) => {
return client
.collection(INSTANCE_COLLECTION)
.create<InstanceFields>(payload)
}
},
)
const getInstanceBySubdomain = safeCatch(
@ -57,12 +57,12 @@ export const createInstanceMixin = (context: MixinContext) => {
.then((user) => {
return [instance, user]
})
})
}),
)
const getInstanceById = async (
instanceId: InstanceId,
context?: AsyncContext
context?: AsyncContext,
): Promise<[InstanceFields, UserFields] | []> =>
client
.collection(INSTANCE_COLLECTION)
@ -86,7 +86,7 @@ export const createInstanceMixin = (context: MixinContext) => {
logger,
async (instanceId: InstanceId, fields: Partial<InstanceFields>) => {
await client.collection(INSTANCE_COLLECTION).update(instanceId, fields)
}
},
)
const updateInstanceStatus = safeCatch(
@ -94,7 +94,7 @@ export const createInstanceMixin = (context: MixinContext) => {
logger,
async (instanceId: InstanceId, status: InstanceStatus) => {
await updateInstance(instanceId, { status })
}
},
)
const getInstance = safeCatch(
@ -104,7 +104,7 @@ export const createInstanceMixin = (context: MixinContext) => {
return client
.collection(INSTANCE_COLLECTION)
.getOne<InstanceFields>(instanceId)
}
},
)
const getInstances = safeCatch(`getInstances`, logger, async () => {
@ -129,14 +129,14 @@ export const createInstanceMixin = (context: MixinContext) => {
return client
.collection(INSTANCE_COLLECTION)
.update(r.id, toUpdate)
})
}),
)
return c
},
[] as Promise<void>[]
[] as Promise<void>[],
)
await Promise.all(promises)
}
},
)
const updateInstanceSeconds = safeCatch(
@ -156,7 +156,7 @@ export const createInstanceMixin = (context: MixinContext) => {
assertExists(row, `Expected row here`)
const secondsThisMonth = row.t
await updateInstance(instanceId, { secondsThisMonth })
}
},
)
return {

View File

@ -9,7 +9,7 @@ import { MixinContext } from './PbClient'
export const createInvocationMixin = (
context: MixinContext,
instanceApi: InstanceApi
instanceApi: InstanceApi,
) => {
const { logger } = context
const { dbg } = logger.create('InvocationMixin')
@ -32,7 +32,7 @@ export const createInvocationMixin = (
$cancelKey: `createInvocation:${instance.id}:${pid}`,
})
return _inv
}
},
)
const pingInvocation = safeCatch(
@ -49,7 +49,7 @@ export const createInvocationMixin = (
.update<InvocationFields>(invocation.id, toUpdate)
await instanceApi.updateInstanceSeconds(invocation.instanceId)
return _inv
}
},
)
const finalizeInvocation = safeCatch(
@ -69,7 +69,7 @@ export const createInvocationMixin = (
.update<InvocationFields>(invocation.id, toUpdate)
await instanceApi.updateInstanceSeconds(invocation.instanceId)
return _inv
}
},
)
return { finalizeInvocation, pingInvocation, createInvocation }

View File

@ -18,7 +18,7 @@ export const createPbClient = (url: string, logger: Logger) => {
info(`Initializing client: ${url}`)
const rawDb = createRawPbClient(
`${DAEMON_PB_DATA_DIR}/${PUBLIC_APP_DB}/pb_data/data.db`,
_clientLogger
_clientLogger,
)
const client = new PocketBase(url)
@ -27,7 +27,7 @@ export const createPbClient = (url: string, logger: Logger) => {
`adminAuthViaEmail`,
_clientLogger,
(email: string, password: string) =>
client.admins.authWithPassword(email, password)
client.admins.authWithPassword(email, password),
)
const createFirstAdmin = safeCatch(
@ -40,7 +40,7 @@ export const createPbClient = (url: string, logger: Logger) => {
console.log({ email, password })
console.log(JSON.stringify(res, null, 2))
return res
})
}),
)
const context: MixinContext = { client, rawDb, logger: _clientLogger }

View File

@ -1,7 +1,7 @@
import {
RPC_COLLECTION,
RpcFields,
RpcStatus,
RPC_COLLECTION,
safeCatch,
} from '@pockethost/common'
import { ClientResponseError } from 'pocketbase'
@ -31,7 +31,7 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
cb(e.record)
})
return unsub
}
},
)
const resetRpcs = safeCatch(`resetRpcs`, logger, async () =>
@ -43,7 +43,7 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
.update<RpcFields<any, any>>({
status: RpcStatus.FinishedError,
result: `Canceled by reset`,
})
}),
)
const incompleteRpcs = safeCatch(`incompleteRpcs`, logger, async () => {
@ -65,7 +65,7 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
return client
.collection(RPC_COLLECTION)
.update<RpcFields<any, any>>(rpc.id, fields)
}
},
)
const setRpcStatus = safeCatch(
@ -74,12 +74,12 @@ export const createRpcHelper = (config: RpcHelperConfig) => {
async (
rpc: RpcFields<any, any>,
status: RpcStatus,
result: JsonObject = {}
result: JsonObject = {},
) => {
return client
.collection(RPC_COLLECTION)
.update(rpc.id, { status, result })
}
},
)
return {

View File

@ -31,7 +31,7 @@ export const clientService = mkSingleton(async (cfg: ClientServiceConfig) => {
dbg(`Logged in`)
} catch (e) {
error(
`CANNOT AUTHENTICATE TO ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DB}.${PUBLIC_APP_DOMAIN}/_/`
`CANNOT AUTHENTICATE TO ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DB}.${PUBLIC_APP_DOMAIN}/_/`,
)
process.exit(-1)
}

View File

@ -1,5 +1,3 @@
export * from './clientService/clientService'
export * from './clientService/PbClient'
export * from './FtpService/FtpService'
export * from './InstanceService/InstanceService'
export * from './PocketBaseService'
@ -7,3 +5,5 @@ export * from './ProxyService'
export * from './RealtimeLog'
export * from './RpcService/RpcService'
export * from './SqliteService/SqliteService'
export * from './clientService/PbClient'
export * from './clientService/clientService'

View File

@ -1,12 +1,12 @@
import { clientService } from '$services'
import {
InstanceFields,
INSTANCE_COLLECTION,
InvocationFields,
INVOCATION_COLLECTION,
logger,
RpcFields,
InstanceFields,
InvocationFields,
RPC_COLLECTION,
RpcFields,
logger,
singletonAsyncExecutionGuard,
} from '@pockethost/common'
import Bottleneck from 'bottleneck'
@ -17,7 +17,7 @@ export const deleteInvocation = singletonAsyncExecutionGuard(
const { client } = await clientService()
await client.client.collection(INVOCATION_COLLECTION).delete(invocation.id)
},
(invocation) => `deleteInvocation:${invocation.id}`
(invocation) => `deleteInvocation:${invocation.id}`,
)
export const deleteInvocationsForInstance = singletonAsyncExecutionGuard(
@ -50,7 +50,7 @@ export const deleteInvocationsForInstance = singletonAsyncExecutionGuard(
}
}
},
(instance) => `deleteInvocationsForInstance:${instance.id}`
(instance) => `deleteInvocationsForInstance:${instance.id}`,
)
export const deleteRpc = singletonAsyncExecutionGuard(
@ -58,7 +58,7 @@ export const deleteRpc = singletonAsyncExecutionGuard(
const { client } = await clientService()
await client.client.collection(RPC_COLLECTION).delete(rpc.id)
},
(rpc) => `deleteRpc:${rpc.id}`
(rpc) => `deleteRpc:${rpc.id}`,
)
export const getAllRpcs = singletonAsyncExecutionGuard(
@ -70,7 +70,7 @@ export const getAllRpcs = singletonAsyncExecutionGuard(
console.log(`Loaded rpcs`)
return rpcs
},
() => `getAllRpcs`
() => `getAllRpcs`,
)
export const deleteRpcsForInstance = singletonAsyncExecutionGuard(
@ -80,7 +80,7 @@ export const deleteRpcsForInstance = singletonAsyncExecutionGuard(
const instanceRpcs = allRpcs.filter((rpc) => rpc.payload?.instanceId === id)
await Promise.all(instanceRpcs.map(deleteRpc))
},
(instance) => `deleteRpcsForInstance:${instance.id}`
(instance) => `deleteRpcsForInstance:${instance.id}`,
)
export const deleteInstance = singletonAsyncExecutionGuard(
@ -95,7 +95,7 @@ export const deleteInstance = singletonAsyncExecutionGuard(
await deleteInvocationsForInstance(instance).catch((e) => {
console.error(
`deleteInvocationsForInstance error`,
JSON.stringify(e, null, 2)
JSON.stringify(e, null, 2),
)
throw e
})
@ -110,7 +110,7 @@ export const deleteInstance = singletonAsyncExecutionGuard(
})
console.log(`Instance deleted ${id}`)
},
(instance) => `deleteInstance:${instance.id}`
(instance) => `deleteInstance:${instance.id}`,
)
export const deleteInstancesByFilter = singletonAsyncExecutionGuard(
@ -122,9 +122,9 @@ export const deleteInstancesByFilter = singletonAsyncExecutionGuard(
const limiter = new Bottleneck({ maxConcurrent: 50 })
await Promise.all(
instances.map((instance) =>
limiter.schedule(() => deleteInstance(instance))
)
limiter.schedule(() => deleteInstance(instance)),
),
)
},
(filter) => `deleteInstancesByFilter:${filter}`
(filter) => `deleteInstancesByFilter:${filter}`,
)

View File

@ -16,7 +16,7 @@ export const createCleanup = (context: { program: Command } & ContextBase) => {
.option(
`-f, --filter <filter>`,
`Filter to use when deleting instances`,
`stress-%`
`stress-%`,
)
.action(async () => {
const options = cleanupCmd.optsWithGlobals<CleanupOptions>()

View File

@ -38,7 +38,7 @@ export const createSeed = (context: { program: Command } & ContextBase) => {
`-c, --count`,
`Number of new seed instances to create`,
parseInt,
10
10,
)
.action(async () => {
const options = seedCmd.optsWithGlobals<SeedOptions>()

View File

@ -24,25 +24,25 @@ export const createStress = (context: { program: Command } & ContextBase) => {
'-ic, --instance-count <number>',
`Number of simultaneous instances to hit`,
parseInt,
100
100,
)
.option(
'-rc, --requests-per-instance <number>',
`Number of simultaneous requests per instance`,
parseInt,
50
50,
)
.option(
'-mind, --min-delay <number>',
`Minimum number of milliseconds to delay before sending another request`,
parseInt,
50
50,
)
.option(
'-maxd, --max-delay <number>',
`Maximum number of milliseconds to delay before sending another request`,
parseInt,
500
500,
)
.action(async () => {
const options = seedCmd.optsWithGlobals<StressOptions>()
@ -63,7 +63,7 @@ export const createStress = (context: { program: Command } & ContextBase) => {
if (excluded[instanceId]) return
await client.updateInstance(instanceId, { maintenance: false })
},
(id) => `reset:${id}`
(id) => `reset:${id}`,
)
const instances = await client.getInstances()
@ -80,7 +80,7 @@ export const createStress = (context: { program: Command } & ContextBase) => {
dbg(
`There are ${instances.length} instances and ${
values(excluded).length
} excluded`
} excluded`,
)
if (!instance) throw new Error(`No instance to grab`)
@ -108,7 +108,7 @@ export const createStress = (context: { program: Command } & ContextBase) => {
return // Timeout
}
}
})
}),
)
}
} catch (e) {

View File

@ -22,7 +22,7 @@ program
.option(
'-u, --mothership-url',
'URL to central database',
'http://127.0.0.1:8090'
'http://127.0.0.1:8090',
)
createCleanup({ program, logger })

View File

@ -7,7 +7,7 @@ import { dirname } from 'path'
export function assert<T>(
v: T | undefined | void | null,
msg?: string
msg?: string,
): asserts v is T {
if (!v) {
throw new Error(msg || `Assertion failure`)
@ -28,7 +28,7 @@ const downloadFile = async (url: string, path: string) => {
const _unsafe_downloadAndExtract = async (
url: string,
binPath: string,
logger: Logger
logger: Logger,
) => {
const { dbg, error } = logger.create('downloadAndExtract')
@ -48,5 +48,5 @@ const _unsafe_downloadAndExtract = async (
export const downloadAndExtract = singletonAsyncExecutionGuard(
_unsafe_downloadAndExtract,
(url) => url
(url) => url,
)

View File

@ -5,7 +5,7 @@ import { dirname } from 'path'
export const smartFetch = async <TRet>(
url: string,
path: string
path: string,
): Promise<TRet> => {
const { dbg } = logger().create(`smartFetch`)

View File

@ -40,7 +40,7 @@ export const tryFetch = async (url: string, config?: Partial<Config>) => {
resolve()
} catch (e) {
dbg(
`Could not fetch ${url}, trying again in ${retryMs}ms. Raw error ${e}`
`Could not fetch ${url}, trying again in ${retryMs}ms. Raw error ${e}`,
)
setTimeout(tryFetch, retryMs)
}

View File

@ -250,7 +250,7 @@ export class EventSource extends EventTarget {
await new Promise<void>((res) => {
const id = setTimeout(
() => res(clearTimeout(id)),
this.#settings.reconnectionTime
this.#settings.reconnectionTime,
)
})

View File

@ -19,7 +19,7 @@ declare class EventSource {
constructor(
url: string,
eventSourceInitDict?: EventSource.EventSourceInitDict
eventSourceInitDict?: EventSource.EventSourceInitDict,
)
readonly CLOSED: number

View File

@ -23,7 +23,7 @@ export const init = (klass: typeof PocketBase) => {
const adminAuthWithPassword = async (
login = ADMIN_LOGIN,
password = ADMIN_PASSWORD
password = ADMIN_PASSWORD,
) => {
console.log(`Connecting to ${POCKETBASE_URL} with ${ADMIN_LOGIN}`)
await client.admins.authWithPassword(login, password)

View File

@ -1,16 +0,0 @@
{
"useTabs": false,
"singleQuote": true,
"semi": false,
"trailingComma": "none",
"printWidth": 100,
"pluginSearchDirs": [".", "../.."],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}

View File

@ -10,7 +10,7 @@
</script>
<div class="accordion-item">
<h2 class="accordion-header " id={headerId}>
<h2 class="accordion-header" id={headerId}>
<button
class="accordion-button {show ? '' : 'collapsed'} text-bg-{header} "
type="button"

View File

@ -6,5 +6,5 @@ export enum AlertTypes {
Warning = 'warning',
Info = 'info',
Light = 'light',
Dark = 'dark'
Dark = 'dark',
}

View File

@ -5,13 +5,13 @@ import Cookies from 'js-cookie'
// Set some default values to be referenced later
export enum ThemeNames {
Light = 'light',
Dark = 'dark'
Dark = 'dark',
}
export const HLJS_THEMES = {
[ThemeNames.Light]:
'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css',
[ThemeNames.Dark]:
'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/a11y-dark.min.css'
'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/a11y-dark.min.css',
}
export const ALLOWED_THEMES: ThemeNames[] = [ThemeNames.Light, ThemeNames.Dark]
export const DEFAULT_THEME: ThemeNames = ThemeNames.Light
@ -19,7 +19,7 @@ export const STORAGE_NAME: string = 'theme'
export const THEME_ATTRIBUTE: string = 'data-bs-theme'
export const THEME_ICONS: { [_ in ThemeNames]: string } = {
[ThemeNames.Light]: 'bi bi-moon-stars',
[ThemeNames.Dark]: 'bi bi-brightness-high'
[ThemeNames.Dark]: 'bi bi-brightness-high',
}
export const html = () => {
@ -30,7 +30,8 @@ export const html = () => {
export const getCurrentTheme = () => {
const savedTheme = Cookies.get(STORAGE_NAME)
const currentTheme = find(ALLOWED_THEMES, (v) => savedTheme === v) || DEFAULT_THEME
const currentTheme =
find(ALLOWED_THEMES, (v) => savedTheme === v) || DEFAULT_THEME
return currentTheme
}

View File

@ -28,7 +28,9 @@ export const PUBLIC_DEBUG = envb('PUBLIC_DEBUG', dev)
export const PUBLIC_POCKETHOST_VERSION = base.version
export const PUBLIC_ROUTES = publicRoutes.map((pattern) => new UrlPattern(pattern))
export const PUBLIC_ROUTES = publicRoutes.map(
(pattern) => new UrlPattern(pattern),
)
try {
logger()

View File

@ -1,17 +1,17 @@
import { createGenericSyncEvent } from '$util/events'
import { fetchEventSource } from '@microsoft/fetch-event-source'
import {
assertExists,
CreateInstancePayloadSchema,
createRpcHelper,
createWatchHelper,
logger,
RenameInstancePayloadSchema,
RpcCommands,
safeCatch,
SaveSecretsPayloadSchema,
SaveVersionPayloadSchema,
SetInstanceMaintenancePayloadSchema,
assertExists,
createRpcHelper,
createWatchHelper,
logger,
safeCatch,
type CreateInstancePayload,
type CreateInstanceResult,
type InstanceFields,
@ -26,7 +26,7 @@ import {
type SetInstanceMaintenancePayload,
type SetInstanceMaintenanceResult,
// gen:import
type UserFields
type UserFields,
} from '@pockethost/common'
import { keys, map } from '@s-libs/micro-dash'
import PocketBase, {
@ -34,7 +34,7 @@ import PocketBase, {
BaseAuthStore,
ClientResponseError,
type RecordSubscription,
type UnsubscribeFunc
type UnsubscribeFunc,
} from 'pocketbase'
export type AuthChangeHandler = (user: BaseAuthStore) => void
@ -66,36 +66,45 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
const logOut = () => authStore.clear()
const createUser = safeCatch(`createUser`, _logger, (email: string, password: string) =>
client
.collection('users')
.create({
email,
password,
passwordConfirm: password
})
.then(() => {
// dbg(`Sending verification email to ${email}`)
return client.collection('users').requestVerification(email)
})
const createUser = safeCatch(
`createUser`,
_logger,
(email: string, password: string) =>
client
.collection('users')
.create({
email,
password,
passwordConfirm: password,
})
.then(() => {
// dbg(`Sending verification email to ${email}`)
return client.collection('users').requestVerification(email)
}),
)
const confirmVerification = safeCatch(`confirmVerification`, _logger, (token: string) =>
client
.collection('users')
.confirmVerification(token)
.then((response) => {
return response
})
const confirmVerification = safeCatch(
`confirmVerification`,
_logger,
(token: string) =>
client
.collection('users')
.confirmVerification(token)
.then((response) => {
return response
}),
)
const requestPasswordReset = safeCatch(`requestPasswordReset`, _logger, (email: string) =>
client
.collection('users')
.requestPasswordReset(email)
.then(() => {
return true
})
const requestPasswordReset = safeCatch(
`requestPasswordReset`,
_logger,
(email: string) =>
client
.collection('users')
.requestPasswordReset(email)
.then(() => {
return true
}),
)
const requestPasswordResetConfirm = safeCatch(
@ -107,15 +116,18 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
.confirmPasswordReset(token, password, password)
.then((response) => {
return response
})
}),
)
const authViaEmail = safeCatch(`authViaEmail`, _logger, (email: string, password: string) =>
client.collection('users').authWithPassword(email, password)
const authViaEmail = safeCatch(
`authViaEmail`,
_logger,
(email: string, password: string) =>
client.collection('users').authWithPassword(email, password),
)
const refreshAuthToken = safeCatch(`refreshAuthToken`, _logger, () =>
client.collection('users').authRefresh()
client.collection('users').authRefresh(),
)
const watchHelper = createWatchHelper({ client })
@ -125,27 +137,27 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
const createInstance = mkRpc<CreateInstancePayload, CreateInstanceResult>(
RpcCommands.CreateInstance,
CreateInstancePayloadSchema
CreateInstancePayloadSchema,
)
const saveSecrets = mkRpc<SaveSecretsPayload, SaveSecretsResult>(
RpcCommands.SaveSecrets,
SaveSecretsPayloadSchema
SaveSecretsPayloadSchema,
)
const saveVersion = mkRpc<SaveVersionPayload, SaveVersionResult>(
RpcCommands.SaveVersion,
SaveVersionPayloadSchema
SaveVersionPayloadSchema,
)
const renameInstance = mkRpc<RenameInstancePayload, RenameInstanceResult>(
RpcCommands.RenameInstance,
RenameInstancePayloadSchema
RenameInstancePayloadSchema,
)
const setInstanceMaintenance = mkRpc<SetInstanceMaintenancePayload, SetInstanceMaintenanceResult>(
RpcCommands.SetInstanceMaintenance,
SetInstanceMaintenancePayloadSchema
)
const setInstanceMaintenance = mkRpc<
SetInstanceMaintenancePayload,
SetInstanceMaintenanceResult
>(RpcCommands.SetInstanceMaintenance, SetInstanceMaintenancePayloadSchema)
// gen:mkRpc
@ -153,42 +165,56 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
`getInstanceById`,
_logger,
(id: InstanceId): Promise<InstanceFields | undefined> =>
client.collection('instances').getOne<InstanceFields>(id)
client.collection('instances').getOne<InstanceFields>(id),
)
const watchInstanceById = async (
id: InstanceId,
cb: (data: RecordSubscription<InstanceFields>) => void
cb: (data: RecordSubscription<InstanceFields>) => void,
): Promise<UnsubscribeFunc> => watchById('instances', id, cb)
const getAllInstancesById = safeCatch(`getAllInstancesById`, _logger, async () =>
(await client.collection('instances').getFullList()).reduce((c, v) => {
c[v.id] = v as unknown as InstanceFields
return c
}, {} as { [_: InstanceId]: InstanceFields })
const getAllInstancesById = safeCatch(
`getAllInstancesById`,
_logger,
async () =>
(await client.collection('instances').getFullList()).reduce(
(c, v) => {
c[v.id] = v as unknown as InstanceFields
return c
},
{} as { [_: InstanceId]: InstanceFields },
),
)
const parseError = (e: Error): string[] => {
if (!(e instanceof ClientResponseError)) return [e.message]
if (e.data.message && keys(e.data.data).length === 0) return [e.data.message]
return map(e.data.data, (v, k) => (v ? v.message : undefined)).filter((v) => !!v)
if (e.data.message && keys(e.data.data).length === 0)
return [e.data.message]
return map(e.data.data, (v, k) => (v ? v.message : undefined)).filter(
(v) => !!v,
)
}
const resendVerificationEmail = safeCatch(`resendVerificationEmail`, _logger, async () => {
const user = client.authStore.model
assertExists(user, `Login required`)
await client.collection('users').requestVerification(user.email)
})
const resendVerificationEmail = safeCatch(
`resendVerificationEmail`,
_logger,
async () => {
const user = client.authStore.model
assertExists(user, `Login required`)
await client.collection('users').requestVerification(user.email)
},
)
const getAuthStoreProps = (): AuthStoreProps => {
const { token, model, isValid } = client.authStore as AuthStoreProps
// dbg(`current authStore`, { token, model, isValid })
if (model instanceof Admin) throw new Error(`Admin models not supported`)
if (model && !model.email) throw new Error(`Expected model to be a user here`)
if (model && !model.email)
throw new Error(`Expected model to be a user here`)
return {
token,
model,
isValid
isValid,
}
}
@ -196,7 +222,8 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
* Use synthetic event for authStore changers so we can broadcast just
* the props we want and not the actual authStore object.
*/
const [onAuthChange, fireAuthChange] = createGenericSyncEvent<AuthStoreProps>()
const [onAuthChange, fireAuthChange] =
createGenericSyncEvent<AuthStoreProps>()
/**
* This section is for initialization
@ -254,7 +281,7 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
const watchInstanceLog = (
instanceId: InstanceId,
update: (log: InstanceLogFields) => void,
nInitial = 100
nInitial = 100,
): (() => void) => {
const { dbg, trace } = _logger.create('watchInstanceLog')
const auth = client.authStore.exportToCookie()
@ -266,12 +293,12 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
fetchEventSource(`${url}/logs`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
},
body: JSON.stringify({
instanceId,
n: nInitial,
auth
auth,
}),
onmessage: (event) => {
trace(`Got stream event`, event)
@ -290,7 +317,7 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
setTimeout(continuallyFetchFromEventSource, 100)
dbg(`Stream closed`)
},
signal
signal,
})
}
continuallyFetchFromEventSource()
@ -323,6 +350,6 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
renameInstance,
setInstanceMaintenance,
// gen:export
saveVersion
saveVersion,
}
}

View File

@ -1,7 +1,10 @@
import { browser } from '$app/environment'
import { PUBLIC_APP_DB, PUBLIC_APP_DOMAIN } from '$src/env'
import { logger } from '@pockethost/common'
import { createPocketbaseClient, type PocketbaseClient } from './PocketbaseClient'
import {
createPocketbaseClient,
type PocketbaseClient,
} from './PocketbaseClient'
export const client = (() => {
let clientInstance: PocketbaseClient | undefined

View File

@ -23,14 +23,14 @@ function formatInput(input: SecretsArray): SecretsArray {
.map(({ name, value }, index) => ({
name,
value,
color: colorScale(index.toString())
color: colorScale(index.toString()),
}))
}
const sanitize = (item: SecretItem) => {
return {
name: item.name.toUpperCase().trim(),
value: item.value.trim()
value: item.value.trim(),
}
}
@ -54,8 +54,8 @@ function createItems(initialItems: SecretsArray) {
...n,
{
name,
value
}
value,
},
]
return formatInput(n)
})
@ -69,7 +69,7 @@ function createItems(initialItems: SecretsArray) {
n = [...n.slice(0, index), ...n.slice(index + 1)]
return formatInput(n)
})
}
},
}
}

View File

@ -28,7 +28,7 @@ export const handleLogin = async (
email: string,
password: string,
setError?: FormErrorHandler,
shouldRedirect: boolean = true
shouldRedirect: boolean = true,
) => {
const { authViaEmail } = client()
// Reset the form error if the form is submitted
@ -42,7 +42,9 @@ export const handleLogin = async (
}
} catch (error) {
if (!(error instanceof Error)) {
throw new Error(`Expected Error type here, but got ${typeof error}:${error}`)
throw new Error(
`Expected Error type here, but got ${typeof error}:${error}`,
)
}
handleFormError(error, setError)
}
@ -57,7 +59,7 @@ export const handleLogin = async (
export const handleRegistration = async (
email: string,
password: string,
setError?: FormErrorHandler
setError?: FormErrorHandler,
) => {
const { createUser } = client()
// Reset the form error if the form is submitted
@ -75,7 +77,10 @@ export const handleRegistration = async (
* @param token {string} The token from the verification email
* @param setError {function} This can be used to show an alert bar if an error occurs during the login process
*/
export const handleAccountConfirmation = async (token: string, setError?: FormErrorHandler) => {
export const handleAccountConfirmation = async (
token: string,
setError?: FormErrorHandler,
) => {
const { confirmVerification } = client()
// Reset the form error if the form is submitted
setError?.('')
@ -98,7 +103,7 @@ export const handleAccountConfirmation = async (token: string, setError?: FormEr
*/
export const handleUnauthenticatedPasswordReset = async (
email: string,
setError?: FormErrorHandler
setError?: FormErrorHandler,
) => {
const { requestPasswordReset } = client()
// Reset the form error if the form is submitted
@ -122,7 +127,7 @@ export const handleUnauthenticatedPasswordReset = async (
export const handleUnauthenticatedPasswordResetConfirm = async (
token: string,
password: string,
setError?: FormErrorHandler
setError?: FormErrorHandler,
) => {
const { requestPasswordResetConfirm } = client()
// Reset the form error if the form is submitted
@ -141,7 +146,7 @@ export const handleUnauthenticatedPasswordResetConfirm = async (
export const handleCreateNewInstance = async (
instanceName: string,
setError?: FormErrorHandler
setError?: FormErrorHandler,
) => {
const { user, createInstance } = client()
// Get the newly created user id
@ -154,7 +159,7 @@ export const handleCreateNewInstance = async (
// Create a new instance using the generated name
const record = await createInstance({
subdomain: instanceName
subdomain: instanceName,
})
await goto(`/app/instances/${record.instance.id}`)
@ -167,7 +172,7 @@ export const handleInstanceGeneratorWidget = async (
email: string,
password: string,
instanceName: string,
setError = (value: string) => {}
setError = (value: string) => {},
) => {
const { dbg, error, warn } = logger()
@ -203,7 +208,7 @@ export const handleInstanceGeneratorWidget = async (
// If registration succeeds, login should always succeed.
// If a login fails at this point, the system is broken.
throw new Error(
`Login system is currently down. Please contact us so we can fix this.`
`Login system is currently down. Please contact us so we can fix this.`,
)
})
})
@ -247,7 +252,9 @@ export const handleInstanceGeneratorWidget = async (
}
}
export const handleResendVerificationEmail = async (setError = (value: string) => {}) => {
export const handleResendVerificationEmail = async (
setError = (value: string) => {},
) => {
const { resendVerificationEmail } = client()
try {
await resendVerificationEmail()

View File

@ -4,7 +4,7 @@ export type Unsubscribe = () => void
export const createGenericAsyncEvent = <TPayload>(): [
(cb: (payload: TPayload) => Promise<void>) => Unsubscribe,
(payload: TPayload) => Promise<void>
(payload: TPayload) => Promise<void>,
] => {
let i = 0
const callbacks: any = {}
@ -22,7 +22,7 @@ export const createGenericAsyncEvent = <TPayload>(): [
(c, cb) => {
return c.then(cb(payload))
},
Promise.resolve()
Promise.resolve(),
)
return [onEvent, fireEvent]
@ -30,7 +30,7 @@ export const createGenericAsyncEvent = <TPayload>(): [
export const createGenericSyncEvent = <TPayload>(): [
(cb: (payload: TPayload) => void) => Unsubscribe,
(payload: TPayload) => void
(payload: TPayload) => void,
] => {
let i = 0
const callbacks: any = {}

View File

@ -4,7 +4,11 @@ import type { AuthStoreProps } from '$src/pocketbase/PocketbaseClient'
import { logger } from '@pockethost/common'
import { writable } from 'svelte/store'
export const authStoreState = writable<AuthStoreProps>({ isValid: false, model: null, token: '' })
export const authStoreState = writable<AuthStoreProps>({
isValid: false,
model: null,
token: '',
})
export const isUserLoggedIn = writable(false)
export const isUserVerified = writable(false)
export const isAuthStateInitialized = writable(false)

View File

@ -6,8 +6,8 @@ import markedOptions from './marked.config.js'
const config: UserConfig = {
plugins: [markdown({ markedOptions }), sveltekit()],
optimizeDeps: {
include: ['highlight.js', 'highlight.js/lib/core']
}
include: ['highlight.js', 'highlight.js/lib/core'],
},
}
export default config

255
yarn.lock
View File

@ -31,6 +31,13 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
"@babel/runtime@^7.21.0":
version "7.22.15"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.15.tgz#38f46494ccf6cf020bd4eed7124b425e83e523b8"
integrity sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==
dependencies:
regenerator-runtime "^0.14.0"
"@dansvel/vite-plugin-markdown@^2.0.5":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@dansvel/vite-plugin-markdown/-/vite-plugin-markdown-2.0.5.tgz#55cff46adb457cb654b84a424aef2e25ca635926"
@ -1296,6 +1303,11 @@ aria-query@^5.3.0:
dependencies:
dequal "^2.0.3"
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
axobject-query@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.2.1.tgz#39c378a6e3b06ca679f29138151e45b2b32da62a"
@ -1534,10 +1546,10 @@ chrome-trace-event@^1.0.2:
resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac"
integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==
ci-info@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==
ci-info@^3.7.0:
version "3.8.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.8.0.tgz#81408265a5380c929f0bc665d62256628ce9ef91"
integrity sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==
clean-stack@^2.0.0:
version "2.2.0"
@ -1651,20 +1663,20 @@ concat-map@0.0.1:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
concurrently@^7.4.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-7.5.0.tgz#4dd432d4634a8251f27ab000c4974e78e3906bd3"
integrity sha512-5E3mwiS+i2JYBzr5BpXkFxOnleZTMsG+WnE/dCG4/P+oiVXrbmrBwJ2ozn4SxwB2EZDrKR568X+puVohxz3/Mg==
concurrently@^8.2.1:
version "8.2.1"
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-8.2.1.tgz#bcab9cacc38c23c503839583151e0fa96fd5b584"
integrity sha512-nVraf3aXOpIcNud5pB9M82p1tynmZkrSGQ1p6X/VY8cJ+2LMVqAgXsJxYYefACSHbTYlm92O1xuhdGTjwoEvbQ==
dependencies:
chalk "^4.1.0"
date-fns "^2.29.1"
chalk "^4.1.2"
date-fns "^2.30.0"
lodash "^4.17.21"
rxjs "^7.0.0"
shell-quote "^1.7.3"
spawn-command "^0.0.2-1"
supports-color "^8.1.0"
rxjs "^7.8.1"
shell-quote "^1.8.1"
spawn-command "0.0.2"
supports-color "^8.1.1"
tree-kill "^1.2.2"
yargs "^17.3.1"
yargs "^17.7.2"
console-control-strings@^1.0.0, console-control-strings@^1.1.0:
version "1.1.0"
@ -1699,16 +1711,14 @@ cross-fetch@^3.1.5:
dependencies:
node-fetch "2.6.7"
cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
dependencies:
nice-try "^1.0.4"
path-key "^2.0.1"
semver "^5.5.0"
shebang-command "^1.2.0"
which "^1.2.9"
path-key "^3.1.0"
shebang-command "^2.0.0"
which "^2.0.1"
css-select@^4.1.3:
version "4.3.0"
@ -1822,10 +1832,12 @@ data-uri-to-buffer@^4.0.0:
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz#b5db46aea50f6176428ac05b73be39a57701a64b"
integrity sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==
date-fns@^2.29.1, date-fns@^2.29.3:
version "2.29.3"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==
date-fns@^2.29.3, date-fns@^2.30.0:
version "2.30.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.30.0.tgz#f367e644839ff57894ec6ac480de40cae4b0f4d0"
integrity sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==
dependencies:
"@babel/runtime" "^7.21.0"
debug@4, debug@4.3.4, debug@^4.1.0, debug@^4.3.3, debug@^4.3.4:
version "4.3.4"
@ -2524,14 +2536,15 @@ fs-constants@^1.0.0:
resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
fs-extra@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
fs-extra@^9.0.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"
fs-minipass@^2.0.0:
version "2.1.0"
@ -2693,7 +2706,7 @@ globrex@^0.1.2:
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==
graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.2.6:
graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6:
version "4.2.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
@ -2894,13 +2907,6 @@ is-builtin-module@^3.2.0:
dependencies:
builtin-modules "^3.3.0"
is-ci@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c"
integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==
dependencies:
ci-info "^2.0.0"
is-core-module@^2.9.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144"
@ -3024,18 +3030,32 @@ json-schema-traverse@^1.0.0:
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2"
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
json-stable-stringify@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.2.tgz#e06f23128e0bbe342dc996ed5a19e28b57b580e0"
integrity sha512-eunSSaEnxV12z+Z73y/j5N37/In40GK4GmsSy+tEHJMxknvqnA7/djeYtAgW0GsWHUfg+847WJjKaEylk2y09g==
dependencies:
jsonify "^0.0.1"
json5@^2.2.0, json5@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==
jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
dependencies:
universalify "^2.0.0"
optionalDependencies:
graceful-fs "^4.1.6"
jsonify@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.1.tgz#2aa3111dae3d34a0f151c63f3a45d995d9420978"
integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==
klaw-sync@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
@ -3477,11 +3497,6 @@ negotiator@^0.6.2:
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==
nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
node-addon-api@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
@ -3710,25 +3725,26 @@ parse-json@^5.0.0:
json-parse-even-better-errors "^2.3.0"
lines-and-columns "^1.1.6"
patch-package@^6.5.0:
version "6.5.0"
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.5.0.tgz#feb058db56f0005da59cfa316488321de585e88a"
integrity sha512-tC3EqJmo74yKqfsMzELaFwxOAu6FH6t+FzFOsnWAuARm7/n2xB5AOeOueE221eM9gtMuIKMKpF9tBy/X2mNP0Q==
patch-package@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-8.0.0.tgz#d191e2f1b6e06a4624a0116bcb88edd6714ede61"
integrity sha512-da8BVIhzjtgScwDJ2TtKsfT5JFWz1hYoBl9rUQ1f38MC2HwnEIkK8VN3dKMKcP7P7bvvgzNDbfNHtx3MsQb5vA==
dependencies:
"@yarnpkg/lockfile" "^1.1.0"
chalk "^4.1.2"
cross-spawn "^6.0.5"
ci-info "^3.7.0"
cross-spawn "^7.0.3"
find-yarn-workspace-root "^2.0.0"
fs-extra "^7.0.1"
is-ci "^2.0.0"
fs-extra "^9.0.0"
json-stable-stringify "^1.0.2"
klaw-sync "^6.0.0"
minimist "^1.2.6"
open "^7.4.2"
rimraf "^2.6.3"
semver "^5.6.0"
semver "^7.5.3"
slash "^2.0.0"
tmp "^0.0.33"
yaml "^1.10.2"
yaml "^2.2.2"
path-exists@^3.0.0:
version "3.0.0"
@ -3750,10 +3766,10 @@ path-is-absolute@^1.0.0:
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==
path-key@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
path-parse@^1.0.7:
version "1.0.7"
@ -3869,20 +3885,20 @@ postinstall-postinstall@^2.1.0:
resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==
prettier-plugin-organize-imports@^3.1.1:
version "3.2.0"
resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.0.tgz#d33d739109ae4108e02738b9d8f7eb2b29deae93"
integrity sha512-jeZ13YVKgXYCzkuwnoR6saKxJmdRYWMxS2G/su1V3qDWqTo1Q5iSoTblBxsXXAmomXfPqa/uA7YCK0/S86KLOQ==
prettier-plugin-organize-imports@^3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.3.tgz#6b0141ac71f7ee9a673ce83e95456319e3a7cf0d"
integrity sha512-KFvk8C/zGyvUaE3RvxN2MhCLwzV6OBbFSkwZ2OamCrs9ZY4i5L77jQ/w4UmUr+lqX8qbaqVq6bZZkApn+IgJSg==
prettier-plugin-svelte@^2.7.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-2.8.0.tgz#e5681d9867c4ab584c0ccbe43c3684d132b389f2"
integrity sha512-QlXv/U3bUszks3XYDPsk1fsaQC+fo2lshwKbcbO+lrSVdJ+40mB1BfL8OCAk1W9y4pJxpqO/4gqm6NtF3zNGCw==
prettier-plugin-svelte@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-3.0.3.tgz#a823295167f27dc71a4462ee6cb3da9f3f5ca2ea"
integrity sha512-dLhieh4obJEK1hnZ6koxF+tMUrZbV5YGvRpf2+OADyanjya5j0z1Llo8iGwiHmFWZVG/hLEw/AJD5chXd9r3XA==
prettier@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
prettier@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643"
integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==
pretty-bytes@^6.0.0:
version "6.0.0"
@ -3981,6 +3997,11 @@ regenerator-runtime@^0.13.7:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz#ed07b19616bcbec5da6274ebc75ae95634bfc2ee"
integrity sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==
regenerator-runtime@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45"
integrity sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==
replace-in-file@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/replace-in-file/-/replace-in-file-7.0.1.tgz#1bb69a2e5596341cc6f0f581309add6c1d364b71"
@ -4081,10 +4102,10 @@ run-parallel@^1.1.9:
dependencies:
queue-microtask "^1.2.2"
rxjs@^7.0.0:
version "7.5.7"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.7.tgz#2ec0d57fdc89ece220d2e702730ae8f1e49def39"
integrity sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==
rxjs@^7.8.1:
version "7.8.1"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543"
integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==
dependencies:
tslib "^2.1.0"
@ -4141,7 +4162,7 @@ seek-bzip@^1.0.5:
dependencies:
commander "^2.8.1"
semver@^5.5.0, semver@^5.6.0, semver@^5.7.0, semver@^5.7.1:
semver@^5.7.0, semver@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
@ -4151,10 +4172,10 @@ semver@^6.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
semver@^7.3.5, semver@^7.3.8:
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
semver@^7.3.5, semver@^7.3.8, semver@^7.5.3:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"
@ -4168,22 +4189,22 @@ set-cookie-parser@^2.6.0:
resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz#131921e50f62ff1a66a461d7d62d7b21d5d15a51"
integrity sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==
shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
dependencies:
shebang-regex "^1.0.0"
shebang-regex "^3.0.0"
shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==
shebang-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
shell-quote@^1.7.3:
version "1.7.4"
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.4.tgz#33fe15dee71ab2a81fcbd3a52106c5cfb9fb75d8"
integrity sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw==
shell-quote@^1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.1.tgz#6dbf4db75515ad5bac63b4f1894c3a154c766680"
integrity sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==
signal-exit@^3.0.0, signal-exit@^3.0.7:
version "3.0.7"
@ -4259,10 +4280,10 @@ source-map@^0.6.0, source-map@^0.6.1:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
spawn-command@^0.0.2-1:
version "0.0.2-1"
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
integrity sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==
spawn-command@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2.tgz#9544e1a43ca045f8531aac1a48cb29bdae62338e"
integrity sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==
sprintf-js@~1.0.2:
version "1.0.3"
@ -4376,7 +4397,7 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"
supports-color@^8.1.0:
supports-color@^8.1.1:
version "8.1.1"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
@ -4631,10 +4652,10 @@ unique-slug@^2.0.0:
dependencies:
imurmurhash "^0.1.4"
universalify@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
update-browserslist-db@^1.0.9:
version "1.0.10"
@ -4741,14 +4762,7 @@ which-module@^2.0.0:
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
integrity sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==
which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==
dependencies:
isexe "^2.0.0"
which@^2.0.2:
which@^2.0.1, which@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
@ -4819,11 +4833,16 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
yaml@^1.10.0, yaml@^1.10.2:
yaml@^1.10.0:
version "1.10.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
yaml@^2.2.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.2.tgz#f522db4313c671a0ca963a75670f1c12ea909144"
integrity sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==
yargs-parser@^13.1.2:
version "13.1.2"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38"
@ -4878,7 +4897,7 @@ yargs@^15.4.1:
y18n "^4.0.0"
yargs-parser "^18.1.2"
yargs@^17.3.1, yargs@^17.7.2:
yargs@^17.7.2:
version "17.7.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==