@klerick/json-api-nestjs-shared 1.0.0-beta.4 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +8 -0
- package/cjs/src/lib/types/entity-type.d.ts +15 -6
- package/cjs/src/lib/types/entity-type.test-d.js.map +1 -1
- package/cjs/src/lib/types/response-body.d.ts +2 -2
- package/mjs/src/lib/types/entity-type.d.ts +15 -6
- package/mjs/src/lib/types/entity-type.test-d.js.map +1 -1
- package/mjs/src/lib/types/response-body.d.ts +2 -2
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 1.0.0-beta.6 (2026-01-23)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **json-api-nestjs-shared,json-api-nestjs:** im did mistake in commit msg ([56c483a](https://github.com/klerick/nestjs-json-api/commit/56c483a))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Alex H
|
|
10
|
+
|
|
11
|
+
## 1.0.0-beta.5 (2026-01-23)
|
|
12
|
+
|
|
13
|
+
### 🚀 Features
|
|
14
|
+
|
|
15
|
+
- **json-api-nestjs-shared:** enhance type utilities with `UnwrapReference`, `FunctionKeys`, and refine `PropertyKeys` logic ([d864270](https://github.com/klerick/nestjs-json-api/commit/d864270))
|
|
16
|
+
|
|
17
|
+
### ❤️ Thank You
|
|
18
|
+
|
|
19
|
+
- Alex H
|
|
20
|
+
|
|
1
21
|
## 1.0.0-beta.4 (2025-11-13)
|
|
2
22
|
|
|
3
23
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<p align='center'>
|
|
2
|
+
<a href="https://www.npmjs.com/package/@klerick/json-api-nestjs-shared" target="_blank"><img src="https://img.shields.io/npm/v/@klerick/json-api-nestjs-shared.svg" alt="NPM Version" /></a>
|
|
3
|
+
<a href="https://www.npmjs.com/package/@klerick/json-api-nestjs-shared" target="_blank"><img src="https://img.shields.io/npm/l/@klerick/json-api-nestjs-shared.svg" alt="Package License" /></a>
|
|
4
|
+
<a href="https://www.npmjs.com/package/@klerick/json-api-nestjs-shared" target="_blank"><img src="https://img.shields.io/npm/dm/@klerick/json-api-nestjs-shared.svg" alt="NPM Downloads" /></a>
|
|
5
|
+
<a href="http://commitizen.github.io/cz-cli/" target="_blank"><img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen friendly" /></a>
|
|
6
|
+
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/klerick/02a4c98cf7008fea2af70dc2d50f4cb7/raw/json-api-nestjs-microorm.json" alt="Coverage Badge" />
|
|
7
|
+
</p>
|
|
8
|
+
|
|
1
9
|
# json-api-nestjs-shared
|
|
2
10
|
|
|
3
11
|
Helper module for **[json-api-nestjs](https://github.com/klerick/nestjs-json-api/tree/master/libs/json-api/json-api-nestjs)**
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type HasId<T, IdKey extends string> = IdKey extends keyof T ? 1 : 0;
|
|
2
|
+
type UnwrapReference<T> = T extends {
|
|
3
|
+
unwrap: Function;
|
|
4
|
+
} ? T extends {
|
|
5
|
+
unwrap(): infer U;
|
|
6
|
+
} ? U & {} : T : T;
|
|
3
7
|
export type CastIteratorType<T> = T extends {
|
|
4
8
|
[Symbol.iterator](): Iterator<infer U>;
|
|
5
|
-
} ? U : T
|
|
9
|
+
} ? U : UnwrapReference<T>;
|
|
6
10
|
type RelationCheck<T, IdKey extends string> = T extends never ? 0 : T extends Promise<infer U> ? RelationCheck<U, IdKey> : HasId<Exclude<CastIteratorType<T>, undefined>, IdKey>;
|
|
11
|
+
type StringKeys<E> = Extract<keyof E, string>;
|
|
12
|
+
type FunctionKeys<E> = {
|
|
13
|
+
[K in StringKeys<E>]: E[K] extends Function ? K : never;
|
|
14
|
+
}[StringKeys<E>];
|
|
7
15
|
export type RelationKeys<E, IdKey extends string = 'id'> = {
|
|
8
|
-
[K in
|
|
9
|
-
}[
|
|
10
|
-
export type PropertyKeys<E, IdKey extends string = 'id'> =
|
|
16
|
+
[K in StringKeys<E>]: Exclude<E[K], null> extends never ? never : RelationCheck<Exclude<E[K], null>, IdKey> extends 1 ? K : never;
|
|
17
|
+
}[StringKeys<E>];
|
|
18
|
+
export type PropertyKeys<E, IdKey extends string = 'id'> = Exclude<StringKeys<E>, RelationKeys<E, IdKey> | FunctionKeys<E>>;
|
|
19
|
+
export type AttrKeys<E, IdKey extends string = 'id'> = Exclude<PropertyKeys<E, IdKey>, IdKey>;
|
|
11
20
|
export type IsIterator<T> = T extends {
|
|
12
21
|
[Symbol.iterator](): Iterator<any>;
|
|
13
22
|
} ? 1 : 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-type.test-d.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-shared/src/lib/types/entity-type.test-d.ts"],"names":[],"mappings":";;AAAA,6BAAiC;
|
|
1
|
+
{"version":3,"file":"entity-type.test-d.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-shared/src/lib/types/entity-type.test-d.ts"],"names":[],"mappings":";;AAAA,6BAAiC;AAqDjC,IAAA,gBAAU,EAAqB,CAAC,CAAC,CAAC;AAClC,IAAA,gBAAU,EAAuB,CAAC,CAAC,CAAC;AACpC,IAAA,gBAAU,EAAyB,CAAC,CAAC,CAAC;AAEtC,IAAA,gBAAU,EAAqB,CAAC,CAAC,CAAC;AAClC,IAAA,gBAAU,EAAuB,CAAC,CAAC,CAAC;AACpC,IAAA,gBAAU,EAAyB,CAAC,CAAC,CAAC;AAKtC,IAAA,gBAAU,EAAyB,CAAC,CAAC,CAAC;AACtC,IAAA,gBAAU,EAA8B,CAAC,CAAC,CAAC;AAC3C,IAAA,gBAAU,EAAoB,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttrKeys, RelationKeys, IsIterator, CastIteratorType } from './entity-type';
|
|
2
2
|
import { ValueOf } from './entity-type';
|
|
3
3
|
export type DebugMetaProps = Partial<{
|
|
4
4
|
time: number;
|
|
@@ -24,7 +24,7 @@ export type BaseLinks = {
|
|
|
24
24
|
links: Links;
|
|
25
25
|
};
|
|
26
26
|
export type Attributes<Entity extends object, IdKey extends string = 'id'> = {
|
|
27
|
-
[P in Exclude<
|
|
27
|
+
[P in Exclude<AttrKeys<Entity>, IdKey>]?: Entity[P];
|
|
28
28
|
};
|
|
29
29
|
export type BaseAttribute<Entity extends object, IdKey extends string = 'id'> = {
|
|
30
30
|
attributes?: Attributes<Entity, IdKey>;
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type HasId<T, IdKey extends string> = IdKey extends keyof T ? 1 : 0;
|
|
2
|
+
type UnwrapReference<T> = T extends {
|
|
3
|
+
unwrap: Function;
|
|
4
|
+
} ? T extends {
|
|
5
|
+
unwrap(): infer U;
|
|
6
|
+
} ? U & {} : T : T;
|
|
3
7
|
export type CastIteratorType<T> = T extends {
|
|
4
8
|
[Symbol.iterator](): Iterator<infer U>;
|
|
5
|
-
} ? U : T
|
|
9
|
+
} ? U : UnwrapReference<T>;
|
|
6
10
|
type RelationCheck<T, IdKey extends string> = T extends never ? 0 : T extends Promise<infer U> ? RelationCheck<U, IdKey> : HasId<Exclude<CastIteratorType<T>, undefined>, IdKey>;
|
|
11
|
+
type StringKeys<E> = Extract<keyof E, string>;
|
|
12
|
+
type FunctionKeys<E> = {
|
|
13
|
+
[K in StringKeys<E>]: E[K] extends Function ? K : never;
|
|
14
|
+
}[StringKeys<E>];
|
|
7
15
|
export type RelationKeys<E, IdKey extends string = 'id'> = {
|
|
8
|
-
[K in
|
|
9
|
-
}[
|
|
10
|
-
export type PropertyKeys<E, IdKey extends string = 'id'> =
|
|
16
|
+
[K in StringKeys<E>]: Exclude<E[K], null> extends never ? never : RelationCheck<Exclude<E[K], null>, IdKey> extends 1 ? K : never;
|
|
17
|
+
}[StringKeys<E>];
|
|
18
|
+
export type PropertyKeys<E, IdKey extends string = 'id'> = Exclude<StringKeys<E>, RelationKeys<E, IdKey> | FunctionKeys<E>>;
|
|
19
|
+
export type AttrKeys<E, IdKey extends string = 'id'> = Exclude<PropertyKeys<E, IdKey>, IdKey>;
|
|
11
20
|
export type IsIterator<T> = T extends {
|
|
12
21
|
[Symbol.iterator](): Iterator<any>;
|
|
13
22
|
} ? 1 : 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-type.test-d.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-shared/src/lib/types/entity-type.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"entity-type.test-d.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-shared/src/lib/types/entity-type.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAqDjC,UAAU,CAAqB,CAAC,CAAC,CAAC;AAClC,UAAU,CAAuB,CAAC,CAAC,CAAC;AACpC,UAAU,CAAyB,CAAC,CAAC,CAAC;AAEtC,UAAU,CAAqB,CAAC,CAAC,CAAC;AAClC,UAAU,CAAuB,CAAC,CAAC,CAAC;AACpC,UAAU,CAAyB,CAAC,CAAC,CAAC;AAKtC,UAAU,CAAyB,CAAC,CAAC,CAAC;AACtC,UAAU,CAA8B,CAAC,CAAC,CAAC;AAC3C,UAAU,CAAoB,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttrKeys, RelationKeys, IsIterator, CastIteratorType } from './entity-type';
|
|
2
2
|
import { ValueOf } from './entity-type';
|
|
3
3
|
export type DebugMetaProps = Partial<{
|
|
4
4
|
time: number;
|
|
@@ -24,7 +24,7 @@ export type BaseLinks = {
|
|
|
24
24
|
links: Links;
|
|
25
25
|
};
|
|
26
26
|
export type Attributes<Entity extends object, IdKey extends string = 'id'> = {
|
|
27
|
-
[P in Exclude<
|
|
27
|
+
[P in Exclude<AttrKeys<Entity>, IdKey>]?: Entity[P];
|
|
28
28
|
};
|
|
29
29
|
export type BaseAttribute<Entity extends object, IdKey extends string = 'id'> = {
|
|
30
30
|
attributes?: Attributes<Entity, IdKey>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klerick/json-api-nestjs-shared",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "Shared Helper for JsonApi Plugin for NestJs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"CRUD"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"change-case-commonjs": "^5.4.4"
|
|
16
|
-
"ts-toolbelt": "^9.6.0"
|
|
15
|
+
"change-case-commonjs": "^5.4.4"
|
|
17
16
|
},
|
|
18
17
|
"peerDependencies": {
|
|
19
18
|
"tslib": ">2.3.0"
|