Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7861481
run-action-curry.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
run-action-curry.ts
View Options
import
{
Context
,
ActionName
,
App
}
from
"../main"
;
import
{
NotFound
}
from
"../response/errors"
;
const
ActionResultCache
=
new
WeakMap
();
export
function
runActionCurry
(
app
:
App
)
{
return
async
function
runAction
(
context
:
Context
,
subject_path
:
string
[],
action_name
:
ActionName
,
params
:
any
)
{
if
(
!
action_name
)
{
throw
new
Error
(
"Action name not provided"
);
}
const
original_context
=
context
.
original_context
||
context
;
if
(
!
ActionResultCache
.
has
(
original_context
))
{
ActionResultCache
.
set
(
original_context
,
new
Map
());
}
app
.
Logger
.
debug
(
subject_path
.
toString
(),
action_name
,
params
);
const
subject
=
await
app
.
RootSubject
.
getSubject
(
subject_path
);
if
(
!
subject
)
{
throw
new
NotFound
(
"Subject not found: "
+
subject_path
.
toString
());
}
params
=
await
app
.
emitHook
(
{
when
:
"before"
,
subject_path
:
subject_path
.
join
(
"."
),
action
:
action_name
,
metadata
:
{
context
,
params
,
},
},
params
);
const
response
=
await
subject
.
performAction
(
context
,
action_name
,
params
);
return
app
.
emitHook
(
{
when
:
"after"
,
subject_path
:
subject_path
.
join
(
"."
),
action
:
action_name
,
metadata
:
{
context
,
params
,
},
},
response
);
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, Aug 13, 19:36 (4 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
876988
Default Alt Text
run-action-curry.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment