Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Schemastery Gen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
Schemastery Gen
Commits
749d9658
Commit
749d9658
authored
Feb 24, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump to schemastery 3
parent
d9106d66
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
14 deletions
+28
-14
package-lock.json
package-lock.json
+7
-7
package.json
package.json
+1
-1
src/decorators/register.ts
src/decorators/register.ts
+8
-2
tests/schema-array.spec.ts
tests/schema-array.spec.ts
+12
-4
No files found.
package-lock.json
View file @
749d9658
...
...
@@ -29,7 +29,7 @@
"typescript"
:
"^4.5.2"
},
"peerDependencies"
:
{
"schemastery"
:
"^
2.4.2
"
"schemastery"
:
"^
3.0.0
"
}
},
"node_modules/@babel/code-frame"
:
{
...
...
@@ -4545,9 +4545,9 @@
}
},
"node_modules/schemastery"
:
{
"version"
:
"
2.4.2
"
,
"resolved"
:
"https://registry.npmjs.org/schemastery/-/schemastery-
2.4.2
.tgz"
,
"integrity"
:
"sha512-0
sCJuGa7LyAtnoXEVwUKSPSTMfizA0zpK0kX7dzGPLpeLuxgJg7VVyR2KFsfHg+WlqYbUOvoGY7JSNPk5I5uHQ
=="
,
"version"
:
"
3.0.0
"
,
"resolved"
:
"https://registry.npmjs.org/schemastery/-/schemastery-
3.0.0
.tgz"
,
"integrity"
:
"sha512-0
aWxVyVoa5XMxfsFqHdyj2QZCiUgImzcsCEdseALm57JlmBktu92EvTXm1AebD21q/fcSi+M7BGclDQyfMjQzg
=="
,
"peer"
:
true
},
"node_modules/semver"
:
{
...
...
@@ -8711,9 +8711,9 @@
}
},
"schemastery"
:
{
"version"
:
"
2.4.2
"
,
"resolved"
:
"https://registry.npmjs.org/schemastery/-/schemastery-
2.4.2
.tgz"
,
"integrity"
:
"sha512-0
sCJuGa7LyAtnoXEVwUKSPSTMfizA0zpK0kX7dzGPLpeLuxgJg7VVyR2KFsfHg+WlqYbUOvoGY7JSNPk5I5uHQ
=="
,
"version"
:
"
3.0.0
"
,
"resolved"
:
"https://registry.npmjs.org/schemastery/-/schemastery-
3.0.0
.tgz"
,
"integrity"
:
"sha512-0
aWxVyVoa5XMxfsFqHdyj2QZCiUgImzcsCEdseALm57JlmBktu92EvTXm1AebD21q/fcSi+M7BGclDQyfMjQzg
=="
,
"peer"
:
true
},
"semver"
:
{
...
...
package.json
View file @
749d9658
...
...
@@ -59,6 +59,6 @@
"testEnvironment"
:
"node"
},
"peerDependencies"
:
{
"schemastery"
:
"^
2.4.2
"
"schemastery"
:
"^
3.0.0
"
}
}
src/decorators/register.ts
View file @
749d9658
...
...
@@ -14,19 +14,25 @@ function getBasePropertySchemaFromOptions(options: SchemaOptions) {
if
(
options
.
schema
)
{
return
options
.
schema
;
}
switch
(
options
.
type
as
string
)
{
// eslint-disable-next-line @typescript-eslint/ban-types
switch
(
options
.
type
as
string
|
Function
)
{
case
'
any
'
:
return
Schema
.
any
();
case
'
never
'
:
return
Schema
.
never
();
case
'
string
'
:
case
String
:
return
Schema
.
string
();
case
'
number
'
:
case
Number
:
return
Schema
.
number
();
case
'
boolean
'
:
case
Boolean
:
return
Schema
.
boolean
();
case
'
object
'
:
return
Schema
.
object
({}).
default
({});
case
Function
:
return
Schema
.
function
();
default
:
return
Schema
.
from
(
options
.
type
);
}
...
...
@@ -105,9 +111,9 @@ const schemaFields: (keyof Schema)[] = [
const
schemaFunctions
:
(
keyof
Schema
)[]
=
[
'
toJSON
'
,
'
toBSON
'
,
'
required
'
,
'
hidden
'
,
'
adaptive
'
,
'
role
'
,
'
link
'
,
'
default
'
,
...
...
tests/schema-array.spec.ts
View file @
749d9658
...
...
@@ -20,7 +20,7 @@ describe('Schema arrays', () => {
class
MyConfig
{
constructor
(
_
:
any
)
{}
@
SchemaProperty
({
type
:
Schema
.
array
(
Schema
.
string
())
})
@
SchemaProperty
({
type
:
Schema
.
array
(
Schema
.
string
())
,
default
:
[
'
dress
'
]
})
foo
:
string
[];
@
SchemaProperty
({
type
:
Number
})
...
...
@@ -32,10 +32,13 @@ describe('Schema arrays', () => {
@
SchemaProperty
()
notArray
:
string
;
@
SchemaProperty
({
type
:
Schema
.
tuple
([
Number
,
String
])
})
@
SchemaProperty
({
type
:
Schema
.
tuple
([
Schema
.
number
(),
Schema
.
string
()
])
})
myTup
:
[
number
,
string
];
@
SchemaProperty
({
type
:
Schema
.
tuple
([
Number
,
String
]),
array
:
true
})
@
SchemaProperty
({
type
:
Schema
.
tuple
([
Schema
.
number
(),
Schema
.
string
()]),
array
:
true
,
})
myTupArr
:
[
number
,
string
][];
}
...
...
@@ -51,7 +54,12 @@ describe('Schema arrays', () => {
});
it
(
'
should be instance of property
'
,
()
=>
{
const
config
=
new
MyConfig
({
myProperties
:
[{
name
:
'
foo
'
}]
});
const
config
=
new
MyConfig
({
myProperties
:
[{
name
:
'
foo
'
}],
bar
:
[
4
],
});
expect
(
config
.
myProperties
[
0
].
getName
()).
toEqual
(
'
foo
'
);
expect
(
config
.
bar
[
0
]).
toEqual
(
4
);
expect
(
config
.
foo
[
0
]).
toEqual
(
'
dress
'
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment