joist-graphql-resolver-utils 2.3.0-next.9 → 2.3.0-next.91

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 (129) hide show
  1. package/build/context.cjs +2 -0
  2. package/build/context.d.cts +7 -0
  3. package/build/context.d.cts.map +1 -0
  4. package/build/context.d.mts +7 -0
  5. package/build/context.d.mts.map +1 -0
  6. package/build/context.js +2 -3
  7. package/build/cursorPagination.cjs +110 -0
  8. package/build/cursorPagination.cjs.map +1 -0
  9. package/build/cursorPagination.d.cts +43 -0
  10. package/build/cursorPagination.d.cts.map +1 -0
  11. package/build/cursorPagination.d.mts +43 -0
  12. package/build/cursorPagination.d.mts.map +1 -0
  13. package/build/cursorPagination.js +94 -62
  14. package/build/cursorPagination.js.map +1 -1
  15. package/build/entityResolver.cjs +95 -0
  16. package/build/entityResolver.cjs.map +1 -0
  17. package/build/entityResolver.d.cts +23 -0
  18. package/build/entityResolver.d.cts.map +1 -0
  19. package/build/entityResolver.d.mts +23 -0
  20. package/build/entityResolver.d.mts.map +1 -0
  21. package/build/entityResolver.js +84 -135
  22. package/build/entityResolver.js.map +1 -1
  23. package/build/hint.cjs +50 -0
  24. package/build/hint.cjs.map +1 -0
  25. package/build/hint.d.cts +12 -0
  26. package/build/hint.d.cts.map +1 -0
  27. package/build/hint.d.mts +12 -0
  28. package/build/hint.d.mts.map +1 -0
  29. package/build/hint.js +36 -65
  30. package/build/hint.js.map +1 -1
  31. package/build/index.cjs +14 -0
  32. package/build/index.d.cts +6 -0
  33. package/build/index.d.mts +6 -0
  34. package/build/index.js +6 -17
  35. package/build/limitPagination.cjs +68 -0
  36. package/build/limitPagination.cjs.map +1 -0
  37. package/build/limitPagination.d.cts +34 -0
  38. package/build/limitPagination.d.cts.map +1 -0
  39. package/build/limitPagination.d.mts +34 -0
  40. package/build/limitPagination.d.mts.map +1 -0
  41. package/build/limitPagination.js +62 -52
  42. package/build/limitPagination.js.map +1 -1
  43. package/build/makeRunInputMutation.cjs +21 -0
  44. package/build/makeRunInputMutation.cjs.map +1 -0
  45. package/build/{makeRunInputMutation.d.ts → makeRunInputMutation.d.cts} +9 -7
  46. package/build/makeRunInputMutation.d.cts.map +1 -0
  47. package/build/makeRunInputMutation.d.mts +24 -0
  48. package/build/makeRunInputMutation.d.mts.map +1 -0
  49. package/build/makeRunInputMutation.js +16 -14
  50. package/build/makeRunInputMutation.js.map +1 -1
  51. package/build/makeRunObjectField.cjs +22 -0
  52. package/build/makeRunObjectField.cjs.map +1 -0
  53. package/build/{makeRunObjectField.d.ts → makeRunObjectField.d.cts} +7 -5
  54. package/build/makeRunObjectField.d.cts.map +1 -0
  55. package/build/makeRunObjectField.d.mts +16 -0
  56. package/build/makeRunObjectField.d.mts.map +1 -0
  57. package/build/makeRunObjectField.js +17 -16
  58. package/build/makeRunObjectField.js.map +1 -1
  59. package/build/makeRunObjectFields.cjs +24 -0
  60. package/build/makeRunObjectFields.cjs.map +1 -0
  61. package/build/{makeRunObjectFields.d.ts → makeRunObjectFields.d.cts} +8 -8
  62. package/build/makeRunObjectFields.d.cts.map +1 -0
  63. package/build/makeRunObjectFields.d.mts +15 -0
  64. package/build/makeRunObjectFields.d.mts.map +1 -0
  65. package/build/makeRunObjectFields.js +19 -19
  66. package/build/makeRunObjectFields.js.map +1 -1
  67. package/build/makeRunQuery.cjs +20 -0
  68. package/build/makeRunQuery.cjs.map +1 -0
  69. package/build/{makeRunQuery.d.ts → makeRunQuery.d.cts} +7 -5
  70. package/build/makeRunQuery.d.cts.map +1 -0
  71. package/build/makeRunQuery.d.mts +20 -0
  72. package/build/makeRunQuery.d.mts.map +1 -0
  73. package/build/makeRunQuery.js +15 -14
  74. package/build/makeRunQuery.js.map +1 -1
  75. package/build/paginationUtils.cjs +34 -0
  76. package/build/paginationUtils.cjs.map +1 -0
  77. package/build/paginationUtils.d.cts +17 -0
  78. package/build/paginationUtils.d.cts.map +1 -0
  79. package/build/paginationUtils.d.mts +17 -0
  80. package/build/paginationUtils.d.mts.map +1 -0
  81. package/build/paginationUtils.js +30 -4
  82. package/build/paginationUtils.js.map +1 -1
  83. package/build/saveEntity.cjs +24 -0
  84. package/build/saveEntity.cjs.map +1 -0
  85. package/build/saveEntity.d.cts +15 -0
  86. package/build/saveEntity.d.cts.map +1 -0
  87. package/build/saveEntity.d.mts +15 -0
  88. package/build/saveEntity.d.mts.map +1 -0
  89. package/build/saveEntity.js +15 -13
  90. package/build/saveEntity.js.map +1 -1
  91. package/build/tests.cjs +9 -0
  92. package/build/tests.d.cts +6 -0
  93. package/build/tests.d.mts +6 -0
  94. package/build/tests.js +5 -27
  95. package/build/typeUtils.cjs +2 -0
  96. package/build/typeUtils.d.cts +11 -0
  97. package/build/typeUtils.d.cts.map +1 -0
  98. package/build/typeUtils.d.mts +11 -0
  99. package/build/typeUtils.d.mts.map +1 -0
  100. package/build/typeUtils.js +2 -3
  101. package/package.json +74 -16
  102. package/build/context.d.ts +0 -4
  103. package/build/context.d.ts.map +0 -1
  104. package/build/context.js.map +0 -1
  105. package/build/cursorPagination.d.ts +0 -33
  106. package/build/cursorPagination.d.ts.map +0 -1
  107. package/build/entityResolver.d.ts +0 -25
  108. package/build/entityResolver.d.ts.map +0 -1
  109. package/build/hint.d.ts +0 -9
  110. package/build/hint.d.ts.map +0 -1
  111. package/build/index.d.ts +0 -6
  112. package/build/index.d.ts.map +0 -1
  113. package/build/index.js.map +0 -1
  114. package/build/limitPagination.d.ts +0 -28
  115. package/build/limitPagination.d.ts.map +0 -1
  116. package/build/makeRunInputMutation.d.ts.map +0 -1
  117. package/build/makeRunObjectField.d.ts.map +0 -1
  118. package/build/makeRunObjectFields.d.ts.map +0 -1
  119. package/build/makeRunQuery.d.ts.map +0 -1
  120. package/build/paginationUtils.d.ts +0 -7
  121. package/build/paginationUtils.d.ts.map +0 -1
  122. package/build/saveEntity.d.ts +0 -12
  123. package/build/saveEntity.d.ts.map +0 -1
  124. package/build/tests.d.ts +0 -6
  125. package/build/tests.d.ts.map +0 -1
  126. package/build/tests.js.map +0 -1
  127. package/build/typeUtils.d.ts +0 -10
  128. package/build/typeUtils.d.ts.map +0 -1
  129. package/build/typeUtils.js.map +0 -1
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./typeUtils.cjs");
3
+ let joist_core = require("joist-core");
4
+ //#region src/makeRunObjectFields.ts
5
+ /**
6
+ * Creates a `makeRunObjectFields` function for each project's `testUtils` file.
7
+ *
8
+ * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
9
+ * that is customized (basically curried) to their own `newContext` function.
10
+ */
11
+ function makeMakeRunObjectFields(runFn) {
12
+ return (resolver) => {
13
+ return (ctx, root, fields) => {
14
+ return runFn(ctx, async (ctx) => {
15
+ const _root = (0, joist_core.isEntity)(root) ? await ctx.em.load(root.id) : root;
16
+ return Object.fromEntries(await Promise.all(fields.map(async (key) => [key, await resolver[key](_root, {}, ctx, void 0)])));
17
+ });
18
+ };
19
+ };
20
+ }
21
+ //#endregion
22
+ exports.makeMakeRunObjectFields = makeMakeRunObjectFields;
23
+
24
+ //# sourceMappingURL=makeRunObjectFields.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeRunObjectFields.cjs","names":["isEntity"],"sources":["../src/makeRunObjectFields.ts"],"sourcesContent":["import { isEntity } from \"joist-core\";\n\nimport { type ResolverResult, type ResolverRoot, type RunFn } from \"./typeUtils.ts\";\n\n/**\n * Creates a `makeRunObjectFields` function for each project's `testUtils` file.\n *\n * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory\n * that is customized (basically curried) to their own `newContext` function.\n */\nexport function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C> {\n return (resolver) => {\n return (ctx, root, fields) => {\n return runFn(ctx, async (ctx) => {\n // Sneak in a Joist-ism that will load the entity in the new em\n const _root = isEntity(root) ? await (ctx as any).em.load((root as any).id) : root;\n // Build a result with each key, where fields might return a promise, so we `await` to make assertions easier\n return Object.fromEntries(\n await Promise.all(fields.map(async (key) => [key, await (resolver[key] as any)(_root, {}, ctx, undefined!)])),\n );\n });\n };\n };\n}\n\n/** Creates a `run` method that can invoke multiple fields against an object resolver. */\nexport type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;\n\n// The return type for makeRunResolverKeys\ntype RunFieldsResolverMethod<C, T, R extends ResolverRoot<T>> = <K extends (keyof T)[]>(\n ctx: C,\n root: R,\n keys: K,\n) => Promise<{ [k in K[number]]: ResolverResult<T, k> }>;\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,wBAA8B,OAAyC;CACrF,QAAQ,aAAa;EACnB,QAAQ,KAAK,MAAM,WAAW;GAC5B,OAAO,MAAM,KAAK,OAAO,QAAQ;IAE/B,MAAM,SAAA,GAAQA,WAAAA,SAAAA,CAAS,IAAI,IAAI,MAAO,IAAY,GAAG,KAAM,KAAa,EAAE,IAAI;IAE9E,OAAO,OAAO,YACZ,MAAM,QAAQ,IAAI,OAAO,IAAI,OAAO,QAAQ,CAAC,KAAK,MAAO,SAAS,IAAI,CAAS,OAAO,CAAC,GAAG,KAAK,KAAA,CAAU,CAAC,CAAC,CAAC,CAC9G;GACF,CAAC;EACH;CACF;AACF"}
@@ -1,15 +1,15 @@
1
- import { ResolverResult, ResolverRoot, RunFn } from "./typeUtils";
1
+ import { ResolverResult, ResolverRoot, RunFn } from "./typeUtils.cjs";
2
+ //#region src/makeRunObjectFields.d.ts
2
3
  /**
3
4
  * Creates a `makeRunObjectFields` function for each project's `testUtils` file.
4
5
  *
5
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
6
7
  * that is customized (basically curried) to their own `newContext` function.
7
8
  */
8
- export declare function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C>;
9
+ declare function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C>;
9
10
  /** Creates a `run` method that can invoke multiple fields against an object resolver. */
10
- export type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;
11
- type RunFieldsResolverMethod<C, T, R extends ResolverRoot<T>> = <K extends (keyof T)[]>(ctx: C, root: R, keys: K) => Promise<{
12
- [k in K[number]]: ResolverResult<T, k>;
13
- }>;
14
- export {};
15
- //# sourceMappingURL=makeRunObjectFields.d.ts.map
11
+ type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;
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
+ //#endregion
14
+ export { MakeRunObjectFields, makeMakeRunObjectFields };
15
+ //# sourceMappingURL=makeRunObjectFields.d.cts.map
@@ -0,0 +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"}
@@ -0,0 +1,15 @@
1
+ import { ResolverResult, ResolverRoot, RunFn } from "./typeUtils.mjs";
2
+ //#region src/makeRunObjectFields.d.ts
3
+ /**
4
+ * Creates a `makeRunObjectFields` function for each project's `testUtils` file.
5
+ *
6
+ * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
+ * that is customized (basically curried) to their own `newContext` function.
8
+ */
9
+ declare function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C>;
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>;
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
+ //#endregion
14
+ export { MakeRunObjectFields, makeMakeRunObjectFields };
15
+ //# sourceMappingURL=makeRunObjectFields.d.mts.map
@@ -0,0 +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,23 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeMakeRunObjectFields = makeMakeRunObjectFields;
4
- const joist_core_1 = require("joist-core");
1
+ import "./typeUtils.js";
2
+ import { isEntity } from "joist-core";
3
+ //#region src/makeRunObjectFields.ts
5
4
  /**
6
- * Creates a `makeRunObjectFields` function for each project's `testUtils` file.
7
- *
8
- * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
9
- * that is customized (basically curried) to their own `newContext` function.
10
- */
5
+ * Creates a `makeRunObjectFields` function for each project's `testUtils` file.
6
+ *
7
+ * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
8
+ * that is customized (basically curried) to their own `newContext` function.
9
+ */
11
10
  function makeMakeRunObjectFields(runFn) {
12
- return (resolver) => {
13
- return (ctx, root, fields) => {
14
- return runFn(ctx, async (ctx) => {
15
- // Sneak in a Joist-ism that will load the entity in the new em
16
- const _root = (0, joist_core_1.isEntity)(root) ? await ctx.em.load(root.id) : root;
17
- // Build a result with each key, where fields might return a promise, so we `await` to make assertions easier
18
- return Object.fromEntries(await Promise.all(fields.map(async (key) => [key, await resolver[key](_root, {}, ctx, undefined)])));
19
- });
20
- };
21
- };
11
+ return (resolver) => {
12
+ return (ctx, root, fields) => {
13
+ return runFn(ctx, async (ctx) => {
14
+ const _root = isEntity(root) ? await ctx.em.load(root.id) : root;
15
+ return Object.fromEntries(await Promise.all(fields.map(async (key) => [key, await resolver[key](_root, {}, ctx, void 0)])));
16
+ });
17
+ };
18
+ };
22
19
  }
20
+ //#endregion
21
+ export { makeMakeRunObjectFields };
22
+
23
23
  //# sourceMappingURL=makeRunObjectFields.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunObjectFields.js","sourceRoot":"","sources":["../src/makeRunObjectFields.ts"],"names":[],"mappings":";;AASA,0DAaC;AAtBD,2CAAsC;AAGtC;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAO,KAAe;IAC3D,OAAO,CAAC,QAAQ,EAAE,EAAE;QAClB,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;YAC3B,OAAO,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;gBAC9B,+DAA+D;gBAC/D,MAAM,KAAK,GAAG,IAAA,qBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAO,GAAW,CAAC,EAAE,CAAC,IAAI,CAAE,IAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBACnF,6GAA6G;gBAC7G,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAO,QAAQ,CAAC,GAAG,CAAS,CAAC,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,SAAU,CAAC,CAAC,CAAC,CAAC,CAC9G,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"makeRunObjectFields.js","names":[],"sources":["../src/makeRunObjectFields.ts"],"sourcesContent":["import { isEntity } from \"joist-core\";\n\nimport { type ResolverResult, type ResolverRoot, type RunFn } from \"./typeUtils.ts\";\n\n/**\n * Creates a `makeRunObjectFields` function for each project's `testUtils` file.\n *\n * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory\n * that is customized (basically curried) to their own `newContext` function.\n */\nexport function makeMakeRunObjectFields<C, T>(runFn: RunFn<C>): MakeRunObjectFields<C> {\n return (resolver) => {\n return (ctx, root, fields) => {\n return runFn(ctx, async (ctx) => {\n // Sneak in a Joist-ism that will load the entity in the new em\n const _root = isEntity(root) ? await (ctx as any).em.load((root as any).id) : root;\n // Build a result with each key, where fields might return a promise, so we `await` to make assertions easier\n return Object.fromEntries(\n await Promise.all(fields.map(async (key) => [key, await (resolver[key] as any)(_root, {}, ctx, undefined!)])),\n );\n });\n };\n };\n}\n\n/** Creates a `run` method that can invoke multiple fields against an object resolver. */\nexport type MakeRunObjectFields<C> = <T, R extends ResolverRoot<T>>(resolvers: T) => RunFieldsResolverMethod<C, T, R>;\n\n// The return type for makeRunResolverKeys\ntype RunFieldsResolverMethod<C, T, R extends ResolverRoot<T>> = <K extends (keyof T)[]>(\n ctx: C,\n root: R,\n keys: K,\n) => Promise<{ [k in K[number]]: ResolverResult<T, k> }>;\n"],"mappings":";;;;;;;;;AAUA,SAAgB,wBAA8B,OAAyC;CACrF,QAAQ,aAAa;EACnB,QAAQ,KAAK,MAAM,WAAW;GAC5B,OAAO,MAAM,KAAK,OAAO,QAAQ;IAE/B,MAAM,QAAQ,SAAS,IAAI,IAAI,MAAO,IAAY,GAAG,KAAM,KAAa,EAAE,IAAI;IAE9E,OAAO,OAAO,YACZ,MAAM,QAAQ,IAAI,OAAO,IAAI,OAAO,QAAQ,CAAC,KAAK,MAAO,SAAS,IAAI,CAAS,OAAO,CAAC,GAAG,KAAK,KAAA,CAAU,CAAC,CAAC,CAAC,CAC9G;GACF,CAAC;EACH;CACF;AACF"}
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./typeUtils.cjs");
3
+ //#region src/makeRunQuery.ts
4
+ /**
5
+ * Creates a `makeRunQuery` function for each project's `testUtils` file.
6
+ *
7
+ * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
8
+ * that is customized (basically curried) to their own `newContext` function.
9
+ */
10
+ function makeMakeRunQuery(runFn) {
11
+ return (resolver) => {
12
+ return (ctx, args) => runFn(ctx, async (ctx) => {
13
+ return resolver[Object.keys(resolver)[0]]({}, args instanceof Function ? args() : args ?? {}, ctx, void 0);
14
+ });
15
+ };
16
+ }
17
+ //#endregion
18
+ exports.makeMakeRunQuery = makeMakeRunQuery;
19
+
20
+ //# sourceMappingURL=makeRunQuery.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeRunQuery.cjs","names":[],"sources":["../src/makeRunQuery.ts"],"sourcesContent":["import { type ResolverArgs, type ResolverResult, type RunFn } from \"./typeUtils.ts\";\n\n/**\n * Creates a `makeRunQuery` function for each project's `testUtils` file.\n *\n * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory\n * that is customized (basically curried) to their own `newContext` function.\n */\nexport function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C> {\n return (resolver) => {\n return (ctx, args) =>\n runFn(ctx, async (ctx) => {\n const key = Object.keys(resolver)[0];\n return ((resolver as any)[key] as any)({}, args instanceof Function ? args() : (args ?? {}), ctx, undefined!);\n });\n };\n}\n\n/**\n * Creates a `run` method that invokes the query resolver's single query.\n *\n * Following our `query / foo` conventions, query resolver will have a single `fooResolver.foo` method.\n */\nexport type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;\n\n/** The return type of `makeRunQuery`. */\ntype RunQueryMethod<C, T> = <A extends ResolverArgs<T, keyof T>>(\n ctx: C,\n // Support either the resolver arg directly or a lambda to create the args post-flush\n args?: A | (() => A),\n) => Promise<ResolverResult<T, keyof T>>;\n"],"mappings":";;;;;;;;;AAQA,SAAgB,iBAAoB,OAAkC;CACpE,QAAQ,aAAa;EACnB,QAAQ,KAAK,SACX,MAAM,KAAK,OAAO,QAAQ;GAExB,OAAS,SADG,OAAO,KAAK,QAAQ,CAAC,CAAC,GACJ,CAAS,CAAC,GAAG,gBAAgB,WAAW,KAAK,IAAK,QAAQ,CAAC,GAAI,KAAK,KAAA,CAAU;EAC9G,CAAC;CACL;AACF"}
@@ -1,18 +1,20 @@
1
- import { ResolverArgs, ResolverResult, RunFn } from "./typeUtils";
1
+ import { ResolverArgs, ResolverResult, RunFn } from "./typeUtils.cjs";
2
+ //#region src/makeRunQuery.d.ts
2
3
  /**
3
4
  * Creates a `makeRunQuery` function for each project's `testUtils` file.
4
5
  *
5
6
  * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
6
7
  * that is customized (basically curried) to their own `newContext` function.
7
8
  */
8
- export declare function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C>;
9
+ declare function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C>;
9
10
  /**
10
11
  * Creates a `run` method that invokes the query resolver's single query.
11
12
  *
12
13
  * Following our `query / foo` conventions, query resolver will have a single `fooResolver.foo` method.
13
14
  */
14
- export type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;
15
+ type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;
15
16
  /** The return type of `makeRunQuery`. */
16
17
  type RunQueryMethod<C, T> = <A extends ResolverArgs<T, keyof T>>(ctx: C, args?: A | (() => A)) => Promise<ResolverResult<T, keyof T>>;
17
- export {};
18
- //# sourceMappingURL=makeRunQuery.d.ts.map
18
+ //#endregion
19
+ export { MakeRunQuery, makeMakeRunQuery };
20
+ //# sourceMappingURL=makeRunQuery.d.cts.map
@@ -0,0 +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"}
@@ -0,0 +1,20 @@
1
+ import { ResolverArgs, ResolverResult, RunFn } from "./typeUtils.mjs";
2
+ //#region src/makeRunQuery.d.ts
3
+ /**
4
+ * Creates a `makeRunQuery` function for each project's `testUtils` file.
5
+ *
6
+ * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
+ * that is customized (basically curried) to their own `newContext` function.
8
+ */
9
+ declare function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C>;
10
+ /**
11
+ * Creates a `run` method that invokes the query resolver's single query.
12
+ *
13
+ * Following our `query / foo` conventions, query resolver will have a single `fooResolver.foo` method.
14
+ */
15
+ type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;
16
+ /** The return type of `makeRunQuery`. */
17
+ type RunQueryMethod<C, T> = <A extends ResolverArgs<T, keyof T>>(ctx: C, args?: A | (() => A)) => Promise<ResolverResult<T, keyof T>>;
18
+ //#endregion
19
+ export { MakeRunQuery, makeMakeRunQuery };
20
+ //# sourceMappingURL=makeRunQuery.d.mts.map
@@ -0,0 +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,18 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeMakeRunQuery = makeMakeRunQuery;
1
+ import "./typeUtils.js";
2
+ //#region src/makeRunQuery.ts
4
3
  /**
5
- * Creates a `makeRunQuery` function for each project's `testUtils` file.
6
- *
7
- * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
8
- * that is customized (basically curried) to their own `newContext` function.
9
- */
4
+ * Creates a `makeRunQuery` function for each project's `testUtils` file.
5
+ *
6
+ * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory
7
+ * that is customized (basically curried) to their own `newContext` function.
8
+ */
10
9
  function makeMakeRunQuery(runFn) {
11
- return (resolver) => {
12
- return (ctx, args) => runFn(ctx, async (ctx) => {
13
- const key = Object.keys(resolver)[0];
14
- return resolver[key]({}, args instanceof Function ? args() : (args ?? {}), ctx, undefined);
15
- });
16
- };
10
+ return (resolver) => {
11
+ return (ctx, args) => runFn(ctx, async (ctx) => {
12
+ return resolver[Object.keys(resolver)[0]]({}, args instanceof Function ? args() : args ?? {}, ctx, void 0);
13
+ });
14
+ };
17
15
  }
16
+ //#endregion
17
+ export { makeMakeRunQuery };
18
+
18
19
  //# sourceMappingURL=makeRunQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeRunQuery.js","sourceRoot":"","sources":["../src/makeRunQuery.ts"],"names":[],"mappings":";;AAQA,4CAQC;AAdD;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAI,KAAe;IACjD,OAAO,CAAC,QAAQ,EAAE,EAAE;QAClB,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CACnB,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YACvB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACrC,OAAS,QAAgB,CAAC,GAAG,CAAS,CAAC,EAAE,EAAE,IAAI,YAAY,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,SAAU,CAAC,CAAC;QAChH,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"makeRunQuery.js","names":[],"sources":["../src/makeRunQuery.ts"],"sourcesContent":["import { type ResolverArgs, type ResolverResult, type RunFn } from \"./typeUtils.ts\";\n\n/**\n * Creates a `makeRunQuery` function for each project's `testUtils` file.\n *\n * This is called `makeMake` because it's a factory for each project's `testUtils` to make its own factory\n * that is customized (basically curried) to their own `newContext` function.\n */\nexport function makeMakeRunQuery<C>(runFn: RunFn<C>): MakeRunQuery<C> {\n return (resolver) => {\n return (ctx, args) =>\n runFn(ctx, async (ctx) => {\n const key = Object.keys(resolver)[0];\n return ((resolver as any)[key] as any)({}, args instanceof Function ? args() : (args ?? {}), ctx, undefined!);\n });\n };\n}\n\n/**\n * Creates a `run` method that invokes the query resolver's single query.\n *\n * Following our `query / foo` conventions, query resolver will have a single `fooResolver.foo` method.\n */\nexport type MakeRunQuery<C> = <T extends object>(resolver: T) => RunQueryMethod<C, T>;\n\n/** The return type of `makeRunQuery`. */\ntype RunQueryMethod<C, T> = <A extends ResolverArgs<T, keyof T>>(\n ctx: C,\n // Support either the resolver arg directly or a lambda to create the args post-flush\n args?: A | (() => A),\n) => Promise<ResolverResult<T, keyof T>>;\n"],"mappings":";;;;;;;;AAQA,SAAgB,iBAAoB,OAAkC;CACpE,QAAQ,aAAa;EACnB,QAAQ,KAAK,SACX,MAAM,KAAK,OAAO,QAAQ;GAExB,OAAS,SADG,OAAO,KAAK,QAAQ,CAAC,CAAC,GACJ,CAAS,CAAC,GAAG,gBAAgB,WAAW,KAAK,IAAK,QAAQ,CAAC,GAAI,KAAK,KAAA,CAAU;EAC9G,CAAC;CACL;AACF"}
@@ -0,0 +1,34 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let joist_core = require("joist-core");
3
+ //#region src/paginationUtils.ts
4
+ const defaultLimit = 100;
5
+ /** Executes an entity selection after pagination has been applied. */
6
+ function queryEntities(ctx, base) {
7
+ return ctx.em.query(base);
8
+ }
9
+ /** Counts the unpaginated rows, preserving distinct, grouping, and join semantics. */
10
+ async function countQuery(ctx, base) {
11
+ const select = { id: base.select.id };
12
+ if (Array.isArray(base.orderBy)) for (const [index, order] of base.orderBy.entries()) {
13
+ const sort = order?.sort;
14
+ if (typeof sort === "object" && sort !== null && order.order !== void 0) select[`order${index}`] = sort;
15
+ }
16
+ const rows = (0, joist_core.query)({
17
+ ...base,
18
+ select,
19
+ orderBy: void 0,
20
+ limit: void 0,
21
+ offset: void 0
22
+ });
23
+ const [result] = await ctx.em.query({
24
+ from: rows,
25
+ select: { count: rows.id.count() }
26
+ });
27
+ return result.count;
28
+ }
29
+ //#endregion
30
+ exports.countQuery = countQuery;
31
+ exports.defaultLimit = defaultLimit;
32
+ exports.queryEntities = queryEntities;
33
+
34
+ //# sourceMappingURL=paginationUtils.cjs.map
@@ -0,0 +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<TableFor<T> & { readonly id: EntityColumn<T, never, string> }>;\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":";;;AAeA,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"}
@@ -0,0 +1,17 @@
1
+ import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, TableFor } from "joist-core";
2
+ //#region src/paginationUtils.d.ts
3
+ type ContextWithEm = {
4
+ em: EntityManager;
5
+ };
6
+ type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
7
+ type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
8
+ readonly id: EntityColumn<T, never, string>;
9
+ }>;
10
+ declare const defaultLimit = 100;
11
+ /** Executes an entity selection after pagination has been applied. */
12
+ declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
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>;
15
+ //#endregion
16
+ export { ContextWithEm, PaginationFilter, PaginationQuery, countQuery, defaultLimit, queryEntities };
17
+ //# sourceMappingURL=paginationUtils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginationUtils.d.cts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;KAWY;EAAkB,IAAI;;KACtB,iBAAiB,UAAU,UAAU,uBAAuB;KAC5D,gBAAgB,UAAU,UAAU,MAAM,SAAS;WAAgB,IAAI,aAAa;;cAEnF;;iBAGG,cAAc,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK,QAAQ;;iBAMjF,WAAW,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK"}
@@ -0,0 +1,17 @@
1
+ import { Entity, EntityColumn, EntityManager, GraphQLFilterWithAlias, Query, TableFor } from "joist-core";
2
+ //#region src/paginationUtils.d.ts
3
+ type ContextWithEm = {
4
+ em: EntityManager;
5
+ };
6
+ type PaginationFilter<T extends Entity> = GraphQLFilterWithAlias<T>;
7
+ type PaginationQuery<T extends Entity> = Query<TableFor<T> & {
8
+ readonly id: EntityColumn<T, never, string>;
9
+ }>;
10
+ declare const defaultLimit = 100;
11
+ /** Executes an entity selection after pagination has been applied. */
12
+ declare function queryEntities<T extends Entity>(ctx: ContextWithEm, base: PaginationQuery<T>): Promise<T[]>;
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>;
15
+ //#endregion
16
+ export { ContextWithEm, PaginationFilter, PaginationQuery, countQuery, defaultLimit, queryEntities };
17
+ //# sourceMappingURL=paginationUtils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginationUtils.d.mts","names":[],"sources":["../src/paginationUtils.ts"],"mappings":";;KAWY;EAAkB,IAAI;;KACtB,iBAAiB,UAAU,UAAU,uBAAuB;KAC5D,gBAAgB,UAAU,UAAU,MAAM,SAAS;WAAgB,IAAI,aAAa;;cAEnF;;iBAGG,cAAc,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK,QAAQ;;iBAMjF,WAAW,UAAU,QAAQ,KAAK,eAAe,MAAM,gBAAgB,KAAK"}
@@ -1,5 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultLimit = void 0;
4
- exports.defaultLimit = 100;
1
+ import { query } from "joist-core";
2
+ //#region src/paginationUtils.ts
3
+ const defaultLimit = 100;
4
+ /** Executes an entity selection after pagination has been applied. */
5
+ function queryEntities(ctx, base) {
6
+ return ctx.em.query(base);
7
+ }
8
+ /** Counts the unpaginated rows, preserving distinct, grouping, and join semantics. */
9
+ async function countQuery(ctx, base) {
10
+ const select = { id: base.select.id };
11
+ if (Array.isArray(base.orderBy)) for (const [index, order] of base.orderBy.entries()) {
12
+ const sort = order?.sort;
13
+ if (typeof sort === "object" && sort !== null && order.order !== void 0) select[`order${index}`] = sort;
14
+ }
15
+ const rows = query({
16
+ ...base,
17
+ select,
18
+ orderBy: void 0,
19
+ limit: void 0,
20
+ offset: void 0
21
+ });
22
+ const [result] = await ctx.em.query({
23
+ from: rows,
24
+ select: { count: rows.id.count() }
25
+ });
26
+ return result.count;
27
+ }
28
+ //#endregion
29
+ export { countQuery, defaultLimit, queryEntities };
30
+
5
31
  //# sourceMappingURL=paginationUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paginationUtils.js","sourceRoot":"","sources":["../src/paginationUtils.ts"],"names":[],"mappings":";;;AAKa,QAAA,YAAY,GAAG,GAAG,CAAC"}
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<TableFor<T> & { readonly id: EntityColumn<T, never, string> }>;\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":";;AAeA,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"}
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let joist_core = require("joist-core");
3
+ require("joist-test-utils");
4
+ //#region src/saveEntity.ts
5
+ /** Given an GraphQL input, creates-or-updates an entity of `type`. */
6
+ async function saveEntity(ctx, type, input, opts = {}) {
7
+ return saveEntities(ctx, type, [input], opts).then((r) => r[0]);
8
+ }
9
+ /** Given GraphQL inputs, creates-or-updates multiple entities of `type`. */
10
+ async function saveEntities(ctx, type, input, opts = {}) {
11
+ const { em } = ctx;
12
+ const { opts: entityOpts = {}, flush = true } = opts;
13
+ const results = await Promise.allSettled(input.map((input) => em.upsert(type, {
14
+ ...entityOpts,
15
+ ...input
16
+ })));
17
+ if (flush) await ctx.em.flush();
18
+ return (0, joist_core.failIfAnyRejected)(results);
19
+ }
20
+ //#endregion
21
+ exports.saveEntities = saveEntities;
22
+ exports.saveEntity = saveEntity;
23
+
24
+ //# sourceMappingURL=saveEntity.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saveEntity.cjs","names":["failIfAnyRejected"],"sources":["../src/saveEntity.ts"],"sourcesContent":["import {\n type DeepPartialOrNull,\n type Entity,\n type EntityConstructor,\n type OptsOf,\n failIfAnyRejected,\n} from \"joist-core\";\nimport { type Context } from \"joist-test-utils\";\n\n/** Given an GraphQL input, creates-or-updates an entity of `type`. */\nexport async function saveEntity<T extends Entity>(\n ctx: Context,\n type: EntityConstructor<T>,\n input: DeepPartialOrNull<T>,\n opts: { flush?: boolean } = {},\n): Promise<T> {\n return saveEntities(ctx, type, [input], opts).then((r) => r[0]);\n}\n\n/** Given GraphQL inputs, creates-or-updates multiple entities of `type`. */\nexport async function saveEntities<T extends Entity>(\n ctx: Context,\n type: EntityConstructor<T>,\n input: readonly DeepPartialOrNull<T>[],\n opts: { flush?: boolean; opts?: Partial<OptsOf<T>> } = {},\n): Promise<T[]> {\n const { em } = ctx;\n const { opts: entityOpts = {}, flush = true } = opts;\n const results = await Promise.allSettled(input.map((input) => em.upsert(type, { ...entityOpts, ...input })));\n if (flush) {\n await ctx.em.flush();\n }\n return failIfAnyRejected(results);\n}\n"],"mappings":";;;;;AAUA,eAAsB,WACpB,KACA,MACA,OACA,OAA4B,CAAC,GACjB;CACZ,OAAO,aAAa,KAAK,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,EAAE;AAChE;;AAGA,eAAsB,aACpB,KACA,MACA,OACA,OAAuD,CAAC,GAC1C;CACd,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,MAAM,aAAa,CAAC,GAAG,QAAQ,SAAS;CAChD,MAAM,UAAU,MAAM,QAAQ,WAAW,MAAM,KAAK,UAAU,GAAG,OAAO,MAAM;EAAE,GAAG;EAAY,GAAG;CAAM,CAAC,CAAC,CAAC;CAC3G,IAAI,OACF,MAAM,IAAI,GAAG,MAAM;CAErB,QAAA,GAAOA,WAAAA,kBAAAA,CAAkB,OAAO;AAClC"}
@@ -0,0 +1,15 @@
1
+ import { DeepPartialOrNull, Entity, EntityConstructor, OptsOf } from "joist-core";
2
+ import { Context } from "joist-test-utils";
3
+ //#region src/saveEntity.d.ts
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?: {
6
+ flush?: boolean;
7
+ }): Promise<T>;
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?: {
10
+ flush?: boolean;
11
+ opts?: Partial<OptsOf<T>>;
12
+ }): Promise<T[]>;
13
+ //#endregion
14
+ export { saveEntities, saveEntity };
15
+ //# sourceMappingURL=saveEntity.d.cts.map
@@ -0,0 +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"}
@@ -0,0 +1,15 @@
1
+ import { DeepPartialOrNull, Entity, EntityConstructor, OptsOf } from "joist-core";
2
+ import { Context } from "joist-test-utils";
3
+ //#region src/saveEntity.d.ts
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?: {
6
+ flush?: boolean;
7
+ }): Promise<T>;
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?: {
10
+ flush?: boolean;
11
+ opts?: Partial<OptsOf<T>>;
12
+ }): Promise<T[]>;
13
+ //#endregion
14
+ export { saveEntities, saveEntity };
15
+ //# sourceMappingURL=saveEntity.d.mts.map
@@ -0,0 +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,20 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.saveEntity = saveEntity;
4
- exports.saveEntities = saveEntities;
5
- const joist_core_1 = require("joist-core");
1
+ import { failIfAnyRejected } from "joist-core";
2
+ import "joist-test-utils";
3
+ //#region src/saveEntity.ts
6
4
  /** Given an GraphQL input, creates-or-updates an entity of `type`. */
7
5
  async function saveEntity(ctx, type, input, opts = {}) {
8
- return saveEntities(ctx, type, [input], opts).then((r) => r[0]);
6
+ return saveEntities(ctx, type, [input], opts).then((r) => r[0]);
9
7
  }
10
8
  /** Given GraphQL inputs, creates-or-updates multiple entities of `type`. */
11
9
  async function saveEntities(ctx, type, input, opts = {}) {
12
- const { em } = ctx;
13
- const { opts: entityOpts = {}, flush = true } = opts;
14
- const results = await Promise.allSettled(input.map((input) => em.upsert(type, { ...entityOpts, ...input })));
15
- if (flush) {
16
- await ctx.em.flush();
17
- }
18
- return (0, joist_core_1.failIfAnyRejected)(results);
10
+ const { em } = ctx;
11
+ const { opts: entityOpts = {}, flush = true } = opts;
12
+ const results = await Promise.allSettled(input.map((input) => em.upsert(type, {
13
+ ...entityOpts,
14
+ ...input
15
+ })));
16
+ if (flush) await ctx.em.flush();
17
+ return failIfAnyRejected(results);
19
18
  }
19
+ //#endregion
20
+ export { saveEntities, saveEntity };
21
+
20
22
  //# sourceMappingURL=saveEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveEntity.js","sourceRoot":"","sources":["../src/saveEntity.ts"],"names":[],"mappings":";;AAIA,gCAOC;AAGD,oCAaC;AA3BD,2CAAqG;AAGrG,sEAAsE;AAC/D,KAAK,UAAU,UAAU,CAC9B,GAAY,EACZ,IAA0B,EAC1B,KAA2B,EAC3B,OAA4B,EAAE;IAE9B,OAAO,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,4EAA4E;AACrE,KAAK,UAAU,YAAY,CAChC,GAAY,EACZ,IAA0B,EAC1B,KAAsC,EACtC,OAAuD,EAAE;IAEzD,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;IACnB,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,EAAE,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACrD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7G,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,IAAA,8BAAiB,EAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
1
+ {"version":3,"file":"saveEntity.js","names":[],"sources":["../src/saveEntity.ts"],"sourcesContent":["import {\n type DeepPartialOrNull,\n type Entity,\n type EntityConstructor,\n type OptsOf,\n failIfAnyRejected,\n} from \"joist-core\";\nimport { type Context } from \"joist-test-utils\";\n\n/** Given an GraphQL input, creates-or-updates an entity of `type`. */\nexport async function saveEntity<T extends Entity>(\n ctx: Context,\n type: EntityConstructor<T>,\n input: DeepPartialOrNull<T>,\n opts: { flush?: boolean } = {},\n): Promise<T> {\n return saveEntities(ctx, type, [input], opts).then((r) => r[0]);\n}\n\n/** Given GraphQL inputs, creates-or-updates multiple entities of `type`. */\nexport async function saveEntities<T extends Entity>(\n ctx: Context,\n type: EntityConstructor<T>,\n input: readonly DeepPartialOrNull<T>[],\n opts: { flush?: boolean; opts?: Partial<OptsOf<T>> } = {},\n): Promise<T[]> {\n const { em } = ctx;\n const { opts: entityOpts = {}, flush = true } = opts;\n const results = await Promise.allSettled(input.map((input) => em.upsert(type, { ...entityOpts, ...input })));\n if (flush) {\n await ctx.em.flush();\n }\n return failIfAnyRejected(results);\n}\n"],"mappings":";;;;AAUA,eAAsB,WACpB,KACA,MACA,OACA,OAA4B,CAAC,GACjB;CACZ,OAAO,aAAa,KAAK,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,EAAE;AAChE;;AAGA,eAAsB,aACpB,KACA,MACA,OACA,OAAuD,CAAC,GAC1C;CACd,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,MAAM,aAAa,CAAC,GAAG,QAAQ,SAAS;CAChD,MAAM,UAAU,MAAM,QAAQ,WAAW,MAAM,KAAK,UAAU,GAAG,OAAO,MAAM;EAAE,GAAG;EAAY,GAAG;CAAM,CAAC,CAAC,CAAC;CAC3G,IAAI,OACF,MAAM,IAAI,GAAG,MAAM;CAErB,OAAO,kBAAkB,OAAO;AAClC"}
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_makeRunInputMutation = require("./makeRunInputMutation.cjs");
3
+ const require_makeRunObjectField = require("./makeRunObjectField.cjs");
4
+ const require_makeRunObjectFields = require("./makeRunObjectFields.cjs");
5
+ const require_makeRunQuery = require("./makeRunQuery.cjs");
6
+ exports.makeMakeRunInputMutation = require_makeRunInputMutation.makeMakeRunInputMutation;
7
+ exports.makeMakeRunObjectField = require_makeRunObjectField.makeMakeRunObjectField;
8
+ exports.makeMakeRunObjectFields = require_makeRunObjectFields.makeMakeRunObjectFields;
9
+ exports.makeMakeRunQuery = require_makeRunQuery.makeMakeRunQuery;
@@ -0,0 +1,6 @@
1
+ import { ResolverArgs, ResolverResult, ResolverRoot, RunFn } from "./typeUtils.cjs";
2
+ import { MakeRunInputMutation, makeMakeRunInputMutation } from "./makeRunInputMutation.cjs";
3
+ import { MakeRunObjectField, makeMakeRunObjectField } from "./makeRunObjectField.cjs";
4
+ import { MakeRunObjectFields, makeMakeRunObjectFields } from "./makeRunObjectFields.cjs";
5
+ import { MakeRunQuery, makeMakeRunQuery } from "./makeRunQuery.cjs";
6
+ export { type MakeRunInputMutation, type MakeRunObjectField, type MakeRunObjectFields, type MakeRunQuery, type ResolverArgs, type ResolverResult, type ResolverRoot, type RunFn, makeMakeRunInputMutation, makeMakeRunObjectField, makeMakeRunObjectFields, makeMakeRunQuery };
@@ -0,0 +1,6 @@
1
+ import { ResolverArgs, ResolverResult, ResolverRoot, RunFn } from "./typeUtils.mjs";
2
+ import { MakeRunInputMutation, makeMakeRunInputMutation } from "./makeRunInputMutation.mjs";
3
+ import { MakeRunObjectField, makeMakeRunObjectField } from "./makeRunObjectField.mjs";
4
+ import { MakeRunObjectFields, makeMakeRunObjectFields } from "./makeRunObjectFields.mjs";
5
+ import { MakeRunQuery, makeMakeRunQuery } from "./makeRunQuery.mjs";
6
+ export { type MakeRunInputMutation, type MakeRunObjectField, type MakeRunObjectFields, type MakeRunQuery, type ResolverArgs, type ResolverResult, type ResolverRoot, type RunFn, makeMakeRunInputMutation, makeMakeRunObjectField, makeMakeRunObjectFields, makeMakeRunQuery };
package/build/tests.js CHANGED
@@ -1,27 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.makeMakeRunQuery = exports.makeMakeRunObjectFields = exports.makeMakeRunObjectField = exports.makeMakeRunInputMutation = void 0;
18
- var makeRunInputMutation_1 = require("./makeRunInputMutation");
19
- Object.defineProperty(exports, "makeMakeRunInputMutation", { enumerable: true, get: function () { return makeRunInputMutation_1.makeMakeRunInputMutation; } });
20
- var makeRunObjectField_1 = require("./makeRunObjectField");
21
- Object.defineProperty(exports, "makeMakeRunObjectField", { enumerable: true, get: function () { return makeRunObjectField_1.makeMakeRunObjectField; } });
22
- var makeRunObjectFields_1 = require("./makeRunObjectFields");
23
- Object.defineProperty(exports, "makeMakeRunObjectFields", { enumerable: true, get: function () { return makeRunObjectFields_1.makeMakeRunObjectFields; } });
24
- var makeRunQuery_1 = require("./makeRunQuery");
25
- Object.defineProperty(exports, "makeMakeRunQuery", { enumerable: true, get: function () { return makeRunQuery_1.makeMakeRunQuery; } });
26
- __exportStar(require("./typeUtils"), exports);
27
- //# sourceMappingURL=tests.js.map
1
+ import { makeMakeRunInputMutation } from "./makeRunInputMutation.js";
2
+ import { makeMakeRunObjectField } from "./makeRunObjectField.js";
3
+ import { makeMakeRunObjectFields } from "./makeRunObjectFields.js";
4
+ import { makeMakeRunQuery } from "./makeRunQuery.js";
5
+ export { makeMakeRunInputMutation, makeMakeRunObjectField, makeMakeRunObjectFields, makeMakeRunQuery };
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./context.cjs");
@@ -0,0 +1,11 @@
1
+ import { Resolver } from "./context.cjs";
2
+ //#region src/typeUtils.d.ts
3
+ type RunFn<C> = <T>(ctx: C, fn: (ctx: C) => Promise<T>) => Promise<T>;
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;
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;
9
+ //#endregion
10
+ export { ResolverArgs, ResolverResult, ResolverRoot, RunFn };
11
+ //# sourceMappingURL=typeUtils.d.cts.map
@@ -0,0 +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"}