@travetto/schema-faker 3.0.0-rc.4 → 3.0.0-rc.6
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/README.md +3 -3
- package/{index.ts → __index__.ts} +0 -0
- package/package.json +7 -5
- package/src/faker.ts +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
2
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/schema-faker/
|
|
2
|
+
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/schema-faker/DOC.ts and execute "npx trv doc" to rebuild -->
|
|
3
3
|
# Schema Faker
|
|
4
4
|
## Data generation for schema-registered objects.
|
|
5
5
|
|
|
@@ -23,14 +23,14 @@ By default all types are mapped as-is:
|
|
|
23
23
|
* url
|
|
24
24
|
* telephone
|
|
25
25
|
* postalCode
|
|
26
|
-
* Sub-schemas as registered via [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#
|
|
26
|
+
* Sub-schemas as registered via [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L14) decorators.
|
|
27
27
|
|
|
28
28
|
In addition to the general types, the code relies upon name matching to provide additional refinement:
|
|
29
29
|
|
|
30
30
|
**Code: Supported Mappings**
|
|
31
31
|
```typescript
|
|
32
32
|
static #namesToType = {
|
|
33
|
-
string: new Map([
|
|
33
|
+
string: new Map<RegExp, () => string>([
|
|
34
34
|
[/^(image|img).*url$/, faker.image.imageUrl],
|
|
35
35
|
[/^url$/, faker.internet.url],
|
|
36
36
|
[/^email(addr(ress)?)?$/, faker.internet.email],
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/schema-faker",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.0.0-rc.4",
|
|
3
|
+
"version": "3.0.0-rc.6",
|
|
5
4
|
"description": "Data generation for schema-registered objects.",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"faker",
|
|
@@ -17,19 +16,22 @@
|
|
|
17
16
|
"name": "Travetto Framework"
|
|
18
17
|
},
|
|
19
18
|
"files": [
|
|
20
|
-
"
|
|
19
|
+
"__index__.ts",
|
|
21
20
|
"src"
|
|
22
21
|
],
|
|
23
|
-
"main": "
|
|
22
|
+
"main": "__index__.ts",
|
|
24
23
|
"repository": {
|
|
25
24
|
"url": "https://github.com/travetto/travetto.git",
|
|
26
25
|
"directory": "module/schema-faker"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"@travetto/schema": "^3.0.0-rc.
|
|
28
|
+
"@travetto/schema": "^3.0.0-rc.6",
|
|
30
29
|
"@types/faker": "^5.5.9",
|
|
31
30
|
"faker": "^5.5.3"
|
|
32
31
|
},
|
|
32
|
+
"travetto": {
|
|
33
|
+
"displayName": "Schema Faker"
|
|
34
|
+
},
|
|
33
35
|
"publishConfig": {
|
|
34
36
|
"access": "public"
|
|
35
37
|
}
|
package/src/faker.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import faker from 'faker';
|
|
2
2
|
|
|
3
3
|
import { Class } from '@travetto/base';
|
|
4
4
|
import { BindUtil, SchemaRegistry, FieldConfig, CommonRegExp } from '@travetto/schema';
|
|
@@ -21,7 +21,7 @@ export class SchemaFaker {
|
|
|
21
21
|
* Mapping of field types to faker utils
|
|
22
22
|
*/
|
|
23
23
|
static #namesToType = {
|
|
24
|
-
string: new Map([
|
|
24
|
+
string: new Map<RegExp, () => string>([
|
|
25
25
|
[/^(image|img).*url$/, faker.image.imageUrl],
|
|
26
26
|
[/^url$/, faker.internet.url],
|
|
27
27
|
[/^email(addr(ress)?)?$/, faker.internet.email],
|
|
@@ -203,6 +203,6 @@ export class SchemaFaker {
|
|
|
203
203
|
out[f] = this.#value(fieldConfig);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
return BindUtil.bindSchema(cls, out, view);
|
|
206
|
+
return BindUtil.bindSchema(cls, out, { view });
|
|
207
207
|
}
|
|
208
208
|
}
|