pinejs-client-core 8.1.5 → 8.1.6-build-strict-mode-ef861ef2e796bdb61ba57eaa765a41316e59bbbf-1
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/.versionbot/CHANGELOG.yml +13 -1
- package/CHANGELOG.md +4 -0
- package/dist/index.d.ts +27 -0
- package/package.json +2 -2
- package/src/index.ts +63 -0
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
- commits:
|
|
2
|
+
- subject: WIP Add strict pinejs mode
|
|
3
|
+
hash: ef861ef2e796bdb61ba57eaa765a41316e59bbbf
|
|
4
|
+
body: ""
|
|
5
|
+
footer:
|
|
6
|
+
Change-type: patch
|
|
7
|
+
change-type: patch
|
|
8
|
+
author: Otavio Jacobi
|
|
9
|
+
nested: []
|
|
10
|
+
version: 8.1.6
|
|
11
|
+
title: ""
|
|
12
|
+
date: 2025-05-29T00:57:24.688Z
|
|
1
13
|
- commits:
|
|
2
14
|
- subject: Fix linting
|
|
3
15
|
hash: 29627add4a7c5701c9e4f032ea1f15a0523e2877
|
|
@@ -9,7 +21,7 @@
|
|
|
9
21
|
nested: []
|
|
10
22
|
version: 8.1.5
|
|
11
23
|
title: ""
|
|
12
|
-
date: 2025-05-
|
|
24
|
+
date: 2025-05-23T11:24:08.969Z
|
|
13
25
|
- commits:
|
|
14
26
|
- subject: Update dependency mocha to v11
|
|
15
27
|
hash: 85c2c2a779ba2cc94da6d35504e4f5ffb0263dcc
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## 8.1.6 - 2025-05-29
|
|
8
|
+
|
|
9
|
+
* WIP Add strict pinejs mode [Otavio Jacobi]
|
|
10
|
+
|
|
7
11
|
## 8.1.5 - 2025-05-23
|
|
8
12
|
|
|
9
13
|
* Fix linting [Otavio Jacobi]
|
package/dist/index.d.ts
CHANGED
|
@@ -352,3 +352,30 @@ export interface UpsertParams<T extends Resource = AnyResource> extends Omit<Par
|
|
|
352
352
|
resource: string;
|
|
353
353
|
body: Partial<T['Write']>;
|
|
354
354
|
}
|
|
355
|
+
export type StrictODataOptions<T extends Resource['Read'] = AnyResourceObject> = Omit<ODataOptions<T>, '$select' | '$expand'> & {
|
|
356
|
+
$expand?: StrictExpand<T>;
|
|
357
|
+
} & ({
|
|
358
|
+
$count: NonNullable<ODataOptions<T>['$count']>;
|
|
359
|
+
$select?: ODataOptions<T>['$select'];
|
|
360
|
+
} | {
|
|
361
|
+
$count?: undefined;
|
|
362
|
+
$select: NonNullable<ODataOptions<T>['$select']>;
|
|
363
|
+
});
|
|
364
|
+
type StrictResourceExpand<T extends Resource['Read']> = {
|
|
365
|
+
[K in StringKeyOf<T> as ExtractExpand<T, K> extends never ? never : K]?: ExtractExpand<T, K> extends Resource['Read'] ? StrictODataOptions<ExtractExpand<T, K>> : ODataOptions<ExtractExpand<T, K>>;
|
|
366
|
+
};
|
|
367
|
+
type StrictExpand<T extends Resource['Read']> = StrictResourceExpand<T> | ReadonlyArray<StrictResourceExpand<T>>;
|
|
368
|
+
type StrictParams<T extends Resource = AnyResource> = Omit<Params<T>, 'options'> & {
|
|
369
|
+
options: StrictODataOptions<T['Read']>;
|
|
370
|
+
};
|
|
371
|
+
export type StrictPinejsClientCore<Model extends {
|
|
372
|
+
[key in keyof Model]: Resource;
|
|
373
|
+
} = {
|
|
374
|
+
[key in string]: AnyResource;
|
|
375
|
+
}> = Omit<PinejsClientCore<Model>, 'get' | 'subscribe' | 'prepare'> & {
|
|
376
|
+
get<TResource extends StringKeyOf<Model>, TParams extends StrictParams<Model[TResource]> & {
|
|
377
|
+
resource: TResource;
|
|
378
|
+
}>(params: {
|
|
379
|
+
resource: TResource;
|
|
380
|
+
} & TParams): Promise<NoInfer<OptionsToResponse<Model[TResource]['Read'], NonNullable<StrictParams['options']>, TParams['id']>>>;
|
|
381
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinejs-client-core",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.6-build-strict-mode-ef861ef2e796bdb61ba57eaa765a41316e59bbbf-1",
|
|
4
4
|
"description": "This module provides the core tools to enable easier interaction with the pinejs API.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"browser": "dist",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"_": "test/*.ts"
|
|
53
53
|
},
|
|
54
54
|
"versionist": {
|
|
55
|
-
"publishedAt": "2025-05-
|
|
55
|
+
"publishedAt": "2025-05-29T00:57:24.867Z"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/index.ts
CHANGED
|
@@ -2039,6 +2039,7 @@ export type ResourceExpand<T extends Resource['Read'] = AnyResourceObject> = {
|
|
|
2039
2039
|
export type BaseExpand<T extends Resource['Read'] = AnyResourceObject> =
|
|
2040
2040
|
| ExpandableStringKeyOf<T>
|
|
2041
2041
|
| ResourceExpand<T>;
|
|
2042
|
+
|
|
2042
2043
|
export type Expand<T extends Resource['Read'] = AnyResourceObject> =
|
|
2043
2044
|
| BaseExpand<T>
|
|
2044
2045
|
| ReadonlyArray<BaseExpand<T>>;
|
|
@@ -2163,3 +2164,65 @@ export interface UpsertParams<T extends Resource = AnyResource>
|
|
|
2163
2164
|
resource: string;
|
|
2164
2165
|
body: Partial<T['Write']>;
|
|
2165
2166
|
}
|
|
2167
|
+
|
|
2168
|
+
export type StrictODataOptions<T extends Resource['Read'] = AnyResourceObject> =
|
|
2169
|
+
Omit<ODataOptions<T>, '$select' | '$expand'> & {
|
|
2170
|
+
$expand?: StrictExpand<T>;
|
|
2171
|
+
} & (
|
|
2172
|
+
| {
|
|
2173
|
+
$count: NonNullable<ODataOptions<T>['$count']>;
|
|
2174
|
+
// TODO: Maybe never is the better type here?
|
|
2175
|
+
// TODO: Ask Page if it makes any sense to have $count & $select together
|
|
2176
|
+
$select?: ODataOptions<T>['$select'];
|
|
2177
|
+
}
|
|
2178
|
+
| {
|
|
2179
|
+
// TODO: Maybe never is the better type here?
|
|
2180
|
+
$count?: undefined;
|
|
2181
|
+
$select: NonNullable<ODataOptions<T>['$select']>;
|
|
2182
|
+
}
|
|
2183
|
+
);
|
|
2184
|
+
|
|
2185
|
+
type StrictResourceExpand<T extends Resource['Read']> = {
|
|
2186
|
+
[K in StringKeyOf<T> as ExtractExpand<T, K> extends never
|
|
2187
|
+
? never
|
|
2188
|
+
: K]?: ExtractExpand<T, K> extends Resource['Read']
|
|
2189
|
+
? StrictODataOptions<ExtractExpand<T, K>>
|
|
2190
|
+
: ODataOptions<ExtractExpand<T, K>>;
|
|
2191
|
+
};
|
|
2192
|
+
|
|
2193
|
+
// StrictExpand does not allow to $expand with a string or list of string (resources)
|
|
2194
|
+
// instead, it enforces a resource expand with $select
|
|
2195
|
+
type StrictExpand<T extends Resource['Read']> =
|
|
2196
|
+
| StrictResourceExpand<T>
|
|
2197
|
+
| ReadonlyArray<StrictResourceExpand<T>>;
|
|
2198
|
+
|
|
2199
|
+
type StrictParams<T extends Resource = AnyResource> = Omit<
|
|
2200
|
+
Params<T>,
|
|
2201
|
+
'options'
|
|
2202
|
+
> & {
|
|
2203
|
+
options: StrictODataOptions<T['Read']>;
|
|
2204
|
+
};
|
|
2205
|
+
|
|
2206
|
+
// Forces a $select to exist for get, subscribe and prepare
|
|
2207
|
+
export type StrictPinejsClientCore<
|
|
2208
|
+
Model extends { [key in keyof Model]: Resource } = {
|
|
2209
|
+
[key in string]: AnyResource;
|
|
2210
|
+
},
|
|
2211
|
+
> = Omit<PinejsClientCore<Model>, 'get' | 'subscribe' | 'prepare'> & {
|
|
2212
|
+
get<
|
|
2213
|
+
TResource extends StringKeyOf<Model>,
|
|
2214
|
+
TParams extends StrictParams<Model[TResource]> & {
|
|
2215
|
+
resource: TResource;
|
|
2216
|
+
},
|
|
2217
|
+
>(
|
|
2218
|
+
params: { resource: TResource } & TParams,
|
|
2219
|
+
): Promise<
|
|
2220
|
+
NoInfer<
|
|
2221
|
+
OptionsToResponse<
|
|
2222
|
+
Model[TResource]['Read'],
|
|
2223
|
+
NonNullable<StrictParams['options']>,
|
|
2224
|
+
TParams['id']
|
|
2225
|
+
>
|
|
2226
|
+
>
|
|
2227
|
+
>;
|
|
2228
|
+
};
|