mirror of
https://github.com/EthanShoeDev/fressh.git
synced 2026-01-11 06:12:51 +00:00
fmt
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
import { logger, consoleTransport } from "react-native-logs";
|
||||
import { logger, consoleTransport } from 'react-native-logs';
|
||||
|
||||
export const rootLogger = logger.createLogger({
|
||||
levels: {
|
||||
debug: 0,
|
||||
info: 1,
|
||||
warn: 2,
|
||||
error: 3,
|
||||
},
|
||||
severity: "debug",
|
||||
transport: consoleTransport,
|
||||
transportOptions: {
|
||||
colors: {
|
||||
info: "blueBright",
|
||||
warn: "yellowBright",
|
||||
error: "redBright",
|
||||
},
|
||||
},
|
||||
async: true,
|
||||
dateFormat: "time",
|
||||
printLevel: true,
|
||||
printDate: true,
|
||||
fixedExtLvlLength: false,
|
||||
enabled: true,
|
||||
levels: {
|
||||
debug: 0,
|
||||
info: 1,
|
||||
warn: 2,
|
||||
error: 3,
|
||||
},
|
||||
severity: 'debug',
|
||||
transport: consoleTransport,
|
||||
transportOptions: {
|
||||
colors: {
|
||||
info: 'blueBright',
|
||||
warn: 'yellowBright',
|
||||
error: 'redBright',
|
||||
},
|
||||
},
|
||||
async: true,
|
||||
dateFormat: 'time',
|
||||
printLevel: true,
|
||||
printDate: true,
|
||||
fixedExtLvlLength: false,
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
@@ -22,15 +22,15 @@ export const useSshConnMutation = (opts?: {
|
||||
const security =
|
||||
connectionDetails.security.type === 'password'
|
||||
? {
|
||||
type: 'password' as const,
|
||||
password: connectionDetails.security.password,
|
||||
}
|
||||
type: 'password' as const,
|
||||
password: connectionDetails.security.password,
|
||||
}
|
||||
: {
|
||||
type: 'key' as const,
|
||||
privateKey: await secretsManager.keys.utils
|
||||
.getPrivateKey(connectionDetails.security.keyId)
|
||||
.then((e) => e.value),
|
||||
};
|
||||
type: 'key' as const,
|
||||
privateKey: await secretsManager.keys.utils
|
||||
.getPrivateKey(connectionDetails.security.keyId)
|
||||
.then((e) => e.value),
|
||||
};
|
||||
|
||||
const sshConnection = await connect({
|
||||
host: connectionDetails.host,
|
||||
|
||||
@@ -78,9 +78,9 @@ function makeBetterSecureStore<
|
||||
const unsafedRootManifest: unknown = rawRootManifestString
|
||||
? JSON.parse(rawRootManifestString)
|
||||
: {
|
||||
manifestVersion: rootManifestVersion,
|
||||
manifestChunksIds: [],
|
||||
};
|
||||
manifestVersion: rootManifestVersion,
|
||||
manifestChunksIds: [],
|
||||
};
|
||||
const rootManifest = rootManifestSchema.parse(unsafedRootManifest);
|
||||
const manifestChunks = await Promise.all(
|
||||
rootManifest.manifestChunksIds.map(async (manifestChunkId) => {
|
||||
@@ -202,7 +202,10 @@ function makeBetterSecureStore<
|
||||
(mChunk) => mChunk.manifestChunk.entries.length === 0,
|
||||
);
|
||||
if (emptyManifestChunks.length > 0) {
|
||||
logger.debug('removing empty manifest chunks', emptyManifestChunks.length);
|
||||
logger.debug(
|
||||
'removing empty manifest chunks',
|
||||
emptyManifestChunks.length,
|
||||
);
|
||||
manifest.rootManifest.manifestChunksIds =
|
||||
manifest.rootManifest.manifestChunksIds.filter(
|
||||
(mChunkId) =>
|
||||
@@ -247,7 +250,10 @@ function makeBetterSecureStore<
|
||||
const existingManifestChunkWithRoom = manifest.manifestChunks.find(
|
||||
(mChunk) => sizeLimit > mChunk.manifestChunkSize + newManifestEntrySize,
|
||||
);
|
||||
logger.debug('existingManifestChunkWithRoom', existingManifestChunkWithRoom);
|
||||
logger.debug(
|
||||
'existingManifestChunkWithRoom',
|
||||
existingManifestChunkWithRoom,
|
||||
);
|
||||
const manifestChunkWithRoom =
|
||||
existingManifestChunkWithRoom ??
|
||||
(await (async () => {
|
||||
@@ -259,7 +265,9 @@ function makeBetterSecureStore<
|
||||
manifestChunkId: Crypto.randomUUID(),
|
||||
manifestChunkSize: 0,
|
||||
} satisfies NonNullable<(typeof manifest.manifestChunks)[number]>;
|
||||
logger.info(`Adding new manifest chunk ${newManifestChunk.manifestChunkId}`);
|
||||
logger.info(
|
||||
`Adding new manifest chunk ${newManifestChunk.manifestChunkId}`,
|
||||
);
|
||||
manifest.rootManifest.manifestChunksIds.push(
|
||||
newManifestChunk.manifestChunkId,
|
||||
);
|
||||
@@ -336,7 +344,9 @@ async function upsertPrivateKey(params: {
|
||||
throw new Error('Invalid private key', { cause: validateKeyResult.error });
|
||||
}
|
||||
const keyId = params.keyId ?? `key_${Crypto.randomUUID()}`;
|
||||
logger.info(`${params.keyId ? 'Upserting' : 'Creating'} private key ${keyId}`);
|
||||
logger.info(
|
||||
`${params.keyId ? 'Upserting' : 'Creating'} private key ${keyId}`,
|
||||
);
|
||||
// Preserve createdAtMs if the entry already exists
|
||||
const existing = await betterKeyStorage
|
||||
.getEntry(keyId)
|
||||
|
||||
@@ -15,11 +15,10 @@ export const AbortSignalTimeout = (timeout: number) => {
|
||||
return controller.signal;
|
||||
};
|
||||
|
||||
|
||||
export const useContextSafe = <T>(context: Context<T>) => {
|
||||
const contextValue = use(context);
|
||||
if (!contextValue) {
|
||||
throw new Error('Context not found');
|
||||
}
|
||||
return contextValue;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user