mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
feat: enable strictNullChecks
feat: enable `noImplicitAny` chore: remove sync data access fix loading package data for affected dependencies chore: properly get alt marketplace data update patchdb client to allow for emit on undefined values
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
"peerDependencies": {
|
||||
"@angular/common": "^13.2.0",
|
||||
"@angular/core": "^13.2.0",
|
||||
"@angular/router": "^13.2.0",
|
||||
"@ionic/angular": "^6.0.3",
|
||||
"@start9labs/emver": "^0.1.5"
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ export class RpcError<T> {
|
||||
return `${this.error.message}\n\n${this.error.data}`
|
||||
}
|
||||
|
||||
return this.error.data.details
|
||||
return this.error.data?.details
|
||||
? `${this.error.message}\n\n${this.error.data.details}`
|
||||
: this.error.message
|
||||
}
|
||||
@@ -20,6 +20,6 @@ export class RpcError<T> {
|
||||
private getRevision(): T | null {
|
||||
return typeof this.error.data === 'string'
|
||||
? null
|
||||
: this.error.data.revision || null
|
||||
: this.error.data?.revision || null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,12 @@ import { Emver } from '../../services/emver.service'
|
||||
export class EmverSatisfiesPipe implements PipeTransform {
|
||||
constructor(private readonly emver: Emver) {}
|
||||
|
||||
transform(versionUnderTest: string, range: string): boolean {
|
||||
return this.emver.satisfies(versionUnderTest, range)
|
||||
transform(versionUnderTest?: string, range?: string): boolean {
|
||||
return (
|
||||
!!versionUnderTest &&
|
||||
!!range &&
|
||||
this.emver.satisfies(versionUnderTest, range)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,17 @@ export class ConvertBytesPipe implements PipeTransform {
|
||||
name: 'durationToSeconds',
|
||||
})
|
||||
export class DurationToSecondsPipe implements PipeTransform {
|
||||
transform(duration: string | null): number {
|
||||
transform(duration?: string | null): number {
|
||||
if (!duration) return 0
|
||||
const splitUnit = duration.match(/^([0-9]*(\.[0-9]+)?)(ns|µs|ms|s|m|d)$/)
|
||||
const unit = splitUnit[3]
|
||||
const num = splitUnit[1]
|
||||
const [, num, , unit] =
|
||||
duration.match(/^([0-9]*(\.[0-9]+)?)(ns|µs|ms|s|m|d)$/) || []
|
||||
return Number(num) * unitsToSeconds[unit]
|
||||
}
|
||||
}
|
||||
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
|
||||
const unitsToSeconds = {
|
||||
const unitsToSeconds: Record<string, number> = {
|
||||
ns: 1e-9,
|
||||
µs: 1e-6,
|
||||
ms: 0.001,
|
||||
|
||||
@@ -34,5 +34,6 @@ export * from './types/rpc-error-details'
|
||||
export * from './types/url'
|
||||
export * from './types/workspace-config'
|
||||
|
||||
export * from './util/get-pkg-id'
|
||||
export * from './util/misc.util'
|
||||
export * from './util/unused'
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as emver from '@start9labs/emver'
|
||||
export class Emver {
|
||||
constructor() {}
|
||||
|
||||
compare(lhs: string, rhs: string): number {
|
||||
compare(lhs: string, rhs: string): number | null {
|
||||
if (!lhs || !rhs) return null
|
||||
return emver.compare(lhs, rhs)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { IonicSafeString, ToastController } from '@ionic/angular'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ErrorToastService {
|
||||
private toast: HTMLIonToastElement
|
||||
private toast?: HTMLIonToastElement
|
||||
|
||||
constructor(private readonly toastCtrl: ToastController) {}
|
||||
|
||||
|
||||
11
frontend/projects/shared/src/util/get-pkg-id.ts
Normal file
11
frontend/projects/shared/src/util/get-pkg-id.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
|
||||
export function getPkgId({ snapshot }: ActivatedRoute): string {
|
||||
const pkgId = snapshot.paramMap.get('pkgId')
|
||||
|
||||
if (!pkgId) {
|
||||
throw new Error('pkgId is missing from route params')
|
||||
}
|
||||
|
||||
return pkgId
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export function debounce(delay: number = 300): MethodDecorator {
|
||||
|
||||
const original = descriptor.value
|
||||
|
||||
descriptor.value = function (...args) {
|
||||
descriptor.value = function (this: any, ...args: any[]) {
|
||||
clearTimeout(this[timeoutKey])
|
||||
this[timeoutKey] = setTimeout(() => original.apply(this, args), delay)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export function traceThrowDesc<T>(description: string, t: T | undefined): T {
|
||||
export function inMs(
|
||||
count: number,
|
||||
unit: 'days' | 'hours' | 'minutes' | 'seconds',
|
||||
) {
|
||||
): number {
|
||||
switch (unit) {
|
||||
case 'seconds':
|
||||
return count * 1000
|
||||
@@ -63,31 +63,6 @@ export function toObject<T>(t: T[], map: (t0: T) => string): Record<string, T> {
|
||||
}, {} as Record<string, T>)
|
||||
}
|
||||
|
||||
export function deepCloneUnknown<T>(value: T): T {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
return value
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return deepCloneArray(value)
|
||||
}
|
||||
return deepCloneObject(value)
|
||||
}
|
||||
|
||||
export function deepCloneObject<T>(source: T) {
|
||||
const result = {}
|
||||
Object.keys(source).forEach(key => {
|
||||
const value = source[key]
|
||||
result[key] = deepCloneUnknown(value)
|
||||
}, {})
|
||||
return result as T
|
||||
}
|
||||
|
||||
export function deepCloneArray(collection: any) {
|
||||
return collection.map(value => {
|
||||
return deepCloneUnknown(value)
|
||||
})
|
||||
}
|
||||
|
||||
export function partitionArray<T>(
|
||||
ts: T[],
|
||||
condition: (t: T) => boolean,
|
||||
@@ -110,21 +85,3 @@ export function update<T>(
|
||||
): Record<string, T> {
|
||||
return { ...t, ...u }
|
||||
}
|
||||
|
||||
export function uniqueBy<T>(
|
||||
ts: T[],
|
||||
uniqueBy: (t: T) => string,
|
||||
prioritize: (t1: T, t2: T) => T,
|
||||
) {
|
||||
return Object.values(
|
||||
ts.reduce((acc, next) => {
|
||||
const previousValue = acc[uniqueBy(next)]
|
||||
if (previousValue) {
|
||||
acc[uniqueBy(next)] = prioritize(acc[uniqueBy(next)], previousValue)
|
||||
} else {
|
||||
acc[uniqueBy(next)] = previousValue
|
||||
}
|
||||
return acc
|
||||
}, {}),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user