Skip to content

Commit

Permalink
fix: remove utils sub-project (#101)
Browse files Browse the repository at this point in the history
* fix: ngx-repository

* fix: ngx-http-repository

* fix: ngx-firestore-repository and utils

* fix: remove utils

* fix: remove utils lcov path

* fix: rework module imports

* fix: back 2 environment providers
  • Loading branch information
oscar-guerin authored Nov 15, 2024
1 parent 7125f10 commit 90ad2d7
Show file tree
Hide file tree
Showing 97 changed files with 451 additions and 283 deletions.
4 changes: 1 addition & 3 deletions merge-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const path = require('path');
const inputFiles = [
path.join(__dirname, 'coverage/ngx-repository/lcov.info'),
path.join(__dirname, 'coverage/ngx-http-repository/lcov.info'),
path.join(__dirname, 'coverage/ngx-firestore-repository/lcov.info'),
path.join(__dirname, 'coverage/utils/lcov.info'),

path.join(__dirname, 'coverage/ngx-firestore-repository/lcov.info')
];

// Path to save the merged LCOV file
Expand Down
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,30 @@
"scripts": {
"ng": "ng",
"start": "ng serve --project ngx-repository-app",
"build:all": "tsc -p projects/utils/tsconfig.lib.json && ng build --project ngx-repository && ng build --project ngx-http-repository && ng build --project ngx-firestore-repository",
"build:utils": "tsc -p projects/utils/tsconfig.lib.json",
"build:ngx-repository": "npm run build:utils && ng build --project ngx-repository --configuration production && cp README.md dist/ngx-repository",
"build:all": "ng build --project ngx-repository && ng build --project ngx-http-repository && ng build --project ngx-firestore-repository",
"build:ngx-repository": "ng build --project ngx-repository --configuration production && cp README.md dist/ngx-repository",
"build:ngx-http-repository": "npm run build:ngx-repository && ng build --project ngx-http-repository --configuration production && cp README.md dist/ngx-http-repository",
"build:ngx-firestore-repository": "npm run build:ngx-repository && ng build --project ngx-firestore-repository --configuration production && cp README.md dist/ngx-firestore-repository",
"test:ngx-repository": "ng test --project ngx-repository --code-coverage",
"test:ngx-http-repository": "ng test --project ngx-http-repository --code-coverage",
"test:ngx-firestore-repository": "ng test --project ngx-firestore-repository --code-coverage",
"test:utils": "ng test --karma-config projects/utils/karma.conf.js --code-coverage",
"doc:all": "typedoc ./projects/ngx-repository ./projects/ngx-http-repository projects/ngx-firestore-repository",
"doc:ngx-repository": "typedoc ./projects/ngx-repository",
"doc:ngx-http-repository": "typedoc ./projects/ngx-http-repository",
"doc:ngx-firestore-repository": "typedoc projects/ngx-firestore-repository",
"test:ci:ngx-repository": "npm run test:ngx-repository -- --no-watch --no-progress --browsers=ChromeHeadlessCI",
"test:ci:ngx-http-repository": "npm run test:ngx-http-repository -- --no-watch --no-progress --browsers=ChromeHeadlessCI",
"test:ci:ngx-firestore-repository": "npm run test:ngx-firestore-repository -- --no-watch --no-progress --browsers=ChromeHeadlessCI",
"test:ci:utils": "npm run test:utils -- --no-watch --no-progress --browsers=ChromeHeadlessCI",
"test:ci": "npm run test:ci:ngx-repository && npm run test:ci:ngx-http-repository && npm run test:ci:ngx-firestore-repository && npm run test:ci:utils",
"test:ci": "npm run test:ci:ngx-repository && npm run test:ci:ngx-http-repository && npm run test:ci:ngx-firestore-repository",
"test:e2e": "npm run test:ci:ngx-repository && npm run test:ci:ngx-http-repository && npm run test:ci:ngx-firestore-repository",
"posttest:ci": "node merge-coverage.js",
"lint:all": "npm run lint:ngx-repository && npm run lint:ngx-http-repository && npm run lint:ngx-firestore-repository && npm run lint:ngx-repository-app",
"lint:ngx-repository": "ng lint --project ngx-repository",
"lint:ngx-http-repository": "ng lint --project ngx-http-repository",
"lint:ngx-firestore-repository": "ng lint --project ngx-firestore-repository",
"lint:ngx-repository-app": "ng lint --project ngx-repository-app",
"lint:utils": "npx eslint projects/utils/src/**/*.ts",
"release": "cd projects/ngx-repository && npm version ${npm_config_release} && cd ../ngx-http-repository && npm version ${npm_config_release} && cd ../ngx-firestore-repository && npm version ${npm_config_release} && git commit -a -m \"release: v${npm_config_release}\"",
"lint": "ng lint && npm run lint:utils"
"lint": "ng lint"
},
"private": true,
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, Type } from '@angular/core';
import { InjectRepository, provideNgxRepositoryModule } from '@paddls/ngx-repository';
import { InjectRepository, provideNgxRepository } from '@paddls/ngx-repository';
import { TestBed } from '@angular/core/testing';
import { Firestore, getFirestore } from 'firebase/firestore';
import { initializeApp } from 'firebase/app';
Expand Down Expand Up @@ -36,7 +36,7 @@ export function initializeRepository<T>(bookImpl: Type<T>, providers: any[] = []

TestBed.configureTestingModule({
providers: [
provideNgxRepositoryModule(),
provideNgxRepository(),
provideNgxFirestoreRepository(),
BookServiceImpl,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { initializeRepository, RepositoryContext } from './repository-intializer
import { addDoc, deleteDoc, query, updateDoc } from '../../lib/firestore-functions';
import { CollectionReference, DocumentReference } from 'firebase/firestore';
import { FirestoreMock } from './firestore-mock.spec';
import { forOwn } from '@paddls/utils';
import { forOwn } from '../../lib/utils/for-own';

export interface FirestoreTestContext {
entity: Type<any>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { ResourceConfiguration, ResourceParamConfiguration } from '@paddls/ngx-repository';
import { InjectionToken } from '@angular/core';
import { FIRESTORE_OPERATIONS } from '../request/firestore.operation';
import { get, isString, isUndefined, omit } from '@paddls/utils';
import { FirestoreRepositoryParamConfiguration } from './firestore-repository-param.configuration';
import { omit } from '../utils/omit';
import { get } from '../utils/get';
import { isUndefined } from '../utils/is-undefined';
import { isString } from '../utils/is-string';

export const FIRESTORE_REPOSITORY_CONFIGURATION: InjectionToken<FirestoreResourceConfiguration> = new InjectionToken<FirestoreResourceConfiguration>('FIRESTORE_REPOSITORY_CONFIGURATION');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FirestoreRepositoryRequest } from '../request/firestore-repository.request';
import { omitBy } from '@paddls/utils';
import { omitBy } from '../utils/omit-by';

const IGNORED_KEYS: string[] = ['paths', 'readPath', 'createPath', 'updatePath', 'deletePath', 'pathParams', 'replaceParams'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '../configuration/context/firestore-updated-at-context.configuration';
import { NORMALIZER_CONFIGURATION_TOKEN } from '@paddls/ngx-serializer';
import { serverTimestamp } from 'firebase/firestore';
import { set } from '@paddls/utils';
import { set } from '../utils/set';

/**
* @ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { forOwn } from './for-own';

describe('forOwn', () => {
it('should iterate over own properties of an object', () => {
const obj = { a: 1, b: 2, c: 3 };
const obj = {a: 1, b: 2, c: 3};
const result: [string, any][] = [];

forOwn(obj, (value, key) => {
Expand All @@ -13,7 +13,7 @@ describe('forOwn', () => {
});

it('should pass the correct arguments to the iteratee', () => {
const obj = { a: 1 };
const obj = {a: 1};
const iteratee = jasmine.createSpy('iteratee');

forOwn(obj, iteratee);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ import { get } from './get';

describe('get', () => {
it('should return undefined if path is empty', () => {
const obj = { a: 1 };
const obj = {a: 1};
expect(get(obj, '')).toBeUndefined();
});

it('should return the value at the specified path', () => {
const obj = { a: { b: { c: 42 } } };
const obj = {a: {b: {c: 42}}};
expect(get(obj, 'a.b.c')).toBe(42);
});

it('should return the default value if the path does not exist', () => {
const obj = { a: { b: { c: 42 } } };
const obj = {a: {b: {c: 42}}};
expect(get(obj, 'a.b.d', 'default')).toBe('default');
});

it('should return undefined if the path does not exist and no default value is provided', () => {
const obj = { a: { b: { c: 42 } } };
const obj = {a: {b: {c: 42}}};
expect(get(obj, 'a.b.d')).toBeUndefined();
});

it('should handle array paths correctly', () => {
const obj = { a: [{ b: 42 }] };
const obj = {a: [{b: 42}]};
expect(get(obj, 'a[0].b')).toBe(42);
});

it('should handle complex paths with arrays and objects', () => {
const obj = { a: [{ b: { c: 42 } }] };
const obj = {a: [{b: {c: 42}}]};
expect(get(obj, 'a[0].b.c')).toBe(42);
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { omitBy } from './omit-by';

describe('omitBy', () => {
it('should omit properties based on the check function', () => {
const obj = { a: 1, b: '2', c: 3, d: '4' };
const obj = {a: 1, b: '2', c: 3, d: '4'};
const result = omitBy(obj, (value: any) => typeof value === 'string');
expect(result).toEqual({ a: 1, c: 3 });
expect(result).toEqual({a: 1, c: 3});
});

it('should not omit any properties if check function always returns false', () => {
const obj = { a: 1, b: 2, c: 3 };
const obj = {a: 1, b: 2, c: 3};
const result = omitBy(obj, (value: any) => typeof value === 'boolean');
expect(result).toEqual({ a: 1, b: 2, c: 3 });
expect(result).toEqual({a: 1, b: 2, c: 3});
});

it('should omit all properties if check function always returns true', () => {
const obj = { a: 1, b: 2, c: 3 };
const obj = {a: 1, b: 2, c: 3};
const result = omitBy(obj, (value: any) => typeof value === 'number');
expect(result).toEqual({});
});
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ import { omit } from './omit';

describe('omit', () => {
it('should omit a single property', () => {
const obj = { a: 1, b: 2, c: 3 };
const obj = {a: 1, b: 2, c: 3};
const result = omit(obj, ['b']);
expect(result).toEqual({ a: 1, c: 3 });
expect(result).toEqual({a: 1, c: 3});
});

it('should omit multiple properties', () => {
const obj = { a: 1, b: 2, c: 3 };
const obj = {a: 1, b: 2, c: 3};
const result = omit(obj, ['a', 'b']);
expect(result).toEqual({c: 3 });
expect(result).toEqual({c: 3});
});

it('should return an empty object if all properties are omitted', () => {
const obj = { a: 1, b: 2, c: 3 };
const obj = {a: 1, b: 2, c: 3};
const result = omit(obj, ['a', 'b', 'c']);
expect(result).toEqual({});
});

it('should return the original object if no properties are omitted', () => {
const obj = { a: 1, b: 2, c: 3 };
const obj = {a: 1, b: 2, c: 3};
const result = omit(obj, []);
expect(result).toEqual({ a: 1, b: 2, c: 3 });
expect(result).toEqual({a: 1, b: 2, c: 3});
});

it('should handle non-existing properties correctly', () => {
const obj = { a: 1, b: 2 };
const obj = {a: 1, b: 2};
const result = omit(obj, ['c']);
expect(result).toEqual({ a: 1, b: 2 });
expect(result).toEqual({a: 1, b: 2});
});

});
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@ import { set } from './set';

describe('set', () => {
it('should set a value at a given path with dot notation', () => {
const obj = { a: { b: undefined } };
const obj = {a: {b: undefined}};
set(obj, 'a.b.c', 42);
expect(obj).toEqual({ a: { b: { c: 42 } } });
expect(obj).toEqual({a: {b: {c: 42}}});
});

it('should set a value at a given path with array notation', () => {
const obj = { a: { b: undefined } };
const obj = {a: {b: undefined}};
set(obj, ['a', 'b', 'c'], 42);
expect(obj).toEqual({ a: { b: { c: 42 } } });
expect(obj).toEqual({a: {b: {c: 42}}});
});

it('should create nested objects if they do not exist', () => {
const obj = {};
set(obj, 'x.y.z', 'test');
expect(obj).toEqual({ x: { y: { z: 'test' } } });
expect(obj).toEqual({x: {y: {z: 'test'}}});
});

it('should overwrite existing values at the given path', () => {
const obj = { a: { b: { c: 10 } } };
const obj = {a: {b: {c: 10}}};
set(obj, 'a.b.c', 42);
expect(obj).toEqual({ a: { b: { c: 42 } } });
expect(obj).toEqual({a: {b: {c: 42}}});
});

it('should handle empty path array correctly', () => {
const obj = { a: 1 };
const obj = {a: 1};
set(obj, [], 42);
expect(obj).toEqual({ a: 1 });
expect(obj).toEqual({a: 1});
});

it('should handle empty path string correctly', () => {
const obj = { a: 1 };
const obj = {a: 1};
set(obj, '', 42);
expect(obj).toEqual({ a: 1 });
expect(obj).toEqual({a: 1});
});
});
File renamed without changes.
3 changes: 0 additions & 3 deletions projects/ngx-firestore-repository/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"paths": {
"@paddls/ngx-repository": [
"projects/ngx-repository/src/public-api.ts"
],
"@paddls/utils": [
"projects/utils/index.ts"
]
}
},
Expand Down
10 changes: 5 additions & 5 deletions projects/ngx-http-repository/src/e2e/http-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
PageResponseProcessor,
PathColumn,
PathParam,
provideNgxRepositoryModule
provideNgxRepository
} from '@paddls/ngx-repository';
import { provideNgxHttpRepositoryModule } from '../lib/ngx-http-repository.module';
import { provideNgxHttpRepository } from '../lib/ngx-http-repository.module';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { expectHttpRequest, HttpRequestTestContext } from './util/expect-http-request.spec';
Expand All @@ -26,7 +26,7 @@ import {
HttpQueryParam
} from '../public-api';
import { buildHttpParams } from './util/build-http.params.spec';
import { forOwn } from '@paddls/utils';
import { forOwn } from '../lib/utils/for-own';

describe('HttpRequestDecorator', () => {

Expand Down Expand Up @@ -194,8 +194,8 @@ describe('HttpRequestDecorator', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
provideNgxRepositoryModule(),
provideNgxHttpRepositoryModule(),
provideNgxRepository(),
provideNgxHttpRepository(),
Api
]
});
Expand Down
8 changes: 4 additions & 4 deletions projects/ngx-http-repository/src/e2e/live-resource.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { TestBed } from '@angular/core/testing';
import { Column, Id, InjectRepository, Page, provideNgxRepositoryModule } from '@paddls/ngx-repository';
import { Column, Id, InjectRepository, Page, provideNgxRepository } from '@paddls/ngx-repository';
import { HttpLiveResource, HttpRepository, HttpResource } from '../public-api';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { of } from 'rxjs';
import { take, toArray } from 'rxjs/operators';
import { provideNgxHttpRepositoryModule } from '../lib/ngx-http-repository.module';
import { provideNgxHttpRepository } from '../lib/ngx-http-repository.module';

describe('LiveResource', () => {

Expand Down Expand Up @@ -40,8 +40,8 @@ describe('LiveResource', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
provideNgxRepositoryModule(),
provideNgxHttpRepositoryModule(),
provideNgxRepository(),
provideNgxHttpRepository(),
BookService
]
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, Type } from '@angular/core';
import { InjectRepository, provideNgxRepositoryModule } from '@paddls/ngx-repository';
import { InjectRepository, provideNgxRepository } from '@paddls/ngx-repository';
import { HttpRepository } from '../../lib/repository/http.repository';
import { TestBed } from '@angular/core/testing';
import { provideNgxHttpRepositoryModule } from '../../lib/ngx-http-repository.module';
import { provideNgxHttpRepository } from '../../lib/ngx-http-repository.module';

export interface RepositoryContext<T> {
repository: HttpRepository<T, number>;
Expand All @@ -21,8 +21,8 @@ export function initializeRepository<T>(bookImpl: Type<T>, providers: any[] = []

TestBed.configureTestingModule({
providers: [
provideNgxRepositoryModule(),
provideNgxHttpRepositoryModule(),
provideNgxRepository(),
provideNgxHttpRepository(),
BookServiceImpl,
...providers
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable, Type } from '@angular/core';
import { InjectRepository, provideNgxRepositoryModule } from '@paddls/ngx-repository';
import { InjectRepository, provideNgxRepository } from '@paddls/ngx-repository';
import { TestBed } from '@angular/core/testing';
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpRepository } from '../../lib/repository/http.repository';
import { NgxHttpRepositoryModuleConfiguration } from '../../public-api';
import { expectHttpRequest, HttpRequestTestContext } from './expect-http-request.spec';
import { provideNgxHttpRepositoryModule } from '../../lib/ngx-http-repository.module';
import { forOwn } from '@paddls/utils';
import { provideNgxHttpRepository } from '../../lib/ngx-http-repository.module';
import { forOwn } from '../../lib/utils/for-own';

export interface HttpTestContext extends HttpRequestTestContext {
entity: Type<any>;
Expand Down Expand Up @@ -58,8 +58,8 @@ export async function httpTest(httpTestContext: HttpTestContext): Promise<void>

TestBed.configureTestingModule({
providers: [
provideNgxRepositoryModule(),
provideNgxHttpRepositoryModule(httpTestContext.httpConfiguration || {debug: false}),
provideNgxRepository(),
provideNgxHttpRepository(httpTestContext.httpConfiguration || {debug: false}),
...(httpTestContext.providers || []),
...providers
]
Expand Down
Loading

0 comments on commit 90ad2d7

Please sign in to comment.