@prisma/client-generator-ts 6.6.0-dev.95 → 6.6.0-dev.97

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.
@@ -6,7 +6,6 @@ export declare class ArgsTypeBuilder {
6
6
  private readonly context;
7
7
  private readonly action?;
8
8
  private moduleExport;
9
- private hasDefaultName;
10
9
  constructor(type: DMMF.OutputType, context: GenerateContext, action?: DMMF.ModelAction | undefined);
11
10
  private addProperty;
12
11
  addSchemaArgs(args: readonly DMMF.SchemaArg[]): this;
@@ -6,8 +6,6 @@ export declare class Enum implements Generable {
6
6
  constructor(type: DMMF.SchemaEnum, useNamespace: boolean);
7
7
  private isObjectEnum;
8
8
  private isStrictEnum;
9
- toJS(): string;
10
- private getValueJS;
11
9
  toTS(): string;
12
- private getValueTS;
10
+ private getValue;
13
11
  }
@@ -1,9 +1,3 @@
1
1
  export interface Generable {
2
- toJS?(): string;
3
2
  toTS(): string;
4
- toBrowserJS?(): string;
5
- toTSWithoutNamespace?(): string;
6
3
  }
7
- export declare function JS(gen: Generable): string;
8
- export declare function BrowserJS(gen: Generable): string;
9
- export declare function TS(gen: Generable): string;
@@ -7,8 +7,7 @@ export declare class PrismaClientClass implements Generable {
7
7
  protected readonly internalDatasources: DataSource[];
8
8
  protected readonly outputDir: string;
9
9
  protected readonly runtimeName: TSClientOptions['runtimeName'];
10
- protected readonly browser?: boolean | undefined;
11
- constructor(context: GenerateContext, internalDatasources: DataSource[], outputDir: string, runtimeName: TSClientOptions['runtimeName'], browser?: boolean | undefined);
10
+ constructor(context: GenerateContext, internalDatasources: DataSource[], outputDir: string, runtimeName: TSClientOptions['runtimeName']);
12
11
  private get jsDoc();
13
12
  toTSWithoutNamespace(): string;
14
13
  toTS(): string;
@@ -1,31 +1,19 @@
1
- import { EnvPaths } from '@prisma/internals';
2
1
  import type { O } from 'ts-toolbelt';
3
2
  import { DMMFHelper } from '../dmmf';
4
3
  import { GenerateClientOptions } from '../generateClient';
5
4
  import { GenericArgsInfo } from '../GenericsArgsInfo';
6
5
  import { type Generable } from './Generable';
7
- type RuntimeName = 'binary' | 'library' | 'wasm' | 'edge' | 'react-native' | 'client' | (string & {});
6
+ export type RuntimeName = 'binary' | 'library' | 'wasm' | 'edge' | 'react-native' | 'client' | (string & {});
8
7
  export type TSClientOptions = O.Required<GenerateClientOptions, 'runtimeBase'> & {
9
8
  /** The name of the runtime bundle to use */
10
9
  runtimeName: RuntimeName;
11
- /** When generating the browser client */
12
- browser: boolean;
13
- /** When generating via the Deno CLI */
14
- deno: boolean;
15
- /** When we are generating an /edge client */
10
+ /** When we are generating an edge-compatible client */
16
11
  edge: boolean;
17
- /** When we are generating a /wasm client */
18
- wasm: boolean;
19
- /** result of getEnvPaths call */
20
- envPaths: EnvPaths;
21
12
  };
22
13
  export declare class TSClient implements Generable {
23
14
  protected readonly options: TSClientOptions;
24
15
  protected readonly dmmf: DMMFHelper;
25
16
  protected readonly genericsInfo: GenericArgsInfo;
26
17
  constructor(options: TSClientOptions);
27
- toJS(): string;
28
18
  toTS(): string;
29
- toBrowserJS(): string;
30
19
  }
31
- export {};
@@ -1,7 +1,5 @@
1
1
  import type { TSClientOptions } from './TSClient';
2
- export declare const commonCodeJS: ({ runtimeBase, runtimeName, browser, clientVersion, engineVersion, generator, deno, }: TSClientOptions) => string;
3
- export declare const notSupportOnBrowser: (fnc: string, browser?: boolean) => string;
4
- export declare const commonCodeTS: ({ runtimeBase, runtimeName, clientVersion, engineVersion, generator, }: TSClientOptions) => {
2
+ export declare const commonCodeTS: ({ runtimeBase, runtimeName, clientVersion, engineVersion, generator, moduleFormat, edge, }: TSClientOptions) => {
5
3
  tsWithoutNamespace: () => string;
6
4
  ts: () => string;
7
5
  };
@@ -1,5 +1,4 @@
1
1
  export { Enum } from './Enum';
2
- export { BrowserJS, JS, TS } from './Generable';
3
2
  export { InputField, InputType } from './Input';
4
3
  export { Model, ModelDelegate } from './Model';
5
4
  export { TSClient } from './TSClient';
@@ -0,0 +1,4 @@
1
+ import { NamedType, TypeBuilder } from '@prisma/ts-builders';
2
+ export declare function promise(resultType: TypeBuilder): NamedType;
3
+ export declare function prismaPromise(resultType: TypeBuilder): NamedType;
4
+ export declare function optional(innerType: TypeBuilder): NamedType;
@@ -0,0 +1,16 @@
1
+ import { TsConfigJsonResolved } from 'get-tsconfig';
2
+ declare const expectedGeneratedFileExtensions: readonly ["ts", "mts", "cts"];
3
+ export type GeneratedFileExtension = (typeof expectedGeneratedFileExtensions)[number] | (string & {});
4
+ declare const expectedImportFileExtensions: readonly ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
5
+ export type ImportFileExtension = (typeof expectedImportFileExtensions)[number] | (string & {});
6
+ export declare function parseGeneratedFileExtension(extension: unknown): GeneratedFileExtension;
7
+ export declare function parseImportFileExtension(extension: unknown): ImportFileExtension;
8
+ export type FileNameMapper = (baseName: string) => string;
9
+ export declare function generatedFileNameMapper(generatedFileExtension: GeneratedFileExtension): FileNameMapper;
10
+ export declare function importFileNameMapper(importFileExtension: ImportFileExtension): FileNameMapper;
11
+ type InferImportFileExtensionOptions = {
12
+ tsconfig: TsConfigJsonResolved | undefined;
13
+ generatedFileExtension: GeneratedFileExtension;
14
+ };
15
+ export declare function inferImportFileExtension({ tsconfig, generatedFileExtension, }: InferImportFileExtensionOptions): ImportFileExtension;
16
+ export {};
@@ -2,6 +2,9 @@ import type * as DMMF from '@prisma/dmmf';
2
2
  import type { ActiveConnectorType, BinaryPaths, DataSource, GeneratorConfig, SqlQueryOutput } from '@prisma/generator';
3
3
  import { EnvPaths } from '@prisma/internals';
4
4
  import type { O } from 'ts-toolbelt';
5
+ import { GeneratedFileExtension, ImportFileExtension } from './file-extensions';
6
+ import { ModuleFormat } from './module-format';
7
+ import { RuntimeTarget } from './runtime-targets';
5
8
  export declare class DenylistError extends Error {
6
9
  constructor(message: string);
7
10
  }
@@ -24,6 +27,10 @@ export interface GenerateClientOptions {
24
27
  /** False when --no-engine is passed via CLI */
25
28
  copyEngine?: boolean;
26
29
  typedSql?: SqlQueryOutput[];
30
+ target: RuntimeTarget;
31
+ generatedFileExtension: GeneratedFileExtension;
32
+ importFileExtension: ImportFileExtension;
33
+ moduleFormat: ModuleFormat;
27
34
  }
28
35
  export interface FileMap {
29
36
  [name: string]: string | FileMap;
@@ -32,5 +39,5 @@ export interface BuildClientResult {
32
39
  fileMap: FileMap;
33
40
  prismaClientDmmf: DMMF.Document;
34
41
  }
35
- export declare function buildClient({ schemaPath, runtimeBase, datamodel, binaryPaths, outputDir, generator, dmmf, datasources, engineVersion, clientVersion, activeProvider, postinstall, copyEngine, envPaths, typedSql, }: O.Required<GenerateClientOptions, 'runtimeBase'>): BuildClientResult;
42
+ export declare function buildClient({ schemaPath, runtimeBase, datamodel, binaryPaths, outputDir, generator, dmmf, datasources, engineVersion, clientVersion, activeProvider, postinstall, copyEngine, envPaths, typedSql, target, generatedFileExtension, importFileExtension, moduleFormat, }: O.Required<GenerateClientOptions, 'runtimeBase'>): BuildClientResult;
36
43
  export declare function generateClient(options: GenerateClientOptions): Promise<void>;
package/dist/index.d.mts CHANGED
@@ -10,11 +10,9 @@ import { GeneratorOptions } from '@prisma/generator';
10
10
  import type { GetDMMFOptions } from '@prisma/internals';
11
11
  import type { SqlQueryOutput } from '@prisma/generator';
12
12
 
13
- /**
14
- * @internal
15
- * @remarks Used by, for example, the PDP to avoid child process calls to the CLI.
16
- */
17
- export declare function dmmfToTypes(dmmf: DMMF.Document): string;
13
+ declare const expectedGeneratedFileExtensions: readonly ["ts", "mts", "cts"];
14
+
15
+ declare const expectedImportFileExtensions: readonly ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
18
16
 
19
17
  /**
20
18
  * Turns type: string into type: string[] for all args in order to support union input types
@@ -24,7 +22,7 @@ export declare function externalToInternalDmmf(document: DMMF.Document): DMMF.Do
24
22
 
25
23
  export declare function generateClient(options: GenerateClientOptions): Promise<void>;
26
24
 
27
- declare interface GenerateClientOptions {
25
+ export declare interface GenerateClientOptions {
28
26
  datamodel: string;
29
27
  schemaPath: string;
30
28
  /** Runtime path used in runtime/type imports */
@@ -43,14 +41,30 @@ declare interface GenerateClientOptions {
43
41
  /** False when --no-engine is passed via CLI */
44
42
  copyEngine?: boolean;
45
43
  typedSql?: SqlQueryOutput[];
44
+ target: RuntimeTarget;
45
+ generatedFileExtension: GeneratedFileExtension;
46
+ importFileExtension: ImportFileExtension;
47
+ moduleFormat: ModuleFormat;
46
48
  }
47
49
 
50
+ declare type GeneratedFileExtension = (typeof expectedGeneratedFileExtensions)[number] | (string & {});
51
+
48
52
  export declare function getDMMF(options: GetDMMFOptions): Promise<DMMF.Document>;
49
53
 
54
+ declare type ImportFileExtension = (typeof expectedImportFileExtensions)[number] | (string & {});
55
+
56
+ declare type ModuleFormat = (typeof moduleFormats)[number];
57
+
58
+ declare const moduleFormats: readonly ["esm", "cjs"];
59
+
50
60
  export declare class PrismaClientTsGenerator implements Generator_2 {
51
61
  readonly name = "prisma-client-ts";
52
62
  getManifest(config: GeneratorConfig): Promise<GeneratorManifest>;
53
63
  generate(options: GeneratorOptions): Promise<void>;
54
64
  }
55
65
 
66
+ declare type RuntimeTarget = (typeof supportedRuntimes)[number];
67
+
68
+ declare const supportedRuntimes: readonly ["nodejs", "deno", "deno-deploy", "bun", "workerd", "edge-light", "react-native"];
69
+
56
70
  export { }
package/dist/index.d.ts CHANGED
@@ -10,11 +10,9 @@ import { GeneratorOptions } from '@prisma/generator';
10
10
  import type { GetDMMFOptions } from '@prisma/internals';
11
11
  import type { SqlQueryOutput } from '@prisma/generator';
12
12
 
13
- /**
14
- * @internal
15
- * @remarks Used by, for example, the PDP to avoid child process calls to the CLI.
16
- */
17
- export declare function dmmfToTypes(dmmf: DMMF.Document): string;
13
+ declare const expectedGeneratedFileExtensions: readonly ["ts", "mts", "cts"];
14
+
15
+ declare const expectedImportFileExtensions: readonly ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
18
16
 
19
17
  /**
20
18
  * Turns type: string into type: string[] for all args in order to support union input types
@@ -24,7 +22,7 @@ export declare function externalToInternalDmmf(document: DMMF.Document): DMMF.Do
24
22
 
25
23
  export declare function generateClient(options: GenerateClientOptions): Promise<void>;
26
24
 
27
- declare interface GenerateClientOptions {
25
+ export declare interface GenerateClientOptions {
28
26
  datamodel: string;
29
27
  schemaPath: string;
30
28
  /** Runtime path used in runtime/type imports */
@@ -43,14 +41,30 @@ declare interface GenerateClientOptions {
43
41
  /** False when --no-engine is passed via CLI */
44
42
  copyEngine?: boolean;
45
43
  typedSql?: SqlQueryOutput[];
44
+ target: RuntimeTarget;
45
+ generatedFileExtension: GeneratedFileExtension;
46
+ importFileExtension: ImportFileExtension;
47
+ moduleFormat: ModuleFormat;
46
48
  }
47
49
 
50
+ declare type GeneratedFileExtension = (typeof expectedGeneratedFileExtensions)[number] | (string & {});
51
+
48
52
  export declare function getDMMF(options: GetDMMFOptions): Promise<DMMF.Document>;
49
53
 
54
+ declare type ImportFileExtension = (typeof expectedImportFileExtensions)[number] | (string & {});
55
+
56
+ declare type ModuleFormat = (typeof moduleFormats)[number];
57
+
58
+ declare const moduleFormats: readonly ["esm", "cjs"];
59
+
50
60
  export declare class PrismaClientTsGenerator implements Generator_2 {
51
61
  readonly name = "prisma-client-ts";
52
62
  getManifest(config: GeneratorConfig): Promise<GeneratorManifest>;
53
63
  generate(options: GeneratorOptions): Promise<void>;
54
64
  }
55
65
 
66
+ declare type RuntimeTarget = (typeof supportedRuntimes)[number];
67
+
68
+ declare const supportedRuntimes: readonly ["nodejs", "deno", "deno-deploy", "bun", "workerd", "edge-light", "react-native"];
69
+
56
70
  export { }