@superbia/untrue 2.0.0 → 2.0.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/dist/Api.d.ts CHANGED
@@ -4,10 +4,10 @@ import { DocumentContext, Documents } from "./DocumentContext";
4
4
  import { RequestContext, Request } from "./RequestContext";
5
5
  export default class Api<K extends DocumentSchemaRecord, M extends EndpointRecord, N extends EndpointRecord = {}, O extends string = "id"> {
6
6
  readonly client: Client<M, N>;
7
- readonly documents: DocumentContext<K, M>;
7
+ readonly documents: DocumentContext<K, M, O>;
8
8
  readonly requests: RequestContext<M, O>;
9
9
  constructor(client: Client<M, N>, idKey?: string);
10
- useDocuments<W>(selector: (documents: Documents<K>) => W): W;
10
+ useDocuments<W>(selector: (documents: Documents<K, O>) => W): W;
11
11
  useRequest<Y extends ResponseResult, W, X extends any[] = any[]>(key: string, selector: (request: Request<Y, O>) => W, requester?: (...args: X) => Promise<Response<Y>>): [W, (...args: X) => Promise<void>];
12
12
  useLoad<Y extends ResponseResult, W, X extends any[]>(key: string, selector: (request: Request<Y, O>) => W, loader: (...args: X) => Promise<Response<Y>>): [W, (...args: X) => Promise<void>];
13
13
  useRequestKey(params?: any[]): string;
@@ -1,13 +1,13 @@
1
1
  import { Client, Result, EndpointRecord } from "@superbia/client";
2
2
  import { ParsedResult, SuperbiaContext, DocumentSchema, DocumentSchemaRecord } from "./SuperbiaContext";
3
- export type Document<T extends DocumentSchema> = {
4
- [K in keyof T]: ParsedResult<T[K]>;
3
+ export type Document<T extends DocumentSchema, O extends string = "id"> = {
4
+ [K in keyof T]: ParsedResult<T[K], O>;
5
5
  };
6
- export type Documents<T extends DocumentSchemaRecord> = {
7
- [K in keyof T]: Record<string, Result<Document<T[K]>>>;
6
+ export type Documents<T extends DocumentSchemaRecord, O extends string> = {
7
+ [K in keyof T]: Record<string, Result<Document<T[K], O>>>;
8
8
  };
9
- export declare class DocumentContext<K extends DocumentSchemaRecord, M extends EndpointRecord> extends SuperbiaContext<M> {
10
- data: Documents<K>;
9
+ export declare class DocumentContext<K extends DocumentSchemaRecord, M extends EndpointRecord, O extends string> extends SuperbiaContext<M> {
10
+ data: Documents<K, O>;
11
11
  constructor(client: Client<M, any>, idKey: string);
12
12
  hydrate(data: any): void;
13
13
  persist(): any;
@@ -1,11 +1,11 @@
1
1
  import { Context } from "untrue";
2
2
  import { Client, EndpointRecord } from "@superbia/client";
3
- type IdObject<U extends string> = {
4
- [K in U]: string;
3
+ type IdObject<O extends string> = {
4
+ [K in O]: string;
5
+ };
6
+ export type ParsedResult<T, O extends string = "id"> = T extends string | number | boolean | null ? T : T extends IdObject<O> ? string : {
7
+ [K in keyof T]: ParsedResult<T[K], O>;
5
8
  };
6
- export type ParsedResult<T, U extends string = "id"> = T extends IdObject<U> ? string : T extends IdObject<U> | null ? string | null : T extends IdObject<U>[] ? string[] : T extends (IdObject<U> | null)[] ? (string | null)[] : T extends null ? null : T extends object ? {
7
- [K in keyof T]: ParsedResult<T[K], U>;
8
- } : T;
9
9
  export type DocumentSchema = Record<string, any>;
10
10
  export type DocumentSchemaRecord = Record<string, DocumentSchema>;
11
11
  export type DocumentData = Record<string, Record<string, DocumentSchema>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superbia/untrue",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Integrate Superbia and Untrue.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,8 +18,8 @@
18
18
  ],
19
19
  "license": "MIT",
20
20
  "peerDependencies": {
21
- "untrue": "^5.8.0",
22
- "@superbia/client": "^2.0.8"
21
+ "@superbia/client": "^2.0.10",
22
+ "untrue": "^5.8.0"
23
23
  },
24
24
  "dependencies": {
25
25
  "uuid": "^10.0.0"