index-browser.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. declare class AnyNull extends NullTypesEnumValue {
  2. }
  3. declare type Args<T, F extends Operation> = T extends {
  4. [K: symbol]: {
  5. types: {
  6. operations: {
  7. [K in F]: {
  8. args: any;
  9. };
  10. };
  11. };
  12. };
  13. } ? T[symbol]['types']['operations'][F]['args'] : any;
  14. declare class DbNull extends NullTypesEnumValue {
  15. }
  16. export declare namespace Decimal {
  17. export type Constructor = typeof Decimal;
  18. export type Instance = Decimal;
  19. export type Rounding = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
  20. export type Modulo = Rounding | 9;
  21. export type Value = string | number | Decimal;
  22. // http://mikemcl.github.io/decimal.js/#constructor-properties
  23. export interface Config {
  24. precision?: number;
  25. rounding?: Rounding;
  26. toExpNeg?: number;
  27. toExpPos?: number;
  28. minE?: number;
  29. maxE?: number;
  30. crypto?: boolean;
  31. modulo?: Modulo;
  32. defaults?: boolean;
  33. }
  34. }
  35. export declare class Decimal {
  36. readonly d: number[];
  37. readonly e: number;
  38. readonly s: number;
  39. constructor(n: Decimal.Value);
  40. absoluteValue(): Decimal;
  41. abs(): Decimal;
  42. ceil(): Decimal;
  43. clampedTo(min: Decimal.Value, max: Decimal.Value): Decimal;
  44. clamp(min: Decimal.Value, max: Decimal.Value): Decimal;
  45. comparedTo(n: Decimal.Value): number;
  46. cmp(n: Decimal.Value): number;
  47. cosine(): Decimal;
  48. cos(): Decimal;
  49. cubeRoot(): Decimal;
  50. cbrt(): Decimal;
  51. decimalPlaces(): number;
  52. dp(): number;
  53. dividedBy(n: Decimal.Value): Decimal;
  54. div(n: Decimal.Value): Decimal;
  55. dividedToIntegerBy(n: Decimal.Value): Decimal;
  56. divToInt(n: Decimal.Value): Decimal;
  57. equals(n: Decimal.Value): boolean;
  58. eq(n: Decimal.Value): boolean;
  59. floor(): Decimal;
  60. greaterThan(n: Decimal.Value): boolean;
  61. gt(n: Decimal.Value): boolean;
  62. greaterThanOrEqualTo(n: Decimal.Value): boolean;
  63. gte(n: Decimal.Value): boolean;
  64. hyperbolicCosine(): Decimal;
  65. cosh(): Decimal;
  66. hyperbolicSine(): Decimal;
  67. sinh(): Decimal;
  68. hyperbolicTangent(): Decimal;
  69. tanh(): Decimal;
  70. inverseCosine(): Decimal;
  71. acos(): Decimal;
  72. inverseHyperbolicCosine(): Decimal;
  73. acosh(): Decimal;
  74. inverseHyperbolicSine(): Decimal;
  75. asinh(): Decimal;
  76. inverseHyperbolicTangent(): Decimal;
  77. atanh(): Decimal;
  78. inverseSine(): Decimal;
  79. asin(): Decimal;
  80. inverseTangent(): Decimal;
  81. atan(): Decimal;
  82. isFinite(): boolean;
  83. isInteger(): boolean;
  84. isInt(): boolean;
  85. isNaN(): boolean;
  86. isNegative(): boolean;
  87. isNeg(): boolean;
  88. isPositive(): boolean;
  89. isPos(): boolean;
  90. isZero(): boolean;
  91. lessThan(n: Decimal.Value): boolean;
  92. lt(n: Decimal.Value): boolean;
  93. lessThanOrEqualTo(n: Decimal.Value): boolean;
  94. lte(n: Decimal.Value): boolean;
  95. logarithm(n?: Decimal.Value): Decimal;
  96. log(n?: Decimal.Value): Decimal;
  97. minus(n: Decimal.Value): Decimal;
  98. sub(n: Decimal.Value): Decimal;
  99. modulo(n: Decimal.Value): Decimal;
  100. mod(n: Decimal.Value): Decimal;
  101. naturalExponential(): Decimal;
  102. exp(): Decimal;
  103. naturalLogarithm(): Decimal;
  104. ln(): Decimal;
  105. negated(): Decimal;
  106. neg(): Decimal;
  107. plus(n: Decimal.Value): Decimal;
  108. add(n: Decimal.Value): Decimal;
  109. precision(includeZeros?: boolean): number;
  110. sd(includeZeros?: boolean): number;
  111. round(): Decimal;
  112. sine() : Decimal;
  113. sin() : Decimal;
  114. squareRoot(): Decimal;
  115. sqrt(): Decimal;
  116. tangent() : Decimal;
  117. tan() : Decimal;
  118. times(n: Decimal.Value): Decimal;
  119. mul(n: Decimal.Value) : Decimal;
  120. toBinary(significantDigits?: number): string;
  121. toBinary(significantDigits: number, rounding: Decimal.Rounding): string;
  122. toDecimalPlaces(decimalPlaces?: number): Decimal;
  123. toDecimalPlaces(decimalPlaces: number, rounding: Decimal.Rounding): Decimal;
  124. toDP(decimalPlaces?: number): Decimal;
  125. toDP(decimalPlaces: number, rounding: Decimal.Rounding): Decimal;
  126. toExponential(decimalPlaces?: number): string;
  127. toExponential(decimalPlaces: number, rounding: Decimal.Rounding): string;
  128. toFixed(decimalPlaces?: number): string;
  129. toFixed(decimalPlaces: number, rounding: Decimal.Rounding): string;
  130. toFraction(max_denominator?: Decimal.Value): Decimal[];
  131. toHexadecimal(significantDigits?: number): string;
  132. toHexadecimal(significantDigits: number, rounding: Decimal.Rounding): string;
  133. toHex(significantDigits?: number): string;
  134. toHex(significantDigits: number, rounding?: Decimal.Rounding): string;
  135. toJSON(): string;
  136. toNearest(n: Decimal.Value, rounding?: Decimal.Rounding): Decimal;
  137. toNumber(): number;
  138. toOctal(significantDigits?: number): string;
  139. toOctal(significantDigits: number, rounding: Decimal.Rounding): string;
  140. toPower(n: Decimal.Value): Decimal;
  141. pow(n: Decimal.Value): Decimal;
  142. toPrecision(significantDigits?: number): string;
  143. toPrecision(significantDigits: number, rounding: Decimal.Rounding): string;
  144. toSignificantDigits(significantDigits?: number): Decimal;
  145. toSignificantDigits(significantDigits: number, rounding: Decimal.Rounding): Decimal;
  146. toSD(significantDigits?: number): Decimal;
  147. toSD(significantDigits: number, rounding: Decimal.Rounding): Decimal;
  148. toString(): string;
  149. truncated(): Decimal;
  150. trunc(): Decimal;
  151. valueOf(): string;
  152. static abs(n: Decimal.Value): Decimal;
  153. static acos(n: Decimal.Value): Decimal;
  154. static acosh(n: Decimal.Value): Decimal;
  155. static add(x: Decimal.Value, y: Decimal.Value): Decimal;
  156. static asin(n: Decimal.Value): Decimal;
  157. static asinh(n: Decimal.Value): Decimal;
  158. static atan(n: Decimal.Value): Decimal;
  159. static atanh(n: Decimal.Value): Decimal;
  160. static atan2(y: Decimal.Value, x: Decimal.Value): Decimal;
  161. static cbrt(n: Decimal.Value): Decimal;
  162. static ceil(n: Decimal.Value): Decimal;
  163. static clamp(n: Decimal.Value, min: Decimal.Value, max: Decimal.Value): Decimal;
  164. static clone(object?: Decimal.Config): Decimal.Constructor;
  165. static config(object: Decimal.Config): Decimal.Constructor;
  166. static cos(n: Decimal.Value): Decimal;
  167. static cosh(n: Decimal.Value): Decimal;
  168. static div(x: Decimal.Value, y: Decimal.Value): Decimal;
  169. static exp(n: Decimal.Value): Decimal;
  170. static floor(n: Decimal.Value): Decimal;
  171. static hypot(...n: Decimal.Value[]): Decimal;
  172. static isDecimal(object: any): object is Decimal;
  173. static ln(n: Decimal.Value): Decimal;
  174. static log(n: Decimal.Value, base?: Decimal.Value): Decimal;
  175. static log2(n: Decimal.Value): Decimal;
  176. static log10(n: Decimal.Value): Decimal;
  177. static max(...n: Decimal.Value[]): Decimal;
  178. static min(...n: Decimal.Value[]): Decimal;
  179. static mod(x: Decimal.Value, y: Decimal.Value): Decimal;
  180. static mul(x: Decimal.Value, y: Decimal.Value): Decimal;
  181. static noConflict(): Decimal.Constructor; // Browser only
  182. static pow(base: Decimal.Value, exponent: Decimal.Value): Decimal;
  183. static random(significantDigits?: number): Decimal;
  184. static round(n: Decimal.Value): Decimal;
  185. static set(object: Decimal.Config): Decimal.Constructor;
  186. static sign(n: Decimal.Value): number;
  187. static sin(n: Decimal.Value): Decimal;
  188. static sinh(n: Decimal.Value): Decimal;
  189. static sqrt(n: Decimal.Value): Decimal;
  190. static sub(x: Decimal.Value, y: Decimal.Value): Decimal;
  191. static sum(...n: Decimal.Value[]): Decimal;
  192. static tan(n: Decimal.Value): Decimal;
  193. static tanh(n: Decimal.Value): Decimal;
  194. static trunc(n: Decimal.Value): Decimal;
  195. static readonly default?: Decimal.Constructor;
  196. static readonly Decimal?: Decimal.Constructor;
  197. static readonly precision: number;
  198. static readonly rounding: Decimal.Rounding;
  199. static readonly toExpNeg: number;
  200. static readonly toExpPos: number;
  201. static readonly minE: number;
  202. static readonly maxE: number;
  203. static readonly crypto: boolean;
  204. static readonly modulo: Decimal.Modulo;
  205. static readonly ROUND_UP: 0;
  206. static readonly ROUND_DOWN: 1;
  207. static readonly ROUND_CEIL: 2;
  208. static readonly ROUND_FLOOR: 3;
  209. static readonly ROUND_HALF_UP: 4;
  210. static readonly ROUND_HALF_DOWN: 5;
  211. static readonly ROUND_HALF_EVEN: 6;
  212. static readonly ROUND_HALF_CEIL: 7;
  213. static readonly ROUND_HALF_FLOOR: 8;
  214. static readonly EUCLID: 9;
  215. }
  216. declare type Exact<A, W> = (A extends unknown ? (W extends A ? {
  217. [K in keyof A]: Exact<A[K], W[K]>;
  218. } : W) : never) | (A extends Narrowable ? A : never);
  219. export declare function getRuntime(): GetRuntimeOutput;
  220. declare type GetRuntimeOutput = {
  221. id: Runtime;
  222. prettyName: string;
  223. isEdge: boolean;
  224. };
  225. declare class JsonNull extends NullTypesEnumValue {
  226. }
  227. /**
  228. * Generates more strict variant of an enum which, unlike regular enum,
  229. * throws on non-existing property access. This can be useful in following situations:
  230. * - we have an API, that accepts both `undefined` and `SomeEnumType` as an input
  231. * - enum values are generated dynamically from DMMF.
  232. *
  233. * In that case, if using normal enums and no compile-time typechecking, using non-existing property
  234. * will result in `undefined` value being used, which will be accepted. Using strict enum
  235. * in this case will help to have a runtime exception, telling you that you are probably doing something wrong.
  236. *
  237. * Note: if you need to check for existence of a value in the enum you can still use either
  238. * `in` operator or `hasOwnProperty` function.
  239. *
  240. * @param definition
  241. * @returns
  242. */
  243. export declare function makeStrictEnum<T extends Record<PropertyKey, string | number>>(definition: T): T;
  244. declare type Narrowable = string | number | bigint | boolean | [];
  245. declare class NullTypesEnumValue extends ObjectEnumValue {
  246. _getNamespace(): string;
  247. }
  248. /**
  249. * Base class for unique values of object-valued enums.
  250. */
  251. declare abstract class ObjectEnumValue {
  252. constructor(arg?: symbol);
  253. abstract _getNamespace(): string;
  254. _getName(): string;
  255. toString(): string;
  256. }
  257. export declare const objectEnumValues: {
  258. classes: {
  259. DbNull: typeof DbNull;
  260. JsonNull: typeof JsonNull;
  261. AnyNull: typeof AnyNull;
  262. };
  263. instances: {
  264. DbNull: DbNull;
  265. JsonNull: JsonNull;
  266. AnyNull: AnyNull;
  267. };
  268. };
  269. declare type Operation = 'findFirst' | 'findFirstOrThrow' | 'findUnique' | 'findUniqueOrThrow' | 'findMany' | 'create' | 'createMany' | 'createManyAndReturn' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'aggregate' | 'count' | 'groupBy' | '$queryRaw' | '$executeRaw' | '$queryRawUnsafe' | '$executeRawUnsafe' | 'findRaw' | 'aggregateRaw' | '$runCommandRaw';
  270. declare namespace Public {
  271. export {
  272. validator
  273. }
  274. }
  275. export { Public }
  276. declare type Runtime = "edge-routine" | "workerd" | "deno" | "lagon" | "react-native" | "netlify" | "electron" | "node" | "bun" | "edge-light" | "fastly" | "unknown";
  277. declare function validator<V>(): <S>(select: Exact<S, V>) => S;
  278. declare function validator<C, M extends Exclude<keyof C, `$${string}`>, O extends keyof C[M] & Operation>(client: C, model: M, operation: O): <S>(select: Exact<S, Args<C[M], O>>) => S;
  279. declare function validator<C, M extends Exclude<keyof C, `$${string}`>, O extends keyof C[M] & Operation, P extends keyof Args<C[M], O>>(client: C, model: M, operation: O, prop: P): <S>(select: Exact<S, Args<C[M], O>[P]>) => S;
  280. export { }