Skip to content

Commit

Permalink
Re-prettify the sources
Browse files Browse the repository at this point in the history
  • Loading branch information
thgreasi committed Nov 29, 2023
1 parent b03a34f commit 91aac0a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export function mergePineOptions<R extends object>(
...(typeof result.$select === 'string'
? [result.$select as Pine.SelectableProps<R>]
: Array.isArray(result.$select)
? result.$select
: []),
? result.$select
: []),
...(extraSelect ?? []),
];
}
Expand Down
16 changes: 8 additions & 8 deletions src/util/request-batching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export function batchResourceOperationFactory<
)
? [uuidOrIdOrArray]
: typeof uuidOrIdOrArray[0] === 'string'
? chunk(uuidOrIdOrArray as string[], UUID_CHUNK_SIZE)
: chunk(uuidOrIdOrArray as number[], ID_CHUNK_SIZE);
? chunk(uuidOrIdOrArray as string[], UUID_CHUNK_SIZE)
: chunk(uuidOrIdOrArray as number[], ID_CHUNK_SIZE);

const items: Array<
Item<TOpts> &
Expand All @@ -118,12 +118,12 @@ export function batchResourceOperationFactory<
id: { $in: uuidOrIdOrArrayChunk as number[] },
}
: typeof uuidOrIdOrArrayChunk === 'string'
? {
uuid: { $startswith: uuidOrIdOrArrayChunk },
}
: {
id: uuidOrIdOrArrayChunk,
};
? {
uuid: { $startswith: uuidOrIdOrArrayChunk },
}
: {
id: uuidOrIdOrArrayChunk,
};
const combinedOptions = mergePineOptions(
{
$select: [
Expand Down
50 changes: 25 additions & 25 deletions typings/pinejs-client-core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ type SelectedProperty<
> = T[K] extends NavigationResource<any>
? PineDeferred
: T[K] extends OptionalNavigationResource<any>
? PineDeferred | null
: T[K] extends ConceptTypeNavigationResource<any>
? Exclude<T[K], any[]>
: T[K];
? PineDeferred | null
: T[K] extends ConceptTypeNavigationResource<any>
? Exclude<T[K], any[]>
: T[K];

type SelectResultObject<T, Props extends keyof T> = {
[P in Props]: SelectedProperty<T, P>;
Expand All @@ -80,12 +80,12 @@ export type TypedSelectResult<
> = TParams['$select'] extends keyof T
? SelectResultObject<T, TParams['$select']>
: TParams['$select'] extends Array<keyof T>
? SelectResultObject<T, TParams['$select'][number]>
: TParams['$select'] extends '*'
? SelectResultObject<T, SelectableProps<T>>
: undefined extends TParams['$select']
? SelectResultObject<T, SelectableProps<T>>
: never;
? SelectResultObject<T, TParams['$select'][number]>
: TParams['$select'] extends '*'
? SelectResultObject<T, SelectableProps<T>>
: undefined extends TParams['$select']
? SelectResultObject<T, SelectableProps<T>>
: never;

type ExpandedProperty<
T,
Expand All @@ -94,12 +94,12 @@ type ExpandedProperty<
> = KOpts extends ODataOptionsWithCount<any>
? number
: T[K] extends NavigationResource<any> | ConceptTypeNavigationResource<any>
? [TypedResult<InferAssociatedResourceType<T[K]>, KOpts>]
: T[K] extends OptionalNavigationResource<any>
? [TypedResult<InferAssociatedResourceType<T[K]>, KOpts>] | []
: T[K] extends ReverseNavigationResource<any>
? Array<TypedResult<InferAssociatedResourceType<T[K]>, KOpts>>
: never;
? [TypedResult<InferAssociatedResourceType<T[K]>, KOpts>]
: T[K] extends OptionalNavigationResource<any>
? [TypedResult<InferAssociatedResourceType<T[K]>, KOpts>] | []
: T[K] extends ReverseNavigationResource<any>
? Array<TypedResult<InferAssociatedResourceType<T[K]>, KOpts>>
: never;

export type ExpandResultObject<T, Props extends keyof T> = {
[P in Props]: ExpandedProperty<T, P, object>;
Expand All @@ -122,22 +122,22 @@ export type TypedExpandResult<
> = TParams['$expand'] extends ExpandableProps<T>
? ExpandResultObject<T, TParams['$expand']>
: TParams['$expand'] extends ResourceExpand<T>
? keyof TParams['$expand'] extends ExpandableProps<T>
? ExpandResourceExpandObject<T, TParams['$expand']>
: never
: object;
? keyof TParams['$expand'] extends ExpandableProps<T>
? ExpandResourceExpandObject<T, TParams['$expand']>
: never
: object;

export type TypedResult<
T,
TParams extends ODataOptions<T> | undefined,
> = TParams extends ODataOptionsWithCount<T>
? number
: TParams extends ODataOptions<T>
? Omit<TypedSelectResult<T, TParams>, keyof TypedExpandResult<T, TParams>> &
TypedExpandResult<T, TParams>
: undefined extends TParams
? TypedSelectResult<T, { $select: '*' }>
: never;
? Omit<TypedSelectResult<T, TParams>, keyof TypedExpandResult<T, TParams>> &
TypedExpandResult<T, TParams>
: undefined extends TParams
? TypedSelectResult<T, { $select: '*' }>
: never;

export type PostResult<T> = SelectResultObject<
T,
Expand Down

0 comments on commit 91aac0a

Please sign in to comment.