Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22405640
field-hybrid.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
field-hybrid.ts
View Options
import
type
Context
from
"../context.js"
;
import
type
{
App
,
Collection
,
CollectionItem
,
ItemListResult
,
TransitionChecker
,
ValidationResult
,
}
from
"../main.js"
;
import
{
OpenApiTypes
}
from
"../schemas/open-api-types.js"
;
import
Field
from
"./field.js"
;
/*
A hybrid field is one that takes a field type as a param. All
uncustomized methods should be taken from that given field type
*/
export
default
abstract
class
HybridField
<
ParsedType
,
InputType
,
StorageType
,
InnerParsedType
,
InnerInputType
,
InnerStorageType
,
T
extends
Field
<
InnerParsedType
,
InnerInputType
,
InnerStorageType
>
,
>
extends
Field
<
ParsedType
,
InputType
,
StorageType
>
{
virtual_field
:
T
;
open_api_type
=
OpenApiTypes
.
NONE
;
async
getOpenApiSchema
(
context
:
Context
)
:
Promise
<
Record
<
string
,
unknown
>>
{
return
await
this
.
virtual_field
.
getOpenApiSchema
(
context
);
}
transitionChecker
:
TransitionChecker
<
ParsedType
>
;
constructor
(
base_field
:
T
)
{
super
();
this
.
virtual_field
=
base_field
;
this
.
open_api_type
=
base_field
.
open_api_type
;
this
.
transitionChecker
=
({
context
,
old_value
,
new_value
,
}
:
{
context
:
Context
;
old_value
:
ParsedType
|
undefined
;
new_value
:
ParsedType
;
})
=>
{
return
this
.
virtual_field
.
transitionChecker
({
context
,
old_value
:
old_value
as
InnerParsedType
,
new_value
:
new_value
as
unknown
as
InnerParsedType
,
});
};
}
setName
(
name
:
string
)
{
super
.
setName
(
name
);
this
.
virtual_field
.
setName
(
name
);
}
setCollection
(
collection
:
Collection
)
{
super
.
setCollection
(
collection
);
this
.
virtual_field
.
setCollection
(
collection
);
}
async
builtinTransitionChecker
(
context
:
Context
,
old_value
:
ParsedType
|
undefined
,
new_value
:
ParsedType
)
:
Promise
<
ValidationResult
>
{
return
await
this
.
virtual_field
.
builtinTransitionChecker
(
context
,
old_value
as
InnerParsedType
,
new_value
as
unknown
as
InnerParsedType
);
}
async
encode
(
context
:
Context
,
value
:
InputType
|
null
,
old_value
?:
InputType
)
{
return
this
.
virtual_field
.
encode
(
context
,
value
as
unknown
as
InnerInputType
,
old_value
)
as
StorageType
;
}
async
getMatchQueryValue
(
context
:
Context
,
filter
:
any
)
{
return
this
.
virtual_field
.
getMatchQueryValue
(
context
,
filter
);
}
async
getMatchQuery
(
context
:
Context
,
filter
:
any
)
{
return
this
.
virtual_field
.
getMatchQuery
(
context
,
filter
,
await
this
.
getValuePath
()
);
}
async
isProperValue
(
context
:
Context
,
new_value
:
Parameters
<
T
[
"checkValue"
]
>
[
1
],
old_value
:
Parameters
<
T
[
"checkValue"
]
>
[
2
],
new_value_blessing_token
:
symbol
|
null
,
item
:
CollectionItem
|
undefined
)
{
return
this
.
virtual_field
.
checkValue
(
context
,
new_value
,
old_value
,
new_value_blessing_token
,
item
);
}
async
getAggregationStages
(
context
:
Context
,
field_filter
:
unknown
)
{
return
this
.
virtual_field
.
getAggregationStages
(
context
,
field_filter
);
}
async
decode
(
context
:
Context
,
storage_value
:
StorageType
,
old_value
:
Parameters
<
T
[
"decode"
]
>
[
2
],
is_http_api_request
=
false
)
{
return
this
.
virtual_field
.
decode
(
context
,
storage_value
as
unknown
as
InnerStorageType
,
old_value
,
is_http_api_request
)
as
ParsedType
;
}
async
getAttachments
(
context
:
Context
,
values
:
any
[],
attachment_options
:
any
)
:
Promise
<
ItemListResult
<
any
>>
{
return
this
.
virtual_field
.
getAttachments
(
context
,
values
,
attachment_options
);
}
async
init
(
app
:
App
,
collection
:
Collection
)
{
await
super
.
init
(
app
,
collection
);
await
this
.
virtual_field
.
init
(
app
,
collection
);
}
getPostgreSqlFieldDefinitions
()
:
string
[]
{
return
this
.
virtual_field
.
getPostgreSqlFieldDefinitions
();
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 19:54 (7 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1190158
Default Alt Text
field-hybrid.ts (3 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline