Skip to content

Commit

Permalink
feat(deliveryFunctions): Allow CCA to upload delivery functions [MONE…
Browse files Browse the repository at this point in the history
…T-1336] (#1926)

* feat: support delivery fns

* fix types

* Update test/unit/create-app-definition-api-test.js

Co-authored-by: Richard Moran <richardmoran8@gmail.com>

---------

Co-authored-by: Richard Moran <richardmoran8@gmail.com>
  • Loading branch information
kdamball and RichardM99 committed Aug 22, 2023
1 parent 48fdbe1 commit 8280588
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/adapters/REST/endpoints/app-bundle.ts
Expand Up @@ -44,7 +44,7 @@ export const create: RestEndpoint<'AppBundle', 'create'> = (
params: GetAppDefinitionParams,
payload: CreateAppBundleProps
) => {
const { appUploadId, comment, actions } = payload
const { appUploadId, comment, actions, deliveryFunctions } = payload

const data = {
upload: {
Expand All @@ -56,6 +56,7 @@ export const create: RestEndpoint<'AppBundle', 'create'> = (
},
comment,
actions,
deliveryFunctions,
}

return raw.post<AppBundleProps>(http, getBaseUrl(params), data)
Expand Down
10 changes: 10 additions & 0 deletions lib/entities/app-bundle.ts
Expand Up @@ -16,6 +16,15 @@ interface ActionManifestProps {
description: string
category: string
path: string
allowNetworks?: string[]
}

interface DeliveryFunctionManifestProps {
id: string
name: string
description: string
path: string
allowNetworks?: string[]
}

export type AppBundleFile = {
Expand All @@ -28,6 +37,7 @@ export type CreateAppBundleProps = {
appUploadId: string
comment?: string
actions?: ActionManifestProps[]
deliveryFunctions?: DeliveryFunctionManifestProps[]
}

export type AppBundleProps = {
Expand Down
21 changes: 21 additions & 0 deletions test/unit/create-app-definition-api-test.js
Expand Up @@ -125,6 +125,27 @@ describe('createAppDefinitionApi', () => {
})
})

test('API call createAppBundle with delivery functions', async () => {
const { api, entitiesMock } = setup(Promise.resolve({}))
const appBundleWithDeliveryFns = {
...appBundleMock,
deliveryFunctions: [
{
id: 'myCustomId',
name: 'My Delivery function',
description: 'Delivery function uploaded with bundle',
path: 'functions/test.js',
},
],
}

entitiesMock['appBundle']['wrapAppBundle'].returns(appBundleWithDeliveryFns)

return api['createAppBundle']({ appBundleId: 'id' }).then((result) => {
expect(result).equals(appBundleWithDeliveryFns)
})
})

test('API call createAppBundle fails', async () => {
return makeEntityMethodFailingTest(setup, {
methodToTest: 'createAppBundle',
Expand Down

0 comments on commit 8280588

Please sign in to comment.