Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010704
component-argument.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
component-argument.ts
View Options
import
{
JDDContext
,
Table
,
TableData
}
from
"../index.js"
;
import
{
List
}
from
"./list.js"
;
export
type
ExtractStructuredComponentArgumentsParsed
<
C
>
=
{
[
property
in
keyof
C
]
:
ExtractParsed
<
C
[
property
]
>
;
};
export
type
ExtractStructuredComponentArgumentsStorage
<
C
>
=
{
[
property
in
keyof
C
]
:
ExtractStorage
<
C
[
property
]
>
;
};
export
type
ExtractStructuredComponentArgumentsReceived
<
C
>
=
{
[
property
in
keyof
C
]
:
ExtractReceived
<
C
[
property
]
>
;
};
export
type
ExtractParsed
<
C
>
=
C
extends
List
<
infer
T
>
?
T
[]
:
// eslint-disable-next-line @typescript-eslint/no-explicit-any
C
extends
ComponentArgument
<
infer
T2
,
any
,
any
>
?
T2
:
C
extends
Table
<
infer
TT1
,
infer
TT2
>
?
TableData
<
TT1
,
TT2
>
:
never
;
export
type
ExtractStorage
<
C
>
=
C
extends
ComponentArgument
<
infer
_
,
infer
T
>
?
T
:
never
;
export
type
ExtractReceived
<
C
>
=
C
extends
ComponentArgument
<
infer
_
,
infer
__
,
infer
T
>
?
T
:
never
;
export
abstract
class
ComponentArgument
<
ParsedType
,
StorageType
=
ParsedType
,
ReceivedDataType
=
StorageType
>
{
public
example_values
:
ParsedType
[]
=
[];
public
parent_argument
:
ComponentArgument
<
unknown
>
|
null
=
null
;
abstract
getTypeName
()
:
string
;
abstract
getEmptyValue
()
:
ParsedType
;
abstract
countWords
(
value
:
ParsedType
)
:
number
;
abstract
getSubArgument
(
key
:
string
,
value
:
ParsedType
)
:
ComponentArgument
<
unknown
>
|
null
;
// Received - what we get on the server side when receiveing the request
// Parsed - the useful form of the value, ready for processing
// Storage - how it's represented when storing in a JSON form
// Formdata - how it's represented when it needs to be sent to the server
abstract
receivedToParsed
(
context
:
JDDContext
,
value
:
ReceivedDataType
)
:
Promise
<
ParsedType
|
ParsedType
[]
>
;
abstract
parsedToStorage
(
context
:
JDDContext
,
value
:
ParsedType
)
:
Promise
<
StorageType
>
;
abstract
storageToParsed
(
context
:
JDDContext
,
value
:
StorageType
)
:
Promise
<
ParsedType
>
;
getExampleValue
(
_context
:
JDDContext
)
:
Promise
<
ParsedType
>
|
ParsedType
{
return
this
.
example_values
[
Math
.
floor
(
this
.
example_values
.
length
*
Math
.
random
())
];
}
setExampleValues
(
values
:
ParsedType
[])
:
this
{
this
.
example_values
=
values
;
return
this
;
}
hasParent
(
type
:
string
)
{
let
parent
=
this
.
parent_argument
;
while
(
parent
)
{
if
(
parent
.
getTypeName
()
==
type
)
{
return
true
;
}
parent
=
parent
.
parent_argument
;
}
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:46 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
661301
Default Alt Text
component-argument.ts (2 KB)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment