index-browser.d.ts 11 KB

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