feat(carbone): add add-template
action
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Add Template',
|
||||||
|
key: 'addTemplate',
|
||||||
|
description:
|
||||||
|
'Creates an attachment of a specified object by given parent ID.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Templete Data',
|
||||||
|
key: 'templateData',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
variables: true,
|
||||||
|
description: 'The content of your new Template in XML/HTML format.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const templateData = $.step.parameters.templateData as string;
|
||||||
|
|
||||||
|
const base64Data = Buffer.from(templateData).toString('base64');
|
||||||
|
const dataURI = `data:application/xml;base64,${base64Data}`;
|
||||||
|
|
||||||
|
const body = JSON.stringify({ template: dataURI });
|
||||||
|
|
||||||
|
const response = await $.http.post('/template', body, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
$.setActionItem({ raw: response.data });
|
||||||
|
},
|
||||||
|
});
|
3
packages/backend/src/apps/carbone/actions/index.ts
Normal file
3
packages/backend/src/apps/carbone/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import addTemplate from './add-template';
|
||||||
|
|
||||||
|
export default [addTemplate];
|
@@ -1,6 +1,7 @@
|
|||||||
import defineApp from '../../helpers/define-app';
|
import defineApp from '../../helpers/define-app';
|
||||||
import addAuthHeader from './common/add-auth-header';
|
import addAuthHeader from './common/add-auth-header';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
|
import actions from './actions';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Carbone',
|
name: 'Carbone',
|
||||||
@@ -13,4 +14,5 @@ export default defineApp({
|
|||||||
primaryColor: '6f42c1',
|
primaryColor: '6f42c1',
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
actions,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user