Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262207
props-parser.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
props-parser.ts
View Options
import
{
Context
}
from
"koa"
;
import
merge
from
"merge"
;
import
{
FormDataValue
}
from
"../forms/form-types.js"
;
import
type
{
BasePageProps
}
from
"./list.js"
;
export
type
EncodedProps
=
Record
<
string
,
unknown
>
;
// page props parser is only tasked with getting the raw props from *somewhere*
// and being able to put new values back to that somewhere. Parsing to numbers
// or any other exotic types is done by fields logic.
export
abstract
class
PagePropsParser
<
PropsType
>
{
abstract
decode
(
ctx
:
Context
)
:
Record
<
string
,
FormDataValue
>
;
abstract
encode
(
props
:
Record
<
string
,
FormData
>
)
:
EncodedProps
;
abstract
getHTMLInputName
(
prop_name
:
string
)
:
string
;
overwriteProp
(
ctx
:
Context
,
new_props
:
Partial
<
PropsType
>
)
:
EncodedProps
{
const
result
=
{};
merge
.
recursive
(
result
,
this
.
decode
(
ctx
),
new_props
);
return
result
;
}
}
export
class
AllQueryParams
<
PropsType
extends
BasePageProps
>
extends
PagePropsParser
<
PropsType
>
{
decode
(
ctx
:
Context
)
:
Record
<
string
,
FormDataValue
>
{
return
ctx
.
query
;
}
encode
(
props
:
PropsType
)
:
Record
<
string
,
unknown
>
{
return
props
;
}
getHTMLInputName
(
prop_name
:
string
)
:
string
{
return
prop_name
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Thu, Jan 23, 19:19 (16 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
600738
Default Alt Text
props-parser.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment