@jorgebodega/typeorm-seeding 4.0.0-next.1 → 4.0.0
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.
- package/CHANGELOG.md +59 -22
- package/README.md +184 -88
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/seed.command.js +2 -2
- package/dist/commands/seed.command.js.map +1 -1
- package/dist/connection/index.js +3 -3
- package/dist/connection/index.js.map +1 -1
- package/dist/factory.d.ts +10 -13
- package/dist/factory.js +42 -36
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/instanceAttribute.d.ts +3 -0
- package/dist/instanceAttribute.js +8 -0
- package/dist/instanceAttribute.js.map +1 -0
- package/dist/lazyAttribute.d.ts +6 -0
- package/dist/lazyAttribute.js +13 -0
- package/dist/lazyAttribute.js.map +1 -0
- package/dist/lazyInstanceAttribute.d.ts +3 -0
- package/dist/lazyInstanceAttribute.js +8 -0
- package/dist/lazyInstanceAttribute.js.map +1 -0
- package/dist/seeder.d.ts +2 -2
- package/dist/seeder.js.map +1 -1
- package/dist/subfactory.d.ts +13 -0
- package/dist/subfactory.js +24 -0
- package/dist/subfactory.js.map +1 -0
- package/dist/types.d.ts +8 -1
- package/dist/useSeeders.d.ts +3 -3
- package/dist/useSeeders.js.map +1 -1
- package/package.json +21 -22
- package/dist/utils/isPromiseLike.d.ts +0 -1
- package/dist/utils/isPromiseLike.js +0 -6
- package/dist/utils/isPromiseLike.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,40 +1,77 @@
|
|
|
1
|
-
# [4.0.0
|
|
1
|
+
# [4.0.0](https://github.com/jorgebodega/typeorm-seeding/compare/v3.2.0...v4.0.0) (2022-03-23)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* add type check on subfactories creation ([2b2883b](https://github.com/jorgebodega/typeorm-seeding/commit/2b2883b48ea08173a032b219266b1fece937e753))
|
|
7
|
+
* attrs failing with lazy instances ([c8ddda8](https://github.com/jorgebodega/typeorm-seeding/commit/c8ddda841f9e65d7081e419d2d2e662c6d6a78df))
|
|
8
|
+
* update dependency yargs to v17.4.0 ([b64c224](https://github.com/jorgebodega/typeorm-seeding/commit/b64c2245ebb086d891c503972f74cdcca0e2ddab))
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add factorized attrs ([4a2ce08](https://github.com/jorgebodega/typeorm-seeding/commit/4a2ce08e1be1d79df8f1c0450ba4b315ebca8c46))
|
|
14
|
+
* add lazyattribute and subfactory as options in attribs ([48a3630](https://github.com/jorgebodega/typeorm-seeding/commit/48a3630b8c606ff5189c05dc51908dc09f142184))
|
|
15
|
+
* add subfactory as valid factorized attr ([0f4b37e](https://github.com/jorgebodega/typeorm-seeding/commit/0f4b37e0f8c3e93aedbd109ddb8f33ac0127a2dc))
|
|
16
|
+
* separate different types of lazy attributes ([3efe94e](https://github.com/jorgebodega/typeorm-seeding/commit/3efe94ea140643ccb12dbf8858968a5866fd7577))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* definition function has been substituted with attrs
|
|
22
|
+
|
|
23
|
+
# [4.0.0-next.3](https://github.com/jorgebodega/typeorm-seeding/compare/v4.0.0-next.2...v4.0.0-next.3) (2022-03-03)
|
|
24
|
+
|
|
25
|
+
# [4.0.0-next.2](https://github.com/jorgebodega/typeorm-seeding/compare/v4.0.0-next.1...v4.0.0-next.2) (2022-02-12)
|
|
12
26
|
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
# [4.0.0-next.1](https://github.com/jorgebodega/typeorm-seeding/compare/v3.2.0...v4.0.0-next.1) (2022-02-12)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* add type check on subfactories creation ([2b2883b](https://github.com/jorgebodega/typeorm-seeding/commit/2b2883b48ea08173a032b219266b1fece937e753))
|
|
33
|
+
* attrs failing with lazy instances ([c8ddda8](https://github.com/jorgebodega/typeorm-seeding/commit/c8ddda841f9e65d7081e419d2d2e662c6d6a78df))
|
|
15
34
|
|
|
16
35
|
|
|
17
36
|
### Features
|
|
18
37
|
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* remove factory helper methods and test associateds ([#30](https://github.com/jorgebodega/typeorm-seeding/issues/30)) ([a335ca2](https://github.com/jorgebodega/typeorm-seeding/commit/a335ca232410e2d1d93011ceca33068e01a7f16e))
|
|
24
|
-
* remove useFactories helper method ([#29](https://github.com/jorgebodega/typeorm-seeding/issues/29)) ([6fbeaba](https://github.com/jorgebodega/typeorm-seeding/commit/6fbeabaf2988b3d71fa19c2b44e443f58b805495))
|
|
25
|
-
* seed command will execute now default seeder or seed param ([84025f9](https://github.com/jorgebodega/typeorm-seeding/commit/84025f9a948c2d0823c2f95e6fb0193f0e36716a))
|
|
38
|
+
* add factorized attrs ([4a2ce08](https://github.com/jorgebodega/typeorm-seeding/commit/4a2ce08e1be1d79df8f1c0450ba4b315ebca8c46))
|
|
39
|
+
* add lazyattribute and subfactory as options in attribs ([48a3630](https://github.com/jorgebodega/typeorm-seeding/commit/48a3630b8c606ff5189c05dc51908dc09f142184))
|
|
40
|
+
* add subfactory as valid factorized attr ([0f4b37e](https://github.com/jorgebodega/typeorm-seeding/commit/0f4b37e0f8c3e93aedbd109ddb8f33ac0127a2dc))
|
|
41
|
+
* separate different types of lazy attributes ([3efe94e](https://github.com/jorgebodega/typeorm-seeding/commit/3efe94ea140643ccb12dbf8858968a5866fd7577))
|
|
26
42
|
|
|
27
43
|
|
|
28
44
|
### BREAKING CHANGES
|
|
29
45
|
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
46
|
+
* definition function has been substituted with attrs
|
|
47
|
+
|
|
48
|
+
# [3.2.0](https://github.com/jorgebodega/typeorm-seeding/compare/v3.1.0...v3.2.0) (2022-02-06)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Features
|
|
52
|
+
|
|
53
|
+
* Allow async map function ([2d2c27b](https://github.com/jorgebodega/typeorm-seeding/commit/2d2c27bfb6d208a4507169a9e9fa41e8e3680072))
|
|
54
|
+
|
|
55
|
+
# [3.1.0](https://github.com/jorgebodega/typeorm-seeding/compare/v3.0.1...v3.1.0) (2022-01-13)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* add support to async definition on factory ([9432089](https://github.com/jorgebodega/typeorm-seeding/commit/9432089394b027552c12dc0a1dcb5f706cb6c107))
|
|
61
|
+
|
|
62
|
+
# [3.1.0-next.1](https://github.com/jorgebodega/typeorm-seeding/compare/v3.0.1...v3.1.0-next.1) (2022-01-09)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Features
|
|
66
|
+
|
|
67
|
+
* add support to async definition on factory ([5fcca0e](https://github.com/jorgebodega/typeorm-seeding/commit/5fcca0e8d2016c68fda18fe1b202739558b07466))
|
|
68
|
+
|
|
69
|
+
## [3.0.1](https://github.com/jorgebodega/typeorm-seeding/compare/v3.0.0...v3.0.1) (2022-01-08)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
* update dependencies and add rimraf to dev deps ([504cef2](https://github.com/jorgebodega/typeorm-seeding/commit/504cef2f94b1b8e2e47d6bfa6e0bb1e8325490e2))
|
|
38
75
|
|
|
39
76
|
# [3.0.0](https://github.com/jorgebodega/typeorm-seeding/compare/v2.0.0...v3.0.0) (2022-01-06)
|
|
40
77
|
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</a>
|
|
14
14
|
<a href="https://github.com/semantic-release/semantic-release">
|
|
15
15
|
<img src="https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release&style=for-the-badge" alt="Semantic release" />
|
|
16
|
-
</a>
|
|
16
|
+
</a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
<p align="center">
|
|
@@ -43,14 +43,27 @@
|
|
|
43
43
|
|
|
44
44
|
<br />
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
# Contents
|
|
47
47
|
|
|
48
48
|
- [Factory](#factory-1)
|
|
49
|
+
- [attrs](#attrs)
|
|
50
|
+
- [Simple value](#simple-value)
|
|
51
|
+
- [Function](#function)
|
|
52
|
+
- [InstanceAttribute](#instanceattribute)
|
|
53
|
+
- [LazyInstanceAttribute](#lazyinstanceattribute)
|
|
54
|
+
- [Subfactory](#subfactory)
|
|
55
|
+
- [make & makeMany](#make--makemany)
|
|
56
|
+
- [create & createMany](#create--createmany)
|
|
57
|
+
- [faker](#faker)
|
|
49
58
|
- [Seeder](#seeder-1)
|
|
59
|
+
- [run](#run)
|
|
60
|
+
- [call](#call)
|
|
50
61
|
- [CLI](#cli-configuration)
|
|
62
|
+
- [config](#config)
|
|
63
|
+
- [seed](#seed)
|
|
51
64
|
- [Testing features](#testing-features)
|
|
52
65
|
|
|
53
|
-
|
|
66
|
+
# Installation
|
|
54
67
|
|
|
55
68
|
Before using this TypeORM extension please read the [TypeORM Getting Started](https://typeorm.io/#/) documentation. This explains how to setup a TypeORM project.
|
|
56
69
|
|
|
@@ -61,9 +74,9 @@ npm i [-D] @jorgebodega/typeorm-seeding
|
|
|
61
74
|
yarn add [-D] @jorgebodega/typeorm-seeding
|
|
62
75
|
```
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
## Configuration
|
|
65
78
|
|
|
66
|
-
To configure the path to your seeders
|
|
79
|
+
To configure the path to your seeders extends the TypeORM config file or use environment variables like TypeORM. If both are used the environment variables will be prioritized.
|
|
67
80
|
|
|
68
81
|
**ormconfig.js**
|
|
69
82
|
|
|
@@ -83,7 +96,7 @@ TYPEORM_SEEDING_SEEDERS=src/seeds/**/*{.ts,.js}
|
|
|
83
96
|
TYPEORM_SEEDING_DEFAULT_SEEDER=RootSeeder
|
|
84
97
|
```
|
|
85
98
|
|
|
86
|
-
|
|
99
|
+
# Introduction
|
|
87
100
|
|
|
88
101
|
Isn't it exhausting to create some sample data for your database, well this time is over!
|
|
89
102
|
|
|
@@ -94,11 +107,24 @@ How does it work? Just create a entity factory and/or seed script.
|
|
|
94
107
|
```typescript
|
|
95
108
|
@Entity()
|
|
96
109
|
class User {
|
|
97
|
-
@PrimaryGeneratedColumn('
|
|
110
|
+
@PrimaryGeneratedColumn('increment')
|
|
111
|
+
id!: number
|
|
112
|
+
|
|
113
|
+
@Column()
|
|
114
|
+
name!: string
|
|
115
|
+
|
|
116
|
+
@Column()
|
|
117
|
+
lastName!: string
|
|
98
118
|
|
|
99
|
-
@Column()
|
|
119
|
+
@Column()
|
|
120
|
+
email!: string
|
|
100
121
|
|
|
101
|
-
@
|
|
122
|
+
@OneToMany(() => Pet, (pet) => pet.owner)
|
|
123
|
+
pets?: Pet[]
|
|
124
|
+
|
|
125
|
+
@ManyToOne(() => Country, (country) => country.users, { nullable: false })
|
|
126
|
+
@JoinColumn()
|
|
127
|
+
country!: Country
|
|
102
128
|
}
|
|
103
129
|
```
|
|
104
130
|
|
|
@@ -106,13 +132,14 @@ class User {
|
|
|
106
132
|
|
|
107
133
|
```typescript
|
|
108
134
|
class UserFactory extends Factory<User> {
|
|
109
|
-
protected
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
135
|
+
protected entity = User
|
|
136
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
137
|
+
name: faker.name.firstName(),
|
|
138
|
+
lastName: async () => faker.name.lastName(),
|
|
139
|
+
email: new InstanceAttribute((instance) =>
|
|
140
|
+
[instance.name.toLowerCase(), instance.lastName.toLowerCase(), '@email.com'].join(''),
|
|
141
|
+
),
|
|
142
|
+
country: new Subfactory(CountryFactory),
|
|
116
143
|
}
|
|
117
144
|
}
|
|
118
145
|
```
|
|
@@ -120,67 +147,164 @@ class UserFactory extends Factory<User> {
|
|
|
120
147
|
### Seeder
|
|
121
148
|
|
|
122
149
|
```typescript
|
|
123
|
-
|
|
124
|
-
async run() {
|
|
125
|
-
await new UserFactory().
|
|
126
|
-
|
|
127
|
-
|
|
150
|
+
class UserSeeder extends Seeder {
|
|
151
|
+
async run(connection: Connection) {
|
|
152
|
+
await new UserFactory().createMany(10)
|
|
153
|
+
|
|
154
|
+
await this.call(connection, [PetSeeder])
|
|
128
155
|
}
|
|
129
156
|
}
|
|
130
157
|
```
|
|
131
158
|
|
|
132
|
-
|
|
159
|
+
# Factory
|
|
133
160
|
|
|
134
161
|
Factory is how we provide a way to simplify entities creation, implementing a [factory creational pattern](https://refactoring.guru/design-patterns/factory-method). It is defined as an abstract class with generic typing, so you have to extend over it.
|
|
135
162
|
|
|
136
163
|
```typescript
|
|
137
164
|
class UserFactory extends Factory<User> {
|
|
138
|
-
protected
|
|
165
|
+
protected entity = User
|
|
166
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
139
167
|
...
|
|
140
168
|
}
|
|
141
169
|
}
|
|
142
170
|
```
|
|
143
171
|
|
|
144
|
-
|
|
172
|
+
## `attrs`
|
|
173
|
+
|
|
174
|
+
Attributes objects are superset from the original entity attributes.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
178
|
+
name: faker.name.firstName(),
|
|
179
|
+
lastName: async () => faker.name.lastName(),
|
|
180
|
+
email: new InstanceAttribute((instance) =>
|
|
181
|
+
[instance.name.toLowerCase(), instance.lastName.toLowerCase(), '@email.com'].join(''),
|
|
182
|
+
),
|
|
183
|
+
country: new Subfactory(CountryFactory),
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Those factorized attributes resolves to the value of the original attribute, and could be one of the following types:
|
|
188
|
+
|
|
189
|
+
- [Simple value](#simple-value)
|
|
190
|
+
- [Function](#function)
|
|
191
|
+
- [InstanceAttribute](#instanceattribute)
|
|
192
|
+
- [LazyInstanceAttribute](#lazyinstanceattribute)
|
|
193
|
+
- [Subfactory](#subfactory)
|
|
194
|
+
|
|
195
|
+
### Simple value
|
|
196
|
+
|
|
197
|
+
Nothing special, just a value with same type.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
201
|
+
name: faker.name.firstName(),
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Function
|
|
206
|
+
|
|
207
|
+
Function that could be sync or async, and return a value of the same type. This function will be executed once per entity.
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
211
|
+
lastName: async () => faker.name.lastName(),
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `InstanceAttribute`
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
class InstanceAttribute<T, V> {
|
|
219
|
+
constructor(private callback: (entity: T) => V) {}
|
|
220
|
+
|
|
221
|
+
...
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Class with a function that receive the current instance and returns a value of the same type. It is ideal for attributes that could depend on some others to be computed.
|
|
145
226
|
|
|
146
|
-
|
|
227
|
+
Will be executed after the entity has been created and the rest of the attributes have been calculated, but before persistance (in case of `create` or `createMany`).
|
|
147
228
|
|
|
148
229
|
```typescript
|
|
149
|
-
protected
|
|
150
|
-
|
|
230
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
231
|
+
name: faker.name.firstName(),
|
|
232
|
+
lastName: async () => faker.name.lastName(),
|
|
233
|
+
email: new InstanceAttribute((instance) =>
|
|
234
|
+
[instance.name.toLowerCase(), instance.lastName.toLowerCase(), '@email.com'].join(''),
|
|
235
|
+
),
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
In this simple case, if `name` or `lastName` override the value in any way, the `email` attribute will be affected too.
|
|
240
|
+
|
|
241
|
+
### `LazyInstanceAttribute`
|
|
151
242
|
|
|
152
|
-
|
|
153
|
-
|
|
243
|
+
```typescript
|
|
244
|
+
class LazyInstanceAttribute<T, V> {
|
|
245
|
+
constructor(private callback: (entity: T) => V) {}
|
|
154
246
|
|
|
155
|
-
|
|
247
|
+
...
|
|
156
248
|
}
|
|
157
249
|
```
|
|
158
250
|
|
|
159
|
-
|
|
251
|
+
Class with similar functionality than `InstanceAttribute`, but it will be executed only after persistance. This is useful for attributes that depends on the database id, like relations.
|
|
160
252
|
|
|
161
|
-
|
|
253
|
+
Just remember that, if you use `make` or `makeMany`, the only difference between `InstanceAttribute` and `LazyInstanceAttribute` is that `LazyInstanceAttribute` will be processed the last.
|
|
162
254
|
|
|
163
|
-
|
|
255
|
+
```typescript
|
|
256
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
257
|
+
name: faker.name.firstName(),
|
|
258
|
+
email: new LazyInstanceAttribute((instance) =>
|
|
259
|
+
[instance.name.toLowerCase(), instance.id, '@email.com'].join(''),
|
|
260
|
+
),
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### `Subfactory`
|
|
164
265
|
|
|
165
266
|
```typescript
|
|
166
|
-
|
|
267
|
+
export class Subfactory<T> {
|
|
268
|
+
constructor(factory: Constructable<Factory<T>>)
|
|
269
|
+
constructor(factory: Constructable<Factory<T>>, values?: Partial<FactorizedAttrs<T>>)
|
|
270
|
+
constructor(factory: Constructable<Factory<T>>, count?: number)
|
|
271
|
+
constructor(factory: Constructable<Factory<T>>, values?: Partial<FactorizedAttrs<T>>, count?: number)
|
|
272
|
+
|
|
273
|
+
...
|
|
274
|
+
}
|
|
167
275
|
```
|
|
168
276
|
|
|
277
|
+
Subfactories are just a wrapper of another factory, to avoid explicit operations that could lead to unexpected results over that factory, like
|
|
278
|
+
|
|
169
279
|
```typescript
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
280
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
281
|
+
country: async () => new CountryFactory().create({
|
|
282
|
+
name: faker.address.country(),
|
|
283
|
+
}),
|
|
284
|
+
}
|
|
173
285
|
```
|
|
174
286
|
|
|
175
|
-
|
|
287
|
+
instead of
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
protected attrs: FactorizedAttrs<User> = {
|
|
291
|
+
country: new Subfactory(CountryFactory, {
|
|
292
|
+
name: faker.address.country(),
|
|
293
|
+
}),
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Subfactory just execute the same kind of operation (`make` or `create`) over the factory. If `count` param is provided, it will execute `makeMany`/`createMany` instead of `make`/`create`, and returns an array.
|
|
298
|
+
|
|
299
|
+
## `make` & `makeMany`
|
|
176
300
|
|
|
177
301
|
Make and makeMany executes the factory functions and return a new instance of the given entity. The instance is filled with the generated values from the factory function, but not saved in the database.
|
|
178
302
|
|
|
179
303
|
- **overrideParams** - Override some of the attributes of the entity.
|
|
180
304
|
|
|
181
305
|
```typescript
|
|
182
|
-
make(overrideParams: Partial<
|
|
183
|
-
makeMany(amount: number, overrideParams: Partial<
|
|
306
|
+
make(overrideParams: Partial<FactorizedAttrs<T>> = {}): Promise<T>
|
|
307
|
+
makeMany(amount: number, overrideParams: Partial<FactorizedAttrs<T>> = {}): Promise<T[]>
|
|
184
308
|
```
|
|
185
309
|
|
|
186
310
|
```typescript
|
|
@@ -192,7 +316,7 @@ new UserFactory().make({ email: 'other@mail.com' })
|
|
|
192
316
|
new UserFactory().makeMany(10, { email: 'other@mail.com' })
|
|
193
317
|
```
|
|
194
318
|
|
|
195
|
-
|
|
319
|
+
## `create` & `createMany`
|
|
196
320
|
|
|
197
321
|
the create and createMany method is similar to the make and makeMany method, but at the end the created entity instance gets persisted in the database using TypeORM entity manager.
|
|
198
322
|
|
|
@@ -200,8 +324,8 @@ the create and createMany method is similar to the make and makeMany method, but
|
|
|
200
324
|
- **saveOptions** - [Save options](https://github.com/typeorm/typeorm/blob/master/src/repository/SaveOptions.ts) from TypeORM
|
|
201
325
|
|
|
202
326
|
```typescript
|
|
203
|
-
create(overrideParams: Partial<
|
|
204
|
-
createMany(amount: number, overrideParams: Partial<
|
|
327
|
+
create(overrideParams: Partial<FactorizedAttrs<T>> = {}, saveOptions?: SaveOptions): Promise<T>
|
|
328
|
+
createMany(amount: number, overrideParams: Partial<FactorizedAttrs<T>> = {}, saveOptions?: SaveOptions): Promise<T[]>
|
|
205
329
|
```
|
|
206
330
|
|
|
207
331
|
```typescript
|
|
@@ -217,50 +341,24 @@ new UserFactory().create({ email: 'other@mail.com' }, { listeners: false })
|
|
|
217
341
|
new UserFactory().createMany(10, { email: 'other@mail.com' }, { listeners: false })
|
|
218
342
|
```
|
|
219
343
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
As the order of execution can be complex, you can check it here:
|
|
223
|
-
|
|
224
|
-
2. **Map function**: Map function alters the already existing entity.
|
|
225
|
-
3. **Override params**: Alters the already existing entity.
|
|
226
|
-
4. **Promises**: If some attribute is a promise, the promise will be resolved before the entity is created.
|
|
227
|
-
5. **Factories**: If some attribute is a factory, the factory will be executed with `make`/`create` like the previous one.
|
|
344
|
+
## faker
|
|
228
345
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
[Faker](https://github.com/marak/Faker.js/) package was previously a dependency of the project, but now it is optional due to its size. If you want to use faker, you may need to install it and import it.
|
|
232
|
-
|
|
233
|
-
Instead of the previous example:
|
|
234
|
-
|
|
235
|
-
```typescript
|
|
236
|
-
define(User, (faker: typeof Faker) => {
|
|
237
|
-
const firstName = faker.name.firstName()
|
|
238
|
-
const lastName = faker.name.lastName()
|
|
346
|
+
[Faker](https://github.com/faker-js/faker) package has been removed from `dependencies`. If you want to use it, please install it manually and just import when needed.
|
|
239
347
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
})
|
|
348
|
+
```bash
|
|
349
|
+
npm i [-D] @faker-js/faker
|
|
350
|
+
yarn add [-D] @faker-js/faker
|
|
244
351
|
```
|
|
245
352
|
|
|
246
|
-
You can do:
|
|
247
|
-
|
|
248
353
|
```typescript
|
|
249
|
-
import
|
|
354
|
+
import { faker } from '@faker-js/faker'
|
|
250
355
|
|
|
251
356
|
class UserFactory extends Factory<User> {
|
|
252
|
-
|
|
253
|
-
const user = new User()
|
|
254
|
-
|
|
255
|
-
user.name = faker.name.firstName()
|
|
256
|
-
user.lastname = faker.name.lastName()
|
|
257
|
-
|
|
258
|
-
return user
|
|
259
|
-
}
|
|
357
|
+
...
|
|
260
358
|
}
|
|
261
359
|
```
|
|
262
360
|
|
|
263
|
-
|
|
361
|
+
# Seeder
|
|
264
362
|
|
|
265
363
|
Seeder class is how we provide a way to insert data into databases, and could be executed by the command line or by helper method. Is an abstract class with one method to be implemented, and a helper function to run some more seeder sequentially.
|
|
266
364
|
|
|
@@ -272,7 +370,7 @@ class UserSeeder extends Seeder {
|
|
|
272
370
|
}
|
|
273
371
|
```
|
|
274
372
|
|
|
275
|
-
|
|
373
|
+
## `run`
|
|
276
374
|
|
|
277
375
|
This function is the one that needs to be defined when extending the class. Could use `call` to run some other seeders.
|
|
278
376
|
|
|
@@ -288,7 +386,7 @@ async run(connection: Connection) {
|
|
|
288
386
|
}
|
|
289
387
|
```
|
|
290
388
|
|
|
291
|
-
|
|
389
|
+
## `call`
|
|
292
390
|
|
|
293
391
|
This function allow to run some other seeders in a sequential way.
|
|
294
392
|
|
|
@@ -298,7 +396,7 @@ In order to use seeders from cli command, a default seeder class must be provide
|
|
|
298
396
|
<img src="./seeders.png" alt="logo" />
|
|
299
397
|
</p>
|
|
300
398
|
|
|
301
|
-
|
|
399
|
+
# CLI Configuration
|
|
302
400
|
|
|
303
401
|
There are two possible commands to execute, one to see the current configuration and one to run a seeder.
|
|
304
402
|
|
|
@@ -312,7 +410,7 @@ Add the following scripts to your `package.json` file to configure them.
|
|
|
312
410
|
}
|
|
313
411
|
```
|
|
314
412
|
|
|
315
|
-
|
|
413
|
+
## `config`
|
|
316
414
|
|
|
317
415
|
This command just print the connection configuration.
|
|
318
416
|
|
|
@@ -342,7 +440,7 @@ Example result
|
|
|
342
440
|
| `--configName` or `-n` | TypeORM default value | Name to the TypeORM config file. |
|
|
343
441
|
| `--root` or `-r` | TypeORM default value | Path to the TypeORM config file. |
|
|
344
442
|
|
|
345
|
-
|
|
443
|
+
## `seed`
|
|
346
444
|
|
|
347
445
|
This command execute a seeder, that could be specified as a parameter.
|
|
348
446
|
|
|
@@ -350,6 +448,8 @@ This command execute a seeder, that could be specified as a parameter.
|
|
|
350
448
|
typeorm-seeding seed
|
|
351
449
|
```
|
|
352
450
|
|
|
451
|
+
The name of the seeder to execute (either set with the `--seed` option or with default in [configs](#configuration)) must be the seeder's class name, and thus, the seeder must be exported with a named export. Please avoid default export for seeders: it may imply unwanted behavior. (See [\#75](https://github.com/jorgebodega/typeorm-seeding/issues/75)).
|
|
452
|
+
|
|
353
453
|
##### Options
|
|
354
454
|
|
|
355
455
|
| Option | Default | Description |
|
|
@@ -359,12 +459,12 @@ typeorm-seeding seed
|
|
|
359
459
|
| `--configName` or `-n` | TypeORM default value | Name to the TypeORM config file. |
|
|
360
460
|
| `--root` or `-r` | TypeORM default value | Path to the TypeORM config file. |
|
|
361
461
|
|
|
362
|
-
|
|
462
|
+
# Testing features
|
|
363
463
|
|
|
364
464
|
We provide some testing features that we already use to test this package, like connection configuration.
|
|
365
465
|
The entity factories can also be used in testing. To do so call the `useFactories` or `useSeeders` function.
|
|
366
466
|
|
|
367
|
-
|
|
467
|
+
## `useSeeders`
|
|
368
468
|
|
|
369
469
|
Execute one or more seeders.
|
|
370
470
|
|
|
@@ -375,7 +475,3 @@ useSeeders(
|
|
|
375
475
|
customOptions: Partial<ConnectionConfiguration>,
|
|
376
476
|
): Promise<void>
|
|
377
477
|
```
|
|
378
|
-
|
|
379
|
-
### Factories
|
|
380
|
-
|
|
381
|
-
If factories are being used to create entities, just remember to clean up fake data after every execution.
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/* istanbul ignore file */
|
|
6
6
|
require("reflect-metadata");
|
|
7
|
-
const yargs =
|
|
7
|
+
const yargs = tslib_1.__importStar(require("yargs"));
|
|
8
8
|
const seed_command_1 = require("./commands/seed.command");
|
|
9
9
|
const config_command_1 = require("./commands/config.command");
|
|
10
10
|
yargs
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AACA,0BAA0B;AAC1B,4BAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AACA,0BAA0B;AAC1B,4BAAyB;AACzB,qDAA8B;AAC9B,0DAAqD;AACrD,8DAAyD;AAEzD,KAAK;KACF,KAAK,CAAC,+BAA+B,CAAC;KACtC,OAAO,CAAC,IAAI,8BAAa,EAAE,CAAC;KAC5B,OAAO,CAAC,IAAI,0BAAW,EAAE,CAAC;KAC1B,iBAAiB,EAAE;KACnB,aAAa,CAAC,CAAC,CAAC;KAChB,MAAM,EAAE;KACR,IAAI,CAAC,GAAG,CAAC;KACT,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,IAAI,CAAA"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SeedCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const yargs_1 = require("yargs");
|
|
6
|
-
const ora_1 =
|
|
6
|
+
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
7
7
|
const chalk_1 = require("chalk");
|
|
8
8
|
const connection_1 = require("../connection");
|
|
9
9
|
const useSeeders_1 = require("../useSeeders");
|
|
@@ -66,7 +66,7 @@ class SeedCommand {
|
|
|
66
66
|
let seeder;
|
|
67
67
|
try {
|
|
68
68
|
const seederFiles = (0, fileHandling_1.calculateFilePaths)(options.seeders);
|
|
69
|
-
const seedersImported = await Promise.all(seederFiles.map((seederFile) => Promise.resolve().then(() =>
|
|
69
|
+
const seedersImported = await Promise.all(seederFiles.map((seederFile) => Promise.resolve().then(() => tslib_1.__importStar(require(seederFile)))));
|
|
70
70
|
const allSeeders = seedersImported.reduce((prev, curr) => Object.assign(prev, curr), {});
|
|
71
71
|
const seederWanted = args.seed || options.defaultSeeder;
|
|
72
72
|
seeder = allSeeders[seederWanted];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.command.js","sourceRoot":"","sources":["../../src/commands/seed.command.ts"],"names":[],"mappings":";;;;AAAA,iCAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"seed.command.js","sourceRoot":"","sources":["../../src/commands/seed.command.ts"],"names":[],"mappings":";;;;AAAA,iCAA4D;AAC5D,sDAA8B;AAC9B,iCAA4B;AAC5B,8CAAyE;AAEzE,8CAA0C;AAC1C,wDAA0D;AAE1D,6EAAyE;AASzE,MAAa,WAAW;IAAxB;QACE,YAAO,GAAG,MAAM,CAAA;QAChB,aAAQ,GAAG,gBAAgB,CAAA;IAmF7B,CAAC;IAjFC;;OAEG;IACH,OAAO,CAAC,IAAU;QAChB,OAAO,IAAI;aACR,MAAM,CAAC,GAAG,EAAE;YACX,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,+CAA+C;SAC1D,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACX,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,gCA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/dist/connection/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./configureConnection"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./fetchConnection"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./getConnectionOptions"), exports);
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;AAAA,gEAAqC;AACrC,4DAAiC;AACjC,iEAAsC"}
|
package/dist/factory.d.ts
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import type { SaveOptions } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
protected abstract
|
|
5
|
-
|
|
6
|
-
* This function is used to alter the generated values of entity, before it
|
|
7
|
-
* is persist into the database
|
|
8
|
-
*/
|
|
9
|
-
map(mapFunction: (entity: Entity) => void): this;
|
|
2
|
+
import type { Constructable, FactorizedAttrs } from './types';
|
|
3
|
+
export declare abstract class Factory<T> {
|
|
4
|
+
protected abstract entity: Constructable<T>;
|
|
5
|
+
protected abstract attrs: FactorizedAttrs<T>;
|
|
10
6
|
/**
|
|
11
7
|
* Make a new entity without persisting it
|
|
12
8
|
*/
|
|
13
|
-
make(overrideParams?: Partial<
|
|
9
|
+
make(overrideParams?: Partial<FactorizedAttrs<T>>): Promise<T>;
|
|
14
10
|
/**
|
|
15
11
|
* Make many new entities without persisting it
|
|
16
12
|
*/
|
|
17
|
-
makeMany(amount: number, overrideParams?: Partial<
|
|
13
|
+
makeMany(amount: number, overrideParams?: Partial<FactorizedAttrs<T>>): Promise<T[]>;
|
|
18
14
|
/**
|
|
19
15
|
* Create a new entity and persist it
|
|
20
16
|
*/
|
|
21
|
-
create(overrideParams?: Partial<
|
|
17
|
+
create(overrideParams?: Partial<FactorizedAttrs<T>>, saveOptions?: SaveOptions): Promise<T>;
|
|
22
18
|
/**
|
|
23
19
|
* Create many new entities and persist them
|
|
24
20
|
*/
|
|
25
|
-
createMany(amount: number, overrideParams?: Partial<
|
|
21
|
+
createMany(amount: number, overrideParams?: Partial<FactorizedAttrs<T>>, saveOptions?: SaveOptions): Promise<T[]>;
|
|
26
22
|
private makeEntity;
|
|
27
|
-
private
|
|
23
|
+
private applyLazyAttributes;
|
|
24
|
+
private static resolveValue;
|
|
28
25
|
}
|
package/dist/factory.js
CHANGED
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Factory = void 0;
|
|
4
4
|
const connection_1 = require("./connection");
|
|
5
|
-
const
|
|
5
|
+
const instanceAttribute_1 = require("./instanceAttribute");
|
|
6
|
+
const lazyInstanceAttribute_1 = require("./lazyInstanceAttribute");
|
|
7
|
+
const subfactory_1 = require("./subfactory");
|
|
6
8
|
class Factory {
|
|
7
|
-
/**
|
|
8
|
-
* This function is used to alter the generated values of entity, before it
|
|
9
|
-
* is persist into the database
|
|
10
|
-
*/
|
|
11
|
-
map(mapFunction) {
|
|
12
|
-
this.mapFunction = mapFunction;
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
9
|
/**
|
|
16
10
|
* Make a new entity without persisting it
|
|
17
11
|
*/
|
|
18
12
|
async make(overrideParams = {}) {
|
|
19
|
-
|
|
13
|
+
const attrs = { ...this.attrs, ...overrideParams };
|
|
14
|
+
const entity = await this.makeEntity(attrs, false);
|
|
15
|
+
await this.applyLazyAttributes(entity, attrs, false);
|
|
16
|
+
return entity;
|
|
20
17
|
}
|
|
21
18
|
/**
|
|
22
19
|
* Make many new entities without persisting it
|
|
@@ -32,9 +29,13 @@ class Factory {
|
|
|
32
29
|
* Create a new entity and persist it
|
|
33
30
|
*/
|
|
34
31
|
async create(overrideParams = {}, saveOptions) {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
32
|
+
const attrs = { ...this.attrs, ...overrideParams };
|
|
33
|
+
const preloadedAttrs = Object.entries(attrs).filter(([, value]) => !(value instanceof lazyInstanceAttribute_1.LazyInstanceAttribute));
|
|
34
|
+
const entity = await this.makeEntity(Object.fromEntries(preloadedAttrs), true);
|
|
35
|
+
const em = (await (0, connection_1.fetchConnection)()).createEntityManager();
|
|
36
|
+
const savedEntity = await em.save(entity, saveOptions);
|
|
37
|
+
await this.applyLazyAttributes(savedEntity, attrs, true);
|
|
38
|
+
return em.save(savedEntity, saveOptions);
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Create many new entities and persist them
|
|
@@ -46,32 +47,37 @@ class Factory {
|
|
|
46
47
|
}
|
|
47
48
|
return list;
|
|
48
49
|
}
|
|
49
|
-
async makeEntity(
|
|
50
|
-
const entity = this.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
async resolveEntity(entity, isSeeding) {
|
|
60
|
-
for (const attribute in entity) {
|
|
61
|
-
const attributeValue = entity[attribute];
|
|
62
|
-
if ((0, isPromiseLike_1.isPromiseLike)(attributeValue)) {
|
|
63
|
-
entity[attribute] = await attributeValue;
|
|
50
|
+
async makeEntity(attrs, shouldPersist) {
|
|
51
|
+
const entity = new this.entity();
|
|
52
|
+
await Promise.all(Object.entries(attrs).map(async ([key, value]) => {
|
|
53
|
+
Object.assign(entity, { [key]: await Factory.resolveValue(value, shouldPersist) });
|
|
54
|
+
}));
|
|
55
|
+
await Promise.all(Object.entries(attrs).map(async ([key, value]) => {
|
|
56
|
+
if (value instanceof instanceAttribute_1.InstanceAttribute) {
|
|
57
|
+
const newAttrib = value.resolve(entity);
|
|
58
|
+
Object.assign(entity, { [key]: await Factory.resolveValue(newAttrib, shouldPersist) });
|
|
64
59
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
}));
|
|
61
|
+
return entity;
|
|
62
|
+
}
|
|
63
|
+
async applyLazyAttributes(entity, attrs, shouldPersist) {
|
|
64
|
+
await Promise.all(Object.entries(attrs).map(async ([key, value]) => {
|
|
65
|
+
if (value instanceof lazyInstanceAttribute_1.LazyInstanceAttribute) {
|
|
66
|
+
const newAttrib = value.resolve(entity);
|
|
67
|
+
Object.assign(entity, { [key]: await Factory.resolveValue(newAttrib, shouldPersist) });
|
|
72
68
|
}
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
static resolveValue(value, shouldPersist) {
|
|
72
|
+
if (value instanceof subfactory_1.Subfactory) {
|
|
73
|
+
return shouldPersist ? value.create() : value.make();
|
|
74
|
+
}
|
|
75
|
+
else if (value instanceof Function) {
|
|
76
|
+
return value();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return value;
|
|
73
80
|
}
|
|
74
|
-
return entity;
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
exports.Factory = Factory;
|
package/dist/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,2DAAuD;AACvD,mEAA+D;AAC/D,6CAAyC;AAGzC,MAAsB,OAAO;IAI3B;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,iBAA8C,EAAE;QACzD,MAAM,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,cAAc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C,CAAA;aACvF;QACH,CAAC,CAAC,CACH,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,MAAS,EAAE,KAAyB,EAAE,aAAsB;QAC5F,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC/C,IAAI,KAAK,YAAY,6CAAqB,EAAE;gBAC1C,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;gBACvC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,CAAC,CAAA;aACvF;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,KAAc,EAAE,aAAsB;QAChE,IAAI,KAAK,YAAY,uBAAU,EAAE;YAC/B,OAAO,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;SACrD;aAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;YACpC,OAAO,KAAK,EAAE,CAAA;SACf;aAAM;YACL,OAAO,KAAK,CAAA;SACb;IACH,CAAC;CACF;AAnGD,0BAmGC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./connection"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./factory"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./instanceAttribute"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lazyInstanceAttribute"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./seeder"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./subfactory"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./useSeeders"), exports);
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,oDAAyB;AACzB,8DAAmC;AACnC,kEAAuC;AACvC,mDAAwB;AACxB,uDAA4B;AAC5B,kDAAuB;AACvB,uDAA4B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstanceAttribute = void 0;
|
|
4
|
+
const lazyAttribute_1 = require("./lazyAttribute");
|
|
5
|
+
class InstanceAttribute extends lazyAttribute_1.LazyAttribute {
|
|
6
|
+
}
|
|
7
|
+
exports.InstanceAttribute = InstanceAttribute;
|
|
8
|
+
//# sourceMappingURL=instanceAttribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instanceAttribute.js","sourceRoot":"","sources":["../src/instanceAttribute.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAE/C,MAAa,iBAAwB,SAAQ,6BAAmB;CAAG;AAAnE,8CAAmE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LazyAttribute = void 0;
|
|
4
|
+
class LazyAttribute {
|
|
5
|
+
constructor(callback) {
|
|
6
|
+
this.callback = callback;
|
|
7
|
+
}
|
|
8
|
+
resolve(entity) {
|
|
9
|
+
return this.callback(entity);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.LazyAttribute = LazyAttribute;
|
|
13
|
+
//# sourceMappingURL=lazyAttribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyAttribute.js","sourceRoot":"","sources":["../src/lazyAttribute.ts"],"names":[],"mappings":";;;AAEA,MAAsB,aAAa;IACjC,YAAoB,QAAqC;QAArC,aAAQ,GAAR,QAAQ,CAA6B;IAAG,CAAC;IAE7D,OAAO,CAAC,MAAS;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC9B,CAAC;CACF;AAND,sCAMC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LazyInstanceAttribute = void 0;
|
|
4
|
+
const lazyAttribute_1 = require("./lazyAttribute");
|
|
5
|
+
class LazyInstanceAttribute extends lazyAttribute_1.LazyAttribute {
|
|
6
|
+
}
|
|
7
|
+
exports.LazyInstanceAttribute = LazyInstanceAttribute;
|
|
8
|
+
//# sourceMappingURL=lazyInstanceAttribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyInstanceAttribute.js","sourceRoot":"","sources":["../src/lazyInstanceAttribute.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAE/C,MAAa,qBAA4B,SAAQ,6BAAmB;CAAG;AAAvE,sDAAuE"}
|
package/dist/seeder.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Connection } from 'typeorm';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Constructable } from './types';
|
|
3
3
|
export declare abstract class Seeder {
|
|
4
4
|
abstract run(connection: Connection): Promise<void>;
|
|
5
|
-
protected call(connection: Connection, seeders:
|
|
5
|
+
protected call(connection: Connection, seeders: Constructable<Seeder>[]): Promise<void>;
|
|
6
6
|
}
|
package/dist/seeder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seeder.js","sourceRoot":"","sources":["../src/seeder.ts"],"names":[],"mappings":";;;AAGA,MAAsB,MAAM;IAGhB,KAAK,CAAC,IAAI,CAAC,UAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"seeder.js","sourceRoot":"","sources":["../src/seeder.ts"],"names":[],"mappings":";;;AAGA,MAAsB,MAAM;IAGhB,KAAK,CAAC,IAAI,CAAC,UAAsB,EAAE,OAAgC;QAC3E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,MAAM,IAAI,MAAM,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;SACnC;IACH,CAAC;CACF;AARD,wBAQC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Factory } from './factory';
|
|
2
|
+
import type { Constructable, FactorizedAttrs } from './types';
|
|
3
|
+
export declare class Subfactory<T> {
|
|
4
|
+
private factoryInstance;
|
|
5
|
+
private values?;
|
|
6
|
+
private count?;
|
|
7
|
+
constructor(factory: Constructable<Factory<T>>);
|
|
8
|
+
constructor(factory: Constructable<Factory<T>>, values?: Partial<FactorizedAttrs<T>>);
|
|
9
|
+
constructor(factory: Constructable<Factory<T>>, count?: number);
|
|
10
|
+
constructor(factory: Constructable<Factory<T>>, values?: Partial<FactorizedAttrs<T>>, count?: number);
|
|
11
|
+
create(): Promise<T[]> | Promise<T>;
|
|
12
|
+
make(): Promise<T[]> | Promise<T>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Subfactory = void 0;
|
|
4
|
+
class Subfactory {
|
|
5
|
+
constructor(factory, countOrValues, count) {
|
|
6
|
+
this.factoryInstance = new factory();
|
|
7
|
+
this.values = typeof countOrValues === 'number' ? undefined : countOrValues;
|
|
8
|
+
this.count = typeof countOrValues === 'number' ? countOrValues : count;
|
|
9
|
+
}
|
|
10
|
+
create() {
|
|
11
|
+
if (this.count !== undefined) {
|
|
12
|
+
return this.factoryInstance.createMany(this.count, this.values);
|
|
13
|
+
}
|
|
14
|
+
return this.factoryInstance.create(this.values);
|
|
15
|
+
}
|
|
16
|
+
make() {
|
|
17
|
+
if (this.count !== undefined) {
|
|
18
|
+
return this.factoryInstance.makeMany(this.count, this.values);
|
|
19
|
+
}
|
|
20
|
+
return this.factoryInstance.make(this.values);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Subfactory = Subfactory;
|
|
24
|
+
//# sourceMappingURL=subfactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subfactory.js","sourceRoot":"","sources":["../src/subfactory.ts"],"names":[],"mappings":";;;AAGA,MAAa,UAAU;IAUrB,YACE,OAAkC,EAClC,aAAoD,EACpD,KAAc;QAEd,IAAI,CAAC,eAAe,GAAG,IAAI,OAAO,EAAE,CAAA;QACpC,IAAI,CAAC,MAAM,GAAG,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAA;QAC3E,IAAI,CAAC,KAAK,GAAG,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAA;IACxE,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;SAChE;QAED,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACjD,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;SAC9D;QAED,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;CACF;AAnCD,gCAmCC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ConnectionOptions as TypeORMConnectionOptions } from 'typeorm';
|
|
2
|
-
|
|
2
|
+
import type { LazyAttribute } from './lazyAttribute';
|
|
3
|
+
import type { Subfactory } from './subfactory';
|
|
3
4
|
export declare type ConnectionOptions = TypeORMConnectionOptions & {
|
|
4
5
|
seeders: string[];
|
|
5
6
|
defaultSeeder: string;
|
|
@@ -9,3 +10,9 @@ export declare type ConnectionConfiguration = {
|
|
|
9
10
|
configName?: string;
|
|
10
11
|
connection: string;
|
|
11
12
|
};
|
|
13
|
+
export declare type Constructable<T> = new () => T;
|
|
14
|
+
export declare type FactorizedAttr<V> = V | (() => V | Promise<V>) | Subfactory<V extends Array<infer U> ? U : V>;
|
|
15
|
+
export declare type FactorizedAttrs<T> = {
|
|
16
|
+
[K in keyof Partial<T>]: FactorizedAttr<T[K]> | LazyAttribute<T, FactorizedAttr<T[K]>>;
|
|
17
|
+
};
|
|
18
|
+
export declare type LazyAttributeCallback<T, V> = (entity: T) => V;
|
package/dist/useSeeders.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Seeder } from './seeder';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function useSeeders(entrySeeders:
|
|
4
|
-
export declare function useSeeders(entrySeeders:
|
|
2
|
+
import type { ConnectionConfiguration, Constructable } from './types';
|
|
3
|
+
export declare function useSeeders(entrySeeders: Constructable<Seeder> | Constructable<Seeder>[]): Promise<void>;
|
|
4
|
+
export declare function useSeeders(entrySeeders: Constructable<Seeder> | Constructable<Seeder>[], customOptions: Partial<ConnectionConfiguration>): Promise<void>;
|
package/dist/useSeeders.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSeeders.js","sourceRoot":"","sources":["../src/useSeeders.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AAU5D,KAAK,UAAU,UAAU,CAC9B,
|
|
1
|
+
{"version":3,"file":"useSeeders.js","sourceRoot":"","sources":["../src/useSeeders.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AAU5D,KAAK,UAAU,UAAU,CAC9B,YAA6D,EAC7D,aAAgD;IAEhD,IAAI,aAAa;QAAE,IAAA,gCAAmB,EAAC,aAAa,CAAC,CAAA;IAErD,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAe,GAAE,CAAA;IAE1C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;IAC3E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,MAAM,IAAI,MAAM,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;KACnC;AACH,CAAC;AAZD,gCAYC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jorgebodega/typeorm-seeding",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "🌱 A delightful way to seed test data into your database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gery Hirschfeld <gery.hirschfeld@w3tec.ch> (https://github.com/hirsch88)",
|
|
@@ -36,39 +36,38 @@
|
|
|
36
36
|
"typecheck": "tsc --noEmit"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@faker-js/faker": "6.0.0",
|
|
39
40
|
"@semantic-release/changelog": "6.0.1",
|
|
40
41
|
"@semantic-release/git": "10.0.1",
|
|
41
42
|
"@tsconfig/node16": "1.0.2",
|
|
42
43
|
"@types/bcryptjs": "2.4.2",
|
|
43
44
|
"@types/chalk": "2.2.0",
|
|
44
|
-
"@types/faker": "5.5.9",
|
|
45
45
|
"@types/glob": "7.2.0",
|
|
46
|
-
"@types/jest": "27.4.
|
|
47
|
-
"@types/node": "
|
|
48
|
-
"@types/yargs": "17.0.
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
50
|
-
"@typescript-eslint/parser": "5.
|
|
46
|
+
"@types/jest": "27.4.1",
|
|
47
|
+
"@types/node": "17.0.17",
|
|
48
|
+
"@types/yargs": "17.0.10",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "5.15.0",
|
|
50
|
+
"@typescript-eslint/parser": "5.15.0",
|
|
51
51
|
"bcryptjs": "2.4.3",
|
|
52
|
-
"eslint": "8.
|
|
53
|
-
"eslint-config-prettier": "8.
|
|
52
|
+
"eslint": "8.11.0",
|
|
53
|
+
"eslint-config-prettier": "8.5.0",
|
|
54
54
|
"eslint-plugin-import": "2.25.4",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"semantic-release": "18.0.1",
|
|
55
|
+
"jest": "27.5.1",
|
|
56
|
+
"prettier": "2.6.0",
|
|
57
|
+
"rimraf": "3.0.2",
|
|
58
|
+
"semantic-release": "19.0.2",
|
|
60
59
|
"sqlite3": "5.0.2",
|
|
61
|
-
"ts-jest": "27.1.
|
|
62
|
-
"ts-node": "10.
|
|
60
|
+
"ts-jest": "27.1.3",
|
|
61
|
+
"ts-node": "10.7.0",
|
|
63
62
|
"typeorm": "0.2.41",
|
|
64
|
-
"typescript": "4.
|
|
63
|
+
"typescript": "4.6.2"
|
|
65
64
|
},
|
|
66
65
|
"dependencies": {
|
|
67
|
-
"chalk": "
|
|
68
|
-
"glob": "
|
|
69
|
-
"ora": "
|
|
70
|
-
"reflect-metadata": "
|
|
71
|
-
"yargs": "
|
|
66
|
+
"chalk": "4.1.2",
|
|
67
|
+
"glob": "7.2.0",
|
|
68
|
+
"ora": "5.4.1",
|
|
69
|
+
"reflect-metadata": "0.1.13",
|
|
70
|
+
"yargs": "17.4.0"
|
|
72
71
|
},
|
|
73
72
|
"peerDependencies": {
|
|
74
73
|
"typeorm": "^0.2.41"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isPromiseLike: (o: any) => o is Promise<any>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPromiseLike = void 0;
|
|
4
|
-
const isPromiseLike = (o) => o && Object.prototype.toString.call(o) === '[object Promise]';
|
|
5
|
-
exports.isPromiseLike = isPromiseLike;
|
|
6
|
-
//# sourceMappingURL=isPromiseLike.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isPromiseLike.js","sourceRoot":"","sources":["../../src/utils/isPromiseLike.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,CAAM,EAAqB,EAAE,CACzD,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAA;AADlD,QAAA,aAAa,iBACqC"}
|