joist-graphql-resolver-utils 2.3.0-next.100 → 2.3.0-next.101
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginationUtils.cjs","names":["query"],"sources":["../src/paginationUtils.ts"],"sourcesContent":["import {\n type Entity,\n type EntityColumn,\n type EntityManager,\n type ExprLike,\n type GraphQLFilterWithAlias,\n type Query,\n type TableFor,\n query,\n} from \"joist-core\";\n\nexport type ContextWithEm = { em: EntityManager };\nexport type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;\nexport type PaginationQuery<T extends Entity> = Query
|
|
1
|
+
{"version":3,"file":"paginationUtils.cjs","names":["query"],"sources":["../src/paginationUtils.ts"],"sourcesContent":["import {\n type Entity,\n type EntityColumn,\n type EntityManager,\n type ExprLike,\n type GraphQLFilterWithAlias,\n type Query,\n type QueryJoinList,\n type TableFor,\n query,\n} from \"joist-core\";\n\nexport type ContextWithEm = { em: EntityManager };\nexport type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;\nexport type PaginationQuery<T extends Entity> = Query<\n TableFor<T> & { readonly id: EntityColumn<T, never, string> },\n QueryJoinList\n>;\n\nexport const defaultLimit = 100;\n\n/** Executes an entity selection after pagination has been applied. */\nexport function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]> {\n // Widen the phantom entity type so em.query can resolve its conditional scope checks.\n return ctx.em.query(base as PaginationQuery<Entity>) as Promise<T[]>;\n}\n\n/** Counts the unpaginated rows, preserving distinct, grouping, and join semantics. */\nexport async function countQuery<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<number> {\n const select: { id: EntityColumn<T, never, string> } & Record<string, ExprLike<unknown>> = { id: base.select.id };\n // Keep references from expression ordering so removing ORDER BY does not prune a join.\n // I.e. ordering Authors by Book title must still count the joined Author/Book rows.\n if (Array.isArray(base.orderBy)) {\n for (const [index, order] of base.orderBy.entries()) {\n const sort = order?.sort;\n if (typeof sort === \"object\" && sort !== null && order.order !== undefined) select[`order${index}`] = sort;\n }\n }\n const rows = query({ ...base, select, orderBy: undefined, limit: undefined, offset: undefined });\n const [result] = await ctx.em.query({ from: rows, select: { count: rows.id.count() } });\n return result.count;\n}\n"],"mappings":";;;AAmBA,MAAa,eAAe;;AAG5B,SAAgB,cAAgC,KAAoB,MAAwC;CAE1G,OAAO,IAAI,GAAG,MAAM,IAA+B;AACrD;;AAGA,eAAsB,WAA6B,KAAoB,MAA2C;CAChH,MAAM,SAAqF,EAAE,IAAI,KAAK,OAAO,GAAG;CAGhH,IAAI,MAAM,QAAQ,KAAK,OAAO,GAC5B,KAAK,MAAM,CAAC,OAAO,UAAU,KAAK,QAAQ,QAAQ,GAAG;EACnD,MAAM,OAAO,OAAO;EACpB,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,UAAU,KAAA,GAAW,OAAO,QAAQ,WAAW;CACxG;CAEF,MAAM,QAAA,GAAOA,WAAAA,MAAAA,CAAM;EAAE,GAAG;EAAM;EAAQ,SAAS,KAAA;EAAW,OAAO,KAAA;EAAW,QAAQ,KAAA;CAAU,CAAC;CAC/F,MAAM,CAAC,UAAU,MAAM,IAAI,GAAG,MAAM;EAAE,MAAM;EAAM,QAAQ,EAAE,OAAO,KAAK,GAAG,MAAM,EAAE;CAAE,CAAC;CACtF,OAAO,OAAO;AAChB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, TableFor } from "joist-core";
|
|
1
|
+
import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, QueryJoinList, TableFor } from "joist-core";
|
|
2
2
|
//#region src/paginationUtils.d.ts
|
|
3
3
|
type ContextWithEm = {
|
|
4
4
|
em: EntityManager;
|
|
@@ -6,7 +6,7 @@ type ContextWithEm = {
|
|
|
6
6
|
type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
|
|
7
7
|
type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
|
|
8
8
|
readonly id: EntityColumn<T, never, string>;
|
|
9
|
-
}>;
|
|
9
|
+
}, QueryJoinList>;
|
|
10
10
|
declare const defaultLimit = 100;
|
|
11
11
|
/** Executes an entity selection after pagination has been applied. */
|
|
12
12
|
declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginationUtils.d.cts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, TableFor } from "joist-core";
|
|
1
|
+
import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, QueryJoinList, TableFor } from "joist-core";
|
|
2
2
|
//#region src/paginationUtils.d.ts
|
|
3
3
|
type ContextWithEm = {
|
|
4
4
|
em: EntityManager;
|
|
@@ -6,7 +6,7 @@ type ContextWithEm = {
|
|
|
6
6
|
type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
|
|
7
7
|
type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
|
|
8
8
|
readonly id: EntityColumn<T, never, string>;
|
|
9
|
-
}>;
|
|
9
|
+
}, QueryJoinList>;
|
|
10
10
|
declare const defaultLimit = 100;
|
|
11
11
|
/** Executes an entity selection after pagination has been applied. */
|
|
12
12
|
declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginationUtils.d.mts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginationUtils.js","names":[],"sources":["../src/paginationUtils.ts"],"sourcesContent":["import {\n type Entity,\n type EntityColumn,\n type EntityManager,\n type ExprLike,\n type GraphQLFilterWithAlias,\n type Query,\n type TableFor,\n query,\n} from \"joist-core\";\n\nexport type ContextWithEm = { em: EntityManager };\nexport type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;\nexport type PaginationQuery<T extends Entity> = Query
|
|
1
|
+
{"version":3,"file":"paginationUtils.js","names":[],"sources":["../src/paginationUtils.ts"],"sourcesContent":["import {\n type Entity,\n type EntityColumn,\n type EntityManager,\n type ExprLike,\n type GraphQLFilterWithAlias,\n type Query,\n type QueryJoinList,\n type TableFor,\n query,\n} from \"joist-core\";\n\nexport type ContextWithEm = { em: EntityManager };\nexport type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;\nexport type PaginationQuery<T extends Entity> = Query<\n TableFor<T> & { readonly id: EntityColumn<T, never, string> },\n QueryJoinList\n>;\n\nexport const defaultLimit = 100;\n\n/** Executes an entity selection after pagination has been applied. */\nexport function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]> {\n // Widen the phantom entity type so em.query can resolve its conditional scope checks.\n return ctx.em.query(base as PaginationQuery<Entity>) as Promise<T[]>;\n}\n\n/** Counts the unpaginated rows, preserving distinct, grouping, and join semantics. */\nexport async function countQuery<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<number> {\n const select: { id: EntityColumn<T, never, string> } & Record<string, ExprLike<unknown>> = { id: base.select.id };\n // Keep references from expression ordering so removing ORDER BY does not prune a join.\n // I.e. ordering Authors by Book title must still count the joined Author/Book rows.\n if (Array.isArray(base.orderBy)) {\n for (const [index, order] of base.orderBy.entries()) {\n const sort = order?.sort;\n if (typeof sort === \"object\" && sort !== null && order.order !== undefined) select[`order${index}`] = sort;\n }\n }\n const rows = query({ ...base, select, orderBy: undefined, limit: undefined, offset: undefined });\n const [result] = await ctx.em.query({ from: rows, select: { count: rows.id.count() } });\n return result.count;\n}\n"],"mappings":";;AAmBA,MAAa,eAAe;;AAG5B,SAAgB,cAAgC,KAAoB,MAAwC;CAE1G,OAAO,IAAI,GAAG,MAAM,IAA+B;AACrD;;AAGA,eAAsB,WAA6B,KAAoB,MAA2C;CAChH,MAAM,SAAqF,EAAE,IAAI,KAAK,OAAO,GAAG;CAGhH,IAAI,MAAM,QAAQ,KAAK,OAAO,GAC5B,KAAK,MAAM,CAAC,OAAO,UAAU,KAAK,QAAQ,QAAQ,GAAG;EACnD,MAAM,OAAO,OAAO;EACpB,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,UAAU,KAAA,GAAW,OAAO,QAAQ,WAAW;CACxG;CAEF,MAAM,OAAO,MAAM;EAAE,GAAG;EAAM;EAAQ,SAAS,KAAA;EAAW,OAAO,KAAA;EAAW,QAAQ,KAAA;CAAU,CAAC;CAC/F,MAAM,CAAC,UAAU,MAAM,IAAI,GAAG,MAAM;EAAE,MAAM;EAAM,QAAQ,EAAE,OAAO,KAAK,GAAG,MAAM,EAAE;CAAE,CAAC;CACtF,OAAO,OAAO;AAChB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joist-graphql-resolver-utils",
|
|
3
|
-
"version": "2.3.0-next.
|
|
3
|
+
"version": "2.3.0-next.101",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"build"
|
|
85
85
|
],
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"joist-core": "2.3.0-next.
|
|
88
|
-
"joist-test-utils": "2.3.0-next.
|
|
87
|
+
"joist-core": "2.3.0-next.101",
|
|
88
|
+
"joist-test-utils": "2.3.0-next.101"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"graphql": "^17.0.2"
|