Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #113

Merged
merged 7 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ jobs:
run: npm run build

- name: Verify @decorator folder, index.ts file, and content
run: ts-node ./postinstall/util/Verifier.ts
run: ts-node ./test/postinstall/Verifier.ts
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ out
# Ignore everything in dist
/dist/*

# But not the postinstall folder
!/dist/postinstall/

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
Expand Down Expand Up @@ -139,6 +136,3 @@ out
.npmrc
@cds-models
@dispatcher

# But not the @dispatcher folder from the test
!/test/bookshop/@dispatcher
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1326,15 +1326,19 @@ class BookHandler {

**@IsColumnSupplied\<T\>(field : keyof T)**

The `@IsColumnSupplied<T>()` decorator is utilized at the `parameter level`. It allows your to verify the existence of a column in the `SELECT`, `INSERT` or `UPSERT` Query.
The `@IsColumnSupplied<T>(field : keyof T)` decorator is utilized at the `parameter level`. It allows your to verify the existence of a column in the `SELECT`, `INSERT` or `UPSERT` Query.

`Parameters`

- `column (string)`: A string representing the name of the column to be verified.
- `field (string)`: A string representing the name of the column to be verified.

`Type Parameters`

- `T`: The entity type (e.g., `MyEntity`) representing the table or collection on which the decorator operates. This allows TypeScript to enforce type safety for the field parameter.

`Return` :

- `boolean`: This decorator returns `true` if `column` was found, `false` otherwise
- `boolean`: This decorator returns `true` if `field / column` was found, `false` otherwise

`Example`

Expand Down Expand Up @@ -1686,7 +1690,7 @@ public async beforeCreate(

##### @Env

**@Env**
**@Env\<T\>(env: PropertyStringPath\<T\>)**

The `@Env` decorator is a parameter decorator used to inject values from the cds.env configuration object directly into a method parameter.

Expand All @@ -1695,6 +1699,9 @@ The `@Env` decorator is a parameter decorator used to inject values from the cds
- `env (string)`: A string path representing a property from `cds.env`. This path follows the format `property string path`, which allows access to deeply nested configuration properties.
- E.g. : `'requires.db.credentials.url'` corresponds to **cds.env.requires.db.credentials.url** object.

`Type Parameters`

- `T`: The `CDS environmental variables` type (e.g., `cds env get`) representing the collection on which the decorator operates. This allows TypeScript to enforce type safety.

`Return` :

Expand All @@ -1703,8 +1710,7 @@ The `@Env` decorator is a parameter decorator used to inject values from the cds
`Example`

```ts
// Generated import inside of your package.json when you run 'npm install' or install the cds-ts-dispatcher
import { CDS_ENV } from '@dispatcher';
import { CDS_ENV } from '#dispatcher';

@BeforeCreate()
public async beforeCreate(
Expand All @@ -1715,10 +1721,11 @@ public async beforeCreate(
// or any other type if you do not want to use the CDS_ENV generated types
) {
if (dbUrl) {
// handle logic using dbUrl
// handle custom logic ...
}
}
```

> [!NOTE]
> When you install cds-ts-dispatcher `(e.g. npm install @dxfrontier/cds-ts-dispatcher)` or run a general `npm install`, the following will be generated or updated :
> - New `@dispatcher` folder is generated at the project ***root***.
Expand Down Expand Up @@ -1750,6 +1757,12 @@ public async beforeCreate(
> [!NOTE]
> The `@dispatcher` folder is ***regenerated each time you run npm install.***

> [!TIP]
> You can import the generated `CDS env` from the generated `@dispatcher` folder by using :
> ```ts
> import { CDS_ENV } from '#dispatcher';
> ```

<p align="right">(<a href="#table-of-contents">back to top</a>)</p>

#### `Method`-`active entity`
Expand Down
159 changes: 0 additions & 159 deletions dist/postinstall/PostInstall.js

This file was deleted.

2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export default tseslint.config(
},
},
{
ignores: ['@dispatcher/', 'dist/', 'build/', 'test/', 'lib/docs/', '*.js'],
ignores: ['@dispatcher/', 'dist/', 'build/', 'test/', 'lib/docs/', '*.js', 'postinstall/'],
},
);
Loading
Loading