Skip to content

Commit

Permalink
Merge branch 'master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 17, 2025
2 parents e9c8727 + 49c13fc commit ce18cb8
Show file tree
Hide file tree
Showing 16 changed files with 2,883 additions and 3,980 deletions.
7 changes: 2 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ aliases:
- &install-deps
run:
name: Install dependencies
command: npm ci --ignore-scripts
command: npm install --ignore-scripts
- &build-packages
run:
name: Build
Expand All @@ -20,14 +20,11 @@ jobs:
- image: cimg/node:22.3
steps:
- checkout
- run:
name: Update NPM version
command: sudo npm install -g npm@latest
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: npm ci --ignore-scripts
command: npm install --ignore-scripts
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
Expand Down
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

25 changes: 0 additions & 25 deletions .eslintrc.js

This file was deleted.

40 changes: 40 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: ['tests/**'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-base-to-string': 'warn',
},
},
);
10 changes: 8 additions & 2 deletions lib/conditional.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { DynamicModule, ForwardReference, Logger, ModuleMetadata, Type } from '@nestjs/common';
import {
DynamicModule,
ForwardReference,
Logger,
ModuleMetadata,
Type,
} from '@nestjs/common';
import { ConfigModule } from './config.module';

/**
Expand Down Expand Up @@ -54,7 +60,7 @@ export class ConditionalModule {
const evaluation = condition(process.env);
if (evaluation) {
returnModule.imports.push(module);
returnModule.exports.push(module);
returnModule.exports.push(module as Exclude<typeof module, Promise<any>>);
} else {
if (debug) {
Logger.debug(
Expand Down
1 change: 0 additions & 1 deletion lib/config-host.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from './config.constants';
import { ConfigService } from './config.service';


/**
* @publicApi
*/
Expand Down
12 changes: 8 additions & 4 deletions lib/config.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ConfigModule {
.map(factory =>
createConfigProvider(factory as ConfigFactory & ConfigFactoryKeyHost),
)
.filter(item => item) as FactoryProvider[];
.filter(item => item);

const configProviderTokens = providers.map(item => item.provide);
const configServiceProvider = {
Expand Down Expand Up @@ -212,7 +212,9 @@ export class ConfigModule {
return config;
}

private static assignVariablesToProcess(config: Record<string, unknown>) {
private static assignVariablesToProcess(
config: Record<string, unknown>,
): void {
if (!isObject(config)) {
return;
}
Expand All @@ -231,13 +233,15 @@ export class ConfigModule {
host: Record<string, any>,
item: Record<string, any>,
provider: FactoryProvider,
) {
): void {
const factoryRef = provider.useFactory;
const token = getRegistrationToken(factoryRef);
mergeConfigObject(host, item, token);
}

private static getSchemaValidationOptions(options: ConfigModuleOptions) {
private static getSchemaValidationOptions(
options: ConfigModuleOptions,
): Record<string, any> {
if (options.validationOptions) {
if (typeof options.validationOptions.allowUnknown === 'undefined') {
options.validationOptions.allowUnknown = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class ConfigService<
return options && options?.infer && Object.keys(options).length === 1;
}

private updateInterpolatedEnv(propertyPath: string, value: string) {
private updateInterpolatedEnv(propertyPath: string, value: string): void {
let config: ReturnType<typeof dotenv.parse> = {};
for (const envFilePath of this.envFilePaths) {
if (fs.existsSync(envFilePath)) {
Expand Down
14 changes: 7 additions & 7 deletions lib/types/path-value.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export type PathImpl<T, Key extends keyof T> = Key extends string
? IsAny<T[Key]> extends true
? never
: T[Key] extends Record<string, any>
?
| `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> &
string}`
| `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}`
: never
?
| `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> &
string}`
| `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}`
: never
: never;

export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
Expand All @@ -39,5 +39,5 @@ export type PathValue<
: never
: never
: P extends keyof T
? T[P]
: never;
? T[P]
: never;
2 changes: 1 addition & 1 deletion lib/utils/create-config-factory.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FactoryProvider } from '@nestjs/common/interfaces';
import { ConfigFactory } from '../interfaces';
import { getConfigToken } from './get-config-token.util';
import { ConfigFactoryKeyHost } from './register-as.util';
import { randomUUID } from "crypto";
import { randomUUID } from 'crypto';

/**
* @publicApi
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/get-config-token.util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @publicApi
*/
export function getConfigToken(token: string) {
export function getConfigToken(token: string): string {
return `CONFIGURATION(${token})`;
}
2 changes: 1 addition & 1 deletion lib/utils/merge-configs.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function mergeConfigObject(
host: Record<string, any>,
partial: Record<string, any>,
token?: string,
) {
): Record<string, any> | undefined {
if (token) {
set(host, token, partial);
return partial;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/register-as.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigFactoryKeyHost<T = unknown> {

/**
* @publicApi
*
*
* Registers the configuration object behind a specified token.
*/
export function registerAs<
Expand Down
Loading

0 comments on commit ce18cb8

Please sign in to comment.