Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9582943
jdd.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
jdd.ts
View Options
import
{
Context
,
Field
,
ValidationResult
}
from
"../../../main.js"
;
import
Text
from
"./text.js"
;
import
JsonObject
from
"./json-object.js"
;
import
{
StructuredArray
}
from
"./structured-array.js"
;
export
type
JDDocument
=
Array
<
{
component_name
:
string
;
args
:
Record
<
string
,
unknown
>
;
}
>
;
export
default
class
JDD
extends
StructuredArray
<
{
component_name
:
Text
;
args
:
JsonObject
;
}
>
{
typeName
=
"jdd"
;
constructor
(
private
allowedComponents
:
string
[]
|
null
=
null
)
{
super
({
component_name
:
new
Text
(),
args
:
new
JsonObject
(),
});
}
async
isProperValue
(
context
:
Context
,
new_value
:
unknown
)
:
Promise
<
ValidationResult
>
{
const
names
=
(
new_value
as
JDDocument
).
map
(
(
item
)
=>
item
.
component_name
);
if
(
this
.
allowedComponents
!==
null
)
{
const
whitelist
=
this
.
allowedComponents
;
const
names_valid
=
names
.
every
((
name
)
=>
whitelist
.
includes
(
name
));
if
(
!
names_valid
)
{
return
Promise
.
resolve
(
Field
.
invalid
(
"Some of the components are not allowed here"
)
);
}
}
return
Promise
.
resolve
(
Field
.
valid
());
}
public
getAllowedComponents
()
:
string
[]
|
null
{
return
this
.
allowedComponents
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Oct 11, 08:15 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
981662
Default Alt Text
jdd.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment