prisma 6.15.0-dev.1 → 6.15.0-dev.2

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.
@@ -21,6 +21,29 @@ declare type AccelerateEngineConfig = {
21
21
  accelerateUtils?: AccelerateUtils;
22
22
  };
23
23
 
24
+ /**
25
+ * A stripped down interface of `fetch` that `@prisma/extension-accelerate`
26
+ * relies on. It must be in sync with the corresponding definition in the
27
+ * Accelerate extension.
28
+ *
29
+ * This is the actual interface exposed by the extension. We can't use the
30
+ * custom fetch function provided by it as normal fetch because the API is
31
+ * different. Notably, `headers` must be an object and not a `Headers`
32
+ * instance, and `url` must be a `string` and not a `URL`.
33
+ *
34
+ * The return type is `Response` but we can't specify this in an exported type
35
+ * because it would end up referencing external types from `@types/node` or DOM
36
+ * which can fail typechecking depending on TypeScript configuration in a user's
37
+ * project.
38
+ */
39
+ declare type AccelerateExtensionFetch = (url: string, options: {
40
+ body?: string;
41
+ method?: string;
42
+ headers: Record<string, string>;
43
+ }) => Promise<unknown>;
44
+
45
+ declare type AccelerateExtensionFetchDecorator = (fetch: AccelerateExtensionFetch) => AccelerateExtensionFetch;
46
+
24
47
  declare type AccelerateUtils = EngineConfig['accelerateUtils'];
25
48
 
26
49
  export declare type Action = keyof typeof DMMF_2.ModelAction | 'executeRaw' | 'queryRaw' | 'runCommandRaw';
@@ -104,7 +127,7 @@ declare type BatchArgs = {
104
127
 
105
128
  declare type BatchInternalParams = {
106
129
  requests: RequestParams[];
107
- customDataProxyFetch?: CustomDataProxyFetch;
130
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
108
131
  };
109
132
 
110
133
  declare type BatchQuery = {
@@ -310,37 +333,6 @@ export declare type Count<O> = {
310
333
 
311
334
  export declare function createParam(name: string): Param<unknown, string>;
312
335
 
313
- /**
314
- * Custom fetch function for `DataProxyEngine`.
315
- *
316
- * We can't use the actual type of `globalThis.fetch` because this will result
317
- * in API Extractor referencing Node.js type definitions in the `.d.ts` bundle
318
- * for the client runtime. We can only use such types in internal types that
319
- * don't end up exported anywhere.
320
-
321
- * It's also not possible to write a definition of `fetch` that would accept the
322
- * actual `fetch` function from different environments such as Node.js and
323
- * Cloudflare Workers (with their extensions to `RequestInit` and `Response`).
324
- * `fetch` is used in both covariant and contravariant positions in
325
- * `CustomDataProxyFetch`, making it invariant, so we need the exact same type.
326
- * Even if we removed the argument and left `fetch` in covariant position only,
327
- * then for an extension-supplied function to be assignable to `customDataProxyFetch`,
328
- * the platform-specific (or custom) `fetch` function needs to be assignable
329
- * to our `fetch` definition. This, in turn, requires the third-party `Response`
330
- * to be a subtype of our `Response` (which is not a problem, we could declare
331
- * a minimal `Response` type that only includes what we use) *and* requires the
332
- * third-party `RequestInit` to be a supertype of our `RequestInit` (i.e. we
333
- * have to declare all properties any `RequestInit` implementation in existence
334
- * could possibly have), which is not possible.
335
- *
336
- * Since `@prisma/extension-accelerate` redefines the type of
337
- * `__internalParams.customDataProxyFetch` to its own type anyway (probably for
338
- * exactly this reason), our definition is never actually used and is completely
339
- * ignored, so it doesn't matter, and we can just use `unknown` as the type of
340
- * `fetch` here.
341
- */
342
- declare type CustomDataProxyFetch = (fetch: unknown) => unknown;
343
-
344
336
  declare class DataLoader<T = unknown> {
345
337
  private options;
346
338
  batches: {
@@ -1943,7 +1935,7 @@ declare type InternalRequestParams = {
1943
1935
  /** Used to convert args for middleware and back */
1944
1936
  middlewareArgsMapper?: MiddlewareArgsMapper<unknown, unknown>;
1945
1937
  /** Used for Accelerate client extension via Data Proxy */
1946
- customDataProxyFetch?: CustomDataProxyFetch;
1938
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
1947
1939
  } & Omit<QueryMiddlewareParams, 'runInTransaction'>;
1948
1940
 
1949
1941
  declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SNAPSHOT' | 'SERIALIZABLE';
@@ -3159,7 +3151,7 @@ declare type RequestBatchOptions<InteractiveTransactionPayload> = {
3159
3151
  traceparent?: string;
3160
3152
  numTry?: number;
3161
3153
  containsWrite: boolean;
3162
- customDataProxyFetch?: CustomDataProxyFetch;
3154
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
3163
3155
  };
3164
3156
 
3165
3157
  declare interface RequestError {
@@ -3196,7 +3188,7 @@ declare type RequestOptions<InteractiveTransactionPayload> = {
3196
3188
  numTry?: number;
3197
3189
  interactiveTransaction?: InteractiveTransactionOptions<InteractiveTransactionPayload>;
3198
3190
  isWrite: boolean;
3199
- customDataProxyFetch?: CustomDataProxyFetch;
3191
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
3200
3192
  };
3201
3193
 
3202
3194
  declare type RequestParams = {
@@ -3214,7 +3206,7 @@ declare type RequestParams = {
3214
3206
  otelParentCtx?: Context;
3215
3207
  otelChildCtx?: Context;
3216
3208
  globalOmit?: GlobalOmitOptions;
3217
- customDataProxyFetch?: CustomDataProxyFetch;
3209
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
3218
3210
  };
3219
3211
 
3220
3212
  declare type RequiredExtensionArgs = NameArgs & ResultArgs & ModelArgs & ClientArgs & QueryOptions;
@@ -21,6 +21,29 @@ declare type AccelerateEngineConfig = {
21
21
  accelerateUtils?: AccelerateUtils;
22
22
  };
23
23
 
24
+ /**
25
+ * A stripped down interface of `fetch` that `@prisma/extension-accelerate`
26
+ * relies on. It must be in sync with the corresponding definition in the
27
+ * Accelerate extension.
28
+ *
29
+ * This is the actual interface exposed by the extension. We can't use the
30
+ * custom fetch function provided by it as normal fetch because the API is
31
+ * different. Notably, `headers` must be an object and not a `Headers`
32
+ * instance, and `url` must be a `string` and not a `URL`.
33
+ *
34
+ * The return type is `Response` but we can't specify this in an exported type
35
+ * because it would end up referencing external types from `@types/node` or DOM
36
+ * which can fail typechecking depending on TypeScript configuration in a user's
37
+ * project.
38
+ */
39
+ declare type AccelerateExtensionFetch = (url: string, options: {
40
+ body?: string;
41
+ method?: string;
42
+ headers: Record<string, string>;
43
+ }) => Promise<unknown>;
44
+
45
+ declare type AccelerateExtensionFetchDecorator = (fetch: AccelerateExtensionFetch) => AccelerateExtensionFetch;
46
+
24
47
  declare type AccelerateUtils = EngineConfig['accelerateUtils'];
25
48
 
26
49
  export declare type Action = keyof typeof DMMF_2.ModelAction | 'executeRaw' | 'queryRaw' | 'runCommandRaw';
@@ -104,7 +127,7 @@ declare type BatchArgs = {
104
127
 
105
128
  declare type BatchInternalParams = {
106
129
  requests: RequestParams[];
107
- customDataProxyFetch?: CustomDataProxyFetch;
130
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
108
131
  };
109
132
 
110
133
  declare type BatchQuery = {
@@ -310,37 +333,6 @@ export declare type Count<O> = {
310
333
 
311
334
  export declare function createParam(name: string): Param<unknown, string>;
312
335
 
313
- /**
314
- * Custom fetch function for `DataProxyEngine`.
315
- *
316
- * We can't use the actual type of `globalThis.fetch` because this will result
317
- * in API Extractor referencing Node.js type definitions in the `.d.ts` bundle
318
- * for the client runtime. We can only use such types in internal types that
319
- * don't end up exported anywhere.
320
-
321
- * It's also not possible to write a definition of `fetch` that would accept the
322
- * actual `fetch` function from different environments such as Node.js and
323
- * Cloudflare Workers (with their extensions to `RequestInit` and `Response`).
324
- * `fetch` is used in both covariant and contravariant positions in
325
- * `CustomDataProxyFetch`, making it invariant, so we need the exact same type.
326
- * Even if we removed the argument and left `fetch` in covariant position only,
327
- * then for an extension-supplied function to be assignable to `customDataProxyFetch`,
328
- * the platform-specific (or custom) `fetch` function needs to be assignable
329
- * to our `fetch` definition. This, in turn, requires the third-party `Response`
330
- * to be a subtype of our `Response` (which is not a problem, we could declare
331
- * a minimal `Response` type that only includes what we use) *and* requires the
332
- * third-party `RequestInit` to be a supertype of our `RequestInit` (i.e. we
333
- * have to declare all properties any `RequestInit` implementation in existence
334
- * could possibly have), which is not possible.
335
- *
336
- * Since `@prisma/extension-accelerate` redefines the type of
337
- * `__internalParams.customDataProxyFetch` to its own type anyway (probably for
338
- * exactly this reason), our definition is never actually used and is completely
339
- * ignored, so it doesn't matter, and we can just use `unknown` as the type of
340
- * `fetch` here.
341
- */
342
- declare type CustomDataProxyFetch = (fetch: unknown) => unknown;
343
-
344
336
  declare class DataLoader<T = unknown> {
345
337
  private options;
346
338
  batches: {
@@ -1943,7 +1935,7 @@ declare type InternalRequestParams = {
1943
1935
  /** Used to convert args for middleware and back */
1944
1936
  middlewareArgsMapper?: MiddlewareArgsMapper<unknown, unknown>;
1945
1937
  /** Used for Accelerate client extension via Data Proxy */
1946
- customDataProxyFetch?: CustomDataProxyFetch;
1938
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
1947
1939
  } & Omit<QueryMiddlewareParams, 'runInTransaction'>;
1948
1940
 
1949
1941
  declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SNAPSHOT' | 'SERIALIZABLE';
@@ -3159,7 +3151,7 @@ declare type RequestBatchOptions<InteractiveTransactionPayload> = {
3159
3151
  traceparent?: string;
3160
3152
  numTry?: number;
3161
3153
  containsWrite: boolean;
3162
- customDataProxyFetch?: CustomDataProxyFetch;
3154
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
3163
3155
  };
3164
3156
 
3165
3157
  declare interface RequestError {
@@ -3196,7 +3188,7 @@ declare type RequestOptions<InteractiveTransactionPayload> = {
3196
3188
  numTry?: number;
3197
3189
  interactiveTransaction?: InteractiveTransactionOptions<InteractiveTransactionPayload>;
3198
3190
  isWrite: boolean;
3199
- customDataProxyFetch?: CustomDataProxyFetch;
3191
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
3200
3192
  };
3201
3193
 
3202
3194
  declare type RequestParams = {
@@ -3214,7 +3206,7 @@ declare type RequestParams = {
3214
3206
  otelParentCtx?: Context;
3215
3207
  otelChildCtx?: Context;
3216
3208
  globalOmit?: GlobalOmitOptions;
3217
- customDataProxyFetch?: CustomDataProxyFetch;
3209
+ customDataProxyFetch?: AccelerateExtensionFetchDecorator;
3218
3210
  };
3219
3211
 
3220
3212
  declare type RequiredExtensionArgs = NameArgs & ResultArgs & ModelArgs & ClientArgs & QueryOptions;