mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 19:52:53 +00:00
refactor: update all
This commit is contained in:
committed by
Rainer Killinger
parent
bdaa1f0201
commit
3b0014abac
@@ -54,7 +54,7 @@ export function isThing(something: unknown): something is SCThing {
|
||||
export function isThingWithTranslations(
|
||||
thing: SCThingWithoutReferences,
|
||||
): thing is SCThingWithoutReferences & {translations: SCTranslations<SCThingTranslatableProperties>} {
|
||||
return typeof thing.translations !== 'undefined';
|
||||
return thing.translations !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,11 +108,11 @@ export function isSearchResponse(something: unknown): something is SCSearchRespo
|
||||
return (
|
||||
Array.isArray(somethingObject.data) &&
|
||||
Array.isArray(somethingObject.facets) &&
|
||||
typeof somethingObject.pagination !== 'undefined' &&
|
||||
somethingObject.pagination !== undefined &&
|
||||
typeof somethingObject.pagination.count === 'number' &&
|
||||
typeof somethingObject.pagination.offset === 'number' &&
|
||||
typeof somethingObject.pagination.total === 'number' &&
|
||||
typeof somethingObject.stats !== 'undefined' &&
|
||||
somethingObject.stats !== undefined &&
|
||||
typeof somethingObject.stats.time === 'number'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ export abstract class SCAbstractRoute implements SCRoute {
|
||||
|
||||
const parameter = part.slice(1);
|
||||
|
||||
if (typeof parameters[parameter] === 'undefined') {
|
||||
if (parameters[parameter] === undefined) {
|
||||
throw new TypeError(`Parameter '${parameter}' not provided.`);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ export interface SCThingWithCategoriesSpecificValues {
|
||||
* Meta information about a thing without references that accepts payments
|
||||
* It intentionally does not extend the SCThingMeta implementation to be able to include generics.
|
||||
*/
|
||||
export class SCThingWithCategoriesWithoutReferencesMeta<T, U>
|
||||
export class SCThingWithCategoriesWithoutReferencesMeta<T, U extends SCThingWithCategoriesSpecificValues>
|
||||
implements SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>>
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -117,19 +117,19 @@ export class SCThingTranslator {
|
||||
private getAllMetaFieldTranslations(thingType: SCThingType, language: SCLanguageCode): object | undefined {
|
||||
const fieldTranslations = {};
|
||||
const metaClass = this.getMetaClassInstance(thingType);
|
||||
if (typeof metaClass === 'undefined') {
|
||||
if (metaClass === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Assigns every property in fieldTranslations to the known base language translation
|
||||
if (typeof metaClass.fieldTranslations.en !== 'undefined') {
|
||||
if (metaClass.fieldTranslations.en !== undefined) {
|
||||
for (const key of Object.keys(metaClass.fieldTranslations.en)) {
|
||||
(fieldTranslations as any)[key] = metaClass.fieldTranslations.en[key];
|
||||
}
|
||||
}
|
||||
|
||||
// Assigns every property in fieldTranslations to the known translation in given language
|
||||
if (typeof metaClass.fieldTranslations[language] !== 'undefined') {
|
||||
if (metaClass.fieldTranslations[language] !== undefined) {
|
||||
for (const key of Object.keys(metaClass.fieldTranslations[language])) {
|
||||
(fieldTranslations as any)[key] = metaClass.fieldTranslations[language][key];
|
||||
}
|
||||
@@ -162,10 +162,10 @@ export class SCThingTranslator {
|
||||
*/
|
||||
private replaceAvailableMetaFieldValueTranslations(instance: any, language: SCLanguageCode): any {
|
||||
const metaClass = this.getMetaClassInstance(instance.type);
|
||||
if (typeof metaClass === 'undefined') {
|
||||
if (metaClass === undefined) {
|
||||
return instance;
|
||||
}
|
||||
if (typeof metaClass.fieldValueTranslations[language] !== 'undefined') {
|
||||
if (metaClass.fieldValueTranslations[language] !== undefined) {
|
||||
for (const key of Object.keys(metaClass.fieldValueTranslations[language])) {
|
||||
if (
|
||||
metaClass.fieldValueTranslations[language][key] instanceof Object &&
|
||||
@@ -215,7 +215,7 @@ export class SCThingTranslator {
|
||||
}
|
||||
|
||||
// Spread variable translations given by the connector into thing
|
||||
if (typeof nextInstance.translations?.[targetLanguage] !== 'undefined') {
|
||||
if (nextInstance.translations?.[targetLanguage] !== undefined) {
|
||||
nextInstance = {...nextInstance, ...nextInstance.translations![targetLanguage]} as T;
|
||||
}
|
||||
// Spread known translations from meta classes into (partly) translated thing
|
||||
@@ -234,7 +234,7 @@ export class SCThingTranslator {
|
||||
public translate<T extends SCThing>(thing: T): T {
|
||||
if (equal(this.sourceCache.get(thing), thing)) {
|
||||
const cachedInstance = this.cache.get(thing);
|
||||
if (typeof cachedInstance !== 'undefined') {
|
||||
if (cachedInstance !== undefined) {
|
||||
return cachedInstance as T;
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ export class SCThingTranslator {
|
||||
const object: any = target();
|
||||
if (equal(this.sourceCache.get(thing), thing)) {
|
||||
const objectTranslatedFromCache = this.cache.get(thing);
|
||||
if (typeof objectTranslatedFromCache !== 'undefined') {
|
||||
if (objectTranslatedFromCache !== undefined) {
|
||||
return this.deeptranslate((objectTranslatedFromCache as any)[key]);
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ class LRUCache<T> {
|
||||
}
|
||||
|
||||
const entry = this.entries.get(key);
|
||||
if (typeof entry !== 'undefined') {
|
||||
if (entry !== undefined) {
|
||||
// LRU behavior
|
||||
this.entries.delete(key);
|
||||
this.entries.set(key, entry);
|
||||
|
||||
Reference in New Issue
Block a user