drizzle-seed 0.0.1 → 0.1.1-166fb8d

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.
Files changed (153) hide show
  1. package/README.md +105 -0
  2. package/datasets/adjectives.d.cts +5 -0
  3. package/datasets/adjectives.d.mts +5 -0
  4. package/datasets/adjectives.d.ts +5 -0
  5. package/datasets/cityNames.d.cts +6 -0
  6. package/datasets/cityNames.d.mts +6 -0
  7. package/datasets/cityNames.d.ts +6 -0
  8. package/datasets/companyNameSuffixes.d.cts +2 -0
  9. package/datasets/companyNameSuffixes.d.mts +2 -0
  10. package/datasets/companyNameSuffixes.d.ts +2 -0
  11. package/datasets/countries.d.cts +6 -0
  12. package/datasets/countries.d.mts +6 -0
  13. package/datasets/countries.d.ts +6 -0
  14. package/datasets/emailDomains.d.cts +2 -0
  15. package/datasets/emailDomains.d.mts +2 -0
  16. package/datasets/emailDomains.d.ts +2 -0
  17. package/datasets/firstNames.d.cts +5 -0
  18. package/datasets/firstNames.d.mts +5 -0
  19. package/datasets/firstNames.d.ts +5 -0
  20. package/datasets/jobsTitles.d.cts +5 -0
  21. package/datasets/jobsTitles.d.mts +5 -0
  22. package/datasets/jobsTitles.d.ts +5 -0
  23. package/datasets/lastNames.d.cts +5 -0
  24. package/datasets/lastNames.d.mts +5 -0
  25. package/datasets/lastNames.d.ts +5 -0
  26. package/datasets/loremIpsumSentences.d.cts +5 -0
  27. package/datasets/loremIpsumSentences.d.mts +5 -0
  28. package/datasets/loremIpsumSentences.d.ts +5 -0
  29. package/datasets/phonesInfo.d.cts +7 -0
  30. package/datasets/phonesInfo.d.mts +7 -0
  31. package/datasets/phonesInfo.d.ts +7 -0
  32. package/datasets/states.d.cts +2 -0
  33. package/datasets/states.d.mts +2 -0
  34. package/datasets/states.d.ts +2 -0
  35. package/datasets/streetSuffix.d.cts +5 -0
  36. package/datasets/streetSuffix.d.mts +5 -0
  37. package/datasets/streetSuffix.d.ts +5 -0
  38. package/index.cjs +2 -0
  39. package/index.cjs.map +1 -0
  40. package/index.d.cts +288 -0
  41. package/index.d.mts +288 -0
  42. package/index.d.ts +288 -0
  43. package/index.mjs +2 -0
  44. package/index.mjs.map +1 -0
  45. package/package.json +102 -9
  46. package/services/GeneratorsWrappers.d.cts +1293 -0
  47. package/services/GeneratorsWrappers.d.mts +1293 -0
  48. package/services/GeneratorsWrappers.d.ts +1293 -0
  49. package/services/SeedService.d.cts +112 -0
  50. package/services/SeedService.d.mts +112 -0
  51. package/services/SeedService.d.ts +112 -0
  52. package/services/utils.d.cts +20 -0
  53. package/services/utils.d.mts +20 -0
  54. package/services/utils.d.ts +20 -0
  55. package/tests/benchmarks/generatorsBenchmark.d.cts +1 -0
  56. package/tests/benchmarks/generatorsBenchmark.d.mts +1 -0
  57. package/tests/benchmarks/generatorsBenchmark.d.ts +1 -0
  58. package/tests/mysql/allDataTypesTest/drizzle.config.d.cts +2 -0
  59. package/tests/mysql/allDataTypesTest/drizzle.config.d.mts +2 -0
  60. package/tests/mysql/allDataTypesTest/drizzle.config.d.ts +2 -0
  61. package/tests/mysql/allDataTypesTest/mysqlSchema.d.cts +466 -0
  62. package/tests/mysql/allDataTypesTest/mysqlSchema.d.mts +466 -0
  63. package/tests/mysql/allDataTypesTest/mysqlSchema.d.ts +466 -0
  64. package/tests/mysql/allDataTypesTest/mysql_all_data_types.test.d.cts +1 -0
  65. package/tests/mysql/allDataTypesTest/mysql_all_data_types.test.d.mts +1 -0
  66. package/tests/mysql/allDataTypesTest/mysql_all_data_types.test.d.ts +1 -0
  67. package/tests/mysql/drizzle.config.d.cts +2 -0
  68. package/tests/mysql/drizzle.config.d.mts +2 -0
  69. package/tests/mysql/drizzle.config.d.ts +2 -0
  70. package/tests/mysql/generatorsTest/drizzle.config.d.cts +2 -0
  71. package/tests/mysql/generatorsTest/drizzle.config.d.mts +2 -0
  72. package/tests/mysql/generatorsTest/drizzle.config.d.ts +2 -0
  73. package/tests/mysql/generatorsTest/generators.test.d.cts +1 -0
  74. package/tests/mysql/generatorsTest/generators.test.d.mts +1 -0
  75. package/tests/mysql/generatorsTest/generators.test.d.ts +1 -0
  76. package/tests/mysql/generatorsTest/mysqlSchema.d.cts +48 -0
  77. package/tests/mysql/generatorsTest/mysqlSchema.d.mts +48 -0
  78. package/tests/mysql/generatorsTest/mysqlSchema.d.ts +48 -0
  79. package/tests/mysql/mysql.test.d.cts +1 -0
  80. package/tests/mysql/mysql.test.d.mts +1 -0
  81. package/tests/mysql/mysql.test.d.ts +1 -0
  82. package/tests/mysql/mysqlSchema.d.cts +1130 -0
  83. package/tests/mysql/mysqlSchema.d.mts +1130 -0
  84. package/tests/mysql/mysqlSchema.d.ts +1130 -0
  85. package/tests/northwind/mysqlSchema.d.cts +1130 -0
  86. package/tests/northwind/mysqlSchema.d.mts +1130 -0
  87. package/tests/northwind/mysqlSchema.d.ts +1130 -0
  88. package/tests/northwind/mysqlTest.d.cts +1 -0
  89. package/tests/northwind/mysqlTest.d.mts +1 -0
  90. package/tests/northwind/mysqlTest.d.ts +1 -0
  91. package/tests/northwind/pgSchema.d.cts +1131 -0
  92. package/tests/northwind/pgSchema.d.mts +1131 -0
  93. package/tests/northwind/pgSchema.d.ts +1131 -0
  94. package/tests/northwind/pgTest.d.cts +1 -0
  95. package/tests/northwind/pgTest.d.mts +1 -0
  96. package/tests/northwind/pgTest.d.ts +1 -0
  97. package/tests/northwind/sqliteSchema.d.cts +1130 -0
  98. package/tests/northwind/sqliteSchema.d.mts +1130 -0
  99. package/tests/northwind/sqliteSchema.d.ts +1130 -0
  100. package/tests/northwind/sqliteTest.d.cts +1 -0
  101. package/tests/northwind/sqliteTest.d.mts +1 -0
  102. package/tests/northwind/sqliteTest.d.ts +1 -0
  103. package/tests/pg/allDataTypesTest/drizzle.config.d.cts +2 -0
  104. package/tests/pg/allDataTypesTest/drizzle.config.d.mts +2 -0
  105. package/tests/pg/allDataTypesTest/drizzle.config.d.ts +2 -0
  106. package/tests/pg/allDataTypesTest/pgSchema.d.cts +509 -0
  107. package/tests/pg/allDataTypesTest/pgSchema.d.mts +509 -0
  108. package/tests/pg/allDataTypesTest/pgSchema.d.ts +509 -0
  109. package/tests/pg/allDataTypesTest/pg_all_data_types.test.d.cts +1 -0
  110. package/tests/pg/allDataTypesTest/pg_all_data_types.test.d.mts +1 -0
  111. package/tests/pg/allDataTypesTest/pg_all_data_types.test.d.ts +1 -0
  112. package/tests/pg/drizzle.config.d.cts +2 -0
  113. package/tests/pg/drizzle.config.d.mts +2 -0
  114. package/tests/pg/drizzle.config.d.ts +2 -0
  115. package/tests/pg/generatorsTest/drizzle.config.d.cts +2 -0
  116. package/tests/pg/generatorsTest/drizzle.config.d.mts +2 -0
  117. package/tests/pg/generatorsTest/drizzle.config.d.ts +2 -0
  118. package/tests/pg/generatorsTest/generators.test.d.cts +1 -0
  119. package/tests/pg/generatorsTest/generators.test.d.mts +1 -0
  120. package/tests/pg/generatorsTest/generators.test.d.ts +1 -0
  121. package/tests/pg/generatorsTest/pgSchema.d.cts +1136 -0
  122. package/tests/pg/generatorsTest/pgSchema.d.mts +1136 -0
  123. package/tests/pg/generatorsTest/pgSchema.d.ts +1136 -0
  124. package/tests/pg/pg.test.d.cts +1 -0
  125. package/tests/pg/pg.test.d.mts +1 -0
  126. package/tests/pg/pg.test.d.ts +1 -0
  127. package/tests/pg/pgSchema.d.cts +1189 -0
  128. package/tests/pg/pgSchema.d.mts +1189 -0
  129. package/tests/pg/pgSchema.d.ts +1189 -0
  130. package/tests/sqlite/allDataTypesTest/sqliteSchema.d.cts +194 -0
  131. package/tests/sqlite/allDataTypesTest/sqliteSchema.d.mts +194 -0
  132. package/tests/sqlite/allDataTypesTest/sqliteSchema.d.ts +194 -0
  133. package/tests/sqlite/allDataTypesTest/sqlite_all_data_types.test.d.cts +1 -0
  134. package/tests/sqlite/allDataTypesTest/sqlite_all_data_types.test.d.mts +1 -0
  135. package/tests/sqlite/allDataTypesTest/sqlite_all_data_types.test.d.ts +1 -0
  136. package/tests/sqlite/sqlite.test.d.cts +1 -0
  137. package/tests/sqlite/sqlite.test.d.mts +1 -0
  138. package/tests/sqlite/sqlite.test.d.ts +1 -0
  139. package/tests/sqlite/sqliteSchema.d.cts +1130 -0
  140. package/tests/sqlite/sqliteSchema.d.mts +1130 -0
  141. package/tests/sqlite/sqliteSchema.d.ts +1130 -0
  142. package/tests/vitest.config.d.cts +2 -0
  143. package/tests/vitest.config.d.mts +2 -0
  144. package/tests/vitest.config.d.ts +2 -0
  145. package/types/drizzleStudio.d.cts +60 -0
  146. package/types/drizzleStudio.d.mts +60 -0
  147. package/types/drizzleStudio.d.ts +60 -0
  148. package/types/seedService.d.cts +45 -0
  149. package/types/seedService.d.mts +45 -0
  150. package/types/seedService.d.ts +45 -0
  151. package/types/tables.d.cts +25 -0
  152. package/types/tables.d.mts +25 -0
  153. package/types/tables.d.ts +25 -0
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # Drizzle Seed
2
+
3
+ > [!NOTE]
4
+ > `drizzle-seed` can only be used with `drizzle-orm@0.36.4` or higher. Versions lower than this may work at runtime but could have type issues and identity column issues, as this patch was introduced in `drizzle-orm@0.36.4`
5
+
6
+ ## Documentation
7
+
8
+ The full API reference and package overview can be found in our [official documentation](https://orm.drizzle.team/docs/seed-overview)
9
+
10
+ ## Overview
11
+
12
+ `drizzle-seed` is a TypeScript library that helps you generate deterministic, yet realistic,
13
+ fake data to populate your database. By leveraging a seedable pseudorandom number generator (pRNG),
14
+ it ensures that the data you generate is consistent and reproducible across different runs.
15
+ This is especially useful for testing, development, and debugging purposes.
16
+
17
+ #### What is Deterministic Data Generation?
18
+
19
+ Deterministic data generation means that the same input will always produce the same output.
20
+ In the context of `drizzle-seed`, when you initialize the library with the same seed number,
21
+ it will generate the same sequence of fake data every time. This allows for predictable and repeatable data sets.
22
+
23
+ #### Pseudorandom Number Generator (pRNG)
24
+
25
+ A pseudorandom number generator is an algorithm that produces a sequence of numbers
26
+ that approximates the properties of random numbers. However, because it's based on an initial value
27
+ called a seed, you can control its randomness. By using the same seed, the pRNG will produce the
28
+ same sequence of numbers, making your data generation process reproducible.
29
+
30
+ #### Benefits of Using a pRNG:
31
+
32
+ - Consistency: Ensures that your tests run on the same data every time.
33
+ - Debugging: Makes it easier to reproduce and fix bugs by providing a consistent data set.
34
+ - Collaboration: Team members can share seed numbers to work with the same data sets.
35
+
36
+ With drizzle-seed, you get the best of both worlds: the ability to generate realistic fake data and the control to reproduce it whenever needed.
37
+
38
+ ## Getting started
39
+
40
+ `npm install drizzle-seed`
41
+
42
+ You have to install `drizzle-orm` in order to use `drizzle-seed`.
43
+
44
+ `npm install drizzle-orm`
45
+
46
+ ## Basic Usage
47
+
48
+ In this example we will create 10 users with random names and ids
49
+
50
+ ```ts {12}
51
+ import { pgTable, integer, text } from "drizzle-orm/pg-core";
52
+ import { drizzle } from "drizzle-orm/node-postgres";
53
+ import { seed } from "drizzle-seed";
54
+
55
+ const users = pgTable("users", {
56
+ id: integer().primaryKey(),
57
+ name: text().notNull(),
58
+ });
59
+
60
+ async function main() {
61
+ const db = drizzle(process.env.DATABASE_URL!);
62
+ await seed(db, { users });
63
+ }
64
+
65
+ main();
66
+ ```
67
+
68
+ ## Options
69
+
70
+ **`count`**
71
+
72
+ By default, the `seed` function will create 10 entities.
73
+ However, if you need more for your tests, you can specify this in the seed options object
74
+
75
+ ```ts
76
+ await seed(db, schema, { count: 1000 });
77
+ ```
78
+
79
+ **`seed`**
80
+
81
+ If you need a seed to generate a different set of values for all subsequent runs, you can define a different number
82
+ in the `seed` option. Any new number will generate a unique set of values
83
+
84
+ ```ts
85
+ await seed(db, schema, { seed: 12345 });
86
+ ```
87
+
88
+ ## Reset databases
89
+
90
+ With `drizzle-seed`, you can easily reset your database and seed it with new values, for example, in your test suites
91
+
92
+ ```ts
93
+ // path to a file with schema you want to reset
94
+ import * as schema from "./schema.ts";
95
+ import { reset } from "drizzle-seed";
96
+
97
+ async function main() {
98
+ const db = drizzle(process.env.DATABASE_URL!);
99
+ await reset(db, schema);
100
+ }
101
+
102
+ main();
103
+ ```
104
+
105
+ More examples are available in our [official documentation](https://orm.drizzle.team/docs/seed-overview)
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for the Adjectives data was taken from https://www.kaggle.com/datasets/jordansiem/adjectives-list
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for the Adjectives data was taken from https://www.kaggle.com/datasets/jordansiem/adjectives-list
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for the Adjectives data was taken from https://www.kaggle.com/datasets/jordansiem/adjectives-list
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The original source for cities names data was taken from https://www.kaggle.com/datasets/juanmah/world-cities
3
+ * We've excluded a few countries and their cities from this list because we don't think they should ever appear in any list
4
+ */
5
+ declare const _default: string[];
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The original source for cities names data was taken from https://www.kaggle.com/datasets/juanmah/world-cities
3
+ * We've excluded a few countries and their cities from this list because we don't think they should ever appear in any list
4
+ */
5
+ declare const _default: string[];
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The original source for cities names data was taken from https://www.kaggle.com/datasets/juanmah/world-cities
3
+ * We've excluded a few countries and their cities from this list because we don't think they should ever appear in any list
4
+ */
5
+ declare const _default: string[];
6
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The original source for countries data was taken from https://www.kaggle.com/datasets/manusmitajha/countrydatacsv
3
+ * We've excluded a few countries and their cities from this list because we don't think they should ever appear in any list
4
+ */
5
+ declare const _default: string[];
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The original source for countries data was taken from https://www.kaggle.com/datasets/manusmitajha/countrydatacsv
3
+ * We've excluded a few countries and their cities from this list because we don't think they should ever appear in any list
4
+ */
5
+ declare const _default: string[];
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The original source for countries data was taken from https://www.kaggle.com/datasets/manusmitajha/countrydatacsv
3
+ * We've excluded a few countries and their cities from this list because we don't think they should ever appear in any list
4
+ */
5
+ declare const _default: string[];
6
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for first names data was taken from https://www.kaggle.com/datasets/kaggle/us-baby-names?select=StateNames.csv
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for first names data was taken from https://www.kaggle.com/datasets/kaggle/us-baby-names?select=StateNames.csv
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for first names data was taken from https://www.kaggle.com/datasets/kaggle/us-baby-names?select=StateNames.csv
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for the job titles data was taken from https://www.kaggle.com/datasets/ravindrasinghrana/job-description-dataset
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for the job titles data was taken from https://www.kaggle.com/datasets/ravindrasinghrana/job-description-dataset
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for the job titles data was taken from https://www.kaggle.com/datasets/ravindrasinghrana/job-description-dataset
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for last names data was taken from https://www.kaggle.com/datasets/fivethirtyeight/fivethirtyeight-most-common-name-dataset?resource=download&select=surnames.csv
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for last names data was taken from https://www.kaggle.com/datasets/fivethirtyeight/fivethirtyeight-most-common-name-dataset?resource=download&select=surnames.csv
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original source for last names data was taken from https://www.kaggle.com/datasets/fivethirtyeight/fivethirtyeight-most-common-name-dataset?resource=download&select=surnames.csv
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Data was generated, using https://www.lipsum.com/
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Data was generated, using https://www.lipsum.com/
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Data was generated, using https://www.lipsum.com/
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The original source for the phones info data was taken from https://www.kaggle.com/datasets/leighplt/country-code?select=mobile_telephone_prefixes_by_country.csv
3
+ *
4
+ * Data format is: ["country prefix, operator prefix, number length including operator prefix and excluding country prefix"]
5
+ */
6
+ declare const _default: string[];
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The original source for the phones info data was taken from https://www.kaggle.com/datasets/leighplt/country-code?select=mobile_telephone_prefixes_by_country.csv
3
+ *
4
+ * Data format is: ["country prefix, operator prefix, number length including operator prefix and excluding country prefix"]
5
+ */
6
+ declare const _default: string[];
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The original source for the phones info data was taken from https://www.kaggle.com/datasets/leighplt/country-code?select=mobile_telephone_prefixes_by_country.csv
3
+ *
4
+ * Data format is: ["country prefix, operator prefix, number length including operator prefix and excluding country prefix"]
5
+ */
6
+ declare const _default: string[];
7
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original data was taken from the сopycat library: https://github.com/supabase-community/copycat/blob/main/src/locales/en/address/street_suffix.ts
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original data was taken from the сopycat library: https://github.com/supabase-community/copycat/blob/main/src/locales/en/address/street_suffix.ts
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The original data was taken from the сopycat library: https://github.com/supabase-community/copycat/blob/main/src/locales/en/address/street_suffix.ts
3
+ */
4
+ declare const _default: string[];
5
+ export default _default;