Skip to content

fix: FunctionTypeEnum member case #762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions src/requests/typings/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import {
} from './resources'

export enum FunctionTypeEnum {
GRAPHQL_FIELD_MAPPING = 'graphql.field.mapping',
GRAPHQL_QUERY = 'graphql.query',
APP_EVENT_FILTER = 'appevent.filter',
APP_EVENT_HANDLER = 'appevent.handler',
APP_EVENT_TRANSFORMATION = 'appevent.transformation',
APP_ACTION_CALL = 'appaction.call',
RESOURCES_SEARCH = 'resources.search',
RESOURCES_LOOKUP = 'resources.lookup',
GraphqlFieldMapping = 'graphql.field.mapping',
GraphqlQuery = 'graphql.query',
AppEventFilter = 'appevent.filter',
AppEventHandler = 'appevent.handler',
AppEventTransformation = 'appevent.transformation',
AppActionCall = 'appaction.call',
ResourcesSearch = 'resources.search',
ResourcesLookup = 'resources.lookup',
}

type GraphQLFieldTypeMappingRequest = {
type: FunctionTypeEnum.GRAPHQL_FIELD_MAPPING
type: FunctionTypeEnum.GraphqlFieldMapping
fields: { contentTypeId: string; field: Field }[]
}

Expand All @@ -47,7 +47,7 @@ export type GraphQLFieldTypeMapping = {
}

type GraphQLQueryRequest = {
type: FunctionTypeEnum.GRAPHQL_QUERY
type: FunctionTypeEnum.GraphqlQuery
query: string
isIntrospectionQuery: boolean
variables: Record<string, unknown>
Expand Down Expand Up @@ -79,9 +79,9 @@ type AppEventBase<
}
body: AppEventEntityPayload<EntityName, EntityAction>
type:
| FunctionTypeEnum.APP_EVENT_HANDLER
| FunctionTypeEnum.APP_EVENT_TRANSFORMATION
| FunctionTypeEnum.APP_EVENT_FILTER
| FunctionTypeEnum.AppEventHandler
| FunctionTypeEnum.AppEventTransformation
| FunctionTypeEnum.AppEventFilter
}

export type AppEventContentType = {
Expand Down Expand Up @@ -164,7 +164,7 @@ export type AppActionRequest<
> = {
headers: Record<string, string | number>
body: CategoryType extends 'Custom' ? CustomCategoryBody : AppActionRequestBody<CategoryType>
type: FunctionTypeEnum.APP_ACTION_CALL
type: FunctionTypeEnum.AppActionCall
}

export type AppActionResponse = void | Record<string, unknown>
Expand All @@ -187,35 +187,35 @@ type FunctionEventHandlers<
T extends AppActionCategoryType = never,
U extends AppActionRequestBody<T> = never,
> = {
[FunctionTypeEnum.GRAPHQL_FIELD_MAPPING]: {
[FunctionTypeEnum.GraphqlFieldMapping]: {
event: GraphQLFieldTypeMappingRequest
response: GraphQLFieldTypeMappingResponse
}
[FunctionTypeEnum.GRAPHQL_QUERY]: {
[FunctionTypeEnum.GraphqlQuery]: {
event: GraphQLQueryRequest
response: GraphQLQueryResponse
}
[FunctionTypeEnum.APP_ACTION_CALL]: {
[FunctionTypeEnum.AppActionCall]: {
event: AppActionRequest<T, U>
response: AppActionResponse
}
[FunctionTypeEnum.APP_EVENT_FILTER]: {
[FunctionTypeEnum.AppEventFilter]: {
event: AppEventRequest
response: AppEventFilterResponse
}
[FunctionTypeEnum.APP_EVENT_HANDLER]: {
[FunctionTypeEnum.AppEventHandler]: {
event: AppEventRequest
response: AppEventHandlerResponse
}
[FunctionTypeEnum.APP_EVENT_TRANSFORMATION]: {
[FunctionTypeEnum.AppEventTransformation]: {
event: AppEventRequest
response: AppEventTransformationResponse
}
[FunctionTypeEnum.RESOURCES_SEARCH]: {
[FunctionTypeEnum.ResourcesSearch]: {
event: ResourcesSearchRequest
response: ResourcesSearchResponse
}
[FunctionTypeEnum.RESOURCES_LOOKUP]: {
[FunctionTypeEnum.ResourcesLookup]: {
event: ResourcesLookupRequest
response: ResourcesLookupResponse
}
Expand Down
8 changes: 4 additions & 4 deletions src/requests/typings/resources.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { FunctionTypeEnum } from './function'

export const RESOURCES_SEARCH_EVENT = FunctionTypeEnum.RESOURCES_SEARCH
export const RESOURCES_LOOKUP_EVENT = FunctionTypeEnum.RESOURCES_LOOKUP
export const RESOURCES_SEARCH_EVENT = FunctionTypeEnum.ResourcesSearch
export const RESOURCES_LOOKUP_EVENT = FunctionTypeEnum.ResourcesLookup

export type ResourcesSearchRequest = {
type: FunctionTypeEnum.RESOURCES_SEARCH
type: FunctionTypeEnum.ResourcesSearch
resourceType: string
query?: string
locale?: string
Expand All @@ -25,7 +25,7 @@ type Scalar = string | number | boolean

export type ResourcesLookupRequest<L extends Record<string, Scalar[]> = Record<string, Scalar[]>> =
{
type: FunctionTypeEnum.RESOURCES_LOOKUP
type: FunctionTypeEnum.ResourcesLookup
lookupBy: L
resourceType: string
locale?: string
Expand Down