From bde4591486c1657681be5876230aabfb1dc8efaa Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 09:25:29 +0200 Subject: [PATCH 01/11] feat: config datastore and storage collections --- src/services/config/config.services.ts | 49 +++++++++++++++++++++----- src/types/cli.state.ts | 1 + 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index 77471e3a..86d4f005 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -3,6 +3,8 @@ import { getAuthConfig, getDatastoreConfig, getStorageConfig, + listRules, + ListRulesResults, setAuthConfig, setDatastoreConfig, setStorageConfig @@ -11,6 +13,7 @@ import type { AuthenticationConfig, DatastoreConfig, ModuleSettings, + Rule, SatelliteConfig, StorageConfig } from '@junobuild/config'; @@ -28,6 +31,7 @@ import { import { type CliStateSatelliteAppliedConfigHashes, type ConfigHash, + RuleHash, type SettingsHash } from '../../types/cli.state'; import type {SatelliteParametersWithId} from '../../types/satellite'; @@ -48,6 +52,9 @@ export const config = async () => { const {satelliteId} = satellite; const currentConfig = await loadCurrentConfig({satellite, satelliteConfig}); + + console.log(currentConfig); + const lastAppliedConfig = getLatestAppliedConfig({satelliteId}); const editConfig = await prepareConfig({ @@ -109,11 +116,15 @@ const printResults = (results: SetConfigResults) => { }); }; +type CurrentCollectionsConfig = Record; + interface CurrentConfig { storage?: [StorageConfig, ConfigHash]; datastore?: [DatastoreConfig, ConfigHash]; auth?: [AuthenticationConfig, ConfigHash]; settings?: [ModuleSettings, SettingsHash]; + storageCollections?: CurrentCollectionsConfig; + datastoreCollections?: CurrentCollectionsConfig; } const getCurrentConfig = async ({ @@ -127,21 +138,43 @@ const getCurrentConfig = async ({ storage: userStorageConfig, datastore: userDatastoreConfig, authentication: userAuthConfig, - settings: userSettingConfig + settings: userSettingConfig, + collections: userCollectionsConfig } = satelliteConfig; - const [storage, datastore, auth, settings] = await Promise.all([ - nonNullish(userStorageConfig) ? getStorageConfig({satellite}) : Promise.resolve(), - nonNullish(userDatastoreConfig) ? getDatastoreConfig({satellite}) : Promise.resolve(), - nonNullish(userAuthConfig) ? getAuthConfig({satellite}) : Promise.resolve(), - nonNullish(userSettingConfig) ? getSettings({satellite}) : Promise.resolve() - ]); + const userStorageCollectionsConfig = userCollectionsConfig?.storage; + const userDatastoreCollectionsConfig = userCollectionsConfig?.datastore; + + const [storage, datastore, auth, settings, storageCollections, datastoreCollections] = + await Promise.all([ + nonNullish(userStorageConfig) ? getStorageConfig({satellite}) : Promise.resolve(), + nonNullish(userDatastoreConfig) ? getDatastoreConfig({satellite}) : Promise.resolve(), + nonNullish(userAuthConfig) ? getAuthConfig({satellite}) : Promise.resolve(), + nonNullish(userSettingConfig) ? getSettings({satellite}) : Promise.resolve(), + nonNullish(userStorageCollectionsConfig) && userStorageCollectionsConfig.length > 0 + ? listRules({type: 'storage', satellite}) + : Promise.resolve(undefined), + nonNullish(userDatastoreCollectionsConfig) && userDatastoreCollectionsConfig.length > 0 + ? listRules({type: 'db', satellite}) + : Promise.resolve(undefined) + ]); + + const mapRules = ({items}: ListRulesResults): CurrentCollectionsConfig => + items.reduce( + (acc, rule) => ({ + ...acc, + [rule.collection]: [rule, objHash(rule)] + }), + {} + ); return { ...(nonNullish(storage) && {storage: [storage, objHash(storage)]}), ...(nonNullish(datastore) && {datastore: [datastore, objHash(datastore)]}), ...(nonNullish(auth) && {auth: [auth, objHash(auth)]}), - ...(nonNullish(settings) && {settings: [settings, objHash(settings)]}) + ...(nonNullish(settings) && {settings: [settings, objHash(settings)]}), + ...(nonNullish(storageCollections) && {storageCollections: mapRules(storageCollections)}), + ...(nonNullish(datastoreCollections) && {datastoreCollections: mapRules(datastoreCollections)}) }; }; diff --git a/src/types/cli.state.ts b/src/types/cli.state.ts index bf17c829..35b2dd70 100644 --- a/src/types/cli.state.ts +++ b/src/types/cli.state.ts @@ -1,6 +1,7 @@ import {type PrincipalText} from '@dfinity/zod-schemas'; export type ConfigHash = string; +export type RuleHash = ConfigHash; export type SettingsHash = ConfigHash; export interface CliStateSatelliteAppliedConfigHashes { From dfbdad93b94eb30b9202d9a1091d52c3af73c27d Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 09:30:14 +0200 Subject: [PATCH 02/11] chore: remove console log --- src/services/config/config.services.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index 86d4f005..793d054b 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -53,8 +53,6 @@ export const config = async () => { const currentConfig = await loadCurrentConfig({satellite, satelliteConfig}); - console.log(currentConfig); - const lastAppliedConfig = getLatestAppliedConfig({satelliteId}); const editConfig = await prepareConfig({ From 7d213e4133b58e102c437e6547b9933536f4e796 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 09:32:30 +0200 Subject: [PATCH 03/11] docs: comments --- src/services/config/config.services.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index 793d054b..db1e6097 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -51,18 +51,25 @@ export const config = async () => { const {satellite, satelliteConfig} = await assertConfigAndLoadSatelliteContext(); const {satelliteId} = satellite; + // Load configurations and rules from the Satellite const currentConfig = await loadCurrentConfig({satellite, satelliteConfig}); + // Get the hashes from the CLI state const lastAppliedConfig = getLatestAppliedConfig({satelliteId}); + // Compare last hashes with current configuration of the Satellite + // Prompt the user if there will be an overwrite + // Extends the configuration provided by the dev with the version fields (unless they specified the field themselves) const editConfig = await prepareConfig({ currentConfig, lastAppliedConfig, satelliteConfig }); + // Effectively update the configurations and collections of the Satellite const results = await applyConfig({satellite, editConfig}); + // Save the new hashes in the CLI state saveLastAppliedConfigHashes({ results, settings: editConfig.settings, From 01aaae6061251501daa691f3cfeb5daf79da8342 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 11:41:39 +0200 Subject: [PATCH 04/11] feat: wip --- src/services/config/config.services.ts | 121 +++++++++++++++++++++++-- src/types/cli.state.ts | 8 ++ 2 files changed, 122 insertions(+), 7 deletions(-) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index db1e6097..0df0d471 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -6,15 +6,17 @@ import { listRules, ListRulesResults, setAuthConfig, - setDatastoreConfig, + setDatastoreConfig, setRule, setStorageConfig } from '@junobuild/admin'; import type { AuthenticationConfig, + DatastoreCollection, DatastoreConfig, ModuleSettings, - Rule, + Rule, RulesType, SatelliteConfig, + StorageCollection, StorageConfig } from '@junobuild/config'; import {red} from 'kleur'; @@ -29,6 +31,7 @@ import { DEFAULT_SATELLITE_HEAP_WASM_MEMORY_LIMIT } from '../../constants/settings.constants'; import { + CliStateSatelliteAppliedCollection, type CliStateSatelliteAppliedConfigHashes, type ConfigHash, RuleHash, @@ -66,6 +69,9 @@ export const config = async () => { satelliteConfig }); + // TODO: remove + console.log(editConfig?.collections); + // Effectively update the configurations and collections of the Satellite const results = await applyConfig({satellite, editConfig}); @@ -94,6 +100,8 @@ const saveLastAppliedConfigHashes = ({ const datastore = fulfilledValue(1); const auth = fulfilledValue(2); + // TODO + // @ts-ignore const lastAppliedConfig: CliStateSatelliteAppliedConfigHashes = { storage: nonNullish(storage) ? objHash(storage) : undefined, datastore: nonNullish(datastore) ? objHash(datastore) : undefined, @@ -219,7 +227,18 @@ const setConfigs = async ({ satellite: SatelliteParametersWithId; editConfig: Omit; }): Promise => { - const {storage, authentication, datastore, settings} = editConfig; + const {storage, authentication, datastore, settings, collections} = editConfig; + + const storageCollections = collections?.storage; + const datastoreCollections = collections?.datastore; + + const setRules = async ({collections, type}: {collections: (StorageCollection | DatastoreCollection)[], type: RulesType}) => { + return await Promise.allSettled(collections.map((collection) => setRule({ + rule: collection, + type, + satellite + }))) + } return await Promise.allSettled([ isNullish(storage) @@ -260,7 +279,9 @@ const prepareConfig = async ({ storage: currentStorage, datastore: currentDatastore, auth: currentAuth, - settings: currentSettings + settings: currentSettings, + storageCollections: currentStorageCollections, + datastoreCollections: currentDatastoreCollections } = currentConfig; const isNullishOrDefaultSettings = (): boolean => { @@ -279,6 +300,7 @@ const prepareConfig = async ({ ); }; + // The dev has never applied a configuration, changed the settings or even created a single collection const isDefaultConfig = (): boolean => { const storageVersion = currentStorage?.[0].version; @@ -298,6 +320,21 @@ const prepareConfig = async ({ return false; } + const hasStorageCollections = + nonNullish(currentStorageCollections) && Object.keys(currentStorageCollections).length > 0; + + if (hasStorageCollections) { + return false; + } + + const hasDatastoreCollections = + nonNullish(currentDatastoreCollections) && + Object.keys(currentDatastoreCollections).length > 0; + + if (hasDatastoreCollections) { + return false; + } + return isNullishOrDefaultSettings(); }; @@ -310,7 +347,10 @@ const prepareConfig = async ({ return satelliteConfig; } - const {storage, datastore, authentication, settings} = satelliteConfig; + const {storage, datastore, authentication, settings, collections} = satelliteConfig; + + const storageCollections = collections?.storage; + const datastoreCollections = collections?.datastore; // Extend the satellite config from the juno.config with the current versions available in the backend // Unless the config contains manually defined versions. @@ -319,6 +359,29 @@ const prepareConfig = async ({ const versionDatastore = currentDatastore?.[0]?.version; const versionAuth = currentAuth?.[0]?.version; + const extendCollections = ({ + collections, + currentCollections + }: { + collections: (StorageCollection | DatastoreCollection)[] | undefined; + currentCollections: CurrentCollectionsConfig | undefined; + }): (StorageCollection | DatastoreCollection)[] => + (collections ?? []).map(({collection, version, ...rest}) => ({ + ...rest, + collection, + version: version ?? currentCollections?.[collection]?.[0].version + })); + + const extendedStorageCollections = extendCollections({ + collections: storageCollections, + currentCollections: currentStorageCollections + }); + + const extendedDatastoreCollections = extendCollections({ + collections: datastoreCollections, + currentCollections: currentDatastoreCollections + }); + return { storage: nonNullish(storage) && isNullish(storage.version) @@ -332,7 +395,13 @@ const prepareConfig = async ({ nonNullish(authentication) && isNullish(authentication.version) ? {...authentication, version: versionAuth} : authentication, - settings + settings, + ...(nonNullish(collections) && { + collections: { + ...(nonNullish(storageCollections) && {storage: extendedStorageCollections}), + ...(nonNullish(datastoreCollections) && {datastore: extendedDatastoreCollections}) + } + }) }; }; @@ -357,7 +426,8 @@ const prepareConfig = async ({ storage: lastStorageHash, datastore: lastDatastoreHash, auth: lastAuthHash, - settings: lastSettingsHash + settings: lastSettingsHash, + collections: lastCollectionsHashes } = lastAppliedConfig; const storageHash = currentStorage?.[1]; @@ -378,6 +448,43 @@ const prepareConfig = async ({ return false; } + const isLastAppliedCollectionsCurrent = ({ + lastCollectionsHashes, + currentCollections + }: { + lastCollectionsHashes?: Record | undefined; + currentCollections?: CurrentCollectionsConfig; + }): boolean => + Object.entries(lastCollectionsHashes ?? {}).every( + ([collection, lastHash]) => currentCollections?.[collection]?.[1] === lastHash + ); + + // TODO: remove + console.log( + '----', + isLastAppliedCollectionsCurrent({ + lastCollectionsHashes: lastCollectionsHashes?.datastore, + currentCollections: currentDatastoreCollections + }) + ); + + if ( + !isLastAppliedCollectionsCurrent({ + lastCollectionsHashes: lastCollectionsHashes?.storage, + currentCollections: currentStorageCollections + }) + ) { + return false; + } + if ( + !isLastAppliedCollectionsCurrent({ + lastCollectionsHashes: lastCollectionsHashes?.datastore, + currentCollections: currentDatastoreCollections + }) + ) { + return false; + } + const settingsHash = currentSettings?.[1]; return ( diff --git a/src/types/cli.state.ts b/src/types/cli.state.ts index 35b2dd70..f1f5a460 100644 --- a/src/types/cli.state.ts +++ b/src/types/cli.state.ts @@ -4,11 +4,19 @@ export type ConfigHash = string; export type RuleHash = ConfigHash; export type SettingsHash = ConfigHash; +export type CliStateSatelliteAppliedCollection = string; + +export interface CliStateSatelliteAppliedCollectionsHashes { + storage: Record | undefined; + datastore: Record | undefined; +} + export interface CliStateSatelliteAppliedConfigHashes { storage: ConfigHash | undefined; datastore: ConfigHash | undefined; auth: ConfigHash | undefined; settings: SettingsHash | undefined; + collections: CliStateSatelliteAppliedCollectionsHashes | undefined; } export interface CliStateSatellite { From 04ca3effdea2e544fb5e686d4154cb05a3f9bbaa Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 13:04:24 +0200 Subject: [PATCH 05/11] feat: print errors --- src/services/config/config.services.ts | 91 +++++++++++++++++++++----- 1 file changed, 75 insertions(+), 16 deletions(-) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index 0df0d471..d84863f4 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -6,7 +6,8 @@ import { listRules, ListRulesResults, setAuthConfig, - setDatastoreConfig, setRule, + setDatastoreConfig, + setRule, setStorageConfig } from '@junobuild/admin'; import type { @@ -14,7 +15,8 @@ import type { DatastoreCollection, DatastoreConfig, ModuleSettings, - Rule, RulesType, + Rule, + RulesType, SatelliteConfig, StorageCollection, StorageConfig @@ -47,7 +49,9 @@ type SetConfigResults = [ PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, - PromiseSettledResult + PromiseSettledResult, + PromiseSettledResult[]>, + PromiseSettledResult[]> ]; export const config = async () => { @@ -92,7 +96,7 @@ const saveLastAppliedConfigHashes = ({ }: {results: SetConfigResults} & Pick & Pick) => { const fulfilledValue = ( - index: number + index: 0 | 1 | 2 ): void | StorageConfig | DatastoreConfig | AuthenticationConfig | undefined => results[index].status === 'fulfilled' ? results[index].value : undefined; @@ -100,20 +104,53 @@ const saveLastAppliedConfigHashes = ({ const datastore = fulfilledValue(1); const auth = fulfilledValue(2); - // TODO - // @ts-ignore + const fulfilledCollectionsValues = ( + index: 4 | 5 + ): Record | undefined => + results[index].status === 'fulfilled' + ? results[index].value + ?.map((ruleResult) => (ruleResult.status === 'fulfilled' ? ruleResult.value : undefined)) + .filter(nonNullish) + .reduce>( + (acc, rule) => ({ + ...acc, + [rule.collection]: objHash(rule) + }), + {} + ) + : undefined; + + const storageCollections = fulfilledCollectionsValues(4); + const datastoreCollections = fulfilledCollectionsValues(4); + const lastAppliedConfig: CliStateSatelliteAppliedConfigHashes = { storage: nonNullish(storage) ? objHash(storage) : undefined, datastore: nonNullish(datastore) ? objHash(datastore) : undefined, auth: nonNullish(auth) ? objHash(auth) : undefined, - settings: nonNullish(settings) ? objHash(settings) : undefined + settings: nonNullish(settings) ? objHash(settings) : undefined, + collections: + nonNullish(storageCollections) || nonNullish(datastoreCollections) + ? { + storage: storageCollections, + datastore: datastoreCollections + } + : undefined }; saveLastAppliedConfig({lastAppliedConfig, satelliteId}); }; const printResults = (results: SetConfigResults) => { - const errors = results.filter((result) => result.status === 'rejected'); + const configErrors = results.filter((result) => result.status === 'rejected'); + + const filterCollectionsErrors = (index: 4 | 5): PromiseRejectedResult[] => + results[index].status === 'fulfilled' + ? (results[index].value ?? []).filter((result) => result.status === 'rejected') + : []; + + const collectionsErrors = [...filterCollectionsErrors(4), ...filterCollectionsErrors(5)]; + + const errors = [...configErrors, ...collectionsErrors]; if (errors.length === 0) { console.log('✅ Configuration applied.'); @@ -232,13 +269,23 @@ const setConfigs = async ({ const storageCollections = collections?.storage; const datastoreCollections = collections?.datastore; - const setRules = async ({collections, type}: {collections: (StorageCollection | DatastoreCollection)[], type: RulesType}) => { - return await Promise.allSettled(collections.map((collection) => setRule({ - rule: collection, - type, - satellite - }))) - } + const setRules = async ({ + collections, + type + }: { + collections: (StorageCollection | DatastoreCollection)[]; + type: RulesType; + }): Promise[]> => { + return await Promise.allSettled( + collections.map((collection) => + setRule({ + rule: collection, + type, + satellite + }) + ) + ); + }; return await Promise.allSettled([ isNullish(storage) @@ -262,7 +309,19 @@ const setConfigs = async ({ config: authentication, satellite }), - isNullish(settings) ? Promise.resolve() : setSettings({settings, satellite}) + isNullish(settings) ? Promise.resolve() : setSettings({settings, satellite}), + isNullish(storageCollections) || storageCollections.length === 0 + ? Promise.resolve(undefined) + : setRules({ + type: 'storage', + collections: storageCollections + }), + isNullish(datastoreCollections) || datastoreCollections.length === 0 + ? Promise.resolve(undefined) + : setRules({ + type: 'db', + collections: datastoreCollections + }) ]); }; From 7d4b9a0413492d474b2ca91047b77d1f5bc423ed Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 13:05:43 +0200 Subject: [PATCH 06/11] feat: save state collections --- src/configs/cli.state.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/configs/cli.state.config.ts b/src/configs/cli.state.config.ts index 1d470fb1..4cac8a55 100644 --- a/src/configs/cli.state.config.ts +++ b/src/configs/cli.state.config.ts @@ -34,7 +34,8 @@ export const saveLastAppliedConfig = ({ storage: storage ?? lastAppliedConfig?.storage, datastore: datastore ?? lastAppliedConfig?.datastore, auth: auth ?? lastAppliedConfig?.auth, - settings: settings ?? lastAppliedConfig?.settings + settings: settings ?? lastAppliedConfig?.settings, + collections: settings ?? lastAppliedConfig?.collections, } } }; From f9713cd825c8d8e1189977a27163603d8d5f83fc Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 13:06:46 +0200 Subject: [PATCH 07/11] fix: index --- src/services/config/config.services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index d84863f4..0323fb26 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -121,7 +121,7 @@ const saveLastAppliedConfigHashes = ({ : undefined; const storageCollections = fulfilledCollectionsValues(4); - const datastoreCollections = fulfilledCollectionsValues(4); + const datastoreCollections = fulfilledCollectionsValues(5); const lastAppliedConfig: CliStateSatelliteAppliedConfigHashes = { storage: nonNullish(storage) ? objHash(storage) : undefined, From 5afc11cb2a40b21d1632449de0887bfd4cc3abf7 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 13:09:06 +0200 Subject: [PATCH 08/11] fix: save state collections --- src/configs/cli.state.config.ts | 4 ++-- src/services/config/config.services.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/configs/cli.state.config.ts b/src/configs/cli.state.config.ts index 4cac8a55..8a63e458 100644 --- a/src/configs/cli.state.config.ts +++ b/src/configs/cli.state.config.ts @@ -19,7 +19,7 @@ export const getLatestAppliedConfig = ({ export const saveLastAppliedConfig = ({ satelliteId, - lastAppliedConfig: {storage, datastore, auth, settings} + lastAppliedConfig: {storage, datastore, auth, settings, collections} }: {satelliteId: PrincipalText} & Pick) => { const config = getStateConfig(); @@ -35,7 +35,7 @@ export const saveLastAppliedConfig = ({ datastore: datastore ?? lastAppliedConfig?.datastore, auth: auth ?? lastAppliedConfig?.auth, settings: settings ?? lastAppliedConfig?.settings, - collections: settings ?? lastAppliedConfig?.collections, + collections: collections ?? lastAppliedConfig?.collections } } }; diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index 0323fb26..f04b6bfd 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -137,6 +137,9 @@ const saveLastAppliedConfigHashes = ({ : undefined }; + // TODO: remove + console.log('/___', lastAppliedConfig); + saveLastAppliedConfig({lastAppliedConfig, satelliteId}); }; From fc8dd0bfa48a4bf9afc7e7932c5e644fe6332898 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 13:15:39 +0200 Subject: [PATCH 09/11] chore: remove console log --- src/services/config/config.services.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index f04b6bfd..88d28edb 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -73,9 +73,6 @@ export const config = async () => { satelliteConfig }); - // TODO: remove - console.log(editConfig?.collections); - // Effectively update the configurations and collections of the Satellite const results = await applyConfig({satellite, editConfig}); @@ -137,9 +134,6 @@ const saveLastAppliedConfigHashes = ({ : undefined }; - // TODO: remove - console.log('/___', lastAppliedConfig); - saveLastAppliedConfig({lastAppliedConfig, satelliteId}); }; @@ -521,15 +515,6 @@ const prepareConfig = async ({ ([collection, lastHash]) => currentCollections?.[collection]?.[1] === lastHash ); - // TODO: remove - console.log( - '----', - isLastAppliedCollectionsCurrent({ - lastCollectionsHashes: lastCollectionsHashes?.datastore, - currentCollections: currentDatastoreCollections - }) - ); - if ( !isLastAppliedCollectionsCurrent({ lastCollectionsHashes: lastCollectionsHashes?.storage, From 13217072bc8d830bee97b98bf8521ebc7ed870b1 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 13:17:15 +0200 Subject: [PATCH 10/11] chore: lint --- src/services/config/config.services.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index 88d28edb..e85a5217 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -4,7 +4,7 @@ import { getDatastoreConfig, getStorageConfig, listRules, - ListRulesResults, + type ListRulesResults, setAuthConfig, setDatastoreConfig, setRule, @@ -33,10 +33,10 @@ import { DEFAULT_SATELLITE_HEAP_WASM_MEMORY_LIMIT } from '../../constants/settings.constants'; import { - CliStateSatelliteAppliedCollection, + type CliStateSatelliteAppliedCollection, type CliStateSatelliteAppliedConfigHashes, type ConfigHash, - RuleHash, + type RuleHash, type SettingsHash } from '../../types/cli.state'; import type {SatelliteParametersWithId} from '../../types/satellite'; @@ -50,8 +50,8 @@ type SetConfigResults = [ PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, - PromiseSettledResult[]>, - PromiseSettledResult[]> + PromiseSettledResult>>, + PromiseSettledResult>> ]; export const config = async () => { @@ -270,12 +270,12 @@ const setConfigs = async ({ collections, type }: { - collections: (StorageCollection | DatastoreCollection)[]; + collections: Array; type: RulesType; - }): Promise[]> => { + }): Promise>> => { return await Promise.allSettled( - collections.map((collection) => - setRule({ + collections.map(async (collection) => + await setRule({ rule: collection, type, satellite @@ -419,9 +419,9 @@ const prepareConfig = async ({ collections, currentCollections }: { - collections: (StorageCollection | DatastoreCollection)[] | undefined; + collections: Array | undefined; currentCollections: CurrentCollectionsConfig | undefined; - }): (StorageCollection | DatastoreCollection)[] => + }): Array => (collections ?? []).map(({collection, version, ...rest}) => ({ ...rest, collection, From d7a5800d782063272f29916371bf87fac0f74037 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sat, 2 Aug 2025 13:18:54 +0200 Subject: [PATCH 11/11] chore: lint --- eslint.config.mjs | 1 + src/services/config/config.services.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 1d2ecafa..71d91181 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -32,6 +32,7 @@ export default [ 'no-console': 'off', 'arrow-body-style': 'off', complexity: 'off', + 'max-lines': ['error', 600], '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-misused-promises': 'off', diff --git a/src/services/config/config.services.ts b/src/services/config/config.services.ts index e85a5217..79c8ff27 100644 --- a/src/services/config/config.services.ts +++ b/src/services/config/config.services.ts @@ -274,12 +274,13 @@ const setConfigs = async ({ type: RulesType; }): Promise>> => { return await Promise.allSettled( - collections.map(async (collection) => - await setRule({ - rule: collection, - type, - satellite - }) + collections.map( + async (collection) => + await setRule({ + rule: collection, + type, + satellite + }) ) ); };