Skip to content

Commit

Permalink
chore: angular 19 & provide functions (#102)
Browse files Browse the repository at this point in the history
* chore: update to ng 19

* chore: standalone bootstrap

* chore: execute inject migration

* chore: provide ngx repository

* chore: provide drivers

* chore: bump dependencies

* release: v9.0.0-rc.1
  • Loading branch information
oscar-guerin authored Feb 14, 2025
1 parent 6c833b2 commit a8bb737
Show file tree
Hide file tree
Showing 166 changed files with 7,452 additions and 8,018 deletions.
13 changes: 11 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@
"style": "camelCase"
}
],
"quotes": ["error", "single", { "allowTemplateLiterals": true } ],
"semi": ["error", "always"],
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
],
"semi": [
"error",
"always"
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
Expand Down
24 changes: 13 additions & 11 deletions .run/build_all.run.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build:all" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="build:all" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
<configuration default="false"
name="build:all"
type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="build:all"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>
20 changes: 11 additions & 9 deletions .run/core.run.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="core" type="JavaScriptTestRunnerKarma">
<config-file value="$PROJECT_DIR$/projects/ngx-repository/karma.conf.js"/>
<karma-options value="--browsers=ChromeHeadless"/>
<karma-package-dir value="$PROJECT_DIR$/node_modules/@angular/cli"/>
<working-directory value="$PROJECT_DIR$"/>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
<configuration default="false"
name="core"
type="JavaScriptTestRunnerKarma">
<config-file value="$PROJECT_DIR$/projects/ngx-repository/karma.conf.js"/>
<karma-options value="--browsers=ChromeHeadless"/>
<karma-package-dir value="$PROJECT_DIR$/node_modules/@angular/cli"/>
<working-directory value="$PROJECT_DIR$"/>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>
4 changes: 3 additions & 1 deletion .run/firestore.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="firestore" type="JavaScriptTestRunnerKarma">
<configuration default="false"
name="firestore"
type="JavaScriptTestRunnerKarma">
<config-file value="$PROJECT_DIR$/projects/ngx-firestore-repository/karma.conf.js"/>
<karma-options value="--browsers=ChromeHeadless"/>
<karma-package-dir value="$PROJECT_DIR$/node_modules/@angular/cli"/>
Expand Down
20 changes: 11 additions & 9 deletions .run/http.run.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="http" type="JavaScriptTestRunnerKarma">
<config-file value="$PROJECT_DIR$/projects/ngx-http-repository/karma.conf.js"/>
<karma-options value="--browsers=ChromeHeadless"/>
<karma-package-dir value="$PROJECT_DIR$/node_modules/@angular/cli"/>
<working-directory value="$PROJECT_DIR$"/>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
<configuration default="false"
name="http"
type="JavaScriptTestRunnerKarma">
<config-file value="$PROJECT_DIR$/projects/ngx-http-repository/karma.conf.js"/>
<karma-options value="--browsers=ChromeHeadless"/>
<karma-package-dir value="$PROJECT_DIR$/node_modules/@angular/cli"/>
<working-directory value="$PROJECT_DIR$"/>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>
24 changes: 13 additions & 11 deletions .run/lint.run.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lint:all" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="lint:all" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
<configuration default="false"
name="lint:all"
type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="lint:all"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>
22 changes: 12 additions & 10 deletions .run/start.run.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="start" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="start"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
<configuration default="false"
name="start"
type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="start"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>
22 changes: 12 additions & 10 deletions .run/test_ngx-firebase-repository.run.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test:ngx-firestore-repository" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="test:ci:ngx-firestore-repository"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
<configuration default="false"
name="test:ngx-firestore-repository"
type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="test:ci:ngx-firestore-repository"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ To start using NgxRepository, import `NgxRepositoryModule` and the modules corre
import { NgxRepositoryModule } from '@paddls/ngx-repository';
import { NgxHttpRepositoryModule } from '@paddls/ngx-http-repository';
import { NgxFirestoreRepositoryModule } from '@paddls/ngx-firestore-repository';
import {initializeFirestore} from 'firebase/firestore';
import { initializeFirestore } from 'firebase/firestore';

const firebaseApp: FirebaseApp = initializeApp({
apiKey: 'TODO',
Expand All @@ -111,7 +111,7 @@ const firestore = initializeFirestore(firebaseApp, {
NgxRepositoryModule.forRoot(),
NgxHttpRepositoryModule.forRoot(), // Http driver
NgxFirestoreRepositoryModule.forRoot({
firestore
firestore
}), // Firestore driver
]
})
Expand Down Expand Up @@ -200,7 +200,7 @@ import { HttpRepository } from '@paddls/ngx-http-repository'
export class BookService {

// repository is build with Http driver for User resource
@InjectRepository({resourceType: () => Book, repository: () => HttpRepository})
@InjectRepository({ resourceType: () => Book, repository: () => HttpRepository })
private readonly bookRepository: HttpRepository<Book, number>;

public findAll(): Observable<Page<Book>> {
Expand Down Expand Up @@ -262,17 +262,17 @@ export class User {
As shown in the example above, each configuration field is optional : you can define any field you want or not to have
any configuration at all.

| Field | Description | Available on `@Id()` |
|------------------------|-----------------------------------------------------------------------------------------------------------------|------------------------|
| `field` | Field name in JSON | Yes |
| `type` | Field type after deserialization : only fields with `@Id()` or `@Column()` decorator in type will be serialized | No |
| `readOnly` | Boolean to indicate to not send the value in json to the server | Yes |
| `writeOnly` | Boolean to indicate to ignore the field in json | Yes |
| `customConverter` | A converter to make a custom serialization/deserialization | No |
| `denormalizeNull` | Boolean to override global configuration to denormalize the column when is set to null value | Yes |
| `denormalizeUndefined` | Boolean to override global configuration to denormalize the column when is set to undefined value | Yes |
| `normalizeNull` | Boolean to override global configuration to normalize the column when is set to null value | Yes |
| `normalizeUndefined` | Boolean to override global configuration to normalize the column when is set to undefined value | Yes |
| Field | Description | Available on `@Id()` |
|------------------------|-----------------------------------------------------------------------------------------------------------------|----------------------|
| `field` | Field name in JSON | Yes |
| `type` | Field type after deserialization : only fields with `@Id()` or `@Column()` decorator in type will be serialized | No |
| `readOnly` | Boolean to indicate to not send the value in json to the server | Yes |
| `writeOnly` | Boolean to indicate to ignore the field in json | Yes |
| `customConverter` | A converter to make a custom serialization/deserialization | No |
| `denormalizeNull` | Boolean to override global configuration to denormalize the column when is set to null value | Yes |
| `denormalizeUndefined` | Boolean to override global configuration to denormalize the column when is set to undefined value | Yes |
| `normalizeNull` | Boolean to override global configuration to normalize the column when is set to null value | Yes |
| `normalizeUndefined` | Boolean to override global configuration to normalize the column when is set to undefined value | Yes |
|

The `field` and `type` fields can be defined using a shorthand. For `field`, just specify a string directly in the
Expand Down Expand Up @@ -492,10 +492,11 @@ available.
The following example shows a query used in a `findAll()` operation on a Firestore resource.

```typescript

@Injectable()
export class ClientService {

@InjectRepository({resourceType: () => Client, repository: () => FirestoreRepository})
@InjectRepository({ resourceType: () => Client, repository: () => FirestoreRepository })
private repository: FirestoreRepository<Client, string>;

public searchByLastName(searchedLastName: string): Observable<Page<Client>> {
Expand All @@ -516,6 +517,7 @@ and `@FirestoreResource()` resource decorators.
> the operation. This can be done by using the syntax in the following example.
```typescript

@HttpResource({
path: '/libraries',
update: '/library',
Expand Down Expand Up @@ -568,6 +570,7 @@ context is also possible to define the `path` context parameter.
> ⚠️ This context parameter is only available for `@HttpResource()`
```typescript

@HttpResource({
path: '/libraries',
create: {
Expand All @@ -589,6 +592,7 @@ Define a specific [page response processor](#page-response-processor) using
> `@HttpResource()`
```typescript

@HttpResource({
path: '/libraries',
findAll: {
Expand Down Expand Up @@ -764,7 +768,7 @@ export class PersonRepository extends HttpRepository<Person, string> {
public constructor(requestManager: RequestManager,
driver: HttpRepositoryDriver,
@Inject(HTTP_REPOSITORY_CONFIGURATION)
configuration: ResourceConfiguration) {
configuration: ResourceConfiguration) {
super(requestManager, driver, configuration);
}

Expand Down Expand Up @@ -798,6 +802,7 @@ bodies or requests with a response type different from body type.
To do that, simply create an ``@Injectable()`` class and define your API methods inside like in the following example :

```typescript

@Injectable()
class Api {

Expand Down Expand Up @@ -1070,6 +1075,7 @@ describe('LibraryService', () => {
You can enable debug mode by setting ``debug`` flag to ``true`` in your repository module import config.

```typescript

@NgModule({
imports: [
BrowserModule,
Expand Down
10 changes: 5 additions & 5 deletions merge-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const path = require('path');

// List of LCOV files to merge
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/ngx-repository/lcov.info'),
path.join(__dirname, 'coverage/ngx-http-repository/lcov.info'),
path.join(__dirname, 'coverage/ngx-firestore-repository/lcov.info')
];

// Path to save the merged LCOV file
Expand All @@ -15,10 +15,10 @@ const outputFile = path.join(__dirname, 'coverage/merged/lcov.info');
// Ensure the output directory exists
const outputDir = path.dirname(outputFile);
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, {recursive: true});
fs.mkdirSync(outputDir, {recursive: true});
}

mergeCoverageReportFiles(inputFiles, {pattern: ''}).then(filePath => {
fs.writeFileSync(outputFile, fs.readFileSync(filePath, 'utf8'), 'utf8');
fs.writeFileSync(outputFile, fs.readFileSync(filePath, 'utf8'), 'utf8');
});
console.log('Merged coverage reports into:', outputFile);
Loading

0 comments on commit a8bb737

Please sign in to comment.