prisma-cursorstream 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,6 +23,21 @@ import cursorStream from "prisma-cursorstream";
23
23
  const db = new PrismaClient().$extends(cursorStream);
24
24
  ```
25
25
 
26
+ <details>
27
+ <summary>Using CommonJS `require`?</summary>
28
+
29
+ ### CommonJS `require`
30
+
31
+ ```js
32
+ const cursorStream = require("prisma-cursorstream").default;
33
+
34
+ const db = new PrismaClient().$extends(cursorStream);
35
+ ```
36
+
37
+ Refer to [#1](https://github.com/etabits/prisma-cursorstream/issues/1).
38
+
39
+ </details>
40
+
26
41
  ## Usage
27
42
 
28
43
  ```js
package/dist/index.d.ts CHANGED
@@ -2,11 +2,11 @@ import { Prisma, PrismaClientExtends } from "@prisma/client/extension";
2
2
  import { DefaultArgs } from "@prisma/client/runtime/library";
3
3
  declare const _default: (client: any) => PrismaClientExtends<import("@prisma/client/runtime/library").InternalArgs<{}, {
4
4
  $allModels: {
5
- cursorStream<T, A extends Prisma.Args<T, "findMany">, R extends Prisma.Result<T, A, "findMany">[number], C extends ((dataset: R[]) => Promise<unknown[]>) | undefined>(this: T, findManyArgs: A, { batchSize, prefill, batchTransformer }?: {
5
+ cursorStream<T, A extends Prisma.Args<T, "findMany"> | undefined, R extends Prisma.Result<T, A, "findMany">[number], C extends ((dataset: R[]) => Promise<unknown[]>) | undefined>(this: T, findManyArgs: A, { batchSize, prefill, batchTransformer }?: {
6
6
  batchSize?: number | undefined;
7
7
  prefill?: number | undefined;
8
8
  batchTransformer?: C | undefined;
9
- }): Iterable<C extends Function ? Awaited<ReturnType<C>>[number] extends object ? Awaited<ReturnType<C>>[number] : R : R>;
9
+ }): AsyncIterable<C extends Function ? Awaited<ReturnType<C>>[number] extends object ? Awaited<ReturnType<C>>[number] : R : R>;
10
10
  };
11
11
  }, {}, {}> & DefaultArgs>;
12
12
  export default _default;
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ exports.default = extension_1.Prisma.defineExtension((client) => {
7
7
  model: {
8
8
  $allModels: {
9
9
  cursorStream(findManyArgs, { batchSize, prefill, batchTransformer } = {}) {
10
+ findManyArgs = findManyArgs !== null && findManyArgs !== void 0 ? findManyArgs : {};
10
11
  const context = extension_1.Prisma.getExtensionContext(this);
11
12
  const take = batchSize || 100;
12
13
  const highWaterMark = prefill || take * 2;
@@ -24,11 +25,9 @@ exports.default = extension_1.Prisma.defineExtension((client) => {
24
25
  ...findManyArgs,
25
26
  take,
26
27
  skip: cursorValue ? 1 : 0,
27
- cursor: cursorValue
28
- ? {
29
- [cursorField]: cursorValue,
30
- }
31
- : undefined,
28
+ ...(typeof cursorValue !== "undefined"
29
+ ? { cursor: { [cursorField]: cursorValue } }
30
+ : {}),
32
31
  });
33
32
  const transformedResults = batchTransformer
34
33
  ? await batchTransformer(results)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-cursorstream",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Prisma Stream Client Extension (Cursor-based Implementation)",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "typescript": "^5.1.6"
20
20
  },
21
21
  "peerDependencies": {
22
- "@prisma/client": "^5.1.1"
22
+ "@prisma/client": "^5.1.1 || >= 5.1.1 <= 6.2.x"
23
23
  },
24
24
  "scripts": {}
25
25
  }