joist-graphql-resolver-utils 2.4.0-next.5 → 2.4.0-next.50

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.
Files changed (53) hide show
  1. package/build/context.d.cts +2 -3
  2. package/build/context.d.cts.map +1 -1
  3. package/build/context.d.mts +2 -3
  4. package/build/context.d.mts.map +1 -1
  5. package/build/cursorPagination.cjs.map +1 -1
  6. package/build/cursorPagination.d.cts +4 -4
  7. package/build/cursorPagination.d.cts.map +1 -1
  8. package/build/cursorPagination.d.mts +4 -4
  9. package/build/cursorPagination.d.mts.map +1 -1
  10. package/build/cursorPagination.js.map +1 -1
  11. package/build/entityResolver.d.cts +3 -3
  12. package/build/entityResolver.d.cts.map +1 -1
  13. package/build/entityResolver.d.mts +3 -3
  14. package/build/entityResolver.d.mts.map +1 -1
  15. package/build/hint.d.cts +3 -4
  16. package/build/hint.d.cts.map +1 -1
  17. package/build/hint.d.mts +3 -4
  18. package/build/hint.d.mts.map +1 -1
  19. package/build/limitPagination.cjs.map +1 -1
  20. package/build/limitPagination.d.cts +4 -4
  21. package/build/limitPagination.d.cts.map +1 -1
  22. package/build/limitPagination.d.mts +4 -4
  23. package/build/limitPagination.d.mts.map +1 -1
  24. package/build/limitPagination.js.map +1 -1
  25. package/build/makeRunInputMutation.d.cts +3 -3
  26. package/build/makeRunInputMutation.d.cts.map +1 -1
  27. package/build/makeRunInputMutation.d.mts +3 -3
  28. package/build/makeRunInputMutation.d.mts.map +1 -1
  29. package/build/makeRunObjectField.d.cts +3 -3
  30. package/build/makeRunObjectField.d.cts.map +1 -1
  31. package/build/makeRunObjectField.d.mts +3 -3
  32. package/build/makeRunObjectField.d.mts.map +1 -1
  33. package/build/makeRunObjectFields.d.cts +3 -3
  34. package/build/makeRunObjectFields.d.cts.map +1 -1
  35. package/build/makeRunObjectFields.d.mts +3 -3
  36. package/build/makeRunObjectFields.d.mts.map +1 -1
  37. package/build/makeRunQuery.d.cts +3 -3
  38. package/build/makeRunQuery.d.cts.map +1 -1
  39. package/build/makeRunQuery.d.mts +3 -3
  40. package/build/makeRunQuery.d.mts.map +1 -1
  41. package/build/paginationUtils.d.cts +6 -7
  42. package/build/paginationUtils.d.cts.map +1 -1
  43. package/build/paginationUtils.d.mts +6 -7
  44. package/build/paginationUtils.d.mts.map +1 -1
  45. package/build/saveEntity.d.cts +2 -3
  46. package/build/saveEntity.d.cts.map +1 -1
  47. package/build/saveEntity.d.mts +2 -3
  48. package/build/saveEntity.d.mts.map +1 -1
  49. package/build/typeUtils.d.cts +4 -5
  50. package/build/typeUtils.d.cts.map +1 -1
  51. package/build/typeUtils.d.mts +4 -5
  52. package/build/typeUtils.d.mts.map +1 -1
  53. package/package.json +5 -5
@@ -1,7 +1,6 @@
1
1
  import { GraphQLResolveInfo } from "graphql/type";
2
2
  //#region src/context.d.ts
3
- type MaybePromise<T> = T | Promise<T>;
4
- type Resolver<R, A, T> = (root: R, args: A, ctx: any, info: GraphQLResolveInfo) => MaybePromise<T>;
3
+ export type MaybePromise<T> = T | Promise<T>;
4
+ export type Resolver<R, A, T> = (root: R, args: A, ctx: any, info: GraphQLResolveInfo) => MaybePromise<T>;
5
5
  //#endregion
6
- export { MaybePromise, Resolver };
7
6
  //# sourceMappingURL=context.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"mappings":";;KAEY,aAAa,KAAK,IAAI,QAAQ;KAG9B,SAAS,GAAG,GAAG,MAAM,MAAM,GAAG,MAAM,GAAG,UAAU,MAAM,uBAAuB,aAAa"}
1
+ {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"mappings":";;YAEY,aAAa,KAAK,IAAI,QAAQ;YAG9B,SAAS,GAAG,GAAG,MAAM,MAAM,GAAG,MAAM,GAAG,UAAU,MAAM,uBAAuB,aAAa"}
@@ -1,7 +1,6 @@
1
1
  import { GraphQLResolveInfo } from "graphql/type";
2
2
  //#region src/context.d.ts
3
- type MaybePromise<T> = T | Promise<T>;
4
- type Resolver<R, A, T> = (root: R, args: A, ctx: any, info: GraphQLResolveInfo) => MaybePromise<T>;
3
+ export type MaybePromise<T> = T | Promise<T>;
4
+ export type Resolver<R, A, T> = (root: R, args: A, ctx: any, info: GraphQLResolveInfo) => MaybePromise<T>;
5
5
  //#endregion
6
- export { MaybePromise, Resolver };
7
6
  //# sourceMappingURL=context.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.mts","names":[],"sources":["../src/context.ts"],"mappings":";;KAEY,aAAa,KAAK,IAAI,QAAQ;KAG9B,SAAS,GAAG,GAAG,MAAM,MAAM,GAAG,MAAM,GAAG,UAAU,MAAM,uBAAuB,aAAa"}
1
+ {"version":3,"file":"context.d.mts","names":[],"sources":["../src/context.ts"],"mappings":";;YAEY,aAAa,KAAK,IAAI,QAAQ;YAG9B,SAAS,GAAG,GAAG,MAAM,MAAM,GAAG,MAAM,GAAG,UAAU,MAAM,uBAAuB,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"cursorPagination.cjs","names":["queryEntities","#ctx","#type","#filter","#edges","#hasNextPagePromise","#countPastCursor","#hasPreviousPagePromise","#totalCountPromise","countQuery"],"sources":["../src/cursorPagination.ts"],"sourcesContent":["import {\n type Entity,\n type FindGqlFilterOptions,\n type IdOf,\n type MaybeAbstractEntityConstructor,\n type QueryCondition,\n type ValueGraphQLFilter,\n} from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype CursorArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n first?: number | null;\n after?: string | null;\n last?: number | null;\n before?: string | null;\n};\n\n/** Returns an ID-ordered cursor connection for a resolver, replacing the entity query's ordering. */\nexport function paginateCursor<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<CursorArgs<T>, \"filter\">,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport async function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }> {\n const limit = args.first ?? args.last ?? defaultLimit;\n const baseFilter = (args.filter ?? {}) as PaginationFilter<T>;\n const filter = withCursorFilter(baseFilter, args);\n const orderBy = { id: args.last ? \"DESC\" : \"ASC\" } as FindGqlFilterOptions<T>[\"orderBy\"];\n const nodes =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, orderBy })\n : await queryEntities(ctx, {\n ...withCursorQuery(type, args),\n orderBy: [args.last ? { sort: type.select.id, order: \"DESC\" } : { sort: type.select.id, order: \"ASC\" }],\n limit,\n offset: undefined,\n });\n const orderedNodes = args.last ? [...nodes].reverse() : nodes;\n const edges = orderedNodes.map((node) => ({ node, cursor: encodeCursor(String(node.id)) }));\n return {\n edges,\n nodes: orderedNodes,\n pageInfo: new CursorPageInfo(\n ctx,\n typeof type === \"function\" ? type : { ...type, orderBy: undefined },\n baseFilter,\n edges,\n ),\n };\n}\n\n/** Lazily computes cursor page fields. */\nexport class CursorPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #edges: { node: T; cursor: string }[];\n #filter: PaginationFilter<T>;\n #hasNextPagePromise: Promise<boolean> | undefined;\n #hasPreviousPagePromise: Promise<boolean> | undefined;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n edges: { node: T; cursor: string }[],\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#edges = edges;\n }\n\n get startCursor(): string | undefined {\n return this.#edges[0]?.cursor;\n }\n\n get endCursor(): string | undefined {\n return this.#edges[this.#edges.length - 1]?.cursor;\n }\n\n get hasNextPage(): Promise<boolean> {\n return (this.#hasNextPagePromise ??= this.#countPastCursor(\"after\", this.endCursor));\n }\n\n get hasPreviousPage(): Promise<boolean> {\n return (this.#hasPreviousPagePromise ??= this.#countPastCursor(\"before\", this.startCursor));\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n /** Counts rows past a cursor only when the field is requested. */\n async #countPastCursor(direction: \"after\" | \"before\", cursor: string | undefined): Promise<boolean> {\n if (!cursor) return false;\n if (typeof this.#type !== \"function\") {\n return (await countQuery(this.#ctx, withCursorQuery(this.#type, { [direction]: cursor }))) > 0;\n }\n const filter = withCursorFilter(this.#filter, { [direction]: cursor });\n return (await this.#ctx.em.findCount(this.#type, filter)) > 0;\n }\n}\n\n/** Adds both cursor bounds without replacing the query's existing conditions. */\nfunction withCursorQuery<T extends Entity>(\n base: PaginationQuery<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationQuery<T> {\n return {\n ...base,\n where: {\n and: [\n ...(Array.isArray(base.where) ? base.where : [base.where as QueryCondition | undefined]),\n args.after ? base.select.id.gt(decodeCursor(args.after) as IdOf<T>) : undefined,\n args.before ? base.select.id.lt(decodeCursor(args.before) as IdOf<T>) : undefined,\n ],\n },\n };\n}\n\n/** Adds cursor bounds to a filter. */\nfunction withCursorFilter<T extends Entity>(\n filter: PaginationFilter<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationFilter<T> {\n const cursor = args.after ?? args.before;\n if (!cursor) return filter;\n const op = args.after ? \"gt\" : \"lt\";\n return { ...filter, id: { [op]: decodeCursor(cursor) } as ValueGraphQLFilter<string> } as PaginationFilter<T>;\n}\n\n/** Encodes an entity id as an opaque cursor. */\nfunction encodeCursor(id: string): string {\n return Buffer.from(id).toString(\"base64\");\n}\n\n/** Decodes an opaque cursor back into an entity id. */\nfunction decodeCursor(cursor: string): string {\n return Buffer.from(cursor, \"base64\").toString(\"utf8\");\n}\n"],"mappings":";;;;AAqCA,eAAsB,eACpB,KACA,MACA,MAC4F;CAC5F,MAAM,QAAQ,KAAK,SAAS,KAAK,QAAA;CACjC,MAAM,aAAc,KAAK,UAAU,CAAC;CACpC,MAAM,SAAS,iBAAiB,YAAY,IAAI;CAChD,MAAM,UAAU,EAAE,IAAI,KAAK,OAAO,SAAS,MAAM;CACjD,MAAM,QACJ,OAAO,SAAS,aACZ,MAAM,IAAI,GAAG,QAAQ,MAAM,QAAQ;EAAE;EAAO;CAAQ,CAAC,IACrD,MAAMA,wBAAAA,cAAc,KAAK;EACvB,GAAG,gBAAgB,MAAM,IAAI;EAC7B,SAAS,CAAC,KAAK,OAAO;GAAE,MAAM,KAAK,OAAO;GAAI,OAAO;EAAO,IAAI;GAAE,MAAM,KAAK,OAAO;GAAI,OAAO;EAAM,CAAC;EACtG;EACA,QAAQ,KAAA;CACV,CAAC;CACP,MAAM,eAAe,KAAK,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ,IAAI;CACxD,MAAM,QAAQ,aAAa,KAAK,UAAU;EAAE;EAAM,QAAQ,aAAa,OAAO,KAAK,EAAE,CAAC;CAAE,EAAE;CAC1F,OAAO;EACL;EACA,OAAO;EACP,UAAU,IAAI,eACZ,KACA,OAAO,SAAS,aAAa,OAAO;GAAE,GAAG;GAAM,SAAS,KAAA;EAAU,GAClE,YACA,KACF;CACF;AACF;;AAGA,IAAa,iBAAb,MAAuD;CACrD;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAC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a,KAAK,MAAM,CAAY,IAAI,KAAA;EAC1E,EACF;CACF;AACF;;AAGA,SAAS,iBACP,QACA,MACqB;CACrB,MAAM,SAAS,KAAK,SAAS,KAAK;CAClC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,KAAK,KAAK,QAAQ,OAAO;CAC/B,OAAO;EAAE,GAAG;EAAQ,IAAI,GAAG,KAAK,aAAa,MAAM,EAAE;CAAgC;AACvF;;AAGA,SAAS,aAAa,IAAoB;CACxC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,SAAS,QAAQ;AAC1C;;AAGA,SAAS,aAAa,QAAwB;CAC5C,OAAO,OAAO,KAAK,QAAQ,QAAQ,CAAC,CAAC,SAAS,MAAM;AACtD"}
1
+ {"version":3,"file":"cursorPagination.cjs","names":["queryEntities","countQuery"],"sources":["../src/cursorPagination.ts"],"sourcesContent":["import {\n type Entity,\n type FindGqlFilterOptions,\n type IdOf,\n type MaybeAbstractEntityConstructor,\n type QueryCondition,\n type ValueGraphQLFilter,\n} from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype CursorArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n first?: number | null;\n after?: string | null;\n last?: number | null;\n before?: string | null;\n};\n\n/** Returns an ID-ordered cursor connection for a resolver, replacing the entity query's ordering. */\nexport function paginateCursor<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<CursorArgs<T>, \"filter\">,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport async function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }> {\n const limit = args.first ?? args.last ?? defaultLimit;\n const baseFilter = (args.filter ?? {}) as PaginationFilter<T>;\n const filter = withCursorFilter(baseFilter, args);\n const orderBy = { id: args.last ? \"DESC\" : \"ASC\" } as FindGqlFilterOptions<T>[\"orderBy\"];\n const nodes =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, orderBy })\n : await queryEntities(ctx, {\n ...withCursorQuery(type, args),\n orderBy: [args.last ? { sort: type.select.id, order: \"DESC\" } : { sort: type.select.id, order: \"ASC\" }],\n limit,\n offset: undefined,\n });\n const orderedNodes = args.last ? [...nodes].reverse() : nodes;\n const edges = orderedNodes.map((node) => ({ node, cursor: encodeCursor(String(node.id)) }));\n return {\n edges,\n nodes: orderedNodes,\n pageInfo: new CursorPageInfo(\n ctx,\n typeof type === \"function\" ? type : { ...type, orderBy: undefined },\n baseFilter,\n edges,\n ),\n };\n}\n\n/** Lazily computes cursor page fields. */\nexport class CursorPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #edges: { node: T; cursor: string }[];\n #filter: PaginationFilter<T>;\n #hasNextPagePromise: Promise<boolean> | undefined;\n #hasPreviousPagePromise: Promise<boolean> | undefined;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n edges: { node: T; cursor: string }[],\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#edges = edges;\n }\n\n get startCursor(): string | undefined {\n return this.#edges[0]?.cursor;\n }\n\n get endCursor(): string | undefined {\n return this.#edges[this.#edges.length - 1]?.cursor;\n }\n\n get hasNextPage(): Promise<boolean> {\n return (this.#hasNextPagePromise ??= this.#countPastCursor(\"after\", this.endCursor));\n }\n\n get hasPreviousPage(): Promise<boolean> {\n return (this.#hasPreviousPagePromise ??= this.#countPastCursor(\"before\", this.startCursor));\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n /** Counts rows past a cursor only when the field is requested. */\n async #countPastCursor(direction: \"after\" | \"before\", cursor: string | undefined): Promise<boolean> {\n if (!cursor) return false;\n if (typeof this.#type !== \"function\") {\n return (await countQuery(this.#ctx, withCursorQuery(this.#type, { [direction]: cursor }))) > 0;\n }\n const filter = withCursorFilter(this.#filter, { [direction]: cursor });\n return (await this.#ctx.em.findCount(this.#type, filter)) > 0;\n }\n}\n\n/** Adds both cursor bounds without replacing the query's existing conditions. */\nfunction withCursorQuery<T extends Entity>(\n base: PaginationQuery<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationQuery<T> {\n return {\n ...base,\n where: {\n and: [\n ...(Array.isArray(base.where) ? base.where : [base.where as QueryCondition | undefined]),\n args.after ? base.select.id.gt(decodeCursor(args.after) as IdOf<T>) : undefined,\n args.before ? base.select.id.lt(decodeCursor(args.before) as IdOf<T>) : undefined,\n ],\n },\n };\n}\n\n/** Adds cursor bounds to a filter. */\nfunction withCursorFilter<T extends Entity>(\n filter: PaginationFilter<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationFilter<T> {\n const cursor = args.after ?? args.before;\n if (!cursor) return filter;\n const op = args.after ? \"gt\" : \"lt\";\n return { ...filter, id: { [op]: decodeCursor(cursor) } as ValueGraphQLFilter<string> } as PaginationFilter<T>;\n}\n\n/** Encodes an entity id as an opaque cursor. */\nfunction encodeCursor(id: string): string {\n return Buffer.from(id).toString(\"base64\");\n}\n\n/** Decodes an opaque cursor back into an entity id. */\nfunction decode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;AAGA,SAAS,aAAa,IAAoB;CACxC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,SAAS,QAAQ;AAC1C;;AAGA,SAAS,aAAa,QAAwB;CAC5C,OAAO,OAAO,KAAK,QAAQ,QAAQ,CAAC,CAAC,SAAS,MAAM;AACtD"}
@@ -9,7 +9,7 @@ type CursorArgs<T extends Entity, F extends object = PaginationFilter<T>> = {
9
9
  before?: string | null;
10
10
  };
11
11
  /** Returns an ID-ordered cursor connection for a resolver, replacing the entity query's ordering. */
12
- declare function paginateCursor<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<CursorArgs<T>, "filter">): Promise<{
12
+ export declare function paginateCursor<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<CursorArgs<T>, "filter">): Promise<{
13
13
  edges: {
14
14
  node: T;
15
15
  cursor: string;
@@ -17,7 +17,7 @@ declare function paginateCursor<T extends Entity>(ctx: ContextWithEm, query: Pag
17
17
  nodes: T[];
18
18
  pageInfo: CursorPageInfo<T>;
19
19
  }>;
20
- declare function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: CursorArgs<T, F>): Promise<{
20
+ export declare function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: CursorArgs<T, F>): Promise<{
21
21
  edges: {
22
22
  node: T;
23
23
  cursor: string;
@@ -26,7 +26,7 @@ declare function paginateCursor<T extends Entity, F extends object = PaginationF
26
26
  pageInfo: CursorPageInfo<T>;
27
27
  }>;
28
28
  /** Lazily computes cursor page fields. */
29
- declare class CursorPageInfo<T extends Entity = Entity> {
29
+ export declare class CursorPageInfo<T extends Entity = Entity> {
30
30
  #private;
31
31
  constructor(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>, filter: PaginationFilter<T>, edges: {
32
32
  node: T;
@@ -39,5 +39,5 @@ declare class CursorPageInfo<T extends Entity = Entity> {
39
39
  get totalCount(): Promise<number>;
40
40
  }
41
41
  //#endregion
42
- export { CursorPageInfo, paginateCursor };
42
+ export {};
43
43
  //# sourceMappingURL=cursorPagination.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cursorPagination.d.cts","names":[],"sources":["../src/cursorPagination.ts"],"mappings":";;;KAkBK,WAAW,UAAU,QAAQ,mBAAmB,iBAAiB;EACpE,SAAS;EACT;EACA;EACA;EACA;;;iBAIc,eAAe,UAAU,QACvC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,WAAW,gBACrB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;iBACxE,eAAe,UAAU,QAAQ,mBAAmB,iBAAiB,IACnF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,WAAW,GAAG,KACnB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;;cAkC3E,eAAe,UAAU,SAAS;;EAS7C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB;IAAS,MAAM;IAAG;;MAQhB;MAIA;MAIA,eAAe;MAIf,mBAAmB;MAInB,cAAc"}
1
+ {"version":3,"file":"cursorPagination.d.cts","names":[],"sources":["../src/cursorPagination.ts"],"mappings":";;;KAkBK,WAAW,UAAU,QAAQ,mBAAmB,iBAAiB;EACpE,SAAS;EACT;EACA;EACA;EACA;;;wBAIc,eAAe,UAAU,QACvC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,WAAW,gBACrB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;wBACxE,eAAe,UAAU,QAAQ,mBAAmB,iBAAiB,IACnF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,WAAW,GAAG,KACnB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;;qBAkC3E,eAAe,UAAU,SAAS;;EAS7C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB;IAAS,MAAM;IAAG;;MAQhB;MAIA;MAIA,eAAe;MAIf,mBAAmB;MAInB,cAAc"}
@@ -9,7 +9,7 @@ type CursorArgs<T extends Entity, F extends object = PaginationFilter<T>> = {
9
9
  before?: string | null;
10
10
  };
11
11
  /** Returns an ID-ordered cursor connection for a resolver, replacing the entity query's ordering. */
12
- declare function paginateCursor<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<CursorArgs<T>, "filter">): Promise<{
12
+ export declare function paginateCursor<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<CursorArgs<T>, "filter">): Promise<{
13
13
  edges: {
14
14
  node: T;
15
15
  cursor: string;
@@ -17,7 +17,7 @@ declare function paginateCursor<T extends Entity>(ctx: ContextWithEm, query: Pag
17
17
  nodes: T[];
18
18
  pageInfo: CursorPageInfo<T>;
19
19
  }>;
20
- declare function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: CursorArgs<T, F>): Promise<{
20
+ export declare function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: CursorArgs<T, F>): Promise<{
21
21
  edges: {
22
22
  node: T;
23
23
  cursor: string;
@@ -26,7 +26,7 @@ declare function paginateCursor<T extends Entity, F extends object = PaginationF
26
26
  pageInfo: CursorPageInfo<T>;
27
27
  }>;
28
28
  /** Lazily computes cursor page fields. */
29
- declare class CursorPageInfo<T extends Entity = Entity> {
29
+ export declare class CursorPageInfo<T extends Entity = Entity> {
30
30
  #private;
31
31
  constructor(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>, filter: PaginationFilter<T>, edges: {
32
32
  node: T;
@@ -39,5 +39,5 @@ declare class CursorPageInfo<T extends Entity = Entity> {
39
39
  get totalCount(): Promise<number>;
40
40
  }
41
41
  //#endregion
42
- export { CursorPageInfo, paginateCursor };
42
+ export {};
43
43
  //# sourceMappingURL=cursorPagination.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cursorPagination.d.mts","names":[],"sources":["../src/cursorPagination.ts"],"mappings":";;;KAkBK,WAAW,UAAU,QAAQ,mBAAmB,iBAAiB;EACpE,SAAS;EACT;EACA;EACA;EACA;;;iBAIc,eAAe,UAAU,QACvC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,WAAW,gBACrB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;iBACxE,eAAe,UAAU,QAAQ,mBAAmB,iBAAiB,IACnF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,WAAW,GAAG,KACnB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;;cAkC3E,eAAe,UAAU,SAAS;;EAS7C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB;IAAS,MAAM;IAAG;;MAQhB;MAIA;MAIA,eAAe;MAIf,mBAAmB;MAInB,cAAc"}
1
+ {"version":3,"file":"cursorPagination.d.mts","names":[],"sources":["../src/cursorPagination.ts"],"mappings":";;;KAkBK,WAAW,UAAU,QAAQ,mBAAmB,iBAAiB;EACpE,SAAS;EACT;EACA;EACA;EACA;;;wBAIc,eAAe,UAAU,QACvC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,WAAW,gBACrB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;wBACxE,eAAe,UAAU,QAAQ,mBAAmB,iBAAiB,IACnF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,WAAW,GAAG,KACnB;EAAU;IAAS,MAAM;IAAG;;EAAoB,OAAO;EAAK,UAAU,eAAe;;;qBAkC3E,eAAe,UAAU,SAAS;;EAS7C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB;IAAS,MAAM;IAAG;;MAQhB;MAIA;MAIA,eAAe;MAIf,mBAAmB;MAInB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"cursorPagination.js","names":["#ctx","#type","#filter","#edges","#hasNextPagePromise","#countPastCursor","#hasPreviousPagePromise","#totalCountPromise"],"sources":["../src/cursorPagination.ts"],"sourcesContent":["import {\n type Entity,\n type FindGqlFilterOptions,\n type IdOf,\n type MaybeAbstractEntityConstructor,\n type QueryCondition,\n type ValueGraphQLFilter,\n} from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype CursorArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n first?: number | null;\n after?: string | null;\n last?: number | null;\n before?: string | null;\n};\n\n/** Returns an ID-ordered cursor connection for a resolver, replacing the entity query's ordering. */\nexport function paginateCursor<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<CursorArgs<T>, \"filter\">,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport async function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }> {\n const limit = args.first ?? args.last ?? defaultLimit;\n const baseFilter = (args.filter ?? {}) as PaginationFilter<T>;\n const filter = withCursorFilter(baseFilter, args);\n const orderBy = { id: args.last ? \"DESC\" : \"ASC\" } as FindGqlFilterOptions<T>[\"orderBy\"];\n const nodes =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, orderBy })\n : await queryEntities(ctx, {\n ...withCursorQuery(type, args),\n orderBy: [args.last ? { sort: type.select.id, order: \"DESC\" } : { sort: type.select.id, order: \"ASC\" }],\n limit,\n offset: undefined,\n });\n const orderedNodes = args.last ? [...nodes].reverse() : nodes;\n const edges = orderedNodes.map((node) => ({ node, cursor: encodeCursor(String(node.id)) }));\n return {\n edges,\n nodes: orderedNodes,\n pageInfo: new CursorPageInfo(\n ctx,\n typeof type === \"function\" ? type : { ...type, orderBy: undefined },\n baseFilter,\n edges,\n ),\n };\n}\n\n/** Lazily computes cursor page fields. */\nexport class CursorPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #edges: { node: T; cursor: string }[];\n #filter: PaginationFilter<T>;\n #hasNextPagePromise: Promise<boolean> | undefined;\n #hasPreviousPagePromise: Promise<boolean> | undefined;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n edges: { node: T; cursor: string }[],\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#edges = edges;\n }\n\n get startCursor(): string | undefined {\n return this.#edges[0]?.cursor;\n }\n\n get endCursor(): string | undefined {\n return this.#edges[this.#edges.length - 1]?.cursor;\n }\n\n get hasNextPage(): Promise<boolean> {\n return (this.#hasNextPagePromise ??= this.#countPastCursor(\"after\", this.endCursor));\n }\n\n get hasPreviousPage(): Promise<boolean> {\n return (this.#hasPreviousPagePromise ??= this.#countPastCursor(\"before\", this.startCursor));\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n /** Counts rows past a cursor only when the field is requested. */\n async #countPastCursor(direction: \"after\" | \"before\", cursor: string | undefined): Promise<boolean> {\n if (!cursor) return false;\n if (typeof this.#type !== \"function\") {\n return (await countQuery(this.#ctx, withCursorQuery(this.#type, { [direction]: cursor }))) > 0;\n }\n const filter = withCursorFilter(this.#filter, { [direction]: cursor });\n return (await this.#ctx.em.findCount(this.#type, filter)) > 0;\n }\n}\n\n/** Adds both cursor bounds without replacing the query's existing conditions. */\nfunction withCursorQuery<T extends Entity>(\n base: PaginationQuery<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationQuery<T> {\n return {\n ...base,\n where: {\n and: [\n ...(Array.isArray(base.where) ? base.where : [base.where as QueryCondition | undefined]),\n args.after ? base.select.id.gt(decodeCursor(args.after) as IdOf<T>) : undefined,\n args.before ? base.select.id.lt(decodeCursor(args.before) as IdOf<T>) : undefined,\n ],\n },\n };\n}\n\n/** Adds cursor bounds to a filter. */\nfunction withCursorFilter<T extends Entity>(\n filter: PaginationFilter<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationFilter<T> {\n const cursor = args.after ?? args.before;\n if (!cursor) return filter;\n const op = args.after ? \"gt\" : \"lt\";\n return { ...filter, id: { [op]: decodeCursor(cursor) } as ValueGraphQLFilter<string> } as PaginationFilter<T>;\n}\n\n/** Encodes an entity id as an opaque cursor. */\nfunction encodeCursor(id: string): string {\n return Buffer.from(id).toString(\"base64\");\n}\n\n/** Decodes an opaque cursor back into an entity id. */\nfunction decodeCursor(cursor: string): string {\n return Buffer.from(cursor, \"base64\").toString(\"utf8\");\n}\n"],"mappings":";;;AAqCA,eAAsB,eACpB,KACA,MACA,MAC4F;CAC5F,MAAM,QAAQ,KAAK,SAAS,KAAK,QAAA;CACjC,MAAM,aAAc,KAAK,UAAU,CAAC;CACpC,MAAM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":3,"file":"cursorPagination.js","names":[],"sources":["../src/cursorPagination.ts"],"sourcesContent":["import {\n type Entity,\n type FindGqlFilterOptions,\n type IdOf,\n type MaybeAbstractEntityConstructor,\n type QueryCondition,\n type ValueGraphQLFilter,\n} from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype CursorArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n first?: number | null;\n after?: string | null;\n last?: number | null;\n before?: string | null;\n};\n\n/** Returns an ID-ordered cursor connection for a resolver, replacing the entity query's ordering. */\nexport function paginateCursor<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<CursorArgs<T>, \"filter\">,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }>;\nexport async function paginateCursor<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: CursorArgs<T, F>,\n): Promise<{ edges: { node: T; cursor: string }[]; nodes: T[]; pageInfo: CursorPageInfo<T> }> {\n const limit = args.first ?? args.last ?? defaultLimit;\n const baseFilter = (args.filter ?? {}) as PaginationFilter<T>;\n const filter = withCursorFilter(baseFilter, args);\n const orderBy = { id: args.last ? \"DESC\" : \"ASC\" } as FindGqlFilterOptions<T>[\"orderBy\"];\n const nodes =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, orderBy })\n : await queryEntities(ctx, {\n ...withCursorQuery(type, args),\n orderBy: [args.last ? { sort: type.select.id, order: \"DESC\" } : { sort: type.select.id, order: \"ASC\" }],\n limit,\n offset: undefined,\n });\n const orderedNodes = args.last ? [...nodes].reverse() : nodes;\n const edges = orderedNodes.map((node) => ({ node, cursor: encodeCursor(String(node.id)) }));\n return {\n edges,\n nodes: orderedNodes,\n pageInfo: new CursorPageInfo(\n ctx,\n typeof type === \"function\" ? type : { ...type, orderBy: undefined },\n baseFilter,\n edges,\n ),\n };\n}\n\n/** Lazily computes cursor page fields. */\nexport class CursorPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #edges: { node: T; cursor: string }[];\n #filter: PaginationFilter<T>;\n #hasNextPagePromise: Promise<boolean> | undefined;\n #hasPreviousPagePromise: Promise<boolean> | undefined;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n edges: { node: T; cursor: string }[],\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#edges = edges;\n }\n\n get startCursor(): string | undefined {\n return this.#edges[0]?.cursor;\n }\n\n get endCursor(): string | undefined {\n return this.#edges[this.#edges.length - 1]?.cursor;\n }\n\n get hasNextPage(): Promise<boolean> {\n return (this.#hasNextPagePromise ??= this.#countPastCursor(\"after\", this.endCursor));\n }\n\n get hasPreviousPage(): Promise<boolean> {\n return (this.#hasPreviousPagePromise ??= this.#countPastCursor(\"before\", this.startCursor));\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n /** Counts rows past a cursor only when the field is requested. */\n async #countPastCursor(direction: \"after\" | \"before\", cursor: string | undefined): Promise<boolean> {\n if (!cursor) return false;\n if (typeof this.#type !== \"function\") {\n return (await countQuery(this.#ctx, withCursorQuery(this.#type, { [direction]: cursor }))) > 0;\n }\n const filter = withCursorFilter(this.#filter, { [direction]: cursor });\n return (await this.#ctx.em.findCount(this.#type, filter)) > 0;\n }\n}\n\n/** Adds both cursor bounds without replacing the query's existing conditions. */\nfunction withCursorQuery<T extends Entity>(\n base: PaginationQuery<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationQuery<T> {\n return {\n ...base,\n where: {\n and: [\n ...(Array.isArray(base.where) ? base.where : [base.where as QueryCondition | undefined]),\n args.after ? base.select.id.gt(decodeCursor(args.after) as IdOf<T>) : undefined,\n args.before ? base.select.id.lt(decodeCursor(args.before) as IdOf<T>) : undefined,\n ],\n },\n };\n}\n\n/** Adds cursor bounds to a filter. */\nfunction withCursorFilter<T extends Entity>(\n filter: PaginationFilter<T>,\n args: { after?: string | null; before?: string | null },\n): PaginationFilter<T> {\n const cursor = args.after ?? args.before;\n if (!cursor) return filter;\n const op = args.after ? \"gt\" : \"lt\";\n return { ...filter, id: { [op]: decodeCursor(cursor) } as ValueGraphQLFilter<string> } as PaginationFilter<T>;\n}\n\n/** Encodes an entity id as an opaque cursor. */\nfunction encodeCursor(id: string): string {\n return Buffer.from(id).toString(\"base64\");\n}\n\n/** Decodes an opaque cursor back into an entity id. */\nfunction decodeCursor(cursor: string): string {\n return Buffer.from(cursor, \"base64\").toString(\"utf8\");\n}\n"],"mappings":";;;AAqCA,eAAsB,eACpB,KACA,MACA,MAC4F;CAC5F,MAAM,QAAQ,KAAK,SAAS,KAAK,QAAA;CACjC,MAAM,aAAc,KAAK,UAAU,CAAC;CACpC,MAAM,SAAS,iBAAiB,YAAY,IAAI;CAChD,MAAM,UAAU,EAAE,IAAI,KAAK,OAAO,SAAS,MAAM;CACjD,MAAM,QACJ,OAAO,SAAS,aACZ,MAAM,IAAI,GAAG,QAAQ,MAAM,QAAQ;EAAE;EAAO;CAAQ,CAAC,IACrD,MAAM,cAAc,KAAK;EACvB,GAAG,gBAAgB,MAAM,IAAI;EAC7B,SAAS,CAAC,KAAK,OAAO;GAAE,MAAM,KAA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,YAAY,OAAO,CAAC,CAAC,IAAK;EAE/F,MAAM,SAAS,iBAAiB,KAAK,SAAS,GAAG,YAAY,OAAO,CAAC;EACrE,OAAQ,MAAM,KAAK,KAAK,GAAG,UAAU,KAAK,OAAO,MAAM,IAAK;CAC9D;AACF;;AAGA,SAAS,gBACP,MACA,MACoB;CACpB,OAAO;EACL,GAAG;EACH,OAAO,EACL,KAAK;GACH,GAAI,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK,QAAQ,CAAC,KAAK,KAAmC;GACtF,KAAK,QAAQ,KAAK,OAAO,GAAG,GAAG,aAAa,KAAK,KAAK,CAAY,IAAI,KAAA;GACtE,KAAK,SAAS,KAAK,OAAO,GAAG,GAAG,aAAa,KAAK,MAAM,CAAY,IAAI,KAAA;EAC1E,EACF;CACF;AACF;;AAGA,SAAS,iBACP,QACA,MACqB;CACrB,MAAM,SAAS,KAAK,SAAS,KAAK;CAClC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,KAAK,KAAK,QAAQ,OAAO;CAC/B,OAAO;EAAE,GAAG;EAAQ,IAAI,GAAG,KAAK,aAAa,MAAM,EAAE;CAAgC;AACvF;;AAGA,SAAS,aAAa,IAAoB;CACxC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,SAAS,QAAQ;AAC1C;;AAGA,SAAS,aAAa,QAAwB;CAC5C,OAAO,OAAO,KAAK,QAAQ,QAAQ,CAAC,CAAC,SAAS,MAAM;AACtD"}
@@ -13,11 +13,11 @@ type GraphQLPrimitive = string | Date | boolean | number | bigint | null | undef
13
13
  * the GraphQL infra complaining about the extra field resolvers that Joist creates for fields that
14
14
  * are not technically mapped in your GraphQL schema.
15
15
  */
16
- type EntityResolver<T extends Entity> = { [P in keyof T]: P extends "id" ? Resolver<T, Record<string, any>, IdOf<T>> : T[P] extends GraphQLPrimitive | GraphQLPrimitive[] ? Resolver<T, Record<string, any>, T[P]> : T[P] extends Collection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends ReadOnlyCollection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends Reference<any, infer U, infer N> ? Resolver<T, Record<string, any>, U | N> : T[P] extends Property<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends ReactiveGetter<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends Promise<infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends (() => Promise<infer V>) ? Resolver<T, Record<string, any>, V> : T[P] extends (() => infer V) ? Resolver<T, Record<string, any>, V> : Resolver<T, Record<string, any>, T[P]>; };
16
+ export type EntityResolver<T extends Entity> = { [P in keyof T]: P extends "id" ? Resolver<T, Record<string, any>, IdOf<T>> : T[P] extends GraphQLPrimitive | GraphQLPrimitive[] ? Resolver<T, Record<string, any>, T[P]> : T[P] extends Collection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends ReadOnlyCollection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends Reference<any, infer U, infer N> ? Resolver<T, Record<string, any>, U | N> : T[P] extends Property<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends ReactiveGetter<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends Promise<infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends (() => Promise<infer V>) ? Resolver<T, Record<string, any>, V> : T[P] extends (() => infer V) ? Resolver<T, Record<string, any>, V> : Resolver<T, Record<string, any>, T[P]>; };
17
17
  /**
18
18
  * Creates field resolvers for each of the fields on our entity.
19
19
  */
20
- declare function entityResolver<T extends Entity, A extends Record<string, keyof T> = {}>(entity: MaybeAbstractEntityConstructor<T> | EntityMetadata<T>, aliases?: A): EntityResolver<T> & { [K in keyof A]: EntityResolver<T>[A[K]]; };
20
+ export declare function entityResolver<T extends Entity, A extends Record<string, keyof T> = {}>(entity: MaybeAbstractEntityConstructor<T> | EntityMetadata<T>, aliases?: A): EntityResolver<T> & { [K in keyof A]: EntityResolver<T>[A[K]]; };
21
21
  //#endregion
22
- export { EntityResolver, entityResolver };
22
+ export {};
23
23
  //# sourceMappingURL=entityResolver.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entityResolver.d.cts","names":[],"sources":["../src/entityResolver.ts"],"mappings":";;;KAwCK,4BAA4B;;;;;;;;;;;;KAarB,eAAe,UAAU,aAClC,WAAW,IAAI,iBACZ,SAAS,GAAG,qBAAqB,KAAK,MACtC,EAAE,WAAW,mBAAmB,qBAC9B,SAAS,GAAG,qBAAqB,EAAE,MACnC,EAAE,WAAW,sBAAsB,KACjC,SAAS,GAAG,qBAAqB,OACjC,EAAE,WAAW,8BAA8B,KACzC,SAAS,GAAG,qBAAqB,OACjC,EAAE,WAAW,qBAAqB,SAAS,KACzC,SAAS,GAAG,qBAAqB,IAAI,KACrC,EAAE,WAAW,oBAAoB,KAC/B,SAAS,GAAG,qBAAqB,KACjC,EAAE,WAAW,0BAA0B,KACrC,SAAS,GAAG,qBAAqB,KACjC,EAAE,WAAW,cAAc,KACzB,SAAS,GAAG,qBAAqB,KACjC,EAAE,kBAAiB,cAAc,MAC/B,SAAS,GAAG,qBAAqB,KACjC,EAAE,wBAAuB,KACvB,SAAS,GAAG,qBAAqB,KACjC,SAAS,GAAG,qBAAqB,EAAE;;;;iBAM3C,eAAe,UAAU,QAAQ,UAAU,qBAAqB,SAC9E,QAAQ,+BAA+B,KAAK,eAAe,IAC3D,UAAU,IACT,eAAe,QAAQ,WAAW,IAAI,eAAe,GAAG,EAAE"}
1
+ {"version":3,"file":"entityResolver.d.cts","names":[],"sources":["../src/entityResolver.ts"],"mappings":";;;KAwCK,4BAA4B;;;;;;;;;;;;YAarB,eAAe,UAAU,aAClC,WAAW,IAAI,iBACZ,SAAS,GAAG,qBAAqB,KAAK,MACtC,EAAE,WAAW,mBAAmB,qBAC9B,SAAS,GAAG,qBAAqB,EAAE,MACnC,EAAE,WAAW,sBAAsB,KACjC,SAAS,GAAG,qBAAqB,OACjC,EAAE,WAAW,8BAA8B,KACzC,SAAS,GAAG,qBAAqB,OACjC,EAAE,WAAW,qBAAqB,SAAS,KACzC,SAAS,GAAG,qBAAqB,IAAI,KACrC,EAAE,WAAW,oBAAoB,KAC/B,SAAS,GAAG,qBAAqB,KACjC,EAAE,WAAW,0BAA0B,KACrC,SAAS,GAAG,qBAAqB,KACjC,EAAE,WAAW,cAAc,KACzB,SAAS,GAAG,qBAAqB,KACjC,EAAE,kBAAiB,cAAc,MAC/B,SAAS,GAAG,qBAAqB,KACjC,EAAE,wBAAuB,KACvB,SAAS,GAAG,qBAAqB,KACjC,SAAS,GAAG,qBAAqB,EAAE;;;;wBAM3C,eAAe,UAAU,QAAQ,UAAU,qBAAqB,SAC9E,QAAQ,+BAA+B,KAAK,eAAe,IAC3D,UAAU,IACT,eAAe,QAAQ,WAAW,IAAI,eAAe,GAAG,EAAE"}
@@ -13,11 +13,11 @@ type GraphQLPrimitive = string | Date | boolean | number | bigint | null | undef
13
13
  * the GraphQL infra complaining about the extra field resolvers that Joist creates for fields that
14
14
  * are not technically mapped in your GraphQL schema.
15
15
  */
16
- type EntityResolver<T extends Entity> = { [P in keyof T]: P extends "id" ? Resolver<T, Record<string, any>, IdOf<T>> : T[P] extends GraphQLPrimitive | GraphQLPrimitive[] ? Resolver<T, Record<string, any>, T[P]> : T[P] extends Collection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends ReadOnlyCollection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends Reference<any, infer U, infer N> ? Resolver<T, Record<string, any>, U | N> : T[P] extends Property<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends ReactiveGetter<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends Promise<infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends (() => Promise<infer V>) ? Resolver<T, Record<string, any>, V> : T[P] extends (() => infer V) ? Resolver<T, Record<string, any>, V> : Resolver<T, Record<string, any>, T[P]>; };
16
+ export type EntityResolver<T extends Entity> = { [P in keyof T]: P extends "id" ? Resolver<T, Record<string, any>, IdOf<T>> : T[P] extends GraphQLPrimitive | GraphQLPrimitive[] ? Resolver<T, Record<string, any>, T[P]> : T[P] extends Collection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends ReadOnlyCollection<any, infer U> ? Resolver<T, Record<string, any>, U[]> : T[P] extends Reference<any, infer U, infer N> ? Resolver<T, Record<string, any>, U | N> : T[P] extends Property<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends ReactiveGetter<any, infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends Promise<infer V> ? Resolver<T, Record<string, any>, V> : T[P] extends (() => Promise<infer V>) ? Resolver<T, Record<string, any>, V> : T[P] extends (() => infer V) ? Resolver<T, Record<string, any>, V> : Resolver<T, Record<string, any>, T[P]>; };
17
17
  /**
18
18
  * Creates field resolvers for each of the fields on our entity.
19
19
  */
20
- declare function entityResolver<T extends Entity, A extends Record<string, keyof T> = {}>(entity: MaybeAbstractEntityConstructor<T> | EntityMetadata<T>, aliases?: A): EntityResolver<T> & { [K in keyof A]: EntityResolver<T>[A[K]]; };
20
+ export declare function entityResolver<T extends Entity, A extends Record<string, keyof T> = {}>(entity: MaybeAbstractEntityConstructor<T> | EntityMetadata<T>, aliases?: A): EntityResolver<T> & { [K in keyof A]: EntityResolver<T>[A[K]]; };
21
21
  //#endregion
22
- export { EntityResolver, entityResolver };
22
+ export {};
23
23
  //# sourceMappingURL=entityResolver.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entityResolver.d.mts","names":[],"sources":["../src/entityResolver.ts"],"mappings":";;;KAwCK,4BAA4B;;;;;;;;;;;;KAarB,eAAe,UAAU,aAClC,WAAW,IAAI,iBACZ,SAAS,GAAG,qBAAqB,KAAK,MACtC,EAAE,WAAW,mBAAmB,qBAC9B,SAAS,GAAG,qBAAqB,EAAE,MACnC,EAAE,WAAW,sBAAsB,KACjC,SAAS,GAAG,qBAAqB,OACjC,EAAE,WAAW,8BAA8B,KACzC,SAAS,GAAG,qBAAqB,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B,SAC9E,QAAQ,+BAA+B,KAAK,eAAe,IAC3D,UAAU,IACT,eAAe,QAAQ,WAAW,IAAI,eAAe,GAAG,EAAE"}
package/build/hint.d.cts CHANGED
@@ -3,10 +3,9 @@ import { Entity, EntityMetadata, LoadHint } from "joist-core";
3
3
  import { SelectionSetNode } from "graphql/language";
4
4
  //#region src/hint.d.ts
5
5
  /** Returns a load hint for the given `meta` entity at the `info` node.populate`. */
6
- declare function convertInfoToLoadHint<T extends Entity>(meta: EntityMetadata, info: GraphQLResolveInfo): LoadHint<T> | undefined;
6
+ export declare function convertInfoToLoadHint<T extends Entity>(meta: EntityMetadata, info: GraphQLResolveInfo): LoadHint<T> | undefined;
7
7
  /** Converts a GraphQL selection set into a hint for `EntityManager.populate`. */
8
- declare function selectionSetToObject(info: GraphQLResolveInfo, meta: EntityMetadata, gqlType: GraphQLObjectType, selectionSet: SelectionSetNode): Record<string, any>;
9
- declare function convertToObjectType(type: GraphQLOutputType): GraphQLObjectType | undefined;
8
+ export declare function selectionSetToObject(info: GraphQLResolveInfo, meta: EntityMetadata, gqlType: GraphQLObjectType, selectionSet: SelectionSetNode): Record<string, any>;
9
+ export declare function convertToObjectType(type: GraphQLOutputType): GraphQLObjectType | undefined;
10
10
  //#endregion
11
- export { convertInfoToLoadHint, convertToObjectType, selectionSetToObject };
12
11
  //# sourceMappingURL=hint.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hint.d.cts","names":[],"sources":["../src/hint.ts"],"mappings":";;;;;iBAYgB,sBAAsB,UAAU,QAC9C,MAAM,gBACN,MAAM,qBACL,SAAS;;iBAgBI,qBACd,MAAM,oBACN,MAAM,gBACN,SAAS,mBACT,cAAc,mBACb;iBAoCa,oBAAoB,MAAM,oBAAoB"}
1
+ {"version":3,"file":"hint.d.cts","names":[],"sources":["../src/hint.ts"],"mappings":";;;;;wBAYgB,sBAAsB,UAAU,QAC9C,MAAM,gBACN,MAAM,qBACL,SAAS;;wBAgBI,qBACd,MAAM,oBACN,MAAM,gBACN,SAAS,mBACT,cAAc,mBACb;wBAoCa,oBAAoB,MAAM,oBAAoB"}
package/build/hint.d.mts CHANGED
@@ -3,10 +3,9 @@ import { Entity, EntityMetadata, LoadHint } from "joist-core";
3
3
  import { SelectionSetNode } from "graphql/language";
4
4
  //#region src/hint.d.ts
5
5
  /** Returns a load hint for the given `meta` entity at the `info` node.populate`. */
6
- declare function convertInfoToLoadHint<T extends Entity>(meta: EntityMetadata, info: GraphQLResolveInfo): LoadHint<T> | undefined;
6
+ export declare function convertInfoToLoadHint<T extends Entity>(meta: EntityMetadata, info: GraphQLResolveInfo): LoadHint<T> | undefined;
7
7
  /** Converts a GraphQL selection set into a hint for `EntityManager.populate`. */
8
- declare function selectionSetToObject(info: GraphQLResolveInfo, meta: EntityMetadata, gqlType: GraphQLObjectType, selectionSet: SelectionSetNode): Record<string, any>;
9
- declare function convertToObjectType(type: GraphQLOutputType): GraphQLObjectType | undefined;
8
+ export declare function selectionSetToObject(info: GraphQLResolveInfo, meta: EntityMetadata, gqlType: GraphQLObjectType, selectionSet: SelectionSetNode): Record<string, any>;
9
+ export declare function convertToObjectType(type: GraphQLOutputType): GraphQLObjectType | undefined;
10
10
  //#endregion
11
- export { convertInfoToLoadHint, convertToObjectType, selectionSetToObject };
12
11
  //# sourceMappingURL=hint.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hint.d.mts","names":[],"sources":["../src/hint.ts"],"mappings":";;;;;iBAYgB,sBAAsB,UAAU,QAC9C,MAAM,gBACN,MAAM,qBACL,SAAS;;iBAgBI,qBACd,MAAM,oBACN,MAAM,gBACN,SAAS,mBACT,cAAc,mBACb;iBAoCa,oBAAoB,MAAM,oBAAoB"}
1
+ {"version":3,"file":"hint.d.mts","names":[],"sources":["../src/hint.ts"],"mappings":";;;;;wBAYgB,sBAAsB,UAAU,QAC9C,MAAM,gBACN,MAAM,qBACL,SAAS;;wBAgBI,qBACd,MAAM,oBACN,MAAM,gBACN,SAAS,mBACT,cAAc,mBACb;wBAoCa,oBAAoB,MAAM,oBAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"limitPagination.cjs","names":["queryEntities","#ctx","#type","#filter","#page","#hasNextPage","#totalCountPromise","countQuery","#nextPage"],"sources":["../src/limitPagination.ts"],"sourcesContent":["import { type Entity, type MaybeAbstractEntityConstructor } from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype LimitArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n limit?: number | null;\n offset?: number | null;\n};\ntype Page = { offset: number; limit: number };\n\n/** Returns a limit/offset page shape for a resolver, preserving the entity query's ordering. */\nexport function paginateLimit<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<LimitArgs<T>, \"filter\">,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport async function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }> {\n const limit = args.limit ?? defaultLimit;\n const offset = args.offset ?? 0;\n const filter = (args.filter ?? {}) as PaginationFilter<T>;\n const entities =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, offset })\n : await queryEntities<T>(ctx, { ...type, limit, offset });\n return { entities, pageInfo: new LimitPageInfo(ctx, type, filter, { limit, offset }) };\n}\n\n/** Lazily computes limit/offset page fields. */\nexport class LimitPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #filter: PaginationFilter<T>;\n #page: Page;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n page: Page,\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#page = page;\n }\n\n get hasNextPage(): Promise<boolean> {\n return this.#hasNextPage();\n }\n\n get hasPreviousPage(): boolean {\n return this.#page.offset > 0;\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n get nextPage(): Promise<number | undefined> {\n return this.#nextPage();\n }\n\n get currentPage(): number {\n return Math.floor(this.#page.offset / this.#page.limit) + 1;\n }\n\n /** Returns whether another page exists after this page. */\n async #hasNextPage(): Promise<boolean> {\n const total = await this.totalCount;\n const { offset, limit } = this.#page;\n return offset + limit < total;\n }\n\n /** Returns the next limit/offset page if there is one. */\n async #nextPage(): Promise<number | undefined> {\n if (!(await this.hasNextPage)) return undefined;\n return this.currentPage + 1;\n }\n}\n"],"mappings":";;;;AA6BA,eAAsB,cACpB,KACA,MACA,MACwD;CACxD,MAAM,QAAQ,KAAK,SAAA;CACnB,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,SAAU,KAAK,UAAU,CAAC;CAKhC,OAAO;EAAE,UAHP,OAAO,SAAS,aACZ,MAAM,IAAI,GAAG,QAAQ,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC,IACpD,MAAMA,wBAAAA,cAAiB,KAAK;GAAE,GAAG;GAAM;GAAO;EAAO,CAAC;EACzC,UAAU,IAAI,cAAc,KAAK,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC;CAAE;AACvF;;AAGA,IAAa,gBAAb,MAAsD;CACpD;CACA;CACA;CACA;CACA;CAEA,YACE,KACA,MACA,QACA,MACA;EACA,KAAKC,OAAO;EACZ,KAAKC,QAAQ;EACb,KAAKC,UAAU;EACf,KAAKC,QAAQ;CACf;CAEA,IAAI,cAAgC;EAClC,OAAO,KAAKC,aAAa;CAC3B;CAEA,IAAI,kBAA2B;EAC7B,OAAO,KAAKD,MAAM,SAAS;CAC7B;CAEA,IAAI,aAA8B;EAChC,OAAQ,KAAKE,uBACX,OAAO,KAAKJ,UAAU,aAClB,KAAKD,KAAK,GAAG,UAAU,KAAKC,OAAO,KAAKC,OAAO,IAC/CI,wBAAAA,WAAW,KAAKN,MAAM,KAAKC,KAAK;CACxC;CAEA,IAAI,WAAwC;EAC1C,OAAO,KAAKM,UAAU;CACxB;CAEA,IAAI,cAAsB;EACxB,OAAO,KAAK,MAAM,KAAKJ,MAAM,SAAS,KAAKA,MAAM,KAAK,IAAI;CAC5D;;CAGA,MAAMC,eAAiC;EACrC,MAAM,QAAQ,MAAM,KAAK;EACzB,MAAM,EAAE,QAAQ,UAAU,KAAKD;EAC/B,OAAO,SAAS,QAAQ;CAC1B;;CAGA,MAAMI,YAAyC;EAC7C,IAAI,CAAE,MAAM,KAAK,aAAc,OAAO,KAAA;EACtC,OAAO,KAAK,cAAc;CAC5B;AACF"}
1
+ {"version":3,"file":"limitPagination.cjs","names":["queryEntities","countQuery"],"sources":["../src/limitPagination.ts"],"sourcesContent":["import { type Entity, type MaybeAbstractEntityConstructor } from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype LimitArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n limit?: number | null;\n offset?: number | null;\n};\ntype Page = { offset: number; limit: number };\n\n/** Returns a limit/offset page shape for a resolver, preserving the entity query's ordering. */\nexport function paginateLimit<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<LimitArgs<T>, \"filter\">,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport async function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }> {\n const limit = args.limit ?? defaultLimit;\n const offset = args.offset ?? 0;\n const filter = (args.filter ?? {}) as PaginationFilter<T>;\n const entities =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, offset })\n : await queryEntities<T>(ctx, { ...type, limit, offset });\n return { entities, pageInfo: new LimitPageInfo(ctx, type, filter, { limit, offset }) };\n}\n\n/** Lazily computes limit/offset page fields. */\nexport class LimitPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #filter: PaginationFilter<T>;\n #page: Page;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n page: Page,\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#page = page;\n }\n\n get hasNextPage(): Promise<boolean> {\n return this.#hasNextPage();\n }\n\n get hasPreviousPage(): boolean {\n return this.#page.offset > 0;\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n get nextPage(): Promise<number | undefined> {\n return this.#nextPage();\n }\n\n get currentPage(): number {\n return Math.floor(this.#page.offset / this.#page.limit) + 1;\n }\n\n /** Returns whether another page exists after this page. */\n async #hasNextPage(): Promise<boolean> {\n const total = await this.totalCount;\n const { offset, limit } = this.#page;\n return offset + limit < total;\n }\n\n /** Returns the next limit/offset page if there is one. */\n async #nextPage(): Promise<number | undefined> {\n if (!(await this.hasNextPage)) return undefined;\n return this.currentPage + 1;\n }\n}\n"],"mappings":";;;;AA6BA,eAAsB,cACpB,KACA,MACA,MACwD;CACxD,MAAM,QAAQ,KAAK,SAAA;CACnB,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,SAAU,KAAK,UAAU,CAAC;CAKhC,OAAO;EAAE,UAHP,OAAO,SAAS,aACZ,MAAM,IAAI,GAAG,QAAQ,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC,IACpD,MAAMA,wBAAAA,cAAiB,KAAK;GAAE,GAAG;GAAM;GAAO;EAAO,CAAC;EACzC,UAAU,IAAI,cAAc,KAAK,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC;CAAE;AACvF;;AAGA,IAAa,gBAAb,MAAsD;CACpD;CACA;CACA;CACA;CACA;CAEA,YACE,KACA,MACA,QACA,MACA;EACA,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,UAAU;EACf,KAAK,QAAQ;CACf;CAEA,IAAI,cAAgC;EAClC,OAAO,KAAK,aAAa;CAC3B;CAEA,IAAI,kBAA2B;EAC7B,OAAO,KAAK,MAAM,SAAS;CAC7B;CAEA,IAAI,aAA8B;EAChC,OAAQ,KAAK,uBACX,OAAO,KAAK,UAAU,aAClB,KAAK,KAAK,GAAG,UAAU,KAAK,OAAO,KAAK,OAAO,IAC/CC,wBAAAA,WAAW,KAAK,MAAM,KAAK,KAAK;CACxC;CAEA,IAAI,WAAwC;EAC1C,OAAO,KAAK,UAAU;CACxB;CAEA,IAAI,cAAsB;EACxB,OAAO,KAAK,MAAM,KAAK,MAAM,SAAS,KAAK,MAAM,KAAK,IAAI;CAC5D;;CAGA,MAAM,eAAiC;EACrC,MAAM,QAAQ,MAAM,KAAK;EACzB,MAAM,EAAE,QAAQ,UAAU,KAAK;EAC/B,OAAO,SAAS,QAAQ;CAC1B;;CAGA,MAAM,YAAyC;EAC7C,IAAI,CAAE,MAAM,KAAK,aAAc,OAAO,KAAA;EACtC,OAAO,KAAK,cAAc;CAC5B;AACF"}
@@ -11,16 +11,16 @@ type Page = {
11
11
  limit: number;
12
12
  };
13
13
  /** Returns a limit/offset page shape for a resolver, preserving the entity query's ordering. */
14
- declare function paginateLimit<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<LimitArgs<T>, "filter">): Promise<{
14
+ export declare function paginateLimit<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<LimitArgs<T>, "filter">): Promise<{
15
15
  entities: T[];
16
16
  pageInfo: LimitPageInfo<T>;
17
17
  }>;
18
- declare function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: LimitArgs<T, F>): Promise<{
18
+ export declare function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: LimitArgs<T, F>): Promise<{
19
19
  entities: T[];
20
20
  pageInfo: LimitPageInfo<T>;
21
21
  }>;
22
22
  /** Lazily computes limit/offset page fields. */
23
- declare class LimitPageInfo<T extends Entity = Entity> {
23
+ export declare class LimitPageInfo<T extends Entity = Entity> {
24
24
  #private;
25
25
  constructor(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>, filter: PaginationFilter<T>, page: Page);
26
26
  get hasNextPage(): Promise<boolean>;
@@ -30,5 +30,5 @@ declare class LimitPageInfo<T extends Entity = Entity> {
30
30
  get currentPage(): number;
31
31
  }
32
32
  //#endregion
33
- export { LimitPageInfo, paginateLimit };
33
+ export {};
34
34
  //# sourceMappingURL=limitPagination.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"limitPagination.d.cts","names":[],"sources":["../src/limitPagination.ts"],"mappings":";;;KAWK,UAAU,UAAU,QAAQ,mBAAmB,iBAAiB;EACnE,SAAS;EACT;EACA;;KAEG;EAAS;EAAgB;;;iBAGd,cAAc,UAAU,QACtC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,UAAU,gBACpB;EAAU,UAAU;EAAK,UAAU,cAAc;;iBACpC,cAAc,UAAU,QAAQ,mBAAmB,iBAAiB,IAClF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,UAAU,GAAG,KAClB;EAAU,UAAU;EAAK,UAAU,cAAc;;;cAiBvC,cAAc,UAAU,SAAS;;EAO5C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB,MAAM;MAQJ,eAAe;MAIf;MAIA,cAAc;MAOd,YAAY;MAIZ"}
1
+ {"version":3,"file":"limitPagination.d.cts","names":[],"sources":["../src/limitPagination.ts"],"mappings":";;;KAWK,UAAU,UAAU,QAAQ,mBAAmB,iBAAiB;EACnE,SAAS;EACT;EACA;;KAEG;EAAS;EAAgB;;;wBAGd,cAAc,UAAU,QACtC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,UAAU,gBACpB;EAAU,UAAU;EAAK,UAAU,cAAc;;wBACpC,cAAc,UAAU,QAAQ,mBAAmB,iBAAiB,IAClF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,UAAU,GAAG,KAClB;EAAU,UAAU;EAAK,UAAU,cAAc;;;qBAiBvC,cAAc,UAAU,SAAS;;EAO5C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB,MAAM;MAQJ,eAAe;MAIf;MAIA,cAAc;MAOd,YAAY;MAIZ"}
@@ -11,16 +11,16 @@ type Page = {
11
11
  limit: number;
12
12
  };
13
13
  /** Returns a limit/offset page shape for a resolver, preserving the entity query's ordering. */
14
- declare function paginateLimit<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<LimitArgs<T>, "filter">): Promise<{
14
+ export declare function paginateLimit<T extends Entity>(ctx: ContextWithEm, query: PaginationQuery<T>, args: Omit<LimitArgs<T>, "filter">): Promise<{
15
15
  entities: T[];
16
16
  pageInfo: LimitPageInfo<T>;
17
17
  }>;
18
- declare function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: LimitArgs<T, F>): Promise<{
18
+ export declare function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T>, args: LimitArgs<T, F>): Promise<{
19
19
  entities: T[];
20
20
  pageInfo: LimitPageInfo<T>;
21
21
  }>;
22
22
  /** Lazily computes limit/offset page fields. */
23
- declare class LimitPageInfo<T extends Entity = Entity> {
23
+ export declare class LimitPageInfo<T extends Entity = Entity> {
24
24
  #private;
25
25
  constructor(ctx: ContextWithEm, type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>, filter: PaginationFilter<T>, page: Page);
26
26
  get hasNextPage(): Promise<boolean>;
@@ -30,5 +30,5 @@ declare class LimitPageInfo<T extends Entity = Entity> {
30
30
  get currentPage(): number;
31
31
  }
32
32
  //#endregion
33
- export { LimitPageInfo, paginateLimit };
33
+ export {};
34
34
  //# sourceMappingURL=limitPagination.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"limitPagination.d.mts","names":[],"sources":["../src/limitPagination.ts"],"mappings":";;;KAWK,UAAU,UAAU,QAAQ,mBAAmB,iBAAiB;EACnE,SAAS;EACT;EACA;;KAEG;EAAS;EAAgB;;;iBAGd,cAAc,UAAU,QACtC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,UAAU,gBACpB;EAAU,UAAU;EAAK,UAAU,cAAc;;iBACpC,cAAc,UAAU,QAAQ,mBAAmB,iBAAiB,IAClF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,UAAU,GAAG,KAClB;EAAU,UAAU;EAAK,UAAU,cAAc;;;cAiBvC,cAAc,UAAU,SAAS;;EAO5C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB,MAAM;MAQJ,eAAe;MAIf;MAIA,cAAc;MAOd,YAAY;MAIZ"}
1
+ {"version":3,"file":"limitPagination.d.mts","names":[],"sources":["../src/limitPagination.ts"],"mappings":";;;KAWK,UAAU,UAAU,QAAQ,mBAAmB,iBAAiB;EACnE,SAAS;EACT;EACA;;KAEG;EAAS;EAAgB;;;wBAGd,cAAc,UAAU,QACtC,KAAK,eACL,OAAO,gBAAgB,IACvB,MAAM,KAAK,UAAU,gBACpB;EAAU,UAAU;EAAK,UAAU,cAAc;;wBACpC,cAAc,UAAU,QAAQ,mBAAmB,iBAAiB,IAClF,KAAK,eACL,MAAM,+BAA+B,IACrC,MAAM,UAAU,GAAG,KAClB;EAAU,UAAU;EAAK,UAAU,cAAc;;;qBAiBvC,cAAc,UAAU,SAAS;;EAO5C,YACE,KAAK,eACL,MAAM,+BAA+B,KAAK,gBAAgB,IAC1D,QAAQ,iBAAiB,IACzB,MAAM;MAQJ,eAAe;MAIf;MAIA,cAAc;MAOd,YAAY;MAIZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"limitPagination.js","names":["#ctx","#type","#filter","#page","#hasNextPage","#totalCountPromise","#nextPage"],"sources":["../src/limitPagination.ts"],"sourcesContent":["import { type Entity, type MaybeAbstractEntityConstructor } from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype LimitArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n limit?: number | null;\n offset?: number | null;\n};\ntype Page = { offset: number; limit: number };\n\n/** Returns a limit/offset page shape for a resolver, preserving the entity query's ordering. */\nexport function paginateLimit<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<LimitArgs<T>, \"filter\">,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport async function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }> {\n const limit = args.limit ?? defaultLimit;\n const offset = args.offset ?? 0;\n const filter = (args.filter ?? {}) as PaginationFilter<T>;\n const entities =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, offset })\n : await queryEntities<T>(ctx, { ...type, limit, offset });\n return { entities, pageInfo: new LimitPageInfo(ctx, type, filter, { limit, offset }) };\n}\n\n/** Lazily computes limit/offset page fields. */\nexport class LimitPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #filter: PaginationFilter<T>;\n #page: Page;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n page: Page,\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#page = page;\n }\n\n get hasNextPage(): Promise<boolean> {\n return this.#hasNextPage();\n }\n\n get hasPreviousPage(): boolean {\n return this.#page.offset > 0;\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n get nextPage(): Promise<number | undefined> {\n return this.#nextPage();\n }\n\n get currentPage(): number {\n return Math.floor(this.#page.offset / this.#page.limit) + 1;\n }\n\n /** Returns whether another page exists after this page. */\n async #hasNextPage(): Promise<boolean> {\n const total = await this.totalCount;\n const { offset, limit } = this.#page;\n return offset + limit < total;\n }\n\n /** Returns the next limit/offset page if there is one. */\n async #nextPage(): Promise<number | undefined> {\n if (!(await this.hasNextPage)) return undefined;\n return this.currentPage + 1;\n }\n}\n"],"mappings":";;;AA6BA,eAAsB,cACpB,KACA,MACA,MACwD;CACxD,MAAM,QAAQ,KAAK,SAAA;CACnB,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,SAAU,KAAK,UAAU,CAAC;CAKhC,OAAO;EAAE,UAHP,OAAO,SAAS,aACZ,MAAM,IAAI,GAAG,QAAQ,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC,IACpD,MAAM,cAAiB,KAAK;GAAE,GAAG;GAAM;GAAO;EAAO,CAAC;EACzC,UAAU,IAAI,cAAc,KAAK,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC;CAAE;AACvF;;AAGA,IAAa,gBAAb,MAAsD;CACpD;CACA;CACA;CACA;CACA;CAEA,YACE,KACA,MACA,QACA,MACA;EACA,KAAKA,OAAO;EACZ,KAAKC,QAAQ;EACb,KAAKC,UAAU;EACf,KAAKC,QAAQ;CACf;CAEA,IAAI,cAAgC;EAClC,OAAO,KAAKC,aAAa;CAC3B;CAEA,IAAI,kBAA2B;EAC7B,OAAO,KAAKD,MAAM,SAAS;CAC7B;CAEA,IAAI,aAA8B;EAChC,OAAQ,KAAKE,uBACX,OAAO,KAAKJ,UAAU,aAClB,KAAKD,KAAK,GAAG,UAAU,KAAKC,OAAO,KAAKC,OAAO,IAC/C,WAAW,KAAKF,MAAM,KAAKC,KAAK;CACxC;CAEA,IAAI,WAAwC;EAC1C,OAAO,KAAKK,UAAU;CACxB;CAEA,IAAI,cAAsB;EACxB,OAAO,KAAK,MAAM,KAAKH,MAAM,SAAS,KAAKA,MAAM,KAAK,IAAI;CAC5D;;CAGA,MAAMC,eAAiC;EACrC,MAAM,QAAQ,MAAM,KAAK;EACzB,MAAM,EAAE,QAAQ,UAAU,KAAKD;EAC/B,OAAO,SAAS,QAAQ;CAC1B;;CAGA,MAAMG,YAAyC;EAC7C,IAAI,CAAE,MAAM,KAAK,aAAc,OAAO,KAAA;EACtC,OAAO,KAAK,cAAc;CAC5B;AACF"}
1
+ {"version":3,"file":"limitPagination.js","names":[],"sources":["../src/limitPagination.ts"],"sourcesContent":["import { type Entity, type MaybeAbstractEntityConstructor } from \"joist-core\";\n\nimport {\n type ContextWithEm,\n type PaginationFilter,\n type PaginationQuery,\n countQuery,\n defaultLimit,\n queryEntities,\n} from \"./paginationUtils.ts\";\n\ntype LimitArgs<T extends Entity, F extends object = PaginationFilter<T>> = {\n filter?: F | null;\n limit?: number | null;\n offset?: number | null;\n};\ntype Page = { offset: number; limit: number };\n\n/** Returns a limit/offset page shape for a resolver, preserving the entity query's ordering. */\nexport function paginateLimit<T extends Entity>(\n ctx: ContextWithEm,\n query: PaginationQuery<T>,\n args: Omit<LimitArgs<T>, \"filter\">,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }>;\nexport async function paginateLimit<T extends Entity, F extends object = PaginationFilter<T>>(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n args: LimitArgs<T, F>,\n): Promise<{ entities: T[]; pageInfo: LimitPageInfo<T> }> {\n const limit = args.limit ?? defaultLimit;\n const offset = args.offset ?? 0;\n const filter = (args.filter ?? {}) as PaginationFilter<T>;\n const entities =\n typeof type === \"function\"\n ? await ctx.em.findGql(type, filter, { limit, offset })\n : await queryEntities<T>(ctx, { ...type, limit, offset });\n return { entities, pageInfo: new LimitPageInfo(ctx, type, filter, { limit, offset }) };\n}\n\n/** Lazily computes limit/offset page fields. */\nexport class LimitPageInfo<T extends Entity = Entity> {\n #ctx: ContextWithEm;\n #filter: PaginationFilter<T>;\n #page: Page;\n #totalCountPromise: Promise<number> | undefined;\n #type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>;\n\n constructor(\n ctx: ContextWithEm,\n type: MaybeAbstractEntityConstructor<T> | PaginationQuery<T>,\n filter: PaginationFilter<T>,\n page: Page,\n ) {\n this.#ctx = ctx;\n this.#type = type;\n this.#filter = filter;\n this.#page = page;\n }\n\n get hasNextPage(): Promise<boolean> {\n return this.#hasNextPage();\n }\n\n get hasPreviousPage(): boolean {\n return this.#page.offset > 0;\n }\n\n get totalCount(): Promise<number> {\n return (this.#totalCountPromise ??=\n typeof this.#type === \"function\"\n ? this.#ctx.em.findCount(this.#type, this.#filter)\n : countQuery(this.#ctx, this.#type));\n }\n\n get nextPage(): Promise<number | undefined> {\n return this.#nextPage();\n }\n\n get currentPage(): number {\n return Math.floor(this.#page.offset / this.#page.limit) + 1;\n }\n\n /** Returns whether another page exists after this page. */\n async #hasNextPage(): Promise<boolean> {\n const total = await this.totalCount;\n const { offset, limit } = this.#page;\n return offset + limit < total;\n }\n\n /** Returns the next limit/offset page if there is one. */\n async #nextPage(): Promise<number | undefined> {\n if (!(await this.hasNextPage)) return undefined;\n return this.currentPage + 1;\n }\n}\n"],"mappings":";;;AA6BA,eAAsB,cACpB,KACA,MACA,MACwD;CACxD,MAAM,QAAQ,KAAK,SAAA;CACnB,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,SAAU,KAAK,UAAU,CAAC;CAKhC,OAAO;EAAE,UAHP,OAAO,SAAS,aACZ,MAAM,IAAI,GAAG,QAAQ,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC,IACpD,MAAM,cAAiB,KAAK;GAAE,GAAG;GAAM;GAAO;EAAO,CAAC;EACzC,UAAU,IAAI,cAAc,KAAK,MAAM,QAAQ;GAAE;GAAO;EAAO,CAAC;CAAE;AACvF;;AAGA,IAAa,gBAAb,MAAsD;CACpD;CACA;CACA;CACA;CACA;CAEA,YACE,KACA,MACA,QACA,MACA;EACA,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,UAAU;EACf,KAAK,QAAQ;CACf;CAEA,IAAI,cAAgC;EAClC,OAAO,KAAK,aAAa;CAC3B;CAEA,IAAI,kBAA2B;EAC7B,OAAO,KAAK,MAAM,SAAS;CAC7B;CAEA,IAAI,aAA8B;EAChC,OAAQ,KAAK,uBACX,OAAO,KAAK,UAAU,aAClB,KAAK,KAAK,GAAG,UAAU,KAAK,OAAO,KAAK,OAAO,IAC/C,WAAW,KAAK,MAAM,KAAK,KAAK;CACxC;CAEA,IAAI,WAAwC;EAC1C,OAAO,KAAK,UAAU;CACxB;CAEA,IAAI,cAAsB;EACxB,OAAO,KAAK,MAAM,KAAK,MAAM,SAAS,KAAK,MAAM,KAAK,IAAI;CAC5D;;CAGA,MAAM,eAAiC;EACrC,MAAM,QAAQ,MAAM,KAAK;EACzB,MAAM,EAAE,QAAQ,UAAU,KAAK;EAC/B,OAAO,SAAS,QAAQ;CAC1B;;CAGA,MAAM,YAAyC;EAC7C,IAAI,CAAE,MAAM,KAAK,aAAc,OAAO,KAAA;EACtC,OAAO,KAAK,cAAc;CAC5B;AACF"}
@@ -7,18 +7,18 @@ import { ResolverResult, RunFn } from "./typeUtils.cjs";
7
7
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
8
8
  * that is customized (basically curried) to their own `newContext` function.
9
9
  */
10
- declare function makeMakeRunInputMutation<C>(runFn: RunFn<C>): MakeRunInputMutation<C>;
10
+ export declare function makeMakeRunInputMutation<C>(runFn: RunFn<C>): MakeRunInputMutation<C>;
11
11
  /**
12
12
  * Creates a `run` method to invoke a mutation resolver that uses the `input` convention.
13
13
  *
14
14
  * Following our `mutation / foo` conventions, `resolver` will have a single `fooResolver.foo` method.
15
15
  */
16
- type MakeRunInputMutation<C> = <T extends object>(resolver: T) => RunInputMutationMethod<C, T>;
16
+ export type MakeRunInputMutation<C> = <T extends object>(resolver: T) => RunInputMutationMethod<C, T>;
17
17
  type RunInputMutationMethod<C, T> = <I extends MutationInput<T>, R = ResolverResult<T, keyof T>>(ctx: C, input: I | (() => I)) => Promise<R>;
18
18
  /** Matches a mutation resolver that has a single `input` field. */
19
19
  type MutationInput<T> = T[keyof T] extends Resolver<any, {
20
20
  input: infer I;
21
21
  }, any> ? I : never;
22
22
  //#endregion
23
- export { MakeRunInputMutation, makeMakeRunInputMutation };
23
+ export {};
24
24
  //# sourceMappingURL=makeRunInputMutation.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunInputMutation.d.cts","names":[],"sources":["../src/makeRunInputMutation.ts"],"mappings":";;;;;;;;;iBASgB,yBAAyB,GAAG,OAAO,MAAM,KAAK,qBAAqB;;;;;;KAoBvE,qBAAqB,MAAM,kBAAkB,UAAU,MAAM,uBAAuB,GAAG;KAE9F,uBAAuB,GAAG,MAAM,UAAU,cAAc,IAAI,IAAI,eAAe,SAAS,IAC3F,KAAK,GACL,OAAO,WAAW,OACf,QAAQ;;KAGR,cAAc,KAAK,QAAQ,WAAW;EAAgB,aAAa;UAAY"}
1
+ {"version":3,"file":"makeRunInputMutation.d.cts","names":[],"sources":["../src/makeRunInputMutation.ts"],"mappings":";;;;;;;;;wBASgB,yBAAyB,GAAG,OAAO,MAAM,KAAK,qBAAqB;;;;;;YAoBvE,qBAAqB,MAAM,kBAAkB,UAAU,MAAM,uBAAuB,GAAG;KAE9F,uBAAuB,GAAG,MAAM,UAAU,cAAc,IAAI,IAAI,eAAe,SAAS,IAC3F,KAAK,GACL,OAAO,WAAW,OACf,QAAQ;;KAGR,cAAc,KAAK,QAAQ,WAAW;EAAgB,aAAa;UAAY"}
@@ -7,18 +7,18 @@ import { ResolverResult, RunFn } from "./typeUtils.mjs";
7
7
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
8
8
  * that is customized (basically curried) to their own `newContext` function.
9
9
  */
10
- declare function makeMakeRunInputMutation<C>(runFn: RunFn<C>): MakeRunInputMutation<C>;
10
+ export declare function makeMakeRunInputMutation<C>(runFn: RunFn<C>): MakeRunInputMutation<C>;
11
11
  /**
12
12
  * Creates a `run` method to invoke a mutation resolver that uses the `input` convention.
13
13
  *
14
14
  * Following our `mutation / foo` conventions, `resolver` will have a single `fooResolver.foo` method.
15
15
  */
16
- type MakeRunInputMutation<C> = <T extends object>(resolver: T) => RunInputMutationMethod<C, T>;
16
+ export type MakeRunInputMutation<C> = <T extends object>(resolver: T) => RunInputMutationMethod<C, T>;
17
17
  type RunInputMutationMethod<C, T> = <I extends MutationInput<T>, R = ResolverResult<T, keyof T>>(ctx: C, input: I | (() => I)) => Promise<R>;
18
18
  /** Matches a mutation resolver that has a single `input` field. */
19
19
  type MutationInput<T> = T[keyof T] extends Resolver<any, {
20
20
  input: infer I;
21
21
  }, any> ? I : never;
22
22
  //#endregion
23
- export { MakeRunInputMutation, makeMakeRunInputMutation };
23
+ export {};
24
24
  //# sourceMappingURL=makeRunInputMutation.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunInputMutation.d.mts","names":[],"sources":["../src/makeRunInputMutation.ts"],"mappings":";;;;;;;;;iBASgB,yBAAyB,GAAG,OAAO,MAAM,KAAK,qBAAqB;;;;;;KAoBvE,qBAAqB,MAAM,kBAAkB,UAAU,MAAM,uBAAuB,GAAG;KAE9F,uBAAuB,GAAG,MAAM,UAAU,cAAc,IAAI,IAAI,eAAe,SAAS,IAC3F,KAAK,GACL,OAAO,WAAW,OACf,QAAQ;;KAGR,cAAc,KAAK,QAAQ,WAAW;EAAgB,aAAa;UAAY"}
1
+ {"version":3,"file":"makeRunInputMutation.d.mts","names":[],"sources":["../src/makeRunInputMutation.ts"],"mappings":";;;;;;;;;wBASgB,yBAAyB,GAAG,OAAO,MAAM,KAAK,qBAAqB;;;;;;YAoBvE,qBAAqB,MAAM,kBAAkB,UAAU,MAAM,uBAAuB,GAAG;KAE9F,uBAAuB,GAAG,MAAM,UAAU,cAAc,IAAI,IAAI,eAAe,SAAS,IAC3F,KAAK,GACL,OAAO,WAAW,OACf,QAAQ;;KAGR,cAAc,KAAK,QAAQ,WAAW;EAAgB,aAAa;UAAY"}
@@ -6,11 +6,11 @@ import { ResolverArgs, ResolverResult, ResolverRoot, RunFn } from "./typeUtils.c
6
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
7
  * that is customized (basically curried) to their own `newContext` function.
8
8
  */
9
- declare function makeMakeRunObjectField<C>(runFn: RunFn<C>): MakeRunObjectField<C>;
9
+ export declare function makeMakeRunObjectField<C>(runFn: RunFn<C>): MakeRunObjectField<C>;
10
10
  /** Creates a `run` method to invoke a single field resolver with that field's args. */
11
- type MakeRunObjectField<C> = <T extends object, R extends ResolverRoot<T>>(resolvers: T) => RunObjectFieldMethod<C, T, R>;
11
+ export type MakeRunObjectField<C> = <T extends object, R extends ResolverRoot<T>>(resolvers: T) => RunObjectFieldMethod<C, T, R>;
12
12
  /** The return type of `makeRunObject`. */
13
13
  type RunObjectFieldMethod<C, T, R> = <K extends keyof T, A extends ResolverArgs<T, K>>(ctx: C, root: R, key: K, args?: A | ((root: R) => A)) => Promise<ResolverResult<T, K>>;
14
14
  //#endregion
15
- export { MakeRunObjectField, makeMakeRunObjectField };
15
+ export {};
16
16
  //# sourceMappingURL=makeRunObjectField.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunObjectField.d.cts","names":[],"sources":["../src/makeRunObjectField.ts"],"mappings":";;;;;;;;iBAUgB,uBAAuB,GAAG,OAAO,MAAM,KAAK,mBAAmB;;KAYnE,mBAAmB,MAAM,kBAAkB,UAAU,aAAa,IAC5E,WAAW,MACR,qBAAqB,GAAG,GAAG;;KAG3B,qBAAqB,GAAG,GAAG,MAAM,gBAAgB,GAAG,UAAU,aAAa,GAAG,IACjF,KAAK,GACL,MAAM,GACN,KAAK,GAEL,OAAO,MAAM,MAAM,MAAM,OACtB,QAAQ,eAAe,GAAG"}
1
+ {"version":3,"file":"makeRunObjectField.d.cts","names":[],"sources":["../src/makeRunObjectField.ts"],"mappings":";;;;;;;;wBAUgB,uBAAuB,GAAG,OAAO,MAAM,KAAK,mBAAmB;;YAYnE,mBAAmB,MAAM,kBAAkB,UAAU,aAAa,IAC5E,WAAW,MACR,qBAAqB,GAAG,GAAG;;KAG3B,qBAAqB,GAAG,GAAG,MAAM,gBAAgB,GAAG,UAAU,aAAa,GAAG,IACjF,KAAK,GACL,MAAM,GACN,KAAK,GAEL,OAAO,MAAM,MAAM,MAAM,OACtB,QAAQ,eAAe,GAAG"}
@@ -6,11 +6,11 @@ import { ResolverArgs, ResolverResult, ResolverRoot, RunFn } from "./typeUtils.m
6
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
7
  * that is customized (basically curried) to their own `newContext` function.
8
8
  */
9
- declare function makeMakeRunObjectField<C>(runFn: RunFn<C>): MakeRunObjectField<C>;
9
+ export declare function makeMakeRunObjectField<C>(runFn: RunFn<C>): MakeRunObjectField<C>;
10
10
  /** Creates a `run` method to invoke a single field resolver with that field's args. */
11
- type MakeRunObjectField<C> = <T extends object, R extends ResolverRoot<T>>(resolvers: T) => RunObjectFieldMethod<C, T, R>;
11
+ export type MakeRunObjectField<C> = <T extends object, R extends ResolverRoot<T>>(resolvers: T) => RunObjectFieldMethod<C, T, R>;
12
12
  /** The return type of `makeRunObject`. */
13
13
  type RunObjectFieldMethod<C, T, R> = <K extends keyof T, A extends ResolverArgs<T, K>>(ctx: C, root: R, key: K, args?: A | ((root: R) => A)) => Promise<ResolverResult<T, K>>;
14
14
  //#endregion
15
- export { MakeRunObjectField, makeMakeRunObjectField };
15
+ export {};
16
16
  //# sourceMappingURL=makeRunObjectField.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunObjectField.d.mts","names":[],"sources":["../src/makeRunObjectField.ts"],"mappings":";;;;;;;;iBAUgB,uBAAuB,GAAG,OAAO,MAAM,KAAK,mBAAmB;;KAYnE,mBAAmB,MAAM,kBAAkB,UAAU,aAAa,IAC5E,WAAW,MACR,qBAAqB,GAAG,GAAG;;KAG3B,qBAAqB,GAAG,GAAG,MAAM,gBAAgB,GAAG,UAAU,aAAa,GAAG,IACjF,KAAK,GACL,MAAM,GACN,KAAK,GAEL,OAAO,MAAM,MAAM,MAAM,OACtB,QAAQ,eAAe,GAAG"}
1
+ {"version":3,"file":"makeRunObjectField.d.mts","names":[],"sources":["../src/makeRunObjectField.ts"],"mappings":";;;;;;;;wBAUgB,uBAAuB,GAAG,OAAO,MAAM,KAAK,mBAAmB;;YAYnE,mBAAmB,MAAM,kBAAkB,UAAU,aAAa,IAC5E,WAAW,MACR,qBAAqB,GAAG,GAAG;;KAG3B,qBAAqB,GAAG,GAAG,MAAM,gBAAgB,GAAG,UAAU,aAAa,GAAG,IACjF,KAAK,GACL,MAAM,GACN,KAAK,GAEL,OAAO,MAAM,MAAM,MAAM,OACtB,QAAQ,eAAe,GAAG"}
@@ -6,10 +6,10 @@ import { ResolverResult, ResolverRoot, RunFn } from "./typeUtils.cjs";
6
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
7
  * that is customized (basically curried) to their own `newContext` function.
8
8
  */
9
- declare function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C>;
9
+ export declare function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C>;
10
10
  /** Creates a `run` method that can invoke multiple fields against an object resolver. */
11
- type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;
11
+ export type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;
12
12
  type RunFieldsResolverMethod<C, T, R extends ResolverRoot<T>> = <K extends (keyof T)[]>(ctx: C, root: R, keys: K) => Promise<{ [k in K[number]]: ResolverResult<T, k>; }>;
13
13
  //#endregion
14
- export { MakeRunObjectFields, makeMakeRunObjectFields };
14
+ export {};
15
15
  //# sourceMappingURL=makeRunObjectFields.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunObjectFields.d.cts","names":[],"sources":["../src/makeRunObjectFields.ts"],"mappings":";;;;;;;;iBAUgB,wBAAwB,GAAG,GAAG,OAAO,MAAM,KAAK,oBAAoB;;KAgBxE,oBAAoB,MAAM,GAAG,UAAU,aAAa,IAAI,WAAW,MAAM,wBAAwB,GAAG,GAAG;KAG9G,wBAAwB,GAAG,GAAG,UAAU,aAAa,OAAO,iBAAiB,MAChF,KAAK,GACL,MAAM,GACN,MAAM,MACH,WAAW,KAAK,YAAY,eAAe,GAAG"}
1
+ {"version":3,"file":"makeRunObjectFields.d.cts","names":[],"sources":["../src/makeRunObjectFields.ts"],"mappings":";;;;;;;;wBAUgB,wBAAwB,GAAG,GAAG,OAAO,MAAM,KAAK,oBAAoB;;YAgBxE,oBAAoB,MAAM,GAAG,UAAU,aAAa,IAAI,WAAW,MAAM,wBAAwB,GAAG,GAAG;KAG9G,wBAAwB,GAAG,GAAG,UAAU,aAAa,OAAO,iBAAiB,MAChF,KAAK,GACL,MAAM,GACN,MAAM,MACH,WAAW,KAAK,YAAY,eAAe,GAAG"}
@@ -6,10 +6,10 @@ import { ResolverResult, ResolverRoot, RunFn } from "./typeUtils.mjs";
6
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
7
  * that is customized (basically curried) to their own `newContext` function.
8
8
  */
9
- declare function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C>;
9
+ export declare function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C>;
10
10
  /** Creates a `run` method that can invoke multiple fields against an object resolver. */
11
- type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;
11
+ export type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;
12
12
  type RunFieldsResolverMethod<C, T, R extends ResolverRoot<T>> = <K extends (keyof T)[]>(ctx: C, root: R, keys: K) => Promise<{ [k in K[number]]: ResolverResult<T, k>; }>;
13
13
  //#endregion
14
- export { MakeRunObjectFields, makeMakeRunObjectFields };
14
+ export {};
15
15
  //# sourceMappingURL=makeRunObjectFields.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunObjectFields.d.mts","names":[],"sources":["../src/makeRunObjectFields.ts"],"mappings":";;;;;;;;iBAUgB,wBAAwB,GAAG,GAAG,OAAO,MAAM,KAAK,oBAAoB;;KAgBxE,oBAAoB,MAAM,GAAG,UAAU,aAAa,IAAI,WAAW,MAAM,wBAAwB,GAAG,GAAG;KAG9G,wBAAwB,GAAG,GAAG,UAAU,aAAa,OAAO,iBAAiB,MAChF,KAAK,GACL,MAAM,GACN,MAAM,MACH,WAAW,KAAK,YAAY,eAAe,GAAG"}
1
+ {"version":3,"file":"makeRunObjectFields.d.mts","names":[],"sources":["../src/makeRunObjectFields.ts"],"mappings":";;;;;;;;wBAUgB,wBAAwB,GAAG,GAAG,OAAO,MAAM,KAAK,oBAAoB;;YAgBxE,oBAAoB,MAAM,GAAG,UAAU,aAAa,IAAI,WAAW,MAAM,wBAAwB,GAAG,GAAG;KAG9G,wBAAwB,GAAG,GAAG,UAAU,aAAa,OAAO,iBAAiB,MAChF,KAAK,GACL,MAAM,GACN,MAAM,MACH,WAAW,KAAK,YAAY,eAAe,GAAG"}
@@ -6,15 +6,15 @@ import { ResolverArgs, ResolverResult, RunFn } from "./typeUtils.cjs";
6
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
7
  * that is customized (basically curried) to their own `newContext` function.
8
8
  */
9
- declare function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C>;
9
+ export declare function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C>;
10
10
  /**
11
11
  * Creates a `run` method that invokes the query resolver's single query.
12
12
  *
13
13
  * Following our `query / foo` conventions, query resolver will have a single `fooResolver.foo` method.
14
14
  */
15
- type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;
15
+ export type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;
16
16
  /** The return type of `makeRunQuery`. */
17
17
  type RunQueryMethod<C, T> = <A extends ResolverArgs<T, keyof T>>(ctx: C, args?: A | (() => A)) => Promise<ResolverResult<T, keyof T>>;
18
18
  //#endregion
19
- export { MakeRunQuery, makeMakeRunQuery };
19
+ export {};
20
20
  //# sourceMappingURL=makeRunQuery.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunQuery.d.cts","names":[],"sources":["../src/makeRunQuery.ts"],"mappings":";;;;;;;;iBAQgB,iBAAiB,GAAG,OAAO,MAAM,KAAK,aAAa;;;;;;KAevD,aAAa,MAAM,kBAAkB,UAAU,MAAM,eAAe,GAAG;;KAG9E,eAAe,GAAG,MAAM,UAAU,aAAa,SAAS,IAC3D,KAAK,GAEL,OAAO,WAAW,OACf,QAAQ,eAAe,SAAS"}
1
+ {"version":3,"file":"makeRunQuery.d.cts","names":[],"sources":["../src/makeRunQuery.ts"],"mappings":";;;;;;;;wBAQgB,iBAAiB,GAAG,OAAO,MAAM,KAAK,aAAa;;;;;;YAevD,aAAa,MAAM,kBAAkB,UAAU,MAAM,eAAe,GAAG;;KAG9E,eAAe,GAAG,MAAM,UAAU,aAAa,SAAS,IAC3D,KAAK,GAEL,OAAO,WAAW,OACf,QAAQ,eAAe,SAAS"}
@@ -6,15 +6,15 @@ import { ResolverArgs, ResolverResult, RunFn } from "./typeUtils.mjs";
6
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
7
  * that is customized (basically curried) to their own `newContext` function.
8
8
  */
9
- declare function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C>;
9
+ export declare function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C>;
10
10
  /**
11
11
  * Creates a `run` method that invokes the query resolver's single query.
12
12
  *
13
13
  * Following our `query / foo` conventions, query resolver will have a single `fooResolver.foo` method.
14
14
  */
15
- type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;
15
+ export type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;
16
16
  /** The return type of `makeRunQuery`. */
17
17
  type RunQueryMethod<C, T> = <A extends ResolverArgs<T, keyof T>>(ctx: C, args?: A | (() => A)) => Promise<ResolverResult<T, keyof T>>;
18
18
  //#endregion
19
- export { MakeRunQuery, makeMakeRunQuery };
19
+ export {};
20
20
  //# sourceMappingURL=makeRunQuery.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunQuery.d.mts","names":[],"sources":["../src/makeRunQuery.ts"],"mappings":";;;;;;;;iBAQgB,iBAAiB,GAAG,OAAO,MAAM,KAAK,aAAa;;;;;;KAevD,aAAa,MAAM,kBAAkB,UAAU,MAAM,eAAe,GAAG;;KAG9E,eAAe,GAAG,MAAM,UAAU,aAAa,SAAS,IAC3D,KAAK,GAEL,OAAO,WAAW,OACf,QAAQ,eAAe,SAAS"}
1
+ {"version":3,"file":"makeRunQuery.d.mts","names":[],"sources":["../src/makeRunQuery.ts"],"mappings":";;;;;;;;wBAQgB,iBAAiB,GAAG,OAAO,MAAM,KAAK,aAAa;;;;;;YAevD,aAAa,MAAM,kBAAkB,UAAU,MAAM,eAAe,GAAG;;KAG9E,eAAe,GAAG,MAAM,UAAU,aAAa,SAAS,IAC3D,KAAK,GAEL,OAAO,WAAW,OACf,QAAQ,eAAe,SAAS"}
@@ -1,17 +1,16 @@
1
1
  import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, QueryJoinList, TableFor } from "joist-core";
2
2
  //#region src/paginationUtils.d.ts
3
- type ContextWithEm = {
3
+ export type ContextWithEm = {
4
4
  em: EntityManager;
5
5
  };
6
- type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
7
- type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
6
+ export type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
7
+ export type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
8
8
  readonly id: EntityColumn<T, never, string>;
9
9
  }, QueryJoinList>;
10
- declare const defaultLimit = 100;
10
+ export declare const defaultLimit = 100;
11
11
  /** Executes an entity selection after pagination has been applied. */
12
- declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
12
+ export declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
13
13
  /** Counts the unpaginated rows, preserving distinct, grouping, and join semantics. */
14
- declare function countQuery<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<number>;
14
+ export declare function countQuery<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<number>;
15
15
  //#endregion
16
- export { ContextWithEm, PaginationFilter, PaginationQuery, countQuery, defaultLimit, queryEntities };
17
16
  //# sourceMappingURL=paginationUtils.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paginationUtils.d.cts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;KAYY;EAAkB,IAAI;;KACtB,iBAAiB,UAAU,UAAU,uBAAuB;KAC5D,gBAAgB,UAAU,UAAU,MAC9C,SAAS;WAAgB,IAAI,aAAa;GAC1C;cAGW;;iBAGG,cAAc,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK,QAAQ;;iBAMjF,WAAW,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK"}
1
+ {"version":3,"file":"paginationUtils.d.cts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;YAYY;EAAkB,IAAI;;YACtB,iBAAiB,UAAU,UAAU,uBAAuB;YAC5D,gBAAgB,UAAU,UAAU,MAC9C,SAAS;WAAgB,IAAI,aAAa;GAC1C;qBAGW;;wBAGG,cAAc,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK,QAAQ;;wBAMjF,WAAW,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK"}
@@ -1,17 +1,16 @@
1
1
  import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, QueryJoinList, TableFor } from "joist-core";
2
2
  //#region src/paginationUtils.d.ts
3
- type ContextWithEm = {
3
+ export type ContextWithEm = {
4
4
  em: EntityManager;
5
5
  };
6
- type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
7
- type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
6
+ export type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
7
+ export type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
8
8
  readonly id: EntityColumn<T, never, string>;
9
9
  }, QueryJoinList>;
10
- declare const defaultLimit = 100;
10
+ export declare const defaultLimit = 100;
11
11
  /** Executes an entity selection after pagination has been applied. */
12
- declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
12
+ export declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
13
13
  /** Counts the unpaginated rows, preserving distinct, grouping, and join semantics. */
14
- declare function countQuery<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<number>;
14
+ export declare function countQuery<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<number>;
15
15
  //#endregion
16
- export { ContextWithEm, PaginationFilter, PaginationQuery, countQuery, defaultLimit, queryEntities };
17
16
  //# sourceMappingURL=paginationUtils.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paginationUtils.d.mts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;KAYY;EAAkB,IAAI;;KACtB,iBAAiB,UAAU,UAAU,uBAAuB;KAC5D,gBAAgB,UAAU,UAAU,MAC9C,SAAS;WAAgB,IAAI,aAAa;GAC1C;cAGW;;iBAGG,cAAc,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK,QAAQ;;iBAMjF,WAAW,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK"}
1
+ {"version":3,"file":"paginationUtils.d.mts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;YAYY;EAAkB,IAAI;;YACtB,iBAAiB,UAAU,UAAU,uBAAuB;YAC5D,gBAAgB,UAAU,UAAU,MAC9C,SAAS;WAAgB,IAAI,aAAa;GAC1C;qBAGW;;wBAGG,cAAc,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK,QAAQ;;wBAMjF,WAAW,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK"}
@@ -2,14 +2,13 @@ import { DeepPartialOrNull, Entity, EntityConstructor, OptsOf } from "joist-core
2
2
  import { Context } from "joist-test-utils";
3
3
  //#region src/saveEntity.d.ts
4
4
  /** Given an GraphQL input, creates-or-updates an entity of `type`. */
5
- declare function saveEntity<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: DeepPartialOrNull<T>, opts?: {
5
+ export declare function saveEntity<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: DeepPartialOrNull<T>, opts?: {
6
6
  flush?: boolean;
7
7
  }): Promise<T>;
8
8
  /** Given GraphQL inputs, creates-or-updates multiple entities of `type`. */
9
- declare function saveEntities<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: readonly DeepPartialOrNull<T>[], opts?: {
9
+ export declare function saveEntities<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: readonly DeepPartialOrNull<T>[], opts?: {
10
10
  flush?: boolean;
11
11
  opts?: Partial<OptsOf<T>>;
12
12
  }): Promise<T[]>;
13
13
  //#endregion
14
- export { saveEntities, saveEntity };
15
14
  //# sourceMappingURL=saveEntity.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveEntity.d.cts","names":[],"sources":["../src/saveEntity.ts"],"mappings":";;;;iBAUsB,WAAW,UAAU,QACzC,KAAK,SACL,MAAM,kBAAkB,IACxB,OAAO,kBAAkB,IACzB;EAAQ;IACP,QAAQ;;iBAKW,aAAa,UAAU,QAC3C,KAAK,SACL,MAAM,kBAAkB,IACxB,gBAAgB,kBAAkB,MAClC;EAAQ;EAAiB,OAAO,QAAQ,OAAO;IAC9C,QAAQ"}
1
+ {"version":3,"file":"saveEntity.d.cts","names":[],"sources":["../src/saveEntity.ts"],"mappings":";;;;wBAUsB,WAAW,UAAU,QACzC,KAAK,SACL,MAAM,kBAAkB,IACxB,OAAO,kBAAkB,IACzB;EAAQ;IACP,QAAQ;;wBAKW,aAAa,UAAU,QAC3C,KAAK,SACL,MAAM,kBAAkB,IACxB,gBAAgB,kBAAkB,MAClC;EAAQ;EAAiB,OAAO,QAAQ,OAAO;IAC9C,QAAQ"}
@@ -2,14 +2,13 @@ import { DeepPartialOrNull, Entity, EntityConstructor, OptsOf } from "joist-core
2
2
  import { Context } from "joist-test-utils";
3
3
  //#region src/saveEntity.d.ts
4
4
  /** Given an GraphQL input, creates-or-updates an entity of `type`. */
5
- declare function saveEntity<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: DeepPartialOrNull<T>, opts?: {
5
+ export declare function saveEntity<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: DeepPartialOrNull<T>, opts?: {
6
6
  flush?: boolean;
7
7
  }): Promise<T>;
8
8
  /** Given GraphQL inputs, creates-or-updates multiple entities of `type`. */
9
- declare function saveEntities<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: readonly DeepPartialOrNull<T>[], opts?: {
9
+ export declare function saveEntities<T extends Entity>(ctx: Context, type: EntityConstructor<T>, input: readonly DeepPartialOrNull<T>[], opts?: {
10
10
  flush?: boolean;
11
11
  opts?: Partial<OptsOf<T>>;
12
12
  }): Promise<T[]>;
13
13
  //#endregion
14
- export { saveEntities, saveEntity };
15
14
  //# sourceMappingURL=saveEntity.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveEntity.d.mts","names":[],"sources":["../src/saveEntity.ts"],"mappings":";;;;iBAUsB,WAAW,UAAU,QACzC,KAAK,SACL,MAAM,kBAAkB,IACxB,OAAO,kBAAkB,IACzB;EAAQ;IACP,QAAQ;;iBAKW,aAAa,UAAU,QAC3C,KAAK,SACL,MAAM,kBAAkB,IACxB,gBAAgB,kBAAkB,MAClC;EAAQ;EAAiB,OAAO,QAAQ,OAAO;IAC9C,QAAQ"}
1
+ {"version":3,"file":"saveEntity.d.mts","names":[],"sources":["../src/saveEntity.ts"],"mappings":";;;;wBAUsB,WAAW,UAAU,QACzC,KAAK,SACL,MAAM,kBAAkB,IACxB,OAAO,kBAAkB,IACzB;EAAQ;IACP,QAAQ;;wBAKW,aAAa,UAAU,QAC3C,KAAK,SACL,MAAM,kBAAkB,IACxB,gBAAgB,kBAAkB,MAClC;EAAQ;EAAiB,OAAO,QAAQ,OAAO;IAC9C,QAAQ"}
@@ -1,11 +1,10 @@
1
1
  import { Resolver } from "./context.cjs";
2
2
  //#region src/typeUtils.d.ts
3
- type RunFn<C> = <T>(ctx: C, fn: (ctx: C) => Promise<T>) => Promise<T>;
3
+ export type RunFn<C> = <T>(ctx: C, fn: (ctx: C) => Promise<T>) => Promise<T>;
4
4
  /** Infers the root type of the given resolver, by assuming it's always the first arg. */
5
- type ResolverRoot<T> = T extends { [key in keyof T]: infer F; } ? F extends Resolver<infer R, any, any> ? R : never : never;
6
- type ResolverArgs<T, K extends keyof T> = T[K] extends Resolver<any, infer U, any> ? U : never;
5
+ export type ResolverRoot<T> = T extends { [key in keyof T]: infer F; } ? F extends Resolver<infer R, any, any> ? R : never : never;
6
+ export type ResolverArgs<T, K extends keyof T> = T[K] extends Resolver<any, infer U, any> ? U : never;
7
7
  /** Infers the return type of key `K` in the resolver object `T`. */
8
- type ResolverResult<T, K extends keyof T> = T[K] extends Resolver<any, any, infer U> ? U : never;
8
+ export type ResolverResult<T, K extends keyof T> = T[K] extends Resolver<any, any, infer U> ? U : never;
9
9
  //#endregion
10
- export { ResolverArgs, ResolverResult, ResolverRoot, RunFn };
11
10
  //# sourceMappingURL=typeUtils.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeUtils.d.cts","names":[],"sources":["../src/typeUtils.ts"],"mappings":";;KAEY,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,KAAK,MAAM,QAAQ,OAAO,QAAQ;;KAG9D,aAAa,KAAK,aAAa,aAAa,UAAU,OAC9D,UAAU,eAAe,eACvB;KAIM,aAAa,GAAG,gBAAgB,KAAK,EAAE,WAAW,oBAAoB,UAAU;;KAGhF,eAAe,GAAG,gBAAgB,KAAK,EAAE,WAAW,yBAAyB,KAAK"}
1
+ {"version":3,"file":"typeUtils.d.cts","names":[],"sources":["../src/typeUtils.ts"],"mappings":";;YAEY,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,KAAK,MAAM,QAAQ,OAAO,QAAQ;;YAG9D,aAAa,KAAK,aAAa,aAAa,UAAU,OAC9D,UAAU,eAAe,eACvB;YAIM,aAAa,GAAG,gBAAgB,KAAK,EAAE,WAAW,oBAAoB,UAAU;;YAGhF,eAAe,GAAG,gBAAgB,KAAK,EAAE,WAAW,yBAAyB,KAAK"}
@@ -1,11 +1,10 @@
1
1
  import { Resolver } from "./context.mjs";
2
2
  //#region src/typeUtils.d.ts
3
- type RunFn<C> = <T>(ctx: C, fn: (ctx: C) => Promise<T>) => Promise<T>;
3
+ export type RunFn<C> = <T>(ctx: C, fn: (ctx: C) => Promise<T>) => Promise<T>;
4
4
  /** Infers the root type of the given resolver, by assuming it's always the first arg. */
5
- type ResolverRoot<T> = T extends { [key in keyof T]: infer F; } ? F extends Resolver<infer R, any, any> ? R : never : never;
6
- type ResolverArgs<T, K extends keyof T> = T[K] extends Resolver<any, infer U, any> ? U : never;
5
+ export type ResolverRoot<T> = T extends { [key in keyof T]: infer F; } ? F extends Resolver<infer R, any, any> ? R : never : never;
6
+ export type ResolverArgs<T, K extends keyof T> = T[K] extends Resolver<any, infer U, any> ? U : never;
7
7
  /** Infers the return type of key `K` in the resolver object `T`. */
8
- type ResolverResult<T, K extends keyof T> = T[K] extends Resolver<any, any, infer U> ? U : never;
8
+ export type ResolverResult<T, K extends keyof T> = T[K] extends Resolver<any, any, infer U> ? U : never;
9
9
  //#endregion
10
- export { ResolverArgs, ResolverResult, ResolverRoot, RunFn };
11
10
  //# sourceMappingURL=typeUtils.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeUtils.d.mts","names":[],"sources":["../src/typeUtils.ts"],"mappings":";;KAEY,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,KAAK,MAAM,QAAQ,OAAO,QAAQ;;KAG9D,aAAa,KAAK,aAAa,aAAa,UAAU,OAC9D,UAAU,eAAe,eACvB;KAIM,aAAa,GAAG,gBAAgB,KAAK,EAAE,WAAW,oBAAoB,UAAU;;KAGhF,eAAe,GAAG,gBAAgB,KAAK,EAAE,WAAW,yBAAyB,KAAK"}
1
+ {"version":3,"file":"typeUtils.d.mts","names":[],"sources":["../src/typeUtils.ts"],"mappings":";;YAEY,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,KAAK,MAAM,QAAQ,OAAO,QAAQ;;YAG9D,aAAa,KAAK,aAAa,aAAa,UAAU,OAC9D,UAAU,eAAe,eACvB;YAIM,aAAa,GAAG,gBAAgB,KAAK,EAAE,WAAW,oBAAoB,UAAU;;YAGhF,eAAe,GAAG,gBAAgB,KAAK,EAAE,WAAW,yBAAyB,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joist-graphql-resolver-utils",
3
- "version": "2.4.0-next.5",
3
+ "version": "2.4.0-next.50",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -84,17 +84,17 @@
84
84
  "build"
85
85
  ],
86
86
  "peerDependencies": {
87
- "joist-core": "2.4.0-next.5",
88
- "joist-test-utils": "2.4.0-next.5"
87
+ "joist-core": "2.4.0-next.50",
88
+ "joist-test-utils": "2.4.0-next.50"
89
89
  },
90
90
  "dependencies": {
91
91
  "graphql": "^17.0.2"
92
92
  },
93
93
  "devDependencies": {
94
- "@swc/core": "^1.16.1",
94
+ "@swc/core": "1.16.18",
95
95
  "@swc/jest": "^0.2.39",
96
96
  "@types/jest": "^30.0.0",
97
- "@types/node": "^26.2.0",
97
+ "@types/node": "^26.6.5",
98
98
  "jest": "30.4.2",
99
99
  "tsconfig-paths": "^4.2.0",
100
100
  "typescript": "7.0.2"