struct-fakerator 3.2.0 → 3.3.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/dist/create_generator_fn_async.cjs +173 -0
- package/dist/create_generator_fn_async.js +121 -0
- package/dist/index.cjs +16 -5
- package/dist/index.js +1 -0
- package/dist/types/src/create_generator_fn_async.d.ts +10 -0
- package/dist/types/src/create_generator_fn_async.test.d.ts +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +53 -54
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createGeneratorByTypeAsync: ()=>createGeneratorByTypeAsync,
|
|
28
|
+
createSelectionGeneratorAsync: ()=>createSelectionGeneratorAsync,
|
|
29
|
+
createTupleGeneratorAsync: ()=>createTupleGeneratorAsync,
|
|
30
|
+
createValueGeneratorAsync: ()=>createValueGeneratorAsync,
|
|
31
|
+
createArrayGeneratorAsync: ()=>createArrayGeneratorAsync,
|
|
32
|
+
createBoundedSeriesGeneratorAsync: ()=>createBoundedSeriesGeneratorAsync,
|
|
33
|
+
createObjectGeneratorAsync: ()=>createObjectGeneratorAsync
|
|
34
|
+
});
|
|
35
|
+
const faker_namespaceObject = require("@faker-js/faker");
|
|
36
|
+
const external_valibot_namespaceObject = require("valibot");
|
|
37
|
+
const external_config_scheme_cjs_namespaceObject = require("./config_scheme.cjs");
|
|
38
|
+
const _createValueGeneratorAsync = (config, path)=>{
|
|
39
|
+
try {
|
|
40
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.valueConfigScheme, config);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
throw new Error(`config path: ${path}.value\n${err}`);
|
|
43
|
+
}
|
|
44
|
+
return ()=>Promise.resolve().then(()=>config.generateFn());
|
|
45
|
+
};
|
|
46
|
+
const createValueGeneratorAsync = (config)=>_createValueGeneratorAsync(config, "*");
|
|
47
|
+
const _createSelectionGeneratorAsync = (config, path)=>{
|
|
48
|
+
try {
|
|
49
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.selectionConfigScheme, config);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
throw new Error(`config path: ${path}.select\n${err}`);
|
|
52
|
+
}
|
|
53
|
+
const { items } = config;
|
|
54
|
+
return ()=>Promise.resolve(items[faker_namespaceObject.faker.number.int(items.length - 1)]);
|
|
55
|
+
};
|
|
56
|
+
const createSelectionGeneratorAsync = (config)=>_createSelectionGeneratorAsync(config, "*");
|
|
57
|
+
const _createObjectGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
58
|
+
try {
|
|
59
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.objConfigScheme, config);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
throw new Error(`config path: ${path}.obj\n ${err}`);
|
|
62
|
+
}
|
|
63
|
+
const keyWithFns = Object.entries(config.content).map(([key, subConfig])=>[
|
|
64
|
+
key,
|
|
65
|
+
_createGeneratorByTypeAsync(subConfig, `${path}.obj[${key}]`, customTypeMatch)
|
|
66
|
+
]);
|
|
67
|
+
return async ()=>{
|
|
68
|
+
const result = {};
|
|
69
|
+
const results = await Promise.all(keyWithFns.map(([key, generateFn])=>generateFn().then((v)=>[
|
|
70
|
+
key,
|
|
71
|
+
v
|
|
72
|
+
])));
|
|
73
|
+
for (const [key, value] of results)result[key] = value;
|
|
74
|
+
if ("transformer" in config && "function" == typeof config.transformer) return config.transformer(result);
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const createObjectGeneratorAsync = (config, customTypeMatch)=>_createObjectGeneratorAsync(config, "*", customTypeMatch);
|
|
79
|
+
const _createArrayGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
80
|
+
try {
|
|
81
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.arrayConfigScheme, config);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
throw new Error(`config path: ${path}.arr\n ${err}`);
|
|
84
|
+
}
|
|
85
|
+
const itemGeneratorFn = _createGeneratorByTypeAsync(config.item, `${path}.arr`, customTypeMatch);
|
|
86
|
+
if (config.next) {
|
|
87
|
+
const next = config.next;
|
|
88
|
+
return async ()=>{
|
|
89
|
+
let prev = await itemGeneratorFn();
|
|
90
|
+
const result = [];
|
|
91
|
+
for(let i = 0; i < config.len; i += 1){
|
|
92
|
+
const nextValue = next(prev, await itemGeneratorFn());
|
|
93
|
+
result.push(nextValue);
|
|
94
|
+
prev = nextValue;
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return ()=>Promise.all(Array.from({
|
|
100
|
+
length: config.len ?? 0
|
|
101
|
+
}, itemGeneratorFn));
|
|
102
|
+
};
|
|
103
|
+
const createArrayGeneratorAsync = (config, customTypeMatch)=>_createArrayGeneratorAsync(config, "*", customTypeMatch);
|
|
104
|
+
const _createTupleGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
105
|
+
try {
|
|
106
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.tupleConfigScheme, config);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
throw new Error(`config path: ${path}.tuple\n ${err}`);
|
|
109
|
+
}
|
|
110
|
+
const itemsFns = config.configItems.map((configItem, index)=>_createGeneratorByTypeAsync(configItem, `${path}.tuple[${index}]`, customTypeMatch));
|
|
111
|
+
return ()=>Promise.all(itemsFns.map((generateFn)=>generateFn()));
|
|
112
|
+
};
|
|
113
|
+
const createTupleGeneratorAsync = (config, customTypeMatch)=>_createTupleGeneratorAsync(config, "*", customTypeMatch);
|
|
114
|
+
const _createBoundedSeriesGeneratorAsync = (config, path)=>{
|
|
115
|
+
try {
|
|
116
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.boundedSeriesScheme, config);
|
|
117
|
+
} catch (err) {
|
|
118
|
+
throw new Error(`config path: ${path}.boundedSeries\n ${err}`);
|
|
119
|
+
}
|
|
120
|
+
const { upperLimit, lowerLimit, createInitValue, count } = config;
|
|
121
|
+
return ()=>{
|
|
122
|
+
let value = createInitValue();
|
|
123
|
+
const boundedSeries = [];
|
|
124
|
+
for(let i = 0; i < count; i += 1){
|
|
125
|
+
value = faker_namespaceObject.faker.number.float({
|
|
126
|
+
max: upperLimit,
|
|
127
|
+
min: lowerLimit
|
|
128
|
+
}) * value;
|
|
129
|
+
boundedSeries.push(value);
|
|
130
|
+
}
|
|
131
|
+
return Promise.resolve(boundedSeries);
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const createBoundedSeriesGeneratorAsync = (config)=>_createBoundedSeriesGeneratorAsync(config, "*");
|
|
135
|
+
const _createGeneratorByTypeAsync = (config, path, customTypeMatch)=>{
|
|
136
|
+
switch(config.type){
|
|
137
|
+
case "obj":
|
|
138
|
+
return _createObjectGeneratorAsync(config, path, customTypeMatch);
|
|
139
|
+
case "arr":
|
|
140
|
+
return _createArrayGeneratorAsync(config, path, customTypeMatch);
|
|
141
|
+
case "tuple":
|
|
142
|
+
return _createTupleGeneratorAsync(config, path, customTypeMatch);
|
|
143
|
+
case "select":
|
|
144
|
+
return _createSelectionGeneratorAsync(config, path);
|
|
145
|
+
case "value":
|
|
146
|
+
return _createValueGeneratorAsync(config, path);
|
|
147
|
+
case "bounded_series":
|
|
148
|
+
return _createBoundedSeriesGeneratorAsync(config, path);
|
|
149
|
+
default:
|
|
150
|
+
if (customTypeMatch) return createValueGeneratorAsync(customTypeMatch(config, path));
|
|
151
|
+
throw new Error(`path: ${path}\nconfig type is not supported`);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const createGeneratorByTypeAsync = (config, customTypeMatch)=>_createGeneratorByTypeAsync(config, "*", customTypeMatch);
|
|
155
|
+
exports.createArrayGeneratorAsync = __webpack_exports__.createArrayGeneratorAsync;
|
|
156
|
+
exports.createBoundedSeriesGeneratorAsync = __webpack_exports__.createBoundedSeriesGeneratorAsync;
|
|
157
|
+
exports.createGeneratorByTypeAsync = __webpack_exports__.createGeneratorByTypeAsync;
|
|
158
|
+
exports.createObjectGeneratorAsync = __webpack_exports__.createObjectGeneratorAsync;
|
|
159
|
+
exports.createSelectionGeneratorAsync = __webpack_exports__.createSelectionGeneratorAsync;
|
|
160
|
+
exports.createTupleGeneratorAsync = __webpack_exports__.createTupleGeneratorAsync;
|
|
161
|
+
exports.createValueGeneratorAsync = __webpack_exports__.createValueGeneratorAsync;
|
|
162
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
163
|
+
"createArrayGeneratorAsync",
|
|
164
|
+
"createBoundedSeriesGeneratorAsync",
|
|
165
|
+
"createGeneratorByTypeAsync",
|
|
166
|
+
"createObjectGeneratorAsync",
|
|
167
|
+
"createSelectionGeneratorAsync",
|
|
168
|
+
"createTupleGeneratorAsync",
|
|
169
|
+
"createValueGeneratorAsync"
|
|
170
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
171
|
+
Object.defineProperty(exports, '__esModule', {
|
|
172
|
+
value: true
|
|
173
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { faker } from "@faker-js/faker";
|
|
2
|
+
import { assert } from "valibot";
|
|
3
|
+
import { arrayConfigScheme, boundedSeriesScheme, objConfigScheme, selectionConfigScheme, tupleConfigScheme, valueConfigScheme } from "./config_scheme.js";
|
|
4
|
+
const _createValueGeneratorAsync = (config, path)=>{
|
|
5
|
+
try {
|
|
6
|
+
assert(valueConfigScheme, config);
|
|
7
|
+
} catch (err) {
|
|
8
|
+
throw new Error(`config path: ${path}.value\n${err}`);
|
|
9
|
+
}
|
|
10
|
+
return ()=>Promise.resolve().then(()=>config.generateFn());
|
|
11
|
+
};
|
|
12
|
+
const createValueGeneratorAsync = (config)=>_createValueGeneratorAsync(config, "*");
|
|
13
|
+
const _createSelectionGeneratorAsync = (config, path)=>{
|
|
14
|
+
try {
|
|
15
|
+
assert(selectionConfigScheme, config);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
throw new Error(`config path: ${path}.select\n${err}`);
|
|
18
|
+
}
|
|
19
|
+
const { items } = config;
|
|
20
|
+
return ()=>Promise.resolve(items[faker.number.int(items.length - 1)]);
|
|
21
|
+
};
|
|
22
|
+
const createSelectionGeneratorAsync = (config)=>_createSelectionGeneratorAsync(config, "*");
|
|
23
|
+
const _createObjectGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
24
|
+
try {
|
|
25
|
+
assert(objConfigScheme, config);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
throw new Error(`config path: ${path}.obj\n ${err}`);
|
|
28
|
+
}
|
|
29
|
+
const keyWithFns = Object.entries(config.content).map(([key, subConfig])=>[
|
|
30
|
+
key,
|
|
31
|
+
_createGeneratorByTypeAsync(subConfig, `${path}.obj[${key}]`, customTypeMatch)
|
|
32
|
+
]);
|
|
33
|
+
return async ()=>{
|
|
34
|
+
const result = {};
|
|
35
|
+
const results = await Promise.all(keyWithFns.map(([key, generateFn])=>generateFn().then((v)=>[
|
|
36
|
+
key,
|
|
37
|
+
v
|
|
38
|
+
])));
|
|
39
|
+
for (const [key, value] of results)result[key] = value;
|
|
40
|
+
if ("transformer" in config && "function" == typeof config.transformer) return config.transformer(result);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const createObjectGeneratorAsync = (config, customTypeMatch)=>_createObjectGeneratorAsync(config, "*", customTypeMatch);
|
|
45
|
+
const _createArrayGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
46
|
+
try {
|
|
47
|
+
assert(arrayConfigScheme, config);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
throw new Error(`config path: ${path}.arr\n ${err}`);
|
|
50
|
+
}
|
|
51
|
+
const itemGeneratorFn = _createGeneratorByTypeAsync(config.item, `${path}.arr`, customTypeMatch);
|
|
52
|
+
if (config.next) {
|
|
53
|
+
const next = config.next;
|
|
54
|
+
return async ()=>{
|
|
55
|
+
let prev = await itemGeneratorFn();
|
|
56
|
+
const result = [];
|
|
57
|
+
for(let i = 0; i < config.len; i += 1){
|
|
58
|
+
const nextValue = next(prev, await itemGeneratorFn());
|
|
59
|
+
result.push(nextValue);
|
|
60
|
+
prev = nextValue;
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return ()=>Promise.all(Array.from({
|
|
66
|
+
length: config.len ?? 0
|
|
67
|
+
}, itemGeneratorFn));
|
|
68
|
+
};
|
|
69
|
+
const createArrayGeneratorAsync = (config, customTypeMatch)=>_createArrayGeneratorAsync(config, "*", customTypeMatch);
|
|
70
|
+
const _createTupleGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
71
|
+
try {
|
|
72
|
+
assert(tupleConfigScheme, config);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
throw new Error(`config path: ${path}.tuple\n ${err}`);
|
|
75
|
+
}
|
|
76
|
+
const itemsFns = config.configItems.map((configItem, index)=>_createGeneratorByTypeAsync(configItem, `${path}.tuple[${index}]`, customTypeMatch));
|
|
77
|
+
return ()=>Promise.all(itemsFns.map((generateFn)=>generateFn()));
|
|
78
|
+
};
|
|
79
|
+
const createTupleGeneratorAsync = (config, customTypeMatch)=>_createTupleGeneratorAsync(config, "*", customTypeMatch);
|
|
80
|
+
const _createBoundedSeriesGeneratorAsync = (config, path)=>{
|
|
81
|
+
try {
|
|
82
|
+
assert(boundedSeriesScheme, config);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
throw new Error(`config path: ${path}.boundedSeries\n ${err}`);
|
|
85
|
+
}
|
|
86
|
+
const { upperLimit, lowerLimit, createInitValue, count } = config;
|
|
87
|
+
return ()=>{
|
|
88
|
+
let value = createInitValue();
|
|
89
|
+
const boundedSeries = [];
|
|
90
|
+
for(let i = 0; i < count; i += 1){
|
|
91
|
+
value = faker.number.float({
|
|
92
|
+
max: upperLimit,
|
|
93
|
+
min: lowerLimit
|
|
94
|
+
}) * value;
|
|
95
|
+
boundedSeries.push(value);
|
|
96
|
+
}
|
|
97
|
+
return Promise.resolve(boundedSeries);
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const createBoundedSeriesGeneratorAsync = (config)=>_createBoundedSeriesGeneratorAsync(config, "*");
|
|
101
|
+
const _createGeneratorByTypeAsync = (config, path, customTypeMatch)=>{
|
|
102
|
+
switch(config.type){
|
|
103
|
+
case "obj":
|
|
104
|
+
return _createObjectGeneratorAsync(config, path, customTypeMatch);
|
|
105
|
+
case "arr":
|
|
106
|
+
return _createArrayGeneratorAsync(config, path, customTypeMatch);
|
|
107
|
+
case "tuple":
|
|
108
|
+
return _createTupleGeneratorAsync(config, path, customTypeMatch);
|
|
109
|
+
case "select":
|
|
110
|
+
return _createSelectionGeneratorAsync(config, path);
|
|
111
|
+
case "value":
|
|
112
|
+
return _createValueGeneratorAsync(config, path);
|
|
113
|
+
case "bounded_series":
|
|
114
|
+
return _createBoundedSeriesGeneratorAsync(config, path);
|
|
115
|
+
default:
|
|
116
|
+
if (customTypeMatch) return createValueGeneratorAsync(customTypeMatch(config, path));
|
|
117
|
+
throw new Error(`path: ${path}\nconfig type is not supported`);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const createGeneratorByTypeAsync = (config, customTypeMatch)=>_createGeneratorByTypeAsync(config, "*", customTypeMatch);
|
|
121
|
+
export { createArrayGeneratorAsync, createBoundedSeriesGeneratorAsync, createGeneratorByTypeAsync, createObjectGeneratorAsync, createSelectionGeneratorAsync, createTupleGeneratorAsync, createValueGeneratorAsync };
|
package/dist/index.cjs
CHANGED
|
@@ -9,6 +9,9 @@ var __webpack_modules__ = {
|
|
|
9
9
|
"./create_generator_fn" (module) {
|
|
10
10
|
module.exports = require("./create_generator_fn.cjs");
|
|
11
11
|
},
|
|
12
|
+
"./create_generator_fn_async" (module) {
|
|
13
|
+
module.exports = require("./create_generator_fn_async.cjs");
|
|
14
|
+
},
|
|
12
15
|
"./generator_fn" (module) {
|
|
13
16
|
module.exports = require("./generator_fn.cjs");
|
|
14
17
|
},
|
|
@@ -61,7 +64,7 @@ var __webpack_exports__ = {};
|
|
|
61
64
|
__webpack_require__.r(__webpack_exports__);
|
|
62
65
|
__webpack_require__.d(__webpack_exports__, {
|
|
63
66
|
StructConfig: ()=>_config__rspack_import_0,
|
|
64
|
-
StructGenerator: ()=>
|
|
67
|
+
StructGenerator: ()=>_generator_fn__rspack_import_4
|
|
65
68
|
});
|
|
66
69
|
var _config__rspack_import_0 = __webpack_require__("./config");
|
|
67
70
|
var _create_config__rspack_import_1 = __webpack_require__("./create_config");
|
|
@@ -80,14 +83,22 @@ var __webpack_exports__ = {};
|
|
|
80
83
|
"StructGenerator"
|
|
81
84
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_create_generator_fn__rspack_import_2[__rspack_import_key];
|
|
82
85
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
83
|
-
var
|
|
84
|
-
var
|
|
86
|
+
var _create_generator_fn_async__rspack_import_3 = __webpack_require__("./create_generator_fn_async");
|
|
87
|
+
var __rspack_reexport = {};
|
|
88
|
+
for(const __rspack_import_key in _create_generator_fn_async__rspack_import_3)if ([
|
|
89
|
+
"default",
|
|
90
|
+
"StructConfig",
|
|
91
|
+
"StructGenerator"
|
|
92
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_create_generator_fn_async__rspack_import_3[__rspack_import_key];
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
94
|
+
var _generator_fn__rspack_import_4 = __webpack_require__("./generator_fn");
|
|
95
|
+
var _type__rspack_import_5 = __webpack_require__("./type");
|
|
85
96
|
var __rspack_reexport = {};
|
|
86
|
-
for(const __rspack_import_key in
|
|
97
|
+
for(const __rspack_import_key in _type__rspack_import_5)if ([
|
|
87
98
|
"default",
|
|
88
99
|
"StructConfig",
|
|
89
100
|
"StructGenerator"
|
|
90
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
101
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_type__rspack_import_5[__rspack_import_key];
|
|
91
102
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
92
103
|
})();
|
|
93
104
|
exports.StructConfig = __webpack_exports__.StructConfig;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./create_config.js";
|
|
2
2
|
export * from "./create_generator_fn.js";
|
|
3
|
+
export * from "./create_generator_fn_async.js";
|
|
3
4
|
export * from "./type.js";
|
|
4
5
|
import * as __rspack_external__config_js_0f05d986 from "./config.js";
|
|
5
6
|
import * as __rspack_external__generator_fn_js_1567d0d7 from "./generator_fn.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArrayConfig, BoundedSeriesConfig, ObjectConfig, ObjectConfigWithFn, Result, SelectionConfig, TupleConfig, ValueConfig } from "./type";
|
|
2
|
+
type AllConfig = ValueConfig<unknown> | SelectionConfig<unknown> | ArrayConfig<unknown> | ObjectConfig<unknown> | ObjectConfigWithFn<unknown, unknown> | TupleConfig<readonly unknown[]> | BoundedSeriesConfig;
|
|
3
|
+
export declare const createValueGeneratorAsync: <R = unknown>(config: ValueConfig<unknown>) => (() => Promise<R>);
|
|
4
|
+
export declare const createSelectionGeneratorAsync: <T extends SelectionConfig<unknown>>(config: T) => (() => Promise<Result<T>>);
|
|
5
|
+
export declare const createObjectGeneratorAsync: <T extends ObjectConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
6
|
+
export declare const createArrayGeneratorAsync: <T extends ArrayConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
7
|
+
export declare const createTupleGeneratorAsync: <T extends TupleConfig<readonly unknown[]>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
8
|
+
export declare const createBoundedSeriesGeneratorAsync: <T extends BoundedSeriesConfig>(config: T) => (() => Promise<Result<T>>);
|
|
9
|
+
export declare const createGeneratorByTypeAsync: <T extends AllConfig>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,58 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
"./utils": {
|
|
27
|
-
"types": "./dist/types/utils/index.d.ts",
|
|
28
|
-
"require": "./dist/utils/index.cjs",
|
|
29
|
-
"import": "./dist/utils/index.js"
|
|
30
|
-
},
|
|
31
|
-
"./utils/*": {
|
|
32
|
-
"types": "./dist/types/utils/*.d.ts",
|
|
33
|
-
"require": "./dist/utils/*.cjs",
|
|
34
|
-
"import": "./dist/utils/*.js"
|
|
35
|
-
}
|
|
2
|
+
"name": "struct-fakerator",
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fake data",
|
|
7
|
+
"fakerjs",
|
|
8
|
+
"generator"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/FizzyElt/fakerator",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "FizzyElt",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.cjs",
|
|
18
|
+
"module": "dist/index.js",
|
|
19
|
+
"types": "dist/types/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/types/index.d.ts",
|
|
23
|
+
"require": "./dist/index.cjs",
|
|
24
|
+
"import": "./dist/index.js"
|
|
36
25
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
26
|
+
"./utils": {
|
|
27
|
+
"types": "./dist/types/utils/index.d.ts",
|
|
28
|
+
"require": "./dist/utils/index.cjs",
|
|
29
|
+
"import": "./dist/utils/index.js"
|
|
39
30
|
},
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"test": "vitest src"
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"@faker-js/faker": "^10.4.0",
|
|
48
|
-
"valibot": "^1.3.1"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@rslib/core": "^0.19.6",
|
|
52
|
-
"@types/node": "^25.5.2",
|
|
53
|
-
"oxfmt": "^0.44.0",
|
|
54
|
-
"oxlint": "^1.59.0",
|
|
55
|
-
"typescript": "^5.9.3",
|
|
56
|
-
"vitest": "^4.1.4"
|
|
31
|
+
"./utils/*": {
|
|
32
|
+
"types": "./dist/types/utils/*.d.ts",
|
|
33
|
+
"require": "./dist/utils/*.cjs",
|
|
34
|
+
"import": "./dist/utils/*.js"
|
|
57
35
|
}
|
|
58
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@faker-js/faker": "^10.4.0",
|
|
42
|
+
"valibot": "^1.3.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@rslib/core": "^0.19.6",
|
|
46
|
+
"@types/node": "^25.5.2",
|
|
47
|
+
"oxfmt": "^0.44.0",
|
|
48
|
+
"oxlint": "^1.59.0",
|
|
49
|
+
"typescript": "^5.9.3",
|
|
50
|
+
"vitest": "^4.1.4"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"type_check": "tsc --noEmit",
|
|
54
|
+
"build": "pnpm type_check && rslib build src",
|
|
55
|
+
"test": "vitest src"
|
|
56
|
+
}
|
|
57
|
+
}
|