Suchjs add changelog since v1.0.0
.
- Support export in
vite
.
- Add the export of TS enum variables
AssignType
for esmodule, for theassign
method's parameter added in version3.1.0
.
- Now
:dict
and:cascader
type in nodejs environment also support thedata
config to set a data like it in browser, now you can use oneof the file data path or the 'data' config as a data entry.
:date
type add config optionnow
to allowed you to change the base date of the relative date.- Add
dynamics
config options forsuch instance
, now you can change the fields's config dynamic by other depend field's value, it help you to fake the data more exactly as you want. - Add
AssignType
for such instance'sassign
method, so you can assign a variable with different types for different use cases.
- [break change] Change the
Such
instance'sstore
from a property to a method, now you should use this new method to get the data instore
, and a new methodclearStore
is added to allow you clear the store's data.
- Add the
params
config forinstanceOptions
, it allowed you to override the mockit's$config
and$length
parameter, so you can generate the data more exactly.
-
[break change] Now config not support a regexp literal
/xxx/xx
, but support expression without whitespacesa*1+2
. -
[break change] The
config
field inoptions
of the generate methods's first parameter has renamed tokey
to make the meaning more clear.
-
Add the
clear
method forstore
object, it's necessary for reloading the such config. -
Add more types for server's config. see the
such-cli
README.
- Fix the data files such as
json
anddict
files, use a cache missing the namespace. Now it will search the file from it's own namespace also the global namespace.
-
[break change] in the template literal string you need use
//${0}
instead of/${0}
, with two slashs as a path to reference the data type appeared in template. -
[break change] now in the mockit's
generate
method, thetemplate
field inoptions
now is removed and mounted in theoptions
'smocker
field. -
Now you can reference the data type out of the template like this
/template/${0}
. -
Fix the
getPathInfo
get a wrong path when the path begin with./
in deprecated versionv3.0.0
-
Fix the
cascader
anddict
type in node is defined afterloadConf
, so you can't define a new type base on them, now fixed it. -
Fix when check the data attribute if is enable only check the
allowAttrs
of current type, that may cause an unexpected error because the current type may inherit from another type. Now fix it by also check from the inherited base type.
- Change the method
loadExtend
of such class ignore repeatedextends
items thoes have resolved by the global Such instance.
- Added the server config types for such-cli command
such serve
.
-
Fix the type use a function by
@fn(data)
lost the assigneddata
's parameter. -
Fix some date formats in
:date
type lostthis
what need reference theDate
object. -
Fix the user defined type base on template type may also cause an error because can't find the
$template
because it's not initialized.
- Change
loadData
load the config file by checking theprocess.env.SUCH_ROOT
env variable firstly. It's useful for the library's tests in node environment and insuch-cli
command line tool.
- More tests for uncover codes, remove unnecessary codes.
- Fix the
Such.as
call the extended types multiple times may lost theinstance
property because theinstance
was created ininit
method, but theinit
method only call once.
- Fix the extend
:numeric
type's wrong$size
config.
- Now
:cascader
type in browser, the top level field just need thedata
config, theroot
config is not required anymore.
- Fix wrong building deprecated version
v2.1.4
.
- Add support for nodejs load config file in
type: "module"
package.
- Add support for nodejs
esm
module.
- Add generic type for
.instance()
and.as()
methods, so if you build an instance like this.instance<string>()
,const result = instance.a()
then result is astring
type, the same for theas
method, e.g.as<string>()
.
- In nodejs environment, if you used a
.json
file as the mock template, please useasc
method instead ofas
method, so keep theas
method no need to make a special logic to treat that.asc
as from file code, also meansasync
.
- Fix the ts file import path error.
-
Add more recommend url types:
domain
、tld
、protocol
、ipv4
、ipv6
、ip
-
Add more recommend character types:
alpha
、numeric
、alphaNumeric
-
Now
types
in config file supportenum
andtemplate
types.
-
Fix
config
parser#[]
doesn't support keys with number characters, and fix the key-value like#[a=""]
got a empty string value instead of a wrong boolean value. -
Fix the
typo
named capture group nameltd
->tld
inurl
andemail
type, this is a breakchange. -
Fix the
regexp
type'snamedGroupConf
doesn't make sence because the upgrade changes of the dependecy packagereregexp
. -
Upgrade the eslint packages in project.
Hit the npm incident: report, this version is not updated correctly, update to version v2.0.2.
Fix the "process.env" is not defined in browser when import the package by "npm install".
-
Export a new method named
createNsSuch(namespace: string)
, so you can use it to get a such instance with namespace, then the store data such as defined types, alias names, assigned variables and functions are all in it's own namespace, instances with different namespaces can't access to visit each other's data unless they export the data to global by using methods such assetExportType
,setExportVar
,setExportFn
, etc. -
Now the
define
method allow define type base ontemplate
literal string and enum data. -
Allowed set keys config of
index
for enum types.
- Breaking Change: Now the
Such
object is an instance by callingcreateNsSuch
with root namespace, the methods such asdefine
,alias
,template
and other methods that used to be static methods ofSuch
now become to be methods of aSuch
instance.
-
Fix the default handle of the data attribute
$config
,$func
do not trigger correctly. -
Fix the
define
method's parameter ofbaseType
not cover the alias names.
- Add
index
config for the keys of the instance options, so you can use a enum values and get an exactly value by set it.
- Change the
checkKeys()
method also returnoneOf
,alwaysArray
config of the field.
- Add the
checkKeys()
method, so every time you called thea()
method with an instance options with keys will trigger acheck
, all the keys config will be strictly checked one by one.
- Add the
exist
to the path value in the instaceOptions keys, so you need useexist
if the field is optional and also has a count.
- Add
keys()
method for such instance, so you can get the path of keys which has anoptional
or countmin
andmax
config.
- Check the instanceOptions parameter more strictly in the method
a(instanceOptions)
, wrongmin
andmax
value will cause an error.
- Add the keys config options for the such instance's method
a(instanceOptions: IAInstanceOptions)
, so you can across the options to control thoes fields are optional appear or not, and narrow thoes array fields has a range length to a small range length or a specified length.
- Remove the
browser.ts
from the.npmignore
, now in browser you can install the package and import fromsuchjs/lib/browser
to get suchjs as a module.
- Add syntax like
<name>:data-type
in template literal, so the:ref
type can use&/${name}
to reference the named data type's value.
- Fix the
template literal
type can't use:ref
type correctly.
-
Change the
path
parser, now allow special characters such as,
,:
,/
etc. use a translate slash to escape the path name. -
The
:ref
data type's pathdata attribute
will cause an error if the path is not exists in currently.
- The
:ref
data type intemplate literal
type now can use/${0}
(format like/${number}
) to reference the inner data type's generated value.
-
Add
Such.template
static method for generatingtemplate literal
string. -
Add
ToTemplete
mockit, so you can useSuch.as(":::abc")
to call theSuch.template
method for generating.